4698 Commits

Author SHA1 Message Date
ibaker
018d177012 Rollback of 9ec8678525
*** Original commit ***

Don't call MediaDrm.setLogSessionId in FrameworkMediaDrm

This method throws an UnsupportedOperationException on some Android 12
devices.

***

PiperOrigin-RevId: 433708582
2022-03-15 00:25:49 +00:00
Saurabh kumar
c9ce23a1b9 9432 : Added support for filtering forced text tracks
1. Added filtering for forced text tracks.
2. Support for disabling all other tracks other than forced track when None is selected.
2022-03-12 01:15:16 +05:30
bachinger
5bf123165f Avoid rebuffering at the end of SSAI post-rolls
When the start position of a MediaPeriodInfo is equal or higher than the duration,
we set the start position to `duration - 1` to end on the last frame. With server
side inserted ad streams, this has the effect that we actually need to seek back to
the last content frame after a post-roll.

This is desirable when actually ending on that frame but produces a BUFFERING event
when transitioning from an SSAI stream with a post-roll to the next media item in
the playlist. This change sets the start position to the duration when we are
clipping the last content period of an SSAI stream that is played in a playlist.

PiperOrigin-RevId: 433445680
2022-03-09 12:22:02 +00:00
bachinger
25e5680415 Ignore MetadataRenderer when evaluating SSAI period transitions
This makes the reading period advance early as expected at the end of an ad
period. Before this change the reading position of the metadata renderer
prevented advancing the period until metadata arrived after the start position of
the following period. Only then the reading position of the metadata renderer
is updated and beyond the start position of the following period which is a
condition to advance the reading period.

Because transitioning to the next period is a virtual transition and the
SharedMediaPeriod keeps reading from the same underlying sample streams, the
metadata renderer can safely be ignored for this check.

#minor-release

PiperOrigin-RevId: 432646037
2022-03-05 14:16:43 +00:00
olly
d7df426069 Simplify application of track overrides
PiperOrigin-RevId: 432485797
2022-03-04 18:54:25 +00:00
olly
aafe5f48bd DownloadHelper: Add getTracksInfo
We will be migrating our track selection UI components to be
based on TracksInfo. We need DownloadHelper to expose TracksInfo
to make it compatible with such components.

PiperOrigin-RevId: 432474487
2022-03-04 18:10:45 +00:00
olly
b83c2cb8cb DownloadHelper: Support multiple track selection overrides
addTrackSelectionForSingleRenderer takes a list of legacy overrides,
which are then set on the supplied parameters one at a time to run
track selection. This allows multiple overrides for a single track
type to be applied in the download use case, despite it not being
possible to place such overrides directly into a single parameters.

For new style overrides, multiple overrides for the same track type
can be placed directly into a single parameters. Therefore we'll be
able to replace use of addTrackSelectionForSingleRenderer with use
of addTrackSelection, which is a much cleaner API. For this to work,
we need to make DownloadHelper apply multiple overrides in this case.

PiperOrigin-RevId: 432459834
2022-03-04 17:06:26 +00:00
andrewlewis
e66d0c9039 Fix E-AC3 output capability check without sample rate
#minor-release

PiperOrigin-RevId: 432189509
2022-03-07 11:35:09 +00:00
ibaker
540f2061cb Deprecate SingleSampleMediaSource.Factory#setTrackId
This method is no longer needed since we added SubtitleConfiguration#id
in 59d98b9a4e.

Issue: google/ExoPlayer#10016

#minor-release

PiperOrigin-RevId: 432169262
2022-03-07 11:31:27 +00:00
olly
2cb2f6ded4 DownloadHelper: Accept generic TrackSelectionParameters
DownloadHelper is in the ExoPlayer module, so there's no reason
why it can't use ExoPlayer specific track selections. That said,
we want our UI components to operate on generic
TrackSelectionParameters, and we want such UI components to be
useful for selecting tracks for download. To keep this interop,
it's necessary to have DownloadHelper accept generic
TrackSelectionParameters, or to require application code to
convert them. The first approach seems preferable!

