diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 6e0032098..242b421d5 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -63,6 +63,7 @@ elseif(OS_LINUX) add_subdirectory(linux-v4l2) add_subdirectory(linux-jack) add_subdirectory(linux-alsa) + add_subdirectory(linux-pipewire) add_subdirectory(decklink) add_subdirectory(vlc-video) add_subdirectory(sndio) diff --git a/plugins/linux-pipewire/CMakeLists.txt b/plugins/linux-pipewire/CMakeLists.txt new file mode 100644 index 000000000..9d74a85e8 --- /dev/null +++ b/plugins/linux-pipewire/CMakeLists.txt @@ -0,0 +1,28 @@ +project(linux-pipewire) + +option(ENABLE_PIPEWIRE "Enable PipeWire support" ON) +if(NOT ENABLE_PIPEWIRE) + message(STATUS "PipeWire support disabled, linux-pipewire plugin disabled") + return() +endif() + +find_package(PipeWire REQUIRED) + +if(NOT TARGET PipeWire::PipeWire) + message( + FATAL_ERROR + "OBS: - PipeWire library not found! Please install PipeWire or set ENABLE_PIPEWIRE=OFF" + ) +endif() + +add_library(linux-pipewire MODULE) +add_library(OBS::pipewire ALIAS linux-pipewire) + +target_sources(linux-pipewire PRIVATE linux-pipewire.c pipewire-common.c + pipewire-common.h) + +target_link_libraries(linux-pipewire PRIVATE OBS::libobs PipeWire::PipeWire) + +set_target_properties(linux-pipewire PROPERTIES FOLDER "plugins") + +setup_plugin_target(linux-pipewire) diff --git a/plugins/linux-pipewire/data/.gitkeep b/plugins/linux-pipewire/data/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/plugins/linux-pipewire/linux-pipewire.c b/plugins/linux-pipewire/linux-pipewire.c new file mode 100644 index 000000000..04aafa85b --- /dev/null +++ b/plugins/linux-pipewire/linux-pipewire.c @@ -0,0 +1,43 @@ +/* linux-pipewire.c + * + * Copyright 2021 columbarius + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include +#include + +#include "pipewire-common.h" + +OBS_DECLARE_MODULE() +OBS_MODULE_USE_DEFAULT_LOCALE("linux-pipewire", "en-US") +MODULE_EXPORT const char *obs_module_description(void) +{ + return "PipeWire based sources/outputs"; +} + +bool obs_module_load(void) +{ + obs_pipewire_load(); + + return true; +} + +void obs_module_unload(void) +{ + obs_pipewire_unload(); +} diff --git a/plugins/linux-pipewire/pipewire-common.c b/plugins/linux-pipewire/pipewire-common.c new file mode 100644 index 000000000..9dae00210 --- /dev/null +++ b/plugins/linux-pipewire/pipewire-common.c @@ -0,0 +1,33 @@ +/* pipewire-common.c + * + * Copyright 2021 columbarius + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include + +#include "pipewire-common.h" + +void obs_pipewire_load(void) +{ + pw_init(NULL, NULL); +} + +void obs_pipewire_unload(void) +{ + pw_deinit(); +} diff --git a/plugins/linux-pipewire/pipewire-common.h b/plugins/linux-pipewire/pipewire-common.h new file mode 100644 index 000000000..44ffc42a8 --- /dev/null +++ b/plugins/linux-pipewire/pipewire-common.h @@ -0,0 +1,24 @@ +/* pipewire-common.h + * + * Copyright 2021 columbarius + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#pragma once + +void obs_pipewire_load(void); +void obs_pipewire_unload(void);