1673 Commits

Author SHA1 Message Date
tonihei
ae8000aeca Replace MediaMetadata folderType by isBrowsable
The folder type has a mix of information about the item. It shows
whether the item is browsable (type != FOLDER_TYPE_NONE) and
which Bluetooth folder type to set for legacy session information.

It's a lot clearer to split this into a boolean isBrowsable and
use the existing mediaType to map back to the bluetooth folder type
where required.

folderType is not marked as deprecated yet as this would be an API
change, which will be done later.

PiperOrigin-RevId: 493544589
2022-12-12 11:32:57 +00:00
tonihei
4895bc42ff Support release in SimpleBasePlayer
This adds support for the release handling. To align with the
established behavior in ExoPlayer, the player can only call
listeners from within the release methods (and not afterwards)
and automatically enforces an IDLE state (without listener call)
in case getters of the player are used after release.

PiperOrigin-RevId: 493543958
2022-12-12 11:31:56 +00:00
huangdarwin
c07d503e79 Transformer: Always initialize presentationTime in VTSP.
This shouldn't really have anything to do with HDR.

PiperOrigin-RevId: 493357915
2022-12-12 11:29:00 +00:00
huangdarwin
c37317222c Transformer: Rename error code from output to encoding format.
Rename ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED to
ERROR_CODE_ENCODING_FORMAT_UNSUPPORTED.

This makes the error code more consistent with ERROR_CODE_DECODING_FAILED on the
decoding side. Also, the error code is in the "Encoding errors (4xxx)" section,
so muxer errors probably should be in the "Muxer errors (7xxx)" section instead.

Additionally, no muxer errors currently seem to use
ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED, so this should be a safe change.

PiperOrigin-RevId: 493322880
2022-12-12 11:26:43 +00:00
kimvde
0d12de8134 Move slow mo video flattening to AssetLoader
PiperOrigin-RevId: 493300556
2022-12-12 11:25:45 +00:00
kimvde
339205f428 Move progress updates to the AssetLoader
This is necessary to move video slow motion flattening to the
AssetLoader because this step can change the duration. As we use the
duration before flattening to calculate the progress, we must also use
the position before flattening.

PiperOrigin-RevId: 493291990
2022-12-12 11:24:46 +00:00
tofunmi
feb3b0b919 Add support for changing translucency of overlays through alpha values
Implements milestone 1.3 of the [overlays implementation plan](https://docs.google.com/document/d/1EcP2GN8k8N74hHZyD0KTqm9oQo5-W1dZMqIVyqVGtlo/edit#bookmark=id.76uzcie1dg9d)

PiperOrigin-RevId: 493290147
2022-12-12 11:22:33 +00:00
tofunmi
e6cb502bc6 Implement text and drawable overlays
Implements milestone 1.2 of the [overlays implementation plan](https://docs.google.com/document/d/1EcP2GN8k8N74hHZyD0KTqm9oQo5-W1dZMqIVyqVGtlo/edit#bookmark=id.76uzcie1dg9d)

PiperOrigin-RevId: 493282868
2022-12-12 11:21:27 +00:00
claincly
cc43ddb528 Re-assign TODOs
PiperOrigin-RevId: 493281221
2022-12-12 11:20:25 +00:00
ibaker
636a4a8538 Add javadoc links to README files
Fix some other link titles and destinations spotted along the way.

#minor-release

PiperOrigin-RevId: 493276172
2022-12-12 11:19:23 +00:00
huangdarwin
ac0d803027 HDR: Update to use input/output color instead of OETF/EOTF.
These terms are easier to understand, and make sense in the context of
MatrixTextureProcessor now that a MatrixTextureProcessor may have a
different input and output transfer.

PiperOrigin-RevId: 493265980
2022-12-12 11:18:30 +00:00
kimvde
00859a78fd Add comment to explain why cancel exceptions are handled differently
PiperOrigin-RevId: 493260798
2022-12-12 11:17:25 +00:00
huangdarwin
bb2c4c2eff HDR: Add effect interface support for different in/out color transfers
Modify FrameProcessor and MatrixTextureProcessor interfaces to support
different input and output color transfers. Does not implement conversion between
color ranges (ex. HDR and SDR), but should allow for conversion between color
transfers of the same color range (ex. HLG and PQ).

This supports in-app tone mapping, where we need a single FrameProcessor to
input HDR color transfers (ex. HLG/PQ) and output SDR (ex. gamma2.2). This also
supports previewing, where we need a single FrameProcessor to be able to input HLG
and output PQ.

Manually tested by confirming colors still look right on SDR and HDR videos
with a rotation and color affect applied.

PiperOrigin-RevId: 493108678
2022-12-12 11:16:26 +00:00
claincly
02bf7594e2 Change argument order to match API council suggestion
By putting Listener as the last argument.

PiperOrigin-RevId: 493100906
2022-12-12 11:15:23 +00:00
kimvde
7ea74444f3 Avoid sending message on dead thread
PiperOrigin-RevId: 493040714
2022-12-12 11:14:27 +00:00
claincly
900e86ffc8 Allow specifying an Executor in FrameProcessor.Factory.create()
From this CL on, FrameProcessor listeners will be invoked from an Executor that
is passed in when creating the FrameProcessor.

GlTextureProcessor needs to invoke the ErrorListener on the said Executor too.

PiperOrigin-RevId: 493018583
2022-12-12 11:13:30 +00:00
Googler
c14b250445 Temporal fix to allow proper library shrinking.
PiperOrigin-RevId: 492579961
2022-12-12 11:10:18 +00:00
ibaker
3efc62b512 Deprecate C.POSITION_UNSET in favour of C.INDEX_UNSET
These have the same value (`-1`), and basically the same meaning (offset
in an array/list/file/byte stream/etc), but 'position' is an overloaded
term in a media playback library, and there's a risk people assume that
methods like `Player.getCurrentPosition()` may return
`C.POSITION_UNSET`, when in fact unset media times (whether duration or
position) are always represented by `C.TIME_UNSET` which is a) a `long`
(not `int`) and b) a different underlying value. (aside:
`getCurrentPosition()` never returns an unset value, but it's a good
example of the ambiguity of the word 'position' between 'byte offset'
and 'media timestamp'.)

