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/media_stream_impl.h" | 5 #include "content/renderer/media/media_stream_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "content/renderer/media/media_stream_audio_renderer.h" |
13 #include "content/renderer/media/media_stream_dependency_factory.h" | 14 #include "content/renderer/media/media_stream_dependency_factory.h" |
14 #include "content/renderer/media/media_stream_dispatcher.h" | 15 #include "content/renderer/media/media_stream_dispatcher.h" |
15 #include "content/renderer/media/media_stream_extra_data.h" | 16 #include "content/renderer/media/media_stream_extra_data.h" |
16 #include "content/renderer/media/media_stream_source_extra_data.h" | 17 #include "content/renderer/media/media_stream_source_extra_data.h" |
17 #include "content/renderer/media/rtc_video_renderer.h" | 18 #include "content/renderer/media/rtc_video_renderer.h" |
18 #include "content/renderer/media/webrtc_audio_capturer.h" | 19 #include "content/renderer/media/webrtc_audio_capturer.h" |
19 #include "content/renderer/media/webrtc_audio_renderer.h" | 20 #include "content/renderer/media/webrtc_audio_renderer.h" |
20 #include "content/renderer/media/webrtc_local_audio_renderer.h" | 21 #include "content/renderer/media/webrtc_local_audio_renderer.h" |
21 #include "content/renderer/media/webrtc_uma_histograms.h" | 22 #include "content/renderer/media/webrtc_uma_histograms.h" |
22 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" | 23 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" |
23 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" | 24 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" |
24 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 25 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
25 #include "third_party/WebKit/public/platform/WebVector.h" | 26 #include "third_party/WebKit/public/platform/WebVector.h" |
26 #include "third_party/WebKit/public/web/WebDocument.h" | 27 #include "third_party/WebKit/public/web/WebDocument.h" |
27 #include "third_party/WebKit/public/web/WebFrame.h" | 28 #include "third_party/WebKit/public/web/WebFrame.h" |
28 #include "third_party/WebKit/public/web/WebMediaStreamRegistry.h" | 29 #include "third_party/WebKit/public/web/WebMediaStreamRegistry.h" |
29 #include "webkit/renderer/media/media_stream_audio_renderer.h" | |
30 | 30 |
31 namespace content { | 31 namespace content { |
32 namespace { | 32 namespace { |
33 | 33 |
34 std::string GetMandatoryStreamConstraint( | 34 std::string GetMandatoryStreamConstraint( |
35 const WebKit::WebMediaConstraints& constraints, const std::string& key) { | 35 const WebKit::WebMediaConstraints& constraints, const std::string& key) { |
36 if (constraints.isNull()) | 36 if (constraints.isNull()) |
37 return std::string(); | 37 return std::string(); |
38 | 38 |
39 WebKit::WebString value; | 39 WebKit::WebString value; |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 WebKit::WebMediaStreamRegistry::lookupMediaStreamDescriptor(url)); | 211 WebKit::WebMediaStreamRegistry::lookupMediaStreamDescriptor(url)); |
212 | 212 |
213 if (descriptor.isNull() || !descriptor.extraData()) | 213 if (descriptor.isNull() || !descriptor.extraData()) |
214 return false; // This is not a valid stream. | 214 return false; // This is not a valid stream. |
215 | 215 |
216 webrtc::MediaStreamInterface* stream = GetNativeMediaStream(descriptor); | 216 webrtc::MediaStreamInterface* stream = GetNativeMediaStream(descriptor); |
217 return (stream && | 217 return (stream && |
218 (!stream->GetVideoTracks().empty() || !stream->GetAudioTracks().empty())); | 218 (!stream->GetVideoTracks().empty() || !stream->GetAudioTracks().empty())); |
219 } | 219 } |
220 | 220 |
221 scoped_refptr<webkit_media::VideoFrameProvider> | 221 scoped_refptr<VideoFrameProvider> |
222 MediaStreamImpl::GetVideoFrameProvider( | 222 MediaStreamImpl::GetVideoFrameProvider( |
223 const GURL& url, | 223 const GURL& url, |
224 const base::Closure& error_cb, | 224 const base::Closure& error_cb, |
225 const webkit_media::VideoFrameProvider::RepaintCB& repaint_cb) { | 225 const VideoFrameProvider::RepaintCB& repaint_cb) { |
226 DCHECK(CalledOnValidThread()); | 226 DCHECK(CalledOnValidThread()); |
227 WebKit::WebMediaStream descriptor(GetMediaStream(url)); | 227 WebKit::WebMediaStream descriptor(GetMediaStream(url)); |
228 | 228 |
229 if (descriptor.isNull() || !descriptor.extraData()) | 229 if (descriptor.isNull() || !descriptor.extraData()) |
230 return NULL; // This is not a valid stream. | 230 return NULL; // This is not a valid stream. |
231 | 231 |
232 DVLOG(1) << "MediaStreamImpl::GetVideoFrameProvider stream:" | 232 DVLOG(1) << "MediaStreamImpl::GetVideoFrameProvider stream:" |
233 << UTF16ToUTF8(descriptor.label()); | 233 << UTF16ToUTF8(descriptor.label()); |
234 | 234 |
235 webrtc::MediaStreamInterface* stream = GetNativeMediaStream(descriptor); | 235 webrtc::MediaStreamInterface* stream = GetNativeMediaStream(descriptor); |
236 if (stream) | 236 if (stream) |
237 return CreateVideoFrameProvider(stream, error_cb, repaint_cb); | 237 return CreateVideoFrameProvider(stream, error_cb, repaint_cb); |
238 NOTREACHED(); | 238 NOTREACHED(); |
239 return NULL; | 239 return NULL; |
240 } | 240 } |
241 | 241 |
242 scoped_refptr<webkit_media::MediaStreamAudioRenderer> | 242 scoped_refptr<MediaStreamAudioRenderer> |
243 MediaStreamImpl::GetAudioRenderer(const GURL& url) { | 243 MediaStreamImpl::GetAudioRenderer(const GURL& url) { |
244 DCHECK(CalledOnValidThread()); | 244 DCHECK(CalledOnValidThread()); |
245 WebKit::WebMediaStream descriptor(GetMediaStream(url)); | 245 WebKit::WebMediaStream descriptor(GetMediaStream(url)); |
246 | 246 |
247 if (descriptor.isNull() || !descriptor.extraData()) | 247 if (descriptor.isNull() || !descriptor.extraData()) |
248 return NULL; // This is not a valid stream. | 248 return NULL; // This is not a valid stream. |
249 | 249 |
250 DVLOG(1) << "MediaStreamImpl::GetAudioRenderer stream:" | 250 DVLOG(1) << "MediaStreamImpl::GetAudioRenderer stream:" |
251 << UTF16ToUTF8(descriptor.label()); | 251 << UTF16ToUTF8(descriptor.label()); |
252 | 252 |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 media_stream_dispatcher_->CancelGenerateStream( | 500 media_stream_dispatcher_->CancelGenerateStream( |
501 (*request_it)->request_id); | 501 (*request_it)->request_id); |
502 } | 502 } |
503 request_it = user_media_requests_.erase(request_it); | 503 request_it = user_media_requests_.erase(request_it); |
504 } else { | 504 } else { |
505 ++request_it; | 505 ++request_it; |
506 } | 506 } |
507 } | 507 } |
508 } | 508 } |
509 | 509 |
510 scoped_refptr<webkit_media::VideoFrameProvider> | 510 scoped_refptr<VideoFrameProvider> |
511 MediaStreamImpl::CreateVideoFrameProvider( | 511 MediaStreamImpl::CreateVideoFrameProvider( |
512 webrtc::MediaStreamInterface* stream, | 512 webrtc::MediaStreamInterface* stream, |
513 const base::Closure& error_cb, | 513 const base::Closure& error_cb, |
514 const webkit_media::VideoFrameProvider::RepaintCB& repaint_cb) { | 514 const VideoFrameProvider::RepaintCB& repaint_cb) { |
515 if (stream->GetVideoTracks().empty()) | 515 if (stream->GetVideoTracks().empty()) |
516 return NULL; | 516 return NULL; |
517 | 517 |
518 DVLOG(1) << "MediaStreamImpl::CreateRemoteVideoFrameProvider label:" | 518 DVLOG(1) << "MediaStreamImpl::CreateRemoteVideoFrameProvider label:" |
519 << stream->label(); | 519 << stream->label(); |
520 | 520 |
521 return new RTCVideoRenderer( | 521 return new RTCVideoRenderer( |
522 stream->GetVideoTracks()[0], | 522 stream->GetVideoTracks()[0], |
523 error_cb, | 523 error_cb, |
524 repaint_cb); | 524 repaint_cb); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 } | 622 } |
623 | 623 |
624 for (size_t i = 0; i < video_sources.size(); ++i) { | 624 for (size_t i = 0; i < video_sources.size(); ++i) { |
625 video_sources[i].setReadyState( | 625 video_sources[i].setReadyState( |
626 WebKit::WebMediaStreamSource::ReadyStateEnded); | 626 WebKit::WebMediaStreamSource::ReadyStateEnded); |
627 video_sources[i].setExtraData(NULL); | 627 video_sources[i].setExtraData(NULL); |
628 } | 628 } |
629 } | 629 } |
630 | 630 |
631 } // namespace content | 631 } // namespace content |
OLD | NEW |