21770 Commits

Author SHA1 Message Date
bachinger
d4f4a2c1d4 Allow the number of ad groups to grow with AdsMediaSource
This enables `AdsMediaSource` to be used with a live media
source that has a growing `AdPlaybackState` to which ad groups
can be appended.

Before this change, `AdsMediaSource` asserted that the number
of ad groups was kept the same, else an exception was thrown.
After this change, the assertion checks the validity of the
update and throws in case the update isn't considered valid.

An update is valid if ad groups are appended to the existing
`AdPlaybackState` or ads are appended to existing ad groups.
Further the `adGroupIndex` and `timeUs`of an existing ad
group can not be changed and once a media item is set for a
given ad, that media item can't be changed either.

PiperOrigin-RevId: 707244455
2024-12-17 14:10:27 -08:00
bachinger
aa2ee8f702 Add client side post roll placeholder
PiperOrigin-RevId: 707142019
2024-12-17 09:59:16 -08:00
ibaker
32ab258c43 Use Build.MANUFACTURER instead of Util alias in AudioCapabilities
It seems that changes via Robolectric's `ShadowBuild.setManufacturer()`
and similar methods don't propagate correctly (or quickly?) to these
aliases.

This change resolves a failure caused by different test ordering in
`AudioCapabilitiesTest` in order to unblock the 1.6.0-alpha01 release.
A follow-up change will migrate other usages from `Util.XXX` to
`Build.XXX`.

PiperOrigin-RevId: 707125446
2024-12-17 09:10:40 -08:00
bachinger
3dede2415d Add AdsMediaSourceFactory for HLS interstitials
PiperOrigin-RevId: 707109323
2024-12-17 08:25:58 -08:00
shahddaghash
acc41cb5f7 Add contrast effect to effect demo
Added a contrast effect and the connection needed to apply the video effects to ExoPlayer.

The effect can be applied to the video by checking the "Contrast" card, and use the slider to change the contrast value. The effects are applied when `Apply effects` button is clicked.

PiperOrigin-RevId: 707092041
2024-12-17 07:33:52 -08:00
tonihei
2d11a339de Import AudioManagerCompat and AudioFocusRequest from androidx.media
Both classes provide utilities widely used by apps that are not
yet available in Media3. This change imports the existing logic as
it is with style adjustments to the Media3 codebase.

PiperOrigin-RevId: 707067512
2024-12-17 06:14:36 -08:00
rohks
4b26eb2800 Fix lint errors
- Add required mutability flag to `ConnectionStateTest` to fix
  `Missing PendingIntent mutability flag`.
- Suppress `WrongConstant` lint error caused by Kotlin's spread operator
  not propagating the `@IntDef` annotation.

#cherrypick

PiperOrigin-RevId: 707061163
2024-12-17 05:53:19 -08:00
ibaker
601b025b3c Clarify the base of releaseTimeNs in VideoFrameMetadataListener
Also remove docs about API < 21, since the `minSdk` for the library is
now 21.

PiperOrigin-RevId: 707038503
2024-12-17 04:20:44 -08:00
tonihei
71f82df57f Switch default of async crypto mode to disabled
There are reproducible issues with codec timeouts when using
this API, so we disable it entirely until we know more about
potential fixes and where they are available.

Issue: androidx/media#1641
#cherrypick
PiperOrigin-RevId: 707025950
2024-12-17 03:25:32 -08:00
bachinger
12566a50d5 Reorder IMA samples for easier QA testing
PiperOrigin-RevId: 707014618
2024-12-17 02:33:21 -08:00
bachinger
3fe1f2a734 Add adId to AdGroup
PiperOrigin-RevId: 706761644
2024-12-16 10:47:17 -08:00
michaelkatz
d5d85558c1 Skip just-early video frames only if directed to release the frame
`MediaCodecVideoRenderer` will skip frames if a surface has not been set and video frame presentation time is early but too close to the current playback position. In the case that the `VideoFrameReleaseControl` says to `FRAME_RELEASE_TRY_AGAIN_LATER`, these frames should not be skipped.

PiperOrigin-RevId: 706711734
2024-12-16 08:05:30 -08:00
sheenachhabra
319ac2e5af Remove Parcelable interface from Metadata and Metadata.Entry
`Parcelable` is not safe for IPCs between binaries with potentially
different class definitions (e.g. two apps built from different versions
of media3).

