494 Commits

Author SHA1 Message Date
andrewlewis
e9f36f06ec Force rendering a frame every 100 ms
Also remove logic for tracking the next output buffer in LibvpxVideoRenderer, as
this allowed many consecutive frames to be rendered that were actually late
after dropping to keyframe. It looks better to show frames at a consistent
100 ms rate.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=188144739
2018-03-07 15:32:35 +00:00
bachinger
ae421bb50c Add separate interface RatingCallback to handle user ratings.
To support Google Assistant media apps need to support the action
ACTION_SET_RATING. Before this change developers have to use a QueueEditor for
this which does not have any other mandatory actions required for Assistant.
With this change developers can implement the rating action with the
PlaybackPreparer which they need to implement anyway to support Assistant.

https://developer.android.com/guide/topics/media-apps/interacting-with-assistant.html#transport_controls

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=188056722
2018-03-07 15:29:17 +00:00
olly
73048f18c1 Remove "r" from instructions for extension modules
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=188038757
2018-03-07 15:24:33 +00:00
jschlag
cc48b5568c handle errors from vpx_codec_control_ calls in vpx_jni
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=187872692
2018-03-07 15:16:28 +00:00
olly
73b6b20fa3 Improve decoder retention logic.
1. Allow retaining a decoder without any reconfiguration, in addition
   to retaining with reconfiguration (and not retaining)
2. Fix retention logic for video decoders to take into account changing
   ColorInfo
3. Allow retention of audio decoders when possible

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=187500285
2018-03-02 09:27:48 +00:00
tonihei
75c3bfb55c Rename Listener for timeline update to avoid confusion with MediaSourceEventListener.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=187313128
2018-03-02 09:21:28 +00:00
hoangtc
fcb796a80c Migrate ExoPlayer Gradle build files.
- Change 'compile' configuration (deprecared) to using 'implementation'
and 'api' configurations instead.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=187311778
2018-03-02 09:20:02 +00:00
tonihei
2f4a3d2e5d Replace ConcatenatingMediaSource with DynamicConcatenatingMediaSource.
The non-dynamic media source has a strict subset of features of the dynamic one and
thus can be replaced.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=187299432
2018-03-02 09:16:00 +00:00
tonihei
b2c445776a Allow parallel reuse of media sources.
This is achieved by adding a BaseMediaSource which keeps a reference count of the
number of times the source has been prepared and forwards to the actual implementations
only once, such that only minimal changes are needed for each media source.

Issue:#3498

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=187186691
2018-03-02 09:08:28 +00:00
tonihei
b47fb2826b Move extension tests to Robolectric.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=187021822
2018-02-27 11:03:50 +00:00
olly
099cc384a8 Move scheduler into its own top level package
The util package is, in practice, for things that are misc enough
to not warrant their own package. If something is deserving of a
package, it's IMO best placed somewhere else (I know you could
argue it's a util, but you could argue that about almost anything
else as well).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=187010018
2018-02-26 15:41:18 +00:00
andrewlewis
c4f82514bf Fix ImaAdsMediaSource isTopLevelSource
AdsMediaSource must be top-level. Currently the (deprecated) ImaAdsMediaSource
can't be used because it prepares its contained AdsMediaSource as a child
source.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=186990882
2018-02-26 15:41:18 +00:00
olly
fba2b46a8b Fix bad @see Javadoc in CastPlayer
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=186305613
2018-02-20 16:29:55 +00:00
andrewlewis
56c9d023fa Fix content progress updates and position faking
Occasionally the player could transition from playing content to playing an ad
after IMA called playAd. The discontinuity triggered faking the content
position, and the fake position was passed to IMA when content resumed causing
the wrong ad group to be loaded. Fix this by only faking the position if the
player transitions before playAd.

Also fix the calculation of the expected ad group index for a postroll ad, and
wait for the player to transition back from ad to content before passing a
content progress update.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185994229
2018-02-19 13:21:53 +00:00
andrewlewis
6c3b677ddb Catch exceptions in all IMA callbacks
If an exception is thrown in an IMA callback it crashes the process with lots of
logging from WebView (including several stack traces, etc.). This change wraps
ImaAdsLoader code that might throw, skips any remaining ads (as the errors are
not recoverable, in general) and notifies a new load error callback so that the
application can implement its own handling. The intention is to make the loader
robust to unexpected requests from IMA and avoid crashes.

Also handle IMA loading an ad in an ad group that has no available ads. In rare
cases IMA will try to load an ad for which an error was previously notified, so
this drops those load requests allowing playback of the content to continue.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185985850
2018-02-19 13:20:15 +00:00
andrewlewis
0291bc5e2d Fix content progress reporting if there is no preroll
If there was no preroll and the pending content position was set before the
first midroll, the pending content position was never cleared so loading the ad
was never triggered.

