Commit Graph

61 Commits

Author SHA1 Message Date
Theodore Abshire c5de6cb115 Add option to force TS transmuxing
Our support for CEA 708 closed captions only works if the container
video file is transmuxed. Because of that, we were not successfully
reading such captions on platforms with native TS support.
This change adds a configuration option to force TS to be transmuxed
even when unnecessary, to account for that situation.
It also adds an integration test to ensure that CEA 708 captions can
be extracted on every platform.

Closes #276

Change-Id: Id8b2a67f2327d1b69c9cdfc443e9592c99baf0db
2018-03-30 11:04:03 -07:00
Theodore Abshire f22a00aba7 Quarantine CastUtils.TimeRanges.deserialize
This test has been flakey on OSX for quite a while, but it was very
occasional, and the likely cause of the flake is unrelated to the test
itself, so it was never really dealt with.
Recently, though, the test has been failing repeatedly on the BuildBot.
This change quarantines the test so that the BuildBot will stop failing.

Issue #1215

Change-Id: I1a721976c277cfb9324b0b3f9cf8eae49b17d1ca
2018-03-28 17:27:34 +00:00
Joey Parrish f48f7fd9c4 Clean up uncaught Promise rejections
- Translate uncaught Promise rejections into test failures
   (Chrome only until the event is more widely implemented)

 - Clean up uncaught Promise rejection caused by exceptions thrown
   after destroy() in:
   - CastProxy
   - CastReceiver
   - NetworkingEngine
   - StreamingEngine

 - Clean up uncaught Promise rejection caused by test cases in:
   - CancelableChain unit tests
   - DrmEngine unit tests
   - StreamingEngine unit and integration tests
   - Player unit and integration tests

 - Speed up rejection in NetworkingEngine when we should not retry

 - Add --delay-tests to test.py, to aid in debugging uncaught
   Promise rejections and other types of async test pollution

Closes #1323

Change-Id: I5a8f5702a22430929babeb071bf6650c52c5ad17
2018-02-28 22:56:12 +00:00
Sandra Lokshina 6aae04ae29 Add setTextDisplayer() method to MediaSourceEngine.
Invoke the new method after a textDisplayer's been created.

Closes #1314.

Change-Id: I19891c845905a5a3509e74a93ebfe9a9c1ea7816
2018-02-22 23:47:40 +00:00
Jacob Trimble 064089152b Remove spacing around object definitions.
This is an automated fix to be inline with Google style guides, this
was created with eslint's --fix option.

Change-Id: I860eecbc8152603e730aa17a1393f16d26b3b6fc
2018-02-21 13:35:00 -08:00
Jacob Trimble 624acc66b8 Add curly braces to all blocks.
Google style guide requires adding curly braces to all block statements
even if it is only has one line.  This fixes it by using eslint's
--fix flag followed by running clang-format to reformat the change.

Change-Id: Idc086c2aa8c02df5ef8b2140a11bfb9128eeb4bd
2018-02-21 11:23:34 -08:00
Joey Parrish b7bcafccc2 Move MediaSource setup to MediaSourceEngine
This isolates MediaSource code without changing the early
initialization of MediaSource, which was designed for low-latency
startup.

Prerequisite for #1087, #880, #997, #816

Change-Id: I61acedd95d73610d3e67436d9c7767d643fe2d29
2018-02-20 18:50:54 +00:00
Jacob Trimble 61fc107be3 Convert 'var' to 'let'/'const' (1 of 9).
This is part of a change to convert all usages of 'var' with either
'let' or 'const'.  This takes a conservative approach for 'const' where
it will only be used for aliases and storing the "original" values in
tests.

Change-Id: I8f857a24e4c1ad336177d23dfed4f4a29d3262d2
2018-02-13 13:40:02 -08:00
Joey Parrish 82357486a6 Replace buggy Promise polyfill
A bug in our Promise polyfill caused issues with the recently-added
AbortableOperation class on IE11.  Since external polyfills for this
are smaller, it is easier to remove ours in favor of a third-party
polyfill.  Applications that wish to support IE11 must now load this
additional polyfill.

We are using the "es6-promise-polyfill" module from npm, but any
compliant polyfill should suffice.

One feature our own polyfill offered was the ability to flush all
Promises, which allowed us to write synchronous unit tests that
simulated async processes.  To get this ability back, we are now
using the "promise-mock" module in our tests.

Getting "promise-mock" to load correctly involved switching from
"requirejs" to "cajon", which builds on requirejs and supports
AMD modules more directly.

