Added obs-v4l2sink ebuild.

This commit is contained in:
kimitsune 2020-04-22 22:00:27 +02:00
parent a15e445871
commit 06bca8c09b
5 changed files with 453 additions and 0 deletions

View File

@ -0,0 +1,4 @@
AUX CMakeLists.txt 1013 BLAKE2B ba247fd42721925d46bec983d29200697833ba07f824ae3f6e5eaf051d6f1bb083d8ab25ce10c6c88b790d8e06360fab62e589d865d49e23df8475b4a2f64fba SHA512 e43052ace6e233e94b37cba1f69b5330f6dd20474179d91d54a507355a0ad589bb1f32ea9b69edd897fbafd0c3c0106ac17c8420de7134acfe2e7318aac6c9ed
AUX ObsPluginHelpers.cmake 6062 BLAKE2B 51667d8ed211d9ad87e29cbf4e46b996f87166158b181bb3d5a60c7e44dcdcd5d32a04b503b51428fdaeb380a1d8866c95bfb450e66330ce4424ba8e22c67194 SHA512 2ef0b705e3cae4258b17c9852ad0f904158285ca4d829f87749039a680d0e79308c2386eea72b01e2c157d1c60e974d2f34dd9c4b156f4b2aa4096115bde6744
AUX obs-frontend-api/obs-frontend-api.h 7115 BLAKE2B 7bec1d273f0009b483acc4ef4f3d66b54453dba651e352fe160d3000c58918c3b042af92a759ccd5ae9560dae0d606887ea60c52b21d1b28f40aa9202c8fcd97 SHA512 0c7515c9422b09a54f15d08cf6a9fe64d8f40f5f5ea353474cb4d7d81b2cd89d522fa0efbe9d2f1ea4822b0b237773424573f856150b4793fbacc1c8531528bc
EBUILD obs-v4l2sink-0.1.0.ebuild 1253 BLAKE2B c13db6bcd53ecf1f6a27de9df748cd49e2ed7c84fd86fa2d6eb2b5df8aec5f061822e40652d284d40785b0ff57c83b0925212f5267ab748471175c1da163f8ef SHA512 43e40bdfe6e28e5cbcd38e0088d92347eb2f0625136a1e8d128b8174f81ca27cbe60cda432cbf832293a7ce68ba60870b04554373f99610a3b289bda1c9a0494

View File

@ -0,0 +1,50 @@
cmake_minimum_required(VERSION 3.5)
project(obs-v4l2sink)
include(external/FindLibObs.cmake)
find_package(LibObs REQUIRED)
set (CMAKE_CXX_STANDARD 11)
set(CMAKE_PREFIX_PATH "${QTDIR}")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
find_package(Qt5Core REQUIRED)
find_package(Qt5Widgets REQUIRED)
set(virtualoutput_SOURCES
src/v4l2sink.cpp
src/v4l2sinkproperties.cpp)
set(virtualoutput_HEADERS
src/v4l2sink.h
src/v4l2sinkproperties.h)
include_directories("EBUILDFILESDIR/obs-frontend-api")
add_library(v4l2sink MODULE
${virtualoutput_SOURCES}
${virtualoutput_HEADERS})
target_link_libraries(v4l2sink
libobs
Qt5::Core
Qt5::Widgets)
if(ARCH EQUAL 64)
set(ARCH_NAME "x86_64")
else()
set(ARCH_NAME "i686")
endif()
set_target_properties(v4l2sink PROPERTIES PREFIX "")
install(TARGETS v4l2sink
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/obs-plugins)
install(DIRECTORY locale/
DESTINATION "${CMAKE_INSTALL_PREFIX}/share/obs/obs-plugins/v4l2sink/locale")

View File

