7207 Commits

Author SHA1 Message Date
krocard
589f50fb22 Move renderer from Player to ExoPlayer
The concept of Renderers is not needed in the
Player interface. Move it to ExoPlayer.

This should not break most users as they use SimpleExoPlayer.

PiperOrigin-RevId: 359220977
2021-02-24 15:46:35 +00:00
olly
19adc43bf1 Contract test for start-position-out-of-range case
Currently, this only asserts that *if* an exception is thrown, it
must be a position-out-of-range exception as determined by
DataSourceException.isCausedByPositionOutOfRange.

Issue: #7326
PiperOrigin-RevId: 359092124
2021-02-24 15:46:19 +00:00
kimvde
32e3f15e8f Fix conditions to enable UI actions
- Ensure consistency between (Styled)PlayerControlView,
  PlayerNotificationManager, TimelineQueueNavigator and
  DefaultControlDispatcher.
- Handle the case where a live stream has ended when enabling previous
  and next actions (window.isLive() is true and window.isDynamic is
  false in that case)

#minor-release

PiperOrigin-RevId: 359063793
2021-02-24 15:46:11 +00:00
olly
d8b5a1d7f4 Contract test for end-position-out-of-range case
Assert that an exception is not thrown from DataSource.open
if the DataSpec's start position is valid but its end position
extends beyond the end of the data.

HTTP based DataSource implementations have no good way of
knowing when this is the case, so it makes sense to make this
the required behaviour, rather than requiring an exception to
be thrown or allowing both.

There are also use cases where the caller may want to use the
end position as an upper bound, without knowing for sure how
long the content is. An example of this use case is wanting to
pre-cache the first N bytes of a stream. This implies that any
exception should be thrown after reading to the end of the
data, rather than preemptively in open.

Issue: #7326
PiperOrigin-RevId: 359063721
2021-02-24 15:46:02 +00:00
olly
c067ee8853 Fix CacheWriter to handle potential DataSink write failures
- If DataSource.close fails then it's unknown whether the underlying file was
  written to the cache. We should assume that it has not been.
- Always re-query cachedBytes at the start of CacheWriter.cache, since its
  current value may be incorrect if a previous failure was the result of a
  file not being written to the cache.

PiperOrigin-RevId: 359039109
2021-02-23 15:06:38 +00:00
gyumin
520f77bef5 Mark convenience methods as final in BasePlayer
PiperOrigin-RevId: 359021944
2021-02-23 15:06:28 +00:00
marcbaechinger
95fcfdd71d Merge pull request #8539 from larryng:patch-1
PiperOrigin-RevId: 359000734
2021-02-23 12:30:31 +00:00
olly
920d2e03e6 Remove unused mocking in CacheWriterTest
#minor-release

PiperOrigin-RevId: 358998449
2021-02-23 12:30:22 +00:00
olly
b4b22d9808 Simplify Resource.isEndOfInputExpected
- Make it a property of the DataSource, not of the resource.
- Apply it only when a contract test reads using an
  unbounded DataSpec.

PiperOrigin-RevId: 358997735
2021-02-23 12:30:14 +00:00
ibaker
7b692f9676 Pass the session state to the onDrmSessionAcquired listener method
PiperOrigin-RevId: 358823166
2021-02-23 12:29:59 +00:00
ibaker
c64a1a0c3c Add tests to CopyOnWriteMultisetTest for modification during iteration
This is a key use-case for copy-on-write collections.

PiperOrigin-RevId: 358807866
2021-02-23 12:29:51 +00:00
ibaker
623597addb De-duplicate DRM acquire & release events by EventDispatcher
When we add DRM pre-acquire support to SampleQueue, we'll dispatch
twice the number of acquire and release events. This is slightly
confusing, since there's the same number of
DrmSessionManager#acquireSession() calls.

We can mitigate this by only dispatching each acquire and release
event to at most one EventDispatcher.

This also changes the events fired when playing a stream with both audio
and video encrypted with the same keys (even without pre-acquisition).

Before: The EventDispatcher would see 2 aquires, 1 key load and 2
release events.

After: The EventDispatcher will see 1 acquire, 1 key load and 1 release.
PiperOrigin-RevId: 358804502
2021-02-23 12:29:43 +00:00
gyumin
0eed19d8a3 Add @Documented to FieldNumber @IntDef
PiperOrigin-RevId: 358799813
2021-02-23 12:29:35 +00:00
ibaker
8d942dc213 Simplify release event logic in DefaultDrmSession
This is a no-op assuming the class is always used correctly.
When release causes referenceCount to reach zero there can be at most
one EventDispatcher still connected (which is the one that must be
passed to that final release() call), so we can always pass the event
directly to the EventDispatcher passed in to release().

PiperOrigin-RevId: 358794004
2021-02-23 12:29:19 +00:00
krocard
399e1365d0 Add missing @Nullable to method override.
Method override parameter nullness should contravariant.