Closes #1260

Change-Id: I5de48e88a910736ae5c1897a7a509bc5641acb70
2018-01-30 23:10:04 +00:00
Theodore Abshire be5c80eb6d Standardize feature support checks in tests
This replaces checkWhatever type functions, which are called at the
start of a test, with checkAndRun functions, which are a wrapper
around the test method. This change standardizes our tests, since
checkAndRun functions are used in the db engine tests but not
elsewhere.

Change-Id: I74c7ac6836bbaab15b57fd480dbd6105ddc5ee60
2018-01-26 16:55:44 +00:00
theodab c2ce686fb0 Send MediaInfo message with duration when casting
When casting, the cast dialogue contains information about the current
media, including volume, time, and duration. These values are
synchronized by different messages. We were sending over the
MediaStatus messages that synchronize current time, but were not
including duration in our MediaInfo messages. This caused the cast
dialogue progress bar to not display correctly.
This change makes it so that our MediaInfo messages now include
duration, and we now send over MediaInfo messages in situations where
we did not previously.

Closes #1174

Change-Id: Ic585f3befec9e44ef4e9895d04ddfad6cc5473b3
2018-01-19 22:19:58 +00:00
Joey Parrish 529e97fbf2 [ES6] Configure eslint with Google style checks
Some style rules are temporarily overridden until we can get in
compliance.

Issue #1157

Change-Id: Ie27be6ec6632b7786a1f9ebc32911ba9dcd42599
2018-01-18 00:01:05 +00:00
Joey Parrish a63352c8f3 [ES6] Enable stricter checks in eslint
This digests and organizes many of the automatic settings in eslint,
and changes several of them to be more strict.  This also fixes the
following errors:
  - array-callback-return
  - no-catch-shadow
  - no-multi-spaces
  - no-new
  - no-throw-literal
  - no-useless-call
  - no-useless-concat
  - no-useless-return

Several checks have been organized into a group of checks we should
use, but need more time to implement and fix.  Some other checks have
been delegated to the Closure compiler, which can more precisely
whitelist exceptions.

Issue #1157

Change-Id: I8fe4966959e08050f8159e6a1fee161e7d71177e
2018-01-17 21:56:41 +00:00
theodab 8ed316d3c2 Reduced frequency of some getters on cast updates
Not all values need to be updated twice a second. This change modifies
the list of player getters so that each value also includes an update
frequency, and only updates that property once in that many updates.
This acts as a configurable way to ensure that some properties update
in different amounts, without having to have multiple update timers or
compose multiple update messages in the same timeframe.

Change-Id: I90e75e3e73f6c633d91b1799307ec2b15587327b
2017-12-14 21:02:48 +00:00
theodab 31b2984f6b Stopped proxying getManifest()
getManifest() hugely increased the message size when casting, to the
point where we were having message size problems.
This CL stops that property from being proxied.

This also adds an integration test that makes sure update messages do not get
too large.

Closes #1128

Change-Id: I3c4bfabb4d35ee870a603c38f784cb226366a28b
2017-12-13 22:16:30 +00:00
Joey Parrish bc7b56d971 CastReceiver integration cleanup
Clean up several small things in the new integration test:
  - Do not use the _compiled suffix in test streams, since this test
    does not run against the compiled version of the library
  - Append the video element to the document
  - Set up wrappers in the order in which they will execute
  - Send the init message only after all other setup is complete

Change-Id: I62488474e83c44923ace9c533449794d62bc0f6f
2017-12-08 14:43:55 -08:00
Joey Parrish 5c364df655 Fix CastReceiver integration tests on Chromecast
Because we mocked out canDisplayType to return false, and because that
is actually used on Chromecast in the MediaSource polyfill, this
caused the receiver integration test to fail with
CONTENT_UNSUPPORTED_BY_BROWSER.  Because nothing was listening for
errors, this error was shown only as a timeout.

This fixes the mock and listens for errors.

Change-Id: I05a62c439666cfe1a282aa523a75e362e1674a4b
2017-12-08 22:43:06 +00:00
theodab 5f612bd1d3 Added an integration test for cast receiver
This adds a single integration test for cast receiver, as well as a
framework for adding more in the future.
This particular test pauses at each stage in Player.load where the
player could theoretically be polled to compose an update message, and
waits for an update message to be polled. This should help catch any
further null exceptions in the cast receiver that prevent update
messages from being sent out.

Issue #1162

