3740 Commits

Author SHA1 Message Date
tonihei
c8ae6d1142 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
(cherry picked from commit cbed80ecf36d3ff49ec9d2806670f1fda3551aba)
2024-03-11 09:46:07 -07:00
tonihei
3f3d60eb6a Add device-specific opt-ins for async MediaCodecAdapter
Some devices just don't work very well with the synchronous
model, but are currently still excluded from our approximate
API 31 check. This change allows to include additional devices
or device groups by passing in the Context to the default
adapter.

It also adopts the workaround added in ebceee08c6
for Fire TV Smart devices that exhibit this issue.

PiperOrigin-RevId: 614642545
(cherry picked from commit e4a55844d0c99cdfefb37259a8c3bbe0fb9ddc74)
2024-03-11 06:27:15 -07:00
tonihei
fffbf9ac4e Force external surround sound flag if requested by device
Some FireOS6 devices ask to force the external surround global
flag and ignore any signals from the HDMI connection.

This is the equivalent change of e341944d1e

PiperOrigin-RevId: 614634499
(cherry picked from commit 410c0492cc9c7888df7a5283c5ebf8d99bf9c0cc)
2024-03-11 05:52:52 -07:00
tonihei
a85d9e251c Reorder audio capability checks
Using the more accurate check available on later API versions
first is likely better than falling back to a fallback solution
from older API versions.

PiperOrigin-RevId: 614612628
(cherry picked from commit 18cbbf3850df841f0396abcd2c7e5e8196e85bac)
2024-03-11 04:14:31 -07:00
tonihei
a72a23266b Document MergingMediaSource tag contract
Issue: androidx/media#883

#minor-release

PiperOrigin-RevId: 613970048
(cherry picked from commit eb6f607717ce930036f445511414ef21fea5e174)
2024-03-08 10:11:55 -08:00
ibaker
e55621496c Add workarounds for NoSuchMethodError from DRM framework exceptions
Issue: androidx/media#1145

PiperOrigin-RevId: 613573868
(cherry picked from commit a604600126e87037056a0d93b76b2d99e89544c4)
2024-03-07 07:13:01 -08:00
tofunmi
2dc2e5daf1 Composition: clarify javadoc to setTransmuxAudio\Video
Document that assoicated effects are ignored if these setters are set

PiperOrigin-RevId: 613518167
(cherry picked from commit 5b7774fcaf1498b7c72448fcd0497fcc44efd7cc)
2024-03-07 02:55:30 -08:00
ibaker
41771d7fa3 Set Format.frameRate for single-frame MP4 tracks
Issue: androidx/media#1051
PiperOrigin-RevId: 613516802
(cherry picked from commit afacf2cdb7d5561ef61b97059cd8bb22d8558c58)
2024-03-07 02:49:59 -08:00
michaelkatz
71bfdd1bce 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
(cherry picked from commit 638b2a3c86f7362041b09faed7c3c09609e29118)
2024-04-05 13:05:36 +00:00
andrewlewis
3fdd3bdb7a Fix typo
PiperOrigin-RevId: 613156951
(cherry picked from commit a90a7049e8e7c9a283e09cca15f0188954712841)
2024-03-06 03:47:22 -08:00
ibaker
b6cb9c1b90 Fix some invalid javadoc references caught by a new JDK version
PiperOrigin-RevId: 612808322
(cherry picked from commit 3a43bd76875e4f18776f5ec3b0043000a763f9cd)
2024-04-02 18:43:29 +00:00
tonihei
672d149a73 Remove invalid command comparison
The removed check searched for a player command inside a list of
session commands, which is not allowed by the IntDef definition
and only worked because both types map to a Java int.

PiperOrigin-RevId: 612758442
(cherry picked from commit c79ac5ba218c685ea6cf284a634899c8327785c8)
2024-04-02 18:36:27 +00:00
Copybara-Service
e28d772423 Merge pull request #1025 from v-novaltd:dsparano-exo209
PiperOrigin-RevId: 612485043
(cherry picked from commit bbdaf2b092c1cf909502fc49fb7bedf7a5b5b9b8)
2024-04-02 18:36:27 +00:00
tianyifeng
cf9ff4de45 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

PiperOrigin-RevId: 611417539
(cherry picked from commit 1bdc58de0be73c14e1b5fdffab64d69da470ffb3)
2024-04-02 18:36:22 +00:00
ibaker
1d2116c53a 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
(cherry picked from commit c7e00b12b4b3eff6c478d2f4afc7a48bb05d6e7d)
2024-04-02 18:34:46 +00:00
michaelkatz
3521ccda9b 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
(cherry picked from commit 23a301fc5d3d14593f32c04634d7267c8a86a1cd)
2024-04-02 18:30:13 +00:00
christosts
3c10b41ffa ExoPlayerImplInternal.releaseInternal(): unblock the app thread
This change makes ExoPlayerImplInternal.releaseInternal() unblock the
app thread if a runtime exception is thrown while releasing components
from the playback thread.

Before this change, if a runtime exception occurred during releasing
components in the playback thread, ExoPlayer.release() would wait for
`releaseTimeoutMs` and then raise a player error. With this change,
the player error is reported only when the playback thread is blocked
but if there is a runtime exception, the application thread is
unblocked.

The impact of this change is potentially fewer ANRs on
ExoPlayer.release() at the expense of less error reporting.

PiperOrigin-RevId: 609702549
(cherry picked from commit 0480eff6a15152ae965129e5357d70507c792658)
2024-04-02 18:27:25 +00:00
christosts
25e8dc5e8b ForwardingAudioSink: add override for release()
We forgot to add it when we added AudioSink.release(). The commit
includes a test that ensures ForwardingAudioSink overrides all the
methods defined in the AudioSink interface.

PiperOrigin-RevId: 609402258
(cherry picked from commit 440d2ab162604a5555ebdaa6d71b2f82120b1e09)
2024-04-02 18:24:37 +00:00
michaelkatz
81e91c25f1 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
(cherry picked from commit 41929246222e9fdb9aa552db526c1b41d26bdb90)
2024-04-02 18:24:37 +00:00
michaelkatz
ed71172ade 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
(cherry picked from commit 9046f2edb62f3dd9bc735405d2a58a98abd87064)
2024-04-02 18:24:33 +00:00
tianyifeng
2ae79959ef 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
(cherry picked from commit d952a0621471308b0fb545ce7da5067cead0a0df)
2024-04-02 18:21:05 +00:00
michaelkatz
2f47151131 Allow empty information attributes in RTSP Session Description
Issue: androidx/media#1087
PiperOrigin-RevId: 608534659
(cherry picked from commit 52c1d60d39f690b7f3231095fb193510c93fd1ec)
2024-04-02 17:08:26 +00:00
Googler
04ce83691e 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
(cherry picked from commit e43f96687c3c6d13907da1a5c53e90ffa57d624c)
2024-04-02 16:57:22 +00:00
ibaker
b218d910ad Fix docs on playUntilStartOfMediaItem to match playUntilPosition
The behaviour and docs of `playUntilPosition` were changed in
00c7a9bcbb.

This change also affects `playUntilStartOfMediaItem` (since it delegates
to `playUntilPosition`), so the same doc change should also be made
here.

#minor-release

PiperOrigin-RevId: 607364897
(cherry picked from commit fa3212e73e5b5f958e6b0aace459d50232e56de5)
2024-04-02 16:41:12 +00:00
claincly
396ae86fdd Fix forward for 216f3fedb8
The original change missed copying the newly added flag in `buildUpon()`, which
caused some test flakes.

PiperOrigin-RevId: 607232373
(cherry picked from commit ae0da442b1f29b9c8c2b64a99d640fa5b2ce5e0f)
2024-04-02 16:41:12 +00:00
bachinger
879bcb5d99 Check whether the session activity pending intent is an activity
PiperOrigin-RevId: 606613694
(cherry picked from commit 89571c0a9268469f242586af2b964ccd4daf3dee)
2024-04-02 16:41:11 +00:00
claincly
5fd1f61c84 Loosen the requirement to register every input frame
VideoFrameProcessor requires every input frame to be registered before they are
rendered to its input Surface. This CL adds the option to register the input
frame only once. This is useful for camera inputs where not all input frames
come with changing FrameInfo.

PiperOrigin-RevId: 606294894
(cherry picked from commit 216f3fedb857d9a6e0bf846070784c1cc5b7e705)
2024-04-02 16:14:01 +00:00
michaelkatz
c4688fc557 Fallback to including track language name if display name is not found
Issue: androidx/media#988
PiperOrigin-RevId: 606193299
(cherry picked from commit 0b0c419c73b8a67955c6a5244db3ca87244dc4eb)
2024-04-02 16:13:56 +00:00
huangdarwin
2ec19a5da5 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
(cherry picked from commit a5e47982f4d98e02469f0f0240b5ee1469bff015)
2024-04-02 16:12:42 +00:00
tofunmi
39f26e6041 DefaultAssetLoaderFactory: Simplify file extension retrival
Change the file extension retrieval back to how it was before 5488d33da8 to reduce the change of false negatives in `isImage()`

PiperOrigin-RevId: 605281186
(cherry picked from commit 4d29d8f012410bdacd5fb3c45c5f082a328f4028)
2024-04-02 16:11:10 +00:00
huangdarwin
9825e21a71 Effect: Remove extra checkStateNotNull by reordering logic.
PiperOrigin-RevId: 603660773
(cherry picked from commit ae85ba9ee9fe55c37ffbbad62e010d318ce199d6)
2024-04-02 16:11:10 +00:00
huangdarwin
ecaff24e46 Effect: Use element instead of peek, when throwing if null.
If nullness should result in an exception, we should throw as soon as possible,
so that stack traces are easier to follow.

Did a quick scan of media3.effect+transformer and this covers all uses of
peek that immediately throw there.

PiperOrigin-RevId: 603393366
(cherry picked from commit dd7846ee1cbeb48ddb5495858a71517858df0554)
2024-04-02 16:11:10 +00:00
huangdarwin
bfa492bf4f HDR: Don't assume that swapping between BT709 and BT601 needs tone-map.
VideoFrameProcessor treats BT601 and BT709 as roughly equivalent now, so we
shouldn't be making checks that assume BT709 <-> requires tone-mapping.

Also, the color transfer is a better determinant for tone-mapping than color range, so use just the transfer to determine if tone-mapping is required.

PiperOrigin-RevId: 603083100
(cherry picked from commit cebe6d8ba573c2a636426b18c01837fbec6b00aa)
2024-04-02 16:11:10 +00:00
sheenachhabra
99e7156561 Update media3 version for 1.3.0 stable release
PiperOrigin-RevId: 609745599
(cherry picked from commit 9be7a7ab7f5205feece0d6431bc40e534fe9ac9c)
2024-02-26 12:15:21 +00:00
sheenachhabra
fbf8ac37c3 Version bump to media3:1.3.0-rc01
PiperOrigin-RevId: 605573991
(cherry picked from commit a31a3843931e6b8535062f06fa8675c158a54d86)
2024-02-09 11:39:45 +00:00
tianyifeng
38d5635818 Report the skipped silence more deterministically
Issue: androidx/media#1035
#minor-release
PiperOrigin-RevId: 605361126
(cherry picked from commit 9b0cdde7d2fe5ee8cb7a6dcb39d432e877b1a9cd)
2024-02-08 19:09:41 +00:00
ibaker
dbb99fef19 Rollback of 406c0a15be
PiperOrigin-RevId: 605015994
(cherry picked from commit 3a7a665d5df758817be637d026664838ef1af2ea)
2024-02-08 17:30:17 +00:00
ibaker
1dc4377a4b 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
(cherry picked from commit 7ebfed505c5ac42cb6e614a3dd9b7755af3e92b2)
2024-02-08 17:30:17 +00:00
tonihei
245e6231d9 Set correct track id when skipping empty tracks in Mp4Extractor
The track id must be the index in the list of published tracks
as it's used as such elsewhere. This is currently not true if we
skip an empty track as all subsequent tracks get a wrong or even
invalid id.

#minor-release

PiperOrigin-RevId: 604929178
(cherry picked from commit 5f9c96ab53c571af90457e9f22bac1fe32209bd5)
2024-02-08 17:30:17 +00:00
bachinger
74d0f93dd4 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
(cherry picked from commit 138532e3fd158e60d50aa85cc1ac2effa388f4eb)
2024-02-08 17:30:17 +00:00
tianyifeng
9f28e7d81b Improve AudioCapabilities with AudioManager API in Android 13
PiperOrigin-RevId: 604700601
(cherry picked from commit ccd603acb067c560840f7aa1499556733e204c39)
2024-02-08 17:30:17 +00:00
ibaker
bf8b8749fe JpegMotionPhotoExtractor: Don't emit an image track with no metadata
The current implementation of `JpegMotionPhotoExtractor.sniff` returns
`true` for any image with Exif data (not just motion photos). Improving
this is tracked by b/324033919. In the meantime, when we 'extract' a
non-motion photo with `JpegMotionPhotoExtractor`, the result is
currently a single empty image track and no video track (since there's
no video, since this isn't a motion photo). This 'empty' image track
is usually used to transmit metadata about the video parts of the
image file (in the form of `MotionPhotoMetadata`), but this metadata is
also (understandably) absent for non-motion photos. Therefore there's
no need to emit this image track at all, and it's clearer to emit no
tracks at all when extracting a non-motion photo using
`JpegMotionPhotoExtractor`.

This change also removes a `TODO` that is misplaced, since there's no
image bytes being emitted here (and never was).

PiperOrigin-RevId: 604688053
(cherry picked from commit 7ae3d69e001d0a138f3ebe406b050bc06bd24724)
2024-02-08 17:30:16 +00:00
ibaker
7721f387ca Check sampleMimeType rather than containerMimeType for images
These are often the same for image tracks, since we usually drop the
whole image file (both the container and actual encoded image bytes)
into a single sample, but there are cases where we emit a track with
`containerMimeType=image/jpeg` but **no** samples (from
`JpegMotionPhotoExtractor`, to carry some metadata about the image +
video byte offsets).

It's therefore more correct to implement the `supportsFormat` check
based on `sampleMimeType`, so that these 'empty' image tracks are not
considered 'supported' by `ImageRenderer`.

#minor-release

PiperOrigin-RevId: 604672331
(cherry picked from commit eabba49610b8f93ed92450baf55da01e5a8b23b2)
2024-02-08 17:30:16 +00:00
bachinger
dc8d3eaf30 Add constructor that takes only a Context
#minor-release

PiperOrigin-RevId: 604659845
(cherry picked from commit c2273345c51731ba3950298c4f8a8f02957062b7)
2024-02-08 17:30:16 +00:00
tonihei
ca2779e774 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
(cherry picked from commit f8f6d80477241a1f2a65e548855f94eeb5389c96)
2024-02-08 17:30:16 +00:00
tonihei
a294dc9bc5 Include nullness of RequestMetadata.extras in equals method
This ensures RequestMetadata with just non-null extras is not
considered equal to RequestMetadata.EMPTY. This makes sure the
contents are bundled when a controller sets the extras in a
new MediaItem.

PiperOrigin-RevId: 604632788
(cherry picked from commit 766a15a51e5e09e6e5f5df5d53bf603e167af3d3)
2024-02-08 17:30:16 +00:00
ibaker
ad57b41da1 Clearly define the consistency requirements for SequenceableLoader
Add a test for this consistency in `CompositeSequenceableLoaderTest`,
and also make the
`CompositeSequenceableLoaderTest.FakeSequenceableLoader` implementation
more realistic.

#minor-release

PiperOrigin-RevId: 604604103
(cherry picked from commit db74bb9609a59b70a6a477f4abb2af61bba19aa2)
2024-02-08 17:30:16 +00:00
ibaker
4eea69dd46 Merge Cea608Parser back into Cea608Decoder
This reverses 27caeb8038

Due to the re-ordering of packets done in `CeaDecoder`, there's no way
to use the current implementation to correctly parse these subtitle
formats during extraction (the `SubtitleParser` interface), so we have
to keep the `SubtitleDecoder` implementations.

#minor-release

PiperOrigin-RevId: 604594837
(cherry picked from commit 25498b151ba298ef359f245e2ed80718b4adf556)
2024-02-08 17:30:16 +00:00
ibaker
dd2e4a5978 Merge Cea708Parser back into Cea708Decoder
This reverses 94e45eb4ad

Due to the re-ordering of packets done in `CeaDecoder`, there's no way
to use the current implementation to correctly parse these subtitle
formats during extraction (the `SubtitleParser` interface), so we have
to keep the `SubtitleDecoder` implementations.

#minor-release

PiperOrigin-RevId: 604350951
(cherry picked from commit 51b4fa2cc83b60fcb313fd0e6afd2d45fe64e535)
2024-02-08 17:30:16 +00:00
tonihei
548c4ce799 Fix HlsPlaybackTest flakiness
The new test introduced in 45bd5c6f0a is flaky because we only
wait until the media is fully buffered. However, we can't fully
control how much of this data is initially read by the Robolectric
codec and thus the output dump files (containing these codec
interactions) are flaky.

This can be fixed by fully playing the media once and then seeking
back instead.

#minor-release

PiperOrigin-RevId: 603324068
(cherry picked from commit e3e57c9b9943fd160105001b2e8e26782173843e)
2024-02-08 17:30:16 +00:00