diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-10-19 13:58:14 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-10-19 13:58:14 +0200 |
commit | 81ff0c24ef050c1877639ecc3ba6c485fde0a74e (patch) | |
tree | 862e934366547cb8723d94f7f30953cb20d549b8 /libavformat | |
parent | 93f244e3abc3d75a797535a8da890bb1f9932433 (diff) | |
parent | 1cd432e167b1a80853760c89a33606e2b5f229c2 (diff) | |
download | ffmpeg-81ff0c24ef050c1877639ecc3ba6c485fde0a74e.tar.gz |
Merge commit '1cd432e167b1a80853760c89a33606e2b5f229c2'
* commit '1cd432e167b1a80853760c89a33606e2b5f229c2':
configure: fix libcdio check
rtsp: Allow setting the reordering buffer size via an AVOption
rtsp: Vertically align a constant definition
rtp: Update the check for distinguishing between RTP and RTCP
aac: fix build with hardcoded tables
fate: dependencies for screen codec tests
riff: Move functions around to be covered by appropriate #ifdefs
Conflicts:
configure
tests/fate/screen.mak
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/riff.c | 158 | ||||
-rw-r--r-- | libavformat/rtp.h | 15 | ||||
-rw-r--r-- | libavformat/rtsp.c | 16 | ||||
-rw-r--r-- | libavformat/rtsp.h | 7 |
4 files changed, 112 insertions, 84 deletions
diff --git a/libavformat/riff.c b/libavformat/riff.c index 769a4d6ba5..4cdefb91cc 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -589,6 +589,84 @@ void ff_put_bmp_header(AVIOContext *pb, AVCodecContext *enc, const AVCodecTag *t if (!for_asf && enc->extradata_size & 1) avio_w8(pb, 0); } + +void ff_parse_specific_params(AVCodecContext *stream, int *au_rate, int *au_ssize, int *au_scale) +{ + int gcd; + int audio_frame_size; + + /* We use the known constant frame size for the codec if known, otherwise + fallback to using AVCodecContext.frame_size, which is not as reliable + for indicating packet duration */ + audio_frame_size = av_get_audio_frame_duration(stream, 0); + if (!audio_frame_size) + audio_frame_size = stream->frame_size; + + *au_ssize= stream->block_align; + if (audio_frame_size && stream->sample_rate) { + *au_scale = audio_frame_size; + *au_rate= stream->sample_rate; + }else if(stream->codec_type == AVMEDIA_TYPE_VIDEO || + stream->codec_type == AVMEDIA_TYPE_DATA || + stream->codec_type == AVMEDIA_TYPE_SUBTITLE){ + *au_scale= stream->time_base.num; + *au_rate = stream->time_base.den; + }else{ + *au_scale= stream->block_align ? stream->block_align*8 : 8; + *au_rate = stream->bit_rate ? stream->bit_rate : 8*stream->sample_rate; + } + gcd= av_gcd(*au_scale, *au_rate); + *au_scale /= gcd; + *au_rate /= gcd; +} + +void ff_riff_write_info_tag(AVIOContext *pb, const char *tag, const char *str) +{ + int len = strlen(str); + if (len > 0) { + len++; + ffio_wfourcc(pb, tag); + avio_wl32(pb, len); + avio_put_str(pb, str); + if (len & 1) + avio_w8(pb, 0); + } +} + +static int riff_has_valid_tags(AVFormatContext *s) +{ + int i; + AVDictionaryEntry *t = NULL; + + for (i = 0; *ff_riff_tags[i]; i++) { + if ((t = av_dict_get(s->metadata, ff_riff_tags[i], NULL, AV_DICT_MATCH_CASE))) + return 1; + } + + return 0; +} + +void ff_riff_write_info(AVFormatContext *s) +{ + AVIOContext *pb = s->pb; + int i; + int64_t list_pos; + AVDictionaryEntry *t = NULL; + + ff_metadata_conv(&s->metadata, ff_riff_info_conv, NULL); + + /* writing empty LIST is not nice and may cause problems */ + if (!riff_has_valid_tags(s)) + return; + + list_pos = ff_start_tag(pb, "LIST"); + ffio_wfourcc(pb, "INFO"); + for (i = 0; *ff_riff_tags[i]; i++) { + if ((t = av_dict_get(s->metadata, ff_riff_tags[i], NULL, AV_DICT_MATCH_CASE))) + ff_riff_write_info_tag(s->pb, t->key, t->value); + } + ff_end_tag(pb, list_pos); +} #endif //CONFIG_MUXERS #if CONFIG_DEMUXERS @@ -705,37 +783,6 @@ int ff_get_bmp_header(AVIOContext *pb, AVStream *st, unsigned *esize) avio_rl32(pb); /* ClrImportant */ return tag1; } -#endif // CONFIG_DEMUXERS - -void ff_parse_specific_params(AVCodecContext *stream, int *au_rate, int *au_ssize, int *au_scale) -{ - int gcd; - int audio_frame_size; - - /* We use the known constant frame size for the codec if known, otherwise - fallback to using AVCodecContext.frame_size, which is not as reliable - for indicating packet duration */ - audio_frame_size = av_get_audio_frame_duration(stream, 0); - if (!audio_frame_size) - audio_frame_size = stream->frame_size; - - *au_ssize= stream->block_align; - if (audio_frame_size && stream->sample_rate) { - *au_scale = audio_frame_size; - *au_rate= stream->sample_rate; - }else if(stream->codec_type == AVMEDIA_TYPE_VIDEO || - stream->codec_type == AVMEDIA_TYPE_DATA || - stream->codec_type == AVMEDIA_TYPE_SUBTITLE){ - *au_scale= stream->time_base.num; - *au_rate = stream->time_base.den; - }else{ - *au_scale= stream->block_align ? stream->block_align*8 : 8; - *au_rate = stream->bit_rate ? stream->bit_rate : 8*stream->sample_rate; - } - gcd= av_gcd(*au_scale, *au_rate); - *au_scale /= gcd; - *au_rate /= gcd; -} void ff_get_guid(AVIOContext *s, ff_asf_guid *g) { @@ -799,51 +846,4 @@ int ff_read_riff_info(AVFormatContext *s, int64_t size) return 0; } - -static int riff_has_valid_tags(AVFormatContext *s) -{ - int i; - AVDictionaryEntry *t = NULL; - - for (i = 0; *ff_riff_tags[i]; i++) { - if ((t = av_dict_get(s->metadata, ff_riff_tags[i], NULL, AV_DICT_MATCH_CASE))) - return 1; - } - - return 0; -} - -void ff_riff_write_info_tag(AVIOContext *pb, const char *tag, const char *str) -{ - int len = strlen(str); - if (len > 0) { - len++; - ffio_wfourcc(pb, tag); - avio_wl32(pb, len); - avio_put_str(pb, str); - if (len & 1) - avio_w8(pb, 0); - } -} - -void ff_riff_write_info(AVFormatContext *s) -{ - AVIOContext *pb = s->pb; - int i; - int64_t list_pos; - AVDictionaryEntry *t = NULL; - - ff_metadata_conv(&s->metadata, ff_riff_info_conv, NULL); - - /* writing empty LIST is not nice and may cause problems */ - if (!riff_has_valid_tags(s)) - return; - - list_pos = ff_start_tag(pb, "LIST"); - ffio_wfourcc(pb, "INFO"); - for (i = 0; *ff_riff_tags[i]; i++) { - if ((t = av_dict_get(s->metadata, ff_riff_tags[i], NULL, AV_DICT_MATCH_CASE))) - ff_riff_write_info_tag(s->pb, t->key, t->value); - } - ff_end_tag(pb, list_pos); -} +#endif // CONFIG_DEMUXERS diff --git a/libavformat/rtp.h b/libavformat/rtp.h index fa3e1fa1bd..ab2de528a0 100644 --- a/libavformat/rtp.h +++ b/libavformat/rtp.h @@ -84,13 +84,24 @@ enum AVCodecID ff_rtp_codec_id(const char *buf, enum AVMediaType codec_type); /* RTCP packet types */ enum RTCPType { + RTCP_FIR = 192, + RTCP_NACK, // 193 + RTCP_SMPTETC,// 194 + RTCP_IJ, // 195 RTCP_SR = 200, RTCP_RR, // 201 RTCP_SDES, // 202 RTCP_BYE, // 203 - RTCP_APP // 204 + RTCP_APP, // 204 + RTCP_RTPFB,// 205 + RTCP_PSFB, // 206 + RTCP_XR, // 207 + RTCP_AVB, // 208 + RTCP_RSI, // 209 + RTCP_TOKEN,// 210 }; -#define RTP_PT_IS_RTCP(x) ((x) >= RTCP_SR && (x) <= RTCP_APP) +#define RTP_PT_IS_RTCP(x) (((x) >= RTCP_FIR && (x) <= RTCP_IJ) || \ + ((x) >= RTCP_SR && (x) <= RTCP_TOKEN)) #endif /* AVFORMAT_RTP_H */ diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 80f1047c5d..0328d28989 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -75,6 +75,9 @@ { "audio", "Audio", 0, AV_OPT_TYPE_CONST, {.i64 = 1 << AVMEDIA_TYPE_AUDIO}, 0, 0, DEC, "allowed_media_types" }, \ { "data", "Data", 0, AV_OPT_TYPE_CONST, {.i64 = 1 << AVMEDIA_TYPE_DATA}, 0, 0, DEC, "allowed_media_types" } +#define RTSP_REORDERING_OPTS() \ + { "reorder_queue_size", "Number of packets to buffer for handling of reordered packets", OFFSET(reordering_queue_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, DEC } + const AVOption ff_rtsp_options[] = { { "initial_pause", "Don't start playing the stream immediately", OFFSET(initial_pause), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, DEC }, FF_RTP_FLAG_OPTS(RTSPState, rtp_muxer_flags), @@ -88,17 +91,20 @@ const AVOption ff_rtsp_options[] = { { "min_port", "Minimum local UDP port", OFFSET(rtp_port_min), AV_OPT_TYPE_INT, {.i64 = RTSP_RTP_PORT_MIN}, 0, 65535, DEC|ENC }, { "max_port", "Maximum local UDP port", OFFSET(rtp_port_max), AV_OPT_TYPE_INT, {.i64 = RTSP_RTP_PORT_MAX}, 0, 65535, DEC|ENC }, { "timeout", "Maximum timeout (in seconds) to wait for incoming connections. -1 is infinite. Implies flag listen", OFFSET(initial_timeout), AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, INT_MAX, DEC }, + RTSP_REORDERING_OPTS(), { NULL }, }; static const AVOption sdp_options[] = { RTSP_FLAG_OPTS("sdp_flags", "SDP flags"), RTSP_MEDIATYPE_OPTS("allowed_media_types", "Media types to accept from the server"), + RTSP_REORDERING_OPTS(), { NULL }, }; static const AVOption rtp_options[] = { RTSP_FLAG_OPTS("rtp_flags", "RTP flags"), + RTSP_REORDERING_OPTS(), { NULL }, }; @@ -608,6 +614,13 @@ int ff_rtsp_open_transport_ctx(AVFormatContext *s, RTSPStream *rtsp_st) { RTSPState *rt = s->priv_data; AVStream *st = NULL; + int reordering_queue_size = rt->reordering_queue_size; + if (reordering_queue_size < 0) { + if (rt->lower_transport == RTSP_LOWER_TRANSPORT_TCP || !s->max_delay) + reordering_queue_size = 0; + else + reordering_queue_size = RTP_REORDER_QUEUE_DEFAULT_SIZE; + } /* open the RTP context */ if (rtsp_st->stream_index >= 0) @@ -632,8 +645,7 @@ int ff_rtsp_open_transport_ctx(AVFormatContext *s, RTSPStream *rtsp_st) else if (CONFIG_RTPDEC) rtsp_st->transport_priv = ff_rtp_parse_open(s, st, rtsp_st->rtp_handle, rtsp_st->sdp_payload_type, - (rt->lower_transport == RTSP_LOWER_TRANSPORT_TCP || !s->max_delay) - ? 0 : RTP_REORDER_QUEUE_DEFAULT_SIZE); + reordering_queue_size); if (!rtsp_st->transport_priv) { return AVERROR(ENOMEM); diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h index e55073c430..176fef7ee2 100644 --- a/libavformat/rtsp.h +++ b/libavformat/rtsp.h @@ -385,12 +385,17 @@ typedef struct RTSPState { * Timeout to wait for incoming connections. */ int initial_timeout; + + /** + * Size of RTP packet reordering queue. + */ + int reordering_queue_size; } RTSPState; #define RTSP_FLAG_FILTER_SRC 0x1 /**< Filter incoming UDP packets - receive packets only from the right source address and port. */ -#define RTSP_FLAG_LISTEN 0x2 /**< Wait for incoming connections. */ +#define RTSP_FLAG_LISTEN 0x2 /**< Wait for incoming connections. */ /** * Describe a single stream, as identified by a single m= line block in the |