739 Commits

Author SHA1 Message Date
tonihei
985160a47d Use BaseDataSource for all internal leaf data sources.
This allows all leaf data sources (i.e. ones which do not forward the requests
to other data sources) to accept multiple listeners.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=203097587
2018-07-06 14:23:02 +01:00
olly
e48b712a32 Fail tests quickly if they don't start within the host activity
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=202965785
2018-07-03 11:58:20 +01:00
tonihei
c8af6d176f Forward queue of media chunks to getNextChunk.
This allows to use this queue in the track selection in the future.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=202954871
2018-07-03 11:57:26 +01:00
tonihei
98afaa60d0 Forward TransferListener to media sources.
In the future, this allows to register the BandwidthMeter (managed by the player)
as a listener to all media transfers related to this media source.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=202643946
2018-07-03 11:47:15 +01:00
hoangtc
a916ad6a50 Refactor, move MetadataRetrieverTestRunner to testutil package.
- Make it looks more natural to have MetadataRetrieverTestRunner in the same
package as ExoPlayerTestRunner.
- Change moe_config script to remove the file MetadataRetrieverTestRunner,
instead of the folder.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=202626238
2018-06-29 12:10:54 +01:00
tonihei
dd14500eba Add url (after redirection) to LoadEventInfo.
This url is readily available when creating media source events (from the
data source) but so far not published to external listeners. This change
adds a new field to LoadEventInfo which corresponds to DataSource.getUri().

Issue:#2054

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=202459049
2018-06-28 16:18:50 +01:00
hoangtc
eb8c686243 Fix a bug with MetadataRetriever getMedatadata query.
When getMedatadata from an ExtractorMediaPeriod, due to the MediaPeriod refreshing its Timeline twice, the MetadataRetriever may wrongly reset periodIndex of the current trackGroup to C.TIME_UNSET, which makes it unable to handle subsequent metadata queries.

