4698 Commits

Author SHA1 Message Date
tonihei
ddbd9512da Rollback of 12be2bc357
*** Original commit ***

Rollback of 3bb0210d22

*** Original commit ***

Move SimpleExoPlayer logic into ExoPlayerImpl

This makes SimpleExoPlayer a simple forwarding wrapper which can be
removed in the future.

The changes are all purely mechanical with none of the potential further
simplifications made yet...

***

PiperOrigin-RevId: 427131338
2022-02-08 12:34:06 +00:00
olly
7682a6001f Rollback of 3bb0210d22
*** Original commit ***

Move SimpleExoPlayer logic into ExoPlayerImpl

This makes SimpleExoPlayer a simple forwarding wrapper which can be
removed in the future.

The changes are all purely mechanical with none of the potential further
simplifications made yet. The only exceptions are name clashes where
either EPI or SEP was calling a method in one of the classes and both
classes had different implementations for the same method name. In these
cases we needed to disambiguate between the two different
implementations (e

***

PiperOrigin-RevId: 426997821
2022-02-08 12:34:06 +00:00
olly
43b796b64d Rollback of 08c5b1cb0a
*** Original commit ***

Wire up MediaMetricsListener and add configuration to disable it.

The listener will automatically forward diagnostics info to the
Android platform. ExoPlayer.Builder gets a new setter that allows
to disable this feature if required.

#minor-release

***

PiperOrigin-RevId: 426997342
2022-02-08 12:34:06 +00:00
olly
2db8807aac Revert of b19ced30c4c2853b09af3382b86f84c31b3a5af5
PiperOrigin-RevId: 426996878
2022-02-08 12:33:53 +00:00
olly
2e4bcd47cd Rollback of 9b8ed581d0
*** Original commit ***

Add missing imports to ExoPlayerImpl

These were missed in 3bb0210d22

#minor-release

***

PiperOrigin-RevId: 426996503
2022-02-08 12:33:53 +00:00
olly
b946944eca Revert of cf1dcede591e3db5481ef578e0637e271be8f336
PiperOrigin-RevId: 426994820
2022-02-08 12:33:46 +00:00
olly
d2bc6dabde Revert of b27349385b61efa3576bb78b59cb07c93fc3a167
PiperOrigin-RevId: 426994559
2022-02-08 12:33:36 +00:00
ibaker
fa5ac86646 Remove deprecated DefaultRenderersFactory constructors
#minor-release

PiperOrigin-RevId: 426938026
2022-02-08 10:53:11 +00:00
ibaker
8374c63409 Remove deprecated ProgressiveMediaSource.Factory setters
#minor-release

PiperOrigin-RevId: 426909957
2022-02-08 10:46:27 +00:00
olly
b27349385b Add missing calls to AnalyticsCollector
PiperOrigin-RevId: 426892085
2022-02-08 10:42:52 +00:00
olly
cf1dcede59 Remove deprecated EventListener
PiperOrigin-RevId: 426876984
2022-02-08 10:39:28 +00:00
ibaker
9b8ed581d0 Add missing imports to ExoPlayerImpl
These were missed in 3bb0210d22

#minor-release

PiperOrigin-RevId: 426872386
2022-02-08 10:36:06 +00:00
ibaker
c235087c11 Remove deprecated ActionFile and ActionFileUpgradeUtil
#minor-release

PiperOrigin-RevId: 426868933
2022-02-08 10:26:35 +00:00
ibaker
b19ced30c4 Fix the position of IntDefs to match TYPE_USE
#minor-release

PiperOrigin-RevId: 426855255
2022-02-07 11:17:31 +00:00
ibaker
136c997d7b Add TYPE_USE to 'frequently used' IntDefs in a backwards-compatible way
This ensures Kotlin usages of these IntDef annotations in the 'old'
position will continue to compile.

'Frequently used' is a subjective judgement. I have a parallel change
that marks all the other public IntDefs in the library as TYPE_USE
(those that I've judged to be 'rarely used' by apps).

A follow-up change will fix the positions of existing usages to be as if
they're only TYPE_USE.

#minor-release

PiperOrigin-RevId: 426427334
2022-02-07 11:13:54 +00:00
ibaker
75932a0216 Mark all public 'rarely used' IntDefs as only TYPE_USE
This is a breaking change if the annotation itself is in use in Kotlin
code. It's judged that the IntDefs in this commit are unlikely to be
referred to often in Kotlin code. This is because they're either:
- Related to esoteric parts of the library, or
- In a common part of the library but only returned from methods (and
  never passed to callback methods).

A follow-up change will fix the positions of existing usages to match
this new config.

#minor-release

PiperOrigin-RevId: 426410237
2022-02-07 11:10:11 +00:00
ibaker
975910a494 Mark @C.SelectionReason as TYPE_USE (only) and use it in more places
This is not backwards compatible if the @SelectionReason annotation is
used in Kotlin code, but before this change there aren't many library
surfaces that return a value annotated with @SelectionReason, so it
seems relatively unlikely that it is in use in any/many apps.

A follow-up change will fix the positions of existing usages to match
this new config.

#minor-release

PiperOrigin-RevId: 426409877
2022-02-07 11:02:54 +00:00
ibaker
a506d245d1 Move @AudioFocusGain from C to AudioFocusManager and make it private
This is only used inside AudioFocusManager, it doesn't need to public.

Also mark it TYPE_USE and update the position to match.

#minor-release

PiperOrigin-RevId: 426407790
2022-02-07 10:59:11 +00:00
ibaker
15d50d0bf0 Remove @C.AudioManagerOffloadMode IntDef
This is only used in DefaultAudioSink, so we could move it there and
make it private - but at that point we might as well refer to the
underlying AudioManager constants instead.

#minor-release

PiperOrigin-RevId: 426407661
2022-02-07 10:55:25 +00:00
ibaker
0c2e77daca Mark all non-public IntDefs as only TYPE_USE
This only changes IntDefs that cannot be used by apps because they're
either private or package-private.

A follow-up change will fix the positions of existing usages to match
this new config.

#minor-release

PiperOrigin-RevId: 426372273
2022-02-04 15:07:19 +00:00
ibaker
6a269baeed Redefine the SSAI URI format with an "ssai" scheme instead of "imadai"
This allows us to remove the IMA naming from DefaultMediaSourceFactory's
SSAI integration.

#minor-release

PiperOrigin-RevId: 426346456
2022-02-04 14:49:52 +00:00
hschlueter
6c061894b0 Make GlProgram an outer class.
This change makes GlUtil.Program an outer class named GlProgram,
and also moves private static helpers as well as the inner classes
Attribute and Uniform which were only used by GlUtil.Program to
GlProgram. Other static utility methods remain in GlUtil.

No functional changes intended.

PiperOrigin-RevId: 426119299
2022-02-04 10:23:39 +00:00
ibaker
564c3bcb49 Mark some unreleased IntDefs as TYPE_USE only
The longer list of targets is only necessary for backwards
compatibility with existing Kotlin code that will stop compiling
if the position of the annotation becomes 'wrong' by marking it only
TYPE_USE. Since none of these IntDefs have been released (except in
media3 alpha1) we don't need to maintain this compatibility.

Also add a comment to all the places that *do* need the longer list of
targets, in order to explain why it's there and discourage copy-pasting
when defining new IntDefs in future.

Also fix some single-element arrays to remove the array notation.

#minor-release

PiperOrigin-RevId: 426108537
2022-02-04 10:16:43 +00:00
tonihei
08c5b1cb0a Wire up MediaMetricsListener and add configuration to disable it.
The listener will automatically forward diagnostics info to the
Android platform. ExoPlayer.Builder gets a new setter that allows
to disable this feature if required.

#minor-release

PiperOrigin-RevId: 426099872
2022-02-04 10:13:14 +00:00
tonihei
7463011b8d Ignore format changes arriving after the media has been removed.
PiperOrigin-RevId: 426089165
2022-02-04 10:06:10 +00:00
ibaker
032df64f15 Fix parameter comments
PiperOrigin-RevId: 425874534
2022-02-04 09:52:19 +00:00
ibaker
63bc675549 Move DAI MediaSource.Factory from constructor parameter to setter
This allows the same DefaultMediaSourceFactory instance to be used as
the contentMediaSourceFactory inside
ImaServerSideAdInsertionMediaSource.

PiperOrigin-RevId: 425846609
2022-02-04 09:38:14 +00:00
tonihei
3bb0210d22 Move SimpleExoPlayer logic into ExoPlayerImpl
This makes SimpleExoPlayer a simple forwarding wrapper which can be
removed in the future.

The changes are all purely mechanical with none of the potential further
simplifications made yet. The only exceptions are name clashes where
either EPI or SEP was calling a method in one of the classes and both
classes had different implementations for the same method name. In these
cases we needed to disambiguate between the two different
implementations (example: ExoPlayerImpl.setListener was renamed to
setEventListener).

#minor-release

PiperOrigin-RevId: 425823095
2022-02-02 10:47:44 +00:00
olly
319ef63510 Use ImmutableMap.Builder.buildOrThrow() instead of deprecated build().
More info: ​go/immutable-map-buildorthrow-lsc

NOTE: if the source of truth for this code is *NOT* `third_party`, please let me know and I'll revert this CL (and please consider upstreaming this change yourself).

#inlineme

Tested:
    TAP for global presubmit queue passed after automated deflaking of failures: http://mondo/deflaker/run/530857d2-45cb-4069-a234-48c5efe945f1 http://mondo/deflaker/run/0dce4296-e6bb-42d2-8b64-b393f45b6ad3
    http://test/OCL:425453729:BASE:425451020:1643699365244:811c1a24
PiperOrigin-RevId: 425616165
2022-02-02 10:36:25 +00:00
tonihei
fc528ebed7 Avoid creating empty playback metrics
In some cases we create empty playback metrics with no corresponding
events (e.g. when an app seeks to a new media item and immediately
releases the player). There is no benefit in having completely empty
metrics entries, so it's cleaner to not report them in such cases.

#minor-release

PiperOrigin-RevId: 425609010
2022-02-02 10:29:12 +00:00
olly
29a6280b1b Rewrite EventLogger to use new track APIs
PiperOrigin-RevId: 425595951
2022-02-02 10:22:05 +00:00
kimvde
75d370d97b Clarify Javadoc of AudioProcessor.queueInput
PiperOrigin-RevId: 425341138
2022-02-01 14:37:05 +00:00
krocard
dc83de997a Make DRM code removable from ProgressiveMediaSource
Add a constructor that takes a DrmSessionManagerProvider.
This allows R8 to strip the default implementation.

#minor-release

PiperOrigin-RevId: 425330083
2022-02-01 14:33:19 +00:00
krocard
82ee82635b Retry AudioTrack with smaller buffer if > 1M
Some phone with limited memory can't allocate bigger
shared memory buffers.
This might or might not be related to Binder's 1M
transaction limit.

Tested on Pixel 4 by setting the minimum buffer size to
1h.

https://github.com/google/ExoPlayer/issues/9712

#minor-release

PiperOrigin-RevId: 425324536
2022-02-01 14:29:36 +00:00
tonihei
022b5144b1 Add getRenderer method to ExoPlayer.
This allows access to custom renderers, for example to send messages
or to access custom fields and methods.

PiperOrigin-RevId: 424878963
2022-02-01 14:11:36 +00:00
tonihei
174d99481a Remove opt-out for suppressing wrong thread usage error.
Enforcing the correct thread usage has been enabled since 2.13.0.
Opting-out of this enforement is dangerous as it can hide very hard
to debug bugs.

PiperOrigin-RevId: 424815808
2022-01-28 14:33:43 +00:00
krocard
901a5a4845 Make audio track min buffer size configurable.
Move the code in its own class as DefaultAudioTrack
is getting very big. It also help for testability.

The new class is easily configurable and highly tested.
Manual test was used to catch any regression.

https://github.com/google/ExoPlayer/issues/8891

PiperOrigin-RevId: 424602011
2022-01-28 10:01:27 +00:00
tonihei
777246d9dc Remove unneccessary nullability.
AnalyticsCollector can't be null when passed into ExoPlayerImplInternal,
so there is no need to pass it around as nullable.

PiperOrigin-RevId: 424594031
2022-01-28 09:58:06 +00:00
tonihei
145e923dce Fix flakiness in DefaultPlaybackSessionManagerTest
Two of the sessions are finished at the same time in the test
and the order of the corresponding callbacks depends on the randomly
generated session string and the order these strings are stored in a
HashSet.

Update test to assert both callbacks are called and they contain the
right arguments, but don't assert on the order of these two callbacks.

PiperOrigin-RevId: 424548819
2022-01-28 09:54:32 +00:00
tonihei
73d9728f6a Enforce unit speed for ad playback
Ad playback shouldn't be affected by manual speed adjustments set
by the user. This change enforces unit speed for ad playback.

Issue: google/ExoPlayer#9018
PiperOrigin-RevId: 424546258
2022-01-28 09:51:09 +00:00
ibaker
be43ac7563 Propagate error policy to ProgressiveMediaSource used for subtitles
This only affects playbacks using the
experimentalUseProgressiveMediaSourceForSubtitles method.

Also update the SingleSampleMediaSource instantiation to be more
similar, to try and highlight differences like this in future.

PiperOrigin-RevId: 424545980
2022-01-28 09:47:36 +00:00
tonihei
8c685aba4b Move playback speed update at period transitions to reading period.
In some cases we need to update the PlaybackParameters at period
boundaries, for example when switching from live to VOD and live
playback speed adjustment was still active at the point of switching.

Currently, we send the update when the playing MediaPeriod changes in
EPII, which is slightly too late because the new speed gets only applied
after the entire existing AudioTrack buffer has been played out.

We can time the update slightly better by updating the values at the
point where we change the reading period. This makes the update slightly
too early because it also applies to all samples currently in the
decoder. But generally, this is a lot better because the time spent
in the decoder is likely to be considerably lower than the duration of
the AudioTrack buffer.

Note that this change isn't perfectly aligning to the period boundary,
but reduces the number of samples with the wrong speed to a minimum.
If we are getting around to add additional code that allows updating
the speed at exactly the boundary, it also needs to be triggered from
the reading period update, so the new code location is also helpful in
the future.

Issue: google/ExoPlayer#9018
PiperOrigin-RevId: 424540551
2022-01-28 09:44:07 +00:00
Andrew Lewis
e58ffc0682 Merge pull request #9893 from moneytoo:mkv-vtt
PiperOrigin-RevId: 424382031
2022-01-28 09:33:35 +00:00
tonihei
caa0a09c2f Finish pending session if there is one before creating a new one.
PiperOrigin-RevId: 423819515
2022-01-25 19:45:46 +00:00
kimvde
5e583d34ee Fix Javadoc formatting
#minor-release

PiperOrigin-RevId: 423314840
2022-01-25 19:37:38 +00:00
bachinger
e2cf266b1c Set the next live ad in ad group to avoid rebuffering
To avoid the `MediaPeriodQueue`to discard the reading period, we can set the next ad of an ad group early and then (possibly) only change it's duration once we receive the actual duration. This way we avoid a rebuffering as a result of the reading period being discarded.

The change also takes care to properly set ad break and their durations when we join the live stream at the moment when an ad is playing.

PiperOrigin-RevId: 423163467
2022-01-25 19:17:42 +00:00
tonihei
7c60e67f84 End finished sessions on timeline updates.
We currently only end sessions on Timeline updates if the associated media
is no longer in the playlist. But we should also end all sessions that are
finished as a result of the timeline update (similar to how this is done for
discontinuities). This issue was introduced by 394ab7bcfd

PiperOrigin-RevId: 423075855
2022-01-25 19:13:49 +00:00
tonihei
301fcd649a Ensure network transfers are associated with the right session
We currently don't check which session is causing a network transfer
(it could be a preloaded item in a playlist). To clearly associate
network transfer data with sessions, we need to keep track of
transferred bytes and transfer time per session.

PiperOrigin-RevId: 422867845
2022-01-25 19:05:44 +00:00
christosts
4502a1ee63 Extend support for audio spatialization in MediaCodecAudioRenderer
With this change, the MediaCodecAudioRenderer configures the MediaCodec
to not downmix audio only if spatialization can be applied. This way,
decoders who are downmixing by default are left doing so when
spatialization cannot be applied. The renderer re-initializes the codec
when spatialization properties change mid-playback.

PiperOrigin-RevId: 422822952
2022-01-25 18:57:50 +00:00
tonihei
b2ecce4d07 Reset some state values when a session is finished.
Currently, we keep the values for dropped/played frames, audio underruns
and current formats from the last session, causing double reporting
of counters and wrong track change reasons for formats. All these
values should be reset when the active session is finished, so that the
new session can start from scratch.

PiperOrigin-RevId: 422798406
2022-01-25 18:49:27 +00:00