FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 "internal.h"
23 #include "libavutil/opt.h"
24 
25 /**
26  * @file
27  * Options definition for AVFormatContext.
28  */
29 
30 #include "options_table.h"
31 
32 static const char* format_to_name(void* ptr)
33 {
35  if(fc->iformat) return fc->iformat->name;
36  else if(fc->oformat) return fc->oformat->name;
37  else return "NULL";
38 }
39 
40 static void *format_child_next(void *obj, void *prev)
41 {
42  AVFormatContext *s = obj;
43  if (!prev && s->priv_data &&
44  ((s->iformat && s->iformat->priv_class) ||
45  s->oformat && s->oformat->priv_class))
46  return s->priv_data;
47  if (s->pb && s->pb->av_class && prev != s->pb)
48  return s->pb;
49  return NULL;
50 }
51 
52 static const AVClass *format_child_class_next(const AVClass *prev)
53 {
54  AVInputFormat *ifmt = NULL;
55  AVOutputFormat *ofmt = NULL;
56 
57  if (!prev)
58  return &ffio_url_class;
59 
60  while ((ifmt = av_iformat_next(ifmt)))
61  if (ifmt->priv_class == prev)
62  break;
63 
64  if (!ifmt)
65  while ((ofmt = av_oformat_next(ofmt)))
66  if (ofmt->priv_class == prev)
67  break;
68  if (!ofmt)
69  while (ifmt = av_iformat_next(ifmt))
70  if (ifmt->priv_class)
71  return ifmt->priv_class;
72 
73  while (ofmt = av_oformat_next(ofmt))
74  if (ofmt->priv_class)
75  return ofmt->priv_class;
76 
77  return NULL;
78 }
79 
80 static AVClassCategory get_category(void *ptr)
81 {
82  AVFormatContext* s = ptr;
83  if(s->iformat) return AV_CLASS_CATEGORY_DEMUXER;
84  else return AV_CLASS_CATEGORY_MUXER;
85 }
86 
88  .class_name = "AVFormatContext",
89  .item_name = format_to_name,
90  .option = avformat_options,
91  .version = LIBAVUTIL_VERSION_INT,
92  .child_next = format_child_next,
93  .child_class_next = format_child_class_next,
95  .get_category = get_category,
96 };
97 
99 {
100  memset(s, 0, sizeof(AVFormatContext));
101 
103 
105 }
106 
108 {
109  AVFormatContext *ic;
110  ic = av_malloc(sizeof(AVFormatContext));
111  if (!ic) return ic;
113 
114  ic->internal = av_mallocz(sizeof(*ic->internal));
115  if (!ic->internal) {
117  return NULL;
118  }
119 
120  return ic;
121 }
122 
124 {
125  return ctx->duration_estimation_method;
126 }
127 
129 {
130  return &av_format_context_class;
131 }