Commit Graph

248 Commits

Author SHA1 Message Date
Álvaro Velad Galván 298b60481d fix(dash): Fix performance regression (#4064)
See: https://github.com/shaka-project/shaka-player/issues/4062#issuecomment-1077826210
2022-03-25 13:56:38 -07:00
Joey Parrish 1507b1e844 chore: Update URLs after moving projects (#4008) 2022-03-03 14:34:40 -08:00
Joey Parrish b7f04cb36b fix: Fix memory leak in DASH live streams with inband EventStream (#3957)
EventStreams in DASH generate TimelineRegionInfo objects, which are
then stored in the RegionTimeline and RegionObserver classes.  But
DashParser would add all regions to RegionTimeline, even if they would
be quickly removed again, and RegionObserver would cache some regions
from the timeline without ever removing them.

This fixes the issue from both of those directions.  DashParser will
now ignore regions that are outside the DVR window (and therefore
would soon be removed from RegionTimeline), and RegionObserver listens
to an event on RegionTimeline to clean up its own storage when regions
fall outside the DVR window during playback.

Closes #3949 (memory leak in DASH live streams with inband EventStream)
2022-02-16 14:02:54 -08:00
Michelle Zhuo 36d0b5484f feat(HLS): Containerless format support
This adds code to allow Shaka Player to play media in sequence
mode, an alternate playback mode that makes the browser ignore
media timestamps, when playing HLS media.
This is important for containerless media formats, as they do not
contain such timestamps.
Changing HLS to not require timestamps also means that we no
longer need to fetch media segments in order to get the start
time, which should lower bandwidth usage and startup delay.
In initial tests, on a simulated 3G network, load latency went down
from an average 3.16s to 2.61s on the HLS version of "Big Buck Bunny:
the Dark Truths of a Video Dev Cartoon"; an improvement of about 17%.

Issue #2337

Change-Id: I507898d74ae30ddfb1bddf8dce643780949fbd9b
2022-02-08 09:34:03 -08:00
Álvaro Velad Galván f767260dcc fix(DASH): Support "forced-subtitle" role (#3807)
Previously, Shaka Player only supported "forced_subtitle",
which was the working name before the role was finalized.

Closes #3767
2022-01-06 21:50:34 -08:00
theRealRobG 73b430248b Dash hdr signalling via essential or supplemental property (#3727)
Now we parse value of descriptor for urn:mpeg:mpegB:cicp:TransferCharacteristics in AdaptationSet to indicate hdr property on shaka.extern.Stream which seems equivalent to HLS definition given in VIDEO-RANGE attribute within EXT-X-STREAM-INF.

This is done by reading the supplemental / essential property in the parsing of AdaptationSet, then mutating the hdr property on shaka.extern.Stream if no hdr exists after parseRepresentation_.

The alternative considered was to parse all essential / supplemental properties on any shaka.dash.DashParser.InheritanceFrame and then carrying that through to the parseRepresentaiton_ function; this can be seen here. The problem with the alternative approach was that the essential property in the adaptation set would have had to have been "let through" on the assumption that we would parse it within the parseRepresentation_ method... But this to me seemed somewhat risky to change, and also looks messy with the empty else if condition, plus was a much larger change (with more calls to XmlUtils, though not familiar with how that is implemented, so not sure if there was any penalty because of that).

* Test expectation for HDR signalling via property

The test sets the expectation that we should be able to extract the
information of the TransferCharacteristics from the DASH
AdaptationSet. This should then get converted to the nomenclature
used in HLS for the VIDEO-RANGE attribute on EXT-X-STREAM-INF.

* Implement signalling of HDR capability through property descriptor

According to DASH-IF IOP v4.3 6.2.5.1. the transfer characteristics
can be declared at the AdaptationSet level via a supplemental or
essential property. In HLS the transfer characteristics are used to
determine the value of the VIDEO-RANGE attribute on the
EXT-X-STREAM-INF attribute, which is already used to indicate the
hdr property on the shaka.extern.Stream object. Therefore for
consistency we also add the same identification to the DASH parser.

* Added entry in AUTHORS and CONTRIBUTORS

Fixes #3726
2021-12-16 13:19:26 -08:00
Theodore Abshire db47395ad2 Merge branch 'geo-failover-robustness' of https://github.com/harmonicinc-com/shaka-player
Change-Id: I200cd2a53e28e2d3d8d99e4d8d242e7c90fb5a94
2021-11-04 13:35:43 -07:00
Casey Occhialini 221637a66c feat: Add Common Media Client Data (CMCD) logging support (#3662)
Add support for including Common Media Client Data (CMCD) in outgoing requests.

Fixes #3619

NOTE: The following fields have not been implemented: rtp, nrr, nor, dl

Co-authored-by: Dan Sparacio <daniel.sparacio@cbsinteractive.com>
2021-10-20 12:22:41 -07:00
Enson Choy eba7f133ea Fix variable naming as per request 2021-10-18 10:02:58 +08:00
Michelle Zhuo fce5935800 refactor(dash): Use map of streams for Dash Parser
This is a step prior to the closeSegmentIndex implementation.
In the DashParser, use a map of context id to stream instead of
context id to segment index when parsing SegmentList.

For Dash live content, every time we parse a manifest update, we
create a new Stream object, leaving the old stream with its old
segment index.
If we close the segment index and create it later again, we need
update the stream's segment index.

Change-Id: I7a3af3666ddb4e26362c40eeb82c3d050fafe3ee
2021-09-10 13:43:19 -07:00
Enson Choy 5f77d2b8f1 Fix: Enhanced fix for geo-redundancy
Enhance fix for geo-redundancy: Discard only inconsistent periods not seen before
2021-08-27 17:00:57 +08:00
Enson Choy 84f45780aa Fix: Use period ID instead of start time 2021-08-27 10:52:33 +08:00
Enson Choy 94d696fd04 Fix: Discard only invalid periods
Discard only invalid periods instead of all obsolete periods to support modification of previous periods
2021-08-26 11:26:38 +08:00
Enson Choy 1c64e20909 Fix: Discard only invalid overlapping periods
Discard only invalid and/or overlapping periods to fulfil the requirements
2021-08-25 15:21:32 +08:00
Enson Choy 930c158629 Fix: Failover in geo-redundant streams
This is for fixing a case in geo-redundant streams failover:

1. ShakaPlayer identifies DASH period based on period id
2. Period ids generated by two synchronized packager could be inconsistent temporarily in some negative scenarios
3. After the scenario the packagers resync at the live edge, but the inconsistency is preserved in the manifest for the length of the DVR window
4. When ShakaPlayer receives a new mpd with inconsistent period ids (i.e. jumping between mpds from two packagers), it might result in
- Wrong presentation time
- Wrong buffer ahead estimation
- Old segment references added into segment index
5. Consequently, playback gets stalled and requires end-user to refresh the player (i.e. VPF)
2021-08-20 15:14:21 +08:00
Joey Parrish 3cc9ec50b4 fix: Use "undetermined" for missing CC language
When caption languages are not present in the manifest (such as
"CC2=;CC3="), use "und", the language code for "undetermined".

Bug: 187442669
Change-Id: Ia129815efb2ae6b0ac6b655ac02398a7b1f70e68
2021-07-19 14:37:45 -07:00
Aidan Ridley 9afa4eb20d feat: Add callback for apps to pre-process DASH manifests (#3480)
Added support for efficient preprocessing of DASH manifest after they have been parsed into an XMLDocument

This is configured with the new manifest.dash.manifestPreprocessor setting.

This is need to efficiently repair manifests that are not compatible with Shaka Player.

Closes #3339
2021-06-22 15:15:56 -07:00
Aidan Ridley 9dc466475a fix: Fix buffering due to re-fetch (SegmentTemplate+duration) (#3419)
In DASH with SegmentTemplate and a fixed duration, indexes would
continue to grow so long as they had not ended.  However, this was
based on a callback which captured an end time variable that could
become out-of-date in a multi-period live stream.

This prevents indexes from continuing to grow indefinitely by always
using the most up-to-date end time for the period.

This also fixes eviction of segments in the same scenario, which
fixes SegmentIterator access and related assertions later.

Issue #3354 (partial fix)

b/186457868

Change-Id: I2b34ee52dd12b59e1c1237258050b50e3189bee3
2021-06-16 13:23:08 -07:00
Joey Parrish 6143a6d314 fix: Fix key rotation in DASH
This was broken accidentally during MediaCapabilities refactoring.
This does not affect any release version.

The filtering step does two things: it applys the "restrictions"
config to the streams in the manifest, and it sends DRM init data to
DrmEngine for all streams in case new sessions need to be created.

For key rotation, it is critical to create new sessions in DrmEngine.
The init datas for new periods are added to existing streams when the
new period's streams are stitched onto the old ones.

The restrictions config should also be applied on manifest update,
since the update could have created some new streams with
characteristics outside of the current restrictions config.

Closes #3169

Change-Id: I716c2978c7394d7bb56227aa1854392a10eae058
2021-04-21 10:16:33 -07:00
Joey Parrish 29e7ab19d9 fix: Fix failed assertion for eviction logic
In #3169, we discovered failing assertions for some multi-Period DASH
live streams.  The failing assertion was meant to ensure that our
eviction logic was correct, and that our assumptions are maintained
properly.

Though the assertion failed, nothing was actually wrong with playback.
But the assertion itself should only fail if there is actually
something wrong.

With the choice between removing the assertion (since playback is
fine) or "fixing" the assertion (to avoid this false negative), I
chose to fix the assertion to retain the value of it to catch actual
bugs in our logic in the future.

The assertion specifies that you should not see evicted segments after
non-evicted segments.  But eviction was only done when merging a
segment index with an old version of the same index (same
Representation and Period).  When an update drops a Period from the
manifest, this means everything in that Period should be evicted.  But
the eviction call wouldn't happen, because we had no new version of
the segment index to update the old one.

An extra call to evict() on each manifest update can fix the state
of the system so that our assertions pass.

The assertion message appeared identically in two different
assertions, so this change also rewrites the assertion messages to
differentiate them and to clarify their meanings.

Issue #3169

Change-Id: Ifeb7a1a8f48af704b028a22d987349209d7ee485
2021-04-21 17:14:09 +00:00
Vincent Valot b4595d5a59 feat(drm): make dash keySystems configurable (#3276)
Make the DASH keySystems configurable, so that any developer could chose to opt-in for recommendation based on DASH DRM UUID.

Example:
player.configure({
  dash: {
    keySystemsByURI: {
      'urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95': 'com.microsoft.playready.recommendation',
    }
  }
});
2021-04-02 17:33:39 -07:00
Michelle Zhuo acfa1a800c feat(MediaCap): get decodingInfo results before queryMediaKeys
Previously, we fill in the variants' drmInfos with the drm
configurations of |clearKeys|, |servers| and |advanced| during
initializing the DrmEngine, before we query the media keys.

Now we need to call |MediaCapabilities.decodingInfo()| to get the
mediaKeySystemAccess of the variants after the DrmEngine is
created and configured, and the drm values are filled in for the
variants, and before |DrmEngine.queryMediaKey_()|.

The steps would be:
0. StreamUtils.setDecodingInfo() should not be called before
   DrmEngine is initialized and configured.
1. Create and configure DrmEngine.
2. Fill in drm values for the variants with configurations.
3. Call StreamUtils.setDecodingInfo() to get the decodingInfo of
   the variants.
4. Use the decodingInfo results to set up the Drm mediaKeys in
   DrmEngine.
5. When StreamUtils.filterManifest() is called, we can reuse the
   decodingInfo results instead of calling decodingInfo again.

Previously we call filterManifest() when parsing the manifest, to
filter out the unsupported streams.
Now decodingInfo can tell us if a variant is supported and its
MediaKeys at once. When initializing the DrmEngine, we get the
decodingInfo results of the variants, and only use the supported
streams to set up the MediaKeys. After that, we filter the manifest
right after DrmEngine is initialized.
Thus, we can skip filterManifest() in manifest parsers.

Using decodingInfo to get media keys will be in the next CL.

Issue #1391

Change-Id: Ieb401a1e4dfbcc958f7a14fa96df546237b0f446
2021-03-23 23:41:51 +00:00
Álvaro Velad Galván 014e14638b Add config to disableXlinkProcessing (#3240)
Xlink processing is very slow on some TVs.

This adds a configuration parameter to disable that feature, for platforms that won't use it.
2021-03-17 16:30:20 -07:00
Álvaro Velad Galván f23ee0a9af feat(Dash): Extract HDR metadata from DASH manifests (#3226) 2021-03-17 10:27:42 -07:00
Álvaro Velad Galván b9b3cc8098 feat(dash): Add support for thumbnail tracks (#3145) 2021-03-02 13:36:09 -08:00
Álvaro Velad Galván f067ae10ac Parse spatial audio from manifest (#3148) 2021-02-24 09:28:33 -08:00
Álvaro Velad Galván 23808ea988 feat: add ignoreMaxSegmentDuration config for DASH manifest (#3115)
Adding a new Configuration to ignore the maxSegmentDuration from the DASH manifest.
Closes: #2834
2021-01-26 20:11:54 -08:00
Benjamin Wallberg 9ec5cb19d6 fix: Fix trick mode tracks in DASH (work around compiler bug) (#3087)
Closes #3085
2021-01-11 13:13:55 -08:00
Álvaro Velad Galván 607deb71c9 feat(dash): Add support for mpegB:cicp:ChannelConfiguration (#3057)
Closes: #2873
2020-12-23 10:27:15 -08:00
Álvaro Velad Galván 65143a6d32 fix(DASH): Fix trick-mode tracks associated with multiple regular tracks (#2992)
In DASH, a trick mode track can be associated with multiple regular tracks.

This fixes the parser to respect the whitespace-separated list of IDs instead of assuming just one ID.

Resolves #2978
2020-11-23 14:23:46 -08:00
Álvaro Velad Galván 57d11d13c6 fix(media): Ignore incompatible TrickMode streams (#2984)
Resolves: #2846
2020-11-13 13:28:00 -08:00
Álvaro Velad Galván 28f35c251c feat(lowLatency): Add autoLowLatencyMode config (#2861)
With "lowLatencyMode" enabled, "rebufferingGoal" is set to 0.001, and inaccurateManifestTolerance is set to 0 by default. However, in some cases longer rebufferingGoal helps to avoid new rebuffering.
Besides  "lowLatencyMode", this code change adds the  "autoLowLatencyMode" config. When "lowLatencyMode" config is disabled and "autoLowLatencyMode" config is enabled, and the manifest provides low latency features, we automatically activate the lowLatencyMode.
If "lowLatencyMode" is enabled, "autoLowLatencyMode" has no effect.

Issue #1525
2020-11-12 11:07:19 -08:00
Álvaro Velad Galván 01998f3b99 Parse forced subtitles from manifest (#2938)
Issue #2122
Issue #2916
2020-10-27 14:00:48 -07:00
Michelle Zhuo 281d3ed96f feat(LowLatency): Show warning if lowLatencyMode should be enabled
Updated the warning message.

Change-Id: Ifc655cfd11d617b87ff9d0f3a11b37eef12bfc86
2020-09-20 16:22:03 -07:00
Michelle Zhuo ac4fb76e05 feat(LowLatency): Show warning if lowLatencyMode should be enabled
If an HLS playlist contains partials segments, or a Dash playlist
has availabilityTimeOffset value, we check whether lowLatencyMode
is enabled. If not, we show a warning to remind the developer to
set the configuration.

Issue #1525

Change-Id: If7b851c32c325203870c33d868668e1a3dd3c8bf
2020-09-18 19:37:43 +00:00
Muhammad Haris 54ff2d8f28 feat(cea): CEA-708 Decoder (#2807)
This pertains to #2648 (although this is a new feature, not a replacement) and #1404. A CEA-708 decoder that follows the CEA-708-E standard, decodes closed caption data from User Data Registered by Rec. ITU-T T.35 SEI messages, and returns them as cues in Shaka's internal cue format. Furthermore, this pull request fixes and cements some of the logic surrounding CEA-608 and CEA-708 tag parsing on the Dash Manifest Parser.

Format:
Similar to the CEA-608 decoder, cues are emitted in Shaka's internal format (lib/text/cue.js). This decoder makes use of nested cues. The top level cue is always a blank cue with no text, and each nested cue inside it contains text, as well as a specific style, or linebreak cues to facilitate line breaks. This also allows for inline style (color, italics, underline) changes.

Details:
- ASCII (G0), Latin-1 (G1), and CEA-708 specific charsets (G2 and G3) all supported.
- Underlines, colors, and Italics supported, set as a property on each nested cue.
- Positioning of text is supported. (Exception: In CEA-708 the default positioning is left, in this decoder it is centered.)
- Positioning of windows not supported, but relevant fields that could be used to support this are extracted and left as a TODO.
2020-09-10 13:06:07 -07:00
Theodore Abshire 509e7b046a fix(manifest): Fix embedded captions vanishing.
Previously, on manifest updates, embedded captions would vanish in
single-period live DASH streams.  The problem was based on the
specific point in the load order that we added dummy text streams
to indicate the presence of embedded captions.
This modifies the PlayerInterface for manifest parsers to add a
new method passed in, makeTextStreamsForClosedCaptions, which
must be called by manifest parsers for new video streams.
This also completes an unfinished feature, where new video streams
which add new closed captions would not get corresponding
text streams.

Closes #2811

Change-Id: Iee7499ec950b363cf6839765cc2bd2d01743467d
2020-08-26 15:05:40 -07:00
Michelle Zhuo a22df6d18c feat(lowLatency): Move lowLatencyMode config to streaming configuration
1. Move the config field from ManifestConfiguration to StreamingConfiguration, since StreamingEngine will need it.
2. In manifest parsers, we get the value of lowLatencyMode config from the StreamingConfiguration.

Issue #1525

Change-Id: Iaa961b4e6799ecc1fcf3147b2fb992e86d4b043d
2020-08-20 03:33:46 +00:00
michellezhuo d1547672b4 feat(LL-Dash): Add support for availabilityTimeOffset
availabilityTimeOffset indicates that a segment is available for
download earlier than its availability start time.
1. This attribute can be on Period, Adaptation set, and Representation
level. The availabilityTimeOffset value of a segment should be the sum
of the values on different levels that apply to the segment.
2. We pick the minimum of the availabilityTimeOffset value among the
representations, reduce the distance from live edge by this value.
3. The availability window should be:
timeShiftBufferDepth + availabilityTimeOffset.

Doc: https://dashif-documents.azurewebsites.net/Guidelines-TimingModel/master/Guidelines-TimingModel.html

Tested with demo page, and the live latency got reduced by the availabilityTimeOffset value.

Issue #1525

Change-Id: Ibe87b0293b31e594f38f98c7caa9f5aeb134e40b
2020-08-10 19:27:36 +00:00
Jacob Trimble dc8b007d56 cleanup: Add missing requires.
This is a port of the internal changes: cr/321495405, cr/321592702,
and cr/321594488.

Change-Id: If6a4c4266ed10a70b01442974dbd19329bb5122e
2020-07-16 10:59:49 -07:00
Joey Parrish f539147d48 fix: Correct license headers in compiled output
This fixes all the license headers in the main library, which corrects
the appearance of the main license in the compiled output.

It seems that the `!` in the header forces the compiler to keep it in
the output.  I believe older compiler releases did this purely based
on `@license`.

Issue #2638

Change-Id: I7f0e918caad10c9af689c9d07672b7fe9be7b2f3
2020-06-09 16:05:09 -07:00
Theodore Abshire 8d657140f1 Made ManifestParser.PlayerInterface.filter async.
This is a change in preparation for the adoption of the
MediaCapabilities API.

Related to #1391

Change-Id: If0988aedafe15aa3be794fb977fd8e04e91ca10e
2020-06-04 17:42:27 -07:00
Álvaro Velad Galván 1568d28686 Wrong pixelAspectRatio population in DASH (#2614)
The current implementation of pixelAspectRatio in DASH is wrong. `@par` in DASH is "picture  aspect ratio" so the correct is populate this field with `@sar`.
2020-06-03 14:46:41 -07:00
Joey Parrish 342d35f4f9 Fix issues with nullability of numbers
Various issues with the nullability of number types led to various
fixes, including:
 - defaulting a nullable number to 0 to avoid propagating a null value
   through calculations
 - adding an assertion or runtime check that something is not null
 - moving an existing null check to before the calculation
 - returning early on null during an iteration
 - changing a nullable number to non-nullable
 - defaulting to NaN instead of null

These issues were caught by a compiler upgrade.

Issue #2528

Change-Id: I86d516c74a42ee3624c33d7513d2d4c76d3ea589
2020-04-30 16:00:00 +00:00
Joey Parrish e24fec4b08 Flatten periods
This creates a new utility used by DashParser and old offline DB
formats to combine Streams across Periods.  This allows multi-Period
DASH content to be played without period-specific structures in the
manifest format, StreamingEngine, or Player.  This also makes the
Tracks stable across Periods.

Closes #1339 (flatten periods)
Closes #1698 (rapid period transitions issue)
Closes #856 (audio change causes bitrate change)

Change-Id: Icb04c8e47e36eacf7ac024a5063130d85a115e54
2020-04-09 19:22:16 +00:00
Joey Parrish 6e3dfa40ba Deduplicate key IDs with Set
When period-flattening combines Streams, key ID arrays would get very
long with duplicates.

This changes keyIds in the manifest and offline structures from Array
to Set.

Issue #1339

Change-Id: I003d23e567efafa771ecd2ad597900181604ad18
2020-04-09 19:22:16 +00:00
Joey Parrish e8ac57f36c Move drmInfos array to Stream
Period-flattening will concatenate Stream objects, so this information
should be available per-Stream instead of at the Variant level.

Issue #1339

Change-Id: I96195fea48cab1e4a349b2ab0b16064a443e928a
2020-04-09 19:22:16 +00:00
Joey Parrish 99de217c23 Remove periods from manifest structure
This removes periods from the internal manifest structure and cleans
up code and tests accordingly.  This leaves us unable to play
multi-period DASH & offline streams until the main period-flattening
algorithm is completed in shaka.util.Periods.

Three test cases have been disabled for the moment.

Multi-period playback will be restored in a smaller, more focused
follow-up commit, with disabled tests re-enabled.

Issue #1339 (flatten periods)
Issue #1698 (rapid period transitions issue)
Issue #856 (audio change causes bitrate change)
Closes #892 (refactor StreamingEngine)

Change-Id: I0cbf3b56bfdb51add15229df323b902f0b2e643a
2020-04-09 19:22:16 +00:00
michellezhuo 3b52166f56 Remove support for custom DASH ContentProtection schemas
Remove manifest.dash.customScheme callback function since it's no longer used.

Closes #2356

Change-Id: I6d08fcf97cff1bf2985e7c660d74efcd767eaed9
2020-04-09 09:11:20 -07:00
Joey Parrish 51779cf3be Fix memory leak in live streams
Live stream tests call stop() on their manifest parsers, but nobody
was calling release() on the SegmentIndex objects.  This meant they
could continue to generate SegmentReference objects indefinitely.

In production, the Player releases all SegmentIndex objects.  But if
some Variants had been removed due to filtering, they would never be
stopped.

By having DashParser release all SegmentIndexes it generated, we can
ensure that there are no timers running after the parser is stopped.

This bug was introduced in the master branch and has not appeared in
any release.

Change-Id: If885e828b4761528e40abdbc601a11cf13849a1e
2020-04-04 03:46:15 +00:00