242 Commits

Author SHA1 Message Date
jbibik
f7c31bd3ef Fix Gradle Lint with @RequiresApi and SDK version
Gradle Lint doesn't recognise `checkState` assertion and TargetApi should only ever be used for suppressing a bug in Android Lint. Hence, we keep @RequiresApi and add an if-statement explicitly. Also, fixes >26 to >=26 for the version check.

#minor-release

PiperOrigin-RevId: 555144577
2023-08-10 12:21:27 +00:00
rohks
481ea4a274 Enhance continueLoading() API to allow passing more information
Modifies the `SequenceableLoader.continueLoading(long)` method in the `SequenceableLoader` interface to `SequenceableLoader.continueLoading(LoadingInfo)`.

`LoadingInfo` contains additional parameters, including `playbackSpeed` and `lastRebufferRealtimeMs` in addition to the existing `playbackPositionUs`. The additional parameters will allow us to pass these information to Common Media Client Data (CMCD) logging.

By using the `LoadingInfo` object, we ensure future flexibility to add more fields without causing any breaking changes to the API.

PiperOrigin-RevId: 555123961
2023-08-10 12:16:41 +00:00
andrewlewis
691bf93032 Use lower resolution bitmap for tests
The test file decompresses to about 48 MB, which can cause an
`OutOfMemoryError` on lower end devices.

Also, a test appears to apply a rotation to this bitmap without downscaling
first, leading to exceeding a maximum texture width/height of 4096 on some
devices.

Replace the test file with one that has a quarter of the original's
width/height so that these tests can pass reliably even on lower end
devices.

PiperOrigin-RevId: 554507185
2023-08-10 11:58:25 +00:00
claincly
670658f3ae Use a larger pixel difference on real devices
PiperOrigin-RevId: 554452842
2023-08-07 14:04:36 +00:00
huangdarwin
05782a7e99 Compositor: Add support for mismatched timestamps.
This means we now require 2+ input frames per input, and compare the primary
stream timestamp with secondary stream timestamps in order to select the
correct output timestamp. We also must release frames and back-pressure as
soon as possible to avoid blocking upstream VFPs.

Also, improve signalling of VFP onReadyToAcceptInputFrame

PiperOrigin-RevId: 553448965
2023-08-07 11:29:44 +00:00
huangdarwin
4302102cf0 Test: Use TestName in media3.effects tests.
Instead of duplicating strings

PiperOrigin-RevId: 552865414
2023-08-07 11:22:02 +00:00
claincly
c221958889 Remove setInputFrameInfo
After this change, every queued bitmap is treated as an individual input stream
(like a new MediaItems).

This change merges the FrameDropTest and FrameDropPixelTest into one (while maintaining all the test cases)

- This is accomplished by generating bitmaps with timestamps on it in FrameDropTest and compare them with goldens (one may call this a pixel test, please lmk if you want this to be renamed)
- The most part of the change comes from DefaultVideoFrameProcessorVideoFrameRenderingTest. The overall working is
  - We bypass the input manager
  - The TestFrameGenerator generates frames based on timestamps. In this case, we generate frames with timestamps on it
  - The generated frame is sent to texture output and in turn saved to bitmaps
  - We then compare the generated bitmap with the goldens

PiperOrigin-RevId: 551795770
2023-08-01 14:17:59 +01:00
Googler
7adc0af8a6 Save to TestStorage when saving Bitmap
PiperOrigin-RevId: 548733979
2023-07-20 10:15:47 +01:00
huangdarwin
952086174a Test: Remove unused DecodeOneCacheFileFrame method.
PiperOrigin-RevId: 547821350
2023-07-14 10:18:17 +01:00
huangdarwin
c122c0ca05 Compositor: Add support for multiple bitmaps, and add testrunner
* Allow more than one input bitmap at a time.
* Allow Compositor to take in and set up an Executor. Otherwise,
Compositor resources may be created on one thread and accessed on another.
* Add a Compositor TestRunner to reuse test code more.
* Update VideoFrameProcessingTaskExecutor to use a new onError listener, so
that it's more reusable in non-DVFP contexts, like for Compositor.

PiperOrigin-RevId: 547206053
2023-07-13 15:45:30 +01:00
tonihei
7441c1f083 Add more data to e2etest dumps
We currently only log the input buffers to the codec, but the test
will be more complete and provide more insights into the playback
behavior if we also dump more information about these input buffers
(timestamps and flags) and also all output buffers with their
timestamps and whether they are rendererd (only relevant for video).
And also use the CapturingAudioSink to output the audio data we produce.

PiperOrigin-RevId: 546898937
2023-07-13 15:33:33 +01:00
tonihei
3d4bd7ce19 Make MediaItems updateable
This changes all MediaSources in our library to allow updates to
their MediaItems (if supported).

