735 Commits

Author SHA1 Message Date
hschlueter
de4c2e08e1 Move FrameProcessor and related interfaces to common.
This will allow effects preview in ExoPlayer to use the
Effect and FrameProcessor interface (and the interfaces
they depend on) without depending on transformer or the
future effects module.

PiperOrigin-RevId: 464060047
(cherry picked from commit 480c129c54777780f298d7e5dbd9fa23a371f660)
2022-07-29 12:54:30 +00:00
leonwind
1b5e3ceb32 Add slider option for contrast in demo app
PiperOrigin-RevId: 464050072
(cherry picked from commit 3fae9df8a9a1ab844d65a2336fc75a57e53d78d2)
2022-07-29 11:30:44 +00:00
hschlueter
6e390771a0 Add Effect marker interface.
This allows non-GL effects to be passed to custom FrameProcessor
implementations.

PiperOrigin-RevId: 463696384
(cherry picked from commit 580e44fc47ec5b62da5a133d12048a20d716e94f)
2022-07-27 22:40:20 +00:00
hschlueter
4001e699a1 Replace Size with Pair in effects.
Size requires API 21. Using Pair instead will allow effects to be
used from API 18 during previewing once they are moved out of
transformer.

PiperOrigin-RevId: 463206474
(cherry picked from commit 4adf19939839baa3eaf018fef0d1b58049fd3b91)
2022-07-25 23:39:59 +00:00
hschlueter
9eeb4bc272 Allow stream offset passed to GlEffectsFrameProcessor to change.
This is needed for applying effects to a playlist.

The effects are applied based on the presentation time of the
frame in its corresponding media item and the offset is added
back before encoding.

Each time the offset changes, end of input stream is signalled
to the texture processors. This is needed because the texture
processors can expect monotonically increasing timestamp within
the same input stream but when the offset changes, the timstamps
jump back to 0.

PiperOrigin-RevId: 462714966
(cherry picked from commit 30e5bc9837e2423cd2bb426c5797211e0f6ad76b)
2022-07-22 22:18:55 +00:00
bachinger
9cf85c5574 Enable subtitle selection in session demo app
Issue: androidx/media#102
#minor-release
PiperOrigin-RevId: 462391045
(cherry picked from commit 7fa3f99304b3cfbfaf35acd2017eb71db68faafa)
2022-07-21 15:34:46 +00:00
huangdarwin
06d3c07a1c HDR: Implement HLG EOTF and OETF.
This allows us to use BT.2020 RGB linear for intermediate shaders, which also
allows us to re-enable PeriodicVignetteProcessor, which should work properly in
linear color-spaces.

Manually tested by adding a GlEffectsWrapper, and confirming that HLG HDR editing still looks correct.

PiperOrigin-RevId: 462265821
(cherry picked from commit 2f977eeec93be5cc71fda57f80362c1bc639c041)
2022-07-21 00:24:41 +00:00
olly
e959af40f1 Add ContrastProcessor for contrast adjustments.
PiperOrigin-RevId: 462232813
(cherry picked from commit 714edc93be549f93194ad0a1d7e187c32b49d1e8)
2022-07-20 21:38:10 +00:00
huangdarwin
54cdec4614 HDR: Use FP16 color representation for texture processors.
* Introduced `useHdr` for `GlEffect#toGlTextureProcessor`, so
  `TextureProcessor` implementations can decide how to handle HDR.
* Creating FP16 color textures for HDR input.

Tested via manual testing, adding a no-op GlEffectWrapper to the transformation to
force use of intermediate textures, adding a linear ramp to the fragment shader,
and trying to ascertain that there's a real reduction in posterization when
switching from 4-bit to 8-bit unsigned bytes, and again from 8-bit unsigned bytes
to 16-bit floating point.

PiperOrigin-RevId: 461613117
(cherry picked from commit ba9c9bb96471a9589d391ae498ebb0c194a5b41e)
2022-07-18 14:21:17 +00:00
andrewlewis
c4e64c3d0d Update demo HDR10 video URL
The old URL doesn't correctly signal the HDR10 color info in the container.

The new URL signals ST2084 (PQ) transfer function and BT.2020 color space as expected.

PiperOrigin-RevId: 461560107
(cherry picked from commit 794e366b3661e9dfec01abcbd4598a26bec9e235)
2022-07-18 08:51:54 +00:00
hschlueter
d48507a2d1 Move DebugViewProvider out of Transformer class.
The GlEffectsFrameProcessor that will be part of the effects module
uses the DebugViewProvider. So it does not make sense for it
to be an inner interface of Transformer.

PiperOrigin-RevId: 458014932
(cherry picked from commit cd0e5b99de9577ff1af0da15a9ea6c9041f38361)
2022-06-29 17:56:53 +00:00
hschlueter
864230fd11 Rename setVideoFrameEffects to setVideoEffects.
PiperOrigin-RevId: 457023382
(cherry picked from commit 4819b28587c41e75c716ba3fa84fa84a8934c78e)
2022-06-24 17:04:45 +01:00
samrobinson
90c904b089 Add a Builder for DefaultEncoderFactory.
PiperOrigin-RevId: 456728032
(cherry picked from commit 352967f65661296ff5551138fd6346fce0c52a3f)
2022-06-23 11:37:19 +01:00
hschlueter
26ee3d32b2 Use GlTextureProcessor to avoid redundant copy in MediaPipeProcessor.
After this change GlEffects can use any GlTextureProcessor not just
SingleFrameGlTextureProcessor.
MediaPipeProcessor now implements GlTextureProcessor directly which
allows it to reuse MediaPipe's output texture for its output texture
and avoids an extra copy shader step.

PiperOrigin-RevId: 456530718
(cherry picked from commit 69ab79418ef21033ca25cebdf5a5e80752818ab5)
2022-06-22 17:16:54 +01:00
hschlueter
0007a47365 Support chaining async GlTextureProcessors in FrameProcessorChain.
After this change, FrameProcessorChain chains any GlTextureProcessors
instead of only SingleFrameGlTextureProcessors.

The GlTextureProcessors are chained in a bidirectional manner using
ChainingGlTextureProcessorListener to feed input and output related
events forward and release events backwards.

PiperOrigin-RevId: 456478414
(cherry picked from commit 555ab97e34d6586d38a9979bc0595a4818b7ecb8)
2022-06-22 12:03:41 +01:00
hschlueter
fab04c45f1 Add option to disable debug preview.
This is useful for testing Transformer in the same way as it is used
in tests and to see only the real transformation time.

PiperOrigin-RevId: 456058466
(cherry picked from commit 931562c24380ff8bd1f8fad6b2c0bb3581dc65e5)
2022-06-20 13:50:16 +01:00
hschlueter
56f234ea75 Check targetSdkVersion for frame dropping workaround.
Based on
https://developer.android.com/reference/android/media/MediaCodec#using-an-output-surface,
frame dropping behaviour depends on the target SDK version.
After this change transformer will only use
MediaFormat#KEY_ALLOW_FRAME_DROP if both the target and system SDK
version are at least 29 and default to its pre 29 behaviour where each
decoder output frame must be processed before a new one is rendered
to prevent frame dropping otherwise.

Also remove deprecated Transformer.Builder constructor without a
context and the context setter.

PiperOrigin-RevId: 453971097
(cherry picked from commit a105d033a7d44b8c3afb0e8134ad65f624caf256)
2022-06-09 18:22:39 +00:00
hschlueter
0b08396255 Make GlUtil.GlException checked and remove flag to disable it.
Transformer always enabled glAssertionsEnabled, so there should
be no functional change.

ExoPlayer previously disabled glAssertionsEnabled, so GlUtil logged
GlExceptions instead of throwing them. The GlExceptions are now
caught and logged by the callers so that there should also be no
functional change overall.

This change also replaces EGLSurfaceTexture#GlException with
GlUtil#GlException.

PiperOrigin-RevId: 453963741
(cherry picked from commit cc1f32d094cc4371d92b3ddab144d8965e1bc1c3)
2022-06-09 17:53:39 +00:00
hschlueter
dac3878273 Implement default GlTextureProcessor in SingleFrameGlTextureProcessor.
SingleFrameGlTextureProcessor is now an abstract class containing a
default implementation of the more flexible GlTextureProcessor interface
while still exposing the same simple abstract methods for single frame
processing it previously did.

FrameProcessorChain and GlEffect will be changed to use
GlTextureProcessor in follow-ups.

PiperOrigin-RevId: 453633000
(cherry picked from commit 457f446114823831b940bf46fb256daa0ea00815)
2022-06-08 09:44:25 +00:00
hschlueter
22ee071b53 Move program initialization to texture processor constructor.
Once the more advanced GlTextureProcessor interface exists,
it will be possible to change the output size of a GlTextureProcessor
between frames. To keep the re-configuration based on the frame sizes
minimal, things indepedent of the frame size, such as the GlProgram,
can be initialized in the constructor.

PiperOrigin-RevId: 451997584
(cherry picked from commit 87ab96d352c0ffbf83d514d93193638895b61e5e)
2022-05-31 09:36:18 +00:00
bachinger
23888c1217 Use ContextCompat.getMainExecutor when calling MediaBrowser methods
This allows the service to be switched to run in another process and the app still works the same as if it is running in the same process.

