Commit fbb8468f authored by Stefano Sabatini's avatar Stefano Sabatini

ffprobe: prefer lowercase section names over uppercase ones

This is consistent with chapter names. The default writer section names
are converted to uppercase for keeping backward compatibility.
parent 92e36ee5
...@@ -336,16 +336,30 @@ static void default_print_chapter_header(WriterContext *wctx, const char *chapte ...@@ -336,16 +336,30 @@ static void default_print_chapter_header(WriterContext *wctx, const char *chapte
printf("\n"); printf("\n");
} }
/* lame uppercasing routine, assumes the string is lower case ASCII */
static inline char *upcase_string(char *dst, size_t dst_size, const char *src)
{
int i;
for (i = 0; src[i] && i < dst_size-1; i++)
dst[i] = src[i]-32;
dst[i] = 0;
return dst;
}
static void default_print_section_header(WriterContext *wctx, const char *section) static void default_print_section_header(WriterContext *wctx, const char *section)
{ {
char buf[32];
if (wctx->nb_section) if (wctx->nb_section)
printf("\n"); printf("\n");
printf("[%s]\n", section); printf("[%s]\n", upcase_string(buf, sizeof(buf), section));
} }
static void default_print_section_footer(WriterContext *wctx, const char *section) static void default_print_section_footer(WriterContext *wctx, const char *section)
{ {
printf("[/%s]", section); char buf[32];
printf("[/%s]", upcase_string(buf, sizeof(buf), section));
} }
static void default_print_str(WriterContext *wctx, const char *key, const char *value) static void default_print_str(WriterContext *wctx, const char *key, const char *value)
...@@ -550,7 +564,7 @@ static void show_packet(WriterContext *w, AVFormatContext *fmt_ctx, AVPacket *pk ...@@ -550,7 +564,7 @@ static void show_packet(WriterContext *w, AVFormatContext *fmt_ctx, AVPacket *pk
AVStream *st = fmt_ctx->streams[pkt->stream_index]; AVStream *st = fmt_ctx->streams[pkt->stream_index];
struct print_buf pbuf = {.s = NULL}; struct print_buf pbuf = {.s = NULL};
print_section_header("PACKET"); print_section_header("packet");
print_str("codec_type", av_x_if_null(av_get_media_type_string(st->codec->codec_type), "unknown")); print_str("codec_type", av_x_if_null(av_get_media_type_string(st->codec->codec_type), "unknown"));
print_int("stream_index", pkt->stream_index); print_int("stream_index", pkt->stream_index);
print_str("pts", ts_value_string (val_str, sizeof(val_str), pkt->pts)); print_str("pts", ts_value_string (val_str, sizeof(val_str), pkt->pts));
...@@ -562,7 +576,7 @@ static void show_packet(WriterContext *w, AVFormatContext *fmt_ctx, AVPacket *pk ...@@ -562,7 +576,7 @@ static void show_packet(WriterContext *w, AVFormatContext *fmt_ctx, AVPacket *pk
print_str("size", value_string (val_str, sizeof(val_str), pkt->size, unit_byte_str)); print_str("size", value_string (val_str, sizeof(val_str), pkt->size, unit_byte_str));
print_fmt("pos", "%"PRId64, pkt->pos); print_fmt("pos", "%"PRId64, pkt->pos);
print_fmt("flags", "%c", pkt->flags & AV_PKT_FLAG_KEY ? 'K' : '_'); print_fmt("flags", "%c", pkt->flags & AV_PKT_FLAG_KEY ? 'K' : '_');
print_section_footer("PACKET"); print_section_footer("packet");
av_free(pbuf.s); av_free(pbuf.s);
fflush(stdout); fflush(stdout);
...@@ -588,7 +602,7 @@ static void show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_i ...@@ -588,7 +602,7 @@ static void show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_i
AVRational display_aspect_ratio; AVRational display_aspect_ratio;
struct print_buf pbuf = {.s = NULL}; struct print_buf pbuf = {.s = NULL};
print_section_header("STREAM"); print_section_header("stream");
print_int("index", stream->index); print_int("index", stream->index);
...@@ -651,7 +665,7 @@ static void show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_i ...@@ -651,7 +665,7 @@ static void show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_i
show_tags(stream->metadata); show_tags(stream->metadata);
print_section_footer("STREAM"); print_section_footer("stream");
av_free(pbuf.s); av_free(pbuf.s);
fflush(stdout); fflush(stdout);
} }
...@@ -668,7 +682,7 @@ static void show_format(WriterContext *w, AVFormatContext *fmt_ctx) ...@@ -668,7 +682,7 @@ static void show_format(WriterContext *w, AVFormatContext *fmt_ctx)
char val_str[128]; char val_str[128];
struct print_buf pbuf = {.s = NULL}; struct print_buf pbuf = {.s = NULL};
print_section_header("FORMAT"); print_section_header("format");
print_str("filename", fmt_ctx->filename); print_str("filename", fmt_ctx->filename);
print_int("nb_streams", fmt_ctx->nb_streams); print_int("nb_streams", fmt_ctx->nb_streams);
print_str("format_name", fmt_ctx->iformat->name); print_str("format_name", fmt_ctx->iformat->name);
...@@ -678,7 +692,7 @@ static void show_format(WriterContext *w, AVFormatContext *fmt_ctx) ...@@ -678,7 +692,7 @@ static void show_format(WriterContext *w, AVFormatContext *fmt_ctx)
print_str("size", value_string(val_str, sizeof(val_str), fmt_ctx->file_size, unit_byte_str)); print_str("size", value_string(val_str, sizeof(val_str), fmt_ctx->file_size, unit_byte_str));
print_str("bit_rate", value_string(val_str, sizeof(val_str), fmt_ctx->bit_rate, unit_bit_per_second_str)); print_str("bit_rate", value_string(val_str, sizeof(val_str), fmt_ctx->bit_rate, unit_bit_per_second_str));
show_tags(fmt_ctx->metadata); show_tags(fmt_ctx->metadata);
print_section_footer("FORMAT"); print_section_footer("format");
av_free(pbuf.s); av_free(pbuf.s);
fflush(stdout); fflush(stdout);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment