4306 Commits

Author SHA1 Message Date
aquilescanta
29eeff9ff7 Assign error codes to FileDataSourceExceptions
PiperOrigin-RevId: 377481210
2021-06-08 12:54:31 +01:00
Dean Wheatley
cb1084f498 Use isDirectPlaybackSupported in AudioCapabilities
For Q devices and higher, use AudioTrack.isDirectPlaybackSupported
for determining AudioCapabilities.
2021-06-07 20:59:31 +10:00
aquilescanta
af4b891c99 Use UnrecognizedFormatException for progressive media only
PiperOrigin-RevId: 377303025
2021-06-03 20:07:04 +01:00
olly
2b6581afe0 Fix nullness checks for addition of Cursor.getString stub
PiperOrigin-RevId: 377298145
2021-06-03 20:05:58 +01:00
kimvde
b0a3bc5b28 Rename ExoFlags to FlagSet
We want to remove mentions of ExoPlayer for
convergence.

PiperOrigin-RevId: 377290376
2021-06-03 20:04:39 +01:00
aquilescanta
36841d4f6f Replace one of the ParserException constructors with factory method
PiperOrigin-RevId: 377281961
2021-06-03 20:03:16 +01:00
olly
bb2e0bc0ef Bump targetSdkVersion to 30
- Remove Robolectric workarounds that are no longer needed
- Add workarounds for b/190021699

PiperOrigin-RevId: 377279422
2021-06-03 20:01:50 +01:00
aquilescanta
89fe0d0cf9 Make AnalyticsListener.onPlayerError take a PlaybackException
NO_EXTERNAL

PiperOrigin-RevId: 377090819
2021-06-03 13:49:28 +01:00
olly
08c882a6ae Trigger reconfiguration on newly obtained MediaCodecAdapters
Add the `needsReconfiguration` API on the `MediaCodecAdapter` interface so that `MediaCodecRenderer` can reconfigure the `MediaCodec` in case a `MediaCodecAdapter` needs to be reconfigured immediately after being obtained from the `MediaCodecAdapter.Factory`.

PiperOrigin-RevId: 376944334
2021-06-02 18:10:01 +01:00
bachinger
2fb61b8ab5 Remove fully qualified package in link tag to avoid reformatting
PiperOrigin-RevId: 376932836
2021-06-02 00:00:55 +01:00
ibaker
58e307c6b0 Keep secure MediaCodec instances when disabling the renderer
A renderer is disabled (without being reset) in two situations:
* When transitioning into a period that starts with a discontinuity
* When stopping the player with setForegroundMode(true)

Before this change the behaviour of `MediaCodecRenderer` when disabled
(but not reset) depended on whether the content being decoded had an
associated `DrmSession`:
* For content without an associated DRM session the MediaCodec instance
  was kept alive.
* For content with an associated DRM session, the MediaCodec instance
  was released. This was to prevent the DRM session from staying alive
  and continuing to make license refresh network requests while the
  player was stopped in 'foreground mode'.

This change removes the second bullet, and keeps MediaCodec instances
alive in both the secure and insecure case. This will result in the
DRM machinery making occasional license refresh network requests (at
a frequency defined by the license policy) while the player is stopped
and in 'foreground mode'. This network usage is considered to be a
'limited resource' as described by the `ExoPlayer#setForegroundMode`
javadoc.

This means that switches between secure content (or between secure and
clear content when `MediaItem.drmConfiguration.sessionForClearTypes`
indicates a secure decoder should be used for clear content) should
keep the same video decoder, thus avoiding the 'black flash' that occurs
on some devices when switching the surface away from a secure decoder.

Issue: #8842

#minor-release

PiperOrigin-RevId: 376825501
2021-06-01 15:48:18 +01:00
ibaker
1bf5a273ff Ensure DefaultDrmSessions keep working if their manager is released
This change introduces a third 'state' for `DefaultDrmSessionManager`:
It's been fully released (prepareCount == 0) but at least one of its
sessions is still active.

In this state new acquisitions are rejected (`(pre)acquireSession()`
calls will fail) but the machinery to support the existing sessions
(ExoMediaDrm and MediaDrmHandler) is kept until they're all released.

This change will allow us to remove the TODO in MediaCodecRenderer
that resolves Issue: #8842.

PiperOrigin-RevId: 376193952
2021-05-27 18:56:29 +01:00
ibaker
4cca8b6d4a Add a test for handling of DRM key refresh events
In a follow-up change I will add an additional test to ensure these
events continue to be correctly handled when DefaultDrmSessionManager
has prepareCount==0 but a non-null ExoMediaDrm instance.

PiperOrigin-RevId: 376190225
2021-05-27 18:55:03 +01:00
olly
513185b72a Fix incorrect re-use of non-secure DummySurface with secure decoder
Issue: #8776
PiperOrigin-RevId: 376186877
2021-05-27 18:53:47 +01:00
tonihei
2938d40bf4 Allow to specify the number of removed ad groups in AdPlaybackState.
This helps to remove old ad groups (e.g. those that fell out
of the live window) to keep the data size of AdPlaybackState small.

Also added this case to some existing unit tests to ensure it's
covered.

PiperOrigin-RevId: 376170653
2021-05-27 18:49:53 +01:00
tonihei
0d0ccadc83 Add getter for ad groups in AdPlaybackState.
This allows to decouple the data structure from the access. In
a future change, this allows to completely remove old ad groups
(e.g. for live streams where the number of groups would otherwise
grow forever).

Also move the time into the group itself for better encapsulation.

PiperOrigin-RevId: 376170408
2021-05-27 18:48:40 +01:00
aquilescanta
c353151288 Add errorCode to the EventLogger
PiperOrigin-RevId: 376126959
2021-05-27 16:00:32 +01:00
ibaker
e7516fe4e0 Throw from (pre)acquireSession if the DrmSessionManager isn't prepared
Currently acquireSession() fails with an NPE from
checkNotNull(exoMediaDrm). A follow-up change will result in exoMediaDrm
sometimes being non-null while prepareCount==0 (and in this case we
still want acquireSession() to fail).

preacquireSession() doesn't currently fail in a way the caller can
observe - the same NPE is thrown, but asynchronously and it doesn't
propagate out of the background thread. Throwing directly seems
preferable since it's a clear bug to be trying to preacquire sessions
from an unprepared/released manager.

PiperOrigin-RevId: 375906450
2021-05-27 10:36:20 +01:00
aquilescanta
a1ecf3193a Assign ERROR_CODE_PARSING_* to ParsingException
PiperOrigin-RevId: 375515685
2021-05-26 11:29:53 +01:00
Oliver Woodman
afe4217c1c Merge pull request #8943 from dlafayet:embeddedstyle2
PiperOrigin-RevId: 375484765
2021-05-26 11:28:37 +01:00
ibaker
5afc915e51 Don't restore DRM keys before releasing them
#minor-release

PiperOrigin-RevId: 375436117
2021-05-26 11:26:09 +01:00
aquilescanta
2c2197d12c Assign ERROR_CODE_IO_BAD_HTTP_STATUS to InvalidResponseCodeException
PiperOrigin-RevId: 374885599
2021-05-21 12:03:39 +01:00
tonihei
d08303d05d Add ServerSideInsertedAdsMediaSource.
This media source wraps another source and publishes a Timeline with
ads. The created MediaPeriods for ad and content are mapped back to
the original stream to allow seamless playback.

PiperOrigin-RevId: 374836091
2021-05-20 15:43:00 +01:00
tonihei
1a6f36d4a4 Fix reading position at stream transition.
PiperOrigin-RevId: 374836046
2021-05-20 15:42:31 +01:00
tonihei
8eb990e47a Make SSAI player logic more targeted.
There is a newly added condition to help advancing between SSAI ads
and content in case the ad group position or ad duration changed. The
condition currently doesn't check directly whether it's a SSAI
transition but relies on indrect signals. Making this more direct
helps to understand the purpose and avoid unintentional bugs where
this condition would apply in other cases too.

