OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 } | 295 } |
296 return; | 296 return; |
297 } | 297 } |
298 | 298 |
299 std::string sdp; | 299 std::string sdp; |
300 if (!rtc::GetStringFromJsonObject(jmessage, kSessionDescriptionSdpName, | 300 if (!rtc::GetStringFromJsonObject(jmessage, kSessionDescriptionSdpName, |
301 &sdp)) { | 301 &sdp)) { |
302 LOG(WARNING) << "Can't parse received session description message."; | 302 LOG(WARNING) << "Can't parse received session description message."; |
303 return; | 303 return; |
304 } | 304 } |
| 305 webrtc::SdpParseError error; |
305 webrtc::SessionDescriptionInterface* session_description( | 306 webrtc::SessionDescriptionInterface* session_description( |
306 webrtc::CreateSessionDescription(type, sdp)); | 307 webrtc::CreateSessionDescription(type, sdp, &error)); |
307 if (!session_description) { | 308 if (!session_description) { |
308 LOG(WARNING) << "Can't parse received session description message."; | 309 LOG(WARNING) << "Can't parse received session description message. " |
| 310 << "SdpParseError was: " << error.description; |
309 return; | 311 return; |
310 } | 312 } |
311 LOG(INFO) << " Received session description :" << message; | 313 LOG(INFO) << " Received session description :" << message; |
312 peer_connection_->SetRemoteDescription( | 314 peer_connection_->SetRemoteDescription( |
313 DummySetSessionDescriptionObserver::Create(), session_description); | 315 DummySetSessionDescriptionObserver::Create(), session_description); |
314 if (session_description->type() == | 316 if (session_description->type() == |
315 webrtc::SessionDescriptionInterface::kOffer) { | 317 webrtc::SessionDescriptionInterface::kOffer) { |
316 peer_connection_->CreateAnswer(this, NULL); | 318 peer_connection_->CreateAnswer(this, NULL); |
317 } | 319 } |
318 return; | 320 return; |
319 } else { | 321 } else { |
320 std::string sdp_mid; | 322 std::string sdp_mid; |
321 int sdp_mlineindex = 0; | 323 int sdp_mlineindex = 0; |
322 std::string sdp; | 324 std::string sdp; |
323 if (!rtc::GetStringFromJsonObject(jmessage, kCandidateSdpMidName, | 325 if (!rtc::GetStringFromJsonObject(jmessage, kCandidateSdpMidName, |
324 &sdp_mid) || | 326 &sdp_mid) || |
325 !rtc::GetIntFromJsonObject(jmessage, kCandidateSdpMlineIndexName, | 327 !rtc::GetIntFromJsonObject(jmessage, kCandidateSdpMlineIndexName, |
326 &sdp_mlineindex) || | 328 &sdp_mlineindex) || |
327 !rtc::GetStringFromJsonObject(jmessage, kCandidateSdpName, &sdp)) { | 329 !rtc::GetStringFromJsonObject(jmessage, kCandidateSdpName, &sdp)) { |
328 LOG(WARNING) << "Can't parse received message."; | 330 LOG(WARNING) << "Can't parse received message."; |
329 return; | 331 return; |
330 } | 332 } |
| 333 webrtc::SdpParseError error; |
331 rtc::scoped_ptr<webrtc::IceCandidateInterface> candidate( | 334 rtc::scoped_ptr<webrtc::IceCandidateInterface> candidate( |
332 webrtc::CreateIceCandidate(sdp_mid, sdp_mlineindex, sdp)); | 335 webrtc::CreateIceCandidate(sdp_mid, sdp_mlineindex, sdp, &error)); |
333 if (!candidate.get()) { | 336 if (!candidate.get()) { |
334 LOG(WARNING) << "Can't parse received candidate message."; | 337 LOG(WARNING) << "Can't parse received candidate message. " |
| 338 << "SdpParseError was: " << error.description; |
335 return; | 339 return; |
336 } | 340 } |
337 if (!peer_connection_->AddIceCandidate(candidate.get())) { | 341 if (!peer_connection_->AddIceCandidate(candidate.get())) { |
338 LOG(WARNING) << "Failed to apply the received candidate"; | 342 LOG(WARNING) << "Failed to apply the received candidate"; |
339 return; | 343 return; |
340 } | 344 } |
341 LOG(INFO) << " Received candidate :" << message; | 345 LOG(INFO) << " Received candidate :" << message; |
342 return; | 346 return; |
343 } | 347 } |
344 } | 348 } |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 peer_connection_->SetLocalDescription( | 533 peer_connection_->SetLocalDescription( |
530 DummySetSessionDescriptionObserver::Create(), desc); | 534 DummySetSessionDescriptionObserver::Create(), desc); |
531 | 535 |
532 std::string sdp; | 536 std::string sdp; |
533 desc->ToString(&sdp); | 537 desc->ToString(&sdp); |
534 | 538 |
535 // For loopback test. To save some connecting delay. | 539 // For loopback test. To save some connecting delay. |
536 if (loopback_) { | 540 if (loopback_) { |
537 // Replace message type from "offer" to "answer" | 541 // Replace message type from "offer" to "answer" |
538 webrtc::SessionDescriptionInterface* session_description( | 542 webrtc::SessionDescriptionInterface* session_description( |
539 webrtc::CreateSessionDescription("answer", sdp)); | 543 webrtc::CreateSessionDescription("answer", sdp, nullptr)); |
540 peer_connection_->SetRemoteDescription( | 544 peer_connection_->SetRemoteDescription( |
541 DummySetSessionDescriptionObserver::Create(), session_description); | 545 DummySetSessionDescriptionObserver::Create(), session_description); |
542 return; | 546 return; |
543 } | 547 } |
544 | 548 |
545 Json::StyledWriter writer; | 549 Json::StyledWriter writer; |
546 Json::Value jmessage; | 550 Json::Value jmessage; |
547 jmessage[kSessionDescriptionTypeName] = desc->type(); | 551 jmessage[kSessionDescriptionTypeName] = desc->type(); |
548 jmessage[kSessionDescriptionSdpName] = sdp; | 552 jmessage[kSessionDescriptionSdpName] = sdp; |
549 SendMessage(writer.write(jmessage)); | 553 SendMessage(writer.write(jmessage)); |
550 } | 554 } |
551 | 555 |
552 void Conductor::OnFailure(const std::string& error) { | 556 void Conductor::OnFailure(const std::string& error) { |
553 LOG(LERROR) << error; | 557 LOG(LERROR) << error; |
554 } | 558 } |
555 | 559 |
556 void Conductor::SendMessage(const std::string& json_object) { | 560 void Conductor::SendMessage(const std::string& json_object) { |
557 std::string* msg = new std::string(json_object); | 561 std::string* msg = new std::string(json_object); |
558 main_wnd_->QueueUIThreadCallback(SEND_MESSAGE_TO_PEER, msg); | 562 main_wnd_->QueueUIThreadCallback(SEND_MESSAGE_TO_PEER, msg); |
559 } | 563 } |
OLD | NEW |