19477 Commits

Author SHA1 Message Date
christosts
c0e11e0edd Move bitmap loader tests in test
These tests were under androidTest because we needed a functional
BitmapFactory. Robolectric now supports decoding bitmaps so moving them
under tests.

PiperOrigin-RevId: 565181239
2023-09-13 15:40:55 -07:00
claincly
bf25b3e89d Move listener methods into private method for readability
The logic that handles components' boundaries are grouped together in private
methods, like handling VideoCompositor's output textures.

PiperOrigin-RevId: 565131579
2023-09-13 12:45:40 -07:00
claincly
1d8135e563 Add test for MultiInputVideoGraph
This test composites the first frame from two video inputs.

PiperOrigin-RevId: 565090338
2023-09-13 10:28:07 -07:00
claincly
5106f2f45a Rollback of e2882c051b
PiperOrigin-RevId: 565069442
2023-09-13 09:15:35 -07:00
ibaker
56fbf7377e Add javadoc to SubtitleParser.OutputOptions
PiperOrigin-RevId: 565066243
2023-09-13 09:04:27 -07:00
ibaker
f8b23da7af Add overflow tests for sample count to duration conversion methods
These methods were updated to use the new overflow-resistant
`scaleLargeValue` method in 885ddb167e.

PiperOrigin-RevId: 565059609
2023-09-13 08:38:14 -07:00
ibaker
d111976125 Change SubtitleParser interface to support incremental output
This change introduces two new types of method to `SubtitleParser`:
1. `parse()` methods that take a `Consumer<CuesWithTiming>` and return `void`
2. `parseToLegacySubtitle` method that returns `Subtitle`

(1) ensures that in the new 'parse before SampleQueue' world we can
write cues to the `SampleQueue` as soon as they're ready - this is
especially important when parsing monolithic text files, e.g. for a
whole movie.

