945 Commits

Author SHA1 Message Date
claincly
4991e623c9 Use the actual render time in VideoFrameMetadataListener
This listener is used by apps to associate render timestamp and presentation
timestamp when using a SurfaceTexture, so this timestamp must match up with
what's set in `eglPresentationTimeANDROID`.

PiperOrigin-RevId: 736494784
2025-03-13 07:17:18 -07:00
claincly
44b3a43652 Use VideoGraph as top level component
...and reduce the number of classes/interfaces

PiperOrigin-RevId: 735451687
2025-03-10 11:30:20 -07:00
ibaker
e8842b939c Prevent ParsableByteArray.bytesLeft() returning a negative value
PiperOrigin-RevId: 735417945
2025-03-10 10:03:21 -07:00
ibaker
d7574ffd66 Add ParsableByteArray.peekCodePoint and deprecate peekChar(Charset)
This is analagous to `String.codePointAt` and similar methods. By
dealing only in unicode code points, and returning an `int`, we can
avoid having to reason about how to handle UTF-8 code units that
require two UTF-16 code units (each one a Java `char`) to represent
them.

The zero-arg `peekChar` method remains undeprecated, because it behaves
as "you'd expect" when compared to `peekUnsignedByte` (always reads two
big-endian bytes).

PiperOrigin-RevId: 733752645
2025-03-05 08:55:32 -08:00
ivanbuper
5a0f4c6b3f Add support for constant power mixing in DefaultAudioMixer
This change exposes a flag in `DefaultAudioMixer#Factory` to set whether
to upmix/downmix using constant power or constant gain mixing matrices.

This is a non-functional change.

PiperOrigin-RevId: 733339367
2025-03-04 08:31:40 -08:00
ivanbuper
c3d734066d Add support for audio fades and gain automation
This change introduces `GainProcessor` to apply gain automation over an
audio stream. The gain automation is defined with a `GainProvider`.
`DefaultGainProvider` implements a basic `GainProvider` that allows
populating a gain automation line additively by adding fade shapes
(`FadeProvider`) at specific positions with specific durations.
`DefaultGainProvider` also implements basic equal gain and equal power
fades.

The current `DefaultGainProvider` implementation does not support adding
fades at relative offsets from the stream end. Users must know the
stream duration in advance and add fades at absolute positions.

PiperOrigin-RevId: 733311314
2025-03-04 06:51:24 -08:00
ibaker
2da814c8ef Add ParsableByteArray tests for \r line endings
PiperOrigin-RevId: 733140077
2025-03-03 19:02:06 -08:00
ibaker
a92cf5311f Add tests for ParsableByteArray.peekChar
This will help to ensure I don't change the behaviour when I add
`peekCodePoint` in a follow-up change.

PiperOrigin-RevId: 733139422
2025-03-03 18:58:37 -08:00
jbibik
cdb112a85a Version bump for Media3 1.6.0-rc01
#cherrypick

PiperOrigin-RevId: 733036051
2025-03-03 13:19:30 -08:00
ibaker
da8df3fb81 Statically import charset constants in ParsableByteArrayTest
This makes charset-heavy tests easier to read (and I'm going to add some
more in a follow-up change).

Also switch to Truth's `isEmpty()` assertion as prompted by a lint
check.

PiperOrigin-RevId: 732925878
2025-03-03 08:06:10 -08:00
tonihei
2088697a19 Add util to obtain AudioManager
AudioManager internally assumes the thread is was created on can be
used as a callback thread. Since the AudioManager is only created
once in the lifetime of an app, we need to make sure its obtained
on a thread that stays alive.

#cherrypick

PiperOrigin-RevId: 732072255
2025-02-28 03:23:10 -08:00
tonihei
1ac82d9824 Do not assume default callback for Audio focus requests is main looper
On API < 26, the callback thread couldn't be set and the current compat
code assumes it's always the main thread. This isn't true, however,
because AudioManager uses the thread on which it was first instantiated
anywhere in the app.

#cherrypick

PiperOrigin-RevId: 731696188
2025-02-27 06:03:25 -08:00
Copybara-Service
c1a269b79f Merge pull request #2114 from MGaetan89:remove_player_deprecated_next_methods
PiperOrigin-RevId: 731651706
2025-02-27 03:00:46 -08:00
claincly
5d9c2e309e Add APIs for redrawing effects.
PiperOrigin-RevId: 731255074
2025-02-26 04:08:32 -08:00
tonihei
4f039eaafa Add ClippingConfiguration.allowUnseekableMedia
PiperOrigin-RevId: 731240278
2025-02-26 03:11:19 -08:00
ibaker
6ffa0854d5 Define how PBA.peekChar behaves for UTF-8 multi-byte characters
PiperOrigin-RevId: 730908033
2025-02-25 09:04:37 -08:00
bachinger
cecee3bdda Add explicit property windowStartTimeUs to TimelineWindowDefinition
Before this change constructors of `TimelineWindowDefinition` used
`windowOffsetInFirstPeriodUs` for both, `positionInFirstPeriodUs`
and `startTimeUs` of the exposed `Timeline.Window`.

Adding `windowStartTimeUs` differentiates these two properties which
allows using `FakeTimeline` for unit tests that emulate live streams
with a forward moving live window in the period like `HlsMediaSource`
constructs a `SinglePeriodTimeline` for live.

A `TimelineWindowDefinition.Builder` is added for API usability and
sanitation.

PiperOrigin-RevId: 730892809
2025-02-25 08:17:24 -08:00
Copybara-Service
57d4f8354a Merge pull request #2135 from bubenheimer:handleMoveMediaItems_docfix
PiperOrigin-RevId: 730886871
2025-02-25 08:00:35 -08:00
Copybara-Service
cc44de8757 Merge pull request #2115 from MGaetan89:use_objects_equals
PiperOrigin-RevId: 730860597
2025-02-25 06:30:48 -08:00
ibaker
fe19d8c9be Fix casting in ParsableByteArray.peekCharacterAndSize
This was introduced in 841bdc6efe.

There's no need to cast the `char` (2 bytes) down to a `byte` in order
to pack it into an `int` (4 bytes) alongside a short (2 bytes).

We also don't need to use `short` to track the character count (max 4
with UTF-8) - a single byte is enough. This change also uses
`Ints.fromBytes` to avoid having to reason about how casting &
bit-shifting interact.

This change introduces a test which reproduces the failure reported in
Issue: androidx/media#2167.

#cherrypick

PiperOrigin-RevId: 730809219
2025-02-25 03:18:30 -08:00
bachinger
a75da2f5f3 Add withRemovedAdGroupCountBefore to AdPlaybackState
Adds a helper method to remove ad groups from the
ad playback state before a given period time.

PiperOrigin-RevId: 730804505
2025-02-25 02:58:39 -08:00
ivanbuper
ee6eb98d4b Rollback of 6e9a2cc0cd
PiperOrigin-RevId: 730482824
2025-02-24 09:32:45 -08:00
claincly
2f5a72a165 Add javadoc to clarify using bitmap
PiperOrigin-RevId: 730441676
2025-02-24 07:25:13 -08:00
Copybara-Service
05c8a66dc2 Merge pull request #2149 from bubenheimer:util_postorrun_fix
PiperOrigin-RevId: 729495445
2025-02-21 05:40:11 -08:00
Copybara-Service
2b12a57447 Merge pull request #2139 from bubenheimer:handleReplaceMediaItems_removerangecodefix
PiperOrigin-RevId: 729490370
2025-02-21 05:18:57 -08:00
Uli Bubenheimer
7cc97ddce2 Minor Util.postOrRun refactor: fix skipped reuse of variable created for reuse 2025-02-21 12:31:22 +00:00
tonihei
7a85cfb4bd Add {} 2025-02-21 11:38:33 +00:00
Uli Bubenheimer
a32c768ea1 handleReplaceMediaItems: filter invalid parameters for handleRemoveMediaItems 2025-02-21 11:36:05 +00:00
Uli Bubenheimer
26cf8e1e94 Fix permitted parameter range for handleReplaceMediaItems in javadoc 2025-02-21 11:30:14 +00:00
Uli Bubenheimer
ea1562b7cc Fix permitted parameter range for handleMoveMediaItems in javadoc 2025-02-21 11:26:06 +00:00
Gaëtan Muller
a17a3ebc67 Replace usages of Util.areEqual() with Objects.equals() 2025-02-21 11:01:09 +00:00
Gaëtan Muller
0a648200ba Remove deprecated Player.seekToNextWindow()
Use `Player.seekToNextMediaItem()` instead.
2025-02-21 10:54:02 +00:00
Gaëtan Muller
2644409801 Remove deprecated Player.seekToPreviousWindow()
Use `Player.seekToPreviousMediaItem()` instead.
2025-02-21 10:54:02 +00:00
Gaëtan Muller
72884c3bf3 Remove deprecated Player.next()
Use `Player.seekToNextMediaItem()` instead.
2025-02-21 10:54:02 +00:00
Gaëtan Muller
521871b9d5 Remove deprecated Player.hasNext() and Player.hasNextWindow()
Use `Player.hasNextMediaItem()` instead.
2025-02-21 10:54:02 +00:00
sheenachhabra
462533219d Create muxer specific BufferInfo class
Muxer does not use `offset` field, hence not added.

