2006-09-10 17:02:42 +03:00
|
|
|
/*
|
|
|
|
* copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
|
|
|
|
*
|
2006-10-07 18:30:46 +03:00
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
2006-09-10 17:02:42 +03:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2006-10-07 18:30:46 +03:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2006-09-10 17:02:42 +03:00
|
|
|
*
|
2006-10-07 18:30:46 +03:00
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
2006-09-10 17:02:42 +03:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2006-10-07 18:30:46 +03:00
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
2006-09-10 17:02:42 +03:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2008-08-31 10:39:47 +03:00
|
|
|
#ifndef AVUTIL_LOG_H
|
|
|
|
#define AVUTIL_LOG_H
|
2006-07-18 14:00:55 +03:00
|
|
|
|
|
|
|
#include <stdarg.h>
|
2011-06-17 10:31:11 +03:00
|
|
|
#include "attributes.h"
|
2021-07-23 10:50:16 +02:00
|
|
|
#include "version.h"
|
2006-07-18 14:00:55 +03:00
|
|
|
|
2012-05-28 13:49:23 +03:00
|
|
|
typedef enum {
|
|
|
|
AV_CLASS_CATEGORY_NA = 0,
|
|
|
|
AV_CLASS_CATEGORY_INPUT,
|
|
|
|
AV_CLASS_CATEGORY_OUTPUT,
|
|
|
|
AV_CLASS_CATEGORY_MUXER,
|
|
|
|
AV_CLASS_CATEGORY_DEMUXER,
|
|
|
|
AV_CLASS_CATEGORY_ENCODER,
|
|
|
|
AV_CLASS_CATEGORY_DECODER,
|
|
|
|
AV_CLASS_CATEGORY_FILTER,
|
|
|
|
AV_CLASS_CATEGORY_BITSTREAM_FILTER,
|
2012-07-04 20:22:16 +03:00
|
|
|
AV_CLASS_CATEGORY_SWSCALER,
|
|
|
|
AV_CLASS_CATEGORY_SWRESAMPLER,
|
2014-02-23 01:32:45 +03:00
|
|
|
AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT = 40,
|
|
|
|
AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT,
|
|
|
|
AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT,
|
|
|
|
AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT,
|
|
|
|
AV_CLASS_CATEGORY_DEVICE_OUTPUT,
|
|
|
|
AV_CLASS_CATEGORY_DEVICE_INPUT,
|
2016-10-20 08:48:25 +02:00
|
|
|
AV_CLASS_CATEGORY_NB ///< not part of ABI/API
|
2012-05-28 13:49:23 +03:00
|
|
|
}AVClassCategory;
|
|
|
|
|
2014-08-07 02:58:56 +03:00
|
|
|
#define AV_IS_INPUT_DEVICE(category) \
|
|
|
|
(((category) == AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT) || \
|
|
|
|
((category) == AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT) || \
|
|
|
|
((category) == AV_CLASS_CATEGORY_DEVICE_INPUT))
|
|
|
|
|
|
|
|
#define AV_IS_OUTPUT_DEVICE(category) \
|
|
|
|
(((category) == AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT) || \
|
|
|
|
((category) == AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT) || \
|
|
|
|
((category) == AV_CLASS_CATEGORY_DEVICE_OUTPUT))
|
|
|
|
|
2012-11-25 19:10:09 +03:00
|
|
|
struct AVOptionRanges;
|
|
|
|
|
2006-07-18 14:00:55 +03:00
|
|
|
/**
|
2010-06-30 18:38:06 +03:00
|
|
|
* Describe the class of an AVClass context structure. That is an
|
2008-04-24 13:13:38 +03:00
|
|
|
* arbitrary struct of which the first field is a pointer to an
|
|
|
|
* AVClass struct (e.g. AVCodecContext, AVFormatContext etc.).
|
2006-07-18 14:00:55 +03:00
|
|
|
*/
|
2011-10-12 23:30:56 +03:00
|
|
|
typedef struct AVClass {
|
2008-04-24 13:13:38 +03:00
|
|
|
/**
|
2008-05-06 11:41:13 +03:00
|
|
|
* The name of the class; usually it is the same name as the
|
2008-05-06 11:03:30 +03:00
|
|
|
* context structure type to which the AVClass is associated.
|
2008-04-24 13:13:38 +03:00
|
|
|
*/
|
2006-07-18 14:00:55 +03:00
|
|
|
const char* class_name;
|
2008-04-24 13:13:38 +03:00
|
|
|
|
|
|
|
/**
|
2009-01-29 01:03:17 +02:00
|
|
|
* A pointer to a function which returns the name of a context
|
2009-06-06 12:35:15 +03:00
|
|
|
* instance ctx associated with the class.
|
2008-04-24 13:13:38 +03:00
|
|
|
*/
|
|
|
|
const char* (*item_name)(void* ctx);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* a pointer to the first option specified in the class if any or NULL
|
|
|
|
*
|
|
|
|
* @see av_set_default_options()
|
|
|
|
*/
|
2006-11-16 02:29:15 +02:00
|
|
|
const struct AVOption *option;
|
2010-04-28 23:00:23 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* LIBAVUTIL_VERSION with which this structure was created.
|
2010-04-28 23:08:02 +03:00
|
|
|
* This is used to allow fields to be added without requiring major
|
2010-04-28 23:00:23 +03:00
|
|
|
* version bumps everywhere.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int version;
|
2010-05-08 23:41:20 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Offset in the structure where log_level_offset is stored.
|
|
|
|
* 0 means there is no such variable
|
|
|
|
*/
|
|
|
|
int log_level_offset_offset;
|
2010-05-20 01:50:39 +03:00
|
|
|
|
|
|
|
/**
|
2012-12-07 18:07:51 +03:00
|
|
|
* Offset in the structure where a pointer to the parent context for
|
|
|
|
* logging is stored. For example a decoder could pass its AVCodecContext
|
|
|
|
* to eval as such a parent context, which an av_log() implementation
|
|
|
|
* could then leverage to display the parent context.
|
|
|
|
* The offset can be NULL.
|
2010-05-20 01:50:39 +03:00
|
|
|
*/
|
|
|
|
int parent_log_context_offset;
|
2011-05-22 14:25:19 +03:00
|
|
|
|
2012-05-28 13:49:23 +03:00
|
|
|
/**
|
|
|
|
* Category used for visualization (like color)
|
2012-06-03 23:39:54 +03:00
|
|
|
* This is only set if the category is equal for all objects using this class.
|
2012-05-28 13:49:23 +03:00
|
|
|
* available since version (51 << 16 | 56 << 8 | 100)
|
|
|
|
*/
|
|
|
|
AVClassCategory category;
|
2012-06-03 23:39:54 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback to return the category.
|
|
|
|
* available since version (51 << 16 | 59 << 8 | 100)
|
|
|
|
*/
|
|
|
|
AVClassCategory (*get_category)(void* ctx);
|
2012-11-25 19:10:09 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback to return the supported/allowed ranges.
|
|
|
|
* available since version (52.12)
|
|
|
|
*/
|
|
|
|
int (*query_ranges)(struct AVOptionRanges **, void *obj, const char *key, int flags);
|
2020-05-27 15:21:30 +02:00
|
|
|
|
2021-08-04 18:25:08 +02:00
|
|
|
/**
|
|
|
|
* Return next AVOptions-enabled child or NULL
|
|
|
|
*/
|
|
|
|
void* (*child_next)(void *obj, void *prev);
|
|
|
|
|
2020-05-27 15:21:30 +02:00
|
|
|
/**
|
|
|
|
* Iterate over the AVClasses corresponding to potential AVOptions-enabled
|
|
|
|
* children.
|
|
|
|
*
|
|
|
|
* @param iter pointer to opaque iteration state. The caller must initialize
|
|
|
|
* *iter to NULL before the first call.
|
|
|
|
* @return AVClass for the next AVOptions-enabled child or NULL if there are
|
|
|
|
* no more such children.
|
|
|
|
*
|
|
|
|
* @note The difference between child_next and this is that child_next
|
|
|
|
* iterates over _already existing_ objects, while child_class_iterate
|
|
|
|
* iterates over _all possible_ children.
|
|
|
|
*/
|
|
|
|
const struct AVClass* (*child_class_iterate)(void **iter);
|
2009-07-12 14:30:42 +03:00
|
|
|
} AVClass;
|
2006-07-18 14:00:55 +03:00
|
|
|
|
2013-09-18 16:27:52 +03:00
|
|
|
/**
|
|
|
|
* @addtogroup lavu_log
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @defgroup lavu_log_constants Logging Constants
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
2006-07-18 14:00:55 +03:00
|
|
|
|
2013-09-18 16:27:52 +03:00
|
|
|
/**
|
|
|
|
* Print no output.
|
|
|
|
*/
|
2007-01-21 22:47:10 +02:00
|
|
|
#define AV_LOG_QUIET -8
|
|
|
|
|
|
|
|
/**
|
2009-01-29 01:03:17 +02:00
|
|
|
* Something went really wrong and we will crash now.
|
2007-01-21 22:47:10 +02:00
|
|
|
*/
|
|
|
|
#define AV_LOG_PANIC 0
|
|
|
|
|
|
|
|
/**
|
2009-01-29 01:16:49 +02:00
|
|
|
* Something went wrong and recovery is not possible.
|
|
|
|
* For example, no header was found for a format which depends
|
|
|
|
* on headers or an illegal combination of parameters is used.
|
2007-01-21 22:47:10 +02:00
|
|
|
*/
|
|
|
|
#define AV_LOG_FATAL 8
|
|
|
|
|
|
|
|
/**
|
2009-01-29 01:16:49 +02:00
|
|
|
* Something went wrong and cannot losslessly be recovered.
|
|
|
|
* However, not all future data is affected.
|
2007-01-21 22:47:10 +02:00
|
|
|
*/
|
|
|
|
#define AV_LOG_ERROR 16
|
|
|
|
|
|
|
|
/**
|
2009-01-29 01:16:49 +02:00
|
|
|
* Something somehow does not look correct. This may or may not
|
|
|
|
* lead to problems. An example would be the use of '-vstrict -2'.
|
2007-01-21 22:47:10 +02:00
|
|
|
*/
|
|
|
|
#define AV_LOG_WARNING 24
|
|
|
|
|
2013-09-18 16:27:52 +03:00
|
|
|
/**
|
|
|
|
* Standard information.
|
|
|
|
*/
|
2007-01-21 22:47:10 +02:00
|
|
|
#define AV_LOG_INFO 32
|
2013-09-18 16:27:52 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Detailed information.
|
|
|
|
*/
|
2007-01-21 22:47:10 +02:00
|
|
|
#define AV_LOG_VERBOSE 40
|
|
|
|
|
|
|
|
/**
|
2009-01-29 01:03:17 +02:00
|
|
|
* Stuff which is only useful for libav* developers.
|
2007-01-21 22:47:10 +02:00
|
|
|
*/
|
|
|
|
#define AV_LOG_DEBUG 48
|
2006-07-18 14:00:55 +03:00
|
|
|
|
2015-03-16 10:57:34 +02:00
|
|
|
/**
|
|
|
|
* Extremely verbose debugging, useful for libav* development.
|
|
|
|
*/
|
|
|
|
#define AV_LOG_TRACE 56
|
|
|
|
|
2015-06-26 10:17:22 +02:00
|
|
|
#define AV_LOG_MAX_OFFSET (AV_LOG_TRACE - AV_LOG_QUIET)
|
|
|
|
|
2013-04-26 16:12:05 +03:00
|
|
|
/**
|
2014-04-03 16:51:48 +03:00
|
|
|
* @}
|
2013-04-26 16:12:05 +03:00
|
|
|
*/
|
|
|
|
|
2013-09-18 16:27:52 +03:00
|
|
|
/**
|
2014-04-03 16:51:48 +03:00
|
|
|
* Sets additional colors for extended debugging sessions.
|
|
|
|
* @code
|
|
|
|
av_log(ctx, AV_LOG_DEBUG|AV_LOG_C(134), "Message in purple\n");
|
|
|
|
@endcode
|
|
|
|
* Requires 256color terminal support. Uses outside debugging is not
|
|
|
|
* recommended.
|
2013-09-18 16:27:52 +03:00
|
|
|
*/
|
2015-02-17 01:04:22 +02:00
|
|
|
#define AV_LOG_C(x) ((x) << 8)
|
2013-09-18 16:27:52 +03:00
|
|
|
|
2007-03-05 01:04:49 +02:00
|
|
|
/**
|
2010-06-30 18:38:06 +03:00
|
|
|
* Send the specified message to the log if the level is less than or equal
|
2009-01-29 01:03:17 +02:00
|
|
|
* to the current av_log_level. By default, all logging messages are sent to
|
2013-09-18 16:27:52 +03:00
|
|
|
* stderr. This behavior can be altered by setting a different logging callback
|
2007-03-05 01:04:49 +02:00
|
|
|
* function.
|
2013-09-18 16:27:52 +03:00
|
|
|
* @see av_log_set_callback
|
2007-03-05 01:04:49 +02:00
|
|
|
*
|
|
|
|
* @param avcl A pointer to an arbitrary struct of which the first field is a
|
2015-04-23 14:27:37 +02:00
|
|
|
* pointer to an AVClass struct or NULL if general log.
|
2013-09-18 16:27:52 +03:00
|
|
|
* @param level The importance level of the message expressed using a @ref
|
|
|
|
* lavu_log_constants "Logging Constant".
|
2007-03-05 01:04:49 +02:00
|
|
|
* @param fmt The format string (printf-compatible) that specifies how
|
2013-09-18 16:27:52 +03:00
|
|
|
* subsequent arguments are converted to output.
|
2007-03-05 01:04:49 +02:00
|
|
|
*/
|
2011-06-17 10:31:11 +03:00
|
|
|
void av_log(void *avcl, int level, const char *fmt, ...) av_printf_format(3, 4);
|
2006-07-18 14:00:55 +03:00
|
|
|
|
2020-01-16 17:34:07 +02:00
|
|
|
/**
|
|
|
|
* Send the specified message to the log once with the initial_level and then with
|
|
|
|
* the subsequent_level. By default, all logging messages are sent to
|
|
|
|
* stderr. This behavior can be altered by setting a different logging callback
|
|
|
|
* function.
|
|
|
|
* @see av_log
|
|
|
|
*
|
|
|
|
* @param avcl A pointer to an arbitrary struct of which the first field is a
|
|
|
|
* pointer to an AVClass struct or NULL if general log.
|
|
|
|
* @param initial_level importance level of the message expressed using a @ref
|
|
|
|
* lavu_log_constants "Logging Constant" for the first occurance.
|
|
|
|
* @param subsequent_level importance level of the message expressed using a @ref
|
|
|
|
* lavu_log_constants "Logging Constant" after the first occurance.
|
|
|
|
* @param fmt The format string (printf-compatible) that specifies how
|
|
|
|
* subsequent arguments are converted to output.
|
|
|
|
* @param state a variable to keep trak of if a message has already been printed
|
|
|
|
* this must be initialized to 0 before the first use. The same state
|
|
|
|
* must not be accessed by 2 Threads simultaneously.
|
|
|
|
*/
|
|
|
|
void av_log_once(void* avcl, int initial_level, int subsequent_level, int *state, const char *fmt, ...) av_printf_format(5, 6);
|
|
|
|
|
2013-09-18 16:27:52 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Send the specified message to the log if the level is less than or equal
|
|
|
|
* to the current av_log_level. By default, all logging messages are sent to
|
|
|
|
* stderr. This behavior can be altered by setting a different logging callback
|
|
|
|
* function.
|
|
|
|
* @see av_log_set_callback
|
|
|
|
*
|
|
|
|
* @param avcl A pointer to an arbitrary struct of which the first field is a
|
|
|
|
* pointer to an AVClass struct.
|
|
|
|
* @param level The importance level of the message expressed using a @ref
|
|
|
|
* lavu_log_constants "Logging Constant".
|
|
|
|
* @param fmt The format string (printf-compatible) that specifies how
|
|
|
|
* subsequent arguments are converted to output.
|
|
|
|
* @param vl The arguments referenced by the format string.
|
|
|
|
*/
|
|
|
|
void av_vlog(void *avcl, int level, const char *fmt, va_list vl);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the current log level
|
|
|
|
*
|
|
|
|
* @see lavu_log_constants
|
|
|
|
*
|
|
|
|
* @return Current log level
|
|
|
|
*/
|
2008-04-11 17:18:33 +03:00
|
|
|
int av_log_get_level(void);
|
2013-09-18 16:27:52 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the log level
|
|
|
|
*
|
|
|
|
* @see lavu_log_constants
|
|
|
|
*
|
|
|
|
* @param level Logging level
|
|
|
|
*/
|
|
|
|
void av_log_set_level(int level);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the logging callback
|
|
|
|
*
|
2013-10-17 02:40:19 +03:00
|
|
|
* @note The callback must be thread safe, even if the application does not use
|
|
|
|
* threads itself as some codecs are multithreaded.
|
|
|
|
*
|
2013-09-18 16:27:52 +03:00
|
|
|
* @see av_log_default_callback
|
|
|
|
*
|
|
|
|
* @param callback A logging function with a compatible signature.
|
|
|
|
*/
|
|
|
|
void av_log_set_callback(void (*callback)(void*, int, const char*, va_list));
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Default logging callback
|
|
|
|
*
|
|
|
|
* It prints the message to stderr, optionally colorizing it.
|
|
|
|
*
|
|
|
|
* @param avcl A pointer to an arbitrary struct of which the first field is a
|
|
|
|
* pointer to an AVClass struct.
|
|
|
|
* @param level The importance level of the message expressed using a @ref
|
|
|
|
* lavu_log_constants "Logging Constant".
|
|
|
|
* @param fmt The format string (printf-compatible) that specifies how
|
|
|
|
* subsequent arguments are converted to output.
|
2014-02-12 00:15:06 +03:00
|
|
|
* @param vl The arguments referenced by the format string.
|
2013-09-18 16:27:52 +03:00
|
|
|
*/
|
2014-02-12 00:15:06 +03:00
|
|
|
void av_log_default_callback(void *avcl, int level, const char *fmt,
|
|
|
|
va_list vl);
|
2013-09-18 16:27:52 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the context name
|
|
|
|
*
|
|
|
|
* @param ctx The AVClass context
|
|
|
|
*
|
|
|
|
* @return The AVClass class_name
|
|
|
|
*/
|
2010-05-20 01:45:04 +03:00
|
|
|
const char* av_default_item_name(void* ctx);
|
2012-06-03 23:39:54 +03:00
|
|
|
AVClassCategory av_default_get_category(void *ptr);
|
2006-07-18 14:00:55 +03:00
|
|
|
|
2011-12-08 15:54:05 +03:00
|
|
|
/**
|
|
|
|
* Format a line of log the same way as the default callback.
|
2015-06-13 21:34:40 +02:00
|
|
|
* @param line buffer to receive the formatted line
|
2011-12-08 15:54:05 +03:00
|
|
|
* @param line_size size of the buffer
|
|
|
|
* @param print_prefix used to store whether the prefix must be printed;
|
|
|
|
* must point to a persistent integer initially set to 1
|
|
|
|
*/
|
|
|
|
void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl,
|
|
|
|
char *line, int line_size, int *print_prefix);
|
|
|
|
|
2016-04-27 08:15:17 +02:00
|
|
|
/**
|
|
|
|
* Format a line of log the same way as the default callback.
|
|
|
|
* @param line buffer to receive the formatted line;
|
|
|
|
* may be NULL if line_size is 0
|
|
|
|
* @param line_size size of the buffer; at most line_size-1 characters will
|
|
|
|
* be written to the buffer, plus one null terminator
|
|
|
|
* @param print_prefix used to store whether the prefix must be printed;
|
|
|
|
* must point to a persistent integer initially set to 1
|
2016-04-27 23:21:08 +02:00
|
|
|
* @return Returns a negative value if an error occurred, otherwise returns
|
2016-04-27 08:15:17 +02:00
|
|
|
* the number of characters that would have been written for a
|
|
|
|
* sufficiently large buffer, not including the terminating null
|
|
|
|
* character. If the return value is not less than line_size, it means
|
|
|
|
* that the log message was truncated to fit the buffer.
|
|
|
|
*/
|
|
|
|
int av_log_format_line2(void *ptr, int level, const char *fmt, va_list vl,
|
|
|
|
char *line, int line_size, int *print_prefix);
|
|
|
|
|
2010-09-24 18:37:01 +03:00
|
|
|
/**
|
|
|
|
* Skip repeated messages, this requires the user app to use av_log() instead of
|
|
|
|
* (f)printf as the 2 would otherwise interfere and lead to
|
|
|
|
* "Last message repeated x times" messages below (f)printf messages with some
|
|
|
|
* bad luck.
|
|
|
|
* Also to receive the last, "last repeated" line if any, the user app must
|
2011-06-15 12:24:00 +03:00
|
|
|
* call av_log(NULL, AV_LOG_QUIET, "%s", ""); at the end
|
2010-09-24 18:37:01 +03:00
|
|
|
*/
|
|
|
|
#define AV_LOG_SKIP_REPEATED 1
|
2014-02-28 03:36:09 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Include the log severity in messages originating from codecs.
|
|
|
|
*
|
|
|
|
* Results in messages such as:
|
|
|
|
* [rawvideo @ 0xDEADBEEF] [error] encode did not produce valid pts
|
|
|
|
*/
|
|
|
|
#define AV_LOG_PRINT_LEVEL 2
|
|
|
|
|
2010-09-24 18:37:01 +03:00
|
|
|
void av_log_set_flags(int arg);
|
2014-03-20 05:53:22 +03:00
|
|
|
int av_log_get_flags(void);
|
2010-09-24 18:37:01 +03:00
|
|
|
|
2013-09-18 16:27:52 +03:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2008-08-31 10:39:47 +03:00
|
|
|
#endif /* AVUTIL_LOG_H */
|