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_controller.h" | 5 #include "content/browser/renderer_host/media/video_capture_controller.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 350 } | 350 } |
| 351 | 351 |
| 352 VideoCaptureController::~VideoCaptureController() { | 352 VideoCaptureController::~VideoCaptureController() { |
| 353 STLDeleteContainerPointers(controller_clients_.begin(), | 353 STLDeleteContainerPointers(controller_clients_.begin(), |
| 354 controller_clients_.end()); | 354 controller_clients_.end()); |
| 355 } | 355 } |
| 356 | 356 |
| 357 void VideoCaptureController::DoIncomingCapturedVideoFrameOnIOThread( | 357 void VideoCaptureController::DoIncomingCapturedVideoFrameOnIOThread( |
| 358 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> buffer, | 358 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> buffer, |
| 359 const scoped_refptr<VideoFrame>& frame, | 359 const scoped_refptr<VideoFrame>& frame, |
| 360 const base::TimeTicks& timestamp) { | 360 base::TimeTicks reference_time) { |
|
miu
2016/06/07 20:03:47
(See comment for video_capture_host.cc.) You could
qiangchen
2016/06/08 18:04:30
Done.
| |
| 361 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 361 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 362 const int buffer_id = buffer->id(); | 362 const int buffer_id = buffer->id(); |
| 363 DCHECK_NE(buffer_id, VideoCaptureBufferPool::kInvalidId); | 363 DCHECK_NE(buffer_id, VideoCaptureBufferPool::kInvalidId); |
| 364 | 364 |
| 365 int count = 0; | 365 int count = 0; |
| 366 if (state_ == VIDEO_CAPTURE_STATE_STARTED) { | 366 if (state_ == VIDEO_CAPTURE_STATE_STARTED) { |
| 367 if (!frame->metadata()->HasKey(VideoFrameMetadata::FRAME_RATE)) { | 367 if (!frame->metadata()->HasKey(VideoFrameMetadata::FRAME_RATE)) { |
| 368 frame->metadata()->SetDouble(VideoFrameMetadata::FRAME_RATE, | 368 frame->metadata()->SetDouble(VideoFrameMetadata::FRAME_RATE, |
| 369 video_capture_format_.frame_rate); | 369 video_capture_format_.frame_rate); |
| 370 } | 370 } |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 389 | 389 |
| 390 for (const auto& client : controller_clients_) { | 390 for (const auto& client : controller_clients_) { |
| 391 if (client->session_closed || client->paused) | 391 if (client->session_closed || client->paused) |
| 392 continue; | 392 continue; |
| 393 | 393 |
| 394 // On the first use of a buffer on a client, share the memory handles. | 394 // On the first use of a buffer on a client, share the memory handles. |
| 395 const bool is_new_buffer = client->known_buffers.insert(buffer_id).second; | 395 const bool is_new_buffer = client->known_buffers.insert(buffer_id).second; |
| 396 if (is_new_buffer) | 396 if (is_new_buffer) |
| 397 DoNewBufferOnIOThread(client, buffer.get(), frame); | 397 DoNewBufferOnIOThread(client, buffer.get(), frame); |
| 398 | 398 |
| 399 client->event_handler->OnBufferReady(client->controller_id, | 399 client->event_handler->OnBufferReady(client->controller_id, buffer_id, |
| 400 buffer_id, | 400 frame, reference_time); |
| 401 frame, | |
| 402 timestamp); | |
| 403 const bool inserted = | 401 const bool inserted = |
| 404 client->active_buffers.insert(std::make_pair(buffer_id, frame)) | 402 client->active_buffers.insert(std::make_pair(buffer_id, frame)) |
| 405 .second; | 403 .second; |
| 406 DCHECK(inserted) << "Unexpected duplicate buffer: " << buffer_id; | 404 DCHECK(inserted) << "Unexpected duplicate buffer: " << buffer_id; |
| 407 count++; | 405 count++; |
| 408 } | 406 } |
| 409 } | 407 } |
| 410 | 408 |
| 411 if (!has_received_frames_) { | 409 if (!has_received_frames_) { |
| 412 UMA_HISTOGRAM_COUNTS("Media.VideoCapture.Width", | 410 UMA_HISTOGRAM_COUNTS("Media.VideoCapture.Width", |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 510 int session_id, | 508 int session_id, |
| 511 const ControllerClients& clients) { | 509 const ControllerClients& clients) { |
| 512 for (auto client : clients) { | 510 for (auto client : clients) { |
| 513 if (client->session_id == session_id) | 511 if (client->session_id == session_id) |
| 514 return client; | 512 return client; |
| 515 } | 513 } |
| 516 return NULL; | 514 return NULL; |
| 517 } | 515 } |
| 518 | 516 |
| 519 } // namespace content | 517 } // namespace content |
| OLD | NEW |