Issue: androidx/media#100
PiperOrigin-RevId: 458460005
(cherry picked from commit c9abe70259adabd1523b0e2aa0a4df74d78339d9)
2022-07-01 13:53:11 +00:00
olly
e665edc863 Fix handling of content URIs by demo apps
PiperOrigin-RevId: 453510883
(cherry picked from commit 96274bfd98b45347e6a06059465625e01e952158)
2022-06-07 20:23:51 +00:00
tonihei
f5dc99f596 Forward legacy controller onPlay/PrepareFromXY calls to onAddMediaItems
These legacy callbacks are currently forwarded to onSetMediaUri which
will be removed in the future.

Also make sure to only call player.prepare/play after the items have
been set.

The calls to onAddQueueItem are also forwarded to onAddMediaItems to
actually allow a session to resolve these items to playable media, which
wasn't possible so far.

PiperOrigin-RevId: 453625204
(cherry picked from commit bd126ec5c5497615572bcdf259278a899b4574f8)
2022-06-09 18:36:35 +00:00
andrewlewis
9cd84696c7 Create withMediaPipe variant only if AAR is present
This should fix running `./gradlew clean test` if MediaPipe hasn't been built, for example.

PiperOrigin-RevId: 452033698
(cherry picked from commit 208a9114a9f516f7034b75b4f21f9ded34de8501)
2022-05-31 14:07:20 +00:00
bachinger
7671e50d71 Remove deprecated calls
#minor-release

PiperOrigin-RevId: 452006137
(cherry picked from commit acb48a249564c5793cfadbee262e2eed29dea528)
2022-05-31 13:51:49 +00:00
tonihei
6b782d1011 Replace MediaItemFiller by asynchronous callback.
The MediaItemFiller is not flexible enough for most realworld usages
because:
 - it doesn't allow asynchronous resolution of MediaItems (e.g. to
   look up URIs from a database)
 - it doesn't allow to batch updates for multiple items or do more
   advanced customizations (e.g. expanding a mediaId representing
   a playlist to multiple items).

Both issues can be solved by passing in a list of items and
returning a ListenableFuture. The callback itself can also move
into MediaSession.Callback for consistency with the other
callbacks.

PiperOrigin-RevId: 451857319
2022-05-30 16:48:41 +00:00
bachinger
9a70bbca05 Demonstrate how to use custom actions in the session demo app.
PiperOrigin-RevId: 451410714
2022-05-30 16:40:41 +00:00
hschlueter
fe3831c5b4 Fix handling clipping in transformer renderers.
Decode-only video frames (needed when the frame at / first frame after the
clipping start is not a key frame) need to be decoded but not passed to
the frame processor chain or encoder.

The clipping start offset needs to be removed from the frame timestamps
in the passthrough and video pipelines.
There are no changes needed for this in the audio pipeline, as it doesn't
use the input timestamps -- it uses its own timestamps derived from the
buffer sizes instead.

Also add demo option to try this out.

#minor-release

PiperOrigin-RevId: 451353609
2022-05-30 16:34:38 +00:00
hschlueter
0eaf3d30c8 Rename GlFrameProcessor to SingleFrameGlTextureProcessor.
Also update names of implementations to match design doc.
In follow-ups, SingleFrameGlTextureProcessor will become
an abstract implementation of a new GlTextureProcessor
interface.

Texture processor makes sense as it processes OpenGL textures.
The term frame processor will be used for something else in
follow-ups.

PiperOrigin-RevId: 451142085
2022-05-30 16:31:13 +00:00
ibaker
591eaef756 Fix some inconsistencies in the MediaItem API
* Rename (via deprecation)
  `MediaItem.DrmConfiguration.Builder#forceSessionsForAudioAndVideoTracks`
  to `setForceSessionsForAudioAndVideoTracks`. This is more consistent
  with existing 'force' method names both in this class and in
  `TrackSelectionParameters.Builder`.
* Add missing `@Nullable` annotation to the parameter for
  `MediaItem.SubtitleConfiguration.Builder#setMimeType`. This annotation
  is already present on the `MediaItem.SubtitleConfiguration#mimeType`
  field that this setter corresponds to.

PiperOrigin-RevId: 450941336
2022-05-26 11:57:21 +00:00
ibaker
89194dee59 Add DefaultMediaSourceFactory.setDataSourceFactory
Also add this to the stable API instead of the constructor that takes
`DataSource.Factory`.

PiperOrigin-RevId: 450414119
2022-05-23 13:26:05 +01:00
andrewlewis
0fa0735935 Reorder demo samples
Put cloud storage samples at the top to avoid having a sample at the top of the list where we don't control the server.

