Commit Graph

102 Commits

Author SHA1 Message Date
KongQun Yang 4f14a6f973 [HLS] Always set FRAME-RATE attribute
Although FRAME-RATE is optional per HLS specification, but per HLS
Authoring Specification for Apple Devices (https://apple.co/30n90DC):
  Each EXT-X-STREAM-INF tag MUST have a FRAME-RATE attribute.

Also, iOS and TVos refuse to play the content if VIDEO-RANGE is
present but FRAME-RATE is missing.

Issue #632, #634.

Change-Id: Ica282f023a7e8538f7b506094e2286840cf5c193
2019-10-09 21:20:32 +00:00
KongQun Yang ab8fa87d18 [HLS] Always signal Dolby Vision as PQ
Issue #341.

Change-Id: I9665ba032b1e069500d866281cb8569ce59876f9
2019-10-04 16:19:07 -07:00
KongQun Yang 0f15ce149b [HLS] Support FRAME-RATE attribute
Calculate FRAME-RATE from sample duration as in the DASH solution.

Right now calculated frame-rate may not be accurate in some scenarios,
so we avoid setting the attribute in HLS unless it is more than 30
fps. We will set it unconditionally once it is fixed.

Fixes #634.

Change-Id: I87b6e9a047d959ae88dd4dcb2b4786527ba5c9fc
2019-10-04 22:50:34 +00:00
KongQun Yang 3f909fa551 [HLS] Support HDR signaling, i.e. VIDEO-RANGE attribute
- Parse and extract transfer_characteristics from H264/H265 VUI
  parameters.
- Set VIDEO-RANGE attribute in HLS according to HLS specification:
  https://tools.ietf.org/html/draft-pantos-hls-rfc8216bis-02#section-4.4.4.2
- Also added an end to end test.

Fixes #632.

Change-Id: Iadf557d967b42ade321fb0b152e8e7b64fe9ff3e
2019-10-04 22:50:20 +00:00
KongQun Yang 9029e2d34f [HLS] Fix live chunks not deleted with $Time$ in segment template
Store and use the segment start time in the original time scale to
delete old segments, instead of storing it in seconds, as the segment
file name is generated using the time with the time scale.

Fixes #625.

Change-Id: I7524d597b1ffc081dd1399d6fb3ea47c13502881
2019-08-20 17:43:46 +00:00
Tomohiro IKEDA 2c51dcc601 Code cleanup: no "if return else return" (#611)
- Unify code format
- Low nest level
2019-07-15 11:03:42 -07:00
KongQun Yang 3c26dfbd53 Estimate target duration in bandwidth calculation from initial blocks
We used to use the target segment duration provided by the user.
Unfortunately that does not work for iframe only playlist which
the target duration is effectively equal to the GOP duration.

In the new approach, we estimate the target duration from the initial
few blocks (10 blocks right now).

Fixes #610.

Change-Id: Ie8bf943e157149ca7ed3b9382fe0a1088d0774e2
2019-07-11 17:45:55 -07:00
KongQun Yang 0a2b43939c [HLS] Replace hev1 in codec with hvc1 and avc3 with avc1
And also dvhe with dvh1.

Apple's specification does not recommend video formats with the
parameter sets stored in the samples.

It also fails mediastreamvalidator checks and some Apple devices /
platforms refused to play.

See https://apple.co/30n90DC 1.10.

Replaced with the corresponding formats with the parameter sets stored
in the sample descriptions instead.

Fixes #587.

Change-Id: Ic5d3f6fde115b1d09d1dcac32cef5fe0ad246aa0
2019-05-22 13:17:27 -07:00
KongQun Yang adc3c804a9 Support absolute file path in playlist_name
Fixes #585.

Change-Id: Icd0bc97a0b210c22a2dab716542d993a69d3d081
2019-05-13 18:13:37 -07:00
KongQun Yang ac616f36e4 SimpleHlsNotifierTest: Use value parameterized tests for rebase tests
Change-Id: Ie734624f6335b01b9bf989e1432ddb4fdf2e4b8b
2019-05-07 23:55:23 +00:00
KongQun Yang b85e5c9368 Use segment duration in buffer depth calculation
Segment start,end time was used previously, which could result in
problems if there are discontinuity in the streams. E.g. if the
stream has timestamp, 10000, 10001, 10002 and then next segment
comes in with timestamp 1. With the previous logic, all the segments
would remain in the time shift buffer until after 10000 segments
even with a small time shift buffer depth of 10.

This could also happen when timestamp wraps around, which could
happen during long time of live streaming.

This change will also be useful to support multi-period live DASH.

Fixes #563.

Change-Id: Ie078d76c6e4af13ade9ad46191c8e3529069ed4d
2019-04-17 22:47:10 +00:00
KongQun Yang 6d6db76c80 Retry file deletion if it fails
The file deletion could fail if it is still held by the web server.

This CL adds retry logic to retry the deletion.

Closes #533.

Change-Id: Ib42ed8db11f32897a29e3b58c1be89d05f5dd034
2019-01-02 15:23:27 -08:00
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