Commit 0694d870 authored by Josh de Kock's avatar Josh de Kock

lavf: add new API for iterating muxers and demuxers

parent 598d5f85
...@@ -143,7 +143,8 @@ distclean:: clean ...@@ -143,7 +143,8 @@ distclean:: clean
ffbuild/.config ffbuild/config.* libavutil/avconfig.h \ ffbuild/.config ffbuild/config.* libavutil/avconfig.h \
version.h libavutil/ffversion.h libavcodec/codec_names.h \ version.h libavutil/ffversion.h libavcodec/codec_names.h \
libavcodec/bsf_list.c libavformat/protocol_list.c \ libavcodec/bsf_list.c libavformat/protocol_list.c \
libavcodec/codec_list.c libavcodec/parser_list.c libavcodec/codec_list.c libavcodec/parser_list.c \
libavformat/muxer_list.c libavformat/demuxer_list.c
ifeq ($(SRC_LINK),src) ifeq ($(SRC_LINK),src)
$(RM) src $(RM) src
endif endif
......
...@@ -3525,8 +3525,6 @@ find_things(){ ...@@ -3525,8 +3525,6 @@ find_things(){
sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file" sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
} }
MUXER_LIST=$(find_things muxer _MUX libavformat/allformats.c)
DEMUXER_LIST=$(find_things demuxer DEMUX libavformat/allformats.c)
OUTDEV_LIST=$(find_things outdev OUTDEV libavdevice/alldevices.c) OUTDEV_LIST=$(find_things outdev OUTDEV libavdevice/alldevices.c)
INDEV_LIST=$(find_things indev _IN libavdevice/alldevices.c) INDEV_LIST=$(find_things indev _IN libavdevice/alldevices.c)
FILTER_LIST=$(find_things filter FILTER libavfilter/allfilters.c) FILTER_LIST=$(find_things filter FILTER libavfilter/allfilters.c)
...@@ -3538,6 +3536,8 @@ find_things_extern(){ ...@@ -3538,6 +3536,8 @@ find_things_extern(){
sed -n "s/^[^#]*extern.*$pattern *ff_\([^ ]*\)_$thing;/\1_$thing/p" "$file" sed -n "s/^[^#]*extern.*$pattern *ff_\([^ ]*\)_$thing;/\1_$thing/p" "$file"
} }
MUXER_LIST=$(find_things_extern muxer AVOutputFormat libavformat/allformats.c)
DEMUXER_LIST=$(find_things_extern demuxer AVInputFormat libavformat/allformats.c)
ENCODER_LIST=$(find_things_extern encoder AVCodec libavcodec/allcodecs.c) ENCODER_LIST=$(find_things_extern encoder AVCodec libavcodec/allcodecs.c)
DECODER_LIST=$(find_things_extern decoder AVCodec libavcodec/allcodecs.c) DECODER_LIST=$(find_things_extern decoder AVCodec libavcodec/allcodecs.c)
CODEC_LIST=" CODEC_LIST="
...@@ -7036,6 +7036,8 @@ print_enabled_components(){ ...@@ -7036,6 +7036,8 @@ print_enabled_components(){
print_enabled_components libavcodec/codec_list.c AVCodec codec_list $CODEC_LIST print_enabled_components libavcodec/codec_list.c AVCodec codec_list $CODEC_LIST
print_enabled_components libavcodec/parser_list.c AVCodecParser parser_list $PARSER_LIST print_enabled_components libavcodec/parser_list.c AVCodecParser parser_list $PARSER_LIST
print_enabled_components libavcodec/bsf_list.c AVBitStreamFilter bitstream_filters $BSF_LIST print_enabled_components libavcodec/bsf_list.c AVBitStreamFilter bitstream_filters $BSF_LIST
print_enabled_components libavformat/demuxer_list.c AVInputFormat demuxer_list $DEMUXER_LIST
print_enabled_components libavformat/muxer_list.c AVOutputFormat muxer_list $MUXER_LIST
print_enabled_components libavformat/protocol_list.c URLProtocol url_protocols $PROTOCOL_LIST print_enabled_components libavformat/protocol_list.c URLProtocol url_protocols $PROTOCOL_LIST
# Settings for pkg-config files # Settings for pkg-config files
......
...@@ -15,7 +15,12 @@ libavutil: 2017-10-21 ...@@ -15,7 +15,12 @@ libavutil: 2017-10-21
API changes, most recent first: API changes, most recent first:
2018-01-xx - xxxxxxx - lavc 58.9.100 - avcodec.h 2018-xx-xx - xxxxxxx - lavf 58.9.100 - avformat.h
Deprecate use of av_register_input_format(), av_register_output_format(),
avformat_register_all(), av_iformat_next(), av_oformat_next().
Add av_demuxer_iterate(), and av_muxer_iterate().
2018-xx-xx - xxxxxxx - lavc 58.9.100 - avcodec.h
Deprecate use of avcodec_register(), avcodec_register_all(), and Deprecate use of avcodec_register(), avcodec_register_all(), and
av_codec_next(). Add av_codec_iterate(). av_codec_next(). Add av_codec_iterate().
......
/protocol_list.c /protocol_list.c
/muxer_list.c
/demuxer_list.c
This diff is collapsed.
...@@ -2011,6 +2011,7 @@ const char *avformat_configuration(void); ...@@ -2011,6 +2011,7 @@ const char *avformat_configuration(void);
*/ */
const char *avformat_license(void); const char *avformat_license(void);
#if FF_API_NEXT
/** /**
* Initialize libavformat and register all the muxers, demuxers and * Initialize libavformat and register all the muxers, demuxers and
* protocols. If you do not call this function, then you can select * protocols. If you do not call this function, then you can select
...@@ -2019,10 +2020,14 @@ const char *avformat_license(void); ...@@ -2019,10 +2020,14 @@ const char *avformat_license(void);
* @see av_register_input_format() * @see av_register_input_format()
* @see av_register_output_format() * @see av_register_output_format()
*/ */
attribute_deprecated
void av_register_all(void); void av_register_all(void);
attribute_deprecated
void av_register_input_format(AVInputFormat *format); void av_register_input_format(AVInputFormat *format);
attribute_deprecated
void av_register_output_format(AVOutputFormat *format); void av_register_output_format(AVOutputFormat *format);
#endif
/** /**
* Do global initialization of network libraries. This is optional, * Do global initialization of network libraries. This is optional,
...@@ -2046,11 +2051,13 @@ int avformat_network_init(void); ...@@ -2046,11 +2051,13 @@ int avformat_network_init(void);
*/ */
int avformat_network_deinit(void); int avformat_network_deinit(void);
#if FF_API_NEXT
/** /**
* If f is NULL, returns the first registered input format, * If f is NULL, returns the first registered input format,
* if f is non-NULL, returns the next registered input format after f * if f is non-NULL, returns the next registered input format after f
* or NULL if f is the last one. * or NULL if f is the last one.
*/ */
attribute_deprecated
AVInputFormat *av_iformat_next(const AVInputFormat *f); AVInputFormat *av_iformat_next(const AVInputFormat *f);
/** /**
...@@ -2058,7 +2065,31 @@ AVInputFormat *av_iformat_next(const AVInputFormat *f); ...@@ -2058,7 +2065,31 @@ AVInputFormat *av_iformat_next(const AVInputFormat *f);
* if f is non-NULL, returns the next registered output format after f * if f is non-NULL, returns the next registered output format after f
* or NULL if f is the last one. * or NULL if f is the last one.
*/ */
attribute_deprecated
AVOutputFormat *av_oformat_next(const AVOutputFormat *f); AVOutputFormat *av_oformat_next(const AVOutputFormat *f);
#endif
/**
* Iterate over all registered muxers.
*
* @param opaque a pointer where libavformat will store the iteration state. Must
* point to NULL to start the iteration.
*
* @return the next registered muxer or NULL when the iteration is
* finished
*/
const AVOutputFormat *av_muxer_iterate(void **opaque);
/**
* Iterate over all registered demuxers.
*
* @param opaque a pointer where libavformat will store the iteration state. Must
* point to NULL to start the iteration.
*
* @return the next registered demuxer or NULL when the iteration is
* finished
*/
const AVInputFormat *av_demuxer_iterate(void **opaque);
/** /**
* Allocate an AVFormatContext. * Allocate an AVFormatContext.
......
...@@ -34,65 +34,6 @@ ...@@ -34,65 +34,6 @@
* @file * @file
* Format register and lookup * Format register and lookup
*/ */
/** head of registered input format linked list */
static AVInputFormat *first_iformat = NULL;
/** head of registered output format linked list */
static AVOutputFormat *first_oformat = NULL;
static AVInputFormat **last_iformat = &first_iformat;
static AVOutputFormat **last_oformat = &first_oformat;
AVInputFormat *av_iformat_next(const AVInputFormat *f)
{
if (f)
return f->next;
else
return first_iformat;
}
AVOutputFormat *av_oformat_next(const AVOutputFormat *f)
{
if (f)
return f->next;
else
return first_oformat;
}
static AVMutex iformat_register_mutex = AV_MUTEX_INITIALIZER;
void av_register_input_format(AVInputFormat *format)
{
AVInputFormat **p;
ff_mutex_lock(&iformat_register_mutex);
p = last_iformat;
while (*p)
p = &(*p)->next;
*p = format;
format->next = NULL;
last_iformat = &format->next;
ff_mutex_unlock(&iformat_register_mutex);
}
static AVMutex oformat_register_mutex = AV_MUTEX_INITIALIZER;
void av_register_output_format(AVOutputFormat *format)
{
AVOutputFormat **p;
ff_mutex_lock(&oformat_register_mutex);
p = last_oformat;
while (*p)
p = &(*p)->next;
*p = format;
format->next = NULL;
last_oformat = &format->next;
ff_mutex_unlock(&oformat_register_mutex);
}
int av_match_ext(const char *filename, const char *extensions) int av_match_ext(const char *filename, const char *extensions)
{ {
...@@ -111,6 +52,7 @@ AVOutputFormat *av_guess_format(const char *short_name, const char *filename, ...@@ -111,6 +52,7 @@ AVOutputFormat *av_guess_format(const char *short_name, const char *filename,
const char *mime_type) const char *mime_type)
{ {
AVOutputFormat *fmt = NULL, *fmt_found; AVOutputFormat *fmt = NULL, *fmt_found;
void *i = 0;
int score_max, score; int score_max, score;
/* specific test for image sequences */ /* specific test for image sequences */
...@@ -124,7 +66,7 @@ AVOutputFormat *av_guess_format(const char *short_name, const char *filename, ...@@ -124,7 +66,7 @@ AVOutputFormat *av_guess_format(const char *short_name, const char *filename,
/* Find the proper file type. */ /* Find the proper file type. */
fmt_found = NULL; fmt_found = NULL;
score_max = 0; score_max = 0;
while ((fmt = av_oformat_next(fmt))) { while ((fmt = av_muxer_iterate(&i))) {
score = 0; score = 0;
if (fmt->name && short_name && av_match_name(short_name, fmt->name)) if (fmt->name && short_name && av_match_name(short_name, fmt->name))
score += 100; score += 100;
...@@ -176,7 +118,8 @@ enum AVCodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name, ...@@ -176,7 +118,8 @@ enum AVCodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
AVInputFormat *av_find_input_format(const char *short_name) AVInputFormat *av_find_input_format(const char *short_name)
{ {
AVInputFormat *fmt = NULL; AVInputFormat *fmt = NULL;
while ((fmt = av_iformat_next(fmt))) void *i = 0;
while ((fmt = av_demuxer_iterate(&i)))
if (av_match_name(short_name, fmt->name)) if (av_match_name(short_name, fmt->name))
return fmt; return fmt;
return NULL; return NULL;
...@@ -188,6 +131,7 @@ AVInputFormat *av_probe_input_format3(AVProbeData *pd, int is_opened, ...@@ -188,6 +131,7 @@ AVInputFormat *av_probe_input_format3(AVProbeData *pd, int is_opened,
AVProbeData lpd = *pd; AVProbeData lpd = *pd;
AVInputFormat *fmt1 = NULL, *fmt; AVInputFormat *fmt1 = NULL, *fmt;
int score, score_max = 0; int score, score_max = 0;
void *i = 0;
const static uint8_t zerobuffer[AVPROBE_PADDING_SIZE]; const static uint8_t zerobuffer[AVPROBE_PADDING_SIZE];
enum nodat { enum nodat {
NO_ID3, NO_ID3,
...@@ -213,7 +157,7 @@ AVInputFormat *av_probe_input_format3(AVProbeData *pd, int is_opened, ...@@ -213,7 +157,7 @@ AVInputFormat *av_probe_input_format3(AVProbeData *pd, int is_opened,
} }
fmt = NULL; fmt = NULL;
while ((fmt1 = av_iformat_next(fmt1))) { while ((fmt1 = av_demuxer_iterate(&i))) {
if (!is_opened == !(fmt1->flags & AVFMT_NOFILE) && strcmp(fmt1->name, "image2")) if (!is_opened == !(fmt1->flags & AVFMT_NOFILE) && strcmp(fmt1->name, "image2"))
continue; continue;
score = 0; score = 0;
......
...@@ -91,6 +91,9 @@ ...@@ -91,6 +91,9 @@
#ifndef FF_API_OLD_RTSP_OPTIONS #ifndef FF_API_OLD_RTSP_OPTIONS
#define FF_API_OLD_RTSP_OPTIONS (LIBAVFORMAT_VERSION_MAJOR < 59) #define FF_API_OLD_RTSP_OPTIONS (LIBAVFORMAT_VERSION_MAJOR < 59)
#endif #endif
#ifndef FF_API_NEXT
#define FF_API_NEXT (LIBAVFORMAT_VERSION_MAJOR < 59)
#endif
#ifndef FF_API_R_FRAME_RATE #ifndef FF_API_R_FRAME_RATE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment