Missing library from test link list.
[dcpomatic.git] / test / stream_test.cc
1 /*
2     Copyright (C) 2013-2014 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 /** @test  test/stream_test.cc
22  *  @brief Some simple tests of FFmpegAudioStream.
23  */
24
25 #include <boost/test/unit_test.hpp>
26 #include <libxml++/libxml++.h>
27 #include <libcxml/cxml.h>
28 #include "lib/ffmpeg_content.h"
29 #include "lib/ffmpeg_audio_stream.h"
30 #include "lib/film.h"
31
32 using std::pair;
33 using std::list;
34 using boost::shared_ptr;
35
36 BOOST_AUTO_TEST_CASE (stream_test)
37 {
38         xmlpp::Document doc;
39         xmlpp::Element* root = doc.create_root_node ("FFmpegAudioStream");
40         root->add_child("Name")->add_child_text ("hello there world");
41         root->add_child("Id")->add_child_text ("4");
42         root->add_child("FrameRate")->add_child_text ("44100");
43         root->add_child("Channels")->add_child_text ("2");
44
45         /* This is the state file version 5 description of the mapping */
46
47         xmlpp::Element* mapping = root->add_child("Mapping");
48         mapping->add_child("ContentChannels")->add_child_text ("2");
49         {
50                 /* L -> L */
51                 xmlpp::Element* map = mapping->add_child ("Map");
52                 map->add_child("ContentIndex")->add_child_text ("0");
53                 map->add_child("DCP")->add_child_text ("0");
54         }
55         {
56                 /* L -> C */
57                 xmlpp::Element* map = mapping->add_child ("Map");
58                 map->add_child("ContentIndex")->add_child_text ("0");
59                 map->add_child("DCP")->add_child_text ("2");
60         }
61         {
62                 /* R -> R */
63                 xmlpp::Element* map = mapping->add_child ("Map");
64                 map->add_child("ContentIndex")->add_child_text ("1");
65                 map->add_child("DCP")->add_child_text ("1");
66         }
67         {
68                 /* R -> C */
69                 xmlpp::Element* map = mapping->add_child ("Map");
70                 map->add_child("ContentIndex")->add_child_text ("1");
71                 map->add_child("DCP")->add_child_text ("2");
72         }
73
74         FFmpegAudioStream a (cxml::NodePtr (new cxml::Node (root)), 5);
75
76         BOOST_CHECK_EQUAL (a.identifier(), "4");
77         BOOST_CHECK_EQUAL (a.frame_rate(), 44100);
78         BOOST_CHECK_EQUAL (a.channels(), 2);
79         BOOST_CHECK_EQUAL (a.name, "hello there world");
80         BOOST_CHECK_EQUAL (a.mapping().input_channels(), 2);
81
82         BOOST_CHECK_EQUAL (a.mapping().get (0, static_cast<int> (dcp::LEFT)), 1);
83         BOOST_CHECK_EQUAL (a.mapping().get (0, static_cast<int> (dcp::RIGHT)), 0);
84         BOOST_CHECK_EQUAL (a.mapping().get (0, static_cast<int> (dcp::CENTRE)), 1);
85         BOOST_CHECK_EQUAL (a.mapping().get (1, static_cast<int> (dcp::LEFT)), 0);
86         BOOST_CHECK_EQUAL (a.mapping().get (1, static_cast<int> (dcp::RIGHT)), 1);
87         BOOST_CHECK_EQUAL (a.mapping().get (1, static_cast<int> (dcp::CENTRE)), 1);
88 }
89