Compare commits

...

178 commits

Author SHA1 Message Date
c4917e8f86 sync.sh and sync.bat replaced with sync.py.
Update README.md.
2024-09-23 19:29:58 +03:00
4475233318 Fix synchronization for old versions of WebRTC. 2024-08-19 22:35:00 +03:00
92fb3fdc01 Disable use of sysroot to avoid conflicts on non-Debian based systems. 2024-08-19 22:30:50 +03:00
915e13f4ce Make installation directory be relocatable (replace hard-coded paths in CMake configs with dynamic ones). 2024-08-19 22:30:50 +03:00
c3a581c11c Enable RTTI. 2023-08-05 13:45:08 +03:00
cf009964cf Discard local changes and untracked files on sync. 2023-08-23 20:46:44 +03:00
9d7075b4f0 Debian package splits into common, debug and release. 2023-08-23 20:46:25 +03:00
292a9b8751 Disable building of tests, examples and tools. 2022-10-03 19:20:27 +03:00
0e08c8388a Add an ability to replace some source files before building. 2022-10-03 15:43:17 +03:00
d667dab439 Change configurations case. 2022-09-27 23:15:08 +03:00
1e24732035 Add an option to disable the use of internal Clang compiler 2022-09-14 20:58:03 +03:00
ab22b5519e Sync branch-heads. 2021-07-21 00:51:37 +03:00
2db22c8048 Passthrough GN_EXTRA_ARGS and NINJA_ARGS.
Fix GEN_ARGS_DEBUG for MSVC.
2021-07-21 00:31:50 +03:00
477b5b2220 Add 'use_lld=false' on Windows 2021-05-26 17:38:13 +03:00
c8cdba02bc Fix PATH
Add single-configuration generators support on Windows
2021-05-21 22:30:50 +03:00
5a40775960 Add libyuv and jsoncpp include directories to INTERFACE_INCLUDE_DIRECTORIES. 2021-05-11 17:07:22 +03:00
d5583c9a6c Add option to build DEB package. 2021-04-07 22:28:41 +03:00
f158466213 Separated sources fetching and building. 2021-04-07 21:37:04 +03:00
8185da4a10
Install common_audio directory. 2021-03-05 00:54:34 +03:00
bb6c49081b Update README 2021-02-11 23:07:34 +03:00
700e94ff03 Fix prefix in CMakeTargets.cmake 2021-02-11 23:05:34 +03:00
40db8152b4 Fix: set is_clang and enable_iterator_debugging only on MSVC 2020-11-27 18:49:02 +03:00
7fefa7dc53 Enable iterator debugging in Windows debug configuration
Disable Clang completely on Windows
2020-11-26 17:49:12 +03:00
3315befa38 Update depot-tools after cloning 2020-11-25 19:04:32 +03:00
dccaa6f5f4 Do not use libc++
Use C++11 ABI on Linux
2020-11-18 19:53:15 +03:00
5ac8845681 Build with dynamic runtime on desktop Windows
Add suffix to debug library name
2020-11-11 18:06:46 +03:00
Michael Kris
b248e1cd73 gn now comes with depot tools no need to download separately 2020-10-28 13:59:51 -07:00
ssskip
336476a1f8 xcode 11.5 2020-06-14 22:50:20 +08:00
ssskip
38d6a4e9ea m83 2020-06-14 22:48:34 +08:00
Mike Lester
2ac0e402e1 Copy absl include directory directly into webrtc/ (instead of third_party/) 2020-04-08 15:55:05 +10:00
Mike Lester
05445b2fd5
Update README.md 2020-04-08 14:50:38 +10:00
Mike Lester
46f502d2d1 Copy abseil headers 2020-04-08 11:03:30 +10:00
Mike Lester
d44f0e4c3a CMake config file now points to the correct root include directory 2020-04-08 10:34:04 +10:00
湖北捷智云技术有限公司
a24a5e5947 Update WebRTC version to m72. 2019-02-19 01:31:53 +08:00
Martin Müllenhaupt
6fa64674be update to webrtc 68 2018-08-25 10:40:14 +02:00
Martin Müllenhaupt
09a07366da circleci 2018-06-11 21:26:32 +02:00
Martin Müllenhaupt
4ee758711c select package headers 2018-06-09 00:14:18 +02:00
Martin Müllenhaupt
b9480efda7 fix header paths 2018-06-06 09:55:40 +02:00
Martin Müllenhaupt
9db425ba54 install pdb files 2018-05-30 12:38:47 +02:00
Martin Müllenhaupt
475d263a51 try to fix header installation 2018-05-30 12:28:28 +02:00
Martin Müllenhaupt
2e92e72f0a remove BUILD_TESTS option 2018-05-30 11:33:02 +02:00
Martin Müllenhaupt
a627d1bc9a update appveyor to msvc 2017 2018-05-30 11:06:47 +02:00
Martin Müllenhaupt
66fa38e90d fix quote typo 2018-05-30 10:33:22 +02:00
Martin Müllenhaupt
9664e669e6 build less targets required for the ice-adapter 2018-05-30 10:29:31 +02:00
Martin Müllenhaupt
60407d29cd enable debug build and update to version 66 2018-05-30 10:29:10 +02:00
Martin Müllenhaupt
0569dc61df update to webrtc 63 2017-12-17 14:04:48 +01:00
Martin Müllenhaupt
37eeec231e build release 62 2017-11-15 20:14:41 +01:00
Martin Müllenhaupt
d2d4b017f8 try circleci build 2017-10-09 10:43:29 +02:00
Martin Müllenhaupt
ffd60ae7d8 build jsoncpp 2017-10-05 19:14:18 +02:00
Martin Müllenhaupt
787fe28f96 fix gclient command to download test assets 2017-07-19 09:38:50 +02:00
Martin Müllenhaupt
a477b6a2a8 make appveyor build webrtc 60 2017-07-18 20:13:01 +02:00
Martin Müllenhaupt
1d52ac650f turn off the sample for now 2017-07-14 11:19:02 +02:00
Martin Müllenhaupt
d26a48fc0d disable x64 and debug builds for now 2017-07-14 11:19:02 +02:00
Martin Müllenhaupt
3d42742689 remove audio_coding/test/utility.cc object files to fix multiple definition linking error of webrtc::CircularBuffer 2017-07-14 11:19:02 +02:00
Martin Müllenhaupt
a925a1bad2 appveyor: build tests 2017-07-14 11:19:02 +02:00
Martin Mllenhaupt
107f4dccb3 rename library to libwebrtc on Windows to match node-webrtc 2017-07-14 11:19:02 +02:00
Axel Isouard
be407aced0
(#30): Add release 58 support 2017-04-16 11:25:36 +02:00
Axel Isouard
f7e01514ed
(#5): Set the right arch inside install-sysroot.py argument 2017-04-02 18:01:17 +02:00
Axel Isouard
b3651f0e14
(#5): Set the arch inside Package.cmake and install-sysroot.py argument 2017-04-02 17:45:41 +02:00
Axel Isouard
8d571cb492
(#10): State BUILD_TESTS variable inside the README and CHANGELOG 2017-03-30 19:44:36 +02:00
Axel Isouard
f496ce1a29 (#10): Add webrtc_tests target to ninja build command 2017-03-30 11:28:08 +02:00
Axel Isouard
9b5dadf807
Fix Travis deploy script, prefix the file with ls 2017-03-27 22:59:03 +02:00
Axel Isouard
5cfd7585f8
Write CHANGELOG.md, release 1.0 2017-03-27 21:06:31 +02:00
Axel Isouard
d2de52cdce
Enhance the deployment process through CIs 2017-03-27 20:01:31 +02:00
Axel Isouard
1bed0a6818
Build version from current tag 2017-03-27 19:59:16 +02:00
Axel Isouard
5cda935434
Write windows-related build instructions, stuff about debug mode 2017-03-27 17:59:04 +02:00
Axel Isouard
9f324642f5 (#23): Add sample target, build it and run it 2017-03-27 13:28:37 +02:00
Axel Isouard
941688e7fc Build webrtc, system_wrappers_default and libjingle_peerconnection 2017-03-27 13:27:46 +02:00
Axel Isouard
eec2846651 Install CMake target files, from libwebrtc target this time 2017-03-27 13:27:14 +02:00
Axel Isouard
7cd0a79bd2 Include protobuf_full objects instead of protobuf_lite's 2017-03-27 13:26:36 +02:00
Axel Isouard
1dbc538b4b Link with crypt32 and iphlpapi 2017-03-27 13:25:37 +02:00
Axel Isouard
ee7fb4f42d Link with rt and pthread library 2017-03-27 13:25:23 +02:00
Axel Isouard
ad6d1a565a (#39): Force is_component_build=false argument 2017-03-27 13:24:49 +02:00
Axel Isouard
2969a0f603 Remove CMAKE_THREAD_LIBS_INIT definition inside Install.cmake 2017-03-27 13:23:57 +02:00
Axel Isouard
67ac79ff0f Use the CMAKE_FILES_DIRECTORY CMake variable 2017-03-27 13:23:02 +02:00
Axel Isouard
bc9c05404f Define WEBRTC_MAC under macOS, set correct pthread and debugging flags 2017-03-27 13:22:39 +02:00
Axel Isouard
b35dc15d8d Travis: Remove x86 build for now, use g++ 4.8 2017-03-27 13:21:59 +02:00
Axel Isouard
55f1e9d761 Use the same CMAKE_BUILD_TYPE for the libwebrtc target 2017-03-27 13:21:06 +02:00
Axel Isouard
7acf691f2b State GCC / G++ 4.8 inside the README 2017-03-27 13:19:53 +02:00
Axel Isouard
ab1cf49414
(#40): Do not put CMake target files inside the package 2017-03-25 14:35:08 +01:00
Axel Isouard
7ef534cd55
(#40): Do not run generator variables during package 2017-03-25 12:23:02 +01:00
Axel Isouard
77208bccbd
(#40): Remove mac x86 build, set appveyor matrix the right way 2017-03-25 12:00:49 +01:00
Axel Isouard
9ee8a5aec6
(#40): Fix Debug build, add debug configuration in Travis and Appveyor 2017-03-25 11:18:37 +01:00
Axel Isouard
53a331a356
(#38): Do not fetch gn and clang-format at the same time 2017-03-25 09:36:44 +01:00
Axel Isouard
7047a4dfef
Add LIBWEBRTC_WEBRTC_BRANCH_HEAD inside CMake Config file, fix WEBRTC_REVISION 2017-03-21 19:16:20 +01:00
Axel Isouard
522e16128a
Enforce static linking, closes #37 2017-03-21 18:55:56 +01:00
Axel Isouard
cb13886cbe README: Remove BUILD_TESTS since they are not supported yet (#37) 2017-03-21 09:38:25 +01:00
Axel Isouard
5ae2a5de6b README: Remove BUILD_SHARED_LIB flag (#37) 2017-03-21 09:32:58 +01:00
Axel Isouard
6aab703673 Merge branch refactor-depot-tools 2017-03-19 22:58:59 -07:00
Axel Isouard
5744e63abe
Rename artifact for Appveyor 2017-03-19 20:22:30 +01:00
Axel Isouard
58f2d70a74
No longer need for clang_use_chrome_plugins=false, disable tests on appveyor 2017-03-19 20:06:21 +01:00
Axel Isouard
418e54b401
Execute checkout commands inside the main CMake file 2017-03-19 19:52:34 +01:00
Axel Isouard
c21220c58c
Replace all execute_process calls with libwebrtc_execute 2017-03-19 18:56:08 +01:00
Axel Isouard
64690d1a30
Define WEBRTC_BRANCH_HEAD and WEBRTC_REVISION when required 2017-03-19 18:55:36 +01:00
Axel Isouard
16578cdd5c
Use the right variable for the lib output directory 2017-03-19 18:36:21 +01:00
Axel Isouard
7311f13bfa
Use the correct variable for the stamp file 2017-03-19 18:36:21 +01:00
Axel Isouard
7950fa7e8a Fix the environment variables forever, add .bat suffix for win32 2017-03-19 09:17:53 -07:00
Axel Isouard
c8a3e8eb8a
Remove prefix files, use cmake -E env 2017-03-19 14:14:55 +01:00
Axel Isouard
5d3887b918 No prefix file for gn command anymore, set the right directory for IDE config 2017-03-19 04:30:25 -07:00
Axel Isouard
ea5d4643aa
Gn.cmake: Set is_debug depending on the IDE 2017-03-19 11:56:21 +01:00
Axel Isouard
daf8535a2d
Set the target dependencies in a list 2017-03-19 10:30:50 +01:00
Axel Isouard
c10f3458f0
Enable parallel build for CI, remove -j 4 flag everywhere, fixes #34 2017-03-19 10:25:22 +01:00
Axel Isouard
8970f2368b
README: Add more instructions for specific commits and depot_tools management 2017-03-19 10:23:09 +01:00
Axel Isouard
17ef828ce2
Use libwebrtc_command instead of execute_process 2017-03-19 10:20:45 +01:00
Axel Isouard
bbdd74ce9a
Add libwebrtc_execute function, use it in DepotTools.cmake 2017-03-19 10:17:26 +01:00
Axel Isouard
b294fac627
Remove unused PREFIX_NEWLINE variable 2017-03-19 08:29:30 +01:00
Axel Isouard
b59291f093
Manage depot_tools, replace modules, remove Targets folder, fixes #33 2017-03-18 16:13:36 +01:00
Axel Isouard
5a602922c0
Remove include guards 2017-03-18 16:00:31 +01:00
Axel Isouard
e3a4e5d64e
README: Add CMake syntax highlighting 2017-03-18 12:48:30 +01:00
Axel Isouard
93438caf76
README: Add Acknowledgements 2017-03-18 12:48:03 +01:00
Axel Isouard
e60dbd57f6
Find all libraries first, set HAS_OWN_DEPOT_TOOLS variable 2017-03-17 23:26:47 +01:00
Axel Isouard
7ad84637f4
Add include guards 2017-03-17 18:52:54 +01:00
Axel Isouard
a750ea484d
Add DEPOT_TOOLS_PATH variable 2017-03-17 18:40:07 +01:00
Axel Isouard
b565920acb
Do not manage depot_tools as a submodule anymore 2017-03-12 12:38:19 +01:00
Axel Isouard
638022675f
Look for depot_tools only when DEPOT_TOOLS_PATH is set 2017-03-12 12:29:01 +01:00
Axel Isouard
470e444791
Find git and depot_tools in the main file 2017-03-12 12:16:19 +01:00
Axel Isouard
987a23fcef
README: Select the right version of Windows 10 SDK 2017-03-12 08:56:32 +01:00
Axel Isouard
80281d8afa
README.md: Add Windows 10 SDK / Windows Driver Kit 10 installation instructions 2017-03-11 14:19:08 +01:00
Axel Isouard
9eafe12813
#31: Set clang_use_chrome_plugins to false on Travis 2017-03-09 20:42:13 +01:00
Axel Isouard
058d9e0da3
Add GN_EXTRA_ARGS config variable 2017-03-09 20:40:23 +01:00
Axel Isouard
287d483478
Add WEBRTC_BRANCH_HEAD config variable 2017-03-09 20:39:38 +01:00
Axel Isouard
bc67c8f626
#29: Set _NEXT_DEPENDS and _DOWNLOAD_COMMAND according to WEBRTC_REVISION 2017-03-08 07:16:23 +01:00
Axel Isouard
b668195218
Add WEBRTC_REVISION variable, fetch the release branch head by default 2017-02-21 19:51:58 +01:00
Axel Isouard
83814ef6f3
Rename DEPOTTOOLS_GCLIENT_EXECUTABLE to GCLIENT_EXECUTABLE 2017-02-21 19:51:58 +01:00
Axel Isouard
f25382438d
Remove a Windows definition set inside Unix target 2017-02-21 19:51:58 +01:00
Axel Isouard
91ab805302 Include the full Apache License 2.0 2017-02-15 18:34:04 +01:00
Axel Isouard
54b08c7c27
Remove Javascript and node-related files 2017-02-12 10:09:36 +01:00
Axel Isouard
1588d232cd
Define package summary, author, support DEB and RPM 2017-02-12 09:59:40 +01:00
Axel Isouard
2d714a93b3
Add options to build DEB and RPM packages 2017-02-12 09:51:53 +01:00
Axel Isouard
d1992ce19f
Include Package CMake module in the end of the main CMake file 2017-02-12 09:49:35 +01:00
Axel Isouard
28034f95c8
Remove Jake 2017-02-12 09:48:41 +01:00
Axel Isouard
25345ad1a7
Move the package definitions from Install.cmake to Package.cmake 2017-02-12 09:25:19 +01:00
Axel Isouard
34afab9454 Use depot_tools' Python executable under Windows 2017-02-12 00:20:39 -08:00
Axel Isouard
1f20b932cf
README.md: Tell the user to run CMake 2017-02-09 21:14:17 +01:00
Axel Isouard
2d2ddde88d
Enhance pkg-config generation, state it inside README.md 2017-02-09 21:13:36 +01:00
Axel Isouard
702153c428
Move CMake template files inside a dedicated folder 2017-02-06 22:17:01 +01:00
Axel Isouard
6203fac5b2
Fix BUILD_TESTS option usage 2017-02-06 22:08:33 +01:00
Axel Isouard
5281a34c37
Enable BUILD_TESTS flag, check if we want to build a static library 2017-02-06 20:31:50 +01:00
Axel Isouard
11819b2917
README.md: Rewrite compatibility table, fix CMake version, add BUILD_SHARED_LIB option 2017-02-06 20:14:35 +01:00
Axel Isouard
dfaeab6dfa
Rewrite OS detection code properly 2017-02-06 20:10:33 +01:00
Axel Isouard
9743793fdb
Let the developer specify their own path to pkg-config files 2017-02-06 20:02:57 +01:00
Axel Isouard
c8042df583
Enable threading libraries inside the CMake Use file 2017-02-06 20:01:33 +01:00
Axel Isouard
7e7fa0d7d4
Add extra required libraries for Windows, prepend the list with webrtc 2017-02-06 19:32:18 +01:00
Axel Isouard
b334e9098a
Move target OS and CPU detection code to a separate CMake module 2017-02-06 19:22:15 +01:00
Axel Isouard
282570038c
Move options code to a separate CMake module 2017-02-06 19:13:57 +01:00
Axel Isouard
5337697608
Move version settings code to a separate CMake module 2017-02-06 19:12:00 +01:00
Axel Isouard
82cedb40a9
Move libraries finding code to a separate CMake module 2017-02-06 19:08:52 +01:00
Axel Isouard
6d5a20ee0a
Remove old CMake modules 2017-02-06 19:04:54 +01:00
Axel Isouard
c5c86b729b
Set the minimum CMake version to 3.3, closes #16 2017-02-05 19:17:38 +01:00
Axel Isouard
e994c40b0d
README.md: State x86 support under Windows 2017-02-05 18:35:42 +01:00
Axel Isouard
1b11dcc9c3
Generate and install pkg-config file, closes #3 2017-02-05 18:29:26 +01:00
Axel Isouard
f381807566 Write a better host CPU arch detection 2017-02-05 09:07:10 -08:00
Axel Isouard
a702d36f56 Merge pull request #21 from gitter-badger/gitter-badge
Add a Gitter chat badge to README.md
2017-02-05 07:21:51 -08:00
Axel Isouard
fc4badad3d
is_debug value depends of the CMAKE_BUILD_TYPE variable 2017-02-05 16:01:59 +01:00
Axel Isouard
9bf16c0940
README.md: Remove BUILD_SAMPLES, update Usage, compiling instructions, mention generated CMake scripts 2017-02-05 06:37:10 -08:00
Axel Isouard
ea0b0de53b
Add GClientConfig cmake module 2017-02-05 06:34:33 -08:00
Axel Isouard
c3285ca001
Create uninstall target 2017-02-05 06:34:05 -08:00
Axel Isouard
e2877a8598
Generate Prefix file at LibWebRTCCommand module inclusion 2017-02-05 06:33:48 -08:00
Axel Isouard
c314b374df
Don't generate a libwebrtc.h file anymore, export CMake targets 2017-02-05 06:33:19 -08:00
Axel Isouard
92307e4367
Simpler variable names, get CMake's object extension, include .o files under Windows 2017-02-05 06:32:38 -08:00
Axel Isouard
f634b8ec10
Flags and module path definition not needed anymore 2017-02-05 06:30:13 -08:00
Axel Isouard
7c4895a6fd
Define BUILD_SHARED_LIBS flag, which will define LIBRARY_TYPE variable 2017-02-05 06:28:20 -08:00
Axel Isouard
fc819a24b6
Build root not needed anymore, just define webrtc as the library's name, export the package 2017-02-05 06:27:08 -08:00
Axel Isouard
5ccda05d8c
Set better install paths for lib, include and cmake components 2017-02-05 06:26:26 -08:00
Axel Isouard
95384c655e
Move Targets/WebRTC/CMakeLists.txt to Targets/CMakeLists.txt 2017-02-05 06:25:55 -08:00
Axel Isouard
62f3b7d5a1
Move the package and install scripts into the Install module 2017-02-05 06:25:13 -08:00
Axel Isouard
59375cab38
Do not build the samples since they are not included anymore 2017-02-05 06:20:50 -08:00
Axel Isouard
2617dd15d7
Use CMake 3.0 for now, refactor the header 2017-02-05 06:16:50 -08:00
Axel Isouard
bb1b53a49e
Force 2.7 version for Python, look for it inside the detected depot_tools path 2017-02-05 06:15:21 -08:00
Axel Isouard
29b4333904
Enhance FindDepotTools.cmake, include it before looking for Python 2017-02-05 06:14:42 -08:00
Axel Isouard
704267abcb
Set the project's version and targets inside the main CMakeLists.txt file 2017-02-05 06:13:21 -08:00
Axel Isouard
0607a2bd6f
Lower required CMake version for libwebrtc 2017-02-05 06:04:25 -08:00
Axel Isouard
f57ddc50c0
Update package.json, remove useless parameters 2017-02-05 06:02:56 -08:00
Axel Isouard
0bfeb679e9
Set default configurations, only keep Debug and Release for the moment 2017-02-05 06:00:52 -08:00
Axel Isouard
a179540e7e
Create Config, ConfigVersion and Use CMake files
Signed-off-by: Axel Isouard <axel@isouard.fr>
2017-02-05 06:00:08 -08:00
Axel Isouard
aa4bca5f44
Ignore cmake-build-debug caused by CLion 2017-02-05 05:57:28 -08:00
Axel Isouard
598a7f2c15 Update README.md 2017-02-05 14:36:12 +01:00
The Gitter Badger
aaa4bf41c5 Add Gitter badge 2017-02-05 13:33:43 +00:00
63 changed files with 1064 additions and 2295 deletions

10
.gitignore vendored
View file

@ -1,6 +1,4 @@
.DS_Store
/out/
/.idea/
*.gclient
/node_modules/
*.gclient_entries
.idea
cmake-build-*
webrtc
depot_tools

3
.gitmodules vendored
View file

@ -1,3 +0,0 @@
[submodule "depot_tools"]
path = depot_tools
url = https://chromium.googlesource.com/chromium/tools/depot_tools.git

View file

@ -1,60 +0,0 @@
matrix:
include:
- os: linux
sudo: required
- os: osx
osx_image: xcode7.3
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
before_install:
- DEPS_DIR="${TRAVIS_BUILD_DIR}/deps"
- mkdir -p ${DEPS_DIR} && cd ${DEPS_DIR}
- |
if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
CMAKE_URL="http://www.cmake.org/files/v3.5/cmake-3.5.2-Linux-x86_64.tar.gz"
mkdir cmake && travis_retry wget --no-check-certificate --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C cmake
export PATH=${DEPS_DIR}/cmake/bin:${PATH}
else
if ! brew ls --version cmake &>/dev/null; then brew update && brew install cmake; fi
fi
- cd ${TRAVIS_BUILD_DIR}
- cmake --version
install:
- git submodule init
- git submodule update
- mkdir out
- cd out
- cmake -DNINJA_ARGS="-j 4" ..
script:
- make package
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

53
CHANGELOG.md Normal file
View 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

View file

@ -1,55 +1,46 @@
cmake_minimum_required(VERSION 2.8)
cmake_policy(SET CMP0057 NEW)
cmake_minimum_required(VERSION 3.20)
set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING INTERNAL FORCE)
project(libwebrtc)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
${CMAKE_SOURCE_DIR}/CMakeModules)
set(USE_CLANG ON CACHE BOOL "Build using internal Clang compiler (set to OFF to build using system GCC/MSVC)")
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)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
# Allow the use of IN_LIST operand
cmake_policy(SET CMP0057 NEW)
find_package(Git REQUIRED)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
include(FindLibraries)
include(TargetOsAndCpu)
include(Utils)
prependPath("${CMAKE_SOURCE_DIR}/depot_tools")
if (WIN32)
set(PYTHON_EXECUTABLE ${CMAKE_SOURCE_DIR}/depot_tools/python.bat)
else (WIN32)
find_package(PythonInterp REQUIRED)
endif (WIN32)
find_package(DepotTools REQUIRED)
set(ENV{DEPOT_TOOLS_WIN_TOOLCHAIN} 0)
endif()
#
# Options
#
set(WEBRTC_SOURCE_DIR "${CMAKE_SOURCE_DIR}/webrtc/src")
set(WEBRTC_BUILD_DIR "${CMAKE_BINARY_DIR}/webrtc")
option(BUILD_TESTS "Build test binaries" OFF)
option(BUILD_SAMPLES "Build samples binaries" OFF)
set(NINJA_ARGS "" CACHE STRING "Ninja arguments to pass before compiling WebRTC")
include(Version)
get_webrtc_version_from_git(WEBRTC_VERSION)
message(STATUS "WebRTC version: ${WEBRTC_VERSION}")
include(LibWebRTCSubsystem)
include(LibWebRTCVersion)
#
# 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")
if (MSVC)
# Always build with dynamic runtime on MSVC
patch_file(${WEBRTC_SOURCE_DIR}/build/config/win/BUILD.gn ":static_crt" ":dynamic_crt")
endif ()
set(LIBWEBRTC_LIBRARY_NAME ${CMAKE_STATIC_LIBRARY_PREFIX}webrtc${CMAKE_STATIC_LIBRARY_SUFFIX})
set(LIBWEBRTC_LIBRARY_PATH ${CMAKE_BINARY_DIR}/${LIBWEBRTC_INSTALL_LIB_DIR}/${LIBWEBRTC_LIBRARY_NAME})
# 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")
set(LIBWEBRTC_BUILD_ROOT ${CMAKE_SOURCE_DIR}/src/out/Default)
add_subdirectory(Targets)
include(AddWebRTCTarget)
add_webrtc_target(${WEBRTC_SOURCE_DIR} ${WEBRTC_BUILD_DIR})
if (BUILD_SAMPLES)
add_subdirectory(Samples)
endif (BUILD_SAMPLES)
add_subdirectory(libwebrtc)

View file

@ -1,14 +0,0 @@
if (WIN32)
find_program(DEPOTTOOLS_GCLIENT_EXECUTABLE
NAMES gclient.bat
PATHS ${CMAKE_CURRENT_SOURCE_DIR}/depot_tools)
else (WIN32)
find_program(DEPOTTOOLS_GCLIENT_EXECUTABLE
NAMES gclient
PATHS ${CMAKE_CURRENT_SOURCE_DIR}/depot_tools)
endif (WIN32)
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.")

View file

@ -1,60 +0,0 @@
# - Try to find LibWebRTC
# Once done this will define
# LIBWEBRTC_FOUND - System has LibWebRTC
# LIBWEBRTC_INCLUDE_DIRS - The LibWebRTC include directories
# LIBWEBRTC_LIBRARIES - The libraries needed to use LibWebRTC
# LIBWEBRTC_DEFINITIONS - Compiler switches required for using LibWebRTC
if (LibWebRTC_FIND_QUIETLY)
set(_FIND_FLAGS QUIET)
endif (LibWebRTC_FIND_QUIETLY)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED ${_FIND_FLAGS})
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)
elseif (UNIX)
find_package(X11 REQUIRED ${_FIND_FLAGS})
endif (APPLE)
if (WIN32)
set(LIBWEBRTC_DEFINITIONS -DWEBRTC_WIN -DNOMINMAX)
elseif (UNIX)
set(LIBWEBRTC_DEFINITIONS -DWEBRTC_POSIX -std=gnu++0x -D_GLIBCXX_USE_CXX11_ABI=0)
endif (WIN32)
find_path(LIBWEBRTC_INCLUDE_DIR libwebrtc.h
HINTS ${PC_LIBXML_INCLUDEDIR} ${PC_LIBXML_INCLUDE_DIRS}
PATH_SUFFIXES libwebrtc)
find_library(LIBWEBRTC_LIBRARY NAMES webrtc
HINTS ${PC_LIBXML_LIBDIR} ${PC_LIBXML_LIBRARY_DIRS})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibWebRTC DEFAULT_MSG
LIBWEBRTC_LIBRARY LIBWEBRTC_INCLUDE_DIR)
if (LIBWEBRTC_FOUND)
set(LIBWEBRTC_LIBRARIES ${LIBWEBRTC_LIBRARY} Threads::Threads)
if (WIN32)
set(LIBWEBRTC_LIBRARIES ${LIBWEBRTC_LIBRARIES} msdmo.lib wmcodecdspuuid.lib
dmoguids.lib ole32.lib secur32.lib)
elseif (APPLE)
set(LIBWEBRTC_LIBRARIES ${LIBWEBRTC_LIBRARIES}
${AUDIOTOOLBOX_LIBRARY} ${COREAUDIO_LIBRARY} ${COREFOUNDATION_LIBRARY}
${COREGRAPHICS_LIBRARY} ${FOUNDATION_LIBRARY})
elseif (UNIX)
set(LIBWEBRTC_LIBRARIES ${LIBWEBRTC_LIBRARIES} ${X11_LIBRARIES}
${CMAKE_DL_LIBS})
endif (WIN32)
set(LIBWEBRTC_INCLUDE_DIRS ${LIBWEBRTC_INCLUDE_DIR})
endif()
mark_as_advanced(LIBWEBRTC_INCLUDE_DIR LIBWEBRTC_LIBRARY)

View file

@ -1,22 +0,0 @@
include(CMakeParseArguments)
function(libwebrtc_command)
set(ONE_VALUE_ARGS NAME COMMENT DEPENDS WORKING_DIRECTORY)
set(MULTI_VALUE_ARGS COMMAND)
cmake_parse_arguments(COMMAND "" "${ONE_VALUE_ARGS}" "${MULTI_VALUE_ARGS}" ${ARGN} )
set(CMF_DIR ${CMAKE_BINARY_DIR}/CMakeFiles)
set(STAMP_FILE "${CMF_DIR}/${COMMAND_NAME}-complete")
add_custom_command(
OUTPUT ${STAMP_FILE}
COMMENT ${COMMAND_COMMENT}
COMMAND ${PREFIX_EXECUTE} ${COMMAND_COMMAND}
COMMAND ${CMAKE_COMMAND} -E touch ${STAMP_FILE}
WORKING_DIRECTORY ${COMMAND_WORKING_DIRECTORY}
)
add_custom_target(${COMMAND_NAME} ALL DEPENDS ${STAMP_FILE})
add_dependencies(${COMMAND_NAME} ${COMMAND_DEPENDS})
endfunction()

View file

@ -1,25 +0,0 @@
#
# Retrieve WebRTC source code
#
file(WRITE ${CMAKE_BINARY_DIR}/.gclient "solutions = [
{
\"url\": \"https://chromium.googlesource.com/external/webrtc.git\",
\"managed\": False,
\"name\": \"src\",
\"deps_file\": \"DEPS\",
\"custom_deps\": {},
},
]
")
if (TARGET_OS STREQUAL "android")
file(APPEND ${CMAKE_BINARY_DIR}/.gclient "target_os = [\"android\", \"unix\"]")
elseif (TARGET_OS STREQUAL "ios")
file(APPEND ${CMAKE_BINARY_DIR}/.gclient "target_os = [\"ios\", \"mac\"]")
elseif (TARGET_OS STREQUAL "linux")
file(APPEND ${CMAKE_BINARY_DIR}/.gclient "target_os = [\"unix\"]")
elseif (TARGET_OS STREQUAL "mac")
file(APPEND ${CMAKE_BINARY_DIR}/.gclient "target_os = [\"mac\"]")
elseif (TARGET_OS STREQUAL "win")
file(APPEND ${CMAKE_BINARY_DIR}/.gclient "target_os = [\"win\"]")
endif (TARGET_OS STREQUAL "android")

View file

@ -1,49 +0,0 @@
#
# Generate environment variables
#
set(WEBRTC_PATH ${CMAKE_SOURCE_DIR}/depot_tools)
if (WIN32)
get_filename_component(DEPOT_TOOLS_PYTHON_PATH
"${WEBRTC_PATH}/python276_bin"
REALPATH)
list(APPEND WEBRTC_PATH ${DEPOT_TOOLS_PYTHON_PATH})
endif (WIN32)
list(APPEND WEBRTC_PATH $ENV{PATH})
if (WIN32)
string(REGEX REPLACE "/" "\\\\" WEBRTC_PATH "${WEBRTC_PATH}")
string(REGEX REPLACE ";" "\\\;" WEBRTC_PATH "${WEBRTC_PATH}")
else (WIN32)
string(REGEX REPLACE ";" ":" WEBRTC_PATH "${WEBRTC_PATH}")
endif (WIN32)
get_filename_component(CHROMIUM_PYTHONPATH
"${CMAKE_BINARY_DIR}/src/build"
REALPATH)
if (WIN32)
set(PREFIX_FILENAME ${CMAKE_BINARY_DIR}/prefix.bat)
set(PREFIX_COMMAND set)
set(PREFIX_HEADER "@ECHO OFF")
set(PREFIX_EVAL "%*")
set(PREFIX_EXECUTE cmd /c ${PREFIX_FILENAME})
set(PREFIX_NEWLINE \r\n)
else (WIN32)
set(PREFIX_FILENAME ${CMAKE_BINARY_DIR}/prefix.sh)
set(PREFIX_COMMAND export)
set(PREFIX_HEADER "")
set(PREFIX_EVAL eval\ $@)
set(PREFIX_EXECUTE /bin/sh ${PREFIX_FILENAME})
set(PREFIX_NEWLINE \n)
endif (WIN32)
file(WRITE ${PREFIX_FILENAME} "${PREFIX_HEADER}
${PREFIX_COMMAND} PATH=${WEBRTC_PATH}
${PREFIX_COMMAND} PYTHONPATH=${CHROMIUM_PYTHONPATH}
${PREFIX_COMMAND} DEPOT_TOOLS_WIN_TOOLCHAIN=0
${PREFIX_COMMAND} DEPOT_TOOLS_UPDATE=0
${PREFIX_COMMAND} CHROME_HEADLESS=1
${PREFIX_EVAL}
")

View file

@ -1,46 +0,0 @@
#
# Subsystem
#
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 (TARGET_OS STREQUAL "")
if (NOT ${TARGET_OS} IN_LIST TARGET_OS_LIST)
message(FATAL_ERROR "Unknown value '${TARGET_OS}' for variable TARGET_OS, the following values are supported: ${TARGET_OS_LIST}")
endif (NOT ${TARGET_OS} IN_LIST TARGET_OS_LIST)
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 "")
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$")
set(TARGET_CPU "x86")
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^x86.64$")
set(TARGET_CPU "x64")
elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64")
set(TARGET_CPU "x64")
else ()
set(TARGET_CPU ${CMAKE_SYSTEM_PROCESSOR})
endif (CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$")
endif (TARGET_CPU STREQUAL "")
if (NOT ${TARGET_CPU} IN_LIST TARGET_CPU_LIST)
message(FATAL_ERROR "Unknown value '${TARGET_CPU}' for variable TARGET_CPU, the following values are supported: ${TARGET_CPU_LIST}")
endif (NOT ${TARGET_CPU} IN_LIST TARGET_CPU_LIST)
if (UNIX)
if (TARGET_CPU STREQUAL "x86")
set(CMAKE_C_FLAGS -m32)
set(CMAKE_CXX_FLAGS -m32)
endif (TARGET_CPU STREQUAL "x86")
endif(UNIX)

View file

@ -1,32 +0,0 @@
#
# Versioning
#
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}")
set(LIBWEBRTC_WEBRTC_REVISION ae2551232b5249e38298a50f2d9a64d3c862db00)
file(WRITE ${CMAKE_BINARY_DIR}/libwebrtc.h "#ifndef LIBWEBRTC_H_
#define LIBWEBRTC_H_
#define LIBWEBRTC_MAJOR_VERSION \"${LIBWEBRTC_MAJOR_VERSION}\"
#define LIBWEBRTC_MINOR_VERSION \"${LIBWEBRTC_MINOR_VERSION}\"
#define LIBWEBRTC_PATCH_VERSION \"${LIBWEBRTC_PATCH_VERSION}\"
#define LIBWEBRTC_BUILD_VERSION \"${LIBWEBRTC_BUILD_VERSION}\"
#define LIBWEBRTC_WEBRTC_REVISION \"${LIBWEBRTC_WEBRTC_REVISION}\"
#endif /* LIBWEBRTC_H_ */
")

View file

@ -1,4 +0,0 @@
'use strict';
desc('Default task');
task('default', ['fetch:precompiled'], function () {});

206
LICENSE
View file

@ -1,13 +1,201 @@
Copyright 2016 Axel Isouard
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
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
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.
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.

263
README.md
View file

@ -1,58 +1,29 @@
# libwebrtc [![License][license-img]][license-href] [![Build Status][travis-img]][travis-href] [![Build Status][appveyor-img]][appveyor-href]
# libwebrtc [![License][license-img]][license-href]
> CMake script for retrieving, building and linking Google's WebRTC into a single static 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:
## Status
```cmake
cmake_minimum_required(VERSION 3.9)
project(sample)
The following table displays the current state of this project, including
supported platforms and architectures.
find_package(LibWebRTC REQUIRED)
include(${LIBWEBRTC_USE_FILE})
<table>
<tr>
<th colspan="3">Linux</th>
<th colspan="2">macOS</th>
<th colspan="2">Windows</th>
<th colspan="1">iOS</th>
<th colspan="4">Android</th>
</tr>
<tr>
<td align="center">x86</td>
<td align="center">x64</td>
<td align="center">arm</td>
<td align="center">x86</td>
<td align="center">x64</td>
<td align="center">x86</td>
<td align="center">x64</td>
<td align="center">arm</td>
<td align="center">arm</td>
<td align="center">arm64</td>
<td align="center">x86</td>
<td align="center">x64</td>
</tr>
<tr>
<td align="center"></td>
<td align="center"></td>
<td></td>
<td></td>
<td align="center"></td>
<td></td>
<td align="center"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
set(SOURCE_FILES main.cpp)
add_executable(sample ${SOURCE_FILES})
target_link_libraries(sample ${LIBWEBRTC_LIBRARIES})
```
## Prerequisites
- CMake 3.5 or later,
- Python 2.7 (optional for Windows)
- 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
Install the required development packages
- Required development packages:
```
# apt-get install build-essential libglib2.0-dev libgtk2.0-dev libxtst-dev \
@ -61,154 +32,152 @@ Install the required development packages
libudev-dev
```
- GCC & G++ 4.8 or later, for C++11 support
### macOS
- OS X 10.11 or later,
- OS X 10.11 or later
- Xcode 7.3.1 or later
### Windows
* Windows 7 x64 or later, x86 operating systems are unsupported.
* Visual Studio 2015 **with updates** - Download the [Installer][vs2015-installer]
- 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
* Universal Windows Apps Development Tools > Windows 10 SDK (**10.0.10586**)
- 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**)
## Getting Started
- [Windows 10 SDK][w10sdk] with **Debugging Tools for Windows** or
[Windows Driver Kit 10][wdk10] installed in the same Windows 10 SDK
installation directory.
Clone the repository, initialize the submodules if `depot_tools` is not
installed on your system or not defined inside your `PATH` environment variable.
Create an output directory and browse inside it.
## 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/aisouard/libwebrtc.git
$ cd libwebrtc
$ git submodule init
$ git submodule update
$ mkdir out
$ cd out
git clone https://github.com/UltraCoderRU/libwebrtc.git
cd libwebrtc
python3 sync.py [WEBRTC_VERSION]
```
Windows users **must** append `Win64` if they are using a Visual Studio
generator. The `libwebrtc.sln` project solution will be located inside the
current directory output directory.
## Compiling
Create an output directory, browse inside it, then run CMake to configure project.
```
> cmake -G "Visual Studio 14 2015 Win64" ..
mkdir build
cd build
cmake -G Ninja -DCMAKE_BUILD_TYPE=<Debug/Release> -DCMAKE_INSTALL_PREFIX=<install_path> ..
```
Unix users will just have to run `$ cmake ..` to generate the Makefiles, then
run the following commands.
After configuration build library using standard CMake commands.
```
$ make
$ make package
# make install
cmake --build .
cmake --install .
```
The library will be located inside the `lib` folder of the current output
directory. The `include` folder will contain the header files.
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
Copy the `CMakeModules/FindLibWebRTC.cmake` file inside your CMake modules
directory. Let CMake find your libwebrtc headers and libraries with the
`find_package(LibWebRTC)` the following CMake variables will be created:
- **LIBWEBRTC_DEFINITIONS** - Preprocessor definitions, such as enabling C++11
features, to be used with `add_definitions`
- **LIBWEBRTC_INCLUDE_DIRS** - Include directories, use it with
`include_directories`
- **LIBWEBRTC_LIBRARIES** - List of required libraries to link your software,
use it with `target_link_libraries`
Here is what a CMakeLists.txt file should look like:
```
project(sample)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/CMakeModules)
To import LibWebRTC into your CMake project use `find_package`:
```cmake
find_package(LibWebRTC REQUIRED)
include(${LIBWEBRTC_USE_FILE})
set(SOURCE_FILES main.cpp)
include_directories(${LIBWEBRTC_INCLUDE_DIRS})
add_definitions(${LIBWEBRTC_DEFINITIONS})
add_executable(sample ${SOURCE_FILES})
target_link_libraries(sample ${LIBWEBRTC_LIBRARIES})
target_link_libraries(my-app ${LIBWEBRTC_LIBRARIES})
```
## Advanced Usage
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.
- **BUILD_SAMPLES**
- **GN_EXTRA_ARGS**
Build `PeerConnection` sample, source code located inside the
Samples/PeerConnection directory.
- **BUILD_TESTS**
Build WebRTC tests. (not supported yet)
Add extra arguments to the `gn gen --args` parameter.
- **NINJA_ARGS**
Arguments to pass while executing the `ninja` command. For instance, you can
define the number of cores you would like to use, in order to speed-up the
build process:
Arguments to pass while executing the `ninja` command.
`cmake -DNINJA_ARGS="-j 4" ..`
## Status
- **TARGET_OS**
The following table displays the current state of this project, including
supported platforms and architectures.
Target operating system, the value will be used inside the `--target_os`
argument of the `gn gen` command. The value **must** be one of the following:
<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>
- `android`
- `chromeos`
- `ios`
- `linux`
- `mac`
- `nacl`
- `win`
- **TARGET_CPU**
## Acknowledgements
Target architecture, the value will be used inside the `--target_cpu`
argument of the `gn gen` command. The value **must** be one of the following:
Many thanks to Dr. Alex Gouaillard for being an excellent mentor for this
project.
- `x86`
- `x64`
- `arm`
- `arm64`
- `mipsel`
## Contributing
Feel free to open an issue if you wish a bug to be fixed, to discuss a new
feature or to ask a question. I'm open to pull requests, as long as your
modifications are working on the three major OS (Windows, macOS and Linux).
Don't forget to put your name and e-mail address inside the `AUTHORS` file!
You can also reach me on [Twitter][twitter] for further discussion.
## License
Apache License 2.0 © [Axel Isouard][author]
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
[appveyor-img]:https://ci.appveyor.com/api/projects/status/yd1s303md3tt4w9a?svg=true
[appveyor-href]:https://ci.appveyor.com/project/aisouard/libwebrtc
[travis-img]:https://travis-ci.org/aisouard/libwebrtc.svg?branch=master
[travis-href]:https://travis-ci.org/aisouard/libwebrtc
[osx1011sdk]: https://github.com/phracker/MacOSX-SDKs/releases/download/MacOSX10.11.sdk/MacOSX10.11.sdk.tar.xz
[vs2015-installer]:https://www.microsoft.com/en-US/download/details.aspx?id=48146
[twitter]:https://twitter.com/aisouard
[author]:https://axel.isouard.fr
[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

View file

@ -1 +0,0 @@
add_subdirectory(PeerConnection)

View file

@ -1,75 +0,0 @@
project(PeerConnection)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
if(UNIX AND NOT APPLE)
find_package(X11 REQUIRED)
endif(UNIX AND NOT APPLE)
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)
endif(APPLE)
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_BINARY_DIR}/src)
if(WIN32)
add_definitions(-DWEBRTC_WIN -DNOMINMAX)
set(PEERCONNECTION_SOURCE_FILES ${PEERCONNECTION_SOURCE_FILES}
Win32Console.cpp)
else(WIN32)
add_definitions(-DWEBRTC_POSIX -std=gnu++0x -D_GLIBCXX_USE_CXX11_ABI=0)
set(PEERCONNECTION_SOURCE_FILES ${PEERCONNECTION_SOURCE_FILES}
UnixConsole.cpp)
endif(WIN32)
add_executable(PeerConnection
${PEERCONNECTION_SOURCE_FILES}
${PEERCONNECTION_HEADER_FILES})
set(PEERCONNECTION_LIBRARIES webrtc Threads::Threads)
if(WIN32)
set(PEERCONNECTION_LIBRARIES ${PEERCONNECTION_LIBRARIES} msdmo.lib wmcodecdspuuid.lib dmoguids.lib ole32.lib secur32.lib)
elseif(UNIX AND NOT APPLE)
set(PEERCONNECTION_LIBRARIES ${PEERCONNECTION_LIBRARIES}
${X11_LIBRARIES}
${CMAKE_DL_LIBS})
elseif(APPLE)
set(PEERCONNECTION_LIBRARIES ${PEERCONNECTION_LIBRARIES}
${AUDIOTOOLBOX_LIBRARY} ${COREAUDIO_LIBRARY} ${COREFOUNDATION_LIBRARY}
${COREGRAPHICS_LIBRARY} ${FOUNDATION_LIBRARY})
endif(WIN32)
add_library(webrtc STATIC IMPORTED)
set_property(TARGET webrtc PROPERTY IMPORTED_LOCATION "${CMAKE_BINARY_DIR}/libwebrtc/${LIBWEBRTC_LIBRARY_NAME}")
target_link_libraries(PeerConnection ${PEERCONNECTION_LIBRARIES})
add_dependencies(PeerConnection libwebrtc)

View file

@ -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

View file

@ -1,87 +0,0 @@
//
// Created by ax on 24/09/16.
//
#include "webrtc/base/ssladapter.h"
#ifdef WIN32
#include "webrtc/base/win32socketinit.h"
#include "webrtc/base/win32socketserver.h"
#include <Windows.h>
#endif
#include "Core.h"
rtc::Thread *Core::_signalingThread = NULL;
rtc::Thread *Core::_workerThread = NULL;
webrtc::PeerConnectionFactoryInterface *Core::_peerConnectionFactory = NULL;
bool Core::Init() {
#if 0
rtc::EnsureWinsockInit();
rtc::Win32Thread w32_thread;
rtc::ThreadManager::Instance()->SetCurrentThread(&w32_thread);
#endif
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;
}

View file

@ -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

View file

@ -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());
}

View file

@ -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

View file

@ -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) {
}

View file

@ -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

View file

@ -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

View file

@ -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);
}

