00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "avformat.h"
00021 #include "libavcodec/opt.h"
00022
00028 static const char* format_to_name(void* ptr)
00029 {
00030 AVFormatContext* fc = (AVFormatContext*) ptr;
00031 if(fc->iformat) return fc->iformat->name;
00032 else if(fc->oformat) return fc->oformat->name;
00033 else return "NULL";
00034 }
00035
00036 #define OFFSET(x) offsetof(AVFormatContext,x)
00037 #define DEFAULT 0 //should be NAN but it does not work as it is not a constant in glibc as required by ANSI/ISO C
00038
00039 #define E AV_OPT_FLAG_ENCODING_PARAM
00040 #define D AV_OPT_FLAG_DECODING_PARAM
00041
00042 static const AVOption options[]={
00043 {"probesize", "set probing size", OFFSET(probesize), FF_OPT_TYPE_INT, 5000000, 32, INT_MAX, D},
00044 {"muxrate", "set mux rate", OFFSET(mux_rate), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, E},
00045 {"packetsize", "set packet size", OFFSET(packet_size), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, E},
00046 {"fflags", NULL, OFFSET(flags), FF_OPT_TYPE_FLAGS, DEFAULT, INT_MIN, INT_MAX, D|E, "fflags"},
00047 {"ignidx", "ignore index", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_IGNIDX, INT_MIN, INT_MAX, D, "fflags"},
00048 {"genpts", "generate pts", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_GENPTS, INT_MIN, INT_MAX, D, "fflags"},
00049 {"nofillin", "do not fill in missing values that can be exactly calculated", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_NOFILLIN, INT_MIN, INT_MAX, D, "fflags"},
00050 {"noparse", "disable AVParsers, this needs nofillin too", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_NOPARSE, INT_MIN, INT_MAX, D, "fflags"},
00051 {"igndts", "ingore dts", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_IGNDTS, INT_MIN, INT_MAX, D, "fflags"},
00052 {"rtphint", "add rtp hinting", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_RTP_HINT, INT_MIN, INT_MAX, E, "fflags"},
00053 #if LIBAVFORMAT_VERSION_INT < (53<<16)
00054 {"track", " set the track number", OFFSET(track), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, E},
00055 {"year", "set the year", OFFSET(year), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, E},
00056 #endif
00057 {"analyzeduration", "how many microseconds are analyzed to estimate duration", OFFSET(max_analyze_duration), FF_OPT_TYPE_INT, 5*AV_TIME_BASE, 0, INT_MAX, D},
00058 {"cryptokey", "decryption key", OFFSET(key), FF_OPT_TYPE_BINARY, 0, 0, 0, D},
00059 {"indexmem", "max memory used for timestamp index (per stream)", OFFSET(max_index_size), FF_OPT_TYPE_INT, 1<<20, 0, INT_MAX, D},
00060 {"rtbufsize", "max memory used for buffering real-time frames", OFFSET(max_picture_buffer), FF_OPT_TYPE_INT, 3041280, 0, INT_MAX, D},
00061 {"fdebug", "print specific debug info", OFFSET(debug), FF_OPT_TYPE_FLAGS, DEFAULT, 0, INT_MAX, E|D, "fdebug"},
00062 {"ts", NULL, 0, FF_OPT_TYPE_CONST, FF_FDEBUG_TS, INT_MIN, INT_MAX, E|D, "fdebug"},
00063 {NULL},
00064 };
00065
00066 #undef E
00067 #undef D
00068 #undef DEFAULT
00069
00070 static const AVClass av_format_context_class = { "AVFormatContext", format_to_name, options, LIBAVUTIL_VERSION_INT };
00071
00072 static void avformat_get_context_defaults(AVFormatContext *s)
00073 {
00074 memset(s, 0, sizeof(AVFormatContext));
00075
00076 s->av_class = &av_format_context_class;
00077
00078 av_opt_set_defaults(s);
00079 }
00080
00081 AVFormatContext *avformat_alloc_context(void)
00082 {
00083 AVFormatContext *ic;
00084 ic = av_malloc(sizeof(AVFormatContext));
00085 if (!ic) return ic;
00086 avformat_get_context_defaults(ic);
00087 ic->av_class = &av_format_context_class;
00088 return ic;
00089 }
00090
00091 #if LIBAVFORMAT_VERSION_MAJOR < 53
00092 AVFormatContext *av_alloc_format_context(void)
00093 {
00094 return avformat_alloc_context();
00095 }
00096 #endif