Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifications for LIVE webvtt: option for explicit input format, and a less strict webvtt header check. #1027

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
79a3d74
Added ability to set by command line argument an arbitrary HLS media …
Dec 31, 2019
bb0a329
fix: wrong condition placement.
Dec 31, 2019
97950bb
Changed help/doc strings as for @kqyang comments.
Jan 24, 2020
3079acf
Removed an unnecessary line, as stated [here](https://github.com/goog…
Jan 25, 2020
83dfc23
Sent variable to constructor, as per [code review comment](https://gi…
Jan 25, 2020
9ad7ccc
Several minor tweaks as for @kqyang comments:
Jan 31, 2020
adeec48
Minor doc tweaks, as per review indications.
Jan 31, 2020
bbae84c
Added missing punctuation
Canta Jan 31, 2020
5ca890e
Fix for #701.
Jan 31, 2020
ce03957
Merge pull request #1 from google/master
Canta Jan 31, 2020
06547fc
Sorted AUTHORS and CONTRIBUTORS files.
Jan 31, 2020
38a7a75
Merge remote-tracking branch 'upstream/master'
Mar 5, 2021
9a65e74
Applying camel case to imageType attribute in TTML generation. Fixes …
Mar 5, 2021
913876c
Change in MPEG object type handling, as stated [here](https://github.…
Mar 17, 2021
68f62f1
Merge pull request #3 from google/master
Canta May 4, 2021
7ad4458
Several changes to HttpFile implementation, as discussed in https://g…
May 4, 2021
b32a46a
Merge pull request #4 from google/master
Canta May 6, 2021
1e11bfb
Changed default HTTP UserAgent to "ShakaPackager/<version>". See http…
May 6, 2021
e253261
Changed useragent evaluation to constructor. #939
May 7, 2021
598ea70
Added http_file to atomic writes warning check. Should fix #945
May 20, 2021
6e2e094
Merge pull request #5 from google/master
Canta May 20, 2021
a5127ac
Added check for kHttpsFilePrefix when ignoring atomic write warnings.…
May 20, 2021
3c808f5
Merge pull request #6 from google/master
Canta Jun 1, 2021
3661dcf
Fix for warning spam in file class when no "delete" method is declare…
Jun 1, 2021
9fd7681
Merge pull request #7 from google/master
Canta Jul 21, 2021
b97e098
Merge pull request #8 from google/master
Canta Sep 1, 2021
1e5c4ec
Merge branch 'google:master' into master
Canta Feb 3, 2022
a66f1e5
Added option for excplicitly set input format as stream selector para…
Feb 3, 2022
3783719
Lint for chromium style.
Feb 4, 2022
5d760ff
Lint for chromium style.
Feb 4, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packager/app/stream_descriptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ enum FieldType {
kDashRolesField,
kDashOnlyField,
kHlsOnlyField,
kInputFormatField,
};

struct FieldNameToTypeMapping {
Expand Down Expand Up @@ -83,6 +84,7 @@ const FieldNameToTypeMapping kFieldNameTypeMappings[] = {
{"role", kDashRolesField},
{"dash_only", kDashOnlyField},
{"hls_only", kHlsOnlyField},
{"input_format", kInputFormatField},
};

FieldType GetFieldType(const std::string& field_name) {
Expand Down Expand Up @@ -247,6 +249,10 @@ base::Optional<StreamDescriptor> ParseStreamDescriptor(
}
descriptor.hls_only = hls_only_value > 0;
break;
case kInputFormatField: {
descriptor.input_format = iter->second;
break;
}
default:
LOG(ERROR) << "Unknown field in stream descriptor (\"" << iter->first
<< "\").";
Expand Down
24 changes: 14 additions & 10 deletions packager/media/demuxer/demuxer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,22 @@ Status Demuxer::InitializeParser() {
"Cannot open file for reading " + file_name_);
}

// Read enough bytes before detecting the container.
int64_t bytes_read = 0;
while (static_cast<size_t>(bytes_read) < kInitBufSize) {
int64_t read_result =
media_file_->Read(buffer_.get() + bytes_read, kInitBufSize);
if (read_result < 0)
return Status(error::FILE_FAILURE, "Cannot read file " + file_name_);
if (read_result == 0)
break;
bytes_read += read_result;
if (input_format_.empty()) {
// Read enough bytes before detecting the container.
while (static_cast<size_t>(bytes_read) < kInitBufSize) {
int64_t read_result =
media_file_->Read(buffer_.get() + bytes_read, kInitBufSize);
if (read_result < 0)
return Status(error::FILE_FAILURE, "Cannot read file " + file_name_);
if (read_result == 0)
break;
bytes_read += read_result;
}
container_name_ = DetermineContainer(buffer_.get(), bytes_read);
} else {
container_name_ = DetermineContainerFromFormatName(input_format_);
}
container_name_ = DetermineContainer(buffer_.get(), bytes_read);

// Initialize media parser.
switch (container_name_) {
Expand Down
6 changes: 6 additions & 0 deletions packager/media/demuxer/demuxer.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ class Demuxer : public OriginHandler {
dump_stream_info_ = dump_stream_info;
}

void set_input_format(std::string input_format) {
input_format_ = input_format;
}

protected:
/// @name MediaHandler implementation overrides.
/// @{
Expand Down Expand Up @@ -148,6 +152,8 @@ class Demuxer : public OriginHandler {
// Whether to dump stream info when it is received.
bool dump_stream_info_ = false;
Status init_event_status_;
// Explicitly defined input format, for avoiding autodetection.
std::string input_format_;
};

} // namespace media
Expand Down
2 changes: 2 additions & 0 deletions packager/media/event/muxer_listener_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class MuxerListenerFactory {
std::vector<std::string> dash_accessiblities;
std::vector<std::string> dash_roles;
bool dash_only = false;

std::string input_format;
};

/// Create a new muxer listener.
Expand Down
10 changes: 4 additions & 6 deletions packager/media/formats/webvtt/webvtt_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,12 @@ bool WebVttParser::Parse() {
// Check the header. It is possible for a 0xFEFF BOM to come before the
// header text.
if (block.size() != 1) {
LOG(ERROR) << "Failed to read WEBVTT header - "
<< "block size should be 1 but was " << block.size() << ".";
return false;
LOG(WARNING) << "Failed to read WEBVTT header - "
<< "block size should be 1 but was " << block.size() << ".";
}
if (block[0] != "WEBVTT" && block[0] != "\xEF\xBB\xBFWEBVTT") {
LOG(ERROR) << "Failed to read WEBVTT header - should be WEBVTT but was "
<< block[0];
return false;
LOG(WARNING) << "Failed to read WEBVTT header - should be WEBVTT but was "
<< block[0];
}
initialized_ = true;
}
Expand Down
3 changes: 3 additions & 0 deletions packager/packager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ MuxerListenerFactory::StreamData ToMuxerListenerData(
data.dash_accessiblities = stream.dash_accessiblities;
data.dash_roles = stream.dash_roles;
data.dash_only = stream.dash_only;

data.input_format = stream.input_format;
return data;
};

Expand Down Expand Up @@ -471,6 +473,7 @@ Status CreateDemuxer(const StreamDescriptor& stream,
std::shared_ptr<Demuxer>* new_demuxer) {
std::shared_ptr<Demuxer> demuxer = std::make_shared<Demuxer>(stream.input);
demuxer->set_dump_stream_info(packaging_params.test_params.dump_stream_info);
demuxer->set_input_format(stream.input_format);

if (packaging_params.decryption_params.key_provider != KeyProvider::kNone) {
std::unique_ptr<KeySource> decryption_key_source(
Expand Down
5 changes: 5 additions & 0 deletions packager/packager.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ struct StreamDescriptor {
bool dash_only = false;
/// Set to true to indicate that the stream is for hls only.
bool hls_only = false;

/// Optional value which specifies input container format.
/// Useful for live streaming situations, like auto-detecting webvtt without
/// its initial header.
std::string input_format;
};

class SHAKA_EXPORT Packager {
Expand Down