Commit 8714fccc authored by Thomas Guillem's avatar Thomas Guillem

lib/video: toggle teletext from libvlc_video_set_teletext

If the page is in the range [0; 1000[ the teletext spu will be enabled. If the
page is -1, the teletext spu will be disabled. Otherwise do nothing and print
an error.
parent d05d123f
......@@ -1351,7 +1351,9 @@ LIBVLC_API int libvlc_video_get_teletext( libvlc_media_player_t *p_mi );
* Set new teletext page to retrieve.
*
* \param p_mi the media player
* \param i_page teletex page number requested
* \param i_page teletex page number requested. This value can be -1 to disable
* teletext or a number in the range [0;1000[ to show the requested page. 100
* is the default teletext page.
*/
LIBVLC_API void libvlc_video_set_teletext( libvlc_media_player_t *p_mi, int i_page );
......
......@@ -515,7 +515,13 @@ void libvlc_video_set_teletext( libvlc_media_player_t *p_mi, int i_page )
vlc_object_t *p_zvbi = NULL;
int telx;
var_SetInteger (p_mi, "vbi-page", i_page);
if( i_page >= 0 && i_page < 1000 )
var_SetInteger( p_mi, "vbi-page", i_page );
else if( i_page != -1 )
{
libvlc_printerr("Invalid page number");
return;
}
p_input_thread = libvlc_get_input_thread( p_mi );
if( !p_input_thread ) return;
......@@ -526,14 +532,26 @@ void libvlc_video_set_teletext( libvlc_media_player_t *p_mi, int i_page )
return;
}
telx = var_GetInteger( p_input_thread, "teletext-es" );
if( telx >= 0 )
if( i_page == -1 )
{
teletext_enable( p_input_thread, false );
}
else
{
if( input_GetEsObjects( p_input_thread, telx, &p_zvbi, NULL, NULL )
== VLC_SUCCESS )
telx = var_GetInteger( p_input_thread, "teletext-es" );
if( telx >= 0 )
{
if( input_GetEsObjects( p_input_thread, telx, &p_zvbi, NULL, NULL )
== VLC_SUCCESS )
{
var_SetInteger( p_zvbi, "vbi-page", i_page );
vlc_object_release( p_zvbi );
}
}
else
{
var_SetInteger( p_zvbi, "vbi-page", i_page );
vlc_object_release( p_zvbi );
/* the "vbi-page" will be selected on es creation */
teletext_enable( p_input_thread, true );
}
}
vlc_object_release( p_input_thread );
......
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