Issue: google/ExoPlayer#9978
Issue: androidx/media#33
PiperOrigin-RevId: 546808812
2023-07-13 15:26:30 +01:00
huangdarwin
cd0b45092e Test: Rename bitmap test method from Current to Focused GlFrameBuffer
Frame buffers are focused, not current. EGL Contexts may be current but this
is a prerequisite for focusing a framebuffer, and this alone isn't
sufficient to make a bitmap.

Clear this up as it can make some complex tests harder to understand, if the
methods needed don't match up in naming.

PiperOrigin-RevId: 546305118
2023-07-13 15:15:34 +01:00
huangdarwin
7a368b9a11 Effect: Remove GlTextureInfo accessor methods.
The extra check was a bit excessive, especially as it's called multiple times
per frame.

PiperOrigin-RevId: 545657102
2023-07-13 14:51:38 +01:00
tonihei
aa57d48347 Add MediaSource.canUpdateMediaItem/updateMediaItem
This allows MediaSources to accept MediaItem updates after creation.

This CL adds the handling and plumbing logic in `ExoPlayerImpl`,
`ExoPlayerImplInternal`, `MediaSourceList` and `MaskingMediaSource`.

It also updates all forwarding/wrapping sources to forward these calls
to their wrapped instance.

The actual functionality is only added to `FakeMediaSource` instances in
tests so far.

PiperOrigin-RevId: 545450210
2023-07-05 09:21:22 +00:00
michaelkatz
de4575da28 Add nanoTime method to Clock to support overriding System.nanoTime()
#minor-release

PiperOrigin-RevId: 545237925
2023-07-05 09:15:49 +00:00
huangdarwin
1fce0cfd4d Test: Fix missed latch exceptions.
Catch timeouts, and general errors in the case of an InterupptedException.

PiperOrigin-RevId: 545219647
2023-07-05 09:09:59 +00:00
huangdarwin
546b9a2a88 Effect Test: Use latch instead of thread.sleep.
The timeout time of 5000ms is quite long, and means that for tests with >1
VFPTestRunner, like texture output and compositor tests, we have to wait 10s.

The latch allows us to continue with the test once we're done processing input,
instead of needing to wait longer, until the timeout is reached.

PiperOrigin-RevId: 545159839
2023-07-05 09:06:14 +00:00
tofunmi
6f9731ce7e TextureInput: Advise client to delete syncObject after use
PiperOrigin-RevId: 544670927
2023-07-05 08:57:55 +00:00
tofunmi
8cecb93570 Texture Input: Add GLSyncToken to the OnInputFrameProcessedListener
PiperOrigin-RevId: 543867944
2023-06-29 23:02:20 +00:00
claincly
f98a10f3f2 Move GlShaderProgram creation away from VFP creation
PiperOrigin-RevId: 543773418
2023-06-29 23:00:11 +00:00
sheenachhabra
8735382590 Move SSIM related files to test_util
PiperOrigin-RevId: 543444043
2023-06-29 22:51:20 +00:00
tonihei
2322462404 Do not trim audio samples by changing their timestamp
MP4 edit lists sometimes ask to start playback between two samples.
If this happens, we currently change the timestamp of the first
sample to zero to trim it (e.g. to display the first frame for a
slightly shorter period of time). However, we can't do this to audio
samples are they have an inherent duration and trimming them this
way is not possible.

#minor-release

PiperOrigin-RevId: 543420218
2023-06-29 22:50:04 +00:00
jbibik
ea0f564c1e Fix missing equals sign in inline-comment parameter names
PiperOrigin-RevId: 542577676
2023-06-23 16:44:33 +00:00
tonihei
2ac5d8f1af Make FakeClock Espresso and Compose UI test compatible
FakeClock currently doesn't work well with Espresso and Compose UI
tests because view interactions in both frameworks intentionally idle
the main looper to handle pending UI effects. However, this also
advances playback progress even though we want to deterministically
trigger progress from the test itself.

To solve this problem, we can detect the idling Robolectric call and
postpone any further updates until we leave this state.

PiperOrigin-RevId: 541831050
2023-06-20 14:03:06 +01:00
tofunmi
251fb013c3 Reset the simple frame dropping logic on flush or EOS.
#minor-release

PiperOrigin-RevId: 540633875
2023-06-19 16:20:09 +01:00
Googler
42915e9a58 Rename the APIs for playback suppression due to unsuitable output.
The APIs /related fields for playback suppression due to unsuitable output should be renamed from '..SuppressPlaybackWhenNoSuitableOutputAvailable' to '..SuppressPlaybackOnUnsuitableOutput'

PiperOrigin-RevId: 540555715
2023-06-19 16:12:33 +01:00
ibaker
3ce6c06169 Rollback of 45d35c5d78
*** Original commit ***

