1 /* 2 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> 3 * 4 * This file is part of FFmpeg. 5 * 6 * FFmpeg is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * FFmpeg is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with FFmpeg; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 */ 20 21 module ffmpeg.libavutil.log; 22 23 import core.stdc.stdio; 24 25 extern (C): 26 import ffmpeg; @nogc nothrow: 27 28 enum AVClassCategory 29 { 30 AV_CLASS_CATEGORY_NA = 0, 31 AV_CLASS_CATEGORY_INPUT = 1, 32 AV_CLASS_CATEGORY_OUTPUT = 2, 33 AV_CLASS_CATEGORY_MUXER = 3, 34 AV_CLASS_CATEGORY_DEMUXER = 4, 35 AV_CLASS_CATEGORY_ENCODER = 5, 36 AV_CLASS_CATEGORY_DECODER = 6, 37 AV_CLASS_CATEGORY_FILTER = 7, 38 AV_CLASS_CATEGORY_BITSTREAM_FILTER = 8, 39 AV_CLASS_CATEGORY_SWSCALER = 9, 40 AV_CLASS_CATEGORY_SWRESAMPLER = 10, 41 AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT = 40, 42 AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT = 41, 43 AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT = 42, 44 AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT = 43, 45 AV_CLASS_CATEGORY_DEVICE_OUTPUT = 44, 46 AV_CLASS_CATEGORY_DEVICE_INPUT = 45, 47 AV_CLASS_CATEGORY_NB = 46 ///< not part of ABI/API 48 } 49 50 extern (D) auto AV_IS_INPUT_DEVICE(T)(auto ref T category) 51 { 52 return (category == AVClassCategory.AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT) || (category == AVClassCategory.AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT) || (category == AVClassCategory.AV_CLASS_CATEGORY_DEVICE_INPUT); 53 } 54 55 extern (D) auto AV_IS_OUTPUT_DEVICE(T)(auto ref T category) 56 { 57 return (category == AVClassCategory.AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT) || (category == AVClassCategory.AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT) || (category == AVClassCategory.AV_CLASS_CATEGORY_DEVICE_OUTPUT); 58 } 59 60 struct AVOptionRanges; 61 62 /** 63 * Describe the class of an AVClass context structure. That is an 64 * arbitrary struct of which the first field is a pointer to an 65 * AVClass struct (e.g. AVCodecContext, AVFormatContext etc.). 66 */ 67 struct AVClass 68 { 69 /** 70 * The name of the class; usually it is the same name as the 71 * context structure type to which the AVClass is associated. 72 */ 73 const(char)* class_name; 74 75 /** 76 * A pointer to a function which returns the name of a context 77 * instance ctx associated with the class. 78 */ 79 const(char)* function (void* ctx) item_name; 80 81 /** 82 * a pointer to the first option specified in the class if any or NULL 83 * 84 * @see av_set_default_options() 85 */ 86 struct AVOption; 87 const(AVOption)* option; 88 89 /** 90 * LIBAVUTIL_VERSION with which this structure was created. 91 * This is used to allow fields to be added without requiring major 92 * version bumps everywhere. 93 */ 94 95 int version_; 96 97 /** 98 * Offset in the structure where log_level_offset is stored. 99 * 0 means there is no such variable 100 */ 101 int log_level_offset_offset; 102 103 /** 104 * Offset in the structure where a pointer to the parent context for 105 * logging is stored. For example a decoder could pass its AVCodecContext 106 * to eval as such a parent context, which an av_log() implementation 107 * could then leverage to display the parent context. 108 * The offset can be NULL. 109 */ 110 int parent_log_context_offset; 111 112 /** 113 * Return next AVOptions-enabled child or NULL 114 */ 115 void* function (void* obj, void* prev) child_next; 116 117 /** 118 * Return an AVClass corresponding to the next potential 119 * AVOptions-enabled child. 120 * 121 * The difference between child_next and this is that 122 * child_next iterates over _already existing_ objects, while 123 * child_class_next iterates over _all possible_ children. 124 */ 125 const(AVClass)* function (const(AVClass)* prev) child_class_next; 126 127 /** 128 * Category used for visualization (like color) 129 * This is only set if the category is equal for all objects using this class. 130 * available since version (51 << 16 | 56 << 8 | 100) 131 */ 132 AVClassCategory category; 133 134 /** 135 * Callback to return the category. 136 * available since version (51 << 16 | 59 << 8 | 100) 137 */ 138 AVClassCategory function (void* ctx) get_category; 139 140 /** 141 * Callback to return the supported/allowed ranges. 142 * available since version (52.12) 143 */ 144 int function (AVOptionRanges**, void* obj, const(char)* key, int flags) query_ranges; 145 } 146 147 /** 148 * @addtogroup lavu_log 149 * 150 * @{ 151 * 152 * @defgroup lavu_log_constants Logging Constants 153 * 154 * @{ 155 */ 156 157 /** 158 * Print no output. 159 */ 160 enum AV_LOG_QUIET = -8; 161 162 /** 163 * Something went really wrong and we will crash now. 164 */ 165 enum AV_LOG_PANIC = 0; 166 167 /** 168 * Something went wrong and recovery is not possible. 169 * For example, no header was found for a format which depends 170 * on headers or an illegal combination of parameters is used. 171 */ 172 enum AV_LOG_FATAL = 8; 173 174 /** 175 * Something went wrong and cannot losslessly be recovered. 176 * However, not all future data is affected. 177 */ 178 enum AV_LOG_ERROR = 16; 179 180 /** 181 * Something somehow does not look correct. This may or may not 182 * lead to problems. An example would be the use of '-vstrict -2'. 183 */ 184 enum AV_LOG_WARNING = 24; 185 186 /** 187 * Standard information. 188 */ 189 enum AV_LOG_INFO = 32; 190 191 /** 192 * Detailed information. 193 */ 194 enum AV_LOG_VERBOSE = 40; 195 196 /** 197 * Stuff which is only useful for libav* developers. 198 */ 199 enum AV_LOG_DEBUG = 48; 200 201 /** 202 * Extremely verbose debugging, useful for libav* development. 203 */ 204 enum AV_LOG_TRACE = 56; 205 206 enum AV_LOG_MAX_OFFSET = AV_LOG_TRACE - AV_LOG_QUIET; 207 208 /** 209 * @} 210 */ 211 212 /** 213 * Sets additional colors for extended debugging sessions. 214 * @code 215 av_log(ctx, AV_LOG_DEBUG|AV_LOG_C(134), "Message in purple\n"); 216 @endcode 217 * Requires 256color terminal support. Uses outside debugging is not 218 * recommended. 219 */ 220 extern (D) auto AV_LOG_C(T)(auto ref T x) 221 { 222 return x << 8; 223 } 224 225 /** 226 * Send the specified message to the log if the level is less than or equal 227 * to the current av_log_level. By default, all logging messages are sent to 228 * stderr. This behavior can be altered by setting a different logging callback 229 * function. 230 * @see av_log_set_callback 231 * 232 * @param avcl A pointer to an arbitrary struct of which the first field is a 233 * pointer to an AVClass struct or NULL if general log. 234 * @param level The importance level of the message expressed using a @ref 235 * lavu_log_constants "Logging Constant". 236 * @param fmt The format string (printf-compatible) that specifies how 237 * subsequent arguments are converted to output. 238 */ 239 void av_log (void* avcl, int level, const(char)* fmt, ...); 240 241 /** 242 * Send the specified message to the log if the level is less than or equal 243 * to the current av_log_level. By default, all logging messages are sent to 244 * stderr. This behavior can be altered by setting a different logging callback 245 * function. 246 * @see av_log_set_callback 247 * 248 * @param avcl A pointer to an arbitrary struct of which the first field is a 249 * pointer to an AVClass struct. 250 * @param level The importance level of the message expressed using a @ref 251 * lavu_log_constants "Logging Constant". 252 * @param fmt The format string (printf-compatible) that specifies how 253 * subsequent arguments are converted to output. 254 * @param vl The arguments referenced by the format string. 255 */ 256 void av_vlog (void* avcl, int level, const(char)* fmt, char* vl); 257 258 /** 259 * Get the current log level 260 * 261 * @see lavu_log_constants 262 * 263 * @return Current log level 264 */ 265 int av_log_get_level (); 266 267 /** 268 * Set the log level 269 * 270 * @see lavu_log_constants 271 * 272 * @param level Logging level 273 */ 274 void av_log_set_level (int level); 275 276 /** 277 * Set the logging callback 278 * 279 * @note The callback must be thread safe, even if the application does not use 280 * threads itself as some codecs are multithreaded. 281 * 282 * @see av_log_default_callback 283 * 284 * @param callback A logging function with a compatible signature. 285 */ 286 void av_log_set_callback (void function (void*, int, const(char)*, char*) callback); 287 288 /** 289 * Default logging callback 290 * 291 * It prints the message to stderr, optionally colorizing it. 292 * 293 * @param avcl A pointer to an arbitrary struct of which the first field is a 294 * pointer to an AVClass struct. 295 * @param level The importance level of the message expressed using a @ref 296 * lavu_log_constants "Logging Constant". 297 * @param fmt The format string (printf-compatible) that specifies how 298 * subsequent arguments are converted to output. 299 * @param vl The arguments referenced by the format string. 300 */ 301 void av_log_default_callback ( 302 void* avcl, 303 int level, 304 const(char)* fmt, 305 char* vl); 306 307 /** 308 * Return the context name 309 * 310 * @param ctx The AVClass context 311 * 312 * @return The AVClass class_name 313 */ 314 const(char)* av_default_item_name (void* ctx); 315 AVClassCategory av_default_get_category (void* ptr); 316 317 /** 318 * Format a line of log the same way as the default callback. 319 * @param line buffer to receive the formatted line 320 * @param line_size size of the buffer 321 * @param print_prefix used to store whether the prefix must be printed; 322 * must point to a persistent integer initially set to 1 323 */ 324 void av_log_format_line ( 325 void* ptr, 326 int level, 327 const(char)* fmt, 328 char* vl, 329 char* line, 330 int line_size, 331 int* print_prefix); 332 333 /** 334 * Format a line of log the same way as the default callback. 335 * @param line buffer to receive the formatted line; 336 * may be NULL if line_size is 0 337 * @param line_size size of the buffer; at most line_size-1 characters will 338 * be written to the buffer, plus one null terminator 339 * @param print_prefix used to store whether the prefix must be printed; 340 * must point to a persistent integer initially set to 1 341 * @return Returns a negative value if an error occurred, otherwise returns 342 * the number of characters that would have been written for a 343 * sufficiently large buffer, not including the terminating null 344 * character. If the return value is not less than line_size, it means 345 * that the log message was truncated to fit the buffer. 346 */ 347 int av_log_format_line2 ( 348 void* ptr, 349 int level, 350 const(char)* fmt, 351 char* vl, 352 char* line, 353 int line_size, 354 int* print_prefix); 355 356 /** 357 * Skip repeated messages, this requires the user app to use av_log() instead of 358 * (f)printf as the 2 would otherwise interfere and lead to 359 * "Last message repeated x times" messages below (f)printf messages with some 360 * bad luck. 361 * Also to receive the last, "last repeated" line if any, the user app must 362 * call av_log(NULL, AV_LOG_QUIET, "%s", ""); at the end 363 */ 364 enum AV_LOG_SKIP_REPEATED = 1; 365 366 /** 367 * Include the log severity in messages originating from codecs. 368 * 369 * Results in messages such as: 370 * [rawvideo @ 0xDEADBEEF] [error] encode did not produce valid pts 371 */ 372 enum AV_LOG_PRINT_LEVEL = 2; 373 374 void av_log_set_flags (int arg); 375 int av_log_get_flags (); 376 377 /** 378 * @} 379 */ 380 381 /* AVUTIL_LOG_H */