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

Side by Side Diff: content/browser/media/capture/content_video_capture_device_core.cc

Issue 457823003: Video capture should set visible size and coded size separately. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Actually separate visible and coded size Created 6 years, 4 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 | Annotate | Revision Log
« 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 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 "content/browser/media/capture/content_video_capture_device_core.h" 5 #include "content/browser/media/capture/content_video_capture_device_core.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/callback_forward.h" 9 #include "base/callback_forward.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 VideoCaptureOracle::Event event, 68 VideoCaptureOracle::Event event,
69 const gfx::Rect& damage_rect, 69 const gfx::Rect& damage_rect,
70 base::TimeTicks event_time, 70 base::TimeTicks event_time,
71 scoped_refptr<media::VideoFrame>* storage, 71 scoped_refptr<media::VideoFrame>* storage,
72 CaptureFrameCallback* callback) { 72 CaptureFrameCallback* callback) {
73 base::AutoLock guard(lock_); 73 base::AutoLock guard(lock_);
74 74
75 if (!client_) 75 if (!client_)
76 return false; // Capture is stopped. 76 return false; // Capture is stopped.
77 77
78 // Always round up the coded size to multiples of 16 pixels.
79 // See http://crbug.com/402151.
80 const gfx::Size visible_size = params_.requested_format.frame_size;
81 const gfx::Size coded_size((visible_size.width() + 15) & ~15,
82 (visible_size.height() + 15) & ~15);
83
78 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> output_buffer = 84 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> output_buffer =
79 client_->ReserveOutputBuffer(video_frame_format_, 85 client_->ReserveOutputBuffer(video_frame_format_, coded_size);
80 params_.requested_format.frame_size);
81 const bool should_capture = 86 const bool should_capture =
82 oracle_->ObserveEventAndDecideCapture(event, damage_rect, event_time); 87 oracle_->ObserveEventAndDecideCapture(event, damage_rect, event_time);
83 const bool content_is_dirty = 88 const bool content_is_dirty =
84 (event == VideoCaptureOracle::kCompositorUpdate || 89 (event == VideoCaptureOracle::kCompositorUpdate ||
85 event == VideoCaptureOracle::kSoftwarePaint); 90 event == VideoCaptureOracle::kSoftwarePaint);
86 const char* event_name = 91 const char* event_name =
87 (event == VideoCaptureOracle::kTimerPoll ? "poll" : 92 (event == VideoCaptureOracle::kTimerPoll ? "poll" :
88 (event == VideoCaptureOracle::kCompositorUpdate ? "gpu" : 93 (event == VideoCaptureOracle::kCompositorUpdate ? "gpu" :
89 "paint")); 94 "paint"));
90 95
(...skipping 25 matching lines...) Expand all
116 } 121 }
117 int frame_number = oracle_->RecordCapture(); 122 int frame_number = oracle_->RecordCapture();
118 TRACE_EVENT_ASYNC_BEGIN2("mirroring", "Capture", output_buffer.get(), 123 TRACE_EVENT_ASYNC_BEGIN2("mirroring", "Capture", output_buffer.get(),
119 "frame_number", frame_number, 124 "frame_number", frame_number,
120 "trigger", event_name); 125 "trigger", event_name);
121 // NATIVE_TEXTURE frames wrap a texture mailbox, which we don't have at the 126 // NATIVE_TEXTURE frames wrap a texture mailbox, which we don't have at the
122 // moment. We do not construct those frames. 127 // moment. We do not construct those frames.
123 if (video_frame_format_ != media::VideoFrame::NATIVE_TEXTURE) { 128 if (video_frame_format_ != media::VideoFrame::NATIVE_TEXTURE) {
124 *storage = media::VideoFrame::WrapExternalPackedMemory( 129 *storage = media::VideoFrame::WrapExternalPackedMemory(
125 video_frame_format_, 130 video_frame_format_,
126 params_.requested_format.frame_size, 131 coded_size,
127 gfx::Rect(params_.requested_format.frame_size), 132 gfx::Rect(visible_size),
128 params_.requested_format.frame_size, 133 visible_size,
129 static_cast<uint8*>(output_buffer->data()), 134 static_cast<uint8*>(output_buffer->data()),
130 output_buffer->size(), 135 output_buffer->size(),
131 base::SharedMemory::NULLHandle(), 136 base::SharedMemory::NULLHandle(),
132 base::TimeDelta(), 137 base::TimeDelta(),
133 base::Closure()); 138 base::Closure());
134 } 139 }
135 *callback = base::Bind(&ThreadSafeCaptureOracle::DidCaptureFrame, 140 *callback = base::Bind(&ThreadSafeCaptureOracle::DidCaptureFrame,
136 this, 141 this,
137 frame_number, 142 frame_number,
138 output_buffer); 143 output_buffer);
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 return; 340 return;
336 341
337 if (oracle_proxy_) 342 if (oracle_proxy_)
338 oracle_proxy_->ReportError(reason); 343 oracle_proxy_->ReportError(reason);
339 344
340 StopAndDeAllocate(); 345 StopAndDeAllocate();
341 TransitionStateTo(kError); 346 TransitionStateTo(kError);
342 } 347 }
343 348
344 } // namespace content 349 } // namespace content
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