19720 Commits

Author SHA1 Message Date
Alexey Rochev
38b5b03ebb Fix error with NDK r26 2023-12-12 10:40:27 +00:00
Alexey Rochev
6874cc80cf ffmpeg: add support of specifying Android ABI version when building FFmpeg
Also add proper error message when using NDK that doesn't support requested ABI version.
2023-12-12 10:40:27 +00:00
samrobinson
90a0cbdf3d Fix handling of repeated EOS in SilenceSkippingAudioProcessor.
Issue: androidx/media#712
PiperOrigin-RevId: 589882412
2023-12-11 11:17:14 -08:00
ibaker
d356d88c4f Improve test dump output for role and selection flags
PiperOrigin-RevId: 589878576
2023-12-11 11:05:40 -08:00
bachinger
7f9b02080a Make the media notification controller marker key visible
An app that uses the `MediaSession` without a `MediaSessionService` may
want to connect a media notification controller on it own. To avoid apps
using a string literal, the key should be exposed as public.

PiperOrigin-RevId: 589875603
2023-12-11 10:57:00 -08:00
ibaker
3e5ef51594 Remove empty container/src/androidTest directory
PiperOrigin-RevId: 589870662
2023-12-11 10:41:51 -08:00
ibaker
5266c71b3a Fix handling of multiple HEVC tracks in JPEG motion photos
The MP4 data in JPEG motion photos can contain multiple `video/hevc` tracks, but only the first is at a playable frame rate while the others are low-fps, high-res tracks designed for specific use-cases (not direct video playback).

ExoPlayer currently selects the unplayable track by default, because it
has a higher resolution. This change introduces a flag to
`Mp4Extractor` that results in the first video track being marked as
`ROLE_FLAG_MAIN`, and all subsequent video tracks `ROLE_FLAG_ALTERNATE`
- this then results in the playable lower-res track being selected by
default.

PiperOrigin-RevId: 589832072
2023-12-11 08:31:13 -08:00
christosts
4c4c5f6a90 CompositionVideoSinkProvider: apply rotation effects per video
There is a bug in CompositionVideoSinkProvider where the rotation
effect is applied only on the first video and the same effect
is applied on subsequent videos without checking if the next
items in the playlist must be rotated.

The bug applies only on devices with API < 21.

PiperOrigin-RevId: 589823797
2023-12-11 07:56:50 -08:00
ibaker
379cb3ba54 Tighten the handling of validDataChannelTimeoutMs in Cea608Parser
This matches the documented requirements for this parameter.

PiperOrigin-RevId: 589799256
2023-12-11 06:05:53 -08:00
tonihei
00c7a9bcbb Keep playback thread blocked until next action with playUntilPosition
We currently pause playback to prevent further progress while the
app thread runs assertion and triggers additional actions. This is
not ideal because we do not actually want to pause playback in
almost all cases where this method used.

This can be improved by keeping the playback thread blocked and only
unblock it the next time the app thread waits for the player (either
via RobolectricUtil methods or by blocking the thread itself). To
add this automatic handling, this change introduces a new util class
for the tests that can keep the list of waiting threads statically
(because the access to this logic is spread across multiple independent
classes).

PiperOrigin-RevId: 589784204
2023-12-11 04:45:31 -08:00
tofunmi
00d5b6ec99 TransformerEndToEndTest: replace /*testId=*/ with variable
PiperOrigin-RevId: 589765715
2023-12-11 03:14:34 -08:00
huangdarwin
1ebe099685 Test: Make a method scope private.
For clarity.

PiperOrigin-RevId: 589758781
2023-12-11 02:43:25 -08:00
tianyifeng
b2a673d521 Move preload components to androidx.media3.exoplayer.source.preload
PiperOrigin-RevId: 589455479
2023-12-09 13:41:55 -08:00
ibaker
224dad3988 Remove AnalyticsListener as a public super-type of ExoHostedTest
Move the `AnalyticsListener` implementation to a private inner class.

This avoids polluting the public API of `ExoHostedTest`, especially as
it's designed to be extended.

PiperOrigin-RevId: 589188113
2023-12-08 11:13:18 -08:00
sheenachhabra
ac67f739d4 Specify which input file has B-frames in Transformer demo app
For out of order B-frames, the samples comes out of order and hence
presentation timestamps are not strictly increasing.
This can be verified by adding following assertion in `writeSampleData()` API
either in `MuxerWrapper` or in `Muxer API`.
```
checkArgument(
          bufferInfo.presentationTimeUs > lastSamplePresentationTimeUs,
          "Out of order B-frames are not supported");
```

