FFmpeg
Loading...
Searching...
No Matches
avtextformat.h
Go to the documentation of this file.
1/*
2 * Copyright (c) The FFmpeg developers
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#ifndef FFTOOLS_TEXTFORMAT_AVTEXTFORMAT_H
22#define FFTOOLS_TEXTFORMAT_AVTEXTFORMAT_H
23
24#include <stdint.h>
25#include "libavutil/dict.h"
26#include "libavformat/avio.h"
27#include "libavutil/bprint.h"
28#include "libavutil/rational.h"
29#include "libavutil/hash.h"
30#include "avtextwriters.h"
31
32#define SECTION_MAX_NB_CHILDREN 11
33
39
40
41typedef struct AVTextFormatSection {
42 int id; ///< unique id identifying a section
43 const char *name;
44
45#define AV_TEXTFORMAT_SECTION_FLAG_IS_WRAPPER 1 ///< the section only contains other sections, but has no data at its own level
46#define AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY 2 ///< the section contains an array of elements of the same type
47#define AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS 4 ///< the section may contain a variable number of fields with variable keys.
48 /// For these sections the element_name field is mandatory.
49#define AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE 8 ///< the section contains a type to distinguish multiple nested elements
50#define AV_TEXTFORMAT_SECTION_FLAG_NUMBERING_BY_TYPE 16 ///< the items in this array section should be numbered individually by type
51#define AV_TEXTFORMAT_SECTION_FLAG_IS_SHAPE 32 ///< ...
52#define AV_TEXTFORMAT_SECTION_FLAG_HAS_LINKS 64 ///< ...
53#define AV_TEXTFORMAT_SECTION_PRINT_TAGS 128 ///< ...
54#define AV_TEXTFORMAT_SECTION_FLAG_IS_SUBGRAPH 256 ///< ...
55
56 int flags;
57 const int children_ids[SECTION_MAX_NB_CHILDREN + 1]; ///< list of children section IDS, terminated by -1
58 const char *element_name; ///< name of the contained element, if provided
59 const char *unique_name; ///< unique section name, in case the name is ambiguous
60 const char *(*get_type)(const void *data); ///< function returning a type if defined, must be defined when SECTION_FLAG_HAS_TYPE is defined
61 const char *id_key; ///< name of the key to be used as the id
62 const char *src_id_key; ///< name of the key to be used as the source id for diagram connections
63 const char *dest_id_key; ///< name of the key to be used as the target id for diagram connections
64 const char *linktype_key; ///< name of the key to be used as the link type for diagram connections (AVTextFormatLinkType)
66
68
69#define AV_TEXTFORMAT_FLAG_SUPPORTS_OPTIONAL_FIELDS 1
70#define AV_TEXTFORMAT_FLAG_SUPPORTS_MIXED_ARRAY_CONTENT 2
71#define AV_TEXTFORMAT_FLAG_IS_DIAGRAM_FORMATTER 4
72
79
91
96
97typedef struct AVTextFormatter {
98 const AVClass *priv_class; ///< private class of the formatter, if any
99 int priv_size; ///< private size for the formatter context
100 const char *name;
101
102 int (*init) (AVTextFormatContext *tctx);
104
105 void (*print_section_header)(AVTextFormatContext *tctx, const void *data);
107 void (*print_integer) (AVTextFormatContext *tctx, const char *, int64_t);
108 void (*print_string) (AVTextFormatContext *tctx, const char *, const char *);
109 int flags; ///< a combination or AV_TEXTFORMAT__FLAG_*
111
112#define SECTION_MAX_NB_LEVELS 12
113#define SECTION_MAX_NB_SECTIONS 100
114
115typedef struct AVTextFormatOptions {
116 /**
117 * Callback to discard certain elements based upon the key used.
118 * It is called before any element with a key is printed.
119 * If this callback is unset, all elements are printed.
120 *
121 * @retval 1 if the element is supposed to be printed
122 * @retval 0 if the element is supposed to be discarded
123 */
124 int (*is_key_selected)(struct AVTextFormatContext *tctx, const char *key);
132
134 const AVClass *class; ///< class of the formatter
135 const AVTextFormatter *formatter; ///< the AVTextFormatter of which this is an instance
136 AVTextWriterContext *writer; ///< the AVTextWriterContext
137
138 char *name; ///< name of this formatter instance
139 void *priv; ///< private data for use by the filter
140
141 const AVTextFormatSection *sections; ///< array containing all sections
142 int nb_sections; ///< number of sections
143
144 int level; ///< current level, starting from 0
145
146 /** number of the item printed in the given section, starting from 0 */
149
150 /** section per each level */
152 AVBPrint section_pbuf[SECTION_MAX_NB_LEVELS]; ///< generic print buffer dedicated to each section,
153 /// used by various formatters
154
156
158
162};
163
171
172#define AV_TEXTFORMAT_PRINT_STRING_OPTIONAL 1
173#define AV_TEXTFORMAT_PRINT_STRING_VALIDATE 2
174
175int avtext_context_open(AVTextFormatContext **ptctx, const AVTextFormatter *formatter, AVTextWriterContext *writer_context, const char *args,
177
179
180
181void avtext_print_section_header(AVTextFormatContext *tctx, const void *data, int section_id);
182
184
185void avtext_print_integer(AVTextFormatContext *tctx, const char *key, int64_t val, int flags);
186
187int avtext_print_string(AVTextFormatContext *tctx, const char *key, const char *val, int flags);
188
189void avtext_print_unit_integer(AVTextFormatContext *tctx, const char *key, int64_t val, AVTextFormatValueFormat fmt, const char *unit);
190
191void avtext_print_unit_double(AVTextFormatContext *tctx, const char *key, double val, AVTextFormatValueFormat fmt, const char *unit);
192
193void avtext_print_rational(AVTextFormatContext *tctx, const char *key, AVRational q, char sep);
194
195void avtext_print_time(AVTextFormatContext *tctx, const char *key, int64_t ts, const AVRational *time_base, int is_duration);
196
197void avtext_print_ts(AVTextFormatContext *tctx, const char *key, int64_t ts, int is_duration);
198
199void avtext_print_data(AVTextFormatContext *tctx, const char *key, const uint8_t *data, int size);
200
201void avtext_print_data_hash(AVTextFormatContext *tctx, const char *key, const uint8_t *data, int size);
202
204
214
215#endif /* FFTOOLS_TEXTFORMAT_AVTEXTFORMAT_H */
static double val(void *priv, double ch)
Definition aeval.c:77
Buffered I/O operations.
const AVTextFormatter avtextformatter_compact
Definition tf_compact.c:239
void avtext_print_integer(AVTextFormatContext *tctx, const char *key, int64_t val, int flags)
AVTextFormatDataDump
@ AV_TEXTFORMAT_DATADUMP_BASE64
@ AV_TEXTFORMAT_DATADUMP_XXD
#define SECTION_MAX_NB_LEVELS
#define SECTION_MAX_NB_CHILDREN
const AVTextFormatter avtextformatter_ini
Definition tf_ini.c:140
const AVTextFormatter avtextformatter_csv
Definition tf_compact.c:270
#define SECTION_MAX_NB_SECTIONS
void avtext_print_unit_integer(AVTextFormatContext *tctx, const char *key, int64_t val, AVTextFormatValueFormat fmt, const char *unit)
int avtext_context_close(AVTextFormatContext **tctx)
AVTextFormatValueFormat
@ AV_TEXTFORMAT_VALUE_FMT_INT
@ AV_TEXTFORMAT_VALUE_FMT_DOUBLE
@ AV_TEXTFORMAT_VALUE_FMT_DECIBEL
@ AV_TEXTFORMAT_VALUE_FMT_SECOND
@ AV_TEXTFORMAT_VALUE_FMT_BYTE
const AVTextFormatter avtextformatter_default
Definition tf_default.c:128
void avtext_print_unit_double(AVTextFormatContext *tctx, const char *key, double val, AVTextFormatValueFormat fmt, const char *unit)
int avtext_context_open(AVTextFormatContext **ptctx, const AVTextFormatter *formatter, AVTextWriterContext *writer_context, const char *args, const AVTextFormatSection *sections, int nb_sections, AVTextFormatOptions options, char *show_data_hash)
void avtext_print_data(AVTextFormatContext *tctx, const char *key, const uint8_t *data, int size)
int avtext_print_string(AVTextFormatContext *tctx, const char *key, const char *val, int flags)
StringValidation
@ AV_TEXTFORMAT_STRING_VALIDATION_NB
@ AV_TEXTFORMAT_STRING_VALIDATION_FAIL
@ AV_TEXTFORMAT_STRING_VALIDATION_IGNORE
@ AV_TEXTFORMAT_STRING_VALIDATION_REPLACE
AVTextFormatLinkType
@ AV_TEXTFORMAT_LINKTYPE_MANYTOONE
@ AV_TEXTFORMAT_LINKTYPE_ONETOMANY
@ AV_TEXTFORMAT_LINKTYPE_MANYTOMANY
@ AV_TEXTFORMAT_LINKTYPE_BIDIR
@ AV_TEXTFORMAT_LINKTYPE_NONDIR
@ AV_TEXTFORMAT_LINKTYPE_DESTSRC
@ AV_TEXTFORMAT_LINKTYPE_ONETOONE
@ AV_TEXTFORMAT_LINKTYPE_HIDDEN
@ AV_TEXTFORMAT_LINKTYPE_SRCDEST
const AVTextFormatter avtextformatter_mermaid
Definition tf_mermaid.c:650
const AVTextFormatter avtextformatter_json
Definition tf_json.c:202
void avtext_print_time(AVTextFormatContext *tctx, const char *key, int64_t ts, const AVRational *time_base, int is_duration)
void avtext_print_ts(AVTextFormatContext *tctx, const char *key, int64_t ts, int is_duration)
const AVTextFormatter avtextformatter_flat
Definition tf_flat.c:150
const AVTextFormatter avtextformatter_mermaidhtml
Definition tf_mermaid.c:664
void avtext_print_data_hash(AVTextFormatContext *tctx, const char *key, const uint8_t *data, int size)
void avtext_print_rational(AVTextFormatContext *tctx, const char *key, AVRational q, char sep)
void avtext_print_section_header(AVTextFormatContext *tctx, const void *data, int section_id)
void avtext_print_section_footer(AVTextFormatContext *tctx)
const AVTextFormatter * avtext_get_formatter_by_name(const char *name)
const AVTextFormatter avtextformatter_xml
Definition tf_xml.c:202
AVBPrint public header.
#define flags(name, subs,...)
Definition cbs_h264.c:74
long long int64_t
Definition coverity.c:34
Public dictionary API.
const char * key
static char * show_data_hash
Definition ffprobe.c:147
static const AVTextFormatSection sections[]
Definition ffprobe.c:259
Generic hashing API.
const char data[16]
Definition mxf.c:149
const char * name
Definition qsvenc.c:142
Utilities for rational number calculation.
Describe the class of an AVClass context structure.
Definition log.h:76
Rational number (pair of numerator and denominator).
Definition rational.h:58
unsigned int nb_item_type[SECTION_MAX_NB_LEVELS][SECTION_MAX_NB_SECTIONS]
struct AVHashContext * hash
void * priv
private data for use by the filter
const AVTextFormatSection * section[SECTION_MAX_NB_LEVELS]
section per each level
char * name
name of this formatter instance
AVTextFormatOptions opts
char * string_validation_replacement
int level
current level, starting from 0
unsigned int nb_item[SECTION_MAX_NB_LEVELS]
number of the item printed in the given section, starting from 0
unsigned int string_validation_utf8_flags
AVTextWriterContext * writer
the AVTextWriterContext
AVBPrint section_pbuf[SECTION_MAX_NB_LEVELS]
generic print buffer dedicated to each section, used by various formatters
const AVTextFormatSection * sections
array containing all sections
const AVTextFormatter * formatter
the AVTextFormatter of which this is an instance
int nb_sections
number of sections
int(* is_key_selected)(struct AVTextFormatContext *tctx, const char *key)
Callback to discard certain elements based upon the key used.
AVTextFormatDataDump data_dump_format
const char * id_key
name of the key to be used as the id
const char * linktype_key
name of the key to be used as the link type for diagram connections (AVTextFormatLinkType)
const char * src_id_key
name of the key to be used as the source id for diagram connections
const char * element_name
name of the contained element, if provided
const char * name
const char * dest_id_key
name of the key to be used as the target id for diagram connections
const int children_ids[SECTION_MAX_NB_CHILDREN+1]
list of children section IDS, terminated by -1
const char * unique_name
unique section name, in case the name is ambiguous
int id
unique id identifying a section
int(* uninit)(AVTextFormatContext *tctx)
int priv_size
private size for the formatter context
int flags
a combination or AV_TEXTFORMAT__FLAG_*
void(* print_string)(AVTextFormatContext *tctx, const char *, const char *)
void(* print_section_header)(AVTextFormatContext *tctx, const void *data)
const AVClass * priv_class
private class of the formatter, if any
const char * name
void(* print_integer)(AVTextFormatContext *tctx, const char *, int64_t)
void(* print_section_footer)(AVTextFormatContext *tctx)
int(* init)(AVTextFormatContext *tctx)
int size