Pārlūkot izejas kodu

linux-pipewire: Create new plugin

This plugin should contain different plugins importing and exporting
multimedia streams via PipeWire.
columbarius 4 gadi atpakaļ
vecāks
revīzija
ebe8f6c72a

+ 1 - 0
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)

+ 28 - 0
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)

+ 0 - 0
plugins/linux-pipewire/data/.gitkeep


+ 43 - 0
plugins/linux-pipewire/linux-pipewire.c

@@ -0,0 +1,43 @@
+/* linux-pipewire.c
+ *
+ * Copyright 2021 columbarius <[email protected]>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include <obs-module.h>
+#include <obs-nix-platform.h>
+
+#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();
+}

+ 33 - 0
plugins/linux-pipewire/pipewire-common.c

@@ -0,0 +1,33 @@
+/* pipewire-common.c
+ *
+ * Copyright 2021 columbarius <[email protected]>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include <pipewire/pipewire.h>
+
+#include "pipewire-common.h"
+
+void obs_pipewire_load(void)
+{
+	pw_init(NULL, NULL);
+}
+
+void obs_pipewire_unload(void)
+{
+	pw_deinit();
+}

+ 24 - 0
plugins/linux-pipewire/pipewire-common.h

@@ -0,0 +1,24 @@
+/* pipewire-common.h
+ *
+ * Copyright 2021 columbarius <[email protected]>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#pragma once
+
+void obs_pipewire_load(void);
+void obs_pipewire_unload(void);