Commit Graph

90 Commits

Author SHA1 Message Date
KongQun Yang 89611a526b [HLS] Support audio only master playlist
Generate an audio only master playlist if there are no videos and
subtitles.

We do not support mixing audio only EXT-X-STREAM-INF with video
EXT-X-STREAM-INF right now.

Fixes #461.

Change-Id: I999b335ad7abbe183ffcb0f5d471948977c2772f
2018-12-13 23:52:35 +00:00
KongQun Yang 4b97a6d8a2 Add support for --default_text_language
It allows users to override the default language for text tracks.

If not specified, --default_language applies to both audio and text
tracks.

Issue #430.

Change-Id: I86a9baba2072be27b6661fa7b65a8bc8b6adb3cc
2018-11-26 13:42:58 -08:00
KongQun Yang 273ab09f05 Support HLS characteristics
Add hls_characteristics stream descriptor, which is a colon or semi-colon
separated list of strings. It is optional.

Fixes #430.

Change-Id: Ifcf79316e68768ff065891933de565cd0ff32ec4
2018-11-26 20:02:43 +00:00
KongQun Yang 74df8d30cc Exclude short segments from peak bandwidth computation
https://tools.ietf.org/html/rfc8216#section-4.1
The peak segment bit rate of a Media Playlist is the largest bit rate
of any contiguous set of segments whose total duration is between 0.5
and 1.5 times the target duration.

Fixes #498.

Change-Id: I1f28972b9cc5977735e47906bdcd88ba3942db5a
2018-11-26 20:02:09 +00:00
KongQun Yang 5a912815c1 Move protection system Ids to protection_system_ids.h
Change-Id: Ia22b89c38b3b1ff7ead05f8484e15edef6218953
2018-09-17 15:29:53 -07:00
KongQun Yang cb77b65117 Rename RawKeyPsshGenerator to CommonPsshGenerator
Change-Id: I59f9156ae0f13f04ba846806c661292f29339945
2018-09-17 15:10:59 -07:00
KongQun Yang 451406ad3f Update DRM documentations
Fixes: #245.
Fixes: #306.

Change-Id: Ib847f5cfbf01b98f7a7e088dfcbc4d25cbbc15f2
2018-08-15 17:18:57 -07:00
KongQun Yang 04a4275a44 Not generating Legacy Widevine HLS signaling by default
Configurable under --enable_legacy_widevine_hls_signaling, off by
default.

When it is enabled, do not fail if provider or content_id are missing,
but log a warning instead.

Bug: 112268769.

Change-Id: I2531aa7474d2818700b90fa0679b49891bb935ef
2018-08-14 23:00:04 +00:00
KongQun Yang db076d6892 Support Fairplay in --additional_protection_systems
Issue: #245.

Change-Id: I15187c1d3463534bf5e11ff97032311bb1d0c3bf
2018-08-09 23:59:40 +00:00
Yohann Connell f331f18f0e Removing dependence on base file atomic_sequence_num.h
This part of issue #346.

Change-Id: If03736b688a0bf95aaf09ed3cfd5d5a0134e1c44
2018-07-24 21:22:50 +00:00
KongQun Yang 5dd21179ec Do not use harmonic mean in bandwidth calculation
Instead, caclulating average bandwidth by dividing the sum of the
sizes of every segment by the sum of the durations of every segment.
This aligns with the requirement in HLS spec:
https://tools.ietf.org/html/draft-pantos-http-live-streaming-23 4.1.

BandwidthEstimator is also simplified to handle all blocks only.

Fixes #361

Change-Id: I89e7d415a841f4d4048f199de8dae7ffa250467b
2018-07-12 10:46:47 -07:00
KongQun Yang 99a2ad03af [HLS] Support AVERAGE-BANDWIDTH
Issue #361

Change-Id: Id8eb8283675cba5ec7234d13c4ac235f34e3bec9
2018-07-12 10:43:49 -07:00
KongQun Yang b4256bf040 [Cleanup] Use int64_t for time for consistency
Change-Id: I408f3fe7c98320be4e43ca2a5bcb9b22cc8a2012
2018-06-29 22:53:06 +00:00
KongQun Yang 6b4a75b6ba Changed to use BandwidthEstimator in MediaPlaylist
Preparing for addressing #361.

Change-Id: I4b2e834948e681bc790efc61b63a24d44f70015d
2018-06-22 11:12:23 -07:00
Aaron Vaage d8830e3168 Remove "wvtt" from Master Playlist Codec String
Having "wvtt" in the codec string (in the master playlist) causes
errors on some older Apple products. As including it is optional,
we are opted to omit it to ensure support for all Apple products.

Close #402