PiperOrigin-RevId: 432158846
2022-03-03 12:34:30 +00:00
olly
ad81d5dd20 TrackSelectionOverride: Remove select-all-tracks constructor
This constructor always does the wrong thing for non-adaptive groups
containing more than 1 track, because it'll incorrectly generate an
adaptive selection. Replace it with a constructor for specifying a
single track within the group instead.

PiperOrigin-RevId: 431673458
2022-03-03 12:27:28 +00:00
olly
b4e05e00f2 TrackSelectionParameters: Simplify disabling of track types
As evidenced by the somewhat awkward logic in PlayerControlView, the
previous design wasn't very friendly to expected usage. There will be
more usage when the track selection dialog components are migrated,
which would be similarly awkward without this change.

PiperOrigin-RevId: 431407675
2022-03-01 10:14:38 +00:00
Ian Baker
f66c9290ad Merge pull request #10011 from tonykwok:dev-v2
PiperOrigin-RevId: 431395359
2022-03-01 10:11:06 +00:00
ibaker
bbfeb27600 Rollback of 9961d918a9
*** Original commit ***

Rollback of 8d9c4f4774

*** Original commit ***

Rollback of 43b796b64d

*** Original commit ***

Rollback of 08c5b1cb0a

*** Original commit ***

PiperOrigin-RevId: 430905772
2022-03-01 09:49:59 +00:00
christosts
4d518806ea Remove experimental flag for AsynchronousMediaCodecAdapter
The AsyncronousMediaCodecAdapter should call MediaCodec.start()
on the same thread it calls MediaCodec.flush(), i.e. the playback
thread. This change removes the experimental flag that allowed
calling MediaCodec.start() from the callback thread.

The flag was flipped to true already.

PiperOrigin-RevId: 430689665
2022-03-01 09:43:00 +00:00
ibaker
9ec8678525 Don't call MediaDrm.setLogSessionId in FrameworkMediaDrm
This method throws an UnsupportedOperationException on some Android 12
devices.

PiperOrigin-RevId: 430647264
2022-03-01 09:35:42 +00:00
Tony Guo
d7bd15fe59 Add missing @Retention(SOURCE) to UnsupportedDrmException.Reason
This can fix the following warning caused by commit a7aa84a:

Warning: com.google.android.exoplayer2.drm.UnsupportedDrmException.Reason:
The typedef annotation should have @Retention(RetentionPolicy.SOURCE)

 Author:    Tony Guo <tony.guo.peng@gmail.com>
 Date:      Mon Feb 28 10:56:52 2022 +0800
2022-02-28 11:32:04 +08:00
ibaker
1b5a0c11ab Fix DefaultAnalyticsCollectorTest failure when run with JaCoCo
#minor-release

PiperOrigin-RevId: 430189385
2022-02-22 17:07:09 +00:00
olly
25e58f5f2a Remove deprecated Player track methods
getCurrentTrackGroups and getCurrentTrackSelections are
retained for now, but moved from Player to ExoPlayer, to
ease the transition for some application code that currently
uses these methods.

PiperOrigin-RevId: 430036355
2022-02-22 10:58:21 +00:00
ibaker
9961d918a9 Rollback of 8d9c4f4774
*** Original commit ***

Rollback of 43b796b64d

*** Original commit ***

Rollback of 08c5b1cb0a

*** Original commit ***

Wire up MediaMetricsListener and add configuration to...

***

PiperOrigin-RevId: 429585773
2022-02-22 10:34:13 +00:00
Ian Baker
87d8ca0af2 Reformat some javadoc 2022-02-18 15:02:33 +00:00
olly
c7ea8114e9 Move track type from TrackGroupInfo to TrackGroup
The track type is derived solely from the content. It does
not depend on any runtime properties such as the player's
capabilities of user track selection. Hence it belongs in
TrackGroup rather than TrackGroupInfo.

Note that this avoids TrackSelectionOverride from having to
re-derive the track type internally.

