Commit 72084a0b authored by luyikei's avatar luyikei

Rename Consumer to Output

parent 0163177e
......@@ -32,7 +32,7 @@
namespace Backend
{
class IConsumer;
class IOutput;
class IProfile;
class IFilterInfo;
......
/*****************************************************************************
* IConsumer: Defines an interface to control a player
* IOutput: Defines an interface to control a player
*****************************************************************************
* Copyright (C) 2008-2016 VideoLAN
*
......@@ -20,8 +20,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef IRENDERER_H
#define IRENDERER_H
#ifndef IOUTPUT_H
#define IOUTPUT_H
#include <string>
#include <cstdint>
......@@ -33,22 +33,22 @@ namespace Backend
{
class IProducer;
class IConsumerEventCb
class IOutputEventCb
{
public:
virtual ~IConsumerEventCb() = default;
virtual ~IOutputEventCb() = default;
virtual void onPlaying() = 0;
virtual void onStopped() = 0;
virtual void onVolumeChanged() = 0;
};
class IConsumer : virtual public IService
class IOutput : virtual public IService
{
public:
virtual ~IConsumer() = default;
virtual ~IOutput() = default;
virtual void setName( const char* name ) = 0;
virtual void setCallback( IConsumerEventCb* callback ) = 0;
virtual void setCallback( IOutputEventCb* callback ) = 0;
/**
* @brief start Initializes and launches playback.
*/
......@@ -64,4 +64,4 @@ namespace Backend
};
}
#endif // IRENDERER_H
#endif // IOUTPUT_H
......@@ -33,12 +33,12 @@ namespace Mlt
{
class Repository;
class Profile;
class Consumer;
class Output;
}
namespace Backend
{
class IConsumer;
class IOutput;
class IProducer;
class IProfile;
class IClip;
......
/*****************************************************************************
* MLTConsumer.cpp: Wrapper of Mlt::Consumer
* MLTOutput.cpp: Wrapper of Mlt::Output
*****************************************************************************
* Copyright (C) 2008-2016 VideoLAN
*
......@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "MLTConsumer.h"
#include "MLTOutput.h"
#include "MLTProducer.h"
#include "MLTProfile.h"
#include "MLTBackend.h"
......@@ -33,13 +33,13 @@
using namespace Backend::MLT;
MLTConsumer::MLTConsumer()
: MLTConsumer( Backend::instance()->profile(), "sdl" )
MLTOutput::MLTOutput()
: MLTOutput( Backend::instance()->profile(), "sdl" )
{
}
MLTConsumer::MLTConsumer( Backend::IProfile& profile, const char *id, Backend::IConsumerEventCb* callback )
MLTOutput::MLTOutput( Backend::IProfile& profile, const char *id, Backend::IOutputEventCb* callback )
: m_callback( callback )
, m_producer( nullptr )
{
......@@ -50,14 +50,14 @@ MLTConsumer::MLTConsumer( Backend::IProfile& profile, const char *id, Backend::I
throw InvalidServiceException();
}
MLTConsumer::~MLTConsumer()
MLTOutput::~MLTOutput()
{
stop();
delete m_consumer;
}
void
MLTConsumer::onConsumerStarted( void*, MLTConsumer* self )
MLTOutput::onOutputStarted( void*, MLTOutput* self )
{
if ( self->m_callback == nullptr )
return;
......@@ -65,7 +65,7 @@ MLTConsumer::onConsumerStarted( void*, MLTConsumer* self )
}
void
MLTConsumer::onConsumerStopped( void*, MLTConsumer* self )
MLTOutput::onOutputStopped( void*, MLTOutput* self )
{
if ( self->m_callback == nullptr )
return;
......@@ -73,53 +73,53 @@ MLTConsumer::onConsumerStopped( void*, MLTConsumer* self )
}
void
MLTConsumer::setName( const char* name )
MLTOutput::setName( const char* name )
{
m_name = std::string( name );
}
void
MLTConsumer::setCallback(Backend::IConsumerEventCb *callback)
MLTOutput::setCallback(Backend::IOutputEventCb *callback)
{
if ( callback == nullptr )
return;
m_callback = callback;
m_consumer->listen( "consumer-thread-started", this, (mlt_listener)MLTConsumer::onConsumerStarted );
m_consumer->listen( "consumer-stopped", this, (mlt_listener)MLTConsumer::onConsumerStopped );
m_consumer->listen( "consumer-thread-started", this, (mlt_listener)MLTOutput::onOutputStarted );
m_consumer->listen( "consumer-stopped", this, (mlt_listener)MLTOutput::onOutputStopped );
}
void
MLTConsumer::start()
MLTOutput::start()
{
m_consumer->start();
}
void
MLTConsumer::stop()
MLTOutput::stop()
{
m_consumer->stop();
}
bool
MLTConsumer::isStopped() const
MLTOutput::isStopped() const
{
return m_consumer->is_stopped();
}
int
MLTConsumer::volume() const
MLTOutput::volume() const
{
return m_consumer->get_double( "volume" ) * 100;
}
void
MLTConsumer::setVolume( int volume )
MLTOutput::setVolume( int volume )
{
m_consumer->set( "volume", volume / 100.f );
}
bool
MLTConsumer::connect( Backend::IProducer& producer )
MLTOutput::connect( Backend::IProducer& producer )
{
MLTProducer* mltProducer = dynamic_cast<MLTProducer*>( &producer );
assert( mltProducer );
......@@ -128,71 +128,71 @@ MLTConsumer::connect( Backend::IProducer& producer )
}
bool
MLTConsumer::isConnected() const
MLTOutput::isConnected() const
{
return m_producer != nullptr;
}
void
MLTSdlConsumer::setWindowId( intptr_t id )
MLTSdlOutput::setWindowId( intptr_t id )
{
m_consumer->set( "window_id", std::to_string( id ).c_str() );
}
void
MLTFFmpegConsumer::setTarget( const char* path )
MLTFFmpegOutput::setTarget( const char* path )
{
m_consumer->set( "target", path );
}
void
MLTFFmpegConsumer::setWidth( int width )
MLTFFmpegOutput::setWidth( int width )
{
m_consumer->set( "width", width );
}
void
MLTFFmpegConsumer::setHeight( int height )
MLTFFmpegOutput::setHeight( int height )
{
m_consumer->set( "height", height );
}
void
MLTFFmpegConsumer::setFrameRate( int num, int den )
MLTFFmpegOutput::setFrameRate( int num, int den )
{
m_consumer->set( "frame_rate_num", num );
m_consumer->set( "frame_rate_den", den );
}
void
MLTFFmpegConsumer::setAspectRatio( int num, int den )
MLTFFmpegOutput::setAspectRatio( int num, int den )
{
m_consumer->set( "display_aspect_num", num );
m_consumer->set( "display_aspect_den", den );
}
void
MLTFFmpegConsumer::setVideoBitrate( int kbps )
MLTFFmpegOutput::setVideoBitrate( int kbps )
{
std::string str = std::to_string( kbps ) + "K";
m_consumer->set( "vb", str.c_str() );
}
void
MLTFFmpegConsumer::setAudioBitrate( int kbps )
MLTFFmpegOutput::setAudioBitrate( int kbps )
{
std::string str = std::to_string( kbps ) + "K";
m_consumer->set( "ab", str.c_str() );
}
void
MLTFFmpegConsumer::setChannels( int channels )
MLTFFmpegOutput::setChannels( int channels )
{
m_consumer->set( "channels", channels );
}
void
MLTFFmpegConsumer::setAudioSampleRate( int rate )
MLTFFmpegOutput::setAudioSampleRate( int rate )
{
m_consumer->set( "frequency", rate );
}
/*****************************************************************************
* MLTConsumer.h: Wrapper of Mlt::Consumer
* MLTOutput.h: Wrapper of Mlt::Output
*****************************************************************************
* Copyright (C) 2008-2016 VideoLAN
*
......@@ -20,11 +20,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef MLTCONSUMER_H
#define MLTCONSUMER_H
#ifndef MLTOUTPUT_H
#define MLTOUTPUT_H
#include "MLTService.h"
#include "Backend/IConsumer.h"
#include "Backend/IOutput.h"
#include "Backend/IBackend.h"
#include "Backend/IProfile.h"
......@@ -41,18 +41,18 @@ namespace MLT
{
class MLTProducer;
class MLTConsumer : public IConsumer, public MLTService
class MLTOutput : public IOutput, public MLTService
{
public:
MLTConsumer();
MLTConsumer( IProfile& profile, const char *id, IConsumerEventCb* callback = nullptr );
virtual ~MLTConsumer();
MLTOutput();
MLTOutput( IProfile& profile, const char *id, IOutputEventCb* callback = nullptr );
virtual ~MLTOutput();
static void onConsumerStarted( void* owner, MLTConsumer* self );
static void onConsumerStopped( void* owner, MLTConsumer* self );
static void onOutputStarted( void* owner, MLTOutput* self );
static void onOutputStopped( void* owner, MLTOutput* self );
virtual void setName( const char* name ) override;
virtual void setCallback( IConsumerEventCb* callback ) override;
virtual void setCallback( IOutputEventCb* callback ) override;
virtual void start() override;
virtual void stop() override;
......@@ -66,25 +66,25 @@ class MLTConsumer : public IConsumer, public MLTService
protected:
Mlt::Consumer* m_consumer;
IConsumerEventCb* m_callback;
IOutputEventCb* m_callback;
MLTProducer* m_producer;
std::string m_name;
};
class MLTSdlConsumer : public MLTConsumer
class MLTSdlOutput : public MLTOutput
{
public:
MLTSdlConsumer()
: MLTConsumer( Backend::instance()->profile(), "sdl" ) { }
MLTSdlOutput()
: MLTOutput( Backend::instance()->profile(), "sdl" ) { }
void setWindowId( intptr_t id );
};
class MLTFFmpegConsumer : public MLTConsumer
class MLTFFmpegOutput : public MLTOutput
{
public:
MLTFFmpegConsumer()
: MLTConsumer( Backend::instance()->profile(), "avformat" ) { }
MLTFFmpegOutput()
: MLTOutput( Backend::instance()->profile(), "avformat" ) { }
void setTarget( const char* path );
void setWidth( int width );
......@@ -101,4 +101,4 @@ class MLTFFmpegConsumer : public MLTConsumer
}
}
#endif // MLTCONSUMER_H
#endif // MLTOUTPUT_H
......@@ -104,7 +104,7 @@ class MLTProducer : virtual public IProducer, public MLTService
int m_nbVideoTracks;
int m_nbAudioTracks;
friend class MLTConsumer;
friend class MLTOutput;
friend class MLTTrack;
friend class MLTTractor;
};
......
......@@ -29,7 +29,7 @@ namespace Mlt
{
class Repository;
class Profile;
class Consumer;
class Output;
}
namespace Backend
......@@ -62,7 +62,7 @@ class MLTProfile : public IProfile
Mlt::Profile* m_profile;
// To access Mlt::Profile
friend class MLTConsumer;
friend class MLTOutput;
friend class MLTProducer;
friend class MLTBackend;
friend class MLTTrack;
......
......@@ -59,7 +59,7 @@ SET(VLMC_SRCS
Commands/Commands.cpp
Backend/IBackend.h
Backend/IService.h
Backend/IConsumer.h
Backend/IOutput.h
Backend/IProducer.h
Backend/ITrack.h
Backend/IProfile.h
......@@ -67,7 +67,7 @@ SET(VLMC_SRCS
Backend/ITransition.h
Backend/IFilter.h
Backend/MLT/MLTBackend.cpp
Backend/MLT/MLTConsumer.cpp
Backend/MLT/MLTOutput.cpp
Backend/MLT/MLTProducer.cpp
Backend/MLT/MLTTrack.cpp
Backend/MLT/MLTService.cpp
......@@ -94,7 +94,7 @@ SET(VLMC_SRCS
Tools/ErrorHandler.cpp
Tools/MemoryPool.hpp
Tools/RendererEventWatcher.cpp
Tools/ConsumerEventWatcher.cpp
Tools/OutputEventWatcher.cpp
Tools/Singleton.hpp
Tools/Toggleable.hpp
Tools/VlmcDebug.h
......
......@@ -25,7 +25,7 @@
#include "Media/Clip.h"
#include "Renderer/ClipRenderer.h"
#include "Backend/MLT/MLTConsumer.h"
#include "Backend/MLT/MLTOutput.h"
#include "PreviewWidget.h"
#include "PreviewRuler.h"
#include "RenderWidget.h"
......@@ -72,9 +72,9 @@ PreviewWidget::setRenderer( AbstractRenderer* renderer )
// Give the renderer to the ruler
m_ui->rulerWidget->setRenderer( m_renderer );
auto consumer = new Backend::MLT::MLTSdlConsumer;
consumer->setWindowId( m_ui->renderWidget->id() );
m_renderer->setConsumer( std::unique_ptr<Backend::IConsumer>( consumer ) );
auto output = new Backend::MLT::MLTSdlOutput;
output->setWindowId( m_ui->renderWidget->id() );
m_renderer->setOutput( std::unique_ptr<Backend::IOutput>( output ) );
#if defined ( Q_OS_MAC )
/* Releases the NSView in the RenderWidget*/
......
......@@ -25,7 +25,7 @@
#include "AbstractRenderer.h"
#include "Tools/RendererEventWatcher.h"
#include "Backend/MLT/MLTConsumer.h"
#include "Backend/MLT/MLTOutput.h"
#include <QtGlobal>
......@@ -56,7 +56,7 @@ AbstractRenderer::eventWatcher()
void
AbstractRenderer::stop()
{
m_consumer->stop();
m_output->stop();
}
void
......@@ -69,12 +69,12 @@ AbstractRenderer::setPosition( qint64 pos )
void
AbstractRenderer::togglePlayPause()
{
if ( m_producer == nullptr || m_consumer.get() == nullptr )
if ( m_producer == nullptr || m_output.get() == nullptr )
return;
if ( m_consumer->isStopped() )
if ( m_output->isStopped() )
{
m_consumer->start();
m_output->start();
m_producer->setPause( false );
}
else
......@@ -84,13 +84,13 @@ AbstractRenderer::togglePlayPause()
int
AbstractRenderer::getVolume() const
{
return m_consumer->volume();
return m_output->volume();
}
void
AbstractRenderer::setVolume( int volume )
{
m_consumer->setVolume( volume );
m_output->setVolume( volume );
}
void
......@@ -150,7 +150,7 @@ AbstractRenderer::isPaused() const
bool
AbstractRenderer::isRendering() const
{
return !m_consumer->isStopped();
return !m_output->isStopped();
}
void
......@@ -166,18 +166,18 @@ AbstractRenderer::setProducer( Backend::IProducer* producer )
else
emit lengthChanged( 0 );
if ( m_consumer.get() != nullptr )
m_consumer->connect( *m_producer );
if ( m_output.get() != nullptr )
m_output->connect( *m_producer );
}
void
AbstractRenderer::setConsumer( std::unique_ptr<Backend::IConsumer> consuemr )
AbstractRenderer::setOutput( std::unique_ptr<Backend::IOutput> consuemr )
{
m_consumer = std::move( consuemr );
m_consumer->setCallback( m_eventWatcher );
m_output = std::move( consuemr );
m_output->setCallback( m_eventWatcher );
if ( m_producer != nullptr )
m_consumer->connect( *m_producer );
m_output->connect( *m_producer );
}
void
......
......@@ -29,7 +29,7 @@
#include <QObject>
#include "Workflow/Types.h"
#include "Backend/IConsumer.h"
#include "Backend/IOutput.h"
class Clip;
class Media;
......@@ -38,7 +38,7 @@ class RendererEventWatcher;
namespace Backend
{
class IConsumer;
class IOutput;
class IProducer;
}
......@@ -145,11 +145,11 @@ public:
virtual bool isRendering() const;
virtual void setProducer( Backend::IProducer* producer );
virtual void setConsumer( std::unique_ptr<Backend::IConsumer> consuemr );
virtual void setOutput( std::unique_ptr<Backend::IOutput> consuemr );
RendererEventWatcher* eventWatcher();
protected:
std::unique_ptr<Backend::IConsumer> m_consumer;
std::unique_ptr<Backend::IOutput> m_output;
Backend::IProducer* m_producer;
RendererEventWatcher* m_eventWatcher;
......
......@@ -28,7 +28,7 @@
#include "Media/Clip.h"
#include "ClipRenderer.h"
#include "Backend/IBackend.h"
#include "Backend/MLT/MLTConsumer.h"
#include "Backend/MLT/MLTOutput.h"
#include "Backend/MLT/MLTProducer.h"
#include "Tools/RendererEventWatcher.h"
#include "Library/Library.h"
......@@ -74,7 +74,7 @@ ClipRenderer::setClip( Clip* clip )
void
ClipRenderer::updateInfos( Clip* clip )
{
if ( m_consumer->isStopped() == true )
if ( m_output->isStopped() == true )
m_clipLoaded = false;
else
m_mediaChanged = true;
......@@ -88,7 +88,7 @@ ClipRenderer::startPreview()
updateInfos( m_selectedClip );
setProducer( m_selectedClip->producer() );
m_consumer->start();
m_output->start();
m_producer->setPosition( 0 );
m_clipLoaded = true;
......@@ -100,7 +100,7 @@ ClipRenderer::stop()
{
if ( m_clipLoaded == true && isRendering() == true )
{
m_consumer->stop();
m_output->stop();
if ( m_mediaChanged == true )
m_clipLoaded = false;
}
......@@ -117,9 +117,9 @@ ClipRenderer::togglePlayPause()
startPreview();
return ;
}
if ( m_consumer->isStopped() )
if ( m_output->isStopped() )
{
m_consumer->start();
m_output->start();
m_producer->setPause( false );
}
else
......
/*****************************************************************************
* ConsumerEventWatcher.h: Watches events from a IConsumer and convert them to SIGNAL
* OutputEventWatcher.h: Watches events from a IOutput and convert them to SIGNAL
*****************************************************************************
* Copyright (C) 2008-2016 VideoLAN
*
......@@ -20,27 +20,27 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "Tools/ConsumerEventWatcher.h"
#include "Tools/OutputEventWatcher.h"
ConsumerEventWatcher::ConsumerEventWatcher( QObject* parent ) :
OutputEventWatcher::OutputEventWatcher( QObject* parent ) :
QObject( parent )
{
}
void
ConsumerEventWatcher::onPlaying()
OutputEventWatcher::onPlaying()
{
emit playing();
}
void
ConsumerEventWatcher::onStopped()
OutputEventWatcher::onStopped()
{
emit stopped();
}
void
ConsumerEventWatcher::onVolumeChanged()
OutputEventWatcher::onVolumeChanged()
{
emit volumeChanged();
}
/*****************************************************************************
* ConsumerEventWatcher.h: Watches events from a IConsumer and convert them to SIGNAL
* OutputEventWatcher.h: Watches events from a IOutput and convert them to SIGNAL
*****************************************************************************
* Copyright (C) 2008-2016 VideoLAN
*
......@@ -20,18 +20,18 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef CONSUMEREVENTWATCHER_H
#define CONSUMEREVENTWATCHER_H
#ifndef OUTPUTEVENTWATCHER_H
#define OUTPUTEVENTWATCHER_H
#include <QObject>
#include "Backend/IConsumer.h"
#include "Backend/IOutput.h"
class ConsumerEventWatcher : public QObject, public Backend::IConsumerEventCb
class OutputEventWatcher : public QObject, public Backend::IOutputEventCb
{
Q_OBJECT
public:
explicit ConsumerEventWatcher( QObject* parent = 0 );
explicit OutputEventWatcher( QObject* parent = 0 );
private:
virtual void onPlaying();
......@@ -44,4 +44,4 @@ signals:
void volumeChanged();
};
#endif // CONSUMEREVENTWATCHER_H
#endif // OUTPUTEVENTWATCHER_H
/*****************************************************************************
* RendererEventWatcher.cpp: Watches events from a IConsumer and IProducer
* RendererEventWatcher.cpp: Watches events from a IOutput and IProducer
* and convert them to SIGNAL
*****************************************************************************
* Copyright (C) 2008-2016 VideoLAN
......
/*****************************************************************************
* RendererEventWatcher.h: Watches events from a IConsumer and IProducer
* RendererEventWatcher.h: Watches events from a IOutput and IProducer
* and convert them to SIGNAL
*****************************************************************************
* Copyright (C) 2008-2016 VideoLAN
......@@ -26,10 +26,10 @@
#include <QObject>
#include "Backend/IConsumer.h"
#include "Backend/IOutput.h"
#include "Backend/IProducer.h"
class RendererEventWatcher : public QObject, public Backend::IConsumerEventCb, public Backend::IProducerEventCb
class RendererEventWatcher : public QObject, public Backend::IOutputEventCb, public Backend::IProducerEventCb
{
Q_OBJECT
public:
......
<
......@@ -24,7 +24,7 @@
#include "vlmc.h"
#include "Backend/MLT/MLTConsumer.h"
#include "Backend/MLT/MLTOutput.h"
#include "Backend/MLT/MLTTractor.h"
#include "Backend/MLT/MLTTrack.h"
#include "Renderer/AbstractRenderer.h"
......@@ -40,7 +40,7 @@
#include "Settings/Settings.h"
#include "Tools/VlmcDebug.h"
#include "Tools/RendererEventWatcher.h"
#include "Tools/ConsumerEventWatcher.h"
#include "Tools/OutputEventWatcher.h"
#include "Workflow/Types.h"
#include <QMutex>
......@@ -178,40 +178,40 @@ MainWorkflow::startRenderToFile( const QString &outputFileName, quint32 width, q
if ( m_tractor->playableLength() == 0 )
return false;
Backend::MLT::MLTFFmpegConsumer consumer;
ConsumerEventWatcher cEventWatcher;
consumer.setCallback( &cEventWatcher );
consumer.setTarget( qPrintable( outputFileName ) );
consumer.setWidth( width );
consumer.setHeight( height );
consumer.setFrameRate( fps * 100, 100 );
Backend::MLT::MLTFFmpegOutput output;
OutputEventWatcher cEventWatcher;
output.setCallback( &cEventWatcher );
output.setTarget( qPrintable( outputFileName ) );
output.setWidth( width );
output.setHeight( height );
output.setFrameRate( fps * 100, 100 );
auto temp = ar.split( "/" );
consumer.setAspectRatio( temp[0].toInt(), temp[1].toInt() );
consumer.setVideoBitrate( vbitrate );
consumer.setAudioBitrate( abitrate );
consumer.setChannels( nbChannels );