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.
26 #include "lib/ffmpeg_content.h"
27 #include "lib/ffmpeg_audio_stream.h"
28 #include "lib/warnings.h"
29 #include <libcxml/cxml.h>
30 DCPOMATIC_DISABLE_WARNINGS
31 #include <libxml++/libxml++.h>
32 DCPOMATIC_ENABLE_WARNINGS
33 #include <boost/test/unit_test.hpp>
37 using std::shared_ptr;
39 BOOST_AUTO_TEST_CASE (stream_test)
42 xmlpp::Element* root = doc.create_root_node ("FFmpegAudioStream");
43 root->add_child("Name")->add_child_text ("hello there world");
44 root->add_child("Id")->add_child_text ("4");
45 root->add_child("FrameRate")->add_child_text ("44100");
46 root->add_child("Channels")->add_child_text ("2");
48 /* This is the state file version 5 description of the mapping */
50 xmlpp::Element* mapping = root->add_child("Mapping");
51 mapping->add_child("ContentChannels")->add_child_text ("2");
54 xmlpp::Element* map = mapping->add_child ("Map");
55 map->add_child("ContentIndex")->add_child_text ("0");
56 map->add_child("DCP")->add_child_text ("0");
60 xmlpp::Element* map = mapping->add_child ("Map");
61 map->add_child("ContentIndex")->add_child_text ("0");
62 map->add_child("DCP")->add_child_text ("2");
66 xmlpp::Element* map = mapping->add_child ("Map");
67 map->add_child("ContentIndex")->add_child_text ("1");
68 map->add_child("DCP")->add_child_text ("1");
72 xmlpp::Element* map = mapping->add_child ("Map");
73 map->add_child("ContentIndex")->add_child_text ("1");
74 map->add_child("DCP")->add_child_text ("2");
77 FFmpegAudioStream a (cxml::NodePtr (new cxml::Node (root)), 5);
79 BOOST_CHECK_EQUAL (a.identifier(), "4");
80 BOOST_CHECK_EQUAL (a.frame_rate(), 44100);
81 BOOST_CHECK_EQUAL (a.channels(), 2);
82 BOOST_CHECK_EQUAL (a.name, "hello there world");
83 BOOST_CHECK_EQUAL (a.mapping().input_channels(), 2);
85 BOOST_CHECK_EQUAL (a.mapping().get(0, dcp::Channel::LEFT), 1);
86 BOOST_CHECK_EQUAL (a.mapping().get(0, dcp::Channel::RIGHT), 0);
87 BOOST_CHECK_EQUAL (a.mapping().get(0, dcp::Channel::CENTRE), 1);
88 BOOST_CHECK_EQUAL (a.mapping().get(1, dcp::Channel::LEFT), 0);
89 BOOST_CHECK_EQUAL (a.mapping().get(1, dcp::Channel::RIGHT), 1);
90 BOOST_CHECK_EQUAL (a.mapping().get(1, dcp::Channel::CENTRE), 1);