If we get a use case to bundle metadata, then the `Metadata` and
`Metadata.Entry` classes needs to provide a `toBundle()` method.

PiperOrigin-RevId: 706678892
2024-12-16 05:58:02 -08:00
sheenachhabra
1326a92350 Do not bundle metadata when creating Format bundle
Metadata does not provide a `toBundle` method. It implements
`Parcelable` which is not safe for IPCs between binaries with
potentially different class definitions (e.g. two apps built from
different versions of media3).

If we get a use case to bundle metadata as well, then the `Metadata`
class needs to provide a `toBundle()` method.

PiperOrigin-RevId: 705920231
2024-12-13 10:12:37 -08:00
ibaker
36466cf883 Add some session methods to the stable API
This change adds a new stable overload of
`SessionToken.createSessionToken` which takes the platform `Token` type
(instead of `Parcelable`). It also stabilises
`MediaController.getCustomLayout` & the corresponding listener.

PiperOrigin-RevId: 705917161
2024-12-13 10:03:46 -08:00
dancho
72672b7f87 Implement audioNeedsEncoding based on requested settings
Do not use ForceEncodeFactory in tests

PiperOrigin-RevId: 705835243
2024-12-13 04:23:35 -08:00
bachinger
07b658a6da Ignore invalid interstitials instead of throwing
The HLS spec says so in rfc8216bis (4.4.5.1)

PiperOrigin-RevId: 705829265
2024-12-13 03:58:55 -08:00
dancho
522883bf16 Less granular skipping for HE-AAC support
PiperOrigin-RevId: 705822449
2024-12-13 03:28:51 -08:00
tonihei
3bce3af1a3 Switch play FGS exemption to use custom action instead of commands
Custom actions are more naturally associated with a user intent
than commands (that are meant to be used for automated inter-app
communication without user interaction).

PiperOrigin-RevId: 705797057
2024-12-13 01:43:21 -08:00
bachinger
83b5eb0040 Add HlsInterstitialsAdsLoader
Reads HLS interstitials information from the playlist and
populates the `AdPlaybackState` accordingly to play the ads.

An app can register a `Listener` to be informed about ad
related events.

Only VOD streams are supported and X-ASSET-LIST attibutes
are ignored with this change.

PiperOrigin-RevId: 705604201
2024-12-12 13:04:10 -08:00
jbibik
e0496ff88d [demo-compose] Initialize the Player outside of Compose
PiperOrigin-RevId: 705533932
2024-12-12 09:39:50 -08:00
jbibik
beda44520a [ui-compose] Fix PlayerSurface's use of Player
When `PlayerSurface` composable gets a new `Player` object, it should initialise a new Android(Embedded)External Surface with it. However, the lambdas used for that are remembered with the reference to the old Player, even if it has been null'd and released properly.

Android(Embedded)ExternalSurface is an interop - `AndroidView` wrapping `SurfaceView` and `TextureView` under the hood. It uses the `onInit` lambda in its factory to create the View and reuses it on later recompositions, making it a longer-lived object than our Player.

`RememberUpdatedState` acts makes a mutable State out of the Player and always gets its latest value. One can think of it as creating a reference to the Player object and telling the lambdas to always resolve that reference in the moment, rather than hold onto the Player than was passed-by-value.

This change is a precursor to a better lifecycle management of Player and Surface in demo-compose.

PiperOrigin-RevId: 705529626
2024-12-12 09:22:40 -08:00
tonihei
684273e4e1 Add utilities to resolve button preferences to display constraints
PiperOrigin-RevId: 705491402
2024-12-12 07:08:43 -08:00
kimvde
c636d9181b Delete ExoPlayerEffectPlaybackSeekTest
This test was testing a scenario that never happens in production.
Indeed, in this test, a frame was registered to the
ExternalTextureManager but never rendered on the decoder ouput surface.
This never happens in production because both actions are normally
performed in
PlaybackVideoGraphWrapper.InputVideoSink.handleInputFrame().

This test was also failing on API 31 emulator. As the frame was never
rendered, the timeout to release all registered frames in
ExternalTextureManager was always exceeded. This sometimes caused the
decoder to fail on this emulator because there was no interaction with
the decoder for a long time.