@ -0,0 +1,163 @@
# Functions for generating external plugins
set(EXTERNAL_PLUGIN_OUTPUT_DIR "${CMAKE_BINARY_DIR}/rundir")
# Fix XCode includes to ignore warnings on system includes
function(target_include_directories_system _target)
if(XCODE)
foreach(_arg ${ARGN})
if("${_arg}" STREQUAL "PRIVATE" OR "${_arg}" STREQUAL "PUBLIC" OR "${_arg}" STREQUAL "INTERFACE")
set(_scope ${_arg})
else()
target_compile_options(${_target} ${_scope} -isystem${_arg})
endif()
endforeach()
else()
target_include_directories(${_target} SYSTEM ${_scope} ${ARGN})
endif()
endfunction()
function(install_external_plugin_data_internal target source_dir target_dir)
install(DIRECTORY ${source_dir}/
DESTINATION "${target}/${target_dir}"
USE_SOURCE_PERMISSIONS)
add_custom_command(TARGET ${target} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${CMAKE_CURRENT_SOURCE_DIR}/${source_dir}" "${EXTERNAL_PLUGIN_OUTPUT_DIR}/$<CONFIGURATION>/${target}/${target_dir}"
VERBATIM)
endfunction()
# Installs data
# 'target' is the destination target project being installed to
# 'data_loc' specifies the directory of the data
function(install_external_plugin_data target data_loc)
install_external_plugin_data_internal(${target} ${data_loc} "data")
endfunction()
# Installs data in an architecture-specific data directory on windows/linux (data/32bit or data/64bit). Does not apply for mac.
# 'target' is the destination target project being installed to
# 'data_loc' specifies the directory of the data being installed
function(install_external_plugin_arch_data target data_loc)
if(APPLE)
set(_bit_suffix "")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(_bit_suffix "/64bit")
else()
set(_bit_suffix "/32bit")
endif()
install_external_plugin_data_internal(${target} ${data_loc} "data${_bit_suffix}")
endfunction()
# Installs data in the target's bin directory
# 'target' is the destination target project being installed to
# 'data_loc' specifies the directory of the data being installed
function(install_external_plugin_data_to_bin target data_loc)
if(APPLE)
set(_bit_suffix "")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(_bit_suffix "/64bit")
else()
set(_bit_suffix "/32bit")
endif()
install_external_plugin_data_internal(${target} ${data_loc} "bin${_bit_suffix}")
endfunction()
# Installs an additional binary to a target
# 'target' is the destination target project being installed to
# 'additional_target' specifies the additional binary
function(install_external_plugin_additional target additional_target)
if(APPLE)
set(_bit_suffix "")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(_bit_suffix "64bit/")
else()
set(_bit_suffix "32bit/")
endif()
set_target_properties(${additional_target} PROPERTIES
PREFIX "")
install(TARGETS ${additional_target}
LIBRARY DESTINATION "bin"
RUNTIME DESTINATION "bin")
add_custom_command(TARGET ${additional_target} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy
"$<TARGET_FILE:${additional_target}>"
"${EXTERNAL_PLUGIN_OUTPUT_DIR}/$<CONFIGURATION>/${target}/bin/${_bit_suffix}$<TARGET_FILE_NAME:${additional_target}>"
VERBATIM)
endfunction()
# Installs the binary of the target
# 'target' is the target project being installed
function(install_external_plugin target)
install_external_plugin_additional(${target} ${target})
endfunction()
# Installs the binary and data of the target
# 'target' is the destination target project being installed to
function(install_external_plugin_with_data target data_loc)
install_external_plugin(${target})
install_external_plugin_data(${target} ${data_loc})
endfunction()
# Installs an additional binary to the data of a target
# 'target' is the destination target project being installed to
# 'additional_target' specifies the additional binary
function(install_external_plugin_bin_to_data target additional_target)
install(TARGETS ${additional_target}
LIBRARY DESTINATION "data"
RUNTIME DESTINATION "data")
add_custom_command(TARGET ${additional_target} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy
"$<TARGET_FILE:${additional_target}>"
"${EXTERNAL_PLUGIN_OUTPUT_DIR}/$<CONFIGURATION>/${target}/data/$<TARGET_FILE_NAME:${additional_target}>"
VERBATIM)
endfunction()
# Installs an additional binary in an architecture-specific data directory on windows/linux (data/32bit or data/64bit). Does not apply for mac.
# 'target' is the destination target project being installed to
# 'additional_target' specifies the additional binary
function(install_external_plugin_bin_to_arch_data target additional_target)
if(APPLE)
set(_bit_suffix "")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(_bit_suffix "/64bit")
else()
set(_bit_suffix "/32bit")
endif()
install(TARGETS ${additional_target}
LIBRARY DESTINATION "data${_bit_suffix}"
RUNTIME DESTINATION "data${_bit_suffix}")
add_custom_command(TARGET ${additional_target} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy
"$<TARGET_FILE:${additional_target}>"
"${EXTERNAL_PLUGIN_OUTPUT_DIR}/$<CONFIGURATION>/${target}/data${_bit_suffix}/$<TARGET_FILE_NAME:${additional_target}>"
VERBATIM)
endfunction()
# Installs an additional file in an architecture-specific data directory on windows/linux (data/32bit or data/64bit). Does not apply for mac.
# 'target' is the destination target project being installed to
# 'additional_target' specifies the additional binary
function(install_external_plugin_data_file_to_arch_data target additional_target file_target)
if(APPLE)
set(_bit_suffix "")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(_bit_suffix "/64bit")
else()
set(_bit_suffix "/32bit")
endif()
get_filename_component(file_target_name ${file_target} NAME)
install(TARGETS ${additional_target}
LIBRARY DESTINATION "data${_bit_suffix}"
RUNTIME DESTINATION "data${_bit_suffix}")
add_custom_command(TARGET ${additional_target} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy
"${file_target}"
"${EXTERNAL_PLUGIN_OUTPUT_DIR}/$<CONFIGURATION>/${target}/data${_bit_suffix}/${file_target_name}"
VERBATIM)
endfunction()

