libdcp
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | Friends | List of all members
dcp::SubtitleAsset Class Referenceabstract

A parent for classes representing a file containing subtitles. More...

#include <subtitle_asset.h>

Inheritance diagram for dcp::SubtitleAsset:
dcp::Asset dcp::Object dcp::InteropSubtitleAsset dcp::SMPTESubtitleAsset

Classes

class  Font
 
struct  ParseState
 

Public Member Functions

 SubtitleAsset (boost::filesystem::path file)
 
bool equals (std::shared_ptr< const Asset >, EqualityOptions, NoteHandler note) const override
 
std::vector< std::shared_ptr< const Subtitle > > subtitles_during (Time from, Time to, bool starting) const
 
std::vector< std::shared_ptr< const Subtitle > > subtitles_in_reel (std::shared_ptr< const dcp::ReelAsset > asset) const
 
std::vector< std::shared_ptr< const Subtitle > > subtitles () const
 
virtual void add (std::shared_ptr< Subtitle >)
 
virtual void add_font (std::string id, dcp::ArrayData data)=0
 
std::map< std::string, ArrayDatafont_data () const
 
std::map< std::string, boost::filesystem::path > font_filenames () const
 
virtual void write (boost::filesystem::path) const =0
 
virtual std::string xml_as_string () const =0
 
Time latest_subtitle_out () const
 
void fix_empty_font_ids ()
 
virtual std::vector< std::shared_ptr< LoadFontNode > > load_font_nodes () const =0
 
virtual int time_code_rate () const =0
 
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 write_to_assetmap (xmlpp::Node *node, 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
 
std::string hash (boost::function< void(float)> progress={}) const
 
void set_hash (std::string hash)
 
- Public Member Functions inherited from dcp::Object
 Object ()
 
 Object (std::string id)
 
 Object (Object const &)=delete
 
Objectoperator= (Object const &)=delete
 
std::string id () const
 

Protected Member Functions

void parse_subtitles (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 subtitles_as_xml (xmlpp::Element *root, int time_code_rate, Standard standard) const
 

Protected Attributes

std::vector< std::shared_ptr< Subtitle > > _subtitles
 
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
 

Private Member Functions

void maybe_add_subtitle (std::string text, std::vector< ParseState > const &parse_state, float space_before, Standard standard)
 

Static Private Member Functions

static void pull_fonts (std::shared_ptr< order::Part > part)
 

Friends

struct ::interop_dcp_font_test
 
struct ::smpte_dcp_font_test
 
struct ::pull_fonts_test1
 
struct ::pull_fonts_test2
 
struct ::pull_fonts_test3
 

Additional Inherited Members

- Static Protected Member Functions inherited from dcp::Asset
static void write_file_to_assetmap (xmlpp::Node *node, boost::filesystem::path root, boost::filesystem::path file, std::string id)
 

Detailed Description

A parent for classes representing a file containing subtitles.

This class holds a list of Subtitle objects which it can extract from the appropriate part of either an Interop or SMPTE XML file. Its subclasses InteropSubtitleAsset and SMPTESubtitleAsset handle the differences between the two types.

Definition at line 91 of file subtitle_asset.h.

Member Function Documentation

◆ fix_empty_font_ids()

void SubtitleAsset::fix_empty_font_ids ( )

Replace empty IDs in any <LoadFontId> and <Font> tags with a dummy string. Some systems give errors with empty font IDs (see DCP-o-matic bug #1689).

Definition at line 771 of file subtitle_asset.cc.

◆ raw_xml()

virtual boost::optional<std::string> dcp::SubtitleAsset::raw_xml ( ) const
inlinevirtual
Returns
Raw XML loaded from, or written to, an on-disk asset, or boost::none if
  • this object was not created from an existing on-disk asset and has not been written to one, or
  • this asset is encrypted and no key is available.

Definition at line 127 of file subtitle_asset.h.

◆ subtitles_as_xml()

void SubtitleAsset::subtitles_as_xml ( xmlpp::Element *  xml_root,
int  time_code_rate,
Standard  standard 
) const
protected
Parameters
standardStandard (INTEROP or SMPTE); this is used rather than putting things in the child class because the differences between the two are fairly subtle.

Definition at line 655 of file subtitle_asset.cc.

Member Data Documentation

◆ _fonts

std::vector<Font> dcp::SubtitleAsset::_fonts
protected

TTF font data that we need

Definition at line 199 of file subtitle_asset.h.

◆ _raw_xml

boost::optional<std::string> dcp::SubtitleAsset::_raw_xml
mutableprotected

The raw XML data that we read from or wrote to our asset; useful for validation

Definition at line 202 of file subtitle_asset.h.

◆ _subtitles

std::vector<std::shared_ptr<Subtitle> > dcp::SubtitleAsset::_subtitles
protected

All our subtitles, in no particular order

Definition at line 173 of file subtitle_asset.h.


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