mirror of
https://github.com/UltraCoderRU/libwebrtc.git
synced 2026-01-28 19:25:12 +00:00
Compare commits
6 commits
master
...
v1.0.1-nod
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f91533ae03 | ||
|
|
6a1ea46065 | ||
|
|
6abc1de10a | ||
|
|
b2ed90417a | ||
|
|
8f818d2d0d | ||
|
|
7ecb22ead6 |
63 changed files with 2297 additions and 1064 deletions
10
.gitignore
vendored
10
.gitignore
vendored
|
|
@ -1,4 +1,6 @@
|
|||
.idea
|
||||
cmake-build-*
|
||||
webrtc
|
||||
depot_tools
|
||||
.DS_Store
|
||||
/out/
|
||||
/.idea/
|
||||
*.gclient
|
||||
/node_modules/
|
||||
*.gclient_entries
|
||||
|
|
|
|||
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[submodule "depot_tools"]
|
||||
path = depot_tools
|
||||
url = https://chromium.googlesource.com/chromium/tools/depot_tools.git
|
||||
60
.travis.yml
Normal file
60
.travis.yml
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
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
53
CHANGELOG.md
|
|
@ -1,53 +0,0 @@
|
|||
# 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
|
||||
|
|
@ -1,46 +1,54 @@
|
|||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING INTERNAL FORCE)
|
||||
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
cmake_policy(SET CMP0057 NEW)
|
||||
project(libwebrtc)
|
||||
|
||||
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_MODULE_PATH ${CMAKE_MODULE_PATH}
|
||||
${CMAKE_SOURCE_DIR}/CMakeModules)
|
||||
|
||||
# Allow the use of IN_LIST operand
|
||||
cmake_policy(SET CMP0057 NEW)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
|
||||
|
||||
include(FindLibraries)
|
||||
include(TargetOsAndCpu)
|
||||
|
||||
include(Utils)
|
||||
prependPath("${CMAKE_SOURCE_DIR}/depot_tools")
|
||||
find_package(Git REQUIRED)
|
||||
if (WIN32)
|
||||
set(ENV{DEPOT_TOOLS_WIN_TOOLCHAIN} 0)
|
||||
endif()
|
||||
set(PYTHON_EXECUTABLE ${CMAKE_SOURCE_DIR}/depot_tools/python.bat)
|
||||
else (WIN32)
|
||||
find_package(PythonInterp REQUIRED)
|
||||
endif (WIN32)
|
||||
find_package(DepotTools REQUIRED)
|
||||
|
||||
set(WEBRTC_SOURCE_DIR "${CMAKE_SOURCE_DIR}/webrtc/src")
|
||||
set(WEBRTC_BUILD_DIR "${CMAKE_BINARY_DIR}/webrtc")
|
||||
#
|
||||
# Options
|
||||
#
|
||||
|
||||
include(Version)
|
||||
get_webrtc_version_from_git(WEBRTC_VERSION)
|
||||
message(STATUS "WebRTC version: ${WEBRTC_VERSION}")
|
||||
option(BUILD_SAMPLES "Build samples binaries" OFF)
|
||||
set(NINJA_ARGS "" CACHE STRING "Ninja arguments to pass before compiling WebRTC")
|
||||
|
||||
if (MSVC)
|
||||
# Always build with dynamic runtime on MSVC
|
||||
patch_file(${WEBRTC_SOURCE_DIR}/build/config/win/BUILD.gn ":static_crt" ":dynamic_crt")
|
||||
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")
|
||||
endif ()
|
||||
|
||||
# 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_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})
|
||||
|
||||
include(AddWebRTCTarget)
|
||||
add_webrtc_target(${WEBRTC_SOURCE_DIR} ${WEBRTC_BUILD_DIR})
|
||||
set(LIBWEBRTC_BUILD_ROOT ${CMAKE_SOURCE_DIR}/src/out/Default)
|
||||
add_subdirectory(Targets)
|
||||
|
||||
add_subdirectory(libwebrtc)
|
||||
if (BUILD_SAMPLES)
|
||||
add_subdirectory(Samples)
|
||||
endif (BUILD_SAMPLES)
|
||||
|
|
|
|||
14
CMakeModules/FindDepotTools.cmake
Normal file
14
CMakeModules/FindDepotTools.cmake
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
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.")
|
||||
60
CMakeModules/FindLibWebRTC.cmake
Normal file
60
CMakeModules/FindLibWebRTC.cmake
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
# - 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)
|
||||
22
CMakeModules/LibWebRTCCommand.cmake
Normal file
22
CMakeModules/LibWebRTCCommand.cmake
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
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()
|
||||
25
CMakeModules/LibWebRTCConfig.cmake
Normal file
25
CMakeModules/LibWebRTCConfig.cmake
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#
|
||||
# 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")
|
||||
49
CMakeModules/LibWebRTCPrefix.cmake
Normal file
49
CMakeModules/LibWebRTCPrefix.cmake
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
#
|
||||
# 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}
|
||||
")
|
||||
46
CMakeModules/LibWebRTCSubsystem.cmake
Normal file
46
CMakeModules/LibWebRTCSubsystem.cmake
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
#
|
||||
# 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)
|
||||
32
CMakeModules/LibWebRTCVersion.cmake
Normal file
32
CMakeModules/LibWebRTCVersion.cmake
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#
|
||||
# Versioning
|
||||
#
|
||||
|
||||
set(LIBWEBRTC_MAJOR_VERSION 1)
|
||||
set(LIBWEBRTC_MINOR_VERSION 0)
|
||||
set(LIBWEBRTC_PATCH_VERSION 1)
|
||||
set(LIBWEBRTC_BUILD_VERSION nodewrtc)
|
||||
|
||||
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_ */
|
||||
")
|
||||
|
||||
4
Jakefile
Normal file
4
Jakefile
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
'use strict';
|
||||
|
||||
desc('Default task');
|
||||
task('default', ['fetch:precompiled'], function () {});
|
||||
206
LICENSE
206
LICENSE
|
|
@ -1,201 +1,13 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
Copyright 2016 Axel Isouard
|
||||
|
||||
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
|
||||
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.
|
||||
347
README.md
347
README.md
|
|
@ -1,119 +1,6 @@
|
|||
# libwebrtc [![License][license-img]][license-href]
|
||||
# libwebrtc [![License][license-img]][license-href] [![Build Status][travis-img]][travis-href] [![Build Status][appveyor-img]][appveyor-href]
|
||||
|
||||
This repository contains a collection of CMake scripts to help you embed
|
||||
Google's native WebRTC implementation inside your project as simple as this:
|
||||
|
||||
```cmake
|
||||
cmake_minimum_required(VERSION 3.9)
|
||||
project(sample)
|
||||
|
||||
find_package(LibWebRTC REQUIRED)
|
||||
include(${LIBWEBRTC_USE_FILE})
|
||||
|
||||
set(SOURCE_FILES main.cpp)
|
||||
add_executable(sample ${SOURCE_FILES})
|
||||
target_link_libraries(sample ${LIBWEBRTC_LIBRARIES})
|
||||
```
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- CMake 3.9 or later
|
||||
- Python 2.7 (optional for Windows since it will use the interpreter located
|
||||
inside the `depot_tools` installation)
|
||||
|
||||
### Debian & Ubuntu
|
||||
|
||||
- Required development packages:
|
||||
|
||||
```
|
||||
# apt-get install build-essential libglib2.0-dev libgtk2.0-dev libxtst-dev \
|
||||
libxss-dev libpci-dev libdbus-1-dev libgconf2-dev \
|
||||
libgnome-keyring-dev libnss3-dev libasound2-dev libpulse-dev \
|
||||
libudev-dev
|
||||
```
|
||||
|
||||
- GCC & G++ 4.8 or later, for C++11 support
|
||||
|
||||
### macOS
|
||||
|
||||
- OS X 10.11 or later
|
||||
- Xcode 7.3.1 or later
|
||||
|
||||
### Windows
|
||||
|
||||
- Windows 7 x64 or later
|
||||
- Visual Studio 2015/2017
|
||||
|
||||
Make sure that you install the following components:
|
||||
|
||||
- Visual C++, which will select three sub-categories including MFC
|
||||
- Universal Windows Apps Development Tools
|
||||
- Tools (1.4.1) and Windows 10 SDK (**10.0.14393**)
|
||||
|
||||
- [Windows 10 SDK][w10sdk] with **Debugging Tools for Windows** or
|
||||
[Windows Driver Kit 10][wdk10] installed in the same Windows 10 SDK
|
||||
installation directory.
|
||||
|
||||
## Getting sources
|
||||
Clone the repository and run script to fetch WebRTC sources.
|
||||
You can pass WebRTC version (branch) to script to fetch specific version.
|
||||
|
||||
```
|
||||
git clone https://github.com/UltraCoderRU/libwebrtc.git
|
||||
cd libwebrtc
|
||||
python3 sync.py [WEBRTC_VERSION]
|
||||
```
|
||||
|
||||
## Compiling
|
||||
|
||||
Create an output directory, browse inside it, then run CMake to configure project.
|
||||
|
||||
```
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -G Ninja -DCMAKE_BUILD_TYPE=<Debug/Release> -DCMAKE_INSTALL_PREFIX=<install_path> ..
|
||||
```
|
||||
|
||||
After configuration build library using standard CMake commands.
|
||||
|
||||
```
|
||||
cmake --build .
|
||||
cmake --install .
|
||||
```
|
||||
|
||||
The library will be located inside the `lib` subdirectory of the `<install_path>`.
|
||||
The `include` subdirectory will contain the header files.
|
||||
CMake scripts will be placed inside the `lib/cmake/LibWebRTC` subdirectory.
|
||||
|
||||
## Using WebRTC in your project
|
||||
|
||||
To import LibWebRTC into your CMake project use `find_package`:
|
||||
```cmake
|
||||
find_package(LibWebRTC REQUIRED)
|
||||
include(${LIBWEBRTC_USE_FILE})
|
||||
|
||||
target_link_libraries(my-app ${LIBWEBRTC_LIBRARIES})
|
||||
```
|
||||
|
||||
You should add library installation path to `CMAKE_INSTALL_PREFIX` variable
|
||||
while configuring your project:
|
||||
```
|
||||
cmake -DCMAKE_PREFIX_PATH=<install_path> ...
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
The library will be compiled and usable on the same host's platform and
|
||||
architecture. Here are some CMake flags which could be useful if you need to
|
||||
perform cross-compiling.
|
||||
|
||||
- **GN_EXTRA_ARGS**
|
||||
|
||||
Add extra arguments to the `gn gen --args` parameter.
|
||||
|
||||
- **NINJA_ARGS**
|
||||
|
||||
Arguments to pass while executing the `ninja` command.
|
||||
> CMake script for retrieving, building and linking Google's WebRTC into a single static library.
|
||||
|
||||
## Status
|
||||
|
||||
|
|
@ -122,62 +9,206 @@ supported platforms and architectures.
|
|||
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center"></td>
|
||||
<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">amd64</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>
|
||||
<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>
|
||||
<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>
|
||||
|
||||
## Prerequisites
|
||||
|
||||
## Acknowledgements
|
||||
- CMake 3.5 or later,
|
||||
- Python 2.7 (optional for Windows)
|
||||
|
||||
Many thanks to Dr. Alex Gouaillard for being an excellent mentor for this
|
||||
project.
|
||||
### Debian & Ubuntu
|
||||
|
||||
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.
|
||||
Install the required development packages
|
||||
|
||||
```
|
||||
# apt-get install build-essential libglib2.0-dev libgtk2.0-dev libxtst-dev \
|
||||
libxss-dev libpci-dev libdbus-1-dev libgconf2-dev \
|
||||
libgnome-keyring-dev libnss3-dev libasound2-dev libpulse-dev \
|
||||
libudev-dev
|
||||
```
|
||||
|
||||
### macOS
|
||||
|
||||
- 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]
|
||||
|
||||
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**)
|
||||
|
||||
## Getting Started
|
||||
|
||||
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.
|
||||
|
||||
```
|
||||
$ git clone https://github.com/aisouard/libwebrtc.git
|
||||
$ cd libwebrtc
|
||||
$ git submodule init
|
||||
$ git submodule update
|
||||
$ mkdir out
|
||||
$ cd out
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
```
|
||||
> cmake -G "Visual Studio 14 2015 Win64" ..
|
||||
```
|
||||
|
||||
Unix users will just have to run `$ cmake ..` to generate the Makefiles, then
|
||||
run the following commands.
|
||||
|
||||
```
|
||||
$ make
|
||||
$ make package
|
||||
# make install
|
||||
```
|
||||
|
||||
The library will be located inside the `lib` folder of the current output
|
||||
directory. The `include` folder will contain the header files.
|
||||
|
||||
## 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)
|
||||
|
||||
find_package(LibWebRTC REQUIRED)
|
||||
|
||||
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})
|
||||
```
|
||||
|
||||
## Advanced Usage
|
||||
|
||||
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**
|
||||
|
||||
Build `PeerConnection` sample, source code located inside the
|
||||
Samples/PeerConnection directory.
|
||||
|
||||
- **BUILD_TESTS**
|
||||
|
||||
Build WebRTC tests. (not supported yet)
|
||||
|
||||
- **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:
|
||||
|
||||
`cmake -DNINJA_ARGS="-j 4" ..`
|
||||
|
||||
- **TARGET_OS**
|
||||
|
||||
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:
|
||||
|
||||
- `android`
|
||||
- `chromeos`
|
||||
- `ios`
|
||||
- `linux`
|
||||
- `mac`
|
||||
- `nacl`
|
||||
- `win`
|
||||
|
||||
- **TARGET_CPU**
|
||||
|
||||
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:
|
||||
|
||||
- `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]
|
||||
|
||||
[license-img]:https://img.shields.io/badge/License-Apache%202.0-blue.svg
|
||||
[license-href]:https://opensource.org/licenses/Apache-2.0
|
||||
[w10sdk]:https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk
|
||||
[wdk10]:https://go.microsoft.com/fwlink/p/?LinkId=526733
|
||||
[webrtc-dr-alex-cmake]:http://webrtcbydralex.com/index.php/2015/07/22/automating-libwebrtc-build-with-cmake
|
||||
[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
|
||||
1
Samples/CMakeLists.txt
Normal file
1
Samples/CMakeLists.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
add_subdirectory(PeerConnection)
|
||||
75
Samples/PeerConnection/CMakeLists.txt
Normal file
75
Samples/PeerConnection/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
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)
|
||||
20
Samples/PeerConnection/Console.h
Normal file
20
Samples/PeerConnection/Console.h
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
//
|
||||
// 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
|
||||
87
Samples/PeerConnection/Core.cpp
Normal file
87
Samples/PeerConnection/Core.cpp
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
28
Samples/PeerConnection/Core.h
Normal file
28
Samples/PeerConnection/Core.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
//
|
||||
// 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
|
||||
23
Samples/PeerConnection/CreateSessionObserver.cpp
Normal file
23
Samples/PeerConnection/CreateSessionObserver.cpp
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
//
|
||||
// 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());
|
||||
}
|
||||
26
Samples/PeerConnection/CreateSessionObserver.h
Normal file
26
Samples/PeerConnection/CreateSessionObserver.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
//
|
||||
// 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
|
||||
31
Samples/PeerConnection/DataChannelObserver.cpp
Normal file
31
Samples/PeerConnection/DataChannelObserver.cpp
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
//
|
||||
// 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) {
|
||||
}
|
||||
22
Samples/PeerConnection/DataChannelObserver.h
Normal file
22
Samples/PeerConnection/DataChannelObserver.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
//
|
||||
// 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
|
||||
27
Samples/PeerConnection/IPeer.h
Normal file
27
Samples/PeerConnection/IPeer.h
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
//
|
||||
// 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
|
||||
115
Samples/PeerConnection/Peer.cpp
Normal file
115
Samples/PeerConnection/Peer.cpp
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
//
|
||||
// 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);
|
||||
}
|
||||
41
Samples/PeerConnection/Peer.h
Normal file
41
Samples/PeerConnection/Peer.h
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
//
|
||||
// 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
|
||||
92
Samples/PeerConnection/PeerConnectionObserver.cpp
Normal file
92
Samples/PeerConnection/PeerConnectionObserver.cpp
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
//
|
||||
// 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) {
|
||||
}
|
||||
44
Samples/PeerConnection/PeerConnectionObserver.h
Normal file
44
Samples/PeerConnection/PeerConnectionObserver.h
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
//
|
||||
// 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
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
//
|
||||
// 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());
|
||||
}
|
||||
27
Samples/PeerConnection/SetLocalSessionDescriptionObserver.h
Normal file
27
Samples/PeerConnection/SetLocalSessionDescriptionObserver.h
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
//
|
||||
// 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
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
//
|
||||
// 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());
|
||||
}
|
||||
28
Samples/PeerConnection/SetRemoteSessionDescriptionObserver.h
Normal file
28
Samples/PeerConnection/SetRemoteSessionDescriptionObserver.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
//
|
||||
// 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
|
||||
153
Samples/PeerConnection/UnixConsole.cpp
Normal file
153
Samples/PeerConnection/UnixConsole.cpp
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
//
|
||||
// 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);
|
||||
}
|
||||
195
Samples/PeerConnection/Win32Console.cpp
Normal file
195
Samples/PeerConnection/Win32Console.cpp
Normal file
|
|
@ -0,0 +1,195 @@
|
|||
#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() {
|
||||
}
|
||||
134
Samples/PeerConnection/main.cpp
Normal file
134
Samples/PeerConnection/main.cpp
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
#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;
|
||||
}
|
||||
2
Targets/CMakeLists.txt
Normal file
2
Targets/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
add_subdirectory(WebRTC)
|
||||
add_subdirectory(Package)
|
||||
34
Targets/Package/CMakeLists.txt
Normal file
34
Targets/Package/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#
|
||||
# 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)
|
||||
158
Targets/WebRTC/CMakeLists.txt
Normal file
158
Targets/WebRTC/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
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 rtc_include_tests=true 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 (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}
|
||||
)
|
||||
70
Targets/libwebrtc/CMakeLists.txt
Normal file
70
Targets/libwebrtc/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
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})
|
||||
|
||||
# capture the assembly compile outputs of libvpx_yasm.lib and other third_party libs
|
||||
if (WIN32)
|
||||
file(GLOB_RECURSE LIBWEBRTC_O_FILES
|
||||
${LIBWEBRTC_OUTPUT_DIR}/obj/*.o)
|
||||
list(APPEND LIBWEBRTC_OBJ_FILES ${LIBWEBRTC_O_FILES})
|
||||
endif()
|
||||
|
||||
list(FILTER LIBWEBRTC_OBJ_FILES EXCLUDE REGEX test)
|
||||
list(FILTER LIBWEBRTC_OBJ_FILES EXCLUDE REGEX unittests)
|
||||
list(FILTER LIBWEBRTC_OBJ_FILES EXCLUDE REGEX third_party/yasm/gen)
|
||||
list(FILTER LIBWEBRTC_OBJ_FILES EXCLUDE REGEX third_party/yasm/re2c)
|
||||
list(FILTER LIBWEBRTC_OBJ_FILES EXCLUDE REGEX third_party/yasm/re2c)
|
||||
list(FILTER LIBWEBRTC_OBJ_FILES EXCLUDE REGEX third_party/protobuf/protoc)
|
||||
list(FILTER LIBWEBRTC_OBJ_FILES EXCLUDE REGEX third_party/protobuf/protobuf_full)
|
||||
list(FILTER LIBWEBRTC_OBJ_FILES EXCLUDE REGEX webrtc/examples)
|
||||
list(FILTER LIBWEBRTC_OBJ_FILES EXCLUDE REGEX webrtc/tools)
|
||||
list(FILTER LIBWEBRTC_OBJ_FILES EXCLUDE REGEX webrtc/modules/video_capture/video_capture/video_capture_external)
|
||||
list(FILTER LIBWEBRTC_OBJ_FILES EXCLUDE REGEX webrtc/modules/video_capture/video_capture/device_info_external)
|
||||
list(FILTER LIBWEBRTC_OBJ_FILES EXCLUDE REGEX webrtc/modules/video_capture/video_capture/device_info_external)
|
||||
|
||||
#add fakeaudio device
|
||||
file(GLOB_RECURSE LIBWEBRTC_TEST_COMMON_FILES
|
||||
"${LIBWEBRTC_OUTPUT_DIR}/obj/webrtc/test/test_common/*.${LIBWEBRTC_OBJ_EXT}"
|
||||
"${LIBWEBRTC_OUTPUT_DIR}/obj/testing/gtest/gtest*.${LIBWEBRTC_OBJ_EXT}")
|
||||
list(APPEND LIBWEBRTC_OBJ_FILES ${LIBWEBRTC_TEST_COMMON_FILES})
|
||||
|
||||
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}
|
||||
PREFIX lib)
|
||||
|
||||
#
|
||||
# Install headers
|
||||
#
|
||||
install(DIRECTORY ${LIBWEBRTC_INCLUDE_DIR}
|
||||
DESTINATION "include"
|
||||
FILES_MATCHING PATTERN "*.h")
|
||||
|
||||
#
|
||||
# Install library
|
||||
#
|
||||
install(TARGETS webrtc
|
||||
DESTINATION "lib"
|
||||
COMPONENT Libraries)
|
||||
20
appveyor.yml
Normal file
20
appveyor.yml
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
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
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
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()
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
#
|
||||
# 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 ()
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
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()
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
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})")
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
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()
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
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
depot_tools
Submodule
1
depot_tools
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 33e88a4e19aa1eb306fe66431e8b0621773eb66c
|
||||
1
index.js
Normal file
1
index.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
console.log(require('path').relative('.', __dirname));
|
||||
86
jakelib/build.jake
Normal file
86
jakelib/build.jake
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
'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 () {});
|
||||
});
|
||||
22
jakelib/common.js
Normal file
22
jakelib/common.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
'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
|
||||
};
|
||||
109
jakelib/fetch.jake
Normal file
109
jakelib/fetch.jake
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
'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 () {
|
||||
});
|
||||
});
|
||||
15
jakelib/package.jake
Normal file
15
jakelib/package.jake
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
'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();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
@ -1,129 +0,0 @@
|
|||
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 ()
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
# - 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")
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
# 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 ()
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
#----------------------------------------------------------------
|
||||
# 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)
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
#----------------------------------------------------------------
|
||||
# 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)
|
||||
|
|
@ -1,83 +0,0 @@
|
|||
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)
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
#
|
||||
# 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 ()
|
||||
33
package.json
Normal file
33
package.json
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
78
sync.py
78
sync.py
|
|
@ -1,78 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def execute(command: str):
|
||||
subprocess.run(command, shell=True, check=True)
|
||||
|
||||
|
||||
def get_output(command: str):
|
||||
return subprocess.run(command, capture_output=True, shell=True, check=True).stdout.decode()
|
||||
|
||||
|
||||
# To determine last stable WebRTC revision,
|
||||
# see https://chromiumdash.appspot.com/branches
|
||||
# and https://chromiumdash.appspot.com/schedule
|
||||
WEBRTC_REVISION = 4692
|
||||
|
||||
if len(sys.argv) == 2:
|
||||
WEBRTC_REVISION = sys.argv[1]
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent
|
||||
DEPOT_TOOLS_DIR = REPO_ROOT / 'depot_tools'
|
||||
WEBRTC_DIR = REPO_ROOT / 'webrtc'
|
||||
SRC_DIR = WEBRTC_DIR / 'src'
|
||||
|
||||
os.environ['PATH'] = '{}{}{}'.format(DEPOT_TOOLS_DIR, os.pathsep, os.environ['PATH'])
|
||||
if sys.platform == 'win32':
|
||||
os.environ['DEPOT_TOOLS_WIN_TOOLCHAIN'] = '0'
|
||||
|
||||
os.chdir(REPO_ROOT)
|
||||
if not os.path.isdir(DEPOT_TOOLS_DIR):
|
||||
print('Cloning Depot Tools...')
|
||||
execute('git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git')
|
||||
os.chdir(DEPOT_TOOLS_DIR)
|
||||
|
||||
if sys.platform == 'win32':
|
||||
execute('gclient --version')
|
||||
execute('where python')
|
||||
|
||||
execute('python update_depot_tools_toggle.py --disable')
|
||||
else:
|
||||
print('Updating Depot Tools to the latest revision...')
|
||||
os.chdir(DEPOT_TOOLS_DIR)
|
||||
execute('git checkout -q -f main')
|
||||
execute('git pull -q')
|
||||
|
||||
if not os.path.isdir(WEBRTC_DIR):
|
||||
print('Cloning WebRTC...')
|
||||
os.mkdir(WEBRTC_DIR)
|
||||
os.chdir(WEBRTC_DIR)
|
||||
execute('fetch --nohooks webrtc')
|
||||
os.chdir(SRC_DIR)
|
||||
execute('gclient sync --with_branch_heads --nohooks')
|
||||
else:
|
||||
print('Updating WebRTC branches info...')
|
||||
os.chdir(SRC_DIR)
|
||||
execute('gclient sync --with_branch_heads --nohooks')
|
||||
|
||||
# Latest Depot Tools versions are not compatible
|
||||
# with old WebRTC versions, so we peek revision
|
||||
# from around the same time as the WebRTC and
|
||||
# forbid gclient to auto-update Depot Tools.
|
||||
os.chdir(SRC_DIR)
|
||||
LAST_WEBRTC_COMMIT_DATE = get_output('git log -n 1 --pretty=format:%ci branch-heads/{}'.format(WEBRTC_REVISION)).strip()
|
||||
os.chdir(DEPOT_TOOLS_DIR)
|
||||
DEPOT_TOOLS_COMPATIBLE_REVISION = get_output('git rev-list -n 1 --before="{}" main'.format(LAST_WEBRTC_COMMIT_DATE)).strip()
|
||||
print('Updating Depot Tools to a compatible revision {}...'.format(DEPOT_TOOLS_COMPATIBLE_REVISION))
|
||||
execute('git checkout -f {}'.format(DEPOT_TOOLS_COMPATIBLE_REVISION))
|
||||
|
||||
print('Updating WebRTC to version {}...'.format(WEBRTC_REVISION))
|
||||
os.chdir(SRC_DIR)
|
||||
execute('git clean -ffd')
|
||||
execute('git checkout -q -B {} branch-heads/{}'.format(WEBRTC_REVISION, WEBRTC_REVISION))
|
||||
execute('gclient sync --force -D --reset')
|
||||
Loading…
Add table
Reference in a new issue