Change-Id: If24486dd821275ab674960e559bd6d10776955a7
2017-12-06 13:45:17 -08:00
theodab e63b4abd3b Store and re-use session_ in CastSender.
The cast sender API doesn't seem to be able to re-use an existing session
unless you reload the page. This stores the old session, so that it can be
re-used without reloading the page.

In order to enable this, CastProxy.destroy no longer leaves the current session;
I figure if you want to leave the session, you'll call forceDisconnect.
That part I am not fully sure about; perhaps it would be better to have a
separate optional argument about whether or not to leave, or make it a part of
the forceDisconnect argument.

Issue #768

Change-Id: Ie648372cea4b106ff85df3d0dcc563fca5d10d8c
2017-10-05 16:53:49 +00:00
theodab 84bfdd3a5d Remove listeners before destroying CastSender.
Beforehand, calling chrome.cast.session_.destroy() would typically cause an
error, as the message or update listener was called after the the CastSender
was destroyed.
This removes those listeners before destroying.

Issue #768

Change-Id: I7889adce7b829c3f24dac7a178c9be26e2fdc887
2017-10-02 19:46:13 +00:00
theodab f42edbe966 Changed hasReceivers_ into a class variable.
If you call chrome.cast.initialize a second time, it does not error but it
also does not fire off receiverStatusChanged in order to signal the
initial receiver status. This can result in problems if the CastProxy is
destroyed and then re-created; specifically, it will erroneously claim to be
unable to cast until the receiver status next changes.

This makes hasReceivers_ into a class variable, so that a new sender will use
the hasReceivers_ of previous ones.

The original bug report was kind of confusing, so I cannot say for sure if
this actually solves their problem or not. Hopefully it does.

Issue #768

Change-Id: I7839ed99a8c48c69567bbcaeb1f9b6728265d63b
2017-08-30 23:20:16 +00:00
theodab 95d2855b8f Fixed a problem with live-only getters on cast
Beforehand, the Chromecast would poll getPlayheadTimeAsDate and
getPresentationStartTimeAsDate for every update message, which are live-only
getters, even on VOD.
This would cause a lot of error messages in the debug output of the receiver;
we didn't notice this before because we mostly run the receiver in compiled
mode.
This also allowed users to poll those attributes for VODs without any error
messages when casting, since the results of the last update were cached.

This change adds a list of getters that require live; such getters are not added
to state update messages, and are set up with asserts in the sender.
This should solve the problem and slim down our update messages a bit at the
same time.

Change-Id: Ifc0b445def2d85b22fcb9af160dec2205d1faace
2017-08-28 17:57:58 +00:00
theodab 1a68b2b72f Show pause icon if casting to playing ChromeCast
Previously, if you connected to a ChromeCast that is currently playing, the
local interface would continue to show play icons as though the video was
paused.
This makes it so that the cast proxy sends out synthetic play or pause events
after the first state update after joining an existing session.

Change-Id: I1eb4c23f7b58225d361d353aacf0743def2f576c
2017-08-25 04:40:51 +00:00
Jacob Trimble 30450f8cbb Fix Chromecast tests and add missing members.
There was a bug in the cast_utils test that meant that the new members
on Player weren't being detected.  The test should fail when we forget
to add a new member to the list in cast_utils.js.  This updates the
test and adds the new members to the list.

Change-Id: I27c25d07b409b8350b5709c3ce26696d72a6a11d
2017-08-18 17:51:52 +00:00
Joey Parrish 3cd18bb336 Query platform MSE support using "extended" MIME types
Some platforms (such as Chromecast) support extra MIME parameters like
framerate, bitrate, width, height, and channels.  Since other
platforms will ignore these extra parameters, we should always query
using these parameters.

This introduces the framework to construct these "extended" MIME types
from Stream objects.  Extra parameters for other platforms can easily
be added later.

Change-Id: I8936ca93e84068da18f12127fbc8fc1a0646695a
2017-08-17 17:35:00 +00:00
Joey Parrish 6834054906 Remove deprecated methods for v2.2
The getTracks and selectTrack methods have been deprecated since v2.1
and scheduled for removal in v2.2.

Change-Id: I938b3015262d71683ac871c05a9f4c74c96acf50
2017-08-10 18:56:09 +00:00
Jacob Trimble adb8da4764 Disallow unknown properties (1/5).
This is part of adding a new conformance rule to add additional type
safety.  This will disallow using properties of unknown types or using
unknown properties.

The first parts will be fixing errors caused by the new rule.  These
are backwards compatible, so can be applied before the rule is enabled.
Once all the errors and bugs are fixed, the rule will be enabled.