Suppress warnings in preparation for Checker Framework version 3.34.0-eisop1

***

PiperOrigin-RevId: 540539608
2023-06-19 16:11:42 +01:00
huangdarwin
5fc5105f7a Test: Log saved bitmap file path.
This helps debug bitmap tests. Without this CL, I typically
need to go into the file to find the test name and absolute
path. With this CL, I can just adb pull the printed file path,
which is much simpler.

PiperOrigin-RevId: 540539042
2023-06-19 16:10:30 +01:00
bachinger
bd97dd8519 Rollback of 7956c80f73
*** Original commit ***

Rollback of 2a6f893fba

*** Original commit ***

Set video size to 0/0 when video render is disabled

In terms of MCVR wi...

***

PiperOrigin-RevId: 540525069
2023-06-19 16:09:13 +01:00
tonihei
51fb72b00d Replace deprecated NullableType from checkerframework with our own one
The existing NullableType has been deprecated 5 years ago and causes
crashes in Kotlin apps because Kotlin doesn't recognize this annotation
as a nullable type annotation.

While we can't align on a single @Nullable annotation yet, we can at
least replace this one by JSR305's @Nonnull(MAYBE) as it fulfils all
requirements, including full Kotlin compatiblity. To avoid the
cumbersome name, we can redefine it as our own @NullableType
annotation. (We can't use @Nullable to avoid name clashes with the main
@Nullable annotation from AndroidX)

Issue: google/ExoPlayer#6792
PiperOrigin-RevId: 540497469
2023-06-19 16:08:20 +01:00
cushon
45d35c5d78 Suppress warnings in preparation for Checker Framework version 3.34.0-eisop1
More information: go/checker-lsc

Tested:
    TAP --sample ran all affected tests and none failed
    http://test/OCL:539686832:BASE:539663180:1686589466563:d12d5eb7
PiperOrigin-RevId: 539887073
2023-06-14 20:29:07 +01:00
claincly
5961637c0a Add test for per-MediaItem effect
The test transcodes four media items with distinct effects, keeping one frame
each; extracts the four frames in the produced video, and compares them against
the expected results.

PiperOrigin-RevId: 539697344
2023-06-14 20:27:37 +01:00
tofunmi
219212d54f rename videoFrameProcessorTestRunner.queueInputBitmap
This methods currently registers and queues the bitmaps Will need to have a method that just queues bitmaps in future CLs.

#minor-release

PiperOrigin-RevId: 539605628
2023-06-12 14:06:22 +00:00
claincly
5f43180a68 Allow using different video effects per MediaItem
PiperOrigin-RevId: 539596345
2023-06-12 14:04:42 +00:00
Googler
605af62d00 Add playback suppression for the attempted playbacks on an unsuitable output.
This CL introduces the new public API setSuppressPlaybackWhenUnsuitableOutput which if set to TRUE will cause suppression of a requested playback if that is going to happen on an unsuitable audio output (e.g. builtin speaker on a WearOS device).

PiperOrigin-RevId: 538867212
2023-06-09 13:58:42 +00:00
huangdarwin
adf53b4d50 Effect: Add multiple texture output test.
Confirms that multiple textures can be output, and that timestamps and pixels
are as expected.

PiperOrigin-RevId: 538459296
2023-06-08 12:37:00 +00:00
Googler
7956c80f73 Rollback of 2a6f893fba
*** Original commit ***

BEGIN_PUBLIC
Set video size to 0/0 when video render is disabled

In terms of MCVR with a `VideoRendererEventListener`, the video size is set to
0/0 right after `onVideoDisabled()` is called and is set to the actual size as
soon as the video size is known after 'onVideoEnabled()`.

For ExoPlayer and in terms of the `Player` interface, `Player.getVideoSize()`
returns a video size of 0/0 when `Player.getCurrentTracks()` does not support
`C.TRACK_TYPE_VIDEO`. This is ensured by the masking behavior

***

PiperOrigin-RevId: 537938947
2023-06-06 18:06:46 +00:00
ibaker
7e6dae7b31 Remove exoplayer2-only javadoc machinery from media3
This introduces whitespace-only changes in exoplayer2 due to the way
copybara stripping works.

PiperOrigin-RevId: 537296933
2023-06-05 09:47:58 +00:00
huangdarwin
06908e1a86 Rollback of 438ae0ed6a
*** Original commit ***

ExoPlayer: Add setVideoFrameProcessorFactory().

This allows apps to use a custom VideoFrameProcessor implementation for video
playback. This may be useful, for example, when outputting to a texture.
***

