diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-01-25 17:16:13 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-01-25 17:16:13 +0000 |
| commit | be1b34275e14d2584e233ac2a81d3dc44a97c208 (patch) | |
| tree | 1e3f68105cbf8f46297c3d88c696d1c34f2ce534 /src/lib | |
| parent | 8657b4ad0776366f58fe4e7fba07bab78fa749a1 (diff) | |
Make DCIMetadata class and use it.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/dci_metadata.cc | 55 | ||||
| -rw-r--r-- | src/lib/dci_metadata.h | 40 | ||||
| -rw-r--r-- | src/lib/film.cc | 127 | ||||
| -rw-r--r-- | src/lib/film.h | 55 | ||||
| -rw-r--r-- | src/lib/wscript | 1 |
5 files changed, 125 insertions, 153 deletions
diff --git a/src/lib/dci_metadata.cc b/src/lib/dci_metadata.cc new file mode 100644 index 000000000..2b4cc3ae7 --- /dev/null +++ b/src/lib/dci_metadata.cc @@ -0,0 +1,55 @@ +/* + Copyright (C) 2012 Carl Hetherington <cth@carlh.net> + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include <iostream> +#include "dci_metadata.h" + +using namespace std; + +void +DCIMetadata::write (ostream& f) const +{ + f << "audio_language " << audio_language << "\n"; + f << "subtitle_language " << subtitle_language << "\n"; + f << "territory " << territory << "\n"; + f << "rating " << rating << "\n"; + f << "studio " << studio << "\n"; + f << "facility " << facility << "\n"; + f << "package_type " << package_type << "\n"; +} + +void +DCIMetadata::read (string k, string v) +{ + if (k == "audio_language") { + audio_language = v; + } else if (k == "subtitle_language") { + subtitle_language = v; + } else if (k == "territory") { + territory = v; + } else if (k == "rating") { + rating = v; + } else if (k == "studio") { + studio = v; + } else if (k == "facility") { + facility = v; + } else if (k == "package_type") { + package_type = v; + } +} diff --git a/src/lib/dci_metadata.h b/src/lib/dci_metadata.h new file mode 100644 index 000000000..eecdc7655 --- /dev/null +++ b/src/lib/dci_metadata.h @@ -0,0 +1,40 @@ +/* + Copyright (C) 2012 Carl Hetherington <cth@carlh.net> + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef DVDOMATIC_DCI_METADATA_H +#define DVDOMATIC_DCI_METADATA_H + +#include <string> + +class DCIMetadata +{ +public: + void read (std::string, std::string); + void write (std::ostream &) const; + + std::string audio_language; + std::string subtitle_language; + std::string territory; + std::string rating; + std::string studio; + std::string facility; + std::string package_type; +}; + +#endif diff --git a/src/lib/film.cc b/src/lib/film.cc index 5a11b0ca9..df89a2552 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -170,13 +170,7 @@ Film::Film (Film const & o) , _subtitle_scale (o._subtitle_scale) , _colour_lut (o._colour_lut) , _j2k_bandwidth (o._j2k_bandwidth) - , _audio_language (o._audio_language) - , _subtitle_language (o._subtitle_language) - , _territory (o._territory) - , _rating (o._rating) - , _studio (o._studio) - , _facility (o._facility) - , _package_type (o._package_type) + , _dci_metadata (o._dci_metadata) , _size (o._size) , _length (o._length) , _content_digest (o._content_digest) @@ -432,14 +426,7 @@ Film::write_metadata () const f << "subtitle_scale " << _subtitle_scale << "\n"; f << "colour_lut " << _colour_lut << "\n"; f << "j2k_bandwidth " << _j2k_bandwidth << "\n"; - f << "audio_language " << _audio_language << "\n"; - f << "subtitle_language " << _subtitle_language << "\n"; - f << "territory " << _territory << "\n"; - f << "rating " << _rating << "\n"; - f << "studio " << _studio << "\n"; - f << "facility " << _facility << "\n"; - f << "package_type " << _package_type << "\n"; - + _dci_metadata.write (f); f << "width " << _size.width << "\n"; f << "height " << _size.height << "\n"; f << "length " << _length.get_value_or(0) << "\n"; @@ -561,21 +548,9 @@ Film::read_metadata () _colour_lut = atoi (v.c_str ()); } else if (k == "j2k_bandwidth") { _j2k_bandwidth = atoi (v.c_str ()); - } else if (k == "audio_language") { - _audio_language = v; - } else if (k == "subtitle_language") { - _subtitle_language = v; - } else if (k == "territory") { - _territory = v; - } else if (k == "rating") { - _rating = v; - } else if (k == "studio") { - _studio = v; - } else if (k == "facility") { - _facility = v; - } else if (k == "package_type") { - _package_type = v; } + + _dci_metadata.read (k, v); /* Cached stuff */ if (k == "width") { @@ -752,10 +727,12 @@ Film::dci_name () const d << format()->dci_name() << "_"; } - if (!audio_language().empty ()) { - d << audio_language(); - if (!subtitle_language().empty() && with_subtitles()) { - d << "-" << subtitle_language(); + DCIMetadata const dm = dci_metadata (); + + if (!dm.audio_language.empty ()) { + d << dm.audio_language; + if (!dm.subtitle_language.empty() && with_subtitles()) { + d << "-" << dm.subtitle_language; } else { d << "-XX"; } @@ -763,10 +740,10 @@ Film::dci_name () const d << "_"; } - if (!territory().empty ()) { - d << territory(); - if (!rating().empty ()) { - d << "-" << rating(); + if (!dm.territory.empty ()) { + d << dm.territory; + if (!dm.rating.empty ()) { + d << "-" << dm.rating; } d << "_"; } @@ -788,18 +765,18 @@ Film::dci_name () const d << "2K_"; - if (!studio().empty ()) { - d << studio() << "_"; + if (!dm.studio.empty ()) { + d << dm.studio << "_"; } d << boost::gregorian::to_iso_string (_dci_date) << "_"; - if (!facility().empty ()) { - d << facility() << "_"; + if (!dm.facility.empty ()) { + d << dm.facility << "_"; } - if (!package_type().empty ()) { - d << package_type(); + if (!dm.package_type.empty ()) { + d << dm.package_type; } return d.str (); @@ -1227,71 +1204,11 @@ Film::set_j2k_bandwidth (int b) } void -Film::set_audio_language (string l) -{ - { - boost::mutex::scoped_lock lm (_state_mutex); - _audio_language = l; - } - signal_changed (DCI_METADATA); -} - -void -Film::set_subtitle_language (string l) -{ - { - boost::mutex::scoped_lock lm (_state_mutex); - _subtitle_language = l; - } - signal_changed (DCI_METADATA); -} - -void -Film::set_territory (string t) -{ - { - boost::mutex::scoped_lock lm (_state_mutex); - _territory = t; - } - signal_changed (DCI_METADATA); -} - -void -Film::set_rating (string r) -{ - { - boost::mutex::scoped_lock lm (_state_mutex); - _rating = r; - } - signal_changed (DCI_METADATA); -} - -void -Film::set_studio (string s) -{ - { - boost::mutex::scoped_lock lm (_state_mutex); - _studio = s; - } - signal_changed (DCI_METADATA); -} - -void -Film::set_facility (string f) -{ - { - boost::mutex::scoped_lock lm (_state_mutex); - _facility = f; - } - signal_changed (DCI_METADATA); -} - -void -Film::set_package_type (string p) +Film::set_dci_metadata (DCIMetadata m) { { boost::mutex::scoped_lock lm (_state_mutex); - _package_type = p; + _dci_metadata = m; } signal_changed (DCI_METADATA); } diff --git a/src/lib/film.h b/src/lib/film.h index d3530b817..af7ec6701 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -38,6 +38,7 @@ extern "C" { #include "dcp_content_type.h" #include "util.h" #include "stream.h" +#include "dci_metadata.h" class Format; class Job; @@ -265,41 +266,11 @@ public: return _j2k_bandwidth; } - std::string audio_language () const { + DCIMetadata dci_metadata () const { boost::mutex::scoped_lock lm (_state_mutex); - return _audio_language; + return _dci_metadata; } - std::string subtitle_language () const { - boost::mutex::scoped_lock lm (_state_mutex); - return _subtitle_language; - } - - std::string territory () const { - boost::mutex::scoped_lock lm (_state_mutex); - return _territory; - } - - std::string rating () const { - boost::mutex::scoped_lock lm (_state_mutex); - return _rating; - } - - std::string studio () const { - boost::mutex::scoped_lock lm (_state_mutex); - return _studio; - } - - std::string facility () const { - boost::mutex::scoped_lock lm (_state_mutex); - return _facility; - } - - std::string package_type () const { - boost::mutex::scoped_lock lm (_state_mutex); - return _package_type; - } - libdcp::Size size () const { boost::mutex::scoped_lock lm (_state_mutex); return _size; @@ -368,13 +339,7 @@ public: void set_subtitle_scale (float); void set_colour_lut (int); void set_j2k_bandwidth (int); - void set_audio_language (std::string); - void set_subtitle_language (std::string); - void set_territory (std::string); - void set_rating (std::string); - void set_studio (std::string); - void set_facility (std::string); - void set_package_type (std::string); + void set_dci_metadata (DCIMetadata); void set_size (libdcp::Size); void set_length (SourceFrame); void unset_length (); @@ -472,15 +437,9 @@ private: int _colour_lut; /** bandwidth for J2K files in bits per second */ int _j2k_bandwidth; - - /* DCI naming stuff */ - std::string _audio_language; - std::string _subtitle_language; - std::string _territory; - std::string _rating; - std::string _studio; - std::string _facility; - std::string _package_type; + + /** DCI naming stuff */ + DCIMetadata _dci_metadata; /* Data which are cached to speed things up */ diff --git a/src/lib/wscript b/src/lib/wscript index 4d93a31aa..cada2b0c3 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -18,6 +18,7 @@ def build(bld): config.cc combiner.cc cross.cc + dci_metadata.cc dcp_content_type.cc dcp_video_frame.cc decoder.cc |
