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

Side by Side Diff: chromecast/media/cma/ipc_streamer/av_streamer_proxy.cc

Issue 1875623002: Convert //chromecast from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 "chromecast/media/cma/ipc_streamer/av_streamer_proxy.h" 5 #include "chromecast/media/cma/ipc_streamer/av_streamer_proxy.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 17 matching lines...) Expand all
28 weak_factory_(this) { 28 weak_factory_(this) {
29 weak_this_ = weak_factory_.GetWeakPtr(); 29 weak_this_ = weak_factory_.GetWeakPtr();
30 thread_checker_.DetachFromThread(); 30 thread_checker_.DetachFromThread();
31 } 31 }
32 32
33 AvStreamerProxy::~AvStreamerProxy() { 33 AvStreamerProxy::~AvStreamerProxy() {
34 DCHECK(thread_checker_.CalledOnValidThread()); 34 DCHECK(thread_checker_.CalledOnValidThread());
35 } 35 }
36 36
37 void AvStreamerProxy::SetCodedFrameProvider( 37 void AvStreamerProxy::SetCodedFrameProvider(
38 scoped_ptr<CodedFrameProvider> frame_provider) { 38 std::unique_ptr<CodedFrameProvider> frame_provider) {
39 DCHECK(thread_checker_.CalledOnValidThread()); 39 DCHECK(thread_checker_.CalledOnValidThread());
40 DCHECK(!frame_provider_); 40 DCHECK(!frame_provider_);
41 frame_provider_.reset(frame_provider.release()); 41 frame_provider_.reset(frame_provider.release());
42 } 42 }
43 43
44 void AvStreamerProxy::SetMediaMessageFifo( 44 void AvStreamerProxy::SetMediaMessageFifo(
45 scoped_ptr<MediaMessageFifo> fifo) { 45 std::unique_ptr<MediaMessageFifo> fifo) {
46 DCHECK(thread_checker_.CalledOnValidThread()); 46 DCHECK(thread_checker_.CalledOnValidThread());
47 DCHECK(!fifo_); 47 DCHECK(!fifo_);
48 fifo_.reset(fifo.release()); 48 fifo_.reset(fifo.release());
49 } 49 }
50 50
51 void AvStreamerProxy::Start() { 51 void AvStreamerProxy::Start() {
52 DCHECK(!is_running_); 52 DCHECK(!is_running_);
53 53
54 is_running_ = true; 54 is_running_ = true;
55 RequestBufferIfNeeded(); 55 RequestBufferIfNeeded();
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 151
152 pending_av_data_ = false; 152 pending_av_data_ = false;
153 base::ThreadTaskRunnerHandle::Get()->PostTask( 153 base::ThreadTaskRunnerHandle::Get()->PostTask(
154 FROM_HERE, 154 FROM_HERE,
155 base::Bind(&AvStreamerProxy::RequestBufferIfNeeded, weak_this_)); 155 base::Bind(&AvStreamerProxy::RequestBufferIfNeeded, weak_this_));
156 } 156 }
157 157
158 bool AvStreamerProxy::SendAudioDecoderConfig( 158 bool AvStreamerProxy::SendAudioDecoderConfig(
159 const ::media::AudioDecoderConfig& config) { 159 const ::media::AudioDecoderConfig& config) {
160 // Create a dummy message to calculate first the message size. 160 // Create a dummy message to calculate first the message size.
161 scoped_ptr<MediaMessage> dummy_msg( 161 std::unique_ptr<MediaMessage> dummy_msg(
162 MediaMessage::CreateDummyMessage(AudioConfigMediaMsg)); 162 MediaMessage::CreateDummyMessage(AudioConfigMediaMsg));
163 AudioDecoderConfigMarshaller::Write(config, dummy_msg.get()); 163 AudioDecoderConfigMarshaller::Write(config, dummy_msg.get());
164 164
165 // Create the real message and write the actual content. 165 // Create the real message and write the actual content.
166 scoped_ptr<MediaMessage> msg( 166 std::unique_ptr<MediaMessage> msg(MediaMessage::CreateMessage(
167 MediaMessage::CreateMessage( 167 AudioConfigMediaMsg, base::Bind(&MediaMessageFifo::ReserveMemory,
168 AudioConfigMediaMsg, 168 base::Unretained(fifo_.get())),
169 base::Bind(&MediaMessageFifo::ReserveMemory, 169 dummy_msg->content_size()));
170 base::Unretained(fifo_.get())),
171 dummy_msg->content_size()));
172 if (!msg) 170 if (!msg)
173 return false; 171 return false;
174 172
175 AudioDecoderConfigMarshaller::Write(config, msg.get()); 173 AudioDecoderConfigMarshaller::Write(config, msg.get());
176 return true; 174 return true;
177 } 175 }
178 176
179 bool AvStreamerProxy::SendVideoDecoderConfig( 177 bool AvStreamerProxy::SendVideoDecoderConfig(
180 const ::media::VideoDecoderConfig& config) { 178 const ::media::VideoDecoderConfig& config) {
181 // Create a dummy message to calculate first the message size. 179 // Create a dummy message to calculate first the message size.
182 scoped_ptr<MediaMessage> dummy_msg( 180 std::unique_ptr<MediaMessage> dummy_msg(
183 MediaMessage::CreateDummyMessage(VideoConfigMediaMsg)); 181 MediaMessage::CreateDummyMessage(VideoConfigMediaMsg));
184 VideoDecoderConfigMarshaller::Write(config, dummy_msg.get()); 182 VideoDecoderConfigMarshaller::Write(config, dummy_msg.get());
185 183
186 // Create the real message and write the actual content. 184 // Create the real message and write the actual content.
187 scoped_ptr<MediaMessage> msg( 185 std::unique_ptr<MediaMessage> msg(MediaMessage::CreateMessage(
188 MediaMessage::CreateMessage( 186 VideoConfigMediaMsg, base::Bind(&MediaMessageFifo::ReserveMemory,
189 VideoConfigMediaMsg, 187 base::Unretained(fifo_.get())),
190 base::Bind(&MediaMessageFifo::ReserveMemory, 188 dummy_msg->content_size()));
191 base::Unretained(fifo_.get())),
192 dummy_msg->content_size()));
193 if (!msg) 189 if (!msg)
194 return false; 190 return false;
195 191
196 VideoDecoderConfigMarshaller::Write(config, msg.get()); 192 VideoDecoderConfigMarshaller::Write(config, msg.get());
197 return true; 193 return true;
198 } 194 }
199 195
200 bool AvStreamerProxy::SendBuffer( 196 bool AvStreamerProxy::SendBuffer(
201 const scoped_refptr<DecoderBufferBase>& buffer) { 197 const scoped_refptr<DecoderBufferBase>& buffer) {
202 // Create a dummy message to calculate first the message size. 198 // Create a dummy message to calculate first the message size.
203 scoped_ptr<MediaMessage> dummy_msg( 199 std::unique_ptr<MediaMessage> dummy_msg(
204 MediaMessage::CreateDummyMessage(FrameMediaMsg)); 200 MediaMessage::CreateDummyMessage(FrameMediaMsg));
205 DecoderBufferBaseMarshaller::Write(buffer, dummy_msg.get()); 201 DecoderBufferBaseMarshaller::Write(buffer, dummy_msg.get());
206 202
207 // Create the real message and write the actual content. 203 // Create the real message and write the actual content.
208 scoped_ptr<MediaMessage> msg( 204 std::unique_ptr<MediaMessage> msg(MediaMessage::CreateMessage(
209 MediaMessage::CreateMessage( 205 FrameMediaMsg, base::Bind(&MediaMessageFifo::ReserveMemory,
210 FrameMediaMsg, 206 base::Unretained(fifo_.get())),
211 base::Bind(&MediaMessageFifo::ReserveMemory, 207 dummy_msg->content_size()));
212 base::Unretained(fifo_.get())),
213 dummy_msg->content_size()));
214 if (!msg) 208 if (!msg)
215 return false; 209 return false;
216 210
217 DecoderBufferBaseMarshaller::Write(buffer, msg.get()); 211 DecoderBufferBaseMarshaller::Write(buffer, msg.get());
218 return true; 212 return true;
219 } 213 }
220 214
221 } // namespace media 215 } // namespace media
222 } // namespace chromecast 216 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/media/cma/ipc_streamer/av_streamer_proxy.h ('k') | chromecast/media/cma/ipc_streamer/av_streamer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698