Skip to content

reland: audio & video player: migrate to common playbin implementation #483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
36a2127
video player: use square BO
ardera Feb 21, 2025
0b3f3a4
video player: use playbin3 instead of uridecodebin
ardera Feb 21, 2025
2298020
video player: don't handle dma_drm video info
ardera Feb 21, 2025
ca1eee4
video player: fix code for gstreamer < 1.24.0
ardera Feb 21, 2025
58663ba
video player: fix parameter in g_object_set
ardera Feb 21, 2025
dc0ff2a
video player: disable hw decoding for gstreamer < 1.22.8
ardera May 8, 2025
ef858c0
video player: make seek flags construction a bit more easier to follow
ardera May 8, 2025
878f39c
util: add khash hashmap implementation
ardera May 8, 2025
0e6b1da
platform channels: helpers for decoding method calls
ardera May 12, 2025
5f65e73
gitignore: ignore .cache
ardera May 12, 2025
63de32b
gstplayer: feature parity with audioplayers player
ardera May 12, 2025
2f37727
audioplayers: migrate to gstplayer
ardera May 9, 2025
0740253
gstplayer: move gstplayer into separate file
ardera May 12, 2025
efab797
modesetting: remove logs if a separate cursor plane couldn't be found
ardera May 12, 2025
436f790
cmake: remove deleted `audioplayers/player.c` file
ardera May 12, 2025
c7a7493
Revert "video player: disable hw decoding for gstreamer < 1.22.8"
ardera May 13, 2025
815ac82
gstplayer: don't use gst_video_info_new_from_caps
ardera May 13, 2025
facc7fc
gstplayer: only define appsink event handler for gstreamer >= 1.20.0
ardera May 13, 2025
5e72346
gstplayer: don't use sd_event_source_disable_unref
ardera May 13, 2025
cd2c8ef
notifier/listener: fix change notifiers notifying on listen
ardera May 16, 2025
1584c59
gstplayer/audio player/video player: various compatibility fixes
ardera May 16, 2025
c2ed358
flutter-pi: allow getting tracer of flutterpi instance
ardera May 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,6 @@ Icon
Network Trash Folder
Temporary Items
.apdisk

# Used by zed to store clangd cache
.cache
104 changes: 48 additions & 56 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -305,73 +305,65 @@ endif()
if (BUILD_TEST_PLUGIN)
target_sources(flutterpi_module PRIVATE src/plugins/testplugin.c)
endif()
if (BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN)
if (NOT HAVE_EGL_GLES2)
message(NOTICE "EGL and OpenGL ES2 are required for gstreamer video player. Gstreamer video player plugin won't be build.")
else()

set(HAVE_GSTREAMER_VIDEO_PLAYER OFF)
if (BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN OR BUILD_GSTREAMER_AUDIO_PLAYER_PLUGIN)#
pkg_check_modules(LIBGSTREAMER IMPORTED_TARGET
gstreamer-1.0
gstreamer-plugins-base-1.0
gstreamer-app-1.0
gstreamer-allocators-1.0
gstreamer-video-1.0
gstreamer-audio-1.0
)

if (LIBGSTREAMER_FOUND)
string(REPLACE "." ";" LIBGSTREAMER_VERSION_AS_LIST ${LIBGSTREAMER_gstreamer-1.0_VERSION})
list(GET LIBGSTREAMER_VERSION_AS_LIST 0 LIBGSTREAMER_VERSION_MAJOR)
list(GET LIBGSTREAMER_VERSION_AS_LIST 1 LIBGSTREAMER_VERSION_MINOR)
list(GET LIBGSTREAMER_VERSION_AS_LIST 2 LIBGSTREAMER_VERSION_PATCH)

target_sources(flutterpi_module PRIVATE src/plugins/gstplayer.c)
target_link_libraries(flutterpi_module PUBLIC PkgConfig::LIBGSTREAMER)
endif()

if (BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN AND NOT LIBGSTREAMER_FOUND)
if (TRY_BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN)
pkg_check_modules(LIBGSTREAMER IMPORTED_TARGET gstreamer-1.0)
pkg_check_modules(LIBGSTREAMER_PLUGINS_BASE IMPORTED_TARGET gstreamer-plugins-base-1.0)
pkg_check_modules(LIBGSTREAMER_APP IMPORTED_TARGET gstreamer-app-1.0)
pkg_check_modules(LIBGSTREAMER_ALLOCATORS IMPORTED_TARGET gstreamer-allocators-1.0)
pkg_check_modules(LIBGSTREAMER_VIDEO IMPORTED_TARGET gstreamer-video-1.0)
message(NOTICE "Some required gstreamer dependencies were not found. Gstreamer video player plugin won't be built.")
else()
pkg_check_modules(LIBGSTREAMER REQUIRED IMPORTED_TARGET gstreamer-1.0)
pkg_check_modules(LIBGSTREAMER_PLUGINS_BASE REQUIRED IMPORTED_TARGET gstreamer-plugins-base-1.0)
pkg_check_modules(LIBGSTREAMER_APP REQUIRED IMPORTED_TARGET gstreamer-app-1.0)
pkg_check_modules(LIBGSTREAMER_ALLOCATORS REQUIRED IMPORTED_TARGET gstreamer-allocators-1.0)
pkg_check_modules(LIBGSTREAMER_VIDEO REQUIRED IMPORTED_TARGET gstreamer-video-1.0)
message(ERROR "Some required gstreamer dependencies were not found. Can't build gstreamer video player plugin.")
endif()
endif()

if (LIBGSTREAMER_FOUND AND LIBGSTREAMER_PLUGINS_BASE_FOUND AND LIBGSTREAMER_APP_FOUND AND LIBGSTREAMER_ALLOCATORS_FOUND AND LIBGSTREAMER_VIDEO_FOUND)
# There's no other way to query the libinput version (in code) somehow.
# So we need to roll our own libinput version macro
string(REPLACE "." ";" LIBGSTREAMER_VERSION_AS_LIST ${LIBGSTREAMER_VERSION})
list(GET LIBGSTREAMER_VERSION_AS_LIST 0 LIBGSTREAMER_VERSION_MAJOR)
list(GET LIBGSTREAMER_VERSION_AS_LIST 1 LIBGSTREAMER_VERSION_MINOR)
list(GET LIBGSTREAMER_VERSION_AS_LIST 2 LIBGSTREAMER_VERSION_PATCH)

target_sources(flutterpi_module PRIVATE
src/plugins/gstreamer_video_player/plugin.c
src/plugins/gstreamer_video_player/player.c
src/plugins/gstreamer_video_player/frame.c
)
target_link_libraries(flutterpi_module PUBLIC
PkgConfig::LIBGSTREAMER
PkgConfig::LIBGSTREAMER_PLUGINS_BASE
PkgConfig::LIBGSTREAMER_APP
PkgConfig::LIBGSTREAMER_ALLOCATORS
PkgConfig::LIBGSTREAMER_VIDEO
)
if (BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN AND NOT HAVE_EGL_GLES2)
if (TRY_BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN)
message(NOTICE "EGL and OpenGL ES2 are required for gstreamer video player. Gstreamer video player plugin won't be built.")
else()
message(NOTICE "Couldn't find gstreamer libraries. Gstreamer video player plugin won't be build.")
message(ERROR "EGL and OpenGL ES2 are required for gstreamer video player. Can't build gstreamer video player plugin.")
endif()
endif()
endif()

