Commit Graph

52 Commits

Author SHA1 Message Date
Joey Parrish f86e7208ee style: Re-enable the prefer-spread eslint rule
The prefer-spread rule to prevent use of apply() was disabled, but we
had another custom rule that also prevented the use of apply().  This
re-enables the standard rule.

Issue #2639

Change-Id: Ic3778d7267deb6cd5ed49282ea43bb84ad076060
2020-06-15 23:53:39 +00: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
Joey Parrish 0df39c62b6 Add content metadata methods to CastReceiver
This change adds the following methods on CastReceiver:
 - setContentMetadata(metadata)
 - clearContentMetadata()
 - setContentTitle(title)
 - setContentImage(imageUrl)
 - setContentArtist(artist)

These should be called from the CastReceiver's app data callback.

The title, image, and artist methods cover all the Cast content
metadata fields that have an effect in the Google Home App as of June
2020, and setContentMetadata can be used to set one of several object
formats with many more fields defined in the Cast SDK docs.

See https://developers.google.com/cast/docs/reference/messages and the
definitions of GenericMediaMetadata, MovieMediaMetadata,
TvShowMediaMetadata, and MusicTrackMediaMetadata for details.

This also uses these methods from our cast receiver demo, so our demo
will now set all possible metadata when casting our content library.

Closes #2606

Change-Id: I6386276449dbddd2501cd6e3e52206f7fb30b8fd
2020-06-04 20:59:08 +00:00
Joey Parrish 732b6895f1 Report support for all commands in cast receiver
There is not a separate message for skip forward or skip backward, and
we already support seek.  So there's no obvious reason to claim we
can't support skip forward and skip backward.

Related to #2606

Change-Id: If9a931afa2d6a0d323b561ed9f6500f79fb0d1bd
2020-06-02 19:57:34 -07:00
Joey Parrish b3996ad98b Slight improvement to media info messaging in Cast
The docs for the Cast messages say that duration is optional, so it
seems better to omit it for live content, rather than send back an
absurdly-large number.

Note that this does not seem to affect seeking in live streams.
Seeking in live streams seems to be disallowed by the Google Home app
either way.

Related to #2606

Change-Id: Id7d3911b410489b56643afaaee12102b5d6929a1
2020-06-02 19:57:34 -07:00
Joey Parrish 8c3775ce5e Fix Google Home app scrubber for casted VOD
When we get a GET_STATUS request, we are supposed to send back media
info.  That field is only optional for other requests.

This fixes the scrubber in the Google Home app for VOD content.

Issue #2606

Change-Id: Iceec95f18cf15325b7ee2350a0f30f31edc90560
2020-06-03 00:42:25 +00:00
Joey Parrish c8942ba250 Minor cleanup in cast_receiver.js
Set default value for requestId, to make the call sites look cleaner.

Related to #2606

Change-Id: Ia3527b0bba4395f0f49a354c7002b96dfa57ffc1
2020-06-03 00:42:25 +00:00
Joey Parrish 4dc2c65578 Add type assertions for Errors
In many places, we check error codes on shaka.util.Error.  But the
compiler doesn't know that what is caught in "catch" is that type, so
we add type assertions.

In some cases, we know that other types may also be thrown, so there
are also some runtime checks.  Some of these had to be refactored to
allow the compiler to correctly infer types.

