Commit Graph

2275 Commits

Author SHA1 Message Date
Joey Parrish d03021603b Make types nullable, use HTMLMediaElement
Non-nullability on some types forces us to use casts everywhere, at
which point the compiler is just trusting us.  So they might as well
be nullable and save us some typing.

Also, change HTMLVideoElement to the more general HTMLMediaElement.

Change-Id: Iaf111835bfbf230b99ad8cd7a7a06a6caffd16bc
2016-02-10 19:00:42 +00:00
Joey Parrish 493438cce5 Infer a missing URI scheme
Uses location to determine what the scheme should be if unspecified.
This is important because it allows us to use URIs that work for
either HTTP or HTTPS hosted apps without mixed content warnings.

Some special sauce was needed to make it testable, since we generally
can't mock location in tests.

Change-Id: I294ac532f1bba80977597e11addd7f585d1e9b79
2016-02-10 19:00:23 +00:00
Joey Parrish 6d57a9181b Improve jasmine/karma formatting of util.Error
Add extra info to util.Error in non-compiled builds so that we have
meaningful stack traces in test failures.

Change-Id: I351d2f65ef764947f8318372a47eeb6f014d7b16
2016-02-09 14:44:59 -08:00
Joey Parrish 63cc420d70 Promise.resolve requires context
This fails on Chrome:

var fn = Promise.resolve;
fn();

But this does not:

var fn = Promise.resolve.bind(Promise);
fn();

It seems that the native implementation of function "Promise.resolve"
needs the context of "Promise" as "this" to execute.

Change-Id: I4e06e6a85f966ef0af2f630da50cbfc60f12ed50
2016-02-09 20:22:10 +00:00
Joey Parrish 17fdcc61b9 Do not assume an initial duration of 0
This brings the MediaSourceEngine integration tests more in line with
reality.

Change-Id: I2a9446071e937e58c3878250aa1ece2c8a750b93
2016-02-09 11:28:36 -08:00
Joey Parrish 489ebfa941 Fix handling of configuration callbacks
Nullable callbacks can't be handled generically, since types won't
match the template.  typeof(null) != typeof(function(){})

- Make customScheme non-nullable.
- Check number of parameters in callbacks.
- Add a test that covers customScheme setting and validation.

Change-Id: I58eb88fc667bfa8ab13a679f1b1eed0c894e3755
2016-02-03 11:16:59 -08:00
Joey Parrish 2226269674 Add configure() to manifest parser
This simplifies the parser constructor and allows config updates after
playback has begun.

Change-Id: I43d53f2e074c1696a1f042961f399514b1afe5d6
2016-02-03 11:10:46 -08:00
Joey Parrish a6a150848e Player configuration
Change-Id: I43298c6bb86399fc10fbd5c201fed0902e0850fa
2016-02-02 18:41:19 -08:00
Jacob Trimble 823fdd7896 Fixed incorrect error reporting in ContentProtection parsing.
DASH sec. 5.8.5.2 states that with the mp4protection scheme, the
@value attribute should be the scheme type.  Rather than verify
the value is correct and ignore it anyway, this simply ignores it
entirely.

Change-Id: Ic1d089aecc1b5444b05cc5021606d9318e727a3a
2016-02-02 14:11:21 -08:00
Jacob Trimble 47a99253b0 Polyfills now register as plugins.
Change-Id: I498bda84d92f2c733f120e1b1c5a0ccae305ba15
2016-02-02 12:11:49 -08:00
Jacob Trimble a7bd6991ba Add ContentProtection parsing to DASH parser.
Now, the DASH parser correctly parses ContentProtection elements
and creates the needed DRM info.

