OLD | NEW |
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/thread_safe_capture_oracle.h" | 5 #include "media/capture/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/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 if (!client_) | 46 if (!client_) |
47 return false; // Capture is stopped. | 47 return false; // Capture is stopped. |
48 | 48 |
49 const gfx::Size visible_size = resolution_chooser_.capture_size(); | 49 const gfx::Size visible_size = resolution_chooser_.capture_size(); |
50 // Always round up the coded size to multiple of 16 pixels. | 50 // Always round up the coded size to multiple of 16 pixels. |
51 // See http://crbug.com/402151. | 51 // See http://crbug.com/402151. |
52 const gfx::Size coded_size((visible_size.width() + 15) & ~15, | 52 const gfx::Size coded_size((visible_size.width() + 15) & ~15, |
53 (visible_size.height() + 15) & ~15); | 53 (visible_size.height() + 15) & ~15); |
54 | 54 |
55 scoped_ptr<media::VideoCaptureDevice::Client::Buffer> output_buffer( | 55 scoped_ptr<VideoCaptureDevice::Client::Buffer> output_buffer( |
56 client_->ReserveOutputBuffer(coded_size, | 56 client_->ReserveOutputBuffer(params_.requested_format.pixel_format, |
57 (params_.requested_format.pixel_storage != | 57 coded_size)); |
58 media::PIXEL_STORAGE_TEXTURE) | |
59 ? media::PIXEL_FORMAT_I420 | |
60 : media::PIXEL_FORMAT_ARGB, | |
61 params_.requested_format.pixel_storage)); | |
62 // TODO(miu): Use current buffer pool utilization to drive automatic video | 58 // TODO(miu): Use current buffer pool utilization to drive automatic video |
63 // resolution changes. http://crbug.com/156767. | 59 // resolution changes. http://crbug.com/156767. |
64 VLOG(2) << "Current buffer pool utilization is " | 60 VLOG(2) << "Current buffer pool utilization is " |
65 << (client_->GetBufferPoolUtilization() * 100.0) << '%'; | 61 << (client_->GetBufferPoolUtilization() * 100.0) << '%'; |
66 | 62 |
67 const bool should_capture = | 63 const bool should_capture = |
68 oracle_.ObserveEventAndDecideCapture(event, damage_rect, event_time); | 64 oracle_.ObserveEventAndDecideCapture(event, damage_rect, event_time); |
69 | 65 |
70 const char* event_name = | 66 const char* event_name = |
71 (event == VideoCaptureOracle::kTimerPoll ? "poll" : | 67 (event == VideoCaptureOracle::kTimerPoll ? "poll" : |
(...skipping 23 matching lines...) Expand all Loading... |
95 // to because no output buffer was available. | 91 // to because no output buffer was available. |
96 TRACE_EVENT_INSTANT1("gpu.capture", "NearlyPipelineLimited", | 92 TRACE_EVENT_INSTANT1("gpu.capture", "NearlyPipelineLimited", |
97 TRACE_EVENT_SCOPE_THREAD, | 93 TRACE_EVENT_SCOPE_THREAD, |
98 "trigger", event_name); | 94 "trigger", event_name); |
99 return false; | 95 return false; |
100 } | 96 } |
101 int frame_number = oracle_.RecordCapture(); | 97 int frame_number = oracle_.RecordCapture(); |
102 TRACE_EVENT_ASYNC_BEGIN2("gpu.capture", "Capture", output_buffer.get(), | 98 TRACE_EVENT_ASYNC_BEGIN2("gpu.capture", "Capture", output_buffer.get(), |
103 "frame_number", frame_number, | 99 "frame_number", frame_number, |
104 "trigger", event_name); | 100 "trigger", event_name); |
105 // Texture frames wrap a texture mailbox, which we don't have at the moment. | 101 // NATIVE_TEXTURE frames wrap a texture mailbox, which we don't have at the |
106 // We do not construct those frames. | 102 // moment. We do not construct those frames. |
107 if (params_.requested_format.pixel_storage != media::PIXEL_STORAGE_TEXTURE) { | 103 if (params_.requested_format.pixel_format != PIXEL_FORMAT_TEXTURE) { |
108 *storage = VideoFrame::WrapExternalData( | 104 *storage = VideoFrame::WrapExternalData( |
109 VideoFrame::I420, | 105 VideoFrame::I420, |
110 coded_size, | 106 coded_size, |
111 gfx::Rect(visible_size), | 107 gfx::Rect(visible_size), |
112 visible_size, | 108 visible_size, |
113 static_cast<uint8*>(output_buffer->data()), | 109 static_cast<uint8*>(output_buffer->data()), |
114 output_buffer->size(), | 110 output_buffer->size(), |
115 base::TimeDelta()); | 111 base::TimeDelta()); |
116 DCHECK(*storage); | 112 DCHECK(*storage); |
117 } | 113 } |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 utilization >= 0.0) { | 194 utilization >= 0.0) { |
199 VLOG(2) << "Consumer resource utilization for frame " << frame_number | 195 VLOG(2) << "Consumer resource utilization for frame " << frame_number |
200 << ": " << utilization; | 196 << ": " << utilization; |
201 } | 197 } |
202 | 198 |
203 // TODO(miu): Use |utilization| to drive automatic video resolution changes. | 199 // TODO(miu): Use |utilization| to drive automatic video resolution changes. |
204 // http://crbug.com/156767. | 200 // http://crbug.com/156767. |
205 } | 201 } |
206 | 202 |
207 } // namespace media | 203 } // namespace media |
OLD | NEW |