Skip to content

Commit 22160f3

Browse files
committed
chore: Add objc modules to libwebrtc for mac (#179)
* add objc modules to libwebrtc for mac * [skip ci] Update plugins
1 parent 381f8ed commit 22160f3

File tree

6 files changed

+49
-6
lines changed

6 files changed

+49
-6
lines changed

BuildScripts~/build_libwebrtc_macos.sh

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ fi
2424
# add jsoncpp
2525
patch -N "src/BUILD.gn" < "$COMMAND_DIR/patches/add_jsoncpp.patch"
2626

27+
# add objc library to use videotoolbox
28+
patch -N "src/sdk/BUILD.gn" < "$COMMAND_DIR/patches/add_objc_mac.patch"
29+
2730
mkdir -p "$ARTIFACTS_DIR/lib"
2831

2932
# generate ninja files for release
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--- src/sdk/BUILD.gn 2020-08-31 17:02:50.000000000 +0900
2+
+++ src/sdk/BUILD.gn.edited 2020-08-31 17:15:53.000000000 +0900
3+
@@ -24,6 +24,16 @@ group("sdk") {
4+
if (is_ios) {
5+
public_deps += [ ":framework_objc" ]
6+
}
7+
+ if(is_mac) {
8+
+ public_deps += [
9+
+ ":base_objc",
10+
+ ":default_codec_factory_objc",
11+
+ ":native_api",
12+
+ ":native_video",
13+
+ ":videocodec_objc",
14+
+ ":videotoolbox_objc"
15+
+ ]
16+
+ }
17+
}
18+
}
19+

Plugin~/WebRTCPlugin/CMakeLists.txt

+9-2
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,11 @@ if(MSVC)
3838
elseif(APPLE)
3939
file(GLOB append_source
4040
../libcxx/debug.cpp
41+
*.mm
4142
GraphicsDevice/Metal/*.h
4243
GraphicsDevice/Metal/*.mm
4344
Codec/SoftwareCodec/*.h
4445
Codec/SoftwareCodec/*.cpp
45-
#Codec/VideoToolbox/VTEncoderMetal.mm
46-
#Codec/VideoToolbox/VTEncoderMetal.h
4746
)
4847
list (APPEND sources ${append_source})
4948
elseif(UNIX)
@@ -165,7 +164,15 @@ elseif(APPLE)
165164
PROPERTIES LIBRARY_OUTPUT_DIRECTORY_RELEASE
166165
${PROJECT_BINARY_DIR}
167166
)
167+
target_include_directories(webrtc
168+
PRIVATE
169+
${WEBRTC_OBJC_INCLUDE_DIR}
170+
)
168171

172+
set_target_properties( webrtc
173+
PROPERTIES LINK_FLAGS
174+
"-ObjC"
175+
)
169176
elseif(UNIX)
170177
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-lto -fno-rtti -stdlib=libc++")
171178

Plugin~/WebRTCPluginTest/CMakeLists.txt

+7
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ if(MSVC)
4141
elseif(APPLE)
4242
file(GLOB append_source
4343
../libcxx/debug.cpp
44+
../WebRTCPlugin/*.mm
4445
../WebRTCPlugin/GraphicsDevice/Metal/*.h
4546
../WebRTCPlugin/GraphicsDevice/Metal/*.mm
4647
../WebRTCPlugin/Codec/SoftwareCodec/*.h
@@ -132,6 +133,11 @@ if(MSVC)
132133
elseif(APPLE)
133134
set(CMAKE_C_FLAGS "-x objective-c")
134135
set(CMAKE_CXX_FLAGS "-x objective-c++")
136+
137+
set_target_properties( WebRTCPluginTest
138+
PROPERTIES LINK_FLAGS
139+
"-ObjC"
140+
)
135141

136142
target_compile_definitions(WebRTCPluginTest
137143
PRIVATE
@@ -151,6 +157,7 @@ elseif(APPLE)
151157
target_include_directories(WebRTCPluginTest
152158
PRIVATE
153159
..
160+
${WEBRTC_OBJC_INCLUDE_DIR}
154161
)
155162
elseif(UNIX)
156163
find_package(OpenGL REQUIRED)

Plugin~/cmake/FindFramework.cmake

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
find_library(CORE_FOUNDATION Foundation)
3+
find_library(AV_FOUNDATION AVFoundation)
34
find_library(APPLICATION_SERVICES ApplicationServices)
45
find_library(CORE_SERVICES CoreServices)
56
find_library(CORE_AUDIO CoreAudio)
@@ -11,6 +12,7 @@ find_library(METAL Metal)
1112

1213
set(FRAMEWORK_LIBS
1314
${CORE_FOUNDATION}
15+
${AV_FOUNDATION}
1416
${APPLICATION_SERVICES}
1517
${CORE_SERVICES}
1618
${CORE_AUDIO}

Plugin~/cmake/FindWebRTC.cmake

+9-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@
33
set(WEBRTC_DIR "${CMAKE_SOURCE_DIR}/webrtc")
44

55
set(WEBRTC_INCLUDE_DIR
6-
${WEBRTC_DIR}/include
7-
${WEBRTC_DIR}/include/third_party/abseil-cpp
8-
${WEBRTC_DIR}/include/third_party/jsoncpp/source/include
9-
${WEBRTC_DIR}/include/third_party/jsoncpp/generated
6+
${WEBRTC_DIR}/include
7+
${WEBRTC_DIR}/include/third_party/abseil-cpp
8+
${WEBRTC_DIR}/include/third_party/jsoncpp/source/include
9+
${WEBRTC_DIR}/include/third_party/jsoncpp/generated
10+
)
11+
12+
set(WEBRTC_OBJC_INCLUDE_DIR
13+
${WEBRTC_DIR}/include/sdk/objc
14+
${WEBRTC_DIR}/include/sdk/objc/base
1015
)
1116

1217
set(WEBRTC_LIBRARY_DIR

0 commit comments

Comments
 (0)