summaryrefslogtreecommitdiff
path: root/libavformat/format.c
diff options
context:
space:
mode:
authorJosh de Kock <josh@itanimul.li>2018-01-21 16:06:54 +0000
committerJosh de Kock <josh@itanimul.li>2018-02-06 18:57:42 +0000
commit0694d8702421e7aff1340038559c438b61bb30dd (patch)
treeeb02d480f6f6c75696c9e83f898b13bba586589f /libavformat/format.c
parent598d5f8579b3a048a643486a5f20fc4d479a2017 (diff)
lavf: add new API for iterating muxers and demuxers
Diffstat (limited to 'libavformat/format.c')
-rw-r--r--libavformat/format.c68
1 files changed, 6 insertions, 62 deletions
diff --git a/libavformat/format.c b/libavformat/format.c
index 759b5b1ab4..608af1b692 100644
--- a/libavformat/format.c
+++ b/libavformat/format.c
@@ -34,65 +34,6 @@
* @file
* 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)
{
@@ -111,6 +52,7 @@ AVOutputFormat *av_guess_format(const char *short_name, const char *filename,
const char *mime_type)
{
AVOutputFormat *fmt = NULL, *fmt_found;
+ void *i = 0;
int score_max, score;
/* specific test for image sequences */
@@ -124,7 +66,7 @@ AVOutputFormat *av_guess_format(const char *short_name, const char *filename,
/* Find the proper file type. */
fmt_found = NULL;
score_max = 0;
- while ((fmt = av_oformat_next(fmt))) {
+ while ((fmt = av_muxer_iterate(&i))) {
score = 0;
if (fmt->name && short_name && av_match_name(short_name, fmt->name))
score += 100;
@@ -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 *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))
return fmt;
return NULL;
@@ -188,6 +131,7 @@ AVInputFormat *av_probe_input_format3(AVProbeData *pd, int is_opened,
AVProbeData lpd = *pd;
AVInputFormat *fmt1 = NULL, *fmt;
int score, score_max = 0;
+ void *i = 0;
const static uint8_t zerobuffer[AVPROBE_PADDING_SIZE];
enum nodat {
NO_ID3,
@@ -213,7 +157,7 @@ AVInputFormat *av_probe_input_format3(AVProbeData *pd, int is_opened,
}
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"))
continue;
score = 0;