963 Commits

Author SHA1 Message Date
tianyifeng
2c8d07c2dd Inform DefaultPreloadManager when player uses PreloadMediaSource
Add a new method `onUsedByPlayer(PreloadMediaSource)` for `PreloadMediaSource.PreloadControl`, which will be invoked when the player starts to use the `PreloadMediaSource`, or calling `PreloadMediaSource.preload` while the player is already using that source. `DefaultPreloadManager` will immediately preload the next source when receiving `onUsedByPlayer` event.

PiperOrigin-RevId: 616789121
2024-03-18 04:54:49 -07:00
tofunmi
762065fae0 Add api to find duration after an effect is applied
PiperOrigin-RevId: 616157067
2024-03-15 09:41:40 -07:00
huangdarwin
b126bae93d Effect: Add EGL_EXT_gl_colorspace_bt2020_hlg support, on API 34+
Confirmed that the HLG extension displays properly on Pixel 7 Pro, API 34 and Samsung S24, API 34. On these devices, this fixes the washed out HLG preview issue on API 34, where the PQ ext had a washed out look, and where the HLG ext is supported (this bug didn't occur on API 33, only 34).

More info on manual tests done to sanity-check:
* Test cases: Transformer debug SurfaceView and ExoPlayer.setVideoEffects
* Test inputs: HLG and PQ
* Test devices: Pixel 7 Pro (API 33 & 34), Samsung Galaxy S24 (API 34)
* Added debugging: Logging colorInfo used in GlUtil.createEglSurface

No regressions were seen. HLG extension is used more in API 34, and behavior stays the same on API 33. Only human-visible change without logging is that HLG content looks better on API 34, for Samsung S24 and Pixel 7 Pro.

PiperOrigin-RevId: 616131192
2024-03-15 08:06:49 -07:00
ibaker
48cffc849a Fix proguard rule for DefaultVideoFrameProcess.Factory.Builder.build()
Issue: androidx/media#1187

#minor-release

PiperOrigin-RevId: 616112879
2024-03-15 06:50:16 -07:00
kimvde
3248b7962a Add clipFloatOutput parameter to AudioMixer
PiperOrigin-RevId: 615720340
2024-03-14 03:44:37 -07:00
christosts
5f6e5bcda2 Composition preview: image renderer does not forward VideoSink events
PiperOrigin-RevId: 615479550
2024-03-13 11:10:02 -07:00
michaelkatz
8b219b0ae6 Start playing period-enabled renderers when setting playWhenReady true
Renderers may be enabled for subsequent media items as soon as the current media item's renderer's isEnded() returns true. Currently, when a player is set to pause, it stops all renderers that are `STATE_STARTED`. When a player is set to play, it starts all renderers that are enabled. This would include renderers that were enabled early for the subsequent media item. The solution is to only start renderers that are enabled by the current playing period.

Issue: androidx/media#1017
PiperOrigin-RevId: 614734437
2024-03-11 11:31:12 -07:00
tonihei
cbed80ecf3 Always set PARAMETER_KEY_TUNNEL_PEEK when tunneling
This should already be the default, but some devices seem
to not adhere to this contract and assume the default is unset.

Issue: androidx/media#1169
PiperOrigin-RevId: 614697283
2024-03-11 09:49:09 -07:00
christosts
6f109ffa6a Composition preview: play multiple images
PiperOrigin-RevId: 614690669
2024-03-11 09:28:40 -07:00
tonihei
e4a55844d0 Add device-specific opt-ins for async MediaCodecAdapter
Some devices just don't work very well with the synchronous
model, but are currently still excluded from our approximate
API 31 check. This change allows to include additional devices
or device groups by passing in the Context to the default
adapter.

It also adopts the workaround added in ebceee08c6
for Fire TV Smart devices that exhibit this issue.

PiperOrigin-RevId: 614642545
2024-03-11 06:29:46 -07:00
tonihei
410c0492cc Force external surround sound flag if requested by device
Some FireOS6 devices ask to force the external surround global
flag and ignore any signals from the HDMI connection.

This is the equivalent change of e341944d1e

PiperOrigin-RevId: 614634499
2024-03-11 05:55:43 -07:00
tonihei
18cbbf3850 Reorder audio capability checks
Using the more accurate check available on later API versions
first is likely better than falling back to a fallback solution
from older API versions.

PiperOrigin-RevId: 614612628
2024-03-11 04:17:35 -07:00
tonihei
eb6f607717 Document MergingMediaSource tag contract
Issue: androidx/media#883

#minor-release

PiperOrigin-RevId: 613970048
2024-03-08 10:16:23 -08:00
claincly
16ef146482 Allow playing mixed input types.
These input types include images, video without audio, and video with audio.
While playing these inputs, the video frame presentation is always synced with
audio.

PiperOrigin-RevId: 613921719
2024-03-08 07:02:51 -08:00
ibaker
7f5b1a98e9 Use Guava's toByteArray & fromByteArray methods where possible
Also remove intermediate object allocations in
`Util.toByteArray(int...)`.

`Util.toByteArray(InputStream)` is kept (but deprecated) because it's
been part of the library for a while and might be in use by some apps.
The others are much newer, so the chance of usages outside the library
is very low, so we just remove them directly.

PiperOrigin-RevId: 613878453
2024-03-08 03:27:29 -08:00
ibaker
a604600126 Add workarounds for NoSuchMethodError from DRM framework exceptions
Issue: androidx/media#1145

#minor-release

PiperOrigin-RevId: 613573868
2024-03-07 07:16:28 -08:00
michaelkatz
638b2a3c86 Start early-enabled renderers only after advancing the playing period
Renderers may be enabled for subsequent media items as soon as the current media item's renderer's isEnded() returns true. When a renderer is being enabled and the player is 'playing', that renderer is also started. When playing a mixed playlist of images and content with audio & video, the player may skip some image items because the early-starting of the audio renderer causes a clock update.

A solution is to only start the "early-enabled" renderers at the point of media transition and add a condition on DefaultMediaClock to use the standalone clock when reading-ahead and the renderer clock source is not in a started state.

Issue: androidx/media#1017
PiperOrigin-RevId: 613231227
2024-03-06 08:50:42 -08:00
bachinger
a0a40871b5 Pass player ID to methods of LoadControl
The old methods are deprecated and are called from the new
method for backwards compatibility of custom implementations.

'DefaultLoadControl' is unchanged, but `ExoPlayerImplInternal`
already calls the new methods passing in the `PlayerId`,

PiperOrigin-RevId: 613197190
2024-03-06 06:48:02 -08:00
andrewlewis
a90a7049e8 Fix typo
PiperOrigin-RevId: 613156951
2024-03-06 03:51:11 -08:00
Googler
4d0af794df Internal changes only
Internal changes

PiperOrigin-RevId: 613155879
2024-03-06 03:44:42 -08:00
andrewlewis
11b14d7594 Set profile for DV profile 10 AV1
PiperOrigin-RevId: 612918953
2024-03-05 11:53:44 -08:00
tianyifeng
5e31cd9df3 Add BasePreloadManager and DefaultPreloadManager
`BasePreloadManager` coordinates the preloading for multiple sources based on the priorities defined by their `rankingData`. Customization is possible by extending this class. Apps will implement `TargetPreloadStatusControl` to return preload manager the target preload status for a given `rankingData` of the source.

`DefaultPreloadManager` extends from the above base class and uses `PreloadMediaSource` to preload media samples of the sources into memory. It also uses an integer `rankingData` that indicates the index of an item on the UI, and the priority of the items is determined by their adjacency to the current playing item. Apps can set the index of current playing item via `DefaultPreloadManager.setCurrentPlayingIndex` when the user swiping is detected.

PiperOrigin-RevId: 612829642
2024-03-05 07:14:18 -08:00
Copybara-Service
bbdaf2b092 Merge pull request #1025 from v-novaltd:dsparano-exo209
PiperOrigin-RevId: 612485043
2024-03-04 09:55:00 -08:00
claincly
305f24f947 Clarify ExoPlayer.setVideoEffects() javadoc
PiperOrigin-RevId: 612464321
2024-03-04 08:45:38 -08:00
Daniele Sparano
0cdae9af20 Read resolution for debug text view from VideoSize object to reflect changes from video effects 2024-03-04 14:09:54 +00:00
claincly
27d78e69d7 Clarify setVideoEffect() javadoc
PiperOrigin-RevId: 611147963
2024-02-28 10:31:42 -08:00
christosts
55bfe4f95c Composition preview: do not report errors on release
PiperOrigin-RevId: 611096895
2024-02-28 07:37:15 -08:00
ibaker
09ac916119 Remove DefaultTrackSelector.NO_ORDER ordering
This implementation generates lint errors because neither the `first`
nor `second` parameters are used, and that's generally
unexpected/incorrect for a `Comparator` implementation since it should
always consider both its parameters.

PiperOrigin-RevId: 611039632
2024-02-28 02:58:41 -08:00
ibaker
c7e00b12b4 Add fps-awareness to DefaultTrackSelector
This change aims to prioritise tracks that have a 'smooth enough for
video' frame rate, without always selecting the track with the highest
frame rate.

In particular MP4 files extracted from motion photos sometimes have two
HEVC tracks, with the higher-res one having a very low frame rate (not
intended for use in video playback). Before this change
`DefaultTrackSelector` would pick the low-fps, high-res track.

This change adds a somewhat arbitrary 10fps threshold for "smooth video
playback", meaning any tracks above this threshold are selected in
preference to tracks below it. Within the tracks above the threshold
other attributes are used to select the preferred track. We deliberately
don't pick the highest-fps track (over pixel count and bitrate), because
most users would prefer to see a 30fps 4k track over a 60fps 720p track.

This change also includes a test MP4 file, extracted from the existing
`jpeg/pixel-motion-photo-2-hevc-tracks.jpg` file by logging
`mp4StartPosition` in
[`MotionPhotoDescription.getMotionPhotoMetadata`](b930b40a16/libraries/extractor/src/main/java/androidx/media3/extractor/jpeg/MotionPhotoDescription.java (L123))
and then using `dd`:

```
mp4StartPosition=2603594

$ dd if=jpeg/pixel-motion-photo-2-hevc-tracks.jpg \
    of=mp4/pixel-motion-photo-2-hevc-tracks.mp4 \
    bs=1 \
    skip=2603594
```

----

This solution is in addition to the `JpegMotionPhotoExtractor` change
made specifically for these two-track motion photos in
5266c71b3a.
We will keep both changes, even though that change is not strictly
needed after this one, because adding the role flags helps to
communicate more clearly the intended usage of these tracks. This
change to consider FPS seems like a generally useful improvement to
`DefaultTrackSelector`, since it seems unlikely we would prefer a 5fps
video track over a 30fps one.

Issue: androidx/media#1051
PiperOrigin-RevId: 611015459
2024-02-28 01:09:50 -08:00
michaelkatz
a45e734bb0 Create audio offload failure recovery playback tests
These audio offload failure recovery tests model the DefaultAudioSink failing at audio track init and write operations in offload mode. Playback should recover and try again as DefaultAudioSink will disable offload mode.

PiperOrigin-RevId: 610372935
2024-02-26 05:06:04 -08:00
tofunmi
5a892509f7 remove media/bitmap/input_images
move the images into the respective places in the file extension directory so they file the pre-existing structure

PiperOrigin-RevId: 609744673
2024-02-23 09:07:03 -08:00
michaelkatz
23a301fc5d Fallback to legacy sizerate check if CDD H264 PerfPoint check fails
Some devices supporting Performance Points for decoder coverage are missing coverage over the CDD requirements for H264. For these cases ExoPlayer should fall back to legacy resolution and frame rate support checks. If there is a stream evaluated as a PerformancePointCoverageResult of COVERAGE_RESULT_NO, then ExoPlayer checks for coverage of the 720p H264 CDD requirement.

Issue: google/ExoPlayer#10898

Issue: androidx/media#693

Issue: androidx/media#966
PiperOrigin-RevId: 609740128
2024-02-23 08:48:09 -08:00
claincly
68a78b9218 When effects are enabled, opportunistally render to VFP
Even when there's no display surface, MCVR can render frames to VFP, becuase by
the time the frame is processed:

- If there's still no surface, VFP will drop the frame;
- If there's surface, the processed frame would be rendered.

In short, placeholder surface is not needed in effect enabled playback. FWIW,
it is used to swallow frames directly from MediaCodec when there's no output
surface.

PiperOrigin-RevId: 609705222
2024-02-23 06:07:54 -08:00
christosts
0480eff6a1 ExoPlayerImplInternal.releaseInternal(): unblock the app thread
This change makes ExoPlayerImplInternal.releaseInternal() unblock the
app thread if a runtime exception is thrown while releasing components
from the playback thread.

Before this change, if a runtime exception occurred during releasing
components in the playback thread, ExoPlayer.release() would wait for
`releaseTimeoutMs` and then raise a player error. With this change,
the player error is reported only when the playback thread is blocked
but if there is a runtime exception, the application thread is
unblocked.

The impact of this change is potentially fewer ANRs on
ExoPlayer.release() at the expense of less error reporting.

PiperOrigin-RevId: 609702549
2024-02-23 05:54:37 -08:00
sheenachhabra
fd8f45b38e Add MdtaMetadataEntry constructor with default locale indicator
PiperOrigin-RevId: 609427529
2024-02-22 10:55:50 -08:00
christosts
440d2ab162 ForwardingAudioSink: add override for release()
We forgot to add it when we added AudioSink.release(). The commit
includes a test that ensures ForwardingAudioSink overrides all the
methods defined in the AudioSink interface.

PiperOrigin-RevId: 609402258
2024-02-22 09:59:15 -08:00
michaelkatz
4192924622 Use playing period TrackSelectorResult in track reselection update
If the reading period has already advanced and a track reselection procs that only affects the reading period media, then ExoPlayer may try and apply the reading period's track selection incorrectly unto the playing period. ExoPlayer should apply the playing period's track selection to the playing period instead.

PiperOrigin-RevId: 609375077
2024-02-22 08:08:18 -08:00
ibaker
d1ae9ffc52 Add more details about why Extractor.sniff returned false
PiperOrigin-RevId: 609335656
2024-02-22 05:20:16 -08:00
michaelkatz
9046f2edb6 Allow renderer retry for audio track offload initialization failure
If render error occurs due to AudioTrack initialization failure in offload mode, then ExoPlayer should allow retry as subsequent attempt will be with DefaultAudioSink disabling offload.

PiperOrigin-RevId: 609304897
2024-02-22 03:00:10 -08:00
tianyifeng
d952a06214 Fix a bug in retaining streams when preload a PreloadMediaPeriod again
The `PreloadMediaPeriod.selectTracksForPreloading` can be called for multiple times at the preloading stage (before the period is being played). For example, when the period resumes preloading. This change fix the assertion failure in `ProgressiveMediaPeriod.selectTracks` caused by the wrong implementation of `PreloadMediaPeriod.selectTracksForPreloading` when it is trying to retain the previously preloaded streams.

Also the `TrackSelectorResult` parameter is changed to a list of `ExoTrackSelection`. We should compare the selections only rather than considering the `RendererConfiguration` in the `TrackSelectorResult` to decide whether to retain the streams, as for preloading case the renderers haven't consumed the samples yet.

PiperOrigin-RevId: 609126868
2024-02-21 14:41:33 -08:00
tofunmi
7a632a43ba Move bitmap decoding into datasource util
PiperOrigin-RevId: 608588505
2024-02-20 06:57:02 -08:00
christosts
8dd6590fe9 Use application context in CompositingVideoSinkProvider.Builder
PiperOrigin-RevId: 608572065
2024-02-20 05:45:44 -08:00
ibaker
c872af4bc0 Consolidate requiresSecureDecoder logic in ExoMediaDrm
This change:
1. Updates the implementation of
   `FrameworkMediaDrm.requiresSecureDecoder` to include the
   'force allow insecure decoder' workaround logic.
2. Removes the 'force allow insecure decoder' logic from MCR
3. Removes the `requiresSecureDecoder` field from MCR (it can just
   be a local derived from `codecDrmSession` now).

PiperOrigin-RevId: 607664186
2024-02-16 05:57:50 -08:00
Ian Baker
e24febf1e2 Small clean-ups and added @InlineMe annotation 2024-02-13 14:48:15 +00:00
Ian Baker
1bf3101269 Remove V19 from AudioTimestampPoller.AudioTimestampV19 2024-02-13 10:26:20 +00:00
Ian Baker
205c8734cc In-line more V19 methods in TrackSelectionParameters, AudioTimestampPoller and CaptionStyleCompat 2024-02-13 10:26:20 +00:00
Ian Baker
c4d9df970c Format with google-java-format 2024-02-13 10:26:20 +00:00
Ian Baker
c0c1c315c5 In-line GlUtil.Api18 and VideoFrameReleaseHelper.DisplayHelperV16/17
Also put back a comment in DownloadTracker that is still relevant on API 19.

Also deprecate PlaceholderSurface.newInstanceV17() in favour of just
newInstance()
2024-02-13 10:26:20 +00:00
Gaëtan Muller
d327cb4795 Code cleanup 2024-02-13 10:26:20 +00:00
Gaëtan Muller
e1ba75c871 Remove some API-dependant classes 2024-02-13 10:26:20 +00:00