3100 Commits

Author SHA1 Message Date
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
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
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
eguven
f6541b498a Fix FilteringHlsPlaylistParser
Only filter HlsMasterPlaylists.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183394956
2018-02-01 14:42:54 +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
tonihei
e6d25a9cb6 Keep replaced manifest uri in DashMediaSource after release.
This is only allowed for user-replaced manifest uris. If the manifest
itself forwards to another manifest, we keep the original manifest in
case the forwarding changes.

Also removed the initialManifest as it can be simplified by using the
sideloadedManifest indicator.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183376209
2018-02-01 14:29:58 +00:00
tonihei
d418204e26 Allow reusing HlsMediaSource.
GitHub:#3498

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183373647
2018-02-01 14:28:26 +00:00
tonihei
e4a91b9e3d Make SsMediaSource reusable.
GitHub:#3498

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183369041
2018-02-01 14:26:54 +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
tonihei
bc9dbdb49e Make DashMediaSource reusable.
GitHub:#3498

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183253017
2018-02-01 14:23:28 +00:00
hoangtc
3d320e9506 Fix a minor bug in SsMediaSource.
When SsMediaSource loads Manifest, it dispatches loadCompleted event even when
the load is cancelled. This change makes sure SsMediaSource dispatch
loadCancelled event instead.

GitHub: #3754

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183241940
2018-02-01 14:21:21 +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
hoangtc
205055a01f Update ExoPlayer PlayerView, add zoom mode for PlayerView xml attributes
Since AspectRatioFrameLayout supports zoom mode as another resize_mode,
PlayerView's resize mode xml attribute should include this as well.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183237663
2018-02-01 14:17:10 +00:00
eguven
10879e32ba 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-01 14:15:40 +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
aquilescanta
35dad90bea Fix DefaultDrmSessionManager canAcquireSession for offline modes
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183102837
2018-01-24 19:59:43 +00:00
olly
6174d04755 Fix CacheDataSource hold-lock-forever problem
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183098172
2018-01-24 19:58:11 +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
aquilescanta
91cacc29ff Fix SimpleDecoderAudioRenderer processEndOfStream error propagation
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183068548
2018-01-24 19:55:06 +00:00
andrewlewis
b8bb1f642b Move MediaPeriodHolder and MediaPeriodHolderQueue to top level
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183065262
2018-01-24 19:53:16 +00:00
Oliver Woodman
d098effa69 Cleanup merged pull requests 2018-01-24 10:51:05 +00:00
ojw28
4d2e0bf122
Merge pull request #3635 from drhill/dev-v2_24bitpcm
add support in mediacodecaudiorenderer for 24bit pcm to float
2018-01-24 10:40:32 +00:00
ojw28
13b46dab93
Merge pull request #3719 from eneim/improve/raw-resource
Improve raw resource data source (recreated)
2018-01-24 10:40:23 +00:00
olly
a1274591b1 Defer retries for progressive live audio streams
Issue: #1606

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183058160
2018-01-24 10:36:26 +00:00
olly
5dff21e5de Remove part of DemoUtil from demo app
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183056883
2018-01-24 10:34:56 +00:00
eguven
5ce40fa04b Fix CacheDataSource trying to read more after EOS
setBytesRemaining() doesn't work when called after closeCurrentSource()

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182999254
2018-01-24 10:32:00 +00:00
eguven
8b79028880 Add filtering manifest parsers for DASH, HLS and SmoothStreaming
These parsers can be used to get a manifest which includes only the
representations identified by the given keys.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182932874
2018-01-23 19:36:41 +00:00
tonihei
4671c23c4d Migrate ExoPlayerTest to Robolectric.
So far this wasn't possible because Robolectric's Looper and MessageQueue
implementations have multiple shortcomings:
 1. The message loop of new HandlerThreads is an not an actual loop and
    scheduled messages are executed on the thread the message is enqueued
    (not the handler thread).
 2. The scheduler used to replace the message queue is synchronizing all its
    methods. Thus, when a test attempts to add messages to a Handler from
    two different threads, it may easily run into a deadlock.
 3. The scheduler doesn't correctly emulate the order of messages as they
    would be in an actual MessageQueue:
   a. If the message is enqueued on the handler thread, it gets executed
      immediately (and not after all other messages at the same time).
   b. The list of messages is always re-sorted by time, meaning that the
      order of execution for messages at the same time is indeterminate.
 4. Robolectric's SystemClock implementation returns the current scheduler
    time of the main UI thread. So, unless this scheduler is used to add
    messages in the future, the SystemClock time never advances.