if (BUILD_GSTREAMER_AUDIO_PLAYER_PLUGIN)
if (TRY_BUILD_GSTREAMER_AUDIO_PLAYER_PLUGIN)
pkg_check_modules(LIBGSTREAMER IMPORTED_TARGET gstreamer-1.0)
pkg_check_modules(LIBGSTREAMER_APP IMPORTED_TARGET gstreamer-app-1.0)
pkg_check_modules(LIBGSTREAMER_AUDIO IMPORTED_TARGET gstreamer-audio-1.0)
else()
pkg_check_modules(LIBGSTREAMER REQUIRED IMPORTED_TARGET gstreamer-1.0)
pkg_check_modules(LIBGSTREAMER_APP REQUIRED IMPORTED_TARGET gstreamer-app-1.0)
pkg_check_modules(LIBGSTREAMER_AUDIO REQUIRED IMPORTED_TARGET gstreamer-audio-1.0)
if (BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN AND LIBGSTREAMER_FOUND AND HAVE_EGL_GLES2)
set(HAVE_GSTREAMER_VIDEO_PLAYER ON)
target_sources(flutterpi_module PRIVATE
src/plugins/gstreamer_video_player/frame.c
src/plugins/gstreamer_video_player/flutter_texture_sink.c
src/plugins/gstreamer_video_player/plugin.c
)
endif()

if (LIBGSTREAMER_FOUND AND LIBGSTREAMER_APP_FOUND AND LIBGSTREAMER_AUDIO_FOUND)
if (BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN AND NOT LIBGSTREAMER_FOUND)
if (TRY_BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN)
message(NOTICE "Some required gstreamer dependencies were not found. Gstreamer audio player plugin won't be built.")
else()
message(ERROR "Some required gstreamer dependencies were not found. Can't build gstreamer audio player plugin.")
endif()
endif()

if (BUILD_GSTREAMER_AUDIO_PLAYER_PLUGIN AND LIBGSTREAMER_FOUND)
target_sources(flutterpi_module PRIVATE
src/plugins/audioplayers/plugin.c
src/plugins/audioplayers/player.c
)
target_link_libraries(flutterpi_module PUBLIC
PkgConfig::LIBGSTREAMER
PkgConfig::LIBGSTREAMER_APP
PkgConfig::LIBGSTREAMER_AUDIO
)
else()
message(NOTICE "Couldn't find gstreamer libraries. Gstreamer audio player plugin won't be build.")
endif()
endif()

Expand All @@ -390,10 +382,10 @@ if (BUILD_SENTRY_PLUGIN)

if (SENTRY_BACKEND STREQUAL "crashpad" AND SENTRY_PLUGIN_BUNDLE_CRASHPAD_HANDLER)
set(HAVE_BUNDLED_CRASHPAD_HANDLER ON)

target_sources(flutter-pi PRIVATE src/crashpad_handler_trampoline.cc)
# link against the same libraries the crashpad_handler uses

get_target_property(handler_deps crashpad_handler INTERFACE_LINK_LIBRARIES)
target_link_libraries(flutter-pi PUBLIC ${handler_deps})
endif()
Expand Down
1 change: 1 addition & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
#cmakedefine ENABLE_MTRACE
#cmakedefine ENABLE_ASAN
#cmakedefine HAVE_BUNDLED_CRASHPAD_HANDLER
#cmakedefine HAVE_GSTREAMER_VIDEO_PLAYER

#endif
5 changes: 5 additions & 0 deletions src/flutter-pi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,11 @@ struct gl_renderer *flutterpi_get_gl_renderer(struct flutterpi *flutterpi) {
return flutterpi->gl_renderer;
}

struct tracer *flutterpi_get_tracer(struct flutterpi *flutterpi) {
ASSERT_NOT_NULL(flutterpi);
return flutterpi->tracer;
}

void flutterpi_set_pointer_kind(struct flutterpi *flutterpi, enum pointer_kind kind) {
return compositor_set_cursor(flutterpi->compositor, false, false, true, kind, false, VEC2F(0, 0));
}
Expand Down
3 changes: 3 additions & 0 deletions src/flutter-pi.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ struct drmdev;
struct locales;
struct vk_renderer;
struct flutterpi;
struct tracer;

/// TODO: Remove this
extern struct flutterpi *flutterpi;
Expand Down Expand Up @@ -188,6 +189,8 @@ bool flutterpi_has_gl_renderer(struct flutterpi *flutterpi);

struct gl_renderer *flutterpi_get_gl_renderer(struct flutterpi *flutterpi);

