2010-12-21 02:05:13 +01:00
|
|
|
/*
|
|
|
|
|
TIMECODE.hpp - grid aligned and fixed format time specifications
|
|
|
|
|
|
|
|
|
|
Copyright (C) Lumiera.org
|
|
|
|
|
2010, 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 LIB_TIME_TIMECODE_H
|
|
|
|
|
#define LIB_TIME_TIMECODE_H
|
|
|
|
|
|
2010-12-27 02:04:34 +01:00
|
|
|
#include "lib/time/timevalue.hpp"
|
2011-01-02 01:21:39 +01:00
|
|
|
#include "lib/time/formats.hpp"
|
2011-01-13 23:56:52 +01:00
|
|
|
#include "lib/time/digxel.hpp"
|
2011-01-05 18:15:44 +01:00
|
|
|
#include "lib/symbol.hpp"
|
2010-12-27 02:04:34 +01:00
|
|
|
|
2011-01-05 05:14:10 +01:00
|
|
|
//#include <iostream>
|
2010-12-21 02:05:13 +01:00
|
|
|
//#include <boost/operators.hpp>
|
2011-01-05 18:15:44 +01:00
|
|
|
#include <boost/lexical_cast.hpp> ///////////////TODO
|
2010-12-21 02:05:13 +01:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace lib {
|
|
|
|
|
namespace time {
|
|
|
|
|
|
2011-01-04 01:45:11 +01:00
|
|
|
using std::string;
|
2011-01-05 18:15:44 +01:00
|
|
|
using lib::Literal;
|
|
|
|
|
using boost::lexical_cast; /////////TODO
|
2011-01-04 01:45:11 +01:00
|
|
|
|
2010-12-21 02:05:13 +01:00
|
|
|
|
|
|
|
|
/**
|
2011-01-05 02:43:29 +01:00
|
|
|
* Interface: fixed format timecode specification.
|
2011-01-02 01:21:39 +01:00
|
|
|
* @see time::Format
|
2010-12-21 02:05:13 +01:00
|
|
|
* @todo WIP-WIP-WIP
|
|
|
|
|
*/
|
|
|
|
|
class TCode
|
|
|
|
|
{
|
2011-01-13 23:56:52 +01:00
|
|
|
QuantiserRef qID_;
|
2010-12-21 02:05:13 +01:00
|
|
|
|
|
|
|
|
public:
|
2011-01-05 02:43:29 +01:00
|
|
|
virtual ~TCode();
|
2011-01-04 01:45:11 +01:00
|
|
|
|
2011-01-05 05:14:10 +01:00
|
|
|
operator string() const { return show(); }
|
2011-01-05 18:15:44 +01:00
|
|
|
string describe() const { return string(tcID()); }
|
|
|
|
|
Time getTime() const { return Time(value()); }
|
2011-01-05 05:14:10 +01:00
|
|
|
|
|
|
|
|
protected:
|
2011-01-13 23:56:52 +01:00
|
|
|
TCode (QuantiserRef const& qID)
|
|
|
|
|
: qID_(qID)
|
|
|
|
|
{ }
|
|
|
|
|
|
2011-01-05 05:14:10 +01:00
|
|
|
virtual string show() const =0;
|
2011-01-05 18:15:44 +01:00
|
|
|
virtual Literal tcID() const =0;
|
|
|
|
|
virtual TimeValue value() const =0;
|
2010-12-21 02:05:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2011-01-02 01:21:39 +01:00
|
|
|
class QuTime;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A frame counting timecode value.
|
|
|
|
|
* This is an hard-coded representation of
|
|
|
|
|
* TCode<format::Frames>, with additional convenience
|
|
|
|
|
* constructors and conversions, which basically make
|
|
|
|
|
* FrameNr values interchangeable with integral numbers.
|
|
|
|
|
*/
|
|
|
|
|
class FrameNr
|
2011-01-05 02:43:29 +01:00
|
|
|
: public TCode
|
2011-01-13 23:56:52 +01:00
|
|
|
, CountVal
|
2011-01-02 01:21:39 +01:00
|
|
|
{
|
2011-01-05 18:15:44 +01:00
|
|
|
|
|
|
|
|
string show() const { return lexical_cast<string>(nr_)+"fr"; }
|
|
|
|
|
Literal tcID() const { return "Frame-count"; }
|
|
|
|
|
TimeValue value() const { return Time(FACTOR_TODO * nr_); }
|
2011-01-02 01:21:39 +01:00
|
|
|
|
|
|
|
|
public:
|
2011-01-13 23:56:52 +01:00
|
|
|
typedef format::Frames Format;
|
|
|
|
|
|
|
|
|
|
FrameNr (QuTime const& quantisedTime)
|
|
|
|
|
: TCode(quantisedTime)
|
|
|
|
|
, CountVal()
|
|
|
|
|
{
|
|
|
|
|
quantisedTime.castInto (*this);
|
|
|
|
|
}
|
2011-01-02 01:21:39 +01:00
|
|
|
|
2011-01-05 18:15:44 +01:00
|
|
|
operator long() const { return nr_; }
|
2011-01-02 01:21:39 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2010-12-21 02:05:13 +01:00
|
|
|
|
2011-01-04 01:45:11 +01:00
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
class SmpteTC
|
2011-01-05 02:43:29 +01:00
|
|
|
: public TCode
|
2011-01-04 01:45:11 +01:00
|
|
|
{
|
2011-01-05 18:15:44 +01:00
|
|
|
TimeVar tpoint_;
|
|
|
|
|
|
|
|
|
|
virtual string show() const { return string(tpoint_); }
|
|
|
|
|
virtual Literal tcID() const { return "SMPTE"; }
|
|
|
|
|
virtual TimeValue value() const { return tpoint_; }
|
2011-01-05 05:14:10 +01:00
|
|
|
|
2011-01-04 01:45:11 +01:00
|
|
|
public:
|
2011-01-13 23:56:52 +01:00
|
|
|
typedef format::Smpte Format;
|
|
|
|
|
|
2011-01-04 01:45:11 +01:00
|
|
|
SmpteTC (QuTime const& quantisedTime);
|
|
|
|
|
|
|
|
|
|
int getSecs () const;
|
|
|
|
|
int getMins () const;
|
|
|
|
|
int getHours () const;
|
|
|
|
|
int getFrames () const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-05 02:43:29 +01:00
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
class HmsTC
|
|
|
|
|
: public TCode
|
|
|
|
|
{
|
2011-01-05 18:15:44 +01:00
|
|
|
TimeVar tpoint_;
|
2011-01-05 02:43:29 +01:00
|
|
|
|
2011-01-05 18:15:44 +01:00
|
|
|
virtual string show() const { return string(tpoint_); }
|
|
|
|
|
virtual Literal tcID() const { return "Timecode"; }
|
|
|
|
|
virtual TimeValue value() const { return tpoint_; }
|
2011-01-05 05:14:10 +01:00
|
|
|
|
2011-01-05 02:43:29 +01:00
|
|
|
public:
|
2011-01-13 23:56:52 +01:00
|
|
|
typedef format::Hms Format;
|
|
|
|
|
|
2011-01-05 02:43:29 +01:00
|
|
|
HmsTC (QuTime const& quantisedTime);
|
|
|
|
|
|
|
|
|
|
double getMillis () const;
|
|
|
|
|
int getSecs () const;
|
|
|
|
|
int getMins () const;
|
|
|
|
|
int getHours () const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
class Secs
|
|
|
|
|
: public TCode
|
|
|
|
|
{
|
2011-01-05 18:15:44 +01:00
|
|
|
FSecs sec_;
|
2011-01-05 02:43:29 +01:00
|
|
|
|
2011-01-05 18:15:44 +01:00
|
|
|
virtual string show() const { return string(Time(sec_)); }
|
|
|
|
|
virtual Literal tcID() const { return "Seconds"; }
|
|
|
|
|
virtual TimeValue value() const { return Time(sec_); }
|
2011-01-05 05:14:10 +01:00
|
|
|
|
2011-01-05 02:43:29 +01:00
|
|
|
public:
|
2011-01-13 23:56:52 +01:00
|
|
|
typedef format::Seconds Format;
|
|
|
|
|
|
2011-01-05 02:43:29 +01:00
|
|
|
Secs (QuTime const& quantisedTime);
|
|
|
|
|
|
|
|
|
|
operator FSecs() const;
|
|
|
|
|
};
|
|
|
|
|
|
2011-01-05 05:14:10 +01:00
|
|
|
|
|
|
|
|
/** writes time value, formatted as HH:MM:SS:mmm */
|
2011-01-05 02:43:29 +01:00
|
|
|
|
2011-01-05 05:14:10 +01:00
|
|
|
|
2011-01-05 02:43:29 +01:00
|
|
|
|
2010-12-21 02:05:13 +01:00
|
|
|
}} // lib::time
|
|
|
|
|
#endif
|