Use an enum class for Marker.
[libdcp.git] / src / mxf.cc
index 6ec634da053adb94121349d10ec042d23676ddf7..b6c11bb8f64db087b635694ff8422e04d21614b5 100644 (file)
@@ -53,18 +53,34 @@ using std::string;
 using std::cout;
 using std::list;
 using std::pair;
-using boost::shared_ptr;
-using boost::dynamic_pointer_cast;
+using std::shared_ptr;
+using std::dynamic_pointer_cast;
 using namespace dcp;
 
+MXF::MXF ()
+       : _context_id (make_uuid ())
+{
+       /* Subclasses can create MXFs with unspecified _standard but are expected to fill
+          _standard in once the MXF is read.
+       */
+}
+
+MXF::MXF (Standard standard)
+       : _context_id (make_uuid ())
+       , _standard (standard)
+{
+
+}
+
 void
-MXF::fill_writer_info (ASDCP::WriterInfo* writer_info, string id, Standard standard) const
+MXF::fill_writer_info (ASDCP::WriterInfo* writer_info, string id) const
 {
        writer_info->ProductVersion = _metadata.product_version;
        writer_info->CompanyName = _metadata.company_name;
-       writer_info->ProductName = _metadata.product_name.c_str();
+       writer_info->ProductName = _metadata.product_name;
 
-       if (standard == INTEROP) {
+       DCP_ASSERT (_standard);
+       if (_standard == INTEROP) {
                writer_info->LabelSetType = ASDCP::LS_MXF_INTEROP;
        } else {
                writer_info->LabelSetType = ASDCP::LS_MXF_SMPTE;
@@ -76,7 +92,7 @@ MXF::fill_writer_info (ASDCP::WriterInfo* writer_info, string id, Standard stand
        writer_info->UsesHMAC = true;
 
        if (_key_id) {
-               Kumu::GenRandomUUID (writer_info->ContextID);
+               Kumu::hex2bin (_context_id.c_str(), writer_info->ContextID, Kumu::UUID_Length, &c);
                writer_info->EncryptedEssence = true;
 
                unsigned int c;
@@ -111,6 +127,17 @@ MXF::read_writer_info (ASDCP::WriterInfo const & info)
                _key_id = buffer;
        }
 
+       switch (info.LabelSetType) {
+       case ASDCP::LS_MXF_INTEROP:
+               _standard = INTEROP;
+               break;
+       case ASDCP::LS_MXF_SMPTE:
+               _standard = SMPTE;
+               break;
+       default:
+               throw ReadError ("Unrecognised label set type in MXF");
+       }
+
        _metadata.read (info);
 
        Kumu::bin2UUIDhex (info.AssetUUID, ASDCP::UUIDlen, buffer, sizeof (buffer));