Skip to content
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

Add gstreamer based audioplayers plugin #277

Merged
merged 16 commits into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
8 changes: 4 additions & 4 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ jobs:

steps:
- uses: actions/checkout@v2

- name: Install dependencies
run: sudo apt-get install -y cmake libgl1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev libdrm-dev libgbm-dev ttf-mscorefonts-installer fontconfig libsystemd-dev libinput-dev libudev-dev libxkbcommon-dev ninja-build

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DBUILD_OMXPLAYER_VIDEO_PLAYER_PLUGIN=On -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -GNinja
run: cmake -B ${{github.workspace}}/build -DBUILD_OMXPLAYER_VIDEO_PLAYER_PLUGIN=On -DBUILD_GSTREAMER_AUDIO_VIDEO_PLAYER_PLUGIN=off -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -GNinja
DoumanAsh marked this conversation as resolved.
Show resolved Hide resolved

- name: Build
# Build your program with the given configuration
Expand All @@ -37,7 +37,7 @@ jobs:
- name: Test
if: false
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${{env.BUILD_TYPE}}

15 changes: 11 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ option(BUILD_TEXT_INPUT_PLUGIN "Include the text input plugin in the finished bi
option(BUILD_RAW_KEYBOARD_PLUGIN "Include the raw keyboard plugin in the finished binary. Enables raw keycode listening in flutter via the flutter RawKeyboard interface." ON)
option(BUILD_TEST_PLUGIN "Include the test plugin in the finished binary. Allows testing platform channel communication." OFF)
option(BUILD_OMXPLAYER_VIDEO_PLAYER_PLUGIN "Include the omxplayer_video_player plugin in the finished binary. Allows for hardware accelerated video playback in flutter using omxplayer." ON)
option(BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN "Include the gstreamer_video_player plugin in the finished binary. Allows for more stable, hardware accelerated video playback in flutter using gstreamer." ON)
option(TRY_BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN "Don't throw an error if the gstreamer libs aren't found, instead just don't build the gstreamer video player plugin in that case." ON)
option(BUILD_GSTREAMER_AUDIO_VIDEO_PLAYER_PLUGIN "Include the gstreamer based video and audio plugins in the finished binary. Allows for more stable, hardware accelerated video playback in flutter using gstreamer." ON)
option(TRY_BUILD_GSTREAMER_AUDIO_VIDEO_PLAYER_PLUGIN "Don't throw an error if the gstreamer libs aren't found, instead just don't build the gstreamer audio and video player plugin in that case." ON)
ardera marked this conversation as resolved.
Show resolved Hide resolved
option(DUMP_ENGINE_LAYERS "True if flutter-pi should dump the list of rendering layers that the flutter engine sends to flutter-pi on each draw." OFF)
option(ENABLE_TSAN "True to build & link with -fsanitize=thread" OFF)
option(ENABLE_ASAN "True to build & link with -fsanitize=address" OFF)
Expand Down Expand Up @@ -191,26 +191,30 @@ endif()
if (OMXPLAYER_SUPPORTS_RUNTIME_ROTATION)
target_compile_definitions(flutter-pi PRIVATE "OMXPLAYER_SUPPORTS_RUNTIME_ROTATION")
endif()
if (BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN)
if (TRY_BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN)
if (BUILD_GSTREAMER_AUDIO_VIDEO_PLAYER_PLUGIN)
if (TRY_BUILD_GSTREAMER_AUDIO_VIDEO_PLAYER_PLUGIN)
ardera marked this conversation as resolved.
Show resolved Hide resolved
pkg_check_modules(LIBGSTREAMER gstreamer-1.0)
pkg_check_modules(LIBGSTREAMER_PLUGINS_BASE gstreamer-plugins-base-1.0)
pkg_check_modules(LIBGSTREAMER_APP gstreamer-app-1.0)
pkg_check_modules(LIBGSTREAMER_ALLOCATORS gstreamer-allocators-1.0)
pkg_check_modules(LIBGSTREAMER_VIDEO gstreamer-video-1.0)
pkg_check_modules(LIBGSTREAMER-AUDIO REQUIRED gstreamer-audio-1.0)
ardera marked this conversation as resolved.
Show resolved Hide resolved
else()
pkg_check_modules(LIBGSTREAMER REQUIRED gstreamer-1.0)
pkg_check_modules(LIBGSTREAMER_PLUGINS_BASE REQUIRED gstreamer-plugins-base-1.0)
pkg_check_modules(LIBGSTREAMER_APP REQUIRED gstreamer-app-1.0)
pkg_check_modules(LIBGSTREAMER_ALLOCATORS REQUIRED gstreamer-allocators-1.0)
pkg_check_modules(LIBGSTREAMER_VIDEO REQUIRED gstreamer-video-1.0)
pkg_check_modules(LIBGSTREAMER-AUDIO REQUIRED gstreamer-audio-1.0)
ardera marked this conversation as resolved.
Show resolved Hide resolved
endif()

if (LIBGSTREAMER_FOUND AND LIBGSTREAMER_PLUGINS_BASE_FOUND AND LIBGSTREAMER_APP_FOUND AND LIBGSTREAMER_ALLOCATORS_FOUND AND LIBGSTREAMER_VIDEO_FOUND)
ardera marked this conversation as resolved.
Show resolved Hide resolved
target_sources(flutter-pi PRIVATE
src/plugins/gstreamer_video_player/plugin.c
src/plugins/gstreamer_video_player/player.c
src/plugins/gstreamer_video_player/frame.c
src/plugins/audioplayers/plugin.c
src/plugins/audioplayers/player.c
)
target_compile_definitions(flutter-pi PRIVATE "BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN")
target_link_libraries(flutter-pi
Expand All @@ -219,20 +223,23 @@ if (BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN)
${LIBGSTREAMER_APP_LDFLAGS}
${LIBGSTREAMER_ALLOCATORS_LDFLAGS}
${LIBGSTREAMER_VIDEO_LDFLAGS}
${LIBGSTREAMER-AUDIO_LIBRARY_DIRS}
ardera marked this conversation as resolved.
Show resolved Hide resolved
)
target_include_directories(flutter-pi PRIVATE
${LIBGSTREAMER_INCLUDE_DIRS}
${LIBGSTREAMER_PLUGINS_BASE_INCLUDE_DIRS}
${LIBGSTREAMER_APP_INCLUDE_DIRS}
${LIBGSTREAMER_ALLOCATORS_INCLUDE_DIRS}
${LIBGSTREAMER_VIDEO_INCLUDE_DIRS}
${LIBGSTREAMER-AUDIO_INCLUDE_DIRS}
ardera marked this conversation as resolved.
Show resolved Hide resolved
)
target_compile_options(flutter-pi PRIVATE
${LIBGSTREAMER_CFLAGS}
${LIBGSTREAMER_PLUGINS_BASE_CFLAGS}
${LIBGSTREAMER_APP_CFLAGS}
${LIBGSTREAMER_ALLOCATORS_CFLAGS}
${LIBGSTREAMER_VIDEO_CFLAGS}
${LIBGSTREAMER_AUDIO_CFLAGS}
ardera marked this conversation as resolved.
Show resolved Hide resolved
)
else()
message(NOTICE "Couldn't find gstreamer libraries. Gstreamer video player plugin won't be build.")
Expand Down
41 changes: 41 additions & 0 deletions include/plugins/audioplayers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#ifndef AUDIOPLAYERS_H_
#define AUDIOPLAYERS_H_

#include <stdbool.h>
#include <stdint.h>

#include <gst/gst.h>

DoumanAsh marked this conversation as resolved.
Show resolved Hide resolved
struct audio_player;

struct audio_player *audio_player_new(char *playerId, char *channel);

// Instance function

int64_t audio_player_get_position(struct audio_player *self);

int64_t audio_player_get_duration(struct audio_player *self);

bool audio_player_get_loopin(struct audio_player *self);
DoumanAsh marked this conversation as resolved.
Show resolved Hide resolved

void audio_player_play(struct audio_player *self);

void audio_player_pause(struct audio_player *self);

void audio_player_resume(struct audio_player *self);

void audio_player_dispose(struct audio_player *self);
DoumanAsh marked this conversation as resolved.
Show resolved Hide resolved

void audio_player_set_looping(struct audio_player *self, bool isLooping);

void audio_player_set_volume(struct audio_player *self, double volume);

void audio_player_set_playback_rate(struct audio_player *self, double rate);

void audio_player_set_position(struct audio_player *self, int64_t position);

void audio_player_set_source_url(struct audio_player *self, char *url);

bool audio_player_is_id(struct audio_player *self, char *id);

#endif // AUDIOPLAYERS_H_
Loading