4362 Commits

Author SHA1 Message Date
olly
a720380e77 Update DownloadService for Android 12
- If DownloadService is configured to run as a foreground service,
  it will remain started and in the foreground when downloads are
  waiting for requirements to be met, with a suitable "waiting for
  XYZ" message in the notification. This is necessary because new
  foreground service restrictions in Android 12 prevent to service
  from being restarted from the background.
- Cases where requirements are not supported by the Scheduler will
  be handled in the same way, even on earlier versions of Android.
  So will cases where a Scheduler is not provided.
- The Scheduler will still be used on earlier versions of Android
  where possible.

Note: We could technically continue to use the old behavior on
Android 12 in cases where the containing application still has a
targetSdkVersion corresponding to Android 11 or earlier. However,
in practice, there seems to be little value in doing this.
PiperOrigin-RevId: 398720114
2021-09-24 18:04:42 +01:00
andrewlewis
fecb8b7ec8 Make parameter name match inherited doc @param
This is currently required to make javadoc generation via Dackka succeed.

PiperOrigin-RevId: 398518538
2021-09-24 18:00:27 +01:00
ibaker
c5abf34646 Add ExoPlayer.Builder#buildExoPlayer method
Annotate build() with @InlineMe. I will update build() to return Player
in a future change.

PiperOrigin-RevId: 398446323
2021-09-23 15:15:20 +01:00
bachinger
4fec4b8f6a Move format specific metadata packages to lib-extractor
PiperOrigin-RevId: 398262695
2021-09-23 15:13:10 +01:00
bachinger
f2a027e068 Move text classes from lib-exoplayer to lib-extractor and lib-common
PiperOrigin-RevId: 398247348
2021-09-23 15:09:07 +01:00
bachinger
1372300073 Fix lint warning that breaks gradle build
Calling AudioManager.isOffloadedPlaybackSupported is available since API 29 only.

PiperOrigin-RevId: 398229498
2021-09-23 15:03:01 +01:00
ibaker
a63155975a Use the new MediaItem.Builder#setLiveConfiguration method
PiperOrigin-RevId: 398215071
2021-09-23 14:57:19 +01:00
ibaker
a194d73c75 Use the new MediaItem.Builder#setAdsConfiguration method
PiperOrigin-RevId: 398185843
2021-09-23 14:53:21 +01:00
ibaker
c927bc8358 Add clearkey-based DRM playback emulator tests
These give some documentation-as-code for a clearkey integration with
ExoPlayer.

#exofixit

PiperOrigin-RevId: 398017708
2021-09-23 14:51:10 +01:00
ibaker
e0a9540cd3 Mark MediaItem.Subtitle.mimeType as @Nullable
The MIME type is currently required to select a SubtitleDecoder
implementation in the TextRenderer. Future changes might remove this
requirement, so we pre-emptively mark the field as @Nullable.

The change in SingleSampleMediaSource ensures the track still maps to
the TextRenderer, otherwise it shows up as unmapped. Passing null MIME
type to MediaItem.Subtitle constructor now results in this from
EventLogger:

TextRenderer [
  Group:0, adaptive_supported=N/A [
    [ ] Track:0, id=null, mimeType=text/x-unknown, language=en, supported=NO_UNSUPPORTED_TYPE
  ]
]

PiperOrigin-RevId: 398010809
2021-09-23 14:49:15 +01:00
ibaker
dd39513a2e Rename MediaItem.DrmConfiguration.requestHeaders to add license
Both license and provisioning requests could be considered 'DRM
requests', and these headers are only sent on license requests, so
rename them to reflect that.

The old field remains deprecated for backwards compatibility.

PiperOrigin-RevId: 397980021
2021-09-23 14:47:13 +01:00
ibaker
e804df8c1f Rename MediaItem.DrmConfiguration.uuid to scheme
The type is already UUID so there's no need to duplicate that info in
the field name, and 'scheme' is a widely used term throughout both
ExoPlayer and android.os.MediaDrm documentation.

