[vlc-commits] [Git][videolan/npapi-vlc][master] 5 commits: On the road to 2.2.7

Hugo Beauzée-Luyssen gitlab at videolan.org
Tue Jun 6 18:18:04 CEST 2017


Hugo Beauzée-Luyssen pushed to branch master at videolan / VLC Browser Plugins


Commits:
b8ea41ef by Hugo Beauzée-Luyssen at 2017-06-06T18:17:45+02:00
On the road to 2.2.7

- - - - -
70f104eb by Daniel Amm at 2017-06-06T18:17:45+02:00
Update NEWS

Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>

- - - - -
af6aa60c by Daniel Amm at 2017-06-06T18:17:45+02:00
Add some useful events to the JS API

Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>

- - - - -
ce8f4474 by Daniel Amm at 2017-06-06T18:17:45+02:00
Fix toggleTeletext in 3.0 builds

Since commit 76c74ca0 in vlc.git, 0 is used to disable teletext.

Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>

- - - - -
8d974bf0 by Daniel Amm at 2017-06-06T18:17:45+02:00
Add support for multiple video tracks

Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>

- - - - -


11 changed files:

- NEWS
- activex/axvlc.idl
- activex/plugin.cpp
- activex/plugin.h
- activex/vlccontrol2.cpp
- activex/vlccontrol2.h
- common/vlc_player.cpp
- common/vlc_player.h
- configure.ac
- npapi/npruntime/npolibvlc.cpp
- npapi/vlcplugin_base.cpp


Changes:

=====================================
NEWS
=====================================
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,13 @@
+Changes between VLC plugins 2.2.5 and 2.2.6:
+--------------------------------------------
+
+NPAPI Core:
+ * Fix usage of toggleTeletext() for 3.0 builds
+
+Platforms:
+ * Bundle manifest with DLLs
+
+
 Changes between VLC plugins 2.2.4 and 2.2.5:
 --------------------------------------------
 


=====================================
activex/axvlc.idl
=====================================
--- a/activex/axvlc.idl
+++ b/activex/axvlc.idl
@@ -84,6 +84,12 @@ library AXVLC
     const int DISPID_MediaPlayerMediaChangedEvent = 214;
     const int DISPID_MediaPlayerTitleChangedEvent = 215;
     const int DISPID_MediaPlayerLengthChangedEvent = 216;
+    const int DISPID_MediaPlayerChapterChangedEvent = 217;
+
+    const int DISPID_MediaPlayerVoutEvent = 218;
+    const int DISPID_MediaPlayerMutedEvent = 219;
+    const int DISPID_MediaPlayerUnmutedEvent = 220;
+    const int DISPID_MediaPlayerAudioVolumeEvent = 221;
 
     [
       uuid(DF48072F-5EF8-434e-9B40-E2F3AE759B5F),
@@ -129,6 +135,17 @@ library AXVLC
             void MediaPlayerTitleChanged([in] int title);
             [id(DISPID_MediaPlayerLengthChangedEvent), helpstring("Length changed")]
             void MediaPlayerLengthChanged([in] long length);
+            [id(DISPID_MediaPlayerChapterChangedEvent), helpstring("Chapter changed")]
+            void MediaPlayerChapterChanged([in] int chapter);
+
+            [id(DISPID_MediaPlayerVoutEvent), helpstring("Number of vout changed")]
+            void MediaPlayerVout([in] int count);
+            [id(DISPID_MediaPlayerMutedEvent), helpstring("Audio muted")]
+            void MediaPlayerMuted();
+            [id(DISPID_MediaPlayerUnmutedEvent), helpstring("Audio unmuted")]
+            void MediaPlayerUnmuted();
+            [id(DISPID_MediaPlayerAudioVolumeEvent), helpstring("Audio volume changed")]
+            void MediaPlayerAudioVolume([in] float volume);
     };
 
     [
@@ -520,6 +537,16 @@ library AXVLC
         [helpstring("toggle teletext transparent state.")]
         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.")]
         HRESULT marquee([out, retval] IVLCMarquee** obj);
 


=====================================
activex/plugin.cpp
=====================================
--- a/activex/plugin.cpp
+++ b/activex/plugin.cpp
@@ -1114,6 +1114,61 @@ void VLCPlugin::fireOnMediaPlayerLengthChangedEvent(long length)
     vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerLengthChangedEvent, &params);
 }
 