PiperOrigin-RevId: 589152093
2023-12-08 09:23:42 -08:00
samrobinson
1471528176 Change AudioGraph #release to #reset, resetting internal state.
PiperOrigin-RevId: 589113634
2023-12-08 06:36:32 -08:00
tofunmi
c5c8e988e8 Abandon trim optimization when transcoding effects are set
PiperOrigin-RevId: 588839072
2023-12-07 10:39:38 -08:00
samrobinson
ab798659d9 Request specific AudioFormat from AudioGraphInputs on creation.
Also adds an alternate way to configure the AudioGraph.

Apps should no longer need to ensure that inputs have the same sample
rate.

PiperOrigin-RevId: 588747431
2023-12-07 04:42:03 -08:00
andrewlewis
c014ba9d5f Use API 33 constants for DV levels
PiperOrigin-RevId: 588740855
2023-12-07 04:15:19 -08:00
tofunmi
be5b29d92d Update ExportResult.OptimizationResult options
Added a new ABANDONED option so one can tell the difference between when the optimization has been requested but not applied vs not requested at all. also changed the ordering do better represent the hierarchy of failure modes

PiperOrigin-RevId: 588720513
2023-12-07 02:52:16 -08:00
tofunmi
cd346ca14d Transformer: Add support for transmuxing audio in trim optimization
PiperOrigin-RevId: 588711597
2023-12-07 02:18:21 -08:00
christosts
faeff17a4c Fix bug in CompositingVideoSinkProvider.isInitialized()
Fix a bug where CompositingVideoSinkProvider.isInitialized() returns
true even after releasing the CompositingVideoSinkProvider.

PiperOrigin-RevId: 588481744
2023-12-06 11:01:45 -08:00
christosts
073ee8a1d0 Move instantiation of CompositingVideoSinkProvider
This change moves the instantiation of the CompositingVideoSinkProvider
out of MediaCodecVideoRenderer so that the composition preview player can
re-use the CompositingVideoSinkProvider instance for driving the rendering of
images.

The main point of the change is the ownership of the
VideoFrameReleaseControl, which decides when a frame should be rendered
and so far was owned by the MediaCodecVideoRenderer. With this change,
in the context of composition preview, the VideoFrameReleaseControl
is no longer owned by MediaCodecVideoRenderer, but provided to it.

This way, the CompositingVideoSinkProvider instance, hence the
VideoFrameReleaseControl can be re-used to funnel images into the
video pipeline and render the pipeline from elsewhere (and not
MediaCodecVideoRenderer).

PiperOrigin-RevId: 588459007
2023-12-06 09:52:43 -08:00
ibaker
bd19953ac9 Split Cue.toBundle into serializable and binder-based variants
The serializable form is used when we need to serialize the result into
bytes in the sample queue. The binder-based (ultimately
filedescriptor-based) form is used for
session/controller IPC, in order to avoid sending the bitmap bytes over
the IPC.

Issue: androidx/media#836

#minor-release

PiperOrigin-RevId: 588420836
2023-12-06 07:35:34 -08:00
huangdarwin
a98052b3fc Test: Mention expected bitmap in assertion message.
This helped me debug which bitmap was actually failing. Otherwise, you need to clear all bitmaps on the device relating to this test, then adb pull all bitmaps and see the last uploaded one to see, which is much more confusing.

PiperOrigin-RevId: 588374081
2023-12-06 04:17:37 -08:00
samrobinson
757585ce6d Release MuxerWrapper in every test (in an @After block).
PiperOrigin-RevId: 588110566
2023-12-05 10:13:27 -08:00
ibaker
6360082b87 Add extractor and playback tests for Pixel JPEG motion photo
This image has two video tracks in the MP4 data, one is a 'real' video
which we want to play by default, and the other is a low-fps video track
which isn't intended to be directly played, it's encoded in HEVC for
compression and decoding efficiency.

This test demonstrates ExoPlayer's current behaviour default extraction
and playback, which results in selecting the high-res, low-fps track
(actually single sample in this example), instead of playing the actual
video.

