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

Side by Side Diff: media/capture/video/file_video_capture_device.cc

Issue 2076423004: Remove calls to MessageLoop::current() in media. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "media/capture/video/file_video_capture_device.h" 5 #include "media/capture/video/file_video_capture_device.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 325
326 capture_thread_.message_loop()->PostTask( 326 capture_thread_.message_loop()->PostTask(
327 FROM_HERE, base::Bind(&FileVideoCaptureDevice::OnStopAndDeAllocate, 327 FROM_HERE, base::Bind(&FileVideoCaptureDevice::OnStopAndDeAllocate,
328 base::Unretained(this))); 328 base::Unretained(this)));
329 capture_thread_.Stop(); 329 capture_thread_.Stop();
330 } 330 }
331 331
332 void FileVideoCaptureDevice::OnAllocateAndStart( 332 void FileVideoCaptureDevice::OnAllocateAndStart(
333 const VideoCaptureParams& params, 333 const VideoCaptureParams& params,
334 std::unique_ptr<VideoCaptureDevice::Client> client) { 334 std::unique_ptr<VideoCaptureDevice::Client> client) {
335 DCHECK_EQ(capture_thread_.message_loop(), base::MessageLoop::current()); 335 DCHECK(capture_thread_.task_runner()->BelongsToCurrentThread());
336 336
337 client_ = std::move(client); 337 client_ = std::move(client);
338 338
339 DCHECK(!file_parser_); 339 DCHECK(!file_parser_);
340 file_parser_ = GetVideoFileParser(file_path_, &capture_format_); 340 file_parser_ = GetVideoFileParser(file_path_, &capture_format_);
341 if (!file_parser_) { 341 if (!file_parser_) {
342 client_->OnError(FROM_HERE, "Could not open Video file"); 342 client_->OnError(FROM_HERE, "Could not open Video file");
343 return; 343 return;
344 } 344 }
345 345
346 DVLOG(1) << "Opened video file " << capture_format_.frame_size.ToString() 346 DVLOG(1) << "Opened video file " << capture_format_.frame_size.ToString()
347 << ", fps: " << capture_format_.frame_rate; 347 << ", fps: " << capture_format_.frame_rate;
348 348
349 capture_thread_.message_loop()->PostTask( 349 capture_thread_.message_loop()->PostTask(
350 FROM_HERE, base::Bind(&FileVideoCaptureDevice::OnCaptureTask, 350 FROM_HERE, base::Bind(&FileVideoCaptureDevice::OnCaptureTask,
351 base::Unretained(this))); 351 base::Unretained(this)));
352 } 352 }
353 353
354 void FileVideoCaptureDevice::OnStopAndDeAllocate() { 354 void FileVideoCaptureDevice::OnStopAndDeAllocate() {
355 DCHECK_EQ(capture_thread_.message_loop(), base::MessageLoop::current()); 355 DCHECK(capture_thread_.task_runner()->BelongsToCurrentThread());
356 file_parser_.reset(); 356 file_parser_.reset();
357 client_.reset(); 357 client_.reset();
358 next_frame_time_ = base::TimeTicks(); 358 next_frame_time_ = base::TimeTicks();
359 } 359 }
360 360
361 void FileVideoCaptureDevice::OnCaptureTask() { 361 void FileVideoCaptureDevice::OnCaptureTask() {
362 DCHECK_EQ(capture_thread_.message_loop(), base::MessageLoop::current()); 362 DCHECK(capture_thread_.task_runner()->BelongsToCurrentThread());
363 if (!client_) 363 if (!client_)
364 return; 364 return;
365 365
366 // Give the captured frame to the client. 366 // Give the captured frame to the client.
367 int frame_size = 0; 367 int frame_size = 0;
368 const uint8_t* frame_ptr = file_parser_->GetNextFrame(&frame_size); 368 const uint8_t* frame_ptr = file_parser_->GetNextFrame(&frame_size);
369 DCHECK(frame_size); 369 DCHECK(frame_size);
370 CHECK(frame_ptr); 370 CHECK(frame_ptr);
371 const base::TimeTicks current_time = base::TimeTicks::Now(); 371 const base::TimeTicks current_time = base::TimeTicks::Now();
372 if (first_ref_time_.is_null()) 372 if (first_ref_time_.is_null())
(...skipping 12 matching lines...) Expand all
385 if (next_frame_time_ < current_time) 385 if (next_frame_time_ < current_time)
386 next_frame_time_ = current_time; 386 next_frame_time_ = current_time;
387 } 387 }
388 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 388 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
389 FROM_HERE, base::Bind(&FileVideoCaptureDevice::OnCaptureTask, 389 FROM_HERE, base::Bind(&FileVideoCaptureDevice::OnCaptureTask,
390 base::Unretained(this)), 390 base::Unretained(this)),
391 next_frame_time_ - current_time); 391 next_frame_time_ - current_time);
392 } 392 }
393 393
394 } // namespace media 394 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698