Commit 00b286e0 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Use named media players

parent 2c777eb0
......@@ -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;
}
......@@ -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;
......
......@@ -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 );
......
......@@ -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() ),
......
......@@ -28,7 +28,7 @@
GenericRenderer::GenericRenderer() :
m_paused( false )
{
m_mediaPlayer = new LibVLCpp::MediaPlayer();
m_mediaPlayer = new LibVLCpp::MediaPlayer( "Renderer" );
m_mediaPlayer->disableTitle();
}
......
......@@ -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 )
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment