1665 Commits

Author SHA1 Message Date
ibaker
10c4a4dfc1 Fix Dackka/Metalava errors in the ExoPlayer module
This makes two types of fix:
1. Align parameter names on overridden methods where the superclass
   has `@param` javadoc.
2. Use `@hide` on `protected final` methods that refer to package-private
   types. This will hide these symbols from Dackka javadoc generation
   but not (currently) from the artefacts distributed on Maven. These
   methods are currently unusable outside their package anyway (e.g. by
   external developers) because of the dependency on a package-private
   type.

This also changes some HLS, SmoothStreaming, and IMA code where I've renamed
parameters of overridden methods to be consistent across the type
hierarchy.

#minor-release

PiperOrigin-RevId: 487472665
2022-11-10 15:15:25 +00:00
Tolriq
6d2e7a1b57 Merge Issue: google/ExoPlayer#10762: Fix ffmpeg jni wrapper returning invalid result codes
Imported from GitHub PR Issue: google/ExoPlayer#10762

This ensure that ffmpeg error code are properly translated to values that the ExoPlayer decoder understand.
The main gain is that it allows the decoder to properly ignore more cases of invalid data and recover.
The second gain is that the other errors are now proper ExoPlayer errors and no more obscure buffer ones.

Fixes: Issue: google/ExoPlayer#10760
Merge 82ceeb77d6df71f5ffb0474db66a36fd6eb8e51a into 972e169bd85b14848dcae75e34f9e95fe87e1f4b
COPYBARA_INTEGRATE_REVIEW=go/exoghi/10762 from Tolriq:ffmpeg_error_code 82ceeb77d6df71f5ffb0474db66a36fd6eb8e51a
PiperOrigin-RevId: 487189910
2022-11-10 14:47:17 +00:00
Googler
39d28304af Add 'Player.getVideoSurfaceSize' that returns the size of the surface
on which the video is rendered.

Design Doc: go/aaos-mu-media-dd

PiperOrigin-RevId: 485884772
2022-11-08 14:09:54 +00:00
rohks
55b82ff8ae Disable failing tests of FlacExtractorSeekTest
PiperOrigin-RevId: 485061783
2022-11-01 16:19:10 +00:00
bachinger
136addf640 Make adding ad live breaks more robust
This change makes adding ad events in live streams more robust by allowing ad
groups to grow in number of ads if more ad events are received than initially
announced by the SDK.

With the IMA prefetch feature, an AdPod can grow in size in certain conditions
like from initially 2 ads to 4 ads being part of the ad group. With this change,
if an additional ad event arrives while the ad group is still being played,
the ad group is expanded. If the event arrives late and the ad group is already
completed, a new group is created for the remaining ads.

This also covers the case where we join the live stream while an ad is being
played and we missed at least one LOADED event from the SDK. Ads of the group
before the first LOADED event are ignored in such a case.

PiperOrigin-RevId: 484214760
2022-10-31 16:29:48 +00:00
samrobinson
dda17db261 Move AudioProcessor to common.
PiperOrigin-RevId: 483699606
2022-10-31 16:03:50 +00:00
Rohit Singh
a413b478f7 Merge pull request #10618 from vishnuchilakala:fix/do_not_send_content_complete_if_midroll_skipped
PiperOrigin-RevId: 482481703
2022-10-24 10:51:21 +00:00
bachinger
325e973ace Add manifest to make gradle build work
PiperOrigin-RevId: 481606248
2022-10-20 02:35:14 +00:00
rohks
6015f052ba Fix instrumentation tests not working via Gradle
PiperOrigin-RevId: 475560401
2022-10-19 22:54:45 +00:00
bachinger
072f376b48 Add withAvailableAd for server side inserted ad groups
#minor-release

