libwebrtc/Samples/PeerConnection/Core.cpp
Axel Isouard 3bca34b165
Win32: Add Win32Console.cpp, temporary fix for merge script
Signed-off-by: Axel Isouard <axel@isouard.fr>
2016-11-01 10:58:38 +01:00

87 lines
1.7 KiB
C++

//
// Created by ax on 24/09/16.
//
#include "webrtc/base/ssladapter.h"
#ifdef WIN32
#include "webrtc/base/win32socketinit.h"
#include "webrtc/base/win32socketserver.h"
#include <Windows.h>
#endif
#include "Core.h"
rtc::Thread *Core::_signalingThread = NULL;
rtc::Thread *Core::_workerThread = NULL;
webrtc::PeerConnectionFactoryInterface *Core::_peerConnectionFactory = NULL;
bool Core::Init() {
#if 0
rtc::EnsureWinsockInit();
rtc::Win32Thread w32_thread;
rtc::ThreadManager::Instance()->SetCurrentThread(&w32_thread);
#endif
rtc::InitializeSSL();
rtc::InitRandom(rtc::Time());
rtc::ThreadManager::Instance()->WrapCurrentThread();
_signalingThread = new rtc::Thread();
_workerThread = new rtc::Thread();
_signalingThread->SetName("signaling_thread", NULL);
_workerThread->SetName("worker_thread", NULL);
if (!_signalingThread->Start() || !_workerThread->Start()) {
return false;
}
_peerConnectionFactory =
webrtc::CreatePeerConnectionFactory(_signalingThread,
_workerThread,
NULL, NULL, NULL).release();
return true;
}
bool Core::Update() {
return rtc::Thread::Current()->ProcessMessages(0);
}
bool Core::Cleanup() {
_peerConnectionFactory->Release();
_peerConnectionFactory = NULL;
_signalingThread->Stop();
_workerThread->Stop();
delete _signalingThread;
delete _workerThread;
_signalingThread = NULL;
_workerThread = NULL;
return rtc::CleanupSSL();
}
rtc::Thread *Core::GetSignalingThread() {
return _signalingThread;
}
rtc::Thread *Core::GetWorkerThread() {
return _workerThread;
}
webrtc::PeerConnectionFactoryInterface *Core::GetPeerConnectionFactory() {
return _peerConnectionFactory;
}