2118 Commits

Author SHA1 Message Date
tofunmi
f4fefd19f7 Document and test multi asset ultraHDR support
PiperOrigin-RevId: 619200688
2024-03-26 08:39:44 -07:00
ibaker
d00ca1e343 Plumb MP3 average bitrate from metadata frames into Format
Issue: androidx/media#1081

#minor-release

PiperOrigin-RevId: 619185083
2024-03-26 07:40:08 -07:00
tonihei
6e0f8e3b0d Remove decode-only flag
No known component is using this flag anymore and it has been
deprecated for a while for custom renderers and decoders.

PiperOrigin-RevId: 619154299
2024-03-26 05:28:27 -07:00
tonihei
ab0391167c Include nullness of MediaMetadata.extras in equals method
This ensures MediaMetadata with just non-null extras is not
considered equal to MediaMetadata.EMPTY. This makes sure the
contents are bundled when a controller sets the extras in a
new MediaItem

Issue: androidx/media#1176

#minor-release

PiperOrigin-RevId: 618876642
2024-03-25 10:05:15 -07:00
tonihei
3a7d31a599 Don't set codec color info for default SDR
Some media can read color info values from the bitstream
and may partially set some of the SDR default values in
Format.ColorInfo. Setting these default values for SDR can
confuse some codecs and may also prevent adaptive ABR
switches if not all ColorInfo values are set in exactly the
same way.

We can avoid any influence of HDR color info handling by
disabling setting the color info MediaFormat keys for SDR
video and also avoid codec reset at format changes if both
formats are SDR with slightly different ColorInfo settings.

To identify "SDR" ColorInfo instances, we need to do some
fuzzy matching as many of the default values are assumed to
match the SDR profile even if not set.

Issue: androidx/media#1158
PiperOrigin-RevId: 617473937
2024-03-20 04:58:13 -07:00
huangdarwin
b126bae93d Effect: Add EGL_EXT_gl_colorspace_bt2020_hlg support, on API 34+
Confirmed that the HLG extension displays properly on Pixel 7 Pro, API 34 and Samsung S24, API 34. On these devices, this fixes the washed out HLG preview issue on API 34, where the PQ ext had a washed out look, and where the HLG ext is supported (this bug didn't occur on API 33, only 34).

More info on manual tests done to sanity-check:
* Test cases: Transformer debug SurfaceView and ExoPlayer.setVideoEffects
* Test inputs: HLG and PQ
* Test devices: Pixel 7 Pro (API 33 & 34), Samsung Galaxy S24 (API 34)
* Added debugging: Logging colorInfo used in GlUtil.createEglSurface

No regressions were seen. HLG extension is used more in API 34, and behavior stays the same on API 33. Only human-visible change without logging is that HLG content looks better on API 34, for Samsung S24 and Pixel 7 Pro.

PiperOrigin-RevId: 616131192
2024-03-15 08:06:49 -07:00
ibaker
48cffc849a Fix proguard rule for DefaultVideoFrameProcess.Factory.Builder.build()
Issue: androidx/media#1187

#minor-release

PiperOrigin-RevId: 616112879
2024-03-15 06:50:16 -07:00
ibaker
e9ed874e51 Don't emit a CuesWithTiming for zero-duration Subtitle events
It's a bit arguable whether the `Subtitle` implementation supports
zero-duration events, since `getEventTimeCount` is documented as
effectively "the number of times the cues returns by `getCues(long)`
changes", and zero-duration events violate that. However, the current
`WebvttSubtitle` impl **does** produce zero-duration events, so it
seems safer to handle them gracefully here and then, as a possible
follow-up, fix the `WebvttSubtitle` impl (or remove it completely).

Issue: androidx/media#1177

#minor-release

PiperOrigin-RevId: 616095798
2024-03-15 05:26:21 -07:00
tofunmi
f39fe82bba Support ultra HDR in effect
adding sending gainmap to shader program and applying gainmap to base in shader

PiperOrigin-RevId: 616070582
2024-03-15 03:22:54 -07:00
Copybara-Service
e9a28beb44 Merge pull request #1117 from loliball:dev_wav_align_fix
PiperOrigin-RevId: 615820438
2024-03-14 10:17:49 -07:00
tonihei
cbed80ecf3 Always set PARAMETER_KEY_TUNNEL_PEEK when tunneling
This should already be the default, but some devices seem
to not adhere to this contract and assume the default is unset.

Issue: androidx/media#1169
PiperOrigin-RevId: 614697283
2024-03-11 09:49:09 -07:00
tonihei
0e42c8945f Automatically add icon drawables for icon constants
Having a default icon available allows apps to only specify the
icon constant without having to define an icon drawable themselves
as Media3 can fill in the icon resource for backwards compatibility.

The switch util method allows R8 to easily remove unused icons, so
having default icons won't affect APK size unless the constants are
used to set up the CommandButtons.

PiperOrigin-RevId: 614623909
2024-03-11 05:06:21 -07:00
ibaker
4bca1ac47b Add opt-in flag for the MIDI module for apps with a local dependency
PiperOrigin-RevId: 613938538
2024-03-08 08:17:02 -08:00
ibaker
f9032a5893 Add checkNotNull(uri) to DataSpec constructor
This check is already present in `DataSpec.Builder.build()` but there
are many public constructors which bypass the builder (only some of
which are deprecated), so this adds an additional check.

PiperOrigin-RevId: 613908358
2024-03-08 05:59:10 -08:00
ibaker
a604600126 Add workarounds for NoSuchMethodError from DRM framework exceptions
Issue: androidx/media#1145

#minor-release

PiperOrigin-RevId: 613573868
2024-03-07 07:16:28 -08:00
michaelkatz
638b2a3c86 Start early-enabled renderers only after advancing the playing period
Renderers may be enabled for subsequent media items as soon as the current media item's renderer's isEnded() returns true. When a renderer is being enabled and the player is 'playing', that renderer is also started. When playing a mixed playlist of images and content with audio & video, the player may skip some image items because the early-starting of the audio renderer causes a clock update.

A solution is to only start the "early-enabled" renderers at the point of media transition and add a condition on DefaultMediaClock to use the standalone clock when reading-ahead and the renderer clock source is not in a started state.

Issue: androidx/media#1017
PiperOrigin-RevId: 613231227
2024-03-06 08:50:42 -08:00
bachinger
a0a40871b5 Pass player ID to methods of LoadControl
The old methods are deprecated and are called from the new
method for backwards compatibility of custom implementations.

'DefaultLoadControl' is unchanged, but `ExoPlayerImplInternal`
already calls the new methods passing in the `PlayerId`,

PiperOrigin-RevId: 613197190
2024-03-06 06:48:02 -08:00
ibaker
b1b8b2e6f9 Remove some deprecated DataSpec constructors
PiperOrigin-RevId: 613137809
2024-03-06 02:26:11 -08:00
tonihei
9abe9e2a97 Refine auto-update logic of CommandButton.isEnabled
We currently update this value for controllers to match the
availability of the associated command. This however makes it
impossible to mark a button as unavailable if the command is
available. This can be refined by only setting the 'enabled'
field to false if the command is not available, not the other
way round. And we should also enable the button by default as
disabling is the unusual case not many apps will use.

In addition, this change fixes missing update logic when the
player commands changed and it adds some additional test coverage
for all these cases.

PiperOrigin-RevId: 612881016
2024-03-05 10:08:17 -08:00
tianyifeng
5e31cd9df3 Add BasePreloadManager and DefaultPreloadManager
`BasePreloadManager` coordinates the preloading for multiple sources based on the priorities defined by their `rankingData`. Customization is possible by extending this class. Apps will implement `TargetPreloadStatusControl` to return preload manager the target preload status for a given `rankingData` of the source.

`DefaultPreloadManager` extends from the above base class and uses `PreloadMediaSource` to preload media samples of the sources into memory. It also uses an integer `rankingData` that indicates the index of an item on the UI, and the priority of the items is determined by their adjacency to the current playing item. Apps can set the index of current playing item via `DefaultPreloadManager.setCurrentPlayingIndex` when the user swiping is detected.

PiperOrigin-RevId: 612829642
2024-03-05 07:14:18 -08:00
ibaker
7395c9a159 Remove deprecated CronetDataSourceFactory
PiperOrigin-RevId: 611431225
2024-02-29 04:59:35 -08:00
tianyifeng
1bdc58de0b Avoid position jumping back when controller replaces the current item
When the controller replaces the current item, the masking position will be changed to the default position of the new item for a short while, before the correct position comes from the session. This will interrupt the current position fetched from the controller when the playback doesn't interrupted by the item replacing.

Issue: androidx/media#951

#minor-release

PiperOrigin-RevId: 611417539
2024-02-29 04:07:17 -08:00
ibaker
c7e00b12b4 Add fps-awareness to DefaultTrackSelector
This change aims to prioritise tracks that have a 'smooth enough for
video' frame rate, without always selecting the track with the highest
frame rate.

In particular MP4 files extracted from motion photos sometimes have two
HEVC tracks, with the higher-res one having a very low frame rate (not
intended for use in video playback). Before this change
`DefaultTrackSelector` would pick the low-fps, high-res track.

This change adds a somewhat arbitrary 10fps threshold for "smooth video
playback", meaning any tracks above this threshold are selected in
preference to tracks below it. Within the tracks above the threshold
other attributes are used to select the preferred track. We deliberately
don't pick the highest-fps track (over pixel count and bitrate), because
most users would prefer to see a 30fps 4k track over a 60fps 720p track.

This change also includes a test MP4 file, extracted from the existing
`jpeg/pixel-motion-photo-2-hevc-tracks.jpg` file by logging
`mp4StartPosition` in
[`MotionPhotoDescription.getMotionPhotoMetadata`](b930b40a16/libraries/extractor/src/main/java/androidx/media3/extractor/jpeg/MotionPhotoDescription.java (L123))
and then using `dd`:

```
mp4StartPosition=2603594

$ dd if=jpeg/pixel-motion-photo-2-hevc-tracks.jpg \
    of=mp4/pixel-motion-photo-2-hevc-tracks.mp4 \
    bs=1 \
    skip=2603594
```

----

This solution is in addition to the `JpegMotionPhotoExtractor` change
made specifically for these two-track motion photos in
5266c71b3a.
We will keep both changes, even though that change is not strictly
needed after this one, because adding the role flags helps to
communicate more clearly the intended usage of these tracks. This
change to consider FPS seems like a generally useful improvement to
`DefaultTrackSelector`, since it seems unlikely we would prefer a 5fps
video track over a 30fps one.

Issue: androidx/media#1051
PiperOrigin-RevId: 611015459
2024-02-28 01:09:50 -08:00
Rohit Singh
1994ba991c Add release note and update comment 2024-02-27 15:59:59 +00:00
Googler
477ace1be9 Composition audio effects
Implement composition-level audio effects in AudioGraph.

PiperOrigin-RevId: 610689632
2024-02-27 02:54:08 -08:00
michaelkatz
23a301fc5d Fallback to legacy sizerate check if CDD H264 PerfPoint check fails
Some devices supporting Performance Points for decoder coverage are missing coverage over the CDD requirements for H264. For these cases ExoPlayer should fall back to legacy resolution and frame rate support checks. If there is a stream evaluated as a PerformancePointCoverageResult of COVERAGE_RESULT_NO, then ExoPlayer checks for coverage of the 720p H264 CDD requirement.

Issue: google/ExoPlayer#10898

Issue: androidx/media#693

Issue: androidx/media#966
PiperOrigin-RevId: 609740128
2024-02-23 08:48:09 -08:00
sheenachhabra
82065e699a Update release notes section for 1.3.0 stable release
PiperOrigin-RevId: 609407248
2024-02-22 10:01:30 -08:00
michaelkatz
4192924622 Use playing period TrackSelectorResult in track reselection update
If the reading period has already advanced and a track reselection procs that only affects the reading period media, then ExoPlayer may try and apply the reading period's track selection incorrectly unto the playing period. ExoPlayer should apply the playing period's track selection to the playing period instead.

PiperOrigin-RevId: 609375077
2024-02-22 08:08:18 -08:00
michaelkatz
9046f2edb6 Allow renderer retry for audio track offload initialization failure
If render error occurs due to AudioTrack initialization failure in offload mode, then ExoPlayer should allow retry as subsequent attempt will be with DefaultAudioSink disabling offload.

PiperOrigin-RevId: 609304897
2024-02-22 03:00:10 -08:00
tianyifeng
d952a06214 Fix a bug in retaining streams when preload a PreloadMediaPeriod again
The `PreloadMediaPeriod.selectTracksForPreloading` can be called for multiple times at the preloading stage (before the period is being played). For example, when the period resumes preloading. This change fix the assertion failure in `ProgressiveMediaPeriod.selectTracks` caused by the wrong implementation of `PreloadMediaPeriod.selectTracksForPreloading` when it is trying to retain the previously preloaded streams.

Also the `TrackSelectorResult` parameter is changed to a list of `ExoTrackSelection`. We should compare the selections only rather than considering the `RendererConfiguration` in the `TrackSelectorResult` to decide whether to retain the streams, as for preloading case the renderers haven't consumed the samples yet.

PiperOrigin-RevId: 609126868
2024-02-21 14:41:33 -08:00
huangdarwin
fde6a32156 Transformer: Input decoder output color to VideoSampleExporter.
Previously, the track format was used in VideoSampleExporter. Now, we use a
simulated decoder output format.

As the last expected change for this bug, also adds release notes

PiperOrigin-RevId: 609080629
2024-02-21 12:15:11 -08:00
ibaker
bb5c688543 Update TestPlayerRunHelper to fail on non-fatal errors by default
Also introduce a fluent API that allows callers to ignore non-fatal
errors (while avoiding adding boolean overloads for every method).

**Most** tests want to fail on non-fatal errors (since they likely
indicate user-visible issues like codec errors etc), only tests
explicitly testing fallback in error scenarios should want to ignore
them.

Before this change there were a few `playUntilXXX` methods. These can
now all be triggered via `play(player).untilXXX`, which means
effectively every 'until' condition is available in a 'play until'
variant that calls `play` just before waiting for the condition.

PiperOrigin-RevId: 608988234
2024-02-21 07:39:07 -08:00
Googler
dca7bae416 Allow mismatching H.264/AVC level for trimming or resuming
MediaCodec docs already allude to potentially mismatching H.264 level
between container and bitstream. Relax the initialization data check to
reflect this.

PiperOrigin-RevId: 608942322
2024-02-21 04:20:50 -08:00
sheenachhabra
ebcb4e8b21 Fix nit issues in 1.3.0-rc01 release notes
PiperOrigin-RevId: 608580903
2024-02-20 06:22:14 -08:00
michaelkatz
52c1d60d39 Allow empty information attributes in RTSP Session Description
Issue: androidx/media#1087
PiperOrigin-RevId: 608534659
2024-02-20 02:47:40 -08:00
ibaker
3bbb0e7453 Add documented support for android.resource://package/id URIs
These were previously somewhat supported, but the `package` part was
never read (so it only worked if it was either absent or the same as the
current application's package). This change parses and uses the
`package` part.

This partially reverts 35121a2d3d.

This is hard to test for the same reasons as 88f554c74b:

> This is hard to test because to do so robustly requires being able to guaranteed that another test APK will be installed with a known raw resource inside it.

PiperOrigin-RevId: 608270463
2024-02-19 02:28:39 -08:00
Googler
e43f96687c Fix failure to write negative PTS sample
Fixes an issue caused by no support for negative audio PTS and edit lists
in FrameworkMuxer, Android versions before 11

PiperOrigin-RevId: 607690507
2024-02-16 08:03:38 -08:00
tofunmi
caf584152d Add release notes for recent transformer features
PiperOrigin-RevId: 606565385
2024-02-13 12:23:50 +00:00
tianyifeng
2b473831c6 Implement onInit() and onRelease() in FakeRenderer
PiperOrigin-RevId: 606301390
2024-02-12 10:57:14 -08:00
tofunmi
1a5eb4eecd Support segment-specific speed changes in SpeedChangeEffect
PiperOrigin-RevId: 606204479
2024-02-12 04:03:23 -08:00
michaelkatz
0b0c419c73 Fallback to including track language name if display name is not found
Issue: androidx/media#988
PiperOrigin-RevId: 606193299
2024-02-12 03:07:36 -08:00
sheenachhabra
c4605b3c90 Update release notes for media3:1.3.0-rc01
#minor-release

PiperOrigin-RevId: 605561427
2024-02-09 01:40:25 -08:00
huangdarwin
a5e47982f4 HDR: Add color-space conversion for PQ tone-map.
Previously, we missed the BT2020->BT709 color-space conversion.

A user-visible impact of this is that red and green channels used to be
undersaturated, but now are more correctly saturated.

PiperOrigin-RevId: 605411926
2024-02-08 13:33:52 -08:00
tianyifeng
9b0cdde7d2 Report the skipped silence more deterministically
Issue: androidx/media#1035
#minor-release
PiperOrigin-RevId: 605361126
2024-02-08 10:40:40 -08:00
tonihei
e56e27e725 Move release note to the right section
#minor-release

PiperOrigin-RevId: 605310711
2024-02-08 07:31:57 -08:00
ibaker
7ebfed505c Stop double-encoding CMCD query parameters
`Uri.appendQueryParameter` is documented to encode its arguments, so
calling `Uri.encode` beforehand results in double-encoding.

Issue: androidx/media#1075

#minor-release

PiperOrigin-RevId: 604995441
2024-02-07 08:44:33 -08:00
tofunmi
2cb9d9b383 Export: Add methods to determine the conversion process of a track
PiperOrigin-RevId: 604754827
2024-02-06 13:58:14 -08:00
bachinger
138532e3fd Fix the regex used for validating custom CMCD key names
Relax the regex to only check for hyphen which is required by the specification.

Issue: androidx/media#1028
#minor-release
PiperOrigin-RevId: 604719300
2024-02-06 11:59:20 -08:00
bachinger
c2273345c5 Add constructor that takes only a Context
#minor-release

PiperOrigin-RevId: 604659845
2024-02-06 08:47:03 -08:00
tonihei
f8f6d80477 Add source prefix to MergingMediaPeriod Format ids
This was already done for the TrackGroup ids in <unknown commit>,
but in some scenarios only the Format instances are known and
it's helpful to be able to identify where they came from.

Issue: androidx/media#883

#minor-release

PiperOrigin-RevId: 604644039
2024-02-06 07:45:42 -08:00