Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/media/peer_connection_handler_jsep.h" | 5 #include "content/renderer/media/peer_connection_handler_jsep.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
| 13 #include "base/stringprintf.h" | |
| 13 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 14 #include "content/renderer/media/media_stream_dependency_factory.h" | 15 #include "content/renderer/media/media_stream_dependency_factory.h" |
| 15 #include "content/renderer/media/media_stream_impl.h" | 16 #include "content/renderer/media/media_stream_impl.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebICECandid ateDescriptor.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebICECandid ateDescriptor.h" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebICEOption s.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebICEOption s.h" |
| 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConne ction00HandlerClient.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConne ction00HandlerClient.h" |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaHint s.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaHint s.h" |
| 20 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amDescriptor.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amDescriptor.h" |
| 21 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amSource.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amSource.h" |
| 22 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSessionDe scriptionDescriptor.h" | 23 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSessionDe scriptionDescriptor.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 default: | 147 default: |
| 147 NOTREACHED(); | 148 NOTREACHED(); |
| 148 return false; | 149 return false; |
| 149 } | 150 } |
| 150 native_peer_connection_->StartIce(native_options); | 151 native_peer_connection_->StartIce(native_options); |
| 151 return true; | 152 return true; |
| 152 } | 153 } |
| 153 | 154 |
| 154 bool PeerConnectionHandlerJsep::processIceMessage( | 155 bool PeerConnectionHandlerJsep::processIceMessage( |
| 155 const WebKit::WebICECandidateDescriptor& candidate) { | 156 const WebKit::WebICECandidateDescriptor& candidate) { |
| 157 int m_line_index = -1; | |
| 158 if (!base::StringToInt(UTF16ToUTF8(candidate.label()), &m_line_index)) { | |
| 159 LOG(ERROR) << "Invalid candidate label: " | |
| 160 << UTF16ToUTF8(candidate.label()); | |
| 161 return false; | |
| 162 } | |
| 163 // TODO: Use sdp_mid when its available, for now its empty string. | |
|
Ronghua Wu (Left Chromium)
2012/07/30 18:59:00
You can put my name on the TODO. :)
Mallinath (Gone from Chromium)
2012/07/30 19:11:25
Sure.
On 2012/07/30 18:59:00, Ronghua Wu wrote:
| |
| 164 const std::string sdp_mid = ""; | |
| 156 scoped_ptr<webrtc::IceCandidateInterface> native_candidate( | 165 scoped_ptr<webrtc::IceCandidateInterface> native_candidate( |
| 157 dependency_factory_->CreateIceCandidate( | 166 dependency_factory_->CreateIceCandidate( |
| 158 UTF16ToUTF8(candidate.label()), | 167 sdp_mid, |
| 168 m_line_index, | |
| 159 UTF16ToUTF8(candidate.candidateLine()))); | 169 UTF16ToUTF8(candidate.candidateLine()))); |
| 160 if (!native_candidate.get()) { | 170 if (!native_candidate.get()) { |
| 161 LOG(ERROR) << "Could not create native ICE candidate"; | 171 LOG(ERROR) << "Could not create native ICE candidate"; |
| 162 return false; | 172 return false; |
| 163 } | 173 } |
| 164 | 174 |
| 165 bool return_value = | 175 bool return_value = |
| 166 native_peer_connection_->ProcessIceMessage(native_candidate.get()); | 176 native_peer_connection_->ProcessIceMessage(native_candidate.get()); |
| 167 if (!return_value) | 177 if (!return_value) |
| 168 LOG(ERROR) << "Error processing ICE message"; | 178 LOG(ERROR) << "Error processing ICE message"; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 272 WebKit::WebMediaStreamDescriptor descriptor = it->second; | 282 WebKit::WebMediaStreamDescriptor descriptor = it->second; |
| 273 DCHECK(!descriptor.isNull()); | 283 DCHECK(!descriptor.isNull()); |
| 274 remote_streams_.erase(it); | 284 remote_streams_.erase(it); |
| 275 client_->didRemoveRemoteStream(descriptor); | 285 client_->didRemoveRemoteStream(descriptor); |
| 276 } | 286 } |
| 277 | 287 |
| 278 void PeerConnectionHandlerJsep::OnIceCandidate( | 288 void PeerConnectionHandlerJsep::OnIceCandidate( |
| 279 const webrtc::IceCandidateInterface* candidate) { | 289 const webrtc::IceCandidateInterface* candidate) { |
| 280 WebKit::WebICECandidateDescriptor web_candidate; | 290 WebKit::WebICECandidateDescriptor web_candidate; |
| 281 | 291 |
| 282 std::string label = candidate->label(); | 292 std::string label = StringPrintf("%d", candidate->sdp_mline_index()); |
| 283 std::string sdp; | 293 std::string sdp; |
| 284 if (!candidate->ToString(&sdp)) { | 294 if (!candidate->ToString(&sdp)) { |
| 285 LOG(ERROR) << "Could not get SDP string"; | 295 LOG(ERROR) << "Could not get SDP string"; |
| 286 return; | 296 return; |
| 287 } | 297 } |
| 288 | 298 |
| 289 web_candidate.initialize(UTF8ToUTF16(label), UTF8ToUTF16(sdp)); | 299 web_candidate.initialize(UTF8ToUTF16(label), UTF8ToUTF16(sdp)); |
| 290 | 300 |
| 291 // moreToFollow parameter isn't supported in native PeerConnection, so we | 301 // moreToFollow parameter isn't supported in native PeerConnection, so we |
| 292 // always use true here, and then false in OnIceComplete(). | 302 // always use true here, and then false in OnIceComplete(). |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 303 webrtc::SessionDescriptionInterface* | 313 webrtc::SessionDescriptionInterface* |
| 304 PeerConnectionHandlerJsep::CreateNativeSessionDescription( | 314 PeerConnectionHandlerJsep::CreateNativeSessionDescription( |
| 305 const WebKit::WebSessionDescriptionDescriptor& description) { | 315 const WebKit::WebSessionDescriptionDescriptor& description) { |
| 306 std::string initial_sdp = UTF16ToUTF8(description.initialSDP()); | 316 std::string initial_sdp = UTF16ToUTF8(description.initialSDP()); |
| 307 webrtc::SessionDescriptionInterface* native_desc = | 317 webrtc::SessionDescriptionInterface* native_desc = |
| 308 dependency_factory_->CreateSessionDescription(initial_sdp); | 318 dependency_factory_->CreateSessionDescription(initial_sdp); |
| 309 if (!native_desc) { | 319 if (!native_desc) { |
| 310 LOG(ERROR) << "Failed to create native session description"; | 320 LOG(ERROR) << "Failed to create native session description"; |
| 311 return NULL; | 321 return NULL; |
| 312 } | 322 } |
| 313 | 323 // TODO: Apply sdp_mid when its available, for now its empty string. |
| 324 const std::string sdp_mid = ""; | |
| 314 for (size_t i = 0; i < description.numberOfAddedCandidates(); ++i) { | 325 for (size_t i = 0; i < description.numberOfAddedCandidates(); ++i) { |
| 315 WebKit::WebICECandidateDescriptor candidate = description.candidate(i); | 326 WebKit::WebICECandidateDescriptor candidate = description.candidate(i); |
| 327 int m_line_index = -1; | |
| 328 if (!base::StringToInt(UTF16ToUTF8(candidate.label()), &m_line_index)) { | |
| 329 LOG(ERROR) << "Invalid candidate label: " | |
| 330 << UTF16ToUTF8(candidate.label()); | |
| 331 continue; | |
| 332 } | |
| 316 scoped_ptr<webrtc::IceCandidateInterface> native_candidate( | 333 scoped_ptr<webrtc::IceCandidateInterface> native_candidate( |
| 317 dependency_factory_->CreateIceCandidate( | 334 dependency_factory_->CreateIceCandidate( |
| 318 UTF16ToUTF8(candidate.label()), | 335 sdp_mid, |
| 336 m_line_index, | |
| 319 UTF16ToUTF8(candidate.candidateLine()))); | 337 UTF16ToUTF8(candidate.candidateLine()))); |
| 320 if (!native_desc->AddCandidate(native_candidate.get())) | 338 if (!native_desc->AddCandidate(native_candidate.get())) |
| 321 LOG(ERROR) << "Failed to add candidate to native session description"; | 339 LOG(ERROR) << "Failed to add candidate to native session description"; |
| 322 } | 340 } |
| 323 | 341 |
| 324 return native_desc; | 342 return native_desc; |
| 325 } | 343 } |
| 326 | 344 |
| 327 WebKit::WebSessionDescriptionDescriptor | 345 WebKit::WebSessionDescriptionDescriptor |
| 328 PeerConnectionHandlerJsep::CreateWebKitSessionDescription( | 346 PeerConnectionHandlerJsep::CreateWebKitSessionDescription( |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 355 break; | 373 break; |
| 356 case ActionSDPAnswer: | 374 case ActionSDPAnswer: |
| 357 *native_action = webrtc::PeerConnectionInterface::kAnswer; | 375 *native_action = webrtc::PeerConnectionInterface::kAnswer; |
| 358 break; | 376 break; |
| 359 default: | 377 default: |
| 360 NOTREACHED(); | 378 NOTREACHED(); |
| 361 return false; | 379 return false; |
| 362 } | 380 } |
| 363 return true; | 381 return true; |
| 364 } | 382 } |
| OLD | NEW |