20923 Commits

Author SHA1 Message Date
ibaker
5fcc7433a1 Use MediaCodec.stop() before release() for surface switching bug
ExoPlayer used to call `stop()` before `release()`. This was removed in
<unknown commit>.

A framework bug introduced in Android 11 (API 30) resulted in some
DRM -> clear transitions failing during `MediaCodec.configure()`. An
investigation in Issue: google/ExoPlayer#8696 and b/191966399 identified that this was
due to `release()` returning 'too early' and the subsequent
`configure()` call was then trying to re-use a `Surface` that hadn't
been fully detached from the previous codec. This was fixed in
Android 13 (API 33) with http://r.android.com/2094347.

ExoPlayer worked around the framework bug by adding an arbitrary 50ms
sleep after a failed codec initialization, followed by retrying. This
was enough to resolve the problem in the test scenario on a OnePlus
AC2003.

Issue: androidx/media#1497 points out that 50ms might not be the appropriate delay
for all devices, so it's an incomplete fix. They suggested re-adding the
`MediaCodec.stop()` call instead. This also reliably resolves the issue
on the OnePlus AC2003 (with neither workaround in place, the problem
repros almost immediately).
PiperOrigin-RevId: 646461943
2024-06-25 06:54:45 -07:00
claincly
73bf852405 Make ExoPlayer.setVideoEffects() timestamp start from 0
This is consistent with `Transformer` and `CompositionPlayer`

Issue: androidx/media#1098
PiperOrigin-RevId: 646446824
2024-06-25 05:59:15 -07:00
tonihei
867410fece Rename DummyTrackOutput and DummyExtractorOutput
#cherrypick

PiperOrigin-RevId: 646434450
2024-06-25 05:07:56 -07:00
tonihei
18e631ff79 Add guard against additional tracks reported by Extractors
Extractors should not report additional tracks once they called
ExtractorOutput.endTracks. This causes thread safety issues in
ProgressiveMediaPeriod where the array of sample queues is
extended while the playback thread accesses the arrays.

Detecting this problem early is beneficial to avoid unexplained
exceptions later one. In most cases where this may happen (namely
TS extractors finding new tracks), it's better to ignore the new
tracks instead of failing completely. So this change adds a
warning log message and assigns a placeholder output.

Note: The same workaround already exists in HlsSampleStreamWrapper
and MediaExtractorCompat.

Issue: androidx/media#1476
#cherrypick
PiperOrigin-RevId: 646427213
2024-06-25 04:38:22 -07:00
Copybara-Service
0466728497 Merge pull request #1479 from dryganets:sdryanets/fix-handler-usage
PiperOrigin-RevId: 646402268
2024-06-25 02:56:09 -07:00
kimvde
304c4e41f8 Call VideoFrameReleaseControl.isReady from VideoSink when enabled
PiperOrigin-RevId: 646385384
2024-06-25 01:51:14 -07:00
sheenachhabra
babc9c69c6 Remove unnecessary FileChannel from Mp4Muxer
As per the documentation, closing a `FileOutputStream`
automatically closes the associated `FileChannel`.

PiperOrigin-RevId: 646152280
2024-06-24 10:58:30 -07:00
sheenachhabra
327f728010 Move muxer closing logic from Mp4Writer to Mp4Muxer
PiperOrigin-RevId: 646134522
2024-06-24 10:11:52 -07:00
Copybara-Service
b026271c84 Merge pull request #1416 from khouzam:customFormat
PiperOrigin-RevId: 646121082
2024-06-24 09:30:28 -07:00
tonihei
58864a4bb9 Additional variable changes + argument checks in HandlerWrapper 2024-06-24 16:42:02 +01:00
Sergei Dryganets
457deec4eb Stop using what == 0 for messages. 2024-06-24 16:26:27 +01:00
tonihei
b6070a5299 Formatting fixes 2024-06-24 16:10:13 +01:00
tonihei
71ef848ec3 Add fail-early checks for TrackSelectorResult correctness
The two arrays need to have the same length and the selection
must match in their nullness (unless for TYPE_NONE
renderers). Clarify this more clearly in the docs and add
new asssertions for it. This avoids that the player is failing
in obscure ways much later.

Issue: androidx/media#1473
#cherrypick
PiperOrigin-RevId: 646086833
2024-06-24 07:30:25 -07:00
okunhardt
bb568b5150 In DemoUtil, don't set cookie handler when using HttpEngineDataSource.
HttpEngine does not support cookie storage.

#cherrypick

PiperOrigin-RevId: 646084702
2024-06-24 07:21:08 -07:00
samrobinson
938fac4161 Update CompositionPlayer state for volume.
PiperOrigin-RevId: 646071591
2024-06-24 06:25:28 -07:00
tonihei
ada4dc982f Fix flakiness in MediaCodecVideoRendererTest
The test is flaky because the decoding process in the renderer
depends on some timing from MediaCodec beyond our control and
the new keyframe added in the test is sometimes 'dropped' when
it arrives too late.