In addition, we need to exclude TextRenderer from the check because
its read position doesn't correspond to the actual decode position
since the decoding happens in the renderer itself (b/181312195).

PiperOrigin-RevId: 374835985
2021-05-20 15:42:02 +01:00
tonihei
5ff4211c5e Avoid recalculation of whether a MediaPeriod is part of a SSAI stream
We can instead just save this information in MediaPeriodInfo, similar
to how we store whether the MediaPeriod is last in the timeline etc.

PiperOrigin-RevId: 374835918
2021-05-20 15:41:34 +01:00
klhyun
9e4315f48d Implement MediaController#getCurrentCues
It only covers MediaSession - MediaController
(Does not consider cases that either a legacy session or a legacy controller is involved)

Add PlayerInfo#Builder to clean it up.

PiperOrigin-RevId: 374785779
2021-05-20 15:39:34 +01:00
aquilescanta
66c1aedeb3 Assign ERROR_CODE_BEHIND_LIVE_WINDOW to BehindLiveWindowExceptions
PiperOrigin-RevId: 374425179
2021-05-19 20:23:38 +01:00
aquilescanta
227795964b Add an IntDef for DATA_TYPE_* constants
PiperOrigin-RevId: 374418502
2021-05-19 20:22:48 +01:00
tonihei
378b3f6eb5 Add Util class for server-side inserted ads.
When working with SSAI ads, we need to easily convert positions between
the underlying stream and the media model that exposes ad groups. To
simplify this, we can add util methods (that are testable on their own).

In addition, we need an easy way to build AdPlaybackStates for SSAI
inserted ads. The metadata is obtained out-of-band and usually has the
ad group start and end times in the underlying stream only. Hence, we
also add a util method to add a new ad group based on this information.

PiperOrigin-RevId: 374369360
2021-05-19 20:21:32 +01:00
aquilescanta
c7db9fb390 Deduplicate calls to maybeNotifyPlaybackInfoChanged
PiperOrigin-RevId: 374253036
2021-05-19 20:21:08 +01:00
Denise LaFayette
e3228064f3 Introduce LanguageFeatureStyle interface to mark language features 2021-05-17 13:20:34 -07:00
olly
2566b24642 Remove deprecated Listener.onTimelineChanged
PiperOrigin-RevId: 374171038
2021-05-17 18:19:13 +01:00
olly
0c80a54bc1 Update avcLevelToMaxFrameSize for AVCLevel6, 61 and 62
#minor-release