Change-Id: Ib1072bcc26a3ff66e3a6d3204789c0c8c678d4db
2018-06-20 17:31:51 +00:00
KongQun Yang 1a52a9b7c0 Fix potential incorrect target duration in iFrame Playlist
This may happen if media segments do not start with iframes.

Change-Id: Ie7b2d33a14405a5dcd071644f2fa3d5f9656dd07
2018-05-23 10:33:48 -07:00
KongQun Yang cf40accaa8 [HLS] Fixing AdCues handling in iframe playlists
Previously for the last iframe in a segment, we wait for the next
segment to arrive before writing the EXTINF tag. If an Ad Cue comes
in before the next segment, the EXT-X-PLACEMENT_OPPORTUNITY tag would
be inserted before the iframe in previous segment.

Fixes #378, #396.

Change-Id: I1ede72a4d4edca94781c7b05bc25397d67916d1a
2018-05-22 16:02:28 -07:00
KongQun Yang b209aeeb7a Remove the usage of JsonWriter in SimpleHlsNotifier
Use protobuf utilities instead.

packager/base/json_writer comes from Chromium base. We are going
to switch to abseil which does not have a JSON library.

This is unfortunately, at the expense of increased output binary size.
packager binary increases by about 300KB due to:
- Protos cannot be compiled with LITE_RUNTIME any more.
- Additional protobuf library needed to convert between JSON and proto.

Change-Id: I45a497376925b42d147ffcaabcfc2fa4dbdeacc1
2018-05-15 20:06:54 +00:00
KongQun Yang b5a73fc1d5 Refactor ProtectionSystemSpecificInfo class to struct
This is in preparation of supporting entitlement license API, where
common encryption server may return concatenated PSSHs directly.

Refactored ProtectionSystemSpecificInfo into a struct containing
concatenated PSSHs. This will make it easier to pass PSSHs around.

Also, most of the time, users of ProtectionSystemSpecificInfo do
not care what is in PSSH; so moved PSSH box parsing and building out
of ProtectionSystemSpecificInfo.

b/78171767

Change-Id: I1c4d5e7e23efd2f7d4b2b9704378323112e47f00
2018-05-11 00:10:07 +00:00
KongQun Yang a7463f60c1 Enable segment auto removal for live packaging
The number of preserved segments outside live window can be
configured using flag --preserved_segments_outside_live_window,
which is default to 50, i.e. 5 minutes for 6s segment.

Note that the segment removal will be disabled if it is set to 0.

Only HLS live playlist and DASH dynamic MPD are affected by this flag.

- Also add end to end tests.

Fixes #223.

Change-Id: I8a566efebe2f1552c7d9509ab017bade5a4a1c98
2018-05-02 00:18:42 +00:00
KongQun Yang 37d4ff017f Support removing segments outside of live window in HLS
Issue: #223

Change-Id: Ib91c60268d8df9adbaf5f6cac77eaebd6a3edb6e
2018-04-30 17:25:39 -07:00
KongQun Yang 60d7a4b2d5 Make MediaPlaylist accept HlsParams as contructor param
And for HlsNotifier and SimpleHlsNotifier as well.

This will make it easier to add preserve_segments_outside_live_window
param in a later CL.

Change-Id: I86d464fe247e04574158a0a76e39d8a122960ae4
2018-04-23 18:29:38 -07:00
KongQun Yang adc9549e2d Add new URL fields in MediaInfo
The file_name fields will be used to solely indicate file paths on the
designated file system, and they are used to do normal file operations,
including file creation, file updating and file removal if needed;
added new xxx_url fields, for the URLs that should appear on DASH
manifest or HLS playlists.

xxx_url are the URIs of the media in the manifest. The fields are
converted from file_name fields but adjusted to be relative to DASH
manifest path or HLS playlist path, optionally with base_url prepended.

Previously the file_name fields are converted in place to indicate
URLs when passing to manifest / playlist builders. The original file
names were lost, which made it difficult to remove files outside of
live window.

Now that the input file names are preserved. File system APIs can
operate on the original file names while manifest / playlist generation
functions can operate on URLs.

Issue: #233

Change-Id: I36a64f16e3d1261ce91783a86588f24ad1371662
2018-04-23 22:49:47 +00:00
KongQun Yang 0ef078a23b Fix default_language not effective with 2-char code
Two-character ISO-639 code in --default_language was ignored due to
a bug in language code matching as the language code in stream is
always converted to 3-character code.

Fixes #371.

Change-Id: I8618938af583a417446636ff9efe1c72ce822c33
2018-04-13 20:08:12 +00:00
Haoming Chen 76d68de6c1 Implement multi DRM support. (Part 1)
- Refactoring current clearkey DRM support for Widevine key source.
- Add playready pssh box in Widevine key source encrypted content.

Partially addresses issue #245

