draft the player facade interface
This commit is contained in:
parent
cb6453afe1
commit
20f95ca26f
9 changed files with 260 additions and 97 deletions
|
|
@ -184,7 +184,7 @@ namespace lumiera {
|
|||
|
||||
public:
|
||||
/** Set up an InstanceHandle representing a plugin.
|
||||
* Should be placed at the client side.
|
||||
* Should be placed at the client side.
|
||||
* @param iName unmangled name of the interface
|
||||
* @param version major version
|
||||
* @param minminor minimum acceptable minor version number
|
||||
|
|
@ -203,7 +203,7 @@ namespace lumiera {
|
|||
* registration and deregistration of interface(s).
|
||||
* Should be placed at the service providing side.
|
||||
* @param a (single) interface descriptor, which can be created with
|
||||
* LUMIERA_INTERFACE_INSTANCE and referred to by LUMIERA_INTERFACE_REF
|
||||
* LUMIERA_INTERFACE_INSTANCE and referred to by LUMIERA_INTERFACE_REF
|
||||
*/
|
||||
InstanceHandle (LumieraInterface descriptor)
|
||||
: desc_(descriptor)
|
||||
|
|
@ -222,9 +222,9 @@ namespace lumiera {
|
|||
|
||||
|
||||
|
||||
/** act as smart pointer providing access through the facade.
|
||||
/** act as smart pointer providing access through the facade.
|
||||
* @note we don't provide operator* */
|
||||
FA * operator-> () const { return &(facadeLink_(*this)); }
|
||||
FA * operator-> () const { return &(facadeLink_(*this)); }
|
||||
|
||||
/** directly access the instance via the CL interface */
|
||||
I& get () const { ENSURE(instance_); return *instance_; }
|
||||
|
|
|
|||
|
|
@ -28,73 +28,87 @@
|
|||
|
||||
using util::cStr;
|
||||
|
||||
namespace lumiera {
|
||||
namespace facade {
|
||||
|
||||
|
||||
LUMIERA_ERROR_DEFINE (FACADE_LIFECYCLE, "facade interface currently not accessible");
|
||||
|
||||
|
||||
template<class IHA>
|
||||
class Holder;
|
||||
|
||||
template<class FA, class I>
|
||||
class Holder<InstanceHandle<I,FA> >
|
||||
: Accessor<FA>,
|
||||
protected FA
|
||||
{
|
||||
protected:
|
||||
typedef InstanceHandle<I,FA> IHandle;
|
||||
typedef Holder<IHandle> THolder;
|
||||
typedef Proxy<IHandle> TProxy;
|
||||
typedef Accessor<FA> Access;
|
||||
|
||||
I& _i_;
|
||||
|
||||
Holder (IHandle const& iha)
|
||||
: _i_(iha.get())
|
||||
{ }
|
||||
|
||||
public:
|
||||
static TProxy& open(IHandle const& iha)
|
||||
{
|
||||
static char buff[sizeof(TProxy)];
|
||||
TProxy* p = new(buff) TProxy(iha);
|
||||
Access::implProxy_ = p;
|
||||
return *p;
|
||||
}
|
||||
|
||||
static void close()
|
||||
{
|
||||
if (!Access::implProxy_) return;
|
||||
TProxy* p = static_cast<TProxy*> (Access::implProxy_);
|
||||
Access::implProxy_ = 0;
|
||||
p->~TProxy();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<class FA>
|
||||
FA* Accessor<FA>::implProxy_;
|
||||
|
||||
|
||||
template<class IHA>
|
||||
void
|
||||
openProxy (IHA const& iha)
|
||||
{
|
||||
Proxy<IHA>::open(iha);
|
||||
}
|
||||
|
||||
template<class IHA>
|
||||
void
|
||||
closeProxy ()
|
||||
{
|
||||
Proxy<IHA>::close();
|
||||
}
|
||||
|
||||
} // namespace facade
|
||||
namespace lumiera{
|
||||
namespace facade {
|
||||
|
||||
} // namespace lumiera
|
||||
|
||||
LUMIERA_ERROR_DEFINE (FACADE_LIFECYCLE, "facade interface currently not accessible");
|
||||
|
||||
|
||||
/**
|
||||
* Implementation Base
|
||||
* for building Facade Proxy implementations.
|
||||
* Typically the purpose of such a proxy is to route
|
||||
* any calls through the C-Bindings of the Lumiera Interface system.
|
||||
* The actual storage for the concrete proxy object is embedded,
|
||||
* inline within the #open() function. For access by the clients,
|
||||
* a frontend-object of type \c Accessor<FA> may be placed into
|
||||
* the facade interface; this accessor-frontend is basically
|
||||
* a concealed static pointer to the proxy, and will be set,
|
||||
* when the interface is opened. This opening and closing
|
||||
* of the interface itself is controlled by the
|
||||
* InstanceHandle, which in turn is typically
|
||||
* created and managed within the context
|
||||
* of the service implementation.
|
||||
*/
|
||||
template<class IHA>
|
||||
class Holder;
|
||||
|
||||
template<class FA, class I>
|
||||
class Holder<InstanceHandle<I,FA> >
|
||||
: Accessor<FA>
|
||||
, protected FA
|
||||
{
|
||||
protected:
|
||||
typedef InstanceHandle<I,FA> IHandle;
|
||||
typedef Holder<IHandle> THolder;
|
||||
typedef Proxy<IHandle> TProxy;
|
||||
typedef Accessor<FA> Access;
|
||||
|
||||
I& _i_;
|
||||
|
||||
Holder (IHandle const& iha)
|
||||
: _i_(iha.get())
|
||||
{ }
|
||||
|
||||
public:
|
||||
static TProxy& open(IHandle const& iha)
|
||||
{
|
||||
static char buff[sizeof(TProxy)];
|
||||
TProxy* p = new(buff) TProxy(iha);
|
||||
Access::implProxy_ = p;
|
||||
return *p;
|
||||
}
|
||||
|
||||
static void close()
|
||||
{
|
||||
if (!Access::implProxy_) return;
|
||||
TProxy* p = static_cast<TProxy*> (Access::implProxy_);
|
||||
Access::implProxy_ = 0;
|
||||
p->~TProxy();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<class FA>
|
||||
FA* Accessor<FA>::implProxy_;
|
||||
|
||||
|
||||
template<class IHA>
|
||||
void
|
||||
openProxy (IHA const& iha)
|
||||
{
|
||||
Proxy<IHA>::open(iha);
|
||||
}
|
||||
|
||||
template<class IHA>
|
||||
void
|
||||
closeProxy ()
|
||||
{
|
||||
Proxy<IHA>::close();
|
||||
}
|
||||
|
||||
}} // namespace lumiera::facade
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,13 +21,18 @@
|
|||
*/
|
||||
|
||||
/** @file display-facade.h
|
||||
** Major public Interface of the Lumiera GUI. While, generally speaking, the GUI
|
||||
** controls the application and thus acts on its own, it exposes some services
|
||||
** to the lower layers. Especially the lumiera::Display interface serves to
|
||||
** hand over calculated frames to the GUI for displaying them in a viewer.
|
||||
** It's a first draft as of 1/2009, probably it can be factored out into
|
||||
** a more general display service in future.
|
||||
**
|
||||
** Experimental Interface, allowing the Dummy-Player to access the
|
||||
** video display widget in the GUI. While, generally speaking, the GUI
|
||||
** controls the application and thus acts on its own, it might expose some
|
||||
** services to the lower layers.
|
||||
**
|
||||
** In the Dummy-Player design study, the lumiera::Display interface serves
|
||||
** to hand over calculated frames to the GUI for displaying them in a viewer.
|
||||
**
|
||||
** This is a first draft as of 1/2009, and likely to be superseded by a
|
||||
** better design, where rather the \em provider of an output facility
|
||||
** registers with the OutputManager in the core.
|
||||
**
|
||||
** @see gui::GuiFacade
|
||||
** @see dummy-player-facade.h
|
||||
**
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@
|
|||
#include "include/interfaceproxy.hpp"
|
||||
#include "lib/handle.hpp"
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
** Typically there is another subclass of the Facade interfaces sitting "on the other side"
|
||||
** of the interface barrier and actually implementing the functionality. The template
|
||||
** facade::Accessor can be thought of as a factory creating such a proxy instance of the
|
||||
** facade interface for the client code to use. Typically, in instance of the \em factory
|
||||
** facade interface for the client code to use. Typically, an instance of the \em factory
|
||||
** is embedded (as a static functor member object) right within the otherwise abstract
|
||||
** facade interface, this way allowing the client code to write e.g. \c XYZInterface::facade()
|
||||
** to yield a reference to a proxy object implementing \c XYZInterface.
|
||||
|
|
|
|||
141
src/include/play-facade.h
Normal file
141
src/include/play-facade.h
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
PLAYER-FACADE.h - access point to the Lumiera player subsystem
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2011, Hermann Vosseler <Ichthyostega@web.de>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PROC_INTERFACE_PLAY_H
|
||||
#define PROC_INTERFACE_PLAY_H
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus /* ============== C++ Interface ================= */
|
||||
|
||||
//#include "include/interfaceproxy.hpp"
|
||||
#include "lib/handle.hpp"
|
||||
#include "lib/iter-source.hpp"
|
||||
#include "lib/time/timevalue.hpp"
|
||||
#include "proc/mobject/model-port.hpp"
|
||||
#include "proc/mobject/output-designation.hpp"
|
||||
#include "proc/mobject/session/clip.hpp"
|
||||
#include "proc/mobject/session/track.hpp"
|
||||
#include "proc/play/output-manager.hpp"
|
||||
#include "asset/timeline.hpp"
|
||||
#include "asset/viewer.hpp"
|
||||
|
||||
|
||||
|
||||
namespace proc {
|
||||
namespace play {
|
||||
|
||||
class PlayProcess;
|
||||
} }
|
||||
|
||||
|
||||
namespace lumiera {
|
||||
|
||||
|
||||
/******************************************************************
|
||||
* Interface to the Player subsystem of Lumiera (Proc-Layer).
|
||||
* Global access point for starting playback and render processes,
|
||||
* calculating media data by running the render engine.
|
||||
*
|
||||
* @todo WIP-WIP-WIP 6/2011
|
||||
* @note Lumiera is not yet able actually to deliver rendered data.
|
||||
* @todo there should be an accompanying CL Interface defined for
|
||||
* the Lumiera interface system, so the player can be
|
||||
* accessed from external clients. This was left out
|
||||
* for now, as we don't have either plugins, nor
|
||||
* any script running capabilities yet. (5/2011)
|
||||
*/
|
||||
class Play
|
||||
{
|
||||
public:
|
||||
|
||||
/** get an implementation instance of this service */
|
||||
static lumiera::facade::Accessor<DummyPlayer> facade;
|
||||
|
||||
|
||||
/**
|
||||
* Continuous playback process, which has been hooked up
|
||||
* and started with a fixed set of output slots. started with a specific
|
||||
* output size, format and framerate. It is a handle to a calculation process,
|
||||
* which is about to produce a stream of frames and push them to the outputs.
|
||||
*
|
||||
* The Lifecycle of the referred playback process is managed automatically
|
||||
* through this handle (by ref count). Client code is supposed to use the
|
||||
* API on this handle to navigate and control the playback mode.
|
||||
*
|
||||
* @see handle.hpp
|
||||
* @see player-service.cpp implementation
|
||||
*/
|
||||
class Controller
|
||||
: public lib::Handle<proc::play::PlayProcess>
|
||||
{
|
||||
public:
|
||||
void play(bool); ///< play/pause toggle
|
||||
void adjustSpeed(double); ///< playback speed control
|
||||
void go(lib::time::Time);
|
||||
/////////////////////////////TODO how to modify the Loop range, the playback mode, scrubbing?
|
||||
};
|
||||
|
||||
|
||||
typedef lib::IterSource<mobject::ModelPort> ModelPorts;
|
||||
typedef lib::IterSource<mobject::OutputDesignation> Pipes;
|
||||
typedef proc::play::POutputManager Output;
|
||||
typedef mobject::session::PClipMO Clip;
|
||||
typedef mobject::PTrack Track;
|
||||
typedef asset::PTimeline Timeline;
|
||||
typedef asset::PViewer Viewer;
|
||||
|
||||
/** create a new playback process outputting to the given viewer/display */
|
||||
virtual Controller connect(ModelPorts, Output) =0;
|
||||
|
||||
|
||||
/* ==== convenience shortcuts for common use cases ==== */
|
||||
Controller perform(Pipes, Output);
|
||||
Controller perform(Timeline);
|
||||
Controller perform(Viewer);
|
||||
Controller perform(Track);
|
||||
Controller perform(Clip);
|
||||
|
||||
protected:
|
||||
virtual ~Player();
|
||||
};
|
||||
|
||||
|
||||
} // namespace lumiera
|
||||
|
||||
|
||||
|
||||
|
||||
extern "C" {
|
||||
#endif /* =========================== CL Interface ===================== */
|
||||
|
||||
|
||||
// #include "common/interface.h"
|
||||
////////////////////////////////////TODO define a C binding for the Interface system here
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -79,51 +79,51 @@ namespace lumiera {
|
|||
P ( ) : BASE() {}
|
||||
template<class Y> explicit P (Y* p) : BASE(p) {}
|
||||
template<class Y, class D> P (Y* p, D d) : BASE(p,d){}
|
||||
|
||||
|
||||
P (P const& r) : BASE(r) {}
|
||||
template<class Y> P (shared_ptr<Y> const& r) : BASE(r) {}
|
||||
template<class Y> explicit P (weak_ptr<Y> const& wr) : BASE(wr) {}
|
||||
template<class Y> explicit P (std::auto_ptr<Y> & ar) : BASE(ar) {}
|
||||
|
||||
template<class Y> explicit P (std::auto_ptr<Y> & ar) : BASE(ar) {}
|
||||
|
||||
P& operator= (P const& r) { BASE::operator= (r); return *this; }
|
||||
|
||||
P& operator= (P const& r) { BASE::operator= (r); return *this; }
|
||||
template<class Y> P& operator=(shared_ptr<Y> const& sr) { BASE::operator= (sr); return *this; }
|
||||
template<class Y> P& operator=(std::auto_ptr<Y> & ar) { BASE::operator= (ar); return *this; }
|
||||
|
||||
|
||||
TAR* get() const { return dynamic_cast<TAR*> (BASE::get()); }
|
||||
TAR& operator*() const { return *get(); }
|
||||
TAR* operator->() const { return get(); }
|
||||
|
||||
|
||||
void swap(P& b) { BASE::swap (b);}
|
||||
|
||||
|
||||
|
||||
private: /* === friend operators injected into enclosing namespace for ADL === */
|
||||
template<typename _O_>
|
||||
friend inline bool
|
||||
operator== (P const& p, P<_O_> const& q) { return (p && q)? (*p == *q) : (!p && !q); }
|
||||
|
||||
|
||||
template<typename _O_>
|
||||
friend inline bool
|
||||
operator!= (P const& p, P<_O_> const& q) { return (p && q)? (*p != *q) : !(!p && !q); }
|
||||
|
||||
|
||||
template<typename _O_>
|
||||
friend inline bool
|
||||
operator< (P const& p, P<_O_> const& q) { REQUIRE (p && q); return *p < *q; } ///< @note deliberately not allowing comparison on NIL ////TICKET #307 : problem with equality test in associative containers, where equal(a,b) := !(a < b) && !(b < a)
|
||||
|
||||
|
||||
template<typename _O_>
|
||||
friend inline bool
|
||||
operator> (P const& p, P<_O_> const& q) { REQUIRE (p && q); return *q < *p; }
|
||||
|
||||
|
||||
template<typename _O_>
|
||||
friend inline bool
|
||||
operator<= (P const& p, P<_O_> const& q) { REQUIRE (p && q); return *p <= *q;}
|
||||
|
||||
|
||||
template<typename _O_>
|
||||
friend inline bool
|
||||
operator>= (P const& p, P<_O_> const& q) { REQUIRE (p && q); return *p >= *q;}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace lumiera
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -53,8 +53,8 @@ namespace lumiera {
|
|||
namespace facade {
|
||||
|
||||
typedef lumiera::InstanceHandle< LUMIERA_INTERFACE_INAME(lumieraorg_DummyPlayer, 0)
|
||||
, proc::play::DummyPlayer
|
||||
> IHandle_DummyPlayer;
|
||||
, proc::play::DummyPlayer
|
||||
> IHandle_DummyPlayer;
|
||||
|
||||
|
||||
template<>
|
||||
|
|
|
|||
|
|
@ -36,12 +36,15 @@
|
|||
#include <boost/noncopyable.hpp>
|
||||
//#include <string>
|
||||
//#include <vector>
|
||||
#include <tr1/memory>
|
||||
|
||||
|
||||
namespace proc {
|
||||
namespace play {
|
||||
|
||||
//using std::string;
|
||||
//using std::vector;
|
||||
using std::tr1::shared_ptr;
|
||||
|
||||
|
||||
|
||||
|
|
@ -77,8 +80,9 @@ namespace play {
|
|||
public:
|
||||
OutputManager() {}
|
||||
};
|
||||
|
||||
|
||||
typedef shared_ptr<OutputManager> POutputManager;
|
||||
|
||||
|
||||
} // namespace play
|
||||
}} // namespace proc::play
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue