795 Commits

Author SHA1 Message Date
tonihei
51a88ac59d Add Moto C+ to surface switching workaround.
Issue:#3835

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185501181
2018-02-16 11:50:05 +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
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
eguven
2c2aaf0a4b Make SegmentDownloadAction constructor keys parameter simpler
Removed option to pass null keys parameter.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185134822
2018-02-16 11:42:21 +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
aquilescanta
a9e11e4107 Extend support of 608 captions in SEI messages
Issue:#3816

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185124378
2018-02-16 11:40:20 +00:00
andrewlewis
34a318d348 Check sys.display-size on Philips ATVs
Device models are from
https://support.google.com/googleplay/answer/1727131?hl=en. It looks like among
these devices Build.MANUFACTURER can be set to either "PHILIPS" or "Philips",
based on looking at internal bug reports.

Issue: #3807

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185121182
2018-02-16 11:39:15 +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
tonihei
81eed7c2c3 Support isAtomic flag in DynamicConcatenatingMediaSource.
This feature is supported in the ConcatenatingMediaSource and is easily copied to this
media source. Also adding tests to check whether the atomic property works in normal
concatenation and in also in nested use.

Also fixes a bug where timeline methods of the DeferredTimeline were not correctly
forwarded.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184526881
2018-02-08 14:49:00 +00:00
tonihei
4437de4818 Fix potential media source release before media period release.
This could happen when a media source is removed from a
DynamicConcatenatingMediaSource and one of its media periods is still active.
This media period is only removed by the player after the player received
a timeline update and thus we shouldn't release the removed child source
as long as it has active media periods.

Issue:#3796

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184522836
2018-02-08 14:49:00 +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
eguven
de293af3a4 Fix not thread safe static buffer usage
DefaultExtractorInput.SCRATCH_SPACE buffer is used to skip data by
reading it into this buffer and discarding.

Simultaneous use of skip methods corrupts this buffer. Normally the
read data is discarded so it doesn't matter but the underlying
DataSource may use the buffer too. If it's a CacheDataSource it uses
this buffer to read data from upstream then write to cache.

Issue: #3762

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184502170
2018-02-08 14:49:00 +00:00
andrewlewis
e437248f4f Refer to E-AC3 JOC rather than Atmos in MIME type/comments
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184501752
2018-02-08 14:49:00 +00:00
andrewlewis
75574928e5 Only override gapless data if set in ClippingMediaPeriod
This avoids reading a format that is not equal because of switching between
NO_VALUE and 0.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184298076
2018-02-08 14:49:00 +00:00
andrewlewis
0b2497799f Interrupt the test thread for uncaught errors
This makes assertion errors in code running on the Looper less easy to miss.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184294290
2018-02-08 14:49:00 +00:00
andrewlewis
10033623e7 Handle repeat mode/shuffle mode changes in MediaPeriodQueue
This should be a no-op change.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184150266
2018-02-08 14:49:00 +00:00
eguven
a075b23893 Fix API level 16 method use without guard and refactoring
For below API level 16, the logic copied from ConnectivityManagerCompat.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184131406
2018-02-08 14:49:00 +00:00
eguven
e1dbaf26c2 Add DownloadNotificationHelper
Helper class to create notifications for downloads using DownloadManager.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183225948
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
tonihei
c8f39fe14d Update ExoPlayer doc to specifically discourage parallel access instead of allowing it.
Even if a developer synchronizes every method, thread safety is still not guaranteed
because the internal callback methods can't be synced from outside.

Issue:#3773

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184122072
2018-02-01 15:30:00 +00:00
olly
51963dea2e Clean up message naming in EPII
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184122057
2018-02-01 15:28:30 +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
e8fb3078d6 Normalize language code independently of device language
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184120873
2018-02-01 15:25:31 +00:00
olly
696ebf3ded Suppress proguard notes about unresolved classes
In the case of the components we deliberately access via
reflection, it's normal that they might not be resolved
due to proguarding (i.e. if the app isn't being built to
include them). Don't note their omission.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184120611
2018-02-01 15:24:00 +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
6ee87b7ad9 Remove static imports of constants with API level > 14
I think (?) they're harmless, but lint doesn't like them.
Using them within the class body means the TargetApi
annotation applies, which makes lint happy.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184117951
2018-02-01 15:16:45 +00:00
hoangtc
4f36ab203f Use new MediaCodec APIs in MediaCodecRenderer.
In MediaCodecRenderer, we currently uses codec.getInput/OutputBuffers event
though these APIs are deprecated and are not recommended from API 21+. This
change makes sure that:
- On API 20 and below, we will keep using codec.getInput/OutputBuffers.
- On API 21+, we will use getInput/OutputBuffer(index) APIs instead.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184112329
2018-02-01 15:15:20 +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
tonihei
cb95f7e95b Make remaining media source reusable.
This make sure all media sources can be reprepared after being released.

