20569 Commits

Author SHA1 Message Date
kimvde
e23cc756e2 Handle playToEndOfStream called before configuring the audio sink
ExoPlayer sometimes calls AudioSink.playToEndOfStream before configuring
the sink. Before this CL, the composition player was failing if this
happened.

PiperOrigin-RevId: 634306592
2024-05-16 04:19:36 -07:00
Copybara-Service
a4faf4db6f Merge pull request #1367 from TheBeastLT:main
PiperOrigin-RevId: 634289663
2024-05-16 03:26:32 -07:00
Ian Baker
743e7942b6 Format with google-java-format and add release note 2024-05-16 10:04:49 +01:00
Simon Hung
d2f677bc4c Update PgsParser.java
Fix "subtitles rendered with border and no fill color" problem:
https://github.com/moneytoo/Player/issues/413

because '0' means it's an index to the palette table, not an RGBA value of 0
2024-05-16 10:02:46 +01:00
ibaker
0352db9a37 Default to parse subtitles while extracting, instead of while rendering
To override this change, and go back to parsing during rendering,
apps must make two method calls:

1. `MediaSource.Factory.experimentalParseSubtitlesDuringExtraction(false)`
2. `TextRenderer.experimentalSetLegacyDecodingEnabled(true)`

PiperOrigin-RevId: 634262798
2024-05-16 01:42:56 -07:00
samrobinson
5c6f48ecaf Add debug trace logs for AudioMixer & AudioGraph events.
PiperOrigin-RevId: 633973723
2024-05-15 09:06:34 -07:00
tofunmi
7b357337d2 Support AVIF in exoplayer
https://developer.android.com/media/platform/supported-formats#image-formats was updated to include AVIF support in API 34+, so <unknown commit> updated our associated Util's to reflect this. After that change, ExoPlayer's BitmapFactoryImageDecoder will be able to decode AVIF, but the player won't be able to detect or extract it. Add this support for completeness, so that ExoPlayer can continue to say it supports all formats in https://developer.android.com/media/platform/supported-formats#image-formats.

PiperOrigin-RevId: 633956245
2024-05-15 08:04:41 -07:00
ibaker
0e5a5e0294 Publish CompositionPlayer for playing compositions
This class is not ready for production app usage yet, so it is still
marked `@RestrictTo(LIBRARY_GROUP)` for now. Apps can experiment with it
in a non-prod context by suppressing the associated lint error.

* Issue: androidx/media#1014
* Issue: androidx/media#1185
* Issue: androidx/media#816

PiperOrigin-RevId: 633921353
2024-05-15 05:55:08 -07:00
tonihei
67554395cb Fix test flakiness
The test currently resets the time too far in the past and then has
to run through ~30000 additional iterations of doSomeWork to reach
the end, sometimes triggering the test timeout.

Fix it by resetting the time to the intended start position when
transitioning items.

PiperOrigin-RevId: 633918706
2024-05-15 05:45:45 -07:00
tianyifeng
e4f0ff8177 Clear the PreloadMediaSource when deprioritized by the preload manager
PiperOrigin-RevId: 633917110
2024-05-15 05:40:58 -07:00
kimvde
a5c94245f8 Add unit test for seeking in clipped MediaItem
PiperOrigin-RevId: 633912487
2024-05-15 05:25:43 -07:00
ibaker
c6f4ed0b66 Remove /* package */ comment from public classes
Also make one class truly package-private and keep the comment instead.

This comment should only appear on elements with default (package-private) visibility.

PiperOrigin-RevId: 633911914
2024-05-15 05:23:30 -07:00
ibaker
ed4820cb61 Remove @UnstableApi from package-private files
This annotation is only needed on public classes.

This change also removes the `/* package */` comment from some `public`
classes.

PiperOrigin-RevId: 633864544
2024-05-15 02:26:55 -07:00
ibaker
8dfcf025d9 Remove @UnstableApi from demo apps
This annotation is only needed on public classes that are part of a
distributed library.

Switch to `@OptIn` for the one file where `@UnstableApi` was
suppressing lint errors.

PiperOrigin-RevId: 633858516
2024-05-15 02:00:13 -07:00
tonihei
d27c36ac9e Use MaskingMediaSource for AdsMediaSource content source
This means the content source is 'prepared' instantly with a
placeholder, enabling all further preparation steps (e.g. loading
preroll ads) while the actual content is still preparing. This
improvement can speed up the start time for prerolls in  manifest-based
content that doesn't have a zero-time preparation step like progressive
media.

Issue: androidx/media#1358
PiperOrigin-RevId: 633640746
2024-05-14 11:02:00 -07:00
bachinger
bf7b4e0d8c Reset platform playback state immediately after sending custom error
This change resets the error in the platform error state immediately
to make sure that the custom error is reflected only very briefly
and then gets back to the playback state that actually reflects the
player state.