Only set a pending content position if we know that we need to trigger playing
an ad for the current position and IMA will poll for an ad (because there is a
midroll ad group). Clearing the pending content position happens when IMA pauses
content to play the ad.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185818315
2018-02-16 12:09:03 +00:00
andrewlewis
344932af75 Fix handling of ad group load errors
IMA sometimes delivers an ad group load error just after the time of the ad
group, which is problematic now that we set the expected ad group index based on
the last returned content progress.

Only update the expected ad group index once we are within a fixed preloading
threshold of the next ad.

Also fix updating the ad group to use the new ad count, and check for ad group
load errors when we have no expected ad group defensively.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185803086
2018-02-16 12:07:43 +00:00
andrewlewis
da08b65f3b Fix handling of ad tags with only preroll and postroll ads
Content progress is only polled if there are midroll ad groups. If the ad tag
had only preroll/postroll ads, the pending content position was not provided to
IMA, which meant that the postroll ad could never play.

Only set the pending content position if there are midroll ads.

Issue: #3715

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185680803
2018-02-16 12:05:07 +00:00
andrewlewis
43cfb08207 Handle VAST_LINEAR_ASSET_MISMATCH
This error marks the current ad group as unplayable.

Issue: #3801

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185663472
2018-02-16 11:57:22 +00:00
andrewlewis
5b6344a006 Skip ads for which the media failed to prepare
Also make ad group skipping more robust. After calling onError for an ad, IMA
will sometimes trigger an ad group load error, so this needs to be handled in a
way that allows some ads to be loaded already for the ad group.

This change also fixes calculation of the expected ad index to take into account
whether the position is being faked to trigger loading an ad or is the actual
player position.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185655844
2018-02-16 11:55:02 +00:00
andrewlewis
4cb2d255ab Fix handling of ad tags where ad groups are out of order
IMA's cue points may not be in order, so sort them. It looks like IMA events use
time ordered ad indices, so it is not necessary to map between the original cue
point order and the time order.

Issue: #3716

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185495798
2018-02-16 11:48:58 +00:00
olly
77ec24ca58 Translation console import
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185409304
2018-02-16 11:47:49 +00:00
tonihei
c14ef75037 Move (almost all) remaining core library instrumentation tests to Robolectric.
There are 4 tests which can't currently be moved:
 - DownloadManagerTest explicitly uses the main looper which isn't easily
   supported because the test runs on this thread.
 - ContentDataSourceTest uses an AssetFileDescriptor which wraps a
   ParcelFileDescriptor. It seems Robolectric doesn't correctly forward the
   inner wrapped file descriptor leading to NPE.
 - CacheContentIndexTest and SimpleCacheSpanTest both work fine with Gradle
   but fail with seemingly valid test failures on Blaze.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185366678
2018-02-16 11:46:34 +00:00
andrewlewis
b6a46fd3ee Set the expected ad group based on the content position
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185139106
2018-02-16 11:44:29 +00:00
andrewlewis
ac2f6cbf98 Move two further methods from Timeline to AdPlaybackState
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185138158
2018-02-16 11:43:31 +00:00
andrewlewis
f432b52111 Link libopus statically with libopusJNI
We now build one .so file for the opus extension in the
internal build, so make the external build work the same way.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184962896
2018-02-08 14:49:00 +00:00
andrewlewis
6fc70149b5 Fix ad group skipping
Allow skipping an ad group when requested by IMA, even if we aren't currently
playing one, to handle cases where no ads in an ad group will load (so IMA
requests resuming content but we never managed to start playing an ad).

Use the known ad group index (rather than the expected one) when handling ad
group load errors. This ensures we skip the right ad group if we notify IMA of
playback errors for every ad in the ad group, then IMA notifies that the ad
group is empty via a load error.

Also make some other miscellaneous small fixes to ads code:

- Avoid warning about unexpected ad group indices more than once.
- Output a warning if the ad count in an ad group decreases.
- Remove unnecessary assertion.
- Fix getting the ad duration for ad indices that haven't loaded yet.
- Allow setting an ad group state to its current value.
- Fix javadoc for setting the ad resume position.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184831495
2018-02-08 14:49:00 +00:00
andrewlewis
165fce4c64 Get the next ad index to play in MediaPeriodQueue
The ad index in the ad group may need to skip over ads that failed to load, so
it can't just be incremented any more.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184812556
2018-02-08 14:49:00 +00:00
aquilescanta
8f81abee86 Prevent "unexpected read attempt" illegal state exception
When using cronet data source, calling read after the end of input has
been read will trigger this.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184667794
2018-02-08 14:49:00 +00:00
andrewlewis
aa63ad3af0 Handle LOG AdEvents for ad group load errors.
If IMA loads an empty VAST document for an ad group it notifies via a LOG
AdEvent. Handle the event by updating the AdPlaybackState accordingly.

The error state will be handled in ExoPlayerImplInternal in a separate change.

