class MockClient: public webrtc::PeerConnectionObserver,
public webrtc::CreateSessionDescriptionObserver,
public rtc::Runnable {
MockClient(): mServer(), mSignalingThread(&mServer)
{
mSignalingThread.SetName("SignalingThread", nullptr);
mSignalingThread.Start(this);
}
void Run(rtc::Thread* thread) override
{
mPcf = webrtc::CreatePeerConnectionFactory(
nullptr /* network_thread */, nullptr /* worker_thread */,
nullptr /* signaling_thread */, nullptr /* default_adm */,
webrtc::CreateBuiltinAudioEncoderFactory(),
webrtc::CreateBuiltinAudioDecoderFactory(),
webrtc::CreateBuiltinVideoEncoderFactory(),
webrtc::CreateBuiltinVideoDecoderFactory(), nullptr /* audio_mixer */,
nullptr /* audio_processing */);
assert(mPcf != nullptr);
webrtc::PeerConnectionInterface::RTCConfiguration config;
config.sdp_semantics = webrtc::SdpSemantics::kUnifiedPlan;
config.enable_dtls_srtp = true;
webrtc::PeerConnectionInterface::IceServer server;
server.uri = "stun:address.of.my.stun.server";
config.servers.push_back(server);
mPc = mPcf->CreatePeerConnection(
config, nullptr, nullptr, this);
assert(mPc != nullptr);
std::unique_ptr<cricket::VideoCapturer> videoDevice = OpenVideoCaptureDevice();
rtc::scoped_refptr<webrtc::VideoTrackInterface> videoTrack(
mPc->CreateVideoTrack(
kVideoLabel,
mPcf->CreateVideoSource(std::move(videoDevice), nullptr)
)
);
auto res = mPc->AddTrack(videoTrack, { "videoStreamId-123" });
assert(res.ok());
mPc->CreateOffer(this, webrtc::PeerConnectionInterface::RTCOfferAnswerOptions());
thread->Run();
}
// other interface callbacks
private:
rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> mPcf;
rtc::scoped_refptr<webrtc::PeerConnectionInterface> mPc;
rtc::PhysicalSocketServer mServer;
rtc::Thread mSignalingThread;
}
int main()
{
rtc::InitializeSSL();
MockClient client;
sleep(10000000);
rtc::CleanupSSL();
return 0;
}