We can fix this by controlling the test progress a bit more
tightly: first rendering with the same current time until the
key frame is processed and then start increasing the time
until we've reached the end.

#cherrypick

PiperOrigin-RevId: 646064352
2024-06-24 05:53:48 -07:00
okunhardt
e591c37b1e Use HttpEngineDataSource when supported in demo app.
HttpEngineDataSource is the recommended HttpDataSource when it is available. It uses the [HttpEngine](https://developer.android.com/reference/android/net/http/HttpEngine).

#cherrypick

PiperOrigin-RevId: 646051562
2024-06-24 04:52:15 -07:00
Gilles Khouzam
d717a0c5d5 Add a CustomData field to the Format class
Summary:
    This change aims to add a generic `CustomData` field to the `Format` class.

    The intent is to allow ExoPlayer customers to add extra data to the Format class without forcing
    specific data to be included, impacting customers that do not need it and would allow for the data
    to be changed without requiring changes to the `Media3` codebase.
2024-06-24 09:43:00 +01:00
dancho
476ec607f2 Implement isNoOp for LanczosResample
This allows for transmuxing whenever resolutions match,
and LanczosResample is in the video effects chain.

PiperOrigin-RevId: 645433104
2024-06-21 10:37:19 -07:00
simakova
d16004781e Remove AspectRatioFrameLayout usage from transformer demo
Removing unnecessary usage from transformer demo

PiperOrigin-RevId: 645426871
2024-06-21 10:18:30 -07:00
samrobinson
f1fadccef5 Add software decoder workaround for redmi 7a.
PiperOrigin-RevId: 645383707
2024-06-21 07:31:18 -07:00
claincly
89fbd0d27a Add Accept header to DESCRIBE request
The Accept header is required by some servers, and we only support SDP.

Issue: google/ExoPlayer#10919
PiperOrigin-RevId: 645361576
2024-06-21 05:47:52 -07:00
simakova
52bd9a2815 Add an option to include background audio sequence in Composition.
PiperOrigin-RevId: 645100835
2024-06-20 11:29:28 -07:00
ibaker
99803066ea Add null-check to PlayerView to avoid NPE in edit mode
Previously we assumed that `surfaceSyncGroupV34` was always non-null on
API 34, but this isn't true in edit mode. Instead we add an explicit
null-check before accessing it. We don't need to null-check it at the
other usage site because we are already null-checking `surfaceView` (via
`instanceof` check).

Issue: androidx/media#1237

#cherrypick

PiperOrigin-RevId: 645008049
2024-06-20 06:30:42 -07:00
sheenachhabra
307655f6d5 Move component initialization from Mp4Muxer.Builder to Mp4Muxer
PiperOrigin-RevId: 645004885
2024-06-20 06:18:13 -07:00
ibaker
cb8f87e05e Remove direct AspectRatioFrameLayout usage from session demo
This class is a lower-level UI component that isn't directly needed if
apps are using `PlayerView` to handle their video output (it is used as
an implementation detail of `PlayerView`).

Removing its unecessary usages from this demo avoids developers copying
this as an example when building their own apps.

#cherrypick

PiperOrigin-RevId: 644972454
2024-06-20 04:06:23 -07:00
tonihei
e84bb0d21c Fix audio focus handling in ExoPlayerImpl
Some cases are not handled correctly at the moment:
 - Pausing during suppressed playback should not clear the
   suppression state.
 - Transient focus loss while paused should be reported as
   a playback suppression.

Issue: androidx/media#1436
#cherrypick
PiperOrigin-RevId: 644971218
2024-06-20 04:00:57 -07:00
tonihei
1d26d1891e Clarify that onPlayWhenReadyChanged can be called again with new reason
Sometimes the reason for the current state may change. If we don't
report this again, users have no way of knowing that the reason
changed.

Also adjust ExoPlayerImpl and MediaControllerImplBase accordingly.
SimpleBasePlayer already adheres to this logic.

#cherrypick

PiperOrigin-RevId: 644970236
2024-06-20 03:58:05 -07:00
tonihei
c0abd6f91e Move playWhenReadyChangeReason inside PlaybackInfo
This helps to keep the reason always together with the state it
is referring to, avoiding any side channels and making sure there
are no accidental inconsistencies.

#cherrypick

PiperOrigin-RevId: 644969317
2024-06-20 03:54:04 -07:00
samrobinson
f2305cc05c Add a parameterized android test for single asset exports.
PiperOrigin-RevId: 644740900
2024-06-19 07:23:01 -07:00
kimvde
4751b80703 Call VideoFrameReleaseControl.join from VideoSink when enabled
PiperOrigin-RevId: 644738200
2024-06-19 07:09:38 -07:00
samrobinson
ff4feed0eb Add case to parameterized sequence test for no composition effects.
PiperOrigin-RevId: 644734136
2024-06-19 06:48:39 -07:00
ibaker
968f72fec6 Use SurfaceSyncGroup to ensure resize transaction isn't dropped
This workaround is only applied on API 34, because the problem isn't
present on API 33 and it is fixed in the platform for API 35 onwards.

Issue: androidx/media#1237

#cherrypick

PiperOrigin-RevId: 644729909
2024-06-19 06:27:13 -07:00
bachinger
6cc6444dd9 Use a localized fallback message for known error codes
In the case of a legacy session app providing an error
code different to `ERROR_UNKNOWN` without an error
message, a localized fallback message is provided
instead of ignoring the error.

#cherrypick

PiperOrigin-RevId: 644704680
2024-06-19 04:28:20 -07:00
bachinger
856d394c28 Allow session activity to be set per controller
#cherrypick

PiperOrigin-RevId: 644693533
2024-06-19 03:37:02 -07:00
kimvde
30b9c976ea Fix Javadoc of EditedMediaItem.Builder.setDurationUs
The Javadoc was indicating that the duration should always be set,
but it doesn't need to be set in most cases for export.

PiperOrigin-RevId: 644685827
2024-06-19 03:03:15 -07:00
samrobinson
afa7935553 Split parameterized android test utils into utility class.
Includes adjusting how effects are defined, to make it clearer in a
test that a given ItemConfig has effects associated with it.

PiperOrigin-RevId: 644684308
2024-06-19 02:56:34 -07:00
kimvde
d27549d29a Skip 4K export test on Pixel 3a
PiperOrigin-RevId: 644659699
2024-06-19 01:18:05 -07:00
tonihei
66c19390e2 Audio focus player command clean up
The 'player commands' returned to ExoPlayerImpl instruct the
player on how to treat the current audio focus state.

The current return value when playWhenReady==false is misleading
because it implies we are definitely not allowed to play as if
we've lost focus. Instead, we should return the actual player
command corresponding to the focus state we are in.

This has no practical effect in ExoPlayerImpl as we already
ignore the 'player command' completely  when playWhenReady=false.

To facilitate this change, we also introduce a new internal
state for FOCUS_NOT_REQUESTED to distinguish it from the state
in which we lost focus.

#cherrypick

PiperOrigin-RevId: 644416586
2024-06-18 09:42:26 -07:00
kimvde
048d71e392 Change muxer video duration unit to microseconds
PiperOrigin-RevId: 644402109
2024-06-18 08:56:26 -07:00
kimvde
ada7271974 Add a method to change the frame rate strategy from the VideoSink
PiperOrigin-RevId: 644373231
2024-06-18 07:11:58 -07:00
samrobinson
1d8b2e3f43 Migrate ParameterizedInputSequenceExportTest to AssetInfo for images.
PiperOrigin-RevId: 644363298
2024-06-18 06:31:56 -07:00
michaelkatz
c07bbd333c Version bump to media3:1.4.0-beta01
#cherrypick

PiperOrigin-RevId: 644352776
2024-06-18 05:52:03 -07:00
michaelkatz
794731607d Update release notes for 1.4.0-beta01
#cherrypick

PiperOrigin-RevId: 644351958
2024-06-18 05:48:00 -07:00
tonihei
e20e94fde2 Improve audio focus handling tests with ExoPlayer
There are a lot of tests for AudioFocusManager in isolation,
but almost none for the handling in ExoPlayer.

Add test coverage for all the common cases, including some
currently broken behavior that is indicated by TODOs.

PiperOrigin-RevId: 644319251
2024-06-18 03:24:21 -07:00
samrobinson
21ad768628 Add AndroidTestUtil missing asset Format info.
Also adds basic support for canDecode receiving an image Format.

PiperOrigin-RevId: 644300521
2024-06-18 02:06:59 -07:00
kimvde
f0aa30555a Remove calls to VideoFrameReleaseControl.join in CompositionPlayer
These calls have no effect because the VideoFrameReleaseControl of
CompositionPlayer is created with allowedJoiningTimeMs set to 0.

PiperOrigin-RevId: 644274524
2024-06-18 00:22:25 -07:00
samrobinson
2698f3ffc2 Migrate performance tests to use AndroidTestUtil constants.
PiperOrigin-RevId: 644058273
2024-06-17 10:38:23 -07:00
samrobinson
2b55a5bc2d Create an AssetInfo class for AndroidTestUtil test asset information.
This is an internal refactor with no logic changed.

There is a duplication in information and a lack of consistency around
the use of test assets in transformer androidTest. This change
refactors each asset to be defined as its own AssetInfo, with the other
relevant parts stored alongside the uri.

Once this is in place, we can consider other useful functionality, such
as having boolean flags for what tracks an asset has, helper methods
for whether an asset is local or remote, and more. This will reduce the
manual overhead necessary to use more assets in tests, and in
particular leads towards easily using new & existing assets in
parameterized tests.

PiperOrigin-RevId: 644040595
2024-06-17 09:47:56 -07:00
ibaker
d0815d3f7b Deprecate Util.areEqual in favour of Objects.equals
`Objects.equals` has been available since API 19.

PiperOrigin-RevId: 644026884
2024-06-17 09:04:48 -07:00