4401 Commits

Author SHA1 Message Date
cushon
04ca79182a Fix an invalid javadoc link
PiperOrigin-RevId: 641895590
2024-06-10 07:34:29 -07:00
ibaker
253fcb1fd1 Clarify docs on ExoPlayer.setVideoEffects() re calling prepare()
The previous wording suggested that `setVideoEffects()` may **only** be
called before `prepare()`, i.e. the effect cannot be changed during
playback. The intent is instead that `setVideoEffects()` must be called
once before playback in order to configure the effects pipeline, but
the effect can then be changed during playback by further calls to
`setVideoEffects()`.

Issue: androidx/media#1393
PiperOrigin-RevId: 641853629
2024-06-10 04:12:50 -07:00
kimvde
ec49d19384 Call VideoFrameReleaseControl.setPlaybackSpeed from sink when enabled
Do not call VideoFrameReleaseControl.setPlaybackSpeed directly from
MCVR when the video sink is enabled.

PiperOrigin-RevId: 641840894
2024-06-10 03:15:05 -07:00
dancho
abf601feaa Support upscaling with LanczosResample
Avoid scaling the lanczos windown function when scaling up.
When scaling up (output > input), we shouldn't scale the window
function or we risk not sampling any of the input pixels.

PiperOrigin-RevId: 641838149
2024-06-10 03:01:11 -07:00
tofunmi
228d63848e HDR-only assets sequence effect test: rename golden files
rename to match test name

PiperOrigin-RevId: 641836522
2024-06-10 02:53:34 -07:00
tofunmi
0d2fdcd025 Add Transformer HDR-only assets sequence effect tests.
PiperOrigin-RevId: 641828107
2024-06-10 02:11:09 -07:00
kimvde
2c71150f2b Set VideoSink listener when enabling MCVR
Before, the listener was set in onReadyToInitializeCodec, which means
that it was reset every time a new codec was used.

We need to set the listener every time MCVR is enabled (not only the
first time), because it might have been set by another renderer.

PiperOrigin-RevId: 641825717
2024-06-10 02:01:00 -07:00
ibaker
82970a6861 Remove incorrect 'bundleable' reference from stringMapToBundle param
This was accidentally copy-pasted in 5008417c8c

PiperOrigin-RevId: 641823991
2024-06-10 01:54:09 -07:00
samrobinson
6bb3af527a Add support for setting and getting volume for composition preview.
PiperOrigin-RevId: 641822822
2024-06-10 01:46:10 -07:00
claincly
b42b63f3a3 Change externalShaderProgramInputCapacity to int
The field is only accessed on the GL thread.

PiperOrigin-RevId: 641273595
2024-06-07 09:34:45 -07:00
ibaker
b1c6d9ff04 Mark PlayerWrapper as final
This package-private class isn't currently extended, so this change
makes it not possible to be extended in future.

PiperOrigin-RevId: 641270464
2024-06-07 09:23:56 -07:00
andrewlewis
3b6175daa7 Fix test names
PiperOrigin-RevId: 641249128
2024-06-07 07:56:30 -07:00
claincly
ea7cfeccb8 Fix timestamps in tests
38a7229d96 changed only some of the timestamps, in fact all
of the timestamps should have the offset removed.

PiperOrigin-RevId: 641226102
2024-06-07 06:04:31 -07:00
claincly
39e572ad6d Fix a concurrency issue that shader capacity is set off GL thread
Also add test to cover transitions between BT709 and 601.

PiperOrigin-RevId: 641224971
2024-06-07 05:59:20 -07:00
claincly
38a7229d96 Unify timestamp handling
Before this change, the timestamps output from composition playback is offset
with the renderer offset. After this change, the offset is removed and the
timestamp behaviour converges with Transformer, that is, the timestamps of
video/images frames will follow that of the composition. For example, with a
composition of two 10-s items, clipping the first with 2s at the start, the
timestamp of the first frame in the second item, will be 8s.

PiperOrigin-RevId: 641121358
2024-06-06 21:36:15 -07:00
sheenachhabra
ec0af5a7e0 Add CodecDetails to ExportException
This will replace the existing free-form string in the error message

PiperOrigin-RevId: 640954158
2024-06-06 11:01:29 -07:00
tonihei
977fe6aef3 Stabilize offload related error codes
PiperOrigin-RevId: 640839273
2024-06-06 03:34:58 -07:00
tofunmi
cd5a638e43 MuxerWrapper: Fix spelling mistake in method name
PiperOrigin-RevId: 640838741
2024-06-06 03:32:19 -07:00
tonihei
f238db8208 Exit early if buffer becomes invalid
When the frame release control invalidates a buffer and returns that
the buffer must be ignored, we need to exit early before performing
additional checks that may result in method calls using the invalid
buffer.

PiperOrigin-RevId: 640555688
2024-06-05 09:48:30 -07:00
tonihei
9547828468 Add missing null check
PiperOrigin-RevId: 640555113
2024-06-05 09:45:28 -07:00
rohks
438279a3a0 Remove unnecessary throws Exception from HlsChunkSourceTest
PiperOrigin-RevId: 640552488
2024-06-05 09:35:53 -07:00
samrobinson
8a02b44c96 Refactor trim optimization getProgress for improved readability.
This change is a no-op refactor to improve the readability of the
states returned in this method.