PiperOrigin-RevId: 472714732
2022-10-19 21:33:13 +00:00
bachinger
60a3ea48b8 Bump IMA SDK version for gradle
PiperOrigin-RevId: 472500789
2022-10-19 21:22:12 +00:00
Googler
dfdcf76daf Fix 1 ErrorProneStyle finding:
* Non-standard parameter comment; prefer `/* paramName= */ arg`
  (see http://go/bugpattern/ParameterComment)

This CL looks good? Just LGTM and Approve it!
This CL doesn’t look good? This is what you can do:
* Revert this CL, by replying "REVERT: <provide reason>"
* File a bug under go/error-prone-bug for category ErrorProneStyle if there's an issue with the CL content.
* File a bug under go/rosie-bug if there's an issue with how the CL was managed.
* Revert this CL and not get a CL that cleans up these paths in the future by
replying "BLOCKLIST: <provide reason>". This is not reversible! We recommend to
opt out the respective paths in your CL Robot configuration instead:
go/clrobot-opt-out.

This CL was generated by CL Robot - a tool that cleans up code findings
(go/clrobot). The affected code paths have been enabled for CL Robot in //depot/google3/java/com/google/android/libraries/media/METADATA which is reachable following include_presubmits from //depot/google3/third_party/java_src/android_libs/media/METADATA.
Anything wrong with the signup? File a bug at go/clrobot-bug.

#codehealth

Tested:
    Local presubmit tests passed.
PiperOrigin-RevId: 472252461
2022-10-19 20:48:24 +00:00
rohks
142d1c062c Switch incorrectly configured native multidex to legacy
Native multidex can only be used for binaries with minSdkVersion of 21 or higher, but minSdkVersion was specified to 16.

PiperOrigin-RevId: 470003836
2022-10-19 19:39:59 +00:00
rohks
f01896af15 Replace usage of android_binary with build_test for libraries
`android_binary` is only required when building an application.

PiperOrigin-RevId: 469413752
2022-10-19 19:13:34 +00:00
bachinger
d6442f63fa Add device info to CastPlayer
Issue: androidx/media#142
PiperOrigin-RevId: 468666737
2022-10-19 19:02:04 +00:00
tonihei
29208ec1ed Define CueGroup.EMPTY_TIME_ZERO for convenience
We create an empty CueGroup in many places as default or
where none is needed. Instead, we can define a constant
for this purpose and reuse it.

PiperOrigin-RevId: 467944841
2022-10-19 18:30:47 +00:00
tonihei
80b635e7ab Update CMake version for AV1 extension
The specified CMake version doesn't work with the latest
Android Studio releases. Updating to a more recent version
fixes the problem.

Issue: google/ExoPlayer#9933
PiperOrigin-RevId: 467634063
2022-10-19 18:15:44 +00:00
tonihei
6ea1d0ecf0 Add additional build flags for ffmpeg on "arm64-v8a"
From NDK 23.1.7779620 and above, the arm64-v8a ABI needs additional
build flags to correctly link the ffmpeg libraries.

Issue: google/ExoPlayer#9933
PiperOrigin-RevId: 467161973
2022-10-19 17:57:17 +00:00
tonihei
91fc5c4f3c Add timeout for ad to load.
In some cases, the IMA SDK fails to call the expected loadAd
event to load the next ad to play. This is (potentially) the
only remaining case where playback can get stuck due to missing
calls from IMA as the player doesn't even have a MediaSource at
this stage and is only waiting for IMA to provide the ad URL.

We can reuse the existing adPreloadTimeoutMs that was added for
a similar purpose (when preloading the first ad in the group).
The JavaDoc matches this purpose as well and the default timeout
is appropriate since we expect to get the loadAd call immediately.

Issue: google/ExoPlayer#10510
PiperOrigin-RevId: 466953617
2022-10-19 17:53:39 +00:00
Googler
a3de13c9a9 Update Leanback library from androidx-platform-dev with build#8803384
TGP: https://fusion2.corp.google.com/presubmit/tap/459592967/OCL:459592967:BASE:464692555:1659412331108:1ed6eb4e/targets

If you need additional help investigating this issue, please consider using g/androidx-discuss to reach the wider Jetpack library owner and client community. For general questions about prebuilt drops, refer to go/androidx/g3_faq

PiperOrigin-RevId: 464852576
2022-10-19 15:56:41 +00:00
Vishnu Chilakala
b9b30c4669 Do not send content complete if any midroll is skipped 2022-10-18 18:20:55 +05:30
ibaker
21cab6124d Annotate methods that always return this with @CanIgnoreReturnValue
It's always safe to ignore the result of these methods, because the
caller already has a reference to the returned value.

PiperOrigin-RevId: 462388947
2022-07-25 22:19:11 +01:00
bachinger
759de7d612 Remove okhttp related proguard rules
Issue: androidx/media#10310
#minor-release
PiperOrigin-RevId: 461889651
2022-07-21 13:09:23 +00:00
bachinger
9d87c0db78 Don't set the tag in CastTimeline
Leaving the media item that has been passed in unchanged, ensures that the
media item in the timeline is equal to the media item that the user has
passed into the player. The value of the tag is the uid of the window,
meaning this is redundant information.

#minor-release

PiperOrigin-RevId: 460542246
2022-07-13 17:57:48 +00:00
bachinger
d6659e92df Enable onMediaMetadataChanged in CastPlayer
Issue: androidx/media#25
PiperOrigin-RevId: 460476841
2022-07-13 17:40:54 +00:00
bachinger
268de237a7 Don't set the tag in CastTimeline
Leaving the media item that has been passed in unchanged, ensures that the
media item in the timeline is equal to the media item that the user has
passed into the player. The value of the tag is the uid of the window,
meaning this is redundant information.

#minor-release

PiperOrigin-RevId: 460542246
(cherry picked from commit 9d87c0db78f899ff05e8a26a3e6b4a9667fa81d2)
2022-07-12 20:41:57 +00:00
bachinger
6abbb49738 Enable onMediaMetadataChanged in CastPlayer
Issue: androidx/media#25
PiperOrigin-RevId: 460476841
(cherry picked from commit d6659e92dfc3b5100bbd79f2d28f296a425a2ac1)
2022-07-12 16:04:45 +00:00
ibaker
1b1e0f890d Group COMMAND_SET_MEDIA_ITEM and COMMAND_CHANGE_MEDIA_ITEMS together
I don't think it's useful to keep these in numerical order, it makes
more sense to keep them grouped into a 'logical' ordering.

#minor-release

PiperOrigin-RevId: 460453464
2022-07-12 15:29:33 +00:00
bachinger
02e1484ebc Use the public MediaItem in the timeline of CastPlayer
The media item needs to be assigned to `Window.mediaItem` in `CastTimeline.setWindow`. For this the `MediaItem` needs to be available in the timeline.

When a `MediaItem` is passed to the `set/addMediaItems` method, we can't yet know the Cast `MediaQueueItem.itemId` that is generated on the device and arrives with an async update of the `RemoteMediaClient` state. Hence in the `CastTimelineTracker`, we need to store the `MediaItem` by Casts's `MediaItem.contentId`. When we then receive the updated queue, we look the media item up by the content ID to augment the `ItemData` that is available in the `CastTimeline`.

Issue: androidx/media#25
Issue: google/ExoPlayer#8212

#minor-release

PiperOrigin-RevId: 460325235
2022-07-12 15:19:41 +00:00
christosts
c43d9f5b57 Listen to playWhenReady changes in LeanbackPlayerAdapter
#minor-release

Issue: google/ExoPlayer#10420
PiperOrigin-RevId: 460223064
2022-07-12 15:08:56 +00:00
ibaker
4b684b59d3 Group COMMAND_SET_MEDIA_ITEM and COMMAND_CHANGE_MEDIA_ITEMS together
I don't think it's useful to keep these in numerical order, it makes
more sense to keep them grouped into a 'logical' ordering.

#minor-release

PiperOrigin-RevId: 460453464
(cherry picked from commit 1b1e0f890da4de6055491730595f72afdde0811a)
2022-07-12 14:06:27 +00:00
bachinger
05e42ebb07 Use the public MediaItem in the timeline of CastPlayer
The media item needs to be assigned to `Window.mediaItem` in `CastTimeline.setWindow`. For this the `MediaItem` needs to be available in the timeline.

When a `MediaItem` is passed to the `set/addMediaItems` method, we can't yet know the Cast `MediaQueueItem.itemId` that is generated on the device and arrives with an async update of the `RemoteMediaClient` state. Hence in the `CastTimelineTracker`, we need to store the `MediaItem` by Casts's `MediaItem.contentId`. When we then receive the updated queue, we look the media item up by the content ID to augment the `ItemData` that is available in the `CastTimeline`.

Issue: androidx/media#25
Issue: google/ExoPlayer#8212

#minor-release

PiperOrigin-RevId: 460325235
(cherry picked from commit 02e1484ebc14a97829c9f5836333412c01205f57)
2022-07-11 23:22:27 +00:00
christosts
36a99cb1d3 Listen to playWhenReady changes in LeanbackPlayerAdapter
#minor-release

Issue: google/ExoPlayer#10420
PiperOrigin-RevId: 460223064
(cherry picked from commit c43d9f5b5794e5019758ee7df68f79ed9f9bc4a7)
2022-07-11 15:49:33 +00:00
bachinger
84c801a723 Use mediaId as contentId if available
This is to be consistent with what cast `QueueMediaItem` is doing. If a contentId is
not available the contentUrl is used as the ID.

#minor-release

PiperOrigin-RevId: 459133323
2022-07-07 18:01:32 +00:00
bachinger
c2ddf27715 Use mediaId as contentId if available
This is to be consistent with what cast `QueueMediaItem` is doing. If a contentId is
not available the contentUrl is used as the ID.

#minor-release

PiperOrigin-RevId: 459133323
(cherry picked from commit 84c801a723f56c9c0fcdf10ab8bbab35bfd9f333)
2022-07-05 23:21:59 +00:00
rohks
bf11a8a831 Add timestamp to CueGroup
`TextRenderer` is updated to output `CueGroup`, which contains the presentation time of the cues, in microseconds.

PiperOrigin-RevId: 456531399
2022-06-27 11:36:43 +01:00
bachinger
d1fbef8106 Suppress lint errors RestrictedApis in lib-media2
PiperOrigin-RevId: 454939082
2022-06-15 14:50:11 +00:00
tonihei
2056152824 Add COMMAND_SET_MEDIA_ITEM to Player.Commands
Some Player implementations have no playlist capability but can still
set a MediaItem for playback. Examples are a MediaController connected
to a legacy MediaSession, ExoPlayer up to 2.12 or MediaPlayer.

To indicate this capability, we need an allowed command in addition
to COMMAND_CHANGE_MEDIA_ITEMS that just allows to set a single item
that replaces everything that is currently played.

#minor-release

PiperOrigin-RevId: 453879626
2022-06-09 17:11:12 +00:00
bachinger
ff582ec2a1 Suppress lint errors RestrictedApis in lib-media2
PiperOrigin-RevId: 454939082
(cherry picked from commit d1fbef810699688fdfb832ba0bde7282df3d3260)
2022-06-15 16:51:04 +00:00
tonihei
c1aff0dc8f Add COMMAND_SET_MEDIA_ITEM to Player.Commands
Some Player implementations have no playlist capability but can still
set a MediaItem for playback. Examples are a MediaController connected
to a legacy MediaSession, ExoPlayer up to 2.12 or MediaPlayer.

To indicate this capability, we need an allowed command in addition
to COMMAND_CHANGE_MEDIA_ITEMS that just allows to set a single item
that replaces everything that is currently played.

#minor-release

PiperOrigin-RevId: 453879626
(cherry picked from commit 2056152824512bcd8f2f09b2f7c1a752e913feac)
2022-06-09 18:08:16 +00:00
bachinger
2b8dbb5143 Ignore decoding test cases when library not available
#minor-release

PiperOrigin-RevId: 452043577
(cherry picked from commit c3866449e248bb7e7fce6c78b51f4960e14a0c91)
2022-05-31 15:33:13 +00:00
bachinger
c3866449e2 Ignore decoding test cases when library not available
#minor-release

PiperOrigin-RevId: 452043577
2022-05-31 14:46:02 +00:00
ibaker
30bed6cdc5 Add @deprecated javadoc to all @Deprecated @Override methods
This ensures the 'use X instead' message is easily visible in the
generated HTML for the overriding method. Currently it's not, e.g.:
https://exoplayer.dev/doc/reference/com/google/android/exoplayer2/BasePlayer.html#getCurrentWindowIndex()

#minor-release

PiperOrigin-RevId: 452002224
(cherry picked from commit d711dee003c9f7d8a3f31031b35a4121d0db6f09)
2022-05-31 13:50:40 +00:00
bachinger
401c220c32 Add explicit cast to ByteBuffer for Java 8 compatibility
PiperOrigin-RevId: 451994696
(cherry picked from commit 1c5032e1a9091e0e53fc881581aaba8d7dfb2dd9)
2022-05-31 13:50:40 +00:00
ibaker
d711dee003 Add @deprecated javadoc to all @Deprecated @Override methods
This ensures the 'use X instead' message is easily visible in the
generated HTML for the overriding method. Currently it's not, e.g.:
https://exoplayer.dev/doc/reference/com/google/android/exoplayer2/BasePlayer.html#getCurrentWindowIndex()

#minor-release

PiperOrigin-RevId: 452002224
2022-05-31 11:06:26 +00:00
bachinger
1c5032e1a9 Add explicit cast to ByteBuffer for Java 8 compatibility
PiperOrigin-RevId: 451994696
2022-05-31 10:59:14 +00:00
Marc Baechinger
b332d66cf7 Remove FfmpegVideoRenderer from 2.1.18 release 2022-05-30 18:22:06 +00:00
ibaker
32fd374405 Simplify DefaultMediaSourceFactory instantiation in a test
There's no need to manually construct a 'default'
DefaultDataSource.Factory instance, we can just pass the `Context` to
`DefaultMediaSourceFactory` and let it construct the
`DefaultDataSource.Factory` internally.

PiperOrigin-RevId: 451155747
2022-05-30 17:08:17 +00:00
ibaker
ecea2b9e90 Rollback of e705999cf3
*** Original commit ***

Rollback of 57182ac7bd

*** Original commit ***

Remove `@Nullable` from `MediaSource.Factory` setters

The null-behaviour of these methods creates a minimization footgun,
because **any** call to these setters will prevent R8 from removing
the default implementation (even if it's never used by the app) - this
is because R8 can't tell the default imple...

***

PiperOrigin-RevId: 450453325
2022-05-23 17:12:22 +01:00
ibaker
274f3a13a2 Rollback of 57182ac7bd32db54d11fd41e21338a2bbfaf043c
*** Original commit ***

Remove `@Nullable` from `MediaSource.Factory` setters

The null-behaviour of these methods creates a minimization footgun,
because **any** call to these setters will prevent R8 from removing
the default implementation (even if it's never used by the app) - this
is because R8 can't tell the default implementation is only used if the
parameter is `null`.

******

PiperOrigin-RevId: 450410833
2022-05-23 13:01:22 +01:00