annotate ffmpeg/libavutil/log.h @ 11:f445c3017523

new files
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Sun, 21 Apr 2013 11:16:23 +0200
parents
children
rev   line source
yading@11 1 /*
yading@11 2 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
yading@11 3 *
yading@11 4 * This file is part of FFmpeg.
yading@11 5 *
yading@11 6 * FFmpeg is free software; you can redistribute it and/or
yading@11 7 * modify it under the terms of the GNU Lesser General Public
yading@11 8 * License as published by the Free Software Foundation; either
yading@11 9 * version 2.1 of the License, or (at your option) any later version.
yading@11 10 *
yading@11 11 * FFmpeg is distributed in the hope that it will be useful,
yading@11 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@11 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@11 14 * Lesser General Public License for more details.
yading@11 15 *
yading@11 16 * You should have received a copy of the GNU Lesser General Public
yading@11 17 * License along with FFmpeg; if not, write to the Free Software
yading@11 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@11 19 */
yading@11 20
yading@11 21 #ifndef AVUTIL_LOG_H
yading@11 22 #define AVUTIL_LOG_H
yading@11 23
yading@11 24 #include <stdarg.h>
yading@11 25 #include "avutil.h"
yading@11 26 #include "attributes.h"
yading@11 27
yading@11 28 typedef enum {
yading@11 29 AV_CLASS_CATEGORY_NA = 0,
yading@11 30 AV_CLASS_CATEGORY_INPUT,
yading@11 31 AV_CLASS_CATEGORY_OUTPUT,
yading@11 32 AV_CLASS_CATEGORY_MUXER,
yading@11 33 AV_CLASS_CATEGORY_DEMUXER,
yading@11 34 AV_CLASS_CATEGORY_ENCODER,
yading@11 35 AV_CLASS_CATEGORY_DECODER,
yading@11 36 AV_CLASS_CATEGORY_FILTER,
yading@11 37 AV_CLASS_CATEGORY_BITSTREAM_FILTER,
yading@11 38 AV_CLASS_CATEGORY_SWSCALER,
yading@11 39 AV_CLASS_CATEGORY_SWRESAMPLER,
yading@11 40 AV_CLASS_CATEGORY_NB, ///< not part of ABI/API
yading@11 41 }AVClassCategory;
yading@11 42
yading@11 43 struct AVOptionRanges;
yading@11 44
yading@11 45 /**
yading@11 46 * Describe the class of an AVClass context structure. That is an
yading@11 47 * arbitrary struct of which the first field is a pointer to an
yading@11 48 * AVClass struct (e.g. AVCodecContext, AVFormatContext etc.).
yading@11 49 */
yading@11 50 typedef struct AVClass {
yading@11 51 /**
yading@11 52 * The name of the class; usually it is the same name as the
yading@11 53 * context structure type to which the AVClass is associated.
yading@11 54 */
yading@11 55 const char* class_name;
yading@11 56
yading@11 57 /**
yading@11 58 * A pointer to a function which returns the name of a context
yading@11 59 * instance ctx associated with the class.
yading@11 60 */
yading@11 61 const char* (*item_name)(void* ctx);
yading@11 62
yading@11 63 /**
yading@11 64 * a pointer to the first option specified in the class if any or NULL
yading@11 65 *
yading@11 66 * @see av_set_default_options()
yading@11 67 */
yading@11 68 const struct AVOption *option;
yading@11 69
yading@11 70 /**
yading@11 71 * LIBAVUTIL_VERSION with which this structure was created.
yading@11 72 * This is used to allow fields to be added without requiring major
yading@11 73 * version bumps everywhere.
yading@11 74 */
yading@11 75
yading@11 76 int version;
yading@11 77
yading@11 78 /**
yading@11 79 * Offset in the structure where log_level_offset is stored.
yading@11 80 * 0 means there is no such variable
yading@11 81 */
yading@11 82 int log_level_offset_offset;
yading@11 83
yading@11 84 /**
yading@11 85 * Offset in the structure where a pointer to the parent context for
yading@11 86 * logging is stored. For example a decoder could pass its AVCodecContext
yading@11 87 * to eval as such a parent context, which an av_log() implementation
yading@11 88 * could then leverage to display the parent context.
yading@11 89 * The offset can be NULL.
yading@11 90 */
yading@11 91 int parent_log_context_offset;
yading@11 92
yading@11 93 /**
yading@11 94 * Return next AVOptions-enabled child or NULL
yading@11 95 */
yading@11 96 void* (*child_next)(void *obj, void *prev);
yading@11 97
yading@11 98 /**
yading@11 99 * Return an AVClass corresponding to the next potential
yading@11 100 * AVOptions-enabled child.
yading@11 101 *
yading@11 102 * The difference between child_next and this is that
yading@11 103 * child_next iterates over _already existing_ objects, while
yading@11 104 * child_class_next iterates over _all possible_ children.
yading@11 105 */
yading@11 106 const struct AVClass* (*child_class_next)(const struct AVClass *prev);
yading@11 107
yading@11 108 /**
yading@11 109 * Category used for visualization (like color)
yading@11 110 * This is only set if the category is equal for all objects using this class.
yading@11 111 * available since version (51 << 16 | 56 << 8 | 100)
yading@11 112 */
yading@11 113 AVClassCategory category;
yading@11 114
yading@11 115 /**
yading@11 116 * Callback to return the category.
yading@11 117 * available since version (51 << 16 | 59 << 8 | 100)
yading@11 118 */
yading@11 119 AVClassCategory (*get_category)(void* ctx);
yading@11 120
yading@11 121 /**
yading@11 122 * Callback to return the supported/allowed ranges.
yading@11 123 * available since version (52.12)
yading@11 124 */
yading@11 125 int (*query_ranges)(struct AVOptionRanges **, void *obj, const char *key, int flags);
yading@11 126 } AVClass;
yading@11 127
yading@11 128 /* av_log API */
yading@11 129
yading@11 130 #define AV_LOG_QUIET -8
yading@11 131
yading@11 132 /**
yading@11 133 * Something went really wrong and we will crash now.
yading@11 134 */
yading@11 135 #define AV_LOG_PANIC 0
yading@11 136
yading@11 137 /**
yading@11 138 * Something went wrong and recovery is not possible.
yading@11 139 * For example, no header was found for a format which depends
yading@11 140 * on headers or an illegal combination of parameters is used.
yading@11 141 */
yading@11 142 #define AV_LOG_FATAL 8
yading@11 143
yading@11 144 /**
yading@11 145 * Something went wrong and cannot losslessly be recovered.
yading@11 146 * However, not all future data is affected.
yading@11 147 */
yading@11 148 #define AV_LOG_ERROR 16
yading@11 149
yading@11 150 /**
yading@11 151 * Something somehow does not look correct. This may or may not
yading@11 152 * lead to problems. An example would be the use of '-vstrict -2'.
yading@11 153 */
yading@11 154 #define AV_LOG_WARNING 24
yading@11 155
yading@11 156 #define AV_LOG_INFO 32
yading@11 157 #define AV_LOG_VERBOSE 40
yading@11 158
yading@11 159 /**
yading@11 160 * Stuff which is only useful for libav* developers.
yading@11 161 */
yading@11 162 #define AV_LOG_DEBUG 48
yading@11 163
yading@11 164 #define AV_LOG_MAX_OFFSET (AV_LOG_DEBUG - AV_LOG_QUIET)
yading@11 165
yading@11 166 /**
yading@11 167 * Send the specified message to the log if the level is less than or equal
yading@11 168 * to the current av_log_level. By default, all logging messages are sent to
yading@11 169 * stderr. This behavior can be altered by setting a different av_vlog callback
yading@11 170 * function.
yading@11 171 *
yading@11 172 * @param avcl A pointer to an arbitrary struct of which the first field is a
yading@11 173 * pointer to an AVClass struct.
yading@11 174 * @param level The importance level of the message, lower values signifying
yading@11 175 * higher importance.
yading@11 176 * @param fmt The format string (printf-compatible) that specifies how
yading@11 177 * subsequent arguments are converted to output.
yading@11 178 * @see av_vlog
yading@11 179 */
yading@11 180 void av_log(void *avcl, int level, const char *fmt, ...) av_printf_format(3, 4);
yading@11 181
yading@11 182 void av_vlog(void *avcl, int level, const char *fmt, va_list);
yading@11 183 int av_log_get_level(void);
yading@11 184 void av_log_set_level(int);
yading@11 185 void av_log_set_callback(void (*)(void*, int, const char*, va_list));
yading@11 186 void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl);
yading@11 187 const char* av_default_item_name(void* ctx);
yading@11 188 AVClassCategory av_default_get_category(void *ptr);
yading@11 189
yading@11 190 /**
yading@11 191 * Format a line of log the same way as the default callback.
yading@11 192 * @param line buffer to receive the formated line
yading@11 193 * @param line_size size of the buffer
yading@11 194 * @param print_prefix used to store whether the prefix must be printed;
yading@11 195 * must point to a persistent integer initially set to 1
yading@11 196 */
yading@11 197 void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl,
yading@11 198 char *line, int line_size, int *print_prefix);
yading@11 199
yading@11 200 /**
yading@11 201 * av_dlog macros
yading@11 202 * Useful to print debug messages that shouldn't get compiled in normally.
yading@11 203 */
yading@11 204
yading@11 205 #ifdef DEBUG
yading@11 206 # define av_dlog(pctx, ...) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__)
yading@11 207 #else
yading@11 208 # define av_dlog(pctx, ...) do { if (0) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__); } while (0)
yading@11 209 #endif
yading@11 210
yading@11 211 /**
yading@11 212 * Skip repeated messages, this requires the user app to use av_log() instead of
yading@11 213 * (f)printf as the 2 would otherwise interfere and lead to
yading@11 214 * "Last message repeated x times" messages below (f)printf messages with some
yading@11 215 * bad luck.
yading@11 216 * Also to receive the last, "last repeated" line if any, the user app must
yading@11 217 * call av_log(NULL, AV_LOG_QUIET, "%s", ""); at the end
yading@11 218 */
yading@11 219 #define AV_LOG_SKIP_REPEATED 1
yading@11 220 void av_log_set_flags(int arg);
yading@11 221
yading@11 222 #endif /* AVUTIL_LOG_H */