From 331b2f8297b2b8a6db07a22dbbff7f913fe7a2f1 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 5 Jun 2015 19:14:54 +0100 Subject: Bits of tidying; comments. --- src/dcp_time.cc | 21 +++++++++++++++++++- src/dcp_time.h | 2 +- src/interop_subtitle_asset.h | 24 +++++++++++++++++++++- src/reel_sound_asset.h | 2 +- src/reel_stereo_picture_asset.h | 4 ++-- src/smpte_subtitle_asset.cc | 13 ++++++++---- src/smpte_subtitle_asset.h | 44 +++++++++++++++++++++++++++++++++++++++-- src/sound_frame.h | 2 +- 8 files changed, 99 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/dcp_time.cc b/src/dcp_time.cc index 5d9bed81..43c1ee49 100644 --- a/src/dcp_time.cc +++ b/src/dcp_time.cc @@ -38,11 +38,22 @@ Time::Time (int frame, int frames_per_second, int tcr_) set (double (frame) / frames_per_second, tcr_); } +/** Construct a Time with a timecode rate of 24 and using the supplied + * number of seconds. + * + * @param seconds A number of seconds. + */ Time::Time (double seconds) { set (seconds, 24); } +/** Construct a Time with specified timecode rate and using the supplied + * number of seconds. + * + * @param seconds A number of seconds. + * @param tcr_ Timecode rate to use. + */ void Time::set (double seconds, int tcr_) { @@ -66,7 +77,7 @@ Time::set (double seconds, int tcr_) } } -/** @param time String of the form HH:MM:SS:EE */ +/** @param time String of the form HH:MM:SS:EE[E] */ Time::Time (string time, int tcr_) : tcr (tcr_) { @@ -251,18 +262,26 @@ Time::as_string () const return str.str (); } +/** @param tcr_ Timecode rate with which the return value should be counted. + * @return the total number of editable units that this time consists of at the specified timecode rate. + * For example, as_editable_units (24) returns the total time in frames at 24fps. + */ int64_t Time::as_editable_units (int tcr_) const { return (int64_t(e) * float (tcr_ / tcr)) + int64_t(s) * tcr_ + int64_t(m) * 60 * tcr_ + int64_t(h) * 60 * 60 * tcr_; } +/** @return the total number of seconds that this time consists of */ double Time::as_seconds () const { return h * 3600 + m * 60 + s + double(e) / tcr; } +/** @param tcr_ New timecode rate. + * @return A new Time which is this time at the spcified new timecode rate. + */ Time Time::rebase (int tcr_) const { diff --git a/src/dcp_time.h b/src/dcp_time.h index 4e505738..c5d0186e 100644 --- a/src/dcp_time.h +++ b/src/dcp_time.h @@ -33,10 +33,10 @@ namespace dcp { /** @class Time * @brief A representation of time within a DCP. */ - class Time { public: + /** Construct a zero Time */ Time () : h (0), m (0), s (0), e (0), tcr (1) {} /** Construct a Time from a frame index (starting from 0), diff --git a/src/interop_subtitle_asset.h b/src/interop_subtitle_asset.h index 2a1fae7f..56350421 100644 --- a/src/interop_subtitle_asset.h +++ b/src/interop_subtitle_asset.h @@ -17,6 +17,10 @@ */ +/** @file src/interop_subtitle_asset.h + * @brief InteropSubtitleAsset class. + */ + #include "subtitle_asset.h" #include @@ -24,6 +28,11 @@ namespace dcp { class InteropLoadFontNode; +/** @class InteropSubtitleAsset + * @brief A set of subtitles to be read and/or written in the Inter-Op format. + * + * Inter-Op subtitles are sometimes known as CineCanvas. + */ class InteropSubtitleAsset : public SubtitleAsset { public: @@ -43,26 +52,39 @@ public: Glib::ustring xml_as_string () const; void write (boost::filesystem::path path) const; + /** Set the reel number or sub-element identifier + * of these subtitles. + * @param n New reel number. + */ void set_reel_number (std::string n) { _reel_number = n; } + /** Set the language tag of these subtitles. + * @param l New language. + */ void set_language (std::string l) { _language = l; } + /** @return title of the movie that the subtitles are for */ void set_movie_title (std::string m) { _movie_title = m; } + /** @return reel number or sub-element of a programme that + * these subtitles refer to. + */ std::string reel_number () const { return _reel_number; } - + + /** @return language used in the subtitles */ std::string language () const { return _language; } + /** @return movie title that these subtitles are for */ std::string movie_title () const { return _movie_title; } diff --git a/src/reel_sound_asset.h b/src/reel_sound_asset.h index e7358bd0..9767307a 100644 --- a/src/reel_sound_asset.h +++ b/src/reel_sound_asset.h @@ -30,7 +30,7 @@ namespace dcp { /** @class ReelSoundAsset - * @brief Part of a Reel's description which refers to a sound MXF. + * @brief Part of a Reel's description which refers to a sound asset. */ class ReelSoundAsset : public ReelAsset, public ReelMXF { diff --git a/src/reel_stereo_picture_asset.h b/src/reel_stereo_picture_asset.h index df939a9c..07d31a03 100644 --- a/src/reel_stereo_picture_asset.h +++ b/src/reel_stereo_picture_asset.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,7 +31,7 @@ namespace dcp { class StereoPictureAsset; /** @class ReelStereoPictureAsset - * @brief Part of a Reel's description which refers to a stereoscopic picture MXF. + * @brief Part of a Reel's description which refers to a stereoscopic picture asset. */ class ReelStereoPictureAsset : public ReelPictureAsset { diff --git a/src/smpte_subtitle_asset.cc b/src/smpte_subtitle_asset.cc index a81b84eb..eef28e51 100644 --- a/src/smpte_subtitle_asset.cc +++ b/src/smpte_subtitle_asset.cc @@ -17,6 +17,10 @@ */ +/** @file src/smpte_subtitle_asset.cc + * @brief SMPTESubtitleAsset class. + */ + #include "smpte_subtitle_asset.h" #include "smpte_load_font_node.h" #include "font_node.h" @@ -39,6 +43,10 @@ using boost::split; using boost::is_any_of; using namespace dcp; +/** Construct a SMPTESubtitleAsset by reading an XML or MXF file. + * @param file Filename. + * @param mxf true if file is an MXF, false if it is XML. + */ SMPTESubtitleAsset::SMPTESubtitleAsset (boost::filesystem::path file, bool mxf) : SubtitleAsset (file) { @@ -59,10 +67,7 @@ SMPTESubtitleAsset::SMPTESubtitleAsset (boost::filesystem::path file, bool mxf) ASDCP::WriterInfo info; reader.FillWriterInfo (info); - - char buffer[64]; - Kumu::bin2UUIDhex (info.AssetUUID, ASDCP::UUIDlen, buffer, sizeof (buffer)); - _id = buffer; + _id = read_writer_info (info); } else { xml->read_file (file); _id = xml->string_child("Id").substr (9); diff --git a/src/smpte_subtitle_asset.h b/src/smpte_subtitle_asset.h index 5f4d8833..c796e1d4 100644 --- a/src/smpte_subtitle_asset.h +++ b/src/smpte_subtitle_asset.h @@ -17,6 +17,10 @@ */ +/** @file src/smpte_subtitle_asset.h + * @brief SMPTESubtitleAsset class. + */ + #include "subtitle_asset.h" #include "local_time.h" #include "mxf.h" @@ -26,6 +30,9 @@ namespace dcp { class SMPTELoadFontNode; +/** @class SMPTESubtitleAsset + * @brief A set of subtitles to be read and/or written in the SMPTE format. + */ class SMPTESubtitleAsset : public SubtitleAsset, public MXF { public: @@ -45,10 +52,43 @@ public: Glib::ustring xml_as_string () const; void write (boost::filesystem::path path) const; - /** @return language, if one was specified */ + /** @return title of the film that these subtitles are for, + * to be presented to the user. + */ + std::string content_title_text () const { + return _content_title_text; + } + + /** @return language as a xs:language, if one was specified */ boost::optional language () const { return _language; } + + /** @return annotation text, to be presented to the user */ + boost::optional annotation_text () const { + return _annotation_text; + } + + /** @return file creation time and date */ + LocalTime issue_date () const { + return _issue_date; + } + + Fraction edit_rate () const { + return _edit_rate; + } + + /** @return subdivision of 1 second that is used for subtitle times; + * e.g. a time_code_rate of 250 means that a subtitle time of 0:0:0:001 + * represents 4ms. + */ + int time_code_rate () const { + return _time_code_rate; + } + + boost::optional