Skip to content

Motion photo poc #2689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 249 commits into from
Closed

Motion photo poc #2689

wants to merge 249 commits into from

Conversation

SheenaChhabra
Copy link
Contributor

No description provided.

ybai001 and others added 30 commits June 5, 2025 10:10
Merge latest androidx/media main branch
This commit addresses the following warnings:
- Remove unnecessary semi-colons.
- Use `isEmpty()` instead of comparing the size to 0 (for collections) or the value to `""` (for strings).
- Remove unnecessary calls to `toString()`.
- Remove redundant type declarations.
- Use Kotlin's property instead of getter/setter.
- Replace redundant `StringBuilder` with `String`.
- Remove unnecessary casts.
And keep CastPlayer a forwarding player of RemoteCastPlayer, for
backwards compatibility.

PiperOrigin-RevId: 773345960
PiperOrigin-RevId: 773355539
Provides a utility method for skipping LEB128 values without reading them, avoiding the need to declare unused variables when the value is not needed.

PiperOrigin-RevId: 773382281
The (dis)connect messages and their replies were only sent from
MediaBrowserCompat instances before API 21. This means we can
remove the constants and their handling completely.

PiperOrigin-RevId: 773652726
#cherrypick

PiperOrigin-RevId: 773670933
This change adds support for `android.media.AudioAttributes.setIsContentSpatialized()` which was introduced with android API level 32.

Fixes: Issue: #2540
PiperOrigin-RevId: 773747168
#cherrypick

PiperOrigin-RevId: 774689870
The motion photo metadata is stored in XMP which can be stored in a
JPEG without an Exif segment, so there's no need to look for an Exif
segment.

Issue: #2552
PiperOrigin-RevId: 774705930
This CL does a few things

1. Check if we can skipping creating/setting media sources
2. If yes, trigger a track selection

PiperOrigin-RevId: 774715579
The same is already done in the Android platform MediaBrowserService,
but needs to be repeated for Media3 only connections that are not verified
via this path.

#cherrypick

PiperOrigin-RevId: 774720837
When the AndroidView created instances are reused, it currently
fails to assign the surface to the player correctly.

 - The local remembered `view` variable is reset and wasn't assigned
   to the already existing view because the `factory` wasn't run
   again. Instead we should assign the local variable in `update`,
   which is run at the point of reusing the view.
 - To avoid assigning the same surface to multiple players, we need
   to know which player it was assigned to previously. Since the
   remembered Compose states are all cleared, we can instead store
   the currently assigned player as a `tag` in the View itself. This
   removes the need to have the `registeredPlayer` local state as
   it now trackes the assigned player within a single usage and
   across reuses.
 - The LaunchedEffect can now be run when the view is reused, but
   the player hasn't actually changed. So we can add an extra check
   to avoid clearing the player if it hasn't changed. It's still
   useful to keep setting the same player twice as it re-triggers
   size callbacks and first frame callbacks which might be needed by
   the new usage.

Also add new test coverage to capture the usage in reusable containers
like LazyColumn, both with different players, the same player, and two
players (so that the same player reuses the same surface as before).
All 3 tests can also be done with `null` assignments to the invisible
elements to ensure that the transition via `null` doesn't cause any
issues.

To actually assert everything works as expected, we need to track all
surface interactions more closely and then check the test setup
assumptions, and the correct and effective usage via helper methods.
This is needed as we can't know exactly how many instances are reused
by the LazyColumn in the test and when they are reset, etc.

Issue: #2493
PiperOrigin-RevId: 774743304
This avoids logcat warnings about sending messages to dead threads.

PiperOrigin-RevId: 775172292
This allows legacy clients to obtain this icon uri and the information
won't get lost even when doing a roundtrip conversion between platform
and Media3 data.

#cherrypick

PiperOrigin-RevId: 775178792
PiperOrigin-RevId: 775197832
PiperOrigin-RevId: 775255316
PiperOrigin-RevId: 775360918
This is an extension to 6c24cc1. While the previous change
prevents selecting a new chunk that forces an impossbile splice
operation caused by having already read too far, it doesn't prevent
the player from reading into the to-be-replaced data later before
the chunk can be spliced in. This may still cause stuck playbacks
while we are waiting for a suitable splice-in point.

Since the most common case during low-latency playback for this
situation is going back to a previous independent part or segment,
we should be able to avoid the splice entirely by discarding the
chunks we are going to replace anyway. If we do this, then we
don't need to worry reading into them later. The main conditions
that need to be fulfilled for this to work are:
 - The new chunk must be independent (= we know the first sample
   could be spliced in successfully anyway)
 - The replaced chunk must be declared to start at the same time
   (=we don't need samples of a previous chunk to remain and can
   discard it entirely). Note that we use the declared start time
   from the playlist (not the actual sample times) so that this
   works in the same way as any other ABR switch even if the actual
   sample times are not perfectly aligned.

Issue: #2299

#cherrypick

PiperOrigin-RevId: 775615562
tonihei and others added 27 commits July 29, 2025 04:24
Some playback tests may get caught in timeout conditions for
stuck playback during the initial phase of waiting for playback
to become ready. For real files in particular, this phase may
take an arbitrary amount of time due to the free-running loading
thread. This can be avoided by explicitly waiting for playback
to be ready before attempting to play.

PiperOrigin-RevId: 788396993
#cherrypick

PiperOrigin-RevId: 788411907
The default implementation of the media key event handling ignores
action up events, but they still need to be delivered to the
`MediaSession.Callback` so an app receives all the events that the
session receives.

