mirror of
https://github.com/UltraCoderRU/libwebrtc.git
synced 2026-01-28 19:25:12 +00:00
Compare commits
244 commits
0.0.1-rc.4
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| c4917e8f86 | |||
| 4475233318 | |||
| 92fb3fdc01 | |||
| 915e13f4ce | |||
| c3a581c11c | |||
| cf009964cf | |||
| 9d7075b4f0 | |||
| 292a9b8751 | |||
| 0e08c8388a | |||
| d667dab439 | |||
| 1e24732035 | |||
| ab22b5519e | |||
| 2db22c8048 | |||
| 477b5b2220 | |||
| c8cdba02bc | |||
| 5a40775960 | |||
| d5583c9a6c | |||
| f158466213 | |||
| 8185da4a10 | |||
| bb6c49081b | |||
| 700e94ff03 | |||
| 40db8152b4 | |||
| 7fefa7dc53 | |||
| 3315befa38 | |||
| dccaa6f5f4 | |||
| 5ac8845681 | |||
|
|
b248e1cd73 | ||
|
|
336476a1f8 | ||
|
|
38d6a4e9ea | ||
|
|
2ac0e402e1 | ||
|
|
05445b2fd5 | ||
|
|
46f502d2d1 | ||
|
|
d44f0e4c3a | ||
|
|
a24a5e5947 | ||
|
|
6fa64674be | ||
|
|
09a07366da | ||
|
|
4ee758711c | ||
|
|
b9480efda7 | ||
|
|
9db425ba54 | ||
|
|
475d263a51 | ||
|
|
2e92e72f0a | ||
|
|
a627d1bc9a | ||
|
|
66fa38e90d | ||
|
|
9664e669e6 | ||
|
|
60407d29cd | ||
|
|
0569dc61df | ||
|
|
37eeec231e | ||
|
|
d2d4b017f8 | ||
|
|
ffd60ae7d8 | ||
|
|
787fe28f96 | ||
|
|
a477b6a2a8 | ||
|
|
1d52ac650f | ||
|
|
d26a48fc0d | ||
|
|
3d42742689 | ||
|
|
a925a1bad2 | ||
|
|
107f4dccb3 | ||
|
|
be407aced0 | ||
|
|
f7e01514ed | ||
|
|
b3651f0e14 | ||
|
|
8d571cb492 | ||
|
|
f496ce1a29 | ||
|
|
9b5dadf807 | ||
|
|
5cfd7585f8 | ||
|
|
d2de52cdce | ||
|
|
1bed0a6818 | ||
|
|
5cda935434 | ||
|
|
9f324642f5 | ||
|
|
941688e7fc | ||
|
|
eec2846651 | ||
|
|
7cd0a79bd2 | ||
|
|
1dbc538b4b | ||
|
|
ee7fb4f42d | ||
|
|
ad6d1a565a | ||
|
|
2969a0f603 | ||
|
|
67ac79ff0f | ||
|
|
bc9c05404f | ||
|
|
b35dc15d8d | ||
|
|
55f1e9d761 | ||
|
|
7acf691f2b | ||
|
|
ab1cf49414 | ||
|
|
7ef534cd55 | ||
|
|
77208bccbd | ||
|
|
9ee8a5aec6 | ||
|
|
53a331a356 | ||
|
|
7047a4dfef | ||
|
|
522e16128a | ||
|
|
cb13886cbe | ||
|
|
5ae2a5de6b | ||
|
|
6aab703673 | ||
|
|
5744e63abe | ||
|
|
58f2d70a74 | ||
|
|
418e54b401 | ||
|
|
c21220c58c | ||
|
|
64690d1a30 | ||
|
|
16578cdd5c | ||
|
|
7311f13bfa | ||
|
|
7950fa7e8a | ||
|
|
c8a3e8eb8a | ||
|
|
5d3887b918 | ||
|
|
ea5d4643aa | ||
|
|
daf8535a2d | ||
|
|
c10f3458f0 | ||
|
|
8970f2368b | ||
|
|
17ef828ce2 | ||
|
|
bbdd74ce9a | ||
|
|
b294fac627 | ||
|
|
b59291f093 | ||
|
|
5a602922c0 | ||
|
|
e3a4e5d64e | ||
|
|
93438caf76 | ||
|
|
e60dbd57f6 | ||
|
|
7ad84637f4 | ||
|
|
a750ea484d | ||
|
|
b565920acb | ||
|
|
638022675f | ||
|
|
470e444791 | ||
|
|
987a23fcef | ||
|
|
80281d8afa | ||
|
|
9eafe12813 | ||
|
|
058d9e0da3 | ||
|
|
287d483478 | ||
|
|
bc67c8f626 | ||
|
|
b668195218 | ||
|
|
83814ef6f3 | ||
|
|
f25382438d | ||
|
|
91ab805302 | ||
|
|
54b08c7c27 | ||
|
|
1588d232cd | ||
|
|
2d714a93b3 | ||
|
|
d1992ce19f | ||
|
|
28034f95c8 | ||
|
|
25345ad1a7 | ||
|
|
34afab9454 | ||
|
|
1f20b932cf | ||
|
|
2d2ddde88d | ||
|
|
702153c428 | ||
|
|
6203fac5b2 | ||
|
|
5281a34c37 | ||
|
|
11819b2917 | ||
|
|
dfaeab6dfa | ||
|
|
9743793fdb | ||
|
|
c8042df583 | ||
|
|
7e7fa0d7d4 | ||
|
|
b334e9098a | ||
|
|
282570038c | ||
|
|
5337697608 | ||
|
|
82cedb40a9 | ||
|
|
6d5a20ee0a | ||
|
|
c5c86b729b | ||
|
|
e994c40b0d | ||
|
|
1b11dcc9c3 | ||
|
|
f381807566 | ||
|
|
a702d36f56 | ||
|
|
fc4badad3d | ||
|
|
9bf16c0940 | ||
|
|
ea0b0de53b | ||
|
|
c3285ca001 | ||
|
|
e2877a8598 | ||
|
|
c314b374df | ||
|
|
92307e4367 | ||
|
|
f634b8ec10 | ||
|
|
7c4895a6fd | ||
|
|
fc819a24b6 | ||
|
|
5ccda05d8c | ||
|
|
95384c655e | ||
|
|
62f3b7d5a1 | ||
|
|
59375cab38 | ||
|
|
2617dd15d7 | ||
|
|
bb1b53a49e | ||
|
|
29b4333904 | ||
|
|
704267abcb | ||
|
|
0607a2bd6f | ||
|
|
f57ddc50c0 | ||
|
|
0bfeb679e9 | ||
|
|
a179540e7e | ||
|
|
aa4bca5f44 | ||
|
|
598a7f2c15 | ||
|
|
aaa4bf41c5 | ||
|
|
a21997f2ef | ||
|
|
a15061d9d4 | ||
|
|
fdbbed3bb2 | ||
|
|
9685d1e09e | ||
|
|
548218994d | ||
|
|
67d2b0bd4e | ||
|
|
173d9150eb | ||
|
|
abb19d5e3b | ||
|
|
a5ee207afe | ||
|
|
76ea35fdb6 | ||
|
|
e8c3adeb38 | ||
|
|
867ae4f1f4 | ||
|
|
a1d1f3bf15 | ||
|
|
2e5888e284 | ||
|
|
6f80b4ce13 | ||
|
|
5bfddcb3d5 | ||
|
|
4b91b1ffc7 | ||
|
|
4107165208 | ||
|
|
93c874c445 | ||
|
|
f0d2c97881 | ||
|
|
9392f069e4 | ||
|
|
91e9726542 | ||
|
|
7bf5bc518a | ||
|
|
e6b7fba630 | ||
|
|
e84f856658 | ||
|
|
99e0c927d6 | ||
|
|
52804400a2 | ||
|
|
7d4f195624 | ||
|
|
6b3a1de6e8 | ||
|
|
adb56b350c | ||
|
|
377c684fc6 | ||
|
|
2d1dd68e00 | ||
|
|
499ccf20e1 | ||
|
|
4a5c2f53a6 | ||
|
|
afacb2c2e0 | ||
|
|
5f06dc9546 | ||
|
|
c92b3d7f0b | ||
|
|
af87db4d65 | ||
|
|
c9f7b0e7c0 | ||
|
|
87005b3dc3 | ||
|
|
fa11b58067 | ||
|
|
0475eca88d | ||
|
|
1eda115a37 | ||
|
|
49ddc448d1 | ||
|
|
b8796b9359 | ||
|
|
461570efab | ||
|
|
4abf227a7c | ||
|
|
2bbdf4e794 | ||
|
|
c38445b4aa | ||
|
|
d230f08a2c | ||
|
|
ddee3556d7 | ||
|
|
b7b3d1c58a | ||
|
|
58e7553592 | ||
|
|
1944a92f9a | ||
|
|
5fb6525b72 | ||
|
|
5c756a458c | ||
|
|
3bca34b165 | ||
|
|
32f637a95d | ||
|
|
d2018d9f14 | ||
|
|
a30090ad82 | ||
|
|
86bb881422 | ||
|
|
30eda4df99 | ||
|
|
f42594d363 | ||
|
|
edf4abdcf0 | ||
|
|
452450fd20 | ||
|
|
559fb5e0f4 |
58 changed files with 1135 additions and 1632 deletions
9
.gitignore
vendored
9
.gitignore
vendored
|
|
@ -1,5 +1,4 @@
|
||||||
/out/
|
.idea
|
||||||
/.idea/
|
cmake-build-*
|
||||||
*.gclient
|
webrtc
|
||||||
/node_modules/
|
depot_tools
|
||||||
*.gclient_entries
|
|
||||||
|
|
|
||||||
3
.gitmodules
vendored
3
.gitmodules
vendored
|
|
@ -1,3 +0,0 @@
|
||||||
[submodule "Dependencies/depot_tools"]
|
|
||||||
path = Dependencies/depot_tools
|
|
||||||
url = https://chromium.googlesource.com/chromium/tools/depot_tools.git
|
|
||||||
38
.travis.yml
38
.travis.yml
|
|
@ -1,38 +0,0 @@
|
||||||
language: cpp
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- build-essential
|
|
||||||
- libglib2.0-dev
|
|
||||||
- libgtk2.0-dev
|
|
||||||
- libxtst-dev
|
|
||||||
- libxss-dev
|
|
||||||
- libpci-dev
|
|
||||||
- libdbus-1-dev
|
|
||||||
- libgconf2-dev
|
|
||||||
- libgnome-keyring-dev
|
|
||||||
- libnss3-dev
|
|
||||||
- libasound2-dev
|
|
||||||
- libpulse-dev
|
|
||||||
- libudev-dev
|
|
||||||
- cmake
|
|
||||||
|
|
||||||
install:
|
|
||||||
- git submodule init
|
|
||||||
- git submodule update
|
|
||||||
- cmake .
|
|
||||||
|
|
||||||
script:
|
|
||||||
- make package
|
|
||||||
- md5sum libwebrtc*.tar.gz
|
|
||||||
|
|
||||||
deploy:
|
|
||||||
provider: releases
|
|
||||||
api_key:
|
|
||||||
secure: UazaqOOoifs5xE/xw+tjVnFAkl6MMJeZSW7B0DXX0wnHorKM5K72q9Ms3JYvJIp6DDV3vIeX/Yv/WQCnfRkDDhcbLohGZoOj2X3q53RSfJiOq/iIyPiPTRmkk3jQRBOvXl5zLePNaXU2vBuSgcM8az+wGjxaDLUB+EebSGRHPbXrGSnDDHaNnmb4Zm7SZ2DpL5ubRDlLTHst7Jh7OigrIblYKNCzwEc7UQsFNzLnu7dyZT4hF2Y+2KYl/3vUUkUGxu0AxVG7zilnjJE7O5gX76r+SQXs151uWwZeH41NNPxRSod51LKQS/V/I4afjjTaYC5+9lSUdNkOpEGrxU+61hSJvNGxL6rTqfiBTAOiJdMR3u4OmF+B72O0nUUpsNtlkSPBK9402Z65LH/UI2BIJ/oMfkjNSzTNTHvB+n+18nFryzUmgEJ4CEy7Yx5HGO1vXCP4OsHGAu5YCkDGV2uVttiYHlm2qWgTY59cQt61h1saQWMwj6Uivhz8XrS86K0r/YAS30t+7+/xG6dneXgctM9oYjIbVCFnImsE30FpWlCJvGnJzo37wctbTQscHs5iuqjt1an7AhQgOTMQwmtyyg32D6N9e4n+RJA9pEj3Qtpi51LVD1cdCahbZ1l4bURlNueqfB3d4oZvr9o/QNjm+qH/FRUWjAmWtbBr16ZXfiA=
|
|
||||||
file: libwebrtc-$TRAVIS_TAG-linux-x64.tar.gz
|
|
||||||
skip_cleanup: true
|
|
||||||
overwrite: true
|
|
||||||
on:
|
|
||||||
tags: true
|
|
||||||
repo: aisouard/libwebrtc
|
|
||||||
1
AUTHORS
Normal file
1
AUTHORS
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Axel Isouard <axel@isouard.fr>
|
||||||
53
CHANGELOG.md
Normal file
53
CHANGELOG.md
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
# Changelog
|
||||||
|
|
||||||
|
## Version 1.1
|
||||||
|
|
||||||
|
*TBD*
|
||||||
|
|
||||||
|
[View Issues][v1.1-issues]
|
||||||
|
|
||||||
|
**Features:**
|
||||||
|
|
||||||
|
- Added `BUILD_TESTS` CMake configuration variable
|
||||||
|
|
||||||
|
## Version 1.0
|
||||||
|
|
||||||
|
*March 27, 2017*
|
||||||
|
|
||||||
|
[View Issues][v1.0-issues]
|
||||||
|
|
||||||
|
**Features:**
|
||||||
|
|
||||||
|
- Using CMake version 3.3
|
||||||
|
- Installs LibWebRTC as a CMake package
|
||||||
|
- Support for `gn`-based releases
|
||||||
|
- Synchronize depot_tools with WebRTC's commit date
|
||||||
|
- `TARGET_OS` and `TARGET_CPU` CMake config variables
|
||||||
|
- `WEBRTC_REVISION` and `WEBRTC_BRANCH_HEAD` CMake config variables
|
||||||
|
- x86 support under Windows
|
||||||
|
- Better host OS and CPU architecture detection
|
||||||
|
- pkg-config file generation
|
||||||
|
- Deprecated shared library support
|
||||||
|
- Debug mode support
|
||||||
|
- .zip package for Windows, .tar.gz for Unix
|
||||||
|
- Basic .deb and .rpm package generation
|
||||||
|
|
||||||
|
**Fixes:**
|
||||||
|
|
||||||
|
- Removed package.json and Jake support, focusing on CMake only
|
||||||
|
- Refactored source code, removed Targets folder
|
||||||
|
- Run commands with `cmake -E env`, no more Prefix File Trick
|
||||||
|
- No more `merge_libs.py` call, use CMake to create the library
|
||||||
|
- Removed the peer connection sample, wrote a little executable for tests
|
||||||
|
- Removed FindLibWebRTC.cmake, defined CMake package files
|
||||||
|
- Removed depot_tools git submodule
|
||||||
|
- Retrieve the Linux sysroot before calling the generator
|
||||||
|
- Removed support for releases older than January 1st, 2017 for now
|
||||||
|
- Removed libwebrtc-chromium-deps repository
|
||||||
|
- Wrote libwebrtc_execute macro
|
||||||
|
- Created uninstall target
|
||||||
|
- Removed BUILD_TESTS flag for now
|
||||||
|
- Fixed static linking
|
||||||
|
|
||||||
|
[v1.1-issues]:https://github.com/aisouard/libwebrtc/milestone/1
|
||||||
|
[v1.0-issues]:https://github.com/aisouard/libwebrtc/milestone/1
|
||||||
103
CMakeLists.txt
103
CMakeLists.txt
|
|
@ -1,81 +1,46 @@
|
||||||
cmake_minimum_required(VERSION 2.8)
|
cmake_minimum_required(VERSION 3.20)
|
||||||
|
|
||||||
|
set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING INTERNAL FORCE)
|
||||||
|
|
||||||
project(libwebrtc)
|
project(libwebrtc)
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
|
set(USE_CLANG ON CACHE BOOL "Build using internal Clang compiler (set to OFF to build using system GCC/MSVC)")
|
||||||
${CMAKE_SOURCE_DIR}/CMakeModules)
|
set(GN_EXTRA_ARGS "" CACHE STRING "Extra 'gn gen' arguments to pass when configuring WebRTC")
|
||||||
|
set(NINJA_ARGS "" CACHE STRING "Ninja arguments to pass when compiling WebRTC")
|
||||||
|
option(BUILD_DEB_PACKAGE "Build .deb package" OFF)
|
||||||
|
|
||||||
find_package(Git REQUIRED)
|
# Allow the use of IN_LIST operand
|
||||||
find_package(DepotTools REQUIRED)
|
cmake_policy(SET CMP0057 NEW)
|
||||||
|
|
||||||
#
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
|
||||||
# Options
|
|
||||||
#
|
|
||||||
|
|
||||||
option(BUILD_TESTS "Build test binaries" OFF)
|
include(FindLibraries)
|
||||||
option(BUILD_SAMPLES "Build samples binaries" OFF)
|
include(TargetOsAndCpu)
|
||||||
|
|
||||||
#
|
include(Utils)
|
||||||
# Versioning
|
prependPath("${CMAKE_SOURCE_DIR}/depot_tools")
|
||||||
#
|
if (WIN32)
|
||||||
|
set(ENV{DEPOT_TOOLS_WIN_TOOLCHAIN} 0)
|
||||||
execute_process(
|
|
||||||
COMMAND git log -1 --format=%h
|
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
||||||
OUTPUT_VARIABLE GIT_COMMIT_HASH
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
)
|
|
||||||
|
|
||||||
execute_process(
|
|
||||||
COMMAND git describe
|
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
||||||
OUTPUT_VARIABLE GIT_COMMIT_TAG
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
)
|
|
||||||
|
|
||||||
set(LIBWEBRTC_MAJOR_VERSION 0)
|
|
||||||
set(LIBWEBRTC_MINOR_VERSION 0)
|
|
||||||
set(LIBWEBRTC_PATCH_VERSION 1)
|
|
||||||
set(LIBWEBRTC_BUILD_VERSION rc.4)
|
|
||||||
|
|
||||||
set(LIBWEBRTC_API_VERSION
|
|
||||||
"${LIBWEBRTC_MAJOR_VERSION}.${LIBWEBRTC_MINOR_VERSION}.${LIBWEBRTC_PATCH_VERSION}"
|
|
||||||
)
|
|
||||||
set(LIBWEBRTC_VERSION
|
|
||||||
${LIBWEBRTC_API_VERSION}-${LIBWEBRTC_BUILD_VERSION}
|
|
||||||
)
|
|
||||||
|
|
||||||
set(LIBWEBRTC_LIBRARY_PROPERTIES ${LIBWEBRTC_LIBRARY_PROPERTIES}
|
|
||||||
VERSION "${LIBWEBRTC_VERSION}"
|
|
||||||
SOVERSION "${LIBWEBRTC_API_VERSION}"
|
|
||||||
)
|
|
||||||
|
|
||||||
#
|
|
||||||
# Directories
|
|
||||||
#
|
|
||||||
|
|
||||||
if(NOT LIBWEBRTC_INSTALL_BIN_DIR)
|
|
||||||
set(LIBWEBRTC_INSTALL_BIN_DIR "bin")
|
|
||||||
endif()
|
|
||||||
if(NOT LIBWEBRTC_INSTALL_LIB_DIR)
|
|
||||||
set(LIBWEBRTC_INSTALL_LIB_DIR "lib")
|
|
||||||
endif()
|
|
||||||
if(NOT LIBWEBRTC_INSTALL_DATA_DIR)
|
|
||||||
set(LIBWEBRTC_INSTALL_DATA_DIR "share")
|
|
||||||
endif()
|
|
||||||
if(NOT LIBWEBRTC_INSTALL_INCLUDE_DIR)
|
|
||||||
set(LIBWEBRTC_INSTALL_INCLUDE_DIR "include")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(LIBWEBRTC_LIBRARY_NAME ${CMAKE_STATIC_LIBRARY_PREFIX}webrtc${CMAKE_STATIC_LIBRARY_SUFFIX})
|
set(WEBRTC_SOURCE_DIR "${CMAKE_SOURCE_DIR}/webrtc/src")
|
||||||
|
set(WEBRTC_BUILD_DIR "${CMAKE_BINARY_DIR}/webrtc")
|
||||||
|
|
||||||
set(LIBWEBRTC_LIBRARY_PATH ${CMAKE_BINARY_DIR}/${LIBWEBRTC_INSTALL_LIB_DIR}/${LIBWEBRTC_LIBRARY_NAME})
|
include(Version)
|
||||||
|
get_webrtc_version_from_git(WEBRTC_VERSION)
|
||||||
|
message(STATUS "WebRTC version: ${WEBRTC_VERSION}")
|
||||||
|
|
||||||
set(LIBWEBRTC_BUILD_ROOT ${CMAKE_SOURCE_DIR}/src/out/Default)
|
if (MSVC)
|
||||||
set(LIBWEBRTC_CHROMIUM_DEPS https://github.com/aisouard/libwebrtc-chromium-deps.git)
|
# Always build with dynamic runtime on MSVC
|
||||||
set(LIBWEBRTC_WEBRTC_REVISION 7502401788fcba5c9f81a9e4701e2f0831e78698)
|
patch_file(${WEBRTC_SOURCE_DIR}/build/config/win/BUILD.gn ":static_crt" ":dynamic_crt")
|
||||||
|
endif ()
|
||||||
|
|
||||||
add_subdirectory(Targets)
|
# Copy all files from 'patches' directory to 'webrtc/src'
|
||||||
|
# For example, 'patches/api/foo.h' will be copied to 'webrtc/src/api/foo.h'
|
||||||
|
include(PatchSources)
|
||||||
|
patch_sources("${CMAKE_CURRENT_SOURCE_DIR}/patches" "${CMAKE_CURRENT_SOURCE_DIR}/webrtc/src")
|
||||||
|
|
||||||
if(BUILD_SAMPLES)
|
include(AddWebRTCTarget)
|
||||||
add_subdirectory(Samples)
|
add_webrtc_target(${WEBRTC_SOURCE_DIR} ${WEBRTC_BUILD_DIR})
|
||||||
endif(BUILD_SAMPLES)
|
|
||||||
|
add_subdirectory(libwebrtc)
|
||||||
|
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
macro(add_libwebrtc_command
|
|
||||||
ARG_NAME
|
|
||||||
ARG_OUTPUT
|
|
||||||
ARG_COMMAND
|
|
||||||
ARG_WORKING_DIRECTORY
|
|
||||||
ARG_COMMENT
|
|
||||||
)
|
|
||||||
set (ARG_DEPENDENCIES ${ARGN})
|
|
||||||
|
|
||||||
add_custom_command(
|
|
||||||
OUTPUT ${ARG_OUTPUT}
|
|
||||||
COMMAND export "PATH=${CMAKE_SOURCE_DIR}/Dependencies/depot_tools:$ENV{PATH}" && ${ARG_COMMAND}
|
|
||||||
WORKING_DIRECTORY ${ARG_WORKING_DIRECTORY}
|
|
||||||
COMMENT ${ARG_COMMENT}
|
|
||||||
)
|
|
||||||
|
|
||||||
add_custom_target(
|
|
||||||
${ARG_NAME} ALL
|
|
||||||
DEPENDS ${ARG_OUTPUT}
|
|
||||||
)
|
|
||||||
|
|
||||||
list(LENGTH ARG_DEPENDENCIES NUM_ARG_DEPENDENCIES)
|
|
||||||
if (${NUM_ARG_DEPENDENCIES} GREATER 0)
|
|
||||||
add_dependencies(${ARG_NAME} ${ARG_DEPENDENCIES})
|
|
||||||
endif ()
|
|
||||||
endmacro()
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
find_program(DEPOTTOOLS_GCLIENT_EXECUTABLE
|
|
||||||
NAMES gclient gclient.bat
|
|
||||||
PATHS ${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/depot_tools
|
|
||||||
)
|
|
||||||
|
|
||||||
include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
|
|
||||||
find_package_handle_standard_args(DepotTools
|
|
||||||
REQUIRED_VARS DEPOTTOOLS_GCLIENT_EXECUTABLE
|
|
||||||
FAIL_MESSAGE "Could not find the gclient executable."
|
|
||||||
)
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
find_path(
|
|
||||||
LIBWEBRTC_INCLUDE_DIR typedefs.h
|
|
||||||
HINTS
|
|
||||||
ENV LIBWEBRTCDIR
|
|
||||||
PATH_SUFFIXES webrtc
|
|
||||||
include/webrtc include
|
|
||||||
)
|
|
||||||
|
|
||||||
find_library(
|
|
||||||
LIBWEBRTC_LIBRARY
|
|
||||||
NAMES webrtc
|
|
||||||
HINTS
|
|
||||||
ENV LIBWEBRTCDIR
|
|
||||||
PATH_SUFFIXES lib
|
|
||||||
)
|
|
||||||
|
|
||||||
mark_as_advanced(LIBWEBRTC_LIBRARY LIBWEBRTC_INCLUDE_DIR)
|
|
||||||
1
Dependencies/depot_tools
vendored
1
Dependencies/depot_tools
vendored
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit f7b29d4a6dd3fa9777f68423fedcc1a6154014bf
|
|
||||||
4
Jakefile
4
Jakefile
|
|
@ -1,4 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
desc('Default task');
|
|
||||||
task('default', ['fetch:precompiled'], function () {});
|
|
||||||
201
LICENSE
Normal file
201
LICENSE
Normal file
|
|
@ -0,0 +1,201 @@
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright 2016 Axel Isouard
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
185
README.md
185
README.md
|
|
@ -1,2 +1,183 @@
|
||||||
# libwebrtc
|
# libwebrtc [![License][license-img]][license-href]
|
||||||
Attempting to bring the easiest way to work with WebRTC C++ Library
|
|
||||||
|
This repository contains a collection of CMake scripts to help you embed
|
||||||
|
Google's native WebRTC implementation inside your project as simple as this:
|
||||||
|
|
||||||
|
```cmake
|
||||||
|
cmake_minimum_required(VERSION 3.9)
|
||||||
|
project(sample)
|
||||||
|
|
||||||
|
find_package(LibWebRTC REQUIRED)
|
||||||
|
include(${LIBWEBRTC_USE_FILE})
|
||||||
|
|
||||||
|
set(SOURCE_FILES main.cpp)
|
||||||
|
add_executable(sample ${SOURCE_FILES})
|
||||||
|
target_link_libraries(sample ${LIBWEBRTC_LIBRARIES})
|
||||||
|
```
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
- CMake 3.9 or later
|
||||||
|
- Python 2.7 (optional for Windows since it will use the interpreter located
|
||||||
|
inside the `depot_tools` installation)
|
||||||
|
|
||||||
|
### Debian & Ubuntu
|
||||||
|
|
||||||
|
- Required development packages:
|
||||||
|
|
||||||
|
```
|
||||||
|
# apt-get install build-essential libglib2.0-dev libgtk2.0-dev libxtst-dev \
|
||||||
|
libxss-dev libpci-dev libdbus-1-dev libgconf2-dev \
|
||||||
|
libgnome-keyring-dev libnss3-dev libasound2-dev libpulse-dev \
|
||||||
|
libudev-dev
|
||||||
|
```
|
||||||
|
|
||||||
|
- GCC & G++ 4.8 or later, for C++11 support
|
||||||
|
|
||||||
|
### macOS
|
||||||
|
|
||||||
|
- OS X 10.11 or later
|
||||||
|
- Xcode 7.3.1 or later
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
|
||||||
|
- Windows 7 x64 or later
|
||||||
|
- Visual Studio 2015/2017
|
||||||
|
|
||||||
|
Make sure that you install the following components:
|
||||||
|
|
||||||
|
- Visual C++, which will select three sub-categories including MFC
|
||||||
|
- Universal Windows Apps Development Tools
|
||||||
|
- Tools (1.4.1) and Windows 10 SDK (**10.0.14393**)
|
||||||
|
|
||||||
|
- [Windows 10 SDK][w10sdk] with **Debugging Tools for Windows** or
|
||||||
|
[Windows Driver Kit 10][wdk10] installed in the same Windows 10 SDK
|
||||||
|
installation directory.
|
||||||
|
|
||||||
|
## Getting sources
|
||||||
|
Clone the repository and run script to fetch WebRTC sources.
|
||||||
|
You can pass WebRTC version (branch) to script to fetch specific version.
|
||||||
|
|
||||||
|
```
|
||||||
|
git clone https://github.com/UltraCoderRU/libwebrtc.git
|
||||||
|
cd libwebrtc
|
||||||
|
python3 sync.py [WEBRTC_VERSION]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Compiling
|
||||||
|
|
||||||
|
Create an output directory, browse inside it, then run CMake to configure project.
|
||||||
|
|
||||||
|
```
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake -G Ninja -DCMAKE_BUILD_TYPE=<Debug/Release> -DCMAKE_INSTALL_PREFIX=<install_path> ..
|
||||||
|
```
|
||||||
|
|
||||||
|
After configuration build library using standard CMake commands.
|
||||||
|
|
||||||
|
```
|
||||||
|
cmake --build .
|
||||||
|
cmake --install .
|
||||||
|
```
|
||||||
|
|
||||||
|
The library will be located inside the `lib` subdirectory of the `<install_path>`.
|
||||||
|
The `include` subdirectory will contain the header files.
|
||||||
|
CMake scripts will be placed inside the `lib/cmake/LibWebRTC` subdirectory.
|
||||||
|
|
||||||
|
## Using WebRTC in your project
|
||||||
|
|
||||||
|
To import LibWebRTC into your CMake project use `find_package`:
|
||||||
|
```cmake
|
||||||
|
find_package(LibWebRTC REQUIRED)
|
||||||
|
include(${LIBWEBRTC_USE_FILE})
|
||||||
|
|
||||||
|
target_link_libraries(my-app ${LIBWEBRTC_LIBRARIES})
|
||||||
|
```
|
||||||
|
|
||||||
|
You should add library installation path to `CMAKE_INSTALL_PREFIX` variable
|
||||||
|
while configuring your project:
|
||||||
|
```
|
||||||
|
cmake -DCMAKE_PREFIX_PATH=<install_path> ...
|
||||||
|
```
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
The library will be compiled and usable on the same host's platform and
|
||||||
|
architecture. Here are some CMake flags which could be useful if you need to
|
||||||
|
perform cross-compiling.
|
||||||
|
|
||||||
|
- **GN_EXTRA_ARGS**
|
||||||
|
|
||||||
|
Add extra arguments to the `gn gen --args` parameter.
|
||||||
|
|
||||||
|
- **NINJA_ARGS**
|
||||||
|
|
||||||
|
Arguments to pass while executing the `ninja` command.
|
||||||
|
|
||||||
|
## Status
|
||||||
|
|
||||||
|
The following table displays the current state of this project, including
|
||||||
|
supported platforms and architectures.
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td align="center"></td>
|
||||||
|
<td align="center">x86</td>
|
||||||
|
<td align="center">amd64</td>
|
||||||
|
<td align="center">arm</td>
|
||||||
|
<td align="center">arm64</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th align="center">Linux</th>
|
||||||
|
<td align="center">-</td>
|
||||||
|
<td align="center">✔</td>
|
||||||
|
<td align="center">-</td>
|
||||||
|
<td align="center">-</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th align="center">Windows</th>
|
||||||
|
<td align="center">-</td>
|
||||||
|
<td align="center">✔</td>
|
||||||
|
<td align="center">-</td>
|
||||||
|
<td align="center">-</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th align="center">MacOS</th>
|
||||||
|
<td align="center">-</td>
|
||||||
|
<td align="center">-</td>
|
||||||
|
<td align="center">-</td>
|
||||||
|
<td align="center">-</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th align="center">Android</th>
|
||||||
|
<td align="center">-</td>
|
||||||
|
<td align="center">-</td>
|
||||||
|
<td align="center">-</td>
|
||||||
|
<td align="center">-</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th align="center">iOS</th>
|
||||||
|
<td align="center">-</td>
|
||||||
|
<td align="center">-</td>
|
||||||
|
<td align="center">-</td>
|
||||||
|
<td align="center">-</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
## Acknowledgements
|
||||||
|
|
||||||
|
Many thanks to Dr. Alex Gouaillard for being an excellent mentor for this
|
||||||
|
project.
|
||||||
|
|
||||||
|
Everything started from his
|
||||||
|
«[Automating libwebrtc build with CMake][webrtc-dr-alex-cmake]» blog article,
|
||||||
|
which was a great source of inspiration for me to create the easiest way to link
|
||||||
|
the WebRTC library in any native project.
|
||||||
|
|
||||||
|
[license-img]:https://img.shields.io/badge/License-Apache%202.0-blue.svg
|
||||||
|
[license-href]:https://opensource.org/licenses/Apache-2.0
|
||||||
|
[w10sdk]:https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk
|
||||||
|
[wdk10]:https://go.microsoft.com/fwlink/p/?LinkId=526733
|
||||||
|
[webrtc-dr-alex-cmake]:http://webrtcbydralex.com/index.php/2015/07/22/automating-libwebrtc-build-with-cmake
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
add_subdirectory(PeerConnection)
|
|
||||||
|
|
@ -1,52 +0,0 @@
|
||||||
project(PeerConnection)
|
|
||||||
|
|
||||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|
||||||
find_package(Threads REQUIRED)
|
|
||||||
find_package(X11 REQUIRED)
|
|
||||||
|
|
||||||
set(PEERCONNECTION_SOURCE_FILES
|
|
||||||
main.cpp
|
|
||||||
Core.cpp
|
|
||||||
CreateSessionObserver.cpp
|
|
||||||
DataChannelObserver.cpp
|
|
||||||
Peer.cpp
|
|
||||||
PeerConnectionObserver.cpp
|
|
||||||
SetLocalSessionDescriptionObserver.cpp
|
|
||||||
SetRemoteSessionDescriptionObserver.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
set(PEERCONNECTION_HEADER_FILES
|
|
||||||
Console.h
|
|
||||||
Core.h
|
|
||||||
CreateSessionObserver.h
|
|
||||||
DataChannelObserver.h
|
|
||||||
IPeer.h
|
|
||||||
Peer.h
|
|
||||||
PeerConnectionObserver.h
|
|
||||||
SetLocalSessionDescriptionObserver.h
|
|
||||||
SetRemoteSessionDescriptionObserver.h
|
|
||||||
)
|
|
||||||
|
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/out/src)
|
|
||||||
|
|
||||||
if(WIN)
|
|
||||||
add_definitions(-DWEBRTC_WIN)
|
|
||||||
else(WIN)
|
|
||||||
add_definitions(-DWEBRTC_POSIX -std=gnu++0x -D_GLIBCXX_USE_CXX11_ABI=0)
|
|
||||||
set(PEERCONNECTION_SOURCE_FILES ${PEERCONNECTION_SOURCE_FILES}
|
|
||||||
UnixConsole.cpp)
|
|
||||||
endif(WIN)
|
|
||||||
|
|
||||||
add_executable(PeerConnection
|
|
||||||
${PEERCONNECTION_SOURCE_FILES}
|
|
||||||
${PEERCONNECTION_HEADER_FILES})
|
|
||||||
|
|
||||||
set(PEERCONNECTION_LIBRARIES ${LIBWEBRTC_LIBRARY_PATH} Threads::Threads)
|
|
||||||
|
|
||||||
if(UNIX AND NOT APPLE)
|
|
||||||
set(PEERCONNECTION_LIBRARIES ${PEERCONNECTION_LIBRARIES}
|
|
||||||
${X11_LIBRARIES}
|
|
||||||
${CMAKE_DL_LIBS})
|
|
||||||
endif(UNIX AND NOT APPLE)
|
|
||||||
|
|
||||||
target_link_libraries(PeerConnection ${PEERCONNECTION_LIBRARIES})
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
//
|
|
||||||
// Created by ax on 25/09/16.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef LIBWEBRTC_UNIXCONSOLE_H
|
|
||||||
#define LIBWEBRTC_UNIXCONSOLE_H
|
|
||||||
|
|
||||||
class Console {
|
|
||||||
public:
|
|
||||||
static bool Init();
|
|
||||||
static bool Update(std::string &input);
|
|
||||||
static void Cleanup();
|
|
||||||
static void Reset(int num);
|
|
||||||
static void Print(const std::string &line, ...);
|
|
||||||
static void Show();
|
|
||||||
static void Hide();
|
|
||||||
static void Back();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //LIBWEBRTC_UNIXCONSOLE_H
|
|
||||||
|
|
@ -1,76 +0,0 @@
|
||||||
//
|
|
||||||
// Created by ax on 24/09/16.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "webrtc/base/ssladapter.h"
|
|
||||||
#include "Core.h"
|
|
||||||
|
|
||||||
rtc::Thread *Core::_signalingThread = NULL;
|
|
||||||
rtc::Thread *Core::_workerThread = NULL;
|
|
||||||
webrtc::PeerConnectionFactoryInterface *Core::_peerConnectionFactory = NULL;
|
|
||||||
|
|
||||||
bool Core::Init() {
|
|
||||||
rtc::InitializeSSL();
|
|
||||||
rtc::InitRandom(rtc::Time());
|
|
||||||
rtc::ThreadManager::Instance()->WrapCurrentThread();
|
|
||||||
|
|
||||||
_signalingThread = new rtc::Thread();
|
|
||||||
_workerThread = new rtc::Thread();
|
|
||||||
|
|
||||||
_signalingThread->SetName("signaling_thread", NULL);
|
|
||||||
_workerThread->SetName("worker_thread", NULL);
|
|
||||||
|
|
||||||
if (!_signalingThread->Start() || !_workerThread->Start()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
_peerConnectionFactory =
|
|
||||||
webrtc::CreatePeerConnectionFactory(_signalingThread,
|
|
||||||
_workerThread,
|
|
||||||
NULL, NULL, NULL).release();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Core::Update() {
|
|
||||||
return rtc::Thread::Current()->ProcessMessages(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Core::Cleanup() {
|
|
||||||
_peerConnectionFactory->Release();
|
|
||||||
_peerConnectionFactory = NULL;
|
|
||||||
|
|
||||||
_signalingThread->Stop();
|
|
||||||
_workerThread->Stop();
|
|
||||||
|
|
||||||
delete _signalingThread;
|
|
||||||
delete _workerThread;
|
|
||||||
|
|
||||||
_signalingThread = NULL;
|
|
||||||
_workerThread = NULL;
|
|
||||||
|
|
||||||
return rtc::CleanupSSL();
|
|
||||||
}
|
|
||||||
|
|
||||||
rtc::Thread *Core::GetSignalingThread() {
|
|
||||||
return _signalingThread;
|
|
||||||
}
|
|
||||||
|
|
||||||
rtc::Thread *Core::GetWorkerThread() {
|
|
||||||
return _workerThread;
|
|
||||||
}
|
|
||||||
|
|
||||||
webrtc::PeerConnectionFactoryInterface *Core::GetPeerConnectionFactory() {
|
|
||||||
return _peerConnectionFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
//
|
|
||||||
// Created by ax on 24/09/16.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef LIBWEBRTC_CORE_H
|
|
||||||
#define LIBWEBRTC_CORE_H
|
|
||||||
|
|
||||||
#include "webrtc/api/peerconnectioninterface.h"
|
|
||||||
#include "webrtc/base/thread.h"
|
|
||||||
|
|
||||||
class Core {
|
|
||||||
public:
|
|
||||||
static bool Init();
|
|
||||||
static bool Update();
|
|
||||||
static bool Cleanup();
|
|
||||||
|
|
||||||
static rtc::Thread *GetSignalingThread();
|
|
||||||
static rtc::Thread *GetWorkerThread();
|
|
||||||
static webrtc::PeerConnectionFactoryInterface *GetPeerConnectionFactory();
|
|
||||||
|
|
||||||
private:
|
|
||||||
static rtc::Thread *_signalingThread;
|
|
||||||
static rtc::Thread *_workerThread;
|
|
||||||
static webrtc::PeerConnectionFactoryInterface *_peerConnectionFactory;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif //LIBWEBRTC_CORE_H
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
//
|
|
||||||
// Created by ax on 25/09/16.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "CreateSessionObserver.h"
|
|
||||||
#include "Console.h"
|
|
||||||
#include "SetLocalSessionDescriptionObserver.h"
|
|
||||||
|
|
||||||
using namespace webrtc;
|
|
||||||
|
|
||||||
CreateSessionObserver::CreateSessionObserver(IPeer *peer): _peer(peer) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void CreateSessionObserver::OnSuccess(SessionDescriptionInterface* desc) {
|
|
||||||
rtc::scoped_refptr<SetLocalSessionDescriptionObserver> observer =
|
|
||||||
new rtc::RefCountedObject<SetLocalSessionDescriptionObserver>(desc);
|
|
||||||
|
|
||||||
_peer->SetLocalSessionDescription(desc, observer);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CreateSessionObserver::OnFailure(const std::string& error) {
|
|
||||||
Console::Print("[CreateSessionObserver::OnFailure] %s", error.c_str());
|
|
||||||
}
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
//
|
|
||||||
// Created by ax on 25/09/16.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef LIBWEBRTC_CREATEOFFEROBSERVER_H
|
|
||||||
#define LIBWEBRTC_CREATEOFFEROBSERVER_H
|
|
||||||
|
|
||||||
#include <webrtc/api/jsep.h>
|
|
||||||
#include "IPeer.h"
|
|
||||||
|
|
||||||
class CreateSessionObserver: public webrtc::CreateSessionDescriptionObserver {
|
|
||||||
public:
|
|
||||||
CreateSessionObserver(IPeer *peer);
|
|
||||||
|
|
||||||
void OnSuccess(webrtc::SessionDescriptionInterface* desc);
|
|
||||||
void OnFailure(const std::string& error);
|
|
||||||
|
|
||||||
private:
|
|
||||||
IPeer *_peer;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
~CreateSessionObserver() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif //LIBWEBRTC_CREATEOFFEROBSERVER_H
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
//
|
|
||||||
// Created by ax on 25/09/16.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "DataChannelObserver.h"
|
|
||||||
#include "Console.h"
|
|
||||||
|
|
||||||
|
|
||||||
DataChannelObserver::DataChannelObserver(
|
|
||||||
webrtc::DataChannelInterface *dataChannel): _dataChannel(dataChannel) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataChannelObserver::OnStateChange() {
|
|
||||||
Console::Print("[DataChannelObserver::OnStateChange] %s",
|
|
||||||
webrtc::DataChannelInterface::DataStateString(_dataChannel->state()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataChannelObserver::OnMessage(const webrtc::DataBuffer& buffer) {
|
|
||||||
size_t len = buffer.size();
|
|
||||||
const unsigned char *data = buffer.data.cdata();
|
|
||||||
char *message = new char[len + 1];
|
|
||||||
|
|
||||||
memcpy(message, data, len);
|
|
||||||
message[len] = '\0';
|
|
||||||
|
|
||||||
Console::Print("<Remote> %s", message);
|
|
||||||
delete[] message;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataChannelObserver::OnBufferedAmountChange(uint64_t previous_amount) {
|
|
||||||
}
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
//
|
|
||||||
// Created by ax on 25/09/16.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef LIBWEBRTC_DATACHANNELOBSERVER_H
|
|
||||||
#define LIBWEBRTC_DATACHANNELOBSERVER_H
|
|
||||||
|
|
||||||
#include <webrtc/api/datachannelinterface.h>
|
|
||||||
|
|
||||||
class DataChannelObserver: public webrtc::DataChannelObserver {
|
|
||||||
public:
|
|
||||||
DataChannelObserver(webrtc::DataChannelInterface *dataChannel);
|
|
||||||
|
|
||||||
void OnStateChange();
|
|
||||||
void OnMessage(const webrtc::DataBuffer& buffer);
|
|
||||||
void OnBufferedAmountChange(uint64_t previous_amount);
|
|
||||||
|
|
||||||
private:
|
|
||||||
webrtc::DataChannelInterface *_dataChannel;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //LIBWEBRTC_DATACHANNELOBSERVER_H
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
//
|
|
||||||
// Created by ax on 26/09/16.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef LIBWEBRTC_IPEER_H
|
|
||||||
#define LIBWEBRTC_IPEER_H
|
|
||||||
|
|
||||||
#include "webrtc/api/peerconnectioninterface.h"
|
|
||||||
|
|
||||||
class IPeer {
|
|
||||||
public:
|
|
||||||
virtual void CreateOffer(webrtc::CreateSessionDescriptionObserver *createSDPObserver) = 0;
|
|
||||||
virtual void CreateAnswer(webrtc::CreateSessionDescriptionObserver *createSDPObserver) = 0;
|
|
||||||
|
|
||||||
virtual bool AddIceCandidate(webrtc::IceCandidateInterface *candidate) = 0;
|
|
||||||
|
|
||||||
virtual void SetLocalSessionDescription(webrtc::SessionDescriptionInterface* desc,
|
|
||||||
webrtc::SetSessionDescriptionObserver *setSDPObserver) = 0;
|
|
||||||
virtual void SetRemoteSessionDescription(webrtc::SessionDescriptionInterface* desc,
|
|
||||||
webrtc::SetSessionDescriptionObserver *setSDPObserver) = 0;
|
|
||||||
|
|
||||||
virtual bool IsConnected() = 0;
|
|
||||||
virtual void SetDataChannel(webrtc::DataChannelInterface *dataChannel) = 0;
|
|
||||||
virtual void SendMessage(const std::string& message) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //LIBWEBRTC_IPEER_H
|
|
||||||
|
|
@ -1,115 +0,0 @@
|
||||||
//
|
|
||||||
// Created by ax on 24/09/16.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <third_party/jsoncpp/source/include/json/writer.h>
|
|
||||||
|
|
||||||
#include "Core.h"
|
|
||||||
#include "DataChannelObserver.h"
|
|
||||||
#include "Peer.h"
|
|
||||||
#include "PeerConnectionObserver.h"
|
|
||||||
|
|
||||||
using webrtc::DataChannelInit;
|
|
||||||
using webrtc::PeerConnectionInterface;
|
|
||||||
using webrtc::MediaConstraintsInterface;
|
|
||||||
using webrtc::SessionDescriptionInterface;
|
|
||||||
|
|
||||||
using webrtc::MediaStreamInterface;
|
|
||||||
using webrtc::DataChannelInterface;
|
|
||||||
using webrtc::IceCandidateInterface;
|
|
||||||
|
|
||||||
Peer::Peer() {
|
|
||||||
PeerConnectionInterface::RTCConfiguration config;
|
|
||||||
PeerConnectionInterface::IceServer googleIceServer;
|
|
||||||
|
|
||||||
googleIceServer.uri = "stun:stun.l.google.com:19302";
|
|
||||||
googleIceServer.urls.push_back("stun:stun.l.google.com:19302");
|
|
||||||
googleIceServer.urls.push_back("stun:stun1.l.google.com:19302");
|
|
||||||
googleIceServer.urls.push_back("stun:stun2.l.google.com:19302");
|
|
||||||
googleIceServer.urls.push_back("stun:stun3.l.google.com:19302");
|
|
||||||
googleIceServer.urls.push_back("stun:stun4.l.google.com:19302");
|
|
||||||
|
|
||||||
config.servers.push_back(googleIceServer);
|
|
||||||
|
|
||||||
_dataChannel = NULL;
|
|
||||||
_dataChannelObserver = NULL;
|
|
||||||
_peerConnectionObserver = new PeerConnectionObserver(this);
|
|
||||||
_peerConnection = Core::GetPeerConnectionFactory()->
|
|
||||||
CreatePeerConnection(config, &_mediaConstraints,
|
|
||||||
NULL, NULL, _peerConnectionObserver);
|
|
||||||
|
|
||||||
_mediaConstraints.AddOptional(
|
|
||||||
MediaConstraintsInterface::kEnableDtlsSrtp,
|
|
||||||
MediaConstraintsInterface::kValueTrue);
|
|
||||||
|
|
||||||
_mediaConstraints.AddMandatory(
|
|
||||||
MediaConstraintsInterface::kOfferToReceiveAudio,
|
|
||||||
MediaConstraintsInterface::kValueFalse);
|
|
||||||
|
|
||||||
_mediaConstraints.AddMandatory(
|
|
||||||
MediaConstraintsInterface::kOfferToReceiveVideo,
|
|
||||||
MediaConstraintsInterface::kValueFalse);
|
|
||||||
}
|
|
||||||
|
|
||||||
Peer::~Peer() {
|
|
||||||
if (_dataChannel) {
|
|
||||||
_dataChannel->Close();
|
|
||||||
_dataChannel->UnregisterObserver();
|
|
||||||
_dataChannel = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
_peerConnection->Close();
|
|
||||||
_peerConnection = NULL;
|
|
||||||
|
|
||||||
if (_dataChannelObserver) {
|
|
||||||
_dataChannelObserver = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Peer::CreateOffer(webrtc::CreateSessionDescriptionObserver *createSDPObserver) {
|
|
||||||
DataChannelInit init;
|
|
||||||
|
|
||||||
init.reliable = true;
|
|
||||||
_dataChannel = _peerConnection->CreateDataChannel("MyDataChannel", &init);
|
|
||||||
_dataChannelObserver = new DataChannelObserver(_dataChannel);
|
|
||||||
_dataChannel->RegisterObserver(_dataChannelObserver);
|
|
||||||
|
|
||||||
_peerConnection->CreateOffer(createSDPObserver, &_mediaConstraints);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Peer::CreateAnswer(webrtc::CreateSessionDescriptionObserver *createSDPObserver) {
|
|
||||||
_peerConnection->CreateAnswer(createSDPObserver, &_mediaConstraints);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Peer::AddIceCandidate(webrtc::IceCandidateInterface *candidate) {
|
|
||||||
return _peerConnection->AddIceCandidate(candidate);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Peer::SetLocalSessionDescription(SessionDescriptionInterface* desc,
|
|
||||||
webrtc::SetSessionDescriptionObserver *obs) {
|
|
||||||
_peerConnection->SetLocalDescription(obs, desc);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Peer::SetRemoteSessionDescription(SessionDescriptionInterface* desc,
|
|
||||||
webrtc::SetSessionDescriptionObserver *obs) {
|
|
||||||
_peerConnection->SetRemoteDescription(obs, desc);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Peer::IsConnected() {
|
|
||||||
if (!_dataChannel) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _dataChannel->state() == webrtc::DataChannelInterface::kOpen;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Peer::SetDataChannel(webrtc::DataChannelInterface *dataChannel) {
|
|
||||||
_dataChannel = dataChannel;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Peer::SendMessage(const std::string& message) {
|
|
||||||
webrtc::DataBuffer buffer(message);
|
|
||||||
|
|
||||||
_dataChannel->Send(buffer);
|
|
||||||
}
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
//
|
|
||||||
// Created by ax on 24/09/16.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef LIBWEBRTC_PEER_H
|
|
||||||
#define LIBWEBRTC_PEER_H
|
|
||||||
|
|
||||||
#include <third_party/jsoncpp/source/include/json/value.h>
|
|
||||||
#include "webrtc/api/test/fakeconstraints.h"
|
|
||||||
#include "webrtc/api/peerconnectioninterface.h"
|
|
||||||
|
|
||||||
#include "IPeer.h"
|
|
||||||
|
|
||||||
class Peer: public IPeer {
|
|
||||||
public:
|
|
||||||
Peer();
|
|
||||||
~Peer();
|
|
||||||
|
|
||||||
void CreateOffer(webrtc::CreateSessionDescriptionObserver *createSDPObserver);
|
|
||||||
void CreateAnswer(webrtc::CreateSessionDescriptionObserver *createSDPObserver);
|
|
||||||
|
|
||||||
bool AddIceCandidate(webrtc::IceCandidateInterface *candidate);
|
|
||||||
|
|
||||||
void SetLocalSessionDescription(webrtc::SessionDescriptionInterface* desc,
|
|
||||||
webrtc::SetSessionDescriptionObserver *setSDPObserver);
|
|
||||||
void SetRemoteSessionDescription(webrtc::SessionDescriptionInterface* desc,
|
|
||||||
webrtc::SetSessionDescriptionObserver *setSDPObserver);
|
|
||||||
|
|
||||||
bool IsConnected();
|
|
||||||
void SetDataChannel(webrtc::DataChannelInterface *dataChannel);
|
|
||||||
void SendMessage(const std::string& message);
|
|
||||||
|
|
||||||
private:
|
|
||||||
rtc::scoped_refptr<webrtc::PeerConnectionInterface> _peerConnection;
|
|
||||||
webrtc::PeerConnectionObserver *_peerConnectionObserver;
|
|
||||||
webrtc::FakeConstraints _mediaConstraints;
|
|
||||||
rtc::scoped_refptr<webrtc::DataChannelInterface> _dataChannel;
|
|
||||||
webrtc::DataChannelObserver *_dataChannelObserver;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //LIBWEBRTC_PEER_H
|
|
||||||
|
|
@ -1,92 +0,0 @@
|
||||||
//
|
|
||||||
// Created by ax on 25/09/16.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <third_party/jsoncpp/source/include/json/writer.h>
|
|
||||||
#include "DataChannelObserver.h"
|
|
||||||
#include "PeerConnectionObserver.h"
|
|
||||||
#include "Console.h"
|
|
||||||
|
|
||||||
using webrtc::PeerConnectionInterface;
|
|
||||||
using webrtc::MediaStreamInterface;
|
|
||||||
using webrtc::DataChannelInterface;
|
|
||||||
using webrtc::IceCandidateInterface;
|
|
||||||
|
|
||||||
PeerConnectionObserver::PeerConnectionObserver(IPeer *peer):
|
|
||||||
_peer(peer), _dataChannelObserver(NULL) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void PeerConnectionObserver::OnSignalingChange(
|
|
||||||
PeerConnectionInterface::SignalingState new_state) {
|
|
||||||
Console::Print("[PeerConnectionObserver::OnSignalingChange] new signaling state: %d",
|
|
||||||
new_state);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PeerConnectionObserver::OnAddStream(rtc::scoped_refptr<MediaStreamInterface> stream) {
|
|
||||||
Console::Print("[PeerConnectionObserver::OnAddStream]");
|
|
||||||
}
|
|
||||||
|
|
||||||
void PeerConnectionObserver::OnRemoveStream(rtc::scoped_refptr<MediaStreamInterface> stream) {
|
|
||||||
Console::Print("[PeerConnectionObserver::OnRemoveStream]");
|
|
||||||
}
|
|
||||||
|
|
||||||
void PeerConnectionObserver::OnDataChannel(
|
|
||||||
rtc::scoped_refptr<DataChannelInterface> data_channel) {
|
|
||||||
Console::Print("[PeerConnectionObserver::OnDataChannel] %s", data_channel->label().c_str());
|
|
||||||
_dataChannelObserver = new DataChannelObserver(data_channel);
|
|
||||||
data_channel->RegisterObserver(_dataChannelObserver);
|
|
||||||
_peer->SetDataChannel(data_channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PeerConnectionObserver::OnRenegotiationNeeded() {
|
|
||||||
}
|
|
||||||
|
|
||||||
void PeerConnectionObserver::OnIceConnectionChange(
|
|
||||||
PeerConnectionInterface::IceConnectionState new_state) {
|
|
||||||
if (new_state == PeerConnectionInterface::kIceConnectionCompleted) {
|
|
||||||
Console::Print("Connected!");
|
|
||||||
} else if (new_state > PeerConnectionInterface::kIceConnectionCompleted) {
|
|
||||||
Console::Print("Disconnected.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PeerConnectionObserver::OnIceGatheringChange(
|
|
||||||
PeerConnectionInterface::IceGatheringState new_state) {
|
|
||||||
if (new_state == PeerConnectionInterface::kIceGatheringGathering) {
|
|
||||||
Console::Print("Gathering ICE candidates, please wait.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (new_state != PeerConnectionInterface::kIceGatheringComplete) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Json::FastWriter writer;
|
|
||||||
writer.write(_iceCandidates);
|
|
||||||
|
|
||||||
Console::Print("Done, paste this array of ICE candidates once requested." \
|
|
||||||
"\n\n%s", writer.write(_iceCandidates).c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
void PeerConnectionObserver::OnIceCandidate(const IceCandidateInterface* candidate) {
|
|
||||||
Json::Value jmessage;
|
|
||||||
|
|
||||||
jmessage["sdpMid"] = candidate->sdp_mid();
|
|
||||||
jmessage["sdpMLineIndex"] = candidate->sdp_mline_index();
|
|
||||||
std::string sdp;
|
|
||||||
if (!candidate->ToString(&sdp)) {
|
|
||||||
Console::Print("[PeerConnectionObserver::OnIceCandidate] Failed to serialize candidate");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
jmessage["candidate"] = sdp;
|
|
||||||
_iceCandidates.append(jmessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PeerConnectionObserver::OnIceCandidatesRemoved(
|
|
||||||
const std::vector<cricket::Candidate>& candidates) {
|
|
||||||
Console::Print("[PeerConnectionObserver::OnIceCandidatesRemoved]");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void PeerConnectionObserver::OnIceConnectionReceivingChange(bool receiving) {
|
|
||||||
}
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
||||||
//
|
|
||||||
// Created by ax on 25/09/16.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef LIBWEBRTC_PEERCONNECTIONOBSERVER_H
|
|
||||||
#define LIBWEBRTC_PEERCONNECTIONOBSERVER_H
|
|
||||||
|
|
||||||
#include <third_party/jsoncpp/source/include/json/value.h>
|
|
||||||
#include <webrtc/api/peerconnectioninterface.h>
|
|
||||||
#include "IPeer.h"
|
|
||||||
|
|
||||||
class PeerConnectionObserver: public webrtc::PeerConnectionObserver {
|
|
||||||
public:
|
|
||||||
PeerConnectionObserver(IPeer *peer);
|
|
||||||
|
|
||||||
void OnSignalingChange(
|
|
||||||
webrtc::PeerConnectionInterface::SignalingState new_state);
|
|
||||||
|
|
||||||
void OnAddStream(rtc::scoped_refptr<webrtc::MediaStreamInterface> stream);
|
|
||||||
void OnRemoveStream(rtc::scoped_refptr<webrtc::MediaStreamInterface> stream);
|
|
||||||
|
|
||||||
void OnDataChannel(
|
|
||||||
rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel);
|
|
||||||
|
|
||||||
void OnRenegotiationNeeded();
|
|
||||||
|
|
||||||
void OnIceConnectionChange(
|
|
||||||
webrtc::PeerConnectionInterface::IceConnectionState new_state);
|
|
||||||
void OnIceGatheringChange(
|
|
||||||
webrtc::PeerConnectionInterface::IceGatheringState new_state);
|
|
||||||
|
|
||||||
void OnIceCandidate(const webrtc::IceCandidateInterface* candidate);
|
|
||||||
void OnIceCandidatesRemoved(
|
|
||||||
const std::vector<cricket::Candidate>& candidates);
|
|
||||||
void OnIceConnectionReceivingChange(bool receiving);
|
|
||||||
|
|
||||||
private:
|
|
||||||
IPeer *_peer;
|
|
||||||
webrtc::DataChannelObserver *_dataChannelObserver;
|
|
||||||
Json::Value _iceCandidates;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif //LIBWEBRTC_PEERCONNECTIONOBSERVER_H
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
//
|
|
||||||
// Created by ax on 25/09/16.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <third_party/jsoncpp/source/include/json/writer.h>
|
|
||||||
#include "SetLocalSessionDescriptionObserver.h"
|
|
||||||
#include "Console.h"
|
|
||||||
|
|
||||||
SetLocalSessionDescriptionObserver::SetLocalSessionDescriptionObserver(
|
|
||||||
webrtc::SessionDescriptionInterface* desc): _desc(desc) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetLocalSessionDescriptionObserver::OnSuccess() {
|
|
||||||
std::string sdp;
|
|
||||||
|
|
||||||
_desc->ToString(&sdp);
|
|
||||||
|
|
||||||
Json::FastWriter writer;
|
|
||||||
Json::Value jmessage;
|
|
||||||
jmessage["type"] = _desc->type();
|
|
||||||
jmessage["sdp"] = sdp;
|
|
||||||
|
|
||||||
Console::Print("Here is the SDP, paste it to the remote client and paste " \
|
|
||||||
"their answer here.\n\n%s", writer.write(jmessage).c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetLocalSessionDescriptionObserver::OnFailure(const std::string& error) {
|
|
||||||
Console::Print("[SetLocalSessionDescriptionObserver::OnFailure] %s",
|
|
||||||
error.c_str());
|
|
||||||
}
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
//
|
|
||||||
// Created by ax on 25/09/16.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef LIBWEBRTC_SETLOCALSESSIONDESCRIPTIONOBSERVER_H
|
|
||||||
#define LIBWEBRTC_SETLOCALSESSIONDESCRIPTIONOBSERVER_H
|
|
||||||
|
|
||||||
|
|
||||||
#include <webrtc/api/jsep.h>
|
|
||||||
|
|
||||||
class SetLocalSessionDescriptionObserver:
|
|
||||||
public webrtc::SetSessionDescriptionObserver {
|
|
||||||
public:
|
|
||||||
SetLocalSessionDescriptionObserver(webrtc::SessionDescriptionInterface* desc);
|
|
||||||
|
|
||||||
void OnSuccess();
|
|
||||||
void OnFailure(const std::string& error);
|
|
||||||
|
|
||||||
private:
|
|
||||||
webrtc::SessionDescriptionInterface* _desc;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
~SetLocalSessionDescriptionObserver() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif //LIBWEBRTC_SETLOCALSESSIONDESCRIPTIONOBSERVER_H
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
//
|
|
||||||
// Created by ax on 25/09/16.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "SetRemoteSessionDescriptionObserver.h"
|
|
||||||
#include "CreateSessionObserver.h"
|
|
||||||
#include "Console.h"
|
|
||||||
|
|
||||||
|
|
||||||
SetRemoteSessionDescriptionObserver::SetRemoteSessionDescriptionObserver(
|
|
||||||
IPeer *peer, webrtc::SessionDescriptionInterface* desc):
|
|
||||||
_peer(peer), _desc(desc) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetRemoteSessionDescriptionObserver::OnSuccess() {
|
|
||||||
if (_desc->type() == webrtc::SessionDescriptionInterface::kOffer) {
|
|
||||||
rtc::scoped_refptr<CreateSessionObserver> createAnswerObserver =
|
|
||||||
new rtc::RefCountedObject<CreateSessionObserver>(_peer);
|
|
||||||
|
|
||||||
_peer->CreateAnswer(createAnswerObserver);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetRemoteSessionDescriptionObserver::OnFailure(const std::string& error) {
|
|
||||||
Console::Print("[SetRemoteSessionDescriptionObserver::OnFailure] %s",
|
|
||||||
error.c_str());
|
|
||||||
}
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
//
|
|
||||||
// Created by ax on 25/09/16.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef LIBWEBRTC_SETREMOTESESSIONDESCRIPTIONOBSERVER_H
|
|
||||||
#define LIBWEBRTC_SETREMOTESESSIONDESCRIPTIONOBSERVER_H
|
|
||||||
|
|
||||||
#include <webrtc/api/jsep.h>
|
|
||||||
#include "IPeer.h"
|
|
||||||
|
|
||||||
class SetRemoteSessionDescriptionObserver:
|
|
||||||
public webrtc::SetSessionDescriptionObserver {
|
|
||||||
public:
|
|
||||||
SetRemoteSessionDescriptionObserver(IPeer *peer, webrtc::SessionDescriptionInterface* desc);
|
|
||||||
|
|
||||||
void OnSuccess();
|
|
||||||
void OnFailure(const std::string& error);
|
|
||||||
|
|
||||||
private:
|
|
||||||
IPeer *_peer;
|
|
||||||
webrtc::SessionDescriptionInterface* _desc;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
~SetRemoteSessionDescriptionObserver() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif //LIBWEBRTC_SETREMOTESESSIONDESCRIPTIONOBSERVER_H
|
|
||||||
|
|
@ -1,153 +0,0 @@
|
||||||
//
|
|
||||||
// Created by ax on 25/09/16.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <csignal>
|
|
||||||
#include <cstdarg>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cstring>
|
|
||||||
#include <iostream>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <termios.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include "Console.h"
|
|
||||||
|
|
||||||
static int ttyErase;
|
|
||||||
static int ttyEof;
|
|
||||||
static struct termios ttyTc;
|
|
||||||
|
|
||||||
static size_t cursor;
|
|
||||||
static std::string buffer;
|
|
||||||
|
|
||||||
bool Console::Init() {
|
|
||||||
struct termios tc;
|
|
||||||
const char* term = getenv("TERM");
|
|
||||||
|
|
||||||
signal(SIGTTIN, SIG_IGN);
|
|
||||||
signal(SIGTTOU, SIG_IGN);
|
|
||||||
signal(SIGCONT, Console::Reset);
|
|
||||||
fcntl(STDIN_FILENO, F_SETFL, fcntl(STDIN_FILENO, F_GETFL, 0) | O_NONBLOCK );
|
|
||||||
|
|
||||||
if (!(isatty(STDIN_FILENO) &&
|
|
||||||
!(term && (!strcmp(term, "raw") || !strcmp(term, "dumb"))))) {
|
|
||||||
std::cerr << "Input is not a tty." << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
tcgetattr (STDIN_FILENO, &ttyTc);
|
|
||||||
ttyErase = ttyTc.c_cc[VERASE];
|
|
||||||
ttyEof = ttyTc.c_cc[VEOF];
|
|
||||||
|
|
||||||
tc = ttyTc;
|
|
||||||
tc.c_lflag &= ~(ECHO | ICANON);
|
|
||||||
tc.c_iflag &= ~(ISTRIP | INPCK);
|
|
||||||
tc.c_cc[VMIN] = 1;
|
|
||||||
tc.c_cc[VTIME] = 0;
|
|
||||||
tcsetattr (STDIN_FILENO, TCSADRAIN, &tc);
|
|
||||||
|
|
||||||
cursor = 0;
|
|
||||||
buffer.clear();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Console::Update(std::string &input) {
|
|
||||||
char key;
|
|
||||||
ssize_t avail = read(STDIN_FILENO, &key, 1);
|
|
||||||
|
|
||||||
input.clear();
|
|
||||||
if (avail == -1) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (key == ttyEof) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (((key == ttyErase) || (key == 127) || (key == 8)) && cursor > 0)
|
|
||||||
{
|
|
||||||
buffer.erase(--cursor, 1);
|
|
||||||
Console::Back();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (key == '\n') {
|
|
||||||
input = buffer;
|
|
||||||
cursor = 0;
|
|
||||||
buffer.clear();
|
|
||||||
|
|
||||||
write(STDOUT_FILENO, &key, 1);
|
|
||||||
key = '>';
|
|
||||||
write(STDOUT_FILENO, &key, 1);
|
|
||||||
key = ' ';
|
|
||||||
write(STDOUT_FILENO, &key, 1);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (key < ' ') {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
cursor++;
|
|
||||||
buffer.append(1, key);
|
|
||||||
write(STDOUT_FILENO, &key, 1);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Console::Cleanup() {
|
|
||||||
tcsetattr (STDIN_FILENO, TCSADRAIN, &ttyTc);
|
|
||||||
fcntl(STDIN_FILENO, F_SETFL, fcntl(STDIN_FILENO, F_GETFL, 0) & ~O_NONBLOCK);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Console::Reset(int num) {
|
|
||||||
Console::Init();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Console::Show() {
|
|
||||||
char key;
|
|
||||||
|
|
||||||
key = '>';
|
|
||||||
write(STDOUT_FILENO, &key, 1);
|
|
||||||
key = ' ';
|
|
||||||
write(STDOUT_FILENO, &key, 1);
|
|
||||||
|
|
||||||
|
|
||||||
for (size_t i = 0; i < cursor; i++) {
|
|
||||||
key = buffer.at(i);
|
|
||||||
write(STDOUT_FILENO, &key, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Console::Hide() {
|
|
||||||
for (int i = 0; i < cursor + 2; i++) {
|
|
||||||
Console::Back();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Console::Print(const std::string &fmt, ...) {
|
|
||||||
va_list argptr;
|
|
||||||
char string[1024];
|
|
||||||
|
|
||||||
if (!fmt.length()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
va_start(argptr, fmt);
|
|
||||||
vsnprintf(string, sizeof(string), fmt.c_str(), argptr);
|
|
||||||
va_end(argptr);
|
|
||||||
|
|
||||||
Console::Hide();
|
|
||||||
std::cout << string << std::endl;
|
|
||||||
Console::Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Console::Back()
|
|
||||||
{
|
|
||||||
char key;
|
|
||||||
|
|
||||||
key = '\b';
|
|
||||||
write(STDOUT_FILENO, &key, 1);
|
|
||||||
key = ' ';
|
|
||||||
write(STDOUT_FILENO, &key, 1);
|
|
||||||
key = '\b';
|
|
||||||
write(STDOUT_FILENO, &key, 1);
|
|
||||||
}
|
|
||||||
|
|
@ -1,134 +0,0 @@
|
||||||
#include <iostream>
|
|
||||||
#include <third_party/jsoncpp/source/include/json/reader.h>
|
|
||||||
#include "Core.h"
|
|
||||||
#include "CreateSessionObserver.h"
|
|
||||||
#include "DataChannelObserver.h"
|
|
||||||
#include "Peer.h"
|
|
||||||
#include "SetRemoteSessionDescriptionObserver.h"
|
|
||||||
#include "Console.h"
|
|
||||||
|
|
||||||
static IPeer *peer = NULL;
|
|
||||||
|
|
||||||
void HandleSDP(Json::Value object) {
|
|
||||||
std::string type = object["type"].asString();
|
|
||||||
std::string sdp = object["sdp"].asString();
|
|
||||||
|
|
||||||
webrtc::SdpParseError error;
|
|
||||||
webrtc::SessionDescriptionInterface* desc(
|
|
||||||
webrtc::CreateSessionDescription(type, sdp, &error));
|
|
||||||
|
|
||||||
if (!desc) {
|
|
||||||
Console::Print("Can't parse the SDP: %s", error.description);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
rtc::scoped_refptr<SetRemoteSessionDescriptionObserver> observer =
|
|
||||||
new rtc::RefCountedObject<SetRemoteSessionDescriptionObserver>(peer, desc);
|
|
||||||
|
|
||||||
peer->SetRemoteSessionDescription(desc, observer);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HandleICECandidate(Json::Value object) {
|
|
||||||
std::string sdp_mid = object["sdpMid"].asString();
|
|
||||||
int sdp_mlineindex = object["sdpMLineIndex"].asInt();
|
|
||||||
std::string sdp = object["candidate"].asString();
|
|
||||||
|
|
||||||
webrtc::SdpParseError error;
|
|
||||||
std::unique_ptr<webrtc::IceCandidateInterface> candidate(
|
|
||||||
webrtc::CreateIceCandidate(sdp_mid, sdp_mlineindex, sdp, &error));
|
|
||||||
|
|
||||||
if (!candidate.get()) {
|
|
||||||
Console::Print("Can't parse the ICE candidate: %s", error.description);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!peer->AddIceCandidate(candidate.get())) {
|
|
||||||
Console::Print("Failed to add the ICE candidate.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void HandleObject(Json::Value object) {
|
|
||||||
if (object.isMember("type") && object["type"].isString() &&
|
|
||||||
object.isMember("sdp") && object["sdp"].isString()) {
|
|
||||||
HandleSDP(object);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (object.isMember("candidate") && object["candidate"].isString() &&
|
|
||||||
object.isMember("sdpMLineIndex") && object["sdpMLineIndex"].isNumeric() &&
|
|
||||||
object.isMember("sdpMid") && object["sdpMid"].isString()) {
|
|
||||||
HandleICECandidate(object);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Console::Print("Unknown object.");
|
|
||||||
}
|
|
||||||
|
|
||||||
void HandleCommand(const std::string& input) {
|
|
||||||
Json::Reader reader;
|
|
||||||
Json::Value jmessage;
|
|
||||||
|
|
||||||
if (peer->IsConnected()) {
|
|
||||||
peer->SendMessage(input);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!reader.parse(input, jmessage)) {
|
|
||||||
Console::Print("Invalid JSON string.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jmessage.isArray()) {
|
|
||||||
for (Json::ValueIterator it = jmessage.begin();
|
|
||||||
it != jmessage.end(); it++) {
|
|
||||||
if (!(*it).isObject()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
HandleObject(*it);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jmessage.isObject()) {
|
|
||||||
HandleObject(jmessage);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Console::Print("Must be an array or object.");
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
|
||||||
std::string input;
|
|
||||||
|
|
||||||
if (!Console::Init()) {
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
Core::Init();
|
|
||||||
|
|
||||||
peer = new Peer();
|
|
||||||
|
|
||||||
if (argc == 1) {
|
|
||||||
rtc::scoped_refptr<CreateSessionObserver> createOfferObserver =
|
|
||||||
new rtc::RefCountedObject<CreateSessionObserver>(peer);
|
|
||||||
|
|
||||||
peer->CreateOffer(createOfferObserver);
|
|
||||||
} else {
|
|
||||||
Console::Print("Recipient mode. Paste the offer made by the emitter.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
while (Console::Update(input)) {
|
|
||||||
if (input.length()) {
|
|
||||||
HandleCommand(input);
|
|
||||||
}
|
|
||||||
Core::Update();
|
|
||||||
}
|
|
||||||
|
|
||||||
delete peer;
|
|
||||||
|
|
||||||
Core::Cleanup();
|
|
||||||
Console::Cleanup();
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
@ -1,57 +0,0 @@
|
||||||
include(Common)
|
|
||||||
|
|
||||||
#
|
|
||||||
# Generate build files
|
|
||||||
#
|
|
||||||
|
|
||||||
set(LIBWEBRTC_GEN_ARGS use_gold=false)
|
|
||||||
|
|
||||||
if(NOT CMAKE_BUILD_TYPE MATCHES DEBUG)
|
|
||||||
set(LIBWEBRTC_GEN_ARGS ${LIBWEBRTC_GEN_ARGS} is_debug=false)
|
|
||||||
endif(NOT CMAKE_BUILD_TYPE MATCHES DEBUG)
|
|
||||||
|
|
||||||
if(NOT BUILD_TESTS)
|
|
||||||
set(LIBWEBRTC_GEN_ARGS ${LIBWEBRTC_GEN_ARGS} rtc_include_tests=false)
|
|
||||||
endif(NOT BUILD_TESTS)
|
|
||||||
|
|
||||||
set(GENERATE_COMMAND gn gen out/Default --args='${LIBWEBRTC_GEN_ARGS}')
|
|
||||||
|
|
||||||
add_libwebrtc_command(libwebrtc_generate_build
|
|
||||||
${CMAKE_BINARY_DIR}/Nevermind
|
|
||||||
"${GENERATE_COMMAND}"
|
|
||||||
${CMAKE_BINARY_DIR}/src
|
|
||||||
"Generate build files"
|
|
||||||
libwebrtc_links
|
|
||||||
)
|
|
||||||
|
|
||||||
#
|
|
||||||
# Run ninja
|
|
||||||
#
|
|
||||||
|
|
||||||
set(BUILD_WEBRTC_COMMAND
|
|
||||||
ninja -C out/Default libjingle_peerconnection field_trial_default metrics_default)
|
|
||||||
|
|
||||||
add_libwebrtc_command(libwebrtc_build
|
|
||||||
${CMAKE_BINARY_DIR}/src/out/Default/obj/root.stamp
|
|
||||||
"${BUILD_WEBRTC_COMMAND}"
|
|
||||||
${CMAKE_BINARY_DIR}/src
|
|
||||||
"Build WebRTC"
|
|
||||||
libwebrtc_generate_build
|
|
||||||
)
|
|
||||||
|
|
||||||
#
|
|
||||||
# Merge libraries into a single one
|
|
||||||
#
|
|
||||||
|
|
||||||
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${LIBWEBRTC_INSTALL_LIB_DIR})
|
|
||||||
|
|
||||||
set(MERGE_COMMAND
|
|
||||||
python webrtc/build/merge_libs.py out/Default ${LIBWEBRTC_LIBRARY_PATH})
|
|
||||||
|
|
||||||
add_libwebrtc_command(libwebrtc_merge
|
|
||||||
${LIBWEBRTC_LIBRARY_PATH}
|
|
||||||
"${MERGE_COMMAND}"
|
|
||||||
${CMAKE_BINARY_DIR}/src
|
|
||||||
"Merging libraries into ${LIBWEBRTC_LIBRARY_NAME}"
|
|
||||||
libwebrtc_build
|
|
||||||
)
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
add_subdirectory(Fetch)
|
|
||||||
add_subdirectory(Build)
|
|
||||||
add_subdirectory(Test)
|
|
||||||
add_subdirectory(Install)
|
|
||||||
|
|
@ -1,76 +0,0 @@
|
||||||
include(Common)
|
|
||||||
|
|
||||||
#
|
|
||||||
# Fetch
|
|
||||||
#
|
|
||||||
|
|
||||||
set(GCLIENT_CONFIG_COMMAND
|
|
||||||
${DEPOTTOOLS_GCLIENT_EXECUTABLE} config --name src
|
|
||||||
https://chromium.googlesource.com/external/webrtc.git
|
|
||||||
)
|
|
||||||
|
|
||||||
add_libwebrtc_command(libwebrtc_config
|
|
||||||
${CMAKE_BINARY_DIR}/.gclient
|
|
||||||
"${GCLIENT_CONFIG_COMMAND}"
|
|
||||||
${CMAKE_BINARY_DIR}
|
|
||||||
"Configuring gclient to pull webrtc code"
|
|
||||||
)
|
|
||||||
|
|
||||||
#
|
|
||||||
# Sync
|
|
||||||
#
|
|
||||||
|
|
||||||
set(GCLIENT_SYNC_COMMAND
|
|
||||||
${DEPOTTOOLS_GCLIENT_EXECUTABLE} sync
|
|
||||||
--revision ${LIBWEBRTC_WEBRTC_REVISION} -n -D
|
|
||||||
)
|
|
||||||
|
|
||||||
add_libwebrtc_command(libwebrtc_sync
|
|
||||||
${CMAKE_BINARY_DIR}/src/all.gyp
|
|
||||||
"${GCLIENT_SYNC_COMMAND}"
|
|
||||||
${CMAKE_BINARY_DIR}
|
|
||||||
"Retrieving WebRTC source code"
|
|
||||||
libwebrtc_config
|
|
||||||
)
|
|
||||||
|
|
||||||
#
|
|
||||||
# Sync Chromium
|
|
||||||
#
|
|
||||||
|
|
||||||
set(GIT_CLONE_COMMAND git clone ${LIBWEBRTC_CHROMIUM_DEPS} ${CMAKE_BINARY_DIR}/src/chromium/src)
|
|
||||||
|
|
||||||
add_libwebrtc_command(libwebrtc_chromium_deps
|
|
||||||
${CMAKE_BINARY_DIR}/src/chromium/src
|
|
||||||
"${GIT_CLONE_COMMAND}"
|
|
||||||
${CMAKE_BINARY_DIR}
|
|
||||||
"Retrieving Chromium dependencies"
|
|
||||||
libwebrtc_sync
|
|
||||||
)
|
|
||||||
|
|
||||||
#
|
|
||||||
# Update Clang
|
|
||||||
#
|
|
||||||
|
|
||||||
set(UPDATE_CLANG_COMMAND python chromium/src/tools/clang/scripts/update.py)
|
|
||||||
|
|
||||||
add_libwebrtc_command(libwebrtc_clang
|
|
||||||
${CMAKE_BINARY_DIR}/src/chromium/src/third_party/llvm-build
|
|
||||||
"${UPDATE_CLANG_COMMAND}"
|
|
||||||
${CMAKE_BINARY_DIR}/src
|
|
||||||
"Updating clang"
|
|
||||||
libwebrtc_chromium_deps
|
|
||||||
)
|
|
||||||
|
|
||||||
#
|
|
||||||
# Setup Links
|
|
||||||
#
|
|
||||||
|
|
||||||
set(SETUP_LINKS_COMMAND python setup_links.py)
|
|
||||||
|
|
||||||
add_libwebrtc_command(libwebrtc_links
|
|
||||||
${CMAKE_BINARY_DIR}/src/tools/clang
|
|
||||||
"${SETUP_LINKS_COMMAND}"
|
|
||||||
${CMAKE_BINARY_DIR}/src
|
|
||||||
"Creating symbolic links"
|
|
||||||
libwebrtc_clang
|
|
||||||
)
|
|
||||||
|
|
@ -1,62 +0,0 @@
|
||||||
#
|
|
||||||
# Install library
|
|
||||||
#
|
|
||||||
|
|
||||||
install(
|
|
||||||
FILES ${LIBWEBRTC_LIBRARY_PATH}
|
|
||||||
DESTINATION ${LIBWEBRTC_INSTALL_LIB_DIR}
|
|
||||||
COMPONENT Libraries
|
|
||||||
)
|
|
||||||
|
|
||||||
#
|
|
||||||
# Install headers
|
|
||||||
#
|
|
||||||
|
|
||||||
install(
|
|
||||||
DIRECTORY ${CMAKE_BINARY_DIR}/src/webrtc
|
|
||||||
DESTINATION ${LIBWEBRTC_INSTALL_INCLUDE_DIR}
|
|
||||||
FILES_MATCHING PATTERN "*.h"
|
|
||||||
)
|
|
||||||
|
|
||||||
#
|
|
||||||
# Create package
|
|
||||||
#
|
|
||||||
|
|
||||||
set(CPACK_PACKAGE_NAME "${LIBWEBRTC_MAJOR_VERSION}")
|
|
||||||
set(CPACK_PACKAGE_VERSION_MAJOR "${LIBWEBRTC_MAJOR_VERSION}")
|
|
||||||
set(CPACK_PACKAGE_VERSION_MINOR "${LIBWEBRTC_MINOR_VERSION}")
|
|
||||||
set(CPACK_PACKAGE_VERSION_PATCH "${LIBWEBRTC_PATCH_VERSION}")
|
|
||||||
|
|
||||||
if(WIN)
|
|
||||||
set(CPACK_GENERATOR "ZIP")
|
|
||||||
else(WIN)
|
|
||||||
set(CPACK_GENERATOR "TGZ")
|
|
||||||
endif(WIN)
|
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
|
||||||
set(LIBWEBRTC_PLATFORM "linux")
|
|
||||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
|
||||||
set(LIBWEBRTC_PLATFORM "mac")
|
|
||||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
|
|
||||||
set(LIBWEBRTC_PLATFORM "win32")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
|
|
||||||
set(LIBWEBRTC_ARCH "arm")
|
|
||||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$")
|
|
||||||
set(LIBWEBRTC_ARCH "x86")
|
|
||||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^x86.64$")
|
|
||||||
set(LIBWEBRTC_ARCH "x64")
|
|
||||||
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "powerpc")
|
|
||||||
set(LIBWEBRTC_ARCH "ppc")
|
|
||||||
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "powerpc64")
|
|
||||||
set(LIBWEBRTC_ARCH "ppc64")
|
|
||||||
else()
|
|
||||||
set(LIBWEBRTC_ARCH "${CMAKE_SYSTEM_PROCESSOR}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
|
|
||||||
set(CPACK_PACKAGE_FILE_NAME "libwebrtc-${LIBWEBRTC_VERSION}-${LIBWEBRTC_PLATFORM}-${LIBWEBRTC_ARCH}")
|
|
||||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY "libwebrtc")
|
|
||||||
|
|
||||||
include(CPack)
|
|
||||||
75
cmake/AddWebRTCTarget.cmake
Normal file
75
cmake/AddWebRTCTarget.cmake
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
function(add_webrtc_target SOURCE_DIR BUILD_DIR)
|
||||||
|
|
||||||
|
set(GEN_ARGS_COMMON "target_cpu=\"${TARGET_CPU}\" target_os=\"${TARGET_OS}\" is_component_build=false use_gold=false use_sysroot=false use_custom_libcxx=false use_custom_libcxx_for_host=false use_rtti=true treat_warnings_as_errors=false rtc_include_tests=false rtc_build_tools=false rtc_build_examples=false rtc_enable_protobuf=false")
|
||||||
|
|
||||||
|
if (USE_CLANG)
|
||||||
|
set(GEN_ARGS_COMMON "${GEN_ARGS_COMMON} is_clang=true use_lld=true")
|
||||||
|
else()
|
||||||
|
set(GEN_ARGS_COMMON "${GEN_ARGS_COMMON} is_clang=false use_lld=false")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(GEN_ARGS_DEBUG "${GEN_ARGS_COMMON} is_debug=true")
|
||||||
|
set(GEN_ARGS_RELEASE "${GEN_ARGS_COMMON} is_debug=false")
|
||||||
|
|
||||||
|
if (MSVC)
|
||||||
|
set(GEN_ARGS_DEBUG "${GEN_ARGS_DEBUG} enable_iterator_debugging=true")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
set(GN_EXECUTABLE gn.bat)
|
||||||
|
else ()
|
||||||
|
set(GN_EXECUTABLE gn)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
macro(run_gn DIRECTORY)
|
||||||
|
execute_process(COMMAND ${GN_EXECUTABLE} gen ${DIRECTORY} "--args=${GEN_ARGS}" WORKING_DIRECTORY ${SOURCE_DIR})
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
if (CMAKE_GENERATOR MATCHES "Visual Studio")
|
||||||
|
# Debug config
|
||||||
|
message(STATUS "Running gn for debug configuration...")
|
||||||
|
set(GEN_ARGS "${GEN_ARGS_DEBUG}")
|
||||||
|
if (GN_EXTRA_ARGS)
|
||||||
|
set(GEN_ARGS "${GEN_ARGS} ${GN_EXTRA_ARGS}")
|
||||||
|
endif ()
|
||||||
|
run_gn("${BUILD_DIR}/Debug")
|
||||||
|
|
||||||
|
# Release config
|
||||||
|
message(STATUS "Running gn for release configuration...")
|
||||||
|
set(GEN_ARGS "${GEN_ARGS_RELEASE}")
|
||||||
|
if (GN_EXTRA_ARGS)
|
||||||
|
set(GEN_ARGS "${GEN_ARGS} ${GN_EXTRA_ARGS}")
|
||||||
|
endif ()
|
||||||
|
run_gn("${BUILD_DIR}/Release")
|
||||||
|
else ()
|
||||||
|
message(STATUS "Running gn...")
|
||||||
|
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
set(GEN_ARGS "${GEN_ARGS_DEBUG}")
|
||||||
|
else ()
|
||||||
|
set(GEN_ARGS "${GEN_ARGS_RELEASE}")
|
||||||
|
endif ()
|
||||||
|
if (GN_EXTRA_ARGS)
|
||||||
|
set(GEN_ARGS "${GEN_ARGS} ${GN_EXTRA_ARGS}")
|
||||||
|
endif ()
|
||||||
|
run_gn("${BUILD_DIR}")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
macro(add_custom_command_with_path TARGET_NAME)
|
||||||
|
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E env "PATH=$ENV{PATH}" ${ARGN}
|
||||||
|
WORKING_DIRECTORY ${SOURCE_DIR}
|
||||||
|
VERBATIM
|
||||||
|
)
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
add_custom_target(webrtc-build ALL)
|
||||||
|
add_custom_target(webrtc-clean)
|
||||||
|
if (CMAKE_GENERATOR MATCHES "Visual Studio")
|
||||||
|
add_custom_command_with_path(webrtc-build ninja -C "${BUILD_DIR}/$<CONFIG>" :webrtc jsoncpp libyuv ${NINJA_ARGS})
|
||||||
|
add_custom_command_with_path(webrtc-clean ${GN_EXECUTABLE} clean "${BUILD_DIR}/$<CONFIG>")
|
||||||
|
else ()
|
||||||
|
add_custom_command_with_path(webrtc-build ninja -C "${BUILD_DIR}" :webrtc jsoncpp libyuv ${NINJA_ARGS})
|
||||||
|
add_custom_command_with_path(webrtc-clean ${GN_EXECUTABLE} clean "${BUILD_DIR}")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
endfunction()
|
||||||
30
cmake/FindLibraries.cmake
Normal file
30
cmake/FindLibraries.cmake
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
#
|
||||||
|
# Find required packages
|
||||||
|
list(APPEND LIBWEBRTC_LIBRARIES webrtc)
|
||||||
|
|
||||||
|
if (UNIX AND NOT APPLE)
|
||||||
|
find_package(X11 REQUIRED)
|
||||||
|
list(APPEND LIBWEBRTC_LIBRARIES ${X11_LIBRARIES} ${CMAKE_DL_LIBS} rt)
|
||||||
|
|
||||||
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||||
|
find_package(Threads REQUIRED)
|
||||||
|
if (CMAKE_HAVE_THREADS_LIBRARY)
|
||||||
|
list(APPEND LIBWEBRTC_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (APPLE)
|
||||||
|
find_library(AUDIOTOOLBOX_LIBRARY AudioToolbox)
|
||||||
|
find_library(COREAUDIO_LIBRARY CoreAudio)
|
||||||
|
find_library(COREFOUNDATION_LIBRARY CoreFoundation)
|
||||||
|
find_library(COREGRAPHICS_LIBRARY CoreGraphics)
|
||||||
|
find_library(FOUNDATION_LIBRARY Foundation)
|
||||||
|
|
||||||
|
list(APPEND LIBWEBRTC_LIBRARIES ${AUDIOTOOLBOX_LIBRARY} ${COREAUDIO_LIBRARY}
|
||||||
|
${COREFOUNDATION_LIBRARY} ${COREGRAPHICS_LIBRARY} ${FOUNDATION_LIBRARY})
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
list(APPEND LIBWEBRTC_LIBRARIES msdmo.lib wmcodecdspuuid.lib dmoguids.lib
|
||||||
|
crypt32.lib iphlpapi.lib ole32.lib secur32.lib winmm.lib ws2_32.lib)
|
||||||
|
endif ()
|
||||||
10
cmake/PatchSources.cmake
Normal file
10
cmake/PatchSources.cmake
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
function(patch_sources PATCH_DIR SOURCE_DIR)
|
||||||
|
file(GLOB_RECURSE PATCHED_SOURCES RELATIVE ${PATCH_DIR} ${PATCH_DIR}/*)
|
||||||
|
list(REMOVE_ITEM PATCHED_SOURCES ".gitkeep")
|
||||||
|
foreach (file ${PATCHED_SOURCES})
|
||||||
|
message(STATUS "Patching ${file}...")
|
||||||
|
set(destination "${SOURCE_DIR}/${file}")
|
||||||
|
cmake_path(GET destination PARENT_PATH dest_dir)
|
||||||
|
file(COPY ${PATCH_DIR}/${file} DESTINATION ${dest_dir})
|
||||||
|
endforeach ()
|
||||||
|
endfunction()
|
||||||
92
cmake/TargetOsAndCpu.cmake
Normal file
92
cmake/TargetOsAndCpu.cmake
Normal file
|
|
@ -0,0 +1,92 @@
|
||||||
|
include(CheckSymbolExists)
|
||||||
|
|
||||||
|
# Target OS
|
||||||
|
set(TARGET_OS "" CACHE STRING "Target OS, used as --target_os argument")
|
||||||
|
set(TARGET_OS_LIST android chromeos ios linux nacl mac win)
|
||||||
|
|
||||||
|
if (TARGET_OS STREQUAL "")
|
||||||
|
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||||
|
set(TARGET_OS "linux")
|
||||||
|
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||||
|
set(TARGET_OS "mac")
|
||||||
|
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||||
|
set(TARGET_OS "win")
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (NOT ${TARGET_OS} IN_LIST TARGET_OS_LIST)
|
||||||
|
message(FATAL_ERROR "Unknown value '${TARGET_OS}' for variable TARGET_OS, options are: ${TARGET_OS_LIST}")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# Target CPU
|
||||||
|
function(detect_current_arch)
|
||||||
|
if (WIN32)
|
||||||
|
check_symbol_exists("_M_X64" "" ARCH_X64)
|
||||||
|
if (NOT ARCH_X64)
|
||||||
|
check_symbol_exists("_M_AMD64" "" ARCH_X64)
|
||||||
|
endif ()
|
||||||
|
check_symbol_exists("_M_IX86" "" ARCH_X86)
|
||||||
|
check_symbol_exists("_M_ARM" "" ARCH_ARM)
|
||||||
|
check_symbol_exists("_M_ARM64" "" ARCH_ARM64)
|
||||||
|
else ()
|
||||||
|
check_symbol_exists("__i386__" "" ARCH_X86)
|
||||||
|
check_symbol_exists("__x86_64__" "" ARCH_X64)
|
||||||
|
check_symbol_exists("__arm__" "" ARCH_ARM)
|
||||||
|
check_symbol_exists("__aarch64__" "" ARCH_ARM64)
|
||||||
|
check_symbol_exists("__mips__" "" ARCH_MIPS)
|
||||||
|
endif ()
|
||||||
|
endfunction(detect_current_arch)
|
||||||
|
|
||||||
|
set(TARGET_CPU "" CACHE STRING "Target CPU, used as --target_cpu argument")
|
||||||
|
set(TARGET_CPU_LIST x86 x64 arm arm64 mipsel)
|
||||||
|
|
||||||
|
if (TARGET_CPU STREQUAL "")
|
||||||
|
detect_current_arch()
|
||||||
|
|
||||||
|
if (ARCH_X64)
|
||||||
|
set(TARGET_CPU "x64")
|
||||||
|
elseif (ARCH_X86)
|
||||||
|
set(TARGET_CPU "x86")
|
||||||
|
elseif (ARCH_ARM64)
|
||||||
|
set(TARGET_CPU "arm64")
|
||||||
|
elseif (ARCH_ARM)
|
||||||
|
set(TARGET_CPU "arm")
|
||||||
|
elseif (ARCH_MIPS)
|
||||||
|
set(TARGET_CPU "mipsel")
|
||||||
|
else ()
|
||||||
|
set(TARGET_CPU ${CMAKE_SYSTEM_PROCESSOR})
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (NOT ${TARGET_CPU} IN_LIST TARGET_CPU_LIST)
|
||||||
|
message(FATAL_ERROR "Unknown value '${TARGET_CPU}' for variable TARGET_CPU, options are: ${TARGET_CPU_LIST}")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (APPLE)
|
||||||
|
list(APPEND LIBWEBRTC_DEFINITIONS_DEBUG WEBRTC_MAC)
|
||||||
|
list(APPEND LIBWEBRTC_DEFINITIONS_RELEASE ${LIBWEBRTC_DEFINITIONS_DEBUG})
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (UNIX)
|
||||||
|
if (TARGET_CPU STREQUAL "x86")
|
||||||
|
set(LIBWEBRTC_REQUIRED_CXX_FLAGS "${LIBWEBRTC_REQUIRED_CXX_FLAGS} -m32")
|
||||||
|
endif (TARGET_CPU STREQUAL "x86")
|
||||||
|
|
||||||
|
set(LIBWEBRTC_REQUIRED_CXX_FLAGS "${LIBWEBRTC_REQUIRED_CXX_FLAGS} -std=gnu++0x")
|
||||||
|
|
||||||
|
if (CMAKE_USE_PTHREADS_INIT)
|
||||||
|
set(LIBWEBRTC_REQUIRED_CXX_FLAGS "${LIBWEBRTC_REQUIRED_CXX_FLAGS} -pthread")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
list(APPEND LIBWEBRTC_DEFINITIONS_DEBUG WEBRTC_POSIX _DEBUG=1)
|
||||||
|
list(APPEND LIBWEBRTC_DEFINITIONS_RELEASE WEBRTC_POSIX)
|
||||||
|
elseif (WIN32)
|
||||||
|
set(LIBWEBRTC_REQUIRED_C_FLAGS_DEBUG "/MDd")
|
||||||
|
set(LIBWEBRTC_REQUIRED_C_FLAGS_RELEASE "/MD")
|
||||||
|
set(LIBWEBRTC_REQUIRED_CXX_FLAGS_DEBUG "${LIBWEBRTC_REQUIRED_C_FLAGS_DEBUG}")
|
||||||
|
set(LIBWEBRTC_REQUIRED_CXX_FLAGS_RELEASE "${LIBWEBRTC_REQUIRED_C_FLAGS_RELEASE}")
|
||||||
|
list(APPEND LIBWEBRTC_DEFINITIONS_DEBUG WEBRTC_WIN NOMINMAX _CRT_SECURE_NO_WARNINGS)
|
||||||
|
list(APPEND LIBWEBRTC_DEFINITIONS_RELEASE ${LIBWEBRTC_DEFINITIONS_DEBUG})
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
message(STATUS "Building for ${TARGET_OS} (${TARGET_CPU})")
|
||||||
13
cmake/Utils.cmake
Normal file
13
cmake/Utils.cmake
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
function(patch_file TARGET_FILE SEARCH_REGEX REPLACE_REGEX)
|
||||||
|
file(READ ${TARGET_FILE} filedata)
|
||||||
|
string(REGEX REPLACE ${SEARCH_REGEX} ${REPLACE_REGEX} filedata "${filedata}")
|
||||||
|
file(WRITE ${TARGET_FILE} "${filedata}")
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(prependPath DIRECTORY)
|
||||||
|
if (WIN32)
|
||||||
|
set(ENV{PATH} "${DIRECTORY};$ENV{PATH}")
|
||||||
|
else()
|
||||||
|
set(ENV{PATH} "${DIRECTORY}:$ENV{PATH}")
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
14
cmake/Version.cmake
Normal file
14
cmake/Version.cmake
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
function(get_webrtc_version_from_git OUT_VAR)
|
||||||
|
|
||||||
|
find_package(Git REQUIRED)
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
|
||||||
|
OUTPUT_VARIABLE WEBRTC_BRANCH
|
||||||
|
WORKING_DIRECTORY ${WEBRTC_SOURCE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
string(REGEX REPLACE "\n$" "" WEBRTC_BRANCH "${WEBRTC_BRANCH}")
|
||||||
|
set(${OUT_VAR} ${WEBRTC_BRANCH} PARENT_SCOPE)
|
||||||
|
|
||||||
|
endfunction()
|
||||||
1
index.js
1
index.js
|
|
@ -1 +0,0 @@
|
||||||
console.log(require('path').relative('.', __dirname));
|
|
||||||
|
|
@ -1,65 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var os = require('os');
|
|
||||||
var fs = require('fs-extra');
|
|
||||||
|
|
||||||
namespace('build', function () {
|
|
||||||
task('generate', {async: true}, function () {
|
|
||||||
var opts = 'use_gold=false is_debug=false rtc_include_tests=false';
|
|
||||||
|
|
||||||
process.env.PATH = process.cwd() + '/Dependencies/depot_tools:' + process.env.PATH;
|
|
||||||
process.chdir('src');
|
|
||||||
jake.exec('gn gen out/Default --args=\'' + opts + '\'', function () {
|
|
||||||
complete();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
task('ninja', ['build:generate'], {async: true}, function () {
|
|
||||||
var packages = 'libjingle_peerconnection field_trial_default metrics_default';
|
|
||||||
|
|
||||||
console.log('Building WebRTC...');
|
|
||||||
jake.exec('ninja -C out/Default ' + packages, { printStdout: true }, function () {
|
|
||||||
complete();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
task('merge', ['build:ninja'], {async: true}, function () {
|
|
||||||
var prefix = os.platform() !== 'windows' ? 'lib' : '';
|
|
||||||
var suffix = os.platform() === 'windows' ? '.lib' : '.a';
|
|
||||||
var path = '../lib/' + prefix + 'webrtc' + suffix;
|
|
||||||
|
|
||||||
console.log('Merging libraries...');
|
|
||||||
|
|
||||||
if (!fs.existsSync('../lib')) {
|
|
||||||
fs.mkdir('../lib');
|
|
||||||
}
|
|
||||||
|
|
||||||
jake.exec('python webrtc/build/merge_libs.py out/Default ' + path, function () {
|
|
||||||
complete();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
task('include', ['build:merge'], function () {
|
|
||||||
var fileList = new jake.FileList();
|
|
||||||
var files;
|
|
||||||
|
|
||||||
console.log('Copying include files...');
|
|
||||||
if (!fs.existsSync('../include')) {
|
|
||||||
fs.mkdir('../include');
|
|
||||||
}
|
|
||||||
|
|
||||||
fileList.include('webrtc/**/*.h');
|
|
||||||
files = fileList.toArray();
|
|
||||||
|
|
||||||
for (var file in files) {
|
|
||||||
fs.copySync(files[file], '../include/' + files[file]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
task('default', [
|
|
||||||
'generate',
|
|
||||||
'ninja',
|
|
||||||
'merge',
|
|
||||||
'include'
|
|
||||||
], function () {});
|
|
||||||
});
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var os = require('os');
|
|
||||||
var pkg = require('../package.json');
|
|
||||||
|
|
||||||
function getPackageName() {
|
|
||||||
var version = pkg.version;
|
|
||||||
var platform = os.platform();
|
|
||||||
var arch = os.arch();
|
|
||||||
var nodever = process.version;
|
|
||||||
var suffix = (platform === 'windows') ? '.zip' : '.tar.gz';
|
|
||||||
|
|
||||||
return pkg.config.filename
|
|
||||||
.replace('{VERSION}', version)
|
|
||||||
.replace('{PLATFORM}', platform)
|
|
||||||
.replace('{ARCH}', arch)
|
|
||||||
.replace('{NODEVER}', nodever) + suffix;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
getPackageName: getPackageName
|
|
||||||
};
|
|
||||||
|
|
@ -1,124 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var crypto = require('crypto');
|
|
||||||
var download = require('download');
|
|
||||||
var fs = require('fs');
|
|
||||||
var getPackageName = require('./common').getPackageName;
|
|
||||||
var os = require('os');
|
|
||||||
var pkg = require('../package.json');
|
|
||||||
|
|
||||||
var WebRTCUrl = pkg.config.webrtc.url;
|
|
||||||
var WebRTCRev = pkg.config.webrtc.revision;
|
|
||||||
var ChromiumUrl = pkg.config.chromium.url;
|
|
||||||
|
|
||||||
function checksum(bytes) {
|
|
||||||
return crypto
|
|
||||||
.createHash('md5')
|
|
||||||
.update(bytes, 'utf8')
|
|
||||||
.digest('hex')
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace('fetch', function () {
|
|
||||||
task('precompiled', ['check-file'], function () {
|
|
||||||
});
|
|
||||||
|
|
||||||
task('check-file', function () {
|
|
||||||
try {
|
|
||||||
var data = fs.readFileSync(getPackageName());
|
|
||||||
|
|
||||||
if (checksum(data) !== pkg.config.webrtc.checksum) {
|
|
||||||
throw new Error('Invalid checksum');
|
|
||||||
}
|
|
||||||
|
|
||||||
jake.Task['fetch:extract'].invoke();
|
|
||||||
} catch (e) {
|
|
||||||
jake.Task['fetch:download'].invoke();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
task('download', {async: true}, function () {
|
|
||||||
var url = pkg.config.url + '/' + pkg.version + '/' + getPackageName();
|
|
||||||
|
|
||||||
console.log('Downloading', url);
|
|
||||||
download(url, '.')
|
|
||||||
.then(function () {
|
|
||||||
var task = jake.Task['fetch:extract'];
|
|
||||||
|
|
||||||
task.addListener('complete', function () {
|
|
||||||
complete();
|
|
||||||
});
|
|
||||||
|
|
||||||
task.invoke();
|
|
||||||
})
|
|
||||||
.catch(function (err) {
|
|
||||||
var task = jake.Task['fetch:source'];
|
|
||||||
|
|
||||||
console.log('Failed, building libwebrtc from source.');
|
|
||||||
task.addListener('complete', function () {
|
|
||||||
complete();
|
|
||||||
});
|
|
||||||
|
|
||||||
task.invoke();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
task('extract', {async: true}, function () {
|
|
||||||
var packageName = getPackageName();
|
|
||||||
|
|
||||||
console.log('Extracting', packageName);
|
|
||||||
jake.exec('tar xf ' + packageName, function () {
|
|
||||||
console.log('Deleting', packageName);
|
|
||||||
fs.unlinkSync(packageName);
|
|
||||||
complete();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
task('gclient', {async: true}, function () {
|
|
||||||
console.log('Updating submodules...');
|
|
||||||
jake.exec(['git submodule init', 'git submodule update'], {printStdout: true}, function () {
|
|
||||||
complete();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
task('configure', ['fetch:gclient'], {async: true}, function () {
|
|
||||||
console.log('Configuring gclient to fetch WebRTC code');
|
|
||||||
process.env.PATH = process.cwd() + '/Dependencies/depot_tools:' + process.env.PATH;
|
|
||||||
jake.exec('gclient config --name src ' + WebRTCUrl, {printStdout: true}, function () {
|
|
||||||
complete();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
task('sync', ['fetch:configure'], {async: true}, function () {
|
|
||||||
console.log('Retrieving WebRTC source code');
|
|
||||||
jake.exec('gclient sync --revision ' + WebRTCRev + ' -n -D', {printStdout: true}, function () {
|
|
||||||
complete();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
task('chromium', ['fetch:sync'], {async: true}, function () {
|
|
||||||
console.log('Retrieving Chromium dependencies');
|
|
||||||
jake.exec('git clone ' + ChromiumUrl + ' src/chromium/src', { breakOnError: false, printStdout: true }, function () {
|
|
||||||
complete();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
task('clang', ['fetch:chromium'], {async: true}, function () {
|
|
||||||
console.log('Updating clang');
|
|
||||||
jake.exec('python src/chromium/src/tools/clang/scripts/update.py', {printStdout: true}, function () {
|
|
||||||
complete();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
task('links', ['fetch:clang'], {async: true}, function () {
|
|
||||||
console.log('Creating symbolic links');
|
|
||||||
jake.exec('python src/setup_links.py', {printStdout: true}, function () {
|
|
||||||
complete();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
task('source', [
|
|
||||||
'links',
|
|
||||||
'build:default'
|
|
||||||
], function () {
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var os = require('os');
|
|
||||||
var getPackageName = require('./common').getPackageName;
|
|
||||||
|
|
||||||
task('package', {async: true}, function () {
|
|
||||||
var packageName = getPackageName();
|
|
||||||
|
|
||||||
console.log('Creating ' + packageName + '...');
|
|
||||||
if (os.platform() !== 'windows') {
|
|
||||||
jake.exec('tar cfz ' + packageName + ' include lib', function () {
|
|
||||||
complete();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
129
libwebrtc/CMakeLists.txt
Normal file
129
libwebrtc/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,129 @@
|
||||||
|
if (BUILD_DEB_PACKAGE)
|
||||||
|
set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH INTERNAL FORCE)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# Prepare CMake exports
|
||||||
|
configure_file(LibWebRTCConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/LibWebRTCConfig.cmake @ONLY)
|
||||||
|
configure_file(LibWebRTCConfigVersion.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/LibWebRTCConfigVersion.cmake @ONLY)
|
||||||
|
|
||||||
|
######################
|
||||||
|
# INSTALL SECTION
|
||||||
|
######################
|
||||||
|
|
||||||
|
# Install headers
|
||||||
|
install(DIRECTORY
|
||||||
|
"${WEBRTC_SOURCE_DIR}/api"
|
||||||
|
"${WEBRTC_SOURCE_DIR}/base"
|
||||||
|
"${WEBRTC_SOURCE_DIR}/call"
|
||||||
|
"${WEBRTC_SOURCE_DIR}/common_audio"
|
||||||
|
"${WEBRTC_SOURCE_DIR}/common_video"
|
||||||
|
"${WEBRTC_SOURCE_DIR}/logging"
|
||||||
|
"${WEBRTC_SOURCE_DIR}/media"
|
||||||
|
"${WEBRTC_SOURCE_DIR}/modules"
|
||||||
|
"${WEBRTC_SOURCE_DIR}/p2p"
|
||||||
|
"${WEBRTC_SOURCE_DIR}/pc"
|
||||||
|
"${WEBRTC_SOURCE_DIR}/rtc_base"
|
||||||
|
"${WEBRTC_SOURCE_DIR}/system_wrappers"
|
||||||
|
DESTINATION "include/webrtc"
|
||||||
|
COMPONENT common
|
||||||
|
FILES_MATCHING PATTERN "*.h"
|
||||||
|
)
|
||||||
|
|
||||||
|
if (EXISTS "${WEBRTC_SOURCE_DIR}/common_types.h")
|
||||||
|
install(FILES "${WEBRTC_SOURCE_DIR}/common_types.h" DESTINATION "include/webrtc" COMPONENT common)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
install(DIRECTORY "${WEBRTC_SOURCE_DIR}/third_party/jsoncpp"
|
||||||
|
DESTINATION "include/webrtc/third_party"
|
||||||
|
COMPONENT common
|
||||||
|
FILES_MATCHING PATTERN "*.h"
|
||||||
|
)
|
||||||
|
|
||||||
|
install(DIRECTORY "${WEBRTC_SOURCE_DIR}/third_party/libyuv"
|
||||||
|
DESTINATION "include/webrtc/third_party"
|
||||||
|
COMPONENT common
|
||||||
|
FILES_MATCHING PATTERN "*.h"
|
||||||
|
)
|
||||||
|
|
||||||
|
install(DIRECTORY "${WEBRTC_SOURCE_DIR}/third_party/abseil-cpp/absl"
|
||||||
|
DESTINATION "include/webrtc"
|
||||||
|
COMPONENT common
|
||||||
|
FILES_MATCHING PATTERN "*.h"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Install pdb files
|
||||||
|
if (MSVC)
|
||||||
|
# TODO: fix install on first run
|
||||||
|
file(GLOB_RECURSE PDB_FILES "${WEBRTC_BUILD_DIR}/Debug/*.pdb")
|
||||||
|
install(FILES DESTINATION lib COMPONENT debug)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Install library
|
||||||
|
if (WIN32)
|
||||||
|
set(LIBRARY_FILENAME_DEBUG "webrtcd.lib")
|
||||||
|
set(LIBRARY_FILENAME_RELEASE "webrtc.lib")
|
||||||
|
else()
|
||||||
|
set(LIBRARY_FILENAME_DEBUG "libwebrtcd.a")
|
||||||
|
set(LIBRARY_FILENAME_RELEASE "libwebrtc.a")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
if (WIN32)
|
||||||
|
install(FILES ${WEBRTC_BUILD_DIR}/obj/webrtc.lib DESTINATION lib RENAME "webrtcd.lib" COMPONENT debug)
|
||||||
|
else()
|
||||||
|
install(FILES ${WEBRTC_BUILD_DIR}/obj/libwebrtc.a DESTINATION lib RENAME "libwebrtcd.a" COMPONENT debug)
|
||||||
|
endif()
|
||||||
|
else ()
|
||||||
|
if (WIN32)
|
||||||
|
install(FILES ${WEBRTC_BUILD_DIR}/obj/webrtc.lib DESTINATION lib COMPONENT release)
|
||||||
|
else()
|
||||||
|
install(FILES ${WEBRTC_BUILD_DIR}/obj/libwebrtc.a DESTINATION lib COMPONENT release)
|
||||||
|
endif()
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
|
install(FILES
|
||||||
|
UseLibWebRTC.cmake
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/LibWebRTCConfig.cmake
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/LibWebRTCConfigVersion.cmake
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/LibWebRTCTargets.cmake
|
||||||
|
DESTINATION "lib/cmake/LibWebRTC"
|
||||||
|
COMPONENT common
|
||||||
|
)
|
||||||
|
|
||||||
|
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
install(FILES LibWebRTCTargets-debug.cmake DESTINATION "lib/cmake/LibWebRTC" COMPONENT debug)
|
||||||
|
else ()
|
||||||
|
install(FILES LibWebRTCTargets-release.cmake DESTINATION "lib/cmake/LibWebRTC" COMPONENT release)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (BUILD_DEB_PACKAGE)
|
||||||
|
set(CPACK_GENERATOR "DEB")
|
||||||
|
set(CPACK_PACKAGE_VENDOR "Kirill Kirilenko")
|
||||||
|
set(CPACK_PACKAGE_CONTACT "Kirill Kirilenko <kirill@ultracoder.org>")
|
||||||
|
set(CPACK_PACKAGE_VERSION_MAJOR ${WEBRTC_VERSION})
|
||||||
|
set(CPACK_PACKAGE_VERSION_MINOR "")
|
||||||
|
set(CPACK_PACKAGE_VERSION_PATCH "")
|
||||||
|
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/UltraCoderRU/libwebrtc")
|
||||||
|
set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
|
||||||
|
set(CPACK_DEB_COMPONENT_INSTALL ON)
|
||||||
|
set(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS ON)
|
||||||
|
|
||||||
|
set(CPACK_DEBIAN_COMMON_PACKAGE_NAME "libwebrtc-common-dev")
|
||||||
|
set(CPACK_DEBIAN_COMMON_FILE_NAME "libwebrtc-common-dev-${WEBRTC_VERSION}.deb")
|
||||||
|
set(CPACK_DEBIAN_COMMON_DESCRIPTION "WebRTC header files and CMake modules")
|
||||||
|
|
||||||
|
set(CPACK_DEBIAN_RELEASE_PACKAGE_NAME "libwebrtc-release-dev")
|
||||||
|
set(CPACK_DEBIAN_RELEASE_FILE_NAME "libwebrtc-release-dev-${WEBRTC_VERSION}.deb")
|
||||||
|
set(CPACK_DEBIAN_RELEASE_DESCRIPTION "WebRTC static library (release version)")
|
||||||
|
set(CPACK_DEBIAN_RELEASE_PACKAGE_DEPENDS "libwebrtc-common-dev (=${WEBRTC_VERSION})")
|
||||||
|
set(CPACK_DEBIAN_RELEASE_PACKAGE_PROVIDES "libwebrtc-dev")
|
||||||
|
|
||||||
|
set(CPACK_DEBIAN_DEBUG_PACKAGE_NAME "libwebrtc-debug-dev")
|
||||||
|
set(CPACK_DEBIAN_DEBUG_FILE_NAME "libwebrtc-debug-dev-${WEBRTC_VERSION}.deb")
|
||||||
|
set(CPACK_DEBIAN_DEBUG_DESCRIPTION "WebRTC static library (debug version)")
|
||||||
|
set(CPACK_DEBIAN_DEBUG_PACKAGE_DEPENDS "libwebrtc-common-dev (=${WEBRTC_VERSION})")
|
||||||
|
set(CPACK_DEBIAN_DEBUG_PACKAGE_PROVIDES "libwebrtc-dev")
|
||||||
|
|
||||||
|
include(CPack)
|
||||||
|
endif ()
|
||||||
43
libwebrtc/LibWebRTCConfig.cmake.in
Normal file
43
libwebrtc/LibWebRTCConfig.cmake.in
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
# - Config file for 'LibWebRTC' package
|
||||||
|
# It defines the following variables
|
||||||
|
#
|
||||||
|
# LIBWEBRTC_INCLUDE_DIRS - include directories
|
||||||
|
# LIBWEBRTC_LIBRARY_DIRS - library directories
|
||||||
|
# LIBWEBRTC_LIBRARIES - libraries to link against
|
||||||
|
# LIBWEBRTC_CMAKE_DIR - path to the CMake modules
|
||||||
|
# LIBWEBRTC_USE_FILE - path to the CMake use file
|
||||||
|
#
|
||||||
|
# - Version variables:
|
||||||
|
# WEBRTC_VERSION - WebRTC version with build prefix
|
||||||
|
#
|
||||||
|
# - Library type and targets variables:
|
||||||
|
# LIBWEBRTC_TARGET_OS - android, chromeos, ios, linux, nacl, mac or win
|
||||||
|
# LIBWEBRTC_TARGET_CPU - x86, x64, arm, arm64 or mipsel
|
||||||
|
|
||||||
|
# WebRTC version number (branch head)
|
||||||
|
set(WEBRTC_VERSION "@WEBRTC_VERSION@")
|
||||||
|
|
||||||
|
# LibWebRTC library type, target OS and target CPU
|
||||||
|
set(LIBWEBRTC_TARGET_OS "@TARGET_OS@")
|
||||||
|
set(LIBWEBRTC_TARGET_CPU "@TARGET_CPU@")
|
||||||
|
|
||||||
|
# Set the expected libraries variable
|
||||||
|
set(LIBWEBRTC_LIBRARIES @LIBWEBRTC_LIBRARIES@)
|
||||||
|
|
||||||
|
# The C and C++ flags added by LibWebRTC to the cmake-configured flags.
|
||||||
|
set(LIBWEBRTC_REQUIRED_C_FLAGS "@LIBWEBRTC_REQUIRED_C_FLAGS@")
|
||||||
|
set(LIBWEBRTC_REQUIRED_CXX_FLAGS "@LIBWEBRTC_REQUIRED_CXX_FLAGS@")
|
||||||
|
set(LIBWEBRTC_REQUIRED_C_FLAGS_DEBUG "@LIBWEBRTC_REQUIRED_C_FLAGS_DEBUG@")
|
||||||
|
set(LIBWEBRTC_REQUIRED_C_FLAGS_RELEASE "@LIBWEBRTC_REQUIRED_C_FLAGS_RELEASE@")
|
||||||
|
set(LIBWEBRTC_REQUIRED_CXX_FLAGS_DEBUG "@LIBWEBRTC_REQUIRED_CXX_FLAGS_DEBUG@")
|
||||||
|
set(LIBWEBRTC_REQUIRED_CXX_FLAGS_RELEASE "@LIBWEBRTC_REQUIRED_CXX_FLAGS_RELEASE@")
|
||||||
|
set(LIBWEBRTC_REQUIRED_STATIC_LINKER_FLAGS "@LIBWEBRTC_REQUIRED_STATIC_LINKER_FLAGS@")
|
||||||
|
set(LIBWEBRTC_DEFINITIONS_DEBUG "@LIBWEBRTC_DEFINITIONS_DEBUG@")
|
||||||
|
set(LIBWEBRTC_DEFINITIONS_RELEASE "@LIBWEBRTC_DEFINITIONS_RELEASE@")
|
||||||
|
|
||||||
|
# The location of the UseLibWebRTC.cmake file.
|
||||||
|
set(LIBWEBRTC_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}")
|
||||||
|
set(LIBWEBRTC_USE_FILE "${LIBWEBRTC_CMAKE_DIR}/UseLibWebRTC.cmake")
|
||||||
|
|
||||||
|
# Import LibWebRTC targets.
|
||||||
|
include("${LIBWEBRTC_CMAKE_DIR}/LibWebRTCTargets.cmake")
|
||||||
8
libwebrtc/LibWebRTCConfigVersion.cmake.in
Normal file
8
libwebrtc/LibWebRTCConfigVersion.cmake.in
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
# The full LibWebRTC version number.
|
||||||
|
set(PACKAGE_VERSION "@WEBRTC_VERSION@")
|
||||||
|
|
||||||
|
# This version is compatible only with equal version
|
||||||
|
if ("${PACKAGE_FIND_VERSION}" VERSION_EQUAL "@WEBRTC_VERSION@")
|
||||||
|
set(PACKAGE_VERSION_COMPATIBLE 1)
|
||||||
|
set(PACKAGE_VERSION_EXACT 1)
|
||||||
|
endif ()
|
||||||
23
libwebrtc/LibWebRTCTargets-debug.cmake
Normal file
23
libwebrtc/LibWebRTCTargets-debug.cmake
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
#----------------------------------------------------------------
|
||||||
|
# CMake target import file for configuration "Debug".
|
||||||
|
#----------------------------------------------------------------
|
||||||
|
|
||||||
|
# Commands may need to know the format version.
|
||||||
|
set(CMAKE_IMPORT_FILE_VERSION 1)
|
||||||
|
|
||||||
|
# Import target "webrtc" for configuration "Debug"
|
||||||
|
set_property(TARGET webrtc APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug)
|
||||||
|
|
||||||
|
if (MSVC)
|
||||||
|
set(_WEBRTC_LIBRARY_PATH "${_IMPORT_PREFIX}/lib/webrtcd.lib")
|
||||||
|
else ()
|
||||||
|
set(_WEBRTC_LIBRARY_PATH "${_IMPORT_PREFIX}/lib/libwebrtcd.a")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
set_target_properties(webrtc PROPERTIES IMPORTED_LOCATION_DEBUG "${_WEBRTC_LIBRARY_PATH}")
|
||||||
|
|
||||||
|
list(APPEND _IMPORT_CHECK_TARGETS webrtc)
|
||||||
|
list(APPEND _IMPORT_CHECK_FILES_FOR_webrtc "${_WEBRTC_LIBRARY_PATH}")
|
||||||
|
|
||||||
|
# Commands beyond this point should not need to know the version.
|
||||||
|
set(CMAKE_IMPORT_FILE_VERSION)
|
||||||
23
libwebrtc/LibWebRTCTargets-release.cmake
Normal file
23
libwebrtc/LibWebRTCTargets-release.cmake
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
#----------------------------------------------------------------
|
||||||
|
# CMake target import file for configuration "Release".
|
||||||
|
#----------------------------------------------------------------
|
||||||
|
|
||||||
|
# Commands may need to know the format version.
|
||||||
|
set(CMAKE_IMPORT_FILE_VERSION 1)
|
||||||
|
|
||||||
|
# Import target "webrtc" for configuration "Release"
|
||||||
|
set_property(TARGET webrtc APPEND PROPERTY IMPORTED_CONFIGURATIONS Release)
|
||||||
|
|
||||||
|
if (MSVC)
|
||||||
|
set(_WEBRTC_LIBRARY_PATH "${_IMPORT_PREFIX}/lib/webrtc.lib")
|
||||||
|
else ()
|
||||||
|
set(_WEBRTC_LIBRARY_PATH "${_IMPORT_PREFIX}/lib/libwebrtc.a")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
set_target_properties(webrtc PROPERTIES IMPORTED_LOCATION_RELEASE "${_WEBRTC_LIBRARY_PATH}")
|
||||||
|
|
||||||
|
list(APPEND _IMPORT_CHECK_TARGETS webrtc)
|
||||||
|
list(APPEND _IMPORT_CHECK_FILES_FOR_webrtc "${_WEBRTC_LIBRARY_PATH}")
|
||||||
|
|
||||||
|
# Commands beyond this point should not need to know the version.
|
||||||
|
set(CMAKE_IMPORT_FILE_VERSION)
|
||||||
83
libwebrtc/LibWebRTCTargets.cmake
Normal file
83
libwebrtc/LibWebRTCTargets.cmake
Normal file
|
|
@ -0,0 +1,83 @@
|
||||||
|
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5)
|
||||||
|
message(FATAL_ERROR "CMake >= 2.6.0 required")
|
||||||
|
endif()
|
||||||
|
cmake_policy(PUSH)
|
||||||
|
cmake_policy(VERSION 2.6)
|
||||||
|
|
||||||
|
# Commands may need to know the format version.
|
||||||
|
set(CMAKE_IMPORT_FILE_VERSION 1)
|
||||||
|
|
||||||
|
# Protect against multiple inclusion, which would fail when already imported targets are added once more.
|
||||||
|
set(_targetsDefined)
|
||||||
|
set(_targetsNotDefined)
|
||||||
|
set(_expectedTargets)
|
||||||
|
foreach(_expectedTarget webrtc)
|
||||||
|
list(APPEND _expectedTargets ${_expectedTarget})
|
||||||
|
if(NOT TARGET ${_expectedTarget})
|
||||||
|
list(APPEND _targetsNotDefined ${_expectedTarget})
|
||||||
|
endif()
|
||||||
|
if(TARGET ${_expectedTarget})
|
||||||
|
list(APPEND _targetsDefined ${_expectedTarget})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
if("${_targetsDefined}" STREQUAL "${_expectedTargets}")
|
||||||
|
unset(_targetsDefined)
|
||||||
|
unset(_targetsNotDefined)
|
||||||
|
unset(_expectedTargets)
|
||||||
|
set(CMAKE_IMPORT_FILE_VERSION)
|
||||||
|
cmake_policy(POP)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
if(NOT "${_targetsDefined}" STREQUAL "")
|
||||||
|
message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n")
|
||||||
|
endif()
|
||||||
|
unset(_targetsDefined)
|
||||||
|
unset(_targetsNotDefined)
|
||||||
|
unset(_expectedTargets)
|
||||||
|
|
||||||
|
|
||||||
|
# The installation prefix configured by this project.
|
||||||
|
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE)
|
||||||
|
|
||||||
|
# Create imported target webrtc
|
||||||
|
add_library(webrtc STATIC IMPORTED)
|
||||||
|
|
||||||
|
set_target_properties(webrtc PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
|
||||||
|
"${_IMPORT_PREFIX}/include;${_IMPORT_PREFIX}/include/webrtc;${_IMPORT_PREFIX}/include/webrtc/third_party/libyuv/include;${_IMPORT_PREFIX}/include/webrtc/third_party/jsoncpp/source/include"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Load information for each installed configuration.
|
||||||
|
get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||||
|
file(GLOB CONFIG_FILES "${_DIR}/LibWebRTCTargets-*.cmake")
|
||||||
|
foreach(f ${CONFIG_FILES})
|
||||||
|
include(${f})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Cleanup temporary variables.
|
||||||
|
set(_IMPORT_PREFIX)
|
||||||
|
|
||||||
|
# Loop over all imported files and verify that they actually exist
|
||||||
|
foreach(target ${_IMPORT_CHECK_TARGETS} )
|
||||||
|
foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )
|
||||||
|
if(NOT EXISTS "${file}" )
|
||||||
|
message(FATAL_ERROR "The imported target \"${target}\" references the file
|
||||||
|
\"${file}\"
|
||||||
|
but this file does not exist. Possible reasons include:
|
||||||
|
* The file was deleted, renamed, or moved to another location.
|
||||||
|
* An install or uninstall procedure did not complete successfully.
|
||||||
|
* The installation package was faulty and contained
|
||||||
|
\"${CMAKE_CURRENT_LIST_FILE}\"
|
||||||
|
but not all the files it references.
|
||||||
|
")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
unset(_IMPORT_CHECK_FILES_FOR_${target})
|
||||||
|
endforeach()
|
||||||
|
unset(_IMPORT_CHECK_TARGETS)
|
||||||
|
|
||||||
|
# This file does not depend on other imported targets which have
|
||||||
|
# been exported from the same project but in a separate export set.
|
||||||
|
|
||||||
|
# Commands beyond this point should not need to know the version.
|
||||||
|
set(CMAKE_IMPORT_FILE_VERSION)
|
||||||
|
cmake_policy(POP)
|
||||||
38
libwebrtc/UseLibWebRTC.cmake
Normal file
38
libwebrtc/UseLibWebRTC.cmake
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
#
|
||||||
|
# This module is provided as LIBWEBRTC_USE_FILE by LibWebRTCConfig.cmake.
|
||||||
|
# It can be INCLUDEd in a project to load the needed compiler and linker
|
||||||
|
# settings to use LibWebRTC.
|
||||||
|
#
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.9)
|
||||||
|
|
||||||
|
if (LIBWEBRTC_USE_FILE_INCLUDED)
|
||||||
|
return()
|
||||||
|
endif ()
|
||||||
|
set(LIBWEBRTC_USE_FILE_INCLUDED 1)
|
||||||
|
|
||||||
|
# Enable threading
|
||||||
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||||
|
find_package(Threads REQUIRED)
|
||||||
|
|
||||||
|
# Update CMAKE_MODULE_PATH so includes work.
|
||||||
|
list(APPEND CMAKE_MODULE_PATH ${LIBWEBRTC_CMAKE_DIR})
|
||||||
|
|
||||||
|
# Add compiler flags needed to use LibWebRTC.
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBWEBRTC_REQUIRED_C_FLAGS}")
|
||||||
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${LIBWEBRTC_REQUIRED_C_FLAGS_DEBUG}")
|
||||||
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${LIBWEBRTC_REQUIRED_C_FLAGS_RELEASE}")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBWEBRTC_REQUIRED_CXX_FLAGS}")
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${LIBWEBRTC_REQUIRED_CXX_FLAGS_DEBUG}")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${LIBWEBRTC_REQUIRED_CXX_FLAGS_RELEASE}")
|
||||||
|
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} ${LIBWEBRTC_REQUIRED_STATIC_LINKER_FLAGS}")
|
||||||
|
|
||||||
|
# Add preprocessor definitions needed to use LibWebRTC.
|
||||||
|
if (GENERATOR_IS_MULTI_CONFIG)
|
||||||
|
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG ${LIBWEBRTC_DEFINITIONS_DEBUG})
|
||||||
|
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE ${LIBWEBRTC_DEFINITIONS_RELEASE})
|
||||||
|
elseif (CMAKE_BUILD_TYPE MATCHES Debug)
|
||||||
|
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS ${LIBWEBRTC_DEFINITIONS_DEBUG})
|
||||||
|
else ()
|
||||||
|
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS ${LIBWEBRTC_DEFINITIONS_RELEASE})
|
||||||
|
endif ()
|
||||||
34
package.json
34
package.json
|
|
@ -1,34 +0,0 @@
|
||||||
{
|
|
||||||
"name": "libwebrtc-src",
|
|
||||||
"version": "0.0.1-rc.4",
|
|
||||||
"description": "libwebrtc source code",
|
|
||||||
"main": "index.js",
|
|
||||||
"config": {
|
|
||||||
"filename": "libwebrtc-{VERSION}-{PLATFORM}-{ARCH}",
|
|
||||||
"url": "https://github.com/aisouard/libwebrtc/releases/download",
|
|
||||||
"webrtc": {
|
|
||||||
"url": "https://chromium.googlesource.com/external/webrtc.git",
|
|
||||||
"revision": "7502401788fcba5c9f81a9e4701e2f0831e78698",
|
|
||||||
"checksum": "298b2c8d977478252cdf4f44d24a53e8"
|
|
||||||
},
|
|
||||||
"chromium": {
|
|
||||||
"url": "https://github.com/aisouard/libwebrtc-chromium-deps.git"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"install": "jake",
|
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com//aisouard/libwebrtc"
|
|
||||||
},
|
|
||||||
"author": "Axel Isouard <axel@isouard.fr>",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"download": "^5.0.2",
|
|
||||||
"fs-extra": "^0.30.0",
|
|
||||||
"jake": "^8.0.14",
|
|
||||||
"npm": "^3.10.8"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
78
sync.py
Executable file
78
sync.py
Executable file
|
|
@ -0,0 +1,78 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
def execute(command: str):
|
||||||
|
subprocess.run(command, shell=True, check=True)
|
||||||
|
|
||||||
|
|
||||||
|
def get_output(command: str):
|
||||||
|
return subprocess.run(command, capture_output=True, shell=True, check=True).stdout.decode()
|
||||||
|
|
||||||
|
|
||||||
|
# To determine last stable WebRTC revision,
|
||||||
|
# see https://chromiumdash.appspot.com/branches
|
||||||
|
# and https://chromiumdash.appspot.com/schedule
|
||||||
|
WEBRTC_REVISION = 4692
|
||||||
|
|
||||||
|
if len(sys.argv) == 2:
|
||||||
|
WEBRTC_REVISION = sys.argv[1]
|
||||||
|
|
||||||
|
REPO_ROOT = Path(__file__).resolve().parent
|
||||||
|
DEPOT_TOOLS_DIR = REPO_ROOT / 'depot_tools'
|
||||||
|
WEBRTC_DIR = REPO_ROOT / 'webrtc'
|
||||||
|
SRC_DIR = WEBRTC_DIR / 'src'
|
||||||
|
|
||||||
|
os.environ['PATH'] = '{}{}{}'.format(DEPOT_TOOLS_DIR, os.pathsep, os.environ['PATH'])
|
||||||
|
if sys.platform == 'win32':
|
||||||
|
os.environ['DEPOT_TOOLS_WIN_TOOLCHAIN'] = '0'
|
||||||
|
|
||||||
|
os.chdir(REPO_ROOT)
|
||||||
|
if not os.path.isdir(DEPOT_TOOLS_DIR):
|
||||||
|
print('Cloning Depot Tools...')
|
||||||
|
execute('git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git')
|
||||||
|
os.chdir(DEPOT_TOOLS_DIR)
|
||||||
|
|
||||||
|
if sys.platform == 'win32':
|
||||||
|
execute('gclient --version')
|
||||||
|
execute('where python')
|
||||||
|
|
||||||
|
execute('python update_depot_tools_toggle.py --disable')
|
||||||
|
else:
|
||||||
|
print('Updating Depot Tools to the latest revision...')
|
||||||
|
os.chdir(DEPOT_TOOLS_DIR)
|
||||||
|
execute('git checkout -q -f main')
|
||||||
|
execute('git pull -q')
|
||||||
|
|
||||||
|
if not os.path.isdir(WEBRTC_DIR):
|
||||||
|
print('Cloning WebRTC...')
|
||||||
|
os.mkdir(WEBRTC_DIR)
|
||||||
|
os.chdir(WEBRTC_DIR)
|
||||||
|
execute('fetch --nohooks webrtc')
|
||||||
|
os.chdir(SRC_DIR)
|
||||||
|
execute('gclient sync --with_branch_heads --nohooks')
|
||||||
|
else:
|
||||||
|
print('Updating WebRTC branches info...')
|
||||||
|
os.chdir(SRC_DIR)
|
||||||
|
execute('gclient sync --with_branch_heads --nohooks')
|
||||||
|
|
||||||
|
# Latest Depot Tools versions are not compatible
|
||||||
|
# with old WebRTC versions, so we peek revision
|
||||||
|
# from around the same time as the WebRTC and
|
||||||
|
# forbid gclient to auto-update Depot Tools.
|
||||||
|
os.chdir(SRC_DIR)
|
||||||
|
LAST_WEBRTC_COMMIT_DATE = get_output('git log -n 1 --pretty=format:%ci branch-heads/{}'.format(WEBRTC_REVISION)).strip()
|
||||||
|
os.chdir(DEPOT_TOOLS_DIR)
|
||||||
|
DEPOT_TOOLS_COMPATIBLE_REVISION = get_output('git rev-list -n 1 --before="{}" main'.format(LAST_WEBRTC_COMMIT_DATE)).strip()
|
||||||
|
print('Updating Depot Tools to a compatible revision {}...'.format(DEPOT_TOOLS_COMPATIBLE_REVISION))
|
||||||
|
execute('git checkout -f {}'.format(DEPOT_TOOLS_COMPATIBLE_REVISION))
|
||||||
|
|
||||||
|
print('Updating WebRTC to version {}...'.format(WEBRTC_REVISION))
|
||||||
|
os.chdir(SRC_DIR)
|
||||||
|
execute('git clean -ffd')
|
||||||
|
execute('git checkout -q -B {} branch-heads/{}'.format(WEBRTC_REVISION, WEBRTC_REVISION))
|
||||||
|
execute('gclient sync --force -D --reset')
|
||||||
Loading…
Add table
Reference in a new issue