The API is not used anymore, and with the removal of the reference
counting pattern in objects, not required.
Indeed, the OpenGL providers are neither multi-thread nor reentrant
so it needs a locked stated when multiple clients needs to use it,
which will also needs to be reference counted across the clients, so
the whole reference counting can be done there.
In addition, if the context was given from module to other module, like
in the filter chain, the video contexts forwarded in those chains would
already be doing the reference counting. As a side note, there would
probably be few reasons to implement such forwarding currently anyway
since it would means that the beginning of the chain would lose usage
of the context, which also encompass a pool of output picture too
currently.
see e967f81f6a.
note, this does **not** affect cat-based module selection items
(of which there are just three in use by the core), since that
mechanism uses subcats not cats.
Benefits of *not* using designated initializers:
- we can't forget a callback
- it's the same in C and C++ (<20)
Benefits of using designated initializers:
- the order of callbacks may not be wrong
- we can read immediately which function is assigned to which callback
(especially if some are NULL)
- an optional callback may be added without modifying all the modules
- we can grep a callback name to find its assignments easily
- it is consistent with others xxx_operations in the codebase
The config "advanced" flag was unused and has been removed by
6a7a137f7b.
It has been removed from many add_*() macros, but not all. Remove it
from the remaining macros.
Non single-buffered vlc_asurfacetexture are very expensive when you only
want to store a single buffer. When using multiple of them, it's
possible that the phone goes OOM, and especially on old phones that
don't support single-buffered SurfaceTexture so in that case just fail
the creation of the SurfaceTexture.
AWindowHandler_new() failed if no instance were registered in the VLC
variable "drawable-androidwindow".
The official Android app registers an instance here, but other libvlc
clients may not need it (e.g. for offscreen encoding).
Co-authored-by: Alexandre Janniaux <ajanni@videolabs.io>
Move the classes to the AWindowHandler structure, namespacing them for
each window/decoder device and allowing potentially different AWindow
implementation to be provided through JNI.
This restore the release of the SurfaceTexture/Surface classes.
Accept a null vout_window_t.
In the case of a decoder-only AWindowHandler decoder device, there is
no AWindow object necessary and thus no setup required, so calling the
registration functions on the AWindow would prevent any following vout
window creation since it would have been registered.
Co-authored-by: Alexandre Janniaux <ajanni@videolabs.io>
Abstract the storage of SurfaceTexture in the Android video context, so
that the interop doesn't have to bother on how the SurfaceTexture is
handled by the image producer. In particular, this will allow multiple
SurfaceTexture to be used in a single Android context, thus provides the
ability to use SurfaceTexture as a single buffer in each picture_t sent
from an Android producer.
Add support for releaseTexImage in SurfaceTexture, which is needed in
custom SurfaceTexture-based buffer producer to use the less number of
buffer possible. This is especially important on old and low-memory
devices which cannot create a ton of SurfaceTexture objects.
Use the JNI variant for the NDK implementation since the function
doesn't even exists in the NDK.
Only 4 modules actually use the Reset Pictures feature to create a new filter
pipeline when they can't handle the source anymore. It's still faster than
closing the module and probing for a new display module.
The AWindow_ID is not used anymore since we moved the creation of
SurfaceTexture to the usage site. We also don't need to store the
SurfaceTexture in the AWindowHandler anymore.
This finally makes the SurfaceTexture independant of the AWindowHandler
and cleanup previous patches.
Signed-off-by: Alexandre Janniaux <ajanni@videolabs.io>
Now that MediaCodec exposes a SurfaceTexture through the video context,
stop using AWindowHandler in interop and directly use the
vlc_asurfacetexture abstraction to bind the picture to the OpenGL
textures.
It means that, after dropping the hack in vlc_asurfacetexture_New,
multiple interop will finally work within the same AWindowHandler
instance and, for the future GPU Filter support, that filters can
provide their own SurfaceTexture.
Signed-off-by: Alexandre Janniaux <ajanni@videolabs.io>
Initially, the SurfaceTexture reference was created through
AWindowHandler and typically was obtained through a TextureView. By
creating the SurfaceTexture ourselves, we can avoid requesting Android
libVLC user to use libvlc_media_player_set_android_context even if the
user doesn't need any display.
In addition, it means that we don't rely on code that is in the JNI
android binding instead of vlc core when using MediaCodec, which helps
other bindings like C# one to provide support for Android.
Signed-off-by: Alexandre Janniaux <ajanni@videolabs.io>
Expose public functions to create and destroy the vlc_asurfacetexture
objects from an AWindowHandler object. It will be used in particular by
Mediacodec to output to OpenGL textures.
Signed-off-by: Alexandre Janniaux <ajanni@videolabs.io>
Add a JNI variant of SurfaceTexture, which supports any Android API
version starting from API 11.
It effectively removes the need for SurfaceTexture function wrapping in
the AWindow object.
Signed-off-by: Alexandre Janniaux <ajanni@videolabs.io>
The new function use a `struct vlc_asurfacetexture` object and is
written to be extended to the case in which we don't have the NDK
ASurfaceTexture API.
Signed-off-by: Alexandre Janniaux <ajanni@videolabs.io>
When creating a SurfaceTexture JNI object, we can, with recent API,
transform the SurfaceTexture into an ASurfaceTexture NDK object.
However, with previous Android version, the only way is to create the
Surface JNI object directly from the SurfaceTexture JNI object, and then
convert the Surface into a ANativeWindow NDK object for the producer
side.
This patch loads the class and the constructor taking a reference to
SurfaceTexture.
Signed-off-by: Alexandre Janniaux <ajanni@videolabs.io>
init_z needs API 26 and is the most suitable since it allows creating
SurfaceTexture in a detached state, while init_iz needs API 19 and
cannot be created without an EGL context currently bounded.
init_i is the most compatible version (API 11) but won't allow
single-buffering.
Signed-off-by: Alexandre Janniaux <ajanni@videolabs.io>
Instead of passing the full path in the jfields structure, pass the
jfields first-order structure and the method field within it
separately, allowing to use it for future additional other classes too.
Signed-off-by: Alexandre Janniaux <ajanni@videolabs.io>
Refactor SurfaceTexture related API into a structure with vtable, so as
to implement both NDK and JNI API as separate vtable.
It will be exposed to modules and will allow creating SurfaceTexture
directly in the module needing them, instead of relying on an external
SurfaceTexture provided by the binding.
jsurface and ANativeWindow are also both exposed to the user since we
don't expose the ANativeWindow/JNI functions.
The object is made so that SurfaceTexture are always created in the
detached state. The current error path is also relatively defensive
in order to simplify the transition in the future commits, but is only
a temporary path.
Signed-off-by: Alexandre Janniaux <ajanni@videolabs.io>
Avoid forward-declaring SurfaceTexture implementation. In future
refactor we will change their prototype and put them into vtable.
Signed-off-by: Alexandre Janniaux <ajanni@videolabs.io>
When the native SurfaceTexture API is available, construct a SurfaceTexture
object from Java through JNI calls and store the producer side
(Surface/ANativeWindow) for the AWindowHandler clients.
The SurfaceTexture constructor is only available since API 26 but the NDK
API for ASurfaceTexture already require API 28
To use new native functions, we wrap ASurfaceTextureAPI structure pointers
inside a new set of native functions, it allow to describe some specifics
behaviors for the NDK API.
If the NDK API requierements are met, native functions for ASurfaceTexture are
used instead of their JNI counterpart. The behavior change is made through the
SurfaceTextureHandler pointer structure.
Then, in all cases, wrap pointers of SurfaceTextureHandler in a common functions
used by OpenGL to attach / update / detach textures.
fixes#20344
Signed-off-by: Thomas Guillem <thomas@gllm.fr>
The methods from the SurfaceTexture and AndroidNativeWindow structures are
methods of the AWindow class.
Both structures are now merged inside struct AWindow.
SurfaceTexture structure will be used for SurfaceTexture methods and class.
Signed-off-by: Thomas Guillem <thomas@gllm.fr>
This reverts commit 77aa424b72.
The replacement was not equivalent:
strncmp(a, b, strlen(b)) == 0 # test if a starts with b
strcmp(a, b) == 0 # test if a equals b
In practice, it breaks OpenGL on Android when the vout_modules contains
"gles2,none".
Signed-off-by: Steve Lhomme <robux4@ycbcr.xyz>
strcmp will already stop at the second string's length and the first
string is known to be null-terminated.
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>