View file

@ -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

View file

@ -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) {
}

View file

@ -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

View file

@ -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());
}

View file

@ -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

View file

@ -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());
}

View file

@ -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

View file

@ -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);
}

View file

@ -1,195 +0,0 @@
#include <iostream>
#include <cstdarg>
#include <Windows.h>
#include "Console.h"
#define MAX_EDIT_LINE 32768
static HANDLE hOUT;
static HANDLE hIN;
static DWORD dMode;
static WORD wAttrib;
static CONSOLE_CURSOR_INFO cursorInfo;
static size_t cursor;
static std::string buffer;
bool Console::Init() {
CONSOLE_CURSOR_INFO curs;
CONSOLE_SCREEN_BUFFER_INFO info;
hIN = GetStdHandle(STD_INPUT_HANDLE);
if (hIN == INVALID_HANDLE_VALUE) {
return false;
}
hOUT = GetStdHandle(STD_OUTPUT_HANDLE);
if (hOUT == INVALID_HANDLE_VALUE) {
return false;
}
GetConsoleMode(hIN, &dMode);
SetConsoleMode(hIN, dMode & ~ENABLE_MOUSE_INPUT);
FlushConsoleInputBuffer(hIN);
GetConsoleScreenBufferInfo(hOUT, &info);
wAttrib = info.wAttributes;
GetConsoleCursorInfo(hOUT, &cursorInfo);
curs.dwSize = 1;
curs.bVisible = FALSE;
SetConsoleCursorInfo(hOUT, &curs);
cursor = 0;
buffer.clear();
return true;
}
bool Console::Update(std::string &input) {
INPUT_RECORD *buff;
DWORD count;
DWORD events;
char key;
int newline = -1;
int i;
input.clear();
if (!GetNumberOfConsoleInputEvents(hIN, &events)) {
return true;
}
if (events < 1) {
return true;
}
buff = new INPUT_RECORD[events];
if (!ReadConsoleInput(hIN, buff, events, &count)) {
delete[] buff;
return true;
}
if (count < 1) {
delete[] buff;
return true;
}
FlushConsoleInputBuffer(hIN);
for (i = 0; i < count; i++) {
if (buff[i].EventType != KEY_EVENT) {
continue;
}
if (!buff[i].Event.KeyEvent.bKeyDown) {
continue;
}
key = buff[i].Event.KeyEvent.wVirtualKeyCode;
if (key == VK_RETURN) {
newline = i;
break;
} else if (key == VK_BACK) {
buffer.erase(--cursor, 1);
}
char c = buff[i].Event.KeyEvent.uChar.AsciiChar;
if (c) {
cursor++;
buffer.append(1, c);
}
}
delete[] buff;
Console::Show();
if (newline < 0) {
return true;
}
newline = 0;
if (!buffer.length())
{
std::cout << std::endl;
return true;
}
std::cout << buffer.c_str() << std::endl;
input = buffer;
cursor = 0;
buffer.clear();
return true;
}
void Console::Cleanup() {
SetConsoleMode(hIN, dMode);
SetConsoleCursorInfo(hOUT, &cursorInfo);
CloseHandle(hOUT);
CloseHandle(hIN);
}
void Console::Reset(int num) {
Console::Init();
}
void Console::Show() {
int i;
CONSOLE_SCREEN_BUFFER_INFO binfo;
COORD writeSize = { MAX_EDIT_LINE, 1 };
COORD writePos = { 0, 0 };
SMALL_RECT writeArea = { 0, 0, 0, 0 };
CHAR_INFO line[MAX_EDIT_LINE];
GetConsoleScreenBufferInfo(hOUT, &binfo);
if (binfo.dwCursorPosition.X != 0) {
return;
}
writeArea.Left = 0;
writeArea.Top = binfo.dwCursorPosition.Y;
writeArea.Bottom = binfo.dwCursorPosition.Y;
writeArea.Right = MAX_EDIT_LINE;
for (i = 0; i < MAX_EDIT_LINE; i++) {
if (i < buffer.length())
line[i].Char.AsciiChar = buffer.at(i);
else
line[i].Char.AsciiChar = ' ';
line[i].Attributes = wAttrib;
}
if (buffer.length() > binfo.srWindow.Right) {
WriteConsoleOutput(hOUT, line + (buffer.length() - binfo.srWindow.Right),
writeSize, writePos, &writeArea);
} else {
WriteConsoleOutput(hOUT, line, writeSize, writePos, &writeArea);
}
}
void Console::Hide() {
}
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);
std::cout << string << std::endl;
Console::Show();
}
void Console::Back() {
}

