[Libreoffice-commits] core.git: 2 commits - avmedia/source
Minh Ngo
nlminhtl at gmail.com
Sun Sep 15 09:43:19 PDT 2013
avmedia/source/vlc/vlcplayer.cxx | 16 ++++++++++++++++
avmedia/source/vlc/vlcplayer.hxx | 4 ++++
avmedia/source/vlc/vlcwindow.cxx | 21 ++++++++++++++++++---
avmedia/source/vlc/wrapper/Common.cxx | 9 ++++++++-
avmedia/source/vlc/wrapper/Common.hxx | 1 +
avmedia/source/vlc/wrapper/Media.cxx | 18 +++++++++++++++++-
avmedia/source/vlc/wrapper/Player.cxx | 28 ++++++++++++++++++++++++++--
avmedia/source/vlc/wrapper/Player.hxx | 5 +++++
8 files changed, 95 insertions(+), 7 deletions(-)
New commits:
commit fdd3f483ccafd23603252e133d643141bc17ce65
Author: Minh Ngo <nlminhtl at gmail.com>
Date: Sun Sep 15 19:41:54 2013 +0300
Avmedia/VLC: Zooming 1:2, 2:1, 1:1
Doesn't work nice yet :)
Change-Id: I0fbdaea1cc64a94a9b63975b8b24c8d7e6251f6f
diff --git a/avmedia/source/vlc/vlcplayer.cxx b/avmedia/source/vlc/vlcplayer.cxx
index cdabc30b..4a454d8 100644
--- a/avmedia/source/vlc/vlcplayer.cxx
+++ b/avmedia/source/vlc/vlcplayer.cxx
@@ -37,6 +37,16 @@ VLCPlayer::VLCPlayer( const rtl::OUString& url,
mPlayer.setMouseHandling( false );
}
+unsigned VLCPlayer::getWidth() const
+{
+ return mPlayer.getWidth();
+}
+
+unsigned VLCPlayer::getHeight() const
+{
+ return mPlayer.getHeight();
+}
+
void SAL_CALL VLCPlayer::start() throw ( ::com::sun::star::uno::RuntimeException )
{
::osl::MutexGuard aGuard(m_aMutex);
@@ -61,6 +71,12 @@ double SAL_CALL VLCPlayer::getDuration() throw ( ::com::sun::star::uno::RuntimeE
return static_cast<double>( mMedia.getDuration() ) / MS_IN_SEC;
}
+void SAL_CALL VLCPlayer::setScale( float factor )
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ mPlayer.setScale( factor );
+}
+
void SAL_CALL VLCPlayer::setMediaTime( double fTime ) throw ( ::com::sun::star::uno::RuntimeException )
{
::osl::MutexGuard aGuard(m_aMutex);
diff --git a/avmedia/source/vlc/vlcplayer.hxx b/avmedia/source/vlc/vlcplayer.hxx
index bb37f8a..cbc009c 100644
--- a/avmedia/source/vlc/vlcplayer.hxx
+++ b/avmedia/source/vlc/vlcplayer.hxx
@@ -57,6 +57,10 @@ public:
wrapper::Instance& instance,
wrapper::EventHandler& eh );
+ unsigned getWidth() const;
+ unsigned getHeight() const;
+
+ void SAL_CALL setScale( float factor );
void SAL_CALL setWindowID( const intptr_t windowID );
void SAL_CALL start() throw ( ::com::sun::star::uno::RuntimeException );
diff --git a/avmedia/source/vlc/vlcwindow.cxx b/avmedia/source/vlc/vlcwindow.cxx
index aab1ea8..073fc22 100644
--- a/avmedia/source/vlc/vlcwindow.cxx
+++ b/avmedia/source/vlc/vlcwindow.cxx
@@ -41,6 +41,21 @@ void SAL_CALL VLCWindow::update() throw (css::uno::RuntimeException)
meZoomLevel = eZoomLevel;
}
+ switch ( static_cast<int>( eZoomLevel ) )
+ {
+ case media::ZoomLevel_ORIGINAL:
+ mPlayer.setScale( 1.0 );
+ break;
+ case media::ZoomLevel_FIT_TO_WINDOW:
+ break;
+ case media::ZoomLevel_ZOOM_1_TO_2:
+ mPlayer.setScale( 0.5 );
+ break;
+ case media::ZoomLevel_ZOOM_2_TO_1:
+ mPlayer.setScale( 2.0 );
+ break;
+ }
+
bRet = true;
}
@@ -87,7 +102,7 @@ void SAL_CALL VLCWindow::removeEventListener( const uno::Reference< lang::XEvent
{
}
-void SAL_CALL VLCWindow::setPosSize( sal_Int32, sal_Int32, sal_Int32, sal_Int32, sal_Int16 )
+void SAL_CALL VLCWindow::setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags )
throw (uno::RuntimeException)
{
}
@@ -98,8 +113,8 @@ awt::Rectangle SAL_CALL VLCWindow::getPosSize()
awt::Rectangle aRet;
aRet.X = aRet.Y = 0;
- aRet.Width = 320;
- aRet.Height = 240;
+ aRet.Width = mPlayer.getWidth();
+ aRet.Height = mPlayer.getHeight();
return aRet;
}
diff --git a/avmedia/source/vlc/wrapper/Player.cxx b/avmedia/source/vlc/wrapper/Player.cxx
index e5d4f64..0b56e92 100644
--- a/avmedia/source/vlc/wrapper/Player.cxx
+++ b/avmedia/source/vlc/wrapper/Player.cxx
@@ -46,7 +46,10 @@ namespace
#error unknown OS
#endif
unsigned ( *libvlc_media_player_has_vout ) ( libvlc_media_player_t *p_mi );
- void ( *libvlc_video_set_mouse_input ) ( libvlc_media_player_t *p_mi, unsigned on);
+ void ( *libvlc_video_set_mouse_input ) ( libvlc_media_player_t *p_mi, unsigned on );
+ void ( *libvlc_video_set_scale ) ( libvlc_media_player_t *p_mi, float f_factor );
+ int ( *libvlc_video_get_size ) ( libvlc_media_player_t *p_mi, unsigned num,
+ unsigned *px, unsigned *py );
}
namespace avmedia
@@ -82,7 +85,9 @@ namespace wrapper
#endif
SYM_MAP( libvlc_media_player_has_vout ),
SYM_MAP( libvlc_video_set_mouse_input ),
- SYM_MAP( libvlc_media_player_retain )
+ SYM_MAP( libvlc_media_player_retain ),
+ SYM_MAP( libvlc_video_set_scale ),
+ SYM_MAP( libvlc_video_get_size )
};
return InitApiMap( VLC_PLAYER_API );
@@ -138,6 +143,25 @@ namespace wrapper
return ( time == -1 ? 0 : time );
}
+ void Player::setScale( float factor )
+ {
+ libvlc_video_set_scale( mPlayer, factor );
+ }
+
+ unsigned Player::getWidth() const
+ {
+ unsigned width, height;
+ libvlc_video_get_size( mPlayer, 0, &width, &height );
+ return width;
+ }
+
+ unsigned Player::getHeight() const
+ {
+ unsigned width, height;
+ libvlc_video_get_size( mPlayer, 0, &width, &height );
+ return height;
+ }
+
void Player::setMouseHandling(bool flag)
{
libvlc_video_set_mouse_input( mPlayer, flag );
diff --git a/avmedia/source/vlc/wrapper/Player.hxx b/avmedia/source/vlc/wrapper/Player.hxx
index fa387cb..7aa8147 100644
--- a/avmedia/source/vlc/wrapper/Player.hxx
+++ b/avmedia/source/vlc/wrapper/Player.hxx
@@ -57,6 +57,11 @@ namespace wrapper
bool hasVout() const;
+ void setScale( float factor );
+
+ unsigned getWidth() const;
+ unsigned getHeight() const;
+
inline operator libvlc_media_player_t*()
{
return mPlayer;
commit e62092da17170faa93b61a3a2d7a7ce4b29cc1fc
Author: Minh Ngo <nlminhtl at gmail.com>
Date: Sun Sep 15 19:40:15 2013 +0300
Avmedia/VLC: Error handling & Fixing a bug with a zero duration.
Change-Id: I45baeca91b9f5fc725164490b5880c9040acd679
diff --git a/avmedia/source/vlc/wrapper/Common.cxx b/avmedia/source/vlc/wrapper/Common.cxx
index a851038..1ed5256 100644
--- a/avmedia/source/vlc/wrapper/Common.cxx
+++ b/avmedia/source/vlc/wrapper/Common.cxx
@@ -12,6 +12,7 @@
namespace
{
const char* ( *libvlc_get_version ) (void);
+ char * ( * libvlc_errmsg ) (void);
}
namespace avmedia
@@ -24,7 +25,8 @@ bool Common::LoadSymbols()
{
ApiMap VLC_COMMON_API[] =
{
- SYM_MAP( libvlc_get_version )
+ SYM_MAP( libvlc_get_version ),
+ SYM_MAP( libvlc_errmsg )
};
return InitApiMap( VLC_COMMON_API );
@@ -34,6 +36,11 @@ const char* Common::Version()
{
return libvlc_get_version();
}
+
+const char* Common::LastErrorMessage()
+{
+ return libvlc_errmsg();
+}
}
}
}
\ No newline at end of file
diff --git a/avmedia/source/vlc/wrapper/Common.hxx b/avmedia/source/vlc/wrapper/Common.hxx
index edfb338..9cdffcc 100644
--- a/avmedia/source/vlc/wrapper/Common.hxx
+++ b/avmedia/source/vlc/wrapper/Common.hxx
@@ -21,6 +21,7 @@ namespace wrapper
public:
static bool LoadSymbols();
static const char* Version();
+ static const char* LastErrorMessage();
};
}
}
diff --git a/avmedia/source/vlc/wrapper/Media.cxx b/avmedia/source/vlc/wrapper/Media.cxx
index d0538df..c2627de 100644
--- a/avmedia/source/vlc/wrapper/Media.cxx
+++ b/avmedia/source/vlc/wrapper/Media.cxx
@@ -12,6 +12,7 @@
#include "SymbolLoader.hxx"
#include "Instance.hxx"
#include "Types.hxx"
+#include "Common.hxx"
struct libvlc_instance_t;
@@ -27,6 +28,8 @@ namespace
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 );
+ void ( *libvlc_media_parse ) ( libvlc_media_t *p_md );
+ int ( *libvlc_media_is_parsed ) ( libvlc_media_t *p_md );
libvlc_media_t* InitMedia( const rtl::OUString& url, Instance& instance )
{
@@ -44,7 +47,9 @@ bool Media::LoadSymbols()
SYM_MAP( libvlc_media_new_path ),
SYM_MAP( libvlc_media_release ),
SYM_MAP( libvlc_media_retain ),
- SYM_MAP( libvlc_media_get_duration )
+ SYM_MAP( libvlc_media_get_duration ),
+ SYM_MAP( libvlc_media_parse ),
+ SYM_MAP( libvlc_media_is_parsed )
};
return InitApiMap( VLC_MEDIA_API );
@@ -71,9 +76,20 @@ const Media& Media::operator=( const Media& other )
int Media::getDuration() const
{
+ if ( !libvlc_media_is_parsed( mMedia ) )
+ libvlc_media_parse( mMedia );
+
const int duration = libvlc_media_get_duration( mMedia );
if (duration == -1)
+ {
+ SAL_WARN("avmedia", Common::LastErrorMessage());
return 0;
+ }
+ else if (duration == 0)
+ {
+ // A duration must be greater than 0
+ return 1;
+ }
return duration;
}
More information about the Libreoffice-commits
mailing list