Remove DCP class and replace its functionality with a plain method in libdcp.
[dcpomatic.git] / src / wx / content_menu.cc
index 4c0afdf3a05475968dffc26eca6f1b4995360a9d..54306b1a90d3a4f6d73fd71999668bd6409dea08 100644 (file)
@@ -31,7 +31,6 @@
 #include "lib/content_factory.h"
 #include "lib/copy_dcp_details_to_film.h"
 #include "lib/dcp_content.h"
-#include "lib/dcp_examiner.h"
 #include "lib/examine_content_job.h"
 #include "lib/exceptions.h"
 #include "lib/ffmpeg_content.h"
 #include <dcp/cpl.h>
 #include <dcp/decrypted_kdm.h>
 #include <dcp/exceptions.h>
+#include <dcp/search.h>
 #include <wx/dirdlg.h>
 #include <wx/wx.h>
+#include <algorithm>
 #include <iostream>
 
 
@@ -146,8 +147,7 @@ ContentMenu::popup (weak_ptr<Film> film, ContentList c, TimelineContentViewList
                        _ov->Enable (dcp->needs_assets ());
                        _set_dcp_settings->Enable (static_cast<bool>(dcp));
                        try {
-                               DCPExaminer ex (dcp, true);
-                               auto cpls = ex.cpls ();
+                               auto cpls = dcp::find_and_resolve_cpls (dcp->directories(), true);
                                _choose_cpl->Enable (cpls.size() > 1);
                                /* We can't have 0 as a menu item ID on OS X */
                                int id = 1;
@@ -394,16 +394,9 @@ ContentMenu::kdm ()
                        return;
                }
 
-               DCPExaminer ex (dcp, true);
-
-               bool kdm_matches_any_cpl = false;
-               for (auto i: ex.cpls()) {
-                       if (i->id() == kdm->cpl_id()) {
-                               kdm_matches_any_cpl = true;
-                       }
-               }
-
-               bool kdm_matches_selected_cpl = dcp->cpl() || kdm->cpl_id() == dcp->cpl().get();
+               auto cpls = dcp::find_and_resolve_cpls (dcp->directories(), true);
+               bool const kdm_matches_any_cpl = std::any_of(cpls.begin(), cpls.end(), [kdm](shared_ptr<const dcp::CPL> cpl) { return cpl->id() == kdm->cpl_id(); });
+               bool const kdm_matches_selected_cpl = dcp->cpl() || kdm->cpl_id() == dcp->cpl().get();
 
                if (!kdm_matches_any_cpl) {
                        error_dialog (_parent, _("This KDM was not made for this DCP.  You will need a different one."));
@@ -474,8 +467,7 @@ ContentMenu::cpl_selected (wxCommandEvent& ev)
        auto dcp = dynamic_pointer_cast<DCPContent> (_content.front());
        DCPOMATIC_ASSERT (dcp);
 
-       DCPExaminer ex (dcp, true);
-       auto cpls = ex.cpls ();
+       auto cpls = dcp::find_and_resolve_cpls (dcp->directories(), true);
        DCPOMATIC_ASSERT (ev.GetId() > 0);
        DCPOMATIC_ASSERT (ev.GetId() <= int (cpls.size()));