Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: content/renderer/media/video_capture_impl.cc

Issue 1083883003: Move BindToCurrentLoop from media/base/ to base/ Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix media/base/callback_holder.h compile Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // Notes about usage of this object by VideoCaptureImplManager. 5 // Notes about usage of this object by VideoCaptureImplManager.
6 // 6 //
7 // VideoCaptureImplManager access this object by using a Unretained() 7 // VideoCaptureImplManager access this object by using a Unretained()
8 // binding and tasks on the IO thread. It is then important that 8 // binding and tasks on the IO thread. It is then important that
9 // VideoCaptureImpl never post task to itself. All operations must be 9 // VideoCaptureImpl never post task to itself. All operations must be
10 // synchronous. 10 // synchronous.
11 11
12 #include "content/renderer/media/video_capture_impl.h" 12 #include "content/renderer/media/video_capture_impl.h"
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/bind_to_current_loop.h"
15 #include "base/stl_util.h" 16 #include "base/stl_util.h"
16 #include "content/child/child_process.h" 17 #include "content/child/child_process.h"
17 #include "content/common/media/video_capture_messages.h" 18 #include "content/common/media/video_capture_messages.h"
18 #include "media/base/bind_to_current_loop.h"
19 #include "media/base/limits.h" 19 #include "media/base/limits.h"
20 #include "media/base/video_frame.h" 20 #include "media/base/video_frame.h"
21 21
22 namespace content { 22 namespace content {
23 23
24 class VideoCaptureImpl::ClientBuffer 24 class VideoCaptureImpl::ClientBuffer
25 : public base::RefCountedThreadSafe<ClientBuffer> { 25 : public base::RefCountedThreadSafe<ClientBuffer> {
26 public: 26 public:
27 ClientBuffer(scoped_ptr<base::SharedMemory> buffer, 27 ClientBuffer(scoped_ptr<base::SharedMemory> buffer,
28 size_t buffer_size) 28 size_t buffer_size)
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 media::VideoFrame::WrapExternalPackedMemory( 240 media::VideoFrame::WrapExternalPackedMemory(
241 media::VideoFrame::I420, 241 media::VideoFrame::I420,
242 coded_size, 242 coded_size,
243 visible_rect, 243 visible_rect,
244 gfx::Size(visible_rect.width(), visible_rect.height()), 244 gfx::Size(visible_rect.width(), visible_rect.height()),
245 reinterpret_cast<uint8*>(buffer->buffer->memory()), 245 reinterpret_cast<uint8*>(buffer->buffer->memory()),
246 buffer->buffer_size, 246 buffer->buffer_size,
247 buffer->buffer->handle(), 247 buffer->buffer->handle(),
248 0, 248 0,
249 timestamp - first_frame_timestamp_, 249 timestamp - first_frame_timestamp_,
250 media::BindToCurrentLoop( 250 base::BindToCurrentLoop(
251 base::Bind(&VideoCaptureImpl::OnClientBufferFinished, 251 base::Bind(&VideoCaptureImpl::OnClientBufferFinished,
252 weak_factory_.GetWeakPtr(), 252 weak_factory_.GetWeakPtr(),
253 buffer_id, 253 buffer_id,
254 buffer, 254 buffer,
255 0))); 255 0)));
256 frame->metadata()->MergeInternalValuesFrom(metadata); 256 frame->metadata()->MergeInternalValuesFrom(metadata);
257 257
258 for (const auto& client : clients_) 258 for (const auto& client : clients_)
259 client.second.deliver_frame_cb.Run(frame, timestamp); 259 client.second.deliver_frame_cb.Run(frame, timestamp);
260 } 260 }
261 261
262 void VideoCaptureImpl::OnMailboxBufferReceived( 262 void VideoCaptureImpl::OnMailboxBufferReceived(
263 int buffer_id, 263 int buffer_id,
264 const gpu::MailboxHolder& mailbox_holder, 264 const gpu::MailboxHolder& mailbox_holder,
265 const gfx::Size& packed_frame_size, 265 const gfx::Size& packed_frame_size,
266 base::TimeTicks timestamp, 266 base::TimeTicks timestamp,
267 const base::DictionaryValue& metadata) { 267 const base::DictionaryValue& metadata) {
268 DCHECK(io_message_loop_->BelongsToCurrentThread()); 268 DCHECK(io_message_loop_->BelongsToCurrentThread());
269 269
270 if (state_ != VIDEO_CAPTURE_STATE_STARTED || suspended_) { 270 if (state_ != VIDEO_CAPTURE_STATE_STARTED || suspended_) {
271 Send(new VideoCaptureHostMsg_BufferReady(device_id_, buffer_id, 0)); 271 Send(new VideoCaptureHostMsg_BufferReady(device_id_, buffer_id, 0));
272 return; 272 return;
273 } 273 }
274 274
275 if (first_frame_timestamp_.is_null()) 275 if (first_frame_timestamp_.is_null())
276 first_frame_timestamp_ = timestamp; 276 first_frame_timestamp_ = timestamp;
277 277
278 scoped_refptr<media::VideoFrame> frame = media::VideoFrame::WrapNativeTexture( 278 scoped_refptr<media::VideoFrame> frame = media::VideoFrame::WrapNativeTexture(
279 make_scoped_ptr(new gpu::MailboxHolder(mailbox_holder)), 279 make_scoped_ptr(new gpu::MailboxHolder(mailbox_holder)),
280 media::BindToCurrentLoop(base::Bind( 280 base::BindToCurrentLoop(base::Bind(
281 &VideoCaptureImpl::OnClientBufferFinished, weak_factory_.GetWeakPtr(), 281 &VideoCaptureImpl::OnClientBufferFinished, weak_factory_.GetWeakPtr(),
282 buffer_id, scoped_refptr<ClientBuffer>())), 282 buffer_id, scoped_refptr<ClientBuffer>())),
283 packed_frame_size, gfx::Rect(packed_frame_size), packed_frame_size, 283 packed_frame_size, gfx::Rect(packed_frame_size), packed_frame_size,
284 timestamp - first_frame_timestamp_, false); 284 timestamp - first_frame_timestamp_, false);
285 frame->metadata()->MergeInternalValuesFrom(metadata); 285 frame->metadata()->MergeInternalValuesFrom(metadata);
286 286
287 for (const auto& client : clients_) 287 for (const auto& client : clients_)
288 client.second.deliver_frame_cb.Run(frame, timestamp); 288 client.second.deliver_frame_cb.Run(frame, timestamp);
289 } 289 }
290 290
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 const ClientInfoMap::iterator it = clients->find(client_id); 420 const ClientInfoMap::iterator it = clients->find(client_id);
421 if (it != clients->end()) { 421 if (it != clients->end()) {
422 it->second.state_update_cb.Run(VIDEO_CAPTURE_STATE_STOPPED); 422 it->second.state_update_cb.Run(VIDEO_CAPTURE_STATE_STOPPED);
423 clients->erase(it); 423 clients->erase(it);
424 found = true; 424 found = true;
425 } 425 }
426 return found; 426 return found;
427 } 427 }
428 428
429 } // namespace content 429 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/rtc_video_renderer.cc ('k') | content/renderer/media/video_capture_impl_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698