Skip to content

Commit 0740253

Browse files
committed
gstplayer: move gstplayer into separate file
Finishing unifying playback element used by audioplayers and video player plugins.
1 parent 2f37727 commit 0740253

File tree

10 files changed

+314
-885
lines changed

10 files changed

+314
-885
lines changed

CMakeLists.txt

Lines changed: 48 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -305,74 +305,66 @@ endif()
305305
if (BUILD_TEST_PLUGIN)
306306
target_sources(flutterpi_module PRIVATE src/plugins/testplugin.c)
307307
endif()
308-
if (BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN)
309-
if (NOT HAVE_EGL_GLES2)
310-
message(NOTICE "EGL and OpenGL ES2 are required for gstreamer video player. Gstreamer video player plugin won't be build.")
311-
else()
308+
309+
set(HAVE_GSTREAMER_VIDEO_PLAYER OFF)
310+
if (BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN OR BUILD_GSTREAMER_AUDIO_PLAYER_PLUGIN)#
311+
pkg_check_modules(LIBGSTREAMER IMPORTED_TARGET
312+
gstreamer-1.0
313+
gstreamer-plugins-base-1.0
314+
gstreamer-app-1.0
315+
gstreamer-allocators-1.0
316+
gstreamer-video-1.0
317+
gstreamer-audio-1.0
318+
)
319+
320+
if (LIBGSTREAMER_FOUND)
321+
string(REPLACE "." ";" LIBGSTREAMER_VERSION_AS_LIST ${LIBGSTREAMER_gstreamer-1.0_VERSION})
322+
list(GET LIBGSTREAMER_VERSION_AS_LIST 0 LIBGSTREAMER_VERSION_MAJOR)
323+
list(GET LIBGSTREAMER_VERSION_AS_LIST 1 LIBGSTREAMER_VERSION_MINOR)
324+
list(GET LIBGSTREAMER_VERSION_AS_LIST 2 LIBGSTREAMER_VERSION_PATCH)
325+
326+
target_sources(flutterpi_module PRIVATE src/plugins/gstplayer.c)
327+
target_link_libraries(flutterpi_module PUBLIC PkgConfig::LIBGSTREAMER)
328+
endif()
329+
330+
if (BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN AND NOT LIBGSTREAMER_FOUND)
312331
if (TRY_BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN)
313-
pkg_check_modules(LIBGSTREAMER IMPORTED_TARGET gstreamer-1.0)
314-
pkg_check_modules(LIBGSTREAMER_PLUGINS_BASE IMPORTED_TARGET gstreamer-plugins-base-1.0)
315-
pkg_check_modules(LIBGSTREAMER_APP IMPORTED_TARGET gstreamer-app-1.0)
316-
pkg_check_modules(LIBGSTREAMER_ALLOCATORS IMPORTED_TARGET gstreamer-allocators-1.0)
317-
pkg_check_modules(LIBGSTREAMER_VIDEO IMPORTED_TARGET gstreamer-video-1.0)
332+
message(NOTICE "Some required gstreamer dependencies were not found. Gstreamer video player plugin won't be built.")
318333
else()
319-
pkg_check_modules(LIBGSTREAMER REQUIRED IMPORTED_TARGET gstreamer-1.0)
320-
pkg_check_modules(LIBGSTREAMER_PLUGINS_BASE REQUIRED IMPORTED_TARGET gstreamer-plugins-base-1.0)
321-
pkg_check_modules(LIBGSTREAMER_APP REQUIRED IMPORTED_TARGET gstreamer-app-1.0)
322-
pkg_check_modules(LIBGSTREAMER_ALLOCATORS REQUIRED IMPORTED_TARGET gstreamer-allocators-1.0)
323-
pkg_check_modules(LIBGSTREAMER_VIDEO REQUIRED IMPORTED_TARGET gstreamer-video-1.0)
334+
message(ERROR "Some required gstreamer dependencies were not found. Can't build gstreamer video player plugin.")
324335
endif()
336+
endif()
325337