PiperOrigin-RevId: 429303312
2022-02-17 16:20:21 +00:00
olly
8e7ab9c811 Add TracksInfo methods for track selection UI
We need TracksInfo.hasTracksOfType to determine which tabs to
display in TrackSelectionDialog.

We need TrackGroupInfo.isAdaptiveSupported to determine whether
to allow multiple selection (check boxes) or not (radio buttons).

PiperOrigin-RevId: 428793739
2022-02-17 14:24:02 +00:00
olly
daf72f518c Flatten TrackSelectionParameters
PiperOrigin-RevId: 428747243
2022-02-17 14:24:02 +00:00
bachinger
940e934b58 Skip played server side inserted ads in a single period window
This change makes sure played server side ads are skipped in a single period
timeline. It avoids creating an ad-MediaPeriodInfo for played postrolls and
creates a content info instead. It also sets the end position for content infos
that terminate the stream before the stream is actually finished. This prevents
the player from continue playing the remaining media delivered by the
MediaPeriod.

We also make sure that the discontinuity of played ads are not reported because
there is actually no discontinuity.

#minor-release

PiperOrigin-RevId: 428734387
2022-02-17 14:24:02 +00:00
bachinger
3b39e3bd19 Do not manipulate the duration of SSAI periods in FakeTimeline
#minor-release

PiperOrigin-RevId: 428727560
2022-02-17 14:24:02 +00:00
olly
c90745d956 Add getFormat and length to TrackGroupInfo
PiperOrigin-RevId: 428520090
2022-02-17 11:51:07 +00:00
bachinger
3a7f73f1e2 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 11:44:22 +00:00
tonihei
7907f4e047 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 11:41:01 +00:00
olly
b6317837e2 Rewrite AnalyticsCollector to use new track APIs
PiperOrigin-RevId: 428455848
2022-02-17 11:34:08 +00:00
krocard
1087b2f6f6 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 11:27:07 +00:00
bachinger
a7b0202712 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 11:16:56 +00:00
tonihei
00dbb780f1 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 11:13:31 +00:00
tonihei
8be677a426 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 11:10:02 +00:00
krocard
e5f2e44c29 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 11:03:17 +00:00
tonihei
4b794e57ca 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:49:23 +00:00
krocard
173787e8ce 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:21:17 +00:00
tonihei
36ef3328d9 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:17:50 +00:00
olly
d084a71278 Handle Choreographer.getInstance throwing RuntimeException
#minor-release

PiperOrigin-RevId: 427439588
2022-02-17 10:03:26 +00:00
tonihei
86afae9c3e 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-09 10:27:55 +00:00
tonihei
db1762b417 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:38:30 +00:00
tonihei
121013d35e 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:34:57 +00:00
christosts
279fdb5227 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:31:14 +00:00
tonihei
17159f66db 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:24:02 +00:00
tonihei
80cdfd0cf0 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:20:22 +00:00
tonihei
2e34f9d552 Add missing calls to AnalyticsCollector
PiperOrigin-RevId: 427133919
2022-02-08 12:34:07 +00:00
tonihei
d04ecb3cb7 Remove deprecated EventListener
PiperOrigin-RevId: 427133817
2022-02-08 12:34:07 +00:00
tonihei
c381ff25e1 Rollback of 03e645bab3
*** Original commit ***

Rollback of 9b8ed581d0

*** Original commit ***

Add missing imports to ExoPlayerImpl

These were missed in 3bb0210d22

#minor-release

***

***

PiperOrigin-RevId: 427131696
2022-02-08 12:34:06 +00:00
tonihei
17050e8b59 Fix the position of IntDefs to match TYPE_USE
#minor-release

PiperOrigin-RevId: 427131569
2022-02-08 12:34:06 +00:00
tonihei
8d9c4f4774 Rollback of b0abdade50
*** Original commit ***

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.

#...

***

PiperOrigin-RevId: 427131438
2022-02-08 12:34:06 +00:00