Fix to allow re-writing of SMPTE subtitles.
[libdcp.git] / src / atmos_asset.cc
index eac01dcf3525378a35b1b6dd824bad28486674f1..2145d8f80140681dca8436381d08c8ee744e5e50 100644 (file)
 #include <asdcp/AS_DCP.h>
 
 using std::string;
-using boost::shared_ptr;
+using std::shared_ptr;
 using namespace dcp;
 
-AtmosAsset::AtmosAsset (Fraction edit_rate, int first_frame, int max_channel_count, int max_object_count, string atmos_id, int atmos_version)
-       : _edit_rate (edit_rate)
+AtmosAsset::AtmosAsset (Fraction edit_rate, int first_frame, int max_channel_count, int max_object_count, int atmos_version)
+       : MXF (SMPTE)
+       , _edit_rate (edit_rate)
        , _intrinsic_duration (0)
        , _first_frame (first_frame)
        , _max_channel_count (max_channel_count)
        , _max_object_count (max_object_count)
-       , _atmos_id (atmos_id)
+       , _atmos_id (make_uuid())
        , _atmos_version (atmos_version)
 {
 
@@ -55,6 +56,7 @@ AtmosAsset::AtmosAsset (Fraction edit_rate, int first_frame, int max_channel_cou
 
 AtmosAsset::AtmosAsset (boost::filesystem::path file)
        : Asset (file)
+       , MXF (SMPTE)
 {
        ASDCP::ATMOS::MXFReader reader;
        Kumu::Result_t r = reader.OpenRead (file.string().c_str());
@@ -64,7 +66,7 @@ AtmosAsset::AtmosAsset (boost::filesystem::path file)
 
        ASDCP::ATMOS::AtmosDescriptor desc;
        if (ASDCP_FAILURE (reader.FillAtmosDescriptor (desc))) {
-               boost::throw_exception (DCPReadError ("could not read Atmos MXF information"));
+               boost::throw_exception (ReadError ("could not read Atmos MXF information"));
        }
 
        _edit_rate = Fraction (desc.EditRate.Numerator, desc.EditRate.Denominator);
@@ -78,10 +80,17 @@ AtmosAsset::AtmosAsset (boost::filesystem::path file)
        _atmos_id = id;
 
        _atmos_version = desc.AtmosVersion;
+
+       ASDCP::WriterInfo info;
+       if (ASDCP_FAILURE (reader.FillWriterInfo (info))) {
+               boost::throw_exception (ReadError ("could not read audio MXF information"));
+       }
+
+       _id = read_writer_info (info);
 }
 
 string
-AtmosAsset::pkl_type (Standard) const
+AtmosAsset::static_pkl_type (Standard)
 {
        return "application/mxf";
 }
@@ -89,7 +98,7 @@ AtmosAsset::pkl_type (Standard) const
 shared_ptr<AtmosAssetReader>
 AtmosAsset::start_read () const
 {
-       return shared_ptr<AtmosAssetReader> (new AtmosAssetReader (this, key ()));
+       return shared_ptr<AtmosAssetReader> (new AtmosAssetReader (this, key(), SMPTE));
 }
 
 shared_ptr<AtmosAssetWriter>