Skip to content

Commit 9adb6c8

Browse files
committed
enhancement #12: abstracting gstavpipeline to separate windows and linux code
1 parent f9c34dc commit 9adb6c8

File tree

10 files changed

+602
-393
lines changed

10 files changed

+602
-393
lines changed

Plugin/CMakeLists.txt

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,28 @@ include_directories(${GST_INCLUDE_DIRS} ${GST_ARCH_INCLUDE_DIR})
1313

1414
add_definitions(${GST_CFLAGS_OTHER})
1515

16+
# Check the target platform
17+
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
18+
# Windows-specific code or libraries
19+
set(SOURCE_FILES_WIN
20+
src/GstAVPipelineD3D11.cpp
21+
src/GstAVPipelineD3D11.h
22+
)
23+
24+
set(GST_LIBRARIES_WIN
25+
gstd3d11-1.0
26+
)
27+
28+
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
29+
add_definitions(-DUNITY_LINUX=1)
30+
elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
31+
# Android-specific code or libraries
32+
# ...
33+
else()
34+
# Unsupported platform
35+
message(FATAL_ERROR "Unsupported platform: ${CMAKE_SYSTEM_NAME}")
36+
endif()
37+
1638
set(SOURCE_FILES
1739
src/RenderingPlugin.cpp
1840
src/DebugLog.cpp
@@ -23,13 +45,16 @@ set(SOURCE_FILES
2345
src/Unity/IUnityGraphics.h
2446
src/Unity/IUnityGraphicsD3D11.h
2547
src/Unity/IUnityInterface.h
48+
src/Unity/PlatformBase.h
49+
50+
${SOURCES_FILES_WIN}
2651
)
2752

2853
link_directories(${GST_LIBRARY_DIRS})
2954

3055
add_library(UnityGStreamerPlugin SHARED ${SOURCE_FILES})
3156

32-
target_link_libraries(UnityGStreamerPlugin ${GST_LIBRARIES} gstd3d11-1.0 gstapp-1.0 gstvideo-1.0)
57+
target_link_libraries(UnityGStreamerPlugin ${GST_LIBRARIES} gstapp-1.0 gstvideo-1.0)
3358

3459
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
3560
set(TARGET_ARCH "x86_64")
@@ -41,4 +66,4 @@ add_custom_command(TARGET UnityGStreamerPlugin POST_BUILD
4166
COMMAND ${CMAKE_COMMAND} -E copy
4267
$<TARGET_FILE:UnityGStreamerPlugin>
4368
${CMAKE_SOURCE_DIR}/../UnityProject/Packages/com.pollenrobotics.gstreamerwebrtc/Runtime/Plugins/${TARGET_ARCH}
44-
COMMENT "Copying UnityGStreamerPlugin.dll to destination directory")
69+
COMMENT "Copying UnityGStreamerPlugin library to destination directory")

Plugin/src/DebugLog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include <sstream>
44
#include <stdio.h>
5-
#include <string>
5+
#include <string.h>
66

77
//-------------------------------------------------------------------
88
void Debug::Log(const char* message, Level Level)

Plugin/src/DebugLog.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
#pragma once
2+
#include "Unity/IUnityInterface.h"
23
#include <sstream>
34
#include <stdio.h>
4-
#include <stdio.h>
55
#include <string>
66

7-
#define DLLExport __declspec(dllexport)
8-
97
extern "C"
108
{
119
// Create a callback delegate
1210
typedef void (*FuncCallBack)(const char* message, int Level, int size);
1311
static FuncCallBack callbackInstance = nullptr;
14-
DLLExport void RegisterDebugCallback(FuncCallBack cb);
12+
void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API RegisterDebugCallback(FuncCallBack cb);
1513
}
1614

1715
// Level Enum

0 commit comments

Comments
 (0)