PiperOrigin-RevId: 705490910
2024-12-12 07:05:34 -08:00
jbibik
77a215f39c [ui-compose] Check Player commands in PlayerSurface actions
Setting and destroying the Surface should only happen if the `Player` has the required command

PiperOrigin-RevId: 705488781
2024-12-12 06:57:47 -08:00
rohks
4997ea82fa Refactor CmcdData to handle object type determination internally
Moved the `getObjectType` method from `CmcdData.Factory` to `CmcdData` and updated the logic to derive the object type directly within `CmcdData`. This change eliminates the need for chunk source classes to set this value explicitly.

PiperOrigin-RevId: 705457755
2024-12-12 04:36:16 -08:00
ibaker
0b0c198f59 Publish some internal tests now we depend on Robolectric 4.14.1
PiperOrigin-RevId: 705411400
2024-12-12 01:28:26 -08:00
sheenachhabra
f587ac2a67 Remove bundle-serialization methods from ExoPlaybackException
The `toBundle()` method is implemented incorrectly as it uses
`parcelable` implementation to bundle `Format.metadata`.
The `parcelable` is not compatible and is likely to cause crashes if
a new field is added or removed.

Moreover, the `fromBundle` method is likely unused as in session
module the exception is [unbundled](df887a9422/libraries/session/src/main/java/androidx/media3/session/PlayerInfo.java (L1021)) as `PlaybackException`.

This is a non breaking change as all the calls to `toBundle()` and
`fromBundle` will now go to the parent class `PlaybackException`.

If this specific bundling is required in future then `Format.Metadata`
and all the `Metadata.Entry` classes need to provide `toBundle()`
and `fromBundle()` method.

PiperOrigin-RevId: 705167002
2024-12-11 11:06:01 -08:00
Googler
3936c27b6d Don't check codec's profile for MV-HEVC video.
Currently as there is no formal support for MV-HEVC within Android framework, the profile is not correctly specified by the underlying codec; just assume the profile obtained from the MV-HEVC sample is supported.

PiperOrigin-RevId: 705164738
2024-12-11 10:59:26 -08:00
rohks
de31a3745c Make some no-op refactoring in CmcdData
- Moved static fields for object type, stream type, etc. from `CmcdData.Factory` to `CmcdData`.
- Removed redundant `CmcdData` prefix from `@ObjectType` and `@StreamingFormat` annotations.

#cleanup

PiperOrigin-RevId: 705159876
2024-12-11 10:46:22 -08:00
Copybara-Service
893b3775d4 Merge pull request #1963 from khouzam:codecInitialize
PiperOrigin-RevId: 705123773
2024-12-11 08:56:52 -08:00
Copybara-Service
c222bb8e03 Merge pull request #1968 from colinkho:opus
PiperOrigin-RevId: 705106170
2024-12-11 07:55:46 -08:00
andrewlewis
da05a1a66b Fix handling of CBR audio in some AVI files
Before this change, the value of the `dwLength` in the stream header was
interpreted as the number of chunks in the file. Seeking and timestamp
calculation use the media duration and total chunk count. However, in some
files the `dwLength` field appears not to store the number of chunks. For
example, there are CBR MP3 and AC3 files where this field seems to store the
total number of bytes of compressed media instead. That caused seeking and
timestamp calculation to give much smaller values than expected (because the
`dwLength` is very large), which broke seeking.

Work around this using the `idx1` index header if present. We only support
audio formats where every audio sample is a sync sample in AVI, and all chunks
should therefore be listed in this index. Based on testing on many sample AVI
files this gives a reliable total chunk count and fixes seeking.

The test media file is a transcoded version of Big Buck Bunny but manually
edited to overwrite the length, rate and sample size header files to simulate
the error case.

