Commit 3f68c4f1 authored by luyikei's avatar luyikei

Rename Producer to Input

parent f059259c
/*****************************************************************************
* IProducer.h: Defines an interface to produce frames
* IInput.h: Defines an interface to produce frames
*****************************************************************************
* Copyright (C) 2008-2016 VideoLAN
*
......@@ -20,8 +20,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef IPRODUCER_H
#define IPRODUCER_H
#ifndef IINPUT_H
#define IINPUT_H
#include <cstdint>
#include <memory>
......@@ -30,10 +30,10 @@
namespace Backend
{
class IProducerEventCb
class IInputEventCb
{
public:
virtual ~IProducerEventCb() = default;
virtual ~IInputEventCb() = default;
virtual void onPaused() = 0;
virtual void onPlaying() = 0;
virtual void onEndReached() = 0;
......@@ -41,12 +41,12 @@ namespace Backend
virtual void onLengthChanged( int64_t ) = 0;
};
class IProducer : virtual public IService
class IInput : virtual public IService
{
public:
virtual ~IProducer() = default;
virtual void setCallback( IProducerEventCb* callback ) = 0;
virtual ~IInput() = default;
virtual void setCallback( IInputEventCb* callback ) = 0;
virtual const char* path() const = 0;
virtual int64_t begin() const = 0;
......@@ -56,16 +56,16 @@ namespace Backend
virtual void setBoundaries( int64_t begin, int64_t end ) = 0;
// Absolute position in frames
virtual std::unique_ptr<IProducer> cut( int64_t begin = 0, int64_t end = EndOfMedia ) = 0;
virtual std::unique_ptr<IInput> cut( int64_t begin = 0, int64_t end = EndOfMedia ) = 0;
virtual bool isCut( ) const = 0 ;
virtual bool sameClip( IProducer& that ) const = 0;
virtual bool runsInto( IProducer& that ) const = 0;
virtual bool sameClip( IInput& that ) const = 0;
virtual bool runsInto( IInput& that ) const = 0;
// The playable (based on begin and end points) duration
virtual int64_t playableLength() const = 0;
// The duration of the producer regardless of begin and end points.
// The duration of the input regardless of begin and end points.
virtual int64_t length() const = 0;
virtual const char* lengthTime() const = 0;
......@@ -94,4 +94,4 @@ namespace Backend
};
}
#endif // IPRODUCER_H
#endif // IINPUT_H
......@@ -31,7 +31,7 @@
namespace Backend
{
class IProducer;
class IInput;
class IOutputEventCb
{
......@@ -59,7 +59,7 @@ namespace Backend
virtual int volume() const = 0;
virtual void setVolume( int volume ) = 0;
virtual bool connect( IProducer& provider ) = 0;
virtual bool connect( IInput& input ) = 0;
virtual bool isConnected() const = 0;
};
}
......
/*****************************************************************************
* IService.h: Defines an interface of a common base of
* consumer and producer.
* output and input.
*****************************************************************************
* Copyright (C) 2008-2016 VideoLAN
*
......@@ -55,8 +55,8 @@ namespace Backend
virtual ~IService() = default;
virtual std::string identifier() const = 0;
virtual IService* consumer() const = 0;
virtual IService* producer() const = 0;
virtual IService* output() const = 0;
virtual IService* input() const = 0;
virtual IProfile* profile() const = 0;
virtual bool attach( IFilter& filter ) = 0;
virtual bool detach( IFilter& filter ) = 0;
......
......@@ -24,22 +24,22 @@
#define ITRACK_H
#include <string>
#include "IProducer.h"
#include "IInput.h"
namespace Backend
{
class ITrack : virtual public IProducer
class ITrack : virtual public IInput
{
public:
virtual ~ITrack() = default;
virtual bool insertAt( IProducer& producer, int64_t startFrame ) = 0;
virtual bool append( IProducer& producer ) = 0;
virtual bool insertAt( IInput& input, int64_t startFrame ) = 0;
virtual bool append( IInput& input ) = 0;
virtual bool remove( int index ) = 0;
// src and dist are indexes.
virtual bool move( int src, int dist ) = 0;
virtual IProducer* clip( int index ) const = 0;
virtual IProducer* clipAt( int64_t position ) const = 0 ;
virtual IInput* clip( int index ) const = 0;
virtual IInput* clipAt( int64_t position ) const = 0 ;
virtual bool resizeClip( int clip, int64_t begin, int64_t end ) = 0;
virtual int clipIndexAt( int64_t position ) = 0;
virtual int count() const = 0;
......
/*****************************************************************************
* ITractor.h: Defines an interface of a multitrack producer
* ITractor.h: Defines an interface of a multitrack input
*****************************************************************************
* Copyright (C) 2008-2016 VideoLAN
*
......@@ -23,27 +23,27 @@
#ifndef ITRACTOR_H
#define ITRACTOR_H
#include "IProducer.h"
#include "IInput.h"
namespace Backend
{
class IProducer;
class IInput;
class ITransition;
class IFilter;
class ITractor : virtual public IProducer
class ITractor : virtual public IInput
{
public:
virtual ~ITractor() = default;
virtual void refresh() = 0;
virtual bool setTrack( IProducer& producer, int index ) = 0;
virtual bool insertTrack( IProducer& producer, int index ) = 0;
virtual bool setTrack( IInput& input, int index ) = 0;
virtual bool insertTrack( IInput& input, int index ) = 0;
virtual bool removeTrack( int index ) = 0;
virtual IProducer* track( int index ) const = 0;
virtual IInput* track( int index ) const = 0;
virtual int count() const = 0;
virtual void addTransition( ITransition& transition, int aTrack = 0, int bTrack = 1 ) = 0;
virtual void addFilter( IFilter& filter, int track = 0 ) = 0;
virtual bool connect( IProducer& producer ) = 0;
virtual bool connect( IInput& input ) = 0;
};
}
......
......@@ -29,7 +29,7 @@
namespace Backend
{
class IProducer;
class IInput;
class ITransition : virtual public IService
{
public:
......
......@@ -39,7 +39,7 @@ class Output;
namespace Backend
{
class IOutput;
class IProducer;
class IInput;
class IProfile;
class IClip;
class IFilterInfo;
......
......@@ -30,7 +30,7 @@ namespace Mlt
{
class Filter;
class Properties;
class Producer;
class Input;
}
namespace Backend
......
/*****************************************************************************
* MLTProducer.cpp: Wrapper of Mlt::Producer
* MLTInput.cpp: Wrapper of Mlt::Producer
*****************************************************************************
* Copyright (C) 2008-2016 VideoLAN
*
......@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "MLTProducer.h"
#include "MLTInput.h"
#include "MLTProfile.h"
#include "MLTBackend.h"
......@@ -30,7 +30,7 @@
using namespace Backend::MLT;
MLTProducer::MLTProducer()
MLTInput::MLTInput()
: m_producer( nullptr )
, m_callback( nullptr )
, m_paused( false )
......@@ -41,7 +41,7 @@ MLTProducer::MLTProducer()
}
void
MLTProducer::calcTracks()
MLTInput::calcTracks()
{
char s[70];
int nbStreams = m_producer->get_int( "meta.media.nb_streams" );
......@@ -60,8 +60,8 @@ MLTProducer::calcTracks()
}
}
MLTProducer::MLTProducer( Mlt::Producer* producer, IProducerEventCb* callback )
: MLTProducer()
MLTInput::MLTInput( Mlt::Producer* producer, IInputEventCb* callback )
: MLTInput()
{
m_producer = producer;
m_service = producer;
......@@ -71,8 +71,8 @@ MLTProducer::MLTProducer( Mlt::Producer* producer, IProducerEventCb* callback )
throw InvalidServiceException();
}
MLTProducer::MLTProducer( IProfile& profile, const char* path, IProducerEventCb* callback )
: MLTProducer()
MLTInput::MLTInput( IProfile& profile, const char* path, IInputEventCb* callback )
: MLTInput()
{
std::string temp = std::string( "avformat:" ) + path;
MLTProfile& mltProfile = static_cast<MLTProfile&>( profile );
......@@ -84,19 +84,19 @@ MLTProducer::MLTProducer( IProfile& profile, const char* path, IProducerEventCb*
throw InvalidServiceException();
}
MLTProducer::MLTProducer( const char* path, IProducerEventCb* callback )
: MLTProducer( Backend::instance()->profile(), path, callback )
MLTInput::MLTInput( const char* path, IInputEventCb* callback )
: MLTInput( Backend::instance()->profile(), path, callback )
{
}
MLTProducer::~MLTProducer()
MLTInput::~MLTInput()
{
delete m_producer;
}
void
MLTProducer::onPropertyChanged( void*, MLTProducer* self, const char* id )
MLTInput::onPropertyChanged( void*, MLTInput* self, const char* id )
{
if ( self == nullptr || self->m_callback == nullptr )
return;
......@@ -113,47 +113,47 @@ MLTProducer::onPropertyChanged( void*, MLTProducer* self, const char* id )
}
void
MLTProducer::setCallback( Backend::IProducerEventCb* callback )
MLTInput::setCallback( Backend::IInputEventCb* callback )
{
if ( callback == nullptr )
return;
m_callback = callback;
m_producer->listen( "property-changed", this, (mlt_listener)MLTProducer::onPropertyChanged );
m_producer->listen( "property-changed", this, (mlt_listener)MLTInput::onPropertyChanged );
}
const char*
MLTProducer::path() const
MLTInput::path() const
{
return m_producer->get( "resource" );
}
int64_t
MLTProducer::begin() const
MLTInput::begin() const
{
return m_producer->get_in();
}
int64_t
MLTProducer::end() const
MLTInput::end() const
{
return m_producer->get_out();
}
void
MLTProducer::setBegin( int64_t begin )
MLTInput::setBegin( int64_t begin )
{
m_producer->set( "in", (int)begin );
}
void
MLTProducer::setEnd( int64_t end )
MLTInput::setEnd( int64_t end )
{
m_producer->set( "out", (int)end );
}
void
MLTProducer::setBoundaries( int64_t begin, int64_t end )
MLTInput::setBoundaries( int64_t begin, int64_t end )
{
if ( end == EndOfParent )
// parent() will be m_producer itself if it has no parent
......@@ -161,116 +161,116 @@ MLTProducer::setBoundaries( int64_t begin, int64_t end )
m_producer->set_in_and_out( begin, end );
}
std::unique_ptr<Backend::IProducer>
MLTProducer::cut( int64_t begin, int64_t end )
std::unique_ptr<Backend::IInput>
MLTInput::cut( int64_t begin, int64_t end )
{
return std::unique_ptr<IProducer>( new MLTProducer( m_producer->cut( begin, end ) ) );
return std::unique_ptr<IInput>( new MLTInput( m_producer->cut( begin, end ) ) );
}
bool
MLTProducer::isCut() const
MLTInput::isCut() const
{
return m_producer->is_cut();
}
bool
MLTProducer::sameClip( Backend::IProducer& that ) const
MLTInput::sameClip( Backend::IInput& that ) const
{
MLTProducer* producer = dynamic_cast<MLTProducer*>( &that );
MLTInput* producer = dynamic_cast<MLTInput*>( &that );
assert( producer );
return m_producer->same_clip( *producer->m_producer );
}
bool
MLTProducer::runsInto( Backend::IProducer& that ) const
MLTInput::runsInto( Backend::IInput& that ) const
{
MLTProducer* producer = dynamic_cast<MLTProducer*>( &that );
MLTInput* producer = dynamic_cast<MLTInput*>( &that );
assert( producer );
return m_producer->runs_into( *producer->m_producer );
}
int64_t
MLTProducer::playableLength() const
MLTInput::playableLength() const
{
return m_producer->get_playtime();
}
int64_t
MLTProducer::length() const
MLTInput::length() const
{
return m_producer->get_length();
}
const char*
MLTProducer::lengthTime() const
MLTInput::lengthTime() const
{
return m_producer->get_length_time( mlt_time_clock );
}
int64_t
MLTProducer::position() const
MLTInput::position() const
{
return m_producer->position();
}
void
MLTProducer::setPosition( int64_t position )
MLTInput::setPosition( int64_t position )
{
m_producer->seek( position );
}
int64_t
MLTProducer::frame() const
MLTInput::frame() const
{
return m_producer->frame();
}
double
MLTProducer::fps() const
MLTInput::fps() const
{
return m_producer->get_fps();
}
int
MLTProducer::width() const
MLTInput::width() const
{
return m_producer->get_int( "width" );
}
int
MLTProducer::height() const
MLTInput::height() const
{
return m_producer->get_int( "height" );
}
bool
MLTProducer::hasVideo() const
MLTInput::hasVideo() const
{
return m_nbVideoTracks > 0;
}
int
MLTProducer::nbVideoTracks() const
MLTInput::nbVideoTracks() const
{
return m_nbVideoTracks;
}
bool
MLTProducer::hasAudio() const
MLTInput::hasAudio() const
{
return m_nbAudioTracks > 0;
}
int
MLTProducer::nbAudioTracks() const
MLTInput::nbAudioTracks() const
{
return m_nbAudioTracks;
}
void
MLTProducer::playPause()
MLTInput::playPause()
{
if ( m_paused )
m_producer->set_speed( 1.0 );
......@@ -288,13 +288,13 @@ MLTProducer::playPause()
}
bool
MLTProducer::isPaused() const
MLTInput::isPaused() const
{
return m_paused;
}
void
MLTProducer::setPause( bool isPaused )
MLTInput::setPause( bool isPaused )
{
// It will be negated again in playPause.
m_paused = !isPaused;
......@@ -302,7 +302,7 @@ MLTProducer::setPause( bool isPaused )
}
void
MLTProducer::nextFrame()
MLTInput::nextFrame()
{
if ( m_producer->position() < m_producer->get_out() )
{
......@@ -313,7 +313,7 @@ MLTProducer::nextFrame()
}
void
MLTProducer::previousFrame()
MLTInput::previousFrame()
{
if ( m_producer->get_in() < m_producer->position() )
{
......@@ -324,7 +324,7 @@ MLTProducer::previousFrame()
}
bool
MLTProducer::isBlank() const
MLTInput::isBlank() const
{
return m_producer->is_blank();
}
/*****************************************************************************
* MLTProducer.h: Wrapper of Mlt::Producer
* MLTInput.h: Wrapper of Mlt::Producer
*****************************************************************************
* Copyright (C) 2008-2016 VideoLAN
*
......@@ -20,10 +20,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef MLTPRODUCER_H
#define MLTPRODUCER_H
#ifndef MLTINPUT_H
#define MLTINPUT_H
#include "Backend/IProducer.h"
#include "Backend/IInput.h"
#include "Backend/IProfile.h"
#include "MLTService.h"
......@@ -37,18 +37,18 @@ namespace Backend
namespace MLT
{
class MLTProducer : virtual public IProducer, public MLTService
class MLTInput : virtual public IInput, public MLTService
{
public:
MLTProducer( Mlt::Producer* producer, IProducerEventCb* callback = nullptr );
MLTProducer( const char* path, IProducerEventCb* callback = nullptr );
MLTProducer( IProfile& profile, const char* path, IProducerEventCb* callback = nullptr );
~MLTProducer();
MLTInput( Mlt::Producer* input, IInputEventCb* callback = nullptr );
MLTInput( const char* path, IInputEventCb* callback = nullptr );
MLTInput( IProfile& profile, const char* path, IInputEventCb* callback = nullptr );
~MLTInput();
static void onPropertyChanged( void* owner, MLTProducer* self, const char* id );
static void onPropertyChanged( void* owner, MLTInput* self, const char* id );
virtual void setCallback( IProducerEventCb* callback );
virtual void setCallback( IInputEventCb* callback );
virtual const char* path() const override;
virtual int64_t begin() const override;
......@@ -57,16 +57,16 @@ class MLTProducer : virtual public IProducer, public MLTService
virtual void setEnd( int64_t end ) override;
virtual void setBoundaries( int64_t begin, int64_t end ) override;
virtual std::unique_ptr<IProducer> cut( int64_t begin = 0, int64_t end = EndOfMedia ) override;
virtual std::unique_ptr<IInput> cut( int64_t begin = 0, int64_t end = EndOfMedia ) override;
virtual bool isCut() const override;
virtual bool sameClip( IProducer& that ) const override;
virtual bool runsInto( IProducer& that ) const override;
virtual bool sameClip( IInput& that ) const override;
virtual bool runsInto( IInput& that ) const override;
// The playable (based on begin and end points) duration
virtual int64_t playableLength() const override;
// The duration of the producer regardless of begin and end points.
// The duration of the input regardless of begin and end points.
virtual int64_t length() const override;
virtual const char* lengthTime() const override;
......@@ -93,12 +93,12 @@ class MLTProducer : virtual public IProducer, public MLTService
virtual bool isBlank() const override;
protected:
MLTProducer();
MLTInput();
void calcTracks();
Mlt::Producer* m_producer;
IProducerEventCb* m_callback;
IInputEventCb* m_callback;
bool m_paused;
int m_nbVideoTracks;
......@@ -112,4 +112,4 @@ class MLTProducer : virtual public IProducer, public MLTService
}
}
#endif // MLTPRODUCER_H
#endif // MLTINPUT_H
/*****************************************************************************
* MLTOutput.cpp: Wrapper of Mlt::Output
* MLTOutput.cpp: Wrapper of Mlt::Consumer
*****************************************************************************
* Copyright (C) 2008-2016 VideoLAN
*
......@@ -21,7 +21,7 @@
*****************************************************************************/
#include "MLTOutput.h"
#include "MLTProducer.h"
#include "MLTInput.h"
#include "MLTProfile.h"
#include "MLTBackend.h"
......@@ -41,7 +41,7 @@ MLTOutput::MLTOutput()
MLTOutput::MLTOutput( Backend::IProfile& profile, const char *id, Backend::IOutputEventCb* callback )
: m_callback( callback )
, m_producer( nullptr )
, m_input( nullptr )
{
MLTProfile& mltProfile = static_cast<MLTProfile&>( profile );
m_consumer = new Mlt::Consumer( *mltProfile.m_profile, id );
......@@ -119,18 +119,18 @@ MLTOutput::setVolume( int volume )
}
bool
MLTOutput::connect( Backend::IProducer& producer )
MLTOutput::connect( Backend::IInput& input )
{
MLTProducer* mltProducer = dynamic_cast<MLTProducer*>( &producer );
assert( mltProducer );
m_producer = mltProducer;
return m_consumer->connect( *(mltProducer->m_producer) );
MLTInput* mltInput = dynamic_cast<MLTInput*>( &input );
assert( mltInput );
m_input = mltInput;
return m_consumer->connect( *(mltInput->m_producer) );
}
bool
MLTOutput::isConnected() const
{
return m_producer != nullptr;
return m_input != nullptr;
}
void
......
/*****************************************************************************
* MLTOutput.h: Wrapper of Mlt::Output
* MLTOutput.h: Wrapper of Mlt::Consumer
*****************************************************************************
* Copyright (C) 2008-2016 VideoLAN
*
......@@ -39,7 +39,7 @@ namespace Backend
{
namespace MLT
{
class MLTProducer;
class MLTInput;
class MLTOutput : public IOutput, public MLTService
{
......@@ -61,13 +61,13 @@ class MLTOutput : public IOutput, public MLTService
virtual int volume() const override;
virtual void setVolume( int volume ) override;
virtual bool connect( IProducer& producer ) override;
virtual bool connect( IInput& input ) override;
virtual bool isConnected() const override;
protected:
Mlt::Consumer* m_consumer;
IOutputEventCb* m_callback;
MLTProducer* m_producer;
IOutputEventCb* m_callback;
MLTInput* m_input;
std::string m_name;
};
......
......@@ -63,7 +63,7 @@ class MLTProfile : public IProfile
// To access Mlt::Profile
friend class MLTOutput;
friend class MLTProducer;
friend class MLTInput;
friend class MLTBackend;
friend class MLTTrack;
friend class MLTTractor;
......
......@@ -55,13 +55,13 @@ MLTService::identifier() const
}
Backend::IService*
MLTService::consumer() const
MLTService::output() const
{
return new MLTService( m_service->consumer() );
}
Backend::IService*
MLTService::producer() const
MLTService::input() const
{
return new MLTService( m_service->producer() );
}
......
......@@ -43,8 +43,8 @@ namespace MLT
virtual ~MLTService();
virtual std::string identifier() const override;
virtual IService* consumer() const override;
virtual IService* producer() const override;
virtual IService* output() const override;
virtual IService* input() const override;