[FFmpeg-devel] [PATCH 2/2] avformat: deprecate getters and setters for AVFormatContext and AVStream fields
The fields can be accessed directly, so these are not needed anymore. Signed-off-by: James Almer --- libavformat/avformat.h | 30 +- libavformat/utils.c| 4 libavformat/version.h | 3 +++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 7594277f06..b2db234041 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1213,11 +1213,22 @@ typedef struct AVStream { AVStreamInternal *internal; } AVStream; +#if FF_API_FORMAT_GET_SET +/** + * Accessors for some AVStream fields. These used to be provided for ABI + * compatibility, and do not need to be used anymore. + */ +attribute_deprecated AVRational av_stream_get_r_frame_rate(const AVStream *s); +attribute_deprecated void av_stream_set_r_frame_rate(AVStream *s, AVRational r); -struct AVCodecParserContext *av_stream_get_parser(const AVStream *s); +attribute_deprecated char* av_stream_get_recommended_encoder_configuration(const AVStream *s); +attribute_deprecated void av_stream_set_recommended_encoder_configuration(AVStream *s, char *configuration); +#endif + +struct AVCodecParserContext *av_stream_get_parser(const AVStream *s); /** * Returns the pts of the last muxed packet + its duration @@ -1889,29 +1900,46 @@ typedef struct AVFormatContext { int max_streams; } AVFormatContext; +#if FF_API_FORMAT_GET_SET /** * Accessors for some AVFormatContext fields. These used to be provided for ABI * compatibility, and do not need to be used anymore. */ +attribute_deprecated int av_format_get_probe_score(const AVFormatContext *s); +attribute_deprecated AVCodec * av_format_get_video_codec(const AVFormatContext *s); +attribute_deprecated void av_format_set_video_codec(AVFormatContext *s, AVCodec *c); +attribute_deprecated AVCodec * av_format_get_audio_codec(const AVFormatContext *s); +attribute_deprecated void av_format_set_audio_codec(AVFormatContext *s, AVCodec *c); +attribute_deprecated AVCodec * av_format_get_subtitle_codec(const AVFormatContext *s); +attribute_deprecated void av_format_set_subtitle_codec(AVFormatContext *s, AVCodec *c); +attribute_deprecated AVCodec * av_format_get_data_codec(const AVFormatContext *s); +attribute_deprecated void av_format_set_data_codec(AVFormatContext *s, AVCodec *c); +attribute_deprecated int av_format_get_metadata_header_padding(const AVFormatContext *s); +attribute_deprecated void av_format_set_metadata_header_padding(AVFormatContext *s, int c); +attribute_deprecated void *av_format_get_opaque(const AVFormatContext *s); +attribute_deprecated void av_format_set_opaque(AVFormatContext *s, void *opaque); +attribute_deprecated av_format_control_message av_format_get_control_message_cb(const AVFormatContext *s); +attribute_deprecated void av_format_set_control_message_cb(AVFormatContext *s, av_format_control_message callback); #if FF_API_OLD_OPEN_CALLBACKS attribute_deprecated AVOpenCallback av_format_get_open_cb(const AVFormatContext *s); attribute_deprecated void av_format_set_open_cb(AVFormatContext *s, AVOpenCallback callback); #endif +#endif /** * This function will cause global side data to be injected in the next packet diff --git a/libavformat/utils.c b/libavformat/utils.c index 6dbc48d54d..8fd7b82c67 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -104,6 +104,7 @@ static int64_t wrap_timestamp(const AVStream *st, int64_t timestamp) return timestamp; } +#if FF_API_FORMAT_GET_SET MAKE_ACCESSORS(AVStream, stream, AVRational, r_frame_rate) MAKE_ACCESSORS(AVStream, stream, char *, recommended_encoder_configuration) MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, video_codec) @@ -118,6 +119,7 @@ FF_DISABLE_DEPRECATION_WARNINGS MAKE_ACCESSORS(AVFormatContext, format, AVOpenCallback, open_cb) FF_ENABLE_DEPRECATION_WARNINGS #endif +#endif int64_t av_stream_get_end_pts(const AVStream *st) { @@ -215,10 +217,12 @@ static const AVCodec *find_probe_decoder(AVFormatContext *s, const AVStream *st, return codec; } +#if FF_API_FORMAT_GET_SET int av_format_get_probe_score(const AVFormatContext *s) { return s->probe_score; } +#endif /* an arbitrarily chosen "sane" max packet size -- 50M */ #define SANE_CHUNK_SIZE (5000) diff --git a/libavformat/version.h b/libavformat/version.h index 0feb788c36..8765b59435 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -79,6 +79,9 @@ #ifndef FF_API_OLD_ROTATE_API #define FF_API_OLD_ROTATE_API (LIBAVFORMAT_VERSION_MAJOR < 59) #endif +#ifndef FF_API_FORMAT_GET_SET +#define FF_API_FORMAT_GET_SET (LIBAVFORMAT_VERSION_MAJOR < 59) +#endif #ifndef FF_API_R_FRAME_RATE -- 2.14.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/2] avformat: deprecate getters and setters for AVFormatContext and AVStream fields
On 10/23/17, James Almer wrote: > The fields can be accessed directly, so these are not needed anymore. > > Signed-off-by: James Almer > --- > libavformat/avformat.h | 30 +- > libavformat/utils.c| 4 > libavformat/version.h | 3 +++ > 3 files changed, 36 insertions(+), 1 deletion(-) > > diff --git a/libavformat/avformat.h b/libavformat/avformat.h > index 7594277f06..b2db234041 100644 > --- a/libavformat/avformat.h > +++ b/libavformat/avformat.h > @@ -1213,11 +1213,22 @@ typedef struct AVStream { > AVStreamInternal *internal; > } AVStream; > > +#if FF_API_FORMAT_GET_SET > +/** > + * Accessors for some AVStream fields. These used to be provided for ABI > + * compatibility, and do not need to be used anymore. > + */ > +attribute_deprecated > AVRational av_stream_get_r_frame_rate(const AVStream *s); > +attribute_deprecated > void av_stream_set_r_frame_rate(AVStream *s, AVRational r); > -struct AVCodecParserContext *av_stream_get_parser(const AVStream *s); > +attribute_deprecated > char* av_stream_get_recommended_encoder_configuration(const AVStream *s); > +attribute_deprecated > void av_stream_set_recommended_encoder_configuration(AVStream *s, char > *configuration); > +#endif > + > +struct AVCodecParserContext *av_stream_get_parser(const AVStream *s); > > /** > * Returns the pts of the last muxed packet + its duration > @@ -1889,29 +1900,46 @@ typedef struct AVFormatContext { > int max_streams; > } AVFormatContext; > > +#if FF_API_FORMAT_GET_SET > /** > * Accessors for some AVFormatContext fields. These used to be provided for > ABI > * compatibility, and do not need to be used anymore. > */ > +attribute_deprecated > int av_format_get_probe_score(const AVFormatContext *s); > +attribute_deprecated > AVCodec * av_format_get_video_codec(const AVFormatContext *s); > +attribute_deprecated > void av_format_set_video_codec(AVFormatContext *s, AVCodec *c); > +attribute_deprecated > AVCodec * av_format_get_audio_codec(const AVFormatContext *s); > +attribute_deprecated > void av_format_set_audio_codec(AVFormatContext *s, AVCodec *c); > +attribute_deprecated > AVCodec * av_format_get_subtitle_codec(const AVFormatContext *s); > +attribute_deprecated > void av_format_set_subtitle_codec(AVFormatContext *s, AVCodec *c); > +attribute_deprecated > AVCodec * av_format_get_data_codec(const AVFormatContext *s); > +attribute_deprecated > void av_format_set_data_codec(AVFormatContext *s, AVCodec *c); > +attribute_deprecated > int av_format_get_metadata_header_padding(const AVFormatContext *s); > +attribute_deprecated > void av_format_set_metadata_header_padding(AVFormatContext *s, int c); > +attribute_deprecated > void *av_format_get_opaque(const AVFormatContext *s); > +attribute_deprecated > void av_format_set_opaque(AVFormatContext *s, void *opaque); > +attribute_deprecated > av_format_control_message av_format_get_control_message_cb(const > AVFormatContext *s); > +attribute_deprecated > void av_format_set_control_message_cb(AVFormatContext *s, > av_format_control_message callback); > #if FF_API_OLD_OPEN_CALLBACKS > attribute_deprecated AVOpenCallback av_format_get_open_cb(const > AVFormatContext *s); > attribute_deprecated void av_format_set_open_cb(AVFormatContext *s, > AVOpenCallback callback); > #endif > +#endif > > /** > * This function will cause global side data to be injected in the next > packet > diff --git a/libavformat/utils.c b/libavformat/utils.c > index 6dbc48d54d..8fd7b82c67 100644 > --- a/libavformat/utils.c > +++ b/libavformat/utils.c > @@ -104,6 +104,7 @@ static int64_t wrap_timestamp(const AVStream *st, > int64_t timestamp) > return timestamp; > } > > +#if FF_API_FORMAT_GET_SET > MAKE_ACCESSORS(AVStream, stream, AVRational, r_frame_rate) > MAKE_ACCESSORS(AVStream, stream, char *, recommended_encoder_configuration) > MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, video_codec) > @@ -118,6 +119,7 @@ FF_DISABLE_DEPRECATION_WARNINGS > MAKE_ACCESSORS(AVFormatContext, format, AVOpenCallback, open_cb) > FF_ENABLE_DEPRECATION_WARNINGS > #endif > +#endif > > int64_t av_stream_get_end_pts(const AVStream *st) > { > @@ -215,10 +217,12 @@ static const AVCodec > *find_probe_decoder(AVFormatContext *s, const AVStream *st, > return codec; > } > > +#if FF_API_FORMAT_GET_SET > int av_format_get_probe_score(const AVFormatContext *s) > { > return s->probe_score; > } > +#endif > > /* an arbitrarily chosen "sane" max packet size -- 50M */ > #define SANE_CHUNK_SIZE (5000) > diff --git a/libavformat/version.h b/libavformat/version.h > index 0feb788c36..8765b59435 100644 > --- a/libavformat/version.h > +++ b/libavformat/version.h > @@ -79,6 +79,9 @@ > #ifndef FF_API_OLD_ROTATE_API > #define FF_API_OLD_ROTATE_API (LIBAVFORMAT_VERSION_MAJOR < 59) > #endif > +#ifndef FF_API_FORMAT_GET_SET > +#define FF_API_FORMAT_GET_SET (LIBAVFORMAT_VE