(2) ensures that during the transition, the legacy 'parse after
SampleQueue' behaviour doesn't see any regressions in 'time to first
cue being shown'. Previously we had a single implementation to convert
from `List<CuesWithTiming>` to `Subtitle`, but this relies on the
complete list of cues being available, which can take a long time for
large files in some formats (with ExoPlayer's current parsing logic).
By allowing implementations to customise the way they create a
`Subtitle`, we can directly re-use the existing logic, so that the
'time to first cue being shown' should stay the same.

This change migrates all **usages** to the new methods, but doesn't
migrate any **implementations**. I will migrate the implementations in
follow-up CLs before deleting the old list-returning `parse()` methods.

PiperOrigin-RevId: 565057945
2023-09-13 08:33:29 -07:00
huangdarwin
e0de405e68 Compositor: Move input source javadoc to class-level.
As discussed offline, this is important for users of the class, and not all users may choose to read method javadoc, so best to make sure it's visible by leaving it at the class-level.

PiperOrigin-RevId: 565057677
2023-09-13 08:30:15 -07:00
ibaker
fdfec60f6e Remove some debugging lines in AtomParsers
These were accidentally added in 885ddb167e

PiperOrigin-RevId: 565035337
2023-09-13 06:49:25 -07:00
michaelkatz
85c944b955 Enable offload scheduling by default for audio-only offload playback
Removed `ExoPlayer.experimentalSetOffloadSchedulingEnabled` as scheduling will be enabled by default when offload is enabled for audio-only playback.

In addition, the `experimental` key word was taken out of the following
method signatures:
* `ExoPlayer.experimentalIsSleepingForOffload`
* `AudioOffloadListener.onExperimentalSleepingForOffloadChanged`
* `AudioOffloadListener.onExperimentalOffloadedPlayback`

PiperOrigin-RevId: 565035289
2023-09-13 06:46:50 -07:00
ibaker
abaf3e7aa1 Add Format.cueReplacementBehavior
Previously any `CuesWithTiming.durationUs` could be `TIME_UNSET`,
meaning it should be replaced by the next `CuesWithTiming` instance
(instead of being merged if the durations overlap, which is currently
the expected behavior for all `CuesWithTiming` with a 'real' duration).

This technically allowed a single subtitle track to include a mixture of
`CuesWithTiming` that should be merged, and some that should be
replaced. This is not actually needed for any of the subtitle formats
currently supported by ExoPlayer - in all cases a format expects either
all cues to be merged, or each cue to replace the previous one.

Supporting this mixture of merging and replacing in `TextRenderer` ended
up being very complicated, and it seemed a bit pointless since it's not
actually needed. This change means a given subtitle track either merges
**all** cues (meaning `CuesWithTiming.durationUs = C.TIME_UNSET` is not
allowed), or **every** cue is replaced by the next one (meaning
`CuesWithTiming.durationUs` may be set (to allow for cues to 'time out',
needed for CEA-608), or may be `TIME_UNSET`).

This value will be used in a subsequent change that adds cue-merging
support to `TextRenderer`.

PiperOrigin-RevId: 565028066
2023-09-13 06:09:45 -07:00
Googler
282171cb6f Rollback of e2882c051b
PiperOrigin-RevId: 564802194
2023-09-12 12:40:57 -07:00
ibaker
885ddb167e Add general-purpose overflow-resistant divide+multiply util method
This is equivalent to the existing `scaleLargeTimestamp` method with the
following changes/improvements:
* No longer specific to timestamps (there was nothing inherently
  time-specific about the logic in `scaleLargeTimestamp`, but the name
  and docs suggested it shouldn't be used for non-timestamp use-cases).
* Additional 'perfect division' checks between `value` and `divisor`.
* The caller can now provide a `RoundingMode`.
* Robust against `multiplier == 0`.
* Some extra branches before falling through to (potentially lossy)
  floating-point math, including trying to simplify the fraction with
  greatest common divisor to reduce the chance of overflowing `long`.

This was discussed during review of 6e91f0d4c5

This change also includes some golden test file updates - these
represent a bug fix where floating-point maths had previously resulted
in a timestamp being incorrectly rounded down to the previous
microsecond. These changes are due to the 'some more branches' mentioned
above.

PiperOrigin-RevId: 564760748
2023-09-12 10:22:57 -07:00
ibaker
320a45f7d6 Session tests: Log when no controllers are connected
While debugging various session tests failure I found that sometimes
this list was empty (e.g. when a controller had failed to connect, or
hadn't finished connecting yet) - resulting in these methods being
silent no-ops. I think it's basically never expected for there to be no
controllers connected when these methods are invoked, so this logs at
ERROR level to give a clue of what happened when looking at the test
logcat.

PiperOrigin-RevId: 564750969
2023-09-12 09:52:21 -07:00
claincly
e2882c051b Implement MultipleInputVideoGraph
Also adds DebugTraceUtil category to track MultipleInputVideoGraph events.

PiperOrigin-RevId: 564749202
2023-09-12 09:45:23 -07:00
sheenachhabra
b042943102 Add different modes in MuxerWrapper
For pause and resume feature we need to use same `MuxerWrapper`
for `remuxing processed video` and then to `process remaining video`.
In order to use same `MuxerWrapper` across `different Exports`
we need to preserve its state.

PiperOrigin-RevId: 564728396
2023-09-12 08:28:35 -07:00
ibaker
fe10f5ae18 Add tests for Util.scaleLargeTimestamp
This ensures we don't regress this behaviour when introducing
`scaleLargeValue`.

PiperOrigin-RevId: 564708566
2023-09-12 07:00:22 -07:00
ibaker
624eb1d7cb Add missing this.session null check in MockMediaLibraryService.
This aligns the equivalent implementation in `MockMediaSessionService`,
and it looks more correct to me - but the tests seem to pass both with
and without this change (and it doesn't seem to affect flakiness
either).

PiperOrigin-RevId: 564689493
2023-09-12 05:33:24 -07:00
ibaker
cf15463b1f Fix parameter comments in MediaBrowser tests
The parameter name was changed in 782a69e38c

PiperOrigin-RevId: 564688136
2023-09-12 05:25:22 -07:00
michaelkatz
3742f6b1f5 Allow renderer recovery with disabling offload if failed at first write
If offload fails at first write with [ERROR_DEAD_OBJECT](https://developer.android.com/reference/android/media/AudioTrack#ERROR_DEAD_OBJECT), then try disabling offload mode and try again. This allows recovery in a state where AudioTrack succeeds init in offload mode but writing is failing.

Issue: androidx/media#627
PiperOrigin-RevId: 564402181
2023-09-11 09:04:17 -07:00
ibaker
d77c707cd3 Use ISE instead of AssertionError in MockMediaLibraryService
Also pass the full cause instead of just the message.

PiperOrigin-RevId: 564313917
2023-09-11 02:28:38 -07:00
tofunmi
23665090ed Support Jpeg image track extraction in exoplayer
PiperOrigin-RevId: 563818198
2023-09-08 12:15:10 -07:00
tofunmi
be5fa6d130 Support image track extraction for JPEG
PiperOrigin-RevId: 563746945
2023-09-08 07:32:10 -07:00
tonihei
f285334a15 Deprecate multi-window time bar mode
It's much better to merge the windows at source level to reflect the
same state everywhere (e.g. notifications, player state, etc). This
can be done with ConcatenatingMediaSource2.

PiperOrigin-RevId: 563715718
2023-09-08 04:46:43 -07:00
christosts
4afecc9099 Rollback of 51fd06482b
PiperOrigin-RevId: 563714392
2023-09-08 04:39:51 -07:00
tonihei
6cff4a2638 Deprecate ConcatenatingMediaSource
There is no known use case left that needs to be solved by this
class. All other use cases are better solved by alternative
approaches (Player playlist methods or ConcatenatingMediaSource2).

PiperOrigin-RevId: 563713384
2023-09-08 04:36:01 -07:00
samrobinson
866d62dd34 Improve CompositionExportTest assertions by using dump files.
PiperOrigin-RevId: 563708666
2023-09-08 04:09:21 -07:00
Googler
007b7dbbf1 Make sure the mdat box is not extended by more than 1 GB at a time.
PiperOrigin-RevId: 563708468
2023-09-08 04:07:13 -07:00
tonihei
5a1322c9f9 Remove restriction from ConcatenatingMediaSource2
The class currently disallows offsets of periods in their windows
except for the very first window. This is not necessary because
we can use TimeOffsetMediaPeriod to eliminate the offset if needed.
This makes the class more useful for many use cases, in particular
for using it with ClippingMediaSource.

Issue: google/ExoPlayer#11226
PiperOrigin-RevId: 563702120
2023-09-08 03:31:17 -07:00
samrobinson
763dddfbd4 Dump with C.TrackType as key, rather than muxer track index.
Modifying dumping to not required "released" to be called.

Track index is an arbitrary value based on the order of addTrack calls.
Samples are dumped by track (rather than as soon as they are written),
so it's preferable to use a value that provides more context.

By using the track type as a key, dump files will be more deterministic
and will have more similarities when branched.

PiperOrigin-RevId: 563700982
2023-09-08 03:25:13 -07:00
tonihei
0c2aba9ce1 Add MediaPeriodId to CompositeMediaSource.getMediaTimeForChildMediaTime
This callback asks to correct the media time in a composition, but doesn't
provide the MediaPeriodId as the necessary context to do this.

PiperOrigin-RevId: 563699344
2023-09-08 03:17:55 -07:00
tonihei
dd2a373636 Add missing synchronization in ExperimentalBandwidthMeter
Issue: androidx/media#612
PiperOrigin-RevId: 563690229
2023-09-08 02:27:20 -07:00
tonihei
f2b1d0cfa3 Move TimeOffsetMediaPeriod to its own class
This makes it reusable for other MediaSource/Periods in the same
package.

Issue: google/ExoPlayer#11226
PiperOrigin-RevId: 563687935
2023-09-08 02:13:39 -07:00
tianyifeng
2ab5841ac2 Add setPlayerId(PlayerId) and prepareSourceCalled to BaseMediaSource
Also add getLastCreatedSource to FakeMediaSourceFactory which will be helpful in testing.

PiperOrigin-RevId: 563463475
2023-09-07 09:58:42 -07:00
huangdarwin
4c792ac907 Compositor: Add API for specifying input texture ColorInfo.
That said, only SDR is supported for now, so this will always throw if
HDR is input. This will also throw if different ColorInfo values are input
because color SDR mixing (ex. between sRGB and BT709) is not yet supported.

PiperOrigin-RevId: 563457729
2023-09-07 09:38:41 -07:00
ibaker
06f5324665 Deflake MediaSessionServiceTest.addSessions_removedWhenReleased
While investigating a different test failure on a pending change I
noticed that sometimes the "testAddSessions_removedWhenClose" session
was being released before it could be fully connected - and this
results in a failure like:

```
expected not to contain: androidx.media3.session.MediaSession@50a9ef1
but was                : [androidx.media3.session.MediaSession@50a9ef1, androidx.media3.session.MediaSession@3a6bac]
	at androidx.media3.session.MediaSessionServiceTest.addSessions_removedWhenReleased(MediaSessionServiceTest.java:376)
```

It also shows up in the logs like:

```
MediaController future failed (so we couldn't release it)
...
Caused by: java.lang.SecurityException: Session rejected the connection request.
```

Adding some debug logging revealed that the `session.release` call
posted to the test thread was happening before the call to
`MediaSessionStub.connect` on the main thread (this is triggered deep
in prod media3 session logic).

PiperOrigin-RevId: 563431265
2023-09-07 08:00:25 -07:00
ibaker
b958f451a7 Fix raw type warning in MediaBrowserCompatWithMediaLibraryServiceTest
PiperOrigin-RevId: 563410425
2023-09-07 06:22:56 -07:00
huangdarwin
19878b0b8b Effect: Clearly state what callers must do onError.
Instead of invoking "undefined behavior" may occur when a class is used
incorrectly, which is clear but not very helpful to callers, specify what Apps
or users of a class should do when issues occur.

Apply this to Compositor as well, where this otherwise might seem unclear.

PiperOrigin-RevId: 563406219
2023-09-07 06:02:09 -07:00
sheenachhabra
3835aa5344 Build ExportResult in Transformer.java
For pause and resume feature we will need to build `ExportResult`
from multiple internal Exports. Keeping the `ExportResultBuider` in
`Transformer` class will allow using same builder across different
internal exports.

PiperOrigin-RevId: 563392443
2023-09-07 04:48:52 -07:00
tofunmi
535af35511 Add heif extractor
PiperOrigin-RevId: 563340591
2023-09-07 00:31:04 -07:00
ibaker
956f58f963 Rename session to match addSessions_removedWhenReleased test name
PiperOrigin-RevId: 563132193
2023-09-06 09:46:21 -07:00
samrobinson
cff2816da4 Add silence generation parameterized test case.
PiperOrigin-RevId: 563098931
2023-09-06 07:34:32 -07:00
samrobinson
92814b84a8 Add alternate MP4 asset with PCM audio.
Audio is Mono 44.1kHz.

Created using:
`ffmpeg -i <input> -c:v copy -c:a pcm_s16be <output>`

PiperOrigin-RevId: 563079553
2023-09-06 05:58:27 -07:00
tofunmi
88b114a997 Add bmpExtractor to DefaultExtractorsFactory
PiperOrigin-RevId: 563076972
2023-09-06 05:41:43 -07:00
samrobinson
ef45c0fe5d Add parameterized dump tests for single item exports.
PiperOrigin-RevId: 563075771
2023-09-06 05:35:51 -07:00
tofunmi
45e15d48c4 Add WebpExtractor to DefaultExtractorsFactory
PiperOrigin-RevId: 563063506
2023-09-06 04:26:53 -07:00
ibaker
100af0b2de Fix test_session_current to be consistent with other test packages
This change ensures that a different package is used for
`test_session_current/src/main:support_app` and
`test_session_current/src/androidTest:test_app` - previously they used
the same package which was unusual (and possibly led to some confusing
behaviour).

PiperOrigin-RevId: 563051818
2023-09-06 03:23:44 -07:00
rohks
8dcafa0398 Add nullness annotations to MediaCodecVideoRenderer
#fixit

PiperOrigin-RevId: 562926813
2023-09-05 16:36:04 -07:00
bachinger
8c0191d0cb Use media button broadcast receiver above Android 31
This change avoids using a framework API that is deprecated since
API 31 and works around difficulties with this deprecated API on
devices from some manufacturers on API 33/34.

Manually tested with BT headphone connected to:

- Samsung SM-G920F (API 24)
- Pixel (API 28)
- Samsung SM-A515W (API 33)
- Pixel 6 Pro (API 33)

(verified manually with devices and adb output of dumpsys)

Issue: androidx/media#167
PiperOrigin-RevId: 562890206
2023-09-05 14:24:06 -07:00
andrewlewis
b56bdd8da0 Remove unnecessary track group count assertion
When checking the color transfer, there is no reason that the file should have
exactly two tracks, and this assertion means that this method can't be used
as-is for checking video-only files, for example.

PiperOrigin-RevId: 562813111
2023-09-05 10:06:44 -07:00