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