Commit 8d974bf0 authored by Daniel Amm's avatar Daniel Amm Committed by Hugo Beauzée-Luyssen

Add support for multiple video tracks

Signed-off-by: default avatarHugo Beauzée-Luyssen <hugo@beauzee.fr>
parent ce8f4474
...@@ -537,6 +537,16 @@ library AXVLC ...@@ -537,6 +537,16 @@ library AXVLC
[helpstring("toggle teletext transparent state.")] [helpstring("toggle teletext transparent state.")]
HRESULT toggleTeletext(); HRESULT toggleTeletext();
[propget, helpstring("Returns/sets video track used/to use.")]
HRESULT track([out, retval] long* track);
[propput, helpstring("Returns/sets video track used/to use.")]
HRESULT track([in] long track);
[propget, helpstring("Returns the number of video tracks available.")]
HRESULT count([out, retval] long* trackNumber);
[helpstring("Returns video track name.")]
HRESULT description([in] long trackID, [out, retval] BSTR* name);
[propget, helpstring("Returns the marquee object.")] [propget, helpstring("Returns the marquee object.")]
HRESULT marquee([out, retval] IVLCMarquee** obj); HRESULT marquee([out, retval] IVLCMarquee** obj);
......
...@@ -1283,6 +1283,46 @@ STDMETHODIMP VLCVideo::toggleTeletext() ...@@ -1283,6 +1283,46 @@ STDMETHODIMP VLCVideo::toggleTeletext()
#endif #endif
} }
STDMETHODIMP VLCVideo::get_track(long* track)
{
if( NULL == track )
return E_POINTER;
*track = _plug->get_player().currentVideoTrack();
return S_OK;
}
STDMETHODIMP VLCVideo::put_track(long track)
{
auto tracks = _plug->get_player().get_mp().videoTrackDescription();
if ( track >= tracks.size() )
return E_INVALIDARG;
_plug->get_player().get_mp().setVideoTrack( tracks[track].id() );
return S_OK;
}
STDMETHODIMP VLCVideo::get_count(long* trackNumber)
{
if( NULL == trackNumber )
return E_POINTER;
*trackNumber = negativeToZero( _plug->get_player().get_mp().videoTrackCount() );
return S_OK;
}
STDMETHODIMP VLCVideo::description(long trackId, BSTR* name)
{
if( NULL == name )
return E_POINTER;
auto tracks = _plug->get_player().get_mp().videoTrackDescription();
if ( trackId >= tracks.size() )
return E_INVALIDARG;
*name = BSTRFromCStr( CP_UTF8, tracks[trackId].name().c_str() );
return (NULL == *name) ? E_OUTOFMEMORY : S_OK;
}
STDMETHODIMP VLCVideo::get_marquee(IVLCMarquee** obj) STDMETHODIMP VLCVideo::get_marquee(IVLCMarquee** obj)
{ {
return object_get(obj,_p_vlcmarquee); return object_get(obj,_p_vlcmarquee);
......
...@@ -357,6 +357,10 @@ public: ...@@ -357,6 +357,10 @@ public:
STDMETHODIMP takeSnapshot(LPPICTUREDISP*); STDMETHODIMP takeSnapshot(LPPICTUREDISP*);
STDMETHODIMP toggleFullscreen(); STDMETHODIMP toggleFullscreen();
STDMETHODIMP toggleTeletext(); STDMETHODIMP toggleTeletext();
STDMETHODIMP get_track(long*);
STDMETHODIMP put_track(long);
STDMETHODIMP get_count(long*);
STDMETHODIMP description(long, BSTR*);
private: private:
IVLCMarquee *_p_vlcmarquee; IVLCMarquee *_p_vlcmarquee;
......
...@@ -120,6 +120,13 @@ int vlc_player::currentSubtitleTrack() ...@@ -120,6 +120,13 @@ int vlc_player::currentSubtitleTrack()
return getTrack( current, tracks ); return getTrack( current, tracks );
} }
int vlc_player::currentVideoTrack()
{
auto current = _mp.videoTrack();
auto tracks = _mp.videoTrackDescription();
return getTrack( current, tracks );
}
int vlc_player::getTrack( int currentId, const std::vector<VLC::TrackDescription>& tracks ) int vlc_player::getTrack( int currentId, const std::vector<VLC::TrackDescription>& tracks )
{ {
if ( tracks.empty() ) if ( tracks.empty() )
......
...@@ -60,6 +60,7 @@ public: ...@@ -60,6 +60,7 @@ public:
int currentAudioTrack(); int currentAudioTrack();
int currentSubtitleTrack(); int currentSubtitleTrack();
int currentVideoTrack();
private: private:
// Returns a 0-based track index, instead of the internal libvlc one // Returns a 0-based track index, instead of the internal libvlc one
......
...@@ -1332,6 +1332,8 @@ const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] = ...@@ -1332,6 +1332,8 @@ const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] =
"subtitle", "subtitle",
"crop", "crop",
"teletext", "teletext",
"track",
"count",
"marquee", "marquee",
"logo", "logo",
"deinterlace", "deinterlace",
...@@ -1346,6 +1348,8 @@ enum LibvlcVideoNPObjectPropertyIds ...@@ -1346,6 +1348,8 @@ enum LibvlcVideoNPObjectPropertyIds
ID_video_subtitle, ID_video_subtitle,
ID_video_crop, ID_video_crop,
ID_video_teletext, ID_video_teletext,
ID_video_track,
ID_video_count,
ID_video_marquee, ID_video_marquee,
ID_video_logo, ID_video_logo,
ID_video_deinterlace, ID_video_deinterlace,
...@@ -1407,6 +1411,16 @@ LibvlcVideoNPObject::getProperty(int index, npapi::OutVariant& result) ...@@ -1407,6 +1411,16 @@ LibvlcVideoNPObject::getProperty(int index, npapi::OutVariant& result)
result = i_page; result = i_page;
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_video_track:
{
result = p_plugin->player().currentVideoTrack();
return INVOKERESULT_NO_ERROR;
}
case ID_video_count:
{
result = negativeToZero( mp.videoTrackCount() );
return INVOKERESULT_NO_ERROR;
}
case ID_video_marquee: case ID_video_marquee:
{ {
InstantObj<LibvlcMarqueeNPObject>( marqueeObj ); InstantObj<LibvlcMarqueeNPObject>( marqueeObj );
...@@ -1503,6 +1517,18 @@ LibvlcVideoNPObject::setProperty(int index, const NPVariant &value) ...@@ -1503,6 +1517,18 @@ LibvlcVideoNPObject::setProperty(int index, const NPVariant &value)
} }
return INVOKERESULT_INVALID_VALUE; return INVOKERESULT_INVALID_VALUE;
} }
case ID_video_track:
{
if( v.is<int>() )
{
auto tracks = mp.videoTrackDescription();
if ( v >= tracks.size() )
return INVOKERESULT_INVALID_VALUE;
mp.setVideoTrack( tracks[v].id() );
return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_INVALID_VALUE;
}
} }
} }
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
...@@ -1512,6 +1538,7 @@ const NPUTF8 * const LibvlcVideoNPObject::methodNames[] = ...@@ -1512,6 +1538,7 @@ const NPUTF8 * const LibvlcVideoNPObject::methodNames[] =
{ {
"toggleFullscreen", "toggleFullscreen",
"toggleTeletext", "toggleTeletext",
"description",
}; };
COUNTNAMES(LibvlcVideoNPObject,methodCount,methodNames); COUNTNAMES(LibvlcVideoNPObject,methodCount,methodNames);
...@@ -1519,16 +1546,20 @@ enum LibvlcVideoNPObjectMethodIds ...@@ -1519,16 +1546,20 @@ enum LibvlcVideoNPObjectMethodIds
{ {
ID_video_togglefullscreen, ID_video_togglefullscreen,
ID_video_toggleteletext, ID_video_toggleteletext,
ID_video_description,
}; };
RuntimeNPObject::InvokeResult RuntimeNPObject::InvokeResult
LibvlcVideoNPObject::invoke(int index, const NPVariant *, LibvlcVideoNPObject::invoke(int index, const NPVariant *args,
uint32_t argCount, npapi::OutVariant&) uint32_t argCount, npapi::OutVariant& result)
{ {
/* is plugin still running */ /* is plugin still running */
if( isPluginRunning() ) if( isPluginRunning() )
{ {
VlcPluginBase* p_plugin = getPrivate<VlcPluginBase>(); VlcPluginBase* p_plugin = getPrivate<VlcPluginBase>();
auto& mp = p_plugin->getMD();
if( !mp )
RETURN_ON_ERROR;
switch( index ) switch( index )
{ {
...@@ -1557,6 +1588,22 @@ LibvlcVideoNPObject::invoke(int index, const NPVariant *, ...@@ -1557,6 +1588,22 @@ LibvlcVideoNPObject::invoke(int index, const NPVariant *,
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
} }
case ID_video_description:
{
if ( argCount < 1 )
return INVOKERESULT_INVALID_ARGS;
const npapi::Variant v( args[0] );
if( v.is<int>() )
{
auto tracks = mp.videoTrackDescription();
if ( v >= tracks.size() )
return INVOKERESULT_INVALID_VALUE;
/* display the name of the track chosen */
result = tracks[v].name();
return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_NO_SUCH_METHOD;
}
default: default:
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
} }
......
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