Also update labels not to mention progressive container type, as it's irrelevant for Transformer, which always transmuxes even if it doesn't transcode.

#ame-bug-week

PiperOrigin-RevId: 450403784
2022-05-24 11:09:55 +01:00
bachinger
08fc89a585 Implement onSubscribe in session demo service
Immediately notify a subscribing client about the availability of child items of
a parent ID to make the client load the children.

PiperOrigin-RevId: 450396690
2022-05-24 11:08:56 +01:00
ibaker
c78c1f5891 Rename nested session callback interfaces to just Callback
This is consistent with other nested callback/listener interfaces like
`Player.Listener`.

PiperOrigin-RevId: 449476261
2022-05-24 10:57:02 +01:00
andrewlewis
a9bdd6e2e9 Attempt to load OpenCV when loading MediaPipe
PiperOrigin-RevId: 449227706
2022-05-24 10:51:36 +01:00
andrewlewis
d8caa2b4c1 Fix initialization of media pipe processors with assets
PiperOrigin-RevId: 449221156
2022-05-24 10:50:41 +01:00
andrewlewis
66b3527a22 Fix demo app crash when media pipe isn't loaded
The toast message about media pipe not loading needs to be shown on the main
(UI) thread.

PiperOrigin-RevId: 449199285
2022-05-24 10:47:57 +01:00
ibaker
25279ad477 Add DefaultMediaSourceFactory.{set,clear}LocalAdInsertionConfig
Deprecate the setAdsLoaderProvider and setAdViewProvider methods these
replace.

PiperOrigin-RevId: 448251423
2022-05-24 10:41:26 +01:00
christosts
7a631f4050 MediaSessionService: define foregroundServiceType
PiperOrigin-RevId: 447467287
2022-05-10 17:49:22 +01:00
hschlueter
63dcdf5803 Add listener for FrameProcessingExceptions.
This listener replaces
FrameProcessorChain#getAndRethrowBackgroundExceptions.
The listener uses a new exception type FrameProcessingException
separate from TransformationException as the frame processing
components will be made reusable outside of transformer soon.

PiperOrigin-RevId: 447455746
2022-05-10 17:47:22 +01:00
hschlueter
2e544224c2 Fix GlUtil vector size constant name.
This constant is used for https://docs.gl/es2/glVertexAttribPointer
which takes the number of components per generic vertex attribute
(meaning the size of the individual coordinate vectors here) not the
number of attributes (the number of vertices that the old constant
name referred to).

PiperOrigin-RevId: 447427241
2022-05-10 17:42:39 +01:00
hschlueter
e9919f6da1 Remove redundant attribute from matrix transformation vertex shader.
The texture coordinates can be derived from the frame coordinates.

PiperOrigin-RevId: 446770538
2022-05-09 11:01:33 +01:00
andrewlewis
e6518126ac Add frame processor based on MediaPipe to demo
PiperOrigin-RevId: 446432695
2022-05-09 10:56:08 +01:00
ibaker
931bc70d5f Migrate usages of the deprecated TrackSelectionParameters.CREATOR
PiperOrigin-RevId: 446400192
2022-05-09 10:52:11 +01:00
hschlueter
c94035278c Separate matrix effect specification and implementation.
This change splits AdvancedFrameProcessor into 4 files:
- MatrixTransformationFrameProcessor for the GlFrameProcessor
  implementation
- MatrixTransformation and GlMatrixTransformation for the GlEffect
  specification
- MatrixUtils for the static matrix helpers

PiperOrigin-RevId: 446236384
2022-05-09 10:51:14 +01:00
ibaker
648b085954 Opt some more bits of the main demo app into the unstable API
PiperOrigin-RevId: 446161354
2022-05-09 10:47:52 +01:00
ibaker
9a67b30750 Migrate usages from C.TYPE_* to C.CONTENT_TYPE_*
PiperOrigin-RevId: 446156308
2022-05-09 10:46:04 +01:00
hschlueter
b410a922fe Introduce GlEffect interface for effect specification.
PiperOrigin-RevId: 446143537
2022-05-09 10:44:30 +01:00
ibaker
2a726cfe9f Use cronet for DRM requests in the main demo app
This ensures that both content and licenses are requested using the
same HTTP stack.

#minor-release

PiperOrigin-RevId: 445378940
2022-05-09 10:39:32 +01:00
ibaker
5766cd52ba Add copies of PlayerControlView's public listeners to PlayerView
Developers are expected to (eventually) only use methods on
PlayerView (and not PlayerControlView) to interact with the UI
controller.

PiperOrigin-RevId: 445361488
2022-05-09 10:35:58 +01:00