Change-Id: I053bd7e96213c689aae3889315052dd402124690
2020-04-29 10:11:21 -07:00
Theodore Abshire 78756198dd Add enum for player event names.
By having an explicit enum, we can make sure there are no typos in
FakeEvent creation calls. This change also allows the cast proxy and
receiver to proxy events based entirely on the enum; that way, they
do not need to maintain their own independent list of events, that
can potentially fall out of sync (see #2318).

Change-Id: I08fa6653f35d86e87efda7fc822c8988688cfcff
2020-01-07 21:35:23 +00:00
Jacob Trimble 011749e95f Standardize argument comments.
This changes the eslint rule to enforce a strict pattern for the
argument comments.  The comment must appear before the argument and
must be /* foo= */.  This still ignores line comments.

Change-Id: I3afb01c65e1088eda13facb3aeeaa7595a2f5aee
2020-01-06 19:40:52 +00:00
Joey Parrish 64896d70b0 Use shorter license header
This reflects changes in Google's policy on JavaScript license
headers, which should be smaller to avoid increasing the size of the
binary unnecessarily.

This also updates the company name from "Google, Inc" to "Google LLC".

Change-Id: I3f8b9ed3700b6351f43173d50c94d35c333e82b4
2019-11-22 18:18:36 +00:00
Jacob Trimble e2fa4626b5 Decrease time it takes to run tests.
- Reduce times for "short delays".
- Remove backoff delay from networking tests.
- Avoid hard-coding delays in the library.
- Move Storage tests to integration tests since they use indexedDB (and
  take over 200ms each to run).

This reduces the time it takes to run unit tests (with --quick) from
50 seconds to about 6 seconds.  Now all but one unit test finish <100ms.

Change-Id: I88461472a87c4cf750a36d07d07422818e069a4d
2019-06-12 20:53:08 +00:00
Joey Parrish 44d5ec18b7 Fix reading customData from standard Cast LOAD message
In my previous fix, I misread the Cast SDK docs and read this field
from the wrong part of the message.  I did not (and still do not) have
any way to test this feature request from @bojant987.  My mistake was
pointed out to me in this comment:

https://github.com/google/shaka-player/commit/bc91f6c9#r33913938

Closes #1989

Change-Id: I97bff23faae897e08fc270a7aa694ddf48076080
2019-06-12 09:35:45 -07:00
Joey Parrish bc91f6c966 Fix ignored customData from standard Cast LOAD message
Closes #1989

Change-Id: Ifac4874d0fb6a8f2b3aa471a7e81357ff8361284
2019-06-11 19:41:31 +00:00
Jacob Trimble 3da809019b Enable additional ES6 linter rules.
Change-Id: I6861541b27153ba034364a5972a9b086de581cef
2019-06-11 18:35:09 +00:00
Jacob Trimble 43e798870f Misc ES6 conversions.
Issue #1157

Change-Id: Ia25a6cae84575f003980e9694b2769f2976e1342
2019-06-03 15:31:57 +00:00
Theodore Abshire 53474af3c3 Convert CastReceiver to ES6
Change-Id: If9e6afeb08a1aa9c33427571ab1b0f8e2ecf5c7d
2019-05-24 20:07:30 +00:00
Jacob Trimble d5780d401b Fix line length issues for indent fix.
Change-Id: I87d75fd88000f8f9bff7b9f1bf5667ba28f6dd60
2019-05-13 22:31:20 +00:00
Jacob Trimble f130dffcef Enable eslint indentation rule.
This is a fully automated change.  The linter will fail because the
extra indentation caused line-length errors.  These won't be fixed
automatically.  They are fixed in a follow-up to make this one fully
automated.

Change-Id: I4d8cf9c998985add2bcd24a81c8d65495668c4f3
2019-05-13 22:31:09 +00:00
Jacob Trimble 0dd64074b9 Only allow one statement per line.
With the new style rule, we cannot have two statements on the same line.
So we can no longer have an "if" on a single line and we cannot have
an arrow function with a body on the same line as when it is used.
This is mostly a manual change.

Change-Id: I2285202dd5ecbad764308bc725e6d317ff2ee7f0
2019-05-13 22:11:50 +00:00
Jacob Trimble 47daf49f31 Use arrow functions for callbacks.
This is an automated change to convert use of "function" functions
to arrow functions.  This doesn't change all uses of bind() that
could be converted.  This also doesn't remove all "function" functions.

Change-Id: I40ac7d086bcef947a1be083359c8fd1d4499a9c3
2019-05-09 16:40:46 +00:00
Jacob Trimble c81389741f Prefer const over let.
A coming update to the Google eslint config will require using "const"
over "let".  This makes that one change to isolate the big changes.

Change-Id: I7d0974c3ae15c53cc45a6b07bf9f6586e2d34aca
2019-05-08 09:22:10 -07:00
Aaron Vaage 71fb7a03ec Use Timer/DelayedTick instead of setTimeout
This CL limits the use of |setTimeout| by wrapping it in our own timer
class. The timer class makes it easier to track and cancel time-based
events.

To ensure that|setTimeout| is not used outside of our timer classes, the
conformance rules have been updated to only allow |setTimeout| to be
used by our timer classes.

Since |setTimeout| is very similar to |setInterval|, the conformance
rules for |setInternal| rules were updates to reflect more of the logic
behind why we don't want to use |setTimeout| and |setInterval| directly.

Change-Id: Iff5da32a61b515dd2016837fa74a34c04b6c5fd2
2019-03-12 18:52:32 +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
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
Joey Parrish 7091275cbf Replace indexOf with includes, startsWith
This replaces almost every instance of indexOf on both String and
Array.  There are very few places where we really wanted an index.
Mostly, indexOf was used to check for inclusion.

Change-Id: I08e299768b6ffdb4bfc30b39b5d82a058c6d1b56
2018-09-14 19:10:56 +00:00
Aaron Vaage c17114e29f Change |manifestUri| to |assetUri|
In preparation to supporting non-manifest assets, let's change
|manifestUri| to |assetUri| as it is a more broad name.

Issue #816

Change-Id: Ibec761caa8acf173571592ce0a7029af0f60de68
2018-07-25 18:10:39 +00:00
Joey Parrish fd0449d8f7 Re-enable some disabled style rules
This re-enables the following style rules:
  - "block-spacing"
  - "brace-style"
  - "comma-dangle"
  - "comma-spacing"
  - "new-cap"
  - "no-multi-spaces"
  - "no-multiple-empty-lines"
  - "one-var"
  - "padded-blocks"
  - "prefer-rest-params"

Change-Id: I15d616e8d5b88b273ded6128b4f9ad86bdb26bd1
2018-07-09 19:44:56 +00:00
Michelle Zhuo 535de4db84 Refactor: Remove underscore from parameter names
Change-Id: Ie9e6fb59763f454f245175f23c6444f919ba8135
2018-05-08 19:21:51 +00:00
Theodore Abshire 5ae80cc67d Typo fixes and rewording in comments, part 4
This makes a large number of small typo fixes. It also rewords a
number of comments and JSDoc descriptions, and does some
formatting standardization.

This doesn't fix every single issue, but it fixes a lot. Notably,
there were some formatting issues I declined to standardize due to
ambivalence on what the proper standardization would be; for example,
when and where empty lines should show up in JSDoc.

Change-Id: I5904ec91b96417a9ac5e19cb4f7b07a084f26ac8
2018-03-21 17:25:03 +00:00
Theodore Abshire dc17969822 Typo fixes and rewording in comments, part 1
This makes a large number of small typo fixes. It also rewords a
number of comments and JSDoc descriptions, and does some
formatting standardization.

This doesn't fix every single issue, but it fixes a lot. Notably,
there were some formatting issues I declined to standardize due to
ambivalence on what the proper standardization would be; for example,
when and where empty lines should show up in JSDoc.

Change-Id: I048b430e4c0bea2ccb9aec572d5e9ec6b606a87a
2018-03-14 17:59:26 +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
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
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
Jacob Trimble c52884afed Fix 'var' scoping problems.
A follow-up fix changes all 'var' definitions to 'let'.  This fixes
issues caused by it.  One major change is adding brackets to case
statements.  Each case statement is considered in the same scope, so
defining variables in them actually are the same variable.  By adding
brackes to the cases, each case gets its own scope.

Change-Id: I99b1298223786f4df415594a2e64eb31d72b2053
2018-02-13 21:32:57 +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
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 17cf08041b Fix a null exception with CastReceiver.destroy
This causes the cast receiver to ignore further proxy events after
the receiver has been destroyed. This is to prevent errors after
destroy.
This is a nearly inconsequential bug; destroy is only called when
the cast receiver app is about to be unloaded, after all.
However, this change is necessary for integration tests to work.

Change-Id: I7bd9cb0f815e8f0989838c7f205e0475eb1b729b
2017-12-01 13:15:21 -08:00
Jacob Trimble 1224464535 Use goog.DEBUG over COMPILED.
This allows including the extra assertions and logging in the debug
compiled library.

Change-Id: Ie8575a31b428e1985077939169bfae9254e395d5
2017-09-27 11:24:32 -07: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
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
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
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 d97e9829b2 Add missing requires
Caught by an upcoming version of the Closure Compiler

Change-Id: I0f76146c04d7b9d0d433d5f7058c78d806f50384
2016-12-14 14:25:33 -08:00
Joey Parrish 894c56d3c9 Remove suppression of "unnecessaryCasts"
This no longer seems to be needed.

Change-Id: I8f9ed03f97b235d4652930745d4416f6c8f77445
2016-11-04 19:40:55 +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
Andy Hochhaus 6a00ee8a31 Add missing goog.require 2016-07-23 14:42:38 -07:00
Joey Parrish 3def38190e Cleanup cast idle state
This simplifies the logic for idle state, fixes some buggy idle state
transitions, and moves the idle logic into CastReceiver (with a little
support from Player).

Issue #261

Change-Id: Ic2729a4235c746ad46353bdf5dc7b605ab31f3ef
2016-07-07 19:29:07 +00:00
Joey Parrish b2fd1406c1 Fix race between Cast sender and receiver
The sender is always polling video.buffered in the controls.  Before
the first update from the receiver, the sender should see local values
for video.buffered.  However, the receiver was updating volume events
before the first full update, leading the sender to try to access
remote values for video.buffered before they existed.  This caused
uncaught TypeErrors in the controls.

Issue #261

Change-Id: I3836315d136be4584c1140842720919bca5d57e2
2016-07-07 19:28:56 +00:00