13370 Commits

Author SHA1 Message Date
bachinger
28b8ae7076 Seek to start position when reusing the last used shared period
The last used shared media period is reused after all media periods have been
released. In case the sample streams are already filled up, they need to be
reset or they download samples from the current position up to the seek
position. This causes long buffering states or load stuck exceptions.

A seek when reusing the shared period takes care for reseting the period or
internally seeks to the current position in the already available samples.

#minor-release

PiperOrigin-RevId: 428484187
2022-02-17 10:35:31 +00:00
tonihei
6048ca2faa Make usage of live minDurationForQualityIncrease more consistent
We have two ways to choose the minDurationForQualityIncreaseMs value in
AdaptiveTrackSelection: use the configured value for non-live or when
enough buffered data is available, or use a fraction of the available
duration to allow switching when playing close to the live edge.

The decision point when to use which value isn't quite consistent because
we compare against availableDurationUs before making the adjustments. This
means there is range of values where no up-switching is possible despite
perfect buffering. Fix this by choosing the minimum of both values.

Issue: google/ExoPlayer#9784

#minor-release

PiperOrigin-RevId: 428474332
2022-02-17 10:34:42 +00:00
bachinger
6197a712ff Use content timeline to get ad group index and ad index in ad group
The timeline used to map ad groups to periods needs to report the original content period duration without subtracting the serverside inserted ad duration. When marking played ads in onPositionDiscontinuity, the public timeline has been used which crashed the app when the ads media source is playing on a window index different to zero (in a playlist).

#minor-release

PiperOrigin-RevId: 428465833
2022-02-17 10:33:44 +00:00
olly
f3a9c6f539 Rewrite AnalyticsCollector to use new track APIs
PiperOrigin-RevId: 428455848
2022-02-17 10:32:55 +00:00
andrewlewis
6adf2f8c91 Improve transformer activity layout
On Samsung S21 with light theme the debug labels weren't showing up because the player view was visible (with a black background) while the transformation was in progress, matching the debug label text color. Hide the player view until the transformation is complete to fix this.

Also tweak the layout slightly to add space between the card border and the labels.

#mse-bug-week

PiperOrigin-RevId: 428455824
2022-02-17 10:31:56 +00:00
krocard
743a46e1b2 Do not reference AnalyticsCollector in common constructor
This prevents it to be stripped by R8 if a custom one is
passed.

#minor-release

PiperOrigin-RevId: 428034999
2022-02-17 10:30:59 +00:00
christosts
437e178ef8 Create MediaNotification.Provider
Define MediaNotification.Provider so that apps can customize
notification UX. Move MediaNotificationManager's functionality
around notifications on DefaultMediaNotificationProvider

PiperOrigin-RevId: 428024699
2022-02-17 10:30:01 +00:00
hschlueter
40a5c01275 Add helpers for FBOs in GlUtil.
FBOs will be used in follow-up CLs to chain multiple GL
shader programs in Transformer.

PiperOrigin-RevId: 428016050
2022-02-17 10:29:06 +00:00
bachinger
a72f04f9b0 Resolve media period ids in multi-period windows
Ignorable ad periods are skipped to resolve the media period id with the
ad playback state of the resulting period. In case of a change in the period
position un-played ad periods are rolled forward to be played.

PiperOrigin-RevId: 428011116
2022-02-17 10:26:59 +00:00
tonihei
4ef007cae7 Add some missing thread verifications
This adds some missing calls to verifyApplicationThread to
ExoPlayerImpl.

Now all public methods start with this call, except listener
registrations because registration after construction on a background
thread is allowed and supported.

PiperOrigin-RevId: 428009498
2022-02-17 10:26:09 +00:00
tonihei
6dae8746ad Stop using SimpleExoPlayer for tests
The class is deprecated and all tests should preferably use the
non-deprecated code paths.

PiperOrigin-RevId: 428007986
2022-02-17 10:25:19 +00:00
tonihei
0314d14737 Set character limit for accessability strings to NONE
They are not normally displayed in any size-restricted UI element and don't
need a character limit.

#minor-release

PiperOrigin-RevId: 427998164
2022-02-17 10:23:57 +00:00
krocard
8f7c91a1ad Split AnalyticsCollector in interface and default Impl
This will allow R8 to strip out the implementation
if it is not needed for an app.

#minor-release

PiperOrigin-RevId: 427983730
2022-02-17 10:23:00 +00:00
huangdarwin
b5ed01d479 Transformer GL: Implement auto-scaling to preserve input frame.
PiperOrigin-RevId: 427982223
2022-02-17 10:21:59 +00:00
kimvde
8b180eb040 Remove Transformer deprecated methods that were never released
#minor-release

PiperOrigin-RevId: 427965501
2022-02-17 10:21:09 +00:00
huangdarwin
f33dff64d6 Rollback of 2848240a8c
*** Original commit ***

Update gradle wrapper

To fix transformer demo + Nexus emulator bug.

#minor-release

***

