]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 44971 via svnmerge from
authorKevin P. Fleming <kpfleming@digium.com>
Thu, 12 Oct 2006 19:15:25 +0000 (19:15 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Thu, 12 Oct 2006 19:15:25 +0000 (19:15 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r44971 | kpfleming | 2006-10-12 14:14:24 -0500 (Thu, 12 Oct 2006) | 2 lines

we can only send one 'a=ptime' attribute per media session, not one for each format

........

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

channels/chan_sip.c

index 5a18342fd0e60fef701b2e94333ec4422c11ec3d..71fc681461b639cd795ee84841730fb7c74a20a1 100644 (file)
@@ -1247,7 +1247,7 @@ static int find_sdp(struct sip_request *req);
 static int process_sdp(struct sip_pvt *p, struct sip_request *req);
 static void add_codec_to_sdp(const struct sip_pvt *p, int codec, int sample_rate,
                             char **m_buf, size_t *m_size, char **a_buf, size_t *a_size,
-                            int debug);
+                            int debug, int *min_packet_size);
 static void add_noncodec_to_sdp(const struct sip_pvt *p, int format, int sample_rate,
                                char **m_buf, size_t *m_size, char **a_buf, size_t *a_size,
                                int debug);
@@ -5638,7 +5638,7 @@ static int add_vidupdate(struct sip_request *req)
 /*! \brief Add codec offer to SDP offer/answer body in INVITE or 200 OK */
 static void add_codec_to_sdp(const struct sip_pvt *p, int codec, int sample_rate,
                             char **m_buf, size_t *m_size, char **a_buf, size_t *a_size,
-                            int debug)
+                            int debug, int *min_packet_size)
 {
        int rtp_code;
        struct ast_format_list fmt;
@@ -5667,9 +5667,8 @@ static void add_codec_to_sdp(const struct sip_pvt *p, int codec, int sample_rate
                ast_build_string(a_buf, a_size, "a=fmtp:%d mode=%d\r\n", rtp_code, fmt.cur_ms);
        }
 
-       if (codec != AST_FORMAT_ILBC) {
-               ast_build_string(a_buf, a_size, "a=ptime:%d\r\n", fmt.cur_ms);
-       }
+       if (fmt.cur_ms && (fmt.cur_ms < *min_packet_size))
+               *min_packet_size = fmt.cur_ms;
 }
 
 /*! \brief Get Max T.38 Transmission rate from T38 capabilities */
@@ -5863,6 +5862,8 @@ static int add_sdp(struct sip_request *resp, struct sip_pvt *p)
        int capability;
        int needvideo = FALSE;
        int debug = sip_debug_test_pvt(p);
+       int min_audio_packet_size = 0;
+       int min_video_packet_size = 0;
 
        m_video[0] = '\0';      /* Reset the video media string if it's not needed */
 
@@ -5995,11 +5996,10 @@ static int add_sdp(struct sip_request *resp, struct sip_pvt *p)
                add_codec_to_sdp(p, p->prefcodec & AST_FORMAT_AUDIO_MASK, 8000,
                                 &m_audio_next, &m_audio_left,
                                 &a_audio_next, &a_audio_left,
-                                debug);
+                                debug, &min_audio_packet_size);
                alreadysent |= p->prefcodec & AST_FORMAT_AUDIO_MASK;
        }
 
-
        /* Start by sending our preferred audio codecs */
        for (x = 0; x < 32; x++) {
                int pref_codec;
@@ -6016,7 +6016,7 @@ static int add_sdp(struct sip_request *resp, struct sip_pvt *p)
                add_codec_to_sdp(p, pref_codec, 8000,
                                 &m_audio_next, &m_audio_left,
                                 &a_audio_next, &a_audio_left,
-                                debug);
+                                debug, &min_audio_packet_size);
                alreadysent |= pref_codec;
        }
 
@@ -6032,12 +6032,12 @@ static int add_sdp(struct sip_request *resp, struct sip_pvt *p)
                        add_codec_to_sdp(p, x, 8000,
                                         &m_audio_next, &m_audio_left,
                                         &a_audio_next, &a_audio_left,
-                                        debug);
+                                        debug, &min_audio_packet_size);
                else 
                        add_codec_to_sdp(p, x, 90000,
                                         &m_video_next, &m_video_left,
                                         &a_video_next, &a_video_left,
-                                        debug);
+                                        debug, &min_video_packet_size);
        }
 
        /* Now add DTMF RFC2833 telephony-event as a codec */
@@ -6054,9 +6054,15 @@ static int add_sdp(struct sip_request *resp, struct sip_pvt *p)
        if (option_debug > 2)
                ast_log(LOG_DEBUG, "-- Done with adding codecs to SDP\n");
 
-       if(!p->owner || !ast_internal_timing_enabled(p->owner))
+       if (!p->owner || !ast_internal_timing_enabled(p->owner))
                ast_build_string(&a_audio_next, &a_audio_left, "a=silenceSupp:off - - - -\r\n");
 
+       if (min_audio_packet_size)
+               ast_build_string(&a_audio_next, &a_audio_left, "a=ptime:%d\r\n", min_audio_packet_size);
+
+       if (min_video_packet_size)
+               ast_build_string(&a_video_next, &a_video_left, "a=ptime:%d\r\n", min_video_packet_size);
+
        if ((m_audio_left < 2) || (m_video_left < 2) || (a_audio_left == 0) || (a_video_left == 0))
                ast_log(LOG_WARNING, "SIP SDP may be truncated due to undersized buffer!!\n");