Commit 57216711 authored by Andre Pang's avatar Andre Pang

* CMML codec:

  - added browse-follow-anchor, browse-go-back and browse-go-forward
    callbacks
  - will not display clip description as subtitles if
    intf-displays-cmml-description variable is set on main interface
    thread
  - bugfix for web browser launching on Mac OS X
parent fcb96bb2
...@@ -29,14 +29,14 @@ ...@@ -29,14 +29,14 @@
#include "xstrcat.h" #include "xstrcat.h"
int browser_Open( char *psz_url ) int browser_Open( const char *psz_url )
{ {
#ifdef SYS_DARWIN #ifdef SYS_DARWIN
char *psz_open_commandline; char *psz_open_commandline;
psz_open_commandline = strdup( "open " ); psz_open_commandline = strdup( "/usr/bin/open " );
xstrcat( psz_open_commandline, psz_url ); psz_open_commandline = xstrcat( psz_open_commandline, psz_url );
return system( psz_open_commandline ); return system( psz_open_commandline );
#elif defined( WIN32 ) #elif defined( WIN32 )
char *psz_open_commandline; char *psz_open_commandline;
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#ifndef __BROWSER_OPEN_H__ #ifndef __BROWSER_OPEN_H__
#define __BROWSER_OPEN_H__ #define __BROWSER_OPEN_H__
int browser_Open( char *psz_url ); int browser_Open( const char *psz_url );
#endif /* __BROWSER_OPEN_H__ */ #endif /* __BROWSER_OPEN_H__ */
...@@ -85,11 +85,19 @@ static void FollowAnchor ( intf_thread_t * ); ...@@ -85,11 +85,19 @@ static void FollowAnchor ( intf_thread_t * );
static void GoBack ( intf_thread_t * ); static void GoBack ( intf_thread_t * );
static void GoForward ( intf_thread_t * ); static void GoForward ( intf_thread_t * );
static int FollowAnchorCallback ( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
static int GoBackCallback ( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
static int GoForwardCallback ( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
static char *GetTimedURLFromPlaylistItem( intf_thread_t *, playlist_item_t * ); static char *GetTimedURLFromPlaylistItem( intf_thread_t *, playlist_item_t * );
static char *GetTimedURIFragmentForTime ( int ); static char *GetTimedURIFragmentForTime ( int );
static int GetCurrentTimeInSeconds ( input_thread_t * ); static int GetCurrentTimeInSeconds ( input_thread_t * );
static int DisplayAnchor ( intf_thread_t *, vout_thread_t *, static int DisplayAnchor ( intf_thread_t *, vout_thread_t *,
char *, char * ); char *, char * );
static int DisplayPendingAnchor ( intf_thread_t *, vout_thread_t * );
static history_t * GetHistory ( playlist_t * ); static history_t * GetHistory ( playlist_t * );
static void ReplacePlaylistItem ( playlist_t *, char * ); static void ReplacePlaylistItem ( playlist_t *, char * );
...@@ -110,11 +118,21 @@ int E_(OpenIntf) ( vlc_object_t *p_this ) ...@@ -110,11 +118,21 @@ int E_(OpenIntf) ( vlc_object_t *p_this )
}; };
p_intf->pf_run = RunIntf; p_intf->pf_run = RunIntf;
var_AddCallback( p_intf->p_vlc, "key-pressed", KeyEvent, p_intf ); var_AddCallback( p_intf->p_vlc, "key-pressed", KeyEvent, p_intf );
/* we also need to add the callback for "mouse-clicked", but do that later /* we also need to add the callback for "mouse-clicked", but do that later
* when we've found a p_vout */ * when we've found a p_vout */
var_Create( p_intf->p_vlc, "browse-go-back", VLC_VAR_VOID );
var_AddCallback( p_intf->p_vlc, "browse-go-back",
GoBackCallback, p_intf );
var_Create( p_intf->p_vlc, "browse-go-forward", VLC_VAR_VOID );
var_AddCallback( p_intf->p_vlc, "browse-go-forward",
GoForwardCallback, p_intf );
var_Create( p_intf->p_vlc, "browse-follow-anchor", VLC_VAR_VOID );
var_AddCallback( p_intf->p_vlc, "browse-follow-anchor",
FollowAnchorCallback, p_intf );
return( 0 ); return( 0 );
} }
...@@ -186,8 +204,6 @@ static void RunIntf( intf_thread_t *p_intf ) ...@@ -186,8 +204,6 @@ static void RunIntf( intf_thread_t *p_intf )
/* Main loop */ /* Main loop */
while( !p_intf->b_die ) while( !p_intf->b_die )
{ {
vlc_value_t val;
decoder_t *p_cmml_decoder;
/* find a video output if we currently don't have one */ /* find a video output if we currently don't have one */
if( p_vout == NULL ) if( p_vout == NULL )
...@@ -223,7 +239,7 @@ static void RunIntf( intf_thread_t *p_intf ) ...@@ -223,7 +239,7 @@ static void RunIntf( intf_thread_t *p_intf )
#ifdef CMML_INTF_DEBUG #ifdef CMML_INTF_DEBUG
msg_Dbg( p_intf, "Got a keypress: %d", val.i_int ); msg_Dbg( p_intf, "Got a keypress: %d", val.i_int );
#endif #endif
for( i = 0; p_hotkeys[i].psz_action != NULL; i++ ) for( i = 0; p_hotkeys[i].psz_action != NULL; i++ )
{ {
if( p_hotkeys[i].i_key == val.i_int ) if( p_hotkeys[i].i_key == val.i_int )
...@@ -248,55 +264,11 @@ static void RunIntf( intf_thread_t *p_intf ) ...@@ -248,55 +264,11 @@ static void RunIntf( intf_thread_t *p_intf )
break; break;
} }
} }
} }
vlc_mutex_unlock( &p_intf->change_lock ); vlc_mutex_unlock( &p_intf->change_lock );
/* (void) DisplayPendingAnchor( p_intf, p_vout );
* Get a pending anchor description/URL from the CMML decoder
* and display it on screen
*/
p_cmml_decoder = p_intf->p_sys->p_cmml_decoder;
if( var_Get( p_cmml_decoder, "psz-current-anchor-description", &val )
== VLC_SUCCESS )
{
if( val.p_address )
{
char *psz_description = NULL;
char *psz_url = NULL;
psz_description = val.p_address;
if( var_Get( p_cmml_decoder, "psz-current-anchor-url", &val )
== VLC_SUCCESS )
{
psz_url = val.p_address;
}
if( p_vout != NULL )
{
if( DisplayAnchor( p_intf, p_vout, psz_description,
psz_url ) != VLC_SUCCESS )
{
/* text render unsuccessful: do nothing */
}
else
{
/* text render successful: clear description */
val.p_address = NULL;
if( var_Set( p_cmml_decoder,
"psz-current-anchor-description", val ) !=
VLC_SUCCESS )
{
msg_Dbg( p_intf, "reset of "
"psz-current-anchor-description failed" );
}
free( psz_description );
psz_url = NULL;
}
}
}
}
/* Wait a bit */ /* Wait a bit */
msleep( INTF_IDLE_SLEEP ); msleep( INTF_IDLE_SLEEP );
...@@ -313,6 +285,76 @@ static void RunIntf( intf_thread_t *p_intf ) ...@@ -313,6 +285,76 @@ static void RunIntf( intf_thread_t *p_intf )
vlc_object_release( p_intf->p_sys->p_input ); vlc_object_release( p_intf->p_sys->p_input );
} }
/*****************************************************************************
* DisplayPendingAnchor: get a pending anchor description/URL from the CMML
* decoder and display it on screen
*****************************************************************************/
static int DisplayPendingAnchor( intf_thread_t *p_intf, vout_thread_t *p_vout )
{
decoder_t *p_cmml_decoder;
char *psz_description = NULL;
char *psz_url = NULL;
intf_thread_t *p_primary_intf;
vlc_value_t val;
p_cmml_decoder = p_intf->p_sys->p_cmml_decoder;
if( var_Get( p_cmml_decoder, "psz-current-anchor-description", &val )
!= VLC_SUCCESS )
{
return VLC_TRUE;
}
if( !val.p_address )
return VLC_TRUE;
psz_description = val.p_address;
if( var_Get( p_cmml_decoder, "psz-current-anchor-url", &val )
== VLC_SUCCESS )
{
psz_url = val.p_address;
}
if( p_vout != NULL )
{
/* don't display anchor if main interface can display it */
p_primary_intf = vlc_object_find( p_intf->p_vlc, VLC_OBJECT_INTF,
FIND_CHILD );
if( p_primary_intf )
{
if( var_Get( p_primary_intf, "intf-displays-cmml-description", &val )
== VLC_SUCCESS )
{
if( val.b_bool == VLC_TRUE ) return TRUE;
}
}
/* display anchor as subtitle on-screen */
if( DisplayAnchor( p_intf, p_vout, psz_description, psz_url )
!= VLC_SUCCESS )
{
/* text render unsuccessful: do nothing */
return VLC_FALSE;
}
/* text render successful: clear description */
val.p_address = NULL;
if( var_Set( p_cmml_decoder, "psz-current-anchor-description", val )
!= VLC_SUCCESS )
{
msg_Dbg( p_intf,
"reset of psz-current-anchor-description failed" );
}
free( psz_description );
psz_url = NULL;
}
return VLC_TRUE;
}
/***************************************************************************** /*****************************************************************************
* InitThread: * InitThread:
*****************************************************************************/ *****************************************************************************/
...@@ -427,7 +469,7 @@ static void FollowAnchor ( intf_thread_t *p_intf ) ...@@ -427,7 +469,7 @@ static void FollowAnchor ( intf_thread_t *p_intf )
p_current_item = p_playlist->pp_items[p_playlist->i_index]; p_current_item = p_playlist->pp_items[p_playlist->i_index];
#ifdef CMML_INTF_DEBUG #ifdef CMML_INTF_DEBUG
msg_Dbg( p_intf, "Current playlist item URL is \"%s\"", msg_Dbg( p_intf, "Current playlist item URL is \"%s\"",
p_current_item->psz_uri ); p_current_item->input.psz_uri );
#endif #endif
psz_uri_to_load = XURL_Concat( p_current_item->input.psz_uri, psz_uri_to_load = XURL_Concat( p_current_item->input.psz_uri,
...@@ -492,6 +534,9 @@ static void FollowAnchor ( intf_thread_t *p_intf ) ...@@ -492,6 +534,9 @@ static void FollowAnchor ( intf_thread_t *p_intf )
} }
else else
{ {
#ifdef CMML_INTF_DEBUG
msg_Dbg( p_intf, "calling browser_Open with \"%s\"", psz_url );
#endif
(void) browser_Open( psz_url ); (void) browser_Open( psz_url );
playlist_Command( p_playlist, PLAYLIST_PAUSE, 0 ); playlist_Command( p_playlist, PLAYLIST_PAUSE, 0 );
} }
...@@ -570,6 +615,34 @@ char *GetTimedURIFragmentForTime( int seconds ) ...@@ -570,6 +615,34 @@ char *GetTimedURIFragmentForTime( int seconds )
return psz_time; return psz_time;
} }
static
int GoBackCallback( vlc_object_t *p_this, char const *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
intf_thread_t *p_intf = (intf_thread_t *) p_data;
GoBack( p_intf );
return VLC_SUCCESS;
}
static
int GoForwardCallback( vlc_object_t *p_this, char const *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
intf_thread_t *p_intf = (intf_thread_t *) p_data;
GoForward( p_intf );
return VLC_SUCCESS;
}
static
int FollowAnchorCallback( vlc_object_t *p_this, char const *psz_var,
vlc_value_t oldval, vlc_value_t newval,
void *p_data )
{
intf_thread_t *p_intf = (intf_thread_t *) p_data;
FollowAnchor( p_intf );
return VLC_SUCCESS;
}
static static
void GoBack( intf_thread_t *p_intf ) void GoBack( intf_thread_t *p_intf )
{ {
......
...@@ -30,13 +30,13 @@ ...@@ -30,13 +30,13 @@
/* like strcat, but realloc's enough memory for the new string too */ /* like strcat, but realloc's enough memory for the new string too */
static inline static inline
char *xstrcat( char *psz_string, char *psz_to_append ) char *xstrcat( char *psz_string, const char *psz_to_append )
{ {
size_t i_new_string_length = strlen( psz_string ) + size_t i_new_string_length = strlen( psz_string ) +
strlen( psz_to_append ) + 1; strlen( psz_to_append ) + 1;
psz_string = (char *) realloc( psz_string, i_new_string_length ); psz_string = (char *) realloc( psz_string, i_new_string_length );
return strcat( psz_string, psz_to_append ); return strcat( psz_string, psz_to_append );
} }
......
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