PiperOrigin-RevId: 536391597
2023-05-30 14:26:39 +00:00
tonihei
2c07468908 Implement Player.replaceMediaItem(s)
This change moves the default logic into the actual Player
implementations, but does not introduce any behavior changes compared
to addMediaItems+removeMediaItems except to make the updates "atomic"
in ExoPlayerImpl, SimpleBasePlayer and MediaController. It also
provides backwards compatbility for cases where Players don't support
the operation.

Issue: google/ExoPlayer#8046

#minor-release

PiperOrigin-RevId: 534945089
2023-05-25 10:00:02 +01:00
ibaker
cad1ac2eb5 Remove deprecated ExoPlayer.setHandleWakeLock(boolean)
Use `setWakeMode(int)` instead.

#minor-release

PiperOrigin-RevId: 534344010
2023-05-24 15:49:01 +01:00
huangdarwin
a6897aedaa Effect: Add GlTextureInfo release() and accessor methods.
This allows us to disallow access after release.

PiperOrigin-RevId: 534046475
2023-05-24 15:42:47 +01:00
huangdarwin
438ae0ed6a ExoPlayer: Add setVideoFrameProcessorFactory().
This allows apps to use a custom VideoFrameProcessor implementation for video
playback. This may be useful, for example, when outputting to a texture.

PiperOrigin-RevId: 534044831
2023-05-24 15:41:46 +01:00
bachinger
2a6f893fba Set video size to 0/0 when video render is disabled
In terms of MCVR with a `VideoRendererEventListener`, the video size is set to
0/0 right after `onVideoDisabled()` is called and is set to the actual size as
soon as the video size is known after 'onVideoEnabled()`.

For ExoPlayer and in terms of the `Player` interface, `Player.getVideoSize()`
returns a video size of 0/0 when `Player.getCurrentTracks()` does not support
`C.TRACK_TYPE_VIDEO`. This is ensured by the masking behavior of
`ExoPlayerImpl` that sets an empty track selection result when the playing
period changes due to a seek or timeline removal.

When transitioning playback from a video media item to the next, or when
seeking within the same video media item, the renderer is not disabled.

#minor-release

PiperOrigin-RevId: 533479600
2023-05-24 15:28:20 +01:00
ibaker
d5f9cf4f19 Add singleVariant publishing config to all published gradle files
Docs:
* https://developer.android.com/build/publish-library/configure-pub-variants#single-pub-var
* https://developer.android.com/reference/tools/gradle-api/8.0/com/android/build/api/dsl/PublishingOptions

This resolves the following warning from Android Gradle Plugin 7.2.2 and
helps unblock the upgrade to AGP 8.0.1:

> Software Components will not be created automatically for Maven
> publishing from Android Gradle Plugin 8.0. To opt-in to the future
> behavior, set the Gradle property
> `android.disableAutomaticComponentCreation=true` in the
> `gradle.properties` file or use the new publishing DSL.
>
> Affected Modules: `lib-cast`, `lib-common`, `lib-container`,
> `lib-database`, `lib-datasource`, `lib-datasource-cronet`,
> `lib-datasource-okhttp`, `lib-datasource-rtmp`, `lib-decoder`,
> `lib-effect`, `lib-exoplayer`, `lib-exoplayer-all (legacy)`,
> `lib-exoplayer-dash`, `lib-exoplayer-hls`, `lib-exoplayer-ima`,
> `lib-exoplayer-rtsp`, `lib-exoplayer-smoothstreaming`,
> `lib-exoplayer-workmanager`, `lib-extractor`, `lib-media2 (legacy)`,
> `lib-mediasession (legacy)`, `lib-muxer`, `lib-session`,
> `lib-transformer`, `lib-ui`, `lib-ui-leanback`, `test-utils`,
> `test-utils-robolectric`

Issue: androidx/media#409
PiperOrigin-RevId: 533464133
2023-05-19 17:22:21 +01:00
ibaker
50112c685b Remove deprecated ExoPlayer.retry(), use prepare() instead.
#minor-release

PiperOrigin-RevId: 533463348
2023-05-19 17:21:17 +01:00
ibaker
b3db85133a Add android.namespace to all build.gradle files
This is a pre-requisite for the Android Studio upgrade assistant to
upgrade from AGP 7.2.2 to 8.0.1, otherwise it fails and complains
this is missing.

Issue: androidx/media#409
PiperOrigin-RevId: 533463246
2023-05-19 17:19:15 +01:00
huangdarwin
25fa2df2de Effect: Use callback to release texture
This allows us to avoid needing a reference to the VideoFrameProcessor, which
can be especially difficult if an App only has a reference to the
VideoFrameProcessor.Factory it passes into Transformer/ExoPlayer.

PiperOrigin-RevId: 533205983
2023-05-19 17:10:53 +01:00
jbibik
1c6b894e88 Allow ExoPlayer to opt into volume device control, forbidden by default
PiperOrigin-RevId: 532136692
2023-05-16 09:54:37 +01:00