2 Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
4 This file is part of libdcp.
6 libdcp 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 libdcp 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 libdcp. If not, see <http://www.gnu.org/licenses/>.
19 In addition, as a special exception, the copyright holders give
20 permission to link the code of portions of this program with the
21 OpenSSL library under certain conditions as described in each
22 individual source file, and distribute linked combinations
25 You must obey the GNU General Public License in all respects
26 for all of the code used other than OpenSSL. If you modify
27 file(s) with this exception, you may extend this exception to your
28 version of the file(s), but you are not obligated to do so. If you
29 do not wish to do so, delete this exception statement from your
30 version. If you delete this exception statement from all source
31 files in the program, then also delete it here.
40 #include "raw_convert.h"
44 #include "exceptions.h"
45 #include "dcp_assert.h"
46 #include "compose.hpp"
47 #include <asdcp/AS_DCP.h>
48 #include <asdcp/KM_prng.h>
49 #include <asdcp/KM_util.h>
50 #include <libxml++/nodes/element.h>
51 #include <boost/filesystem.hpp>
59 using std::shared_ptr;
60 using std::dynamic_pointer_cast;
65 : _context_id (make_uuid ())
67 /* Subclasses can create MXFs with unspecified _standard but are expected to fill
68 _standard in once the MXF is read.
73 MXF::MXF (Standard standard)
74 : _context_id (make_uuid ())
75 , _standard (standard)
82 MXF::fill_writer_info (ASDCP::WriterInfo* writer_info, string id) const
84 writer_info->ProductVersion = _metadata.product_version;
85 writer_info->CompanyName = _metadata.company_name;
86 writer_info->ProductName = _metadata.product_name;
88 DCP_ASSERT (_standard);
89 if (_standard == Standard::INTEROP) {
90 writer_info->LabelSetType = ASDCP::LS_MXF_INTEROP;
92 writer_info->LabelSetType = ASDCP::LS_MXF_SMPTE;
95 Kumu::hex2bin (id.c_str(), writer_info->AssetUUID, Kumu::UUID_Length, &c);
96 DCP_ASSERT (c == Kumu::UUID_Length);
98 writer_info->UsesHMAC = true;
101 Kumu::hex2bin (_context_id.c_str(), writer_info->ContextID, Kumu::UUID_Length, &c);
102 writer_info->EncryptedEssence = true;
105 Kumu::hex2bin (_key_id.get().c_str(), writer_info->CryptographicKeyID, Kumu::UUID_Length, &c);
106 DCP_ASSERT (c == Kumu::UUID_Length);
112 MXF::set_key (Key key)
117 /* No key ID so far; we now need one */
118 _key_id = make_uuid ();
124 MXF::read_writer_info (ASDCP::WriterInfo const & info)
128 if (info.EncryptedEssence) {
129 Kumu::bin2UUIDhex (info.CryptographicKeyID, ASDCP::UUIDlen, buffer, sizeof (buffer));
133 switch (info.LabelSetType) {
134 case ASDCP::LS_MXF_INTEROP:
135 _standard = Standard::INTEROP;
137 case ASDCP::LS_MXF_SMPTE:
138 _standard = Standard::SMPTE;
141 throw ReadError ("Unrecognised label set type in MXF");
144 _metadata.read (info);
146 Kumu::bin2UUIDhex (info.AssetUUID, ASDCP::UUIDlen, buffer, sizeof (buffer));