mirror of
https://github.com/UltraCoderRU/libwebrtc.git
synced 2026-01-28 03:15:11 +00:00
(#23): Add sample target, build it and run it
This commit is contained in:
parent
941688e7fc
commit
9f324642f5
7 changed files with 107 additions and 2 deletions
|
|
@ -63,7 +63,7 @@ install:
|
||||||
- git submodule update
|
- git submodule update
|
||||||
- mkdir out
|
- mkdir out
|
||||||
- cd out
|
- cd out
|
||||||
- cmake -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -DTARGET_CPU=$TARGET_CPU ..
|
- cmake -DBUILD_SAMPLE=1 -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -DCMAKE_INSTALL_PREFIX=. -DTARGET_CPU=$TARGET_CPU ..
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- make -j 4 package
|
- make -j 4 package
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,18 @@ ExternalProject_Add(
|
||||||
-DWEBRTC_SOURCE_DIR:PATH=${CMAKE_BINARY_DIR}/webrtc/src/webrtc
|
-DWEBRTC_SOURCE_DIR:PATH=${CMAKE_BINARY_DIR}/webrtc/src/webrtc
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (BUILD_SAMPLE)
|
||||||
|
ExternalProject_Add(
|
||||||
|
sample
|
||||||
|
DEPENDS libwebrtc
|
||||||
|
SOURCE_DIR ${CMAKE_SOURCE_DIR}/sample
|
||||||
|
INSTALL_COMMAND ""
|
||||||
|
|
||||||
|
CMAKE_ARGS
|
||||||
|
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||||
|
)
|
||||||
|
endif (BUILD_SAMPLE)
|
||||||
|
|
||||||
include(Install)
|
include(Install)
|
||||||
include(Package)
|
include(Package)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#
|
#
|
||||||
# Options, flags
|
# Options, flags
|
||||||
option(BUILD_TESTS "Build test binaries" OFF)
|
option(BUILD_TESTS "Build test binaries" OFF)
|
||||||
|
option(BUILD_SAMPLE "Build sample" OFF)
|
||||||
set(DEPOT_TOOLS_PATH "" CACHE STRING "Path to your own depot_tools directory")
|
set(DEPOT_TOOLS_PATH "" CACHE STRING "Path to your own depot_tools directory")
|
||||||
set(NINJA_ARGS "" CACHE STRING "Ninja arguments to pass before compiling WebRTC")
|
set(NINJA_ARGS "" CACHE STRING "Ninja arguments to pass before compiling WebRTC")
|
||||||
set(GN_EXTRA_ARGS "" CACHE STRING "Extra gn gen arguments to pass before generating build files")
|
set(GN_EXTRA_ARGS "" CACHE STRING "Extra gn gen arguments to pass before generating build files")
|
||||||
|
|
|
||||||
|
|
@ -191,6 +191,10 @@ perform cross-compiling.
|
||||||
|
|
||||||
Generate Red Hat package, defaults to OFF, available under Linux only.
|
Generate Red Hat package, defaults to OFF, available under Linux only.
|
||||||
|
|
||||||
|
- **BUILD_SAMPLE**
|
||||||
|
|
||||||
|
Build an executable located inside the `sample` folder.
|
||||||
|
|
||||||
- **DEPOT_TOOLS_PATH**
|
- **DEPOT_TOOLS_PATH**
|
||||||
|
|
||||||
Set this variable to your own `depot_tools` directory. This will prevent
|
Set this variable to your own `depot_tools` directory. This will prevent
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ before_build:
|
||||||
- cd c:\projects\libwebrtc
|
- cd c:\projects\libwebrtc
|
||||||
- if "%platform%"=="x86" set CMAKE_GENERATOR_NAME=Visual Studio 14 2015
|
- if "%platform%"=="x86" set CMAKE_GENERATOR_NAME=Visual Studio 14 2015
|
||||||
- if "%platform%"=="x64" set CMAKE_GENERATOR_NAME=Visual Studio 14 2015 Win64
|
- if "%platform%"=="x64" set CMAKE_GENERATOR_NAME=Visual Studio 14 2015 Win64
|
||||||
- cmake -G "%CMAKE_GENERATOR_NAME%" -DCMAKE_BUILD_TYPE=%configuration% -DCMAKE_INSTALL_PREFIX=c:\projects\libwebrtc .
|
- cmake -G "%CMAKE_GENERATOR_NAME%" -DBUILD_SAMPLE=1 -DCMAKE_BUILD_TYPE=%configuration% -DCMAKE_INSTALL_PREFIX=c:\projects\libwebrtc .
|
||||||
|
|
||||||
artifacts:
|
artifacts:
|
||||||
- path: libwebrtc-0.0.1-rc.4-win-x86.zip
|
- path: libwebrtc-0.0.1-rc.4-win-x86.zip
|
||||||
|
|
|
||||||
21
sample/CMakeLists.txt
Normal file
21
sample/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
cmake_minimum_required(VERSION 3.3)
|
||||||
|
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})
|
||||||
|
|
||||||
|
set(_STAMP_FILE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/check-sample-done)
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${_STAMP_FILE}
|
||||||
|
COMMENT "Run generated sample"
|
||||||
|
COMMAND sample
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E touch ${_STAMP_FILE}
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_custom_target(check-sample ALL DEPENDS ${_STAMP_FILE})
|
||||||
|
add_dependencies(check-sample sample)
|
||||||
67
sample/main.cpp
Normal file
67
sample/main.cpp
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2017 Axel Isouard <axel@isouard.fr>
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <webrtc/api/peerconnectioninterface.h>
|
||||||
|
#include <webrtc/base/ssladapter.h>
|
||||||
|
#include <webrtc/base/thread.h>
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#include <webrtc/base/win32socketinit.h>
|
||||||
|
#include <webrtc/base/win32socketserver.h>
|
||||||
|
#include <Windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
#ifdef WIN32
|
||||||
|
rtc::EnsureWinsockInit();
|
||||||
|
rtc::Win32Thread w32_thread;
|
||||||
|
rtc::ThreadManager::Instance()->SetCurrentThread(&w32_thread);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
rtc::InitializeSSL();
|
||||||
|
rtc::InitRandom(rtc::Time());
|
||||||
|
rtc::ThreadManager::Instance()->WrapCurrentThread();
|
||||||
|
|
||||||
|
rtc::Thread *signalingThread = new rtc::Thread();
|
||||||
|
rtc::Thread *workerThread = new rtc::Thread();
|
||||||
|
|
||||||
|
signalingThread->SetName("signaling_thread", NULL);
|
||||||
|
workerThread->SetName("worker_thread", NULL);
|
||||||
|
|
||||||
|
if (!signalingThread->Start() || !workerThread->Start()) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> pcFactory =
|
||||||
|
webrtc::CreatePeerConnectionFactory(signalingThread,
|
||||||
|
workerThread,
|
||||||
|
NULL, NULL, NULL);
|
||||||
|
|
||||||
|
pcFactory = NULL;
|
||||||
|
|
||||||
|
if (rtc::ThreadManager::Instance()->CurrentThread() == signalingThread) {
|
||||||
|
rtc::ThreadManager::Instance()->SetCurrentThread(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
signalingThread->Stop();
|
||||||
|
workerThread->Stop();
|
||||||
|
|
||||||
|
delete signalingThread;
|
||||||
|
delete workerThread;
|
||||||
|
|
||||||
|
rtc::CleanupSSL();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue