| 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/browser_main_loop.h" | 10 #include "content/browser/browser_main_loop.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 } | 43 } |
| 44 | 44 |
| 45 void VideoCaptureHost::OnDestruct() const { | 45 void VideoCaptureHost::OnDestruct() const { |
| 46 BrowserThread::DeleteOnIOThread::Destruct(this); | 46 BrowserThread::DeleteOnIOThread::Destruct(this); |
| 47 } | 47 } |
| 48 | 48 |
| 49 /////////////////////////////////////////////////////////////////////////////// | 49 /////////////////////////////////////////////////////////////////////////////// |
| 50 | 50 |
| 51 // Implements VideoCaptureControllerEventHandler. | 51 // Implements VideoCaptureControllerEventHandler. |
| 52 void VideoCaptureHost::OnError(const VideoCaptureControllerID& controller_id) { | 52 void VideoCaptureHost::OnError(const VideoCaptureControllerID& controller_id) { |
| 53 DVLOG(1) << "VideoCaptureHost::OnError"; |
| 53 BrowserThread::PostTask( | 54 BrowserThread::PostTask( |
| 54 BrowserThread::IO, FROM_HERE, | 55 BrowserThread::IO, FROM_HERE, |
| 55 base::Bind(&VideoCaptureHost::DoHandleErrorOnIOThread, | 56 base::Bind(&VideoCaptureHost::DoHandleErrorOnIOThread, |
| 56 this, controller_id)); | 57 this, controller_id)); |
| 57 } | 58 } |
| 58 | 59 |
| 59 void VideoCaptureHost::OnBufferCreated( | 60 void VideoCaptureHost::OnBufferCreated( |
| 60 const VideoCaptureControllerID& controller_id, | 61 const VideoCaptureControllerID& controller_id, |
| 61 base::SharedMemoryHandle handle, | 62 base::SharedMemoryHandle handle, |
| 62 int length, | 63 int length, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 81 const VideoCaptureControllerID& controller_id, | 82 const VideoCaptureControllerID& controller_id, |
| 82 int width, | 83 int width, |
| 83 int height, | 84 int height, |
| 84 int frame_per_second) { | 85 int frame_per_second) { |
| 85 BrowserThread::PostTask( | 86 BrowserThread::PostTask( |
| 86 BrowserThread::IO, FROM_HERE, | 87 BrowserThread::IO, FROM_HERE, |
| 87 base::Bind(&VideoCaptureHost::DoSendFrameInfoOnIOThread, | 88 base::Bind(&VideoCaptureHost::DoSendFrameInfoOnIOThread, |
| 88 this, controller_id, width, height, frame_per_second)); | 89 this, controller_id, width, height, frame_per_second)); |
| 89 } | 90 } |
| 90 | 91 |
| 91 void VideoCaptureHost::OnPaused(const VideoCaptureControllerID& controller_id) { | 92 void VideoCaptureHost::OnEnded(const VideoCaptureControllerID& controller_id) { |
| 93 DVLOG(1) << "VideoCaptureHost::OnEnded"; |
| 92 BrowserThread::PostTask( | 94 BrowserThread::PostTask( |
| 93 BrowserThread::IO, FROM_HERE, | 95 BrowserThread::IO, FROM_HERE, |
| 94 base::Bind(&VideoCaptureHost::DoPausedOnIOThread, this, controller_id)); | 96 base::Bind(&VideoCaptureHost::DoEndedOnIOThread, this, controller_id)); |
| 95 } | 97 } |
| 96 | 98 |
| 97 void VideoCaptureHost::DoSendNewBufferOnIOThread( | 99 void VideoCaptureHost::DoSendNewBufferOnIOThread( |
| 98 const VideoCaptureControllerID& controller_id, | 100 const VideoCaptureControllerID& controller_id, |
| 99 base::SharedMemoryHandle handle, | 101 base::SharedMemoryHandle handle, |
| 100 int length, | 102 int length, |
| 101 int buffer_id) { | 103 int buffer_id) { |
| 102 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 104 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 103 | 105 |
| 104 if (entries_.find(controller_id) == entries_.end()) | 106 if (entries_.find(controller_id) == entries_.end()) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 125 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 127 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 126 | 128 |
| 127 if (entries_.find(controller_id) == entries_.end()) | 129 if (entries_.find(controller_id) == entries_.end()) |
| 128 return; | 130 return; |
| 129 | 131 |
| 130 Send(new VideoCaptureMsg_StateChanged(controller_id.device_id, | 132 Send(new VideoCaptureMsg_StateChanged(controller_id.device_id, |
| 131 VIDEO_CAPTURE_STATE_ERROR)); | 133 VIDEO_CAPTURE_STATE_ERROR)); |
| 132 DeleteVideoCaptureControllerOnIOThread(controller_id); | 134 DeleteVideoCaptureControllerOnIOThread(controller_id); |
| 133 } | 135 } |
| 134 | 136 |
| 135 void VideoCaptureHost::DoPausedOnIOThread( | 137 void VideoCaptureHost::DoEndedOnIOThread( |
| 136 const VideoCaptureControllerID& controller_id) { | 138 const VideoCaptureControllerID& controller_id) { |
| 137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 139 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 138 | 140 DVLOG(1) << "VideoCaptureHost::DoEndedOnIOThread"; |
| 139 if (entries_.find(controller_id) == entries_.end()) | 141 if (entries_.find(controller_id) == entries_.end()) |
| 140 return; | 142 return; |
| 141 | 143 |
| 142 Send(new VideoCaptureMsg_StateChanged(controller_id.device_id, | 144 Send(new VideoCaptureMsg_StateChanged(controller_id.device_id, |
| 143 VIDEO_CAPTURE_STATE_PAUSED)); | 145 VIDEO_CAPTURE_STATE_ENDED)); |
| 144 DeleteVideoCaptureControllerOnIOThread(controller_id); | 146 DeleteVideoCaptureControllerOnIOThread(controller_id); |
| 145 } | 147 } |
| 146 | 148 |
| 147 void VideoCaptureHost::DoSendFrameInfoOnIOThread( | 149 void VideoCaptureHost::DoSendFrameInfoOnIOThread( |
| 148 const VideoCaptureControllerID& controller_id, | 150 const VideoCaptureControllerID& controller_id, |
| 149 int width, int height, int frame_per_second) { | 151 int width, int height, int frame_per_second) { |
| 150 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 152 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 151 | 153 |
| 152 if (entries_.find(controller_id) == entries_.end()) | 154 if (entries_.find(controller_id) == entries_.end()) |
| 153 return; | 155 return; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 | 236 |
| 235 VideoCaptureControllerID controller_id(device_id); | 237 VideoCaptureControllerID controller_id(device_id); |
| 236 | 238 |
| 237 Send(new VideoCaptureMsg_StateChanged(device_id, | 239 Send(new VideoCaptureMsg_StateChanged(device_id, |
| 238 VIDEO_CAPTURE_STATE_STOPPED)); | 240 VIDEO_CAPTURE_STATE_STOPPED)); |
| 239 DeleteVideoCaptureControllerOnIOThread(controller_id); | 241 DeleteVideoCaptureControllerOnIOThread(controller_id); |
| 240 } | 242 } |
| 241 | 243 |
| 242 void VideoCaptureHost::OnPauseCapture(int device_id) { | 244 void VideoCaptureHost::OnPauseCapture(int device_id) { |
| 243 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 245 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 246 DVLOG(1) << "VideoCaptureHost::OnPauseCapture, device_id " << device_id; |
| 244 // Not used. | 247 // Not used. |
| 245 Send(new VideoCaptureMsg_StateChanged(device_id, VIDEO_CAPTURE_STATE_ERROR)); | 248 Send(new VideoCaptureMsg_StateChanged(device_id, VIDEO_CAPTURE_STATE_ERROR)); |
| 246 } | 249 } |
| 247 | 250 |
| 248 void VideoCaptureHost::OnReceiveEmptyBuffer(int device_id, int buffer_id) { | 251 void VideoCaptureHost::OnReceiveEmptyBuffer(int device_id, int buffer_id) { |
| 249 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 252 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 250 | 253 |
| 251 VideoCaptureControllerID controller_id(device_id); | 254 VideoCaptureControllerID controller_id(device_id); |
| 252 EntryMap::iterator it = entries_.find(controller_id); | 255 EntryMap::iterator it = entries_.find(controller_id); |
| 253 if (it != entries_.end()) { | 256 if (it != entries_.end()) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 273 delete it->second; | 276 delete it->second; |
| 274 entries_.erase(controller_id); | 277 entries_.erase(controller_id); |
| 275 } | 278 } |
| 276 | 279 |
| 277 VideoCaptureManager* VideoCaptureHost::GetVideoCaptureManager() { | 280 VideoCaptureManager* VideoCaptureHost::GetVideoCaptureManager() { |
| 278 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 281 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 279 return BrowserMainLoop::GetMediaStreamManager()->video_capture_manager(); | 282 return BrowserMainLoop::GetMediaStreamManager()->video_capture_manager(); |
| 280 } | 283 } |
| 281 | 284 |
| 282 } // namespace content | 285 } // namespace content |
| OLD | NEW |