diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-12-16 21:39:01 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-12-16 21:39:01 +0000 |
| commit | e330669de0f5d7d9d922dc69945cca74ac9800d9 (patch) | |
| tree | c70a8486ef31d69187b3e18bb4c65917e60bc3fc /src | |
| parent | 05c5ef180e7a54e0b6790b2bd8c334e48f1f069a (diff) | |
Add duration() methods to CPL and Reel.
Diffstat (limited to 'src')
| -rw-r--r-- | src/cpl.cc | 10 | ||||
| -rw-r--r-- | src/cpl.h | 2 | ||||
| -rw-r--r-- | src/reel.cc | 19 | ||||
| -rw-r--r-- | src/reel.h | 2 |
4 files changed, 33 insertions, 0 deletions
@@ -255,3 +255,13 @@ CPL::pkl_type (Standard standard) const DCP_ASSERT (false); } } + +int64_t +CPL::duration () const +{ + int64_t d = 0; + BOOST_FOREACH (shared_ptr<Reel> i, _reels) { + d += i->duration (); + } + return d; +} @@ -113,6 +113,8 @@ public: void resolve_refs (std::list<boost::shared_ptr<Asset> >); + int64_t duration () const; + protected: /** @return type string for PKLs for this asset */ std::string pkl_type (Standard standard) const; diff --git a/src/reel.cc b/src/reel.cc index ddab12d3..3ab9993f 100644 --- a/src/reel.cc +++ b/src/reel.cc @@ -36,6 +36,7 @@ using std::string; using std::list; using std::cout; +using std::max; using boost::shared_ptr; using boost::dynamic_pointer_cast; using namespace dcp; @@ -185,3 +186,21 @@ Reel::resolve_refs (list<shared_ptr<Asset> > assets) } } } + +int64_t +Reel::duration () const +{ + int64_t d = 0; + + if (_main_picture) { + d = max (d, _main_picture->duration ()); + } + if (_main_sound) { + d = max (d, _main_sound->duration ()); + } + if (_main_subtitle) { + d = max (d, _main_subtitle->duration ()); + } + + return d; +} @@ -71,6 +71,8 @@ public: return _main_subtitle; } + int64_t duration () const; + void add (boost::shared_ptr<ReelAsset> asset); void write_to_cpl (xmlpp::Element* node, Standard standard) const; |