PiperOrigin-RevId: 358772798
2021-02-22 10:35:41 +00:00
tonihei
ceb76f35e9 Align pattern of calling deprecated listener methods.
There are two different patterns we use at the moment:
 1. Call both deprecated and non-deprecated method from call site with
    no default method implementation body.
 2. Use default method of non-deprecated method to call deprecated
    method.

Pattern 1 is easier to reason about as it makes the calls more explicit,
so changing all usages of pattern 2 to pattern 1.

PiperOrigin-RevId: 358769803
2021-02-22 10:35:30 +00:00
ibaker
93a608d507 Static import Assertions methods in DefaultDrmSessionManager
PiperOrigin-RevId: 358384778
2021-02-22 10:35:22 +00:00
ibaker
74ad0949fd Add support for preparing DRM sessions before they're needed
This adds an optional DrmSessionManager#preacquireSession() method
and implements it on DefaultDrmSessionManager.

The manager doesn't promise to keep the preacquired sessions alive, and
will proactively release them if a ResourceBusyException suggests the
device is running out of available sessions in the underlying framework.

In a future change, SampleQueue will preacquire sessions on the loading
thread and keep track of preacquired 'references', releasing them
when seeking or clearing the queue.

Issue: #4133
PiperOrigin-RevId: 358381616
2021-02-22 10:35:14 +00:00
aquilescanta
ecb109dad8 Make MediaParser available for use in progressive media
PiperOrigin-RevId: 358379167
2021-02-22 10:35:06 +00:00
tonihei
1a12018dae Add ConcatenatingMediaSource version that fully combines windows.
The published Timeline contains one window only with all periods of
the child sources.

Issue: #4868
PiperOrigin-RevId: 358150276
2021-02-19 10:58:05 +00:00
tonihei
7830eb7ae5 Ensure non-fatal errors are logged to logcat.
We already report these errors through callbacks to interested listeners.
However, to ease debugging with bugreports and local error detection,
it's helpful to also log these non-fatal execptions to logcat. Otherwise
nothing in logcat indicates that the player recovered from an exception.

Issue: #6384
PiperOrigin-RevId: 357923899
2021-02-19 10:57:49 +00:00
tonihei
f191000e20 Report unexpected discontinuity as non-fatal audio sink error.
This is preferable to just logging to LogCat so that listeners can
report this to analytics systems if required.

Issue: #6384
PiperOrigin-RevId: 357906079
2021-02-19 10:57:41 +00:00
gyumin
dea6a67ce9 Remove nullable utility methods in Bundleable
PiperOrigin-RevId: 357845774
2021-02-19 10:57:32 +00:00
olly
2e5e1e7c0f SilenceSampleStream.readData: Handle flags-only buffers
The SampleStream.readData contract is that when reading a sample
with a flags-only buffer, the buffer timestamp and flags should
be set and the read position should not be advanced.

#minor-release

PiperOrigin-RevId: 357842130
2021-02-19 10:57:24 +00:00
olly
5da9fd83e9 Improve documentation of StreamStream/SampleQueue read methods
PiperOrigin-RevId: 357734165
2021-02-19 10:57:16 +00:00
olly
1a34de5954 Add plumbing for reporting internal decoder errors
PiperOrigin-RevId: 357732695
2021-02-19 10:57:08 +00:00
gyumin
2326b56132 Implement Bundleable for MediaItem and MediaMetadata
PiperOrigin-RevId: 357656504
2021-02-19 10:56:52 +00:00
olly
9de6a75891 Remove dynamic data from ExoTrackSelection.Definition
PiperOrigin-RevId: 357587767
2021-02-19 10:56:44 +00:00
olly
abaf1e10a2 Respectful language cleanup
PiperOrigin-RevId: 357587009
2021-02-19 10:56:35 +00:00
olly
7f5b5c9b6d Add static TrackSelection type
This type is different to the selection reason, which is
dynamic (i.e., corresponds to the individual selected track,
which can change during playback). The static type is
exposed via TrackSelection, where-as the selection reason
will be internal to the core (i.e., player) module.

PiperOrigin-RevId: 357578201
2021-02-19 10:56:27 +00:00
olly
ff46a87d39 Remove track selection override reason and data
These have limited value, and are confusing because they're only
actually used if the override only selects a single track (if the
override is an adaptive selection then the values are never used).
The simpliest path forward is to remove them.

PiperOrigin-RevId: 357573186
2021-02-19 10:56:10 +00:00
olly
f52e4bed3d Don't clear audioSessionId when audio disabled
Issue: #8585
#minor-release
PiperOrigin-RevId: 357553237
2021-02-19 10:55:54 +00:00
olly
1b6dd40aa5 Move Spherical UI components to the UI module
PiperOrigin-RevId: 357549002
2021-02-19 10:55:46 +00:00
gyumin
6a642ec58b Generalize exception thrown by fromBundle
It allows Bundleable classes throw a RuntimeException which is broader
than IAE. Now, Bundleable implementation may utilize checkNotNull for
brevity.

