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/>.
22 /** @test test/stream_test.cc
23 * @brief Some simple tests of FFmpegAudioStream.
27 #include "lib/ffmpeg_audio_stream.h"
28 #include "lib/ffmpeg_content.h"
30 #include <libcxml/cxml.h>
31 #include <dcp/warnings.h>
32 LIBDCP_DISABLE_WARNINGS
33 #include <libxml++/libxml++.h>
34 LIBDCP_ENABLE_WARNINGS
35 #include <boost/test/unit_test.hpp>
42 BOOST_AUTO_TEST_CASE (stream_test)
45 auto root = doc.create_root_node("FFmpegAudioStream");
46 root->add_child("Name")->add_child_text ("hello there world");
47 root->add_child("Id")->add_child_text ("4");
48 root->add_child("FrameRate")->add_child_text ("44100");
49 root->add_child("Channels")->add_child_text ("2");
51 /* This is the state file version 5 description of the mapping */
53 auto mapping = root->add_child("Mapping");
54 mapping->add_child("ContentChannels")->add_child_text ("2");
57 auto map = mapping->add_child("Map");
58 map->add_child("ContentIndex")->add_child_text ("0");
59 map->add_child("DCP")->add_child_text ("0");
63 auto map = mapping->add_child("Map");
64 map->add_child("ContentIndex")->add_child_text ("0");
65 map->add_child("DCP")->add_child_text ("2");
69 auto map = mapping->add_child("Map");
70 map->add_child("ContentIndex")->add_child_text ("1");
71 map->add_child("DCP")->add_child_text ("1");
75 auto map = mapping->add_child("Map");
76 map->add_child("ContentIndex")->add_child_text ("1");
77 map->add_child("DCP")->add_child_text ("2");
80 FFmpegAudioStream a (cxml::NodePtr (new cxml::Node (root)), 5);
82 BOOST_CHECK_EQUAL (a.identifier(), "4");
83 BOOST_CHECK_EQUAL (a.frame_rate(), 44100);
84 BOOST_CHECK_EQUAL (a.channels(), 2);
85 BOOST_CHECK_EQUAL (a.name, "hello there world");
86 BOOST_CHECK_EQUAL (a.mapping().input_channels(), 2);
88 BOOST_CHECK_EQUAL (a.mapping().get(0, dcp::Channel::LEFT), 1);
89 BOOST_CHECK_EQUAL (a.mapping().get(0, dcp::Channel::RIGHT), 0);
90 BOOST_CHECK_EQUAL (a.mapping().get(0, dcp::Channel::CENTRE), 1);
91 BOOST_CHECK_EQUAL (a.mapping().get(1, dcp::Channel::LEFT), 0);
92 BOOST_CHECK_EQUAL (a.mapping().get(1, dcp::Channel::RIGHT), 1);
93 BOOST_CHECK_EQUAL (a.mapping().get(1, dcp::Channel::CENTRE), 1);