326-
if (LIBGSTREAMER_FOUND AND LIBGSTREAMER_PLUGINS_BASE_FOUND AND LIBGSTREAMER_APP_FOUND AND LIBGSTREAMER_ALLOCATORS_FOUND AND LIBGSTREAMER_VIDEO_FOUND)
327-
# There's no other way to query the libinput version (in code) somehow.
328-
# So we need to roll our own libinput version macro
329-
string(REPLACE "." ";" LIBGSTREAMER_VERSION_AS_LIST ${LIBGSTREAMER_VERSION})
330-
list(GET LIBGSTREAMER_VERSION_AS_LIST 0 LIBGSTREAMER_VERSION_MAJOR)
331-
list(GET LIBGSTREAMER_VERSION_AS_LIST 1 LIBGSTREAMER_VERSION_MINOR)
332-
list(GET LIBGSTREAMER_VERSION_AS_LIST 2 LIBGSTREAMER_VERSION_PATCH)
333-
334-
target_sources(flutterpi_module PRIVATE
335-
src/plugins/gstreamer_video_player/plugin.c
336-
src/plugins/gstreamer_video_player/player.c
337-
src/plugins/gstreamer_video_player/frame.c
338-
src/plugins/gstreamer_video_player/flutter_texture_sink.c
339-
)
340-
target_link_libraries(flutterpi_module PUBLIC
341-
PkgConfig::LIBGSTREAMER
342-
PkgConfig::LIBGSTREAMER_PLUGINS_BASE
343-
PkgConfig::LIBGSTREAMER_APP
344-
PkgConfig::LIBGSTREAMER_ALLOCATORS
345-
PkgConfig::LIBGSTREAMER_VIDEO
346-
)
338+
if (BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN AND NOT HAVE_EGL_GLES2)
339+
if (TRY_BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN)
340+
message(NOTICE "EGL and OpenGL ES2 are required for gstreamer video player. Gstreamer video player plugin won't be built.")
347341
else()
348-
message(NOTICE "Couldn't find gstreamer libraries. Gstreamer video player plugin won't be build.")
342+
message(ERROR "EGL and OpenGL ES2 are required for gstreamer video player. Can't build gstreamer video player plugin.")
349343
endif()
350344
endif()
351-
endif()
352345

353-
if (BUILD_GSTREAMER_AUDIO_PLAYER_PLUGIN)
354-
if (TRY_BUILD_GSTREAMER_AUDIO_PLAYER_PLUGIN)
355-
pkg_check_modules(LIBGSTREAMER IMPORTED_TARGET gstreamer-1.0)
356-
pkg_check_modules(LIBGSTREAMER_APP IMPORTED_TARGET gstreamer-app-1.0)
357-
pkg_check_modules(LIBGSTREAMER_AUDIO IMPORTED_TARGET gstreamer-audio-1.0)
358-
else()
359-
pkg_check_modules(LIBGSTREAMER REQUIRED IMPORTED_TARGET gstreamer-1.0)
360-
pkg_check_modules(LIBGSTREAMER_APP REQUIRED IMPORTED_TARGET gstreamer-app-1.0)
361-
pkg_check_modules(LIBGSTREAMER_AUDIO REQUIRED IMPORTED_TARGET gstreamer-audio-1.0)
346+
if (BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN AND LIBGSTREAMER_FOUND AND HAVE_EGL_GLES2)
347+
set(HAVE_GSTREAMER_VIDEO_PLAYER ON)
348+
target_sources(flutterpi_module PRIVATE
349+
src/plugins/gstreamer_video_player/frame.c
350+
src/plugins/gstreamer_video_player/flutter_texture_sink.c
351+
src/plugins/gstreamer_video_player/plugin.c
352+
)
362353
endif()
363354

364-
if (LIBGSTREAMER_FOUND AND LIBGSTREAMER_APP_FOUND AND LIBGSTREAMER_AUDIO_FOUND)
355+
if (BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN AND NOT LIBGSTREAMER_FOUND)
356+
if (TRY_BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN)
357+
message(NOTICE "Some required gstreamer dependencies were not found. Gstreamer audio player plugin won't be built.")
358+
else()
359+
message(ERROR "Some required gstreamer dependencies were not found. Can't build gstreamer audio player plugin.")
360+
endif()
361+
endif()
362+
363+
if (BUILD_GSTREAMER_AUDIO_PLAYER_PLUGIN AND LIBGSTREAMER_FOUND)
365364
target_sources(flutterpi_module PRIVATE
366365
src/plugins/audioplayers/plugin.c
367366
src/plugins/audioplayers/player.c
368367
)
369-
target_link_libraries(flutterpi_module PUBLIC
370-
PkgConfig::LIBGSTREAMER
371-
PkgConfig::LIBGSTREAMER_APP
372-
PkgConfig::LIBGSTREAMER_AUDIO
373-
)
374-
else()
375-
message(NOTICE "Couldn't find gstreamer libraries. Gstreamer audio player plugin won't be build.")
376368
endif()
377369
endif()
378370

@@ -391,10 +383,10 @@ if (BUILD_SENTRY_PLUGIN)
391383

392384
if (SENTRY_BACKEND STREQUAL "crashpad" AND SENTRY_PLUGIN_BUNDLE_CRASHPAD_HANDLER)
393385
set(HAVE_BUNDLED_CRASHPAD_HANDLER ON)
394-
386+
395387
target_sources(flutter-pi PRIVATE src/crashpad_handler_trampoline.cc)
396388
# link against the same libraries the crashpad_handler uses
397-
389+
398390
get_target_property(handler_deps crashpad_handler INTERFACE_LINK_LIBRARIES)
399391
target_link_libraries(flutter-pi PUBLIC ${handler_deps})
400392
endif()

config.h.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@
2626
#cmakedefine ENABLE_MTRACE
2727
#cmakedefine ENABLE_ASAN
2828
#cmakedefine HAVE_BUNDLED_CRASHPAD_HANDLER
29+
#cmakedefine HAVE_GSTREAMER_VIDEO_PLAYER
2930

3031
#endif

0 commit comments

Comments
 (0)