PiperOrigin-RevId: 728625538
2025-02-19 05:11:04 -08:00
tonihei
f1c62c1239 Make SimpleBasePlayer.State public
This ensures it's easier to handle these State updates in other
helper classes if needed.

Issue: androidx/media#2128

#cherrypick

PiperOrigin-RevId: 728264396
2025-02-18 10:28:05 -08:00
tonihei
78cf53c0b2 Version bump for Media3 1.6.0-beta01
#cherrypick

PiperOrigin-RevId: 727889651
2025-02-17 09:43:14 -08:00
claincly
babc2dd416 Match with ExoPlayer seeking when using CompositionPlayer
In a image sequence, seek to after the image duration should render the final
image frame. But currently it hangs as ConstantRateTimestampIterator doesn't
output any timestamp in this case

PiperOrigin-RevId: 724295475
2025-02-07 04:26:00 -08:00
ibaker
5e6fb88372 Add missing LINT.If/ThenChange comments
PiperOrigin-RevId: 724291745
2025-02-07 04:10:41 -08:00
ibaker
097771306d Remove LINT.IfChange comments with no following LINT.ThenChange
PiperOrigin-RevId: 723918659
2025-02-06 06:58:11 -08:00
rohks
baf46d36d9 Bump Media3 version to 1.6.0-alpha03
#cherrypick

PiperOrigin-RevId: 723531635
2025-02-05 09:03:49 -08:00
Gaëtan Muller
a4cc0f2384
Replace Util.MODEL with Build.MODEL 2025-02-04 15:34:33 +01:00
Gaëtan Muller
2aab921aa2
Replace Util.MANUFACTURER with Build.MANUFACTURER 2025-02-04 15:04:08 +01:00
Gaëtan Muller
d0a3d31e56
Replace Util.DEVICE with Build.DEVICE 2025-02-04 15:00:22 +01:00
Googler
6e9a2cc0cd Rollback of 79b61d05a6
PiperOrigin-RevId: 722741988
2025-02-03 11:55:06 -08:00
ivanbuper
79b61d05a6 Rollback of 492574bded
PiperOrigin-RevId: 721758531
2025-01-31 06:56:13 -08:00
tonihei
6b31b4620c Move NetworkTypeObserver operations off main thread
PiperOrigin-RevId: 721291681
2025-01-30 01:17:22 -08:00
rohks
c9a936e153 Bump Media3 version to 1.6.0-alpha02
#cherrypick

PiperOrigin-RevId: 720990835
2025-01-29 08:43:21 -08:00
ivanbuper
fc6df77831 Remove deprecated androidx.media3.exoplayer.audio.SonicAudioProcessor
Also, make `androidx.media3.common.audio.SonicAudioProcessor` final.

PiperOrigin-RevId: 720987023
2025-01-29 08:30:09 -08:00