]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_rtp_asterisk: enable rtcp & QOS stats on native bridge
authorTorrey Searle <torrey@voxbone.com>
Wed, 26 Jul 2017 14:17:02 +0000 (16:17 +0200)
committerTorrey Searle <tsearle@gmail.com>
Wed, 9 Aug 2017 13:29:45 +0000 (08:29 -0500)
Asterisk wasn't generating or forwarding RTCP packets when native
bridge was activated.  Also the stats weren't available via
CHANNEL(qos). Now the RTCP stats are always calculated.

ASTERISK-27158 #close

Change-Id: I46fb8f61c95e836b9d2dda6054b0cf205c16037b

res/res_rtp_asterisk.c

index 8121dc96c31ae09c403eb930dc39f34177cbd10d..fe1d1e392afaa5aac62f70602970cbe341ec61ff 100644 (file)
@@ -4853,9 +4853,6 @@ static int bridge_p2p_rtp_write(struct ast_rtp_instance *instance,
                return -1;
        }
 
-       rtp->rxcount++;
-       rtp->rxoctetcount += (len - hdrlen);
-
        /* If the payload coming in is not one of the negotiated ones then send it to the core, this will cause formats to change and the bridge to break */
        if (ast_rtp_codecs_find_payload_code(ast_rtp_instance_get_codecs(instance1), bridged_payload) == -1) {
                ast_debug(1, "Unsupported payload type received \n");
@@ -5091,13 +5088,6 @@ static struct ast_frame *ast_rtp_read(struct ast_rtp_instance *instance, int rtc
                }
        }
 
-       /* If we are directly bridged to another instance send the audio directly out */
-       instance1 = ast_rtp_instance_get_bridged(instance);
-       if (instance1
-               && !bridge_p2p_rtp_write(instance, instance1, rtpheader, res, hdrlen)) {
-               return &ast_null_frame;
-       }
-
        /* If the version is not what we expected by this point then just drop the packet */
        if (version != 2) {
                return &ast_null_frame;
@@ -5202,6 +5192,28 @@ static struct ast_frame *ast_rtp_read(struct ast_rtp_instance *instance, int rtc
                rtp->themssrc = ntohl(rtpheader[2]); /* Record their SSRC to put in future RR */
        }
 
+
+       /* If we are directly bridged to another instance send the audio directly out,
+        * but only after updating core information about the received traffic so that
+        * outgoing RTCP reflects it.
+        */
+       instance1 = ast_rtp_instance_get_bridged(instance);
+       if (instance1
+               && !bridge_p2p_rtp_write(instance, instance1, rtpheader, res, hdrlen)) {
+               struct timeval rxtime;
+               struct ast_frame *f;
+
+               /* Update statistics for jitter so they are correct in RTCP */
+               calc_rxstamp(&rxtime, rtp, timestamp, mark);
+
+               /* When doing P2P we don't need to raise any frames about SSRC change to the core */
+               while ((f = AST_LIST_REMOVE_HEAD(&frames, frame_list)) != NULL) {
+                       ast_frfree(f);
+               }
+
+               return &ast_null_frame;
+       }
+
        if (rtp_debug_test_addr(&addr)) {
                ast_verbose("Got  RTP packet from    %s (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6d)\n",
                            ast_sockaddr_stringify(&addr),