20193 Commits

Author SHA1 Message Date
ibaker
7f5b1a98e9 Use Guava's toByteArray & fromByteArray methods where possible
Also remove intermediate object allocations in
`Util.toByteArray(int...)`.

`Util.toByteArray(InputStream)` is kept (but deprecated) because it's
been part of the library for a while and might be in use by some apps.
The others are much newer, so the chance of usages outside the library
is very low, so we just remove them directly.

PiperOrigin-RevId: 613878453
2024-03-08 03:27:29 -08:00
christosts
9f9d955f0d Preview clipped media in composition preview
PiperOrigin-RevId: 613609878
2024-03-07 09:32:11 -08:00
ibaker
5b48ef4e53 Add tests for Util.toByteArray
The implementation of these methods is changed in a follow-up CL, and
these tests help to ensure nothing breaks.

This doesn't include tests for `toByteArray(InputStream)` or
`toByteArray(int)` because these implementations are fully replaced by
Guava equivalents in a follow-up CL.

PiperOrigin-RevId: 613581845
2024-03-07 07:51:04 -08:00
ibaker
ab8b77a6d3 Use try-with-resources for input and output streams in TestUtil
Many of these streams were previously never closed.

PiperOrigin-RevId: 613580471
2024-03-07 07:47:59 -08:00
claincly
0f72126c20 Add getLastTimestampUs() method
PiperOrigin-RevId: 613579674
2024-03-07 07:44:58 -08:00
ibaker
914874566e Remove unused TestUtil.getBitmap method
PiperOrigin-RevId: 613579444
2024-03-07 07:41:14 -08:00
ibaker
0ff80d7da0 Statically import Assertions methods in FakeExoMediaDrm
PiperOrigin-RevId: 613578959
2024-03-07 07:37:50 -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
kimvde
f02dc8e528 Implement AudioGraphInput.flush
PiperOrigin-RevId: 613563855
2024-03-07 06:33:02 -08:00
ibaker
7cffae9cd0 Apply common_library_config in test_session_current/build.gradle
This is the only `build.gradle` file that currently doesn't apply this
config, and it seems to lead to desugaring errors when apps depend on
the library locally.

PiperOrigin-RevId: 613559535
2024-03-07 06:14:25 -08:00
tofunmi
5b7774fcaf Composition: clarify javadoc to setTransmuxAudio\Video
Document that assoicated effects are ignored if these setters are set

PiperOrigin-RevId: 613518167
2024-03-07 02:58:30 -08:00
ibaker
afacf2cdb7 Set Format.frameRate for single-frame MP4 tracks
Issue: androidx/media#1051
PiperOrigin-RevId: 613516802
2024-03-07 02:53:05 -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
andrewlewis
a90a7049e8 Fix typo
PiperOrigin-RevId: 613156951
2024-03-06 03:51:11 -08:00
Googler
4d0af794df Internal changes only
Internal changes

PiperOrigin-RevId: 613155879
2024-03-06 03:44:42 -08:00
ibaker
b1b8b2e6f9 Remove some deprecated DataSpec constructors
PiperOrigin-RevId: 613137809
2024-03-06 02:26:11 -08:00
tofunmi
f8c407cfb6 TransformerInternal: pass outputformat to sampleExporter in image input
Pass firstAssetLoaderOutputFormat to videoSampleExporter for non-video use cases, so that the downstream components like the videoFrameProcessor can be set up with the right output color. Surface creation is still in the VSP so can't do this for all use cases currently.

also moves getDecoderOutputColor() to TransformerUtil, since it is used in multiple places and doesn't make sense for once to have reference to the other.

PiperOrigin-RevId: 613113958
2024-03-06 00:45:28 -08:00
andrewlewis
11b14d7594 Set profile for DV profile 10 AV1
PiperOrigin-RevId: 612918953
2024-03-05 11:53:44 -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
tonihei
8b59888766 Add missing icon constants for repeat/shuffle off
PiperOrigin-RevId: 612858065
2024-03-05 08:56:57 -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
3a43bd7687 Fix some invalid javadoc references caught by a new JDK version
PiperOrigin-RevId: 612808322
2024-03-05 05:48:34 -08:00
Googler
e175a772db Move AudioGraph effects to configure method
Move old configure behavior to private configureMixer.
registerInput() is now required after reset().

PiperOrigin-RevId: 612795418
2024-03-05 04:46:36 -08:00
tonihei
c79ac5ba21 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
2024-03-05 02:20:18 -08:00
Copybara-Service
bbdaf2b092 Merge pull request #1025 from v-novaltd:dsparano-exo209
PiperOrigin-RevId: 612485043
2024-03-04 09:55:00 -08:00
claincly
305f24f947 Clarify ExoPlayer.setVideoEffects() javadoc
PiperOrigin-RevId: 612464321
2024-03-04 08:45:38 -08:00
Daniele Sparano
0cdae9af20 Read resolution for debug text view from VideoSize object to reflect changes from video effects 2024-03-04 14:09:54 +00:00
tofunmi
bcfad4b3b4 Move hdrMode from defaultAssetLoaderFactory constructors to create()
Plumbing hdrMode through the default asset loader factory via the constructor is problematic because it breaks API boundaries. It means there is another way to set hdrMode outside of Composition.java and TransformationRequest.java, which is error prone and cause problems if someone an app starts customizing the assetloaderfactory. It also means custom asset loaders can't receive this information without hacking around.

The introduction of the composition-level settings class makes this approach easily extensible for other settings applied on the composition level but use in an individual asset level basis (e.g. ultraHDR support).

PiperOrigin-RevId: 611466920
2024-02-29 07:41:18 -08:00
ibaker
7395c9a159 Remove deprecated CronetDataSourceFactory
PiperOrigin-RevId: 611431225
2024-02-29 04:59:35 -08:00
christosts
1355f4734d Composition preview tests with surfaces
Add abilitiy to use real surfaces in instrumentation tests
using the ActivityScenarioRule and an activity class for testing
purposes.

PiperOrigin-RevId: 611421490
2024-02-29 04:19:44 -08:00
sheenachhabra
bba45b8b35 Rename DefaultMp4Writer to BasicMp4Writer
PiperOrigin-RevId: 611421036
2024-02-29 04:16:15 -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
claincly
27d78e69d7 Clarify setVideoEffect() javadoc
PiperOrigin-RevId: 611147963
2024-02-28 10:31:42 -08:00
Googler
87c4d60c37 Allow CronetDataSource's read buffer size to be configured.
PiperOrigin-RevId: 611146397
2024-02-28 10:27:59 -08:00
sheenachhabra
6809c0a642 Change Mp4Writer to an interface
The Mp4Writer does not have any default implementation,
hence it can be an interface rather than an abstract class.

PiperOrigin-RevId: 611110415
2024-02-28 08:28:59 -08:00
Googler
08993b6fb1 Have VideoSampleExporter output orientation match input
This should enable trim optimization to work correctly in more cases.

PiperOrigin-RevId: 611096958
2024-02-28 07:40:53 -08:00
christosts
55bfe4f95c Composition preview: do not report errors on release
PiperOrigin-RevId: 611096895
2024-02-28 07:37:15 -08:00
ibaker
09ac916119 Remove DefaultTrackSelector.NO_ORDER ordering
This implementation generates lint errors because neither the `first`
nor `second` parameters are used, and that's generally
unexpected/incorrect for a `Comparator` implementation since it should
always consider both its parameters.

PiperOrigin-RevId: 611039632
2024-02-28 02:58:41 -08:00
ibaker
19cd156a8c Add Mp4ExtractorTest case for pixel-motion-photo-2-hevc-tracks.mp4
A follow-up change will add the frame rate to the single-frame track.

Issue: androidx/media#1051
PiperOrigin-RevId: 611018319
2024-02-28 01:23:01 -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
claincly
626a8adfd8 Test effect-enabled playback
This new test is for `ExoPlayer.setVideoEffects()`. It plays the
one-second-long video, applies an overlay that prints the video frame timestamp
onto the frame, captures the output frame and compares the captured output
frame with golden.

PiperOrigin-RevId: 610781590
2024-02-27 09:44:24 -08:00
Googler
6f28eeff31 Pick max H.264 level when trim optimizing
Instead of always starting with the transcoded H.264 level, take the maximum
from transcoded and transmuxed levels

PiperOrigin-RevId: 610759438
2024-02-27 08:27:38 -08:00
Rohit Singh
1994ba991c Add release note and update comment 2024-02-27 15:59:59 +00:00
Rohit Singh
b254c4625d Format with google-java-format 2024-02-27 15:30:22 +00:00
loliball
f88c9ad68c Fixed missing skip padding issue when reading odd sized chunks from wav files. 2024-02-27 15:30:22 +00:00
Googler
c3aec4f19d Comments for AudioGraph constructor
Add /*effects=*/ at callsites of AudioGraph constructor.

PiperOrigin-RevId: 610741692
2024-02-27 07:12:53 -08:00
sheenachhabra
94e0a27a81 Add unified addMetadata() method in Mp4Muxer
PiperOrigin-RevId: 610710011
2024-02-27 04:34:45 -08:00
Googler
0e0e1c4f1a Tests for composition audio effects
Add tests for the changes to AudioGraph that support composition audio effects

PiperOrigin-RevId: 610691768
2024-02-27 03:04:20 -08:00
Googler
477ace1be9 Composition audio effects
Implement composition-level audio effects in AudioGraph.

PiperOrigin-RevId: 610689632
2024-02-27 02:54:08 -08:00