Try removing the DCI companding from the xyz->rgb conversion.
[libdcp.git] / src / asset.cc
index e2624712c8b1ddf9cc5cb36f79f699c13df3c8a9..3d2a0e03e21054b02805279ea6fd9ff4d303050a 100644 (file)
 
 */
 
+/** @file  src/asset.cc
+ *  @brief Parent class for assets of DCPs.
+ */
+
 #include <iostream>
+#include <fstream>
 #include <boost/filesystem.hpp>
 #include "AS_DCP.h"
 #include "KM_util.h"
 #include "asset.h"
 #include "util.h"
-#include "tags.h"
+#include "metadata.h"
 
 using namespace std;
 using namespace boost;
 using namespace libdcp;
 
-/** Construct an Asset.
- *  @param p Pathname of MXF file.
- *  @param fps Frames per second.
- *  @param len Length in frames.
- */
-
-Asset::Asset (string p, int fps, int len)
-       : _mxf_path (p)
-       , _fps (fps)
-       , _length (len)
+Asset::Asset (string directory, string file_name)
+       : _directory (directory)
+       , _file_name (file_name)
        , _uuid (make_uuid ())
 {
-       
+       if (_file_name.empty ()) {
+               _file_name = _uuid + ".xml";
+       }
 }
 
-/** Write details of the asset to a PKL stream.
- *  @param s Stream.
- */
 void
 Asset::write_to_pkl (ostream& s) const
 {
        s << "    <Asset>\n"
          << "      <Id>urn:uuid:" << _uuid << "</Id>\n"
-         << "      <AnnotationText>" << filesystem::path(_mxf_path).filename() << "</AnnotationText>\n"
-         << "      <Hash>" << _digest << "</Hash>\n"
-         << "      <Size>" << filesystem::file_size(_mxf_path) << "</Size>\n"
+         << "      <AnnotationText>" << _file_name << "</AnnotationText>\n"
+         << "      <Hash>" << digest() << "</Hash>\n"
+         << "      <Size>" << filesystem::file_size(path()) << "</Size>\n"
          << "      <Type>application/mxf</Type>\n"
          << "    </Asset>\n";
 }
 
-/** Write details of the asset to a ASSETMAP stream.
- *  @param s Stream.
- */
 void
 Asset::write_to_assetmap (ostream& s) const
 {
@@ -69,25 +63,30 @@ Asset::write_to_assetmap (ostream& s) const
          << "      <Id>urn:uuid:" << _uuid << "</Id>\n"
          << "      <ChunkList>\n"
          << "        <Chunk>\n"
-         << "          <Path>" << filesystem::path(_mxf_path).filename() << "</Path>\n"
+         << "          <Path>" << _file_name << "</Path>\n"
          << "          <VolumeIndex>1</VolumeIndex>\n"
          << "          <Offset>0</Offset>\n"
-         << "          <Length>" << filesystem::file_size(_mxf_path) << "</Length>\n"
+         << "          <Length>" << filesystem::file_size(path()) << "</Length>\n"
          << "        </Chunk>\n"
          << "      </ChunkList>\n"
          << "    </Asset>\n";
 }
 
-/** Fill in a ADSCP::WriteInfo struct */
-void
-Asset::fill_writer_info (ASDCP::WriterInfo* writer_info) const
+filesystem::path
+Asset::path () const
+{
+       filesystem::path p;
+       p /= _directory;
+       p /= _file_name;
+       return p;
+}
+
+string
+Asset::digest () const
 {
-       writer_info->ProductVersion = Tags::instance()->product_version;
-       writer_info->CompanyName = Tags::instance()->company_name;
-       writer_info->ProductName = Tags::instance()->product_name.c_str();
+       if (_digest.empty ()) {
+               _digest = make_digest (path().string());
+       }
 
-       writer_info->LabelSetType = ASDCP::LS_MXF_SMPTE;
-       unsigned int c;
-       Kumu::hex2bin (_uuid.c_str(), writer_info->AssetUUID, Kumu::UUID_Length, &c);
-       assert (c == Kumu::UUID_Length);
+       return _digest;
 }