| 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/browser/renderer_host/media/video_capture_host.h" | 5 #include "content/browser/renderer_host/media/video_capture_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "content/browser/renderer_host/media/media_stream_manager.h" | 10 #include "content/browser/renderer_host/media/media_stream_manager.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 void VideoCaptureHost::OnFrameInfo(const VideoCaptureControllerID& id, | 97 void VideoCaptureHost::OnFrameInfo(const VideoCaptureControllerID& id, |
| 98 int width, | 98 int width, |
| 99 int height, | 99 int height, |
| 100 int frame_per_second) { | 100 int frame_per_second) { |
| 101 BrowserThread::PostTask( | 101 BrowserThread::PostTask( |
| 102 BrowserThread::IO, FROM_HERE, | 102 BrowserThread::IO, FROM_HERE, |
| 103 base::Bind(&VideoCaptureHost::DoSendFrameInfo, | 103 base::Bind(&VideoCaptureHost::DoSendFrameInfo, |
| 104 this, id.device_id, width, height, frame_per_second)); | 104 this, id.device_id, width, height, frame_per_second)); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void VideoCaptureHost::OnPaused(const VideoCaptureControllerID& id) { |
| 108 BrowserThread::PostTask( |
| 109 BrowserThread::IO, FROM_HERE, |
| 110 base::Bind(&VideoCaptureHost::DoPaused, this, id.device_id)); |
| 111 } |
| 112 |
| 107 void VideoCaptureHost::OnReadyToDelete(const VideoCaptureControllerID& id) { | 113 void VideoCaptureHost::OnReadyToDelete(const VideoCaptureControllerID& id) { |
| 108 BrowserThread::PostTask( | 114 BrowserThread::PostTask( |
| 109 BrowserThread::IO, FROM_HERE, | 115 BrowserThread::IO, FROM_HERE, |
| 110 base::Bind(&VideoCaptureHost::DoDeleteVideoCaptureController, this, id)); | 116 base::Bind(&VideoCaptureHost::DoDeleteVideoCaptureController, this, id)); |
| 111 } | 117 } |
| 112 | 118 |
| 113 void VideoCaptureHost::DoSendNewBuffer( | 119 void VideoCaptureHost::DoSendNewBuffer( |
| 114 int device_id, base::SharedMemoryHandle handle, | 120 int device_id, base::SharedMemoryHandle handle, |
| 115 int length, int buffer_id) { | 121 int length, int buffer_id) { |
| 116 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 122 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 136 return; | 142 return; |
| 137 | 143 |
| 138 it->second->state = video_capture::kError; | 144 it->second->state = video_capture::kError; |
| 139 Send(new VideoCaptureMsg_StateChanged(device_id, | 145 Send(new VideoCaptureMsg_StateChanged(device_id, |
| 140 video_capture::kError)); | 146 video_capture::kError)); |
| 141 | 147 |
| 142 VideoCaptureController* controller = it->second->controller; | 148 VideoCaptureController* controller = it->second->controller; |
| 143 controller->StopCapture(id, this, false); | 149 controller->StopCapture(id, this, false); |
| 144 } | 150 } |
| 145 | 151 |
| 152 void VideoCaptureHost::DoPaused(int device_id) { |
| 153 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 154 |
| 155 VideoCaptureControllerID id(device_id); |
| 156 EntryMap::iterator it = entries_.find(id); |
| 157 if (it == entries_.end() || it->second->state == video_capture::kPaused) |
| 158 return; |
| 159 |
| 160 it->second->state = video_capture::kPaused; |
| 161 Send(new VideoCaptureMsg_StateChanged(device_id, |
| 162 video_capture::kPaused)); |
| 163 } |
| 164 |
| 146 void VideoCaptureHost::DoSendFrameInfo(int device_id, | 165 void VideoCaptureHost::DoSendFrameInfo(int device_id, |
| 147 int width, | 166 int width, |
| 148 int height, | 167 int height, |
| 149 int frame_per_second) { | 168 int frame_per_second) { |
| 150 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 169 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 151 | 170 |
| 152 media::VideoCaptureParams params; | 171 media::VideoCaptureParams params; |
| 153 params.width = width; | 172 params.width = width; |
| 154 params.height = height; | 173 params.height = height; |
| 155 params.frame_per_second = frame_per_second; | 174 params.frame_per_second = frame_per_second; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 delete it->second; | 309 delete it->second; |
| 291 entries_.erase(id); | 310 entries_.erase(id); |
| 292 } | 311 } |
| 293 } | 312 } |
| 294 | 313 |
| 295 media_stream::VideoCaptureManager* VideoCaptureHost::GetVideoCaptureManager() { | 314 media_stream::VideoCaptureManager* VideoCaptureHost::GetVideoCaptureManager() { |
| 296 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 315 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 297 return media_stream::MediaStreamManager::GetForResourceContext( | 316 return media_stream::MediaStreamManager::GetForResourceContext( |
| 298 resource_context_, audio_manager_)->video_capture_manager(); | 317 resource_context_, audio_manager_)->video_capture_manager(); |
| 299 } | 318 } |
| OLD | NEW |