static void sub_default_handler(void *data, struct stasis_subscription *sub, struct stasis_message *message) { struct stasis_app *app = data; RAII_VAR(struct ast_json *, json, NULL, ast_json_unref); if (stasis_subscription_final_message(sub, message)) { ao2_cleanup(app); } if (stasis_message_type(message) == ast_channel_dial_type()) { call_forwarded_handler(app, message); } /* By default, send any message that has a JSON representation */ json = stasis_message_to_json(message, stasis_app_get_sanitizer()); if (!json) { return; } app_send(app, json); }
static void sub_default_handler(void *data, struct stasis_subscription *sub, struct stasis_message *message) { struct stasis_app *app = data; struct ast_json *json; /* The dial type can be converted to JSON so it will always be passed * here. */ if (stasis_message_type(message) == ast_channel_dial_type()) { call_forwarded_handler(app, message); } /* By default, send any message that has a JSON representation */ json = stasis_message_to_json(message, stasis_app_get_sanitizer()); if (!json) { return; } app_send(app, json); ast_json_unref(json); }
static void rtcp_message_handler(struct stasis_message *message) { RAII_VAR(struct ast_json *, json_payload, NULL, ast_json_unref); RAII_VAR(char *, payload, NULL, ast_json_free); struct ast_json *json_blob; struct ast_json *json_channel; struct ast_json *json_rtcp; struct hepv3_capture_info *capture_info; struct ast_json *from; struct ast_json *to; struct timeval current_time = ast_tvnow(); json_payload = stasis_message_to_json(message, NULL); if (!json_payload) { return; } json_blob = ast_json_object_get(json_payload, "blob"); if (!json_blob) { return; } json_channel = ast_json_object_get(json_payload, "channel"); if (!json_channel) { return; } json_rtcp = ast_json_object_get(json_payload, "rtcp_report"); if (!json_rtcp) { return; } from = ast_json_object_get(json_blob, "from"); to = ast_json_object_get(json_blob, "to"); if (!from || !to) { return; } payload = ast_json_dump_string(json_rtcp); if (ast_strlen_zero(payload)) { return; } capture_info = hepv3_create_capture_info(payload, strlen(payload)); if (!capture_info) { return; } ast_sockaddr_parse(&capture_info->src_addr, ast_json_string_get(from), PARSE_PORT_REQUIRE); ast_sockaddr_parse(&capture_info->dst_addr, ast_json_string_get(to), PARSE_PORT_REQUIRE); capture_info->uuid = ast_strdup(ast_json_string_get(ast_json_object_get(json_channel, "name"))); if (!capture_info->uuid) { ao2_ref(capture_info, -1); return; } capture_info->capture_time = current_time; capture_info->capture_type = HEPV3_CAPTURE_TYPE_RTCP; capture_info->zipped = 0; hepv3_send_packet(capture_info); }