Merge remote-tracking branch 'github/master' into HEAD

This commit is contained in:
Widevine Buildbot 2020-02-10 07:11:40 +00:00
commit 888be2d1ee
11 changed files with 48 additions and 5 deletions

View File

@ -15,6 +15,7 @@
Anders Hasselqvist <anders.hasselqvist@gmail.com> Anders Hasselqvist <anders.hasselqvist@gmail.com>
Chun-da Chen <capitalm.c@gmail.com> Chun-da Chen <capitalm.c@gmail.com>
Daniel Cantarín <canta@canta.com.ar>
Google Inc. <*@google.com> Google Inc. <*@google.com>
Leandro Moreira <leandro.ribeiro.moreira@gmail.com> Leandro Moreira <leandro.ribeiro.moreira@gmail.com>
Leo Law <leoltlaw.gh@gmail.com> Leo Law <leoltlaw.gh@gmail.com>

View File

@ -25,6 +25,7 @@
Anders Hasselqvist <anders.hasselqvist@gmail.com> Anders Hasselqvist <anders.hasselqvist@gmail.com>
Bei Li <beil@google.com> Bei Li <beil@google.com>
Chun-da Chen <capitalm.c@gmail.com> Chun-da Chen <capitalm.c@gmail.com>
Daniel Cantarín <canta@canta.com.ar>
David Cavar <pal3thorn@gmail.com> David Cavar <pal3thorn@gmail.com>
Gabe Kopley <gabe@philo.com> Gabe Kopley <gabe@philo.com>
Haoming Chen <hmchen@google.com> Haoming Chen <hmchen@google.com>

View File

@ -51,3 +51,27 @@ HLS options
Same as above, but this applies to text tracks only, and overrides the Same as above, but this applies to text tracks only, and overrides the
default language for text tracks. default language for text tracks.
--hls_media_sequence_number <unsigned_number>
HLS uses the EXT-X-MEDIA-SEQUENCE tag at the start of a live playlist in
order to specify the first segment sequence number. This is because any
live playlist have a limited number of segments, and they also keep
updating with new segments while removing old ones. When a player refreshes
the playlist, this information is important for keeping track of segments
positions.
When the packager starts, it naturally starts this count from zero. However,
there are many situations where the packager may be restarted, without this
meaning starting this value from zero (but continuing a previous sequence).
The most common situations are problems in the encoder feeding the packager.
With those cases in mind, this parameter allows to set the initial
EXT-X-MEDIA-SEQUENCE value. This way, it's possible to continue the sequence
number from previous packager run.
For more information about the reasoning of this, please see issue
`#691 <https://github.com/google/shaka-packager/issues/691>`_.
The EXT-X-MEDIA-SEQUENCE documentation can be read here:
https://tools.ietf.org/html/rfc8216#section-4.3.3.2.

View File

@ -24,3 +24,9 @@ DEFINE_string(hls_playlist_type,
"VOD, EVENT, or LIVE. This defines the EXT-X-PLAYLIST-TYPE in " "VOD, EVENT, or LIVE. This defines the EXT-X-PLAYLIST-TYPE in "
"the HLS specification. For hls_playlist_type of LIVE, " "the HLS specification. For hls_playlist_type of LIVE, "
"EXT-X-PLAYLIST-TYPE tag is omitted."); "EXT-X-PLAYLIST-TYPE tag is omitted.");
DEFINE_int32(hls_media_sequence_number,
0,
"Number. This HLS-only parameter defines the initial "
"EXT-X-MEDIA-SEQUENCE value, which allows continuous media "
"sequence across packager restarts. See #691 for more "
"information about the reasoning of this and its use cases.");

View File

@ -13,5 +13,6 @@ DECLARE_string(hls_master_playlist_output);
DECLARE_string(hls_base_url); DECLARE_string(hls_base_url);
DECLARE_string(hls_key_uri); DECLARE_string(hls_key_uri);
DECLARE_string(hls_playlist_type); DECLARE_string(hls_playlist_type);
DECLARE_int32(hls_media_sequence_number);
#endif // PACKAGER_APP_HLS_FLAGS_H_ #endif // PACKAGER_APP_HLS_FLAGS_H_

View File

