421 Commits

Author SHA1 Message Date
tonihei
ab6fc6a08d Forward seek command details to seekTo method in BasePlayer
BasePlayer simplifies implementations by handling all the various
seek methods and forwarding to a single method that can then be
implemented by subclasses. However, this loses the information about
the concrete entry point used for seeking, which is relevant when
the subclass wants to verify or filter by Player.Command. This
can be improved by adding the command as a new parameter. Since
we have to change the method anyway, we can also incorporate the
boolean flag about whether the current item is repeated to avoid
the separate method.

PiperOrigin-RevId: 494948094
2022-12-15 15:57:08 +00:00
claincly
8dbfa1d64d Clarify the size notification logic in MCVR
- Use a single `VideoSize` instance instead of four primitive fields.
- Clarify that the reported size is the decoded size, that is the encoded video
  size.

PiperOrigin-RevId: 494148190
2022-12-12 11:42:54 +00:00
tonihei
927b2d6a43 Clarify and correct allowed multi-threading for some Player methods
Some Player methods like getting the Looper and adding listeners
were always allowed to be called from any thread, but this is
undocumented. This change makes the threading rules of these
methods more explicit.

Removing listeners was never meant to be called from another thread
and we also don't support it safely because final callbacks may
be triggered from the wrong thread. To find potential issues, we
can assert the correct thread when releasing listeners.

Finally, there is a potential race condition when calling addListener
from a different thread at the same time as release, which may lead to
a registered listener that could receive callbacks after the player is
released.

PiperOrigin-RevId: 493843981
2022-12-12 11:38:06 +00:00
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
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
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
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
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
michaelkatz
2fd38e3912 Removed ExoPlayer specific states from SimpleBasePlayer
PiperOrigin-RevId: 492443147
2022-12-12 11:04:44 +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
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
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
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
ibaker
a6703285d0 Clean up javadoc on Metadata.Entry.populateMediaMetadata
Remove self-links, and remove section that is documenting internal
ordering behaviour of
[`SimpleBasePlayer.getCombinedMediaMetadata`](bb270c62cf/library/common/src/main/java/com/google/android/exoplayer2/SimpleBasePlayer.java (L1770))
rather than anything specifically about this method.

#minor-release

PiperOrigin-RevId: 490923719
2022-11-29 18:33:37 +00:00
huangdarwin
6443c4b6b9 HDR: Add COLOR_TRANSFER_LINEAR in C.java.
This is more clear than using Format.NO_VALUE, when we do actually intend for an
output value.

Also, fix @see formatting by using summary fragments instead, and add an error
output for OETF and EOTF transfer functions.

PiperOrigin-RevId: 490910229
2022-11-29 18:32:28 +00:00
bachinger
3d8c52f28d Exclude tracks from PlayerInfo if not changed
This change includes a change in the `IMediaController.aidl` file and needs
to provide backwards compatibility for when a client connects that is of an older or
newer version of the current service implementation.

This CL proposes to create a new AIDL method `onPlayerInfoChangedWithExtensions`
that is easier to extend in the future because it does use an `Bundle` rather than
primitives. A `Bundle` can be changed in a backward/forwards compatible way
in case we need further changes.

The compatibility handling is provided in `MediaSessionStub` and `MediaControllerStub`. The approach is not based on specific AIDL/Binder features but implemented fully in application code.

Issue: androidx/media#102
#minor-release
PiperOrigin-RevId: 490483068
2022-11-24 14:45:37 +00:00
samrobinson
10fac6847a Return output immediately if available from AudioProcessingPipeline.
If there is output data available (outputBuffer.hasRemaining()), then
there is no need to move other data between the underlying processors.
It will not change the buffer being returned by that call to getOutput.

If there is no output data readily available, it's necessary to go to
the AudioProcessors and pass buffers between them, as this may produce
data for output.

PiperOrigin-RevId: 490482653
2022-11-24 14:44:40 +00:00
samrobinson
af1d7b9b1b Fix SpeedChangingAudioProcessor handling of EMPTY_BUFFER.
PiperOrigin-RevId: 490265564
2022-11-24 14:36:14 +00:00
michaelkatz
4ea72f0c73 Version bump to exoplayer:2.18.2 and media3:1.0.0-beta03
#minor-release

PiperOrigin-RevId: 489959918
2022-11-22 10:09:12 +00:00
claincly
dba9d81640 Destroy eglSurface in FrameProcessor
Previously, FrameProcessor never had the usecase in which the output surface
is replaced, while previewing introduced this usecase.

When switching output surfaces, we need to destroy the EGL Surface linked to the
surface that is being swapped out, because an EGL surface is linked to the EGL
display (which is not destroyed even when releasing FrameProcessor).