PiperOrigin-RevId: 588068908
2023-12-05 07:46:19 -08:00
ibaker
d4fe3fe318 Add Robolectric e2e test support for HEVC content
PiperOrigin-RevId: 588055594
2023-12-05 06:52:39 -08:00
Googler
e0f1783a54 Fix nullability issue in MediaControllerImplLegacy
PiperOrigin-RevId: 588035411
2023-12-05 05:24:57 -08:00
tofunmi
b0e2fd78af Use getter for presentationDurationUs
Delays failures to when the field is used in preview code, so that exports in the demo app can continue succeed

PiperOrigin-RevId: 588022569
2023-12-05 04:43:57 -08:00
michaelkatz
d1e38abf93 Limit processing Opus decode-only frames by seek-preroll in offload
As Opus decoders skip some bytes prior to playback during a seek, the renderer for bypass playback should send samples to the decoder even if they would be decode-only. However, the renderer should not send samples with time preceding that range. This change adds that constraint.

#minor-release

PiperOrigin-RevId: 588014983
2023-12-05 03:44:37 -08:00
tonihei
b1541b096f Map VORBIS channel layout to Android layout
Both the extension OPUS decoder and the OMX/C2 MediaCodec
implementations for OPUS and VORBIS decode into the channel
layout defined by VORBIS. See
https://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-140001.2.3

While this is technically correct for a stand-alone OPUS or VORBIS
decoder, it doesn't match the channel layout expected by Android.
See https://developer.android.com/reference/android/media/AudioFormat#channelMask

The fix is to apply the channel mapping after decoding if needed.
Also add e2e tests with audio dumps for the extension renderer,
including a new 5.1 channel test file.

Issue: google/ExoPlayer#8396

#minor-release

PiperOrigin-RevId: 588004832
2023-12-05 03:01:32 -08:00
ibaker
913f6da083 MCR: Ensure mediaCrypto and codec are atomically non-null
`mediaCrypto` is initialized before `codec` in
`maybeInitCodecOrBypass`. Before this change, it was possible for
`maybeInitCodecOrBypass` to complete with `mediaCrypto != null` and
`codec == null`, in particular if it was run as part of clearing the
player surface (since in that case, no video codec is initialized).
This inconsistent state then causes issues during a later invocation of
`maybeInitCodecOrBypass`, when `mediaCrypto` is still non-null, and
`mediaCryptoRequiresSecureDecoder = true`, but the
content has been changed to unencrypted with no associated DRM session.
This results in a playback error, because a secure decoder is
initialized but there's no DRM session available to work with it.

This change ensures that when `maybeInitCodecOrBypass` completes,
either both `mediaCrypto != null` and `codec != null` (i.e. codec
initialization was completed) or `mediaCrypto == null` and
`codec == null` (i.e. codec initialization was not completed). We also
ensure that when nulling out `mediaCrypto` we also set
`maybeInitCodecOrBypass = false`. A later change should be able to
demote `maybeInitCodecOrBypass` from a field to a local in order to
remove any risk of that part of state becoming out of sync. This
resolves the issue, because during the second invocation of
`maybeInitCodecOrBypass` an insecure decoder is now (correctly)
initialized and the unencrypted content is successfully played.

#minor-release

PiperOrigin-RevId: 587713911
2023-12-04 07:32:52 -08:00
tianyifeng
f32bdf86bc Set playerId when preloading to make the PreloadMediaSource reusable
We set the `playerId` only in the constructor currently. But in the case of this source doesn't have `preload` called, the player's release of this source will set the playerId to `null`, which makes this source un-reusable with a null `playerId`.

PiperOrigin-RevId: 587698214
2023-12-04 06:31:11 -08:00
tofunmi
88b15e73b2 fix: update TransformerPauseResumeTest to use isRunningOnEmulator
#minor-release

PiperOrigin-RevId: 586964536
2023-12-01 04:01:52 -08:00
samrobinson
fe272d3c49 Follow practices/guidance in Muxer tests around:
* @Before and @After usage. [1].
* static fields before non-static. [2].

@Before method should typically be paired with an @After method,
focused on ensuring that the component is released regardless of what
the test does.

