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

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

Issue 2715713006: Fix for issue 696098 (potential video capture crash ChromeOS) (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/video_capture_device_client.h" 5 #include "media/capture/video/video_capture_device_client.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 auto entry_iter = 326 auto entry_iter =
327 std::find(buffer_ids_known_by_receiver_.begin(), 327 std::find(buffer_ids_known_by_receiver_.begin(),
328 buffer_ids_known_by_receiver_.end(), buffer_id_to_drop); 328 buffer_ids_known_by_receiver_.end(), buffer_id_to_drop);
329 if (entry_iter != buffer_ids_known_by_receiver_.end()) { 329 if (entry_iter != buffer_ids_known_by_receiver_.end()) {
330 buffer_ids_known_by_receiver_.erase(entry_iter); 330 buffer_ids_known_by_receiver_.erase(entry_iter);
331 receiver_->OnBufferRetired(buffer_id_to_drop); 331 receiver_->OnBufferRetired(buffer_id_to_drop);
332 } 332 }
333 } 333 }
334 if (buffer_id == VideoCaptureBufferPool::kInvalidId) 334 if (buffer_id == VideoCaptureBufferPool::kInvalidId)
335 return Buffer(); 335 return Buffer();
336
337 if (!base::ContainsValue(buffer_ids_known_by_receiver_, buffer_id)) {
338 receiver_->OnNewBufferHandle(
339 buffer_id,
340 base::MakeUnique<BufferPoolBufferHandleProvider>(buffer_pool_,
341 buffer_id));
342 buffer_ids_known_by_receiver_.push_back(buffer_id);
343 }
344
336 return MakeBufferStruct(buffer_pool_, buffer_id, frame_feedback_id); 345 return MakeBufferStruct(buffer_pool_, buffer_id, frame_feedback_id);
337 } 346 }
338 347
339 void VideoCaptureDeviceClient::OnIncomingCapturedBuffer( 348 void VideoCaptureDeviceClient::OnIncomingCapturedBuffer(
340 Buffer buffer, 349 Buffer buffer,
341 const VideoCaptureFormat& format, 350 const VideoCaptureFormat& format,
342 base::TimeTicks reference_time, 351 base::TimeTicks reference_time,
343 base::TimeDelta timestamp) { 352 base::TimeDelta timestamp) {
344 DFAKE_SCOPED_RECURSIVE_LOCK(call_from_producer_); 353 DFAKE_SCOPED_RECURSIVE_LOCK(call_from_producer_);
345 OnIncomingCapturedBufferExt(std::move(buffer), format, reference_time, 354 OnIncomingCapturedBufferExt(std::move(buffer), format, reference_time,
346 timestamp, gfx::Rect(format.frame_size), 355 timestamp, gfx::Rect(format.frame_size),
347 VideoFrameMetadata()); 356 VideoFrameMetadata());
348 } 357 }
349 358
350 void VideoCaptureDeviceClient::OnIncomingCapturedBufferExt( 359 void VideoCaptureDeviceClient::OnIncomingCapturedBufferExt(
351 Buffer buffer, 360 Buffer buffer,
352 const VideoCaptureFormat& format, 361 const VideoCaptureFormat& format,
353 base::TimeTicks reference_time, 362 base::TimeTicks reference_time,
354 base::TimeDelta timestamp, 363 base::TimeDelta timestamp,
355 gfx::Rect visible_rect, 364 gfx::Rect visible_rect,
356 const VideoFrameMetadata& additional_metadata) { 365 const VideoFrameMetadata& additional_metadata) {
357 DFAKE_SCOPED_RECURSIVE_LOCK(call_from_producer_); 366 DFAKE_SCOPED_RECURSIVE_LOCK(call_from_producer_);
358 367
359 if (!base::ContainsValue(buffer_ids_known_by_receiver_, buffer.id)) {
360 receiver_->OnNewBufferHandle(buffer.id, std::move(buffer.handle_provider));
361 buffer_ids_known_by_receiver_.push_back(buffer.id);
362 }
363
364 VideoFrameMetadata metadata; 368 VideoFrameMetadata metadata;
365 metadata.MergeMetadataFrom(&additional_metadata); 369 metadata.MergeMetadataFrom(&additional_metadata);
366 metadata.SetDouble(media::VideoFrameMetadata::FRAME_RATE, format.frame_rate); 370 metadata.SetDouble(media::VideoFrameMetadata::FRAME_RATE, format.frame_rate);
367 metadata.SetTimeTicks(media::VideoFrameMetadata::REFERENCE_TIME, 371 metadata.SetTimeTicks(media::VideoFrameMetadata::REFERENCE_TIME,
368 reference_time); 372 reference_time);
369 373
370 mojom::VideoFrameInfoPtr info = mojom::VideoFrameInfo::New(); 374 mojom::VideoFrameInfoPtr info = mojom::VideoFrameInfo::New();
371 info->timestamp = timestamp; 375 info->timestamp = timestamp;
372 info->pixel_format = format.pixel_format; 376 info->pixel_format = format.pixel_format;
373 info->storage_type = format.pixel_storage; 377 info->storage_type = format.pixel_storage;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 auto buffer_access = buffer.handle_provider->GetHandleForInProcessAccess(); 467 auto buffer_access = buffer.handle_provider->GetHandleForInProcessAccess();
464 memcpy(buffer_access->data(), data, length); 468 memcpy(buffer_access->data(), data, length);
465 const VideoCaptureFormat output_format = 469 const VideoCaptureFormat output_format =
466 VideoCaptureFormat(format.frame_size, format.frame_rate, 470 VideoCaptureFormat(format.frame_size, format.frame_rate,
467 media::PIXEL_FORMAT_Y16, media::PIXEL_STORAGE_CPU); 471 media::PIXEL_FORMAT_Y16, media::PIXEL_STORAGE_CPU);
468 OnIncomingCapturedBuffer(std::move(buffer), output_format, reference_time, 472 OnIncomingCapturedBuffer(std::move(buffer), output_format, reference_time,
469 timestamp); 473 timestamp);
470 } 474 }
471 475
472 } // namespace media 476 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698