16848 Commits

Author SHA1 Message Date
huangdarwin
a66dae8bfa HDR: Implement GlEffectsFrameProcessor HLG to SDR tone-mapping.
Adds COLOR_TRANSFER_GAMMA_2_2, to match behavior in other HDR to SDR tone mapping
implementations.

PiperOrigin-RevId: 495371736
2022-12-15 16:11:42 +00:00
claincly
9ba03db704 Create frame processor in MCVR
PiperOrigin-RevId: 495368262
2022-12-15 16:10:48 +00:00
tonihei
545fa59462 Allow unset index and position values + remove period index
This simplifies some position tracking needs for an app implementing
SimpleBasePlayer.
 - The period index can always be derived from the media item index
   and the position. So there is no need to set it separately.
 - The media item index can be left unset in the State in case the app
   doesn't care about the value or wants to set it the default start
   index (e.g. while the playlist is still empty where UNSET is
   different from zero).
 - Similarly, we should allow to set the content position (and buffered
   position) to C.TIME_UNSET to let the app ignore it or indicate the
   default position explictly.

PiperOrigin-RevId: 495352633
2022-12-15 16:09:51 +00:00
tonihei
a123134892 Clear one-off events from state as soon as they are triggered.
This ensures they are not accidentally triggered again when
the state is rebuilt with a buildUpon method.

PiperOrigin-RevId: 495280711
2022-12-15 16:08:56 +00:00
kimvde
21ae403049 Pass CapturingDecoderFactory to AssetLoader
Otherwise, the decoders are not captured. It works at the moment for the
video decoder because decoding is still done on the sample pipeline but
it will moved to the AssetLoader soon.

PiperOrigin-RevId: 495275575
2022-12-15 16:08:08 +00:00
andrewlewis
c9e87f0503 Fix some release notes typos
PiperOrigin-RevId: 495262344
2022-12-15 16:07:11 +00:00
andrewlewis
f2cf952f68 Output direct buffers from SilentAudioGenerator
`AudioProcessor`s expect direct buffers. This shouldn't make any functional difference in our code, but a custom audio processor might try to access the buffer from JNI in which case a direct byte buffer is more efficient.

PiperOrigin-RevId: 495241669
2022-12-15 16:06:15 +00:00
andrewlewis
3060b97180 Take format for SilentAudioGenerator
This simplifies the caller slightly.

PiperOrigin-RevId: 495234339
2022-12-15 16:05:17 +00:00
claincly
b1425aa6f4 Fix method name to return all encode-able MIME types
PiperOrigin-RevId: 495093939
2022-12-15 16:04:28 +00:00
rohks
395cf4debc Remove parameters with default values from bundle in MediaItem
This improves the time taken to construct PlayerInfo from bundle from ~600ms to ~450ms.

PiperOrigin-RevId: 495055355
2022-12-15 16:03:32 +00:00
claincly
62b3a39b8e Use Size in MSG_SET_VIDEO_OUTPUT_RESOLUTION.
PiperOrigin-RevId: 495055151
2022-12-15 16:02:42 +00:00
rohks
610e431c90 Document the reason for defining private method defaultIfNull
PiperOrigin-RevId: 495004732
2022-12-15 16:01:53 +00:00
kimvde
5759eda37e Add AssetLoader.Factory
This is so that apps can customise AssetLoader

PiperOrigin-RevId: 494998497
2022-12-15 16:00:55 +00:00
andrewlewis
beee4732fb Generate complete silent audio frames
`SilentAudioGenerator` could output a fractional audio frame, and this could cause downstream components to throw because of trying to read a complete audio frame but only seeing a partial one.

Calculate the output buffer size based on the frame size (which is a no-op for stereo 16-bit audio) and calculate a total number of frames to output then multiple by the frame size.

PiperOrigin-RevId: 494992941
2022-12-15 15:58:50 +00:00
tonihei
6e7de583bb Reset isLoading when calling SimpleBasePlayer.stop/release
isLoading is not allowed to be true when IDLE, so we have to set to
false when stopping in case it was set to true before.