struct tracer *flutterpi_get_tracer(struct flutterpi *flutterpi);

void flutterpi_set_pointer_kind(struct flutterpi *flutterpi, enum pointer_kind kind);

void flutterpi_trace_event_instant(struct flutterpi *flutterpi, const char *name);
Expand Down
3 changes: 0 additions & 3 deletions src/modesetting.c
Original file line number Diff line number Diff line change
Expand Up @@ -2448,9 +2448,6 @@ int kms_req_builder_push_fb_layer(
/* id_range */ false, 0
// clang-format on
);
if (plane == NULL) {
LOG_DEBUG("Couldn't find a fitting cursor plane.\n");
}
}

/// TODO: Not sure we can use crtc_x, crtc_y, etc with primary planes
Expand Down
10 changes: 6 additions & 4 deletions src/notifier_listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,12 @@ struct listener *notifier_listen(struct notifier *notifier, listener_cb_t notify
return NULL;
}

r = listener_notify(l, notifier->state);
if (r == kUnlisten) {
listener_destroy(l);
return NULL;
if (notifier->is_value_notifier) {
r = listener_notify(l, notifier->state);
if (r == kUnlisten) {
listener_destroy(l);
return NULL;
}
}

notifier_lock(notifier);
Expand Down
14 changes: 14 additions & 0 deletions src/platformchannel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1320,6 +1320,10 @@ int platch_respond_native_error_std(const FlutterPlatformMessageResponseHandle *
return platch_respond_error_std(handle, "nativeerror", strerror(_errno), &STDINT32(_errno));
}

int platch_respond_malformed_message_std(const FlutterPlatformMessage *message) {
return platch_respond_error_std(message->response_handle, "malformed-message", "The platform message received was malformed.", &STDNULL);
}

/************************
* JSON METHOD CHANNELS *
************************/
Expand Down Expand Up @@ -2483,3 +2487,13 @@ MALLOCLIKE MUST_CHECK char *raw_std_method_call_get_method_dup(const struct raw_
ATTR_PURE const struct raw_std_value *raw_std_method_call_get_arg(const struct raw_std_value *value) {
return raw_std_value_after(value);
}

ATTR_PURE const struct raw_std_value *raw_std_method_call_from_buffer(const void *buffer, size_t buffer_size) {
const struct raw_std_value *envelope = (const struct raw_std_value *) buffer;

if (!raw_std_method_call_check(envelope, buffer_size)) {
return NULL;
} else {
return envelope;
}
}
5 changes: 4 additions & 1 deletion src/platformchannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Platform Channels
*
* Encoding/Decoding of flutter platform messages, with different
*
*
* Supported codecs:
* - standard message & method codec,
* - json message & method codec
Expand Down Expand Up @@ -1491,6 +1491,8 @@ int platch_respond_illegal_arg_ext_std(const FlutterPlatformMessageResponseHandl

int platch_respond_native_error_std(const FlutterPlatformMessageResponseHandle *handle, int _errno);

int platch_respond_malformed_message_std(const FlutterPlatformMessage *message);

int platch_respond_success_json(const FlutterPlatformMessageResponseHandle *handle, struct json_value *return_value);

int platch_respond_error_json(
Expand Down Expand Up @@ -1614,6 +1616,7 @@ ATTR_PURE bool raw_std_method_call_check(const struct raw_std_value *value, size
ATTR_PURE bool raw_std_method_call_response_check(const struct raw_std_value *value, size_t buffer_size);
ATTR_PURE bool raw_std_event_check(const struct raw_std_value *value, size_t buffer_size);

ATTR_PURE const struct raw_std_value *raw_std_method_call_from_buffer(const void *buffer, size_t buffer_size);
ATTR_PURE const struct raw_std_value *raw_std_method_call_get_method(const struct raw_std_value *value);
ATTR_PURE bool raw_std_method_call_is_method(const struct raw_std_value *value, const char *method_name);
MALLOCLIKE MUST_CHECK char *raw_std_method_call_get_method_dup(const struct raw_std_value *value);
Expand Down
Loading