View file

@ -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.c_str());
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.c_str());
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;
}

View file

@ -1,2 +0,0 @@
add_subdirectory(WebRTC)
add_subdirectory(Package)

View file

@ -1,34 +0,0 @@
#
# Install headers
#
install(DIRECTORY ${CMAKE_BINARY_DIR}/include/libwebrtc
DESTINATION include)
#
# Install library
#
install(DIRECTORY ${CMAKE_BINARY_DIR}/lib/
DESTINATION lib)
#
# Create package
#
set(CPACK_PACKAGE_NAME "LibWebRTC")
set(CPACK_PACKAGE_VERSION_MAJOR "${LIBWEBRTC_MAJOR_VERSION}")
set(CPACK_PACKAGE_VERSION_MINOR "${LIBWEBRTC_MINOR_VERSION}")
set(CPACK_PACKAGE_VERSION_PATCH "${LIBWEBRTC_PATCH_VERSION}")
set(CPACK_INSTALL_CMAKE_PROJECTS
"${CPACK_INSTALL_CMAKE_PROJECTS};${CMAKE_BINARY_DIR}/libwebrtc;libwebrtc;ALL;/")
if (WIN32)
set(CPACK_GENERATOR "7Z")
else (WIN32)
set(CPACK_GENERATOR "TGZ")
endif (WIN32)
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
set(CPACK_PACKAGE_FILE_NAME "libwebrtc-${LIBWEBRTC_VERSION}-${TARGET_OS}-${TARGET_CPU}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "libwebrtc")
include(CPack)

View file

@ -1,162 +0,0 @@
include(ExternalProject)
include(LibWebRTCCommand)
include(LibWebRTCConfig)
include(LibWebRTCPrefix)
ExternalProject_Add(
webrtc-src
PREFIX ${CMAKE_BINARY_DIR}
BINARY_DIR ${CMAKE_BINARY_DIR}
SOURCE_DIR ${CMAKE_BINARY_DIR}
DOWNLOAD_DIR ${CMAKE_BINARY_DIR}
DOWNLOAD_COMMAND ${PREFIX_EXECUTE} ${DEPOTTOOLS_GCLIENT_EXECUTABLE} sync --revision ${LIBWEBRTC_WEBRTC_REVISION} -D -n
BUILD_COMMAND ${PREFIX_EXECUTE} ${PYTHON_EXECUTABLE} src/tools/clang/scripts/update.py
INSTALL_COMMAND ""
LOG_DOWNLOAD 1
)
set(_NEXT_DEPENDS webrtc-src)
if (UNIX AND NOT APPLE)
libwebrtc_command(
NAME webrtc-install-sysroot
COMMAND ${CMAKE_BINARY_DIR}/src/build/linux/sysroot_scripts/install-sysroot.py --running-as-hook
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMENT "Installing Linux sysroots"
DEPENDS webrtc-src
)
set(_NEXT_DEPENDS webrtc-install-sysroot)
set(_PLATFORM linux*)
set(_FOLDER linux64)
elseif (APPLE)
set(_PLATFORM darwin)
set(_FOLDER mac)
elseif (WIN32)
libwebrtc_command(
NAME webrtc-vs-toolchain
COMMAND ${PYTHON_EXECUTABLE} src/build/vs_toolchain.py update
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMENT "Updating Visual Studio toolchain"
DEPENDS webrtc-src
)
set(_NEXT_DEPENDS webrtc-vs-toolchain)
set(_PLATFORM win32)
set(_FOLDER win)
set(_SUFFIX .exe)
endif (UNIX AND NOT APPLE)
libwebrtc_command(
NAME webrtc-fetch-gn
COMMAND download_from_google_storage --no_resume --platform=${_PLATFORM} --no_auth --bucket chromium-gn -s src/buildtools/${_FOLDER}/gn${_SUFFIX}.sha1
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMENT "Fetching gn binary"
DEPENDS ${_NEXT_DEPENDS}
)
libwebrtc_command(
NAME webrtc-fetch-clang-format
COMMAND download_from_google_storage --no_resume --platform=${_PLATFORM} --no_auth --bucket chromium-clang-format -s src/buildtools/${_FOLDER}/clang-format${_SUFFIX}.sha1
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMENT "Fetching clang-format binary"
DEPENDS webrtc-fetch-gn
)
#
# Android dependencies
#
set(_NEXT_DEPENDS webrtc-fetch-clang-format)
if (TARGET_OS STREQUAL "android")
libwebrtc_command(
NAME webrtc-android-fetch-play-services
COMMAND ${PYTHON_EXECUTABLE} src/build/android/play_services/update.py download
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMENT "Fetching Google Play Services"
DEPENDS webrtc-fetch-clang-format
)
libwebrtc_command(
NAME webrtc-android-update-lastchange
COMMAND ${PYTHON_EXECUTABLE} src/build/util/lastchange.py -o src/build/util/LASTCHANGE
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMENT "Updating src/build/util/LASTCHANGE"
DEPENDS webrtc-android-fetch-play-services
)
set(_NEXT_DEPENDS webrtc-android-update-lastchange)
foreach(_DEPENDENCY_NAME android-support-test-runner espresso guava hamcrest javax-inject)
string(REPLACE "-" "_" _DEPENDENCY_FOLDER ${_DEPENDENCY_NAME})
libwebrtc_command(
NAME webrtc-android-fetch-${_DEPENDENCY_NAME}
COMMAND ${PYTHON_EXECUTABLE} src/build/android/update_deps/update_third_party_deps.py download -b chromium-${_DEPENDENCY_NAME} -l third_party/${_DEPENDENCY_FOLDER}
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMENT "Fetching Android dependency: ${_DEPENDENCY_NAME}"
DEPENDS ${_NEXT_DEPENDS}
)
set(_NEXT_DEPENDS webrtc-android-fetch-${_DEPENDENCY_NAME})
endforeach(_DEPENDENCY_NAME)
endif (TARGET_OS STREQUAL "android")
#
# Generate build files
#
set(_GEN_ARGS use_gold=false target_cpu=\\"${TARGET_CPU}\\" target_os=\\"${TARGET_OS}\\")
if (NOT CMAKE_BUILD_TYPE MATCHES DEBUG)
set(_GEN_ARGS ${_GEN_ARGS} is_debug=false)
elseif (NOT CMAKE_BUILD_TYPE MATCHES DEBUG)
set(_GEN_ARGS ${_GEN_ARGS} is_debug=true)
endif (NOT CMAKE_BUILD_TYPE MATCHES DEBUG)
if (NOT BUILD_TESTS)
set(_GEN_ARGS ${_GEN_ARGS} rtc_include_tests=false)
endif (NOT BUILD_TESTS)
if (WIN32)
set(_GEN_ARGS ${_GEN_ARGS})
set(_GEN_COMMAND gn gen out/Default --args="${_GEN_ARGS}")
elseif (UNIX)
set(_GEN_ARGS ${_GEN_ARGS})
set(_GEN_COMMAND gn gen out/Default --args='"${_GEN_ARGS}"')
endif (WIN32)
libwebrtc_command(
NAME webrtc-generate
COMMAND ${_GEN_COMMAND}
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/src"
COMMENT "Generating build files"
DEPENDS ${_NEXT_DEPENDS}
)
#
# Run ninja
#
libwebrtc_command(
NAME webrtc-build
COMMAND ninja ${NINJA_ARGS} -C out/Default
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/src"
COMMENT "Building WebRTC"
DEPENDS webrtc-generate
)
#
# Link the library
#
ExternalProject_Add(
libwebrtc
DEPENDS webrtc-build
INSTALL_DIR ${CMAKE_BINARY_DIR}
SOURCE_DIR ${CMAKE_SOURCE_DIR}/Targets/libwebrtc
BINARY_DIR ${CMAKE_BINARY_DIR}/libwebrtc
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}
-DLIBWEBRTC_INCLUDE_DIR:STRING=${CMAKE_BINARY_DIR}/src/webrtc
-DLIBWEBRTC_OUTPUT_DIR:PATH=${CMAKE_BINARY_DIR}/src/out/Default
-DTARGET_OS:STRING=${TARGET_OS}
)