PiperOrigin-RevId: 492493102
2022-12-12 11:09:18 +00:00
tonihei
634c6161f1 Fix threading of onFallbackApplied callback
The callback is currently triggered on the ExoPlayer playback thread
instead of the app thread that added the listener.

PiperOrigin-RevId: 492474405
2022-12-12 11:08:17 +00:00
ibaker
2650654dd0 Fix ExoPlayerTest to use C.TIME_UNSET instead of C.POSITION_UNSET
This inconsistency was exposed by an upcoming change to deprecate
`POSITION_UNSET` in favour of `INDEX_UNSET` because position is an
ambiguous term between 'byte offset' and 'media position', as shown
here.

PiperOrigin-RevId: 492470241
2022-12-12 11:07:17 +00:00
ibaker
33bbb9511a Fix TextRenderer exception when a subtitle file contains no cues
Discovered while investigating Issue: google/ExoPlayer#10823

Example stack trace with the previous code (I added the index value for
debugging):

```
playerFailed [eventTime=44.07, mediaPos=44.01, window=0, period=0, errorCode=ERROR_CODE_FAILED_RUNTIME_CHECK
  androidx.media3.exoplayer.ExoPlaybackException: Unexpected runtime error
      at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:635)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loopOnce(Looper.java:202)
      at android.os.Looper.loop(Looper.java:291)
      at android.os.HandlerThread.run(HandlerThread.java:67)
  Caused by: java.lang.IllegalArgumentException: index=-1
      at androidx.media3.common.util.Assertions.checkArgument(Assertions.java:55)
      at androidx.media3.extractor.text.webvtt.WebvttSubtitle.getEventTime(WebvttSubtitle.java:62)
      at androidx.media3.extractor.text.SubtitleOutputBuffer.getEventTime(SubtitleOutputBuffer.java:56)
      at androidx.media3.exoplayer.text.TextRenderer.getCurrentEventTimeUs(TextRenderer.java:435)
      at androidx.media3.exoplayer.text.TextRenderer.render(TextRenderer.java:268)
      at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1008)
      at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:509)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loopOnce(Looper.java:202)
      at android.os.Looper.loop(Looper.java:291)
      at android.os.HandlerThread.run(HandlerThread.java:67)
]
```

#minor-release

