1300 Commits

Author SHA1 Message Date
tonihei
039eef00bf Add aquaman to devices needing setOutputSurface workaround.
Issue: google/ExoPlayer#9710
PiperOrigin-RevId: 411568601
2021-11-22 17:21:14 +00:00
tonihei
343279b213 Add MediaMetricsListener class.
PiperOrigin-RevId: 411517319
2021-11-22 17:21:14 +00:00
andrewlewis
5b22b06ec4 Encapsulate attributes and uniforms within Program
Document that apps should retain `GlUtil.Program` while the program is in use,
and keep a reference to attributes/uniforms within the program to make sure
they don't get GC'd causing any allocated buffers passed to GL to become
invalid.

Tested manually by running gldemo and transformer.

PiperOrigin-RevId: 411516894
2021-11-22 17:21:14 +00:00
christosts
f594d914b5 Make SynchronousMediaCodecAdapter final
PiperOrigin-RevId: 411047838
2021-11-22 16:58:15 +00:00
tonihei
14b40506da Set LogSessionId on MediaDrm session.
PiperOrigin-RevId: 411047184
2021-11-22 16:56:47 +00:00
tonihei
e935e0370d Add missing @DoNotInline annotations.
PiperOrigin-RevId: 411041225
2021-11-19 15:17:52 +00:00
tonihei
48118f3c87 Set LogSessionId on MediaParser for DASH sources.
This requires some plumbing through DashMediaPeriod and DashChunkSource.

PiperOrigin-RevId: 411012115
2021-11-19 15:16:39 +00:00
tonihei
9af85d9b25 Move DrmSessionManager initial player setup to its own method.
Currently, DrmSessionManager takes player specific values (= the
playback looper) through (pre)acquireSession calls and requires
the caller to pass in the same values every time.

Instead, we can configure the DrmSessionManager for playback with
a player once before it's being used. We can't simply extend the
prepare() method as prepare may be called before the player is
created to prewarm the DrmSessionManager.

The new method also takes a PlayerId which is bound to the lifetime
of the player similar to the playback looper.

To avoid breakage of custom MediaSources with DRM, we can keep the
old the SampleQueue.createWithDrm method as deprecated.

PiperOrigin-RevId: 410998240
2021-11-19 15:12:13 +00:00
krocard
00a13a5159 Add a warning about device specific tunneling issues
There has been many issue recently about tunneling
that have no obvious solutions and we don't have the
bandwidth to dive into the platform root cause.

- https://github.com/google/ExoPlayer/issues/9661
- https://github.com/google/ExoPlayer/issues/9133
- https://github.com/google/ExoPlayer/issues/9317
- https://github.com/google/ExoPlayer/issues/9502

PiperOrigin-RevId: 410834262
2021-11-19 15:11:07 +00:00
tonihei
4ebe046b5e Set LogSessionId on MediaParser for progressive playbacks.
PiperOrigin-RevId: 410766492
2021-11-19 15:06:49 +00:00
tonihei
26153add56 Set LogSessionId on MediaCodec.
PiperOrigin-RevId: 410516082
2021-11-19 14:59:19 +00:00
tonihei
fb09c4615c Set LogSessionId on AudioTrack.
This requires forwarding the PlayerId to the AudioSink.

PiperOrigin-RevId: 410509605
2021-11-19 14:58:29 +00:00
christosts
57212088c6 Enable immediate codec start after flush
We verified there is a race condition in the
AsynchronousMediaCodecAdapter when flushing the adapter
multiple times. The race condition results in calling MediaCodec.start()
and MediaCodec.flush() in parallel and that makes the MediaCodec
raise an exception.

This changes the default behavior to call MediaCodec.start() on the
same thread after MediaCodec.flush() to avoid the race condition.

#minor-release

PiperOrigin-RevId: 410509388
2021-11-19 14:57:37 +00:00
olly
c046f40fd0 Fixes for some minor misc issues
- Unnecessary deprecation suppressions
- Dead code
- Broken Javadoc

