2009-01-10 09:56:07 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2000, 2001, 2002 Fabrice Bellard
|
|
|
|
*
|
2011-03-18 17:35:10 +00:00
|
|
|
* This file is part of Libav.
|
2009-01-10 09:56:07 +00:00
|
|
|
*
|
2011-03-18 17:35:10 +00:00
|
|
|
* Libav is free software; you can redistribute it and/or
|
2009-01-10 09:56:07 +00: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 17:35:10 +00:00
|
|
|
* Libav is distributed in the hope that it will be useful,
|
2009-01-10 09:56:07 +00: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 17:35:10 +00:00
|
|
|
* License along with Libav; if not, write to the Free Software
|
2009-01-10 09:56:07 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
#include "avformat.h"
|
2011-11-05 11:30:21 +00:00
|
|
|
#include "avio_internal.h"
|
2010-09-26 14:25:22 +00:00
|
|
|
#include "libavutil/opt.h"
|
2009-01-10 09:56:07 +00:00
|
|
|
|
|
|
|
/**
|
2010-04-20 14:45:34 +00:00
|
|
|
* @file
|
2009-01-10 09:56:07 +00:00
|
|
|
* Options definition for AVFormatContext.
|
|
|
|
*/
|
|
|
|
|
2012-03-14 12:18:20 +00:00
|
|
|
#include "options_table.h"
|
|
|
|
|
2009-01-10 09:56:07 +00: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 17:49:12 +00: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 11:30:21 +00:00
|
|
|
if (s->pb && s->pb->av_class && prev != s->pb)
|
|
|
|
return s->pb;
|
2011-10-03 17:49:12 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const AVClass *format_child_class_next(const AVClass *prev)
|
2011-05-22 06:37:25 +00:00
|
|
|
{
|
|
|
|
AVInputFormat *ifmt = NULL;
|
|
|
|
AVOutputFormat *ofmt = NULL;
|
2011-10-03 17:49:12 +00:00
|
|
|
|
2011-11-14 11:24:21 +00:00
|
|
|
if (!prev)
|
|
|
|
return &ffio_url_class;
|
|
|
|
|
|
|
|
while ((ifmt = av_iformat_next(ifmt)))
|
2011-10-03 17:49:12 +00:00
|
|
|
if (ifmt->priv_class == prev)
|
|
|
|
break;
|
2011-11-14 11:24:21 +00:00
|
|
|
|
|
|
|
if (!ifmt)
|
|
|
|
while ((ofmt = av_oformat_next(ofmt)))
|
|
|
|
if (ofmt->priv_class == prev)
|
|
|
|
break;
|
|
|
|
if (!ofmt)
|
2011-10-03 17:49:12 +00:00
|
|
|
while (ifmt = av_iformat_next(ifmt))
|
|
|
|
if (ifmt->priv_class)
|
|
|
|
return ifmt->priv_class;
|
|
|
|
|
2011-11-14 11:24:21 +00:00
|
|
|
while (ofmt = av_oformat_next(ofmt))
|
|
|
|
if (ofmt->priv_class)
|
|
|
|
return ofmt->priv_class;
|
2011-10-03 17:49:12 +00:00
|
|
|
|
2011-05-22 06:37:25 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-04-29 09:30:02 +00:00
|
|
|
static const AVClass av_format_context_class = {
|
|
|
|
.class_name = "AVFormatContext",
|
|
|
|
.item_name = format_to_name,
|
|
|
|
.option = options,
|
|
|
|
.version = LIBAVUTIL_VERSION_INT,
|
2011-10-03 17:49:12 +00:00
|
|
|
.child_next = format_child_next,
|
|
|
|
.child_class_next = format_child_class_next,
|
2011-04-29 09:30:02 +00:00
|
|
|
};
|
2009-01-10 09:56:07 +00: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 08:16:40 +00:00
|
|
|
AVFormatContext *avformat_alloc_context(void)
|
2009-01-10 09:56:07 +00:00
|
|
|
{
|
|
|
|
AVFormatContext *ic;
|
|
|
|
ic = av_malloc(sizeof(AVFormatContext));
|
|
|
|
if (!ic) return ic;
|
|
|
|
avformat_get_context_defaults(ic);
|
|
|
|
return ic;
|
|
|
|
}
|
2011-08-23 05:23:52 +00:00
|
|
|
|
|
|
|
const AVClass *avformat_get_class(void)
|
|
|
|
{
|
|
|
|
return &av_format_context_class;
|
|
|
|
}
|