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/rtc_peer_connection_handler.h" | 5 #include "content/renderer/media/rtc_peer_connection_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "content/renderer/media/media_stream_dependency_factory.h" | 13 #include "content/renderer/media/media_stream_dependency_factory.h" |
| 14 #include "content/renderer/media/rtc_media_constraints.h" | 14 #include "content/renderer/media/rtc_media_constraints.h" |
| 15 #include "content/renderer/media/webrtc_audio_device_impl.h" | |
| 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaConstraints .h" | 16 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaConstraints .h" |
| 17 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamCompo nent.h" | |
| 18 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamSourc e.h" | |
| 16 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCConfiguration .h" | 19 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCConfiguration .h" |
| 17 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCICECandidate. h" | 20 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCICECandidate. h" |
| 18 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCPeerConnectio nHandlerClient.h" | 21 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCPeerConnectio nHandlerClient.h" |
| 19 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCSessionDescri ption.h" | 22 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCSessionDescri ption.h" |
| 20 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCSessionDescri ptionRequest.h" | 23 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCSessionDescri ptionRequest.h" |
| 21 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCVoidRequest.h " | 24 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCVoidRequest.h " |
| 22 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" | 25 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" |
| 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 24 | 27 |
| 25 namespace content { | 28 namespace content { |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 | 302 |
| 300 bool return_value = | 303 bool return_value = |
| 301 native_peer_connection_->AddIceCandidate(native_candidate.get()); | 304 native_peer_connection_->AddIceCandidate(native_candidate.get()); |
| 302 LOG_IF(ERROR, !return_value) << "Error processing ICE candidate."; | 305 LOG_IF(ERROR, !return_value) << "Error processing ICE candidate."; |
| 303 return return_value; | 306 return return_value; |
| 304 } | 307 } |
| 305 | 308 |
| 306 bool RTCPeerConnectionHandler::addStream( | 309 bool RTCPeerConnectionHandler::addStream( |
| 307 const WebKit::WebMediaStreamDescriptor& stream, | 310 const WebKit::WebMediaStreamDescriptor& stream, |
| 308 const WebKit::WebMediaConstraints& options) { | 311 const WebKit::WebMediaConstraints& options) { |
| 312 // See if we're adding a WebAudio MediaStream. | |
| 313 WebKit::WebVector<WebKit::WebMediaStreamComponent> audioComponents; | |
| 314 stream.audioSources(audioComponents); | |
| 315 if (audioComponents.size() > 0) { | |
|
perkj_chrome
2012/11/12 10:35:11
This seems to be in the wrong place and should be
| |
| 316 if (audioComponents[0].source().isWebAudioSource()) { | |
| 317 DVLOG(1) << "RTCPeerConnectionHandler: adding WebAudio MediaStream."; | |
| 318 // TODO(crogers, xians): In reality we should be able to send a unique | |
| 319 // audio stream to each PeerConnection separately. But currently WebRTC | |
| 320 // is only able to handle a global audio stream sent to ALL peers. | |
| 321 base::AutoLock auto_lock(audio_lock_); | |
| 322 webaudio_capturer_source_ = new WebAudioCapturerSource(); | |
|
tommi (sloooow) - chröme
2012/11/12 09:46:18
Should we first DCHECK that webaudioÖcapturer_sour
| |
| 323 WebRtcAudioCapturer* capturer = | |
| 324 dependency_factory_->GetWebRtcAudioDevice()->capturer(); | |
|
tommi (sloooow) - chröme
2012/11/12 09:46:18
no chance that GetWebRtcAudioDevice() returns NULL
| |
| 325 capturer->SetCapturerSource(webaudio_capturer_source_); | |
| 326 capturer->Start(); | |
| 327 } | |
| 328 } | |
| 329 | |
| 309 RTCMediaConstraints constraints(options); | 330 RTCMediaConstraints constraints(options); |
| 310 return AddStream(stream, &constraints); | 331 return AddStream(stream, &constraints); |
| 311 } | 332 } |
| 312 | 333 |
| 313 void RTCPeerConnectionHandler::removeStream( | 334 void RTCPeerConnectionHandler::removeStream( |
| 314 const WebKit::WebMediaStreamDescriptor& stream) { | 335 const WebKit::WebMediaStreamDescriptor& stream) { |
| 315 RemoveStream(stream); | 336 RemoveStream(stream); |
| 316 } | 337 } |
| 317 | 338 |
| 318 void RTCPeerConnectionHandler::stop() { | 339 void RTCPeerConnectionHandler::stop() { |
| 319 DVLOG(1) << "RTCPeerConnectionHandler::stop"; | 340 DVLOG(1) << "RTCPeerConnectionHandler::stop"; |
| 320 native_peer_connection_ = NULL; | 341 native_peer_connection_ = NULL; |
| 321 } | 342 } |
| 322 | 343 |
| 344 void RTCPeerConnectionHandler::consumeAudio( | |
| 345 const WebKit::WebVector<const float*>& audio_data, | |
| 346 size_t number_of_frames) { | |
| 347 base::AutoLock auto_lock(audio_lock_); | |
| 348 if (webaudio_capturer_source_.get()) | |
|
tommi (sloooow) - chröme
2012/11/12 09:46:18
nit: scoped_refptr supports checking validity with
| |
| 349 webaudio_capturer_source_->HandleCapture(audio_data, number_of_frames); | |
| 350 } | |
| 351 | |
| 323 void RTCPeerConnectionHandler::OnError() { | 352 void RTCPeerConnectionHandler::OnError() { |
| 324 // TODO(perkj): Implement. | 353 // TODO(perkj): Implement. |
| 325 NOTIMPLEMENTED(); | 354 NOTIMPLEMENTED(); |
| 326 } | 355 } |
| 327 | 356 |
| 328 void RTCPeerConnectionHandler::OnStateChange(StateType state_changed) { | 357 void RTCPeerConnectionHandler::OnStateChange(StateType state_changed) { |
| 329 switch (state_changed) { | 358 switch (state_changed) { |
| 330 case kReadyState: { | 359 case kReadyState: { |
| 331 WebKit::WebRTCPeerConnectionHandlerClient::ReadyState ready_state = | 360 WebKit::WebRTCPeerConnectionHandlerClient::ReadyState ready_state = |
| 332 GetWebKitReadyState(native_peer_connection_->ready_state()); | 361 GetWebKitReadyState(native_peer_connection_->ready_state()); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 404 webrtc::SessionDescriptionInterface* native_desc = | 433 webrtc::SessionDescriptionInterface* native_desc = |
| 405 dependency_factory_->CreateSessionDescription(type, sdp); | 434 dependency_factory_->CreateSessionDescription(type, sdp); |
| 406 | 435 |
| 407 LOG_IF(ERROR, !native_desc) << "Failed to create native session description." | 436 LOG_IF(ERROR, !native_desc) << "Failed to create native session description." |
| 408 << " Type: " << type << " SDP: " << sdp; | 437 << " Type: " << type << " SDP: " << sdp; |
| 409 | 438 |
| 410 return native_desc; | 439 return native_desc; |
| 411 } | 440 } |
| 412 | 441 |
| 413 } // namespace content | 442 } // namespace content |
| OLD | NEW |