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

Side by Side Diff: media/capture/content/thread_safe_capture_oracle.cc

Issue 1476523005: Verify returned frames from media::VideoFrame::Wrap*() methods (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: LOG in video_Frame and CHECK/return outside. Created 5 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/content/thread_safe_capture_oracle.h" 5 #include "media/capture/content/thread_safe_capture_oracle.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bits.h" 9 #include "base/bits.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 const int frame_number = oracle_.RecordCapture(attenuated_utilization); 113 const int frame_number = oracle_.RecordCapture(attenuated_utilization);
114 TRACE_EVENT_ASYNC_BEGIN2("gpu.capture", "Capture", output_buffer.get(), 114 TRACE_EVENT_ASYNC_BEGIN2("gpu.capture", "Capture", output_buffer.get(),
115 "frame_number", frame_number, "trigger", event_name); 115 "frame_number", frame_number, "trigger", event_name);
116 116
117 DCHECK_EQ(media::PIXEL_STORAGE_CPU, params_.requested_format.pixel_storage); 117 DCHECK_EQ(media::PIXEL_STORAGE_CPU, params_.requested_format.pixel_storage);
118 *storage = VideoFrame::WrapExternalSharedMemory( 118 *storage = VideoFrame::WrapExternalSharedMemory(
119 params_.requested_format.pixel_format, coded_size, 119 params_.requested_format.pixel_format, coded_size,
120 gfx::Rect(visible_size), visible_size, 120 gfx::Rect(visible_size), visible_size,
121 static_cast<uint8*>(output_buffer->data()), output_buffer->mapped_size(), 121 static_cast<uint8*>(output_buffer->data()), output_buffer->mapped_size(),
122 base::SharedMemory::NULLHandle(), 0u, base::TimeDelta()); 122 base::SharedMemory::NULLHandle(), 0u, base::TimeDelta());
123 DCHECK(*storage); 123 if (!(*storage))
124 return false;
124 *callback = 125 *callback =
125 base::Bind(&ThreadSafeCaptureOracle::DidCaptureFrame, this, frame_number, 126 base::Bind(&ThreadSafeCaptureOracle::DidCaptureFrame, this, frame_number,
126 base::Passed(&output_buffer), capture_begin_time, 127 base::Passed(&output_buffer), capture_begin_time,
127 oracle_.estimated_frame_duration()); 128 oracle_.estimated_frame_duration());
128 return true; 129 return true;
129 } 130 }
130 131
131 gfx::Size ThreadSafeCaptureOracle::GetCaptureSize() const { 132 gfx::Size ThreadSafeCaptureOracle::GetCaptureSize() const {
132 base::AutoLock guard(lock_); 133 base::AutoLock guard(lock_);
133 return oracle_.capture_size(); 134 return oracle_.capture_size();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 // destructor. |metadata| is still valid for read-access at this point. 196 // destructor. |metadata| is still valid for read-access at this point.
196 double utilization = -1.0; 197 double utilization = -1.0;
197 if (metadata->GetDouble(media::VideoFrameMetadata::RESOURCE_UTILIZATION, 198 if (metadata->GetDouble(media::VideoFrameMetadata::RESOURCE_UTILIZATION,
198 &utilization)) { 199 &utilization)) {
199 base::AutoLock guard(lock_); 200 base::AutoLock guard(lock_);
200 oracle_.RecordConsumerFeedback(frame_number, utilization); 201 oracle_.RecordConsumerFeedback(frame_number, utilization);
201 } 202 }
202 } 203 }
203 204
204 } // namespace media 205 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698