首先需要安装Visual Studio(Version2017),然后下载WebRTC的代码并对代码进行编译。
下载WebRTC代码:https://webrtc.org/getting-started/hello-world
安装WebRTC编译工具:在命令行中运行以下命令:
win_prereq.py –-force
然后等待安装过程结束。
打开Visual Studio,转到“文件” > “新建” > “项目”,选择“Visual C++” > “空项目”,并命名为“WebRTC”。
在“WebRTC”项目上单击右键,选择“属性” > “VC ++目录”,并将以下路径添加到“包含目录”中:
C:\webrtc\src
C:\webrtc\src\third_party\abseil-cpp
C:\webrtc\src\third_party\libyuv\include
C:\webrtc\src\third_party\openmax_dl\include
C:\webrtc\src\third_party\opus\src\opus
C:\webrtc\src\third_party\opus\src\opus\include
C:\webrtc\src\third_party\usrsctp
C:\webrtc\src\third_party\jsoncpp\include
C:\webrtc\src\third_party\xmp-toolkit\XMP-Toolkit_SDK-Win-CC2019-1903
C:\webrtc\src\third_party
acl_sdk
并将以下路径添加到“库目录”中:
C:\webrtc\src\out\debug\obj
C:\webrtc\src\out\debug\obj\third_party\jsoncpp\jsoncpp
C:\webrtc\src\out\debug\obj\third_party
acl\out
C:\webrtc\src\out\debug\obj\third_party\usrsctp\out
打开“WebRTC”项目,右键单击“源文件”文件夹,选择“添加” > “现有项”,然后选择“C++源文件”文件夹中的文件,将它们添加到项目中。
将以下代码添加到项目中的源文件中,进行编译:
#include "webrtc/peerconnectioninterface.h" #include "webrtc/base/logging.h"
int main(int argc, char* argv[]) { rtc::LogMessage::ConfigureLogging("my_log_file.txt", rtc::LS_VERBOSE); rtc::InitializeSSL(); rtc::ThreadManager::Instance()->WrapCurrentThread();
// Create the PeerConnectionFactory.
rtc::scoped_refptr peer_connection_factory =
webrtc::CreatePeerConnectionFactory();
if (!peer_connection_factory.get()) {
return -1;
}
return 0;
}