2014-02-14 23:21:05 +00:00
|
|
|
// Copyright 2014 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file or at
|
|
|
|
// https://developers.google.com/open-source/licenses/bsd
|
|
|
|
|
2018-01-24 23:26:37 +00:00
|
|
|
#include <gmock/gmock.h>
|
2014-08-21 22:40:44 +00:00
|
|
|
#include <gtest/gtest.h>
|
2017-12-14 21:58:53 +00:00
|
|
|
|
2017-12-13 01:26:37 +00:00
|
|
|
#include "packager/mpd/base/adaptation_set.h"
|
2014-10-01 22:10:21 +00:00
|
|
|
#include "packager/mpd/base/mpd_builder.h"
|
2017-12-14 01:00:11 +00:00
|
|
|
#include "packager/mpd/base/period.h"
|
2018-01-29 18:37:50 +00:00
|
|
|
#include "packager/mpd/base/representation.h"
|
2014-10-01 22:10:21 +00:00
|
|
|
#include "packager/mpd/test/mpd_builder_test_helper.h"
|
2016-07-07 19:34:07 +00:00
|
|
|
#include "packager/version/version.h"
|
2013-12-30 23:05:27 +00:00
|
|
|
|
2018-01-24 23:26:37 +00:00
|
|
|
using ::testing::HasSubstr;
|
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
namespace shaka {
|
2013-12-30 23:05:27 +00:00
|
|
|
|
2014-02-05 18:55:37 +00:00
|
|
|
namespace {
|
2014-05-27 22:21:42 +00:00
|
|
|
|
2016-01-11 23:58:02 +00:00
|
|
|
class TestClock : public base::Clock {
|
|
|
|
public:
|
|
|
|
explicit TestClock(const base::Time& t) : time_(t) {}
|
|
|
|
~TestClock() override {}
|
|
|
|
base::Time Now() override { return time_; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
base::Time time_;
|
|
|
|
};
|
|
|
|
|
2014-02-05 18:55:37 +00:00
|
|
|
} // namespace
|
|
|
|
|
2016-12-21 23:28:56 +00:00
|
|
|
template <DashProfile profile>
|
2015-10-29 22:48:13 +00:00
|
|
|
class MpdBuilderTest : public ::testing::Test {
|
2014-02-28 22:34:26 +00:00
|
|
|
public:
|
2016-12-21 23:28:56 +00:00
|
|
|
MpdBuilderTest() : mpd_(MpdOptions()), representation_() {
|
|
|
|
mpd_.mpd_options_.dash_profile = profile;
|
|
|
|
}
|
2015-07-22 23:40:45 +00:00
|
|
|
~MpdBuilderTest() override {}
|
2014-02-28 22:34:26 +00:00
|
|
|
|
2017-12-14 01:00:11 +00:00
|
|
|
void SetUp() override {
|
2018-01-03 00:10:54 +00:00
|
|
|
const double kPeriodStartTimeSeconds = 0.0;
|
|
|
|
period_ = mpd_.GetOrCreatePeriod(kPeriodStartTimeSeconds);
|
2017-12-14 01:00:11 +00:00
|
|
|
ASSERT_TRUE(period_);
|
|
|
|
}
|
|
|
|
|
2016-12-21 23:28:56 +00:00
|
|
|
MpdOptions* mutable_mpd_options() { return &mpd_.mpd_options_; }
|
|
|
|
|
2014-02-28 22:34:26 +00:00
|
|
|
void CheckMpd(const std::string& expected_output_file) {
|
|
|
|
std::string mpd_doc;
|
|
|
|
ASSERT_TRUE(mpd_.ToString(&mpd_doc));
|
|
|
|
ASSERT_TRUE(ValidateMpdSchema(mpd_doc));
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(
|
|
|
|
ExpectMpdToEqualExpectedOutputFile(mpd_doc, expected_output_file));
|
|
|
|
}
|
|
|
|
|
2018-01-29 18:37:50 +00:00
|
|
|
void AddSegmentToPeriod(double segment_start_time_seconds,
|
|
|
|
double segment_duration_seconds,
|
|
|
|
Period* period) {
|
|
|
|
MediaInfo media_info = GetTestMediaInfo(kFileNameVideoMediaInfo1);
|
|
|
|
// Not relevant in this test.
|
|
|
|
const bool kContentProtectionFlag = true;
|
|
|
|
const size_t kBytes = 1000;
|
|
|
|
|
|
|
|
AdaptationSet* adaptation_set =
|
|
|
|
period->GetOrCreateAdaptationSet(media_info, kContentProtectionFlag);
|
|
|
|
Representation* representation =
|
|
|
|
adaptation_set->AddRepresentation(media_info);
|
|
|
|
representation->AddNewSegment(
|
|
|
|
segment_start_time_seconds * media_info.reference_time_scale(),
|
|
|
|
segment_duration_seconds * media_info.reference_time_scale(), kBytes);
|
|
|
|
}
|
|
|
|
|
2014-02-28 22:34:26 +00:00
|
|
|
protected:
|
2016-01-05 00:33:53 +00:00
|
|
|
// Creates a new AdaptationSet and adds a Representation element using
|
|
|
|
// |media_info|.
|
2014-05-22 02:16:17 +00:00
|
|
|
void AddRepresentation(const MediaInfo& media_info) {
|
2017-12-14 01:00:11 +00:00
|
|
|
AdaptationSet* adaptation_set =
|
|
|
|
period_->GetOrCreateAdaptationSet(media_info, true);
|
2014-05-22 02:16:17 +00:00
|
|
|
ASSERT_TRUE(adaptation_set);
|
|
|
|
|
|
|
|
Representation* representation =
|
|
|
|
adaptation_set->AddRepresentation(media_info);
|
|
|
|
ASSERT_TRUE(representation);
|
|
|
|
|
|
|
|
representation_ = representation;
|
|
|
|
}
|
|
|
|
|
2014-02-28 22:34:26 +00:00
|
|
|
MpdBuilder mpd_;
|
|
|
|
|
2014-05-22 02:16:17 +00:00
|
|
|
// We usually need only one representation.
|
|
|
|
Representation* representation_; // Owned by |mpd_|.
|
|
|
|
|
2014-02-28 22:34:26 +00:00
|
|
|
private:
|
2017-12-14 01:00:11 +00:00
|
|
|
Period* period_ = nullptr;
|
2017-12-14 06:33:47 +00:00
|
|
|
base::AtomicSequenceNumber representation_counter_;
|
2016-12-21 23:28:56 +00:00
|
|
|
|
2014-05-22 02:16:17 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(MpdBuilderTest);
|
2014-02-28 22:34:26 +00:00
|
|
|
};
|
|
|
|
|
2016-12-21 23:28:56 +00:00
|
|
|
class OnDemandMpdBuilderTest : public MpdBuilderTest<DashProfile::kOnDemand> {};
|
2013-12-30 23:05:27 +00:00
|
|
|
|
2016-12-21 23:28:56 +00:00
|
|
|
class LiveMpdBuilderTest : public MpdBuilderTest<DashProfile::kLive> {
|
2014-05-22 02:16:17 +00:00
|
|
|
public:
|
2016-12-21 23:28:56 +00:00
|
|
|
~LiveMpdBuilderTest() override {}
|
2013-12-30 23:05:27 +00:00
|
|
|
|
2014-05-22 02:16:17 +00:00
|
|
|
// Anchors availabilityStartTime so that the test result doesn't depend on the
|
|
|
|
// current time.
|
2015-07-22 23:40:45 +00:00
|
|
|
void SetUp() override {
|
2016-07-07 19:34:07 +00:00
|
|
|
SetPackagerVersionForTesting("<tag>-<hash>-<test>");
|
2016-12-21 23:28:56 +00:00
|
|
|
mpd_.mpd_options_.mpd_type = MpdType::kDynamic;
|
2014-06-26 01:33:09 +00:00
|
|
|
mpd_.availability_start_time_ = "2011-12-25T12:30:00";
|
2016-01-11 23:58:02 +00:00
|
|
|
InjectTestClock();
|
2014-05-22 02:16:17 +00:00
|
|
|
}
|
2013-12-30 23:05:27 +00:00
|
|
|
|
2016-01-11 23:58:02 +00:00
|
|
|
// Injects a clock that always returns 2016 Jan 11 15:10:24 in UTC.
|
|
|
|
void InjectTestClock() {
|
2016-08-14 22:28:21 +00:00
|
|
|
base::Time::Exploded test_time = { 2016, // year.
|
|
|
|
1, // month
|
|
|
|
1, // day_of_week = Monday.
|
|
|
|
11, // day_of_month
|
|
|
|
15, // hour.
|
|
|
|
10, // minute.
|
|
|
|
24, // second.
|
|
|
|
0 }; // millisecond.
|
2016-01-11 23:58:02 +00:00
|
|
|
ASSERT_TRUE(test_time.HasValidValues());
|
2016-08-17 17:41:40 +00:00
|
|
|
mpd_.InjectClockForTesting(std::unique_ptr<base::Clock>(
|
2016-01-11 23:58:02 +00:00
|
|
|
new TestClock(base::Time::FromUTCExploded(test_time))));
|
|
|
|
}
|
2014-05-27 22:21:42 +00:00
|
|
|
};
|
|
|
|
|
2014-05-22 02:16:17 +00:00
|
|
|
// Add one video check the output.
|
2016-12-21 23:28:56 +00:00
|
|
|
TEST_F(OnDemandMpdBuilderTest, Video) {
|
2014-05-22 02:16:17 +00:00
|
|
|
MediaInfo video_media_info = GetTestMediaInfo(kFileNameVideoMediaInfo1);
|
|
|
|
ASSERT_NO_FATAL_FAILURE(AddRepresentation(video_media_info));
|
2014-02-28 22:34:26 +00:00
|
|
|
EXPECT_NO_FATAL_FAILURE(CheckMpd(kFileNameExpectedMpdOutputVideo1));
|
2013-12-30 23:05:27 +00:00
|
|
|
}
|
|
|
|
|
2016-12-21 23:28:56 +00:00
|
|
|
TEST_F(OnDemandMpdBuilderTest, TwoVideosWithDifferentResolutions) {
|
2016-01-05 00:33:53 +00:00
|
|
|
MediaInfo media_info1 = GetTestMediaInfo(kFileNameVideoMediaInfo1);
|
|
|
|
MediaInfo media_info2 = GetTestMediaInfo(kFileNameVideoMediaInfo2);
|
2017-12-14 01:00:11 +00:00
|
|
|
// The order matters here to check against expected output.
|
|
|
|
ASSERT_NO_FATAL_FAILURE(AddRepresentation(media_info1));
|
|
|
|
ASSERT_NO_FATAL_FAILURE(AddRepresentation(media_info2));
|
2016-01-05 00:33:53 +00:00
|
|
|
|
|
|
|
EXPECT_NO_FATAL_FAILURE(CheckMpd(kFileNameExpectedMpdOutputVideo1And2));
|
|
|
|
}
|
|
|
|
|
2014-05-22 02:16:17 +00:00
|
|
|
// Add both video and audio and check the output.
|
2016-12-21 23:28:56 +00:00
|
|
|
TEST_F(OnDemandMpdBuilderTest, VideoAndAudio) {
|
2014-02-05 02:32:46 +00:00
|
|
|
MediaInfo video_media_info = GetTestMediaInfo(kFileNameVideoMediaInfo1);
|
|
|
|
MediaInfo audio_media_info = GetTestMediaInfo(kFileNameAudioMediaInfo1);
|
|
|
|
// The order matters here to check against expected output.
|
2017-12-14 01:00:11 +00:00
|
|
|
ASSERT_NO_FATAL_FAILURE(AddRepresentation(video_media_info));
|
|
|
|
ASSERT_NO_FATAL_FAILURE(AddRepresentation(audio_media_info));
|
2013-12-30 23:05:27 +00:00
|
|
|
|
2014-02-28 22:34:26 +00:00
|
|
|
EXPECT_NO_FATAL_FAILURE(CheckMpd(kFileNameExpectedMpdOutputAudio1AndVideo1));
|
|
|
|
}
|
|
|
|
|
2014-05-22 02:16:17 +00:00
|
|
|
// Static profile requires bandwidth to be set because it has no other way to
|
|
|
|
// get the bandwidth for the Representation.
|
2016-12-21 23:28:56 +00:00
|
|
|
TEST_F(OnDemandMpdBuilderTest, MediaInfoMissingBandwidth) {
|
2014-05-22 02:16:17 +00:00
|
|
|
MediaInfo video_media_info = GetTestMediaInfo(kFileNameVideoMediaInfo1);
|
|
|
|
video_media_info.clear_bandwidth();
|
|
|
|
AddRepresentation(video_media_info);
|
|
|
|
|
|
|
|
std::string mpd_doc;
|
|
|
|
ASSERT_FALSE(mpd_.ToString(&mpd_doc));
|
|
|
|
}
|
|
|
|
|
2018-03-27 16:27:17 +00:00
|
|
|
TEST_F(OnDemandMpdBuilderTest, CheckXmlTest) {
|
|
|
|
const double kPeriod1StartTimeSeconds = 0.0;
|
|
|
|
|
|
|
|
// Actual period duration is determined by the segments not by the period
|
|
|
|
// start time above, which only provides an anchor point.
|
|
|
|
const double kPeriod1SegmentStartSeconds = 0.2;
|
|
|
|
const double kPeriod1SegmentDurationSeconds = 3.0;
|
|
|
|
|
|
|
|
Period* period = mpd_.GetOrCreatePeriod(kPeriod1StartTimeSeconds);
|
|
|
|
AddSegmentToPeriod(kPeriod1SegmentStartSeconds,
|
|
|
|
kPeriod1SegmentDurationSeconds, period);
|
|
|
|
|
|
|
|
std::string mpd_doc;
|
|
|
|
ASSERT_TRUE(mpd_.ToString(&mpd_doc));
|
|
|
|
EXPECT_THAT(mpd_doc, HasSubstr("<Period id=\"0\">\n"));
|
|
|
|
EXPECT_THAT(mpd_doc,
|
|
|
|
HasSubstr("<SegmentBase indexRange=\"121-221\""
|
|
|
|
" timescale=\"1000\" presentationTimeOffset=\"200\">"));
|
|
|
|
}
|
|
|
|
|
2018-01-24 23:26:37 +00:00
|
|
|
TEST_F(OnDemandMpdBuilderTest, MultiplePeriodTest) {
|
2018-01-03 00:10:54 +00:00
|
|
|
const double kPeriodStartTimeSeconds = 1.0;
|
|
|
|
Period* period = mpd_.GetOrCreatePeriod(kPeriodStartTimeSeconds);
|
|
|
|
ASSERT_TRUE(period);
|
|
|
|
ASSERT_EQ(kPeriodStartTimeSeconds, period->start_time_in_seconds());
|
|
|
|
|
|
|
|
const double kPeriodStartTimeSeconds2 = 1.1;
|
|
|
|
Period* period2 = mpd_.GetOrCreatePeriod(kPeriodStartTimeSeconds2);
|
|
|
|
ASSERT_TRUE(period2);
|
|
|
|
// The old Period is re-used if they are closed to each other.
|
|
|
|
ASSERT_EQ(period, period2);
|
|
|
|
ASSERT_EQ(kPeriodStartTimeSeconds, period2->start_time_in_seconds());
|
|
|
|
|
|
|
|
const double kPeriodStartTimeSeconds3 = 5.0;
|
|
|
|
Period* period3 = mpd_.GetOrCreatePeriod(kPeriodStartTimeSeconds3);
|
|
|
|
ASSERT_TRUE(period3);
|
|
|
|
ASSERT_NE(period, period3);
|
|
|
|
ASSERT_EQ(kPeriodStartTimeSeconds3, period3->start_time_in_seconds());
|
|
|
|
}
|
|
|
|
|
2018-01-24 23:26:37 +00:00
|
|
|
TEST_F(OnDemandMpdBuilderTest, MultiplePeriodCheckXmlTest) {
|
2018-01-29 18:37:50 +00:00
|
|
|
const double kPeriod1StartTimeSeconds = 0.0;
|
|
|
|
const double kPeriod2StartTimeSeconds = 3.1;
|
|
|
|
const double kPeriod3StartTimeSeconds = 8.0;
|
|
|
|
|
|
|
|
// Actual period duration is determined by the segments not by the period
|
|
|
|
// start time above, which only provides an anchor point.
|
|
|
|
const double kPeriod1SegmentStartSeconds = 0.2;
|
|
|
|
const double kPeriod1SegmentDurationSeconds = 3.0;
|
|
|
|
const double kPeriod2SegmentStartSeconds = 5.5;
|
|
|
|
const double kPeriod2SegmentDurationSeconds = 10.5;
|
|
|
|
const double kPeriod3SegmentStartSeconds = 1.5;
|
|
|
|
const double kPeriod3SegmentDurationSeconds = 10.0;
|
|
|
|
|
|
|
|
Period* period = mpd_.GetOrCreatePeriod(kPeriod1StartTimeSeconds);
|
|
|
|
AddSegmentToPeriod(kPeriod1SegmentStartSeconds,
|
|
|
|
kPeriod1SegmentDurationSeconds, period);
|
|
|
|
|
|
|
|
period = mpd_.GetOrCreatePeriod(kPeriod2StartTimeSeconds);
|
|
|
|
AddSegmentToPeriod(kPeriod2SegmentStartSeconds,
|
|
|
|
kPeriod2SegmentDurationSeconds, period);
|
|
|
|
|
|
|
|
period = mpd_.GetOrCreatePeriod(kPeriod3StartTimeSeconds);
|
|
|
|
AddSegmentToPeriod(kPeriod3SegmentStartSeconds,
|
|
|
|
kPeriod3SegmentDurationSeconds, period);
|
2018-01-24 23:26:37 +00:00
|
|
|
|
|
|
|
std::string mpd_doc;
|
|
|
|
ASSERT_TRUE(mpd_.ToString(&mpd_doc));
|
2018-01-29 18:37:50 +00:00
|
|
|
EXPECT_THAT(mpd_doc, HasSubstr("<Period id=\"0\" duration=\"PT3S\">\n"));
|
2018-03-27 16:27:17 +00:00
|
|
|
EXPECT_THAT(mpd_doc,
|
|
|
|
HasSubstr("<SegmentBase indexRange=\"121-221\""
|
|
|
|
" timescale=\"1000\" presentationTimeOffset=\"200\">"));
|
|
|
|
EXPECT_THAT(mpd_doc, HasSubstr("<Period id=\"1\" duration=\"PT10.5S\">\n"));
|
2018-01-29 18:37:50 +00:00
|
|
|
EXPECT_THAT(
|
|
|
|
mpd_doc,
|
2018-03-27 16:27:17 +00:00
|
|
|
HasSubstr("<SegmentBase indexRange=\"121-221\""
|
|
|
|
" timescale=\"1000\" presentationTimeOffset=\"5500\">"));
|
2018-01-29 18:37:50 +00:00
|
|
|
EXPECT_THAT(mpd_doc, HasSubstr("<Period id=\"2\" duration=\"PT10S\">\n"));
|
2018-03-27 16:27:17 +00:00
|
|
|
EXPECT_THAT(
|
|
|
|
mpd_doc,
|
|
|
|
HasSubstr("<SegmentBase indexRange=\"121-221\""
|
|
|
|
" timescale=\"1000\" presentationTimeOffset=\"1500\">"));
|
2018-01-24 23:26:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(LiveMpdBuilderTest, MultiplePeriodCheckXmlTest) {
|
2018-01-29 18:37:50 +00:00
|
|
|
const double kPeriod1StartTimeSeconds = 0.0;
|
|
|
|
const double kPeriod2StartTimeSeconds = 3.1;
|
|
|
|
const double kPeriod3StartTimeSeconds = 8.0;
|
|
|
|
mpd_.GetOrCreatePeriod(kPeriod1StartTimeSeconds);
|
|
|
|
mpd_.GetOrCreatePeriod(kPeriod2StartTimeSeconds);
|
|
|
|
mpd_.GetOrCreatePeriod(kPeriod3StartTimeSeconds);
|
2018-01-24 23:26:37 +00:00
|
|
|
|
|
|
|
std::string mpd_doc;
|
|
|
|
ASSERT_TRUE(mpd_.ToString(&mpd_doc));
|
|
|
|
EXPECT_THAT(mpd_doc, HasSubstr(" <Period id=\"0\" start=\"PT0S\"/>\n"
|
|
|
|
" <Period id=\"1\" start=\"PT3.1S\"/>\n"
|
|
|
|
" <Period id=\"2\" start=\"PT8S\"/>\n"));
|
|
|
|
}
|
|
|
|
|
2014-05-22 02:16:17 +00:00
|
|
|
// Check whether the attributes are set correctly for dynamic <MPD> element.
|
2015-07-15 21:57:47 +00:00
|
|
|
// This test must use ASSERT_EQ for comparison because XmlEqual() cannot
|
|
|
|
// handle namespaces correctly yet.
|
2016-12-21 23:28:56 +00:00
|
|
|
TEST_F(LiveMpdBuilderTest, DynamicCheckMpdAttributes) {
|
2014-05-22 02:16:17 +00:00
|
|
|
static const char kExpectedOutput[] =
|
|
|
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
2017-12-14 01:00:11 +00:00
|
|
|
"<!--Generated with https://github.com/google/shaka-packager"
|
|
|
|
" version <tag>-<hash>-<test>-->\n"
|
|
|
|
"<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\""
|
|
|
|
" xmlns:cenc=\"urn:mpeg:cenc:2013\""
|
|
|
|
" profiles=\"urn:mpeg:dash:profile:isoff-live:2011\""
|
|
|
|
" minBufferTime=\"PT2S\""
|
|
|
|
" type=\"dynamic\""
|
|
|
|
" publishTime=\"2016-01-11T15:10:24Z\""
|
|
|
|
" availabilityStartTime=\"2011-12-25T12:30:00\""
|
|
|
|
" minimumUpdatePeriod=\"PT2S\"/>\n";
|
2014-05-22 02:16:17 +00:00
|
|
|
|
|
|
|
std::string mpd_doc;
|
2016-12-21 23:28:56 +00:00
|
|
|
mutable_mpd_options()->mpd_type = MpdType::kDynamic;
|
2017-12-14 01:00:11 +00:00
|
|
|
mutable_mpd_options()->mpd_params.minimum_update_period = 2;
|
2016-12-21 23:28:56 +00:00
|
|
|
ASSERT_TRUE(mpd_.ToString(&mpd_doc));
|
|
|
|
ASSERT_EQ(kExpectedOutput, mpd_doc);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(LiveMpdBuilderTest, StaticCheckMpdAttributes) {
|
|
|
|
static const char kExpectedOutput[] =
|
|
|
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
2017-12-14 01:00:11 +00:00
|
|
|
"<!--Generated with https://github.com/google/shaka-packager"
|
|
|
|
" version <tag>-<hash>-<test>-->\n"
|
|
|
|
"<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\""
|
|
|
|
" xmlns:cenc=\"urn:mpeg:cenc:2013\""
|
|
|
|
" profiles=\"urn:mpeg:dash:profile:isoff-live:2011\""
|
|
|
|
" minBufferTime=\"PT2S\""
|
|
|
|
" type=\"static\""
|
|
|
|
" mediaPresentationDuration=\"PT0S\"/>\n";
|
2016-12-21 23:28:56 +00:00
|
|
|
|
|
|
|
std::string mpd_doc;
|
|
|
|
mutable_mpd_options()->mpd_type = MpdType::kStatic;
|
2014-05-22 02:16:17 +00:00
|
|
|
ASSERT_TRUE(mpd_.ToString(&mpd_doc));
|
|
|
|
ASSERT_EQ(kExpectedOutput, mpd_doc);
|
|
|
|
}
|
|
|
|
|
2017-09-08 17:52:48 +00:00
|
|
|
namespace {
|
|
|
|
const char kMediaFile[] = "foo/bar/media.mp4";
|
|
|
|
const char kMediaFileBase[] = "media.mp4";
|
|
|
|
const char kInitSegment[] = "foo/bar/init.mp4";
|
|
|
|
const char kInitSegmentBase[] = "init.mp4";
|
|
|
|
const char kSegmentTemplate[] = "foo/bar/segment-$Number$.mp4";
|
|
|
|
const char kSegmentTemplateBase[] = "segment-$Number$.mp4";
|
|
|
|
const char kPathModifiedMpd[] = "foo/bar/media.mpd";
|
|
|
|
const char kPathNotModifiedMpd[] = "foo/baz/media.mpd";
|
|
|
|
} // namespace
|
|
|
|
|
2014-12-16 01:32:19 +00:00
|
|
|
TEST(RelativePaths, PathsModified) {
|
|
|
|
MediaInfo media_info;
|
|
|
|
|
|
|
|
media_info.set_media_file_name(kMediaFile);
|
|
|
|
media_info.set_init_segment_name(kInitSegment);
|
|
|
|
media_info.set_segment_template(kSegmentTemplate);
|
2017-09-08 17:52:48 +00:00
|
|
|
MpdBuilder::MakePathsRelativeToMpd(kPathModifiedMpd, &media_info);
|
2014-12-16 01:32:19 +00:00
|
|
|
EXPECT_EQ(kMediaFileBase, media_info.media_file_name());
|
|
|
|
EXPECT_EQ(kInitSegmentBase, media_info.init_segment_name());
|
|
|
|
EXPECT_EQ(kSegmentTemplateBase, media_info.segment_template());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(RelativePaths, PathsNotModified) {
|
|
|
|
MediaInfo media_info;
|
|
|
|
|
|
|
|
media_info.set_media_file_name(kMediaFile);
|
|
|
|
media_info.set_init_segment_name(kInitSegment);
|
|
|
|
media_info.set_segment_template(kSegmentTemplate);
|
2017-09-08 17:52:48 +00:00
|
|
|
MpdBuilder::MakePathsRelativeToMpd(kPathNotModifiedMpd, &media_info);
|
2014-12-16 01:32:19 +00:00
|
|
|
EXPECT_EQ(kMediaFile, media_info.media_file_name());
|
|
|
|
EXPECT_EQ(kInitSegment, media_info.init_segment_name());
|
|
|
|
EXPECT_EQ(kSegmentTemplate, media_info.segment_template());
|
|
|
|
}
|
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|