The old field remains deprecated for backwards compatibility.

The MediaItem.DrmConfiguration.Builder#setUuid method is renamed
directly (without deprecation) because it's not yet part of a released
ExoPlayer version.

PiperOrigin-RevId: 397961553
2021-09-21 14:23:21 +01:00
ibaker
ab484a4b11 Simplify MediaItem.Builder interactions in DefaultMediaSourceFactory
This takes advantage of the new MediaItem.LiveConfiguration.Builder

This change will always allocate a new LiveConfiguration.Builder and
LiveConfiguration, but preserves the behaviour of keeping the same
MediaItem instance if no values have changed.

PiperOrigin-RevId: 397961427
2021-09-21 14:21:32 +01:00
ibaker
ea45f9ffb8 Remove @RequiresApi(16) from SynchronousMediaCodecAdapter
This isn't needed since the whole library's min API is already 16

PiperOrigin-RevId: 397939444
2021-09-21 14:19:28 +01:00
ibaker
ad99a44083 Add empty sdk-version node to all AndroidManifest.xml files
PiperOrigin-RevId: 397772916
2021-09-21 14:17:33 +01:00
ibaker
04943db71c Don't call MediaItem.Builder#setKeySetId without setting the DRM UUID
This is known to silently drop the value. This setter is now deprecated
in favour of `MediaItem.Builder#setDrmConfiguration(MediaItem.DrmConfiguration)`,
which requires a UUID in order to construct the `DrmConfiguration`
instance.

Issue: #9378 tracks correctly propagating the DRM info out of
`DownloadRequest#toMediaItem`.
PiperOrigin-RevId: 397291013
2021-09-17 13:14:57 +01:00
ibaker
13827186aa Use the new MediaItem.Builder#setDrmConfiguration method
PiperOrigin-RevId: 397290953
2021-09-17 13:12:53 +01:00
bachinger
6f728a43ad Remove obsolete imports
PiperOrigin-RevId: 397280475
2021-09-17 12:03:50 +01:00
krocard
74c6ef9ba0 Move EventListener registration down from Player
The deprecated `Player.addListener(EventListener)`
is moved out of Player into its subclasses
(CastPlayer and ExoPlayer).

This is unlikely to break users because:
 - the method has been deprecated in the last major version
 - the method is still present in the major implementations

If an users is affected, they can either:
 - use ExoPlayer instead of Player
 - (recommended) switch to Player.Listener.

Additionally update the threading guarantees that did not
reflect the current implementation.

PiperOrigin-RevId: 397272144
2021-09-17 11:58:31 +01:00
krocard
a75f902c81 Add track type disabling to Track selection parameters
This will allow to disable video/audio... through the player
interface.

PiperOrigin-RevId: 397183548
2021-09-17 11:55:51 +01:00
olly
4ff4263af3 DownloadService: Minor improvements
* Avoid ActivityManager log spam by only calling startForeground once,
  and subsequently updating the notification via NotificationManager.
* Tweak demo app service to make it a tiny bit easier to swap the Scheduler.

PiperOrigin-RevId: 397179398
2021-09-17 11:53:39 +01:00
olly
6edf9c31bf DownloadService: Only call getScheduler once
The second getScheduler() call violates the documentation of
the class, which states that getScheduler() is not called if
foregroundNotificationId if FOREGROUND_NOTIFICATION_ID_NONE.
Presumably implementing subclasses would return null, in which
case this didn't do any harm, but we should make sure the
implementation behaves as documented regardless.

PiperOrigin-RevId: 397167603
2021-09-16 22:44:06 +01:00
olly
f6d8cfeb1f DownloadService: Remove deprecated protected methods
PiperOrigin-RevId: 397138908
2021-09-16 22:35:23 +01:00
krocard
4455554e9e Use Android 12's AudioManager.getPlaybackOffloadSupport
Previously gapless offload support was hardcoded to Pixel
only.

