19394 Commits

Author SHA1 Message Date
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
tofunmi
a1be9d5a60 Add WebpExtractor
Also adds it to the DefaultExtractorsFactory for use throughout exoplayer

PiperOrigin-RevId: 562784760
2023-09-05 08:23:03 -07:00
sheenachhabra
657856dfe5 Fix/Update TODOs in Mp4Muxer tests
PiperOrigin-RevId: 562728777
2023-09-05 04:04:51 -07:00
tianyifeng
2554fe8f70 Recreate AudioTrack when ERROR_DEAD_OBJECT throws as writing PCM data
We have an existing logic for recovering the `AudioTrack` from the [ERROR_DEAD_OBJECT](https://developer.android.com/reference/android/media/AudioTrack#ERROR_DEAD_OBJECT)
throws. However, this only applies to the situation when the
`writtenEncodedFrames > 0`.

However, we have a case when `ERROR_DEAD_OBJECT` throws while writing
PCM data. When the `tunneling` is turned on, the `AudioTrack` is set the
flag `AUDIO_OUTPUT_FLAG_HW_AV_SYNC`, and further because of this flag,
it is forced the flag `AUDIO_OUTPUT_FLAG_DIRECT`. When the platform
invalidates the `AudioTrack`, the `AudioTrack` won't be restored by the
platform due to `AUDIO_OUTPUT_FLAG_DIRECT` flag, and `ERROR_DEAD_OBJECT`
is thrown.

Issue: androidx/media#431
PiperOrigin-RevId: 562582451
2023-09-04 10:41:48 -07:00
tofunmi
9b2668c0ca Add BmpExtractor
Takes single sample extraction logic out of the png extractor and puts it in a helper so it can be used for bmp as well.

PiperOrigin-RevId: 562581815
2023-09-04 10:37:28 -07:00
christosts
5b19e08ea9 Rollback of 51fd06482b
PiperOrigin-RevId: 562550636
2023-09-04 07:13:59 -07:00
christosts
51fd06482b Make Timeline and MediaPeriodId visible to Renderers
This is so CompositionPlayer can customize the Renderers and figure
out when a transition to a MediaItem is made hence it can configure the
effects pipeline with the effects that are specific to the MediaItem.

PiperOrigin-RevId: 562530774
2023-09-04 05:12:13 -07:00
michaelkatz
9d58788d86 Add AudioSink#setOffloadDelayPadding to offload play gapless Opus
Created new method `AudioSink#setOffloadDelayPadding` that will set delay and padding data onto an `AudioTrack` using `AudioTrack#setOffloadDelayPadding`. This feature adds support for offloaded, gapless Opus playback as the content requires the capability to set padding data post-`AudioSink#configure`.

PiperOrigin-RevId: 562518193
2023-09-04 04:02:44 -07:00
huangdarwin
2bdda35731 Overlay: Rename videoFrameAnchor to backgroundFrameAnchor.
Overlays may be overlaid over:
* In VideoFrameProcessor, videos or images (or texture input).
* In Compositor, other videos.

In Compositor, Overlays may consist of video, so it could be confusing
for videoFrameAnchor to contrast with overlayAnchor.

Also, rename overlayAnchor to overlayFrameAnchor, since it's modifying
the anchor in the overlay's frame, so this name seems slightly more precise.

PiperOrigin-RevId: 562004292
2023-09-01 11:28:19 -07:00
christosts
70ad637e52 Conditionally output captured data in CapturingRenderersFactory
This change makes capturing components in CapturingRenderersFactory
to dump data only they have previously captured any. This is so we can
extend the CapturingRenderersFactory with more renderers that do not
capture data in pre-existing tests and we don't have to change the
golden files.

PiperOrigin-RevId: 561973645
2023-09-01 09:26:33 -07:00
tofunmi
502504fd47 Skip runUntilComparisonFrameOrEnded checks for nexus's on API 21
verified with nexus 5 running on api 21

PiperOrigin-RevId: 561957198
2023-09-01 08:10:02 -07:00
tofunmi
e15c05fc3c Flip input buffer in the ImageRenderer
also improves tests to hash bitmap now that we know the bitmaps are decoded in roboelectic tests,
as well as some minor fixes in the DefaultImageDecoder

PiperOrigin-RevId: 561946073
2023-09-01 07:12:57 -07:00
huangdarwin
57bc215210 Compositor: Implement OverlaySettings and custom in/out size support.
Implement VideoCompositor support of:
* Different input and output sizes
* CompositorSettings, to customize output size based on input texture sizes
* OverlaySettings, to place an input frame in an arbitrary position on
  the output frame.

Also, refactor Overlay's matrix logic to make it more reusable between
Compositor and Overlays

PiperOrigin-RevId: 561931854
2023-09-01 05:54:15 -07:00
claincly
6c2713f153 Renames containsKey to contains so it's more readable
PiperOrigin-RevId: 561916837
2023-09-01 04:25:25 -07:00
tonihei
f6be4bc526 Document C.TIME_UNSET on Player.setMediaItem(.., startPositonMs)
This wasn't properly documented yet (unlike the longer setMediaItems
method that already includes this documentation).