A GL exception will be thrown in the following scenario if we don't destroy the
EGL surface:

1. Creates a Surface, the surface is identified by address 0x11
2. Sets Surface(0x11) on FrameProcessor. Eventually an EGL surface is created
  to wrap Surface(0x11)
3. Release FrameProcess, this releases the EGL context
4. Instantiate a new FrameProcessor, sets Surface(0x11) as the output
5. When FrameProcessor creates an EGL surface to wrap Surface(0x11), GL throws
  an exception, becasue Surface(0x11) has previouly been connected to an EGL
  surface.

PiperOrigin-RevId: 489590072
2022-11-22 10:06:58 +00:00
tonihei
81918d8da7 Add remaining state and getters to SimpleBasePlayer
This adds the full Builders and State representation needed to
implement all Player getter methods and listener invocations.

PiperOrigin-RevId: 489503319
2022-11-22 10:05:57 +00:00
kimvde
8a4f72b959 Make sure the AudioProcessors do not receive AP.EMPTY_BUFFER
PiperOrigin-RevId: 489174645
2022-11-22 09:51:22 +00:00
kimvde
7b874e2dee Fix audio slow motion flattening
PiperOrigin-RevId: 488981968
2022-11-22 09:49:11 +00:00
kimvde
1ee185cb10 Refactor transformation completion
PiperOrigin-RevId: 488929446
2022-11-22 09:44:47 +00:00
tonihei
1143edc59a Rename getVideoSurfaceSize to getSurfaceSize
This better matches the callback name (onSurfaceSizeChanged) and
probably cause less confusion with getVideoSize.

PiperOrigin-RevId: 488669786
2022-11-16 12:15:05 +00:00
christosts
491b13622e Set valid channel masks for 8 and 12 channels on all Android versions
Util.getAudioTrackChannelConfig() maps a channel count to a
channel mask that is passed to AudioTrack. The method expected that
playback of 8-channel audio is possible from Android 5.1 and playback of
12-channel audio is only possible from Android 12L. However, there is no
restriction on the upper number of channels that can be passed to the
AudioTrack. google/ExoPlayer#10701 is an example where the audio decoder
outputs 12 channels on an Android 10.

This change removes the restrictions for 8 and 12 channels. Note, we still
do not support playback of arbitrary number of channels as it would require
further changes to DefaultAudioSink.

#minor-release

Issue: google/ExoPlayer#10701
PiperOrigin-RevId: 488659831
2022-11-16 12:14:03 +00:00
tonihei
1def68bf3c Mark iterationFinished when triggering release event.
When we currently trigger the iteration finished event during the
release, we don't mark the event as triggered. This means that
someone can trigger another release from within the callback,
which then tries to resend the event.

Issue: google/ExoPlayer#10758

#minor-release

PiperOrigin-RevId: 488645089
2022-11-16 12:12:47 +00:00
samrobinson
59aedcf309 Handle buffers in DefaultAudioSink with AudioProcessingPipeline.
PiperOrigin-RevId: 488412695
2022-11-16 12:07:58 +00:00
huangdarwin
84a378415f GL: Rename getEglSurface to createEglSurface.
Per documentation, eglCreateWindowSurface creates a new EGL window surface.

getEglSurface suggests instead that a pre-existing surface is returned.

https://registry.khronos.org/EGL/sdk/docs/man/html/eglCreateWindowSurface.xhtml

PiperOrigin-RevId: 488377423
2022-11-14 18:04:04 +00:00
Googler
4271056545 Add 'Player.getVideoSurfaceSize' that returns the size of the surface
on which the video is rendered.

Design Doc: go/aaos-mu-media-dd

PiperOrigin-RevId: 485884772
2022-11-08 11:25:43 +00:00
samrobinson
e6079c38f2 Add AudioProcessor.AudioFormat equals method.
PiperOrigin-RevId: 483983486
2022-10-31 11:38:26 +00:00
samrobinson
7fcb53da2d Move DefaultAudioSink.AudioProcessorChain to AudioProcessorChain
Split inner interface into separate file, which will go in common
module. The old interface will be deprecated and extends the new.

#cleanup

