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,9 +168,10 @@ Status ValidateStreamDescriptor(bool dump_stream_info,
|
||||||
return Status(error::INVALID_ARGUMENT, "Unsupported output format.");
|
return Status(error::INVALID_ARGUMENT, "Unsupported output format.");
|
||||||
} else if (output_format == MediaContainerName::CONTAINER_MPEG2TS) {
|
} else if (output_format == MediaContainerName::CONTAINER_MPEG2TS) {
|
||||||
if (stream.segment_template.empty()) {
|
if (stream.segment_template.empty()) {
|
||||||
return Status(error::INVALID_ARGUMENT,
|
return Status(
|
||||||
"Please specify segment_template. Single file TS output is "
|
error::INVALID_ARGUMENT,
|
||||||
"not supported.");
|
"Please specify 'segment_template'. Single file TS output is "
|
||||||
|
"not supported.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Right now the init segment is saved in |output| for multi-segment
|
// Right now the init segment is saved in |output| for multi-segment
|
||||||
|
@ -181,6 +182,16 @@ Status ValidateStreamDescriptor(bool dump_stream_info,
|
||||||
"All TS segments must be self-initializing. Stream "
|
"All TS segments must be self-initializing. Stream "
|
||||||
"descriptors 'output' or 'init_segment' are not allowed.");
|
"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 {
|
} else {
|
||||||
// For any other format, if there is a segment template, there must be an
|
// For any other format, if there is a segment template, there must be an
|
||||||
// init segment provided.
|
// init segment provided.
|
||||||
|
@ -274,13 +285,6 @@ bool StreamInfoToTextMediaInfo(const StreamDescriptor& stream_descriptor,
|
||||||
return false;
|
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_media_file_name(stream_descriptor.output);
|
||||||
text_media_info->set_container_type(MediaInfo::CONTAINER_TEXT);
|
text_media_info->set_container_type(MediaInfo::CONTAINER_TEXT);
|
||||||
|
|
||||||
|
@ -533,24 +537,6 @@ Status CreateTextJobs(
|
||||||
"Cannot create text output for MPD with segment output.");
|
"Cannot create text output for MPD with segment output.");
|
||||||
}
|
}
|
||||||
|
|
||||||
MediaInfo text_media_info;
|
|
||||||
if (!StreamInfoToTextMediaInfo(stream, &text_media_info)) {
|
|
||||||
return Status(error::INVALID_ARGUMENT,
|
|
||||||
"Could not create media info for stream.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we are outputting to MPD, just add the input to the outputted
|
|
||||||
// manifest.
|
|
||||||
if (mpd_notifier) {
|
|
||||||
uint32_t unused;
|
|
||||||
if (mpd_notifier->NotifyNewContainer(text_media_info, &unused)) {
|
|
||||||
mpd_notifier->Flush();
|
|
||||||
} else {
|
|
||||||
return Status(error::PARSER_FAILURE,
|
|
||||||
"Failed to process text file " + stream.input);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we are outputting to HLS, then create the HLS test pipeline that
|
// If we are outputting to HLS, then create the HLS test pipeline that
|
||||||
// will create segmented text output.
|
// will create segmented text output.
|
||||||
if (hls_listener) {
|
if (hls_listener) {
|
||||||
|
@ -561,9 +547,37 @@ Status CreateTextJobs(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packaging_params.output_media_info) {
|
if (!stream.output.empty()) {
|
||||||
VodMediaInfoDumpMuxerListener::WriteMediaInfoToFile(
|
if (!File::Copy(stream.input.c_str(), stream.output.c_str())) {
|
||||||
text_media_info, stream.output + kMediaInfoSuffix);
|
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,
|
||||||
|
"Could not create media info for stream.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we are outputting to MPD, just add the input to the outputted
|
||||||
|
// manifest.
|
||||||
|
if (mpd_notifier) {
|
||||||
|
uint32_t unused;
|
||||||
|
if (mpd_notifier->NotifyNewContainer(text_media_info, &unused)) {
|
||||||
|
mpd_notifier->Flush();
|
||||||
|
} else {
|
||||||
|
return Status(error::PARSER_FAILURE,
|
||||||
|
"Failed to process text file " + stream.input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (packaging_params.output_media_info) {
|
||||||
|
VodMediaInfoDumpMuxerListener::WriteMediaInfoToFile(
|
||||||
|
text_media_info, stream.output + kMediaInfoSuffix);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue