[FFmpeg-cvslog] rtp: factorize dynamic payload type fallback

Rafaël Carré git at videolan.org
Sat Sep 24 01:28:21 CEST 2011


ffmpeg | branch: master | Rafaël Carré <rafael.carre at savoirfairelinux.com> | Fri Sep 23 15:47:56 2011 -0400| [0c378ea1f76e226eff460c84634e7227e3705372] | committer: Luca Barbato

rtp: factorize  dynamic payload type fallback

Move the identical code in rtp_write_header() and
ff_sdp_write_media() inside ff_rtp_get_payload_type()

Signed-off-by: Luca Barbato <lu_zero at gentoo.org>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0c378ea1f76e226eff460c84634e7227e3705372
---

 libavformat/rtp.c    |    5 +++++
 libavformat/rtpenc.c |    3 ---
 libavformat/sdp.c    |    3 ---
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/libavformat/rtp.c b/libavformat/rtp.c
index d59b694..35edb50 100644
--- a/libavformat/rtp.c
+++ b/libavformat/rtp.c
@@ -103,6 +103,11 @@ int ff_rtp_get_payload_type(AVCodecContext *codec)
                     continue;
             payload_type = AVRtpPayloadTypes[i].pt;
         }
+
+    /* dynamic payload type */
+    if (payload_type < 0)
+        payload_type = RTP_PT_PRIVATE + (codec->codec_type == AVMEDIA_TYPE_AUDIO);
+
     return payload_type;
 }
 
diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
index ef261c3..1f5d9ba 100644
--- a/libavformat/rtpenc.c
+++ b/libavformat/rtpenc.c
@@ -93,9 +93,6 @@ static int rtp_write_header(AVFormatContext *s1)
     }
 
     s->payload_type = ff_rtp_get_payload_type(st->codec);
-    if (s->payload_type < 0)
-        s->payload_type = RTP_PT_PRIVATE + (st->codec->codec_type == AVMEDIA_TYPE_AUDIO);
-
     s->base_timestamp = av_get_random_seed();
     s->timestamp = s->base_timestamp;
     s->cur_timestamp = 0;
diff --git a/libavformat/sdp.c b/libavformat/sdp.c
index c227c7f..f27a899 100644
--- a/libavformat/sdp.c
+++ b/libavformat/sdp.c
@@ -533,9 +533,6 @@ void ff_sdp_write_media(char *buff, int size, AVCodecContext *c, const char *des
     int payload_type;
 
     payload_type = ff_rtp_get_payload_type(c);
-    if (payload_type < 0) {
-        payload_type = RTP_PT_PRIVATE + (c->codec_type == AVMEDIA_TYPE_AUDIO);
-    }
 
     switch (c->codec_type) {
         case AVMEDIA_TYPE_VIDEO   : type = "video"      ; break;



More information about the ffmpeg-cvslog mailing list