libdcp
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
dcp::SMPTETextAsset Class Reference

A set of subtitles/captions to be read and/or written in the SMPTE format. More...

#include <smpte_text_asset.h>

Inheritance diagram for dcp::SMPTETextAsset:
dcp::TextAsset dcp::MXF dcp::Asset dcp::Object

Public Member Functions

 SMPTETextAsset (SubtitleStandard standard=SubtitleStandard::SMPTE_2014)
 
 SMPTETextAsset (boost::filesystem::path file)
 
bool equals (std::shared_ptr< const Asset >, EqualityOptions const &, NoteHandler note) const override
 
std::vector< std::shared_ptr< LoadFontNode > > load_font_nodes () const override
 
std::string xml_as_string () const override
 
void write (boost::filesystem::path path) const override
 
void add (std::shared_ptr< Text >) override
 
void add_font (std::string id, dcp::ArrayData data) override
 
void set_key (Key key) override
 
void set_content_title_text (std::string t)
 
void set_language (dcp::LanguageTag l)
 
void set_issue_date (LocalTime t)
 
void set_reel_number (int r)
 
void set_edit_rate (Fraction e)
 
void set_time_code_rate (int t)
 
void set_start_time (Time t)
 
void set_intrinsic_duration (int64_t d)
 
int64_t intrinsic_duration () const
 
std::string content_title_text () const
 
boost::optional< std::string > language () const
 
boost::optional< std::string > annotation_text () const
 
LocalTime issue_date () const
 
boost::optional< int > reel_number () const
 
Fraction edit_rate () const
 
int time_code_rate () const override
 
boost::optional< Timestart_time () const
 
boost::optional< std::string > xml_id () const
 
boost::optional< std::string > resource_id () const
 
SubtitleStandard subtitle_standard () const override
 
- Public Member Functions inherited from dcp::TextAsset
 TextAsset (boost::filesystem::path file)
 
bool equals (std::shared_ptr< const Asset >, EqualityOptions const &, NoteHandler note) const override
 
std::vector< std::shared_ptr< const Text > > texts_during (Time from, Time to, bool starting) const
 
std::vector< std::shared_ptr< const Text > > texts () const
 
void ensure_font (std::string id, dcp::ArrayData data)
 
std::map< std::string, ArrayDatafont_data () const
 
std::map< std::string, boost::filesystem::path > font_filenames () const
 
Time latest_text_out () const
 
void fix_empty_font_ids ()
 
virtual boost::optional< std::string > raw_xml () const
 
- Public Member Functions inherited from dcp::Asset
 Asset ()
 
 Asset (boost::filesystem::path file)
 
 Asset (std::string id, boost::filesystem::path file)
 
virtual void add_to_assetmap (AssetMap &asset_map, boost::filesystem::path root) const
 
virtual void add_to_pkl (std::shared_ptr< PKL > pkl, boost::filesystem::path root) const
 
boost::optional< boost::filesystem::path > file () const
 
void set_file (boost::filesystem::path file) const
 
void set_file_preserving_hash (boost::filesystem::path file) const
 
void rename_file (boost::filesystem::path file)
 
std::string hash (boost::function< void(int64_t, int64_t)> progress={}) const
 
void set_hash (std::string hash)
 
void unset_hash ()
 
- Public Member Functions inherited from dcp::Object
 Object ()
 
 Object (std::string id)
 
 Object (Object const &other)
 
Objectoperator= (Object const &other)
 
std::string id () const
 
- Public Member Functions inherited from dcp::MXF
 MXF (Standard standard)
 
bool encrypted () const
 
void set_key_id (std::string i)
 
boost::optional< std::string > key_id () const
 
boost::optional< Keykey () const
 
void set_context_id (std::string id)
 
std::string context_id () const
 
void set_metadata (MXFMetadata m)
 
MXFMetadata metadata () const
 
Standard standard () const
 

Static Public Member Functions

static bool valid_mxf (boost::filesystem::path)
 
static std::string static_pkl_type (Standard)
 
- Static Public Member Functions inherited from dcp::TextAsset
static std::string format_xml (xmlpp::Document const &document, boost::optional< std::pair< std::string, std::string >> xml_namespace)
 

