summaryrefslogtreecommitdiff
path: root/cmdutils.h
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-09-05 02:04:27 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-09-05 03:10:45 +0200
commitd2084402e6034e8d49ea50ebe212c4e8783d028a (patch)
tree4887311120f2f7f5bdd105c919e60615ec9f53fb /cmdutils.h
parentb881a2e254f3948a2ff1775a7e2ae58abdef96b6 (diff)
parentfb47997edb9d8ff16fc380d005a08c0545624aa6 (diff)
downloadffmpeg-d2084402e6034e8d49ea50ebe212c4e8783d028a.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: lavc: fix type for thread_type option avconv: move format to options context avconv: move limit_filesize to options context avconv: move start_time, recording_time and input_ts_offset to options context avconv: add a context for options. cmdutils: allow storing per-stream/chapter/.... options in a generic way cmdutils: split per-option code out of parse_options(). cmdutils: add support for caller-provided option context. cmdutils: declare only one pointer type in OptionDef cmdutils: move grow_array() from avconv to cmdutils. cmdutils: move exit_program() declaration to cmdutils from avconv http: Consider the stream as seekable if the reply contains Accept-Ranges: bytes nutenc: add namespace to the api facing functions Conflicts: avconv.c cmdutils.c cmdutils.h ffmpeg.c ffplay.c ffprobe.c ffserver.c libavformat/http.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'cmdutils.h')
-rw-r--r--cmdutils.h54
1 files changed, 47 insertions, 7 deletions
diff --git a/cmdutils.h b/cmdutils.h
index 9e89b7ee18..a0d36865fb 100644
--- a/cmdutils.h
+++ b/cmdutils.h
@@ -112,6 +112,16 @@ double parse_number_or_die(const char *context, const char *numstr, int type, do
*/
int64_t parse_time_or_die(const char *context, const char *timestr, int is_duration);
+typedef struct SpecifierOpt {
+ char *specifier; /**< stream/chapter/program/... specifier */
+ union {
+ uint8_t *str;
+ int i;
+ int64_t i64;
+ float f;
+ } u;
+} SpecifierOpt;
+
typedef struct {
const char *name;
int flags;
@@ -128,12 +138,17 @@ typedef struct {
#define OPT_INT64 0x0400
#define OPT_EXIT 0x0800
#define OPT_DATA 0x1000
+#define OPT_FUNC2 0x2000
+#define OPT_OFFSET 0x4000 /* option is specified as an offset in a passed optctx */
+#define OPT_SPEC 0x8000 /* option is to be stored in an array of SpecifierOpt.
+ Implies OPT_OFFSET. Next element after the offset is
+ an int containing element count in the array. */
+#define OPT_TIME 0x10000
union {
- int *int_arg;
- char **str_arg;
- float *float_arg;
+ void *dst_ptr;
int (*func_arg)(const char *, const char *);
- int64_t *int64_arg;
+ int (*func2_arg)(void *, const char *, const char *);
+ size_t off;
} u;
const char *help;
const char *argname;
@@ -143,14 +158,23 @@ void show_help_options(const OptionDef *options, const char *msg, int mask, int
/**
* Parse the command line arguments.
+ *
+ * @param optctx an opaque options context
* @param options Array with the definitions required to interpret every
* option of the form: -option_name [argument]
* @param parse_arg_function Name of the function called to process every
* argument without a leading option name flag. NULL if such arguments do
* not have to be processed.
*/
-void parse_options(int argc, char **argv, const OptionDef *options,
- int (* parse_arg_function)(const char *opt, const char *arg));
+void parse_options(void *optctx, int argc, char **argv, const OptionDef *options,
+ void (* parse_arg_function)(void *optctx, const char*));
+
+/**
+ * Parse one given option.
+ *
+ * @return on success 1 if arg was consumed, 0 otherwise; negative number on error
+ */
+int parse_option(void *optctx, const char *opt, const char *arg, const OptionDef *options);
/**
* Check if the given stream matches a stream specifier.
@@ -301,4 +325,20 @@ int read_file(const char *filename, char **bufptr, size_t *size);
FILE *get_preset_file(char *filename, size_t filename_size,
const char *preset_name, int is_path, const char *codec_name);
-#endif /* FFMPEG_CMDUTILS_H */
+/**
+ * Do all the necessary cleanup and abort.
+ * This function is implemented in the avtools, not cmdutils.
+ */
+void exit_program(int ret);
+
+/**
+ * Realloc array to hold new_size elements of elem_size.
+ * Calls exit_program() on failure.
+ *
+ * @param elem_size size in bytes of each element
+ * @param size new element count will be written here
+ * @return reallocated array
+ */
+void *grow_array(void *array, int elem_size, int *size, int new_size);
+
+#endif /* LIBAV_CMDUTILS_H */