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
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;
}
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;
};
}
{
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.
*/
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 ()
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) {
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 */
/** 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 */
{
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;
}
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 ())
{
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)
{
}
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 () {
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)
{
}
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 {
SubtitleContent::SubtitleContent (boost::filesystem::path file, bool mxf)
: Content (file)
- , _need_sort (false)
{
shared_ptr<cxml::Document> xml;
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)
{
}
SubtitleContent::add (SubtitleString s)
{
_subtitles.push_back (s);
- _need_sort = true;
}
struct SubtitleSorter {
}
list<SubtitleString> sorted = _subtitles;
- if (_need_sort) {
- sorted.sort (SubtitleSorter ());
- }
+ sorted.sort (SubtitleSorter ());
/* XXX: multiple fonts not supported */
/* XXX: script, underlined, weight not supported */
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;
+}
* @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>,
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";
std::list<boost::shared_ptr<LoadFont> > _load_font_nodes;
std::list<SubtitleString> _subtitles;
- bool _need_sort;
};
}