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

Michael Niedermayer michaelni
Wed Mar 17 15:55:41 CET 2010


On Wed, Mar 17, 2010 at 08:01:05AM +0100, Robert Kr?ger wrote:
> 
> On 16.03.2010, at 22:43, M?ns Rullg?rd wrote:
> 
> > Michael Niedermayer <michaelni at gmx.at> writes:
> > 
> >> On Tue, Mar 16, 2010 at 11:35:10AM +0100, Robert Kr?ger wrote:
> >>> 
> >>> 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".
> >> 
> >> a default of the filename + length in hh:mm as well as % of current position
> >> seems even better
> > 
> > Agreed.  At least the filename, maybe not the dynamic information.
> > 
> >> btw, isnt there some standard way to set the caption of a program without
> >> having to modify the program?
> > 
> > xterm uses -title, but not all the usual X tools support this.  Either
> > way, title is the usual term for this, not caption.
> > 
> 
> Attached is a patch with stefano's comments addressed, the default window title set to input filename, documentation (not sure if this is supposed to be part of main or advanced options, your call) and the parameter renamed to window_title to make it foolproof/self-describing but I don't care and will change it if someone sees this differently (btw I had called it caption because SDL seems to call it that but I agree that title is better).
> 
> @michael: I am not aware of a standard way to set the window title and thought SDL was my best bet to ensure it runs on all platforms and scripts using it are as portable across platforms as possible.
> 
> Regards,
> 
> Robert 
> 

>  doc/ffplay-doc.texi |    2 ++
>  ffplay.c            |   12 +++++++++++-
>  2 files changed, 13 insertions(+), 1 deletion(-)
> 8dd03f7ffb99dba997359dad447128325bed5f48  ffplay_window_title.patch
> Index: ffplay.c
> ===================================================================
> --- ffplay.c	(revision 22578)
> +++ 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 *window_title;
>  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(!window_title)
> +        window_title  = input_filename;
> +    SDL_WM_SetCaption(window_title, window_title);
>  
>      is->width = screen->w;
>      is->height = screen->h;

> @@ -2926,6 +2929,12 @@
>      return 0;
>  }
>  
> +static void opt_window_title(const char *arg)
> +{
> +    window_title = arg;
> +}

missing strdup but its code duplication, OPT_STRING does this simpler


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Everything should be made as simple as possible, but not simpler.
-- Albert Einstein
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100317/e8089c69/attachment.pgp>



More information about the ffmpeg-devel mailing list