4178 Commits

Author SHA1 Message Date
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
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
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
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
Arnold Szabo
dafe710ab3 Remove extra space from SsaDecoderTest.java. 2021-02-22 20:36:06 +01:00
Arnold Szabo
9c35d76184 Parse font size into float, and fallback to Cue.DIMEN_UNSET instead of null. 2021-02-22 20:33:12 +01: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
Arnold Szabo
741a9c2ef7 Add support for font size in SSA v4+ styling. 2021-02-21 18:22:04 +01: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
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
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
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
olly
0b63c17a7e Fix RequiresApi annotation
#minor-release

PiperOrigin-RevId: 357273184
2021-02-12 22:53:40 +00:00
christosts
086d8f3a8e Contract test for TransferListener callbacks
PiperOrigin-RevId: 357190780
2021-02-12 16:40:40 +00:00
kimvde
158e6de25a Add comment explaining Dolby Vision fallback logic
PiperOrigin-RevId: 357158075
2021-02-12 16:40:23 +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
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
olly
493d996c6f Move RepeatModeUtil to common
It's used by the UI and mediasession modules. We may be able to move
it into the UI module if/when the mediasession module goes away.

PiperOrigin-RevId: 356734939
2021-02-11 12:06:02 +00:00
christosts
333de74140 Minor fixes in CacheDataSourceTest
PiperOrigin-RevId: 356695284
2021-02-11 12:05:51 +00:00
ibaker
a062075462 Cache the last DrmSessionManager instance inside the default provider
Without this a new manager is instantiated for every item in a playlist,
meaning the impact of caching improvements to DefaultDrmSessionManager
are reduced (since the cache doesn't persist across playlist items).

With this change, playlists of items with identical DRM config will use
the same manager instance (and thus share existing sessions).

Issue: #8523
#minor-release
PiperOrigin-RevId: 356690852
2021-02-11 12:05:28 +00:00
andrewlewis
e28332ff82 Add common prefix to loader thread names
All threads created by ExoPlayer should now have the prefix "ExoPlayer:".

PiperOrigin-RevId: 356518037
2021-02-11 12:05:06 +00:00
olly
94a4b905c9 Make additional modules depend only on common
ControlDispatcher and DefaultControlDispatcher also need
to move to common for the UI module. As does PlaybackPreparer,
although that will be removed entirely in a future release.

PiperOrigin-RevId: 356467394
2021-02-09 13:59:41 +00:00
tonihei
fbc8d6c801 Don't apply speed adjustment if windowStartTime is unknown.
This may happen for HLS live streams without program date time
information.

Issue: #8560

#minor-release

PiperOrigin-RevId: 356227729
2021-02-09 13:59:16 +00:00
aquilescanta
0b8b03e46d Add method to create a MediaFormat based on an ExoPlayer Format
PiperOrigin-RevId: 356157035
2021-02-09 13:58:59 +00:00
olly
01b6061bd2 Wire CodecException.isRecoverable to ExoPlaybackException
PiperOrigin-RevId: 355896218
2021-02-09 13:58:50 +00:00
olly
438bcada38 Consistently throw the original exception if recovery fails
PiperOrigin-RevId: 355664280
2021-02-09 13:58:33 +00:00
olly
a245fbdc99 #ExoPlayerMigration Ensure RawResourceDataSource class is obfuscated
PiperOrigin-RevId: 355659628
2021-02-09 13:58:24 +00:00
krocard
91d3f47e45 Clarify AudioFocusManager by renaming some methods/field
The current naming had cause confusinon in b/179369346
and #8545.

PiperOrigin-RevId: 355656404
2021-02-09 13:58:15 +00:00
olly
5107fea576 More clearly define the semantics of error recovery
- When throwing a recoverable error from a renderer, it's important to understand
  exactly how the player will attempt recovery. Clarify the documentation to
  make this explicit.
- Rename some methods/constants to make it clear that error recovery is specific
  to renderer errors. The current recovery mechanism only makes sense for
  renderer errors. Making the naming renderer specific avoids reader doubt that
  the implementation doesn't appear to be generic enough for other types of
  errors.

PiperOrigin-RevId: 355650945
2021-02-04 18:14:26 +00:00
kimvde
35d34af2e9 Fall back to AVC/HEVC for Dolby Vision levels 10-13
Before, the level was set to null in this case.
MediaCodecUtil.getCodecProfileAndLevel() was therefore returning null
and the fallback to AVC/HEVC was not enabled in MediaCodecVideoRenderer.

Issue:#8530
#minor-release
PiperOrigin-RevId: 355574499
2021-02-04 09:57:46 +00:00
olly
584a0730c9 Improve EventLogger static metadata formatting
#minor-release

PiperOrigin-RevId: 355203044
2021-02-03 15:02:50 +00:00