最近一段时间在学习webrtc时候遇到源码中demo无法运行问题,安装了vs2022又不想再折腾到 vs2019,查找好多资料都无法解决,最后在官网Issue 13498下找到解决方法,供大家参考:
1. 在peerconnection_client下 main.cc 内新增类
class CustomSocketServer:public rtc::PhysicalSocketServer {
public:
bool Wait(webrtc::TimeDelta max_wait_duration, bool process_io) override {
if (!process_io)
return true;
return rtc::PhysicalSocketServer::Wait(webrtc::TimeDelta::Zero(), process_io);
}
};
} // namespace
2. 注释rtc::PhysicalSocketServer ss 使用CustomSocketServer ss:
} // namespace
int PASCAL wWinMain(HINSTANCE instance,
HINSTANCE prev_instance,
wchar_t* cmd_line,
int cmd_show) {
rtc::WinsockInitializer winsock_init;
//rtc::PhysicalSocketServer ss;
CustomSocketServer ss;
rtc::AutoSocketServerThread main_thread(&ss);
3. 在注释 //Main loop前新增:
main_thread.Start();
// Main loop.
MSG msg;
BOOL gm;
重新编译启动后可用。
如果只有一台电脑,可以下载obs,启动虚拟摄像头,把实体摄像头虚拟一下,就可以启动两个客户端了。
有学习webrtc的小伙伴共勉!!!!!!!!!!!!