[vlmc-devel] Use named media players
Hugo Beauzée-Luyssen
git at videolan.org
Sat Feb 8 18:48:25 CET 2014
vlmc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Sat Feb 8 15:51:07 2014 +0200| [00b286e02115523887904b3b43072119058734b2] | committer: Hugo Beauzée-Luyssen
Use named media players
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=00b286e02115523887904b3b43072119058734b2
---
src/LibVLCpp/VLCMediaPlayer.cpp | 28 ++++++++++++++++++++++++----
src/LibVLCpp/VLCMediaPlayer.h | 6 +++++-
src/Media/Transcoder.cpp | 2 +-
src/Metadata/MetaDataManager.cpp | 2 +-
src/Renderer/GenericRenderer.cpp | 2 +-
src/Settings/SettingValue.cpp | 2 +-
src/Workflow/ClipWorkflow.cpp | 2 ++
7 files changed, 35 insertions(+), 9 deletions(-)
diff --git a/src/LibVLCpp/VLCMediaPlayer.cpp b/src/LibVLCpp/VLCMediaPlayer.cpp
index c0b8520..580746d 100644
--- a/src/LibVLCpp/VLCMediaPlayer.cpp
+++ b/src/LibVLCpp/VLCMediaPlayer.cpp
@@ -29,7 +29,8 @@
using namespace LibVLCpp;
-MediaPlayer::MediaPlayer() : m_media( NULL )
+MediaPlayer::MediaPlayer()
+ : m_media( NULL )
{
m_internalPtr = libvlc_media_player_new( LibVLCpp::Instance::getInstance()->getInternalPtr() );
// Initialize the event manager
@@ -37,7 +38,19 @@ MediaPlayer::MediaPlayer() : m_media( NULL )
registerEvents();
}
-MediaPlayer::MediaPlayer( Media* media ) : m_media( media )
+MediaPlayer::MediaPlayer( const QString& name )
+ : m_name( name )
+ , m_media( NULL )
+{
+ m_internalPtr = libvlc_media_player_new( LibVLCpp::Instance::getInstance()->getInternalPtr() );
+ // Initialize the event manager
+ p_em = libvlc_media_player_event_manager( m_internalPtr );
+ registerEvents();
+}
+
+MediaPlayer::MediaPlayer( const QString& name, Media* media )
+ : m_name( name )
+ , m_media( media )
{
m_internalPtr = libvlc_media_player_new_from_media( media->getInternalPtr() );
@@ -120,12 +133,14 @@ MediaPlayer::callbacks( const libvlc_event_t* event, void* ptr )
{
Q_ASSERT_X( event->type >= libvlc_MediaPlayerMediaChanged &&
event->type < libvlc_MediaListItemAdded, "event callback", "Only libvlc_MediaPlayer* events are supported" );
+
+ MediaPlayer* self = reinterpret_cast<MediaPlayer*>( ptr );
+
if (event->type != libvlc_MediaPlayerPositionChanged &&
event->type != libvlc_MediaPlayerTimeChanged)
{
- qDebug() << ptr << libvlc_event_type_name(event->type);
+ qDebug() << self->m_name << "Event received:" << libvlc_event_type_name(event->type);
}
- MediaPlayer* self = reinterpret_cast<MediaPlayer*>( ptr );
self->checkForWaitedEvents( event );
@@ -384,3 +399,8 @@ MediaPlayer::waitForEvent( unsigned long timeoutDuration )
return Timeout;
return ( found ? Success : Canceled );
}
+
+void MediaPlayer::setName(const QString &name)
+{
+ m_name = name;
+}
diff --git a/src/LibVLCpp/VLCMediaPlayer.h b/src/LibVLCpp/VLCMediaPlayer.h
index 8f6c442..9004d50 100644
--- a/src/LibVLCpp/VLCMediaPlayer.h
+++ b/src/LibVLCpp/VLCMediaPlayer.h
@@ -51,7 +51,8 @@ namespace LibVLCpp
typedef bool (*CheckEventCallback)(const MediaPlayer*, const libvlc_event_t*);
MediaPlayer();
- MediaPlayer( Media* media );
+ MediaPlayer(const QString &name);
+ MediaPlayer(const QString &name, Media* media );
~MediaPlayer();
void play();
void pause();
@@ -133,12 +134,15 @@ namespace LibVLCpp
*/
MediaPlayer::EventWaitResult waitForEvent( unsigned long timeout = ULONG_MAX );
+ void setName( const QString& name );
+
private:
static void callbacks( const libvlc_event_t* event, void* self );
void registerEvents();
void checkForWaitedEvents( const libvlc_event_t* event );
private:
+ QString m_name;
libvlc_event_manager_t* p_em;
Media* m_media;
diff --git a/src/Media/Transcoder.cpp b/src/Media/Transcoder.cpp
index 21e08cd..e46de35 100644
--- a/src/Media/Transcoder.cpp
+++ b/src/Media/Transcoder.cpp
@@ -51,7 +51,7 @@ Transcoder::transcodeToPs()
m_destinationFile = outputDir + '/' + m_media->fileInfo()->baseName() + ".ps";
QString option = ":sout=file://" + m_destinationFile;
media->addOption( option.toUtf8().constData() );
- LibVLCpp::MediaPlayer *mp = new LibVLCpp::MediaPlayer( media );
+ LibVLCpp::MediaPlayer *mp = new LibVLCpp::MediaPlayer( "Transcoder", media );
connect( mp, SIGNAL( positionChanged( float ) ), this, SIGNAL( progress( float ) ) );
connect( mp, SIGNAL( endReached() ), this, SLOT( transcodeFinished() ) );
emit notify( "Transcoding " + m_media->fileInfo()->absoluteFilePath() + " to " + m_destinationFile );
diff --git a/src/Metadata/MetaDataManager.cpp b/src/Metadata/MetaDataManager.cpp
index 2adbbb2..156fd20 100644
--- a/src/Metadata/MetaDataManager.cpp
+++ b/src/Metadata/MetaDataManager.cpp
@@ -46,7 +46,7 @@ MetaDataManager::launchComputing( Media *media )
{
emit startingComputing( media );
m_computeInProgress = true;
- m_mediaPlayer = new LibVLCpp::MediaPlayer;
+ m_mediaPlayer = new LibVLCpp::MediaPlayer( "MetaDataManager" );
MetaDataWorker* worker = new MetaDataWorker( m_mediaPlayer, media );
connect( worker, SIGNAL( computed() ),
this, SLOT( computingCompleted() ),
diff --git a/src/Renderer/GenericRenderer.cpp b/src/Renderer/GenericRenderer.cpp
index 3cc5799..583d240 100644
--- a/src/Renderer/GenericRenderer.cpp
+++ b/src/Renderer/GenericRenderer.cpp
@@ -28,7 +28,7 @@
GenericRenderer::GenericRenderer() :
m_paused( false )
{
- m_mediaPlayer = new LibVLCpp::MediaPlayer();
+ m_mediaPlayer = new LibVLCpp::MediaPlayer( "Renderer" );
m_mediaPlayer->disableTitle();
}
diff --git a/src/Settings/SettingValue.cpp b/src/Settings/SettingValue.cpp
index ff9c230..36ac70a 100644
--- a/src/Settings/SettingValue.cpp
+++ b/src/Settings/SettingValue.cpp
@@ -93,7 +93,7 @@ SettingValue::flags() const
void
SettingValue::setLimits( const QVariant& min, const QVariant& max )
{
- Q_ASSERT_X( ( ( m_flags & Clamped ) != 0 ), "SettingVaklue", "Setting limits to a non-clamped value" );
+ Q_ASSERT_X( ( ( m_flags & Clamped ) != 0 ), "SettingValue", "Setting limits to a non-clamped value" );
if ( min.isValid() == true )
m_min = min;
if ( max.isValid() == true )
diff --git a/src/Workflow/ClipWorkflow.cpp b/src/Workflow/ClipWorkflow.cpp
index 15dd794..6758fbb 100644
--- a/src/Workflow/ClipWorkflow.cpp
+++ b/src/Workflow/ClipWorkflow.cpp
@@ -31,6 +31,7 @@
#include "VLCMediaPlayer.h"
#include <QReadWriteLock>
+#include <QStringBuilder>
#include <QWaitCondition>
#include <QtDebug>
@@ -65,6 +66,7 @@ ClipWorkflow::initialize()
initializeVlcOutput();
m_vlcMedia->addOption( createSoutChain() );
m_mediaPlayer = MemoryPool<LibVLCpp::MediaPlayer>::getInstance()->get();
+ m_mediaPlayer->setName( "ClipWorkflow " % m_clipHelper->uuid().toString() );
m_mediaPlayer->setMedia( m_vlcMedia );
m_mediaPlayer->disableTitle();
More information about the Vlmc-devel
mailing list