Change-Id: I41c4f24e983895f670fae948343400153525545c
2016-02-02 17:10:25 +00:00
Joey Parrish cf6a74c67f Merge pull request #280 from donato/patch-2
Fix typo
2016-01-30 12:58:51 -06:00
Donato Borrello 5fb0bb4f12 Fix typo
Negotiation was the intended spelling
2016-01-29 17:57:15 -05:00
Joey Parrish 18678f2492 Fix IE11 test failures
This fixes small incompatibilities for IE11:
 - XML parser sometimes fails by throwing rather than returning null
 - bug in Promise polyfill prevented use of Promise.all([null, p])
 - IE11 does not have ArrayBuffer.prototype.slice, used by integration
   tests to clone a buffer in StreamGenerator

Change-Id: I9ace6bd17cd60272f85ce388342ca456f14d04c9
2016-01-29 09:18:07 -08:00
Timothy Drews f8b7b01fb0 Implement byte limits and segment eviction.
* StreamingEngine now limits buffers to a specified byte limit
  and evicts old segments as it appends new ones.

Change-Id: Id3e65bc45e782bf9d1214a6b52df0b92892606cb
2016-01-28 14:23:32 -08:00
Jacob Trimble 78e0b96cb4 Add support for UTCTiming elements in DASH.
Closes #205
Closes #241

Change-Id: Ieb870466bc6c38ee4a4e4919afcf15164cf8e981
2016-01-25 13:22:02 -08:00
Joey Parrish 82e5654636 No optional args in NetworkingEngine.makeRequest
The optional arguments in this convenience function really only help
in the tests.  To avoid some component in the library accidentally
making a request with default retry parameters instead of those
configured by the user, I'm making the retry parameters required.

The optional argument for method is only used once.  To avoid the
temptation to add more positional arguments for other seldom-used
fields, I'm dropping the method argument completely.

Change-Id: Ib0afb5766f68c5505f11372e3b004fc8eaca1223
2016-01-25 12:12:06 -08:00
Jacob Trimble 3cc1a43b8d Added some networking utility functions.
This adds some utility functions to NetworkingEngine for common
actions.  This also cleans up the related unit tests.

Change-Id: I1105b77b6dac3637d566c1a4e2f77004ad705e8b
2016-01-25 09:27:38 -08:00
Joey Parrish b822efcb86 Integrate Player with manifest parsers
Change-Id: I2388c8275a886709b35e7ec600fd6fa1340a6635
2016-01-16 05:10:48 +00:00
Jacob Trimble 7cd09c266a Removed goog.require from test code.
This removed any goog.require from the test code to make it simpler.
Now, shaka-player.uncompiled is required to be loaded before any
tests.  This fixes some dependency problems.

This also moves the utility test code to test/util.

Change-Id: I8991a61fc59c9c03e0143bb0883fd6d166af86c2
2016-01-16 01:19:28 +00:00
Joey Parrish 0b886325ab All response headers should be lowercase
This makes it possible for the few parts of the code which will use
headers to do so without relying on assumptions about case.

Change-Id: I3b1ca57a3d789d18d51b4ee94f0791daf301993f
2016-01-15 15:12:21 -08:00
Joey Parrish 33c957298b Stringify Errors for better reporting in tests
This fixes unreadable test failures like "Failed: [object Object]"

Change-Id: I61d5abf273bd49f9b972c1a7adeab99e459f378d
2016-01-15 22:42:32 +00:00
Timothy Drews a4ff2711f2 Add StreamingEngine and Playhead.
Closes #101
Closes #186

Change-Id: I8d1a8d6c0f8cfb5abdd81a149318377282b2bea0
2016-01-15 14:30:27 -08:00
Joey Parrish 736fe9e799 DRM types
A prelude to a more complete DrmEngine.  Should allow development of
DRM-related DASH parsing to proceed in parallel with DrmEngine
development.

Change-Id: Ie51504955f530898469fcacd897cb51588caa7d4
2016-01-14 13:22:41 -08:00
Joey Parrish 075af4ed4b Detect HTTP 302 redirects
When possible, use xhr.responseURL to detect 302 redirects and make
the information available in the Response object.

Use redirect URI as BaseURL for manifest parsing.

See also #225, #266

