Move File Copy Out Of StreamInfoToTextMediaInfo
Moved the file copy out of StreamInfoToTextMediaInfo as the file copy is only needed by the MPD output but the Media Info is needed by MPD output and media info dump. Bug: 36138902 Change-Id: Id233f2041b3e72345b8f709791c6b6070484222f
This commit is contained in:
parent
9ecee46658
commit
c520d85b96
|
@ -168,8 +168,9 @@ Status ValidateStreamDescriptor(bool dump_stream_info,
|
|||
return Status(error::INVALID_ARGUMENT, "Unsupported output format.");
|
||||
} else if (output_format == MediaContainerName::CONTAINER_MPEG2TS) {
|
||||
if (stream.segment_template.empty()) {
|
||||
return Status(error::INVALID_ARGUMENT,
|
||||
"Please specify segment_template. Single file TS output is "
|
||||
return Status(
|
||||
error::INVALID_ARGUMENT,
|
||||
"Please specify 'segment_template'. Single file TS output is "
|
||||
"not supported.");
|
||||
}
|
||||
|
||||
|
@ -181,6 +182,16 @@ Status ValidateStreamDescriptor(bool dump_stream_info,
|
|||
"All TS segments must be self-initializing. Stream "
|
||||
"descriptors 'output' or 'init_segment' are not allowed.");
|
||||
}
|
||||
} else if (output_format == CONTAINER_WEBVTT) {
|
||||
// There is no need for an init segment when outputting to WebVTT because
|
||||
// there is no initialization data.
|
||||
if (stream.segment_template.length() && stream.output.length()) {
|
||||
return Status(
|
||||
error::INVALID_ARGUMENT,
|
||||
"Segmented WebVTT output cannot have an init segment. Do not specify "
|
||||
"stream descriptors 'output' or 'init_segment' when using "
|
||||
"'segment_template' with WebVtt.");
|
||||
}
|
||||
} else {
|
||||
// For any other format, if there is a segment template, there must be an
|
||||
// init segment provided.
|
||||
|
@ -274,13 +285,6 @@ bool StreamInfoToTextMediaInfo(const StreamDescriptor& stream_descriptor,
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!File::Copy(stream_descriptor.input.c_str(),
|
||||
stream_descriptor.output.c_str())) {
|
||||
LOG(ERROR) << "Failed to copy the input file (" << stream_descriptor.input
|
||||
<< ") to output file (" << stream_descriptor.output << ").";
|
||||
return false;
|
||||
}
|
||||
|
||||
text_media_info->set_media_file_name(stream_descriptor.output);
|
||||
text_media_info->set_container_type(MediaInfo::CONTAINER_TEXT);
|
||||
|
||||
|
@ -533,6 +537,25 @@ Status CreateTextJobs(
|
|||
"Cannot create text output for MPD with segment output.");
|
||||
}
|
||||
|
||||
// If we are outputting to HLS, then create the HLS test pipeline that
|
||||
// will create segmented text output.
|
||||
if (hls_listener) {
|
||||
Status status = CreateHlsTextJob(stream, packaging_params,
|
||||
std::move(hls_listener), job_manager);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
if (!stream.output.empty()) {
|
||||
if (!File::Copy(stream.input.c_str(), stream.output.c_str())) {
|
||||
std::string error;
|
||||
base::StringAppendF(
|
||||
&error, "Failed to copy the input file (%s) to output file (%s).",
|
||||
stream.input.c_str(), stream.output.c_str());
|
||||
return Status(error::FILE_FAILURE, error);
|
||||
}
|
||||
|
||||
MediaInfo text_media_info;
|
||||
if (!StreamInfoToTextMediaInfo(stream, &text_media_info)) {
|
||||
return Status(error::INVALID_ARGUMENT,
|
||||
|
@ -551,22 +574,13 @@ Status CreateTextJobs(
|
|||
}
|
||||
}
|
||||
|
||||
// If we are outputting to HLS, then create the HLS test pipeline that
|
||||
// will create segmented text output.
|
||||
if (hls_listener) {
|
||||
Status status = CreateHlsTextJob(stream, packaging_params,
|
||||
std::move(hls_listener), job_manager);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
if (packaging_params.output_media_info) {
|
||||
VodMediaInfoDumpMuxerListener::WriteMediaInfoToFile(
|
||||
text_media_info, stream.output + kMediaInfoSuffix);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Status::OK;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue