Multiple revisions 372327-372328
authorRichard Mudgett <rmudgett@digium.com>
Wed, 5 Sep 2012 17:38:22 +0000 (17:38 +0000)
committerRichard Mudgett <rmudgett@digium.com>
Wed, 5 Sep 2012 17:38:22 +0000 (17:38 +0000)
........
  r372327 | rmudgett | 2012-09-05 12:33:11 -0500 (Wed, 05 Sep 2012) | 15 lines

  Fix RTP/RTCP read error message confusion.

  The RTP/RTCP read error message can report "fail: success" when the
  read failure is because of an ICE failure.

  * Changed __rtp_recvfrom() to generate a PJ ICE message when ICE fails.

  * Changed RTP/RTCP read error message to indicate an unspecified error
  when errno is zero.

  (closes issue ASTERISK-20288)
  Reported by: Joern Krebs
  Patches:
        jira_asterisk_20288_err_msg.patch (license #5621) patch uploaded by rmudgett (modified)
........
  r372328 | rmudgett | 2012-09-05 12:35:20 -0500 (Wed, 05 Sep 2012) | 1 line

  Fix coding guidelines issue with a recent commit.
........

Merged revisions 372327-372328 from http://svn.asterisk.org/svn/asterisk/branches/11

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@372329 65c4cc65-6c06-0410-ace0-fbb531ad65f3

res/res_rtp_asterisk.c

index 9f3b8b8..9a78dbd 100644 (file)
@@ -882,13 +882,21 @@ static int __rtp_recvfrom(struct ast_rtp_instance *instance, void *buf, size_t s
        if (rtp->ice) {
                pj_str_t combined = pj_str(ast_sockaddr_stringify(sa));
                pj_sockaddr address;
+               pj_status_t status;
 
                pj_thread_register_check();
 
                pj_sockaddr_parse(pj_AF_UNSPEC(), 0, &combined, &address);
 
-               if (pj_ice_sess_on_rx_pkt(rtp->ice, rtcp ? COMPONENT_RTCP : COMPONENT_RTP, rtcp ? TRANSPORT_SOCKET_RTCP : TRANSPORT_SOCKET_RTP,
-                                         buf, len, &address, pj_sockaddr_get_len(&address)) != PJ_SUCCESS) {
+               status = pj_ice_sess_on_rx_pkt(rtp->ice, rtcp ? COMPONENT_RTCP : COMPONENT_RTP,
+                       rtcp ? TRANSPORT_SOCKET_RTCP : TRANSPORT_SOCKET_RTP, buf, len, &address,
+                       pj_sockaddr_get_len(&address));
+               if (status != PJ_SUCCESS) {
+                       char buf[100];
+
+                       pj_strerror(status, buf, sizeof(buf));
+                       ast_log(LOG_WARNING, "PJ ICE Rx error status code: %d '%s'.\n",
+                               (int) status, buf);
                        return -1;
                }
                if (!rtp->passthrough) {
@@ -2482,7 +2490,8 @@ static struct ast_frame *ast_rtcp_read(struct ast_rtp_instance *instance)
                                0, &addr)) < 0) {
                ast_assert(errno != EBADF);
                if (errno != EAGAIN) {
-                       ast_log(LOG_WARNING, "RTCP Read error: %s.  Hanging up.\n", strerror(errno));
+                       ast_log(LOG_WARNING, "RTCP Read error: %s.  Hanging up.\n",
+                               (errno) ? strerror(errno) : "Unspecified");
                        return NULL;
                }
                return &ast_null_frame;
@@ -2790,8 +2799,7 @@ static int bridge_p2p_rtp_write(struct ast_rtp_instance *instance, unsigned int
        }
 
        /* 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)
-       {
+       if (ast_rtp_codecs_find_payload_code(ast_rtp_instance_get_codecs(instance1), bridged_payload) == -1) {
                ast_debug(1, "Unsupported payload type received \n");
                return -1;
        }
@@ -2876,7 +2884,8 @@ static struct ast_frame *ast_rtp_read(struct ast_rtp_instance *instance, int rtc
                                &addr)) < 0) {
                ast_assert(errno != EBADF);
                if (errno != EAGAIN) {
-                       ast_log(LOG_WARNING, "RTP Read error: %s. Hanging up.\n", strerror(errno));
+                       ast_log(LOG_WARNING, "RTP Read error: %s.  Hanging up.\n",
+                               (errno) ? strerror(errno) : "Unspecified");
                        return NULL;
                }
                return &ast_null_frame;