std::shared_ptr
[dcpomatic.git] / test / markers_test.cc
1 /*
2     Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     DCP-o-matic is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21
22 /** @file  test/markers_test
23  *  @brief Test SMPTE markers.
24  *  @ingroup feature
25  */
26
27
28 #include "lib/content_factory.h"
29 #include "lib/film.h"
30 #include "test.h"
31 #include <dcp/cpl.h>
32 #include <dcp/dcp.h>
33 #include <dcp/reel_markers_asset.h>
34 #include <dcp/reel.h>
35 #include <boost/test/unit_test.hpp>
36
37
38 using std::string;
39 using boost::optional;
40 using std::shared_ptr;
41
42
43 /** Check that FFOC and LFOC are automatically added if not specified */
44 BOOST_AUTO_TEST_CASE (automatic_ffoc_lfoc_markers_test1)
45 {
46         string const name = "automatic_ffoc_lfoc_markers_test1";
47         shared_ptr<Film> film = new_test_film2 (name);
48         film->examine_and_add_content (content_factory("test/data/flat_red.png").front());
49         BOOST_REQUIRE (!wait_for_jobs());
50
51         film->set_interop (false);
52         film->make_dcp ();
53         BOOST_REQUIRE (!wait_for_jobs());
54
55         dcp::DCP dcp (String::compose("build/test/%1/%2", name, film->dcp_name()));
56         dcp.read ();
57         BOOST_REQUIRE_EQUAL (dcp.cpls().size(), 1U);
58         shared_ptr<dcp::CPL> cpl = dcp.cpls().front();
59         BOOST_REQUIRE_EQUAL (cpl->reels().size(), 1U);
60         shared_ptr<dcp::Reel> reel = cpl->reels().front();
61         shared_ptr<dcp::ReelMarkersAsset> markers = reel->main_markers();
62         BOOST_REQUIRE (markers);
63
64         optional<dcp::Time> ffoc = markers->get (dcp::Marker::FFOC);
65         BOOST_REQUIRE (ffoc);
66         BOOST_CHECK (*ffoc == dcp::Time (0, 0, 0, 0, 24));
67         optional<dcp::Time> lfoc = markers->get (dcp::Marker::LFOC);
68         BOOST_REQUIRE (lfoc);
69         BOOST_CHECK (*lfoc == dcp::Time(0, 0, 9, 23, 24));
70 }
71
72
73 /** Check that FFOC and LFOC are not overridden if they are specified */
74 BOOST_AUTO_TEST_CASE (automatic_ffoc_lfoc_markers_test2)
75 {
76         string const name = "automatic_ffoc_lfoc_markers_test2";
77         shared_ptr<Film> film = new_test_film2 (name);
78         film->examine_and_add_content (content_factory("test/data/flat_red.png").front());
79         BOOST_REQUIRE (!wait_for_jobs());
80
81         film->set_interop (false);
82         film->set_marker (dcp::Marker::FFOC, dcpomatic::DCPTime::from_seconds(1));
83         film->set_marker (dcp::Marker::LFOC, dcpomatic::DCPTime::from_seconds(9));
84         film->make_dcp ();
85         BOOST_REQUIRE (!wait_for_jobs());
86
87         dcp::DCP dcp (String::compose("build/test/%1/%2", name, film->dcp_name()));
88         dcp.read ();
89         BOOST_REQUIRE_EQUAL (dcp.cpls().size(), 1U);
90         shared_ptr<dcp::CPL> cpl = dcp.cpls().front();
91         BOOST_REQUIRE_EQUAL (cpl->reels().size(), 1U);
92         shared_ptr<dcp::Reel> reel = cpl->reels().front();
93         shared_ptr<dcp::ReelMarkersAsset> markers = reel->main_markers();
94         BOOST_REQUIRE (markers);
95
96         optional<dcp::Time> ffoc = markers->get (dcp::Marker::FFOC);
97         BOOST_REQUIRE (ffoc);
98         BOOST_CHECK (*ffoc == dcp::Time (0, 0, 1, 0, 24));
99         optional<dcp::Time> lfoc = markers->get (dcp::Marker::LFOC);
100         BOOST_REQUIRE (lfoc);
101         BOOST_CHECK (*lfoc == dcp::Time(0, 0, 9, 0, 24));
102 }
103