Commit 6399a8e7 authored by Jean-Paul Saman's avatar Jean-Paul Saman Committed by Jean-Paul Saman

Select teletext page to view from JavaScript in IE ActiveX, Mozilla/Firefox and Safari browser.

parent 446c1fc4
......@@ -426,7 +426,12 @@ library AXVLC
HRESULT subtitle([out, retval] long* spu);
[propput, helpstring("Sets video subtitle to use.")]
HRESULT subtitle([in] long spu);
[propget, helpstring("Returns teletext page used.")]
HRESULT teletext([out, retval] long* page);
[propput, helpstring("Sets teletext page to use.")]
HRESULT teletext([in] long page);
[helpstring("toggle fullscreen/windowed state.")]
HRESULT toggleFullscreen();
};
......
......@@ -2272,6 +2272,58 @@ STDMETHODIMP VLCVideo::put_subtitle(long spu)
return hr;
};
STDMETHODIMP VLCVideo::get_teletext(long* page)
{
if( NULL == page )
return E_POINTER;
libvlc_instance_t* p_libvlc;
HRESULT hr = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
if( ! libvlc_exception_raised(&ex) )
{
*page = libvlc_video_get_teletext(p_input, &ex);
libvlc_input_free(p_input);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
}
_p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
return hr;
};
STDMETHODIMP VLCVideo::put_teletext(long page)
{
libvlc_instance_t* p_libvlc;
HRESULT hr = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
libvlc_video_set_teletext(p_input, page, &ex);
libvlc_input_free(p_input);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
return NOERROR;
}
return hr;
};
STDMETHODIMP VLCVideo::toggleFullscreen()
{
libvlc_instance_t* p_libvlc;
......
......@@ -66,6 +66,11 @@ public:
STDMETHODIMP put_mute(VARIANT_BOOL);
STDMETHODIMP get_volume(long*);
STDMETHODIMP put_volume(long);
STDMETHODIMP get_track(long*);
STDMETHODIMP put_track(long);
STDMETHODIMP get_channel(long*);
STDMETHODIMP put_channel(long);
STDMETHODIMP toggleMute();
protected:
......@@ -518,6 +523,11 @@ public:
STDMETHODIMP get_height(long*);
STDMETHODIMP get_aspectRatio(BSTR*);
STDMETHODIMP put_aspectRatio(BSTR);
STDMETHODIMP get_subtitle(long*);
STDMETHODIMP put_subtitle(long);
STDMETHODIMP get_teletext(long*);
STDMETHODIMP put_teletext(long);
STDMETHODIMP toggleFullscreen();
protected:
......
......@@ -345,6 +345,38 @@ char *libvlc_video_get_aspect_ratio( libvlc_input_t *, libvlc_exception_t * );
*/
void libvlc_video_set_aspect_ratio( libvlc_input_t *, char *, libvlc_exception_t * );
/**
* Get current video subtitle track
* \param p_input the input
* \param p_exception an initialized exception
* \return the video current subtitle track
*/
int libvlc_video_get_spu( libvlc_input_t *, libvlc_exception_t * );
/**
* Set new video subtitle track
* \param p_input the input
* \param psz_aspect new video subtitle track
* \param p_exception an initialized exception
*/
void libvlc_video_set_spu( libvlc_input_t *, int, libvlc_exception_t * );
/**
* Get current teletext page requested.
* \param p_input the input
* \param p_exception an initialized exception
* \return the current teletext page requested.
*/
int libvlc_video_get_teletext( libvlc_input_t *, libvlc_exception_t * );
/**
* Set new teletext page to retrieve
* \param p_input the input
* \param i_page teletex page number requested
* \param p_exception an initialized exception
*/
void libvlc_video_set_teletext( libvlc_input_t *, int, libvlc_exception_t * );
/**
* Take a snapshot of the current video window
* \param p_input the input
......
......@@ -1772,6 +1772,19 @@ void LibvlcPlaylistNPObject::parseOptions(NPObject *obj, int *i_options, char***
*i_options = nOptions;
*ppsz_options = options;
}
case ID_video_teletext:
{
int i_page = libvlc_video_get_teletext(p_input, &ex);
libvlc_input_free(p_input);
if( libvlc_exception_raised(&ex) )
{
NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR;
}
INT32_TO_NPVARIANT(i_page, result);
return INVOKERESULT_NO_ERROR;
}
}
}
}
......@@ -1786,7 +1799,8 @@ const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] =
"height",
"width",
"aspectRatio",
"subtitle"
"subtitle",
"teletext"
};
enum LibvlcVideoNPObjectPropertyIds
......@@ -1796,6 +1810,7 @@ enum LibvlcVideoNPObjectPropertyIds
ID_video_width,
ID_video_aspectratio,
ID_video_subtitle
ID_video_teletext
};
const int LibvlcVideoNPObject::propertyCount = sizeof(LibvlcVideoNPObject::propertyNames)/sizeof(NPUTF8 *);
......@@ -1887,6 +1902,24 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVari
INT32_TO_NPVARIANT(i_spu, result);
return INVOKERESULT_NO_ERROR;
}
case ID_video_teletext:
{
if( isNumberValue(value) )
{
libvlc_video_set_teletext(p_input,
numberValue(value), &ex);
libvlc_input_free(p_input);
if( libvlc_exception_raised(&ex) )
{
NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR;
}
return INVOKERESULT_NO_ERROR;
}
libvlc_input_free(p_input);
return INVOKERESULT_INVALID_VALUE;
}
}
libvlc_input_free(p_input);
}
......
......@@ -56,33 +56,6 @@ static input_thread_t *GetInput( libvlc_input_t *p_input,
return p_input_thread;
}
/*
* Remember to release the returned input_thread_t since it is locked at
* the end of this function.
*/
static input_thread_t *GetInput( libvlc_input_t *p_input,
libvlc_exception_t *p_exception )
{
input_thread_t *p_input_thread = NULL;
if( !p_input )
{
libvlc_exception_raise( p_exception, "Input is NULL" );
return NULL;
}
p_input_thread = (input_thread_t*)vlc_object_get(
p_input->p_instance->p_vlc,
p_input->i_input_id );
if( !p_input_thread )
{
libvlc_exception_raise( p_exception, "Input does not exist" );
return NULL;
}
return p_input_thread;
}
/*
* Remember to release the returned vout_thread_t since it is locked at
* the end of this function.
......@@ -484,6 +457,36 @@ void libvlc_video_set_spu( libvlc_input_t *p_input, int i_spu,
vlc_object_release( p_input_thread );
}
int libvlc_video_get_teletext( libvlc_input_t *p_input,
libvlc_exception_t *p_e )
{
vout_thread_t *p_vout = GetVout( p_input, p_e );
int i_ret = -1;
if( !p_vout )
return i_ret;
i_ret = var_GetInteger( p_vout, "vbi-page" );
vlc_object_release( p_vout );
return i_ret;
}
void libvlc_video_set_teletext( libvlc_input_t *p_input, int i_page,
libvlc_exception_t *p_e )
{
vout_thread_t *p_vout = GetVout( p_input, p_e );
int i_ret = -1;
if( !p_vout )
return;
i_ret = var_SetInteger( p_vout, "vbi-page", i_page );
if( i_ret )
libvlc_exception_raise( p_e,
"Unexpected error while setting teletext page" );
vlc_object_release( p_vout );
}
int libvlc_video_destroy( libvlc_input_t *p_input,
libvlc_exception_t *p_e )
{
......
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