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

Side by Side Diff: remoting/client/software_video_renderer.cc

Issue 1288063004: Simplify FrameConsumer interface. Remove FrameProducer interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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 "remoting/client/software_video_renderer.h" 5 #include "remoting/client/software_video_renderer.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/callback_helpers.h" 11 #include "base/callback_helpers.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
15 #include "base/task_runner_util.h"
15 #include "remoting/base/util.h" 16 #include "remoting/base/util.h"
16 #include "remoting/client/frame_consumer.h" 17 #include "remoting/client/frame_consumer.h"
17 #include "remoting/codec/video_decoder.h" 18 #include "remoting/codec/video_decoder.h"
18 #include "remoting/codec/video_decoder_verbatim.h" 19 #include "remoting/codec/video_decoder_verbatim.h"
19 #include "remoting/codec/video_decoder_vpx.h" 20 #include "remoting/codec/video_decoder_vpx.h"
21 #include "remoting/proto/video.pb.h"
20 #include "remoting/protocol/session_config.h" 22 #include "remoting/protocol/session_config.h"
21 #include "third_party/libyuv/include/libyuv/convert_argb.h" 23 #include "third_party/libyuv/include/libyuv/convert_argb.h"
22 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" 24 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
23 25
24 using base::Passed;
25 using remoting::protocol::ChannelConfig; 26 using remoting::protocol::ChannelConfig;
26 using remoting::protocol::SessionConfig; 27 using remoting::protocol::SessionConfig;
27 28
28 namespace remoting { 29 namespace remoting {
29 30
31 namespace {
32
30 // This class wraps a VideoDecoder and byte-swaps the pixels for compatibility 33 // This class wraps a VideoDecoder and byte-swaps the pixels for compatibility
31 // with the android.graphics.Bitmap class. 34 // with the android.graphics.Bitmap class.
32 // TODO(lambroslambrou): Refactor so that the VideoDecoder produces data 35 // TODO(lambroslambrou): Refactor so that the VideoDecoder produces data
33 // in the right byte-order, instead of swapping it here. 36 // in the right byte-order, instead of swapping it here.
34 class RgbToBgrVideoDecoderFilter : public VideoDecoder { 37 class RgbToBgrVideoDecoderFilter : public VideoDecoder {
35 public: 38 public:
36 RgbToBgrVideoDecoderFilter(scoped_ptr<VideoDecoder> parent) 39 RgbToBgrVideoDecoderFilter(scoped_ptr<VideoDecoder> parent)
37 : parent_(parent.Pass()) { 40 : parent_(parent.Pass()) {}
38 }
39 41
40 bool DecodePacket(const VideoPacket& packet) override { 42 bool DecodePacket(const VideoPacket& packet) override {
41 return parent_->DecodePacket(packet); 43 return parent_->DecodePacket(packet);
42 } 44 }
43 45
44 void Invalidate(const webrtc::DesktopSize& view_size, 46 void Invalidate(const webrtc::DesktopSize& view_size,
45 const webrtc::DesktopRegion& region) override { 47 const webrtc::DesktopRegion& region) override {
46 return parent_->Invalidate(view_size, region); 48 return parent_->Invalidate(view_size, region);
47 } 49 }
48 50
49 void RenderFrame(const webrtc::DesktopSize& view_size, 51 void RenderFrame(const webrtc::DesktopSize& view_size,
50 const webrtc::DesktopRect& clip_area, 52 const webrtc::DesktopRect& clip_area,
51 uint8* image_buffer, 53 uint8* image_buffer,
52 int image_stride, 54 int image_stride,
53 webrtc::DesktopRegion* output_region) override { 55 webrtc::DesktopRegion* output_region) override {
54 parent_->RenderFrame(view_size, clip_area, image_buffer, image_stride, 56 parent_->RenderFrame(view_size, clip_area, image_buffer, image_stride,
55 output_region); 57 output_region);
56 58
57 for (webrtc::DesktopRegion::Iterator i(*output_region); !i.IsAtEnd(); 59 for (webrtc::DesktopRegion::Iterator i(*output_region); !i.IsAtEnd();
58 i.Advance()) { 60 i.Advance()) {
59 webrtc::DesktopRect rect = i.rect(); 61 webrtc::DesktopRect rect = i.rect();
60 uint8* pixels = image_buffer + (rect.top() * image_stride) + 62 uint8* pixels = image_buffer + (rect.top() * image_stride) +
61 (rect.left() * kBytesPerPixel); 63 (rect.left() * kBytesPerPixel);
62 libyuv::ABGRToARGB(pixels, image_stride, pixels, image_stride, 64 libyuv::ABGRToARGB(pixels, image_stride, pixels, image_stride,
63 rect.width(), rect.height()); 65 rect.width(), rect.height());
64 } 66 }
65 } 67 }
66 68
67 const webrtc::DesktopRegion* GetImageShape() override { 69 const webrtc::DesktopRegion* GetImageShape() override {
68 return parent_->GetImageShape(); 70 return parent_->GetImageShape();
69 } 71 }
70 72
71 private: 73 private:
72 scoped_ptr<VideoDecoder> parent_; 74 scoped_ptr<VideoDecoder> parent_;
73 }; 75 };
74 76
75 class SoftwareVideoRenderer::Core { 77 scoped_ptr<webrtc::DesktopFrame> DoDecodeFrame(
76 public: 78 VideoDecoder* decoder,
77 Core(scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 79 scoped_ptr<VideoPacket> packet,
78 scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner, 80 scoped_ptr<webrtc::DesktopFrame> frame) {
79 scoped_ptr<FrameConsumerProxy> consumer); 81 if (!decoder->DecodePacket(*packet))
80 ~Core(); 82 frame.reset();
Jamie 2015/08/19 20:52:10 Won't this cause a null deref on the next line?
Sergey Ulanov 2015/08/19 23:37:13 It would. Thanks for catching it!
81 83
82 void OnSessionConfig(const protocol::SessionConfig& config); 84 decoder->RenderFrame(
83 void DrawBuffer(webrtc::DesktopFrame* buffer); 85 frame->size(), webrtc::DesktopRect::MakeSize(frame->size()),
84 void InvalidateRegion(const webrtc::DesktopRegion& region); 86 frame->data(), frame->stride(), frame->mutable_updated_region());
85 void RequestReturnBuffers(const base::Closure& done);
86 void SetOutputSizeAndClip(
87 const webrtc::DesktopSize& view_size,
88 const webrtc::DesktopRect& clip_area);
89 87
90 // Decodes the contents of |packet|. DecodePacket may keep a reference to 88 const webrtc::DesktopRegion* shape = decoder->GetImageShape();
91 // |packet| so the |packet| must remain alive and valid until |done| is 89 if (shape)
92 // executed. 90 frame->set_shape(new webrtc::DesktopRegion(*shape));
93 void DecodePacket(scoped_ptr<VideoPacket> packet, const base::Closure& done);
94 91
95 private: 92 return frame.Pass();
96 // Paints the invalidated region to the next available buffer and returns it 93 }
97 // to the consumer.
98 void SchedulePaint();
99 void DoPaint();
100 94
101 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; 95 } // namespace
102 scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner_;
103 scoped_ptr<FrameConsumerProxy> consumer_;
104 scoped_ptr<VideoDecoder> decoder_;
105 96
106 // Remote screen size in pixels. 97 SoftwareVideoRenderer::SoftwareVideoRenderer(
107 webrtc::DesktopSize source_size_;
108
109 // Vertical and horizontal DPI of the remote screen.
110 webrtc::DesktopVector source_dpi_;
111
112 // The current dimensions of the frame consumer view.
113 webrtc::DesktopSize view_size_;
114 webrtc::DesktopRect clip_area_;
115
116 // The drawing buffers supplied by the frame consumer.
117 std::list<webrtc::DesktopFrame*> buffers_;
118
119 // Flag used to coalesce runs of SchedulePaint()s into a single DoPaint().
120 bool paint_scheduled_;
121
122 base::WeakPtrFactory<Core> weak_factory_;
123 };
124
125 SoftwareVideoRenderer::Core::Core(
126 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
127 scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner, 98 scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner,
128 scoped_ptr<FrameConsumerProxy> consumer) 99 FrameConsumer* consumer)
129 : main_task_runner_(main_task_runner), 100 : decode_task_runner_(decode_task_runner),
130 decode_task_runner_(decode_task_runner), 101 consumer_(consumer),
131 consumer_(consumer.Pass()),
132 paint_scheduled_(false),
133 weak_factory_(this) {} 102 weak_factory_(this) {}
134 103
135 SoftwareVideoRenderer::Core::~Core() { 104 SoftwareVideoRenderer::~SoftwareVideoRenderer() {
105 if (decoder_)
106 decode_task_runner_->DeleteSoon(FROM_HERE, decoder_.release());
136 } 107 }
137 108
138 void SoftwareVideoRenderer::Core::OnSessionConfig(const SessionConfig& config) { 109 void SoftwareVideoRenderer::OnSessionConfig(
139 DCHECK(decode_task_runner_->BelongsToCurrentThread()); 110 const protocol::SessionConfig& config) {
111 DCHECK(thread_checker_.CalledOnValidThread());
140 112
141 // Initialize decoder based on the selected codec. 113 // Initialize decoder based on the selected codec.
142 ChannelConfig::Codec codec = config.video_config().codec; 114 ChannelConfig::Codec codec = config.video_config().codec;
143 if (codec == ChannelConfig::CODEC_VERBATIM) { 115 if (codec == ChannelConfig::CODEC_VERBATIM) {
144 decoder_.reset(new VideoDecoderVerbatim()); 116 decoder_.reset(new VideoDecoderVerbatim());
145 } else if (codec == ChannelConfig::CODEC_VP8) { 117 } else if (codec == ChannelConfig::CODEC_VP8) {
146 decoder_ = VideoDecoderVpx::CreateForVP8(); 118 decoder_ = VideoDecoderVpx::CreateForVP8();
147 } else if (codec == ChannelConfig::CODEC_VP9) { 119 } else if (codec == ChannelConfig::CODEC_VP9) {
148 decoder_ = VideoDecoderVpx::CreateForVP9(); 120 decoder_ = VideoDecoderVpx::CreateForVP9();
149 } else { 121 } else {
150 NOTREACHED() << "Invalid Encoding found: " << codec; 122 NOTREACHED() << "Invalid Encoding found: " << codec;
151 } 123 }
152 124
153 if (consumer_->GetPixelFormat() == FrameConsumer::FORMAT_RGBA) { 125 if (consumer_->GetPixelFormat() == FrameConsumer::FORMAT_RGBA) {
154 scoped_ptr<VideoDecoder> wrapper( 126 scoped_ptr<VideoDecoder> wrapper(
155 new RgbToBgrVideoDecoderFilter(decoder_.Pass())); 127 new RgbToBgrVideoDecoderFilter(decoder_.Pass()));
156 decoder_ = wrapper.Pass(); 128 decoder_ = wrapper.Pass();
157 } 129 }
158 } 130 }
159 131
160 void SoftwareVideoRenderer::Core::DecodePacket(scoped_ptr<VideoPacket> packet,
161 const base::Closure& done) {
162 DCHECK(decode_task_runner_->BelongsToCurrentThread());
163
164 bool decoder_needs_reset = false;
165 bool notify_size_or_dpi_change = false;
166
167 // If the packet includes screen size or DPI information, store them.
168 if (packet->format().has_screen_width() &&
169 packet->format().has_screen_height()) {
170 webrtc::DesktopSize source_size(packet->format().screen_width(),
171 packet->format().screen_height());
172 if (!source_size_.equals(source_size)) {
173 source_size_ = source_size;
174 decoder_needs_reset = true;
175 notify_size_or_dpi_change = true;
176 }
177 }
178 if (packet->format().has_x_dpi() && packet->format().has_y_dpi()) {
179 webrtc::DesktopVector source_dpi(packet->format().x_dpi(),
180 packet->format().y_dpi());
181 if (!source_dpi.equals(source_dpi_)) {
182 source_dpi_ = source_dpi;
183 notify_size_or_dpi_change = true;
184 }
185 }
186
187 // If we've never seen a screen size, ignore the packet.
188 if (source_size_.is_empty()) {
189 main_task_runner_->PostTask(FROM_HERE, base::Bind(done));
190 return;
191 }
192
193 if (notify_size_or_dpi_change)
194 consumer_->SetSourceSize(source_size_, source_dpi_);
195
196 if (decoder_->DecodePacket(*packet.get())) {
197 SchedulePaint();
198 } else {
199 LOG(ERROR) << "DecodePacket() failed.";
200 }
201
202 main_task_runner_->PostTask(FROM_HERE, base::Bind(done));
203 }
204
205 void SoftwareVideoRenderer::Core::SchedulePaint() {
206 DCHECK(decode_task_runner_->BelongsToCurrentThread());
207 if (paint_scheduled_)
208 return;
209 paint_scheduled_ = true;
210 decode_task_runner_->PostTask(
211 FROM_HERE, base::Bind(&SoftwareVideoRenderer::Core::DoPaint,
212 weak_factory_.GetWeakPtr()));
213 }
214
215 void SoftwareVideoRenderer::Core::DoPaint() {
216 DCHECK(decode_task_runner_->BelongsToCurrentThread());
217 DCHECK(paint_scheduled_);
218 paint_scheduled_ = false;
219
220 // If the view size is empty or we have no output buffers ready, return.
221 if (buffers_.empty() || view_size_.is_empty())
222 return;
223
224 // If no Decoder is initialized, or the host dimensions are empty, return.
225 if (!decoder_.get() || source_size_.is_empty())
226 return;
227
228 // Draw the invalidated region to the buffer.
229 webrtc::DesktopFrame* buffer = buffers_.front();
230 webrtc::DesktopRegion output_region;
231 decoder_->RenderFrame(view_size_, clip_area_,
232 buffer->data(), buffer->stride(), &output_region);
233
234 // Notify the consumer that painting is done.
235 if (!output_region.is_empty()) {
236 buffers_.pop_front();
237 consumer_->ApplyBuffer(view_size_, clip_area_, buffer, output_region,
238 decoder_->GetImageShape());
239 }
240 }
241
242 void SoftwareVideoRenderer::Core::RequestReturnBuffers(
243 const base::Closure& done) {
244 DCHECK(decode_task_runner_->BelongsToCurrentThread());
245
246 while (!buffers_.empty()) {
247 consumer_->ReturnBuffer(buffers_.front());
248 buffers_.pop_front();
249 }
250
251 if (!done.is_null())
252 done.Run();
253 }
254
255 void SoftwareVideoRenderer::Core::DrawBuffer(webrtc::DesktopFrame* buffer) {
256 DCHECK(decode_task_runner_->BelongsToCurrentThread());
257 DCHECK(clip_area_.width() <= buffer->size().width() &&
258 clip_area_.height() <= buffer->size().height());
259
260 buffers_.push_back(buffer);
261 SchedulePaint();
262 }
263
264 void SoftwareVideoRenderer::Core::InvalidateRegion(
265 const webrtc::DesktopRegion& region) {
266 DCHECK(decode_task_runner_->BelongsToCurrentThread());
267
268 if (decoder_.get()) {
269 decoder_->Invalidate(view_size_, region);
270 SchedulePaint();
271 }
272 }
273
274 void SoftwareVideoRenderer::Core::SetOutputSizeAndClip(
275 const webrtc::DesktopSize& view_size,
276 const webrtc::DesktopRect& clip_area) {
277 DCHECK(decode_task_runner_->BelongsToCurrentThread());
278
279 // The whole frame needs to be repainted if the scaling factor has changed.
280 if (!view_size_.equals(view_size) && decoder_.get()) {
281 webrtc::DesktopRegion region;
282 region.AddRect(webrtc::DesktopRect::MakeSize(view_size));
283 decoder_->Invalidate(view_size, region);
284 }
285
286 if (!view_size_.equals(view_size) ||
287 !clip_area_.equals(clip_area)) {
288 view_size_ = view_size;
289 clip_area_ = clip_area;
290
291 // Return buffers that are smaller than needed to the consumer for
292 // reuse/reallocation.
293 std::list<webrtc::DesktopFrame*>::iterator i = buffers_.begin();
294 while (i != buffers_.end()) {
295 if ((*i)->size().width() < clip_area_.width() ||
296 (*i)->size().height() < clip_area_.height()) {
297 consumer_->ReturnBuffer(*i);
298 i = buffers_.erase(i);
299 } else {
300 ++i;
301 }
302 }
303
304 SchedulePaint();
305 }
306 }
307
308 SoftwareVideoRenderer::SoftwareVideoRenderer(
309 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
310 scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner,
311 scoped_ptr<FrameConsumerProxy> consumer)
312 : decode_task_runner_(decode_task_runner),
313 core_(new Core(main_task_runner, decode_task_runner, consumer.Pass())),
314 weak_factory_(this) {
315 DCHECK(CalledOnValidThread());
316 }
317
318 SoftwareVideoRenderer::~SoftwareVideoRenderer() {
319 DCHECK(CalledOnValidThread());
320 bool result = decode_task_runner_->DeleteSoon(FROM_HERE, core_.release());
321 DCHECK(result);
322 }
323
324 void SoftwareVideoRenderer::OnSessionConfig(
325 const protocol::SessionConfig& config) {
326 DCHECK(CalledOnValidThread());
327 decode_task_runner_->PostTask(
328 FROM_HERE, base::Bind(&SoftwareVideoRenderer::Core::OnSessionConfig,
329 base::Unretained(core_.get()), config));
330 }
331
332 ChromotingStats* SoftwareVideoRenderer::GetStats() { 132 ChromotingStats* SoftwareVideoRenderer::GetStats() {
333 DCHECK(CalledOnValidThread()); 133 DCHECK(thread_checker_.CalledOnValidThread());
334 return &stats_; 134 return &stats_;
335 } 135 }
336 136
337 protocol::VideoStub* SoftwareVideoRenderer::GetVideoStub() { 137 protocol::VideoStub* SoftwareVideoRenderer::GetVideoStub() {
138 DCHECK(thread_checker_.CalledOnValidThread());
338 return this; 139 return this;
339 } 140 }
340 141
341 void SoftwareVideoRenderer::ProcessVideoPacket(scoped_ptr<VideoPacket> packet, 142 void SoftwareVideoRenderer::ProcessVideoPacket(scoped_ptr<VideoPacket> packet,
342 const base::Closure& done) { 143 const base::Closure& done) {
343 DCHECK(CalledOnValidThread()); 144 DCHECK(thread_checker_.CalledOnValidThread());
145
146 base::ScopedClosureRunner done_runner(done);
344 147
345 stats_.RecordVideoPacketStats(*packet); 148 stats_.RecordVideoPacketStats(*packet);
346 149
347 // If the video packet is empty then drop it. Empty packets are used to 150 // If the video packet is empty then drop it. Empty packets are used to
348 // maintain activity on the network. 151 // maintain activity on the network.
349 if (!packet->has_data() || packet->data().size() == 0) { 152 if (!packet->has_data() || packet->data().size() == 0) {
350 decode_task_runner_->PostTask(FROM_HERE, done);
351 return; 153 return;
352 } 154 }
353 155
354 // Measure the latency between the last packet being received and presented. 156 if (packet->format().has_screen_width() &&
355 base::Time decode_start = base::Time::Now(); 157 packet->format().has_screen_height()) {
158 current_size_.set(packet->format().screen_width(),
159 packet->format().screen_height());
160 }
356 161
357 base::Closure decode_done = base::Bind(&SoftwareVideoRenderer::OnPacketDone, 162 if (current_size_.is_empty()) {
358 weak_factory_.GetWeakPtr(), 163 LOG(ERROR) << "Received VideoPacket with unknown size.";
359 decode_start, done); 164 return;
165 }
360 166
361 decode_task_runner_->PostTask(FROM_HERE, base::Bind( 167 scoped_ptr<webrtc::DesktopFrame> frame =
362 &SoftwareVideoRenderer::Core::DecodePacket, 168 consumer_->AllocateFrame(current_size_);
363 base::Unretained(core_.get()), base::Passed(&packet), decode_done)); 169 base::PostTaskAndReplyWithResult(
170 decode_task_runner_.get(), FROM_HERE,
171 base::Bind(&DoDecodeFrame, decoder_.get(), base::Passed(&packet),
172 base::Passed(&frame)),
173 base::Bind(&SoftwareVideoRenderer::RenderFrame,
174 weak_factory_.GetWeakPtr(), base::TimeTicks::Now(),
175 done_runner.Release()));
364 } 176 }
365 177
366 void SoftwareVideoRenderer::DrawBuffer(webrtc::DesktopFrame* buffer) { 178 void SoftwareVideoRenderer::RenderFrame(
367 decode_task_runner_->PostTask( 179 base::TimeTicks decode_start_time,
368 FROM_HERE, base::Bind(&SoftwareVideoRenderer::Core::DrawBuffer, 180 const base::Closure& done,
369 base::Unretained(core_.get()), buffer)); 181 scoped_ptr<webrtc::DesktopFrame> frame) {
182 DCHECK(thread_checker_.CalledOnValidThread());
183
184 stats_.RecordDecodeTime(
185 (base::TimeTicks::Now() - decode_start_time).InMilliseconds());
186
187 if (!frame) {
188 if (!done.is_null())
189 done.Run();
190 return;
191 }
192
193 consumer_->DrawFrame(
194 frame.Pass(),
195 base::Bind(&SoftwareVideoRenderer::OnFrameRendered,
196 weak_factory_.GetWeakPtr(), base::TimeTicks::Now(), done));
370 } 197 }
371 198
372 void SoftwareVideoRenderer::InvalidateRegion( 199 void SoftwareVideoRenderer::OnFrameRendered(base::TimeTicks paint_start_time,
373 const webrtc::DesktopRegion& region) { 200 const base::Closure& done) {
374 decode_task_runner_->PostTask( 201 DCHECK(thread_checker_.CalledOnValidThread());
375 FROM_HERE, base::Bind(&SoftwareVideoRenderer::Core::InvalidateRegion,
376 base::Unretained(core_.get()), region));
377 }
378 202
379 void SoftwareVideoRenderer::RequestReturnBuffers(const base::Closure& done) { 203 stats_.RecordPaintTime(
380 decode_task_runner_->PostTask( 204 (base::TimeTicks::Now() - paint_start_time).InMilliseconds());
381 FROM_HERE,
382 base::Bind(&SoftwareVideoRenderer::Core::RequestReturnBuffers,
383 base::Unretained(core_.get()), done));
384 }
385 205
386 void SoftwareVideoRenderer::SetOutputSizeAndClip( 206 if (!done.is_null())
387 const webrtc::DesktopSize& view_size, 207 done.Run();
388 const webrtc::DesktopRect& clip_area) {
389 decode_task_runner_->PostTask(
390 FROM_HERE,
391 base::Bind(&SoftwareVideoRenderer::Core::SetOutputSizeAndClip,
392 base::Unretained(core_.get()), view_size, clip_area));
393 }
394
395 void SoftwareVideoRenderer::OnPacketDone(base::Time decode_start,
396 const base::Closure& done) {
397 DCHECK(CalledOnValidThread());
398
399 // Record the latency between the packet being received and presented.
400 base::TimeDelta decode_time = base::Time::Now() - decode_start;
401 stats_.RecordDecodeTime(decode_time.InMilliseconds());
402
403 decode_task_runner_->PostTask(FROM_HERE, done);
404 } 208 }
405 209
406 } // namespace remoting 210 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698