2011-08-15 00:52:56 +02:00
|
|
|
/*
|
|
|
|
|
TIMINGS.hpp - timing specifications for a frame quantised data stream
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/** @file timings.hpp
|
|
|
|
|
** How to define a timing specification or constraint.
|
2012-04-18 03:46:21 +02:00
|
|
|
** A timing spec is used to anchor a data stream with relation to a time axis or frame grid.
|
2011-08-15 00:52:56 +02:00
|
|
|
** There are two kinds of timing specs:
|
|
|
|
|
** - nominal timing specifications relate to the nominal time values
|
|
|
|
|
** of the frames in a data stream, i.e. the "should be" time values.
|
|
|
|
|
** These might be values derived from a timecode or just values in
|
|
|
|
|
** in relation to the timeline axis, but without any connection to
|
|
|
|
|
** the real wall clock time
|
|
|
|
|
** - actual timing specifications are always connected or related to
|
|
|
|
|
** an external time source, typically just wall clock time. For example,
|
|
|
|
|
** actual timing specs dictate the constraints for real time frame
|
|
|
|
|
** delivery to an external output connection.
|
|
|
|
|
**
|
|
|
|
|
** @todo WIP-WIP-WIP 8/2011
|
|
|
|
|
** @see output-slot.hpp ////TODO
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef PROC_PLAY_TIMINGS_H
|
|
|
|
|
#define PROC_PLAY_TIMINGS_H
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "lib/error.hpp"
|
|
|
|
|
//#include "lib/handle.hpp"
|
|
|
|
|
#include "lib/time/timevalue.hpp"
|
|
|
|
|
//#include "proc/engine/buffer-provider.hpp"
|
|
|
|
|
//#include "lib/iter-source.hpp"
|
|
|
|
|
//#include "lib/sync.hpp"
|
|
|
|
|
|
|
|
|
|
//#include <boost/noncopyable.hpp>
|
|
|
|
|
//#include <string>
|
|
|
|
|
//#include <vector>
|
2013-01-11 18:12:40 +01:00
|
|
|
#include <boost/rational.hpp>
|
2012-02-06 02:49:54 +01:00
|
|
|
#include <tr1/memory>
|
2011-08-15 00:52:56 +02:00
|
|
|
//#include <boost/scoped_ptr.hpp>
|
|
|
|
|
|
2012-02-06 02:49:54 +01:00
|
|
|
namespace lib {
|
|
|
|
|
namespace time{
|
|
|
|
|
class Quantiser;
|
2012-02-09 04:52:09 +01:00
|
|
|
typedef std::tr1::shared_ptr<const Quantiser> PQuant;
|
2012-02-06 02:49:54 +01:00
|
|
|
}}
|
2011-08-15 00:52:56 +02:00
|
|
|
|
|
|
|
|
namespace proc {
|
|
|
|
|
namespace play {
|
|
|
|
|
|
2012-02-06 02:49:54 +01:00
|
|
|
using lib::time::FrameRate;
|
|
|
|
|
using lib::time::TimeValue;
|
2012-02-09 04:52:09 +01:00
|
|
|
using lib::time::Duration;
|
|
|
|
|
using lib::time::Offset;
|
2012-03-02 01:33:57 +01:00
|
|
|
using lib::time::Time;
|
2011-08-15 00:52:56 +02:00
|
|
|
//using std::string;
|
|
|
|
|
|
|
|
|
|
//using std::vector;
|
|
|
|
|
//using std::tr1::shared_ptr;
|
|
|
|
|
//using boost::scoped_ptr;
|
|
|
|
|
|
2012-02-06 02:49:54 +01:00
|
|
|
enum PlaybackUrgency {
|
|
|
|
|
ASAP,
|
|
|
|
|
NICE,
|
|
|
|
|
TIMEBOUND
|
|
|
|
|
};
|
2011-08-15 00:52:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-01-16 04:50:21 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
|
* Generic frame timing specification. Defines the expected delivery interval,
|
|
|
|
|
* optionally also the expected quality-of-service
|
2011-08-15 00:52:56 +02:00
|
|
|
*
|
|
|
|
|
* @note copyable value class
|
|
|
|
|
*
|
|
|
|
|
* @todo write type comment
|
2012-02-25 00:27:50 +01:00
|
|
|
* /////////////////////////////////////////////////////////////////TODO: WIP seems to become some kind of abstracted Grid representation!
|
2011-08-15 00:52:56 +02:00
|
|
|
*/
|
|
|
|
|
class Timings
|
|
|
|
|
{
|
2012-02-09 04:52:09 +01:00
|
|
|
lib::time::PQuant grid_;
|
2012-02-06 02:49:54 +01:00
|
|
|
|
2011-08-15 00:52:56 +02:00
|
|
|
public:
|
2012-02-06 02:49:54 +01:00
|
|
|
PlaybackUrgency playbackUrgency;
|
2013-01-11 18:12:40 +01:00
|
|
|
boost::rational<int64_t> playbackSpeed; /////////////TICKET #902 we need a more generic representation for variable speed playback
|
2013-01-12 08:36:35 +01:00
|
|
|
Time scheduledDelivery;
|
2012-03-02 01:33:57 +01:00
|
|
|
Duration outputLatency;
|
2012-02-06 02:49:54 +01:00
|
|
|
|
|
|
|
|
Timings (FrameRate fps);
|
|
|
|
|
|
|
|
|
|
// default copy acceptable
|
|
|
|
|
|
2012-02-09 04:52:09 +01:00
|
|
|
TimeValue getOrigin() const;
|
|
|
|
|
|
|
|
|
|
Offset getFrameOffsetAt (TimeValue refPoint) const;
|
|
|
|
|
Duration getFrameDurationAt (TimeValue refPoint) const;
|
2012-03-02 01:33:57 +01:00
|
|
|
Duration getFrameDurationAt (int64_t refFrameNr) const;
|
2012-02-06 02:49:54 +01:00
|
|
|
|
2012-02-09 04:52:09 +01:00
|
|
|
/** the frame spacing and duration remains constant for some time...
|
|
|
|
|
* @param startPoint looking from that time point into future
|
|
|
|
|
* @return duration after this starting point, where it's safe
|
|
|
|
|
* to assume unaltered frame dimensions */
|
|
|
|
|
Duration constantFrameTimingsInterval (TimeValue startPoint) const;
|
2012-02-06 02:49:54 +01:00
|
|
|
|
2013-01-11 18:12:40 +01:00
|
|
|
/** calculate the given frame's distance from origin,
|
|
|
|
|
* but do so using the real time scale, including any
|
|
|
|
|
* playback speed factory and similar corrections.
|
|
|
|
|
* @param frameOffset frame number relative to the implicit grid
|
|
|
|
|
* @return real time value relative to the implicit grid's zero point
|
|
|
|
|
* @note since the Timings don't contain any information relating the
|
|
|
|
|
* nominal time scale to wall clock time, this result is just
|
|
|
|
|
* a relative offset, but expressed in real time scale values
|
|
|
|
|
* @see proc::engine::TimeAnchor for an absolutely anchored conversion
|
|
|
|
|
*/
|
|
|
|
|
Offset getRealOffset (int64_t frameOffset) const;
|
|
|
|
|
|
2013-01-12 08:36:35 +01:00
|
|
|
/** real time deadline for the given frame, without any latency.
|
|
|
|
|
* This value is provided in case of scheduled time of delivery,
|
|
|
|
|
* which is signalled by \code playbackUrgency == TIMEBOUND \endcode
|
|
|
|
|
* @return wall clock time to expect delivery of data
|
|
|
|
|
* corresponding to a frame specified relative
|
|
|
|
|
* to \link #getOrigin time axis origin \endlink
|
|
|
|
|
* @note for other playback urgencies \c Time::NEVER
|
|
|
|
|
*/
|
|
|
|
|
Time getTimeDue(int64_t frameOffset) const;
|
|
|
|
|
|
|
|
|
|
/** the minimum time span to be covered by frame calculation jobs
|
|
|
|
|
* planned in one sway. The ongoing planning of additional jobs
|
|
|
|
|
* proceeds in chunks of jobs added at once to the schedule.
|
|
|
|
|
* This setting defines the minimum time to plan ahead; after
|
|
|
|
|
* covering at least this time span with new jobs, the
|
|
|
|
|
* frame dispatcher concludes "enough for now" and emits
|
|
|
|
|
* a continuation job for the next planning chunk.
|
2012-04-20 04:05:41 +02:00
|
|
|
*/
|
2013-01-12 08:36:35 +01:00
|
|
|
Duration getPlanningChunkDuration() const;
|
2012-04-20 04:05:41 +02:00
|
|
|
|
|
|
|
|
|
2013-01-11 18:12:40 +01:00
|
|
|
bool isOriginalSpeed() const;
|
|
|
|
|
|
|
|
|
|
|
2012-01-16 04:50:21 +01:00
|
|
|
//////////////TODO further accessor functions here
|
2011-12-17 04:45:42 +01:00
|
|
|
|
2012-03-02 01:33:57 +01:00
|
|
|
Timings constrainedBy (Timings additionalConditions);
|
|
|
|
|
|
2011-08-15 00:52:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-01-11 18:12:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
inline bool
|
|
|
|
|
Timings::isOriginalSpeed() const
|
|
|
|
|
{
|
|
|
|
|
return 1 == playbackSpeed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-08-15 00:52:56 +02:00
|
|
|
}} // namespace proc::play
|
|
|
|
|
#endif
|