PiperOrigin-RevId: 397070378
2021-09-16 16:57:02 +01:00
bachinger
f8dde8ed5f Move classes from util package in lib-exoplayer
PiperOrigin-RevId: 397066804
2021-09-16 16:54:59 +01:00
bachinger
86dc31f291 Reset only renderers that have been enabled
#exofixit

PiperOrigin-RevId: 396938258
2021-09-16 12:11:02 +01:00
olly
5a2fd983a9 Move database package to common module
PiperOrigin-RevId: 396936785
2021-09-16 12:09:16 +01:00
ibaker
4433ac5a2a Rollback of ee8df7afcb
*** Original commit ***

Ensure MediaSourceFactory instances can be re-used

This fixes DefaultDrmSessionManager so it can be used by a new Player
instance (by nulling out its reference to the playback thread, which is
unique per-Player instance). This only works if the
DefaultDrmSessionManager is 'fully released' before being used by the
second Player instance, meaning that the reference count of the manager
and all its sessions is zero.

#exofixit
Issue: #9099

***

PiperOrigin-RevId: 396861138
2021-09-16 12:07:27 +01:00
kimvde
416ec75b94 Add factory methods to create MediaCodecAdapter.Configuration
#exofixit

PiperOrigin-RevId: 396793873
2021-09-16 12:03:30 +01:00
andrewlewis
8540b7266c Add open @IntDef for track selection type
#exofixit

PiperOrigin-RevId: 396780460
2021-09-16 11:59:57 +01:00
ibaker
4d668f1b7b Fix how preacquired DRM sessions are released under resource contention
Previously the released preacquired sessions would start their keepalive
timeout, and so no additional resources would be freed in time for the
manager to retry the session acquisition.

This change adds an additional purge of keepalive sessions *after* the
preacquired sessions are released, which fixes the problem.

#exofixit
#minor-release

PiperOrigin-RevId: 396613352
2021-09-14 21:33:01 +01:00
krocard
cf0ec91934 Simplify rendererDisabledFlags bundling
Align redererDisableFlags (un)bundling
with the other field by using an explicit
temporary data structure (int array).

PiperOrigin-RevId: 396358143
2021-09-14 12:09:58 +01:00
olly
4940f21d48 Make position-out-of-range errors non-retryable
PiperOrigin-RevId: 396354920
2021-09-14 12:07:52 +01:00
andrewlewis
469c0e756a Use @C.TrackType more widely
Also add `TYPE_USE` target on the @IntDef (and fix @Targets for other
@IntDefs).

#exofixit

PiperOrigin-RevId: 396333212
2021-09-14 12:04:11 +01:00
christosts
cd91ae4053 PlaybackStatsListener: add check when adding guessed times
This is was reported in #9257 where the PlaybackStatsListener may try to
access an emtpy ArrayList.

Issue: #9257

#minor-release
#exofixit

PiperOrigin-RevId: 396329373
2021-09-14 12:00:24 +01:00
bachinger
76d60b911e Migrate media item transition tests to TestExoPlayer
PiperOrigin-RevId: 396313679
2021-09-14 11:58:30 +01:00
andrewlewis
71a4b6337c Fix javadoc consistency
#exofixit

PiperOrigin-RevId: 396304941
2021-09-14 11:56:45 +01:00
olly
68ee587e25 Constrain resolved period positions to be within the period
This is a candidate fix for #8906. As mentioned in that issue,
negative positions within windows might be (kind of) valid in
live streaming scenarios, where the window starts at some
non-zero position within the period. However, negative positions
within periods are definitely not valid. Neither are positions
that exceed the period duration.

There was already logic in ExoPlayerImplInternal to prevent a
resolved seek position from exceeding the period duration. This
fix adds the equivalent constraint for the start of the period.
It also moves the application of the constraints into Timeline.
This has the advantage that the constraints are applied as part
of state masking in ExoPlayerImpl.seekTo, removing any UI flicker
where the invalid seek position is temporarily visible.

