summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-07-10 16:16:51 +0100
committerCarl Hetherington <cth@carlh.net>2014-07-10 16:16:51 +0100
commita75132724be4962225e5cb0f5ef5297e2e78aeee (patch)
tree8bd6860f89de21e2ec14226a4eb8d1d6ba87aff4
parent1045480655c09c6fdf0d81f5d9714cb218933c19 (diff)
Move _intrinsic_duration and _edit_rate up to the MXF class as XML subtitle files do not contain this information (whereas MXF files do).
-rw-r--r--src/content.cc23
-rw-r--r--src/content.h26
-rw-r--r--src/dcp.h4
-rw-r--r--src/mxf.cc18
-rw-r--r--src/mxf.h19
-rw-r--r--src/reel_asset.cc10
-rw-r--r--src/reel_asset.h2
-rw-r--r--src/reel_picture_asset.cc2
-rw-r--r--src/reel_sound_asset.cc4
-rw-r--r--src/reel_sound_asset.h2
-rw-r--r--src/reel_subtitle_asset.cc4
-rw-r--r--src/reel_subtitle_asset.h2
-rw-r--r--src/subtitle_content.cc24
-rw-r--r--src/subtitle_content.h5
14 files changed, 71 insertions, 74 deletions
diff --git a/src/content.cc b/src/content.cc
index 995fd920..8a654670 100644
--- a/src/content.cc
+++ b/src/content.cc
@@ -33,19 +33,8 @@ using namespace dcp;
Content::Content (boost::filesystem::path file)
: Asset (file)
- , _edit_rate (24, 1)
- , _intrinsic_duration (0)
{
- /* Note: the _edit_rate and _intrinsic_duration above are just defaults,
- the derived class must set these up according to `file'.
- */
-}
-
-Content::Content (Fraction edit_rate)
- : _edit_rate (edit_rate)
- , _intrinsic_duration (0)
-{
-
+
}
bool
@@ -54,16 +43,6 @@ Content::equals (shared_ptr<const Content> other, EqualityOptions opt, boost::fu
if (!Asset::equals (other, opt, note)) {
return false;
}
-
- if (_edit_rate != other->_edit_rate) {
- note (DCP_ERROR, "content edit rates differ");
- return false;
- }
-
- if (_intrinsic_duration != other->_intrinsic_duration) {
- note (DCP_ERROR, "asset intrinsic durations differ");
- return false;
- }
return true;
}
diff --git a/src/content.h b/src/content.h
index 4bc21570..cf92f536 100644
--- a/src/content.h
+++ b/src/content.h
@@ -51,43 +51,21 @@ namespace dcp
class Content : public Asset
{
public:
+ Content () {}
+
/** Construct a Content object by reading a file.
* @param file File to read.
*/
Content (boost::filesystem::path file);
- /** Construct a new piece of content with a specified edit rate.
- * @param edit_rate Edit rate for the content.
- */
- Content (Fraction edit_rate);
-
bool equals (
boost::shared_ptr<const Content> other,
EqualityOptions opt,
boost::function<void (NoteType, std::string)>
) const;
- Fraction edit_rate () const {
- return _edit_rate;
- }
-
- /** @return The total length of this content in video frames.
- * The amount of content presented may be less than this.
- */
- int64_t intrinsic_duration () const {
- return _intrinsic_duration;
- }
-
protected:
- friend class MXFWriter;
-
virtual std::string asdcp_kind () const = 0;
-
- Fraction _edit_rate;
- /** The total length of this content in video frames. The amount of
- * content presented may be less than this.
- */
- int64_t _intrinsic_duration;
};
}
diff --git a/src/dcp.h b/src/dcp.h
index 0ff7a9fd..3d42b92a 100644
--- a/src/dcp.h
+++ b/src/dcp.h
@@ -62,8 +62,8 @@ class DCP : public boost::noncopyable
{
public:
/** Construct a DCP. You can pass an existing DCP's directory
- * as the parameter, or an empty folder to create a new
- * DCP in.
+ * as the parameter; alternatively, directory will be created
+ * if it does not exist.
*
* @param directory Directory containing the DCP's files.
*/
diff --git a/src/mxf.cc b/src/mxf.cc
index def53c15..f5282f1c 100644
--- a/src/mxf.cc
+++ b/src/mxf.cc
@@ -42,19 +42,21 @@ using boost::dynamic_pointer_cast;
using namespace dcp;
MXF::MXF (Fraction edit_rate)
- : Content (edit_rate)
+ : _edit_rate (edit_rate)
+ , _intrinsic_duration (0)
, _encryption_context (0)
, _decryption_context (0)
{
-
+ /* _intrinsic_duration must be set up up by a subclass */
}
MXF::MXF (boost::filesystem::path file)
: Content (file)
+ , _intrinsic_duration (0)
, _encryption_context (0)
, _decryption_context (0)
{
-
+ /* _edit_rate and _intrinsic_duration must be set up up by a subclass */
}
MXF::~MXF ()
@@ -102,6 +104,16 @@ MXF::equals (shared_ptr<const Content> other, EqualityOptions opt, boost::functi
return false;
}
+ if (_edit_rate != other_mxf->_edit_rate) {
+ note (DCP_ERROR, "content edit rates differ");
+ return false;
+ }
+
+ if (_intrinsic_duration != other_mxf->_intrinsic_duration) {
+ note (DCP_ERROR, "asset intrinsic durations differ");
+ return false;
+ }
+
if (_file != other_mxf->file ()) {
note (DCP_ERROR, "MXF names differ");
if (!opt.mxf_names_can_differ) {
diff --git a/src/mxf.h b/src/mxf.h
index c5ecd1b7..4fbc1495 100644
--- a/src/mxf.h
+++ b/src/mxf.h
@@ -105,10 +105,29 @@ public:
return _metadata;
}
+ Fraction edit_rate () const {
+ return _edit_rate;
+ }
+
+ /** @return The total length of this content in video frames.
+ * The amount of content presented may be less than this.
+ */
+ int64_t intrinsic_duration () const {
+ return _intrinsic_duration;
+ }
+
protected:
+ friend class MXFWriter;
+
std::string pkl_type (Standard standard) const;
void read_writer_info (ASDCP::WriterInfo const &);
+ Fraction _edit_rate;
+ /** The total length of this content in video frames. The amount of
+ * content presented may be less than this.
+ */
+ int64_t _intrinsic_duration;
+
ASDCP::AESEncContext* _encryption_context;
ASDCP::AESDecContext* _decryption_context;
/** ID of the key used for encryption/decryption, or an empty string */
diff --git a/src/reel_asset.cc b/src/reel_asset.cc
index 7987a155..cbb76dd8 100644
--- a/src/reel_asset.cc
+++ b/src/reel_asset.cc
@@ -42,15 +42,17 @@ ReelAsset::ReelAsset ()
/** Construct a ReelAsset.
* @param content Content that this asset refers to.
+ * @param edit_rate Edit rate for the content.
+ * @param intrinsic_duration Intrinsic duration of this content.
* @param entry_point Entry point to use in that content.
*/
-ReelAsset::ReelAsset (boost::shared_ptr<Content> content, int64_t entry_point)
+ReelAsset::ReelAsset (boost::shared_ptr<Content> content, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point)
: Object (content->id ())
, _content (content)
- , _edit_rate (content->edit_rate ())
- , _intrinsic_duration (content->intrinsic_duration ())
+ , _edit_rate (edit_rate)
+ , _intrinsic_duration (intrinsic_duration)
, _entry_point (entry_point)
- , _duration (_intrinsic_duration - _entry_point)
+ , _duration (intrinsic_duration - entry_point)
, _hash (make_digest (content->file (), 0))
{
/* default _annotation_text to the leaf name of our file */
diff --git a/src/reel_asset.h b/src/reel_asset.h
index d2ea56bf..40eb6986 100644
--- a/src/reel_asset.h
+++ b/src/reel_asset.h
@@ -48,7 +48,7 @@ class ReelAsset : public Object
{
public:
ReelAsset ();
- ReelAsset (boost::shared_ptr<Content> content, int64_t entry_point);
+ ReelAsset (boost::shared_ptr<Content> content, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point);
ReelAsset (boost::shared_ptr<const cxml::Node>);
virtual void write_to_cpl (xmlpp::Node* node, Standard standard) const;
diff --git a/src/reel_picture_asset.cc b/src/reel_picture_asset.cc
index 1a3d47b9..344f7019 100644
--- a/src/reel_picture_asset.cc
+++ b/src/reel_picture_asset.cc
@@ -42,7 +42,7 @@ ReelPictureAsset::ReelPictureAsset ()
}
ReelPictureAsset::ReelPictureAsset (boost::shared_ptr<PictureMXF> content, int64_t entry_point)
- : ReelAsset (content, entry_point)
+ : ReelAsset (content, content->edit_rate(), content->intrinsic_duration(), entry_point)
, _frame_rate (content->frame_rate ())
, _screen_aspect_ratio (content->screen_aspect_ratio ())
{
diff --git a/src/reel_sound_asset.cc b/src/reel_sound_asset.cc
index 984434dd..c9af664c 100644
--- a/src/reel_sound_asset.cc
+++ b/src/reel_sound_asset.cc
@@ -28,8 +28,8 @@ using std::string;
using boost::shared_ptr;
using namespace dcp;
-ReelSoundAsset::ReelSoundAsset (boost::shared_ptr<Content> content, int64_t entry_point)
- : ReelAsset (content, entry_point)
+ReelSoundAsset::ReelSoundAsset (boost::shared_ptr<SoundMXF> content, int64_t entry_point)
+ : ReelAsset (content, content->edit_rate(), content->intrinsic_duration(), entry_point)
{
}
diff --git a/src/reel_sound_asset.h b/src/reel_sound_asset.h
index 42835c84..7725c615 100644
--- a/src/reel_sound_asset.h
+++ b/src/reel_sound_asset.h
@@ -34,7 +34,7 @@ namespace dcp {
class ReelSoundAsset : public ReelAsset
{
public:
- ReelSoundAsset (boost::shared_ptr<Content> content, int64_t entry_point);
+ ReelSoundAsset (boost::shared_ptr<dcp::SoundMXF> content, int64_t entry_point);
ReelSoundAsset (boost::shared_ptr<const cxml::Node>);
boost::shared_ptr<SoundMXF> mxf () {
diff --git a/src/reel_subtitle_asset.cc b/src/reel_subtitle_asset.cc
index 1c948200..139e3a39 100644
--- a/src/reel_subtitle_asset.cc
+++ b/src/reel_subtitle_asset.cc
@@ -28,8 +28,8 @@ using std::string;
using boost::shared_ptr;
using namespace dcp;
-ReelSubtitleAsset::ReelSubtitleAsset (boost::shared_ptr<SubtitleContent> content, int64_t entry_point)
- : ReelAsset (content, entry_point)
+ReelSubtitleAsset::ReelSubtitleAsset (boost::shared_ptr<SubtitleContent> content, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point)
+ : ReelAsset (content, edit_rate, intrinsic_duration, entry_point)
{
}
diff --git a/src/reel_subtitle_asset.h b/src/reel_subtitle_asset.h
index 5cdfac13..0f0cf5fa 100644
--- a/src/reel_subtitle_asset.h
+++ b/src/reel_subtitle_asset.h
@@ -36,7 +36,7 @@ class SubtitleContent;
class ReelSubtitleAsset : public ReelAsset
{
public:
- ReelSubtitleAsset (boost::shared_ptr<SubtitleContent> content, int64_t entry_point);
+ ReelSubtitleAsset (boost::shared_ptr<SubtitleContent> content, Fraction edit_rate, int64_t instrinsic_duration, int64_t entry_point);
ReelSubtitleAsset (boost::shared_ptr<const cxml::Node>);
boost::shared_ptr<SubtitleContent> subtitle_content () const {
diff --git a/src/subtitle_content.cc b/src/subtitle_content.cc
index 85a4b360..12ed2afc 100644
--- a/src/subtitle_content.cc
+++ b/src/subtitle_content.cc
@@ -43,7 +43,6 @@ using namespace dcp;
SubtitleContent::SubtitleContent (boost::filesystem::path file, bool mxf)
: Content (file)
- , _need_sort (false)
{
shared_ptr<cxml::Document> xml;
@@ -99,12 +98,10 @@ SubtitleContent::SubtitleContent (boost::filesystem::path file, bool mxf)
examine_font_nodes (xml, font_nodes, parse_state);
}
-SubtitleContent::SubtitleContent (Fraction edit_rate, string movie_title, string language)
- : Content (edit_rate)
- , _movie_title (movie_title)
+SubtitleContent::SubtitleContent (string movie_title, string language)
+ : _movie_title (movie_title)
, _reel_number ("1")
, _language (language)
- , _need_sort (false)
{
}
@@ -223,7 +220,6 @@ void
SubtitleContent::add (SubtitleString s)
{
_subtitles.push_back (s);
- _need_sort = true;
}
struct SubtitleSorter {
@@ -277,9 +273,7 @@ SubtitleContent::xml_as_string () const
}
list<SubtitleString> sorted = _subtitles;
- if (_need_sort) {
- sorted.sort (SubtitleSorter ());
- }
+ sorted.sort (SubtitleSorter ());
/* XXX: multiple fonts not supported */
/* XXX: script, underlined, weight not supported */
@@ -366,3 +360,15 @@ SubtitleContent::xml_as_string () const
return doc.write_to_string_formatted ("UTF-8");
}
+Time
+SubtitleContent::latest_subtitle_out () const
+{
+ Time t;
+ for (list<SubtitleString>::const_iterator i = _subtitles.begin(); i != _subtitles.end(); ++i) {
+ if (i->out() > t) {
+ t = i->out ();
+ }
+ }
+
+ return t;
+}
diff --git a/src/subtitle_content.h b/src/subtitle_content.h
index c00c3f31..b05fe59c 100644
--- a/src/subtitle_content.h
+++ b/src/subtitle_content.h
@@ -48,7 +48,7 @@ public:
* @param mxf true if the file is an MXF file, false for XML.
*/
SubtitleContent (boost::filesystem::path file, bool mxf);
- SubtitleContent (Fraction edit_rate, std::string movie_title, std::string language);
+ SubtitleContent (std::string movie_title, std::string language);
bool equals (
boost::shared_ptr<const Content>,
@@ -74,6 +74,8 @@ public:
void write_xml (boost::filesystem::path) const;
Glib::ustring xml_as_string () const;
+ Time latest_subtitle_out () const;
+
protected:
std::string pkl_type (Standard) const {
return "text/xml";
@@ -113,7 +115,6 @@ private:
std::list<boost::shared_ptr<LoadFont> > _load_font_nodes;
std::list<SubtitleString> _subtitles;
- bool _need_sort;
};
}