This CL adds two helper classes which extend and replace Robolectric's
ShadowLooper and ShadowMessageQueue.
 1. We intercept messages being enqueued or deleted in the message queue.
    Thus Robolectric's faulty scheduler gets never used. Instead, we keep
    a blocking priority queue of messages, sorted first by execution time
    and then by FIFO order to correctly emulate the real MessageQueue.
 2. We also keep a list of deleted messages to know which messages to ignore
    when they come up in the looper.
 3. When a new Looper is started, we override the dummy loop to an actual
    eternal while loop which waits for new messages, checks if they haven't
    been deleted, and runs the messages (similar to what Robolectric's
    MessageQueue would have done at this point).

Because we don't actually use the main UI thread in our tests, we can't rely
on the SystemClock to progress in any sensible manner. To overcome this issue,
we can use the auto-advancing FakeClock also used for the simulation tests.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182912510
2018-01-23 19:30:41 +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
tonihei
32e6cf5509 Remove further potential flakiness from ExoPlayerTest.
These were caused by two issues:
1. The FakeMediaSource can be updated with a new timeline. The setNewSourceInfo
is called from a different thread than prepareSource and both access local
variables without synchronization.
2. For multi-window playback, the FakeRenderer claims that isReady and isEnded
are both set to false if it read the end of the stream. However isReady should be
true because it is able to "render" its data until the end of the stream.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182785169
2018-01-23 19:26:13 +00:00
andrewlewis
d8c61532b6 Group binarySearchFloor overloads
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182770109
2018-01-23 19:24:39 +00:00
hoangtc
a06a670d63 Use same logic for DASH manifest reloading for all cases when manifest is invalid.
When a loaded DASH manifest is invalid (either some periods were removed
illegally, or a manifest for a live event is stale), we will retry using 1
logic:
- Retry loading with back-off up-to a limit.
- Throw a DashManifestExpiredException() if we exceed retry limit.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182770028
2018-01-23 19:23:11 +00:00
eguven
05e55f37eb Fix DashDownloaderTest.testDownloadManifestFailure
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182754993
2018-01-23 19:21:43 +00:00
olly
196f5f7917 Include P8 in setOutputSurfaceWorkaround
Also disable use of dummy surface for devices that require the
workaround. It's only useful in the case that we can use
setOutputSurfaceWorkaround, so if it's disabled the dummy surface
has no purpose (it actually makes things worse by consuming past
the key-frame prior to the current position, which doesn't happen
if you have no surface at all).

Issue: #3724

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182750068
2018-01-23 19:20:16 +00:00
eguven
b3d1635ac4 Fix CacheDataSource and SimpleCache issues
This fixes a very specific case where the data read has non-cached gaps
and a read-only CDS switches to read from upstream in a gap then the
cached data is deleted. When the CDS reaches the end of the gap, it
tries to open the next source. As there is no cached data, it tries to
continue with the already opened upstream data source but as it reached
end of the gap range, the code starts looping.

Also fixes infinite lock which occurs when in the previous case CDS isn't
readonly. It locks the content while filling the gap in the cache. At the
end of the gap, as the following data is deleted it tries to lock the
content for writing but the content is already locked by itself.

The last fix is preventing removal of CachedContent entry from
CachedContentIndex while associated key is locked.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182595426
2018-01-23 19:18:09 +00:00
tonihei
4ba17bb690 Remove potential flakiness from ExoPlayerTest caused by multi-threading.
Some tests in ExoPlayerTest issue commands to the player from the test thread
while the player is actively playing media (playWhenReady=true). Due to the
indeterminate time taken to enqueue the commands on the playback thread, they
may arrive when the player already proceeded to another window or finished
playback.

To ensure the tests are always deterministic, this change pauses playback in
the tests where this may happen before issuing the commands.
Also, for tests where we need to wait for a new window before issuing the
next command, a new action is added which allows to play until a specified
position.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182535096
2018-01-23 19:16:38 +00:00
olly
24f866e788 Fix DashMediaSource NPE
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182534505
2018-01-23 19:15:06 +00:00
aquilescanta
fe1e4fa1f2 Fix preparation of media sources with empty timeline
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182533415
2018-01-23 19:13:39 +00:00
olly
cf27bc84e6 DashMediaSource cleanup
- Get handling of "stale" and "out of sync" manifests so
  they're right next to each other (to be merged)
- Move startLoadingManifest to be next to the methods that
  schedule it, and actually start loading stuff.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182530683
2018-01-23 19:12:10 +00:00
tonihei
9de0123e84 When seeking while player is idle, ensure EPII's position is in sync with EPI.
As soon as the seek gets acknowledged by EPII, EPI returns the actual position
from the playback info again which is set by EPII. Thus, EPII needs to update
the position to reflect the changes expected by EPI.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182515106
2018-01-23 19:10:45 +00:00
bachinger
32f8c2e907 add strings and drawables for fullscreen button
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182512582
2018-01-23 19:09:19 +00:00