@ -470,6 +470,7 @@ base::Optional<PackagingParams> GetPackagingParams() {
FLAGS_preserved_segments_outside_live_window; FLAGS_preserved_segments_outside_live_window;
hls_params.default_language = FLAGS_default_language; hls_params.default_language = FLAGS_default_language;
hls_params.default_text_language = FLAGS_default_text_language; hls_params.default_text_language = FLAGS_default_text_language;
hls_params.media_sequence_number = FLAGS_hls_media_sequence_number;
TestParams& test_params = packaging_params.test_params; TestParams& test_params = packaging_params.test_params;
test_params.dump_stream_info = FLAGS_dump_stream_info; test_params.dump_stream_info = FLAGS_dump_stream_info;

View File

@ -106,7 +106,7 @@ std::string CreatePlaylistHeader(
uint32_t target_duration, uint32_t target_duration,
HlsPlaylistType type, HlsPlaylistType type,
MediaPlaylist::MediaPlaylistStreamType stream_type, MediaPlaylist::MediaPlaylistStreamType stream_type,
int media_sequence_number, uint32_t media_sequence_number,
int discontinuity_sequence_number) { int discontinuity_sequence_number) {
const std::string version = GetPackagerVersion(); const std::string version = GetPackagerVersion();
std::string version_line; std::string version_line;
@ -343,7 +343,12 @@ MediaPlaylist::MediaPlaylist(const HlsParams& hls_params,
: hls_params_(hls_params), : hls_params_(hls_params),
file_name_(file_name), file_name_(file_name),
name_(name), name_(name),
group_id_(group_id) {} group_id_(group_id),
media_sequence_number_(hls_params_.media_sequence_number) {
// When there's a forced media_sequence_number, start with discontinuity
if (media_sequence_number_ > 0)
entries_.emplace_back(new DiscontinuityEntry());
}
MediaPlaylist::~MediaPlaylist() {} MediaPlaylist::~MediaPlaylist() {}
@ -390,6 +395,7 @@ bool MediaPlaylist::SetMediaInfo(const MediaInfo& media_info) {
characteristics_ = characteristics_ =
std::vector<std::string>(media_info_.hls_characteristics().begin(), std::vector<std::string>(media_info_.hls_characteristics().begin(),
media_info_.hls_characteristics().end()); media_info_.hls_characteristics().end());
return true; return true;
} }

View File

@ -236,7 +236,7 @@ class MediaPlaylist {
std::string codec_; std::string codec_;
std::string language_; std::string language_;
std::vector<std::string> characteristics_; std::vector<std::string> characteristics_;
int media_sequence_number_ = 0; uint32_t media_sequence_number_ = 0;
bool inserted_discontinuity_tag_ = false; bool inserted_discontinuity_tag_ = false;
int discontinuity_sequence_number_ = 0; int discontinuity_sequence_number_ = 0;

View File

@ -56,6 +56,9 @@ struct HlsParams {
/// be populated from segment duration specified in ChunkingParams if not /// be populated from segment duration specified in ChunkingParams if not
/// specified. /// specified.
double target_segment_duration = 0; double target_segment_duration = 0;
/// Custom EXT-X-MEDIA-SEQUENCE value to allow continuous media playback
/// across packager restarts. See #691 for details.
uint32_t media_sequence_number = 0;
}; };
} // namespace shaka } // namespace shaka

View File

@ -125,7 +125,7 @@ void TsSegmenter::SetTsWriterFileOpenedForTesting(bool value) {
ts_writer_file_opened_ = value; ts_writer_file_opened_ = value;
} }
Status TsSegmenter::OpenNewSegmentIfClosed(uint32_t next_pts) { Status TsSegmenter::OpenNewSegmentIfClosed(int64_t next_pts) {
if (ts_writer_file_opened_) if (ts_writer_file_opened_)
return Status::OK; return Status::OK;
const std::string segment_name = const std::string segment_name =

View File

@ -71,7 +71,7 @@ class TsSegmenter {
void SetTsWriterFileOpenedForTesting(bool value); void SetTsWriterFileOpenedForTesting(bool value);
private: private:
Status OpenNewSegmentIfClosed(uint32_t next_pts); Status OpenNewSegmentIfClosed(int64_t next_pts);
// Writes PES packets (carried in TsPackets) to a file. If a file is not open, // Writes PES packets (carried in TsPackets) to a file. If a file is not open,
// it will open one. This will not close the file. // it will open one. This will not close the file.