View File

@ -0,0 +1,199 @@
#pragma once
#include <obs.h>
#include <util/darray.h>
#ifdef __cplusplus
extern "C" {
#endif
struct config_data;
typedef struct config_data config_t;
struct obs_data;
typedef struct obs_data obs_data_t;
enum obs_frontend_event {
OBS_FRONTEND_EVENT_STREAMING_STARTING,
OBS_FRONTEND_EVENT_STREAMING_STARTED,
OBS_FRONTEND_EVENT_STREAMING_STOPPING,
OBS_FRONTEND_EVENT_STREAMING_STOPPED,
OBS_FRONTEND_EVENT_RECORDING_STARTING,
OBS_FRONTEND_EVENT_RECORDING_STARTED,
OBS_FRONTEND_EVENT_RECORDING_STOPPING,
OBS_FRONTEND_EVENT_RECORDING_STOPPED,
OBS_FRONTEND_EVENT_SCENE_CHANGED,
OBS_FRONTEND_EVENT_SCENE_LIST_CHANGED,
OBS_FRONTEND_EVENT_TRANSITION_CHANGED,
OBS_FRONTEND_EVENT_TRANSITION_STOPPED,
OBS_FRONTEND_EVENT_TRANSITION_LIST_CHANGED,
OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGED,
OBS_FRONTEND_EVENT_SCENE_COLLECTION_LIST_CHANGED,
OBS_FRONTEND_EVENT_PROFILE_CHANGED,
OBS_FRONTEND_EVENT_PROFILE_LIST_CHANGED,
OBS_FRONTEND_EVENT_EXIT,
OBS_FRONTEND_EVENT_REPLAY_BUFFER_STARTING,
OBS_FRONTEND_EVENT_REPLAY_BUFFER_STARTED,
OBS_FRONTEND_EVENT_REPLAY_BUFFER_STOPPING,
OBS_FRONTEND_EVENT_REPLAY_BUFFER_STOPPED,
OBS_FRONTEND_EVENT_STUDIO_MODE_ENABLED,
OBS_FRONTEND_EVENT_STUDIO_MODE_DISABLED,
OBS_FRONTEND_EVENT_PREVIEW_SCENE_CHANGED,
OBS_FRONTEND_EVENT_SCENE_COLLECTION_CLEANUP,
OBS_FRONTEND_EVENT_FINISHED_LOADING,
OBS_FRONTEND_EVENT_RECORDING_PAUSED,
OBS_FRONTEND_EVENT_RECORDING_UNPAUSED,
OBS_FRONTEND_EVENT_TRANSITION_DURATION_CHANGED,
};
/* ------------------------------------------------------------------------- */
#ifndef SWIG
struct obs_frontend_source_list {
DARRAY(obs_source_t *) sources;
};
static inline void
obs_frontend_source_list_free(struct obs_frontend_source_list *source_list)
{
size_t num = source_list->sources.num;
for (size_t i = 0; i < num; i++)
obs_source_release(source_list->sources.array[i]);
da_free(source_list->sources);
}
#endif //!SWIG
/* ------------------------------------------------------------------------- */
/* NOTE: Functions that return char** string lists are a single allocation of
* memory with pointers to itself. Free with a single call to bfree on the
* base char** pointer. */
/* NOTE: User interface should not use typical Qt locale translation methods,
* as the OBS UI bypasses it to use a custom translation implementation. Use
* standard module translation methods, obs_module_text. For text in a Qt
* window, use obs_frontend_push_ui_translation when the text is about to be
* translated, and obs_frontend_pop_ui_translation when translation is
* complete. */
#ifndef SWIG
EXPORT void *obs_frontend_get_main_window(void);
EXPORT void *obs_frontend_get_main_window_handle(void);
EXPORT void *obs_frontend_get_system_tray(void);
EXPORT char **obs_frontend_get_scene_names(void);
EXPORT void obs_frontend_get_scenes(struct obs_frontend_source_list *sources);
EXPORT obs_source_t *obs_frontend_get_current_scene(void);
EXPORT void obs_frontend_set_current_scene(obs_source_t *scene);
EXPORT void
obs_frontend_get_transitions(struct obs_frontend_source_list *sources);
EXPORT obs_source_t *obs_frontend_get_current_transition(void);
EXPORT void obs_frontend_set_current_transition(obs_source_t *transition);
EXPORT int obs_frontend_get_transition_duration(void);
EXPORT void obs_frontend_set_transition_duration(int duration);
EXPORT char **obs_frontend_get_scene_collections(void);
EXPORT char *obs_frontend_get_current_scene_collection(void);
EXPORT void obs_frontend_set_current_scene_collection(const char *collection);
EXPORT bool obs_frontend_add_scene_collection(const char *name);
EXPORT char **obs_frontend_get_profiles(void);
EXPORT char *obs_frontend_get_current_profile(void);
EXPORT void obs_frontend_set_current_profile(const char *profile);
typedef void (*obs_frontend_cb)(void *private_data);
EXPORT void *obs_frontend_add_tools_menu_qaction(const char *name);
EXPORT void obs_frontend_add_tools_menu_item(const char *name,
obs_frontend_cb callback,
void *private_data);
/* takes QDockWidget and returns QAction */
EXPORT void *obs_frontend_add_dock(void *dock);
typedef void (*obs_frontend_event_cb)(enum obs_frontend_event event,
void *private_data);
EXPORT void obs_frontend_add_event_callback(obs_frontend_event_cb callback,
void *private_data);
EXPORT void obs_frontend_remove_event_callback(obs_frontend_event_cb callback,
void *private_data);
typedef void (*obs_frontend_save_cb)(obs_data_t *save_data, bool saving,
void *private_data);
EXPORT void obs_frontend_add_save_callback(obs_frontend_save_cb callback,
void *private_data);
EXPORT void obs_frontend_remove_save_callback(obs_frontend_save_cb callback,
void *private_data);
EXPORT void obs_frontend_add_preload_callback(obs_frontend_save_cb callback,
void *private_data);
EXPORT void obs_frontend_remove_preload_callback(obs_frontend_save_cb callback,
void *private_data);
typedef bool (*obs_frontend_translate_ui_cb)(const char *text,
const char **out);
EXPORT void
obs_frontend_push_ui_translation(obs_frontend_translate_ui_cb translate);
EXPORT void obs_frontend_pop_ui_translation(void);
#endif //!SWIG
EXPORT void obs_frontend_streaming_start(void);
EXPORT void obs_frontend_streaming_stop(void);
EXPORT bool obs_frontend_streaming_active(void);
EXPORT void obs_frontend_recording_start(void);
EXPORT void obs_frontend_recording_stop(void);
EXPORT bool obs_frontend_recording_active(void);
EXPORT void obs_frontend_recording_pause(bool pause);
EXPORT bool obs_frontend_recording_paused(void);
EXPORT void obs_frontend_replay_buffer_start(void);
EXPORT void obs_frontend_replay_buffer_save(void);
EXPORT void obs_frontend_replay_buffer_stop(void);
EXPORT bool obs_frontend_replay_buffer_active(void);
EXPORT void obs_frontend_open_projector(const char *type, int monitor,
const char *geometry, const char *name);
EXPORT void obs_frontend_save(void);
EXPORT void obs_frontend_defer_save_begin(void);
EXPORT void obs_frontend_defer_save_end(void);
EXPORT obs_output_t *obs_frontend_get_streaming_output(void);
EXPORT obs_output_t *obs_frontend_get_recording_output(void);
EXPORT obs_output_t *obs_frontend_get_replay_buffer_output(void);
EXPORT config_t *obs_frontend_get_profile_config(void);
EXPORT config_t *obs_frontend_get_global_config(void);
EXPORT void obs_frontend_set_streaming_service(obs_service_t *service);
EXPORT obs_service_t *obs_frontend_get_streaming_service(void);
EXPORT void obs_frontend_save_streaming_service(void);
EXPORT bool obs_frontend_preview_program_mode_active(void);
EXPORT void obs_frontend_set_preview_program_mode(bool enable);
EXPORT void obs_frontend_preview_program_trigger_transition(void);
EXPORT void obs_frontend_set_preview_enabled(bool enable);
EXPORT bool obs_frontend_preview_enabled(void);
EXPORT obs_source_t *obs_frontend_get_current_preview_scene(void);
EXPORT void obs_frontend_set_current_preview_scene(obs_source_t *scene);
/* ------------------------------------------------------------------------- */
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,37 @@
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
EAPI=7
inherit cmake-utils git-r3
DESCRIPTION="Obs studio output plugin for Video4Linux2 devices."
HOMEPAGE="https://github.com/CatxFish/obs-v4l2sink"
MY_AUTHOR="CatxFish"
EGIT_REPO_URI="https://github.com/CatxFish/obs-v4l2sink.git"
if [[ ${PV} == "9999" ]] ; then
EGIT_BRANCH="master"
KEYWORDS=""
else
EGIT_COMMIT="${PV}"
KEYWORDS="~x86 ~amd64"
fi
LICENSE="GPL-2"
SLOT="0"
src_prepare(){
default
sed -i 's=include(${LIBOBS_INCLUDE_DIR}/../cmake/external/ObsPluginHelpers.cmake)=include('"${FILESDIR}"'/ObsPluginHelpers.cmake)=g' "${S}"/external/FindLibObs.cmake || die 'Failed to patch ObsPluginHelpers.camke include location.'
cp -f "${FILESDIR}"/CMakeLists.txt "${S}"/CMakeLists.txt || die "Failed to patch obs-frontend-api include location."
sed -i 's@EBUILDFILESDIR@'"${FILESDIR}"'@g' "${S}"/CMakeLists.txt || die "Failed to patch obs-frontend-api include location."
sed -i 's@/lib/@/'"$(get_libdir)"'/@g' "${S}"/CMakeLists.txt || die "Failed to patch to add correct libdir."
cmake-utils_src_prepare
}
src_configure() {
mycmakeargs=( -DLIBOBS_INCLUDE_DIR="${EPREFIX}"/usr/include/obs/ )
cmake-utils_src_configure
}