2 Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
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.
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.
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/>.
21 /** @test test/stream_test.cc
22 * @brief Some simple tests of FFmpegAudioStream.
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"
34 using boost::shared_ptr;
36 BOOST_AUTO_TEST_CASE (stream_test)
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");
45 /* This is the state file version 5 description of the mapping */
47 xmlpp::Element* mapping = root->add_child("Mapping");
48 mapping->add_child("ContentChannels")->add_child_text ("2");
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");
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");
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");
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");
74 FFmpegAudioStream a (cxml::NodePtr (new cxml::Node (root)), 5);
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);
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);