[vlmc-devel] VLCMedia: Don't use an eventWaiter to wait for the duration to change
Hugo Beauzée-Luyssen
git at videolan.org
Thu Mar 24 13:22:26 CET 2016
vlmc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Mon Mar 21 19:47:44 2016 +0100| [911fe2c602c96366f07ad360e9ee1cca96b9699e] | committer: Hugo Beauzée-Luyssen
VLCMedia: Don't use an eventWaiter to wait for the duration to change
The media duration is enough, and is proven to work well in the media
library.
This might break file type detection since we can't rely on the media
player, but this commit is meant to ease up the integration of libvlcpp
by removing some eventWaiter usages. We will take advantage of libvlcpp
methods after the replacement is done, instead of implementing a bunch
of methods in the VLMC's vlc binding, just so we can remove it later
> https://code.videolan.org/videolan/vlmc/commit/911fe2c602c96366f07ad360e9ee1cca96b9699e
---
src/Backend/VLC/LibVLCpp/VLCMedia.cpp | 6 ++++++
src/Backend/VLC/LibVLCpp/VLCMedia.h | 1 +
src/Backend/VLC/VLCSource.cpp | 20 +-------------------
3 files changed, 8 insertions(+), 19 deletions(-)
diff --git a/src/Backend/VLC/LibVLCpp/VLCMedia.cpp b/src/Backend/VLC/LibVLCpp/VLCMedia.cpp
index 8ba6770..7292a97 100644
--- a/src/Backend/VLC/LibVLCpp/VLCMedia.cpp
+++ b/src/Backend/VLC/LibVLCpp/VLCMedia.cpp
@@ -140,3 +140,9 @@ Media::audioCodec() const
return m_tracks[i]->i_codec;
return 0;
}
+
+int64_t
+Media::getDuration()
+{
+ return libvlc_media_get_duration( *this );
+}
diff --git a/src/Backend/VLC/LibVLCpp/VLCMedia.h b/src/Backend/VLC/LibVLCpp/VLCMedia.h
index ed33bd0..a9ed9af 100644
--- a/src/Backend/VLC/LibVLCpp/VLCMedia.h
+++ b/src/Backend/VLC/LibVLCpp/VLCMedia.h
@@ -49,6 +49,7 @@ namespace LibVLCpp
void fetchTrackInfo();
unsigned int videoCodec() const;
unsigned int audioCodec() const;
+ int64_t getDuration();
private:
libvlc_media_track_t **m_tracks;
diff --git a/src/Backend/VLC/VLCSource.cpp b/src/Backend/VLC/VLCSource.cpp
index 27a813a..7e20599 100644
--- a/src/Backend/VLC/VLCSource.cpp
+++ b/src/Backend/VLC/VLCSource.cpp
@@ -63,13 +63,6 @@ VLCSource::createRenderer( ISourceRendererEventCb *callback )
return new VLCSourceRenderer( m_backend, this, callback );
}
-static bool
-checkLengthChanged( const libvlc_event_t* event )
-{
- Q_ASSERT( event->type == libvlc_MediaPlayerLengthChanged );
- return ( event->u.media_player_length_changed.new_length > 0 );
-}
-
bool
VLCSource::preparse()
{
@@ -78,22 +71,11 @@ VLCSource::preparse()
VmemRenderer* renderer = new VmemRenderer( m_backend, this, NULL );
LibVLCpp::MediaPlayer* mediaPlayer = renderer->mediaPlayer();
- {
- EventWaiter ew( mediaPlayer, true );
- ew.setValidationCallback( &checkLengthChanged );
- ew.add( libvlc_MediaPlayerLengthChanged );
- renderer->start();
- if ( ew.wait( 3000 ) != EventWaiter::Success )
- {
- delete renderer;
- return false;
- }
- }
m_media->parse();
m_nbVideoTracks = mediaPlayer->getNbVideoTrack();
m_nbAudioTracks = mediaPlayer->getNbAudioTrack();
//FIXME: handle images with something like m_length = 10000;
- m_length = mediaPlayer->getLength();
+ m_length = m_media->getDuration();
if ( hasVideo() == true )
{
mediaPlayer->getSize( &m_width, &m_height );
More information about the Vlmc-devel
mailing list