2016 Commits

Author SHA1 Message Date
claincly
1f4d8dd778 Support previewing HDR on API33+
FrameProcessor already support using different transfer function for input and
output color. This CL has two major changes:

- Create an eglSurface that recognizes BT.2020 PQ
  - This requires a separate extension that works only after 33
  - So we current throw, if input is HDR, and this extension doesn't work
- Create FrameProcessor with PQ output transfer function

PiperOrigin-RevId: 496023758
2022-12-21 15:10:20 +00:00
tonihei
49ccfd6383 Check if codec still exists before handling tunneling events
The tunneling callbacks are sent via Handler messages and may be
handled after the codec/surface was changed or released.

We already guard against the codec/surface change condition by
creating a new listener and verifying that the current callback
happens for the correct listener instance, but we don't guard
against a released codec yet.

PiperOrigin-RevId: 495882353
2022-12-21 15:09:30 +00:00
samrobinson
def6ca581e Make clear video encoder HighQualityTargeting is experimental.
PiperOrigin-RevId: 495860300
2022-12-21 15:08:24 +00:00
tonihei
a1954f7e0a Clarify behavior for out-of-bounds indices and align implementations
Some Player methods operate relative to existing indices in the
playlist (add,remove,move,seek). As these operations may be issued
from a place with a stale playlist (e.g. a controller that sends
a command while the playlist is changing), we have to handle out-
of-bounds indices gracefully. In most cases this is already
documented and implemented correctly. However, some cases are not
documented and the existing player implementations don't handle
these cases consistently (or in some cases not even correctly).

PiperOrigin-RevId: 495856295
2022-12-21 15:07:20 +00:00
andrewlewis
8a24209fd6 Remove extra colons in build.gradles
modulePrefix should include this already.

PiperOrigin-RevId: 495853065
2022-12-21 15:06:29 +00:00
rohks
3e7f53fda7 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 15:05:30 +00:00
samrobinson
8d15116478 Pass required value into TransformationTestResult.Builder constructor
PiperOrigin-RevId: 495842393
2022-12-21 15:04:23 +00:00
tofunmi
7e63997459 Add TransformerTestBuilderFactory to make transformer testable by apps
PiperOrigin-RevId: 495821660
2022-12-21 15:03:31 +00:00
claincly
6376f5f7c7 Replace Pair with Size in effects.
PiperOrigin-RevId: 495646341
2022-12-21 15:02:20 +00:00
bachinger
22dfd4cb32 Use theme when loading drawables on API 21+
Issue: androidx/media#220
PiperOrigin-RevId: 495642588
2022-12-21 15:01:09 +00:00
rohks
d11e0a35c1 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:00:15 +00:00
samrobinson
63cc0338e1 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 16:15:40 +00:00
claincly
a09bdfe995 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 16:14:41 +00:00
claincly
967d448a1e Apply frame release time adjustment in preview mode
PiperOrigin-RevId: 495471548
2022-12-15 16:13:50 +00:00
claincly
b3571b71b5 Make Codec release frames to frame processor.
PiperOrigin-RevId: 495406734
2022-12-15 16:13:00 +00:00
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
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
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