Return an error when seeing duplicated outputs
Fixes #497. Change-Id: Ic3f5352b6774fbd488e6d688df4c8a5053732549
This commit is contained in:
parent
4b97a6d8a2
commit
c5fa32f0eb
|
@ -279,6 +279,8 @@ Status ValidateParams(const PackagingParams& packaging_params,
|
||||||
// generates multiple segments specified using segment template.
|
// generates multiple segments specified using segment template.
|
||||||
const bool on_demand_dash_profile =
|
const bool on_demand_dash_profile =
|
||||||
stream_descriptors.begin()->segment_template.empty();
|
stream_descriptors.begin()->segment_template.empty();
|
||||||
|
std::set<std::string> outputs;
|
||||||
|
std::set<std::string> segment_templates;
|
||||||
for (const auto& descriptor : stream_descriptors) {
|
for (const auto& descriptor : stream_descriptors) {
|
||||||
if (on_demand_dash_profile != descriptor.segment_template.empty()) {
|
if (on_demand_dash_profile != descriptor.segment_template.empty()) {
|
||||||
return Status(error::INVALID_ARGUMENT,
|
return Status(error::INVALID_ARGUMENT,
|
||||||
|
@ -304,6 +306,27 @@ Status ValidateParams(const PackagingParams& packaging_params,
|
||||||
// Skip the check for DASH as DASH defaults to 'dynamic' MPD when segment
|
// Skip the check for DASH as DASH defaults to 'dynamic' MPD when segment
|
||||||
// template is provided.
|
// template is provided.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!descriptor.output.empty()) {
|
||||||
|
if (outputs.find(descriptor.output) != outputs.end()) {
|
||||||
|
return Status(
|
||||||
|
error::INVALID_ARGUMENT,
|
||||||
|
"Seeing duplicated outputs '" + descriptor.output +
|
||||||
|
"' in stream descriptors. Every output must be unique.");
|
||||||
|
}
|
||||||
|
outputs.insert(descriptor.output);
|
||||||
|
}
|
||||||
|
if (!descriptor.segment_template.empty()) {
|
||||||
|
if (segment_templates.find(descriptor.segment_template) !=
|
||||||
|
segment_templates.end()) {
|
||||||
|
return Status(error::INVALID_ARGUMENT,
|
||||||
|
"Seeing duplicated segment templates '" +
|
||||||
|
descriptor.segment_template +
|
||||||
|
"' in stream descriptors. Every segment template "
|
||||||
|
"must be unique.");
|
||||||
|
}
|
||||||
|
segment_templates.insert(descriptor.segment_template);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packaging_params.output_media_info && !on_demand_dash_profile) {
|
if (packaging_params.output_media_info && !on_demand_dash_profile) {
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "packager/packager.h"
|
#include "packager/packager.h"
|
||||||
|
|
||||||
using testing::_;
|
using testing::_;
|
||||||
|
using testing::HasSubstr;
|
||||||
using testing::Invoke;
|
using testing::Invoke;
|
||||||
using testing::MockFunction;
|
using testing::MockFunction;
|
||||||
using testing::Return;
|
using testing::Return;
|
||||||
|
@ -25,6 +26,7 @@ const char kTestFile[] = "packager/media/test/data/bear-640x360.mp4";
|
||||||
const char kOutputVideo[] = "output_video.mp4";
|
const char kOutputVideo[] = "output_video.mp4";
|
||||||
const char kOutputVideoTemplate[] = "output_video_$Number$.m4s";
|
const char kOutputVideoTemplate[] = "output_video_$Number$.m4s";
|
||||||
const char kOutputAudio[] = "output_audio.mp4";
|
const char kOutputAudio[] = "output_audio.mp4";
|
||||||
|
const char kOutputAudioTemplate[] = "output_audio_$Number$.m4s";
|
||||||
const char kOutputMpd[] = "output.mpd";
|
const char kOutputMpd[] = "output.mpd";
|
||||||
|
|
||||||
const double kSegmentDurationInSeconds = 1.0;
|
const double kSegmentDurationInSeconds = 1.0;
|
||||||
|
@ -138,6 +140,51 @@ TEST_F(PackagerTest, MixingSegmentTemplateAndSingleSegment) {
|
||||||
ASSERT_EQ(error::INVALID_ARGUMENT, status.error_code());
|
ASSERT_EQ(error::INVALID_ARGUMENT, status.error_code());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(PackagerTest, DuplicatedOutputs) {
|
||||||
|
std::vector<StreamDescriptor> stream_descriptors;
|
||||||
|
StreamDescriptor stream_descriptor;
|
||||||
|
|
||||||
|
stream_descriptor.input = kTestFile;
|
||||||
|
stream_descriptor.stream_selector = "video";
|
||||||
|
stream_descriptor.output = GetFullPath(kOutputVideo);
|
||||||
|
stream_descriptor.segment_template = GetFullPath(kOutputVideoTemplate);
|
||||||
|
stream_descriptors.push_back(stream_descriptor);
|
||||||
|
|
||||||
|
stream_descriptor.input = kTestFile;
|
||||||
|
stream_descriptor.stream_selector = "audio";
|
||||||
|
stream_descriptor.output = GetFullPath(kOutputVideo);
|
||||||
|
stream_descriptor.segment_template = GetFullPath(kOutputAudioTemplate);
|
||||||
|
stream_descriptors.push_back(stream_descriptor);
|
||||||
|
|
||||||
|
Packager packager;
|
||||||
|
auto status = packager.Initialize(SetupPackagingParams(), stream_descriptors);
|
||||||
|
ASSERT_EQ(error::INVALID_ARGUMENT, status.error_code());
|
||||||
|
EXPECT_THAT(status.error_message(), HasSubstr("duplicated outputs"));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(PackagerTest, DuplicatedSegmentTemplates) {
|
||||||
|
std::vector<StreamDescriptor> stream_descriptors;
|
||||||
|
StreamDescriptor stream_descriptor;
|
||||||
|
|
||||||
|
stream_descriptor.input = kTestFile;
|
||||||
|
stream_descriptor.stream_selector = "video";
|
||||||
|
stream_descriptor.output = GetFullPath(kOutputVideo);
|
||||||
|
stream_descriptor.segment_template = GetFullPath(kOutputVideoTemplate);
|
||||||
|
stream_descriptors.push_back(stream_descriptor);
|
||||||
|
|
||||||
|
stream_descriptor.input = kTestFile;
|
||||||
|
stream_descriptor.stream_selector = "audio";
|
||||||
|
stream_descriptor.output = GetFullPath(kOutputAudio);
|
||||||
|
stream_descriptor.segment_template = GetFullPath(kOutputVideoTemplate);
|
||||||
|
stream_descriptors.push_back(stream_descriptor);
|
||||||
|
|
||||||
|
Packager packager;
|
||||||
|
auto status = packager.Initialize(SetupPackagingParams(), stream_descriptors);
|
||||||
|
ASSERT_EQ(error::INVALID_ARGUMENT, status.error_code());
|
||||||
|
EXPECT_THAT(status.error_message(),
|
||||||
|
HasSubstr("duplicated segment templates"));
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(PackagerTest, SegmentAlignedAndSubsegmentNotAligned) {
|
TEST_F(PackagerTest, SegmentAlignedAndSubsegmentNotAligned) {
|
||||||
auto packaging_params = SetupPackagingParams();
|
auto packaging_params = SetupPackagingParams();
|
||||||
packaging_params.chunking_params.segment_sap_aligned = true;
|
packaging_params.chunking_params.segment_sap_aligned = true;
|
||||||
|
|
Loading…
Reference in New Issue