PiperOrigin-RevId: 640538374
2024-06-05 08:45:02 -07:00
samrobinson
01b860fdc4 Fix invalid state transitions for trim optimization getProgress.
Ensures valid progress state is returned. Should not return NOT_STARTED
once transformer.start has been called, until export ends.

PiperOrigin-RevId: 640533805
2024-06-05 08:30:42 -07:00
kimvde
f54380f9d8 Remove direct usages of release control when video sink is used
Usages removed in this CL are:
- onProcessedStreamChange, which was already called from the VideoSink
  (via VideoFrameRenderControl)
- setOutputSurface, which was also already called from the VideoSink
- setFrameRate, which this CL now sets in the VideoSink

PiperOrigin-RevId: 640530903
2024-06-05 08:19:17 -07:00
kimvde
9716985272 Move renderer state methods from release control to sink
PiperOrigin-RevId: 640515298
2024-06-05 07:16:36 -07:00
sheenachhabra
f3a9c74de2 Remove @UnknownInitialization DefaultCodec parameter
Using an uninitialised object seems unusual.

PiperOrigin-RevId: 640514501
2024-06-05 07:12:20 -07:00
samrobinson
67c19f87a7 Update FILE_UNKNOWN_DURATION to a longer fmp4 (~15s),
Removes the flakiness of
MediaItemExportTest.getProgress_unknownDuration_returnsConsistentStates
by using a longer input asset, such that ExoPlayer does not determine
the duration of the media.

PiperOrigin-RevId: 640502470
2024-06-05 06:19:11 -07:00
kimvde
d5e9f3b224 MCVR: use shouldUseVideoSink where possible
Before this CL, we were checking whether the video sink was initialized
to determine whether it should be used. In the meantime,
shouldUseVideoSink has been introduced. Use this boolean to check
whether to use the video sink as it's a clearer signal.

PiperOrigin-RevId: 640499147
2024-06-05 06:05:03 -07:00
dancho
9c4a532d5c Add LanczosResample effect to scale videos in Transformer
Add SeparableConvolution.configure(inputSize) to allow effect configuration
depending on input dimensions.
Add LanczosResample.scaleToFit method to scale input images to fit inside
given dimensions.

PiperOrigin-RevId: 640498008
2024-06-05 06:00:25 -07:00
kimvde
3334f0afee Decide whether to use the VideoSink when enabling renderer
This will simplify moving the release control inside the video sink

PiperOrigin-RevId: 640416128
2024-06-04 23:59:10 -07:00
jbibik
f3444aee5f Add icons for fastforward and rewind buttons
PiperOrigin-RevId: 640206040
2024-06-04 10:46:36 -07:00
tianyifeng
6dbf548253 Version bump to media3:1.4.0-alpha02
#minor-release

PiperOrigin-RevId: 640196724
2024-06-04 10:21:36 -07:00
dancho
5371ad406b Skip AV1 test on devices that don't support AV1 HDR encoding
Skip AV1 HDR test on some devices.

PiperOrigin-RevId: 640135455
2024-06-04 06:44:23 -07:00
jbibik
35b8ab411d Add isReleased() to the Exoplayer
This avoids having to add AnalyticsListener and catching the `onPlayerReleased` callback.

The `Exoplayer.release()` method is blocking and one can be sure that the player is released if the call returned. However, the method is useful for UI testing and asserting that the player is released after a certain UI action, e.g. closing the activity or detaching a window.

PiperOrigin-RevId: 640114416
2024-06-04 05:11:15 -07:00
dancho
73dd743929 Support Separable Convolutions with negative coefficients
fragment_shader_separable_convolution_es2.glsl had optimizations that assumed
all convolution coefficients are positive. Support negative coefficients,
and add tests.

PiperOrigin-RevId: 640104741
2024-06-04 04:26:26 -07:00
jbibik
d35bc176ff Allow customisation of various icons in PlayerControlView
Before this change:
The only way to customize the icons was to override the drawables, e.g.
* `exo_styled_controls_play`
* `exo_styled_controls_pause`

However, that would set the drawables globally and prevent users from customizing the icons **per** PlayerView.

After the change, it is possible to provide drawable icons in the xml layout directly via `<androidx.media3.ui.PlayerView>` and
* `app:play_icon="@drawable/...`
* `app:pause_icon="@drawable/...`
* `app:vr_icon="@drawable/...`
* `app:fullscreen_exit_icon="@drawable/...`
* `app:next_icon="@drawable/...`

Note:
Two buttons that are left out of this change are fast-forward and rewind. They are more complicated due to layout insertion and customization with seek back/forward increments in the TextView.

Issue: androidx/media#1200
PiperOrigin-RevId: 639832741
2024-06-03 10:32:39 -07:00
tonihei
9ed86441e3 Remove module registration from HttpEngineDataSource
It used to be its own module in the first revision, but then moved
into the DataSource module as of 250fc80419.