View file

@ -1,63 +0,0 @@
cmake_minimum_required(VERSION 3.5)
project(libwebrtc)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
${CMAKE_SOURCE_DIR}/CMakeModules)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
if (WIN32)
set(LIBWEBRTC_OBJ_EXT obj)
elseif (UNIX AND NOT APPLE)
set(LIBWEBRTC_OBJ_EXT o)
elseif (APPLE)
set(LIBWEBRTC_OBJ_EXT o)
endif ()
file(GLOB_RECURSE LIBWEBRTC_OBJ_FILES
${LIBWEBRTC_OUTPUT_DIR}/obj/*.${LIBWEBRTC_OBJ_EXT})
file(GLOB_RECURSE LIBWEBRTC_OBJ_EXCLUDED
${LIBWEBRTC_OUTPUT_DIR}/obj/third_party/yasm/gen*/*.${LIBWEBRTC_OBJ_EXT}
${LIBWEBRTC_OUTPUT_DIR}/obj/third_party/yasm/re2c/*.${LIBWEBRTC_OBJ_EXT}
${LIBWEBRTC_OUTPUT_DIR}/obj/third_party/yasm/yasm/*.${LIBWEBRTC_OBJ_EXT}
${LIBWEBRTC_OUTPUT_DIR}/obj/third_party/protobuf/protoc/*.${LIBWEBRTC_OBJ_EXT}
${LIBWEBRTC_OUTPUT_DIR}/obj/third_party/protobuf/protobuf_full/*.${LIBWEBRTC_OBJ_EXT}
${LIBWEBRTC_OUTPUT_DIR}/obj/webrtc/examples/*.${LIBWEBRTC_OBJ_EXT}
${LIBWEBRTC_OUTPUT_DIR}/obj/webrtc/tools/*.${LIBWEBRTC_OBJ_EXT}
${LIBWEBRTC_OUTPUT_DIR}/obj/webrtc/modules/video_capture/video_capture/video_capture_external.${LIBWEBRTC_OBJ_EXT}
${LIBWEBRTC_OUTPUT_DIR}/obj/webrtc/modules/video_capture/video_capture/device_info_external.${LIBWEBRTC_OBJ_EXT})
list(LENGTH LIBWEBRTC_OBJ_EXCLUDED LIBWEBRTC_OBJ_EXCLUDED_LEN)
if (${LIBWEBRTC_OBJ_EXCLUDED_LEN} GREATER "0")
list(REMOVE_ITEM LIBWEBRTC_OBJ_FILES ${LIBWEBRTC_OBJ_EXCLUDED})
endif ()
add_library(webrtc STATIC ${LIBWEBRTC_OBJ_FILES})
set_source_files_properties(${LIBWEBRTC_OBJ_FILES} PROPERTIES
EXTERNAL_OBJECT true
GENERATED true)
set_target_properties(webrtc PROPERTIES
LINKER_LANGUAGE C
LIBRARY_OUTPUT_DIRECTORY ${LIBWEBRTC_OUTPUT_DIR})
#
# Install headers
#
install(DIRECTORY ${LIBWEBRTC_INCLUDE_DIR}
DESTINATION "include/libwebrtc"
FILES_MATCHING PATTERN "*.h")
install(FILES ${CMAKE_INSTALL_PREFIX}/libwebrtc.h
DESTINATION "include/libwebrtc")
#
# Install library
#
install(TARGETS webrtc
DESTINATION "lib"
COMPONENT Libraries)

View file

@ -1,20 +0,0 @@
os: Visual Studio 2015
platform:
- x64
configuration: Release
clone_folder: c:\projects\libwebrtc
build:
project: PACKAGE.vcxproj
before_build:
- cd c:\projects\libwebrtc
- git submodule update --init --recursive
- cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=c:\projects\libwebrtc -DNINJA_ARGS="-j 2" .
artifacts:
- path: libwebrtc-0.0.1-rc.4-win32-x64.7z
name: libwebrtc-0.0.1-rc.4-win32-x64.7z

View 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
View 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
View 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()

View 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
View 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
View 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 +0,0 @@
Subproject commit 33e88a4e19aa1eb306fe66431e8b0621773eb66c

View file

@ -1 +0,0 @@
console.log(require('path').relative('.', __dirname));

View file

@ -1,86 +0,0 @@
'use strict';
var os = require('os');
var fs = require('fs-extra');
var exec = require('child_process').exec;
var execSync = require('child_process').execSync;
namespace('build', function () {
task('generate', {async: true}, function () {
var opts = 'use_gold=false is_debug=false rtc_include_tests=false';
var pathSep = (os.platform() === 'win32') ? '\\' : '/';
var envSep = (os.platform() === 'win32') ? ';' : ':';
if (os.platform() === 'win32') {
process.env.DEPOT_TOOLS_WIN_TOOLCHAIN = 0;
process.env.PATH = process.cwd() + '/Dependencies/depot_tools;' + process.env.PATH;
process.env.PATH = process.cwd() + '/Dependencies/depot_tools/python276_bin;' + process.env.PATH;
} else {
process.env.PATH = process.cwd() + '/Dependencies/depot_tools:' + process.env.PATH;
}
console.log('Generating WebRTC build files...' + 'gn gen out/Default --args=\'' + opts + '\'');
process.chdir('src');
exec('gn gen out/Default --args="' + opts + '"', function (error, stdout, stderr) {
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, printStderr: true }, function () {
complete();
});
});
task('merge', ['build:ninja'], {async: true}, function () {
var prefix = os.platform() !== 'win32' ? 'lib' : '';
var suffix = os.platform() === 'win32' ? '.lib' : '.a';
var path = '../lib/' + prefix + 'webrtc' + suffix;
console.log('Merging libraries...');
if (!fs.existsSync('../lib')) {
fs.mkdir('../lib');
}
if (os.platform() === 'win32') {
var output = execSync('python chromium/src/build/vs_toolchain.py get_toolchain_dir', { encoding: 'utf-8' });
var matches = output.match(/vs_path = \"(.*)\"/);
console.log(matches);
process.env.PATH = matches[1] + '\\VC\\bin' + ';' + process.env.PATH;
}
jake.exec('python webrtc/build/merge_libs.py out/Default ' + path, { printStdout: true, printStderr: true }, 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 () {});
});

View file

@ -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 === 'win32') ? '.zip' : '.tar.gz';
return pkg.config.filename
.replace('{VERSION}', version)
.replace('{PLATFORM}', platform)
.replace('{ARCH}', arch)
.replace('{NODEVER}', nodever) + suffix;
}
module.exports = {
getPackageName: getPackageName
};

View file

@ -1,109 +0,0 @@
'use strict';
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;
namespace('fetch', function () {
task('precompiled', ['download'], function () {
});
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 () {
console.log('Done');
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, { printStdout: true, printStderr: true }, function () {
fs.unlinkSync(packageName);
complete();
});
});
task('submodules', {async: true}, function () {
console.log('Updating submodules...');
jake.exec(['git submodule init', 'git submodule update'], {printStdout: true}, function () {
complete();
});
});
task('configure', ['fetch:submodules'], {async: true}, function () {
var pathSep = (os.platform() === 'win32') ? '\\' : '/';
var envSep = (os.platform() === 'win32') ? ';' : ':';
if (os.platform() === 'win32') {
process.env.DEPOT_TOOLS_WIN_TOOLCHAIN = 0;
}
console.log('Configuring gclient to fetch WebRTC code');
process.env.PATH = process.cwd() + pathSep + 'Dependencies' + pathSep + 'depot_tools' + envSep + process.env.PATH;
jake.exec('gclient config --name src ' + WebRTCUrl, { printStdout: true, printStderr: 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, printStderr: 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, printStderr: 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, printStderr: true }, function () {
complete();
});
});
task('links', ['fetch:clang'], {async: true}, function () {
console.log('Creating symbolic links');
jake.exec('python src/setup_links.py', { printStdout: true, printStderr: true }, function () {
complete();
});
});
task('source', [
'links',
'build:default'
], function () {
});
});

View file

@ -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() !== 'win32') {
jake.exec('tar cfz ' + packageName + ' include lib', function () {
complete();
});
}
});

129
libwebrtc/CMakeLists.txt Normal file
View 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 ()

View 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")

View 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 ()

View 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)

View 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)

View 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)

View 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 ()

View file

@ -1,33 +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"
},
"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"
}
}

0
patches/.gitkeep Normal file
View file

78
sync.py Executable file
View 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')