[vlc-commits] Don't use fps() deprecated method

Hugo Beauzée-Luyssen git at videolan.org
Tue Dec 8 17:05:09 CET 2015


npapi-vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Tue Dec  8 16:37:57 2015 +0100| [3fdf1f6b29a55a72cc6e139bd379d34a7e2854f0] | committer: Hugo Beauzée-Luyssen

Don't use fps() deprecated method

> https://code.videolan.org/videolan/npapi-vlc/commit/3fdf1f6b29a55a72cc6e139bd379d34a7e2854f0
---

 activex/vlccontrol2.cpp       | 14 +++++++++++++-
 npapi/npruntime/npolibvlc.cpp | 14 +++++++++++++-
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/activex/vlccontrol2.cpp b/activex/vlccontrol2.cpp
index 681fb24..922a77b 100644
--- a/activex/vlccontrol2.cpp
+++ b/activex/vlccontrol2.cpp
@@ -699,7 +699,19 @@ STDMETHODIMP VLCInput::get_fps(double* fps)
     if( NULL == fps )
         return E_POINTER;
 
-    *fps = static_cast<double>( _plug->get_player().get_mp().fps() );
+    auto media = _plug->get_player().get_mp().media();
+    if ( media == nullptr )
+        return INVOKERESULT_GENERIC_ERROR;
+    auto tracks = media->tracks();
+    for ( const auto& t : tracks )
+    {
+        if ( t.type() == VLC::MediaTrack::Type::Video )
+        {
+            *fps = (float)( (float)t.fpsNum() / (float)t.fpsDen() );
+            return S_OK;
+        }
+    }
+    *fps = 0.0;
 
     return S_OK;
 }
diff --git a/npapi/npruntime/npolibvlc.cpp b/npapi/npruntime/npolibvlc.cpp
index eb2fc9b..b6c76e7 100644
--- a/npapi/npruntime/npolibvlc.cpp
+++ b/npapi/npruntime/npolibvlc.cpp
@@ -472,7 +472,19 @@ LibvlcInputNPObject::getProperty(int index, npapi::OutVariant& result)
             }
             case ID_input_fps:
             {
-                result = mp.fps();
+                auto media = mp.media();
+                if ( media == nullptr )
+                    return INVOKERESULT_GENERIC_ERROR;
+                auto tracks = media->tracks();
+                for ( const auto& t : tracks )
+                {
+                    if ( t.type() == VLC::MediaTrack::Type::Video )
+                    {
+                        result = (float)( (float)t.fpsNum() / (float)t.fpsDen() );
+                        return INVOKERESULT_GENERIC_ERROR;
+                    }
+                }
+                result = 0.0f;
                 return INVOKERESULT_NO_ERROR;
             }
             case ID_input_hasvout:



More information about the vlc-commits mailing list