PiperOrigin-RevId: 705103651
2024-12-11 07:43:57 -08:00
microkatz
2f880bf051 Added release note 2024-12-11 15:31:00 +00:00
microkatz
55d9626b5a Format with google-java-format 2024-12-11 14:56:25 +00:00
Gilles Khouzam
f149cb28a3 Add MediaCodecInfo to MediaCodecRenderer::onReadyToInitializeCodec 2024-12-11 14:56:25 +00:00
Rohit Singh
b2e8489119 Removed empty line 2024-12-11 14:47:04 +00:00
kimvde
424b43d2eb Fix CompositionPlayerSeekTest timeout
Playback was never ending in the case where the video graph rendered
the last frame to the output surface before the end-of-current-input
signal was received. This CL handles this specific case.

PiperOrigin-RevId: 705086366
2024-12-11 06:39:49 -08:00
dancho
f55e0f3a3f VideoFrameProcessorTestRunner add support for portrait video
Fixes test failures due to differences test util bug that introduced
a crop in external texture sampling

PiperOrigin-RevId: 705061267
2024-12-11 04:45:12 -08:00
Colin Kho
af32e859ed Remove ChannelCount Max Limitation on OpusDecoder 2024-12-11 16:03:42 +08:00
rohks
8d2f531470 Enable sending CmcdData for manifest requests in DASH, HLS and SS
Issue: androidx/media#1951
PiperOrigin-RevId: 704875765
2024-12-10 15:59:39 -08:00
ibaker
c377a34a5a Don't call onAudioPositionAdvancing if AudioTrack is paused
`AudioTrackPositionTracker.pause` "re-arms" the event, to ensure it
fires again when playback resumes. However the `AudioTrack` position
advances by about 100ms **after** `AudioTrack.pause()`, which
consistently causes the event to fire immediately after pausing (and
then **not** after a subsequent resumption).

This change checks whether the `AudioTrack` is paused before firing
the event, to avoid this spurious trigger.

PiperOrigin-RevId: 704759929
2024-12-10 10:31:46 -08:00
tonihei
3e3cd8e6ac Fix Javadoc reference link for VORBIS mapping
PiperOrigin-RevId: 704737734
2024-12-10 09:27:36 -08:00
tonihei
b34a5b4e5d Align logic to ignore disabled and non-custom buttons in custom layout
The legacy custom layout doesn't support disabled buttons or buttons
with non-custom actions. These are currently filtered out, but in
inconsistent ways:
 - MediaControllerImplBase doesn't filter at all.
 - DefaultNotificationProvider filters before converting
   mediaButtonPreferences, PlayerWrapper filters after the conversion.
 - PlayerWrapper doesn't disable buttons that are unavailable.

To ensure it's consistent, we can add these checks to the existing util
method in CommandButton and also make sure PlayerWrapper disables
unavailable buttons before triggering the util method.

This also means we can simplify some of the tests that rely on the
mediaButtonPreference to customLayout conversion in MediaController.

This change also includes two bug fixes in PlayerWrapper that
became evident in the tests: The extras need to be copied to
avoid modifying a Bundle instance that be used elsewhere and
we need to update the custom layout and potentially the session
extras when the available commands change, as they depend on them.

PiperOrigin-RevId: 704678404
2024-12-10 06:13:54 -08:00
shahddaghash
dc21f3add2 Add preset input picker functionality
Added functionality to `Choose preset input` button. The picker allows the user to select a preset input from a list of loaded preset playlists. The selected preset input is then used to populate the ExoPlayer with the corresponding media items.

PiperOrigin-RevId: 704626144
2024-12-10 02:51:06 -08:00
michaelkatz
6689fee2b2 Implement error handling support for pre-warming renderers
PiperOrigin-RevId: 704408379
2024-12-09 14:04:00 -08:00
michaelkatz
be63e156bb Implement mediasource list update support for pre-warming renderers
PiperOrigin-RevId: 704381778
2024-12-09 12:41:37 -08:00
michaelkatz
bb62278627 Implement track reselection support for pre-warming renderers
PiperOrigin-RevId: 704371028
2024-12-09 12:07:58 -08:00
ibaker
ef19740c92 Remove Forwarding from assertForwardingClassOverridesAllMethods
And use it in a "non-forwarding" context in
`DefaultAnalyticsCollectorTest`.

PiperOrigin-RevId: 704331859
2024-12-09 10:22:06 -08:00
sheenachhabra
e017213ee8 Fix some MP4-AT file format related naming
Also add spec link in the code.

PiperOrigin-RevId: 704329143
2024-12-09 10:14:34 -08:00