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

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

Issue 1534273002: Switch to standard integer types in media/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more 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"
8 #include "base/bind.h" 7 #include "base/bind.h"
9 #include "base/bits.h" 8 #include "base/bits.h"
10 #include "base/logging.h" 9 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
12 #include "base/synchronization/lock.h" 11 #include "base/synchronization/lock.h"
13 #include "base/time/time.h" 12 #include "base/time/time.h"
14 #include "base/trace_event/trace_event.h" 13 #include "base/trace_event/trace_event.h"
15 #include "media/base/video_capture_types.h" 14 #include "media/base/video_capture_types.h"
16 #include "media/base/video_frame.h" 15 #include "media/base/video_frame.h"
17 #include "media/base/video_frame_metadata.h" 16 #include "media/base/video_frame_metadata.h"
(...skipping 10 matching lines...) Expand all
28 // buffer pool buffers and a desired safety margin. 27 // buffer pool buffers and a desired safety margin.
29 const int kTargetMaxPoolUtilizationPercent = 60; 28 const int kTargetMaxPoolUtilizationPercent = 60;
30 29
31 } // namespace 30 } // namespace
32 31
33 ThreadSafeCaptureOracle::ThreadSafeCaptureOracle( 32 ThreadSafeCaptureOracle::ThreadSafeCaptureOracle(
34 scoped_ptr<VideoCaptureDevice::Client> client, 33 scoped_ptr<VideoCaptureDevice::Client> client,
35 const VideoCaptureParams& params, 34 const VideoCaptureParams& params,
36 bool enable_auto_throttling) 35 bool enable_auto_throttling)
37 : client_(client.Pass()), 36 : client_(client.Pass()),
38 oracle_(base::TimeDelta::FromMicroseconds(static_cast<int64>( 37 oracle_(base::TimeDelta::FromMicroseconds(static_cast<int64_t>(
39 1000000.0 / params.requested_format.frame_rate + 38 1000000.0 / params.requested_format.frame_rate +
40 0.5 /* to round to nearest int */)), 39 0.5 /* to round to nearest int */)),
41 params.requested_format.frame_size, 40 params.requested_format.frame_size,
42 params.resolution_change_policy, 41 params.resolution_change_policy,
43 enable_auto_throttling), 42 enable_auto_throttling),
44 params_(params) { 43 params_(params) {}
45 }
46 44
47 ThreadSafeCaptureOracle::~ThreadSafeCaptureOracle() { 45 ThreadSafeCaptureOracle::~ThreadSafeCaptureOracle() {
48 } 46 }
49 47
50 bool ThreadSafeCaptureOracle::ObserveEventAndDecideCapture( 48 bool ThreadSafeCaptureOracle::ObserveEventAndDecideCapture(
51 VideoCaptureOracle::Event event, 49 VideoCaptureOracle::Event event,
52 const gfx::Rect& damage_rect, 50 const gfx::Rect& damage_rect,
53 base::TimeTicks event_time, 51 base::TimeTicks event_time,
54 scoped_refptr<VideoFrame>* storage, 52 scoped_refptr<VideoFrame>* storage,
55 CaptureFrameCallback* callback) { 53 CaptureFrameCallback* callback) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 109 }
112 110
113 const int frame_number = oracle_.RecordCapture(attenuated_utilization); 111 const int frame_number = oracle_.RecordCapture(attenuated_utilization);
114 TRACE_EVENT_ASYNC_BEGIN2("gpu.capture", "Capture", output_buffer.get(), 112 TRACE_EVENT_ASYNC_BEGIN2("gpu.capture", "Capture", output_buffer.get(),
115 "frame_number", frame_number, "trigger", event_name); 113 "frame_number", frame_number, "trigger", event_name);
116 114
117 DCHECK_EQ(media::PIXEL_STORAGE_CPU, params_.requested_format.pixel_storage); 115 DCHECK_EQ(media::PIXEL_STORAGE_CPU, params_.requested_format.pixel_storage);
118 *storage = VideoFrame::WrapExternalSharedMemory( 116 *storage = VideoFrame::WrapExternalSharedMemory(
119 params_.requested_format.pixel_format, coded_size, 117 params_.requested_format.pixel_format, coded_size,
120 gfx::Rect(visible_size), visible_size, 118 gfx::Rect(visible_size), visible_size,
121 static_cast<uint8*>(output_buffer->data()), output_buffer->mapped_size(), 119 static_cast<uint8_t*>(output_buffer->data()),
122 base::SharedMemory::NULLHandle(), 0u, base::TimeDelta()); 120 output_buffer->mapped_size(), base::SharedMemory::NULLHandle(), 0u,
121 base::TimeDelta());
123 DCHECK(*storage); 122 DCHECK(*storage);
124 *callback = 123 *callback =
125 base::Bind(&ThreadSafeCaptureOracle::DidCaptureFrame, this, frame_number, 124 base::Bind(&ThreadSafeCaptureOracle::DidCaptureFrame, this, frame_number,
126 base::Passed(&output_buffer), capture_begin_time, 125 base::Passed(&output_buffer), capture_begin_time,
127 oracle_.estimated_frame_duration()); 126 oracle_.estimated_frame_duration());
128 return true; 127 return true;
129 } 128 }
130 129
131 gfx::Size ThreadSafeCaptureOracle::GetCaptureSize() const { 130 gfx::Size ThreadSafeCaptureOracle::GetCaptureSize() const {
132 base::AutoLock guard(lock_); 131 base::AutoLock guard(lock_);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 // destructor. |metadata| is still valid for read-access at this point. 194 // destructor. |metadata| is still valid for read-access at this point.
196 double utilization = -1.0; 195 double utilization = -1.0;
197 if (metadata->GetDouble(media::VideoFrameMetadata::RESOURCE_UTILIZATION, 196 if (metadata->GetDouble(media::VideoFrameMetadata::RESOURCE_UTILIZATION,
198 &utilization)) { 197 &utilization)) {
199 base::AutoLock guard(lock_); 198 base::AutoLock guard(lock_);
200 oracle_.RecordConsumerFeedback(frame_number, utilization); 199 oracle_.RecordConsumerFeedback(frame_number, utilization);
201 } 200 }
202 } 201 }
203 202
204 } // namespace media 203 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698