2009-01-23 03:05:21 +01:00
|
|
|
/*
|
|
|
|
|
DUMMY-PLAYER-SERVICE.hpp - service implementing a dummy test player
|
|
|
|
|
|
|
|
|
|
Copyright (C) Lumiera.org
|
|
|
|
|
2009, 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.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/** @file notification-service.hpp
|
|
|
|
|
** A public service provided by the GUI, implementing the gui::GuiNotification facade interface.
|
|
|
|
|
** The purpose of this service is to push state update and notification of events from the lower
|
|
|
|
|
** layers into the Lumiera GUI. Typically, this happens asynchronously and triggered by events
|
|
|
|
|
** within the lower layers.
|
|
|
|
|
**
|
|
|
|
|
** This service is the implementation of a layer separation facade interface. Clients should use
|
2009-01-28 02:49:20 +01:00
|
|
|
** proc::play::DummyPlayer#facade to access this service. This header defines the interface used
|
2009-01-23 03:05:21 +01:00
|
|
|
** to \em provide this service, not to access it.
|
|
|
|
|
**
|
|
|
|
|
** @see gui::GuiFacade
|
|
|
|
|
** @see guifacade.cpp starting this service
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef PROC_DUMMYPLAYER_SERVICE_H
|
|
|
|
|
#define PROC_DUMMYPLAYER_SERVICE_H
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "include/dummy-player-facade.h"
|
|
|
|
|
#include "common/instancehandle.hpp"
|
|
|
|
|
#include "lib/singleton-ref.hpp"
|
|
|
|
|
|
2009-01-28 02:49:20 +01:00
|
|
|
#include <boost/noncopyable.hpp>
|
2009-01-23 04:15:58 +01:00
|
|
|
#include <boost/scoped_ptr.hpp>
|
2009-01-23 03:05:21 +01:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace proc {
|
|
|
|
|
namespace play {
|
|
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
|
using lumiera::Subsys;
|
|
|
|
|
|
|
|
|
|
|
2009-01-23 04:15:58 +01:00
|
|
|
class DummyImageGenerator;
|
|
|
|
|
|
|
|
|
|
|
2009-01-28 02:49:20 +01:00
|
|
|
/********************************************************************
|
|
|
|
|
* Actual implementation of a single (dummy) playback process.
|
|
|
|
|
* The DummyPlayerService (see below) maintains a collection of such
|
|
|
|
|
* actively running playback processes, while the client code gets
|
|
|
|
|
* DummyPlayer::Process handles to track any ongoing use. Users of
|
|
|
|
|
* the plain C interface get a direct bare pointer to the respective
|
|
|
|
|
* ProcessImpl instance and have to manage the lifecycle manually.
|
|
|
|
|
*/
|
2009-01-23 03:05:21 +01:00
|
|
|
class ProcessImpl
|
2009-01-30 00:17:01 +01:00
|
|
|
: public lumiera_playprocess,
|
|
|
|
|
boost::noncopyable
|
2009-01-23 03:05:21 +01:00
|
|
|
{
|
|
|
|
|
uint fps_;
|
2009-01-23 04:15:58 +01:00
|
|
|
bool play_;
|
|
|
|
|
|
|
|
|
|
boost::scoped_ptr<DummyImageGenerator> imageGen_;
|
|
|
|
|
|
2009-01-23 03:05:21 +01:00
|
|
|
|
|
|
|
|
public:
|
2009-01-28 02:49:20 +01:00
|
|
|
ProcessImpl() ;
|
2009-01-23 03:05:21 +01:00
|
|
|
|
|
|
|
|
/* Implementation-level API to be used By DummyPlayerService */
|
|
|
|
|
|
|
|
|
|
/** activate a playback process
|
|
|
|
|
* with given specification */
|
|
|
|
|
void setRate (uint fps);
|
|
|
|
|
|
|
|
|
|
bool isActive () { return fps_ != 0; }
|
|
|
|
|
bool isPlaying() { return play_; }
|
2009-01-28 02:49:20 +01:00
|
|
|
|
|
|
|
|
void doPlay(bool yes);
|
|
|
|
|
void* const getFrame();
|
|
|
|
|
|
|
|
|
|
DummyPlayer::Process createHandle();
|
|
|
|
|
static void terminate(ProcessImpl* process);
|
2009-01-23 03:05:21 +01:00
|
|
|
};
|
2009-01-28 02:49:20 +01:00
|
|
|
|
|
|
|
|
|
2009-01-23 03:05:21 +01:00
|
|
|
|
|
|
|
|
/******************************************************
|
2009-01-28 02:49:20 +01:00
|
|
|
* Actual implementation of the DummyPlayer service.
|
|
|
|
|
* Creating an instance of this class automatically
|
|
|
|
|
* registers the interface lumieraorg_DummyPlayer with
|
|
|
|
|
* the Lumiera Interface/Plugin system and creates
|
2009-01-23 03:05:21 +01:00
|
|
|
* a forwarding proxy within the application core to
|
|
|
|
|
* route calls through this interface.
|
|
|
|
|
*/
|
|
|
|
|
class DummyPlayerService
|
2009-01-28 02:49:20 +01:00
|
|
|
: boost::noncopyable
|
2009-01-23 03:05:21 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
string error_;
|
|
|
|
|
Subsys::SigTerm notifyTermination_;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* === Interface Lifecycle === */
|
|
|
|
|
|
|
|
|
|
typedef lumiera::InstanceHandle< LUMIERA_INTERFACE_INAME(lumieraorg_DummyPlayer, 0)
|
|
|
|
|
, DummyPlayer
|
|
|
|
|
> ServiceInstanceHandle;
|
|
|
|
|
|
2009-01-28 02:49:20 +01:00
|
|
|
lib::SingletonRef<DummyPlayerService> implInstance_;
|
2009-01-23 03:05:21 +01:00
|
|
|
ServiceInstanceHandle serviceInstance_;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
DummyPlayerService(Subsys::SigTerm terminationHandle);
|
|
|
|
|
|
|
|
|
|
~DummyPlayerService() { notifyTermination_(&error_); }
|
|
|
|
|
|
2009-01-28 02:49:20 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/** conceptually, this serves as implementation
|
|
|
|
|
* of the DummyPlayer#start() function. But because
|
|
|
|
|
* this function sits \em behind the interface, it
|
|
|
|
|
* just returns an impl pointer. */
|
|
|
|
|
ProcessImpl* start();
|
|
|
|
|
|
2009-01-23 03:05:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace play
|
|
|
|
|
|
|
|
|
|
} // namespace proc
|
|
|
|
|
#endif
|