PiperOrigin-RevId: 494975405
2022-12-15 15:57:59 +00:00
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
samrobinson
6c7e892d2f Add codec names to TransformationResult
PiperOrigin-RevId: 494736085
2022-12-15 15:56:02 +00:00
samrobinson
36e52691bb Move SetFrameEditTest into TransformationTest.
PiperOrigin-RevId: 494651985
2022-12-12 11:45:45 +00:00
kimvde
c8d8ff5578 Add AssetLoader interface
This is a step towards allowing apps to inject a custom AssetLoader

PiperOrigin-RevId: 494185078
2022-12-12 11:44:50 +00:00
samrobinson
be080f22ae Add handling for null input buffer in DefaultAudioSink processBuffers.
#minor-release

PiperOrigin-RevId: 494166943
2022-12-12 11:43:52 +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
tofunmi
6b15ace9aa Fix bugs in DrawableOverlay.java.
calls setbounds() on the drawable as the bounds of a drawable must be set for the .draw() method to work as noted in the [Drawable Documentation](https://developer.android.com/reference/android/graphics/drawable/Drawable#draw(android.graphics.Canvas)).

Also fixes createStaticDrawableOverlay() not taking specified overlay settings into account.

PiperOrigin-RevId: 494116077
2022-12-12 11:42:00 +00:00
kimvde
cda969985e Make input media duration volatile
The duration in TransformerInternal.ComponentListener is set on the
Transformer internal thread, and is read on the playback thread. Making
this field volatile ensures that the playback thread reads the updated
value.

PiperOrigin-RevId: 493908385
2022-12-12 11:41:05 +00:00
michaelkatz
d64a7ec55c Rollback of c5dc5aeb11
*** Original commit ***

Fix gradle build

Add required import for
androidx.window.java.layout.WindowInfoTrackerCallbackAdapter

***

PiperOrigin-RevId: 493907749
2022-12-12 11:40:08 +00:00
ibaker
481f3fa7c7 Rollback of 46b4ebc7b6
*** Original commit ***

Make PlayerView fold aware

***

PiperOrigin-RevId: 493846471
2022-12-12 11:39:02 +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
533f5288f4 Remove debug timeout multiplier.
It looks like this was added accidentally in <unknown commit>.

PiperOrigin-RevId: 493834134
2022-12-12 11:37:12 +00:00
claincly
c07bd76676 Add render messages for setting video output resolution
An AndroidTest is needed to test the message sending from ExoPlayerImpl to
a video renderer (MCVR in this case). The test will be added later.

PiperOrigin-RevId: 493602259
2022-12-12 11:35:02 +00:00
claincly
39ea5376e4 Rename surface to display surface for previewing.
PiperOrigin-RevId: 493557119
2022-12-12 11:34:03 +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
tofunmi
c7e9a0404f Replace hardcoded selectedEffects indices with public static finals.
PiperOrigin-RevId: 493543188
2022-12-12 11:30:59 +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
tofunmi
9010e8c368 Update demo transformer app with text overlay demo effect.
Implements milestone 1.4.2 of the [overlays implementation plan](https://docs.google.com/document/d/1EcP2GN8k8N74hHZyD0KTqm9oQo5-W1dZMqIVyqVGtlo/edit#bookmark=id.76uzcie1dg9d)

PiperOrigin-RevId: 493324764
2022-12-12 11:27:44 +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
49c49b34fb Update demo transformer app with bitmap overlay demo effect.
Implements milestone 1.4.1 of the [overlays implementation plan](https://docs.google.com/document/d/1EcP2GN8k8N74hHZyD0KTqm9oQo5-W1dZMqIVyqVGtlo/edit#bookmark=id.76uzcie1dg9d)

PiperOrigin-RevId: 493291813
2022-12-12 11:23:28 +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
samrobinson
ead7070b60 Add setter for some audio effects to demo app.
PiperOrigin-RevId: 493001630
2022-12-12 11:12:19 +00:00
samrobinson
991010f24c Add force silent audio to the transformer demo application.
Adds a modified version of sample.mp4 to the list, which has no audio.

PiperOrigin-RevId: 492993918
2022-12-12 11:11:19 +00:00