yading@11: /* yading@11: * copyright (c) 2006 Michael Niedermayer yading@11: * yading@11: * This file is part of FFmpeg. yading@11: * yading@11: * FFmpeg is free software; you can redistribute it and/or yading@11: * modify it under the terms of the GNU Lesser General Public yading@11: * License as published by the Free Software Foundation; either yading@11: * version 2.1 of the License, or (at your option) any later version. yading@11: * yading@11: * FFmpeg is distributed in the hope that it will be useful, yading@11: * but WITHOUT ANY WARRANTY; without even the implied warranty of yading@11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU yading@11: * Lesser General Public License for more details. yading@11: * yading@11: * You should have received a copy of the GNU Lesser General Public yading@11: * License along with FFmpeg; if not, write to the Free Software yading@11: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA yading@11: */ yading@11: yading@11: #ifndef AVUTIL_LOG_H yading@11: #define AVUTIL_LOG_H yading@11: yading@11: #include yading@11: #include "avutil.h" yading@11: #include "attributes.h" yading@11: yading@11: typedef enum { yading@11: AV_CLASS_CATEGORY_NA = 0, yading@11: AV_CLASS_CATEGORY_INPUT, yading@11: AV_CLASS_CATEGORY_OUTPUT, yading@11: AV_CLASS_CATEGORY_MUXER, yading@11: AV_CLASS_CATEGORY_DEMUXER, yading@11: AV_CLASS_CATEGORY_ENCODER, yading@11: AV_CLASS_CATEGORY_DECODER, yading@11: AV_CLASS_CATEGORY_FILTER, yading@11: AV_CLASS_CATEGORY_BITSTREAM_FILTER, yading@11: AV_CLASS_CATEGORY_SWSCALER, yading@11: AV_CLASS_CATEGORY_SWRESAMPLER, yading@11: AV_CLASS_CATEGORY_NB, ///< not part of ABI/API yading@11: }AVClassCategory; yading@11: yading@11: struct AVOptionRanges; yading@11: yading@11: /** yading@11: * Describe the class of an AVClass context structure. That is an yading@11: * arbitrary struct of which the first field is a pointer to an yading@11: * AVClass struct (e.g. AVCodecContext, AVFormatContext etc.). yading@11: */ yading@11: typedef struct AVClass { yading@11: /** yading@11: * The name of the class; usually it is the same name as the yading@11: * context structure type to which the AVClass is associated. yading@11: */ yading@11: const char* class_name; yading@11: yading@11: /** yading@11: * A pointer to a function which returns the name of a context yading@11: * instance ctx associated with the class. yading@11: */ yading@11: const char* (*item_name)(void* ctx); yading@11: yading@11: /** yading@11: * a pointer to the first option specified in the class if any or NULL yading@11: * yading@11: * @see av_set_default_options() yading@11: */ yading@11: const struct AVOption *option; yading@11: yading@11: /** yading@11: * LIBAVUTIL_VERSION with which this structure was created. yading@11: * This is used to allow fields to be added without requiring major yading@11: * version bumps everywhere. yading@11: */ yading@11: yading@11: int version; yading@11: yading@11: /** yading@11: * Offset in the structure where log_level_offset is stored. yading@11: * 0 means there is no such variable yading@11: */ yading@11: int log_level_offset_offset; yading@11: yading@11: /** yading@11: * Offset in the structure where a pointer to the parent context for yading@11: * logging is stored. For example a decoder could pass its AVCodecContext yading@11: * to eval as such a parent context, which an av_log() implementation yading@11: * could then leverage to display the parent context. yading@11: * The offset can be NULL. yading@11: */ yading@11: int parent_log_context_offset; yading@11: yading@11: /** yading@11: * Return next AVOptions-enabled child or NULL yading@11: */ yading@11: void* (*child_next)(void *obj, void *prev); yading@11: yading@11: /** yading@11: * Return an AVClass corresponding to the next potential yading@11: * AVOptions-enabled child. yading@11: * yading@11: * The difference between child_next and this is that yading@11: * child_next iterates over _already existing_ objects, while yading@11: * child_class_next iterates over _all possible_ children. yading@11: */ yading@11: const struct AVClass* (*child_class_next)(const struct AVClass *prev); yading@11: yading@11: /** yading@11: * Category used for visualization (like color) yading@11: * This is only set if the category is equal for all objects using this class. yading@11: * available since version (51 << 16 | 56 << 8 | 100) yading@11: */ yading@11: AVClassCategory category; yading@11: yading@11: /** yading@11: * Callback to return the category. yading@11: * available since version (51 << 16 | 59 << 8 | 100) yading@11: */ yading@11: AVClassCategory (*get_category)(void* ctx); yading@11: yading@11: /** yading@11: * Callback to return the supported/allowed ranges. yading@11: * available since version (52.12) yading@11: */ yading@11: int (*query_ranges)(struct AVOptionRanges **, void *obj, const char *key, int flags); yading@11: } AVClass; yading@11: yading@11: /* av_log API */ yading@11: yading@11: #define AV_LOG_QUIET -8 yading@11: yading@11: /** yading@11: * Something went really wrong and we will crash now. yading@11: */ yading@11: #define AV_LOG_PANIC 0 yading@11: yading@11: /** yading@11: * Something went wrong and recovery is not possible. yading@11: * For example, no header was found for a format which depends yading@11: * on headers or an illegal combination of parameters is used. yading@11: */ yading@11: #define AV_LOG_FATAL 8 yading@11: yading@11: /** yading@11: * Something went wrong and cannot losslessly be recovered. yading@11: * However, not all future data is affected. yading@11: */ yading@11: #define AV_LOG_ERROR 16 yading@11: yading@11: /** yading@11: * Something somehow does not look correct. This may or may not yading@11: * lead to problems. An example would be the use of '-vstrict -2'. yading@11: */ yading@11: #define AV_LOG_WARNING 24 yading@11: yading@11: #define AV_LOG_INFO 32 yading@11: #define AV_LOG_VERBOSE 40 yading@11: yading@11: /** yading@11: * Stuff which is only useful for libav* developers. yading@11: */ yading@11: #define AV_LOG_DEBUG 48 yading@11: yading@11: #define AV_LOG_MAX_OFFSET (AV_LOG_DEBUG - AV_LOG_QUIET) yading@11: yading@11: /** yading@11: * Send the specified message to the log if the level is less than or equal yading@11: * to the current av_log_level. By default, all logging messages are sent to yading@11: * stderr. This behavior can be altered by setting a different av_vlog callback yading@11: * function. yading@11: * yading@11: * @param avcl A pointer to an arbitrary struct of which the first field is a yading@11: * pointer to an AVClass struct. yading@11: * @param level The importance level of the message, lower values signifying yading@11: * higher importance. yading@11: * @param fmt The format string (printf-compatible) that specifies how yading@11: * subsequent arguments are converted to output. yading@11: * @see av_vlog yading@11: */ yading@11: void av_log(void *avcl, int level, const char *fmt, ...) av_printf_format(3, 4); yading@11: yading@11: void av_vlog(void *avcl, int level, const char *fmt, va_list); yading@11: int av_log_get_level(void); yading@11: void av_log_set_level(int); yading@11: void av_log_set_callback(void (*)(void*, int, const char*, va_list)); yading@11: void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl); yading@11: const char* av_default_item_name(void* ctx); yading@11: AVClassCategory av_default_get_category(void *ptr); yading@11: yading@11: /** yading@11: * Format a line of log the same way as the default callback. yading@11: * @param line buffer to receive the formated line yading@11: * @param line_size size of the buffer yading@11: * @param print_prefix used to store whether the prefix must be printed; yading@11: * must point to a persistent integer initially set to 1 yading@11: */ yading@11: void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl, yading@11: char *line, int line_size, int *print_prefix); yading@11: yading@11: /** yading@11: * av_dlog macros yading@11: * Useful to print debug messages that shouldn't get compiled in normally. yading@11: */ yading@11: yading@11: #ifdef DEBUG yading@11: # define av_dlog(pctx, ...) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__) yading@11: #else yading@11: # define av_dlog(pctx, ...) do { if (0) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__); } while (0) yading@11: #endif yading@11: yading@11: /** yading@11: * Skip repeated messages, this requires the user app to use av_log() instead of yading@11: * (f)printf as the 2 would otherwise interfere and lead to yading@11: * "Last message repeated x times" messages below (f)printf messages with some yading@11: * bad luck. yading@11: * Also to receive the last, "last repeated" line if any, the user app must yading@11: * call av_log(NULL, AV_LOG_QUIET, "%s", ""); at the end yading@11: */ yading@11: #define AV_LOG_SKIP_REPEATED 1 yading@11: void av_log_set_flags(int arg); yading@11: yading@11: #endif /* AVUTIL_LOG_H */