Change-Id: Id30ef02ff9f8dc0e2c58d62479e07896452919cc
2018-03-03 01:39:16 +00:00
Aaron Vaage 30b5fdf19f Add Text Codec To Codec String
This change has the hls master playlist add the text codec string
to the list of codecs in a variant.

Bug: 72942756

Change-Id: Ib25bb2064a291d10d7b1d261a4307991df62220c
2018-02-28 19:23:36 +00:00
KongQun Yang 8257eea804 Bug fixes and clean-ups for I-Frame playlists
- Add empty lines between different types of renditions to improve
  readability.
- Group variants with the same audio/text group together, as it is
  where the Adaptation occurs.
- Write master playlist after writing media playlists. This makes
  more sense and it is also necessary to have the bandwidth of
  the last iframe playist segment correctly computed.
- For fMP4, I-Frame segment must include the 'moof' header.
- Fix a problem that hls_iframe_playlist_name is not passed to
  MuxerListenerFactory.

Issue: #287

Change-Id: Icf37c5de1dc29f85ae3f419cbc3264d04ca491a4
2018-02-05 17:36:28 -08:00
KongQun Yang 1750357024 Support EXT-X-I-FRAME-STREAM-INF in master playlist
Issue: #287

Change-Id: I07fdfa095fe1797b3aa091d48798a2b5fbb4dfbe
2018-02-06 01:11:25 +00:00
KongQun Yang 04577b9638 Refactor MasterPlaylist::WriteMasterPlaylist
Change-Id: Ida7453761748087cd13aab640c400381696578e1
2018-02-02 14:13:12 -08:00
Aaron Vaage e98a150d62 Added DEFAULT and AUTOSELECT for Text
Took the same logic for DEFAULT and AUTOSELECT used by audio and
applied it to text. Combined the build tag logic for audio and
text as they were the same expect for a couple fields.

Bug: #205
Change-Id: I75ecbf4b25cd559b826982d12a5b132e70b83b69
2018-02-02 11:07:38 -08:00
Aaron Vaage e2dae2d960 Add Subtitle Support to HLS Playlists
The master playlist and media playlist did not have implementations
for handling text streams. This change adds support for both.

Bug: #205

Change-Id: I1329b8cc2585f15b89959071db9dd16d35847cba
2018-02-02 18:33:13 +00:00
KongQun Yang 82735be58d Support key frame events in MuxerListener and HlsNotifier
Issue: #287

Change-Id: I33b91b73988fc40e113bd2e627d08f549a7e3dc5
2018-02-02 00:00:53 +00:00
Aaron Vaage 8104628f48 Use Tag in Media Playlist
Instead of formatting the tag manually in MediaPlaylist, use the tag
class from MasterPlaylist.

Change-Id: I4099169a80a6d8595ab7f49e21cac4e7e0614832
2018-02-01 22:59:45 +00:00
Aaron Vaage 44847a0737 Changed Group Name Fallback
If no hls group name is given, we would default to "audio" but as
we are working to support text, this won't make sense to see
GROUP="audio" on a text stream.

Instead default to "default-audio-group" for audio streams. A specific
text default will be added later.

Bug: #205

Change-Id: Iefc8bfd35708286619d0004348294d98f2c38482
2018-02-01 10:24:58 -08:00
Aaron Vaage 1731fef14d Move Tag to Own File
Moved HLS Tag to its own file so that it can be used in other
HLS classes.

Change-Id: Ie3c2668fde28e43784661fc789d2edc80fc4a8fa
2018-02-01 17:02:46 +00:00
Aaron Vaage 0f17631017 Use Variants To Build Audio and Video Tags
In the master play list, use a class called variant to build
the video tags.

The variant list will always have one entry. In the case that there
are no audio streams, the variant list will have a null entry.

Bug: #205

Change-Id: I6e4acd83a31cd267c173e4f4c910f93781fe6efd
2018-02-01 17:02:31 +00:00
Aaron Vaage ea96b72d6a Consolidated Making MockMediaPlaylists
It was the same code to make the media playlists for each test, so this
change moves that logic into common functions.

Change-Id: Ifb8680247ad4335332251815a2db5d56d28151aa
2018-02-01 02:21:30 +00:00
Aaron Vaage 48b7282257 Creating HLS Tag Class
Made a tag class to make it easier to build tags for hls
content.

Bug: #205

Change-Id: Ifad6a690c3ade90c089f96ace870a62fd2ef420f
2018-02-01 02:03:37 +00:00
KongQun Yang 6d0a6bb120 Support I-Frames only playlist in MediaPlaylist
Issue: #287

