Move to WebRTC branch-heads/54 branch
- Support GN build - Tested on Windows, Mac OSX and Linux (Ubuntu)master
parent
101fa25cfd
commit
f55d1a0866
|
@ -4,7 +4,12 @@
|
|||
#
|
||||
# ============================================================================
|
||||
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
if (APPLE)
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
else (APPLE)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
endif (APPLE)
|
||||
|
||||
project(peerconnect)
|
||||
|
||||
|
||||
|
@ -133,6 +138,56 @@ if (PC_WITH_STATIC)
|
|||
target_compile_definitions(peerconnect PRIVATE ${_PC_INTERNAL_DEFINES})
|
||||
target_include_directories(peerconnect PRIVATE ${_PC_INTERNAL_INCLUDE_DIR} )
|
||||
|
||||
if (MSVC)
|
||||
add_custom_command(TARGET peerconnect PRE_BUILD
|
||||
COMMAND echo Building WebRTC library
|
||||
COMMAND set PATH=${DEPOT_TOOLS_DIR};%PATH%
|
||||
COMMAND cmd.exe /C gn gen ${WEBRTC_OUT_DIR} --args=\"is_debug=false is_component_build=false target_cpu=\\\"x86\\\"\"
|
||||
COMMAND cmd.exe /C gn gen ${WEBRTC_OUT_DIR_DEBUG} --args=\"is_debug=true is_component_build=false target_cpu=\\\"x86\\\"\"
|
||||
COMMAND ninja -C ${WEBRTC_OUT_DIR}
|
||||
COMMAND ninja -C ${WEBRTC_OUT_DIR_DEBUG}
|
||||
WORKING_DIRECTORY "${WEBRTC_ROOT_DIR}"
|
||||
COMMENT "Building WebRTC library (Once)"
|
||||
)
|
||||
elseif (APPLE)
|
||||
string(TOUPPER "${CMAKE_BUILD_TYPE}" _CMAKE_BUILD_TYPE)
|
||||
if (_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
|
||||
add_custom_command(TARGET peerconnect PRE_LINK
|
||||
COMMAND ${CMAKE_COMMAND} -E env \"PATH=${DEPOT_TOOLS_DIR}:$ENV{PATH}\" gn gen ${WEBRTC_OUT_DIR_DEBUG} --args=\"is_debug=true is_component_build=false\"
|
||||
COMMAND ${CMAKE_COMMAND} -E env \"PATH=${DEPOT_TOOLS_DIR}:$ENV{PATH}\" ninja -C ${WEBRTC_OUT_DIR_DEBUG}
|
||||
WORKING_DIRECTORY "${WEBRTC_ROOT_DIR}"
|
||||
COMMENT "Building WebRTC library (Once)"
|
||||
)
|
||||
else()
|
||||
add_custom_command(TARGET peerconnect PRE_LINK
|
||||
COMMAND ${CMAKE_COMMAND} -E env \"PATH=${DEPOT_TOOLS_DIR}:$ENV{PATH}\" gn gen ${WEBRTC_OUT_DIR} --args=\"is_debug=false is_component_build=false\"
|
||||
COMMAND ${CMAKE_COMMAND} -E env \"PATH=${DEPOT_TOOLS_DIR}:$ENV{PATH}\" ninja -C ${WEBRTC_OUT_DIR}
|
||||
WORKING_DIRECTORY "${WEBRTC_ROOT_DIR}"
|
||||
COMMENT "Building WebRTC library (Once)"
|
||||
)
|
||||
endif()
|
||||
elseif(UNIX)
|
||||
string(TOUPPER "${CMAKE_BUILD_TYPE}" _CMAKE_BUILD_TYPE)
|
||||
if (_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
|
||||
add_custom_command(TARGET peerconnect PRE_LINK
|
||||
COMMAND export \"PATH=${DEPOT_TOOLS_DIR}:$ENV{PATH}\"
|
||||
COMMAND gn gen ${WEBRTC_OUT_DIR_DEBUG} --args=\"is_debug=true is_component_build=false\"
|
||||
COMMAND ninja -C ${WEBRTC_OUT_DIR_DEBUG}
|
||||
WORKING_DIRECTORY "${WEBRTC_ROOT_DIR}"
|
||||
COMMENT "Building WebRTC library (Once)"
|
||||
)
|
||||
else()
|
||||
add_custom_command(TARGET peerconnect PRE_LINK
|
||||
COMMAND export \"PATH=${DEPOT_TOOLS_DIR}:$ENV{PATH}\"
|
||||
COMMAND gn gen ${WEBRTC_OUT_DIR} --args=\"is_debug=false is_component_build=false\"
|
||||
COMMAND ninja -C ${WEBRTC_OUT_DIR}
|
||||
WORKING_DIRECTORY "${WEBRTC_ROOT_DIR}"
|
||||
COMMENT "Building WebRTC library (Once)"
|
||||
)
|
||||
endif()
|
||||
|
||||
endif(MSVC)
|
||||
|
||||
if (WIN32)
|
||||
# Windows uses the same .lib ending for static libraries and shared
|
||||
# library linker files, so rename the static library.
|
||||
|
@ -142,16 +197,26 @@ if (PC_WITH_STATIC)
|
|||
if (MSVC)
|
||||
MERGE_STATIC_LIBRARIES( peerconnect
|
||||
"${WEBRTC_LIBRARIES_INTERNAL_RELEASE}"
|
||||
"${WEBRTC_LIBRARIES_INTERNAL_DEBUG}")
|
||||
"${WEBRTC_LIBRARIES_INTERNAL_DEBUG}"
|
||||
"${WEBRTC_OBJECTS_INTERNAL_RELEASE}"
|
||||
"${WEBRTC_OBJECTS_INTERNAL_DEBUG}"
|
||||
)
|
||||
elseif (APPLE)
|
||||
MERGE_STATIC_LIBRARIES(peerconnect
|
||||
"${WEBRTC_LIBRARIES_INTERNAL_RELEASE}"
|
||||
"${WEBRTC_LIBRARIES_INTERNAL_DEBUG}")
|
||||
"${WEBRTC_LIBRARIES_INTERNAL_DEBUG}"
|
||||
"${WEBRTC_OBJECTS_INTERNAL_RELEASE}"
|
||||
"${WEBRTC_OBJECTS_INTERNAL_DEBUG}"
|
||||
)
|
||||
elseif (UNIX)
|
||||
MERGE_STATIC_LIBRARIES(peerconnect
|
||||
"${WEBRTC_LIBRARIES_INTERNAL_RELEASE}"
|
||||
"${WEBRTC_LIBRARIES_INTERNAL_DEBUG}")
|
||||
"${WEBRTC_LIBRARIES_INTERNAL_DEBUG}"
|
||||
"${WEBRTC_OBJECTS_INTERNAL_RELEASE}"
|
||||
"${WEBRTC_OBJECTS_INTERNAL_DEBUG}"
|
||||
)
|
||||
endif(MSVC)
|
||||
|
||||
endif()
|
||||
|
||||
if (PC_WITH_SHARED)
|
||||
|
@ -159,9 +224,8 @@ if (PC_WITH_SHARED)
|
|||
|
||||
target_compile_definitions(peerconnect_shared PRIVATE ${_PC_INTERNAL_DEFINES})
|
||||
target_include_directories(peerconnect_shared PRIVATE ${_PC_INTERNAL_INCLUDE_DIR} )
|
||||
|
||||
set_target_properties(peerconnect_shared PROPERTIES OUTPUT_NAME peerconnect)
|
||||
target_link_libraries(peerconnect_shared ${_PC_INTERNAL_LIBRARIES})
|
||||
target_link_libraries(peerconnect_shared ${_PC_INTERNAL_LIBRARIES} ${WEBRTC_OBJECTS_INTERNAL})
|
||||
|
||||
if (WIN32)
|
||||
# # Compile as DLL (export function declarations)
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,4 +1,4 @@
|
|||
macro (MERGE_STATIC_LIBRARIES TARGET_LIB LIBRARIES LIBRARIES_DEBUG)
|
||||
macro (MERGE_STATIC_LIBRARIES TARGET_LIB LIBRARIES LIBRARIES_DEBUG OBJECTS OBJECTS_DEBUG)
|
||||
|
||||
if("${CMAKE_CFG_INTDIR}" STREQUAL ".")
|
||||
set(multiconfig FALSE)
|
||||
|
@ -6,10 +6,6 @@ macro (MERGE_STATIC_LIBRARIES TARGET_LIB LIBRARIES LIBRARIES_DEBUG)
|
|||
set(multiconfig TRUE)
|
||||
endif()
|
||||
|
||||
if ("${LIBRARIES_DEBUG}" STREQUAL "")
|
||||
set(LIBRARIES_DEBUG ${LIBRARIES})
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
|
||||
# On Windows you must add aditional formatting to the LIBRARIES variable as a single string for the windows libtool
|
||||
|
@ -20,13 +16,18 @@ macro (MERGE_STATIC_LIBRARIES TARGET_LIB LIBRARIES LIBRARIES_DEBUG)
|
|||
set (LIBS \"${LIBS}\")
|
||||
set (LIBS_DEBUG \"${LIBS_DEBUG}\")
|
||||
|
||||
string (REPLACE ";" "\" \"" OBJS "${OBJECTS}")
|
||||
string (REPLACE ";" "\" \"" OBJS_DEBUG "${OBJECTS_DEBUG}")
|
||||
set (OBJS \"${OBJS}\")
|
||||
set (OBJS_DEBUG \"${OBJS_DEBUG}\")
|
||||
|
||||
foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES})
|
||||
string(TOUPPER "${CONFIG_TYPE}" _CONFIG_TYPE)
|
||||
string(TOUPPER "STATIC_LIBRARY_FLAGS_${CONFIG_TYPE}" PROPNAME)
|
||||
if ("${_CONFIG_TYPE}" STREQUAL "DEBUG")
|
||||
set_property (TARGET ${TARGET_LIB} APPEND PROPERTY ${PROPNAME} "${LIBS_DEBUG}")
|
||||
set_property (TARGET ${TARGET_LIB} APPEND PROPERTY ${PROPNAME} "${LIBS_DEBUG} ${OBJS_DEBUG}")
|
||||
else()
|
||||
set_property (TARGET ${TARGET_LIB} APPEND PROPERTY ${PROPNAME} "${LIBS}")
|
||||
set_property (TARGET ${TARGET_LIB} APPEND PROPERTY ${PROPNAME} "${LIBS} ${OBJS}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
|
@ -43,8 +44,10 @@ macro (MERGE_STATIC_LIBRARIES TARGET_LIB LIBRARIES LIBRARIES_DEBUG)
|
|||
string(TOUPPER "${CMAKE_BUILD_TYPE}" _CMAKE_BUILD_TYPE)
|
||||
if (_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
|
||||
set(_LIBRARIES ${LIBRARIES_DEBUG})
|
||||
set(_OBJECTS ${OBJECTS_DEBUG})
|
||||
else()
|
||||
set(_LIBRARIES ${LIBRARIES})
|
||||
set(_OBJECTS ${OBJECTS})
|
||||
endif()
|
||||
|
||||
add_custom_command(TARGET ${TARGET_LIB} POST_BUILD
|
||||
|
@ -52,7 +55,7 @@ macro (MERGE_STATIC_LIBRARIES TARGET_LIB LIBRARIES LIBRARIES_DEBUG)
|
|||
"${target_temp_file}"
|
||||
COMMAND rm "${outfile}"
|
||||
COMMAND /usr/bin/libtool -no_warning_for_no_symbols -static -o "${outfile}"
|
||||
${_LIBRARIES} "${target_temp_file}"
|
||||
"${target_temp_file}" ${_LIBRARIES} ${_OBJECTS}
|
||||
COMMAND rm "${target_temp_file}"
|
||||
)
|
||||
elseif (UNIX)
|
||||
|
@ -65,18 +68,24 @@ macro (MERGE_STATIC_LIBRARIES TARGET_LIB LIBRARIES LIBRARIES_DEBUG)
|
|||
string(TOUPPER "${CMAKE_BUILD_TYPE}" _CMAKE_BUILD_TYPE)
|
||||
if (_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
|
||||
set(_LIBRARIES ${LIBRARIES_DEBUG})
|
||||
set(_OBJECTS ${OBJECTS_DEBUG})
|
||||
else()
|
||||
set(_LIBRARIES ${LIBRARIES})
|
||||
set(_OBJECTS ${OBJECTS})
|
||||
endif()
|
||||
|
||||
get_target_property (outfile ${TARGET_LIB} LOCATION)
|
||||
set(target_temp_file "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lib${TARGET_LIB}_temp.a")
|
||||
|
||||
set(MRI_SCRIPT "create ${outfile}\n")
|
||||
set(MRI_SCRIPT "${MRI_SCRIPT}addlib ${target_temp_file}\n")
|
||||
foreach(lib ${_LIBRARIES})
|
||||
set(MRI_SCRIPT "${MRI_SCRIPT}addlib ${lib}\n")
|
||||
endforeach()
|
||||
foreach(obj ${_OBJECTS})
|
||||
set(MRI_SCRIPT "${MRI_SCRIPT}addmod ${obj}\n")
|
||||
endforeach()
|
||||
set(MRI_SCRIPT "${MRI_SCRIPT}addlib ${target_temp_file}\n")
|
||||
set(MRI_SCRIPT "${MRI_SCRIPT}delete messagehandler.o\n")
|
||||
set(MRI_SCRIPT "${MRI_SCRIPT}save\n")
|
||||
set(MRI_SCRIPT "${MRI_SCRIPT}end\n")
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "control.h"
|
||||
#include "peer.h"
|
||||
|
||||
#include "webrtc/base/location.h"
|
||||
#include "webrtc/base/json.h"
|
||||
#include "webrtc/base/signalthread.h"
|
||||
|
||||
|
@ -23,6 +24,7 @@ namespace rtc {
|
|||
}
|
||||
|
||||
} // namespace rtc
|
||||
|
||||
#endif // WEBRTC_POSIX
|
||||
|
||||
namespace pc {
|
||||
|
@ -133,7 +135,7 @@ void Control::Close(const CloseCode code, bool force_queuing) {
|
|||
|
||||
if (force_queuing || webrtc_thread_ != rtc::Thread::Current()) {
|
||||
ControlMessageData *data = new ControlMessageData(code, ref_);
|
||||
webrtc_thread_->Post(this, MSG_CLOSE, data);
|
||||
webrtc_thread_->Post(RTC_FROM_HERE, this, MSG_CLOSE, data);
|
||||
LOGP_F( INFO ) << "Queued";
|
||||
return;
|
||||
}
|
||||
|
@ -177,7 +179,7 @@ void Control::ClosePeer( const string channel, const CloseCode code, bool force_
|
|||
if (force_queuing || webrtc_thread_ != rtc::Thread::Current()) {
|
||||
ControlMessageData *data = new ControlMessageData(channel, ref_);
|
||||
data->data_int32_ = code;
|
||||
webrtc_thread_->Post(this, MSG_CLOSE_PEER, data);
|
||||
webrtc_thread_->Post(RTC_FROM_HERE, this, MSG_CLOSE_PEER, data);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -251,7 +253,7 @@ void Control::OnPeerClose(const string channel, CloseCode code) {
|
|||
ControlMessageData *data = new ControlMessageData(channel, ref_);
|
||||
|
||||
// Call Control::OnPeerDisconnected()
|
||||
webrtc_thread_->Post(this, MSG_ON_PEER_CLOSE, data);
|
||||
webrtc_thread_->Post(RTC_FROM_HERE, this, MSG_ON_PEER_CLOSE, data);
|
||||
LOGP_F( INFO ) << "Queued, channel is " << channel;
|
||||
return;
|
||||
}
|
||||
|
@ -390,7 +392,7 @@ void Control::OnCommandReceived(const Json::Value& message) {
|
|||
|
||||
void Control::OnSignalCommandReceived(const Json::Value& message) {
|
||||
ControlMessageData *data = new ControlMessageData(message, ref_);
|
||||
webrtc_thread_->Post(this, MSG_COMMAND_RECEIVED, data);
|
||||
webrtc_thread_->Post(RTC_FROM_HERE, this, MSG_COMMAND_RECEIVED, data);
|
||||
LOGP_F( INFO ) << "Done";
|
||||
}
|
||||
|
||||
|
@ -398,7 +400,7 @@ void Control::OnSignalConnectionClosed(websocketpp::close::status::value code) {
|
|||
LOGP_F(INFO) << "Enter, code is " << code;
|
||||
if (code != websocketpp::close::status::normal) {
|
||||
ControlMessageData *data = new ControlMessageData(CLOSE_SIGNAL_ERROR, ref_);
|
||||
webrtc_thread_->Post(this, MSG_ON_SIGLAL_CONNECTION_CLOSE, data);
|
||||
webrtc_thread_->Post(RTC_FROM_HERE, this, MSG_ON_SIGLAL_CONNECTION_CLOSE, data);
|
||||
}
|
||||
LOGP_F( INFO ) << "Done";
|
||||
}
|
||||
|
|
|
@ -628,7 +628,7 @@ void FakeAudioCaptureModule::UpdateProcessing(bool start) {
|
|||
process_thread_.reset(new rtc::Thread());
|
||||
process_thread_->Start();
|
||||
}
|
||||
process_thread_->Post(this, MSG_START_PROCESS);
|
||||
process_thread_->Post(RTC_FROM_HERE, this, MSG_START_PROCESS);
|
||||
} else {
|
||||
if (process_thread_) {
|
||||
process_thread_->Stop();
|
||||
|
@ -669,7 +669,7 @@ void FakeAudioCaptureModule::ProcessFrameP() {
|
|||
const uint32_t current_time = rtc::Time();
|
||||
const uint32_t wait_time =
|
||||
(next_frame_time_ > current_time) ? next_frame_time_ - current_time : 0;
|
||||
process_thread_->PostDelayed(wait_time, this, MSG_RUN_PROCESS);
|
||||
process_thread_->PostDelayed(RTC_FROM_HERE, wait_time, this, MSG_RUN_PROCESS);
|
||||
}
|
||||
|
||||
void FakeAudioCaptureModule::ReceiveFrameP() {
|
||||
|
|
|
@ -179,8 +179,9 @@ LogMessage::LogMessage(const char* file,
|
|||
#endif // WEBRTC_WIN
|
||||
#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
|
||||
case ERRCTX_OSSTATUS: {
|
||||
std::string desc(DescriptionFromOSStatus(err));
|
||||
tmp << " " << (desc.empty() ? "Unknown error" : desc.c_str());
|
||||
// PeerConnect don't need this.
|
||||
// std::string desc(DescriptionFromOSStatus(err));
|
||||
// tmp << " " << (desc.empty() ? "Unknown error" : desc.c_str());
|
||||
break;
|
||||
}
|
||||
#endif // WEBRTC_MAC && !defined(WEBRTC_IOS)
|
||||
|
|
|
@ -27,8 +27,6 @@ public:
|
|||
|
||||
using string = std::string;
|
||||
using Data = std::map<string, string>;
|
||||
using Control = Control;
|
||||
using Signal = Signal;
|
||||
|
||||
struct Setting {
|
||||
string signal_uri_;
|
||||
|
@ -95,7 +93,7 @@ protected:
|
|||
using EventHandler_2 = EventHandler_t<string>;
|
||||
using EventHandler_3 = EventHandler_t<string, Data&>;
|
||||
using EventHandler_Close = EventHandler_t<string, pc::CloseCode, string>;
|
||||
using EventHandler_Message = EventHandler_t<string, Buffer>;
|
||||
using EventHandler_Message = EventHandler_t<string, Buffer&>;
|
||||
using Events = std::map<string, std::unique_ptr<Handler_t>>;
|
||||
using MessageHandler = std::function<void( PeerConnect*, string, Buffer& )>;
|
||||
|
||||
|
|
Loading…
Reference in New Issue