aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2015-02-26 13:33:59 +0200
committerMartin Storsjö <martin@martin.st>2015-02-28 22:54:11 +0200
commitf8c01257f93ceda3e03bc4e540a51022d1e2bff2 (patch)
treeeac90e97b4a216d00501ef19b892e9cbec5ca163
parent11edeaea3293c41ecf577a330422eabba35f76a2 (diff)
downloadffmpeg-f8c01257f93ceda3e03bc4e540a51022d1e2bff2.tar.gz
rtpenc: Always do the default initialization regardless of codecs
This avoids having to jump to the defaultcase in the switch. Manually override the stream time base back to 90 kHz for the few audio codecs that don't use the sample rate as time base (mp2, mp3). Signed-off-by: Martin Storsjö <martin@martin.st>
-rw-r--r--libavformat/rtpenc.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
index ae1d3e04c6..9a68c6d698 100644
--- a/libavformat/rtpenc.c
+++ b/libavformat/rtpenc.c
@@ -176,11 +176,17 @@ static int rtp_write_header(AVFormatContext *s1)
}
}
- avpriv_set_pts_info(st, 32, 1, 90000);
+ if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+ avpriv_set_pts_info(st, 32, 1, st->codec->sample_rate);
+ } else {
+ avpriv_set_pts_info(st, 32, 1, 90000);
+ }
+ s->buf_ptr = s->buf;
switch(st->codec->codec_id) {
case AV_CODEC_ID_MP2:
case AV_CODEC_ID_MP3:
s->buf_ptr = s->buf + 4;
+ avpriv_set_pts_info(st, 32, 1, 90000);
break;
case AV_CODEC_ID_MPEG1VIDEO:
case AV_CODEC_ID_MPEG2VIDEO:
@@ -224,7 +230,7 @@ static int rtp_write_header(AVFormatContext *s1)
s->max_frames_per_packet = 15;
s->max_frames_per_packet = av_clip(s->max_frames_per_packet, 1, 15);
s->num_frames = 0;
- goto defaultcase;
+ break;
case AV_CODEC_ID_ADPCM_G722:
/* Due to a historical error, the clock rate for G722 in RTP is
* 8000, even if the sample rate is 16000. See RFC 3551. */
@@ -249,7 +255,7 @@ static int rtp_write_header(AVFormatContext *s1)
s->max_frames_per_packet = 1;
s->max_frames_per_packet = FFMIN(s->max_frames_per_packet,
s->max_payload_size / st->codec->block_align);
- goto defaultcase;
+ break;
case AV_CODEC_ID_AMR_NB:
case AV_CODEC_ID_AMR_WB:
if (!s->max_frames_per_packet)
@@ -268,18 +274,13 @@ static int rtp_write_header(AVFormatContext *s1)
goto fail;
}
s->num_frames = 0;
- goto defaultcase;
+ break;
case AV_CODEC_ID_AAC:
s->num_frames = 0;
if (!s->max_frames_per_packet)
s->max_frames_per_packet = 5;
- goto defaultcase;
+ break;
default:
-defaultcase:
- if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- avpriv_set_pts_info(st, 32, 1, st->codec->sample_rate);
- }
- s->buf_ptr = s->buf;
break;
}