问题:
调用DeletePeerConnection的时候,执行peer_connection_ = nullptr;会产生崩溃。
解决办法:
在add stream的时候我写成了同步调用,这个同步调用在启动的时候不会产生问题
case WM_WEBRTC_ADD_STREAM: { webrtc::MediaStreamInterface* stream =reinterpret_cast<webrtc::MediaStreamInterface*>(wParam); webrtc::VideoTrackVector tracks = stream->GetVideoTracks(); // Only render the first track. if (!tracks.empty()) { webrtc::VideoTrackInterface* track = tracks[0]; this->StartRemoteRenderer(track); } stream->Release(); } break;
void Conductor::OnAddStream(rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) { int n = GetCurrentThreadId(); LOG(INFO) << "Conductor::OnAddStream thread id:" << to_string(n); //这里一定要异步去做 ::PostMessage(m_asyncWnd, WM_WEBRTC_ADD_STREAM, (WPARAM)(stream.release()), 0); return; }