This CL changes the MetadataRetriever to keep track of periodUid of the current trackGroup instead of period index. PeriodUid is not changed on timeline refreshing, so is not prone the existing problem.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=201969350
2018-06-25 22:37:15 +01:00
tonihei
156e2317cc Deprecate Player.DefaultEventListener in favor of default no-ops in interface.
The DefaultEventListener was added for selective overrides. Now that Java 8
support is enabled, these selective listener overrides can be implemented
more easily and more flexible using default methods.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=201695490
2018-06-22 17:49:25 +01:00
hoangtc
8dbec616c4 Use isAtLeast() instead of (>=) to make the tests clearer.
Replace assertThat(a >= b).isTrue() with assertThat(a).isAtLeast(b) because it
reads more natural, and in case the assertion fails, it will print out the
actual values to help debugging.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=201371993
2018-06-20 18:34:22 +01:00
tonihei
4f2b596062 Allow to specify player looper at the time of ExoPlayer creation.
Currently, the looper of the thread the player is created on is used (or the
main looper if this thread doesn't have a looper). To allow more control over
the threading, this change lets users specificy the looper which must be used
to call player methods and which is used for event callbacks.

Issue:#4278

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=201331564
2018-06-20 18:05:52 +01:00
hoangtc
3d3ab1f72e Add VideoRendererOutputCapturer
Added a capturer that can capture output from video renderer into bitmaps. This
class uses SurfaceCapturer to setup a surface, then configures this surface as the
output for a video renderer. Once the output is set, it will capture the
output frames from the video renderer and return them as bitmaps.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=201148184
2018-06-20 18:00:03 +01:00
hoangtc
a0b4e58312 Update PixelCopySurfaceCapturerV24, uses only 1 copy step.
Currently, we are using 2 copy steps for PixelCopySurfaceCapturerV24:
- Copy from the source surface to a similarly sized bitmap (using PixelCopy API).
- Copy from the bitmap to a scaled bitmap, based on the given output size, using scaledBitmap API.
This CL merges the 2 steps and uses PixelCopy API to perform copy directly from
the source surface to the bitmap of the given output size.
However, since our test uses scaledBitmap API to create reference bitmap from original image, due to various Bitmap copy optimizations (filtering, antialiasing etc...) that are different between PixelCopy API and scaledBitmap API implementations, the result images cannot be the same. We can perform the our tests by asserting that their PSNR value is very high, which means they are very similar.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=199472005
2018-06-06 19:00:37 +01:00
tonihei
b6113763b4 Allow lazy preparation of child source in a concatenation.
This adds an optional parameter to ConcatenatingMediaSource to prepare
child sources only lazily when are needed. This is helpful for long playlists
of media sources with manifests to prevent a lot of simultaneous manifest
loads.

Issue:#3972

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=198855676
2018-06-05 12:33:31 +01:00
tonihei
27f009d239 Enable Java 8 support.
This enables compiler support for Java 8 features.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=198709705
2018-06-05 12:29:14 +01:00
hoangtc
0cb34dcd1c Add SurfaceCapturer base class, and provide the first implementation
Use PixelCopy API for the first SurfaceCapturer implementation. This supports
devices from API 24+.

Github: #3609.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=197732711
2018-06-05 12:19:00 +01:00
tonihei
2b9c31a14f Add MediaSource and DataSource to inject playback nonce into URLs.
A new playback nonce is created for each playback of the same item. Thus we
need to inject the nonce dynamically into the data source factory.

This CL adds the DataSource which does the actual insertion into the request
URLs and a MediaSource which listens to new media periods, to request the
nonce and to configure the data source factory for this media period to use
this nonce.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=197134217
2018-05-18 15:04:55 +01:00
hoangtc
972304f16b Supports seeking for FLAC files without a SEEKTABLE.
Currently, ExoPlayer only supports seeking for FLAC files with a SEEKTABLE.
This CL adds support seeking for cases when the FLAC files do not have a
SEEKTABLE by searching for individual frames within the file using binary
search.

Github: #1088.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=196816398
2018-05-18 15:04:55 +01:00
olly
7d6b0e1fda Move renderer flags, overrides and tunneling ID into Parameters
- This is needed to make DefaultTrackSelector properly thread
  safe, and enable atomic changes to the selector that, for
  example, disable a renderer and enable another one at the same
  time.

- This change also saves/restores parameters and the start
  position in PlayerActivity, resolving the ref'd issue.

Issue: #3915

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=193913350
2018-05-07 05:56:48 +01:00
tonihei
92dd708ef8 Automated g4 rollback of changelist 192816182.
*** Reason for rollback ***

Added the missing initialization to Timeline.EMPTY.

*** Original change description ***

Automated g4 rollback of changelist 192742299.

*** Reason for rollback ***

Culprit for b/78018932.

*** Original change description ***

Auto-register analytics collector in SimpleExoPlayer.

This automatically registers and deregisters an analytics collector in
SimpleExoPlayer. Doing this also allows to write integration tests checking
whether the reported window indices and media period ids are correct.

***

***

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=193006701
2018-04-16 10:55:42 +01:00
falhassen
752b90027c Automated g4 rollback of changelist 192742299.
*** Reason for rollback ***

Culprit for b/78018932.

*** Original change description ***

Auto-register analytics collector in SimpleExoPlayer.

This automatically registers and deregisters an analytics collector in
SimpleExoPlayer. Doing this also allows to write integration tests checking
whether the reported window indices and media period ids are correct.

***

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=192816182
2018-04-16 10:54:28 +01:00
tonihei
b4a3385a6f Auto-register analytics collector in SimpleExoPlayer.
This automatically registers and deregisters an analytics collector in
SimpleExoPlayer. Doing this also allows to write integration tests checking
whether the reported window indices and media period ids are correct.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=192742299
2018-04-16 10:44:05 +01:00
olly
3568dca3b1 Make tests use DefaultTrackSelector
Issue: #3915

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=192259167
2018-04-11 00:29:53 +01:00
tonihei
66d2b76a6c Remove test max SDK version overrides.
These don't seem to be needed anymore. All tests run without them in gradle
and Blaze.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=191867518
2018-04-08 16:39:57 +01:00
tonihei
6b82d1c2bd Add setters to MediaSource factories for custom window tag.
This field (formerly "id") is almost impossible to use so far. Having setters
in the factories allows to specify custom tags for all media sources.

Also added a ExoPlayer.getCurrentTag() method to retrieve the tag of the
currently playing media source in a convenient way.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=191738754
2018-04-07 19:12:21 +01:00
olly
8b5a34769f Remove unnecessary line from test manifests
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=191409777
2018-04-03 15:30:40 +01:00
tonihei
a71a87af5c Amend WaitForTimelineChange action to allow waiting for arbitrary timeline.
In some situations, the timeline can't be specified because it is created
internally by the media source under test. If the test still needs to wait for
a timeline update, this change allows to do that by specifying an expected
timeline of null.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190768386
2018-03-29 13:35:33 +01:00
aquilescanta
f0bb6bb263 Make MediaPeriod implementations compliant with its specification
Currently, MediaPeriod states that continueLoading may be called
during preparation. Some implementations would throw an error if
this happened.

Also make MediaPeriod documentation clearer.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190596870
2018-03-28 00:52:04 +01:00
tonihei
3cbe91a3b0 Pass DrmSessionManager through SimpleExoPlayer.
This will allow SimpleExoPlayer to auto-register its own listener before the
drm session manager is used to set-up the renderers.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190478174
2018-03-28 00:43:07 +01:00
tonihei
6c0d676050 Add callbacks for media period life cycle.
This adds callbacks for creating, releasing, and starting to read from media
periods.

Such events allow listeners to keep a list of active media periods. This is
useful to determine when no further events for a certain media period are
expected. It also allows listeners to associate renderer events unambigiously
with a reading media period.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190462717
2018-03-28 00:41:29 +01:00
tonihei
eb84b144bf Move window index and media period id out of MediaLoadData again.
This gives the MediaSourceEventListener API a consistent look when new methods are
added which only have a window index and media period id.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190450270
2018-03-28 00:38:09 +01:00
tonihei
c7c9a1e9e4 Send media source events for fake media sources.
This allows to test sending events when using fake media sources.
The FakeMediaSource now simulates a manifest load when being prepared.
And the FakeMediaPeriod simulates a media load when being prepared.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=189205285
2018-03-27 23:58:52 +01:00
tonihei
4f56636328 Add window index and media period id to media source event listener events.
This allows to distinguish between media source events of multi-window and
multi-period media sources. In this change, only media sources currently reporting
events are changed. Proper support in composite sources will be added in a later
change.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=188847366
2018-03-13 15:39:25 +00:00
tonihei
8f952162ff Allow multiple media source event listeners.
This is achieved by moving the listener registration and the creation of the
event dispatcher into BaseMediaSource.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=188461932
2018-03-12 15:15:34 +00:00
tonihei
4e69f71e52 Fix wrong start position in resetInternal.
The start position was set to the old start position instead of the current
playback position. We need to set the start position to the current playback
position to ensure a repreperation with the same media starts from the last
playback position.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=188025439
2018-03-07 15:21:16 +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
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
tonihei
67780bfbc2 Add window sequence number to MediaPeriodId.
All media periods are part of a queue of windows buffered and played by
ExoPlayer. When repeating windows, the current MediaPeriodId is insufficient
to distinguish between the repetitions of the same period. This makes it hard
to see to which media period load events belong to, and it is also difficult to
determine whether two media periods belong to the same logical window or
whether they are part of different repetitions of the same window.

Therefore this change adds a unique sequence number to each window in the
sequence of windows and this sequence number is saved as part of the
MediaPeriodId.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185829509
2018-02-16 12:10:25 +00:00
eguven
c8e950537d Run DownloadManager on a custom thread while testing
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185674707
2018-02-16 12:02:36 +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
tonihei
4916baabf0 Fix bug in media period queue update at dynamic timeline changes.
If the period uid doesn't match, the update procedure currently doesn't
remove the correct periods. This may cause the player to get stuck or to play
the wrong periods.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185129503
2018-02-16 11:41:16 +00:00
andrewlewis
901dd19e3e Fix media period queue updating for ads
Resolve the media period for ad playback when resolving a subsequent period and
when receiving a timeline where the playing period in range (but wasn't before).

Fix the seek position calculation when a current ad must be skipped and is
followed by another ad.

Check MediaPeriodInfos match when checking MediaPeriodHolders, to handle cases
where a future ad should no longer be played. This may involve playing two
content media periods consecutively.

Issue: #3584

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184514558
2018-02-08 14:49:00 +00:00
olly
1950152378 Tweak download notifications
1. Add string for STATE_CANCELED. Lint doesn't like that the
   switch statement on the state IntDef doesn't have a case
   for STATE_CANCELED. May as well add one, even if we're not
   planning on our demo app showing notifications for this
   state.
2. Replace non-human-readable error message with one provided
   by ErrorMessageProvider.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184120892
2018-02-01 15:27:01 +00:00
olly
34b4c52a01 Disable InvalidPackage lint check for testutils
Note this case is special in that JUnit is an actual
compile dependency, as opposed to a testCompile or
androidTestCompile dependency.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184119235
2018-02-01 15:19:40 +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
eguven
168a5d63c5 Remove empty CachedContent in SimpleCache.releaseHoleSpan()
In startReadWrite*() methods a new CachedContent is created if the there
isn't one already for the given key. If the span is release without
writing any content, this fix removes the added CachedContent.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183666821
2018-02-01 15:00:35 +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
tonihei
72d99284c1 Make DynamicConcatenatingMediaSource reusable.
Issue:#3498

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183648419
2018-02-01 14:54:51 +00:00
tonihei
d32181e4e9 Use more realistic timeline window duration for playback unit tests.
100ms is unrealistically short and, for example, causes the player to buffer
many periods ahead when looping.

Previously this was not feasible, because ExoPlayerTest as instrumentation test
actually needed to wait for the realtime playback duration.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183646772
2018-02-01 14:49:12 +00:00