[Libreoffice-commits] core.git: 3 commits - avmedia/source

Minh Ngo nlminhtl at gmail.com
Sat Sep 14 08:24:32 PDT 2013


 avmedia/source/vlc/vlcplayer.cxx        |    4 +---
 avmedia/source/vlc/vlcwindow.cxx        |   27 +++++++++++++++++++++++----
 avmedia/source/vlc/vlcwindow.hxx        |    1 +
 avmedia/source/vlc/wrapper/Instance.cxx |    4 +---
 avmedia/source/vlc/wrapper/Media.cxx    |   17 ++++++++++++++---
 avmedia/source/vlc/wrapper/Media.hxx    |    2 ++
 avmedia/source/vlc/wrapper/Player.cxx   |   22 +++++-----------------
 avmedia/source/vlc/wrapper/Player.hxx   |    2 --
 avmedia/source/vlc/wrapper/Types.hxx    |    6 ++++++
 9 files changed, 53 insertions(+), 32 deletions(-)

New commits:
commit ce0ce2413d206908d60fa38c905f9da06f50be59
Author: Minh Ngo <nlminhtl at gmail.com>
Date:   Sat Sep 14 18:21:41 2013 +0300

    Fixing copying processes for wrapper components.
    
    Change-Id: Iae3f30d5754c3efac01d66f9d0d567874e44602d

diff --git a/avmedia/source/vlc/wrapper/Instance.cxx b/avmedia/source/vlc/wrapper/Instance.cxx
index b9b6ff9..8ec4732 100644
--- a/avmedia/source/vlc/wrapper/Instance.cxx
+++ b/avmedia/source/vlc/wrapper/Instance.cxx
@@ -38,9 +38,7 @@ namespace VLC
 
     Instance::Instance( const Instance& other )
     {
-        libvlc_release( mInstance );
-        mInstance = other.mInstance;
-        libvlc_retain( mInstance );
+        operator=(other);
     }
 
     const Instance& Instance::operator=( const Instance& other )
diff --git a/avmedia/source/vlc/wrapper/Media.cxx b/avmedia/source/vlc/wrapper/Media.cxx
index 5bf5bf0..0df5cbf 100644
--- a/avmedia/source/vlc/wrapper/Media.cxx
+++ b/avmedia/source/vlc/wrapper/Media.cxx
@@ -51,9 +51,8 @@ Media::Media( const rtl::OUString& url, Instance& instance )
 }
 
 Media::Media( const Media& other )
-    : mMedia( other.mMedia )
 {
-    libvlc_media_retain( mMedia );
+    operator=(other);
 }
 
 const Media& Media::operator=( const Media& other )
diff --git a/avmedia/source/vlc/wrapper/Player.cxx b/avmedia/source/vlc/wrapper/Player.cxx
index 2e4c356..657dd23 100644
--- a/avmedia/source/vlc/wrapper/Player.cxx
+++ b/avmedia/source/vlc/wrapper/Player.cxx
@@ -87,9 +87,8 @@ namespace VLC
     }
 
     Player::Player( const Player& other )
-        : mPlayer( other.mPlayer )
     {
-        libvlc_media_player_retain( mPlayer );
+        operator=( other );
     }
 
     const Player& Player::operator=( const Player& other )
commit 1bb7981525c671ebe78263114fe4a454b7e0ae42
Author: Minh Ngo <nlminhtl at gmail.com>
Date:   Sat Sep 14 18:19:32 2013 +0300

    Media zoom for Avmedia/vlc
    
    Change-Id: I2870b3fbeaa6fbb623f21dfde9a33a6048c60b85

diff --git a/avmedia/source/vlc/vlcwindow.cxx b/avmedia/source/vlc/vlcwindow.cxx
index b004875..6bdaa67 100644
--- a/avmedia/source/vlc/vlcwindow.cxx
+++ b/avmedia/source/vlc/vlcwindow.cxx
@@ -17,14 +17,27 @@ void SAL_CALL VLCWindow::update() throw (css::uno::RuntimeException)
 {
 }
 
-::sal_Bool SAL_CALL VLCWindow::setZoomLevel( css::media::ZoomLevel ) throw (css::uno::RuntimeException)
+::sal_Bool SAL_CALL VLCWindow::setZoomLevel( css::media::ZoomLevel eZoomLevel ) throw (css::uno::RuntimeException)
 {
-    return false;
+    sal_Bool bRet = false;
+
+    if( media::ZoomLevel_NOT_AVAILABLE != meZoomLevel &&
+        media::ZoomLevel_NOT_AVAILABLE != eZoomLevel )
+    {
+        if( eZoomLevel != meZoomLevel )
+        {
+            meZoomLevel = eZoomLevel;
+        }
+
+        bRet = true;
+    }
+
+    return bRet;
 }
 
 css::media::ZoomLevel SAL_CALL VLCWindow::getZoomLevel() throw (css::uno::RuntimeException)
 {
-    return css::media::ZoomLevel_NOT_AVAILABLE;
+    return meZoomLevel;
 }
 
 void SAL_CALL VLCWindow::setPointerType( ::sal_Int32 ) throw (css::uno::RuntimeException)
