]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_rtp_asterisk: Don't assume setting retrans props means to enable.
authorJoshua C. Colp <jcolp@sangoma.com>
Mon, 8 Jun 2020 11:27:53 +0000 (08:27 -0300)
committerFriendly Automation <jenkins2@gerrit.asterisk.org>
Thu, 11 Jun 2020 23:00:47 +0000 (18:00 -0500)
The "value" passed in when setting an RTP property determines
whether it should be enabled or disabled. The RTP send and
receive retrans props did not examine this to know if the
buffers should be enabled. They assumed they always should be.

This change makes it so that the "value" passed in is
respected.

ASTERISK-28939

Change-Id: I9244cdbdc5fd065c7f6b02cbfa572bc55c7123dc

res/res_rtp_asterisk.c

index 134eebc07c18ca9965d43752fd0028c4a29e47d0..6004a2f21298337f6a39cf488cc51e16543f0192 100644 (file)
@@ -8136,10 +8136,29 @@ static void ast_rtp_prop_set(struct ast_rtp_instance *instance, enum ast_rtp_pro
        } else if (property == AST_RTP_PROPERTY_ASYMMETRIC_CODEC) {
                rtp->asymmetric_codec = value;
        } else if (property == AST_RTP_PROPERTY_RETRANS_SEND) {
-               rtp->send_buffer = ast_data_buffer_alloc(ast_free_ptr, DEFAULT_RTP_SEND_BUFFER_SIZE);
+               if (value) {
+                       if (!rtp->send_buffer) {
+                               rtp->send_buffer = ast_data_buffer_alloc(ast_free_ptr, DEFAULT_RTP_SEND_BUFFER_SIZE);
+                       }
+               } else {
+                       if (rtp->send_buffer) {
+                               ast_data_buffer_free(rtp->send_buffer);
+                               rtp->send_buffer = NULL;
+                       }
+               }
        } else if (property == AST_RTP_PROPERTY_RETRANS_RECV) {
-               rtp->recv_buffer = ast_data_buffer_alloc(ast_free_ptr, DEFAULT_RTP_RECV_BUFFER_SIZE);
-               AST_VECTOR_INIT(&rtp->missing_seqno, 0);
+               if (value) {
+                       if (!rtp->recv_buffer) {
+                               rtp->recv_buffer = ast_data_buffer_alloc(ast_free_ptr, DEFAULT_RTP_RECV_BUFFER_SIZE);
+                               AST_VECTOR_INIT(&rtp->missing_seqno, 0);
+                       }
+               } else {
+                       if (rtp->recv_buffer) {
+                               ast_data_buffer_free(rtp->recv_buffer);
+                               rtp->recv_buffer = NULL;
+                               AST_VECTOR_FREE(&rtp->missing_seqno);
+                       }
+               }
        }
 }