+#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(3, 0, 0, 0)
+void VLCPlugin::fireOnMediaPlayerChapterChangedEvent(int chapter)
+{
+    DISPPARAMS params;
+    params.cArgs = 1;
+    params.rgvarg = (VARIANTARG *) CoTaskMemAlloc(sizeof(VARIANTARG) * params.cArgs) ;
+    memset(params.rgvarg, 0, sizeof(VARIANTARG) * params.cArgs);
+    params.rgvarg[0].vt = VT_I2;
+    params.rgvarg[0].iVal = chapter;
+    params.rgdispidNamedArgs = NULL;
+    params.cNamedArgs = 0;
+    vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerChapterChangedEvent, &params);
+}
+#endif
+
+void VLCPlugin::fireOnMediaPlayerVoutEvent(int count)
+{
+    DISPPARAMS params;
+    params.cArgs = 1;
+    params.rgvarg = (VARIANTARG *) CoTaskMemAlloc(sizeof(VARIANTARG) * params.cArgs) ;
+    memset(params.rgvarg, 0, sizeof(VARIANTARG) * params.cArgs);
+    params.rgvarg[0].vt = VT_I2;
+    params.rgvarg[0].iVal = count;
+    params.rgdispidNamedArgs = NULL;
+    params.cNamedArgs = 0;
+    vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerVoutEvent, &params);
+}
+
+#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(2, 2, 2, 0)
+void VLCPlugin::fireOnMediaPlayerMutedEvent()
+{
+    DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
+    vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerMutedEvent, &dispparamsNoArgs);
+}
+
+void VLCPlugin::fireOnMediaPlayerUnmutedEvent()
+{
+    DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
+    vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerUnmutedEvent, &dispparamsNoArgs);
+}
+
+void VLCPlugin::fireOnMediaPlayerAudioVolumeEvent(float volume)
+{
+    DISPPARAMS params;
+    params.cArgs = 1;
+    params.rgvarg = (VARIANTARG *) CoTaskMemAlloc(sizeof(VARIANTARG) * params.cArgs) ;
+    memset(params.rgvarg, 0, sizeof(VARIANTARG) * params.cArgs);
+    params.rgvarg[0].vt = VT_R4;
+    params.rgvarg[0].fltVal = volume;
+    params.rgdispidNamedArgs = NULL;
+    params.cNamedArgs = 0;
+    vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerAudioVolumeEvent, &params);
+}
+#endif
+
 /* */
 
 void VLCPlugin::set_player_window()
@@ -1178,6 +1233,25 @@ void VLCPlugin::player_register_events()
     em.onLengthChanged( [this]( int64_t length ) {
         fireOnMediaPlayerLengthChangedEvent( length );
     });
+#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(3, 0, 0, 0)
+    em.onChapterChanged( [this]( int chapter ) {
+        fireOnMediaPlayerChapterChangedEvent( chapter );
+    });
+#endif
+    em.onVout( [this]( int count ) {
+        fireOnMediaPlayerVoutEvent( count );
+    });
+#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(2, 2, 2, 0)
+    em.onMuted( [this] {
+        fireOnMediaPlayerMutedEvent();
+    });
+    em.onUnmuted( [this] {
+        fireOnMediaPlayerUnmutedEvent();
+    });
+    em.onAudioVolume( [this]( float volume ) {
+        fireOnMediaPlayerAudioVolumeEvent( volume );
+    });
+#endif
 }
 
 #undef B


=====================================
activex/plugin.h
=====================================
--- a/activex/plugin.h
+++ b/activex/plugin.h
@@ -258,6 +258,16 @@ public:
     void fireOnMediaPlayerMediaChangedEvent();
     void fireOnMediaPlayerTitleChangedEvent(int title);
     void fireOnMediaPlayerLengthChangedEvent(long length);
+#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(3, 0, 0, 0)
+    void fireOnMediaPlayerChapterChangedEvent(int chapter);
+#endif
+
+    void fireOnMediaPlayerVoutEvent(int count);
+#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(2, 2, 2, 0)
+    void fireOnMediaPlayerMutedEvent();
+    void fireOnMediaPlayerUnmutedEvent();
+    void fireOnMediaPlayerAudioVolumeEvent(float volume);
+#endif
 
     // controlling IUnknown interface
     LPUNKNOWN pUnkOuter;