Change-Id: Ie24abeb3b8418b3e89fed6666eb525aecd74f03b
2016-01-13 17:20:51 -08:00
Jacob Trimble 54fa88f6f0 Added Dash manifest parser.
b/25851171

Change-Id: I4fbd6410d579899b749b50c8819fa8c17ac80658
2016-01-13 19:29:07 +00:00
Joey Parrish dea1021a9b Restrict SourceBuffer.remove() for IE11
This makes sure that remove() is called in a way that is compatible
with IE11.  For more information, see #251.

Change-Id: Iabe752713ba74c7bf516b4e7b93bc83cfccdd481
2016-01-11 17:46:36 -08:00
Joey Parrish b6a39b3e92 Add throws QuotaExceededError to MediaSourceEngine.append_
Relates to issue #258

Change-Id: Id83b1df13f876e565ad481169af11d65902047d6
2016-01-08 17:04:18 -08:00
Natalie Harris 388466dd6f Move XML parsing functions to XML util class.
Change-Id: Iea7256eff9f2f7a60607743cd6cf95e6762bd961
2016-01-08 23:02:25 +00:00
Donato Borrello 13e21f805d Fix typo, rename registerPlugin to registerScheme
This is a simple change to an out of date comment
2016-01-08 14:22:15 -08:00
Joey Parrish 3bb8f06b7d Require assertion messages
This will enforce messages on assertions, which should make console
logs more useful.

Change-Id: I2cff9e20f630d1d4d46192e2ee317b1942cc7188
2016-01-08 13:29:56 -08:00
Joey Parrish f2ca3a5b53 Move externally-used record types to externs
This is important to avoid renaming properties during compilation so
that applications can inject these types without compiling their code.

This also migrates record typedefs to the new documentation format.
Each record will be annotated with 'property' for each field in the
record.  This results in better output from jsdoc.

Change-Id: Ia877b1e2b333ef7020a85f16bc2469a20879bf94
2016-01-06 12:10:47 -08:00
Joey Parrish e798f060dc Add property docs to internal typedefs
We will be transitioning toward a new way of documenting record
typedefs.  Each record will be annotated with 'property' for each
field in the record.  This results in better output from jsdoc.

This covers all internal record types.  External records will be
handled in a separate CL.

Change-Id: I2ab93015bfc9db01b4b6d474b608709c99fd70cd
2016-01-04 12:36:44 -08:00
Joey Parrish 58003ff9d6 Overhaul build and docs layout
* Move redesign docs to docs/design/
* Put all build output (including closure deps) in dist/
* Restore doc-building scripts
* Fix small doc error in MPD utils

Change-Id: I930f4f976370885b3c3c37c59f1ae7fcc5522413
2016-01-04 12:33:10 -08:00
Timothy Drews 6389338d86 Update Manifest and SegmentIndex documentation.
Change-Id: I84d97b5015073f53d9a2f2b546a4bd775ef8000d
2015-12-18 09:16:20 -08:00
Joey Parrish 6231488784 Add docs to all error codes
b/25306826

Change-Id: I0c00d0f3b92f87175d6009dd986c1bff130524a0
2015-12-17 11:31:10 -08:00
Jacob Trimble 0b4ba1f8f8 Unified naming of variables about URIs.
Renamed variables to only use URI instead of URL.  Also made variable
names plural when referring to an array of choices.

Change-Id: I7bfd5022606d77a3153575d8f13dd1e040331901
2015-12-16 16:37:04 -08:00
Joey Parrish 6876ee08cc Use navigator instead of Navigator.prototype
This fixes support checks on Chrome 26, 27, and 28,
and Opera 15.

Change-Id: Ib33ca28754153679bda41fc3c2f6a37a93ed2c99
2015-12-15 17:37:29 +00:00
Joey Parrish bc7c8b88bd Fix build error for unused require
Change-Id: I9341965f7c9be20412d60556d00a0e52dd30c217
2015-12-14 14:44:15 -08:00
Timothy Drews 7a39dce09e Update SegmentIndex functions within the Manifest.
StreamingEngine will require lookup by position and not
just by time.