PiperOrigin-RevId: 409357884
2021-11-19 14:44:25 +00:00
tonihei
1a60b6bea6 Fully support per-track-type selection overrides.
Currently, TrackSelectionOverrides are documented as being applied
per track type, meaning that one override for a type disables all
other selections for the same track type. However, the actual
implementation only applies it per track group, relying on the
track selector to never select another renderer of the same type.

This change fixes DefaultTrackSelector to fully adhere to the
TrackSelectionsOverride definition. This solves problems when
overriding tracks for extension renderers (see Issue: google/ExoPlayer#9675)
and also simplifies a workaround added to StyledPlayerView.

#minor-release

PiperOrigin-RevId: 409121711
2021-11-19 14:40:02 +00:00
christosts
0221e0e159 Async buffer queueing: do not throw from flush/shutdown
The asynchronous MediaCodec adapter queues input buffers in a
background thread. If a codec queueuing operation throws an exception,
the buffer enqueuer will store it as a pending exception and re-throw it
the next time the adapter will attempt to queue another input buffer.

The buffer enqueuer's flush() and shutdown() may throw an exception if
the pending error is set. This is subject to a race-condition in which
the pending error can be set while the adapter is flushing/shutting down
the enqueuer, e.g., if an input buffer is still being queued and the
codec throws an exception. As a result, the adapter cannot flush or
shutdown gracefully.

This change makes the buffer enqueuer to ignore any pending error
when flushing/shuttinf down so that the adapter can flush/release
gracefully even if a queueing error was detected.

PiperOrigin-RevId: 409113054
2021-11-19 14:39:00 +00:00
tonihei
961bfaaec3 Update track selection documentation.
The Javadoc of DefaultTrackSelector can be shortened as it's not the
right place to document detailed options of the Player track selection
parameters.

The documentation page about track selection is updated to the new
APIs and extended with most relevant options and information needed
to work with ExoPlayer's track selection API.

#minor-release

PiperOrigin-RevId: 409088989
2021-11-19 14:36:49 +00:00
tonihei
5d8bb7ddd2 Plumb PlayerId to MediaSource.
MediaSource can be reused with other Player instances after they
have been released, so we need to set the PlayerId when preparing
the source. Access can mostly be handled by the implementation in
BaseMediaSource.

PiperOrigin-RevId: 408878824
2021-11-19 14:35:52 +00:00
tonihei
aa0b0bfcbc Add missing deprecation for old track selection override getters.
The setters in the Builder are already deprecated and using the
old getter is error-prone as they only return the overrides set
with the deprecated setters.

Issue: google/ExoPlayer#9665
PiperOrigin-RevId: 408817640
2021-11-19 14:30:28 +00:00
tonihei
ff615607c0 Plumb PlayerId to renderers.
We can rename the existing setIndex method to a more generic init
as this method is only called by EPII and implemented by BaseRenderer
anyway.

PiperOrigin-RevId: 408616055
2021-11-19 14:26:51 +00:00
tonihei
609cf02330 Add missing @Nullable for ExoPlayer.getPlayerError.
#minor-release

Issue: google/ExoPlayer#9660
PiperOrigin-RevId: 408323173
2021-11-09 10:10:11 +00:00
ibaker
dba30ff863 Add @Deprecated to MediaSourceFactory deprecated overrides
This is needed to ensure the deprecation warning appears on usages in
Android Studio and in javadoc.

#minor-release

PiperOrigin-RevId: 408319182
2021-11-09 10:10:11 +00:00
tonihei
54af82a23f Create wrapper class for LogSessionId.
The platform class is only available from API 31, so we need
a generic wrapper that can be used on all API levels. The wrapper
essentially provides an identifier for a player instance, so naming
it accordingly.

PiperOrigin-RevId: 408292802
2021-11-09 10:10:10 +00:00
tonihei
8900d655d9 Rename indexes to indices in TrackSelectionOverrides
And in a couple of related places.

This is for consistency with the rest of the codebase where
we exclusively use indices.

#minor-release

PiperOrigin-RevId: 408273372
2021-11-09 10:10:10 +00:00
ibaker
429672903f Migrate usages of deprecated MediaItem symbols
#minor-release

PiperOrigin-RevId: 407847729
2021-11-09 10:10:10 +00:00
christosts
81356a222a Add experimental method to turn-off async flush
When operating the MediaCodec in asynchronous mode, after a
MediaCodec.flush(), we start MediaCodec in the callback thread,
which might trigger errors in some platforms. This change adds an
experimental flag to move the call to MediaCodec.start() back to the
playback thread.

PiperOrigin-RevId: 407801013
2021-11-09 10:10:10 +00:00
tonihei
9ae5083102 Fix track selection with mixed empty/non-empty overrides
When we have multiple overrides for TrackGroups associated with
one renderer, we need to look at all of them to find the non-empty
one. Empty ones should only be used to remove previously selected
tracks for this group and otherwise be ignored.

Currently this is broken because the first override (no matter if
it's empty or not) is used as the final selection for this renderer.

Issue: google/ExoPlayer#9649

#minor-release

PiperOrigin-RevId: 407792330
2021-11-09 10:10:10 +00:00
christosts
aed08128c2 Minor fix in AsynchronousMediaCodecAdapter.signalEndOfInputStream()
PiperOrigin-RevId: 407635099
2021-11-09 10:10:10 +00:00
huangdarwin
edc4bd5be1 GL: Misc GL refactoring.
* Remove GlUtil.Program String[] constructor to unify and just use the
  String constructor.
* Add getAttributeArrayLocationAndEnable() to simplify things a tiny bit.
* Increase usage of constant values.

PiperOrigin-RevId: 407570340
2021-11-09 10:10:10 +00:00
christosts
91a0f0203b Add DefaultMediaCodecFactory.getCodecAdapter() method
Add protected method DefaultRenderersFactory.getCodecAdapter(), so that
subclasses of DefaultRenderersFactory that override
buildVideoRenderers() or buildAudioRenderers() can access the
DefaultRenderersFactory codec adapter factory and pass it to
MediaCodecRenderer instances they may create.

#minor-release

PiperOrigin-RevId: 407345431
2021-11-09 10:09:13 +00:00
olly
8f88127b8e Prepare for adding ServerSideInsertedAdsMediaSource for IMA
PiperOrigin-RevId: 407274072
2021-11-09 10:09:13 +00:00
tonihei
cb86a8af49 Suppress lint warning about IntDef assignment.
The values returned by the framework method are equivalent to the local IntDef values.

PiperOrigin-RevId: 407048748
2021-11-09 10:07:30 +00:00
christosts
72f56760bb Replace map with a switch statement in bandwidth meter implementations
#minor-release

PiperOrigin-RevId: 407042882
2021-11-09 10:07:30 +00:00
ibaker
686f2ca96d Migrate usages of Window-based Player methods
Where this introduced an inconsistency (e.g. assigning to something
called `windowIndex`), I generally renamed the transitive closure of
identifiers to maintain consistency (meaning this change is quite
large). The exception is code that interacts with Timeline and Window
directly, where sometimes I kept the 'window' nomenclature.

#minor-release

PiperOrigin-RevId: 407040052
2021-11-09 10:07:30 +00:00
tonihei
90a4383c6b Remove wrong IntDef usage.
The variable is storing OpenGL's draw mode, which is different from Projection.DrawMode.

PiperOrigin-RevId: 406820812
2021-11-09 10:07:30 +00:00
tonihei
665910ab76 Suppress lint warning about wrong IntDef assignment.
The return values of AudioManager.getPlaybackOffloadSupport are the same as the values defined in C.AudioManagerOffloadMode.

PiperOrigin-RevId: 406817413
2021-11-09 10:07:30 +00:00
tonihei
7b84d6b051 Throw pending clipping errors created during period preparation.
Currently, clipping errors are never thrown if we already have a
MediaPeriod. This may happen for example for ProgressiveMediaSource
where we need to create a MediaPeriod before knowing whether clipping
is supported. Playback will still fail, but with unrelated assertion
errors that are hard to understand for users.

Fix this by setting the pending error on the ClippingMediaPeriod.

#minor-release

Issue: Issue: google/ExoPlayer#9580
PiperOrigin-RevId: 406809737
2021-11-09 10:07:30 +00:00
tonihei
10dcdd1df5 Add large renderer position offset.
This helps to prevent issues where decoders can't handle negative
timestamps. In particular it avoids issues when the media accidentally
or intentionally starts with small negative timestamps. But it also
helps to prevent other renderer resets at a later point, for example
if a live stream with a large start offset is enqueued in the playlist.

#minor-release

PiperOrigin-RevId: 406786977
2021-11-09 10:07:00 +00:00
huangdarwin
bf18aae99d GL: Make ProjectionRenderer's GL Program @MonotonicNonNull.
PiperOrigin-RevId: 406385758
2021-11-09 10:07:00 +00:00
olly
a3b71d5400 Remove dependency from common tests to exoplayer
PiperOrigin-RevId: 406354526
2021-11-09 10:07:00 +00:00
christosts
2c98e8bb4f ExoPlayer.Builder: lazily initialize default components
Initialize default components lazily in ExoPlayer.Builder to avoid
redundant component instantiations, useful in cases where apps
overwrite default components with ExoPlayer.Builder setters.

The fields in ExoPlayer.Builder are wrapped in a Supplier (rather than
just making then nullable and initializing them in
ExoPlayer.Builder.build()) so that we maintain the proguarding
properties of this class.

PiperOrigin-RevId: 406345976
2021-11-09 10:06:11 +00:00
ibaker
a60843ead5 Migrate callers of deprecated C.java methods to Util.java
#minor-release

PiperOrigin-RevId: 406166670
2021-11-08 15:17:26 +00:00
huangdarwin
7f64a5a1aa Transformer GL: Simplify GL program handling.
Relanding 9788750ddb, with some changes
applied to improve primarily readability, naming,
and nullness checks.

PiperOrigin-RevId: 406101742
2021-11-08 15:15:02 +00:00
ibaker
d83fe03d88 Update most Player parameter & doc references from Window to MediaItem
Only deprecated references remain.

Usages of the deprecated methods will be migrated in a follow-up change.

#minor-release

PiperOrigin-RevId: 405927141
2021-11-08 15:12:32 +00:00
ibaker
b60acca872 Clarify that ExoPlayer.Builder constructor overloads only exist for R8
Also add a setRenderersFactory() method, so that all constructor-provided
components can also be passed via setters.

This comment already appears on the constructor that takes all
components, but it applies to these ones as well.

PiperOrigin-RevId: 405917343
2021-11-08 15:11:15 +00:00
ibaker
d39ffa5a34 Add missing javadoc to new ExoPlayer.Builder constructors
Should have been part of
<unknown commit>

#minor-release

PiperOrigin-RevId: 405880982
2021-10-27 17:49:43 +01:00
ibaker
9a49a9ccda Remove all references to @NonNull
Our package-info.java files are annotated with @NonNullApi which results
in everything being non-null by default, so this annotation is never
needed.

#minor-release

PiperOrigin-RevId: 405864737
2021-10-27 17:48:40 +01:00
andrewlewis
651985b0ac Move doc-files to new package name
PiperOrigin-RevId: 405862549
2021-10-27 13:08:53 +01:00
olly
aff15ae9ee Set assumedVideoMinimumCodecOperatingRate for all playbacks
PiperOrigin-RevId: 405736227
2021-10-27 09:23:28 +01:00
Andrew Lewis
933e207b3e Update to androidx.media3
PiperOrigin-RevId: 405656499
2021-10-27 09:12:46 +01:00