PiperOrigin-RevId: 357546375
2021-02-19 10:55:37 +00:00
tonihei
8a084daaff Clarify/correct restrictions of AdsMediaSource.
The source can be used in compositions (in fact, every source is
automatically used in an internal composition when constructing the
playlist), and there is not really a concept of top-level media source
any more since the Player supports playlists.

The actual restriction is that the content media source needs to have
exactly one period to be able to create a SinglePeriodAdTimeline.

#minor-release

PiperOrigin-RevId: 357544191
2021-02-19 10:55:29 +00:00
kimvde
842ca9c09f Add method to query whether a command is available
- Other commands will be added later.
- The returned value is a boolean until we decide what it should be.

PiperOrigin-RevId: 357535877
2021-02-19 10:55:20 +00:00
gyumin
c7751344d4 Use compact String keys for Bundleable
To save bytes in serialized format, it uses shorter keys in Bundles.

PiperOrigin-RevId: 357492840
2021-02-19 10:55:11 +00:00
olly
0b63c17a7e Fix RequiresApi annotation
#minor-release

PiperOrigin-RevId: 357273184
2021-02-12 22:53:40 +00:00
olly
18722bfb0b Bump version to 2.13.1
PiperOrigin-RevId: 357219132
2021-02-12 19:55:57 +00:00
kimvde
c1ef00ab42 Revert logic to decide whether meta atom is full
The previous logic was changed under the assumption that the first box
inside a meta box was not always an hdlr box, but this is not true.

#minor-release

PiperOrigin-RevId: 357200713
2021-02-12 19:55:47 +00:00
christosts
086d8f3a8e Contract test for TransferListener callbacks
PiperOrigin-RevId: 357190780
2021-02-12 16:40:40 +00:00
kimvde
b303eceafd Add support for MP4/QuickTime non-full meta atoms
#minor-release

PiperOrigin-RevId: 357160215
2021-02-12 16:40:31 +00:00
kimvde
158e6de25a Add comment explaining Dolby Vision fallback logic
PiperOrigin-RevId: 357158075
2021-02-12 16:40:23 +00:00
kimvde
6afb669aa7 Enable next button if window is live
This behavior is consistent with DefaultControlDispatcher#dispatchNext().

#minor-release

PiperOrigin-RevId: 357145076
2021-02-12 16:40:14 +00:00
olly
0dba806894 Move DebugTextViewHelper to core
It's closely tied to SimpleExoPlayer, so cannot be part of a UI module
that depends only on common.

PiperOrigin-RevId: 357085802
2021-02-12 16:40:05 +00:00
tonihei
d700990198 Fix available end time calculation for multi-period DASH live streams
The available end time was accidentally substracted by the start time
of the last period.

To avoid similar time reference confusion in the future, also renaming
many variables and methods to clearly reflect the time reference point.
And to avoid constant conversion, the processManifest method also
attempts to converge to time relative to the start of the window as
quickly as possible.

Issue: #8537
PiperOrigin-RevId: 357001624
2021-02-12 16:39:56 +00:00
ibaker
6b5b3d8141 Check if keepalive is enabled before releasing sessions in DDSM.release
If keepalive is disabled the existing code over-eagerly releases
DrmSession instances. This is arguably OK since a (Default)DrmSession
should be released before its (Default)Manager is released
(since the underlying MediaDrm instance might be released when the
manager is released). And if all sessions are released before the
manager is released then `sessions` is empty, so the loop is a no-op.

Issue: #8576
#minor-release
PiperOrigin-RevId: 356955308
2021-02-12 16:39:47 +00:00
ibaker
de359cd6fd Propagate DRM config when creating ad media sources
The `DrmConfiguration.sessionForClearTypes` property is often used
to ensure a secure decoder is used for clear ads played in encrypted
content. This is because some devices show black frames when switching
decoders.

Before this change the DRM config isn't propagated down when
constructing the ad media source, meaning
`DrmSessionManager.DRM_UNSUPPORTED` is always used, which will
cause playback to switch from secure to clear decoder when transitioning
to an ad break (ignoring the MediaItem `sessionForClearTypes` option.

Issue: #8568

#minor-release

PiperOrigin-RevId: 356951124
2021-02-12 16:39:38 +00:00
aquilescanta
f8505204cc Move MediaFormatUtil into common
Also move out of the mediacodec package into the util package.

PiperOrigin-RevId: 356949401
2021-02-12 16:39:28 +00:00
andrewlewis
5e229b4f05 Don't set playback parameters when using tunneling
Issue: #4803

#minor-release

PiperOrigin-RevId: 356923345
2021-02-11 12:06:13 +00:00