Chromium Code Reviews| 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/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "content/browser/browser_main_loop.h" | 10 #include "content/browser/browser_main_loop.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 base::SharedMemoryHandle handle, | 59 base::SharedMemoryHandle handle, |
| 60 int length, | 60 int length, |
| 61 int buffer_id) { | 61 int buffer_id) { |
| 62 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 62 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 63 if (entries_.find(controller_id) == entries_.end()) | 63 if (entries_.find(controller_id) == entries_.end()) |
| 64 return; | 64 return; |
| 65 | 65 |
| 66 Send(new VideoCaptureMsg_NewBuffer(controller_id, handle, length, buffer_id)); | 66 Send(new VideoCaptureMsg_NewBuffer(controller_id, handle, length, buffer_id)); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void VideoCaptureHost::OnGpuMemoryBufferCreated( | |
| 70 VideoCaptureControllerID controller_id, | |
| 71 const std::vector<gfx::GpuMemoryBufferHandle>& gmb_handles, | |
| 72 const gfx::Size& size, | |
| 73 int buffer_id) { | |
| 74 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 75 if (entries_.find(controller_id) == entries_.end()) | |
| 76 return; | |
| 77 | |
| 78 Send(new VideoCaptureMsg_NewGpuMemoryBuffer(controller_id, gmb_handles, size, | |
| 79 buffer_id)); | |
| 80 } | |
| 81 | |
| 69 void VideoCaptureHost::OnBufferDestroyed(VideoCaptureControllerID controller_id, | 82 void VideoCaptureHost::OnBufferDestroyed(VideoCaptureControllerID controller_id, |
| 70 int buffer_id) { | 83 int buffer_id) { |
| 71 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 84 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 72 if (entries_.find(controller_id) == entries_.end()) | 85 if (entries_.find(controller_id) == entries_.end()) |
| 73 return; | 86 return; |
| 74 | 87 |
| 75 Send(new VideoCaptureMsg_FreeBuffer(controller_id, buffer_id)); | 88 Send(new VideoCaptureMsg_FreeBuffer(controller_id, buffer_id)); |
| 76 } | 89 } |
| 77 | 90 |
| 78 void VideoCaptureHost::OnBufferReady( | 91 void VideoCaptureHost::OnBufferReady( |
| 79 VideoCaptureControllerID controller_id, | 92 VideoCaptureControllerID controller_id, |
| 80 int buffer_id, | 93 int buffer_id, |
| 81 const scoped_refptr<media::VideoFrame>& video_frame, | 94 const scoped_refptr<media::VideoFrame>& video_frame, |
| 82 const base::TimeTicks& timestamp) { | 95 const base::TimeTicks& timestamp) { |
| 83 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 96 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 84 if (entries_.find(controller_id) == entries_.end()) | 97 if (entries_.find(controller_id) == entries_.end()) |
| 85 return; | 98 return; |
| 86 | 99 |
| 87 VideoCaptureMsg_BufferReady_Params params; | 100 VideoCaptureMsg_BufferReady_Params params; |
| 88 params.device_id = controller_id; | 101 params.device_id = controller_id; |
| 89 params.buffer_id = buffer_id; | 102 params.buffer_id = buffer_id; |
| 90 params.timestamp = timestamp; | 103 params.timestamp = timestamp; |
| 91 video_frame->metadata()->MergeInternalValuesInto(¶ms.metadata); | 104 video_frame->metadata()->MergeInternalValuesInto(¶ms.metadata); |
| 92 params.pixel_format = video_frame->format(); | 105 params.pixel_format = video_frame->format(); |
| 93 params.storage_type = video_frame->storage_type(); | 106 params.storage_type = video_frame->storage_type(); |
| 94 params.coded_size = video_frame->coded_size(); | 107 params.coded_size = video_frame->coded_size(); |
| 95 params.visible_rect = video_frame->visible_rect(); | 108 params.visible_rect = video_frame->visible_rect(); |
| 96 if (video_frame->HasTextures()) { | 109 if (video_frame->HasTextures()) { |
| 97 DCHECK_EQ(media::VideoFrame::NumPlanes(video_frame->format()), 1u) | 110 for (size_t i = 0; i < media::VideoFrame::NumPlanes(video_frame->format()); |
| 98 << "Multiplanar textures not supported"; | 111 ++i) |
|
mcasas
2015/08/21 03:57:25
Needs {}
emircan
2015/08/22 03:13:26
Done.
| |
| 99 params.mailbox_holder = video_frame->mailbox_holder(0); | 112 params.mailbox_holders.push_back(video_frame->mailbox_holder(i)); |
| 100 } | 113 } |
| 101 | 114 |
| 102 Send(new VideoCaptureMsg_BufferReady(params)); | 115 Send(new VideoCaptureMsg_BufferReady(params)); |
| 103 } | 116 } |
| 104 | 117 |
| 105 void VideoCaptureHost::OnEnded(VideoCaptureControllerID controller_id) { | 118 void VideoCaptureHost::OnEnded(VideoCaptureControllerID controller_id) { |
| 106 DVLOG(1) << "VideoCaptureHost::OnEnded"; | 119 DVLOG(1) << "VideoCaptureHost::OnEnded"; |
| 107 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 120 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 108 BrowserThread::PostTask( | 121 BrowserThread::PostTask( |
| 109 BrowserThread::IO, FROM_HERE, | 122 BrowserThread::IO, FROM_HERE, |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 319 return; | 332 return; |
| 320 | 333 |
| 321 if (it->second) { | 334 if (it->second) { |
| 322 media_stream_manager_->video_capture_manager()->StopCaptureForClient( | 335 media_stream_manager_->video_capture_manager()->StopCaptureForClient( |
| 323 it->second.get(), controller_id, this, on_error); | 336 it->second.get(), controller_id, this, on_error); |
| 324 } | 337 } |
| 325 entries_.erase(it); | 338 entries_.erase(it); |
| 326 } | 339 } |
| 327 | 340 |
| 328 } // namespace content | 341 } // namespace content |
| OLD | NEW |