Issue: androidx/media#543
PiperOrigin-RevId: 633626180
2024-05-14 10:18:59 -07:00
tofunmi
f7390faeb0 Update supported image formats in line with platform standards
This treats heic as a separate mimetype to heif (even though heic files are a subset of heif files). This is in line with other platform classes like android.content.ContentResolver

https://developer.android.com/media/platform/supported-formats#image-formats was updated to include avif support or API level 34, so added this MimeType as well and updated our associated util.

solves Issue: androidx/media#1373

PiperOrigin-RevId: 633616214
2024-05-14 09:50:38 -07:00
bachinger
84c0b6bcb1 Add MediaSession.sendError to send non-fatal error data to controllers
This allows to set custom error message for instance on Android
Auto/Automotive OS.

Issue: androidx/media#543
PiperOrigin-RevId: 633610089
2024-05-14 09:30:18 -07:00
tonihei
2175c432d7 Add error code for codec reclaim
This allows apps to better detect when the platform
reclaims a codec. This requires adding the error code
to MediaCodecDecoderException.

PiperOrigin-RevId: 633588914
2024-05-14 08:12:51 -07:00
ibaker
4cbe963b86 Tweak session demo UI strings
* Consistently use 'playlist' instead of 'play list'
* Remove wording about 'playlist loading' since when this message is
  shown the music is already playing in the background, we're just
  waiting for the in-app controller to connect to the background
  service.

PiperOrigin-RevId: 633550729
2024-05-14 05:34:00 -07:00
samrobinson
e17b3d7f83 Omit "last: []" from debug trace json if less than 10 event logged.
Reduces the boilerplate from the json produced without any information
loss.

PiperOrigin-RevId: 633540269
2024-05-14 04:45:42 -07:00
Googler
55b9c391e8 Box: Implement ctts box
Add ctts box implementation to handle muxing B-frame videos.
Add method convertPresentationTimestampsToCompositionOffset to
provide sample offsets. Return empty ctts box in case of video
does not contain B-frame. Add ctts box to MoovStructure to handle
muxing the video containing B-frames.

PiperOrigin-RevId: 633537106
2024-05-14 04:32:04 -07:00
ibaker
f73c24a10d Bump Truth dep to 1.4.0 so we can assert directly on Java 8 types
https://truth.dev/faq#java8

Also use this change to remove most test usages of
`Lists.transform(...)` and replace them with `.stream().map(...)`.

PiperOrigin-RevId: 633523904
2024-05-14 03:38:31 -07:00
samrobinson
95c13819af Log DebugTraceUtil events to logcat as they occur.
PiperOrigin-RevId: 633512813
2024-05-14 03:08:43 -07:00
ibaker
b182e469f6 Standardise leak canary version in constants.gradle
PiperOrigin-RevId: 633505366
2024-05-14 02:51:23 -07:00
tonihei
cf1f9b04cf Add more predefined priority values
Also add documentation that suggests to use them in
PriorityTaskManager and adjust codec priorities in
Transformer's DefaultDe/EncoderFactory accordingly.

PiperOrigin-RevId: 633272667
2024-05-13 11:18:41 -07:00
samrobinson
acf1ede644 Add debug trace logs for input/output events for codecs.
PiperOrigin-RevId: 633244952
2024-05-13 10:01:47 -07:00
tonihei
1a5cf6718b Use BaseAudioProcessor format tracking in SilenceSkippingAudioProcessor
The class currently tracks the input format itself, updating it too
early in onConfigure() instead of onFlush(). This causes issues when
the format changes and the new values are applied to the silence
skipping logic of the old format. The fix is to use the base class
input format handling instead.

Issue: androidx/media#1352
PiperOrigin-RevId: 633232368
2024-05-13 09:17:28 -07:00
samrobinson
04ab71a1d4 Remove component names from event strings.
PiperOrigin-RevId: 633212723
2024-05-13 08:06:44 -07:00
tonihei
d52a32aadc Add method to obtain media duration from playout duration
This is the inverse operation of the already existing method.

PiperOrigin-RevId: 633207017
2024-05-13 07:47:14 -07:00
sheenachhabra
3a3145521b Replace Transformer.Muxer interface with Muxer.Muxer
PiperOrigin-RevId: 633193701
2024-05-13 06:54:19 -07:00
sheenachhabra
5950e884f6 Skip TransformerPauseResumeTest on vivo 1820 and vivo 1906
The process crashes unexpectedly on these devices.

The new changes skips running these tests instead of marking them pass, when
the device needs to be skipped.

