summaryrefslogtreecommitdiffstats
path: root/ffprobe.c
diff options
context:
space:
mode:
authorStefano Sabatini <stefasab@gmail.com>2012-05-27 00:59:28 +0200
committerStefano Sabatini <stefasab@gmail.com>2012-05-29 01:02:50 +0200
commitfa6cb2fdffe59fdd38bf127ff82d09a4fcf46b76 (patch)
tree1627f7fa4d43fa27a6f9cac7a92ae29fb4f5e237 /ffprobe.c
parentc365cdf2028aaefd92f44b0924596f35d165ebda (diff)
downloadffmpeg-streaming-fa6cb2fdffe59fdd38bf127ff82d09a4fcf46b76.zip
ffmpeg-streaming-fa6cb2fdffe59fdd38bf127ff82d09a4fcf46b76.tar.gz
ffprobe: add multiple_sections field to WriterContext
Move the field "multiple_entries" from the JSON writer private context to WriterContext, and rename it "multiple_sections". This allows to factorize the code with the pending INI format patch.
Diffstat (limited to 'ffprobe.c')
-rw-r--r--ffprobe.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/ffprobe.c b/ffprobe.c
index 15e761e..daea512 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -179,6 +179,7 @@ struct WriterContext {
unsigned int nb_section; ///< number of the section printed in the given section sequence, starting at 0
unsigned int nb_chapter; ///< number of the chapter, starting at 0
+ int multiple_sections; ///< tells if the current chapter can contain multiple sections
int is_fmt_chapter; ///< tells if the current chapter is "format", required by the print_format_entry option
};
@@ -255,6 +256,9 @@ static inline void writer_print_chapter_header(WriterContext *wctx,
wctx->writer->print_chapter_header(wctx, chapter);
wctx->nb_section = 0;
+ wctx->multiple_sections = !strcmp(chapter, "packets") || !strcmp(chapter, "frames" ) ||
+ !strcmp(chapter, "packets_and_frames") ||
+ !strcmp(chapter, "streams") || !strcmp(chapter, "library_versions");
wctx->is_fmt_chapter = !strcmp(chapter, "format");
}
@@ -713,7 +717,6 @@ static const Writer csv_writer = {
typedef struct {
const AVClass *class;
- int multiple_entries; ///< tells if the given chapter requires multiple entries
int print_packets_and_frames;
int indent_level;
int compact;
@@ -804,10 +807,7 @@ static void json_print_chapter_header(WriterContext *wctx, const char *chapter)
if (wctx->nb_chapter)
printf(",");
printf("\n");
- json->multiple_entries = !strcmp(chapter, "packets") || !strcmp(chapter, "frames" ) ||
- !strcmp(chapter, "packets_and_frames") ||
- !strcmp(chapter, "streams") || !strcmp(chapter, "library_versions");
- if (json->multiple_entries) {
+ if (wctx->multiple_sections) {
JSON_INDENT();
av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
printf("\"%s\": [\n", json_escape_str(&buf, chapter, wctx));
@@ -821,7 +821,7 @@ static void json_print_chapter_footer(WriterContext *wctx, const char *chapter)
{
JSONContext *json = wctx->priv;
- if (json->multiple_entries) {
+ if (wctx->multiple_sections) {
printf("\n");
json->indent_level--;
JSON_INDENT();
@@ -836,7 +836,7 @@ static void json_print_section_header(WriterContext *wctx, const char *section)
if (wctx->nb_section)
printf(",\n");
JSON_INDENT();
- if (!json->multiple_entries)
+ if (!wctx->multiple_sections)
printf("\"%s\": ", section);
printf("{%s", json->item_start_end);
json->indent_level++;
OpenPOWER on IntegriCloud