|
@@ -0,0 +1,260 @@
|
|
|
+From 1cfa3cc52c34469bbd5199b91089661320fd7ef6 Mon Sep 17 00:00:00 2001
|
|
|
+From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
|
|
|
+Date: Mon, 31 Mar 2014 17:54:01 +0200
|
|
|
+Subject: [PATCH] libvlc: add preliminary code path to modify quartztext
|
|
|
+ variables on-the-fly
|
|
|
+
|
|
|
+---
|
|
|
+ include/vlc/libvlc_media_player.h | 21 +++++++++++++++
|
|
|
+ lib/libvlc.sym | 4 +++
|
|
|
+ lib/media_player.c | 7 +++++
|
|
|
+ lib/video.c | 47 ++++++++++++++++++++++++++++++++++
|
|
|
+ modules/text_renderer/quartztext.c | 52 +++++++++++++++++++++++++++++++++-----
|
|
|
+ 5 files changed, 125 insertions(+), 6 deletions(-)
|
|
|
+
|
|
|
+diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
|
|
|
+index fb91f59..47996f0 100644
|
|
|
+--- a/include/vlc/libvlc_media_player.h
|
|
|
++++ b/include/vlc/libvlc_media_player.h
|
|
|
+@@ -1382,6 +1382,27 @@ LIBVLC_API float libvlc_video_get_adjust_float( libvlc_media_player_t *p_mi,
|
|
|
+ LIBVLC_API void libvlc_video_set_adjust_float( libvlc_media_player_t *p_mi,
|
|
|
+ unsigned option, float value );
|
|
|
+
|
|
|
++/** option values for libvlc_video_{get,set}_adjust_{int,float,bool} */
|
|
|
++enum libvlc_video_textrenderer_option_t {
|
|
|
++ libvlc_textrender_font = 0,
|
|
|
++ libvlc_textrender_fontsize,
|
|
|
++ libvlc_textrender_fontcolor,
|
|
|
++};
|
|
|
++
|
|
|
++LIBVLC_API int libvlc_video_get_textrenderer_int( libvlc_media_player_t *p_mi,
|
|
|
++ unsigned option );
|
|
|
++
|
|
|
++LIBVLC_API void libvlc_video_set_textrenderer_int( libvlc_media_player_t *p_mi,
|
|
|
++ unsigned option, int value );
|
|
|
++
|
|
|
++LIBVLC_API char *libvlc_video_get_textrenderer_string( libvlc_media_player_t *p_mi,
|
|
|
++ unsigned option );
|
|
|
++
|
|
|
++LIBVLC_API void libvlc_video_set_textrenderer_string( libvlc_media_player_t *p_mi,
|
|
|
++ unsigned option,
|
|
|
++ const char *psz_text );
|
|
|
++
|
|
|
++
|
|
|
+ /** @} video */
|
|
|
+
|
|
|
+ /** \defgroup libvlc_audio LibVLC audio controls
|
|
|
+diff --git a/lib/libvlc.sym b/lib/libvlc.sym
|
|
|
+index fdfd164..9ea91db 100644
|
|
|
+--- a/lib/libvlc.sym
|
|
|
++++ b/lib/libvlc.sym
|
|
|
+@@ -216,6 +216,8 @@ libvlc_video_get_spu_count
|
|
|
+ libvlc_video_get_spu_delay
|
|
|
+ libvlc_video_get_spu_description
|
|
|
+ libvlc_video_get_teletext
|
|
|
++libvlc_video_get_text_renderer_int
|
|
|
++libvlc_video_get_text_renderer_string
|
|
|
+ libvlc_video_get_title_description
|
|
|
+ libvlc_video_get_track
|
|
|
+ libvlc_video_get_track_count
|
|
|
+@@ -240,6 +242,8 @@ libvlc_video_set_spu
|
|
|
+ libvlc_video_set_spu_delay
|
|
|
+ libvlc_video_set_subtitle_file
|
|
|
+ libvlc_video_set_teletext
|
|
|
++libvlc_video_set_text_renderer_int
|
|
|
++libvlc_video_set_text_renderer_string
|
|
|
+ libvlc_video_set_track
|
|
|
+ libvlc_video_take_snapshot
|
|
|
+ libvlc_vlm_add_broadcast
|
|
|
+diff --git a/lib/media_player.c b/lib/media_player.c
|
|
|
+index 7027bf4..dfbe64e 100644
|
|
|
+--- a/lib/media_player.c
|
|
|
++++ b/lib/media_player.c
|
|
|
+@@ -464,6 +464,13 @@ libvlc_media_player_new( libvlc_instance_t *instance )
|
|
|
+ var_Create (mp, "saturation", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT);
|
|
|
+ var_Create (mp, "gamma", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT);
|
|
|
+
|
|
|
++#ifdef __APPLE__
|
|
|
++#warning created!
|
|
|
++ var_Create (mp, "quartztext-font", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
|
|
|
++ var_Create (mp, "quartztext-fontsize", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT);
|
|
|
++ var_Create (mp, "quartztext-color", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT);
|
|
|
++#endif
|
|
|
++
|
|
|
+ /* Audio */
|
|
|
+ var_Create (mp, "aout", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
|
|
|
+ var_Create (mp, "mute", VLC_VAR_BOOL);
|
|
|
+diff --git a/lib/video.c b/lib/video.c
|
|
|
+index 43471b9..4eb8de5 100644
|
|
|
+--- a/lib/video.c
|
|
|
++++ b/lib/video.c
|
|
|
+@@ -933,3 +933,50 @@ float libvlc_video_get_adjust_float( libvlc_media_player_t *p_mi,
|
|
|
+ {
|
|
|
+ return get_float( p_mi, "adjust", adjust_option_bynumber(option) );
|
|
|
+ }
|
|
|
++
|
|
|
++
|
|
|
++static const opt_t *
|
|
|
++textrenderer_option_bynumber( unsigned option )
|
|
|
++{
|
|
|
++ static const opt_t optlist[] =
|
|
|
++ {
|
|
|
++ { "quartztext-font", VLC_VAR_STRING },
|
|
|
++ { "quartztext-fontsize", VLC_VAR_INTEGER },
|
|
|
++ { "quartztext-color", VLC_VAR_INTEGER },
|
|
|
++ };
|
|
|
++ enum { num_opts = sizeof(optlist) / sizeof(*optlist) };
|
|
|
++
|
|
|
++ const opt_t *r = option < num_opts ? optlist+option : NULL;
|
|
|
++ if( !r )
|
|
|
++ libvlc_printerr( "Unknown quartztext option" );
|
|
|
++ return r;
|
|
|
++}
|
|
|
++
|
|
|
++/* basic text renderer support */
|
|
|
++
|
|
|
++void libvlc_video_set_textrenderer_int( libvlc_media_player_t *p_mi,
|
|
|
++ unsigned option, int value )
|
|
|
++{
|
|
|
++ set_int( p_mi, "quartztext", textrenderer_option_bynumber(option), value );
|
|
|
++}
|
|
|
++
|
|
|
++
|
|
|
++int libvlc_video_get_textrenderer_int( libvlc_media_player_t *p_mi,
|
|
|
++ unsigned option )
|
|
|
++{
|
|
|
++ return get_int( p_mi, "quartztext", textrenderer_option_bynumber(option) );
|
|
|
++}
|
|
|
++
|
|
|
++
|
|
|
++void libvlc_video_set_textrenderer_string( libvlc_media_player_t *p_mi,
|
|
|
++ unsigned option, const char *psz_value )
|
|
|
++{
|
|
|
++ set_string( p_mi, "quartztext", textrenderer_option_bynumber(option), psz_value );
|
|
|
++}
|
|
|
++
|
|
|
++
|
|
|
++char * libvlc_video_get_textrenderer_string( libvlc_media_player_t *p_mi,
|
|
|
++ unsigned option )
|
|
|
++{
|
|
|
++ return get_string( p_mi, "quartztext", textrenderer_option_bynumber(option) );
|
|
|
++}
|
|
|
+diff --git a/modules/text_renderer/quartztext.c b/modules/text_renderer/quartztext.c
|
|
|
+index 73ed014..a5f73a6 100644
|
|
|
+--- a/modules/text_renderer/quartztext.c
|
|
|
++++ b/modules/text_renderer/quartztext.c
|
|
|
+@@ -65,6 +65,10 @@
|
|
|
+ static int Create (vlc_object_t *);
|
|
|
+ static void Destroy(vlc_object_t *);
|
|
|
+
|
|
|
++static int QuartztextCallback( vlc_object_t *p_this, char const *psz_var,
|
|
|
++ vlc_value_t oldval, vlc_value_t newval,
|
|
|
++ void *p_data );
|
|
|
++
|
|
|
+ static int LoadFontsFromAttachments(filter_t *p_filter);
|
|
|
+
|
|
|
+ static int RenderText(filter_t *, subpicture_region_t *,
|
|
|
+@@ -128,14 +132,17 @@ vlc_module_begin ()
|
|
|
+
|
|
|
+ add_string("quartztext-font", DEFAULT_FONT, FONT_TEXT, FONT_LONGTEXT,
|
|
|
+ false)
|
|
|
+- add_integer("quartztext-rel-fontsize", DEFAULT_REL_FONT_SIZE, FONTSIZER_TEXT,
|
|
|
++ change_safe()
|
|
|
++ add_integer("quartztext-fontsize", DEFAULT_REL_FONT_SIZE, FONTSIZER_TEXT,
|
|
|
+ FONTSIZER_LONGTEXT, false)
|
|
|
++ change_safe()
|
|
|
+ change_integer_list(pi_sizes, ppsz_sizes_text)
|
|
|
+ add_integer("quartztext-color", 0x00FFFFFF, COLOR_TEXT,
|
|
|
+ COLOR_LONGTEXT, false)
|
|
|
++ change_safe()
|
|
|
+ change_integer_list(pi_color_values, ppsz_color_descriptions)
|
|
|
+ set_capability("text renderer", 50)
|
|
|
+- add_shortcut("text")
|
|
|
++ add_shortcut("quartztext")
|
|
|
+ set_callbacks(Create, Destroy)
|
|
|
+ vlc_module_end ()
|
|
|
+
|
|
|
+@@ -177,7 +184,8 @@ struct offscreen_bitmap_t
|
|
|
+ *****************************************************************************/
|
|
|
+ struct filter_sys_t
|
|
|
+ {
|
|
|
+- char *psz_font_name;
|
|
|
++ vlc_mutex_t lock;
|
|
|
++ char *psz_font_name;
|
|
|
+ uint8_t i_font_opacity;
|
|
|
+ int i_font_color;
|
|
|
+ int i_font_size;
|
|
|
+@@ -202,9 +210,9 @@ static int Create(vlc_object_t *p_this)
|
|
|
+ p_filter->p_sys = p_sys = malloc(sizeof(filter_sys_t));
|
|
|
+ if (!p_sys)
|
|
|
+ return VLC_ENOMEM;
|
|
|
+- p_sys->psz_font_name = var_CreateGetString(p_this, "quartztext-font");
|
|
|
++ p_sys->psz_font_name = var_CreateGetStringCommand(p_this, "quartztext-font");
|
|
|
+ p_sys->i_font_opacity = 255;
|
|
|
+- p_sys->i_font_color = VLC_CLIP(var_CreateGetInteger(p_this, "quartztext-color") , 0, 0xFFFFFF);
|
|
|
++ p_sys->i_font_color = VLC_CLIP(var_CreateGetIntegerCommand(p_this, "quartztext-color") , 0, 0xFFFFFF);
|
|
|
+ p_sys->i_font_size = GetFontSize(p_filter);
|
|
|
+
|
|
|
+ p_filter->pf_render_text = RenderText;
|
|
|
+@@ -215,6 +223,11 @@ static int Create(vlc_object_t *p_this)
|
|
|
+ p_sys->i_fonts = 0;
|
|
|
+ #endif
|
|
|
+
|
|
|
++ vlc_mutex_init( &p_sys->lock );
|
|
|
++ var_AddCallback( p_filter, "quartztext-font", QuartztextCallback, p_sys );
|
|
|
++ var_AddCallback( p_filter, "quartztext-fontsize", QuartztextCallback, p_sys );
|
|
|
++ var_AddCallback( p_filter, "quartztext-color", QuartztextCallback, p_sys );
|
|
|
++
|
|
|
+ LoadFontsFromAttachments(p_filter);
|
|
|
+
|
|
|
+ return VLC_SUCCESS;
|
|
|
+@@ -229,6 +242,12 @@ static void Destroy(vlc_object_t *p_this)
|
|
|
+ {
|
|
|
+ filter_t *p_filter = (filter_t *)p_this;
|
|
|
+ filter_sys_t *p_sys = p_filter->p_sys;
|
|
|
++
|
|
|
++ var_DelCallback( p_filter, "quartztext-font", QuartztextCallback, p_sys );
|
|
|
++ var_DelCallback( p_filter, "quartztext-fontsize", QuartztextCallback, p_sys );
|
|
|
++ var_DelCallback( p_filter, "quartztext-color", QuartztextCallback, p_sys );
|
|
|
++ vlc_mutex_destroy( &p_sys->lock );
|
|
|
++
|
|
|
+ #ifndef TARGET_OS_IPHONE
|
|
|
+ if (p_sys->p_fonts) {
|
|
|
+ for (int k = 0; k < p_sys->i_fonts; k++) {
|
|
|
+@@ -959,7 +978,8 @@ static int GetFontSize(filter_t *p_filter)
|
|
|
+ {
|
|
|
+ int i_size = 0;
|
|
|
+
|
|
|
+- int i_ratio = var_CreateGetInteger( p_filter, "quartztext-rel-fontsize" );
|
|
|
++ int i_ratio = var_CreateGetIntegerCommand( p_filter, "quartztext-fontsize" );
|
|
|
++ msg_Err(p_filter, "ratio is %i", i_ratio);
|
|
|
+ if( i_ratio > 0 )
|
|
|
+ i_size = (int)p_filter->fmt_out.video.i_height / i_ratio;
|
|
|
+
|
|
|
+@@ -1048,3 +1068,23 @@ static int RenderYUVA(filter_t *p_filter, subpicture_region_t *p_region,
|
|
|
+
|
|
|
+ return VLC_SUCCESS;
|
|
|
+ }
|
|
|
++
|
|
|
++static int QuartztextCallback( vlc_object_t *p_this, char const *psz_var,
|
|
|
++ vlc_value_t oldval, vlc_value_t newval,
|
|
|
++ void *p_data )
|
|
|
++{
|
|
|
++ VLC_UNUSED(oldval);
|
|
|
++ filter_t *p_filter = (filter_t *)p_this;
|
|
|
++ filter_sys_t *p_sys = (filter_sys_t *)p_data;
|
|
|
++
|
|
|
++ vlc_mutex_lock( &p_sys->lock );
|
|
|
++ if( !strcmp( psz_var, "quartztext-font" ) )
|
|
|
++ p_sys->psz_font_name = newval.psz_string;
|
|
|
++ else if( !strcmp( psz_var, "quartztext-fontsize" ) )
|
|
|
++ p_sys->i_font_size = (int)p_filter->fmt_out.video.i_height / newval.i_int;
|
|
|
++ else if( !strcmp( psz_var, "quartztext-color" ) )
|
|
|
++ p_sys->i_font_color = VLC_CLIP(newval.i_int, 0, 0xFFFFFF);
|
|
|
++ vlc_mutex_unlock( &p_sys->lock );
|
|
|
++
|
|
|
++ return VLC_SUCCESS;
|
|
|
++}
|
|
|
+--
|
|
|
+1.8.5.2 (Apple Git-48)
|
|
|
+
|