PiperOrigin-RevId: 427952642
2022-02-17 10:20:08 +00:00
tonihei
27383068bd Make ExoPlayerImpl an ExoPlayer implementation
All the functionality of SimpleExoPlayer has moved to ExoPlayerImpl.
Hence, ExoPlayerImpl can fulfil its own name and become an ExoPlayer
implementation. As a result, ExoPlayer.Builder can return ExoPlayerImpl
directly without using SimpleExoPlayer at all.

#minor-release

PiperOrigin-RevId: 427947028
2022-02-17 10:19:06 +00:00
olly
8d09da4abf Trim CodecDelay/PreSkip In New OpusDecoder Instances By Default
PiperOrigin-RevId: 427819209
2022-02-17 10:18:14 +00:00
olly
1af8d57032 Fix Sample Size For Supplemental Data In MatroskaExtractor
For when a track is both encrypted and has supplemental data, the sample size will be equal to `block sample size - encryption data size`.

PiperOrigin-RevId: 427807612
2022-02-17 10:17:19 +00:00
claincly
ba3558c0c6 Disable setting profile/level for API level < 24.
We have seen devices running on API21/23 fail transcoding because of setting
encoding profile/level.

Some devices (ale-123/nexus 7) on API21 returns ENOSYS (Function not
implemented) when being configured with a profile setting. (although API21
introduced the capability of setting encoding profile)

Some devices (nexus 5) on API23 fails configuration with a specific parameter
set, despite advertising support for it.

Not setting the baseline profile has no effect on encoding, because when not
set, the encoding will pick a suitable profile to use. Since baseline is
the lowest possible profile, the auto-picked value can't be worse than
baseline.

Ref: b/218696352
PiperOrigin-RevId: 427792124
2022-02-17 10:16:23 +00:00
claincly
b9cb87153f Add logging for exceptions thrown while configuring MediaCodec.
PiperOrigin-RevId: 427728320
2022-02-17 10:15:32 +00:00
claincly
12ce9f7c0f Fix the logic to get the max supported encoding level.
On some Android devices, the return value of

```
MediaCodecInfo.getCapabilitiesForType(mimeType).profileLevels
```

contains one entry for each encoding profile, like <profile, maxSupportedLevel>

but on some other devices, there are multiple entries for the same profile,

like <HIGH_PROFILE, LEVEL1>, <HIGH_PROFILE, LEVEL2>, <HIGH_PROFILE, LEVEL3>,
where we need to iterate through all the entries and find the max.

PiperOrigin-RevId: 427727030
2022-02-17 10:14:29 +00:00
tonihei
ad5f2387e0 Add missing Javadoc for AudioAttributes.
#minor-release

PiperOrigin-RevId: 427712140
2022-02-17 10:13:06 +00:00
krocard
5107be6f7f Fix DefaultAudioTrackBufferSizeProvider test
And move them in separate top level classes so that presubmit runs them.

#minor-release

PiperOrigin-RevId: 427482430
2022-02-17 10:12:08 +00:00
tonihei
c3cb2f7cfb Add missing events to AnalyticsListener.
And also add a test that all Player.Listener events are forwarded
to AnalyticsListener.

The AnalyticsCollector also needlessly implemented
Video/AudioRendererEventListener, which is not needed because all of
the equivalent methods are called directly and never through the
interface.

#minor-release

PiperOrigin-RevId: 427478000
2022-02-17 10:10:25 +00:00
olly
018631320b Fix incorrect parameter name
PiperOrigin-RevId: 427474975
2022-02-17 10:09:21 +00:00
kimvde
f36c94e104 Transformer: format test analysis file to JSON
PiperOrigin-RevId: 427469350
2022-02-17 10:07:50 +00:00
tonihei
cd3bef24b5 Simplify StreamRequest.Builder to an Uri Builder and make it public
Right now, the option to build an IMA DAI URI programmatically is still
package-private. To simplify the process, we can remove the StreamRequest
wrapper and directly provide an URI builder.

The same class can provide some package-private helper methods to parse the
created URI.

#minor-release

PiperOrigin-RevId: 427445326
2022-02-17 10:06:51 +00:00
olly
eb6e25b6fc Handle Choreographer.getInstance throwing RuntimeException
#minor-release

PiperOrigin-RevId: 427439588
2022-02-17 10:05:53 +00:00
tonihei
dc0a293c3f Merge listeners in ExoPlayerImpl and add missing constants
There are two sets of listeners in ExoPlayerImpl at the moment,
which can be merged together to use a single ListenerSet. This has
the added advantage that the events that were previously sent
through the ArraySet get additional guarantees provided by ListenerSet
(e.g. correct event ordering and onEvents triggered).

Also add missing constants for onEvents to ensure all Player.Listener
methods have an corresponding constant.

#minor-release

PiperOrigin-RevId: 427415349
2022-02-17 10:04:50 +00:00
olly
64b56cf184 Include opusV2JNI Target In Non-Android Builds
Allow opusV2JNI to be built-for & included-in non-Android build targets by ifdef'ing out the liblog dependency. Also removed libz and libandroid dependencies.

