Merge "bridge_softmix.c: Don't match dead streams."
authorJenkins2 <jenkins2@gerrit.asterisk.org>
Tue, 19 Dec 2017 17:12:22 +0000 (11:12 -0600)
committerGerrit Code Review <gerrit2@gerrit.digium.api>
Tue, 19 Dec 2017 17:12:22 +0000 (11:12 -0600)
apps/app_voicemail.c
bridges/bridge_softmix.c
main/cel.c
main/rtp_engine.c

index c155186..af2174b 100644 (file)
@@ -5390,6 +5390,7 @@ plain_message:
 static int add_email_attachment(FILE *p, struct ast_vm_user *vmu, char *format, char *attach, char *greeting_attachment, char *mailbox, char *bound, char *filename, int last, int msgnum)
 {
        char fname[PATH_MAX] = "";
+       char sox_gain_tmpdir[PATH_MAX];
        char *file_to_delete = NULL, *dir_to_delete = NULL;
        int res;
 
@@ -5399,7 +5400,6 @@ static int add_email_attachment(FILE *p, struct ast_vm_user *vmu, char *format,
        /* This 'while' loop will only execute once. We use it so that we can 'break' */
        while (vmu->volgain < -.001 || vmu->volgain > .001) {
                char tmpdir[PATH_MAX];
-               char sox_gain_tmpdir[PATH_MAX];
 
                create_dirpath(tmpdir, sizeof(tmpdir), vmu->context, vmu->mailbox, "tmp");
 
@@ -13167,6 +13167,7 @@ static void mwi_sub_event_cb(struct stasis_subscription_change *change)
        }
 
        if (separate_mailbox(ast_strdupa(stasis_topic_name(change->topic)), &mailbox, &context)) {
+               ast_free(mwist);
                return;
        }
 
index c8dd8ea..83b1a83 100644 (file)
@@ -668,6 +668,7 @@ static int softmix_bridge_join(struct ast_bridge *bridge, struct ast_bridge_chan
                                ast_log(LOG_ERROR, "Bridge %s: Failed to join channel %s. "
                                                "Could not allocate enough memory.\n", bridge->uniqueid,
                                                ast_channel_name(bridge_channel->chan));
+                               ast_free(sc);
                                return -1;
                        }
                }
@@ -693,10 +694,11 @@ static int softmix_bridge_join(struct ast_bridge *bridge, struct ast_bridge_chan
        return 0;
 }
 
-static void remove_destination_streams(struct ast_stream_topology *topology,
+static int remove_destination_streams(struct ast_stream_topology *topology,
        const char *channel_name)
 {
        int i;
+       int stream_removed = 0;
 
        for (i = 0; i < ast_stream_topology_get_count(topology); ++i) {
                struct ast_stream *stream;
@@ -705,8 +707,10 @@ static void remove_destination_streams(struct ast_stream_topology *topology,
 
                if (is_video_dest(stream, channel_name, NULL)) {
                        ast_stream_set_state(stream, AST_STREAM_STATE_REMOVED);
+                       stream_removed = 1;
                }
        }
+       return stream_removed;
 }
 
 static int sfu_topologies_on_leave(struct ast_bridge_channel *leaver, struct ast_bridge_channels_list *participants)
@@ -716,13 +720,16 @@ static int sfu_topologies_on_leave(struct ast_bridge_channel *leaver, struct ast
 
        AST_LIST_TRAVERSE(participants, participant, entry) {
                sc = participant->tech_pvt;
-               remove_destination_streams(sc->topology, ast_channel_name(leaver->chan));
+               if (!remove_destination_streams(sc->topology, ast_channel_name(leaver->chan))) {
+                       continue;
+               }
                ast_channel_request_stream_topology_change(participant->chan, sc->topology, NULL);
        }
 
        sc = leaver->tech_pvt;
-       remove_destination_streams(sc->topology, "");
-       ast_channel_request_stream_topology_change(leaver->chan, sc->topology, NULL);
+       if (remove_destination_streams(sc->topology, "")) {
+               ast_channel_request_stream_topology_change(leaver->chan, sc->topology, NULL);
+       }
 
        return 0;
 }
@@ -1302,6 +1309,8 @@ static int softmix_mixing_array_grow(struct softmix_mixing_array *mixing_array,
                ast_log(LOG_NOTICE, "Failed to re-allocate softmix mixing structure.\n");
                return -1;
        }
+       mixing_array->buffers = tmp;
+
        if (binaural_active) {
                struct convolve_channel_pair **tmp2;
                if (!(tmp2 = ast_realloc(mixing_array->chan_pairs,
@@ -1311,7 +1320,6 @@ static int softmix_mixing_array_grow(struct softmix_mixing_array *mixing_array,
                }
                mixing_array->chan_pairs = tmp2;
        }
-       mixing_array->buffers = tmp;
        return 0;
 }
 
index cec0a85..24a35be 100644 (file)
@@ -1835,9 +1835,9 @@ void ast_cel_publish_event(struct ast_channel *chan,
        struct ast_json *cel_blob;
        struct stasis_message *message;
 
-       cel_blob = ast_json_pack("{s: i, s: O}",
+       cel_blob = ast_json_pack("{s: i, s: o}",
                "event_type", event_type,
-               "event_details", blob);
+               "event_details", ast_json_ref(blob));
 
        message = ast_channel_blob_create_from_cache(ast_channel_uniqueid(chan), cel_generic_type(), cel_blob);
        if (message) {
index 68c53e7..a2c0770 100644 (file)
@@ -3092,10 +3092,10 @@ static struct ast_json *rtcp_report_to_json(struct stasis_message *msg,
        const struct stasis_message_sanitizer *sanitize)
 {
        struct rtcp_message_payload *payload = stasis_message_data(msg);
-       RAII_VAR(struct ast_json *, json_rtcp_report, NULL, ast_json_unref);
-       RAII_VAR(struct ast_json *, json_rtcp_report_blocks, NULL, ast_json_unref);
-       RAII_VAR(struct ast_json *, json_rtcp_sender_info, NULL, ast_json_unref);
-       RAII_VAR(struct ast_json *, json_channel, NULL, ast_json_unref);
+       struct ast_json *json_rtcp_report = NULL;
+       struct ast_json *json_rtcp_report_blocks;
+       struct ast_json *json_rtcp_sender_info = NULL;
+       struct ast_json *json_channel = NULL;
        int i;
 
        json_rtcp_report_blocks = ast_json_array_create();
@@ -3106,20 +3106,19 @@ static struct ast_json *rtcp_report_to_json(struct stasis_message *msg,
        for (i = 0; i < payload->report->reception_report_count && payload->report->report_block[i]; i++) {
                struct ast_json *json_report_block;
                char str_lsr[32];
+
                snprintf(str_lsr, sizeof(str_lsr), "%u", payload->report->report_block[i]->lsr);
                json_report_block = ast_json_pack("{s: i, s: i, s: i, s: i, s: i, s: s, s: i}",
-                               "source_ssrc", payload->report->report_block[i]->source_ssrc,
-                               "fraction_lost", payload->report->report_block[i]->lost_count.fraction,
-                               "packets_lost", payload->report->report_block[i]->lost_count.packets,
-                               "highest_seq_no", payload->report->report_block[i]->highest_seq_no,
-                               "ia_jitter", payload->report->report_block[i]->ia_jitter,
-                               "lsr", str_lsr,
-                               "dlsr", payload->report->report_block[i]->dlsr);
-               if (!json_report_block) {
-                       return NULL;
-               }
-
-               if (ast_json_array_append(json_rtcp_report_blocks, json_report_block)) {
+                       "source_ssrc", payload->report->report_block[i]->source_ssrc,
+                       "fraction_lost", payload->report->report_block[i]->lost_count.fraction,
+                       "packets_lost", payload->report->report_block[i]->lost_count.packets,
+                       "highest_seq_no", payload->report->report_block[i]->highest_seq_no,
+                       "ia_jitter", payload->report->report_block[i]->ia_jitter,
+                       "lsr", str_lsr,
+                       "dlsr", payload->report->report_block[i]->dlsr);
+               if (!json_report_block
+                       || ast_json_array_append(json_rtcp_report_blocks, json_report_block)) {
+                       ast_json_unref(json_rtcp_report_blocks);
                        return NULL;
                }
        }
@@ -3127,25 +3126,27 @@ static struct ast_json *rtcp_report_to_json(struct stasis_message *msg,
        if (payload->report->type == AST_RTP_RTCP_SR) {
                char sec[32];
                char usec[32];
+
                snprintf(sec, sizeof(sec), "%lu", (unsigned long)payload->report->sender_information.ntp_timestamp.tv_sec);
                snprintf(usec, sizeof(usec), "%lu", (unsigned long)payload->report->sender_information.ntp_timestamp.tv_usec);
                json_rtcp_sender_info = ast_json_pack("{s: s, s: s, s: i, s: i, s: i}",
-                               "ntp_timestamp_sec", sec,
-                               "ntp_timestamp_usec", usec,
-                               "rtp_timestamp", payload->report->sender_information.rtp_timestamp,
-                               "packets", payload->report->sender_information.packet_count,
-                               "octets", payload->report->sender_information.octet_count);
+                       "ntp_timestamp_sec", sec,
+                       "ntp_timestamp_usec", usec,
+                       "rtp_timestamp", payload->report->sender_information.rtp_timestamp,
+                       "packets", payload->report->sender_information.packet_count,
+                       "octets", payload->report->sender_information.octet_count);
                if (!json_rtcp_sender_info) {
+                       ast_json_unref(json_rtcp_report_blocks);
                        return NULL;
                }
        }
 
        json_rtcp_report = ast_json_pack("{s: i, s: i, s: i, s: o, s: o}",
-                       "ssrc", payload->report->ssrc,
-                       "type", payload->report->type,
-                       "report_count", payload->report->reception_report_count,
-                       "sender_information", json_rtcp_sender_info ? ast_json_ref(json_rtcp_sender_info) : ast_json_ref(ast_json_null()),
-                       "report_blocks", ast_json_ref(json_rtcp_report_blocks));
+               "ssrc", payload->report->ssrc,
+               "type", payload->report->type,
+               "report_count", payload->report->reception_report_count,
+               "sender_information", json_rtcp_sender_info ?: ast_json_null(),
+               "report_blocks", json_rtcp_report_blocks);
        if (!json_rtcp_report) {
                return NULL;
        }
@@ -3153,14 +3154,15 @@ static struct ast_json *rtcp_report_to_json(struct stasis_message *msg,
        if (payload->snapshot) {
                json_channel = ast_channel_snapshot_to_json(payload->snapshot, sanitize);
                if (!json_channel) {
+                       ast_json_unref(json_rtcp_report);
                        return NULL;
                }
        }
 
        return ast_json_pack("{s: o, s: o, s: o}",
-               "channel", payload->snapshot ? ast_json_ref(json_channel) : ast_json_ref(ast_json_null()),
-               "rtcp_report", ast_json_ref(json_rtcp_report),
-               "blob", ast_json_deep_copy(payload->blob));
+               "channel", payload->snapshot ? json_channel : ast_json_null(),
+               "rtcp_report", json_rtcp_report,
+               "blob", ast_json_deep_copy(payload->blob) ?: ast_json_null());
 }
 
 static void rtp_rtcp_report_dtor(void *obj)