Issue: #8906
PiperOrigin-RevId: 395917413
2021-09-10 15:11:52 +01:00
andrewlewis
0c4bb23dd3 Rename audioVolume parameter to volume
The new name is consistent with the corresponding parameters to `onVolumeChanged`, `setDeviceVolume` and `onDeviceVolumeChanged`.

PiperOrigin-RevId: 395705288
2021-09-09 18:17:40 +01:00
kimvde
0c969bb73d Remove deprecated SingleSampleMediaSource.createMediaSource
#exofixit

PiperOrigin-RevId: 395518824
2021-09-09 18:13:25 +01:00
ibaker
ee8df7afcb Ensure MediaSourceFactory instances can be re-used
This fixes DefaultDrmSessionManager so it can be used by a new Player
instance (by nulling out its reference to the playback thread, which is
unique per-Player instance). This only works if the
DefaultDrmSessionManager is 'fully released' before being used by the
second Player instance, meaning that the reference count of the manager
and all its sessions is zero.

#exofixit
#minor-release
Issue: #9099
PiperOrigin-RevId: 395490506
2021-09-09 18:09:21 +01:00
samrobinson
c403de1c19 Fix AudioSink reset javadoc.
PiperOrigin-RevId: 395444714
2021-09-08 17:10:44 +01:00
olly
c2e6d2028b Fix poor documentation and variable name choice in StreamKey
Issue #9284

PiperOrigin-RevId: 395443015
2021-09-08 17:08:56 +01:00
andrewlewis
3cdc8a9ea3 Use correct last timestamp for C2 MP3 workaround
The C2 MP3 decoder produces an extra output buffer when draining after
end-of-stream is queued. This output buffer has a later timestamp than the last
queued input buffer so we need to calculate its timestamp to detect a stream
change in the correct position.

Before this CL we used the original input buffer timestamp as the largest
queued timestamp, which caused the stream change to be detected at the correct
position because the original input buffer timestamp was slightly larger than
the actual last output buffer timestamp. After this change we use exact
calculated timestamp as the largest queued timestamp. I manually verified
gapless continues to work on a device using the C2 MP3 decoder by comparing
output of the MP3 gapless and MP3 gapless stripped playlists in the demo app,
and that the last buffer timestamp now matches.

#exofixit

PiperOrigin-RevId: 395428928
2021-09-08 17:02:48 +01:00
ibaker
9949424da4 Deprecate all methods on C and move them to Util
C should only hold constants.

Also resolve the TODO in getErrorCodeForMediaDrmErrorCode(), and
annotate the deprecated methods with Error Prone's @InlineMe to
facilitate automated refactoring of callers.

PiperOrigin-RevId: 395244855
2021-09-07 17:56:41 +01:00
olly
b6089758ff Fix incorrect assertion in CacheDataSource
#minor-release
#exofixit

PiperOrigin-RevId: 395233639
2021-09-07 17:54:35 +01:00
samrobinson
11d2d7daf9 Add open @IntDef for Renderer message types.
#exofixit

PiperOrigin-RevId: 395233622
2021-09-07 17:52:40 +01:00
olly
2e21208f63 Workaround ConnectivityManager SecurityException on Android 11
#exofixit
#minor-release
Issue: #9002
PiperOrigin-RevId: 395221648
2021-09-07 17:44:41 +01:00
samrobinson
5183eaaf1e Add open @IntDef for track selection reasons.
#exofixit

PiperOrigin-RevId: 395217458
2021-09-07 17:42:30 +01:00
kimvde
7129d84efd Avoid OMX.qti.audio.decoder.flac on API level < 32
Before, this decoder was avoided on API levels < 30.

#minor-release
Issue:#9349
PiperOrigin-RevId: 395209684
2021-09-07 11:56:18 +01:00