Change-Id: Ic0f46173f42aa5e4689687e54c7f5f89779ec855
2015-12-14 17:25:35 +00:00
Joey Parrish 1d1a0fcb46 Enable all compiler errors
This also cleans up compiler errors for:
  - Things required but not used
  - Things used but not required
  - Write-only local variables

We are suppressing the 'unnecessaryCasts' error in specific places
where it is, in fact, necessary to convert between unrelated types
for polyfills and work-alikes.

Change-Id: I155c746116f95383ea0a9caf9239fadccd8601af
2015-12-11 13:30:44 -08:00
Joey Parrish b7fe065419 Add minBufferTime to manifest
This is needed by both the DASH parser and the StreamingEngine.

Change-Id: I7458cbc9f9ee7c4d646e1c491f3966c0012d7bf3
2015-12-10 14:28:44 -08:00
Joey Parrish c9235f859c Add support-testing framework.
Support testing is hierarchical.  Player.support returns an object
mapping out the support present in various parts of the system.

This creates a shell for Player and DrmEngine, and introduces support
tests for MediaSourceEngine, ManifestParser, and DrmEngine.

This also adjusts the way support checks are done for text types, to
allow for expansion into MP4-embedded text types and other segmented
subtitle types.

Text changes related to #150 and #146

Change-Id: I707f01ba52cba6262ee89bee2c1f28d24aca4655
2015-12-10 20:00:22 +00:00
Joey Parrish 3e7014db2b Fix library load and polyfill for old browsers
This will allow support-testing to work on older browsers so that
application developers can still load the library and query for
support to show an appropriate error message.

To accomplish this, we avoid load-time uses of Function.bind, avoid
certain polyfills if modern types are not available, and compile down
to ES3 to avoid errors caused by use of the reserved word "catch" on
Promises.

This has been tested back to IE6, Safari 5.1, iOS 6.0, Firefox 6,
Chrome 15, and Opera 16.

Change-Id: I9deed106a7736758e04452ef85bae40f37c6fe62
2015-12-10 10:49:45 -08:00
Jacob Trimble 5616a47c72 Added Manifest Parser interface.
b/25851171

Change-Id: Ib3f0df9107f81bcf1fa266a980bdf9b5c716210a
2015-12-07 18:11:45 +00:00
Joey Parrish a4b947c9a4 Add @struct to @constructors
Change-Id: I0c4f0468cc0f7632c71ec15e458c9a1d84a2c2af
2015-12-07 18:04:55 +00:00
Joey Parrish 316e4c291f Fix compiled Promise polyfill
Installation of the Promise polyfill was incomplete in compiled mode,
since static methods were not attached to the constructor by the
compiler.

Cherry-picked from v1.6.1.

Change-Id: I304662dfdb88d2fb76fc8c06a23fc6fae2f5b1f1
2015-12-06 22:45:56 +00:00
Joey Parrish c934f426d8 Add new error type
This error type will be used for all internal errors, and will rely
on numeric error codes which can be easily checked by the application.

This also changes PSSH parsing to throw on errors instead of retaining
partial data.

Issue #201
b/25306826

Change-Id: I19d23d99d4ee72cb31fe5f233bac57a3a9cfc283
2015-12-04 10:26:08 -08:00
Joey Parrish 9dbd6e6549 Add messages to all assertions
This makes debugging easier when an assertion fails.

Change-Id: I362e58706c71a12cffcda84dcd0b9ad281c51f30
2015-12-04 02:17:28 +00:00
Jacob Trimble 7e20a8ea68 Updated WebM and MP4 segment index parsers.
* No longer uses FailoverUri.
* Uses string URIs directly.
* WebM now gets the last segment's duration.

Change-Id: I1b17f95c4f3fed4bf7e46964687670860240cc2b
2015-12-04 01:08:04 +00:00