In tests, inlining final class variables is preferrable [1]. In general
things like the file path should be part of the test (the @Rule means
we don't need before/after) if only used once.

Statically importing values and using them directly is preferable to
having a variable declared as non-final that's effectively final,
because from a readability perspective someone can see (the caps) that
the value is final static and immutable, so doesn't have to check if
it's changed/reassigned.

PiperOrigin-RevId: 586697887
2023-11-30 09:29:18 -08:00
tofunmi
5b3491082b fix: make BitmapOverlay constructor public
So developers can subclass it
#minor-release

PiperOrigin-RevId: 586638134
2023-11-30 04:54:06 -08:00
huangdarwin
a2a4ef5f40 Effect: Fix overlay alpha handling.
Before, a translucent overlay over an opaque video would result in a
translucent output. This is not consistent with physical properties of light
(if putting a translucent object in front of an opaque object, you can't see
behind the opaque object).

Using the mixing properties from DefaultVideoCompositor.

PiperOrigin-RevId: 586636275
2023-11-30 04:43:21 -08:00
ibaker
28c210686f Don't include null text or bitmaps in Cue.toBundle()
`fromBundle` doesn't distinguish between `FIELD_BITMAP` and `FIELD_TEXT`
being present with a null value, or being absent, so we might as well
avoid including them when the value is null.

I've separated this from a later change to add
`Cue.toSerializableBundle` which will also skip setting a bitmap value
into the `Bundle` if `this.bitmap == null`. This is partly because it
results in changes to a lot of extractor test dump files, and it's
easier to review that as a separate change.

PiperOrigin-RevId: 586626141
2023-11-30 03:58:33 -08:00
jbibik
03564fdbc6 Promote method to control subtitle parsing to MediaSource.Factory
PiperOrigin-RevId: 586361222
2023-11-29 09:12:04 -08:00
jbibik
8a8b875c72 Add experimental opt-in to parse SS subtitles during extraction
PiperOrigin-RevId: 586331888
2023-11-29 07:14:14 -08:00
huangdarwin
9add30e582 Effect: Use Bitmap generation ID to detect changes.
This is much simpler than using protected methods that signal updates in
bitmaps.

PiperOrigin-RevId: 586295312
2023-11-29 04:29:49 -08:00
christosts
3d1d8f4439 Exit early progressive loads if the load task is canceled
Add an check when loading progressive media in case the load
is canceled. If the player is released very early, the progressive
media period may carry on with the initial loading unnecessarily.

PiperOrigin-RevId: 586288385
2023-11-29 04:01:06 -08:00
andrewlewis
3204313f13 Remove debug logging
This case is expected and we aren't trying to gather information about it
currently, so we shouldn't log.

PiperOrigin-RevId: 586015969
2023-11-28 10:01:37 -08:00
huangdarwin
e5ef31b277 Effect: Avoid allocating bitmaps and textures in Overlays.
In `TextOverlay` and `DrawableOverlay`, treat `Bitmap` as a buffer, where we
allocate it rarely and reuse it as long as possible before making a new one.

In `BitmapOverlay`, avoid allocating GL textures too often as well.

Strongly reduces allocations and memory usage growth (saving ~100-150 MB on 4k60fps
at high end), at the cost of more code complexity and low-end using 70MB more, on
1/1 comparisons.

PiperOrigin-RevId: 585990602
2023-11-28 08:44:30 -08:00
huangdarwin
eb01c3f440 Add exception message for MediaCodecRenderer exception.
Otherwise, it's difficult to differentiate between different sources of ERROR_CODE_DECODING_FORMAT_UNSUPPORTED.

PiperOrigin-RevId: 585966636
2023-11-28 07:15:52 -08:00
andrewlewis
b8c1e22389 Clarify threading-related comments in texture manager
In `ExternalTextureManager` fields are accessed from the GL thread and the class needs to be constructed on the GL thread.

Also visibly document threading requirement in the parent class.

PiperOrigin-RevId: 585941284
2023-11-28 05:30:15 -08:00
andrewlewis
7bbf72c202 Use JsonWriter to convert to JSON
Before the change the output was JSON-like but not valid because it had commas
after objects/arrays.

PiperOrigin-RevId: 585929345
2023-11-28 04:39:50 -08:00
tofunmi
b598c96c2f Update emulator device names
PiperOrigin-RevId: 585682881
2023-11-27 10:02:02 -08:00
andrewlewis
1c7c06999e Turn off debug trace logging by default
The issue that motivated adding this (frames unexpectedly being dropped by the
decoder) has been addressed, so we can turn off the logging to reduce
unnecessary allocations during transformation. We can easily turn on debug
logging in future as needed by setting `DebugTraceUtil.DEBUG = true`.

Also avoid allocations for string building at logging call sites by passing a
format string for extra info. Formatting the string now only happens when
debugging is turned on.

Tested manually by running transformations in the new state (DEBUG = false) and
with debugging turned on.

PiperOrigin-RevId: 585666349
2023-11-27 08:57:30 -08:00