@@ -70,7 +83,13 @@ void SAL_CALL VLCWindow::setPosSize( sal_Int32, sal_Int32, sal_Int32, sal_Int32,
 awt::Rectangle SAL_CALL VLCWindow::getPosSize()
     throw (uno::RuntimeException)
 {
-    return awt::Rectangle();
+    awt::Rectangle aRet;
+
+    aRet.X = aRet.Y = 0;
+    aRet.Width = 320;
+    aRet.Height = 240;
+
+    return aRet;
 }
 
 void SAL_CALL VLCWindow::setVisible( sal_Bool )
diff --git a/avmedia/source/vlc/vlcwindow.hxx b/avmedia/source/vlc/vlcwindow.hxx
index 2aa3e47..ef06576 100644
--- a/avmedia/source/vlc/vlcwindow.hxx
+++ b/avmedia/source/vlc/vlcwindow.hxx
@@ -27,6 +27,7 @@ namespace vlc {
 class VLCWindow : public ::cppu::WeakImplHelper2 < ::com::sun::star::media::XPlayerWindow,
                                                    ::com::sun::star::lang::XServiceInfo >
 {
+    ::com::sun::star::media::ZoomLevel meZoomLevel;
 public:
     VLCWindow();
 
commit 6fe1efc01d6f9dc333a74a4e76e554b182651f60
Author: Minh Ngo <nlminhtl at gmail.com>
Date:   Sat Sep 14 18:18:38 2013 +0300

    Getting correct media file duration and time.
    
    Change-Id: I435175ad7b1f6576e501794ee87f334498000b4f

diff --git a/avmedia/source/vlc/vlcplayer.cxx b/avmedia/source/vlc/vlcplayer.cxx
index a43c412..37be348 100644
--- a/avmedia/source/vlc/vlcplayer.cxx
+++ b/avmedia/source/vlc/vlcplayer.cxx
@@ -57,13 +57,12 @@ void SAL_CALL VLCPlayer::stop() throw ( ::com::sun::star::uno::RuntimeException
 double SAL_CALL VLCPlayer::getDuration() throw ( ::com::sun::star::uno::RuntimeException )
 {
     ::osl::MutexGuard aGuard(m_aMutex);
-    return static_cast<double>( mPlayer.getLength() ) / MS_IN_SEC;
+    return static_cast<double>( mMedia.getDuration() ) / MS_IN_SEC;
 }
 
 void SAL_CALL VLCPlayer::setMediaTime( double fTime ) throw ( ::com::sun::star::uno::RuntimeException )
 {
     ::osl::MutexGuard aGuard(m_aMutex);
-
     if ( fTime < 0.00000001 && !mPlayer.isPlaying() )
     {
         mPlayer.stop();
@@ -174,7 +173,6 @@ uno::Reference< css::media::XPlayerWindow > SAL_CALL VLCPlayer::createPlayerWind
      throw ( ::com::sun::star::uno::RuntimeException )
 {
     ::osl::MutexGuard aGuard(m_aMutex);
-
     VLCWindow * const window = new VLCWindow;
 
     const intptr_t winID = GetWindowID( aArguments );
diff --git a/avmedia/source/vlc/wrapper/Media.cxx b/avmedia/source/vlc/wrapper/Media.cxx
index b893d42..5bf5bf0 100644
--- a/avmedia/source/vlc/wrapper/Media.cxx
+++ b/avmedia/source/vlc/wrapper/Media.cxx
@@ -11,6 +11,7 @@
 #include "Media.hxx"
 #include "SymbolLoader.hxx"
 #include "Instance.hxx"
+#include "Types.hxx"
 
 struct libvlc_instance_t;
 namespace VLC
@@ -20,6 +21,7 @@ namespace VLC
         libvlc_media_t* ( *libvlc_media_new_path ) ( libvlc_instance_t *p_instance, const char *path );
         void ( *libvlc_media_release ) ( libvlc_media_t *p_md );
         void ( *libvlc_media_retain ) ( libvlc_media_t *p_md );
+        libvlc_time_t ( *libvlc_media_get_duration ) ( libvlc_media_t *p_md );
 
         libvlc_media_t* InitMedia( const rtl::OUString& url, VLC::Instance& instance )
         {
@@ -36,7 +38,8 @@ bool Media::LoadSymbols()
     {
         SYM_MAP( libvlc_media_new_path ),
         SYM_MAP( libvlc_media_release ),
-        SYM_MAP( libvlc_media_retain )
+        SYM_MAP( libvlc_media_retain ),
+        SYM_MAP( libvlc_media_get_duration )
     };
 
     return InitApiMap( VLC_MEDIA_API );
@@ -62,6 +65,15 @@ const Media& Media::operator=( const Media& other )
     return *this;
 }
 
+int Media::getDuration() const
+{
+    const int duration = libvlc_media_get_duration( mMedia );
+    if (duration == -1)
+        return 0;
+
+    return duration;
+}
+
 Media::~Media()
 {
     libvlc_media_release( mMedia );
diff --git a/avmedia/source/vlc/wrapper/Media.hxx b/avmedia/source/vlc/wrapper/Media.hxx
index 0575e6e..a79edb3 100644
--- a/avmedia/source/vlc/wrapper/Media.hxx
+++ b/avmedia/source/vlc/wrapper/Media.hxx
@@ -25,6 +25,8 @@ namespace VLC
         Media( const Media& other );
         const Media& operator=( const Media& other );
 
+        int getDuration() const;
+
         virtual ~Media();
 
         inline operator libvlc_media_t*()
diff --git a/avmedia/source/vlc/wrapper/Player.cxx b/avmedia/source/vlc/wrapper/Player.cxx
index f2faee0..2e4c356 100644
--- a/avmedia/source/vlc/wrapper/Player.cxx
+++ b/avmedia/source/vlc/wrapper/Player.cxx
@@ -8,7 +8,7 @@
  */
 
 #include <rtl/ustring.h>
-
+#include "Types.hxx"
 #include "Player.hxx"
 #include "Media.hxx"
 #include "SymbolLoader.hxx"
@@ -18,12 +18,6 @@ namespace VLC
 {
     namespace
     {
-#if defined WNT
-        typedef __int64 libvlc_time_t;
-#else
-        typedef int64_t libvlc_time_t;
-#endif
-
         void ( *libvlc_media_player_retain ) ( libvlc_media_player_t *p_mi );
         libvlc_media_player_t * ( *libvlc_media_player_new_from_media ) ( libvlc_media_t *p_md );
         void ( *libvlc_media_player_release ) ( libvlc_media_player_t *p_mi );
@@ -33,7 +27,6 @@ namespace VLC
         void ( *libvlc_media_player_stop ) ( libvlc_media_player_t *p_mi );
         void ( *libvlc_media_player_set_time ) ( libvlc_media_player_t *p_mi, libvlc_time_t i_time );
         libvlc_time_t ( *libvlc_media_player_get_time ) ( libvlc_media_player_t *p_mi );
-        libvlc_time_t ( *libvlc_media_player_get_length ) ( libvlc_media_player_t *p_mi );
         float ( *libvlc_media_player_get_rate )( libvlc_media_player_t *p_mi );
         int ( *libvlc_audio_set_volume ) ( libvlc_media_player_t *p_mi, int i_volume );
         int ( *libvlc_audio_get_volume ) ( libvlc_media_player_t *p_mi );
@@ -67,7 +60,6 @@ namespace VLC
             SYM_MAP( libvlc_media_player_stop ),
             SYM_MAP( libvlc_media_player_set_time ),
             SYM_MAP( libvlc_media_player_get_time ),
-            SYM_MAP( libvlc_media_player_get_length ),
             SYM_MAP( libvlc_media_player_get_rate ),
             SYM_MAP( libvlc_audio_set_volume ),
             SYM_MAP( libvlc_audio_get_volume ),
@@ -135,7 +127,9 @@ namespace VLC
 
     int Player::getTime() const
     {
-        return libvlc_media_player_get_time( mPlayer );
+        const int time = libvlc_media_player_get_time( mPlayer );
+
+        return ( time == -1 ? 0 : time );
     }
 
     void Player::setMouseHandling(bool flag)
@@ -148,11 +142,6 @@ namespace VLC
         return libvlc_media_player_is_playing( mPlayer ) == 1;
     }
 
-    int Player::getLength() const
-    {
-        return libvlc_media_player_get_length( mPlayer );
-    }
-
     float Player::getRate() const
     {
         return libvlc_media_player_get_rate( mPlayer );
diff --git a/avmedia/source/vlc/wrapper/Player.hxx b/avmedia/source/vlc/wrapper/Player.hxx
index bb5e6b9..ba38026 100644
--- a/avmedia/source/vlc/wrapper/Player.hxx
+++ b/avmedia/source/vlc/wrapper/Player.hxx
@@ -39,8 +39,6 @@ namespace VLC
         int getTime() const;
         bool isPlaying() const;
 
-        int getLength() const;
-
         float getRate() const;
 
         void setVolume( int volume );
diff --git a/avmedia/source/vlc/wrapper/Types.hxx b/avmedia/source/vlc/wrapper/Types.hxx
index 55257b6..624ef13 100644
--- a/avmedia/source/vlc/wrapper/Types.hxx
+++ b/avmedia/source/vlc/wrapper/Types.hxx
@@ -5,6 +5,12 @@
 #ifndef _WRAPPER_TYPES_HXX
 #define _WRAPPER_TYPES_HXX
 
+#if defined WNT
+        typedef __int64 libvlc_time_t;
+#else
+        typedef int64_t libvlc_time_t;
+#endif
+
 extern "C" {
 
 // basic callback / event types we use


More information about the Libreoffice-commits mailing list