MpdWriter unit tests
Change-Id: I3b2ee0df2782d5521260eb9323ddbe598e803be3
This commit is contained in:
parent
4fe1594a73
commit
f8949ae311
|
@ -52,16 +52,19 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'target_name': 'mpd_unittest',
|
'target_name': 'mpd_unittest',
|
||||||
'type': 'executable',
|
'type': '<(gtest_target_type)',
|
||||||
'sources': [
|
'sources': [
|
||||||
'base/mpd_builder_unittest.cc',
|
'base/mpd_builder_unittest.cc',
|
||||||
'base/xml/xml_node_unittest.cc',
|
'base/xml/xml_node_unittest.cc',
|
||||||
|
'util/mpd_writer_unittest.cc',
|
||||||
],
|
],
|
||||||
'dependencies': [
|
'dependencies': [
|
||||||
'../base/base.gyp:base',
|
'../base/base.gyp:base',
|
||||||
'../base/base.gyp:run_all_unittests',
|
'../base/base.gyp:run_all_unittests',
|
||||||
|
'../packager.gyp:file',
|
||||||
'../testing/gtest.gyp:gtest',
|
'../testing/gtest.gyp:gtest',
|
||||||
'mpd_builder',
|
'mpd_builder',
|
||||||
|
'mpd_util',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
bandwidth: 400
|
||||||
|
audio_info {
|
||||||
|
codec: "mp4a.40.2"
|
||||||
|
sampling_frequency: 44100
|
||||||
|
time_scale: 1200
|
||||||
|
num_channels: 2
|
||||||
|
}
|
||||||
|
reference_time_scale: 50
|
||||||
|
container_type: 1
|
||||||
|
media_file_name: "test_output_file_name_audio1.mp4"
|
||||||
|
media_duration_seconds: 10.5
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<MPD xmlns="urn:mpeg:DASH:schema:MPD:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="urn:mpeg:DASH:schema:MPD:2011 DASH-MPD.xsd" minBufferTime="PT2S" type="static" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" mediaPresentationDuration="PT10.5S">
|
||||||
|
<Period>
|
||||||
|
<AdaptationSet id="0">
|
||||||
|
<Representation id="0" bandwidth="400" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
|
||||||
|
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
|
||||||
|
<BaseURL>test_output_file_name_audio1.mp4</BaseURL>
|
||||||
|
<SegmentBase timescale="50"/>
|
||||||
|
</Representation>
|
||||||
|
</AdaptationSet>
|
||||||
|
</Period>
|
||||||
|
</MPD>
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<MPD xmlns="urn:mpeg:DASH:schema:MPD:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="urn:mpeg:DASH:schema:MPD:2011 DASH-MPD.xsd" minBufferTime="PT2S" type="static" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" mediaPresentationDuration="PT10.5S">
|
||||||
|
<Period>
|
||||||
|
<AdaptationSet id="0">
|
||||||
|
<Representation id="1" bandwidth="7620" codecs="avc1.010101" mimeType="video/mp4" width="720" height="480">
|
||||||
|
<BaseURL>test_output_file_name1.mp4</BaseURL>
|
||||||
|
<SegmentBase indexRange="121-221" timescale="1000">
|
||||||
|
<Initialization range="0-120"/>
|
||||||
|
</SegmentBase>
|
||||||
|
</Representation>
|
||||||
|
</AdaptationSet>
|
||||||
|
<AdaptationSet id="1">
|
||||||
|
<Representation id="0" bandwidth="400" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
|
||||||
|
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
|
||||||
|
<BaseURL>test_output_file_name_audio1.mp4</BaseURL>
|
||||||
|
<SegmentBase timescale="50"/>
|
||||||
|
</Representation>
|
||||||
|
</AdaptationSet>
|
||||||
|
</Period>
|
||||||
|
</MPD>
|
|
@ -0,0 +1,19 @@
|
||||||
|
bandwidth: 7620
|
||||||
|
video_info {
|
||||||
|
codec: "avc1.010101"
|
||||||
|
width: 720
|
||||||
|
height: 480
|
||||||
|
time_scale: 10
|
||||||
|
}
|
||||||
|
init_range {
|
||||||
|
begin: 0
|
||||||
|
end: 120
|
||||||
|
}
|
||||||
|
index_range {
|
||||||
|
begin: 121
|
||||||
|
end: 221
|
||||||
|
}
|
||||||
|
reference_time_scale: 1000
|
||||||
|
container_type: 1
|
||||||
|
media_file_name: "test_output_file_name1.mp4"
|
||||||
|
media_duration_seconds: 10.5
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<MPD xmlns="urn:mpeg:DASH:schema:MPD:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="urn:mpeg:DASH:schema:MPD:2011 DASH-MPD.xsd" minBufferTime="PT2S" type="static" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" mediaPresentationDuration="PT10.5S">
|
||||||
|
<Period>
|
||||||
|
<AdaptationSet id="0">
|
||||||
|
<Representation id="0" bandwidth="7620" codecs="avc1.010101" mimeType="video/mp4" width="720" height="480">
|
||||||
|
<BaseURL>test_output_file_name1.mp4</BaseURL>
|
||||||
|
<SegmentBase indexRange="121-221" timescale="1000">
|
||||||
|
<Initialization range="0-120"/>
|
||||||
|
</SegmentBase>
|
||||||
|
</Representation>
|
||||||
|
</AdaptationSet>
|
||||||
|
</Period>
|
||||||
|
</MPD>
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<MPD xmlns="urn:mpeg:DASH:schema:MPD:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="urn:mpeg:DASH:schema:MPD:2011 DASH-MPD.xsd" minBufferTime="PT2S" type="static" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" mediaPresentationDuration="PT10.5S">
|
||||||
|
<Period>
|
||||||
|
<AdaptationSet id="0">
|
||||||
|
<Representation id="0" bandwidth="7620" codecs="avc1.010101" mimeType="video/mp4" width="720" height="480">
|
||||||
|
<BaseURL>test_output_file_name1.mp4</BaseURL>
|
||||||
|
<SegmentBase indexRange="121-221" timescale="1000">
|
||||||
|
<Initialization range="0-120"/>
|
||||||
|
</SegmentBase>
|
||||||
|
</Representation>
|
||||||
|
<Representation id="1" bandwidth="5000" codecs="avc1.010101" mimeType="video/mp4" width="480" height="360">
|
||||||
|
<BaseURL>test_output_file_name2.mp4</BaseURL>
|
||||||
|
<SegmentBase indexRange="54-100" timescale="50">
|
||||||
|
<Initialization range="0-53"/>
|
||||||
|
</SegmentBase>
|
||||||
|
</Representation>
|
||||||
|
</AdaptationSet>
|
||||||
|
</Period>
|
||||||
|
</MPD>
|
|
@ -0,0 +1,19 @@
|
||||||
|
bandwidth: 5000
|
||||||
|
video_info {
|
||||||
|
codec: "avc1.010101"
|
||||||
|
width: 480
|
||||||
|
height: 360
|
||||||
|
time_scale: 20
|
||||||
|
}
|
||||||
|
init_range {
|
||||||
|
begin: 0
|
||||||
|
end: 53
|
||||||
|
}
|
||||||
|
index_range {
|
||||||
|
begin: 54
|
||||||
|
end: 100
|
||||||
|
}
|
||||||
|
reference_time_scale: 50
|
||||||
|
container_type: 1
|
||||||
|
media_file_name: "test_output_file_name2.mp4"
|
||||||
|
media_duration_seconds: 10.5
|
|
@ -0,0 +1,95 @@
|
||||||
|
#include "base/file_util.h"
|
||||||
|
#include "base/path_service.h"
|
||||||
|
#include "mpd/util/mpd_writer.h"
|
||||||
|
#include "testing/gtest/include/gtest/gtest.h"
|
||||||
|
|
||||||
|
// TODO(rkuroiwa): Move schema check function in mpd_builder_unittest.cc to
|
||||||
|
// another file so that this file can use it as well.
|
||||||
|
namespace dash_packager {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
base::FilePath GetTestDataFilePath(const std::string& file_name) {
|
||||||
|
base::FilePath file_path;
|
||||||
|
CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &file_path));
|
||||||
|
|
||||||
|
file_path = file_path.Append(FILE_PATH_LITERAL("mpd"))
|
||||||
|
.Append(FILE_PATH_LITERAL("test"))
|
||||||
|
.Append(FILE_PATH_LITERAL("data"))
|
||||||
|
.AppendASCII(file_name);
|
||||||
|
return file_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExpectToEqualExpectedOutputFile(
|
||||||
|
const std::string& mpd_string,
|
||||||
|
const base::FilePath& expected_output_file) {
|
||||||
|
std::string expected_mpd;
|
||||||
|
ASSERT_TRUE(file_util::ReadFileToString(expected_output_file, &expected_mpd))
|
||||||
|
<< "Failed to read: " << expected_output_file.value();
|
||||||
|
ASSERT_EQ(expected_mpd, mpd_string);
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
TEST(MpdWriterTest, ReadMediaInfoFile_VideoMediaInfo) {
|
||||||
|
MpdWriter mpd_writer;
|
||||||
|
base::FilePath media_info_file = GetTestDataFilePath("video_media_info1.txt");
|
||||||
|
|
||||||
|
ASSERT_TRUE(mpd_writer.AddFile(media_info_file.value().c_str()));
|
||||||
|
std::string generated_mpd;
|
||||||
|
ASSERT_TRUE(mpd_writer.WriteMpdToString(&generated_mpd));
|
||||||
|
|
||||||
|
ASSERT_NO_FATAL_FAILURE(ExpectToEqualExpectedOutputFile(
|
||||||
|
generated_mpd,
|
||||||
|
GetTestDataFilePath("video_media_info1_expected_mpd_output.txt")));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(MpdWriterTest, ReadMediaInfoFile_TwoVideoMediaInfo) {
|
||||||
|
MpdWriter mpd_writer;
|
||||||
|
base::FilePath media_info_file1 =
|
||||||
|
GetTestDataFilePath("video_media_info1.txt");
|
||||||
|
base::FilePath media_info_file2 =
|
||||||
|
GetTestDataFilePath("video_media_info2.txt");
|
||||||
|
|
||||||
|
ASSERT_TRUE(mpd_writer.AddFile(media_info_file1.value().c_str()));
|
||||||
|
ASSERT_TRUE(mpd_writer.AddFile(media_info_file2.value().c_str()));
|
||||||
|
|
||||||
|
std::string generated_mpd;
|
||||||
|
ASSERT_TRUE(mpd_writer.WriteMpdToString(&generated_mpd));
|
||||||
|
|
||||||
|
ASSERT_NO_FATAL_FAILURE(ExpectToEqualExpectedOutputFile(
|
||||||
|
generated_mpd,
|
||||||
|
GetTestDataFilePath("video_media_info1and2_expected_mpd_output.txt")));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(MpdWriterTest, ReadMediaInfoFile_AudioMediaInfo) {
|
||||||
|
MpdWriter mpd_writer;
|
||||||
|
base::FilePath media_info_file = GetTestDataFilePath("audio_media_info1.txt");
|
||||||
|
|
||||||
|
ASSERT_TRUE(mpd_writer.AddFile(media_info_file.value().c_str()));
|
||||||
|
std::string generated_mpd;
|
||||||
|
ASSERT_TRUE(mpd_writer.WriteMpdToString(&generated_mpd));
|
||||||
|
|
||||||
|
ASSERT_NO_FATAL_FAILURE(ExpectToEqualExpectedOutputFile(
|
||||||
|
generated_mpd,
|
||||||
|
GetTestDataFilePath("audio_media_info1_expected_mpd_output.txt")));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(MpdWriterTest, ReadMediaInfoFile_VideoAudioMediaInfo) {
|
||||||
|
MpdWriter mpd_writer;
|
||||||
|
base::FilePath audio_media_info =
|
||||||
|
GetTestDataFilePath("audio_media_info1.txt");
|
||||||
|
base::FilePath video_media_info =
|
||||||
|
GetTestDataFilePath("video_media_info1.txt");
|
||||||
|
|
||||||
|
ASSERT_TRUE(mpd_writer.AddFile(audio_media_info.value().c_str()));
|
||||||
|
ASSERT_TRUE(mpd_writer.AddFile(video_media_info.value().c_str()));
|
||||||
|
|
||||||
|
std::string generated_mpd;
|
||||||
|
ASSERT_TRUE(mpd_writer.WriteMpdToString(&generated_mpd));
|
||||||
|
|
||||||
|
ASSERT_NO_FATAL_FAILURE(ExpectToEqualExpectedOutputFile(
|
||||||
|
generated_mpd,
|
||||||
|
GetTestDataFilePath(
|
||||||
|
"audio_media_info1_video_media_info1_expected_mpd_output.txt")));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace dash_packager
|
Loading…
Reference in New Issue