Change-Id: I204774fd87cf9a159a4448ba3457db5ab17f7889
2018-01-31 21:37:34 +00:00
KongQun Yang 84f1f96f05 Rename SAMPLE-AES-CENC to SAMPLE-AES-CTR
Per the definition in the latest specification:
https://storage.googleapis.com/wvdocs/Widevine_DRM_HLS.pdf

Change-Id: Ic9b222c72ca8fbc4ae011e6557f2c4daaad2e624
2018-01-29 15:45:16 -08:00
KongQun Yang 32d26094ba [HLS] Support AUTOSELECT and DEFAULT in EXT-X-MEDIA
According to HLS spec: https://goo.gl/MiqjNd 4.3.4.1.1. Rendition Groups
- A Group MUST NOT have more than one member with a DEFAULT attribute of
  YES.
- Each EXT-X-MEDIA tag with an AUTOSELECT=YES attribute SHOULD have a
  combination of LANGUAGE[RFC5646], ASSOC-LANGUAGE, FORCED, and
  CHARACTERISTICS attributes that is distinct from those of other
  AUTOSELECT=YES members of its Group.

We tag the first rendition with a particular language in an audio group
with 'AUTOSELECT'; it is tagged with 'DEFAULT' too if the language
matches --default_language.

Fixes #315

Change-Id: Iacc0bc8c89ebffce8717fa65e82d6daf5a1f6adc
2018-01-19 02:10:07 +00:00
KongQun Yang 435d69c3a6 Insert EXT-X-PLACEMENT-OPPORTUNITY on CueEvent
See https://support.google.com/dfp_premium/answer/7295798?hl=en

Change-Id: I931427512cb695dc68d5c8c2ec214fe743161bcb
2018-01-18 17:07:55 +00:00
KongQun Yang db74d6756e Propage CueEvent to MpdNotifier/HlsNotifier
Change-Id: I9828af11a28300d20cc8742251bbe1b4ebfdbad1
2018-01-04 18:25:03 +00:00
KongQun Yang b3194866a6 [HLS] Add CHANNELS attribute to #EXT-X-MEDIA
As specified in HLS spec (https://tools.ietf.org/html/rfc8216):

All audio EXT-X-MEDIA tags SHOULD have a CHANNELS attribute.  If a
Master Playlist contains two Renditions encoded with the same
codec but a different number of channels, then the CHANNELS
attribute is REQUIRED; otherwise, it is OPTIONAL.

Fixes #299

Change-Id: Ic2308c39b170178b11cb0d94c3a8083c8b5f3353
2017-12-12 01:04:21 +00:00
KongQun Yang 8e96dd3b37 Address gcc build failures in some platforms
Seeing some failures on some platforms when compiled with clang
disabled:
  GYP_DEFINES="clang=0" gclient runhooks

Several changes to make it work:
1. Mark packager code with packager_code=1 in GYP definitions.
2. Disable a few checks in non-packager code, which we do not have
   direct control: dangling-else, deprecated-declarations,
                   unused-function
3. Fix the relevant errors in packager code.
4. Revert HAVE_STROPTS_H in curl config which is not available in
   all linux distributions.

Fixes #286
Fixes #293

Change-Id: I729b41f99403c5ad9487c6cc4a7dc06f6323cef8
2017-12-07 11:45:26 -08:00
KongQun Yang 5cf2b17ade Add --hls_key_uri to allow setting fairplay/identity key uri
Change-Id: I52e0f56cd10390faf515170f407ea488a6b3c9fc
2017-11-14 15:49:27 +00:00
KongQun Yang d66d307fc2 Rename fixed_key to raw_key
Change-Id: I1ee9398387b54aa685a5bef5b8704849e62ebae3
2017-10-24 21:52:01 +00:00
KongQun Yang c87c4c2327 [HLS] Fix single segment ULR isn't respecting folder location
Fixes #253

Change-Id: I61de1b28807ff8be9a881edd3adaa36612713dd8
2017-10-11 00:14:09 +00:00
KongQun Yang ae17159b73 [HLS] Fix init segment URL isn't respecting folder locations
Problem occurs when the media playlists are in a sub-directory under
master playlist. If base_url is not set, segment URL should be
relative to the media playlist.

This only affects fMP4 as TS does not have init segment.

Fixes #253

Change-Id: Icddd9ed500d0a705e8b3260bfd4e916ecbba3f28
2017-10-06 17:19:13 -07:00
KongQun Yang bc903d2d83 [HLS] Fix segment URL isn't respecting folder locations
Problem occurs when the media playlists are in a sub-directory under
master playlist. If base_url is not set, media segment URL should be
relative to the media playlist instead of the master playlist.

Also make sure the path separator is "/" in URL instead of "\" on
Windows.

Fixes #253

Change-Id: I8e933750276435d94dd01bfa53ee2bc050dfd193
2017-09-18 19:11:42 +00:00