Commit Graph

120 Commits

Author SHA1 Message Date
Muhammad Haris 480d4a801a Parse CEA-708 Packets from Fragmented MP4 streams. (#2660)
This is an MP4 Parser which extracts CEA-708 packets from Fragmented MP4 streams.

The Closed Caption Parser (shaka.media.ClosedCaptionParser) will own this MP4 Parser, and will initialize it and call it as shown. As data comes in, the parser will parse this data, and the caption packets data then be returned in a callback (on708Data), as shown. Here, a theoretical decoder (future pull request, mentioned as a Todo comment) will decode and extract the parsed captions from these packets.

Issue #2648
2020-07-05 16:29:17 -07:00
Theodore Abshire 34337ca28d feat(UI): Added polyfill for screen.orientation.
There are some platforms (e.g. iPad) which can be rotated,
but do not support the screen.orientation API. This is relevant
because iPad now supports requestFullscreen, which it did not
before.

Found while investigating #2653

Change-Id: Iacc93433aa1fb50a25d968203dc9fd4f7f16b4ae
2020-06-17 12:31:24 -07:00
Muhammad Haris e8f24ece6f Created MP4 Box parsers to parse data for common box types (#2649)
Issue #2648
2020-06-15 17:35:38 -07:00
Sandra Lokshina 26d2e98959 Add a util for handling media readyState related logic.
Fixes #2555.

Change-Id: I735064952bc425bfb18d6c5681921ae1691eb348
2020-05-19 22:43:13 +00:00
michellezhuo 562168a1f6 Set UITextDisplayer as TextDisplayFactory in default config
In player, SimpleTextDisplayer was set as the default TextDisplayer. In
our UI, it changes the configuration to use the UITextDisplayer, and
UITextDisplayer gets constructed with the player. Later in our demo, it
resets the config, so an extra SimpleTextDisplayer gets constructed.
This introduces an extra TextTrack created by SimpleTextDisplayer.

This change sets the UITextDisplayer as the default TextDisplayer in
player's default config.

Closes #2516

Change-Id: I3f653be9fad8b2edbc2fb9de84e8abb327dcfc51
2020-05-04 20:40:18 -07:00
Joey Parrish 1076b78465 Unfork Closure base and update the compiler
The Closure Library's base.js, the Closure Compiler, and the Closure
deps-writer are all now loaded via NPM instead of commiting them
directly to the repo.  This also updates both the library and compiler
to the latest version: 20200406.

We still have a fork of the Closure Library's URI parser.  The latest
upstream version of that has too many dependencies on the rest of the
library to import directly from NPM.

Some internals of the build system have been refactored, and the
"complete" set of files in the build system now includes third_party.

Our forked URI parser does not pass lint checks yet, so the linter
does not run over third_party yet.

A couple of overly-severe sets of compiler checks have been disabled,
since even the latest Closure Library's base.js doesn't pass them.

The script-loader in load.js had to be updated for compatibility with
the new Closure Library.  If you don't return "true" now, Closure's
base.js will stop loading subsequent source files.

Some local externs that we had written are now available from the
compiler, so our local copies have been deleted.

A few type-related changes have been made as well, removing casts that
were necessary with the old compiler, but not necessary with the new
one.

Finally, this corrects some type issues in the tests using the new
"typeof" annotation from the compiler.  This allows us to type a
variable as a class defined elsewhere.  For example, after loading the
compiled library, we can reference compiledShaka.Player, which has the
type "typeof shaka.Player".  The compiler can then type-check all uses
of it in the tests.

Closes #2528 (bad polyfill code generated by the old compiler)

Change-Id: I62ec61e82d4edf342b2c576c2d4f89f11562ee65
2020-04-30 19:32:30 -07: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
Álvaro Velad Galván 697a6ff785 Add initial DAI support (#2382)
This PR ads initial logic to enable support for IMA DAI streams.
Ad-containing streams can now be requested from the IMA stream manager and played.

Integration with the ad UI will follow in a separate CL.
2020-02-18 14:11:51 -08:00
michellezhuo cfe1f89171 Add playback speed selection to UI
Closes #2362
Closes #1676

Change-Id: I10184dccab301be7382940e35e36d66dc7a5e2ad
2020-02-12 20:24:03 +00:00
Sandra Lokshina eda5b72134 Add loop control element to the UI.
Please note that this CL doesn't add the new control
to the default layout, so it won't show up in our
demo page.

Issue #2362

Change-Id: Ibecf6a7174de7d8eca9049f0b46ae179a03b9c01
2020-02-04 21:27:20 +00:00
Sandra Lokshina 1b3b78ea16 Add ad position info to the UI. (Ad x of y).
Issue #2222.

Change-Id: I9bf946552bc6f669164c387480fadc100087708a
2019-11-22 22:04:05 +00:00
Joey Parrish b9b4118938 Add a polyfill for EME encryption scheme queries
Note that the encryptionScheme field isn't being used by Shaka Player
yet, but that this will enable us to experiment with it ahead of the
full launch of the feature in browsers.

See also:
 - https://wicg.github.io/encrypted-media-encryption-scheme/
 - https://github.com/WICG/encrypted-media-encryption-scheme/issues/13
 - https://github.com/w3c/encrypted-media/pull/457

Change-Id: I9e8c2b6ce4ce3f4fe634fa4164669c69959e7fde
2019-11-22 18:18:36 +00:00
Sandra Lokshina 110c0bb485 Create a shaka class to encapsulate ads.
Change-Id: Ic9388679754d24cef7246107e1e3b951977ce27f
2019-10-25 15:23:33 -07:00
Sandra Lokshina 7afac89bc2 Restructure AdManager to be owned by Player, not UI.
This will allow Ad functionality to be available for apps
with custom UI.

Change-Id: I3911cb6d764b7aef94166b5f6de3a0a7fa8bb8d9
2019-10-18 18:42:13 +00:00
Sandra Lokshina f485772b6d Add ad elements to the UI layout.
This change adds an ad counter and a skip add
button to the DOM and styles them appropriately.
Please note that they don't work yet!
The elements are hidden for now.
To check them out, remove the 'shaka-hidden'
class from the 'shaka-ad-controls' div.
(data-shaka-player-container -> shaka-ad-controls-container ->
shaka-ad-controls).

Change-Id: I45a33d43abc6b0a023cc77f09abdae94a4cee014
2019-10-11 21:56:44 +00:00
Sandra Lokshina c2105a362b Lay the ground for the Ad Insertion work.
This CL does:
- define CS IMA externs
- define Ad Insertion classes and sctructures
- add a (non-working) skeleton for the Ad UI
- provide a (working) early draft of the CS implementation

This CL does not:
- add any SS logic
- have a working ad UI
- provide a final and complete implementation for the CS logic
- fully follow the finalized Ad Insertion design

Change-Id: I645cdcb3a1d4041792b940c2d6faf011be5eb682
2019-10-03 20:01:38 +00:00
Jacob Trimble 454ff49006 Add a type to lazily generate a value.
Change-Id: Ibcd5bc76953f1c0c153dd5845d1b095dac0bb358
2019-08-21 22:02:06 +00:00
Jacob Trimble a2bcf7278d Move some utilities to BufferUtils.
Change-Id: Ifb3c4348cc912640b99ff53f7cac59a63480c68e
2019-08-20 22:07:35 +00:00
Sandra Lokshina 5646184030 Add a SettingsMenu class for settings menus.
This extracts common code in our overflow menu settings
menus.
Text, Audio Language and Resolution selections now inherit
from this class. It also makes it easier to create new
overflow menu items.

Closes #2091

Change-Id: Ib68e1fb295ed3ec61cb7a072c039a5c7c4e22183
2019-08-20 17:40:47 +00:00
Jacob Trimble c5b9d6804f Allow custom content ID in FairPlay.
Now there is a generic callback to transform the init data before
passing it to the browser.  This can be used by apps to use a custom
content ID in FairPlay content.  This also adds some utilities to help
in writing these functions and moves the default behavior to DrmEngine.

Closes #1951

Change-Id: I78ce660c126b53a69d5f55b16775ffcdbbe4d748
2019-08-07 18:38:40 +00:00
Sandra Lokshina 635acb6ecf Extract the big play button into its own class & make it optional.
Change-Id: I462632c3da5f8ff5a68e111940591086bb395a13
2019-07-25 22:06:37 +00:00
Joey Parrish fcbb72561f Refactor UI range elements
This factors out common functionality and structure from the volume
bar and seek bar, both of which involved specific CSS workarounds for
IE.  The seek bar had logic to keep the value from jumping around
during casting, which now the volume bar benefits from, as well.
Finally, the seek bar code was spread out throughout controls.js, and
now it has its own class.

Closes #1913

Change-Id: I299476ccbc27f28f7b225a6e6f8b0d21abe5baf2
2019-07-10 12:26:54 -07:00
Joey Parrish d6d9fa9250 Refactor IndexedDB storage cells into a base class
To prepare for an upcoming change to the format of the data stored in
IndexedDB, refactor the storage cells to remove common functionality.
This will make it easier to add a third cell type.

The format will change as we move fields in the manifest structure and
ultimately flatten out periods.

Issue #1339

Change-Id: Ibaeb35596180b2e2362b4d53734019599d6fff77
2019-07-09 16:36:25 +00:00
Joey Parrish f39bade337 Add play/pause button in controls
This is different from the giant play/pause button that sits over the
video container.

Change-Id: I4629b3a64a5208f23c65b383f4fb992e6ddfd334
2019-05-07 17:57:59 +00:00
Joey Parrish e3b49573a2 Rename PiP polyfill to PiPWebkit
Follow-up to #1902

Change-Id: I760d0006c4cbd7c3aad2ce96801259b578269195
2019-05-03 21:30:17 +00:00
Álvaro Velad Galván caa34ca90d Add PiP pollyfill for Safari (#1902) 2019-05-03 10:50:37 -07:00
Joey Parrish 9a4b73df7c Fix runtime errors in the new demo on IE 11
- Polyfill navigator.languages, which is missing on IE
 - Add missing handler for uncaught exceptions (doesn't work on IE,
   but is a good idea to have for debugging the demo app)
 - Avoid offline setup if it's not supported (as on IE)
 - Fix bad reference to uncompiled link (wrong ID)
 - Log any caught errors to the console
 - Wrap the init functions to catch and log any errors during init

Fixes b/131863587
Fixes #1911 (similar storage error on iOS)

Change-Id: Ib2a53392d5632c71825af17dd3e955cd54279e98
2019-05-03 17:26:44 +00:00
Joey Parrish a121733a11 Add FairPlay EME polyfill and DrmEngine support
This adds a polyfill for Apple's prefixed EME implementation.  This
will be used on all macOS versions prior to 10.14 (Mojave) and on
Safari versions prior to 12.1.

This also adds support for FairPlay license protocol eccentricities
in DrmEngine, so that the proper formatting is used for requests and
responses.

Issue #382

Change-Id: If1274d2f018a475f56c09df97645694f13acbde9
2019-04-30 21:15:11 +00:00
Aaron Vaage 40212ec43e Move Trick Play Out of Video Wrapper
This change moves the trick play logic out of the video wrapper so that
it will be more available to the src= code. By doing this, I hope that
we can make it clearer how we are working with the playback rate and
ensure a tighter integration with it.

Issue #816
Issue #997

Change-Id: Id462cda2c5eb82c3713237341424b91891bd38ea
2019-04-11 15:50:11 +00:00
Joey Parrish 00442a9a7c Split up localization data for lazy loading
This changes the format of the localization data to enable apps to
trivially lazy-load translations.  It also adds --locales to the build
scripts to allow app developers to choose the compiled-in locales.
The generated output now goes into dist/ and is not checked into
revision control.  Finally, it adds "description" and "meaning" fields
to the source messages to allow us to more easily integrate with a
context-aware human translation service.  The "description" field
provides application context for the translator, while the "meaning"
field provides linguistic disambiguation for words with multiple
meanings or parts of speech in the original English.

Because the translation service wants to collapse messages with
identical text, we had to merge several messages together.  To this
end, we have removed the prefixes "ARIA_LABEL_" and "LABEL_" from the
messages themselves and collapsed what remained.

Issue #1688

Change-Id: I24c17e71c73f6663cf123cfdba118c486fa80ecc
2019-04-09 16:06:14 -07:00
Sandra Lokshina 493d459c47 Add a DOM util.
Change-Id: Ia0941868f20dbb42fa0fe02a639015ac244a65ed
2019-04-05 12:01:59 -07:00
Aaron Vaage ba1b24dfc9 Isolate Download Estimation
Isolate the download estimation code out of DownloadManager so that it
can be tested in isolation and allow the code in DownloadManager to
focus on downloading.

Change-Id: I509adeaf50acb77bfaa9b2128f730de2653eda81
2019-03-12 21:29:13 +00:00
Aaron Vaage 25710b6c33 Refactor Segment Request Creation To Be Shared
In four different places in our code base, we did the same
work to create a segment request. The bulk of the work was
based on setting-up the range header.

This CL creates a common utility that will create the request
for us while keeping networking engine as ignorant to segments
as it was before.

Issue #1788

Change-Id: Ie3dc2a99a34b3925fecbfdaae7b1e178a0b7a3b6
2019-03-12 21:18:27 +00:00
Aaron Vaage 7a56dd1bdc Prevent late-timer-invokes
In our tests, it was possible for a timeout to fire after |clearTimeout|
was called. This CL makes sure that cannot happen by adding an "alive"
flag to each timeout.

To ensure that the change was as well defined as possible, this CL
changes how |shaka.util.Timer| is implemented and updates the API to
better communicate what is happening internally.

Change-Id: I57e3899046a762bff3293b9822a7e8f7ac804042
2019-03-12 18:52:32 +00:00
Aaron Vaage e1e312538c Add load graph toolkit
In order to support multiple different forms of loading, we have
designed a toolkit that we are calling "The Load Graph Toolkit". It
allows us to describe a series of work as a graph, and provides a way
for us to move through that graph, executing actions at each step.

This is the first step toward resolving #816, #997, and #1570. This
will provide the framework to build a more structured system for
loading and unloading content.

Issue #816
Issue #997
Issue #1570

Change-Id: I2f91089d07b0c901843550492308fcfd775bf161
2019-02-26 23:42:36 +00:00
Aaron Vaage 71e8c4936d Refactor getAllVariants
Refactored |StreamUtils.getAllVariants| to get variants from a collection
of periods (rather than a manifest). This allows us to avoid needing to
assert that the manifest exists (when we know it will).

Looking long-term, as part of the refactor the method was moved to a
period-focused utility class. The goal of this is to make it easier to
see what methods may go away when we flatten periods.

Change-Id: I50aa97583892361ee4714a7beaf61e4cd95fb6b4
2019-02-26 17:22:15 +00:00
Sandra Lokshina 4d41b7b90c Refactor the overflow menu to use components design.
Closes #1673.

Change-Id: I030745def928796a6abc813a91fb163cb2d76175
2019-02-21 13:14:28 -08:00
Sandra Lokshina 4c1f1985a3 Add fullscreen and fast forward buttons to the compiled build.
Closes #1787.

Change-Id: If8f06c3481a24b39fe99d39feddc581fd225f8f2
2019-02-04 14:35:55 -08:00
Aaron Vaage 88b5ad7852 Refactor Playhead Observers Into Separate Classes For Each Observation
Before we had one central playhead observer that would monitor multiple
different relationships:
  1. Buffering
  2. Periods
  3. Timeline Regions

This CL breaks each observer into their own class (allowing for them
to be tested independently). To allow the player to be ignorant of which
ones are in-use, a playhead observer manager has been created.

The player is responsible for creating the observers since it has the
knowledge of what ones need to be created (and the references to
everything).

As part of breaking the observers apart, the Region Timeline was broken
out so that the observer has something to observe (similar to how the
buffering observer observes the buffered region and the period observer
observes the periods).

Change-Id: I18bf0f45561f3bac44da50c0d00a02f8b1fbf3cf
2019-02-01 00:43:35 +00:00
Aaron Vaage 43afe3a7c8 Refactor Event Manager To "Release" and not "Destroy"
We often use the IDestroyable interface to provide us with a standardized
way to break internal references and tear-down objects, however many
objects don't need this to be async. Once using IDestroyable, everyone
must assume that you must be async.

This change introduces IReleasable, a sibling to IDestryable, which
provides the |release| method. IReleasable is the synchronous version of
IDestroyable.

This change converts EventManager from IDestroyable to IReleasable as
the first of many conversions.

Change-Id: Ic3e90e594abc1c7326eccbe2521eb71676b74a09
2019-01-24 01:11:38 +00:00
Sandra Lokshina 40afb00f20 Add spacer element to the UI.
Issue #1673.

Change-Id: I8e01366f82e5e7d3b9365d8387f02eede877ad07
2019-01-18 21:48:31 +00:00
Aaron Vaage e2d0e8c562 Model Stall Detection On Its Own
While looking into a bug that involved stalling content, I found it
hard to keep the separation between stalls and gaps straight in the
code.

To help make it easier, I tried moving the stall code into its own
class (but used by the previously owning class).

During this change, an edge case was found, when paused for a while,
when we start playing again we see that as a stall. To avoid this,
we reset our stall duration so that once we start playing again, it
won't think it was stalled.

Change-Id: Ia6055e56e12ae4bc02063eeb6bbf6ffe472c2cb5
2019-01-18 18:52:56 +00:00
Sandra Lokshina 121b615c3e Break UI into components design.
What's already done:
- UIElement and IUIElement interface
- All elements register themselves with controls
- Each element is responsible for its' behavior
- A bit of clean up with constants/enums moving to
their own files

What is not done yet:
- Overflow menu is a dumping ground now. Its'
elements will move to the UIElement model eventually, too.
- Build files are hacked a bit and will need more attention.
- No clean up has been done except for the constants/enums.

Change-Id: I9917aa705e85158a2f26830bd988552fe177e53b
2019-01-17 21:58:12 +00:00
Michelle Zhuo e89d827717 UI Text Displayer
Adding a custom text displayer at the UI layer to show captions.

Issue #1708

Change-Id: I2aa681459b15d667ab5da7aea195a63e2573c1be
2019-01-17 18:34:32 +00:00
Aaron Vaage 0fb5805beb Create Stats Class
This change defines a class to make it easier to track and return our
external stats record.

We have an external stats type used to communicate internal details about
what is happening during playback. The code for creating and updating the
stats was all in Player. With our src= work, only some of this data will
be trackable. To help, this change defines an internal stats class that
handles partial updates and then creates the external stats type when
requested.

This CL moves some complexity out of player, allowing the player to
focus on providing meaning while the Stat's object focuses on tracking
and storing it.

Change-Id: I8c19c98fde26c198566f33f6cbfead2826e39053
2019-01-11 01:23:28 +00:00
Aaron Vaage 161464b802 Define Deprecation Tools
Define a set of tools that we can use to track, test, and communicate
features that are being deprecated.

When you want to communicate that a feature is now deprecated, you just
need to put:
  ```
  shaka.Deprecate.enforce(MAJOR_VERSION_NUMBER,
                          MINOR_VERSION_NUMBER,
                          'Your message about what is being deprecated');
  ```

This will now print warnings when the feature is waiting to be removed and
print errors and fail asserts when the expiration has passed.

Change-Id: Ic66c53ecdfba7922cf961c7f588ab06beceb16ac
2018-12-12 00:26:50 +00:00
Aaron Vaage 0dbd2d2a4e Define Deprecation Version Class
Define class that will be used by the deprecation system for handling
library versions. We are only going to support deprecating at a
minor-version number level. We are able to use this to our advantage
when implementing Version as it makes the code MUCH simpler.

Change-Id: I041bc8d7c20a277d84fb621479b3116e3751e319
2018-12-12 00:26:50 +00:00
Aaron Vaage 4167b1658b Isolate Platform Checks
To make it easier to know where we are check what platform something is
(normally a sign of a work-around), this change isolates the logic to
make the check into functions.

Now looking for uses of |shaka.util.Platform| should show when we are
using platform-specific logic.

Change-Id: Ief49837c503e951f7138ec08a83355fe1c46db88
2018-12-11 05:43:52 +00:00
Michelle Zhuo bcd10c272e Refactor for Caption Parser
Similar to Transmuxer, adding a Caption Parser class as a wrapper of
mux.js's Caption Parser, and move all relevant operations from Media
Source Engine to Caption Parser wrapper class.

Issue: #1404

Change-Id: Iaafa22a963b53315e1f7ae52a5fe17a4cd3f2bde
2018-12-06 01:26:52 +00:00
Sandra Lokshina 6b1ca2d229 Initial release of Shaka Player UI
Other contributors:
 - @joeyparrish
 - @michellezhuogg
 - @TheModMaker
 - @theodab
 - @vaage

Change-Id: If6df33d9ab5035d1ead4402004f7de37ee8470f4
2018-11-16 14:40:37 -08:00