libavformat/options.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 #include "avformat.h"
21 #include "avio_internal.h"
22 #include "libavutil/opt.h"
23 
24 /**
25  * @file
26  * Options definition for AVFormatContext.
27  */
28 
29 #include "options_table.h"
30 
31 static const char* format_to_name(void* ptr)
32 {
33  AVFormatContext* fc = (AVFormatContext*) ptr;
34  if(fc->iformat) return fc->iformat->name;
35  else if(fc->oformat) return fc->oformat->name;
36  else return "NULL";
37 }
38 
39 static void *format_child_next(void *obj, void *prev)
40 {
41  AVFormatContext *s = obj;
42  if (!prev && s->priv_data &&
43  ((s->iformat && s->iformat->priv_class) ||
44  s->oformat && s->oformat->priv_class))
45  return s->priv_data;
46  if (s->pb && s->pb->av_class && prev != s->pb)
47  return s->pb;
48  return NULL;
49 }
50 
51 static const AVClass *format_child_class_next(const AVClass *prev)
52 {
53  AVInputFormat *ifmt = NULL;
54  AVOutputFormat *ofmt = NULL;
55 
56  if (!prev)
57  return &ffio_url_class;
58 
59  while ((ifmt = av_iformat_next(ifmt)))
60  if (ifmt->priv_class == prev)
61  break;
62 
63  if (!ifmt)
64  while ((ofmt = av_oformat_next(ofmt)))
65  if (ofmt->priv_class == prev)
66  break;
67  if (!ofmt)
68  while (ifmt = av_iformat_next(ifmt))
69  if (ifmt->priv_class)
70  return ifmt->priv_class;
71 
72  while (ofmt = av_oformat_next(ofmt))
73  if (ofmt->priv_class)
74  return ofmt->priv_class;
75 
76  return NULL;
77 }
78 
79 static AVClassCategory get_category(void *ptr)
80 {
81  AVFormatContext* s = ptr;
82  if(s->iformat) return AV_CLASS_CATEGORY_DEMUXER;
83  else return AV_CLASS_CATEGORY_MUXER;
84 }
85 
87  .class_name = "AVFormatContext",
88  .item_name = format_to_name,
89  .option = options,
90  .version = LIBAVUTIL_VERSION_INT,
91  .child_next = format_child_next,
92  .child_class_next = format_child_class_next,
94  .get_category = get_category,
95 };
96 
98 {
99  memset(s, 0, sizeof(AVFormatContext));
100 
102 
104 }
105 
107 {
108  AVFormatContext *ic;
109  ic = av_malloc(sizeof(AVFormatContext));
110  if (!ic) return ic;
112  return ic;
113 }
114 
116 {
117  return ctx->duration_estimation_method;
118 }
119 
121 {
122  return &av_format_context_class;
123 }
const char * s
Definition: avisynth_c.h:668
static const AVClass av_format_context_class
enum AVDurationEstimationMethod duration_estimation_method
The duration field can be estimated through various ways, and this field can be used to know how the ...
Definition: avformat.h:1195
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
Definition: opt.c:942
enum AVDurationEstimationMethod av_fmt_ctx_get_duration_estimation_method(const AVFormatContext *ctx)
Returns the method used to set ctx->duration.
Format I/O context.
Definition: avformat.h:944
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:55
AVOptions.
AVDurationEstimationMethod
The duration of a video can be estimated through various ways, and this enum can be used to know how ...
Definition: avformat.h:930
static void avformat_get_context_defaults(AVFormatContext *s)
const AVClass * av_class
A class for private options.
Definition: avio.h:81
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
const AVClass * priv_class
AVClass for the private context.
Definition: avformat.h:486
static AVClassCategory get_category(void *ptr)
const AVClass * avformat_get_class(void)
Get the AVClass for AVFormatContext.
const OptionDef options[]
Definition: ffserver.c:4697
struct AVOutputFormat * oformat
Definition: avformat.h:958
AVClassCategory category
Category used for visualization (like color) This is only set if the category is equal for all object...
Definition: log.h:113
static const AVClass * format_child_class_next(const AVClass *prev)
const char * name
Definition: avformat.h:378
const AVClass * priv_class
AVClass for the private context.
Definition: avformat.h:406
LIBAVUTIL_VERSION_INT
Definition: eval.c:55
AVOutputFormat * av_oformat_next(AVOutputFormat *f)
If f is NULL, returns the first registered output format, if f is non-NULL, returns the next register...
const AVClass ffio_url_class
Definition: aviobuf.c:59
NULL
Definition: eval.c:55
AVIOContext * pb
I/O context.
Definition: avformat.h:977
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition: mem.c:73
Describe the class of an AVClass context structure.
Definition: log.h:50
static void * format_child_next(void *obj, void *prev)
const AVClass * av_class
A class for logging and AVOptions.
Definition: avformat.h:949
Main libavformat public API header.
struct AVInputFormat * iformat
Can only be iformat or oformat, not both at the same time.
Definition: avformat.h:957
AVInputFormat * av_iformat_next(AVInputFormat *f)
If f is NULL, returns the first registered input format, if f is non-NULL, returns the next registere...
AVClassCategory
Definition: log.h:28
void * priv_data
Format private data.
Definition: avformat.h:964
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:461
static const char * format_to_name(void *ptr)