PiperOrigin-RevId: 639745498
2024-06-03 05:31:01 -07:00
samrobinson
2c916dc306 Make progress tests stricter.
These changes are possible because getProgress is no longer a blocking
operation on transformer.

* Tests call getProgress after every looper message executed.
* Use longer media assets for getProgress tests to give more progress
  intervals.
* Remove conditional assertions.

PiperOrigin-RevId: 639734368
2024-06-03 04:42:36 -07:00
dancho
2bb12de00d Drop API requirement from SeparableConvolution
Switch from 4-channel RGBA_16F lookup texture to 1-channel R_16F.
Do not use a bitmap when creating the lookup table texture.
Instead, fill the texture directly.
Do not manually convert 32-bit float to 16-bit. Instead, let OpenGL
libraries do this for us.

PiperOrigin-RevId: 639717235
2024-06-03 03:31:41 -07:00
rohks
387153fcf2 Fix CMCD data assignment for init segment
The CMCD data was incorrectly added to the `dataSpec` of the media segment instead of the init segment.

Also relaxed the condition for playbackRate to be C.RATE_UNSET when creating an instance of CmcdData.Factory as there was nothing enforcing this check.

#minor-release

PiperOrigin-RevId: 639046080
2024-05-31 08:42:53 -07:00
tianyifeng
9916428728 Add FOREGROUND_SERVICE_MEDIA_PLAYBACK permission for test session app
Foreground service type `mediaPlayback` requires permission `android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK`. The `MockMediaSessionService`, `LocalMockMediaSessionService`, `MockMediaLibraryService`
 and `LocalMockMediaLibraryService` declared in the manifest are in the `mediaPlayback` type.

PiperOrigin-RevId: 639013810
2024-05-31 06:23:17 -07:00
dancho
d3fa33250b Fix a race condition in AudioGraphInput
AudioGraphInput.onMediaItemChanged is called on input thread. Pending
media item changes are processed on processing thread, inside calls to
getOutput().
This change allows multiple pending media item changes to be enqueued,
and processed in sequence.

PiperOrigin-RevId: 638995291
2024-05-31 04:53:13 -07:00
ibaker
4dd8360693 Allow ByteArrayDataSource to resolve the byte array when opened
This is a relatively small change, and massively simplifies the work
needed for an app to consume Kotlin Multiplatform resources (without a
full `KmpResourceDataSource` implementation, which poses some
dependency challenges for now).

Issue: androidx/media#1405
PiperOrigin-RevId: 638991375
2024-05-31 04:33:14 -07:00
michaelkatz
ac34798344 Schedule doSomeWork when MediaCodec signals available buffers
When running in asynchronous mode, MediaCodec will be running the CPU to signal input and output buffers being made available for use by the player. With ExoPlayer.experimentalSetDynamicSchedulingEnabled set to true, ExoPlayer will wakeup to make rendering progress when MediaCodec raises these signals. In this way, ExoPlayer work will align more closely with CPU wake-cycles.

PiperOrigin-RevId: 638962108
2024-05-31 02:22:16 -07:00
jbibik
a652c5b3f5 Add references in javadocs to relevant listeners for Player fields
PiperOrigin-RevId: 638688864
2024-05-30 10:02:01 -07:00
michaelkatz
43f719fbb2 Schedule exoplayer work to when MediaCodecAudioRenderer can progress
Currently ExoPlayer schedules its main work loop on a 10 ms interval. When renderers cannot make any more progress (ex: hardware buffers are fully written with audio data), ExoPlayer should be able to schedule the next work task further than 10ms out into the future.

Through `experimentalSetDynamicSchedulingEnabled` and these changes to `MediaCodecAudioRenderer`, ExoPlayer can use the data provided by the audio renderer to dynamically schedule its work tasks based on when it is expected that progress can be made.

PiperOrigin-RevId: 638677454
2024-05-30 09:25:11 -07:00
tianyifeng
e879c4ac43 Call PreloadControl.onSourcePrepared only once for each preload request
PiperOrigin-RevId: 638677090
2024-05-30 09:21:59 -07:00
michaelkatz
9e0f533a11 Schedule exoplayer work task to when renderers can make progress
Currently ExoPlayer schedules its main work loop on a 10 ms interval. When renderers cannot make any more progress(ex: hardware buffers are fully written with audio data), ExoPlayer should be able to schedule the next work task further than 10Ms out.

Through `experimentalSetDynamicSchedulingEnabled`, ExoPlayer will dynamically schedule its work tasks based on when renderers are expected to be able to make progress.

PiperOrigin-RevId: 638676318
2024-05-30 09:19:28 -07:00
rohks
8c8bf1334e Use INDEX_UNSET instead of LENGTH_UNSET for next media sequence/part
Both constants have the same value, but the method returning initial values for the media sequence/part uses `INDEX_UNSET`, so it makes sense to use it.

PiperOrigin-RevId: 638673282
2024-05-30 09:10:09 -07:00
sheenachhabra
d598eb064d Remove unnecessary sortKey from Mp4Muxer.addTrack()
PiperOrigin-RevId: 638647112
2024-05-30 07:37:26 -07:00