Protected Member Functions

std::string pkl_type (Standard s) const override
 
- Protected Member Functions inherited from dcp::TextAsset
void parse_texts (xmlpp::Element const *node, std::vector< ParseState > &state, boost::optional< int > tcr, Standard standard)
 
ParseState font_node_state (xmlpp::Element const *node, Standard standard) const
 
ParseState text_node_state (xmlpp::Element const *node) const
 
ParseState image_node_state (xmlpp::Element const *node) const
 
ParseState subtitle_node_state (xmlpp::Element const *node, boost::optional< int > tcr) const
 
Time fade_time (xmlpp::Element const *node, std::string name, boost::optional< int > tcr) const
 
void position_align (ParseState &ps, xmlpp::Element const *node) const
 
void texts_as_xml (xmlpp::Element *root, int time_code_rate, Standard standard) const
 
- Protected Member Functions inherited from dcp::MXF
std::string read_writer_info (ASDCP::WriterInfo const &)
 
void fill_writer_info (ASDCP::WriterInfo *w, std::string id) const
 

Private Member Functions

void read_fonts (std::shared_ptr< ASDCP::TimedText::MXFReader >)
 
void parse_xml (std::shared_ptr< cxml::Document > xml)
 
void read_mxf_descriptor (std::shared_ptr< ASDCP::TimedText::MXFReader > reader)
 
void read_mxf_resources (std::shared_ptr< ASDCP::TimedText::MXFReader > reader, std::shared_ptr< DecryptionContext > dec)
 
std::string schema_namespace () const
 

Private Attributes

int64_t _intrinsic_duration = 0
 
std::string _content_title_text
 
boost::optional< std::string > _language
 
boost::optional< std::string > _annotation_text
 
LocalTime _issue_date
 
boost::optional< int > _reel_number
 
Fraction _edit_rate
 
int _time_code_rate = 0
 
boost::optional< Time_start_time
 
SubtitleStandard _subtitle_standard
 
std::vector< std::shared_ptr< SMPTELoadFontNode > > _load_font_nodes
 
boost::optional< std::string > _xml_id
 
boost::optional< std::string > _resource_id
 

Friends

struct ::write_smpte_subtitle_test
 
struct ::write_smpte_subtitle_test2
 
struct ::verify_invalid_language1
 
struct ::verify_invalid_language2
 
struct ::write_subtitles_in_vertical_order_with_top_alignment
 
struct ::write_subtitles_in_vertical_order_with_bottom_alignment
 

Additional Inherited Members

- Static Protected Member Functions inherited from dcp::Asset
static void add_file_to_assetmap (AssetMap &asset_map, boost::filesystem::path root, boost::filesystem::path file, std::string id)
 
- Protected Attributes inherited from dcp::TextAsset
std::vector< std::shared_ptr< Text > > _texts
 
std::vector< Font_fonts
 
boost::optional< std::string > _raw_xml
 
- Protected Attributes inherited from dcp::Asset
boost::optional< boost::filesystem::path > _file
 
- Protected Attributes inherited from dcp::Object
std::string _id
 
- Protected Attributes inherited from dcp::MXF
boost::optional< std::string > _key_id
 
boost::optional< Key_key
 
std::string _context_id
 
MXFMetadata _metadata
 
boost::optional< Standard > _standard
 

Detailed Description

A set of subtitles/captions to be read and/or written in the SMPTE format.

Definition at line 75 of file smpte_text_asset.h.

Constructor & Destructor Documentation

◆ SMPTETextAsset()

SMPTETextAsset::SMPTETextAsset ( boost::filesystem::path  file)
explicit

Construct a SMPTETextAsset by reading an MXF or XML file

Parameters
fileFilename

Definition at line 93 of file smpte_text_asset.cc.

Member Function Documentation

◆ annotation_text()

boost::optional<std::string> dcp::SMPTETextAsset::annotation_text ( ) const
inline
Returns
annotation text, to be presented to the user

Definition at line 153 of file smpte_text_asset.h.

◆ content_title_text()

std::string dcp::SMPTETextAsset::content_title_text ( ) const
inline
Returns
title of the film that these subtitles/captions are for, to be presented to the user