Issue: #2637
PiperOrigin-RevId: 788435637
Previously, if it's set after calling `setComposition()`, the value is lost
when calling `setComposition()` again because we never stored the value.

PiperOrigin-RevId: 788469108
#cherrypick

PiperOrigin-RevId: 788490308
PiperOrigin-RevId: 788814180
PiperOrigin-RevId: 788832847
This change introduces PlayerAudioFocusContractTest as an abstract test
class that tests Player implementations that support audio focus
handling. Player state related tests in ExoPlayerTest were refactored
into the abstract class in test-utils-robolectric and
ExoPlayerAudioFocusContractTest provides the concrete implementation for
ExoPlayer.

This change allows all Player implementations to test their audio focus
support against the same logic without the need to duplicate any tests.

PiperOrigin-RevId: 788845912
This tells apps whether the package name has been verified
against the UID at any point and can be fully trusted to be
correct.

Platform MediaBrowserService had always had this check, the
platform MediaSession calls only added checks with API 33.

Media3 service connections can always verify the values,
but plain MediaSession connections may not see the package info
in all cases.

PiperOrigin-RevId: 788858382
PiperOrigin-RevId: 788878395
We currently wait until either the upstream source is ready or the
audio sink has any pending data. This causes the renderer to become
ready too early (once data is available for decoding but before this
data has been pushed to the AudioSink). This can be checked by reducing
the condition to just checking the audio sink for pending data. Unlike
video, it's okay to not have upstream data available because the audio
sink maintains an internal buffer (usually part of the AudioTrack).

One ExoPlayerTest accidentally relied on this bug in its test setup that
really only wanted to wait for a single processed buffer.

PiperOrigin-RevId: 788893850
Introduces `FLAG_OMIT_TRACK_SAMPLE_TABLE` to `Mp4Extractor`. When this
flag is set, the extractor avoids allocating large per-sample arrays
(offsets, sizes, timestamps, flags) within the `TrackSampleTable` when
parsing the `stbl` box. This significantly reduces memory consumption,
especially for files with a very large number of samples.

`MetadataRetriever` now sets this flag by default to prevent
OutOfMemoryErrors during metadata extraction on such large files.

Fixes: Issue: #2650
PiperOrigin-RevId: 788913014
When `forceVideoTrack` is set to true to generate blank frames for gaps, it alters the order of `MediaSource` instances within the `MergingMediaSource`. This caused an issue in `CompositionTrackSelector`, which incorrectly disabled the main audio track.

`CompositionTrackSelector` is responsible for disabling the `SilenceMediaSource` track when the main media source contains its own audio (`shouldUseMediaAudio` is true). Previously, the selector assumed the silence track is the last in the list. However, when `forceVideoTrack` was enabled, the `mainMediaSource` was added after `SilenceMediaSource`, making the main audio the last track. As a result, the main audio was disabled by mistake.

This change corrects the issue by enforcing a consistent order where `SilenceMediaSource` is always the first source provided to `MergingMediaSource`. The `CompositionTrackSelector` is updated to use the fixed index `0` to correctly disable the silent audio track. Changes were also made to the index of the blank media source to accommodate the silence track changes.

PiperOrigin-RevId: 788926915
Staying in STATE_BUFFERING or STATE_READY is not allowed
while the playlist is empty.

Issue: #2673
PiperOrigin-RevId: 788929128
The was accidentally made public in 7905001.

PiperOrigin-RevId: 788929950
PiperOrigin-RevId: 788969121
This allows for the usage of Lottie animations as .json files as an effect layer in the composition demo. In addition, three sample .json files are included to show the basic functionalities like controlling the speed, scale, position, and more of the animation layer's properties.

PiperOrigin-RevId: 788987365
The current implementation of the session calls
`getCurrentTimeline()` when `COMMAND_GET_CURRENT_MEDIA_ITEM` is
granted but not `COMMAND_GET_TIMELINE`.

This change ensures we don't access the current item through the timeline. In such a case the `placeholder` flag of a timeline period is always set to false.

Issue: #2665
PiperOrigin-RevId: 789229416
Use VideoFrameReleaseEarlyTimeForecaster to determine whether a frame is
likely to be late. The lateness is forecast before applying effects in
`InputVideoSink#handleInputFrame`. If a frame will likely be late, it is
dropped before effects are applied.

The forecaster is also updated with the actual early time for output frames.
`onVideoFrameProcessed` is called when a frame is about to be scheduled
for display, in `VideoFrameRenderControl`.

Pre-effect frame dropping can be controlled via
CompositionPlayer.Builder.experimentalSetLateThresholdToDropInputUs

PiperOrigin-RevId: 789232704
The service may be stopped by the system after running
for 6 hours without the app being in the foreground.

In such a case the system calls `onTimeout(int, int)` to
give the service the chance to gracefully terminate instead
of being suddenly crashed by the system a few instances later.

https://developer.android.com/about/versions/15/behavior-changes-15#datasync-timeout
Issue: #2614
PiperOrigin-RevId: 789247191
PiperOrigin-RevId: 789280146
Changed `CompositionTrackSelector` to no longer assume that the silence audio and blank image tracks are at index 0. It now uses the `trackGroupIndex` variable that was evaluated for each track group.

This removes the brittle assumption that required `SilenceMediaSource` and `BlankMediaSource` to be added before the `mainMediaSource` in `MergingMediaSource`.

The order of the `SilenceMediaSource` and `BlankMediaSource` in the list still needs to be maintained since we use their IDs to find their indices.

PiperOrigin-RevId: 789285123
@SheenaChhabra SheenaChhabra marked this pull request as draft July 31, 2025 16:51
Copy link

google-cla bot commented Jul 31, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.