=====================================
activex/vlccontrol2.cpp
=====================================
--- a/activex/vlccontrol2.cpp
+++ b/activex/vlccontrol2.cpp
@@ -1273,16 +1273,56 @@ STDMETHODIMP VLCVideo::toggleFullscreen()
 STDMETHODIMP VLCVideo::toggleTeletext()
 {
 #if LIBVLC_VERSION_INT >= LIBVLC_VERSION(3, 0, 0, 0)
-    if( _plug->get_player().get_mp().teletext() == -1 )
+    if( _plug->get_player().get_mp().teletext() == 0 )
         _plug->get_player().get_mp().setTeletext( 100 );
     else
-        _plug->get_player().get_mp().setTeletext( -1 );
+        _plug->get_player().get_mp().setTeletext( 0 );
     return S_OK;
 #else
     _plug->get_player().get_mp().toggleTeletext();
 #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)
 {
     return object_get(obj,_p_vlcmarquee);


=====================================
activex/vlccontrol2.h
=====================================
--- a/activex/vlccontrol2.h
+++ b/activex/vlccontrol2.h
@@ -357,6 +357,10 @@ public:
     STDMETHODIMP takeSnapshot(LPPICTUREDISP*);
     STDMETHODIMP toggleFullscreen();
     STDMETHODIMP toggleTeletext();
+    STDMETHODIMP get_track(long*);
+    STDMETHODIMP put_track(long);
+    STDMETHODIMP get_count(long*);
+    STDMETHODIMP description(long, BSTR*);
 
 private:
     IVLCMarquee     *_p_vlcmarquee;


=====================================
common/vlc_player.cpp
=====================================
--- a/common/vlc_player.cpp
+++ b/common/vlc_player.cpp
@@ -120,6 +120,13 @@ int vlc_player::currentSubtitleTrack()
     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 )
 {
     if ( tracks.empty() )


=====================================
common/vlc_player.h
=====================================
--- a/common/vlc_player.h
+++ b/common/vlc_player.h
@@ -60,6 +60,7 @@ public:
 
     int currentAudioTrack();
     int currentSubtitleTrack();
+    int currentVideoTrack();
 
 private:
     // Returns a 0-based track index, instead of the internal libvlc one


=====================================
configure.ac
=====================================
--- a/configure.ac
+++ b/configure.ac
@@ -2,12 +2,12 @@ dnl Autoconf settings for npapi-vlc
 
 AC_COPYRIGHT([Copyright 2002-2017 VLC authors and VideoLAN])
 
-AC_INIT(npapi-vlc, 2.2.6)
+AC_INIT(npapi-vlc, 2.2.7)
 VERSION_MAJOR="2"
 AC_SUBST(VERSION_MAJOR)
 VERSION_MINOR="2"
 AC_SUBST(VERSION_MINOR)
-VERSION_REVISION="6"
+VERSION_REVISION="7"
 AC_SUBST(VERSION_REVISION)
 VERSION_EXTRA=""
 AC_SUBST(VERSION_EXTRA)


=====================================
npapi/npruntime/npolibvlc.cpp
=====================================
--- a/npapi/npruntime/npolibvlc.cpp
+++ b/npapi/npruntime/npolibvlc.cpp
@@ -1332,6 +1332,8 @@ const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] =
     "subtitle",
     "crop",
     "teletext",
+    "track",
+    "count",
     "marquee",
     "logo",
     "deinterlace",
@@ -1346,6 +1348,8 @@ enum LibvlcVideoNPObjectPropertyIds
     ID_video_subtitle,
     ID_video_crop,
     ID_video_teletext,
+    ID_video_track,
+    ID_video_count,
     ID_video_marquee,
     ID_video_logo,
     ID_video_deinterlace,
@@ -1407,6 +1411,16 @@ LibvlcVideoNPObject::getProperty(int index, npapi::OutVariant& result)
                 result = i_page;
                 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:
             {
                 InstantObj<LibvlcMarqueeNPObject>( marqueeObj );
@@ -1503,6 +1517,18 @@ LibvlcVideoNPObject::setProperty(int index, const NPVariant &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;
@@ -1512,6 +1538,7 @@ const NPUTF8 * const LibvlcVideoNPObject::methodNames[] =
 {
     "toggleFullscreen",
     "toggleTeletext",
+    "description",
 };
 COUNTNAMES(LibvlcVideoNPObject,methodCount,methodNames);
 
@@ -1519,16 +1546,20 @@ enum LibvlcVideoNPObjectMethodIds
 {
     ID_video_togglefullscreen,
     ID_video_toggleteletext,
+    ID_video_description,
 };
 
 RuntimeNPObject::InvokeResult
-LibvlcVideoNPObject::invoke(int index, const NPVariant *,
-                            uint32_t argCount, npapi::OutVariant&)
+LibvlcVideoNPObject::invoke(int index, const NPVariant *args,
+                            uint32_t argCount, npapi::OutVariant& result)
 {
     /* is plugin still running */
     if( isPluginRunning() )
     {
         VlcPluginBase* p_plugin = getPrivate<VlcPluginBase>();
+        auto& mp = p_plugin->getMD();
+        if( !mp )
+            RETURN_ON_ERROR;
 
         switch( index )
         {
@@ -1546,10 +1577,10 @@ LibvlcVideoNPObject::invoke(int index, const NPVariant *,
                 if( argCount == 0 )
                 {
 #if LIBVLC_VERSION_INT >= LIBVLC_VERSION(3, 0, 0, 0)
-                    if ( p_plugin->getMD().teletext() == -1 )
+                    if ( p_plugin->getMD().teletext() == 0 )
                         p_plugin->getMD().setTeletext( 100 );
                     else
-                        p_plugin->getMD().setTeletext( -1 );
+                        p_plugin->getMD().setTeletext( 0 );
 #else
                     p_plugin->getMD().toggleTeletext();
 #endif
@@ -1557,6 +1588,22 @@ LibvlcVideoNPObject::invoke(int index, const NPVariant *,
                 }
                 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:
                 return INVOKERESULT_NO_SUCH_METHOD;
         }


=====================================
npapi/vlcplugin_base.cpp
=====================================
--- a/npapi/vlcplugin_base.cpp
+++ b/npapi/vlcplugin_base.cpp
@@ -373,7 +373,16 @@ static struct vlcevents_t {
     { "MediaPlayerSeekableChanged", libvlc_MediaPlayerSeekableChanged },
     { "MediaPlayerPausableChanged", libvlc_MediaPlayerPausableChanged },
     { "MediaPlayerTitleChanged", libvlc_MediaPlayerTitleChanged },
+#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(3, 0, 0, 0)
+    { "MediaPlayerChapterChanged", libvlc_MediaPlayerChapterChanged },
+#endif
     { "MediaPlayerLengthChanged", libvlc_MediaPlayerLengthChanged },
+    { "MediaPlayerVout", libvlc_MediaPlayerVout },
+#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(2, 2, 2, 0)
+    { "MediaPlayerMuted", libvlc_MediaPlayerMuted },
+    { "MediaPlayerUnmuted", libvlc_MediaPlayerUnmuted },
+    { "MediaPlayerAudioVolume", libvlc_MediaPlayerAudioVolume },
+#endif
 };
 
 void VlcPluginBase::subscribe(const char* eventName, npapi::Variant listener)
@@ -438,9 +447,28 @@ void VlcPluginBase::subscribe(const char* eventName, npapi::Variant listener)
         case libvlc_MediaPlayerTitleChanged:
             e = player().get_mp().eventManager().onTitleChanged( std::move( closure ) );
             break;
+#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(3, 0, 0, 0)
+        case libvlc_MediaPlayerChapterChanged:
+            e = player().get_mp().eventManager().onChapterChanged( std::move( closure ) );
+            break;
+#endif
         case libvlc_MediaPlayerLengthChanged:
             e = player().get_mp().eventManager().onLengthChanged( std::move( closure ) );
             break;
+        case libvlc_MediaPlayerVout:
+            e = player().get_mp().eventManager().onVout( std::move( closure ) );
+            break;
+#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(2, 2, 2, 0)
+        case libvlc_MediaPlayerMuted:
+            e = player().get_mp().eventManager().onMuted( std::move( closure ) );
+            break;
+        case libvlc_MediaPlayerUnmuted:
+            e = player().get_mp().eventManager().onUnmuted( std::move( closure ) );
+            break;
+        case libvlc_MediaPlayerAudioVolume:
+            e = player().get_mp().eventManager().onAudioVolume( std::move( closure ) );
+            break;
+#endif
         default:
             break;
     }



View it on GitLab: https://code.videolan.org/videolan/npapi-vlc/compare/0aa3cb301066937d18ab2cbd2ec1994a9d261a36...8d974bf0364402963e3e743311e70970e055af8e

---
View it on GitLab: https://code.videolan.org/videolan/npapi-vlc/compare/0aa3cb301066937d18ab2cbd2ec1994a9d261a36...8d974bf0364402963e3e743311e70970e055af8e
You're receiving this email because of your account on code.videolan.org.


More information about the vlc-commits mailing list