mirror of
https://github.com/godotengine/webrtc-native.git
synced 2026-01-07 10:10:05 +03:00
Compare commits
34 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eeabf0a844 | ||
|
|
04fbae6ce3 | ||
|
|
ce3f086ec4 | ||
|
|
00ac03c8e7 | ||
|
|
fa5296a4e4 | ||
|
|
189c353264 | ||
|
|
e44c42fde8 | ||
|
|
524fdde8f2 | ||
|
|
673a4c1a1c | ||
|
|
cf98eb2e7a | ||
|
|
7b92ab2a7b | ||
|
|
e120cc7ed6 | ||
|
|
da20ebf397 | ||
|
|
3711ad23f6 | ||
|
|
001be78500 | ||
|
|
416ea27305 | ||
|
|
65bb4cb9ae | ||
|
|
3014c3099f | ||
|
|
c1c7ae5081 | ||
|
|
9e287f7cee | ||
|
|
a374cf4510 | ||
|
|
9ee98ff0e9 | ||
|
|
f26a1d8e83 | ||
|
|
7a62fe467b | ||
|
|
74f2c78db5 | ||
|
|
db6d416eba | ||
|
|
5f9e74f2fb | ||
|
|
bd8e139ccc | ||
|
|
61e45cb083 | ||
|
|
6983019cab | ||
|
|
54cbe83c56 | ||
|
|
20f8f89c2c | ||
|
|
4b22741255 | ||
|
|
5769d8b2de |
51
.github/actions/webrtc-download/action.yml
vendored
Normal file
51
.github/actions/webrtc-download/action.yml
vendored
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
name: 'Get WebRTC Library'
|
||||||
|
description: 'Get pre-build statically linked WebRTC library from Faless/webrtc-builds'
|
||||||
|
inputs:
|
||||||
|
repo:
|
||||||
|
description: 'Base repository'
|
||||||
|
required: true
|
||||||
|
default: "godotengine/webrtc-actions"
|
||||||
|
release:
|
||||||
|
description: 'Release tag'
|
||||||
|
required: true
|
||||||
|
default: '4472-33644-92ba70c'
|
||||||
|
webrtc-base-name:
|
||||||
|
description: 'The WebRTC version'
|
||||||
|
required: true
|
||||||
|
default: "webrtc-33644-92ba70c"
|
||||||
|
out-dir:
|
||||||
|
description: 'Directory where to extract the library'
|
||||||
|
required: true
|
||||||
|
default: "webrtc"
|
||||||
|
platform:
|
||||||
|
description: 'Platform to download'
|
||||||
|
required: true
|
||||||
|
archs:
|
||||||
|
description: 'Space separated list of architecture to fetch'
|
||||||
|
required: true
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- shell: bash
|
||||||
|
env:
|
||||||
|
RTC_BASE_URL: https://github.com/${{ inputs.repo }}/releases/download/${{ inputs.release }}/${{ inputs.webrtc-base-name }}
|
||||||
|
run: |
|
||||||
|
cd ${{ inputs.out-dir }}
|
||||||
|
|
||||||
|
libplat=${{ inputs.platform }}
|
||||||
|
if [ "${{ inputs.platform }}" = "windows" ]; then
|
||||||
|
libplat=win
|
||||||
|
elif [ "${{ inputs.platform }}" = "osx" ]; then
|
||||||
|
libplat=mac
|
||||||
|
fi
|
||||||
|
|
||||||
|
for arch in ${{ inputs.archs }}
|
||||||
|
do
|
||||||
|
echo "Downloading ${{ env.RTC_BASE_URL }}-${{ inputs.platform }}-${arch}.tar.gz"
|
||||||
|
curl -L ${{ env.RTC_BASE_URL }}-${libplat}-${arch}.tar.gz -o ${arch}.tar.gz
|
||||||
|
tar -xzf ${arch}.tar.gz
|
||||||
|
done
|
||||||
|
|
||||||
|
mv lib ${{ inputs.platform }}
|
||||||
|
ls -l
|
||||||
|
ls -l *
|
||||||
180
.github/workflows/build_release.yml
vendored
Normal file
180
.github/workflows/build_release.yml
vendored
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
name: 🔧 Build -> Package 📦
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
name: 🔧 Build
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
# Android
|
||||||
|
- platform: android
|
||||||
|
arch: 'x86'
|
||||||
|
sconsflags: 'android_arch=x86'
|
||||||
|
os: 'ubuntu-20.04'
|
||||||
|
- platform: android
|
||||||
|
arch: 'x64'
|
||||||
|
sconsflags: 'android_arch=x86_64'
|
||||||
|
os: 'ubuntu-20.04'
|
||||||
|
- platform: android
|
||||||
|
arch: 'arm'
|
||||||
|
sconsflags: 'android_arch=armv7'
|
||||||
|
os: 'ubuntu-20.04'
|
||||||
|
- platform: android
|
||||||
|
arch: 'arm64'
|
||||||
|
sconsflags: 'android_arch=arm64v8'
|
||||||
|
os: 'ubuntu-20.04'
|
||||||
|
|
||||||
|
# iOS
|
||||||
|
- platform: ios
|
||||||
|
arch: 'x64'
|
||||||
|
sconsflags: 'ios_arch=x86_64 ios_simulator=true'
|
||||||
|
os: 'macos-latest'
|
||||||
|
- platform: ios
|
||||||
|
arch: 'arm'
|
||||||
|
sconsflags: 'ios_arch=armv7'
|
||||||
|
os: 'macos-latest'
|
||||||
|
- platform: ios
|
||||||
|
arch: 'arm64'
|
||||||
|
sconsflags: 'ios_arch=arm64'
|
||||||
|
os: 'macos-latest'
|
||||||
|
|
||||||
|
# Linux
|
||||||
|
- platform: linux
|
||||||
|
arch: 'x86'
|
||||||
|
sconsflags: 'bits=32'
|
||||||
|
os: 'ubuntu-20.04'
|
||||||
|
- platform: linux
|
||||||
|
arch: 'x64'
|
||||||
|
sconsflags: 'bits=64'
|
||||||
|
os: 'ubuntu-20.04'
|
||||||
|
|
||||||
|
# macOS
|
||||||
|
- platform: osx
|
||||||
|
arch: 'x64'
|
||||||
|
sconsflags: 'bits=64'
|
||||||
|
os: 'macos-latest'
|
||||||
|
|
||||||
|
# Windows
|
||||||
|
- platform: windows
|
||||||
|
arch: 'x86'
|
||||||
|
sconsflags: 'bits=32'
|
||||||
|
os: 'windows-latest'
|
||||||
|
msvc_arch: amd64_x86
|
||||||
|
- platform: windows
|
||||||
|
arch: 'x64'
|
||||||
|
sconsflags: 'bits=64'
|
||||||
|
os: 'windows-latest'
|
||||||
|
msvc_arch: amd64
|
||||||
|
|
||||||
|
env:
|
||||||
|
SCONSFLAGS: ${{ matrix.sconsflags }} platform=${{ matrix.platform }} --jobs=2
|
||||||
|
NDK_VERSION: 22b
|
||||||
|
ANDROID_NDK_ROOT: ${{github.workspace}}/android-ndk-r22b
|
||||||
|
MSVC_VARS: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat'
|
||||||
|
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Cache NDK
|
||||||
|
id: cache-ndk
|
||||||
|
if: ${{ matrix.platform == 'android' }}
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ${{ env.ANDROID_NDK_ROOT }}
|
||||||
|
key: ndk-${{ env.NDK_VERSION }}
|
||||||
|
|
||||||
|
- name: Download NDK
|
||||||
|
if: ${{ matrix.platform == 'android' && steps.cache-ndk.outputs.cache-hit != 'true' }}
|
||||||
|
id: setup-ndk
|
||||||
|
run: |
|
||||||
|
cd ${{ github.workspace }}
|
||||||
|
curl -L https://dl.google.com/android/repository/android-ndk-r${{ env.NDK_VERSION }}-linux-x86_64.zip -o ndk.zip
|
||||||
|
unzip ndk.zip
|
||||||
|
ls
|
||||||
|
|
||||||
|
- name: Setup MSVC build environment for ${{ matrix.msvc_arch }}
|
||||||
|
if: ${{ matrix.platform == 'windows' }}
|
||||||
|
run: "'${{ env.MSVC_VARS }}' ${{ matrix.msvc_arch }}"
|
||||||
|
|
||||||
|
- name: Install Linux build dependencies
|
||||||
|
if: ${{ matrix.platform == 'linux' }}
|
||||||
|
run: |
|
||||||
|
sudo apt-get install build-essential gcc-multilib wget g++-multilib
|
||||||
|
|
||||||
|
- name: Set up Python 3.x
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: '3.x'
|
||||||
|
architecture: 'x64'
|
||||||
|
|
||||||
|
- name: Configuring Python packages
|
||||||
|
run: |
|
||||||
|
python -c "import sys; print(sys.version)"
|
||||||
|
python -m pip install scons
|
||||||
|
python --version
|
||||||
|
scons --version
|
||||||
|
|
||||||
|
- name: Get WebRTC package for ${{ matrix.platform }} - ${{ matrix.arch }}
|
||||||
|
uses: ./.github/actions/webrtc-download
|
||||||
|
with:
|
||||||
|
platform: ${{ matrix.platform }}
|
||||||
|
archs: ${{ matrix.arch }}
|
||||||
|
|
||||||
|
- name: Compilation ${{ matrix.platform }} - ${{ matrix.arch }} - godot-cpp
|
||||||
|
run: |
|
||||||
|
scons -C godot-cpp target=debug generate_bindings=yes
|
||||||
|
scons -C godot-cpp target=release
|
||||||
|
|
||||||
|
- name: Compilation ${{ matrix.platform }} - ${{ matrix.arch }} - webrtc-native
|
||||||
|
run: |
|
||||||
|
scons target=debug
|
||||||
|
scons target=release
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: ${{ github.job }}-${{ matrix.platform }}-${{ matrix.arch }}
|
||||||
|
path: bin/*
|
||||||
|
|
||||||
|
package:
|
||||||
|
name: 📦 Package
|
||||||
|
needs: build
|
||||||
|
runs-on: "ubuntu-latest"
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- uses: actions/download-artifact@v2
|
||||||
|
with:
|
||||||
|
path: artifacts
|
||||||
|
|
||||||
|
- name: Package artifacts for release
|
||||||
|
run: |
|
||||||
|
mkdir release
|
||||||
|
cd release
|
||||||
|
for name in webrtc webrtc_debug
|
||||||
|
do
|
||||||
|
mkdir -p ${name}/lib/
|
||||||
|
find ../artifacts -wholename "*/${name}/lib/*" | xargs cp -t ${name}/lib/
|
||||||
|
find ../artifacts -wholename "*/${name}/${name}.tres" | head -n 1 | xargs cp -t ${name}/
|
||||||
|
done
|
||||||
|
|
||||||
|
zip -r godot-webrtc-native-release.zip webrtc
|
||||||
|
zip -r godot-webrtc-native-debug.zip webrtc_debug
|
||||||
|
ls -R
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: godot-webrtc-native-debug.zip
|
||||||
|
path: release/godot-webrtc-native-debug.zip
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: godot-webrtc-native-release.zip
|
||||||
|
path: release/godot-webrtc-native-release.zip
|
||||||
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "godot-cpp"]
|
||||||
|
path = godot-cpp
|
||||||
|
url = https://github.com/GodotNativeTools/godot-cpp
|
||||||
71
README.md
71
README.md
@@ -0,0 +1,71 @@
|
|||||||
|
# GDNative WebRTC plugin for Godot
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
| **Download latest binary version** | [**GitHub**](https://github.com/godotengine/webrtc-native/releases) |
|
||||||
|
| --- | --- |
|
||||||
|
|
||||||
|
### Compiling
|
||||||
|
|
||||||
|
Clone this repository with the following command to checkout both [godot-cpp](https://github.com/godotengine/godot-cpp) and [godot-headers](https://github.com/godotengine/godot-headers) dependencies.
|
||||||
|
|
||||||
|
```
|
||||||
|
$ git clone --recurse-submodules https://github.com/godotengine/webrtc-native.git
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that if you wish to use a specific branch, add the -b option to the clone command:
|
||||||
|
```
|
||||||
|
$ git clone --recurse-submodules -b 3.2 https://github.com/godotengine/webrtc-native.git
|
||||||
|
```
|
||||||
|
|
||||||
|
If you already checked out the branch use the following commands to update the dependencies:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ git submodule update --init --recursive
|
||||||
|
```
|
||||||
|
|
||||||
|
Right now our directory structure should look like this:
|
||||||
|
```
|
||||||
|
webrtc-native/
|
||||||
|
├─bin/
|
||||||
|
├─godot-cpp/
|
||||||
|
| └─godot-headers/
|
||||||
|
├─src/
|
||||||
|
└─webrtc/
|
||||||
|
```
|
||||||
|
|
||||||
|
### Compiling the cpp bindings library
|
||||||
|
First, we need to compile our cpp bindings library:
|
||||||
|
```
|
||||||
|
$ cd godot-cpp
|
||||||
|
$ scons platform=<your platform> generate_bindings=yes
|
||||||
|
$ cd ..
|
||||||
|
```
|
||||||
|
|
||||||
|
> Replace `<your platform>` with either `windows`, `linux` or `osx`.
|
||||||
|
|
||||||
|
> Include `use_llvm=yes` for using clang++
|
||||||
|
|
||||||
|
> Include `target=runtime` to build a runtime build (windows only at the moment)
|
||||||
|
|
||||||
|
> Include `target=release` or `target=debug` for release or debug build.
|
||||||
|
|
||||||
|
> The resulting library will be created in `godot-cpp/bin/`, take note of its name as it will be different depending on platform.
|
||||||
|
|
||||||
|
### Building WebRTC
|
||||||
|
|
||||||
|
Building WebRTC is quite a complex task, involves huge downloads and long build times, and produces multiple output libraries that needs to bundled together.
|
||||||
|
|
||||||
|
To make things easier, a set of [GitHub Actions](https://docs.github.com/en/actions) are used to generate the library for this plugin, [available in this repository](https://github.com/godotengine/webrtc-actions).
|
||||||
|
|
||||||
|
Alternatively, [**download the latest pre-compiled libraries**](https://github.com/godotengine/webrtc-actions/releases).
|
||||||
|
|
||||||
|
Extract content of `include` into `webrtc/include` and content of `bin` into `webrtc/<your platform>`
|
||||||
|
|
||||||
|
### Compiling the plugin.
|
||||||
|
|
||||||
|
```
|
||||||
|
$ scons platform=<your platform> target=<your target>
|
||||||
|
```
|
||||||
|
|
||||||
|
The generated library and associated `tres` will be placed in `bin/webrtc/` or `bin/webrtc_debug/` according to the desired target. You simply need to copy that folder to the root folder of your project.
|
||||||
|
|||||||
262
SConstruct
262
SConstruct
@@ -1,6 +1,14 @@
|
|||||||
#!python
|
#!python
|
||||||
|
|
||||||
import os, sys, platform, json
|
import os, sys, platform, json, subprocess
|
||||||
|
|
||||||
|
if sys.version_info < (3,):
|
||||||
|
def decode_utf8(x):
|
||||||
|
return x
|
||||||
|
else:
|
||||||
|
import codecs
|
||||||
|
def decode_utf8(x):
|
||||||
|
return codecs.utf_8_decode(x)[0]
|
||||||
|
|
||||||
|
|
||||||
def add_sources(sources, dirpath, extension):
|
def add_sources(sources, dirpath, extension):
|
||||||
@@ -9,42 +17,89 @@ def add_sources(sources, dirpath, extension):
|
|||||||
sources.append(dirpath + '/' + f)
|
sources.append(dirpath + '/' + f)
|
||||||
|
|
||||||
|
|
||||||
def get_arch_dir(name):
|
def gen_gdnative_lib(target, source, env):
|
||||||
if name == '32':
|
for t in target:
|
||||||
return 'x86'
|
with open(t.srcnode().path, 'w') as w:
|
||||||
elif name == '64':
|
w.write(decode_utf8(source[0].get_contents()).replace('{GDNATIVE_PATH}', os.path.splitext(t.name)[0]).replace('{TARGET}', env['target']))
|
||||||
return 'x64'
|
|
||||||
return name
|
|
||||||
|
|
||||||
env = Environment()
|
env = Environment()
|
||||||
|
|
||||||
|
target_arch = ARGUMENTS.get('b', ARGUMENTS.get('bits', '64'))
|
||||||
|
target_platform = ARGUMENTS.get('p', ARGUMENTS.get('platform', 'linux'))
|
||||||
|
if target_platform == 'windows':
|
||||||
|
# This makes sure to keep the session environment variables on windows,
|
||||||
|
# that way you can run scons in a vs 2017 prompt and it will find all the required tools
|
||||||
|
if (target_arch == '64'):
|
||||||
|
env = Environment(ENV = os.environ, TARGET_ARCH='amd64')
|
||||||
|
else:
|
||||||
|
env = Environment(ENV = os.environ, TARGET_ARCH='x86')
|
||||||
|
|
||||||
|
env.Append(BUILDERS={'GDNativeLibBuilder': Builder(action=gen_gdnative_lib)})
|
||||||
|
|
||||||
customs = ['custom.py']
|
customs = ['custom.py']
|
||||||
opts = Variables(customs, ARGUMENTS)
|
opts = Variables(customs, ARGUMENTS)
|
||||||
|
|
||||||
opts.Add(BoolVariable('use_llvm', 'Use the LLVM compiler', False))
|
opts.Add(BoolVariable('use_llvm', 'Use the LLVM compiler', False))
|
||||||
opts.Add(EnumVariable('target', "Compilation target", 'debug', ('debug', 'release')))
|
opts.Add(EnumVariable('target', "Compilation target", 'debug', ('debug', 'release')))
|
||||||
|
|
||||||
|
opts.Add(EnumVariable(
|
||||||
|
'android_arch',
|
||||||
|
'Target Android architecture',
|
||||||
|
'armv7',
|
||||||
|
['armv7','arm64v8', 'x86', 'x86_64']
|
||||||
|
))
|
||||||
|
opts.Add(
|
||||||
|
'android_api_level',
|
||||||
|
'Target Android API level',
|
||||||
|
'18' if ARGUMENTS.get("android_arch", 'armv7') in ['armv7', 'x86'] else '21'
|
||||||
|
)
|
||||||
|
opts.Add(
|
||||||
|
'ANDROID_NDK_ROOT',
|
||||||
|
'Path to your Android NDK installation. By default, uses ANDROID_NDK_ROOT from your defined environment variables.',
|
||||||
|
os.environ.get("ANDROID_NDK_ROOT", None)
|
||||||
|
)
|
||||||
|
|
||||||
|
opts.Add(EnumVariable(
|
||||||
|
'ios_arch',
|
||||||
|
'Target iOS architecture',
|
||||||
|
'arm64',
|
||||||
|
['armv7', 'arm64', 'x86_64']
|
||||||
|
))
|
||||||
|
opts.Add(BoolVariable(
|
||||||
|
'ios_simulator',
|
||||||
|
'Target iOS Simulator',
|
||||||
|
False
|
||||||
|
))
|
||||||
|
opts.Add(
|
||||||
|
'IPHONEPATH',
|
||||||
|
'Path to iPhone toolchain',
|
||||||
|
'/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain',
|
||||||
|
)
|
||||||
|
|
||||||
# Update environment (parse options)
|
# Update environment (parse options)
|
||||||
opts.Update(env)
|
opts.Update(env)
|
||||||
|
|
||||||
target = env['target']
|
target = env['target']
|
||||||
|
|
||||||
|
if target_platform == 'android':
|
||||||
|
target_arch = env['android_arch']
|
||||||
|
elif target_platform == 'ios':
|
||||||
|
target_arch = env['ios_arch']
|
||||||
|
|
||||||
host_platform = platform.system()
|
host_platform = platform.system()
|
||||||
target_platform = ARGUMENTS.get('p', ARGUMENTS.get('platform', 'linux'))
|
|
||||||
target_arch = ARGUMENTS.get('a', ARGUMENTS.get('arch', '64'))
|
|
||||||
# Local dependency paths, adapt them to your setup
|
# Local dependency paths, adapt them to your setup
|
||||||
godot_headers = ARGUMENTS.get('headers', '../godot_headers')
|
godot_headers = ARGUMENTS.get('headers', 'godot-cpp/godot-headers')
|
||||||
godot_cpp_headers = ARGUMENTS.get('godot_cpp_headers', '../godot-cpp/include')
|
godot_cpp_headers = ARGUMENTS.get('godot_cpp_headers', 'godot-cpp/include')
|
||||||
godot_cpp_lib_dir = ARGUMENTS.get('godot_cpp_lib_dir', 'lib/godot-cpp')
|
godot_cpp_lib_dir = ARGUMENTS.get('godot_cpp_lib_dir', 'godot-cpp/bin')
|
||||||
result_path = 'bin'
|
result_path = os.path.join('bin', 'webrtc' if env['target'] == 'release' else 'webrtc_debug', 'lib')
|
||||||
result_name = 'webrtc_native'
|
lib_prefix = ""
|
||||||
|
|
||||||
# Convenience check to enforce the use_llvm overrides when CXX is clang(++)
|
# Convenience check to enforce the use_llvm overrides when CXX is clang(++)
|
||||||
if 'CXX' in env and 'clang' in os.path.basename(env['CXX']):
|
if 'CXX' in env and 'clang' in os.path.basename(env['CXX']):
|
||||||
env['use_llvm'] = True
|
env['use_llvm'] = True
|
||||||
|
|
||||||
if target_platform == 'linux':
|
if target_platform == 'linux':
|
||||||
result_name += '.linux.' + target + '.' + target_arch
|
|
||||||
|
|
||||||
env['CXX']='g++'
|
env['CXX']='g++'
|
||||||
|
|
||||||
# LLVM
|
# LLVM
|
||||||
@@ -60,7 +115,7 @@ if target_platform == 'linux':
|
|||||||
else:
|
else:
|
||||||
env.Prepend(CCFLAGS=['-O3'])
|
env.Prepend(CCFLAGS=['-O3'])
|
||||||
|
|
||||||
env.Append(CCFLAGS=['-fPIC', '-std=c++11'])
|
env.Append(CCFLAGS=['-fPIC', '-std=c++14'])
|
||||||
|
|
||||||
if target_arch == '32':
|
if target_arch == '32':
|
||||||
env.Append(CCFLAGS = [ '-m32' ])
|
env.Append(CCFLAGS = [ '-m32' ])
|
||||||
@@ -68,20 +123,13 @@ if target_platform == 'linux':
|
|||||||
elif target_arch == '64':
|
elif target_arch == '64':
|
||||||
env.Append(CCFLAGS = [ '-m64' ])
|
env.Append(CCFLAGS = [ '-m64' ])
|
||||||
env.Append(LINKFLAGS = [ '-m64' ])
|
env.Append(LINKFLAGS = [ '-m64' ])
|
||||||
|
# i386 does not like static libstdc++
|
||||||
|
env.Append(LINKFLAGS=['-static-libgcc', '-static-libstdc++'])
|
||||||
|
|
||||||
elif target_platform == 'windows':
|
elif target_platform == 'windows':
|
||||||
# This makes sure to keep the session environment variables on windows,
|
|
||||||
# that way you can run scons in a vs 2017 prompt and it will find all the required tools
|
|
||||||
if (target_arch == '64'):
|
|
||||||
env = Environment(ENV = os.environ, TARGET_ARCH='amd64')
|
|
||||||
else:
|
|
||||||
env = Environment(ENV = os.environ, TARGET_ARCH='x86')
|
|
||||||
|
|
||||||
result_name += '.windows.' + target + '.' + target_arch
|
|
||||||
|
|
||||||
if host_platform == 'Windows':
|
if host_platform == 'Windows':
|
||||||
#result_name += '.lib'
|
|
||||||
|
|
||||||
|
lib_prefix = "lib"
|
||||||
env.Append(LINKFLAGS = [ '/WX' ])
|
env.Append(LINKFLAGS = [ '/WX' ])
|
||||||
if target == 'debug':
|
if target == 'debug':
|
||||||
env.Append(CCFLAGS = ['/EHsc', '/D_DEBUG', '/MDd' ])
|
env.Append(CCFLAGS = ['/EHsc', '/D_DEBUG', '/MDd' ])
|
||||||
@@ -93,7 +141,12 @@ elif target_platform == 'windows':
|
|||||||
elif target_arch == '64':
|
elif target_arch == '64':
|
||||||
env['CXX']='x86_64-w64-mingw32-g++'
|
env['CXX']='x86_64-w64-mingw32-g++'
|
||||||
|
|
||||||
env.Append(CCFLAGS = [ '-g', '-O3', '-std=c++14', '-Wwrite-strings' ])
|
if env['target'] == 'debug':
|
||||||
|
env.Append(CCFLAGS=['-Og', '-g'])
|
||||||
|
elif env['target'] == 'release':
|
||||||
|
env.Append(CCFLAGS=['-O3'])
|
||||||
|
|
||||||
|
env.Append(CCFLAGS = [ '-std=c++14', '-Wwrite-strings' ])
|
||||||
env.Append(LINKFLAGS = [ '--static', '-Wl,--no-undefined', '-static-libgcc', '-static-libstdc++' ])
|
env.Append(LINKFLAGS = [ '--static', '-Wl,--no-undefined', '-static-libgcc', '-static-libstdc++' ])
|
||||||
|
|
||||||
elif target_platform == 'osx':
|
elif target_platform == 'osx':
|
||||||
@@ -102,11 +155,109 @@ elif target_platform == 'osx':
|
|||||||
|
|
||||||
# Only 64-bits is supported for OS X
|
# Only 64-bits is supported for OS X
|
||||||
target_arch = '64'
|
target_arch = '64'
|
||||||
result_name += '.osx.' + target + '.' + target_arch
|
|
||||||
|
|
||||||
env.Append(CCFLAGS = [ '-g','-O3', '-std=c++14', '-arch', 'x86_64' ])
|
env.Append(CCFLAGS = [ '-std=c++14', '-arch', 'x86_64' ])
|
||||||
env.Append(LINKFLAGS = [ '-arch', 'x86_64', '-framework', 'Cocoa', '-Wl,-undefined,dynamic_lookup' ])
|
env.Append(LINKFLAGS = [ '-arch', 'x86_64', '-framework', 'Cocoa', '-Wl,-undefined,dynamic_lookup' ])
|
||||||
|
|
||||||
|
if env['target'] == 'debug':
|
||||||
|
env.Append(CCFLAGS=['-Og', '-g'])
|
||||||
|
elif env['target'] == 'release':
|
||||||
|
env.Append(CCFLAGS=['-O3'])
|
||||||
|
|
||||||
|
elif target_platform == 'ios':
|
||||||
|
if env['ios_simulator']:
|
||||||
|
sdk_name = 'iphonesimulator'
|
||||||
|
env.Append(CCFLAGS=['-mios-simulator-version-min=10.0'])
|
||||||
|
env['LIBSUFFIX'] = ".simulator" + env['LIBSUFFIX']
|
||||||
|
else:
|
||||||
|
sdk_name = 'iphoneos'
|
||||||
|
env.Append(CCFLAGS=['-miphoneos-version-min=10.0'])
|
||||||
|
|
||||||
|
try:
|
||||||
|
sdk_path = decode_utf8(subprocess.check_output(['xcrun', '--sdk', sdk_name, '--show-sdk-path']).strip())
|
||||||
|
except (subprocess.CalledProcessError, OSError):
|
||||||
|
raise ValueError("Failed to find SDK path while running xcrun --sdk {} --show-sdk-path.".format(sdk_name))
|
||||||
|
|
||||||
|
compiler_path = env['IPHONEPATH'] + '/usr/bin/'
|
||||||
|
env['ENV']['PATH'] = env['IPHONEPATH'] + "/Developer/usr/bin/:" + env['ENV']['PATH']
|
||||||
|
|
||||||
|
env['CC'] = compiler_path + 'clang'
|
||||||
|
env['CXX'] = compiler_path + 'clang++'
|
||||||
|
env['AR'] = compiler_path + 'ar'
|
||||||
|
env['RANLIB'] = compiler_path + 'ranlib'
|
||||||
|
|
||||||
|
env.Append(CCFLAGS=['-std=c++14', '-arch', env['ios_arch'], '-isysroot', sdk_path])
|
||||||
|
env.Append(LINKFLAGS=[
|
||||||
|
'-arch',
|
||||||
|
env['ios_arch'],
|
||||||
|
'-Wl,-undefined,dynamic_lookup',
|
||||||
|
'-isysroot', sdk_path,
|
||||||
|
'-F' + sdk_path
|
||||||
|
])
|
||||||
|
|
||||||
|
if env['target'] == 'debug':
|
||||||
|
env.Append(CCFLAGS=['-Og', '-g'])
|
||||||
|
elif env['target'] == 'release':
|
||||||
|
env.Append(CCFLAGS=['-O3'])
|
||||||
|
|
||||||
|
|
||||||
|
elif target_platform == 'android':
|
||||||
|
# Verify NDK root
|
||||||
|
if not 'ANDROID_NDK_ROOT' in env:
|
||||||
|
raise ValueError("To build for Android, ANDROID_NDK_ROOT must be defined. Please set ANDROID_NDK_ROOT to the root folder of your Android NDK installation.")
|
||||||
|
|
||||||
|
# Validate API level
|
||||||
|
api_level = int(env['android_api_level'])
|
||||||
|
if target_arch in ['arm64v8', 'x86_64'] and api_level < 21:
|
||||||
|
print("WARN: 64-bit Android architectures require an API level of at least 21; setting android_api_level=21")
|
||||||
|
env['android_api_level'] = '21'
|
||||||
|
api_level = 21
|
||||||
|
|
||||||
|
# Setup toolchain
|
||||||
|
toolchain = env['ANDROID_NDK_ROOT'] + "/toolchains/llvm/prebuilt/"
|
||||||
|
if host_platform == "Windows":
|
||||||
|
toolchain += "windows"
|
||||||
|
import platform as pltfm
|
||||||
|
if pltfm.machine().endswith("64"):
|
||||||
|
toolchain += "-x86_64"
|
||||||
|
elif host_platform == "Linux":
|
||||||
|
toolchain += "linux-x86_64"
|
||||||
|
elif host_platform == "Darwin":
|
||||||
|
toolchain += "darwin-x86_64"
|
||||||
|
|
||||||
|
# Get architecture info
|
||||||
|
arch_info_table = {
|
||||||
|
"armv7" : {
|
||||||
|
"march":"armv7-a", "target":"armv7a-linux-androideabi", "tool_path":"arm-linux-androideabi", "compiler_path":"armv7a-linux-androideabi",
|
||||||
|
"ccflags" : ['-mfpu=neon']
|
||||||
|
},
|
||||||
|
"arm64v8" : {
|
||||||
|
"march":"armv8-a", "target":"aarch64-linux-android", "tool_path":"aarch64-linux-android", "compiler_path":"aarch64-linux-android",
|
||||||
|
"ccflags" : []
|
||||||
|
},
|
||||||
|
"x86" : {
|
||||||
|
"march":"i686", "target":"i686-linux-android", "tool_path":"i686-linux-android", "compiler_path":"i686-linux-android",
|
||||||
|
"ccflags" : ['-mstackrealign']
|
||||||
|
},
|
||||||
|
"x86_64" : {"march":"x86-64", "target":"x86_64-linux-android", "tool_path":"x86_64-linux-android", "compiler_path":"x86_64-linux-android",
|
||||||
|
"ccflags" : []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
arch_info = arch_info_table[target_arch]
|
||||||
|
|
||||||
|
# Setup tools
|
||||||
|
env['CC'] = toolchain + "/bin/clang"
|
||||||
|
env['CXX'] = toolchain + "/bin/clang++"
|
||||||
|
|
||||||
|
env.Append(CCFLAGS=['--target=' + arch_info['target'] + env['android_api_level'], '-march=' + arch_info['march'], '-fPIC'])
|
||||||
|
env.Append(CCFLAGS=arch_info['ccflags'])
|
||||||
|
env.Append(LINKFLAGS=['--target=' + arch_info['target'] + env['android_api_level'], '-march=' + arch_info['march']])
|
||||||
|
|
||||||
|
if env['target'] == 'debug':
|
||||||
|
env.Append(CCFLAGS=['-Og', '-g'])
|
||||||
|
elif env['target'] == 'release':
|
||||||
|
env.Append(CCFLAGS=['-O3'])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("No valid target platform selected.")
|
print("No valid target platform selected.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
@@ -114,28 +265,31 @@ else:
|
|||||||
# Godot CPP bindings
|
# Godot CPP bindings
|
||||||
env.Append(CPPPATH=[godot_headers])
|
env.Append(CPPPATH=[godot_headers])
|
||||||
env.Append(CPPPATH=[godot_cpp_headers, godot_cpp_headers + '/core', godot_cpp_headers + '/gen'])
|
env.Append(CPPPATH=[godot_cpp_headers, godot_cpp_headers + '/core', godot_cpp_headers + '/gen'])
|
||||||
env.Append(LIBPATH=[godot_cpp_lib_dir + '/' + target + '/' + get_arch_dir(target_arch)])
|
env.Append(LIBPATH=[godot_cpp_lib_dir])
|
||||||
env.Append(LIBS=['godot-cpp'])
|
env.Append(LIBS=['%sgodot-cpp.%s.%s.%s%s' % (lib_prefix, target_platform, target, target_arch, ".simulator" if env["ios_simulator"] else "")])
|
||||||
|
|
||||||
# WebRTC stuff
|
# WebRTC stuff
|
||||||
webrtc_dir = "lib/webrtc"
|
webrtc_dir = "webrtc"
|
||||||
lib_name = 'libwebrtc_full'
|
lib_name = 'libwebrtc_full'
|
||||||
lib_path = webrtc_dir + '/lib/' + target_platform
|
lib_path = os.path.join(webrtc_dir, target_platform)
|
||||||
|
|
||||||
if target_arch == '64':
|
lib_path += {'32': '/x86',
|
||||||
lib_path += '/x64'
|
'64': '/x64',
|
||||||
elif target_arch == '32':
|
'armv7': '/arm',
|
||||||
lib_path += '/x86'
|
'arm64v8': '/arm64',
|
||||||
|
'arm64': '/arm64',
|
||||||
|
'x86': '/x86',
|
||||||
|
'x86_64': '/x64'}[target_arch]
|
||||||
|
|
||||||
if target == 'debug':
|
if target == 'debug':
|
||||||
lib_path += '/Debug'
|
lib_path += '/Debug'
|
||||||
else:
|
else:
|
||||||
lib_path += '/Release'
|
lib_path += '/Release'
|
||||||
|
|
||||||
env.Append(CPPPATH=[webrtc_dir + "/include"])
|
env.Append(CPPPATH=[webrtc_dir + "/include", webrtc_dir + "/include/third_party/abseil-cpp"])
|
||||||
|
|
||||||
if target_platform == "linux":
|
if target_platform == "linux":
|
||||||
env.Append(LIBS=[lib_name])
|
env.Append(LIBS=[lib_name, "atomic"])
|
||||||
env.Append(LIBPATH=[lib_path])
|
env.Append(LIBPATH=[lib_path])
|
||||||
#env.Append(CCFLAGS=["-std=c++11"])
|
#env.Append(CCFLAGS=["-std=c++11"])
|
||||||
env.Append(CCFLAGS=["-DWEBRTC_POSIX", "-DWEBRTC_LINUX"])
|
env.Append(CCFLAGS=["-DWEBRTC_POSIX", "-DWEBRTC_LINUX"])
|
||||||
@@ -156,6 +310,26 @@ elif target_platform == "windows":
|
|||||||
elif target_platform == "osx":
|
elif target_platform == "osx":
|
||||||
env.Append(LIBS=[lib_name])
|
env.Append(LIBS=[lib_name])
|
||||||
env.Append(LIBPATH=[lib_path])
|
env.Append(LIBPATH=[lib_path])
|
||||||
|
env.Append(CCFLAGS=["-DWEBRTC_POSIX", "-DWEBRTC_MAC"])
|
||||||
|
env.Append(CCFLAGS=["-DRTC_UNUSED=''", "-DNO_RETURN=''"])
|
||||||
|
|
||||||
|
elif target_platform == 'ios':
|
||||||
|
env.Append(LIBS=[lib_name])
|
||||||
|
env.Append(LIBPATH=[lib_path])
|
||||||
|
env.Append(CCFLAGS=["-DWEBRTC_POSIX", "-DWEBRTC_MAC", "-DWEBRTC_IOS"])
|
||||||
|
env.Append(CCFLAGS=["-DRTC_UNUSED=''", "-DNO_RETURN=''"])
|
||||||
|
|
||||||
|
elif target_platform == "android":
|
||||||
|
env.Append(LIBS=['log'])
|
||||||
|
env.Append(LIBS=[lib_name])
|
||||||
|
env.Append(LIBPATH=[lib_path])
|
||||||
|
env.Append(CCFLAGS=["-DWEBRTC_POSIX", "-DWEBRTC_LINUX", "-DWEBRTC_ANDROID"])
|
||||||
|
env.Append(CCFLAGS=["-DRTC_UNUSED=''", "-DNO_RETURN=''"])
|
||||||
|
|
||||||
|
if target_arch == 'arm64v8':
|
||||||
|
env.Append(CCFLAGS=["-DWEBRTC_ARCH_ARM64", "-DWEBRTC_HAS_NEON"])
|
||||||
|
elif target_arch == 'armv7':
|
||||||
|
env.Append(CCFLAGS=["-DWEBRTC_ARCH_ARM", "-DWEBRTC_ARCH_ARM_V7", "-DWEBRTC_HAS_NEON"])
|
||||||
|
|
||||||
# Our includes and sources
|
# Our includes and sources
|
||||||
env.Append(CPPPATH=['src/'])
|
env.Append(CPPPATH=['src/'])
|
||||||
@@ -168,5 +342,13 @@ suffix = '.%s.%s' % (target, target_arch)
|
|||||||
env["SHOBJSUFFIX"] = suffix + env["SHOBJSUFFIX"]
|
env["SHOBJSUFFIX"] = suffix + env["SHOBJSUFFIX"]
|
||||||
|
|
||||||
# Make the shared library
|
# Make the shared library
|
||||||
|
result_name = 'webrtc_native.%s.%s.%s' % (target_platform, target, target_arch) + env["SHLIBSUFFIX"]
|
||||||
|
|
||||||
library = env.SharedLibrary(target=os.path.join(result_path, result_name), source=sources)
|
library = env.SharedLibrary(target=os.path.join(result_path, result_name), source=sources)
|
||||||
Default(library)
|
Default(library)
|
||||||
|
|
||||||
|
# GDNativeLibrary
|
||||||
|
gdnlib = 'webrtc'
|
||||||
|
if target != 'release':
|
||||||
|
gdnlib += '_debug'
|
||||||
|
Default(env.GDNativeLibBuilder([os.path.join('bin', gdnlib, gdnlib + '.tres')], ['misc/gdnlib.tres']))
|
||||||
|
|||||||
1
godot-cpp
Submodule
1
godot-cpp
Submodule
Submodule godot-cpp added at 77d41fa179
2
lib/godot-cpp/debug/x86/.gitignore
vendored
2
lib/godot-cpp/debug/x86/.gitignore
vendored
@@ -1,2 +0,0 @@
|
|||||||
*
|
|
||||||
!.gitignore
|
|
||||||
2
lib/godot-cpp/release/x64/.gitignore
vendored
2
lib/godot-cpp/release/x64/.gitignore
vendored
@@ -1,2 +0,0 @@
|
|||||||
*
|
|
||||||
!.gitignore
|
|
||||||
2
lib/godot-cpp/release/x86/.gitignore
vendored
2
lib/godot-cpp/release/x86/.gitignore
vendored
@@ -1,2 +0,0 @@
|
|||||||
*
|
|
||||||
!.gitignore
|
|
||||||
1
lib/webrtc/.gitignore
vendored
1
lib/webrtc/.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
include/
|
|
||||||
2
lib/webrtc/lib/linux/.gitignore
vendored
2
lib/webrtc/lib/linux/.gitignore
vendored
@@ -1,2 +0,0 @@
|
|||||||
*
|
|
||||||
!.gitignore
|
|
||||||
2
lib/webrtc/lib/windows/.gitignore
vendored
2
lib/webrtc/lib/windows/.gitignore
vendored
@@ -1,2 +0,0 @@
|
|||||||
*
|
|
||||||
!.gitignore
|
|
||||||
28
misc/gdnlib.tres
Normal file
28
misc/gdnlib.tres
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
[gd_resource type="GDNativeLibrary" format=2]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
singleton = true
|
||||||
|
reloadable = false
|
||||||
|
entry/OSX.64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.osx.{TARGET}.64.dylib"
|
||||||
|
entry/OSX.arm64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.osx.{TARGET}.arm64.dylib"
|
||||||
|
entry/Windows.64 = "res://{GDNATIVE_PATH}/lib/webrtc_native.windows.{TARGET}.64.dll"
|
||||||
|
entry/Windows.32 = "res://{GDNATIVE_PATH}/lib/webrtc_native.windows.{TARGET}.32.dll"
|
||||||
|
entry/X11.64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.64.so"
|
||||||
|
entry/X11.32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.32.so"
|
||||||
|
entry/Server.64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.64.so"
|
||||||
|
entry/Server.32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.32.so"
|
||||||
|
entry/Android.armeabi-v7a = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.android.{TARGET}.armv7.so"
|
||||||
|
entry/Android.arm64-v8a = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.android.{TARGET}.arm64v8.so"
|
||||||
|
entry/Android.x64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.android.{TARGET}.x86_64.so"
|
||||||
|
entry/Android.x86 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.android.{TARGET}.x86.so"
|
||||||
|
entry/iOS.armv7 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.ios.{TARGET}.armv7.dylib"
|
||||||
|
entry/iOS.arm64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.ios.{TARGET}.arm64.dylib"
|
||||||
|
entry/iOS.x86_64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.ios.{TARGET}.x86_64.dylib"
|
||||||
|
dependency/Windows.64 = [ ]
|
||||||
|
dependency/Windows.32 = [ ]
|
||||||
|
dependency/X11.64 = [ ]
|
||||||
|
dependency/X11.32 = [ ]
|
||||||
|
dependency/Server.64 = [ ]
|
||||||
|
dependency/Server.32 = [ ]
|
||||||
|
dependency/Android.armeabi-v7a = [ ]
|
||||||
|
dependency/Android.arm64-v8a = [ ]
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
#include "WebRTCLibPeerConnection.hpp"
|
|
||||||
|
|
||||||
using namespace godot_webrtc;
|
|
||||||
|
|
||||||
WebRTCLibPeerConnection::GodotCSDO::GodotCSDO(WebRTCLibPeerConnection *parent) {
|
|
||||||
this->parent = parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebRTCLibPeerConnection::GodotCSDO::OnSuccess(webrtc::SessionDescriptionInterface *desc) {
|
|
||||||
// serialize this offer and send it to the remote peer:
|
|
||||||
std::string sdp; // sdp = session description protocol
|
|
||||||
desc->ToString(&sdp);
|
|
||||||
parent->queue_signal("session_description_created", 2, desc->type().c_str(), sdp.c_str());
|
|
||||||
};
|
|
||||||
|
|
||||||
void WebRTCLibPeerConnection::GodotCSDO::OnFailure(const std::string &error){};
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
#include "WebRTCLibPeerConnection.hpp"
|
|
||||||
#include "WebRTCLibDataChannel.hpp"
|
|
||||||
|
|
||||||
using namespace godot_webrtc;
|
|
||||||
|
|
||||||
WebRTCLibPeerConnection::GodotPCO::GodotPCO(WebRTCLibPeerConnection *parent) {
|
|
||||||
this->parent = parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebRTCLibPeerConnection::GodotPCO::OnSignalingChange(webrtc::PeerConnectionInterface::SignalingState new_state) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebRTCLibPeerConnection::GodotPCO::OnAddStream(rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebRTCLibPeerConnection::GodotPCO::OnRemoveStream(rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebRTCLibPeerConnection::GodotPCO::OnDataChannel(rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel) {
|
|
||||||
parent->queue_signal("data_channel_received", 1, WebRTCLibDataChannel::new_data_channel(data_channel));
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebRTCLibPeerConnection::GodotPCO::OnRenegotiationNeeded() {
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebRTCLibPeerConnection::GodotPCO::OnIceConnectionChange(webrtc::PeerConnectionInterface::IceConnectionState new_state) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebRTCLibPeerConnection::GodotPCO::OnIceGatheringChange(webrtc::PeerConnectionInterface::IceGatheringState new_state) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebRTCLibPeerConnection::GodotPCO::OnIceCandidate(const webrtc::IceCandidateInterface *candidate) {
|
|
||||||
// Serialize the candidate and send it to the remote peer:
|
|
||||||
|
|
||||||
godot::Dictionary candidateSDP;
|
|
||||||
|
|
||||||
godot::String candidateSdpMidName = candidate->sdp_mid().c_str();
|
|
||||||
int candidateSdpMlineIndexName = candidate->sdp_mline_index();
|
|
||||||
std::string sdp;
|
|
||||||
candidate->ToString(&sdp);
|
|
||||||
godot::String candidateSdpName = sdp.c_str();
|
|
||||||
|
|
||||||
parent->queue_signal("ice_candidate_created",
|
|
||||||
3,
|
|
||||||
candidateSdpMidName,
|
|
||||||
candidateSdpMlineIndexName,
|
|
||||||
candidateSdpName);
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
#include "WebRTCLibPeerConnection.hpp"
|
|
||||||
|
|
||||||
using namespace godot_webrtc;
|
|
||||||
|
|
||||||
WebRTCLibPeerConnection::GodotSSDO::GodotSSDO(WebRTCLibPeerConnection *parent) {
|
|
||||||
this->parent = parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebRTCLibPeerConnection::GodotSSDO::OnSuccess(){};
|
|
||||||
|
|
||||||
void WebRTCLibPeerConnection::GodotSSDO::OnFailure(const std::string &error){};
|
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
#include "WebRTCLibDataChannel.hpp"
|
#include "WebRTCLibDataChannel.hpp"
|
||||||
|
|
||||||
|
#include "GDNativeLibrary.hpp"
|
||||||
|
#include "NativeScript.hpp"
|
||||||
|
|
||||||
using namespace godot_webrtc;
|
using namespace godot_webrtc;
|
||||||
|
|
||||||
// Channel observer
|
// Channel observer
|
||||||
@@ -26,12 +29,12 @@ WebRTCLibDataChannel *WebRTCLibDataChannel::new_data_channel(rtc::scoped_refptr<
|
|||||||
godot::WebRTCDataChannelGDNative *out = godot::WebRTCDataChannelGDNative::_new();
|
godot::WebRTCDataChannelGDNative *out = godot::WebRTCDataChannelGDNative::_new();
|
||||||
// Set our implementation as it's script
|
// Set our implementation as it's script
|
||||||
godot::NativeScript *script = godot::NativeScript::_new();
|
godot::NativeScript *script = godot::NativeScript::_new();
|
||||||
script->set_library(godot::get_wrapper<godot::GDNativeLibrary>((godot_object *)godot::gdnlib));
|
script->set_library(godot::detail::get_wrapper<godot::GDNativeLibrary>((godot_object *)godot::gdnlib));
|
||||||
script->set_class_name("WebRTCLibDataChannel");
|
script->set_class_name("WebRTCLibDataChannel");
|
||||||
out->set_script(script);
|
out->set_script(script);
|
||||||
|
|
||||||
// Bind the data channel to the ScriptInstance userdata (our script)
|
// Bind the data channel to the ScriptInstance userdata (our script)
|
||||||
WebRTCLibDataChannel *tmp = godot::as<WebRTCLibDataChannel>(out);
|
WebRTCLibDataChannel *tmp = out->cast_to<WebRTCLibDataChannel>(out);
|
||||||
tmp->bind_channel(p_channel);
|
tmp->bind_channel(p_channel);
|
||||||
|
|
||||||
return tmp;
|
return tmp;
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
#include <Godot.hpp> // Godot.hpp must go first, or windows builds breaks
|
#include <Godot.hpp> // Godot.hpp must go first, or windows builds breaks
|
||||||
|
|
||||||
#include "api/peerconnectioninterface.h" // interface for all things needed from WebRTC
|
#include "api/peer_connection_interface.h" // interface for all things needed from WebRTC
|
||||||
#include "media/base/mediaengine.h" // needed for CreateModularPeerConnectionFactory
|
#include "media/base/media_engine.h" // needed for CreateModularPeerConnectionFactory
|
||||||
|
|
||||||
#include "net/WebRTCDataChannelNative.hpp"
|
#include "net/WebRTCDataChannelNative.hpp"
|
||||||
#include "PoolArrays.hpp"
|
#include "PoolArrays.hpp"
|
||||||
|
|||||||
@@ -5,6 +5,48 @@
|
|||||||
|
|
||||||
using namespace godot_webrtc;
|
using namespace godot_webrtc;
|
||||||
|
|
||||||
|
std::unique_ptr<rtc::Thread> WebRTCLibPeerConnection::signaling_thread = nullptr;
|
||||||
|
|
||||||
|
// PeerConnectionObserver
|
||||||
|
void WebRTCLibPeerConnection::GodotPCO::OnIceCandidate(const webrtc::IceCandidateInterface *candidate) {
|
||||||
|
godot::Dictionary candidateSDP;
|
||||||
|
godot::String candidateSdpMidName = candidate->sdp_mid().c_str();
|
||||||
|
int candidateSdpMlineIndexName = candidate->sdp_mline_index();
|
||||||
|
std::string sdp;
|
||||||
|
candidate->ToString(&sdp);
|
||||||
|
godot::String candidateSdpName = sdp.c_str();
|
||||||
|
parent->queue_signal("ice_candidate_created", 3, candidateSdpMidName, candidateSdpMlineIndexName, candidateSdpName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetSessionDescriptionObserver
|
||||||
|
void WebRTCLibPeerConnection::GodotSSDO::OnSuccess() {
|
||||||
|
if (make_offer) {
|
||||||
|
make_offer = false;
|
||||||
|
parent->peer_connection->CreateAnswer(parent->ptr_csdo, webrtc::PeerConnectionInterface::RTCOfferAnswerOptions());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateSessionDescriptionObserver
|
||||||
|
void WebRTCLibPeerConnection::GodotCSDO::OnSuccess(webrtc::SessionDescriptionInterface *desc) {
|
||||||
|
// serialize this offer and send it to the remote peer:
|
||||||
|
std::string sdp;
|
||||||
|
desc->ToString(&sdp);
|
||||||
|
parent->queue_signal("session_description_created", 2, desc->type().c_str(), sdp.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebRTCLibPeerConnection::initialize_signaling() {
|
||||||
|
if (signaling_thread.get() == nullptr) {
|
||||||
|
signaling_thread = rtc::Thread::Create();
|
||||||
|
}
|
||||||
|
signaling_thread->Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebRTCLibPeerConnection::deinitialize_signaling() {
|
||||||
|
if (signaling_thread.get() != nullptr) {
|
||||||
|
signaling_thread->Stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
godot_error _parse_ice_server(webrtc::PeerConnectionInterface::RTCConfiguration &r_config, godot::Dictionary p_server) {
|
godot_error _parse_ice_server(webrtc::PeerConnectionInterface::RTCConfiguration &r_config, godot::Dictionary p_server) {
|
||||||
godot::Variant v;
|
godot::Variant v;
|
||||||
webrtc::PeerConnectionInterface::IceServer ice_server;
|
webrtc::PeerConnectionInterface::IceServer ice_server;
|
||||||
@@ -57,7 +99,7 @@ godot_error _parse_channel_config(webrtc::DataChannelInit &r_config, godot::Dict
|
|||||||
// ID makes sense only when negotiated is true (and must be set in that case)
|
// ID makes sense only when negotiated is true (and must be set in that case)
|
||||||
ERR_FAIL_COND_V(r_config.negotiated ? r_config.id == -1 : r_config.id != -1, GODOT_ERR_INVALID_PARAMETER);
|
ERR_FAIL_COND_V(r_config.negotiated ? r_config.id == -1 : r_config.id != -1, GODOT_ERR_INVALID_PARAMETER);
|
||||||
// Only one of maxRetransmits and maxRetransmitTime can be set on a channel.
|
// Only one of maxRetransmits and maxRetransmitTime can be set on a channel.
|
||||||
ERR_FAIL_COND_V(r_config.maxRetransmits != -1 && r_config.maxRetransmitTime != -1, GODOT_ERR_INVALID_PARAMETER);
|
ERR_FAIL_COND_V(r_config.maxRetransmits && r_config.maxRetransmitTime, GODOT_ERR_INVALID_PARAMETER);
|
||||||
return GODOT_OK;
|
return GODOT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +161,7 @@ godot_object *WebRTCLibPeerConnection::create_data_channel(const char *p_channel
|
|||||||
|
|
||||||
godot_error WebRTCLibPeerConnection::create_offer() {
|
godot_error WebRTCLibPeerConnection::create_offer() {
|
||||||
ERR_FAIL_COND_V(peer_connection.get() == nullptr, GODOT_ERR_UNCONFIGURED);
|
ERR_FAIL_COND_V(peer_connection.get() == nullptr, GODOT_ERR_UNCONFIGURED);
|
||||||
peer_connection->CreateOffer(ptr_csdo, nullptr);
|
peer_connection->CreateOffer(ptr_csdo, webrtc::PeerConnectionInterface::RTCOfferAnswerOptions());
|
||||||
return GODOT_OK;
|
return GODOT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,8 +169,10 @@ godot_error WebRTCLibPeerConnection::create_offer() {
|
|||||||
godot_error WebRTCLibPeerConnection::set_remote_description(const char *type, const char *sdp) {
|
godot_error WebRTCLibPeerConnection::set_remote_description(const char *type, const char *sdp) {
|
||||||
ERR_FAIL_COND_V(peer_connection.get() == nullptr, GODOT_ERR_UNCONFIGURED);
|
ERR_FAIL_COND_V(peer_connection.get() == nullptr, GODOT_ERR_UNCONFIGURED);
|
||||||
std::unique_ptr<webrtc::SessionDescriptionInterface> desc = _MAKE_DESC(type, sdp);
|
std::unique_ptr<webrtc::SessionDescriptionInterface> desc = _MAKE_DESC(type, sdp);
|
||||||
|
if (desc->GetType() == webrtc::SdpType::kOffer) {
|
||||||
|
ptr_ssdo->make_offer = true;
|
||||||
|
}
|
||||||
peer_connection->SetRemoteDescription(ptr_ssdo, desc.release());
|
peer_connection->SetRemoteDescription(ptr_ssdo, desc.release());
|
||||||
peer_connection->CreateAnswer(ptr_csdo, webrtc::PeerConnectionInterface::RTCOfferAnswerOptions());
|
|
||||||
return GODOT_OK;
|
return GODOT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,20 +203,21 @@ godot_error WebRTCLibPeerConnection::add_ice_candidate(const char *sdpMidName, i
|
|||||||
godot_error WebRTCLibPeerConnection::poll() {
|
godot_error WebRTCLibPeerConnection::poll() {
|
||||||
ERR_FAIL_COND_V(peer_connection.get() == nullptr, GODOT_ERR_UNCONFIGURED);
|
ERR_FAIL_COND_V(peer_connection.get() == nullptr, GODOT_ERR_UNCONFIGURED);
|
||||||
|
|
||||||
std::function<void()> signal;
|
|
||||||
while (!signal_queue.empty()) {
|
while (!signal_queue.empty()) {
|
||||||
mutex_signal_queue->lock();
|
mutex_signal_queue->lock();
|
||||||
signal = signal_queue.front();
|
Signal signal = signal_queue.front();
|
||||||
signal_queue.pop();
|
signal_queue.pop();
|
||||||
mutex_signal_queue->unlock();
|
mutex_signal_queue->unlock();
|
||||||
|
signal.emit(this);
|
||||||
signal();
|
|
||||||
}
|
}
|
||||||
return GODOT_OK;
|
return GODOT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebRTCLibPeerConnection::close() {
|
void WebRTCLibPeerConnection::close() {
|
||||||
peer_connection->Close();
|
if (peer_connection.get() != nullptr) {
|
||||||
|
peer_connection->Close();
|
||||||
|
}
|
||||||
|
peer_connection = nullptr;
|
||||||
while(!signal_queue.empty()) {
|
while(!signal_queue.empty()) {
|
||||||
signal_queue.pop();
|
signal_queue.pop();
|
||||||
}
|
}
|
||||||
@@ -188,16 +233,11 @@ void WebRTCLibPeerConnection::_init() {
|
|||||||
mutex_signal_queue = new std::mutex;
|
mutex_signal_queue = new std::mutex;
|
||||||
|
|
||||||
// create a PeerConnectionFactoryInterface:
|
// create a PeerConnectionFactoryInterface:
|
||||||
signaling_thread = new rtc::Thread;
|
webrtc::PeerConnectionFactoryDependencies deps;
|
||||||
signaling_thread->Start();
|
|
||||||
pc_factory = webrtc::CreateModularPeerConnectionFactory(
|
ERR_FAIL_COND(signaling_thread.get() == nullptr);
|
||||||
nullptr, // rtc::Thread* network_thread,
|
deps.signaling_thread = signaling_thread.get();
|
||||||
nullptr, // rtc::Thread* worker_thread,
|
pc_factory = webrtc::CreateModularPeerConnectionFactory(std::move(deps));
|
||||||
signaling_thread,
|
|
||||||
nullptr, // std::unique_ptr<cricket::MediaEngineInterface> media_engine,
|
|
||||||
nullptr, // std::unique_ptr<CallFactoryInterface> call_factory,
|
|
||||||
nullptr // std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory
|
|
||||||
);
|
|
||||||
|
|
||||||
// Create peer connection with default configuration.
|
// Create peer connection with default configuration.
|
||||||
webrtc::PeerConnectionInterface::RTCConfiguration config;
|
webrtc::PeerConnectionInterface::RTCConfiguration config;
|
||||||
@@ -231,15 +271,7 @@ WebRTCLibPeerConnection::~WebRTCLibPeerConnection() {
|
|||||||
|
|
||||||
void WebRTCLibPeerConnection::queue_signal(godot::String p_name, int p_argc, const godot::Variant &p_arg1, const godot::Variant &p_arg2, const godot::Variant &p_arg3) {
|
void WebRTCLibPeerConnection::queue_signal(godot::String p_name, int p_argc, const godot::Variant &p_arg1, const godot::Variant &p_arg2, const godot::Variant &p_arg3) {
|
||||||
mutex_signal_queue->lock();
|
mutex_signal_queue->lock();
|
||||||
signal_queue.push(
|
const godot::Variant argv[3] = { p_arg1, p_arg2, p_arg3 };
|
||||||
[this, p_name, p_argc, p_arg1, p_arg2, p_arg3] {
|
signal_queue.push(Signal(p_name, p_argc, argv));
|
||||||
if (p_argc == 1) {
|
|
||||||
emit_signal(p_name, p_arg1);
|
|
||||||
} else if (p_argc == 2) {
|
|
||||||
emit_signal(p_name, p_arg1, p_arg2);
|
|
||||||
} else {
|
|
||||||
emit_signal(p_name, p_arg1, p_arg2, p_arg3);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mutex_signal_queue->unlock();
|
mutex_signal_queue->unlock();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,9 @@
|
|||||||
|
|
||||||
#include <Godot.hpp> // Godot.hpp must go first, or windows builds breaks
|
#include <Godot.hpp> // Godot.hpp must go first, or windows builds breaks
|
||||||
|
|
||||||
#include "api/peerconnectioninterface.h" // interface for all things needed from WebRTC
|
#include "api/peer_connection_interface.h" // interface for all things needed from WebRTC
|
||||||
#include "media/base/mediaengine.h" // needed for CreateModularPeerConnectionFactory
|
#include "media/base/media_engine.h" // needed for CreateModularPeerConnectionFactory
|
||||||
#include <functional> // std::function
|
#include <mutex>
|
||||||
#include <mutex> // mutex @TODO replace std::mutex with Godot mutex
|
|
||||||
|
|
||||||
#include "net/WebRTCPeerConnectionNative.hpp"
|
#include "net/WebRTCPeerConnectionNative.hpp"
|
||||||
|
|
||||||
@@ -18,8 +17,11 @@ class WebRTCLibPeerConnection : public WebRTCPeerConnectionNative {
|
|||||||
private:
|
private:
|
||||||
godot_error _create_pc(webrtc::PeerConnectionInterface::RTCConfiguration &config);
|
godot_error _create_pc(webrtc::PeerConnectionInterface::RTCConfiguration &config);
|
||||||
|
|
||||||
|
static std::unique_ptr<rtc::Thread> signaling_thread;
|
||||||
public:
|
public:
|
||||||
static void _register_methods();
|
static void _register_methods();
|
||||||
|
static void initialize_signaling();
|
||||||
|
static void deinitialize_signaling();
|
||||||
|
|
||||||
void _init();
|
void _init();
|
||||||
|
|
||||||
@@ -38,9 +40,8 @@ public:
|
|||||||
~WebRTCLibPeerConnection();
|
~WebRTCLibPeerConnection();
|
||||||
|
|
||||||
/* helper functions */
|
/* helper functions */
|
||||||
|
private:
|
||||||
void queue_signal(godot::String p_name, int p_argc, const godot::Variant &p_arg1 = godot::Variant(), const godot::Variant &p_arg2 = godot::Variant(), const godot::Variant &p_arg3 = godot::Variant());
|
void queue_signal(godot::String p_name, int p_argc, const godot::Variant &p_arg1 = godot::Variant(), const godot::Variant &p_arg2 = godot::Variant(), const godot::Variant &p_arg3 = godot::Variant());
|
||||||
// void queue_signal(godot::StringName p_name, Variant_ARG_LIST);
|
|
||||||
void queue_packet(uint8_t *, int);
|
void queue_packet(uint8_t *, int);
|
||||||
|
|
||||||
/** PeerConnectionObserver callback functions **/
|
/** PeerConnectionObserver callback functions **/
|
||||||
@@ -48,45 +49,83 @@ public:
|
|||||||
public:
|
public:
|
||||||
WebRTCLibPeerConnection *parent;
|
WebRTCLibPeerConnection *parent;
|
||||||
|
|
||||||
GodotPCO(WebRTCLibPeerConnection *parent);
|
GodotPCO(WebRTCLibPeerConnection *p_parent) {
|
||||||
void OnSignalingChange(webrtc::PeerConnectionInterface::SignalingState new_state) override;
|
parent = p_parent;
|
||||||
void OnAddStream(rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) override;
|
}
|
||||||
void OnRemoveStream(rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) override;
|
|
||||||
void OnDataChannel(rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel) override;
|
|
||||||
void OnRenegotiationNeeded() override;
|
|
||||||
void OnIceConnectionChange(webrtc::PeerConnectionInterface::IceConnectionState new_state) override;
|
|
||||||
void OnIceGatheringChange(webrtc::PeerConnectionInterface::IceGatheringState new_state) override;
|
|
||||||
void OnIceCandidate(const webrtc::IceCandidateInterface *candidate) override;
|
void OnIceCandidate(const webrtc::IceCandidateInterface *candidate) override;
|
||||||
|
|
||||||
|
void OnSignalingChange(webrtc::PeerConnectionInterface::SignalingState new_state) override {}
|
||||||
|
void OnAddStream(rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) override {}
|
||||||
|
void OnRemoveStream(rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) override {}
|
||||||
|
void OnDataChannel(rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel) override {}
|
||||||
|
void OnRenegotiationNeeded() override {}
|
||||||
|
void OnIceConnectionChange(webrtc::PeerConnectionInterface::IceConnectionState new_state) override {}
|
||||||
|
void OnIceGatheringChange(webrtc::PeerConnectionInterface::IceGatheringState new_state) override {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** CreateSessionDescriptionObserver callback functions **/
|
/** CreateSessionDescriptionObserver callback functions **/
|
||||||
class GodotCSDO : public webrtc::CreateSessionDescriptionObserver {
|
class GodotCSDO : public webrtc::CreateSessionDescriptionObserver {
|
||||||
public:
|
public:
|
||||||
WebRTCLibPeerConnection *parent;
|
WebRTCLibPeerConnection *parent = nullptr;
|
||||||
|
|
||||||
GodotCSDO(WebRTCLibPeerConnection *parent);
|
GodotCSDO(WebRTCLibPeerConnection *p_parent) {
|
||||||
|
parent = p_parent;
|
||||||
|
}
|
||||||
void OnSuccess(webrtc::SessionDescriptionInterface *desc) override;
|
void OnSuccess(webrtc::SessionDescriptionInterface *desc) override;
|
||||||
void OnFailure(const std::string &error) override;
|
void OnFailure(webrtc::RTCError error) override {
|
||||||
|
ERR_PRINT(godot::String(error.message()));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** SetSessionDescriptionObserver callback functions **/
|
/** SetSessionDescriptionObserver callback functions **/
|
||||||
class GodotSSDO : public webrtc::SetSessionDescriptionObserver {
|
class GodotSSDO : public webrtc::SetSessionDescriptionObserver {
|
||||||
public:
|
public:
|
||||||
WebRTCLibPeerConnection *parent;
|
WebRTCLibPeerConnection *parent = nullptr;
|
||||||
|
bool make_offer = false;
|
||||||
|
|
||||||
GodotSSDO(WebRTCLibPeerConnection *parent);
|
GodotSSDO(WebRTCLibPeerConnection *p_parent) {
|
||||||
|
parent = p_parent;
|
||||||
|
}
|
||||||
void OnSuccess() override;
|
void OnSuccess() override;
|
||||||
void OnFailure(const std::string &error) override;
|
void OnFailure(webrtc::RTCError error) override {
|
||||||
|
make_offer = false;
|
||||||
|
ERR_PRINT(godot::String(error.message()));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class Signal {
|
||||||
|
godot::String method;
|
||||||
|
godot::Variant argv[3];
|
||||||
|
int argc = 0;
|
||||||
|
public:
|
||||||
|
Signal(godot::String p_method, int p_argc, const godot::Variant *p_argv) {
|
||||||
|
method = p_method;
|
||||||
|
argc = p_argc;
|
||||||
|
for (int i = 0; i < argc; i++) {
|
||||||
|
argv[i] = p_argv[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void emit(godot::Object *p_object) {
|
||||||
|
if (argc == 0) {
|
||||||
|
p_object->emit_signal(method);
|
||||||
|
} else if (argc == 1) {
|
||||||
|
p_object->emit_signal(method, argv[0]);
|
||||||
|
} else if (argc == 2) {
|
||||||
|
p_object->emit_signal(method, argv[0], argv[1]);
|
||||||
|
} else if (argc == 3) {
|
||||||
|
p_object->emit_signal(method, argv[0], argv[1], argv[2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
GodotPCO pco;
|
GodotPCO pco;
|
||||||
rtc::scoped_refptr<GodotSSDO> ptr_ssdo;
|
rtc::scoped_refptr<GodotSSDO> ptr_ssdo;
|
||||||
rtc::scoped_refptr<GodotCSDO> ptr_csdo;
|
rtc::scoped_refptr<GodotCSDO> ptr_csdo;
|
||||||
|
|
||||||
std::mutex *mutex_signal_queue;
|
std::mutex *mutex_signal_queue = nullptr;
|
||||||
std::queue<std::function<void()> > signal_queue;
|
std::queue<Signal> signal_queue;
|
||||||
|
|
||||||
rtc::Thread *signaling_thread;
|
|
||||||
rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory;
|
rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory;
|
||||||
rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection;
|
rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
godot_webrtc::WebRTCLibPeerConnection::initialize_signaling();
|
||||||
godot::Godot::gdnative_init(o);
|
godot::Godot::gdnative_init(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,6 +94,7 @@ extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_opt
|
|||||||
if (_singleton) { // If we are the active singleton, unregister
|
if (_singleton) { // If we are the active singleton, unregister
|
||||||
WebRTCPeerConnectionNative::_net_api->godot_net_set_webrtc_library(NULL);
|
WebRTCPeerConnectionNative::_net_api->godot_net_set_webrtc_library(NULL);
|
||||||
}
|
}
|
||||||
|
godot_webrtc::WebRTCLibPeerConnection::deinitialize_signaling();
|
||||||
godot::Godot::gdnative_terminate(o);
|
godot::Godot::gdnative_terminate(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user