Parse ad_cues flag.
Change-Id: I4f5897dcde20e73a01468b80a04d3f3142bc5e42
This commit is contained in:
parent
622ff64595
commit
dac0328b47
|
@ -7,6 +7,7 @@
|
||||||
#include <gflags/gflags.h>
|
#include <gflags/gflags.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "packager/app/ad_cue_generator_flags.h"
|
||||||
#include "packager/app/crypto_flags.h"
|
#include "packager/app/crypto_flags.h"
|
||||||
#include "packager/app/hls_flags.h"
|
#include "packager/app/hls_flags.h"
|
||||||
#include "packager/app/mpd_flags.h"
|
#include "packager/app/mpd_flags.h"
|
||||||
|
@ -213,9 +214,55 @@ bool GetRawKeyParams(RawKeyParams* raw_key) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ParseAdCues(const std::string& ad_cues, std::vector<Cuepoint>* cuepoints) {
|
||||||
|
// Track if optional field is supplied consistently across all cue points.
|
||||||
|
size_t duration_count = 0;
|
||||||
|
|
||||||
|
for (const std::string& ad_cue : base::SplitString(
|
||||||
|
ad_cues, ";", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) {
|
||||||
|
Cuepoint cuepoint;
|
||||||
|
auto split_ad_cue = base::SplitString(ad_cue, ",", base::TRIM_WHITESPACE,
|
||||||
|
base::SPLIT_WANT_NONEMPTY);
|
||||||
|
if (split_ad_cue.size() > 2) {
|
||||||
|
LOG(ERROR) << "Failed to parse --ad_cues " << ad_cues
|
||||||
|
<< " Each ad cue must contain no more than 2 components.";
|
||||||
|
}
|
||||||
|
if (!base::StringToDouble(split_ad_cue.front(),
|
||||||
|
&cuepoint.start_time_in_seconds)) {
|
||||||
|
LOG(ERROR) << "Failed to parse --ad_cues " << ad_cues
|
||||||
|
<< " Start time component must be of type double.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (split_ad_cue.size() > 1) {
|
||||||
|
duration_count++;
|
||||||
|
if (!base::StringToDouble(split_ad_cue[1],
|
||||||
|
&cuepoint.duration_in_seconds)) {
|
||||||
|
LOG(ERROR) << "Failed to parse --ad_cues " << ad_cues
|
||||||
|
<< " Duration component must be of type double.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cuepoints->push_back(cuepoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (duration_count > 0 && duration_count != cuepoints->size()) {
|
||||||
|
LOG(ERROR) << "Failed to parse --ad_cues " << ad_cues
|
||||||
|
<< " Duration component is optional. However if it is supplied,"
|
||||||
|
<< " it must be supplied consistently across all cuepoints.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
base::Optional<PackagingParams> GetPackagingParams() {
|
base::Optional<PackagingParams> GetPackagingParams() {
|
||||||
PackagingParams packaging_params;
|
PackagingParams packaging_params;
|
||||||
|
|
||||||
|
AdCueGeneratorParams& ad_cue_generator_params =
|
||||||
|
packaging_params.ad_cue_generator_params;
|
||||||
|
if (!ParseAdCues(FLAGS_ad_cues, &ad_cue_generator_params.cue_points)) {
|
||||||
|
return base::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
ChunkingParams& chunking_params = packaging_params.chunking_params;
|
ChunkingParams& chunking_params = packaging_params.chunking_params;
|
||||||
chunking_params.segment_duration_in_seconds = FLAGS_segment_duration;
|
chunking_params.segment_duration_in_seconds = FLAGS_segment_duration;
|
||||||
chunking_params.subsegment_duration_in_seconds = FLAGS_fragment_duration;
|
chunking_params.subsegment_duration_in_seconds = FLAGS_fragment_duration;
|
||||||
|
|
|
@ -11,8 +11,9 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "packager/hls/public/hls_params.h"
|
|
||||||
#include "packager/file/public/buffer_callback_params.h"
|
#include "packager/file/public/buffer_callback_params.h"
|
||||||
|
#include "packager/hls/public/hls_params.h"
|
||||||
|
#include "packager/media/public/ad_cue_generator_params.h"
|
||||||
#include "packager/media/public/chunking_params.h"
|
#include "packager/media/public/chunking_params.h"
|
||||||
#include "packager/media/public/crypto_params.h"
|
#include "packager/media/public/crypto_params.h"
|
||||||
#include "packager/media/public/mp4_output_params.h"
|
#include "packager/media/public/mp4_output_params.h"
|
||||||
|
@ -42,6 +43,9 @@ struct PackagingParams {
|
||||||
/// Chunking (segmentation) related parameters.
|
/// Chunking (segmentation) related parameters.
|
||||||
ChunkingParams chunking_params;
|
ChunkingParams chunking_params;
|
||||||
|
|
||||||
|
/// Out of band cuepoint parameters.
|
||||||
|
AdCueGeneratorParams ad_cue_generator_params;
|
||||||
|
|
||||||
/// Create a human readable format of MediaInfo. The output file name will be
|
/// Create a human readable format of MediaInfo. The output file name will be
|
||||||
/// the name specified by output flag, suffixed with `.media_info`.
|
/// the name specified by output flag, suffixed with `.media_info`.
|
||||||
bool output_media_info = false;
|
bool output_media_info = false;
|
||||||
|
|
Loading…
Reference in New Issue