1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

rtsp/rtpdec: Set the AVStream time_base directly in rtsp when it is known

This fixes cases where the RTP time base and the sample rate of the stream
differ. Previously, the AVStream time_base was unconditionally set to
the sample rate (which initially was set to one value when parsing the
rtpmap field in the SDP, but later overridden by an a=SampleRate field).

Additionally, this makes the code actually use the stream time base set
in rtpmap for video codecs, instead of hardcoding it to always be 90 kHz.

Originally committed as revision 25908 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Martin Storsjö 2010-12-07 13:29:44 +00:00
parent bb776f3b00
commit 86b6e387cc
2 changed files with 8 additions and 7 deletions

View File

@ -393,7 +393,6 @@ RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *r
return NULL; return NULL;
} }
} else { } else {
av_set_pts_info(st, 32, 1, 90000);
switch(st->codec->codec_id) { switch(st->codec->codec_id) {
case CODEC_ID_MPEG1VIDEO: case CODEC_ID_MPEG1VIDEO:
case CODEC_ID_MPEG2VIDEO: case CODEC_ID_MPEG2VIDEO:
@ -405,16 +404,12 @@ RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *r
st->need_parsing = AVSTREAM_PARSE_FULL; st->need_parsing = AVSTREAM_PARSE_FULL;
break; break;
case CODEC_ID_ADPCM_G722: case CODEC_ID_ADPCM_G722:
av_set_pts_info(st, 32, 1, st->codec->sample_rate);
/* According to RFC 3551, the stream clock rate is 8000 /* According to RFC 3551, the stream clock rate is 8000
* even if the sample rate is 16000. */ * even if the sample rate is 16000. */
if (st->codec->sample_rate == 8000) if (st->codec->sample_rate == 8000)
st->codec->sample_rate = 16000; st->codec->sample_rate = 16000;
break; break;
default: default:
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
av_set_pts_info(st, 32, 1, st->codec->sample_rate);
}
break; break;
} }
} }

View File

@ -135,9 +135,10 @@ static void init_rtp_handler(RTPDynamicProtocolHandler *handler,
/* parse the rtpmap description: <codec_name>/<clock_rate>[/<other params>] */ /* parse the rtpmap description: <codec_name>/<clock_rate>[/<other params>] */
static int sdp_parse_rtpmap(AVFormatContext *s, static int sdp_parse_rtpmap(AVFormatContext *s,
AVCodecContext *codec, RTSPStream *rtsp_st, AVStream *st, RTSPStream *rtsp_st,
int payload_type, const char *p) int payload_type, const char *p)
{ {
AVCodecContext *codec = st->codec;
char buf[256]; char buf[256];
int i; int i;
AVCodec *c; AVCodec *c;
@ -181,6 +182,7 @@ static int sdp_parse_rtpmap(AVFormatContext *s,
codec->channels = RTSP_DEFAULT_NB_AUDIO_CHANNELS; codec->channels = RTSP_DEFAULT_NB_AUDIO_CHANNELS;
if (i > 0) { if (i > 0) {
codec->sample_rate = i; codec->sample_rate = i;
av_set_pts_info(st, 32, 1, codec->sample_rate);
get_word_sep(buf, sizeof(buf), "/", &p); get_word_sep(buf, sizeof(buf), "/", &p);
i = atoi(buf); i = atoi(buf);
if (i > 0) if (i > 0)
@ -197,6 +199,8 @@ static int sdp_parse_rtpmap(AVFormatContext *s,
break; break;
case AVMEDIA_TYPE_VIDEO: case AVMEDIA_TYPE_VIDEO:
av_log(s, AV_LOG_DEBUG, "video codec set to: %s\n", c_name); av_log(s, AV_LOG_DEBUG, "video codec set to: %s\n", c_name);
if (i > 0)
av_set_pts_info(st, 32, 1, i);
break; break;
default: default:
break; break;
@ -329,6 +333,8 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
RTPDynamicProtocolHandler *handler; RTPDynamicProtocolHandler *handler;
/* if standard payload type, we can find the codec right now */ /* if standard payload type, we can find the codec right now */
ff_rtp_get_codec_info(st->codec, rtsp_st->sdp_payload_type); ff_rtp_get_codec_info(st->codec, rtsp_st->sdp_payload_type);
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
av_set_pts_info(st, 32, 1, st->codec->sample_rate);
/* Even static payload types may need a custom depacketizer */ /* Even static payload types may need a custom depacketizer */
handler = ff_rtp_handler_find_by_id( handler = ff_rtp_handler_find_by_id(
rtsp_st->sdp_payload_type, st->codec->codec_type); rtsp_st->sdp_payload_type, st->codec->codec_type);
@ -371,7 +377,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
payload_type = atoi(buf1); payload_type = atoi(buf1);
st = s->streams[s->nb_streams - 1]; st = s->streams[s->nb_streams - 1];
rtsp_st = st->priv_data; rtsp_st = st->priv_data;
sdp_parse_rtpmap(s, st->codec, rtsp_st, payload_type, p); sdp_parse_rtpmap(s, st, rtsp_st, payload_type, p);
} else if (av_strstart(p, "fmtp:", &p) || } else if (av_strstart(p, "fmtp:", &p) ||
av_strstart(p, "framesize:", &p)) { av_strstart(p, "framesize:", &p)) {
/* NOTE: fmtp is only supported AFTER the 'a=rtpmap:xxx' tag */ /* NOTE: fmtp is only supported AFTER the 'a=rtpmap:xxx' tag */