16333 Commits

Author SHA1 Message Date
andrewlewis
9b82d5317f Remove extra colons in build.gradles
modulePrefix should include this already.

PiperOrigin-RevId: 495853065
2022-12-21 16:13:05 +00:00
rohks
74559b4a18 Rename EMPTY_MEDIA_ITEM to PLACEHOLDER_MEDIA_ITEM
The `MediaItem` instances in the following cases are not actually empty but acts as a placeholder. `EMPTY_MEDIA_ITEM` can also be confused with `MediaItem.EMPTY`.

PiperOrigin-RevId: 495843012
2022-12-21 16:09:14 +00:00
samrobinson
aecc810937 Pass required value into TransformationTestResult.Builder constructor
PiperOrigin-RevId: 495842393
2022-12-21 16:05:22 +00:00
tofunmi
c566b77449 Add TransformerTestBuilderFactory to make transformer testable by apps
PiperOrigin-RevId: 495821660
2022-12-21 16:01:31 +00:00
claincly
4a3d693c3e Replace Pair with Size in effects.
PiperOrigin-RevId: 495646341
2022-12-21 15:57:19 +00:00
bachinger
33f8f40692 Use theme when loading drawables on API 21+
Issue: androidx/media#220
PiperOrigin-RevId: 495642588
2022-12-21 15:53:14 +00:00
rohks
8dea624c98 Remove parameters with null values from bundle in MediaMetadata
Improves the time taken to construct `playerInfo` from its bundle from ~450 ms to ~400 ms. Each `MediaItem` inside `Timeline.Window` contains `MediaMetadata` and hence is a good candidate for bundling optimisations. There already exists a test to check all parameters for null values when unset.

PiperOrigin-RevId: 495614719
2022-12-21 15:49:22 +00:00
samrobinson
e46b4c0fdc Create and return a TransformationResult regardless of success.
The TransformationResult has some useful values that are set in error
cases, such as the codecs used.

PiperOrigin-RevId: 495568259
2022-12-15 17:15:59 +00:00
claincly
c9e644b4f7 Allow changing output surface in previewing
It covers the following cases:

| From/To     | `null` | `surface 0` | `surface 1` |
|-------------|--------|-------------|-------------|
| `null`      | 🆖      | 📺           | 📺           |
| `surface 0` |       | 🔁           | 📺           |
| `surface 1` |       | 📺           | 🔁           |

Where
- 🆖 means NOP
-  means
  - Set `null` on FrameProcessor, effectively dropping all frames
- 📺 means
  - Notify the listener of video size
  - Set FrameProcessor output surface and size when MSG_SET_VIDEO_OUTPUT_SIZE is received
- 🔁 means
  - Notify the listener of video size

PiperOrigin-RevId: 495477620
2022-12-15 17:11:56 +00:00
claincly
d5ae76870e Apply frame release time adjustment in preview mode
PiperOrigin-RevId: 495471548
2022-12-15 17:07:59 +00:00
claincly
678b29c10d Make Codec release frames to frame processor.
PiperOrigin-RevId: 495406734
2022-12-15 17:03:52 +00:00
huangdarwin
b836212b39 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:59:52 +00:00
claincly
4398af3a4d Create frame processor in MCVR
PiperOrigin-RevId: 495368262
2022-12-15 16:55:45 +00:00
tonihei
91557ac9d4 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:51:50 +00:00
tonihei
fa5aaf958d 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:47:58 +00:00
kimvde
254842b782 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:44:04 +00:00
andrewlewis
58242e6caf 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:40:09 +00:00
andrewlewis
eb95362029 Take format for SilentAudioGenerator
This simplifies the caller slightly.

PiperOrigin-RevId: 495234339
2022-12-15 16:36:15 +00:00
claincly
42f0850fa5 Fix method name to return all encode-able MIME types
PiperOrigin-RevId: 495093939
2022-12-15 16:32:18 +00:00
rohks
7de47fe2a1 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:28:30 +00:00
claincly
d77ceaacc4 Use Size in MSG_SET_VIDEO_OUTPUT_RESOLUTION.
PiperOrigin-RevId: 495055151
2022-12-15 16:24:39 +00:00
rohks
c3ca71fda7 Document the reason for defining private method defaultIfNull
PiperOrigin-RevId: 495004732
2022-12-15 16:20:47 +00:00
kimvde
339ce4fced Add AssetLoader.Factory
This is so that apps can customise AssetLoader

PiperOrigin-RevId: 494998497
2022-12-15 16:17:00 +00:00
andrewlewis
c17c23d1f1 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 16:13:05 +00:00
tonihei
e4f0b73aa3 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 16:08:45 +00:00
tonihei
6e0f1f10b3 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 16:04:59 +00:00
samrobinson
03d6da8528 Add codec names to TransformationResult
PiperOrigin-RevId: 494736085
2022-12-15 16:01:01 +00:00
samrobinson
b18d34fc58 Move SetFrameEditTest into TransformationTest.
PiperOrigin-RevId: 494651985
2022-12-12 14:57:31 +00:00
kimvde
0c8c7eeebd Add AssetLoader interface
This is a step towards allowing apps to inject a custom AssetLoader

PiperOrigin-RevId: 494185078
2022-12-12 14:53:17 +00:00
samrobinson
26d75baaeb Add handling for null input buffer in DefaultAudioSink processBuffers.
#minor-release

PiperOrigin-RevId: 494166943
2022-12-12 14:48:58 +00:00
claincly
92bd4c6137 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 14:44:44 +00:00
tofunmi
7a95e08b09 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 14:40:38 +00:00
kimvde
1d0425e211 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 14:36:24 +00:00
michaelkatz
fd12fc1fb7 Rollback of 90d4fdcf0f
*** Original commit ***

Fix gradle build

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

***

PiperOrigin-RevId: 493907749
2022-12-12 14:32:14 +00:00
ibaker
221a56da38 Rollback of 749d77b1d9
*** Original commit ***

Make PlayerView fold aware

***

PiperOrigin-RevId: 493846471
2022-12-12 14:28:04 +00:00
tonihei
e9364b0f6e 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 14:23:55 +00:00
tonihei
f8e4e1765f Remove debug timeout multiplier.
It looks like this was added accidentally in <unknown commit>.

PiperOrigin-RevId: 493834134
2022-12-12 14:19:45 +00:00
claincly
e6bf908b5a 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 14:11:15 +00:00
claincly
03276d1eb0 Rename surface to display surface for previewing.
PiperOrigin-RevId: 493557119
2022-12-12 14:07:01 +00:00
tonihei
9d059352cf 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 14:02:52 +00:00
tonihei
3a66c28d4f 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 13:58:38 +00:00
tofunmi
01ff4e37c5 Replace hardcoded selectedEffects indices with public static finals.
PiperOrigin-RevId: 493543188
2022-12-12 13:54:17 +00:00
huangdarwin
e42a438a3d Transformer: Always initialize presentationTime in VTSP.
This shouldn't really have anything to do with HDR.

PiperOrigin-RevId: 493357915
2022-12-12 13:45:31 +00:00
tofunmi
c513c138f2 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 13:41:11 +00:00
huangdarwin
e9a3077371 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 13:36:56 +00:00
kimvde
5277171d0b Move slow mo video flattening to AssetLoader
PiperOrigin-RevId: 493300556
2022-12-12 13:32:46 +00:00
kimvde
8d655e1267 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 13:28:30 +00:00
tofunmi
e85e343681 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 13:24:14 +00:00
tofunmi
05c84a6795 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 13:19:58 +00:00
tofunmi
369f9bae43 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 13:15:47 +00:00