Change-Id: Iefde089b2f62ddfdf43944cda5badab438577561
2017-06-27 19:43:00 +00:00
Jacob Trimble d8a3d8d2f7 Change jasmine.Spy type definition.
The old definition using a union with a Function causes problems.  The
compiler tends to treat this as an unknown type, so we loose type
safety.  The new types ensure full type safety, at the cost of needing
to "convert" the spy when it is used as a function.

Change-Id: I98ebd9dffd9cb865d0cf5d03db0fb5d6ea001ed3
2017-06-27 12:18:48 -07:00
Joey Parrish 80251cdf91 Fix DRM test errors on IE and Edge
Somehow, errors thrown by CastReceiver unit test setup caused DRM
tests on IE and Edge to fail.  This cleans up the Cast tests to fix
these uncaught errors that somehow polluted the DRM tests.

Change-Id: I435ff994b0b70199eb5a8febd419296b59497920
2017-06-05 20:18:06 +00:00
Sandra Lokshina 843f020008 Chromecast: add support for Media Playback messages.
Media Playback messages are used by generic Chromecast controllers
(Google Home app and the likes). Supporting them is required by
the Chromecast SDK.

Closes #722.

Change-Id: I3c98fb9d63da81b59c2cc82a3e790332fc9bb56e
2017-04-11 19:00:54 +00:00
Aaron Vaage 9a86d0460f Redefining Text Parsing Plugin System
The text parsers were all stateless. This caused problems with MP4
VTT as the timescale is needed later on for other boxes. This changes
parsers to carry state.

How time is referenced with the text parsers is not clear and has
caused confusion. In v2.0.1, we introduced the useRelativeCueTimestamps
option to control the behavior of our WebVTT parser. We decided in #480
(comment) that we would remove this option in v2.1.0. All WebVTT
timestamps in v2.1.0 will be relative to the segment time. This change
creates a new time context interface that will be used to help limit
the confusion around how time is communicated.

Closes #726

Change-Id: I67409608c35d2d5abb8b8b25529859cb37f8f0a8
2017-04-05 13:41:27 -07:00
Jacob Trimble 575f2ad109 Add an indicator for critical errors.
This adds a severity field to Error objects.  This can be used to
detect whether an error is recoverable.  All the same errors are still
reported so the field can be ignored.

There are two possible values:
* RECOVERABLE means that the Player will try to recover from the error
* CRITICAL means the Player will be unable to continue and must call
  load() again

Closes #564

Change-Id: Ie2c5468340c13e7a288b99690ab65b7ecc0a6b29
2017-04-04 23:57:59 +00:00
Jacob Trimble b4d0fa4901 Expose license expiration times through Player.
This adds a method on Player to get the license expiration times for
the current EME sessions.  This also adds the expiration times to the
stored content structure for offline content.  This will update the
stored expiration while playing content (e.g. license duration changes
when playback starts).

Closes #727

Change-Id: I18770a79413423695bbb2ed5f31f6b19038a33d2
2017-04-03 18:25:43 +00:00
Jacob Trimble 67c874c2ca Fix some test contaminations.
There were two instances of tests not cleaning up correctly.  The
Dash Live tests didn't uninstall the Promise polyfill, which breaks
Promise.resolve for tests that don't expect it.  Also, in the
CastReceiver tests, it defines a property on window.  It needs to be
configurable, otherwise it cannot be set twice.  Somehow the resulting
exception is not being caught by jasmine.

Change-Id: I0691a7bcddf14fd455f034d63e12fc8046044750
2017-03-28 12:16:08 -07:00
Sandra Lokshina 0b12937520 Replace content type strings with constansts.
Change-Id: I4fda583915766b40ee7a5c7451d037077d9f2582
2017-03-08 21:41:59 +00:00
Jacob Trimble 6ba6b0631c Consolidate usages of fake video elements.
There are several tests that use fake <video> elements.  All of them
have a createMockVideo method.  This consolidates all of them into a
fake class that also provides more type safety.

Change-Id: I132c3e4a75676594bcefb60d0b115c00ede03067
2017-03-03 19:57:08 +00:00
Jacob Trimble 3253221e99 Add test to verify CastProxy includes every Player member.
Issue #675

Change-Id: I0fe18ea28571ad2dd6c92587e5df345c80b223c6
2017-02-07 12:39:35 -08:00
Sandra Lokshina 23a23b9b36 Make language selection explicit. Split text and variant selection.
Add UI options to select current audio and text language.
Split selectTrack() into selectText() and selectVariant().
Stop automatically disabling ABR manager when a variant is selected.
Add a warning if selectVariant() is called while abr is enabled.

