2 Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
21 /** @file src/content_type.cc
22 * @brief A description of the type of content for a DCP (e.g. feature, trailer etc.)
25 #include "dcp_content_type.h"
26 #include "dcpomatic_assert.h"
31 using boost::optional;
35 vector<DCPContentType> DCPContentType::_dcp_content_types;
38 DCPContentType::DCPContentType (string p, dcp::ContentKind k, string d)
48 DCPContentType::setup_dcp_content_types ()
50 /// TRANSLATORS: these are the types that a DCP can have, explained in some
51 /// more detail here: https://registry-page.isdcf.com/contenttypes/
52 _dcp_content_types = {
53 DCPContentType(_("Feature"), dcp::ContentKind::FEATURE, N_("FTR")),
54 DCPContentType(_("Short"), dcp::ContentKind::SHORT, N_("SHR")),
55 DCPContentType(_("Trailer"), dcp::ContentKind::TRAILER, N_("TLR")),
56 DCPContentType(_("Test"), dcp::ContentKind::TEST, N_("TST")),
57 DCPContentType(_("Transitional"), dcp::ContentKind::TRANSITIONAL, N_("XSN")),
58 DCPContentType(_("Rating"), dcp::ContentKind::RATING, N_("RTG")),
59 DCPContentType(_("Teaser"), dcp::ContentKind::TEASER, N_("TSR")),
60 DCPContentType(_("Policy"), dcp::ContentKind::POLICY, N_("POL")),
61 DCPContentType(_("Public Service Announcement"), dcp::ContentKind::PUBLIC_SERVICE_ANNOUNCEMENT, N_("PSA")),
62 DCPContentType(_("Advertisement"), dcp::ContentKind::ADVERTISEMENT, N_("ADV")),
63 DCPContentType(_("Clip"), dcp::ContentKind::CLIP, N_("CLP")),
64 DCPContentType(_("Promo"), dcp::ContentKind::PROMO, N_("PRO")),
65 DCPContentType(_("Stereo card"), dcp::ContentKind::STEREOCARD, N_("STR")),
66 DCPContentType(_("Episode"), dcp::ContentKind::EPISODE, N_("EPS")),
67 DCPContentType(_("Highlights"), dcp::ContentKind::HIGHLIGHTS, N_("HLT")),
68 DCPContentType(_("Event"), dcp::ContentKind::EVENT, N_("EVT")),
73 DCPContentType const *
74 DCPContentType::from_isdcf_name (string n)
76 for (auto& i: _dcp_content_types) {
77 if (i.isdcf_name() == n) {
86 DCPContentType const *
87 DCPContentType::from_libdcp_kind (dcp::ContentKind kind)
89 for (auto& i: _dcp_content_types) {
90 if (i.libdcp_kind() == kind) {
95 DCPOMATIC_ASSERT (false);
100 DCPContentType const *
101 DCPContentType::from_index (int n)
103 DCPOMATIC_ASSERT (n >= 0 && n < int(_dcp_content_types.size()));
104 return &_dcp_content_types[n];
109 DCPContentType::as_index (DCPContentType const * c)
111 vector<DCPContentType>::size_type i = 0;
112 while (i < _dcp_content_types.size() && &_dcp_content_types[i] != c) {
116 if (i == _dcp_content_types.size()) {
124 vector<DCPContentType const *>
125 DCPContentType::all ()
127 vector<DCPContentType const *> raw;
128 for (auto& type: _dcp_content_types) {
129 raw.push_back (&type);