PiperOrigin-RevId: 633183638
2024-05-13 06:07:20 -07:00
samrobinson
30624aae6e Pass component of event to debug trace logEvent as parameter.
PiperOrigin-RevId: 633176557
2024-05-13 05:33:31 -07:00
tianyifeng
0db23ae904 Add PreloadMediaSource.clear to discard the preloading period
PiperOrigin-RevId: 633167081
2024-05-13 04:47:58 -07:00
sheenachhabra
71e36ac6d2 Remove missing frame workaround from TransformerPauseResumeTest
Two devices were producing B-frames earlier and were causing
frame mismatch. So we had added a workaround for them.
Those devices does not produce B-frames now
after disabling high profile on them, so we don't need workaround now.

PiperOrigin-RevId: 633127755
2024-05-13 01:35:34 -07:00
jbibik
8fa72714db Fail MediaSourceFactory creation if the right module is not added
Due to loading a MediaSourceFactory via reflection:

Before this change
* the content type was logged as an integer, rather than a human-readable string
* `ClassNotFoundException` was swallowed silently by `maybeLoadSupplier` without telling the user what module they were missing

After:
* ClassNotFoundException is swallowed silently ONLY when determining supported types
* ClassNotFoundException is bubbled up when we are trying to play media without the corresponding module properly loaded
PiperOrigin-RevId: 632568989
2024-05-10 12:18:53 -07:00
tonihei
e1d8044ccc Fix flushing logic of SpeedChangingAudioProcessor
When the processor is flushed, it needs to reset its internal state
in preparation for receiving fresh input data.

Flushing the internal SonicAudioProcessor on the other hand should
not go through the parent flush() method and instead flush the
internal processor only when needed.

PiperOrigin-RevId: 632530395
2024-05-10 10:12:03 -07:00
tonihei
daa8750382 Ensure silence skipping doesn't interfere with other discontinuities
The same doSomeWork iteration that triggers the silence skipping
discontinuity may already have another discontinuities (like
AUTO_TRANSITION), which should take precedence over the silence
skipping.

PiperOrigin-RevId: 632432851
2024-05-10 02:51:58 -07:00
tofunmi
1749726bc9 Texture input tests: use separate textures to queue to transformer
Use different textures in calls to queueInputTexture(). Allows the texture to be deleted one it is used in transformer and effect.

PiperOrigin-RevId: 632430866
2024-05-10 02:41:51 -07:00
samrobinson
325f4ec502 Add debug trace JSON nesting per component.
PiperOrigin-RevId: 632424814
2024-05-10 02:13:56 -07:00
samrobinson
fff68f1932 Order DebugTraceUtil JSON output by each component.
PiperOrigin-RevId: 632193924
2024-05-09 10:28:49 -07:00
tofunmi
753f607a81 Test: Remove the invalid dataspace device list when asserting sdr
PiperOrigin-RevId: 632137474
2024-05-09 07:07:51 -07:00
ibaker
861e8218c0 Bump IMA dependency to 3.33.0 to fix NPE with data:// URIs
Issue: androidx/media#700
PiperOrigin-RevId: 632135478
2024-05-09 06:59:53 -07:00
tonihei
971486f5f9 Round bytesToNextSpeedChange up instead of down
Rounding down means that very small diferrences (e.g. 1 us) result
in bytesToNextSpeedChange==0, which stalls progress forever as no
new bytes are read. Rounding up instead ensures that we always read
at least one audio frame if nextSpeedChangeTimeUs is in the future.

PiperOrigin-RevId: 632116560
2024-05-09 05:36:49 -07:00
samrobinson
49fa343127 Remove unused DebugTraceUtil VFP event.
PiperOrigin-RevId: 632109159
2024-05-09 05:00:39 -07:00
tofunmi
e432005653 make TransformerUtil public
help apps statically calculate what transformer will do with certain inputs without running transformer.

PiperOrigin-RevId: 632087821
2024-05-09 03:06:30 -07:00
claincly
145e0faf3d Make DefaultVideoCompositor use the first registered input as primary
PiperOrigin-RevId: 632079022
2024-05-09 02:21:31 -07:00
Googler
524181d7f2 DefaultHttpDS: Allow forcing cross protocol redirects to original
One can set crossProtocolRedirectsForceOriginal to force cross protocol redirects to use the original protocol. This might cause the connection to fail so it can only used when allowCrossProtocolRedirects is set to false or unset (default false).

PiperOrigin-RevId: 631937956
2024-05-08 15:11:04 -07:00
claincly
d977eab5f1 Minor code move for readability
PiperOrigin-RevId: 631922318
2024-05-08 14:19:04 -07:00
samrobinson
8b14d71ff0 Handle null extraFormat on entry in DebugTraceUtil.
PiperOrigin-RevId: 631821753
2024-05-08 09:14:06 -07:00