PiperOrigin-RevId: 483732226
2022-10-31 11:35:32 +00:00
samrobinson
fc34542864 Move AudioProcessor to common.
PiperOrigin-RevId: 483699606
2022-10-31 11:34:30 +00:00
claincly
be7bb0eea4 Add GL utility methods to get 4x4 identity and set identity
PiperOrigin-RevId: 483671580
2022-10-31 11:33:30 +00:00
bachinger
c21c486ec6 Add DAI specific methods to AdPlaybackState
PiperOrigin-RevId: 482755468
2022-10-24 10:50:38 +00:00
Googler
2c61dd9c95 Corrected ordering of javadoc params
PiperOrigin-RevId: 482231370
2022-10-24 10:45:31 +00:00
huangdarwin
bb215857e5 HDR: Support RGBA_1010102 in GlUtil as a parameter.
Make it easier to support use of RGBA_101012 rather than RGBA_8888 for EGL
contexts, displays, and surfaces.

This tangentially supports adding HDR tests, by slightly simplifying the color
selection logic we'd have to add in HDR tests.

PiperOrigin-RevId: 482219428
2022-10-24 10:43:40 +00:00
tonihei
f850206c51 Ensure onMediaItemTransition is sent for repeats of the same item
Currently, repeating the same item (via seekNext/Previous) implicitly
results in a seek to the default position of the current item, which
looks exactly the same as a direct seek. As a result, we don't send
onMediaItemTransition as we would for every other seekNext/Previous
call.

This can be fixed by explicitly marking the repeat case in the internal
BasePlayer/ExoPlayerImpl methods, so that the callback can be triggered.

Issue: google/ExoPlayer#10667
PiperOrigin-RevId: 481951788
2022-10-24 10:35:19 +00:00
huangdarwin
93ee1f48ad GL: Move loadAsset to GlProgram, where it's used.
(Also, make some public methods private)

PiperOrigin-RevId: 481912071
2022-10-24 10:33:35 +00:00
claincly
a426cb27c0 Remove late frame dropping in FrameProcessor
Currently, a frame is dropped if it's requested release time is in the past.
This mode was added to support previewing. However, in normal ExoPlayer
playback, slightly late frames (<30ms late) are also rendered. On MediaCodec
side, this means calling `releaseOutputBuffer` with a release time in the
past.

PiperOrigin-RevId: 479615291
2022-10-17 15:41:25 +00:00
huangdarwin
8548e3519e HDR: Disable tone mapping on unsupported pixel build ID.
Also, update tests to allow AnyOf error codes, and no longer check exception messages, which caused quite a bit of churn.

PiperOrigin-RevId: 479570861
2022-10-17 15:38:30 +00:00
claincly
26be9ae885 Add a FrameProcessor flag to drop the processed frame
This mode is supported by using `C.TIME_UNSET` (which is a negative value). The
new logic decouples the value of `C.TIME_UNSET` and the frame dropping
behaviour.

PiperOrigin-RevId: 479368880
2022-10-17 15:36:29 +00:00
tonihei
b70258e43d Fix RequestMetadata JavaDoc link to point to the right MediaController.
The JavaDoc of RequestMetadata should point to the media3 controller,
not the platform one.

PiperOrigin-RevId: 479047924
2022-10-17 15:32:22 +00:00
claincly
139a6e8d31 Add FrameProcessor functionality to release a frame immediately
Currently `FrameProcessor.releaseOutputFrame()` method supports

Release at a specific system time
Drops the frame
This API is not that convenient to use when the caller wants to release a frame, now, regardless of the release time. A use case is to release (present) a frame when no frame is shown for a while, and it's thus better to just release the frame, now.

Currently if MCVR wants a frame to be rendered now, MCVR calls release frame with a set offset like 10us: `releaseOutputFrame(System.nanoTime() + 10_000)`. The 10us offset is to prevent the frame processor dropping the frame, due to thread hopping delays.

To make the API better usable, consider adding a mode for releasing the frame now, like (bold marks the new mode)

- Use C.TIME_UNSET to drop
- **Use -1 to release the frame immediately, or**
- Use an actual release time.

PiperOrigin-RevId: 479044215
2022-10-17 15:31:34 +00:00
yschimke
278853a2a1 Add suppression reason for unsuitable audio route.
A follow up to stopping speaker playback with a Player decorator from
https://github.com/androidx/media/issues/15.

It looks like we will need to change to using playback suppression to avoid
errors like https://github.com/androidx/media/issues/167, when we don't start
a foreground service.

We may not have this implemented by 1.0, but would like it in the API and it seems to be appropriate.

PiperOrigin-RevId: 478835686
2022-10-17 15:29:26 +00:00
huangdarwin
de82a2be33 Effect: Update javadoc to remove "final effect" references
"Final" was likely added to reference the FinalMatrixTextureProcessorWrapper,
which is a package-private class. However, I think more clear to express that
this is the input size, which then has all effects applied, to get the output
size.

PiperOrigin-RevId: 477975358
2022-09-30 18:33:50 +00:00