Issue: androidx/media#607
PiperOrigin-RevId: 561910073
2023-09-01 03:44:36 -07:00
tofunmi
5944adcc78 Add image e2e test
PiperOrigin-RevId: 561887238
2023-09-01 01:31:45 -07:00
bachinger
3911c9d0c7 Add StreamEventListener for IMA SSAI source
Issue: androidx/media#555
PiperOrigin-RevId: 561711428
2023-08-31 11:29:29 -07:00
sheenachhabra
219b253731 Pass initial timestamp offset to VideoFrameProcessor
For pause and resume feature we will remux the previously processed
video in the first export and then in the second export we will resume
processing remaining video. For the second export we will have to
set initial timestamp offset so that video samples from the second
export are in continuation to the previously muxed samples.

PiperOrigin-RevId: 561689651
2023-08-31 10:17:40 -07:00
Googler
4c3ad641c0 Release StreamManager before calling AdsLoader.destroy()
PiperOrigin-RevId: 561678438
2023-08-31 09:37:27 -07:00
sheenachhabra
56acb3ee21 Move start export code into startInternal() method
For pause and resume we need to perform multiple intermediate exports.
So moved start() logic into a separate so that it can be reused from
different places with different Compositions and MuxerWrapper.

PiperOrigin-RevId: 561675472
2023-08-31 09:26:02 -07:00
ibaker
8af11a980a Remove duplication of various TestUtil methods
In most cases, the places that were trying to avoid a transitive
dependency on `lib-exoplayer` when this duplication was introduced [1]
are already depending on it again, except for `lib-container` where the
dep is added in this change.

In general it seems fine for the tests of module A to depend
(transitively or directly) on module B even where the prod code of
module A **does not** depend on module B.

[1] <unknown commit>

PiperOrigin-RevId: 561660371
2023-08-31 08:23:33 -07:00
samrobinson
6ecd3e9c2d Dump DumpableSamples list in track order.
Switch to SparseArray<List> rather than a Map<Integer, List>.

Track indices now determine sample list dumping, reducing flakiness.

PiperOrigin-RevId: 561658586
2023-08-31 08:15:41 -07:00
rohks
ab64e6f92d Fix remaining test_utils module nullness issues
#fixit

PiperOrigin-RevId: 561636758
2023-08-31 06:32:13 -07:00
Copybara-Service
bbfba27cac Merge pull request #594 from Tolriq:sink_format
PiperOrigin-RevId: 561611655
2023-08-31 04:08:54 -07:00
rohks
206a663dca Add functionality to transmit CMCD data using query parameters
Currently, we only support sending Common Media Client Data (CMCD) data through custom HTTP request headers, added capability to configure and transmit it as HTTP query parameters.

PiperOrigin-RevId: 561591246
2023-08-31 02:11:12 -07:00
ibaker
89f52dcb93 Rollback of 53b882d803
PiperOrigin-RevId: 561587445
2023-08-31 01:52:13 -07:00
rohks
3539b26e19 Add nullness annotations to SsMediaPeriod
#fixit

PiperOrigin-RevId: 561583025
2023-08-31 01:29:27 -07:00
ibaker
147cab89c3 Remove subtitle TODO from CapturingRenderersFactory
We're moving towards parsing subtitles before the `SampleQueue`, and we
already have subtitle playback assertions using `Player.Listener.onCues`
which is the most 'complete' place to assert subtitle output from. We
don't need to hook anything inside `TextRenderer`, so we can remove this
TODO.

PiperOrigin-RevId: 561418660
2023-08-30 12:38:48 -07:00
tonihei
ba4b96d2c1 Prevent forwarding of zero video size to Leanback
Leanback isn't prepared to handle these values and will throw
ArithmeticExceptions.

Issue: androidx/media#617
PiperOrigin-RevId: 561413740
2023-08-30 12:20:51 -07:00
Tolriq
4e93db4d0a Format passed to audioSink.configure is missing information.
AudioSink might require the identifying data and metadata to be able to take decisions.
2023-08-30 18:23:18 +01:00
ibaker
53b882d803 Add subsampleOffsetUs to Format.toLogString
This will help with debugging subtitle sync issues as it will show up in
track selection details emitted to logcat by `EventLogger`.

PiperOrigin-RevId: 561355836
2023-08-30 09:03:42 -07:00
ibaker
64792dfda2 Rollback of 25253698bc
PiperOrigin-RevId: 561352515
2023-08-30 08:53:49 -07:00
sheenachhabra
b37e37aa3c Pass MuxerWrapper to the TransformerInternal
For pause/resume feature, same MuxerWrapper needs to be
used across intermediate exports. So pass the MuxerWrapper
from Transformer.java
More specifically, when resume() is called
1. Create a MuxerWrapper and remux the previous
video samples (Export 1).
2. User the same MuxerWrapper and start processing
remaining video samples (Export 2).

PiperOrigin-RevId: 561325867
2023-08-30 06:45:39 -07:00
michaelkatz
cf3fd1f4dd Added condition to RtspMediaPeriod.isLoading to check RtspState
If a RtspMediaSource is used within a combining source like MergingMediaSource, then it could become stuck in a loop of calling continueLoading when the source has not actually started loading yet.

Issue: androidx/media#577
PiperOrigin-RevId: 561322900
2023-08-30 06:29:53 -07:00