2009-01-10 11:56:07 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2000, 2001, 2002 Fabrice Bellard
|
|
|
|
*
|
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
|
|
|
* 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
|
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
|
|
|
* 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"
|
2014-01-20 15:59:06 +03:00
|
|
|
#include "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 01:43:12 +03:00
|
|
|
if (!prev)
|
2011-11-14 14:24:21 +03:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-07-27 19:11:01 +03:00
|
|
|
static AVClassCategory get_category(void *ptr)
|
2012-06-03 23:41:05 +03:00
|
|
|
{
|
2012-07-27 19:11:01 +03:00
|
|
|
AVFormatContext* s = ptr;
|
2012-06-03 23:41:05 +03:00
|
|
|
if(s->iformat) return AV_CLASS_CATEGORY_DEMUXER;
|
|
|
|
else return AV_CLASS_CATEGORY_MUXER;
|
|
|
|
}
|
|
|
|
|
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,
|
2012-05-28 13:50:06 +03:00
|
|
|
.category = AV_CLASS_CATEGORY_MUXER,
|
2012-06-03 23:41:05 +03:00
|
|
|
.get_category = get_category,
|
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);
|
2014-11-17 13:31:47 +02:00
|
|
|
ic->offset = AV_NOPTS_VALUE;
|
2014-01-20 15:59:06 +03:00
|
|
|
|
|
|
|
ic->internal = av_mallocz(sizeof(*ic->internal));
|
|
|
|
if (!ic->internal) {
|
|
|
|
avformat_free_context(ic);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-01-10 11:56:07 +02:00
|
|
|
return ic;
|
|
|
|
}
|
2011-08-23 08:23:52 +03:00
|
|
|
|
2012-06-23 02:03:18 +03:00
|
|
|
enum AVDurationEstimationMethod av_fmt_ctx_get_duration_estimation_method(const AVFormatContext* ctx)
|
2012-06-18 08:20:09 +03:00
|
|
|
{
|
|
|
|
return ctx->duration_estimation_method;
|
|
|
|
}
|
|
|
|
|
2011-08-23 08:23:52 +03:00
|
|
|
const AVClass *avformat_get_class(void)
|
|
|
|
{
|
|
|
|
return &av_format_context_class;
|
|
|
|
}
|