[FFmpeg-devel] [PATCH] Allow window caption to be set for ffplay

Stefano Sabatini stefano.sabatini-lala
Tue Mar 16 22:15:20 CET 2010


On date Tuesday 2010-03-16 11:35:10 +0100, Robert Kr?ger encoded:
> 
> this patch adds an option to set the window caption. Provided this
> is deemed useful, one could argue if a reasonable default for this
> would be the input filename and not "FFplay".
> 
> Regards,
> 
> Robert
> 

> Index: ffplay.c
> ===================================================================
> --- ffplay.c	(revision 22565)
> +++ ffplay.c	(working copy)
> @@ -224,6 +224,7 @@
>  /* options specified by the user */
>  static AVInputFormat *file_iformat;
>  static const char *input_filename;
> +static const char *caption;

You can set here the default value if you choose to go with "FFplay"
(and in this case maybe just program_name is better).

>  static int fs_screen_width;
>  static int fs_screen_height;
>  static int screen_width = 0;
> @@ -993,7 +994,9 @@
>          fprintf(stderr, "SDL: could not set video mode - exiting\n");
>          return -1;
>      }
> -    SDL_WM_SetCaption("FFplay", "FFplay");
> +    if(!caption)
> +        caption  = "FFplay";
> +    SDL_WM_SetCaption(caption, caption);
>  
>      is->width = screen->w;
>      is->height = screen->h;
> @@ -2926,6 +2929,17 @@
>      return 0;
>  }
>  
> +static void opt_caption(const char *text)

Please s/text/arg for consistency.

> +{
> +    if (caption) {
> +        fprintf(stderr, "Argument '%s' provided as caption, but '%s' was already specified.\n",
> +                text, caption);

Not very strong on this but I don't like this check, I don't see why
-caption "foo" -caption "bar" shouldn't be valid.

> +        exit(1);
> +    }
> +    caption = text;
> +}
> +
> +
>  static const OptionDef options[] = {
>  #include "cmdutils_common_opts.h"
>      { "x", HAS_ARG | OPT_FUNC2, {(void*)opt_width}, "force displayed width", "width" },
> @@ -2960,6 +2974,7 @@
>      { "threads", HAS_ARG | OPT_FUNC2 | OPT_EXPERT, {(void*)opt_thread_count}, "thread count", "count" },
>      { "autoexit", OPT_BOOL | OPT_EXPERT, {(void*)&autoexit}, "exit at the end", "" },
>      { "framedrop", OPT_BOOL | OPT_EXPERT, {(void*)&framedrop}, "drop frames when cpu is too slow", "" },
> +    { "caption", HAS_ARG, {(void*)opt_caption}, "set window caption", "caption" },
>  #if CONFIG_AVFILTER
>      { "vfilters", OPT_STRING | HAS_ARG, {(void*)&vfilters}, "video filters", "filter list" },
>  #endif

And missing ffplay-doc.texi docs (but wait to see if Michael is going
to approve this feature).

Regards.
-- 
FFmpeg = Fancy Fanciful Multimedia Practical Elastic Gargoyle



More information about the ffmpeg-devel mailing list