From: Antonio Ospite Date: Mon, 19 Mar 2012 21:13:04 +0000 (+0100) Subject: examples: add a -l option to am7xxx-play X-Git-Tag: v0.1.0~1^2~11 X-Git-Url: https://git.ao2.it/libam7xxx.git/commitdiff_plain/53ec7b26224b9955fee6f01a44350da29488fb87?ds=inline examples: add a -l option to am7xxx-play Allow setting the verbosity level of log messages. --- diff --git a/examples/am7xxx-play.c b/examples/am7xxx-play.c index f7e069a..a661758 100644 --- a/examples/am7xxx-play.c +++ b/examples/am7xxx-play.c @@ -564,6 +564,7 @@ static void usage(char *name) printf("\t\t\t\t\t1 - JPEG\n"); printf("\t\t\t\t\t2 - NV12\n"); printf("\t-q \t\t\tquality of jpeg sent to the device, between 1 and 100\n"); + printf("\t-l \t\tthe verbosity level of libam7xxx output (0-5)\n"); printf("\t-h \t\t\tthis help message\n"); printf("\n\nEXAMPLES OF USE:\n"); printf("\t%s -f x11grab -i :0.0 -o video_size=800x480\n", name); @@ -585,11 +586,12 @@ int main(int argc, char *argv[]) unsigned int rescale_method = SWS_BICUBIC; unsigned int upscale = 0; unsigned int quality = 95; + int log_level = AM7XXX_LOG_INFO; int format = AM7XXX_IMAGE_FORMAT_JPEG; am7xxx_context *ctx; am7xxx_device *dev; - while ((opt = getopt(argc, argv, "f:i:o:s:uF:q:h")) != -1) { + while ((opt = getopt(argc, argv, "f:i:o:s:uF:q:l:h")) != -1) { switch (opt) { case 'f': input_format_string = strdup(optarg); @@ -662,6 +664,13 @@ int main(int argc, char *argv[]) goto out;; } break; + case 'l': + log_level = atoi(optarg); + if (log_level < AM7XXX_LOG_FATAL || log_level > AM7XXX_LOG_TRACE) { + fprintf(stderr, "Unsupported log level, falling back to AM7XXX_LOG_ERROR\n"); + log_level = AM7XXX_LOG_ERROR; + } + break; case 'h': usage(argv[0]); ret = 0; @@ -713,6 +722,8 @@ int main(int argc, char *argv[]) goto out; } + am7xxx_set_log_level(ctx, log_level); + ret = am7xxx_open_device(ctx, &dev, 0); if (ret < 0) { perror("am7xxx_open_device");