PiperOrigin-RevId: 492464180
2022-12-12 11:05:49 +00:00
michaelkatz
2fd38e3912 Removed ExoPlayer specific states from SimpleBasePlayer
PiperOrigin-RevId: 492443147
2022-12-12 11:04:44 +00:00
tonihei
ca4c6efdb7 Write media type with a custom key to legacy components.
This allows legacy media controllers and browsers to access this
information and legacy sessions and browser services to set this
information.

PiperOrigin-RevId: 492414716
2022-12-12 11:02:38 +00:00
kimvde
85c48c481e Make sure that the sample pipeline data is processed regularly.
This is necessary to move video decoding to the AssetLoader. Otherwise,
if the decoder max pending frame count is reached, the AssetLoader will
stop queuing frames to the pipeline, and process data will not be called
anymore.

PiperOrigin-RevId: 492392621
2022-12-12 11:01:36 +00:00
samrobinson
d711bf7b24 Merge feedXFromInput and feedXFromSilence in ATSP.
PiperOrigin-RevId: 492195931
2022-12-12 11:00:31 +00:00
christosts
f768ff970c Reduce log output for failing bitmap loads
Do not log the exception stack traces raised by the BitmapLoader when a
bitmap fails to load, e.g. when the artwork's URI scheme is not
supported by the SimpleBitmapLoader. The logs are kept in place but only
a single line is printed.

#minor-release

PiperOrigin-RevId: 492191461
2022-12-12 10:58:23 +00:00
ibaker
e4fb663b23 Split SubripDecoder and ParsableByteArray tests
In some cases we split a test method, and in other cases we just add
line breaks to make the separation between arrange/act/assert more
clear.

PiperOrigin-RevId: 492182769
2022-12-12 10:57:18 +00:00
Ian Baker
a919141805 Merge pull request #10750 from Stronger197:subrip_utf_16
PiperOrigin-RevId: 492164739
2022-12-12 10:55:15 +00:00
samrobinson
e5727a2cc7 Add an E2E test for changing sample rate with AudioProcessor.
PiperOrigin-RevId: 492160193
2022-12-12 10:54:06 +00:00
samrobinson
0993479efe Add an option to force a silent audio track.
PiperOrigin-RevId: 492154544
2022-12-12 10:53:06 +00:00
kimvde
c5dc5aeb11 Fix gradle build
Add required import for
androidx.window.java.layout.WindowInfoTrackerCallbackAdapter

PiperOrigin-RevId: 492131661
2022-12-12 10:51:03 +00:00
tonihei
f007238745 Add support for most setters in SimpleBasePlayer
This adds the forwarding logic for most setters in SimpleExoPlayer
in the same style as the existing logic for setPlayWhenReady.

This change doesn't implement the setters for modifying media items,
seeking and releasing yet as they require additional handling that
goes beyond the repeated implementation pattern in this change.

PiperOrigin-RevId: 492124399
2022-12-12 10:50:12 +00:00
tonihei
32fafefae8 Add media type to MediaMetadata
This helps to denote what type of content or folder the metadata
describes.

PiperOrigin-RevId: 492123690
2022-12-12 10:49:15 +00:00
claincly
65fe41bc2c Fix Samsung MediaCodec encoder reports incorrect timestmp in EOS
PiperOrigin-RevId: 492023573
2022-12-12 10:48:08 +00:00
rohks
c7aa54cb41 Parse and set bitrates in Ac3Reader
PiperOrigin-RevId: 492003800
2022-12-12 10:47:12 +00:00
huangdarwin
19b4b310fa Transformer: Move getMaxPendingFrameCount logic to constructor.
Also, use the mediaCodecName passed into the constructor to get the
maxPendingFrameCount.

PiperOrigin-RevId: 491985044
2022-12-12 10:46:13 +00:00
Googler
69093db7f5 Decomission ControllerInfoProxy in favor of ControllerInfo.
This CL makes it possible to create a media3 ControllerInfo in test code, which is needed to test several aspects of a media3-based media app. It does this by exposing a test-only static factory method. This is a hacky low-effort approach; a better solution could be to split ControllerInfo up into a public interface that was exposed to client logic, and that they could extend, and a package-private implementation with internal fields like the callback. That's a much bigger change, however.