PiperOrigin-RevId: 427269838
2022-02-17 10:03:47 +00:00
ibaker
502bb9afdd Remove LegacyPlayerView from media3
Apps should migrate to PlayerView (called StyledPlayerView in
exoplayer2) before migrating from exoplayer2 to media3.

PiperOrigin-RevId: 427222944
2022-02-17 10:02:49 +00:00
ibaker
3d09bc1388 Remove deprecated CronetDataSource constructors
#minor-release

PiperOrigin-RevId: 427216911
2022-02-17 10:01:00 +00:00
tonihei
9042aa7c7a Misc clean-up in ExoPlayerImpl.
This brings listener invocations closer together and removes
unnecessary methods.

Also fixes a bug where a change in track selection parameters only
queued a callback but never flushed it to actually inform the
listeners.

#minor-release

PiperOrigin-RevId: 427201691
2022-02-08 17:22:26 +00:00
tonihei
6dbf9cac8c Avoid special-casing AnalyticsCollector when informing listeners.
In some cases (whose where we previously used EventListener),
AnalyticsCollector is registered as a listener to receive updates,
in other cases it is called directly.

Avoid this inconsistent handling by registering it as normal listener
and removing all callbacks that are handled by the normal listener flow.

The remaining direct usages of AnalyticsCollector calls are those
callbacks that have no equivalent in Player.Listener.

#minor-release

PiperOrigin-RevId: 427201525
2022-02-08 17:21:34 +00:00
christosts
258925d5f3 Android 12L: Always set codec max output channels
With this change, MediaCodecAudioRenderer always configures MediaCodec
with max output channels set to 99 on API 32+.

#minor-release

PiperOrigin-RevId: 427192801
2022-02-08 17:20:35 +00:00
claincly
a41bdbad31 Make Codec an interface and introduce DefaultCodec.
PiperOrigin-RevId: 427191610
2022-02-08 17:19:42 +00:00
tonihei
9582a9f099 Remove self-listening from ExoPlayerImpl
SimpleExoPlayer used to register a listener on ExoPlayerImpl for
the old EventListener callbacks. Now both classes are merged, this is
no longer needed and should be removed in favor of calling methods
directly.

#minor-release

PiperOrigin-RevId: 427187875
2022-02-08 17:18:32 +00:00
tonihei
3ab5437c85 Fix delayed discontinuity for failed ad insertions.
We have logic to not immediately interrupt playback when an ad group
fails to load and instead let the current content play and transition
at the point where the ad group should have been.

This logic was broken by dcbdbe5341 because of one of the conditions
used MediaPeriodId.adGroupIndex, which is always -1 for content ids.
It still worked for the last ad group because the next ad group index
was C.INDEX_UNSET.

Fix the issue and amend the test that was meant to catch this to test
the ad failures for the last ad and previous ads.

Also fix the PositionInfo reported in such a case, which was also wrong.

Issue: google/ExoPlayer#9929

#minor-release

PiperOrigin-RevId: 427143223
2022-02-08 17:17:32 +00:00
tonihei
c832bf495e Add missing calls to AnalyticsCollector
PiperOrigin-RevId: 427133919
2022-02-08 11:07:50 +00:00
tonihei
5cc3ce9a50 Remove deprecated EventListener
PiperOrigin-RevId: 427133817
2022-02-08 11:07:50 +00:00
tonihei
287182952d Fix the position of IntDefs to match TYPE_USE
#minor-release

PiperOrigin-RevId: 427131569
2022-02-08 11:07:50 +00:00
tonihei
caf62842c4 Rollback of 2a7743346c
*** Original commit ***

Rollback of 1521e50307

*** 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.

#...

***

PiperOrigin-RevId: 427131438
2022-02-08 11:07:50 +00:00
tonihei
d807b87e34 Rollback of 795762545b
*** Original commit ***

Rollback of d93b0093ae

*** 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 11:07:50 +00:00
olly
1270eb012d Fix For Sample-To-Bytes Calculation In OpusDecoder
Aligning the byte size calculation with the sizes defined in opus_jni.cc
for the `outputFloat=true` case

#minor-release

PiperOrigin-RevId: 427028982
2022-02-08 11:07:50 +00:00
claincly
31aa9d458d Fix profile-level setting.
On some old devices, the encoding level needs to be set with the encoding
profile, but not on newer devices.

The profile/level override is applied by following
https://developer.android.com/guide/topics/media/sharing-video

PiperOrigin-RevId: 427008536
2022-02-08 11:07:50 +00:00
olly
fab5dfa156 Rollback of d93b0093ae
*** 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 11:07:50 +00:00
olly
c2cb22a056 Rollback of 1521e50307
*** 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 11:07:50 +00:00
olly
1f7174e731 Revert of 87420e5f9bd1671cd3068185f7358f5faba53e71
PiperOrigin-RevId: 426996878
2022-02-08 11:07:43 +00:00
olly
631b107bda Revert of 9c8c0a59823e2a49451fbdf7040107c6cea43cc5
PiperOrigin-RevId: 426994820
2022-02-08 11:07:24 +00:00