summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-12-16 21:39:01 +0000
committerCarl Hetherington <cth@carlh.net>2015-12-16 21:39:01 +0000
commite330669de0f5d7d9d922dc69945cca74ac9800d9 (patch)
treec70a8486ef31d69187b3e18bb4c65917e60bc3fc /src
parent05c5ef180e7a54e0b6790b2bd8c334e48f1f069a (diff)
Add duration() methods to CPL and Reel.
Diffstat (limited to 'src')
-rw-r--r--src/cpl.cc10
-rw-r--r--src/cpl.h2
-rw-r--r--src/reel.cc19
-rw-r--r--src/reel.h2
4 files changed, 33 insertions, 0 deletions
diff --git a/src/cpl.cc b/src/cpl.cc
index 24c8a18a..9633abc4 100644
--- a/src/cpl.cc
+++ b/src/cpl.cc
@@ -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;
+}
diff --git a/src/cpl.h b/src/cpl.h
index d38c0090..b616aeaa 100644
--- a/src/cpl.h
+++ b/src/cpl.h
@@ -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;
+}
diff --git a/src/reel.h b/src/reel.h
index 3b3673ef..7711d101 100644
--- a/src/reel.h
+++ b/src/reel.h
@@ -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;