2 Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
4 This file is part of libdcp.
6 libdcp is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 libdcp is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with libdcp. If not, see <http://www.gnu.org/licenses/>.
19 In addition, as a special exception, the copyright holders give
20 permission to link the code of portions of this program with the
21 OpenSSL library under certain conditions as described in each
22 individual source file, and distribute linked combinations
25 You must obey the GNU General Public License in all respects
26 for all of the code used other than OpenSSL. If you modify
27 file(s) with this exception, you may extend this exception to your
28 version of the file(s), but you are not obligated to do so. If you
29 do not wish to do so, delete this exception statement from your
30 version. If you delete this exception statement from all source
31 files in the program, then also delete it here.
34 /** @file src/dcp_time.h
42 #include <boost/optional.hpp>
51 extern bool operator== (Time const & a, Time const & b);
52 extern bool operator!= (Time const & a, Time const & b);
53 extern bool operator<= (Time const & a, Time const & b);
54 extern bool operator< (Time const & a, Time const & b);
55 extern bool operator> (Time const & a, Time const & b);
56 extern bool operator>= (Time const & a, Time const & b);
57 extern std::ostream & operator<< (std::ostream & s, Time const & t);
58 extern Time operator+ (Time a, Time b);
59 extern Time operator- (Time a, Time b);
60 extern float operator/ (Time a, Time const & b);
63 * @brief A representation of time within a DCP.
68 /** Construct a zero Time */
69 Time () : h (0), m (0), s (0), e (0), tcr (1) {}
72 * @param frame Frame index (starting from 0).
73 * @param frames_per_second Frames per second.
74 * @param tcr Timecode rate.
76 Time (int frame, double frames_per_second, int tcr);
78 /** Construct a Time from hours, minutes, seconds, editable units and a timecode rate.
82 * @param e_ Editable units (where 1 editable unit is 1 / tcr_ seconds)
83 * @param tcr_ Timecode rate; i.e. number of editable units per second.
85 Time (int h_, int m_, int s_, int e_, int tcr_)
93 Time (double seconds, int tcr);
95 Time (std::string time, boost::optional<int> tcr);
100 int e; ///< editable units (where 1 editable unit is 1 / tcr_ seconds)
101 int tcr; ///< timecode rate: the number of editable units per second.
103 std::string as_string (Standard standard) const;
104 double as_seconds () const;
105 int64_t as_editable_units (int tcr_) const;
106 Time rebase (int tcr_) const;
108 Time& operator+= (Time const & o) {
114 void set (double seconds, int tcr);