Issue:#3498

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183990416
2018-02-01 15:07:49 +00:00
tonihei
286977998d Fix bug in DynamicConcatenatingMediaSource at dynamic changes of empty timelines.
When the dynamic media source contains multiple empty timelines in a row and some
of them dynamically change to a non-empty timeline, the window and period indices
are not updated correctly because the index of the changed child source is wrong.

To fix this bug, the child index is added to the media period holder to have direct
access on the current child index to prevent ambiguity.

Furthermore, the uid is changed to be the hash code of the MediaSourceHolder not the
MediaSource itself to allow adding the same MediaSource twice without violating the
unique uid policy.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183973462
2018-02-01 15:06:18 +00:00
tonihei
17edae6528 Make AdsMediaSource reusable.
Also fixes a bug where deferred media periods were kept in the list for
an unprepared media source although the media period was already released.

Issue:#3498

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183800889
2018-02-01 15:03:26 +00:00
eguven
6709dc7f64 Enable caching for data loaded by ParsingLoadable
This enables caching manifest files for DASH, HLS and SmoothStreaming.

To disable caching a non cache DataSource should be provided for reading
manifest to the used MediaSource.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183794252
2018-02-01 15:02:01 +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
eguven
1dde2adbf3 Add SegmentDownloader.getAllRepresentationKeys method
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183656655
2018-02-01 14:59:11 +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
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
olly
e26dc3990d Partially revert "Tell LoadControl whether playback can start"
- Renderers becoming ready is asynchronous, so the change wasn't
well thought through :(.
- This will bring back the possibility of getting stuck in the
buffering-but-not-loading anything state. This will need to be
addressed in a future CL.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183646837
2018-02-01 14:50:40 +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
olly
67a812c1c2 Make FakeRenderer more realistic
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183643457
2018-02-01 14:47:36 +00:00
tonihei
f581acbf5d Allow reusing SingleSampleMediaSource.
GitHub:#3498

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183391117
2018-02-01 14:39:48 +00:00
andrewlewis
de8d402aa6 Merge MediaPeriodInfoSequence into MediaPeriodQueue
MediaPeriodInfoSequence has functionality for determining what MediaPeriod
should be loaded next. Move this into the queue as an initial step towards
moving logic concerning updating the queue of media periods out of
ExoPlayerImplInternal.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183391114
2018-02-01 14:37:58 +00:00
aquilescanta
8ba3335145 Use long segment indices for DASH
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183389701
2018-02-01 14:34:41 +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
tonihei
ea21f72c62 Allow reusing ExtractorMediaSource.
GitHub:#3498

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183378776
2018-02-01 14:31:44 +00:00
aquilescanta
677fc291cf Use long for HLS media sequences
Issue:#3747

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183366339
2018-02-01 14:25:01 +00:00
andrewlewis
f402a84dfa Group Timeline.getPeriod overloads
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183238240
2018-02-01 14:19:41 +00:00
olly
23ff4efda1 Tell LoadControl whether playback can start
- This gives LoadControl enough information in shouldContinueLoading
  to know whether returning false will result in a terminal non-playback
  state.
- DefaultLoadControl will always return true when returning false will
  result in a terminal non-playback state, unless the target buffer size
  is exceeded. This can help to avoid getting stuck in the case that a
  MediaPeriod is providing samples from an unexpected starting time.
- Make the terminal state actually terminal. Previously the player would
  end up in an indefinite buffering state. We now fail with an error.
- Also remove the opportunity for LoadControl implementations to livelock
  playback. No sane LoadControl should simultaneously tell the player that
  it doesn't want to load anything and that it doesn't want to start
  playback. So this change removes the opportunity and starts playback in
  EPII instead in this case.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183114797
2018-01-24 20:01:02 +00:00