blob: bf0d6c9ad0897082baab90d058eea1ab86048304 [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001/*
2 * libjingle
jlmiller@webrtc.org5f93d0a2015-01-20 21:36:13 +00003 * Copyright 2012 Google Inc.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00004 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#include "talk/examples/peerconnection/client/conductor.h"
29
30#include <utility>
braveyao@webrtc.orgc68e0c92015-02-27 09:51:25 +000031#include <vector>
henrike@webrtc.org28e20752013-07-10 00:45:36 +000032
33#include "talk/app/webrtc/videosourceinterface.h"
buildbot@webrtc.orga09a9992014-08-13 17:26:08 +000034#include "talk/examples/peerconnection/client/defaults.h"
35#include "talk/media/devices/devicemanager.h"
braveyao@webrtc.orga742cb12015-01-29 04:23:01 +000036#include "talk/app/webrtc/test/fakeconstraints.h"
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000037#include "webrtc/base/common.h"
38#include "webrtc/base/json.h"
39#include "webrtc/base/logging.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000040
41// Names used for a IceCandidate JSON object.
42const char kCandidateSdpMidName[] = "sdpMid";
43const char kCandidateSdpMlineIndexName[] = "sdpMLineIndex";
44const char kCandidateSdpName[] = "candidate";
45
46// Names used for a SessionDescription JSON object.
47const char kSessionDescriptionTypeName[] = "type";
48const char kSessionDescriptionSdpName[] = "sdp";
49
braveyao@webrtc.orga742cb12015-01-29 04:23:01 +000050#define DTLS_ON true
51#define DTLS_OFF false
52
henrike@webrtc.org28e20752013-07-10 00:45:36 +000053class DummySetSessionDescriptionObserver
54 : public webrtc::SetSessionDescriptionObserver {
55 public:
56 static DummySetSessionDescriptionObserver* Create() {
57 return
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000058 new rtc::RefCountedObject<DummySetSessionDescriptionObserver>();
henrike@webrtc.org28e20752013-07-10 00:45:36 +000059 }
60 virtual void OnSuccess() {
61 LOG(INFO) << __FUNCTION__;
62 }
63 virtual void OnFailure(const std::string& error) {
64 LOG(INFO) << __FUNCTION__ << " " << error;
65 }
66
67 protected:
68 DummySetSessionDescriptionObserver() {}
69 ~DummySetSessionDescriptionObserver() {}
70};
71
72Conductor::Conductor(PeerConnectionClient* client, MainWindow* main_wnd)
73 : peer_id_(-1),
braveyao@webrtc.orga742cb12015-01-29 04:23:01 +000074 loopback_(false),
henrike@webrtc.org28e20752013-07-10 00:45:36 +000075 client_(client),
76 main_wnd_(main_wnd) {
77 client_->RegisterObserver(this);
78 main_wnd->RegisterObserver(this);
79}
80
81Conductor::~Conductor() {
82 ASSERT(peer_connection_.get() == NULL);
83}
84
85bool Conductor::connection_active() const {
86 return peer_connection_.get() != NULL;
87}
88
89void Conductor::Close() {
90 client_->SignOut();
91 DeletePeerConnection();
92}
93
94bool Conductor::InitializePeerConnection() {
95 ASSERT(peer_connection_factory_.get() == NULL);
96 ASSERT(peer_connection_.get() == NULL);
97
98 peer_connection_factory_ = webrtc::CreatePeerConnectionFactory();
99
100 if (!peer_connection_factory_.get()) {
101 main_wnd_->MessageBox("Error",
102 "Failed to initialize PeerConnectionFactory", true);
103 DeletePeerConnection();
104 return false;
105 }
106
braveyao@webrtc.orgc68e0c92015-02-27 09:51:25 +0000107 if (!CreatePeerConnection(DTLS_ON)) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000108 main_wnd_->MessageBox("Error",
109 "CreatePeerConnection failed", true);
110 DeletePeerConnection();
111 }
112 AddStreams();
113 return peer_connection_.get() != NULL;
114}
115
braveyao@webrtc.orga742cb12015-01-29 04:23:01 +0000116bool Conductor::ReinitializePeerConnectionForLoopback() {
braveyao@webrtc.orgc68e0c92015-02-27 09:51:25 +0000117 loopback_ = true;
118 rtc::scoped_refptr<webrtc::StreamCollectionInterface> streams(
119 peer_connection_->local_streams());
120 peer_connection_ = NULL;
braveyao@webrtc.orga742cb12015-01-29 04:23:01 +0000121 if (CreatePeerConnection(DTLS_OFF)) {
braveyao@webrtc.orgc68e0c92015-02-27 09:51:25 +0000122 for (size_t i = 0; i < streams->count(); ++i)
123 peer_connection_->AddStream(streams->at(i));
124 peer_connection_->CreateOffer(this, NULL);
braveyao@webrtc.orga742cb12015-01-29 04:23:01 +0000125 }
126 return peer_connection_.get() != NULL;
127}
128
129bool Conductor::CreatePeerConnection(bool dtls) {
130 ASSERT(peer_connection_factory_.get() != NULL);
131 ASSERT(peer_connection_.get() == NULL);
132
braveyao@webrtc.orgc68e0c92015-02-27 09:51:25 +0000133 webrtc::PeerConnectionInterface::IceServers servers;
134 webrtc::PeerConnectionInterface::IceServer server;
135 server.uri = GetPeerConnectionString();
136 servers.push_back(server);
137
braveyao@webrtc.orga742cb12015-01-29 04:23:01 +0000138 webrtc::FakeConstraints constraints;
139 if (dtls) {
braveyao@webrtc.orgc68e0c92015-02-27 09:51:25 +0000140 constraints.AddOptional(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
141 "true");
142 }
braveyao@webrtc.org9bfa5f02015-03-11 03:20:59 +0000143 else
144 {
145 constraints.AddOptional(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
146 "false");
147 }
braveyao@webrtc.orgc68e0c92015-02-27 09:51:25 +0000148
149 peer_connection_ =
150 peer_connection_factory_->CreatePeerConnection(servers,
151 &constraints,
152 NULL,
153 NULL,
154 this);
braveyao@webrtc.orga742cb12015-01-29 04:23:01 +0000155 return peer_connection_.get() != NULL;
156}
157
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000158void Conductor::DeletePeerConnection() {
159 peer_connection_ = NULL;
160 active_streams_.clear();
161 main_wnd_->StopLocalRenderer();
162 main_wnd_->StopRemoteRenderer();
163 peer_connection_factory_ = NULL;
164 peer_id_ = -1;
braveyao@webrtc.orga742cb12015-01-29 04:23:01 +0000165 loopback_ = false;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000166}
167
168void Conductor::EnsureStreamingUI() {
169 ASSERT(peer_connection_.get() != NULL);
170 if (main_wnd_->IsWindow()) {
171 if (main_wnd_->current_ui() != MainWindow::STREAMING)
172 main_wnd_->SwitchToStreamingUI();
173 }
174}
175
176//
177// PeerConnectionObserver implementation.
178//
179
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000180// Called when a remote stream is added
181void Conductor::OnAddStream(webrtc::MediaStreamInterface* stream) {
182 LOG(INFO) << __FUNCTION__ << " " << stream->label();
183
184 stream->AddRef();
185 main_wnd_->QueueUIThreadCallback(NEW_STREAM_ADDED,
186 stream);
187}
188
189void Conductor::OnRemoveStream(webrtc::MediaStreamInterface* stream) {
190 LOG(INFO) << __FUNCTION__ << " " << stream->label();
191 stream->AddRef();
192 main_wnd_->QueueUIThreadCallback(STREAM_REMOVED,
193 stream);
194}
195
196void Conductor::OnIceCandidate(const webrtc::IceCandidateInterface* candidate) {
197 LOG(INFO) << __FUNCTION__ << " " << candidate->sdp_mline_index();
braveyao@webrtc.orgc68e0c92015-02-27 09:51:25 +0000198 // For loopback test. To save some connecting delay.
199 if (loopback_) {
200 if (!peer_connection_->AddIceCandidate(candidate)) {
201 LOG(WARNING) << "Failed to apply the received candidate";
202 }
203 return;
braveyao@webrtc.orga742cb12015-01-29 04:23:01 +0000204 }
205
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000206 Json::StyledWriter writer;
207 Json::Value jmessage;
208
209 jmessage[kCandidateSdpMidName] = candidate->sdp_mid();
210 jmessage[kCandidateSdpMlineIndexName] = candidate->sdp_mline_index();
211 std::string sdp;
212 if (!candidate->ToString(&sdp)) {
213 LOG(LS_ERROR) << "Failed to serialize candidate";
214 return;
215 }
216 jmessage[kCandidateSdpName] = sdp;
217 SendMessage(writer.write(jmessage));
218}
219
220//
221// PeerConnectionClientObserver implementation.
222//
223
224void Conductor::OnSignedIn() {
225 LOG(INFO) << __FUNCTION__;
226 main_wnd_->SwitchToPeerList(client_->peers());
227}
228
229void Conductor::OnDisconnected() {
230 LOG(INFO) << __FUNCTION__;
231
232 DeletePeerConnection();
233
234 if (main_wnd_->IsWindow())
235 main_wnd_->SwitchToConnectUI();
236}
237
238void Conductor::OnPeerConnected(int id, const std::string& name) {
239 LOG(INFO) << __FUNCTION__;
240 // Refresh the list if we're showing it.
241 if (main_wnd_->current_ui() == MainWindow::LIST_PEERS)
242 main_wnd_->SwitchToPeerList(client_->peers());
243}
244
245void Conductor::OnPeerDisconnected(int id) {
246 LOG(INFO) << __FUNCTION__;
247 if (id == peer_id_) {
248 LOG(INFO) << "Our peer disconnected";
249 main_wnd_->QueueUIThreadCallback(PEER_CONNECTION_CLOSED, NULL);
250 } else {
251 // Refresh the list if we're showing it.
252 if (main_wnd_->current_ui() == MainWindow::LIST_PEERS)
253 main_wnd_->SwitchToPeerList(client_->peers());
254 }
255}
256
257void Conductor::OnMessageFromPeer(int peer_id, const std::string& message) {
258 ASSERT(peer_id_ == peer_id || peer_id_ == -1);
259 ASSERT(!message.empty());
260
261 if (!peer_connection_.get()) {
262 ASSERT(peer_id_ == -1);
263 peer_id_ = peer_id;
264
265 if (!InitializePeerConnection()) {
266 LOG(LS_ERROR) << "Failed to initialize our PeerConnection instance";
267 client_->SignOut();
268 return;
269 }
270 } else if (peer_id != peer_id_) {
271 ASSERT(peer_id_ != -1);
272 LOG(WARNING) << "Received a message from unknown peer while already in a "
273 "conversation with a different peer.";
274 return;
275 }
276
277 Json::Reader reader;
278 Json::Value jmessage;
279 if (!reader.parse(message, jmessage)) {
280 LOG(WARNING) << "Received unknown message. " << message;
281 return;
282 }
283 std::string type;
284 std::string json_object;
285
286 GetStringFromJsonObject(jmessage, kSessionDescriptionTypeName, &type);
287 if (!type.empty()) {
braveyao@webrtc.orgc68e0c92015-02-27 09:51:25 +0000288 if (type == "offer-loopback") {
289 // This is a loopback call.
290 // Recreate the peerconnection with DTLS disabled.
291 if (!ReinitializePeerConnectionForLoopback()) {
braveyao@webrtc.orga742cb12015-01-29 04:23:01 +0000292 LOG(LS_ERROR) << "Failed to initialize our PeerConnection instance";
293 DeletePeerConnection();
braveyao@webrtc.orgc68e0c92015-02-27 09:51:25 +0000294 client_->SignOut();
295 }
296 return;
braveyao@webrtc.orga742cb12015-01-29 04:23:01 +0000297 }
298
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000299 std::string sdp;
300 if (!GetStringFromJsonObject(jmessage, kSessionDescriptionSdpName, &sdp)) {
301 LOG(WARNING) << "Can't parse received session description message.";
302 return;
303 }
304 webrtc::SessionDescriptionInterface* session_description(
305 webrtc::CreateSessionDescription(type, sdp));
306 if (!session_description) {
307 LOG(WARNING) << "Can't parse received session description message.";
308 return;
309 }
310 LOG(INFO) << " Received session description :" << message;
311 peer_connection_->SetRemoteDescription(
312 DummySetSessionDescriptionObserver::Create(), session_description);
313 if (session_description->type() ==
314 webrtc::SessionDescriptionInterface::kOffer) {
315 peer_connection_->CreateAnswer(this, NULL);
316 }
317 return;
318 } else {
319 std::string sdp_mid;
320 int sdp_mlineindex = 0;
321 std::string sdp;
322 if (!GetStringFromJsonObject(jmessage, kCandidateSdpMidName, &sdp_mid) ||
323 !GetIntFromJsonObject(jmessage, kCandidateSdpMlineIndexName,
324 &sdp_mlineindex) ||
325 !GetStringFromJsonObject(jmessage, kCandidateSdpName, &sdp)) {
326 LOG(WARNING) << "Can't parse received message.";
327 return;
328 }
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000329 rtc::scoped_ptr<webrtc::IceCandidateInterface> candidate(
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000330 webrtc::CreateIceCandidate(sdp_mid, sdp_mlineindex, sdp));
331 if (!candidate.get()) {
332 LOG(WARNING) << "Can't parse received candidate message.";
333 return;
334 }
335 if (!peer_connection_->AddIceCandidate(candidate.get())) {
336 LOG(WARNING) << "Failed to apply the received candidate";
337 return;
338 }
339 LOG(INFO) << " Received candidate :" << message;
340 return;
341 }
342}
343
344void Conductor::OnMessageSent(int err) {
345 // Process the next pending message if any.
346 main_wnd_->QueueUIThreadCallback(SEND_MESSAGE_TO_PEER, NULL);
347}
348
349void Conductor::OnServerConnectionFailure() {
350 main_wnd_->MessageBox("Error", ("Failed to connect to " + server_).c_str(),
351 true);
352}
353
354//
355// MainWndCallback implementation.
356//
357
358void Conductor::StartLogin(const std::string& server, int port) {
359 if (client_->is_connected())
360 return;
361 server_ = server;
362 client_->Connect(server, port, GetPeerName());
363}
364
365void Conductor::DisconnectFromServer() {
366 if (client_->is_connected())
367 client_->SignOut();
368}
369
370void Conductor::ConnectToPeer(int peer_id) {
371 ASSERT(peer_id_ == -1);
372 ASSERT(peer_id != -1);
373
374 if (peer_connection_.get()) {
375 main_wnd_->MessageBox("Error",
376 "We only support connecting to one peer at a time", true);
377 return;
378 }
379
380 if (InitializePeerConnection()) {
381 peer_id_ = peer_id;
382 peer_connection_->CreateOffer(this, NULL);
383 } else {
384 main_wnd_->MessageBox("Error", "Failed to initialize PeerConnection", true);
385 }
386}
387
388cricket::VideoCapturer* Conductor::OpenVideoCaptureDevice() {
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000389 rtc::scoped_ptr<cricket::DeviceManagerInterface> dev_manager(
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000390 cricket::DeviceManagerFactory::Create());
391 if (!dev_manager->Init()) {
392 LOG(LS_ERROR) << "Can't create device manager";
393 return NULL;
394 }
395 std::vector<cricket::Device> devs;
396 if (!dev_manager->GetVideoCaptureDevices(&devs)) {
397 LOG(LS_ERROR) << "Can't enumerate video devices";
398 return NULL;
399 }
400 std::vector<cricket::Device>::iterator dev_it = devs.begin();
401 cricket::VideoCapturer* capturer = NULL;
402 for (; dev_it != devs.end(); ++dev_it) {
403 capturer = dev_manager->CreateVideoCapturer(*dev_it);
404 if (capturer != NULL)
405 break;
406 }
407 return capturer;
408}
409
410void Conductor::AddStreams() {
411 if (active_streams_.find(kStreamLabel) != active_streams_.end())
412 return; // Already added.
413
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000414 rtc::scoped_refptr<webrtc::AudioTrackInterface> audio_track(
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000415 peer_connection_factory_->CreateAudioTrack(
416 kAudioLabel, peer_connection_factory_->CreateAudioSource(NULL)));
417
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000418 rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track(
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000419 peer_connection_factory_->CreateVideoTrack(
420 kVideoLabel,
421 peer_connection_factory_->CreateVideoSource(OpenVideoCaptureDevice(),
422 NULL)));
423 main_wnd_->StartLocalRenderer(video_track);
424
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000425 rtc::scoped_refptr<webrtc::MediaStreamInterface> stream =
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000426 peer_connection_factory_->CreateLocalMediaStream(kStreamLabel);
427
428 stream->AddTrack(audio_track);
429 stream->AddTrack(video_track);
perkj@webrtc.orgc2dd5ee2014-11-04 11:31:29 +0000430 if (!peer_connection_->AddStream(stream)) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000431 LOG(LS_ERROR) << "Adding stream to PeerConnection failed";
432 }
433 typedef std::pair<std::string,
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000434 rtc::scoped_refptr<webrtc::MediaStreamInterface> >
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000435 MediaStreamPair;
436 active_streams_.insert(MediaStreamPair(stream->label(), stream));
437 main_wnd_->SwitchToStreamingUI();
438}
439
440void Conductor::DisconnectFromCurrentPeer() {
441 LOG(INFO) << __FUNCTION__;
442 if (peer_connection_.get()) {
443 client_->SendHangUp(peer_id_);
444 DeletePeerConnection();
445 }
446
447 if (main_wnd_->IsWindow())
448 main_wnd_->SwitchToPeerList(client_->peers());
449}
450
451void Conductor::UIThreadCallback(int msg_id, void* data) {
452 switch (msg_id) {
453 case PEER_CONNECTION_CLOSED:
454 LOG(INFO) << "PEER_CONNECTION_CLOSED";
455 DeletePeerConnection();
456
457 ASSERT(active_streams_.empty());
458
459 if (main_wnd_->IsWindow()) {
460 if (client_->is_connected()) {
461 main_wnd_->SwitchToPeerList(client_->peers());
462 } else {
463 main_wnd_->SwitchToConnectUI();
464 }
465 } else {
466 DisconnectFromServer();
467 }
468 break;
469
470 case SEND_MESSAGE_TO_PEER: {
471 LOG(INFO) << "SEND_MESSAGE_TO_PEER";
472 std::string* msg = reinterpret_cast<std::string*>(data);
473 if (msg) {
474 // For convenience, we always run the message through the queue.
475 // This way we can be sure that messages are sent to the server
476 // in the same order they were signaled without much hassle.
477 pending_messages_.push_back(msg);
478 }
479
480 if (!pending_messages_.empty() && !client_->IsSendingMessage()) {
481 msg = pending_messages_.front();
482 pending_messages_.pop_front();
483
484 if (!client_->SendToPeer(peer_id_, *msg) && peer_id_ != -1) {
485 LOG(LS_ERROR) << "SendToPeer failed";
486 DisconnectFromServer();
487 }
488 delete msg;
489 }
490
491 if (!peer_connection_.get())
492 peer_id_ = -1;
493
494 break;
495 }
496
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000497 case NEW_STREAM_ADDED: {
498 webrtc::MediaStreamInterface* stream =
499 reinterpret_cast<webrtc::MediaStreamInterface*>(
500 data);
501 webrtc::VideoTrackVector tracks = stream->GetVideoTracks();
502 // Only render the first track.
503 if (!tracks.empty()) {
504 webrtc::VideoTrackInterface* track = tracks[0];
505 main_wnd_->StartRemoteRenderer(track);
506 }
507 stream->Release();
508 break;
509 }
510
511 case STREAM_REMOVED: {
512 // Remote peer stopped sending a stream.
513 webrtc::MediaStreamInterface* stream =
514 reinterpret_cast<webrtc::MediaStreamInterface*>(
515 data);
516 stream->Release();
517 break;
518 }
519
520 default:
521 ASSERT(false);
522 break;
523 }
524}
525
526void Conductor::OnSuccess(webrtc::SessionDescriptionInterface* desc) {
braveyao@webrtc.orgc68e0c92015-02-27 09:51:25 +0000527 peer_connection_->SetLocalDescription(
528 DummySetSessionDescriptionObserver::Create(), desc);
529
braveyao@webrtc.orga742cb12015-01-29 04:23:01 +0000530 std::string sdp;
braveyao@webrtc.orgc68e0c92015-02-27 09:51:25 +0000531 desc->ToString(&sdp);
532
533 // For loopback test. To save some connecting delay.
534 if (loopback_) {
535 // Replace message type from "offer" to "answer"
536 webrtc::SessionDescriptionInterface* session_description(
537 webrtc::CreateSessionDescription("answer", sdp));
538 peer_connection_->SetRemoteDescription(
539 DummySetSessionDescriptionObserver::Create(), session_description);
540 return;
541 }
braveyao@webrtc.orga742cb12015-01-29 04:23:01 +0000542
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000543 Json::StyledWriter writer;
544 Json::Value jmessage;
545 jmessage[kSessionDescriptionTypeName] = desc->type();
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000546 jmessage[kSessionDescriptionSdpName] = sdp;
547 SendMessage(writer.write(jmessage));
548}
549
550void Conductor::OnFailure(const std::string& error) {
551 LOG(LERROR) << error;
552}
553
554void Conductor::SendMessage(const std::string& json_object) {
555 std::string* msg = new std::string(json_object);
556 main_wnd_->QueueUIThreadCallback(SEND_MESSAGE_TO_PEER, msg);
557}