PiperOrigin-RevId: 491978830
2022-12-12 10:45:07 +00:00
Googler
46b4ebc7b6 Make PlayerView fold aware
PiperOrigin-RevId: 491963883
2022-12-12 10:44:02 +00:00
claincly
7dee3aec51 Add function to clear the cached list of encoders
EncoderUtil using a static list to cache encoders means it's not possible to
use a different set of encoders for different tests when running all
robolectric tests together.

PiperOrigin-RevId: 491959350
2022-12-12 10:43:03 +00:00
kimvde
eecf7caed0 Move audio decoding to AssetLoader
PiperOrigin-RevId: 491933937
2022-12-12 10:42:04 +00:00
tonihei
ff7fe222b8 Rename SimpleBasePlayer.PlaylistItem to MediaItemData
This better matches the terminology we use elsewhere in the Player
interface, where items inside the playlist are referred to as
"media item" and only the entire list is called "playlist".

PiperOrigin-RevId: 491882849
2022-12-12 10:41:05 +00:00
bachinger
2a07a0b445 Use the artist as the subtitle of the legacy media description
The Bluetooth AVRCP service expects the metadata of the item currently
being played to be in sync with the corresponding media description in
the active item of the queue. The comparison expects the metadata values
of `METADATA_KEY_TITLE` and `METADATA_KEY_ARTIST` [1] to be equal to the
`title` and `subtitle` field of the `MediaDescription` [2] of the
corresponding queue item.

Hence we need to populate the media description accordingly to avoid the
BT service to delay the update for two seconds and log an exception.

[1] https://cs.android.com/android/platform/superproject/+/master:packages/modules/Bluetooth/android/app/src/com/android/bluetooth/audio_util/helpers/Metadata.java;l=120
[2] https://cs.android.com/android/platform/superproject/+/master:packages/modules/Bluetooth/android/app/src/com/android/bluetooth/audio_util/MediaPlayerWrapper.java;l=258

Issue: androidx/media#148
PiperOrigin-RevId: 491877806
2022-12-12 10:39:58 +00:00
tofunmi
c5a763e150 Add the processor, GLEffect, texture and bitmap overlays
Implements milestone 1.1 of the [overlays implementation plan](https://docs.google.com/document/d/1EcP2GN8k8N74hHZyD0KTqm9oQo5-W1dZMqIVyqVGtlo/edit#bookmark=id.76uzcie1dg9d)

PiperOrigin-RevId: 491696361
2022-12-12 10:38:59 +00:00
huangdarwin
1aba245a30 HDR: Limit Z Fold 4 c2.qti decoder pending frame count.
Bypass Z Fold 4 HDR10 tone-mapping bug by limiting the max frame count to 12.

This passed with a value of 14, and failed with a value of 15, but I figured I'd use 12 just to be safe.

PiperOrigin-RevId: 491684058
2022-12-12 10:37:55 +00:00
rohks
f3e450e783 Add public constructors to DefaultMediaNotificationProvider
Issue: androidx/media#213

Without a public constructor, it is not possible to extend this class and override its method.

PiperOrigin-RevId: 491673111
2022-11-29 18:54:38 +00:00
samrobinson
a8e9d158cd Change TransformerInternal durationMs to durationUs.
Follow-up CLs will use this duration for silent audio.

PiperOrigin-RevId: 491670359
2022-11-29 18:53:28 +00:00
claincly
4033013ff8 Move audio MIME type fallback away to ATSP
PiperOrigin-RevId: 491660842
2022-11-29 18:52:17 +00:00
christosts
d12afe0596 Use audio bitrate to calculate AudioTrack min buffer in passthrough
Use the bitrate of the audio format (when available) in
DefaultAudioSink.AudioTrackBufferSizeProvider.getBufferSizeInBytes() to
calculate accurate buffer sizes for direct (passthrough) playbacks.

#minor-release

PiperOrigin-RevId: 491628530
2022-11-29 18:50:25 +00:00
kimvde
09df56f31a Move sample processing to transformer thread
PiperOrigin-RevId: 491623586
2022-11-29 18:49:15 +00:00
tonihei
568fa1e1fa Add configuration to support OPUS offload
To support OPUS offload, we need to provide a few configuration values
that are currently not set due to the lack of devices supporting
OPUS offload.

PiperOrigin-RevId: 491613716
2022-11-29 18:48:04 +00:00