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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 if (controllers_.find(controller_id) == controllers_.end()) | 78 if (controllers_.find(controller_id) == controllers_.end()) |
79 return; | 79 return; |
80 | 80 |
81 if (base::ContainsKey(device_id_to_observer_map_, controller_id)) | 81 if (base::ContainsKey(device_id_to_observer_map_, controller_id)) |
82 device_id_to_observer_map_[controller_id]->OnBufferDestroyed(buffer_id); | 82 device_id_to_observer_map_[controller_id]->OnBufferDestroyed(buffer_id); |
83 } | 83 } |
84 | 84 |
85 void VideoCaptureHost::OnBufferReady( | 85 void VideoCaptureHost::OnBufferReady( |
86 VideoCaptureControllerID controller_id, | 86 VideoCaptureControllerID controller_id, |
87 int buffer_id, | 87 int buffer_id, |
88 const scoped_refptr<media::VideoFrame>& video_frame) { | 88 media::mojom::VideoFrameInfoPtr frame_info) { |
89 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 89 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
90 if (controllers_.find(controller_id) == controllers_.end()) | 90 if (controllers_.find(controller_id) == controllers_.end()) |
91 return; | 91 return; |
92 | 92 |
93 if (!base::ContainsKey(device_id_to_observer_map_, controller_id)) | 93 if (!base::ContainsKey(device_id_to_observer_map_, controller_id)) |
94 return; | 94 return; |
95 | 95 |
96 media::mojom::VideoFrameInfoPtr info = media::mojom::VideoFrameInfo::New(); | 96 device_id_to_observer_map_[controller_id]->OnBufferReady( |
97 info->timestamp = video_frame->timestamp(); | 97 buffer_id, std::move(frame_info)); |
98 info->metadata = video_frame->metadata()->CopyInternalValues(); | |
99 | |
100 DCHECK(media::PIXEL_FORMAT_I420 == video_frame->format() || | |
101 media::PIXEL_FORMAT_Y16 == video_frame->format()); | |
102 info->pixel_format = video_frame->format(); | |
103 info->storage_type = media::PIXEL_STORAGE_CPU; | |
104 info->coded_size = video_frame->coded_size(); | |
105 info->visible_rect = video_frame->visible_rect(); | |
106 | |
107 device_id_to_observer_map_[controller_id]->OnBufferReady(buffer_id, | |
108 std::move(info)); | |
109 } | 98 } |
110 | 99 |
111 void VideoCaptureHost::OnEnded(VideoCaptureControllerID controller_id) { | 100 void VideoCaptureHost::OnEnded(VideoCaptureControllerID controller_id) { |
112 DVLOG(1) << __func__; | 101 DVLOG(1) << __func__; |
113 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 102 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
114 BrowserThread::PostTask( | 103 BrowserThread::PostTask( |
115 BrowserThread::IO, FROM_HERE, | 104 BrowserThread::IO, FROM_HERE, |
116 base::Bind(&VideoCaptureHost::DoEnded, weak_factory_.GetWeakPtr(), | 105 base::Bind(&VideoCaptureHost::DoEnded, weak_factory_.GetWeakPtr(), |
117 controller_id)); | 106 controller_id)); |
118 } | 107 } |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 const base::WeakPtr<VideoCaptureController> controller = it->second; | 315 const base::WeakPtr<VideoCaptureController> controller = it->second; |
327 controllers_.erase(it); | 316 controllers_.erase(it); |
328 if (!controller) | 317 if (!controller) |
329 return; | 318 return; |
330 | 319 |
331 media_stream_manager_->video_capture_manager()->StopCaptureForClient( | 320 media_stream_manager_->video_capture_manager()->StopCaptureForClient( |
332 controller.get(), controller_id, this, on_error); | 321 controller.get(), controller_id, this, on_error); |
333 } | 322 } |
334 | 323 |
335 } // namespace content | 324 } // namespace content |
OLD | NEW |