Issue: #3584

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184516585
2018-02-08 14:49:00 +00:00
anjalibh
c57210caaf Reduce Libvpx output buffers to 8, to reduce the chances of out of memory errors.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184317120
2018-02-08 14:49:00 +00:00
andrewlewis
451721d4a7 Update internal opus build
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184274139
2018-02-08 14:49:00 +00:00
eguven
b3da82dc1c Open source DownloadService, DownloadManager and related classes
Issue: #2643

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184844484
2018-02-08 14:47:54 +00:00
olly
340501246b Fix dependency in cast extension
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184125114
2018-02-01 15:31:24 +00:00
olly
ca3be996bc Add proper exception checks when returning to native from Java.
The pending exception will be thrown upon returning to Java
from native, but we should return early rather than continuing
to execute the native method to the end so as to avoid undefined
behavior. Note that the return value is irrelevant (because the
pending exception will be thrown).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184119606
2018-02-01 15:22:32 +00:00
olly
1bf4926338 Stop using Map<Integer, X>
Lint recommends switching to SparseArray<X> instead.
This is done for the DASH case. For the Cast case it's
easier to use a switch statement.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184119312
2018-02-01 15:21:08 +00:00
tonihei
430579dcd9 Update developer guide for sending messages again.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184119097
2018-02-01 15:18:13 +00:00
olly
a7d4d2d21c Automated g4 rollback of changelist 184056034.
*** Reason for rollback ***

Broke everything

*** Original change description ***

Clean up message naming in EPII

***

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184061352
2018-02-01 15:13:51 +00:00
olly
2f932bfaf7 Clean up message naming in EPII
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184056034
2018-02-01 15:11:00 +00:00
strobe
fb0b7a7f86 Fix green bar bug
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184022988
2018-02-01 15:09:18 +00:00
aquilescanta
e7ba2caf47 Clear the media queue and stop casting on app pause
Simplifies the app and prevents inconsistent states between
both players and the media queue.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183831329
2018-02-01 15:04:54 +00:00
andrewlewis
b82178ecb4 Make ad state immutable and store state of each ad
Before this change, the ad playback state stored the number of played ads in
each ad group. There was no way to represent that an ad had failed to load (and
it wouldn't be possible just to increment the played ad count to signal a load
error because there might be an unplayed ad before the ad that failed to load).

Represent the state of each ad (unavailable, available, skipped, played, error)
in each ad group. In a later change the player will use this information to
update its loaded MediaPeriods in response to future ads failing to load.

Also make the AdPlaybackState immutable and remove copying/duplication of its
fields in the ad timeline and period.

Issue: #3584

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183655308
2018-02-01 14:57:45 +00:00
olly
0c67a5783f Add descriptions for strings.
For our strings to be translated, we're required to provide
added context in the form of a description, and specify a
maximum length for the translated strings.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183651515
2018-02-01 14:56:18 +00:00
olly
1f6d161d4d Fix proguard configurations
1. When we try and load something via reflection and find the
   class, always throw rather than failing silently if we
   subsequently fail to instantiate an instance. This is
   indicative of a broken proguard setup, and failing silently
   makes it hard to spot.
2. Add library/core proguard configuration to ensure extension
   renderer constructors that we access via reflection are kept.
3. Add demos/main proguard configuration to ensure ImaAdsLoader
   constructor that we access via reflection is kept.
4. Added IMA proguard file to hopefully fix #3723, although I
   wasn't actually able to reproduce the issue.

Issue: #3723

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183648187
2018-02-01 14:52:16 +00:00
aquilescanta
ac630b616c Propagate RemoteMediaClient's current duration to timeline if necessary
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183390851
2018-02-01 14:36:20 +00:00
tonihei
46c4ca7ddb Add CompositeMediaSource to handle common tasks for composite media sources.
This removes some boiler-plate code for compostite sources and will also
simplify resuing media source in the future (because this class can keep track
of child listeners).

Issue:#3498

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183387123
2018-02-01 14:33:15 +00:00
aquilescanta
8716c0ee32 Implement a best-effort DRM session acquisition approach
Try to delay failure for as long as possible. That is, propagate
DRM session failures only after an encrypted buffer arrives or clear
sample playback without session is not allowed.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183076348
2018-01-24 19:56:41 +00:00
Oliver Woodman
c8298e70b1 Update version of rtmp-client to 3.0.1 2018-01-24 10:51:31 +00:00
andrewlewis
d240249b6c Work around missed ad LOADED events
Track the expected next ad group index so that it can be used as a fallback if
IMA does not notify the ad index via a LOADED event.

Also do some miscellaneous minor cleanup (including logging all LOG events, and
logging at debug level where appropriate).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183048612
2018-01-24 10:33:29 +00:00
tonihei
e991a8015b Use Truth instead of framework asserts in all tests.
This achieves two things:
1. All our tests use the same type of assertions.
2. The tests currently run as instrumentation test can be moved to
   Robolectric without changing the assertions.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182910542
2018-01-23 19:29:12 +00:00