path -> dir, name for MXFs.
[libdcp.git] / src / dcp.cc
index 27f3243eccb0c09022507f0990a65ace49e455f3..8f7a73bcedaadc44a0cefe59e97c12c6371c9aa1 100644 (file)
@@ -35,6 +35,7 @@
 #include "exceptions.h"
 #include "cpl.h"
 #include "pkl.h"
+#include "asset_map.h"
 
 using namespace std;
 using namespace boost;
@@ -53,37 +54,25 @@ DCP::DCP (string directory, string name, ContentKind content_kind, int fps, int
 void
 DCP::add_sound_asset (vector<string> const & files)
 {
-       filesystem::path p;
-       p /= _directory;
-       p /= "audio.mxf";
-       _assets.push_back (shared_ptr<SoundAsset> (new SoundAsset (files, p.string(), &Progress, _fps, _length)));
+       _assets.push_back (shared_ptr<SoundAsset> (new SoundAsset (files, _directory, "audio.mxf", &Progress, _fps, _length)));
 }
 
 void
 DCP::add_sound_asset (sigc::slot<string, Channel> get_path, int channels)
 {
-       filesystem::path p;
-       p /= _directory;
-       p /= "audio.mxf";
-       _assets.push_back (shared_ptr<SoundAsset> (new SoundAsset (get_path, p.string(), &Progress, _fps, _length, channels)));
+       _assets.push_back (shared_ptr<SoundAsset> (new SoundAsset (get_path, _directory, "audio.mxf", &Progress, _fps, _length, channels)));
 }
 
 void
 DCP::add_picture_asset (vector<string> const & files, int width, int height)
 {
-       filesystem::path p;
-       p /= _directory;
-       p /= "video.mxf";
-       _assets.push_back (shared_ptr<PictureAsset> (new PictureAsset (files, p.string(), &Progress, _fps, _length, width, height)));
+       _assets.push_back (shared_ptr<PictureAsset> (new PictureAsset (files, _directory, "video.mxf", &Progress, _fps, _length, width, height)));
 }
 
 void
 DCP::add_picture_asset (sigc::slot<string, int> get_path, int width, int height)
 {
-       filesystem::path p;
-       p /= _directory;
-       p /= "video.mxf";
-       _assets.push_back (shared_ptr<PictureAsset> (new PictureAsset (get_path, p.string(), &Progress, _fps, _length, width, height)));
+       _assets.push_back (shared_ptr<PictureAsset> (new PictureAsset (get_path, _directory, "video.mxf", &Progress, _fps, _length, width, height)));
 }
 
 void
@@ -273,7 +262,45 @@ DCP::DCP (string directory)
                }
        }
 
+       /* Read the XML */
        CPL cpl (cpl_file);
        PKL pkl (pkl_file);
+       AssetMap asset_map (asset_map_file);
+
+       /* Cross-check */
+       /* XXX */
+
+       /* Now cherry-pick the required bits into our own data structure */
+       
+       _name = cpl.annotation_text;
+       _content_kind = cpl.content_kind;
+
+       shared_ptr<CPLAssetList> cpl_assets = cpl.reels.front()->asset_list;
+       
+       /* XXX */
+       _fps = cpl_assets->main_picture->frame_rate.numerator;
+       _length = cpl_assets->main_picture->duration;
+
+       _assets.push_back (shared_ptr<PictureAsset> (
+                                  new PictureAsset (
+                                          _directory,
+                                          cpl_assets->main_picture->annotation_text,
+                                          _fps,
+                                          _length,
+                                          cpl_assets->main_picture->screen_aspect_ratio.numerator,
+                                          cpl_assets->main_picture->screen_aspect_ratio.denominator
+                                          )
+                                  ));
+
+       if (cpl_assets->main_sound) {
+               _assets.push_back (shared_ptr<SoundAsset> (
+                                          new SoundAsset (
+                                                  _directory,
+                                                  cpl_assets->main_picture->annotation_text,
+                                                  _fps,
+                                                  _length
+                                                  )
+                                          ));
+       }
 }