diff options
author | Minh Ngo <nlminhtl@gmail.com> | 2013-09-14 18:18:38 +0300 |
---|---|---|
committer | Minh Ngo <nlminhtl@gmail.com> | 2013-09-14 18:22:22 +0300 |
commit | 6fe1efc01d6f9dc333a74a4e76e554b182651f60 (patch) | |
tree | 04008e65380ca0bca9f6a088f5b3806875f6d7d3 /avmedia/source | |
parent | d03ec9f32d7a6331e6bc49cf54a54d15a1399638 (diff) |
Getting correct media file duration and time.
Change-Id: I435175ad7b1f6576e501794ee87f334498000b4f
Diffstat (limited to 'avmedia/source')
-rw-r--r-- | avmedia/source/vlc/vlcplayer.cxx | 4 | ||||
-rw-r--r-- | avmedia/source/vlc/wrapper/Media.cxx | 14 | ||||
-rw-r--r-- | avmedia/source/vlc/wrapper/Media.hxx | 2 | ||||
-rw-r--r-- | avmedia/source/vlc/wrapper/Player.cxx | 19 | ||||
-rw-r--r-- | avmedia/source/vlc/wrapper/Player.hxx | 2 | ||||
-rw-r--r-- | avmedia/source/vlc/wrapper/Types.hxx | 6 |
6 files changed, 26 insertions, 21 deletions
diff --git a/avmedia/source/vlc/vlcplayer.cxx b/avmedia/source/vlc/vlcplayer.cxx index a43c412d3d55..37be3485d078 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 b893d425077d..5bf5bf0c4a97 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 0575e6e93c29..a79edb321ccb 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 f2faee0bfe3a..2e4c3561ddd4 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 bb5e6b9fc886..ba38026d873b 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 55257b6c4efd..624ef13df413 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 |