diff --git a/src/proc/play/timings.cpp b/src/proc/play/timings.cpp index d5e1dd7b1..956b5f72a 100644 --- a/src/proc/play/timings.cpp +++ b/src/proc/play/timings.cpp @@ -32,6 +32,7 @@ namespace play { using lib::time::PQuant; + using lib::time::Time; namespace { // hidden local details of the service implementation.... @@ -58,7 +59,47 @@ namespace play { Timings::Timings (FrameRate fps) : grid_(buildStandardGridForFramerate(fps)) , playbackUrgency (ASAP) - { } + { + ENSURE (grid_); + } + + + + TimeValue + Timings::getOrigin() const + { + return grid_->timeOf(0); + } + + + Offset + Timings::getFrameOffsetAt (TimeValue refPoint) const + { + return 1 * getFrameDurationAt (refPoint); /////////////////TODO implement a speed factor here + } + + + Duration + Timings::getFrameDurationAt (TimeValue refPoint) const + { + int64_t frameNr = grid_->gridPoint (refPoint); + return Offset (grid_->timeOf(frameNr), grid_->timeOf(frameNr+1)); + } + + + /** @remarks the purpose of this function is to support scheduling + * and frame handling even in case the frame rate isn't constant. + * To indicate the case the frame rate is changing right now, + * this function might returns Duration::NIL + * @todo implement real support for variable frame rates + */ ////////////////////////////////////////////////////////TICKET #236 + Duration + Timings::constantFrameTimingsInterval (TimeValue startPoint) const + { + return Duration (Time::ANYTIME); + } + + diff --git a/src/proc/play/timings.hpp b/src/proc/play/timings.hpp index 3ce908826..f0ac12112 100644 --- a/src/proc/play/timings.hpp +++ b/src/proc/play/timings.hpp @@ -59,6 +59,7 @@ namespace lib { namespace time{ class Quantiser; + typedef std::tr1::shared_ptr PQuant; }} namespace proc { @@ -66,6 +67,8 @@ namespace play { using lib::time::FrameRate; using lib::time::TimeValue; + using lib::time::Duration; + using lib::time::Offset; //using std::string; //using std::vector; @@ -90,9 +93,7 @@ namespace play { */ class Timings { - typedef std::tr1::shared_ptr PQuant; - - PQuant grid_; + lib::time::PQuant grid_; public: PlaybackUrgency playbackUrgency; @@ -101,9 +102,16 @@ namespace play { // default copy acceptable - TimeValue getOrigin(); + TimeValue getOrigin() const; - FrameRate getFrameRate(); + Offset getFrameOffsetAt (TimeValue refPoint) const; + Duration getFrameDurationAt (TimeValue refPoint) const; + + /** 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; //////////////TODO further accessor functions here diff --git a/tests/components/proc/play/timing-constraints-test.cpp b/tests/components/proc/play/timing-constraints-test.cpp index 16e8fbcc5..f63b0114d 100644 --- a/tests/components/proc/play/timing-constraints-test.cpp +++ b/tests/components/proc/play/timing-constraints-test.cpp @@ -36,6 +36,7 @@ namespace play { namespace test { using lib::time::Time; + using lib::time::Duration; using lib::time::FrameRate; //using proc::engine::BuffHandle; @@ -67,10 +68,14 @@ namespace test { { Timings timings (FrameRate::PAL); -#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #831 - CHECK (Time::ZERO == timings.getOrigin()); - CHECK (FrameRate::PAL == timings.getFrameRate()); + Time t(0,10); + Duration lengthPAL (1, FrameRate::PAL); + + CHECK (timings.getOrigin() == Time::ZERO); + CHECK (timings.getFrameDurationAt(t) == lengthPAL); + CHECK (timings.getFrameOffsetAt(t) == lengthPAL); CHECK (ASAP == timings.playbackUrgency); +#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #831 #endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #831 } };