Issue #412.
Issue #626.

Change-Id: I15f1c3c4fdc6d6b641f708fbef19dbcf10cbcfc6
2017-01-18 00:05:52 +00:00
Joey Parrish 1b993ac22a Fix MediaSourceEngine test failures on Chromecast
MediaSourceEngine integration tests were failing on Chromecast due to
pollution of global state by CastUtils tests (video element not
removed, MediaSource object leaked).  By fixing the clean-up in the
CastUtils unit tests, MediaSourceEngine integration tests are now
passing on Chromecast.

This also makes the video clean-up in MediaSource and StreamingEngine
integration tests consistent with the way the library cleans up video
elements in Player.

Change-Id: Id49d40ba1970040c0dd1fc342f2657fc3f5a24b8
2017-01-11 13:48:06 -08:00
Joey Parrish 5fb8b60422 Add support for Chromecast Ultra at 4k
Using a special API available on the Chromecast, determine if we can
do 4k.  If so, raise the hardware limit from 1080p to 4k.

Change-Id: I6e403cce5d9c43a22f1b76cf4d79661ac096dd82
2017-01-11 18:49:01 +00:00
Joey Parrish 2cfaf366e9 Add missing events and methods to cast proxy
The emsg, loading, and unloading events were present in v2.0.0.
The drmInfo, isInProgress, and keySystem method were also present in
v2.0.0.  The getPlayheadTimeAsDate method was introduced in v2.0.1.

None of these were proxied to the cast device until now.  All v2.0.x
events and methods are now being proxied.

Change-Id: I6fba60f4ca451053c1449cafcddd9c1006292ad9
2017-01-07 00:14:41 +00:00
Joey Parrish bcbf1c66ef Fix cast receiver idle behavior
When we replay a video without reloading, the idle card should disappear.

Closes #558

Change-Id: Ib2bca456ad90c8f2b4554f22f1edb920c69c8ada
2016-10-25 00:16:54 +00:00
Sanborn Hilland fff9892373 Add config option for using segment relative timestamps for VTT (#542)
* Add config option for using segment relative timestamps for VTT

Fix for #480

* Make useRelativeCueTimestamps a non-nullable param

* Update tests for the new useRelativeCueTimestamps param

* Move period relative timestamp deprecation warning to vtt parser

* Log warning only if using absolute timestamps in text cue

* Fix vtt text parser test
2016-10-24 11:22:54 -07:00
Joey Parrish 5c4c8f4c1f Offer an API to force disconnect Chromecast
Closes #523

Change-Id: I2a213855479dc23797468757808c05a368d907c6
2016-10-18 18:37:06 +00:00
Sandra Lokshina b335c5a9e3 Delegate disconnecting from chromecast to Chrome.
Show 'stop casting' dialog on chromecast control click when casting.
If user chooses to stop, delegate disconnecting to Chrome.

Related to #261

Change-Id: I3072a3723e0d0d526039946fb45713e20349e54c
2016-09-02 21:00:22 +00:00
Sandra Lokshina 359d2c7299 Add support for casting from the cast button built into Chrome.
Closes #261

Change-Id: I1eb8d673d202d913444746f5adc079fede2f605a
2016-09-01 22:11:56 +00:00
Joey Parrish d0908fe743 Raise the async test timeout to 120s
All tests now have the same timeout value.  This should simplify the
process of addressing timeouts on Safari.

Change-Id: I3b455bd639758007ec8b2b86ef236c56e919c15a
2016-08-11 10:54:49 -07:00
Joey Parrish c6ea804e2a Closure cleanup
* Drop unnecessary type alternation in SegmentIndex unit tests
 * Drop unnecessary bind in StreamingEngine unit tests
 * Drop unnecessary expose annotations in Pssh
 * Add comments about quoted access in cast unit tests
 * Move afterAll() position in cast unit tests
 * Make return type for PublicPromise constructor more specific
 * Define a type for Util.eventLoop return value

Related to PR #421

Change-Id: I092a8ff366b4ac4ea868dd3f4fbe4e3d63a2167f
2016-07-24 16:33:28 -07:00
Joey Parrish 4ccaf23b53 Merge pull request #458 from hochhaus/annotations
Fix JSDoc annotations
2016-07-24 16:21:24 -07:00
Andy Hochhaus 69ad05a63c Fix JSDoc annotations 2016-07-24 11:23:56 -07:00