| 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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 video_frame->metadata()->MergeInternalValuesInto(¶ms.metadata); | 101 video_frame->metadata()->MergeInternalValuesInto(¶ms.metadata); |
| 102 params.pixel_format = video_frame->format(); | 102 params.pixel_format = video_frame->format(); |
| 103 params.storage_type = video_frame->storage_type(); | 103 params.storage_type = video_frame->storage_type(); |
| 104 params.coded_size = video_frame->coded_size(); | 104 params.coded_size = video_frame->coded_size(); |
| 105 params.visible_rect = video_frame->visible_rect(); | 105 params.visible_rect = video_frame->visible_rect(); |
| 106 | 106 |
| 107 Send(new VideoCaptureMsg_BufferReady(params)); | 107 Send(new VideoCaptureMsg_BufferReady(params)); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void VideoCaptureHost::OnEnded(VideoCaptureControllerID controller_id) { | 110 void VideoCaptureHost::OnEnded(VideoCaptureControllerID controller_id) { |
| 111 DVLOG(1) << "VideoCaptureHost::OnEnded"; | 111 DVLOG(1) << __func__; |
| 112 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 112 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 113 BrowserThread::PostTask( | 113 BrowserThread::PostTask( |
| 114 BrowserThread::IO, FROM_HERE, | 114 BrowserThread::IO, FROM_HERE, |
| 115 base::Bind(&VideoCaptureHost::DoEnded, this, controller_id)); | 115 base::Bind(&VideoCaptureHost::DoEnded, this, controller_id)); |
| 116 } | 116 } |
| 117 | 117 |
| 118 void VideoCaptureHost::DoError(VideoCaptureControllerID controller_id) { | 118 void VideoCaptureHost::DoError(VideoCaptureControllerID controller_id) { |
| 119 DVLOG(1) << "VideoCaptureHost::DoError"; | 119 DVLOG(1) << __func__; |
| 120 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 120 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 121 if (controllers_.find(controller_id) == controllers_.end()) | 121 if (controllers_.find(controller_id) == controllers_.end()) |
| 122 return; | 122 return; |
| 123 | 123 |
| 124 Send(new VideoCaptureMsg_StateChanged(controller_id, | 124 Send(new VideoCaptureMsg_StateChanged(controller_id, |
| 125 VIDEO_CAPTURE_STATE_ERROR)); | 125 VIDEO_CAPTURE_STATE_ERROR)); |
| 126 DeleteVideoCaptureController(controller_id, true); | 126 DeleteVideoCaptureController(controller_id, true); |
| 127 } | 127 } |
| 128 | 128 |
| 129 void VideoCaptureHost::DoEnded(VideoCaptureControllerID controller_id) { | 129 void VideoCaptureHost::DoEnded(VideoCaptureControllerID controller_id) { |
| 130 DVLOG(1) << "VideoCaptureHost::DoEnded"; | 130 DVLOG(1) << __func__; |
| 131 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 131 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 132 if (controllers_.find(controller_id) == controllers_.end()) | 132 if (controllers_.find(controller_id) == controllers_.end()) |
| 133 return; | 133 return; |
| 134 | 134 |
| 135 Send(new VideoCaptureMsg_StateChanged(controller_id, | 135 Send(new VideoCaptureMsg_StateChanged(controller_id, |
| 136 VIDEO_CAPTURE_STATE_ENDED)); | 136 VIDEO_CAPTURE_STATE_ENDED)); |
| 137 DeleteVideoCaptureController(controller_id, false); | 137 DeleteVideoCaptureController(controller_id, false); |
| 138 } | 138 } |
| 139 | 139 |
| 140 /////////////////////////////////////////////////////////////////////////////// | |
| 141 // IPC Messages handler. | |
| 142 bool VideoCaptureHost::OnMessageReceived(const IPC::Message& message) { | 140 bool VideoCaptureHost::OnMessageReceived(const IPC::Message& message) { |
| 143 bool handled = true; | 141 bool handled = true; |
| 144 IPC_BEGIN_MESSAGE_MAP(VideoCaptureHost, message) | 142 IPC_BEGIN_MESSAGE_MAP(VideoCaptureHost, message) |
| 145 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_BufferReady, | 143 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_BufferReady, |
| 146 OnRendererFinishedWithBuffer) | 144 OnRendererFinishedWithBuffer) |
| 147 IPC_MESSAGE_UNHANDLED(handled = false) | 145 IPC_MESSAGE_UNHANDLED(handled = false) |
| 148 IPC_END_MESSAGE_MAP() | 146 IPC_END_MESSAGE_MAP() |
| 149 | 147 |
| 150 return handled; | 148 return handled; |
| 151 } | 149 } |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 return; | 309 return; |
| 312 | 310 |
| 313 if (it->second) { | 311 if (it->second) { |
| 314 media_stream_manager_->video_capture_manager()->StopCaptureForClient( | 312 media_stream_manager_->video_capture_manager()->StopCaptureForClient( |
| 315 it->second.get(), controller_id, this, on_error); | 313 it->second.get(), controller_id, this, on_error); |
| 316 } | 314 } |
| 317 controllers_.erase(it); | 315 controllers_.erase(it); |
| 318 } | 316 } |
| 319 | 317 |
| 320 } // namespace content | 318 } // namespace content |
| OLD | NEW |