| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/shell/renderer/shell_media_stream_client.h" | |
| 6 | |
| 7 #include "content/shell/renderer/shell_video_frame_provider.h" | |
| 8 #include "googleurl/src/gurl.h" | |
| 9 #include "third_party/WebKit/public/platform/WebMediaStream.h" | |
| 10 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | |
| 11 #include "third_party/WebKit/public/platform/WebVector.h" | |
| 12 #include "third_party/WebKit/public/web/WebMediaStreamRegistry.h" | |
| 13 #include "webkit/renderer/media/media_stream_audio_renderer.h" | |
| 14 | |
| 15 using namespace WebKit; | |
| 16 | |
| 17 namespace { | |
| 18 | |
| 19 static const int kVideoCaptureWidth = 352; | |
| 20 static const int kVideoCaptureHeight = 288; | |
| 21 static const int kVideoCaptureFrameDurationMs = 33; | |
| 22 | |
| 23 bool IsMockMediaStreamWithVideo(const WebURL& url) { | |
| 24 #if ENABLE_WEBRTC | |
| 25 WebMediaStream descriptor( | |
| 26 WebMediaStreamRegistry::lookupMediaStreamDescriptor(url)); | |
| 27 if (descriptor.isNull()) | |
| 28 return false; | |
| 29 WebVector<WebMediaStreamTrack> videoSources; | |
| 30 descriptor.videoSources(videoSources); | |
| 31 return videoSources.size() > 0; | |
| 32 #else | |
| 33 return false; | |
| 34 #endif | |
| 35 } | |
| 36 | |
| 37 } // namespace | |
| 38 | |
| 39 namespace content { | |
| 40 | |
| 41 ShellMediaStreamClient::ShellMediaStreamClient() {} | |
| 42 | |
| 43 ShellMediaStreamClient::~ShellMediaStreamClient() {} | |
| 44 | |
| 45 bool ShellMediaStreamClient::IsMediaStream(const GURL& url) { | |
| 46 return IsMockMediaStreamWithVideo(url); | |
| 47 } | |
| 48 | |
| 49 scoped_refptr<webkit_media::VideoFrameProvider> | |
| 50 ShellMediaStreamClient::GetVideoFrameProvider( | |
| 51 const GURL& url, | |
| 52 const base::Closure& error_cb, | |
| 53 const webkit_media::VideoFrameProvider::RepaintCB& repaint_cb) { | |
| 54 if (!IsMockMediaStreamWithVideo(url)) | |
| 55 return NULL; | |
| 56 | |
| 57 return new ShellVideoFrameProvider( | |
| 58 gfx::Size(kVideoCaptureWidth, kVideoCaptureHeight), | |
| 59 base::TimeDelta::FromMilliseconds(kVideoCaptureFrameDurationMs), | |
| 60 error_cb, | |
| 61 repaint_cb); | |
| 62 } | |
| 63 | |
| 64 scoped_refptr<webkit_media::MediaStreamAudioRenderer> | |
| 65 ShellMediaStreamClient::GetAudioRenderer(const GURL& url) { | |
| 66 return NULL; | |
| 67 } | |
| 68 | |
| 69 } // namespace content | |
| OLD | NEW |