From 3c90cc2ef21a928a7c11cf5a4583169025cdf847 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 4 Mar 2012 21:41:59 +0100 Subject: [PATCH] lavf: deprecate av_read_packet(). The caller can achieve the same effect (i.e. getting raw unparsed/mangled packets) with av_read_frame() and AVFMT_FLAG_NOPARSE | AVFMT_FLAG_NOFILLIN --- libavformat/avformat.h | 6 ++++++ libavformat/avidec.c | 6 +++--- libavformat/internal.h | 9 +++++++++ libavformat/rtpdec_asf.c | 2 +- libavformat/utils.c | 16 ++++++++++++---- libavformat/version.h | 3 +++ 6 files changed, 34 insertions(+), 8 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index e0b3b3f8a3..4272a4f91f 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1185,7 +1185,11 @@ int av_find_best_stream(AVFormatContext *ic, AVCodec **decoder_ret, int flags); +#if FF_API_READ_PACKET /** + * @deprecated use AVFMT_FLAG_NOFILLIN | AVFMT_FLAG_NOPARSE to read raw + * unprocessed packets + * * Read a transport packet from a media file. * * This function is obsolete and should never be used. @@ -1195,7 +1199,9 @@ int av_find_best_stream(AVFormatContext *ic, * @param pkt is filled * @return 0 if OK, AVERROR_xxx on error */ +attribute_deprecated int av_read_packet(AVFormatContext *s, AVPacket *pkt); +#endif /** * Return the next frame of a stream. diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 82db45abf3..abfea2c7ee 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -782,7 +782,7 @@ static int read_gab2_sub(AVStream *st, AVPacket *pkt) { ast->sub_ctx->pb = pb; if (!avformat_open_input(&ast->sub_ctx, "", sub_demuxer, NULL)) { - av_read_packet(ast->sub_ctx, &ast->sub_pkt); + ff_read_packet(ast->sub_ctx, &ast->sub_pkt); *st->codec = *ast->sub_ctx->streams[0]->codec; ast->sub_ctx->streams[0]->codec->extradata = NULL; time_base = ast->sub_ctx->streams[0]->time_base; @@ -824,7 +824,7 @@ static AVStream *get_subtitle_pkt(AVFormatContext *s, AVStream *next_st, ast = sub_st->priv_data; *pkt = ast->sub_pkt; pkt->stream_index = sub_st->index; - if (av_read_packet(ast->sub_ctx, &ast->sub_pkt) < 0) + if (ff_read_packet(ast->sub_ctx, &ast->sub_pkt) < 0) ast->sub_pkt.data = NULL; } return sub_st; @@ -1268,7 +1268,7 @@ static void seek_subtitle(AVStream *st, AVStream *st2, int64_t timestamp) av_free_packet(&ast2->sub_pkt); if (avformat_seek_file(ast2->sub_ctx, 0, INT64_MIN, ts2, ts2, 0) >= 0 || avformat_seek_file(ast2->sub_ctx, 0, ts2, ts2, INT64_MAX, 0) >= 0) - av_read_packet(ast2->sub_ctx, &ast2->sub_pkt); + ff_read_packet(ast2->sub_ctx, &ast2->sub_pkt); } static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) diff --git a/libavformat/internal.h b/libavformat/internal.h index c30deb7732..ad300325cb 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -318,4 +318,13 @@ int ff_add_param_change(AVPacket *pkt, int32_t channels, */ int ff_framehash_write_header(AVFormatContext *s); +/** + * Read a transport packet from a media file. + * + * @param s media file handle + * @param pkt is filled + * @return 0 if OK, AVERROR_xxx on error + */ +int ff_read_packet(AVFormatContext *s, AVPacket *pkt); + #endif /* AVFORMAT_INTERNAL_H */ diff --git a/libavformat/rtpdec_asf.c b/libavformat/rtpdec_asf.c index 483b196d62..2dd367556d 100644 --- a/libavformat/rtpdec_asf.c +++ b/libavformat/rtpdec_asf.c @@ -256,7 +256,7 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf, for (;;) { int i; - res = av_read_packet(rt->asf_ctx, pkt); + res = ff_read_packet(rt->asf_ctx, pkt); rt->asf_pb_pos = avio_tell(pb); if (res != 0) break; diff --git a/libavformat/utils.c b/libavformat/utils.c index d17b5752f1..4b302a9531 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -612,7 +612,7 @@ fail: /*******************************************************/ -int av_read_packet(AVFormatContext *s, AVPacket *pkt) +int ff_read_packet(AVFormatContext *s, AVPacket *pkt) { int ret, i; AVStream *st; @@ -698,6 +698,14 @@ int av_read_packet(AVFormatContext *s, AVPacket *pkt) } } +#if FF_API_READ_PACKET +int av_read_packet(AVFormatContext *s, AVPacket *pkt) +{ + return ff_read_packet(s, pkt); +} +#endif + + /**********************************************************/ /** @@ -1156,7 +1164,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) AVPacket cur_pkt; /* read next packet */ - ret = av_read_packet(s, &cur_pkt); + ret = ff_read_packet(s, &cur_pkt); if (ret < 0) { if (ret == AVERROR(EAGAIN)) return ret; @@ -1183,7 +1191,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) cur_pkt.size); } if (s->debug & FF_FDEBUG_TS) - av_log(s, AV_LOG_DEBUG, "av_read_packet stream=%d, pts=%"PRId64", dts=%"PRId64", size=%d, duration=%d, flags=%d\n", + av_log(s, AV_LOG_DEBUG, "ff_read_packet stream=%d, pts=%"PRId64", dts=%"PRId64", size=%d, duration=%d, flags=%d\n", cur_pkt.stream_index, cur_pkt.pts, cur_pkt.dts, @@ -1956,7 +1964,7 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset) break; do { - ret = av_read_packet(ic, pkt); + ret = ff_read_packet(ic, pkt); } while(ret == AVERROR(EAGAIN)); if (ret != 0) break; diff --git a/libavformat/version.h b/libavformat/version.h index bcc8c4dca5..ac1c5473bd 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -53,5 +53,8 @@ #ifndef FF_API_APPLEHTTP_PROTO #define FF_API_APPLEHTTP_PROTO (LIBAVFORMAT_VERSION_MAJOR < 55) #endif +#ifndef FF_API_READ_PACKET +#define FF_API_READ_PACKET (LIBAVFORMAT_VERSION_MAJOR < 55) +#endif #endif /* AVFORMAT_VERSION_H */