PiperOrigin-RevId: 374161340
2021-05-17 18:18:34 +01:00
tonihei
795210d7bc Update player logic to handle server-side inserted ads.
There are two main changes that need to be made:
 1. Whenever we determine the next ad to play, we need to select a
    server-side inserted ad even if it has been played already (because
    it's part of the stream).
 2. When the Timeline is updated in the player, we need to avoid changes
    that would unnecessarily reset the renderers. Whenever a Timeline
    change replaces content with a server-side inserted ad at the same
    position we can just keep the existing MediaPeriod and also if the
    duration of the current MediaPeriod is reduced but it is followed by
    a MediaPeriod in the same SSAI stream, we can don't need to reset
    the renderers as we keep playing the same stream.

PiperOrigin-RevId: 373745031
2021-05-14 11:24:46 +01:00
klhyun
bec7b0041e Make Cue implement Bundleable
In order to deliver Cue objects between different processes
(e.g. in Player#getCurrentCues), this CL makes it Bundleable.

PiperOrigin-RevId: 373524501
2021-05-13 10:52:12 +01:00
olly
6596cd1d83 Remove legacyKeepAvailableCodecInfosWithoutCodec
It's no longer used.

PiperOrigin-RevId: 373426109
2021-05-13 10:51:26 +01:00
tonihei
ef5a0b6c4d Allow ad groups to specify a resume offset.
Content after ad groups currently always resumes at the ad break position (unless
overridden by a seek or similar).  In some cases, media inserting ads wants to
specify an offset after the ad group at which playback should resume. A common
example is a live stream that inserts an ad and then wants to continue streaming
at the current live edge.

Support this use case by allowing ad groups to specify a content resume offset
and making sure that the content start position after the ad group uses this offset.

PiperOrigin-RevId: 373393807
2021-05-12 18:57:45 +01:00
olly
1da25f5979 Remove deprecated MediaSource.getTag
PiperOrigin-RevId: 373222158
2021-05-12 11:52:03 +01:00
tonihei
74b126dfc4 Don't wrap FileDataSourceException in FileDataSourceException.
Instead just forward the existing exception.

PiperOrigin-RevId: 373145328
2021-05-11 16:02:28 +01:00
tonihei
08fb7bd65f Support changing ad break positions.
The player already supports changing durations of periods and ads.
The only thing not yet supported is a change in ad break positions
which changes the duration of clipped content ending in an ad break.

Adding support for this requires updating the end position in
MediaPeriodInfo and changing the clip end position of the respective
ClippingMediaPeriod.

Issue: #5067
PiperOrigin-RevId: 373139724
2021-05-11 16:01:25 +01:00
tonihei
5167ca65fb Fix bug where content position of ads in moving live windows is updated
The method to handle Timeline updates currently uses
 isAd() || isPlaceholder()
to trigger two things:
 1. Using the existing requested content position as the content
    position.
 2. Re-resolving the content position from window to period in case
    it changed since the last update.

The condition is correct for case (1) because ads must use the content
position (and not the position in the ad) and a placeholder period must
keep using the requested content position as well until the media
information is no longer a placeholder.

However, case (2) only needs to be done if the content position is
C.TIME_UNSET (to start at the default position) OR if the period is
still a placeholder and we want to re-resolve the position.

The case where re-resolution shouldn't be done is for ads with a non-
placeholder period and a concrete content position. This likely only
affects ads in live stream where the content position is currently
moving with the live stream instead of staying where it is.

PiperOrigin-RevId: 372929439
2021-05-10 23:40:47 +01:00
tonihei
8a5d21adef Remove reference to deprecated Player.EventListener.
#minor-release

PiperOrigin-RevId: 372925409
2021-05-10 23:40:26 +01:00
olly
3c64bc1b49 Fix Javadoc references to deprecated EventListener
#minor-release

PiperOrigin-RevId: 372919342
2021-05-10 23:40:05 +01:00
ibaker
7a3d8b5ef0 Swallow exceptions in TestContentProvider when writing to a pipe fails
The existing code results in flaky tests, where sometimes the write
fails (with "EPIPE (broken pipe)") and the exception propagates out
and causes the test to never complete and time out.

Swallowing the exception resolves this flakiness.

#minor-release

PiperOrigin-RevId: 372909415
2021-05-10 23:39:03 +01:00
kimvde
7f2922d6f2 Deprecate ExoPlayer.Builder.
Apps should migrate from ExoPlayerImpl to SimpleExoPlayer.

#minor-release

PiperOrigin-RevId: 372562923
2021-05-10 09:38:08 +01:00
samrobinson
2914e574e6 Rename MediaMetadata trackTitle and trackArtist to title and artist.
#minor-release

PiperOrigin-RevId: 372537414
2021-05-07 14:58:03 +01:00
bachinger
15ce148877 Avoid media item transitions for auto discontinuities when ads involved
#minor-release

PiperOrigin-RevId: 372433555
2021-05-07 10:22:08 +01:00
olly
782c1739c8 Use correct Log class
#minor-release

PiperOrigin-RevId: 372314890
2021-05-06 13:35:40 +01:00
tonihei
61bbdb3794 Add missing isPlaceholder forwarding in SinglePeriodAdTimeline
Also make future similar issues less likely by adding isPlaceholder
to the set method of Period (in case forwarding Timeline
implementations use this instead of just updating values selectively)

#minor-release

PiperOrigin-RevId: 372138523
2021-05-06 13:33:06 +01:00