Definition at line 141 of file smpte_text_asset.h.

◆ issue_date()

LocalTime dcp::SMPTETextAsset::issue_date ( ) const
inline
Returns
file issue time and date

Definition at line 158 of file smpte_text_asset.h.

◆ language()

boost::optional<std::string> dcp::SMPTETextAsset::language ( ) const
inline
Returns
Language, if one was set. This should be a xs:language, but it might not be if a non-compliant DCP was read in.

Definition at line 148 of file smpte_text_asset.h.

◆ pkl_type()

std::string dcp::SMPTETextAsset::pkl_type ( Standard  standard) const
inlineoverrideprotectedvirtual
Returns
type string for PKLs for this asset

Implements dcp::Asset.

Definition at line 205 of file smpte_text_asset.h.

◆ resource_id()

boost::optional<std::string> dcp::SMPTETextAsset::resource_id ( ) const
inline
Returns
ResourceID read from any MXF that was read

Definition at line 190 of file smpte_text_asset.h.

◆ set_key()

void SMPTETextAsset::set_key ( Key  key)
overridevirtual

Set the (private) key that will be used to encrypt or decrypt this MXF's content This is the top-secret key that is distributed (itself encrypted) to cinemas via Key Delivery Messages (KDMs)

Parameters
keyKey to use

Reimplemented from dcp::MXF.

Definition at line 304 of file smpte_text_asset.cc.

◆ time_code_rate()

int dcp::SMPTETextAsset::time_code_rate ( ) const
inlineoverridevirtual
Returns
subdivision of 1 second that is used for text times; e.g. a time_code_rate of 250 means that a text time of 0:0:0:001 represents 4ms.

Implements dcp::TextAsset.

Definition at line 174 of file smpte_text_asset.h.

◆ write()

void SMPTETextAsset::write ( boost::filesystem::path  path) const
overridevirtual

Write this content to a MXF file

Implements dcp::TextAsset.

Definition at line 406 of file smpte_text_asset.cc.

◆ xml_id()

boost::optional<std::string> dcp::SMPTETextAsset::xml_id ( ) const
inline
Returns
ID from XML's <Id> tag, or the <Id> that will be used when writing the XML, or boost::none if this content is encrypted and no key is available.

Definition at line 185 of file smpte_text_asset.h.

Member Data Documentation

◆ _content_title_text

std::string dcp::SMPTETextAsset::_content_title_text
private

<ContentTitleText> from the asset

Definition at line 228 of file smpte_text_asset.h.

◆ _intrinsic_duration

int64_t dcp::SMPTETextAsset::_intrinsic_duration = 0
private

The total length of this content in video frames. The amount of content presented may be less than this.

Definition at line 226 of file smpte_text_asset.h.

◆ _language

boost::optional<std::string> dcp::SMPTETextAsset::_language
private

This is stored and returned as a string so that we can tolerate non-RFC-5646 strings, but must be set as a dcp::LanguageTag to try to ensure that we create compliant output.

Definition at line 232 of file smpte_text_asset.h.

◆ _resource_id

boost::optional<std::string> dcp::SMPTETextAsset::_resource_id
private

ResourceID read from the MXF, if there was one

Definition at line 254 of file smpte_text_asset.h.

◆ _subtitle_standard

SubtitleStandard dcp::SMPTETextAsset::_subtitle_standard
private

There are two SMPTE standards describing subtitles, 428-7:2010 and 428-7:2014, and they have different interpretations of what Vposition means. Though libdcp does not need to know the difference, this variable stores the standard from the namespace that this asset was written with (or will be written with).

Definition at line 244 of file smpte_text_asset.h.

◆ _xml_id

boost::optional<std::string> dcp::SMPTETextAsset::_xml_id
private

UUID for the XML inside the MXF, which should be the same as the ResourceID in the MXF (our _resource_id) but different to the AssetUUID in the MXF (our _id) according to SMPTE Bv2.1 and Doremi's 2.8.18 release notes. May be boost::none if this object has been made from an encrypted object without a key.

Definition at line 251 of file smpte_text_asset.h.


The documentation for this class was generated from the following files: