3490 Commits

Author SHA1 Message Date
christosts
3d1d8f4439 Exit early progressive loads if the load task is canceled
Add an check when loading progressive media in case the load
is canceled. If the player is released very early, the progressive
media period may carry on with the initial loading unnecessarily.

PiperOrigin-RevId: 586288385
2023-11-29 04:01:06 -08:00
andrewlewis
3204313f13 Remove debug logging
This case is expected and we aren't trying to gather information about it
currently, so we shouldn't log.

PiperOrigin-RevId: 586015969
2023-11-28 10:01:37 -08:00
huangdarwin
e5ef31b277 Effect: Avoid allocating bitmaps and textures in Overlays.
In `TextOverlay` and `DrawableOverlay`, treat `Bitmap` as a buffer, where we
allocate it rarely and reuse it as long as possible before making a new one.

In `BitmapOverlay`, avoid allocating GL textures too often as well.

Strongly reduces allocations and memory usage growth (saving ~100-150 MB on 4k60fps
at high end), at the cost of more code complexity and low-end using 70MB more, on
1/1 comparisons.

PiperOrigin-RevId: 585990602
2023-11-28 08:44:30 -08:00
huangdarwin
eb01c3f440 Add exception message for MediaCodecRenderer exception.
Otherwise, it's difficult to differentiate between different sources of ERROR_CODE_DECODING_FORMAT_UNSUPPORTED.

PiperOrigin-RevId: 585966636
2023-11-28 07:15:52 -08:00
andrewlewis
b8c1e22389 Clarify threading-related comments in texture manager
In `ExternalTextureManager` fields are accessed from the GL thread and the class needs to be constructed on the GL thread.

Also visibly document threading requirement in the parent class.

PiperOrigin-RevId: 585941284
2023-11-28 05:30:15 -08:00
andrewlewis
7bbf72c202 Use JsonWriter to convert to JSON
Before the change the output was JSON-like but not valid because it had commas
after objects/arrays.

PiperOrigin-RevId: 585929345
2023-11-28 04:39:50 -08:00
tofunmi
b598c96c2f Update emulator device names
PiperOrigin-RevId: 585682881
2023-11-27 10:02:02 -08:00
andrewlewis
1c7c06999e Turn off debug trace logging by default
The issue that motivated adding this (frames unexpectedly being dropped by the
decoder) has been addressed, so we can turn off the logging to reduce
unnecessary allocations during transformation. We can easily turn on debug
logging in future as needed by setting `DebugTraceUtil.DEBUG = true`.

Also avoid allocations for string building at logging call sites by passing a
format string for extra info. Formatting the string now only happens when
debugging is turned on.

Tested manually by running transformations in the new state (DEBUG = false) and
with debugging turned on.

PiperOrigin-RevId: 585666349
2023-11-27 08:57:30 -08:00
ibaker
63062a9c10 Make CueSerializationTest more realistic
Serializing bitmap cues is currently broken, but this test is
incorrectly passing. This change makes two changes to introduce the same
failure (both changes are necessary, each one alone still passes):

1. Move from Robolectric to an instrumentation test.
2. Trigger the `Bitmap` to be serialized using a file descriptor, either
   by calling `Bitmap.asShared` in the test when constructing the `Cue`,
   or constructing the `Bitmap` from a 'real' image byte array instead a
   1x1 token image.

Issue: androidx/media#836
PiperOrigin-RevId: 585643486
2023-11-27 07:16:19 -08:00
Copybara-Service
5f27b18210 Merge pull request #837 from superjohan:fix/android-14-clearkey
PiperOrigin-RevId: 585639025
2023-11-27 06:56:45 -08:00
andrewlewis
e84a13fb54 Restrict operating rate workaround to SM8550
PiperOrigin-RevId: 585613041
2023-11-27 04:42:42 -08:00
andrewlewis
8b38b34b9f Work around codec frame rate issues in Redmi Note 9 Pro
The decoder and encoder won't accept high values for frame rate, so avoid
setting the key when configuring the decoder, and set a default value for the
encoder (where the key is required).

Also skip SSIM calculation for 4k, where the device lacks concurrent decoding
support.

PiperOrigin-RevId: 585604976
2023-11-27 04:05:44 -08:00
huangdarwin
c650f05234 Document TimestampWrapper not working with previewing.
Mentioned in https://github.com/androidx/media/issues/821

PiperOrigin-RevId: 585595948
2023-11-27 03:25:31 -08:00
Johan Halin
ad7b12e56f Apply workaround for Android 13 and newer
At least some Android 14 devices still have the same invalid URL issue
when using ClearKey DRM, so might as well apply the check to newer
versions of Android as well.
2023-11-27 10:41:47 +00:00
andrewlewis
ad40db4489 Avoid value close to overflow for KEY_OPERATING_RATE
Using `Integer.MAX_VALUE` risks causing arithmetic overflow in the codec
implementation.

Issue: androidx/media#810

#minor-release

PiperOrigin-RevId: 585104621
2023-11-24 08:57:59 -08:00
siroberts
bc36553e81 Expose isTrusted property of ControllerInfo.
PiperOrigin-RevId: 585052580
2023-11-24 03:37:33 -08:00
jbibik
c0ef5f6de4 Serialize media3 custom Spans for Cue encoding/decoding
PiperOrigin-RevId: 585028521
2023-11-24 01:32:40 -08:00
ibaker
479344d74e Fix typo in DashManifestParser
PiperOrigin-RevId: 585017285
2023-11-24 00:32:26 -08:00
tonihei
85a54e2e19 Remove redundant ) in Javadoc
PiperOrigin-RevId: 584910697
2023-11-23 09:58:45 -08:00
Copybara-Service
45b51d8c97 Merge pull request #707 from equeim:ffmpeg-6.0
PiperOrigin-RevId: 584893190
2023-11-23 08:06:04 -08:00
samrobinson
aef2fcb900 Plumb EditedMediaItem for audio preview.
PiperOrigin-RevId: 584865962
2023-11-23 05:13:32 -08:00
tonihei
e766666482 Instruct MediaCodec to drop buffers before start time in tunneling mode
We don't get the buffer back after decoding to make a proper decision
about whether dropping the buffer is needed, so we do the next best
thing and tell the codec to drop the buffer if its input timestamp is
less than the intended start time.

PiperOrigin-RevId: 584863144
2023-11-23 04:56:57 -08:00
christosts
2a74cb7ef2 Move VideoFrameProcessor reflective loading code
Move the reflective loading of VideoFrameProcessor from
MediaCodecVideoRenderer to the CompositingVideoSinkProvider. This is so
that all reflective code lives in one place. The
CompositingVideoSinkProvider already has reflective code to load the
default PreviewingVideoGraph.Factory.

PiperOrigin-RevId: 584852547
2023-11-23 03:54:18 -08:00
samrobinson
1524d12634 Avoid using unneeded double ended queue.
These usages have no need for the double ended input functionality. All
other usages across media3 are ConcurrentLinkedQueue.

PiperOrigin-RevId: 584841104
2023-11-23 02:51:20 -08:00
huangdarwin
0f040e6c6e Use static import for Util.formatInvariant.
In OverlayShaderProgram, this method is used quite a lot, and is the only method from Util.java in this file. Marginally reduce complexity by using a static import instead.

PiperOrigin-RevId: 584828455
2023-11-23 01:45:19 -08:00
huangdarwin
dc037b22cd Effect: Flip texture in OpenGL instead of allocating a Bitmap.
Reduce short-lived allocations of potentially large objects, like Bitmap.

Unfortunately, this does make the TextureOverlay interface more messy though, requiring a way to signal whether the texture should be flipped vertically.

PiperOrigin-RevId: 584661400
2023-11-22 10:17:10 -08:00
Alexey Rochev
6332693ce4 Use swr_alloc_set_opts2 function to set SwrContext options 2023-11-22 16:14:47 +00:00
Alexey Rochev
815d93cfa2 Migrate to FFmpeg 6.0
These changes are also compatible with FFmpeg 5.1, which is now minimum supported version.

Also set -Wl,-Bsymbolic flag via target_link_options command which is more correct.
2023-11-22 16:14:47 +00:00
tofunmi
2d77e4d22c Implement trim optimization in Transformer
PiperOrigin-RevId: 584622392
2023-11-22 07:28:34 -08:00
christosts
6435ddb89e Create VideoFrameRenderControl
Split CompositingVideoSinkProvider.VideoSinkImpl in two classes:
- VideoSinkImpl now only receives input from MediaCodecVideoRenderer and
  forwards frames to its connected VideoFrameProcessor
- VideoFrameRenderControl takes composited frames out of the VideoGraph
  and schedules the rendering of those.
- CompositingVideoSinkProvider connects VideoSinkImpl with
  VideoFramesRenderer.

PiperOrigin-RevId: 584605078
2023-11-22 06:05:04 -08:00
bachinger
a063d137b4 Add session extras to the state of the controller
This change adds `MediaController.getSessionExtras()` through
which a controller can access the session extras.

The session extras can be set for the entire session when
building the session. This can be overridden for specific
controllers in `MediaSession.Callback.onConnect`.

PiperOrigin-RevId: 584430419
2023-11-21 14:32:33 -08:00
rohks
1d61c48266 Rollback of 1360548649
PiperOrigin-RevId: 584358604
2023-11-21 10:12:47 -08:00
rohks
1360548649 Handle unsupported format xHE-AAC in FfmpegAudioRenderer
Issue: androidx/media#803
PiperOrigin-RevId: 584333812
2023-11-21 08:34:25 -08:00
huangdarwin
0b22a7a0d8 GL: Move private helper method next to the method that uses it.
In addition to being more readable, this will help future CLs that modify
these methods...

PiperOrigin-RevId: 584323686
2023-11-21 07:52:24 -08:00
christosts
ec08db458e MidiExtractor: mark only the first sample as key-frame
This change fixes a bug with seeking forward in MIDI. When seeking forward,
the progressive media period attempts to seek within the sample queue, if a
key-frame exists before the seeking position. With MIDI, however, we can
only skip Note-On and Note-Off samples and all other samples must be sent
to the MIDI decoder.

When seeking outside the sample queue, the MidiExtractor already
instructs the player to start from the beginning of the MIDI input. With
this change, only the first output sample is a key-frame, thus the
progressive media period can no longer seek within the sample queue and
is forced to seek from the MIDI input start always.

Issue: androidx/media#704

#minor-release

PiperOrigin-RevId: 584321443
2023-11-21 07:39:46 -08:00
samrobinson
79fd3365fa Use VolumeScalingAudioProcessor in audio effect preview test.
Dump files changes are easier to understand with a processor that keeps
buffer sizes the same.

PiperOrigin-RevId: 584320606
2023-11-21 07:35:01 -08:00
tonihei
af0282b9db Avoid clipping live offset override to min/max offsets
The live offset override is used to replace the media-defined
live offset after user seeks to ensure the live adjustment adjusts
to the new user-provided live offset and doesn't go back to the
original one.

However, the code currently clips the override to the min/max
live offsets defined in LiveConfiguration. This is useful to
clip the default value (in case of inconsistent values in the media),
but the clipping shouldn't be applied to user overrides as
the player will then adjust the position back to the min/max
and doesn't stay at the desired user position.

See 2416d99857 (r132871601)

#minor-release

PiperOrigin-RevId: 584311004
2023-11-21 06:49:19 -08:00
Copybara-Service
fde142d66e Merge pull request #793 from androidx:mpegh_extractor_changes
PiperOrigin-RevId: 584291984
2023-11-21 05:07:27 -08:00
Rohit Singh
4c3ca9b6f4 update mhm1 mp4 samples and corresponding extractor dumps 2023-11-21 12:12:23 +00:00
bachinger
ec478138ba Add test case to test position conversion when POSITION_UNKNOWN
PiperOrigin-RevId: 584261559
2023-11-21 02:24:30 -08:00
bachinger
167f50a9ca Return empty timeline when media info is null
Issue: androidx/media#708
PiperOrigin-RevId: 584054624
2023-11-20 09:55:36 -08:00
ibaker
4bcb60d31d Add Cea708Decoder/ParserTest with a single, simple example
PiperOrigin-RevId: 584042033
2023-11-20 09:06:03 -08:00
tianyifeng
89bedf0fb5 Emit onPositionDiscontinuity event when silence is skipped
Issue: androidx/media#765
PiperOrigin-RevId: 584024654
2023-11-20 07:50:13 -08:00
tonihei
5eb6a889a7 Adjust Javadoc
PiperOrigin-RevId: 583965332
2023-11-20 02:54:57 -08:00
rohks
ffbaa090aa Use .test top level domain for test URI
PiperOrigin-RevId: 583951327
2023-11-20 02:00:30 -08:00
rohks
6df240877c Populate MediaMetadata.extras to MediaMetadataCompat
Ensures backward compatibility.

Issue: androidx/media#802
PiperOrigin-RevId: 583425114
2023-11-17 10:25:10 -08:00
claincly
ad96ca3b30 Make vararg APIs more robust
Composition and EditedMediaItemSequence don't allow empty lists in their main
constructors, so shouldn't the vararg API. This is more inline with Effective
Java item 53.

PiperOrigin-RevId: 583415124
2023-11-17 09:51:39 -08:00
andrewlewis
7b9aa87344 Allow allocating more buffers when transmuxing
When transmuxing, the `EncodedSampleExporter` maintains a queue of input
buffers that get filled with encoded data by the asset loader. The number of
buffers was limited to avoid using more and more memory if producer (asset
loader) gets far ahead of the consumer (exporter).

Previously this limit was fixed at 10 buffers, but increasing the number of
buffers can make some transmux operations much faster. Allow allocating between
a min and max number of buffers, and also set a target allocation size beyond
which new buffers can't be allocated. This allows audio formats which require
many small buffers to be processed more quickly, while preventing allocating
too much memory for hypothetical very high bitrate formats.

'Remove video' edits on local videos in particular get much faster, because
audio buffers are very short and there are lots of them. With a sample 10
minute video, a 'remove video' edit took 2 seconds (36 seconds before this
change).  With a sample 1 minute removing video took 0.25 seconds after this
change (2.5 seconds before).

The speed improvement is smaller for other types of edits that retain the video
track. Transmuxing a 10 minute video retaining the video track took 26 seconds
(40 seconds before).

PiperOrigin-RevId: 583390284
2023-11-17 08:11:25 -08:00
ibaker
66c162dabd Fix examples in MediaLibraryInfo javadoc to be realistic
Bugfix releases don't have pre-release cycles.

PiperOrigin-RevId: 583295158
2023-11-17 00:52:10 -08:00
christosts
7dc0654c69 Rollback of eafe2e35f0
PiperOrigin-RevId: 583045154
2023-11-16 08:01:24 -08:00