Add image source plugin
A simple plugin that does nothing more than display an image file as a source.
This commit is contained in:
parent
bcd8d5d346
commit
cf0b8be3a2
@ -14,6 +14,7 @@ elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
|
||||
add_subdirectory(linux-v4l2)
|
||||
endif()
|
||||
|
||||
add_subdirectory(image-source)
|
||||
add_subdirectory(obs-x264)
|
||||
add_subdirectory(obs-libfdk)
|
||||
add_subdirectory(obs-ffmpeg)
|
||||
|
11
plugins/image-source/CMakeLists.txt
Normal file
11
plugins/image-source/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
||||
project(image-source)
|
||||
|
||||
set(image-source_SOURCES
|
||||
image-source.c)
|
||||
|
||||
add_library(image-source MODULE
|
||||
${image-source_SOURCES})
|
||||
target_link_libraries(image-source
|
||||
libobs)
|
||||
|
||||
install_obs_plugin(image-source)
|
131
plugins/image-source/image-source.c
Normal file
131
plugins/image-source/image-source.c
Normal file
@ -0,0 +1,131 @@
|
||||
#include <obs-module.h>
|
||||
|
||||
#define warn(format, ...) \
|
||||
blog(LOG_WARNING, "[image_source: '%s'] " format, \
|
||||
obs_source_getname(context->source), ##__VA_ARGS__)
|
||||
|
||||
struct image_source {
|
||||
obs_source_t source;
|
||||
|
||||
texture_t tex;
|
||||
uint32_t cx;
|
||||
uint32_t cy;
|
||||
};
|
||||
|
||||
static const char *image_source_get_name(void)
|
||||
{
|
||||
/* TODO: locale */
|
||||
return "Image";
|
||||
}
|
||||
|
||||
static void image_source_update(void *data, obs_data_t settings)
|
||||
{
|
||||
struct image_source *context = data;
|
||||
const char *file = obs_data_getstring(settings, "file");
|
||||
|
||||
gs_entercontext(obs_graphics());
|
||||
|
||||
if (context->tex) {
|
||||
texture_destroy(context->tex);
|
||||
context->tex = NULL;
|
||||
}
|
||||
|
||||
if (file) {
|
||||
context->tex = gs_create_texture_from_file(file);
|
||||
if (context->tex) {
|
||||
context->cx = texture_getwidth(context->tex);
|
||||
context->cy = texture_getheight(context->tex);
|
||||
} else {
|
||||
warn("failed to load texture '%s'", file);
|
||||
context->cx = 0;
|
||||
context->cy = 0;
|
||||
}
|
||||
}
|
||||
|
||||
gs_leavecontext();
|
||||
}
|
||||
|
||||
static void *image_source_create(obs_data_t settings, obs_source_t source)
|
||||
{
|
||||
struct image_source *context = bzalloc(sizeof(struct image_source));
|
||||
context->source = source;
|
||||
|
||||
image_source_update(context, settings);
|
||||
return context;
|
||||
}
|
||||
|
||||
static void image_source_destroy(void *data)
|
||||
{
|
||||
struct image_source *context = data;
|
||||
|
||||
gs_entercontext(obs_graphics());
|
||||
texture_destroy(context->tex);
|
||||
gs_leavecontext();
|
||||
|
||||
bfree(context);
|
||||
}
|
||||
|
||||
static uint32_t image_source_getwidth(void *data)
|
||||
{
|
||||
struct image_source *context = data;
|
||||
return context->cx;
|
||||
}
|
||||
|
||||
static uint32_t image_source_getheight(void *data)
|
||||
{
|
||||
struct image_source *context = data;
|
||||
return context->cy;
|
||||
}
|
||||
|
||||
static void image_source_render(void *data, effect_t effect)
|
||||
{
|
||||
struct image_source *context = data;
|
||||
if (!context->tex)
|
||||
return;
|
||||
|
||||
effect_settexture(effect_getparambyname(effect, "image"), context->tex);
|
||||
gs_draw_sprite(context->tex, 0, context->cx, context->cy);
|
||||
}
|
||||
|
||||
static const char *image_filter =
|
||||
"All formats (*.bmp *.tga *.png *.jpeg *.jpg *.gif);;"
|
||||
"BMP Files (*.bmp);;"
|
||||
"Targa Files (*.tga);;"
|
||||
"PNG Files (*.png);;"
|
||||
"JPEG Files (*.jpeg *.jpg);;"
|
||||
"GIF Files (*.gif)";
|
||||
|
||||
static obs_properties_t image_source_properties(void)
|
||||
{
|
||||
obs_properties_t props = obs_properties_create();
|
||||
|
||||
/* TODO: locale */
|
||||
obs_properties_add_path(props, "file", "Image file", OBS_PATH_FILE,
|
||||
image_filter, NULL);
|
||||
|
||||
return props;
|
||||
}
|
||||
|
||||
static struct obs_source_info image_source_info = {
|
||||
.id = "image_source",
|
||||
.type = OBS_SOURCE_TYPE_INPUT,
|
||||
.output_flags = OBS_SOURCE_VIDEO,
|
||||
.getname = image_source_get_name,
|
||||
.create = image_source_create,
|
||||
.destroy = image_source_destroy,
|
||||
.update = image_source_update,
|
||||
.getwidth = image_source_getwidth,
|
||||
.getheight = image_source_getheight,
|
||||
.video_render = image_source_render,
|
||||
.properties = image_source_properties
|
||||
};
|
||||
|
||||
OBS_DECLARE_MODULE()
|
||||
|
||||
bool obs_module_load(uint32_t libobs_version)
|
||||
{
|
||||
obs_register_source(&image_source_info);
|
||||
|
||||
UNUSED_PARAMETER(libobs_version);
|
||||
return true;
|
||||
}
|
@ -78,6 +78,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "win-dshow", "win-dshow\win-
|
||||
{6F1AC2AE-6424-401A-AF9F-A771E6BEE026} = {6F1AC2AE-6424-401A-AF9F-A771E6BEE026}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "image-source", "image-source\image-source.vcxproj", "{49B9AB5A-4CF2-4AC8-84EC-CD9E537C65DE}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Mixed Platforms = Debug|Mixed Platforms
|
||||
@ -280,6 +282,18 @@ Global
|
||||
{E733E9CB-EA71-4E77-BD28-2D06F4AA4677}.Release|Win32.Build.0 = Release|Win32
|
||||
{E733E9CB-EA71-4E77-BD28-2D06F4AA4677}.Release|x64.ActiveCfg = Release|x64
|
||||
{E733E9CB-EA71-4E77-BD28-2D06F4AA4677}.Release|x64.Build.0 = Release|x64
|
||||
{49B9AB5A-4CF2-4AC8-84EC-CD9E537C65DE}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
||||
{49B9AB5A-4CF2-4AC8-84EC-CD9E537C65DE}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
||||
{49B9AB5A-4CF2-4AC8-84EC-CD9E537C65DE}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{49B9AB5A-4CF2-4AC8-84EC-CD9E537C65DE}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{49B9AB5A-4CF2-4AC8-84EC-CD9E537C65DE}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{49B9AB5A-4CF2-4AC8-84EC-CD9E537C65DE}.Debug|x64.Build.0 = Debug|x64
|
||||
{49B9AB5A-4CF2-4AC8-84EC-CD9E537C65DE}.Release|Mixed Platforms.ActiveCfg = Release|Win32
|
||||
{49B9AB5A-4CF2-4AC8-84EC-CD9E537C65DE}.Release|Mixed Platforms.Build.0 = Release|Win32
|
||||
{49B9AB5A-4CF2-4AC8-84EC-CD9E537C65DE}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{49B9AB5A-4CF2-4AC8-84EC-CD9E537C65DE}.Release|Win32.Build.0 = Release|Win32
|
||||
{49B9AB5A-4CF2-4AC8-84EC-CD9E537C65DE}.Release|x64.ActiveCfg = Release|x64
|
||||
{49B9AB5A-4CF2-4AC8-84EC-CD9E537C65DE}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
171
vs/2013/image-source/image-source.vcxproj
Normal file
171
vs/2013/image-source/image-source.vcxproj
Normal file
@ -0,0 +1,171 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{49B9AB5A-4CF2-4AC8-84EC-CD9E537C65DE}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>imagesource</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;IMAGESOURCE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>../../../libobs</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>libobs.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>copy "$(OutDir)$(TargetName)$(TargetExt)" "../../../build/obs-plugins/32bit/$(TargetName)$(TargetExt)"</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;IMAGESOURCE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>../../../libobs</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>libobs.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>copy "$(OutDir)$(TargetName)$(TargetExt)" "../../../build/obs-plugins/64bit/$(TargetName)$(TargetExt)"</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;IMAGESOURCE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>../../../libobs</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>libobs.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>copy "$(OutDir)$(TargetName)$(TargetExt)" "../../../build/obs-plugins/32bit/$(TargetName)$(TargetExt)"</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;IMAGESOURCE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>../../../libobs</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>libobs.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>copy "$(OutDir)$(TargetName)$(TargetExt)" "../../../build/obs-plugins/64bit/$(TargetName)$(TargetExt)"</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\plugins\image-source\image-source.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
22
vs/2013/image-source/image-source.vcxproj.filters
Normal file
22
vs/2013/image-source/image-source.vcxproj.filters
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\plugins\image-source\image-source.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
x
Reference in New Issue
Block a user