2009-01-10 11:56:07 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2000, 2001, 2002 Fabrice Bellard
|
|
|
|
*
|
2011-03-18 19:35:10 +02:00
|
|
|
* This file is part of Libav.
|
2009-01-10 11:56:07 +02:00
|
|
|
*
|
2011-03-18 19:35:10 +02:00
|
|
|
* Libav is free software; you can redistribute it and/or
|
2009-01-10 11:56:07 +02:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
2011-03-18 19:35:10 +02:00
|
|
|
* Libav is distributed in the hope that it will be useful,
|
2009-01-10 11:56:07 +02:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2011-03-18 19:35:10 +02:00
|
|
|
* License along with Libav; if not, write to the Free Software
|
2009-01-10 11:56:07 +02:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
#include "avformat.h"
|
2011-11-05 14:30:21 +03:00
|
|
|
#include "avio_internal.h"
|
2010-09-26 17:25:22 +03:00
|
|
|
#include "libavutil/opt.h"
|
2009-01-10 11:56:07 +02:00
|
|
|
|
|
|
|
/**
|
2010-04-20 17:45:34 +03:00
|
|
|
* @file
|
2009-01-10 11:56:07 +02:00
|
|
|
* Options definition for AVFormatContext.
|
|
|
|
*/
|
|
|
|
|
2012-03-14 15:18:20 +03:00
|
|
|
#include "options_table.h"
|
|
|
|
|
2009-01-10 11:56:07 +02:00
|
|
|
static const char* format_to_name(void* ptr)
|
|
|
|
{
|
|
|
|
AVFormatContext* fc = (AVFormatContext*) ptr;
|
|
|
|
if(fc->iformat) return fc->iformat->name;
|
|
|
|
else if(fc->oformat) return fc->oformat->name;
|
|
|
|
else return "NULL";
|
|
|
|
}
|
|
|
|
|
2011-10-03 20:49:12 +03:00
|
|
|
static void *format_child_next(void *obj, void *prev)
|
|
|
|
{
|
|
|
|
AVFormatContext *s = obj;
|
|
|
|
if (!prev && s->priv_data &&
|
|
|
|
((s->iformat && s->iformat->priv_class) ||
|
|
|
|
s->oformat && s->oformat->priv_class))
|
|
|
|
return s->priv_data;
|
2011-11-05 14:30:21 +03:00
|
|
|
if (s->pb && s->pb->av_class && prev != s->pb)
|
|
|
|
return s->pb;
|
2011-10-03 20:49:12 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const AVClass *format_child_class_next(const AVClass *prev)
|
2011-05-22 09:37:25 +03:00
|
|
|
{
|
|
|
|
AVInputFormat *ifmt = NULL;
|
|
|
|
AVOutputFormat *ofmt = NULL;
|
2011-10-03 20:49:12 +03:00
|
|
|
|
2011-11-14 14:24:21 +03:00
|
|
|
if (!prev)
|
|
|
|
return &ffio_url_class;
|
|
|
|
|
|
|
|
while ((ifmt = av_iformat_next(ifmt)))
|
2011-10-03 20:49:12 +03:00
|
|
|
if (ifmt->priv_class == prev)
|
|
|
|
break;
|
2011-11-14 14:24:21 +03:00
|
|
|
|
|
|
|
if (!ifmt)
|
|
|
|
while ((ofmt = av_oformat_next(ofmt)))
|
|
|
|
if (ofmt->priv_class == prev)
|
|
|
|
break;
|
|
|
|
if (!ofmt)
|
2011-10-03 20:49:12 +03:00
|
|
|
while (ifmt = av_iformat_next(ifmt))
|
|
|
|
if (ifmt->priv_class)
|
|
|
|
return ifmt->priv_class;
|
|
|
|
|
2011-11-14 14:24:21 +03:00
|
|
|
while (ofmt = av_oformat_next(ofmt))
|
|
|
|
if (ofmt->priv_class)
|
|
|
|
return ofmt->priv_class;
|
2011-10-03 20:49:12 +03:00
|
|
|
|
2011-05-22 09:37:25 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-04-29 12:30:02 +03:00
|
|
|
static const AVClass av_format_context_class = {
|
|
|
|
.class_name = "AVFormatContext",
|
|
|
|
.item_name = format_to_name,
|
2013-08-01 15:35:01 +03:00
|
|
|
.option = avformat_options,
|
2011-04-29 12:30:02 +03:00
|
|
|
.version = LIBAVUTIL_VERSION_INT,
|
2011-10-03 20:49:12 +03:00
|
|
|
.child_next = format_child_next,
|
|
|
|
.child_class_next = format_child_class_next,
|
2011-04-29 12:30:02 +03:00
|
|
|
};
|
2009-01-10 11:56:07 +02:00
|
|
|
|
|
|
|
static void avformat_get_context_defaults(AVFormatContext *s)
|
|
|
|
{
|
|
|
|
memset(s, 0, sizeof(AVFormatContext));
|
|
|
|
|
|
|
|
s->av_class = &av_format_context_class;
|
|
|
|
|
|
|
|
av_opt_set_defaults(s);
|
|
|
|
}
|
|
|
|
|
2009-02-08 10:16:40 +02:00
|
|
|
AVFormatContext *avformat_alloc_context(void)
|
2009-01-10 11:56:07 +02:00
|
|
|
{
|
|
|
|
AVFormatContext *ic;
|
|
|
|
ic = av_malloc(sizeof(AVFormatContext));
|
|
|
|
if (!ic) return ic;
|
|
|
|
avformat_get_context_defaults(ic);
|
|
|
|
return ic;
|
|
|
|
}
|
2011-08-23 08:23:52 +03:00
|
|
|
|
|
|
|
const AVClass *avformat_get_class(void)
|
|
|
|
{
|
|
|
|
return &av_format_context_class;
|
|
|
|
}
|