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

Side by Side Diff: media/capture/video/fake_video_capture_device.cc

Issue 2166713002: ImageCapture: replace Mojo String/Array with stl/wtf string/vector (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/video/fake_video_capture_device.h" 5 #include "media/capture/video/fake_video_capture_device.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 DrawPacman(true /* use_argb */, buffer.get(), elapsed_time, fake_capture_rate, 101 DrawPacman(true /* use_argb */, buffer.get(), elapsed_time, fake_capture_rate,
102 capture_format.frame_size, zoom); 102 capture_format.frame_size, zoom);
103 103
104 std::vector<uint8_t> encoded_data; 104 std::vector<uint8_t> encoded_data;
105 const bool result = gfx::PNGCodec::Encode( 105 const bool result = gfx::PNGCodec::Encode(
106 buffer.get(), gfx::PNGCodec::FORMAT_RGBA, capture_format.frame_size, 106 buffer.get(), gfx::PNGCodec::FORMAT_RGBA, capture_format.frame_size,
107 capture_format.frame_size.width() * 4, true /* discard_transparency */, 107 capture_format.frame_size.width() * 4, true /* discard_transparency */,
108 std::vector<gfx::PNGCodec::Comment>(), &encoded_data); 108 std::vector<gfx::PNGCodec::Comment>(), &encoded_data);
109 DCHECK(result); 109 DCHECK(result);
110 110
111 callback.Run(mojo::String::From("image/png"), 111 callback.Run(std::string("image/png"), encoded_data);
Wez 2016/07/20 18:52:07 nit: Do you need the explicit std::string here?
mcasas 2016/07/20 22:57:01 Nope, removed. It wouldn't hurt performance becaus
112 mojo::Array<uint8_t>::From(encoded_data));
113 } 112 }
114 113
115 FakeVideoCaptureDevice::FakeVideoCaptureDevice(BufferOwnership buffer_ownership, 114 FakeVideoCaptureDevice::FakeVideoCaptureDevice(BufferOwnership buffer_ownership,
116 float fake_capture_rate) 115 float fake_capture_rate)
117 : buffer_ownership_(buffer_ownership), 116 : buffer_ownership_(buffer_ownership),
118 fake_capture_rate_(fake_capture_rate), 117 fake_capture_rate_(fake_capture_rate),
119 current_zoom_(kMinZoom), 118 current_zoom_(kMinZoom),
120 weak_factory_(this) {} 119 weak_factory_(this) {}
121 120
122 FakeVideoCaptureDevice::~FakeVideoCaptureDevice() { 121 FakeVideoCaptureDevice::~FakeVideoCaptureDevice() {
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 // Don't accumulate any debt if we are lagging behind - just post the next 297 // Don't accumulate any debt if we are lagging behind - just post the next
299 // frame immediately and continue as normal. 298 // frame immediately and continue as normal.
300 const base::TimeTicks next_execution_time = 299 const base::TimeTicks next_execution_time =
301 std::max(current_time, expected_execution_time + frame_interval); 300 std::max(current_time, expected_execution_time + frame_interval);
302 const base::TimeDelta delay = next_execution_time - current_time; 301 const base::TimeDelta delay = next_execution_time - current_time;
303 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 302 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
304 FROM_HERE, base::Bind(next_capture, next_execution_time), delay); 303 FROM_HERE, base::Bind(next_capture, next_execution_time), delay);
305 } 304 }
306 305
307 } // namespace media 306 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698