1740 Commits

Author SHA1 Message Date
tonihei
6c98f238e4 Add error messages to correctness assertions in SimpleBasePlayer
Users of this class may run into these assertions when creating the
State and they need to check the source code to understand why
the State is invalid. Adding error messages to all our correctness
assertions helps to understand the root cause more easily.

PiperOrigin-RevId: 496875109
2022-12-21 15:35:50 +00:00
kimvde
a4c3038b16 Simplify AssetLoader.Listener interface
Replace onTrackRegistered and onAllTracksRegistered with onTrackCount.

PiperOrigin-RevId: 496853037
2022-12-21 15:34:58 +00:00
huangdarwin
06ccb6e8ed HDR: Use SDR settings for gamma 2.2 in createEglSurface
PiperOrigin-RevId: 496768072
2022-12-21 15:33:51 +00:00
huangdarwin
99b665ca3f HDR: Add Transformer GL tone mapping test.
PiperOrigin-RevId: 496727803
2022-12-21 15:32:50 +00:00
claincly
cb0bc28af2 Simplify concurrency in FrameProcessingTaskExecutor
This CL replaces concurrent collections and atomic primitives with a single
lock, this way the code is easier to reason about.

PiperOrigin-RevId: 496718057
2022-12-21 15:32:00 +00:00
huangdarwin
84c81b8575 HDR: Implement Transformer HDR to SDR GL tone-mapping API
Note that we simply use GlEffectsFrameProcessor in-app / GL tone-mapping, so PQ->SDR tone-mapping isn't yet implemented.

Tested manually using the demo on Pixel 7, to confirm that device and in-app tone
mapping behave similarly.

PiperOrigin-RevId: 496700231
2022-12-21 15:30:54 +00:00
steveanton
9465fe2f98 Add low level audio mixing algorithms
Adds the AudioMixerAlgorithm interface which allows for specialized
implementations of audio mixing that also efficiently convert between
source and mixing formats.

Initial implementation has two algorithms:
1. Float -> float (with channel mixing)
2. S16 -> float (with channel mixing)

PiperOrigin-RevId: 496686805
2022-12-21 15:29:47 +00:00
ibaker
d8c964cfe6 Document the relationship between Player methods and available commands
#minor-release

PiperOrigin-RevId: 496668378
2022-12-21 15:28:56 +00:00
tofunmi
81ffe47b23 Create local fallbackDetails to remove checkNotNull.
PiperOrigin-RevId: 496664711
2022-12-21 15:27:49 +00:00
ibaker
31e875b7a0 Clarify some Player command and method javadoc
#minor-release

PiperOrigin-RevId: 496661152
2022-12-21 15:26:38 +00:00
tofunmi
e1775eeb21 Add fallback details to analysis json.
PiperOrigin-RevId: 496660388
2022-12-21 15:25:48 +00:00
kimvde
97e49ac312 Make AssetLoader progress not Transformer specific
To do that, rename PROGRESS_STATE_NO_TRANSFORMATION to
PROGRESS_STATE_NOT_STARTED and update Javadoc of ProgressState to not be
Transformer specific.

PiperOrigin-RevId: 496653460
2022-12-21 15:24:47 +00:00
tianyifeng
d848d3358a Add BitmapLoader injection in MediaController
Also clean up the strict mode violations of using `BitmapFactory.convertToByteArray` on the main thread.

PiperOrigin-RevId: 496422355
2022-12-21 15:23:38 +00:00
andrewlewis
0744a52b8d Fix local asset naming
PiperOrigin-RevId: 496410502
2022-12-21 15:22:27 +00:00
ibaker
14947539e5 Remove TODO from ControllerInfo - the existing approach is fine
PiperOrigin-RevId: 496398934
2022-12-21 15:21:37 +00:00
huangdarwin
b8f88a8bae HDR: Use local instead of remote file for testing.
This should allow us to focus on HDR failures instead of network buffering
failures when debugging HDR issues.

These files are each used on several files, so it should be more worth the
test binary impact to move these files to local first.

Locally, tests did take less time after this diff

PiperOrigin-RevId: 496398130
2022-12-21 15:20:29 +00:00
kimvde
f7f6e25392 Move setMediaSourceFactory to ExoPlayerAssetLoader
The MediaSourceFactory won't be used by the other AssetLoaders

In order to do that, ExoPlayerAssetLoader has been made public, and the
DefaultAssetLoaderFactory has become a wrapper around
ExoPlayerAssetLoader.

PiperOrigin-RevId: 496386853
2022-12-21 15:19:26 +00:00
tofunmi
3708a4f13e Create dynamically created shaders for multiple overlays.
PiperOrigin-RevId: 496379904
2022-12-21 15:18:26 +00:00
ibaker
aae6941981 Fix Dackka error due to param name mismatch
https://developer.android.com/reference/androidx/leanback/media/PlayerAdapter#seekTo(long)

#minor-release

PiperOrigin-RevId: 496378709
2022-12-21 15:17:34 +00:00
ibaker
f0696f9572 Remove ellipsis from Player javadoc
PiperOrigin-RevId: 496377192
2022-12-21 15:16:34 +00:00
tonihei
5fa115641d Add playlist and seek operations to SimpleBasePlayer
These are the remaining setter operations. They all share the same
logic that handles playlist and/or position changes. The logic to
create the placeholder state is mostly copied from ExoPlayerImpl's
maskTimelineAndPosition and getPeriodPositonUsAfterTimelineChanged.

PiperOrigin-RevId: 496364712
2022-12-21 15:14:33 +00:00
tonihei
8ee8910788 Rollback of 7e63997459
*** Original commit ***

Add TransformerTestBuilderFactory to make transformer testable by apps

***

PiperOrigin-RevId: 496342997
2022-12-21 15:13:24 +00:00
tonihei
a974e60379 Rollback of 8a24209fd6
*** Original commit ***

Remove extra colons in `build.gradle`s

modulePrefix should include this already.

***

PiperOrigin-RevId: 496337833
2022-12-21 15:12:32 +00:00
tonihei
0749b05923 Avoid sending periodic position updates while paused and not loading
The period updates were introduced to ensure the buffered position is
updated regularly and that any playback position drift is corrected.

None of these updates need to happen while the player is paused or
not loading and we can avoid the constant binder interactions.

PiperOrigin-RevId: 496329800
2022-12-21 15:11:28 +00:00
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