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

Side by Side Diff: chromecast/renderer/media/video_pipeline_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
« no previous file with comments | « chromecast/renderer/media/video_pipeline_proxy.h ('k') | chromecast/service/cast_service.h » ('j') | 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 "chromecast/renderer/media/video_pipeline_proxy.h" 5 #include "chromecast/renderer/media/video_pipeline_proxy.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 23 matching lines...) Expand all
34 void IgnoreResult() { 34 void IgnoreResult() {
35 } 35 }
36 36
37 } // namespace 37 } // namespace
38 38
39 // VideoPipelineProxyInternal - 39 // VideoPipelineProxyInternal -
40 // This class is not thread safe and should run on the same thread 40 // This class is not thread safe and should run on the same thread
41 // as the media channel proxy. 41 // as the media channel proxy.
42 class VideoPipelineProxyInternal { 42 class VideoPipelineProxyInternal {
43 public: 43 public:
44 typedef base::Callback<void(scoped_ptr<base::SharedMemory>)> SharedMemCB; 44 typedef base::Callback<void(std::unique_ptr<base::SharedMemory>)> SharedMemCB;
45 45
46 static void Release(scoped_ptr<VideoPipelineProxyInternal> proxy); 46 static void Release(std::unique_ptr<VideoPipelineProxyInternal> proxy);
47 47
48 explicit VideoPipelineProxyInternal( 48 explicit VideoPipelineProxyInternal(
49 scoped_refptr<MediaChannelProxy> media_channel_proxy); 49 scoped_refptr<MediaChannelProxy> media_channel_proxy);
50 virtual ~VideoPipelineProxyInternal(); 50 virtual ~VideoPipelineProxyInternal();
51 51
52 // Notify the other side (browser process) of some activity on the video pipe. 52 // Notify the other side (browser process) of some activity on the video pipe.
53 // TODO(erickung): either send an IPC message or write a byte on the 53 // TODO(erickung): either send an IPC message or write a byte on the
54 // SyncSocket. 54 // SyncSocket.
55 void NotifyPipeWrite(); 55 void NotifyPipeWrite();
56 56
(...skipping 22 matching lines...) Expand all
79 // Store the callback for a pending state transition. 79 // Store the callback for a pending state transition.
80 ::media::PipelineStatusCB status_cb_; 80 ::media::PipelineStatusCB status_cb_;
81 81
82 SharedMemCB shared_mem_cb_; 82 SharedMemCB shared_mem_cb_;
83 83
84 DISALLOW_COPY_AND_ASSIGN(VideoPipelineProxyInternal); 84 DISALLOW_COPY_AND_ASSIGN(VideoPipelineProxyInternal);
85 }; 85 };
86 86
87 // static 87 // static
88 void VideoPipelineProxyInternal::Release( 88 void VideoPipelineProxyInternal::Release(
89 scoped_ptr<VideoPipelineProxyInternal> proxy) { 89 std::unique_ptr<VideoPipelineProxyInternal> proxy) {
90 proxy->Shutdown(); 90 proxy->Shutdown();
91 } 91 }
92 92
93 VideoPipelineProxyInternal::VideoPipelineProxyInternal( 93 VideoPipelineProxyInternal::VideoPipelineProxyInternal(
94 scoped_refptr<MediaChannelProxy> media_channel_proxy) 94 scoped_refptr<MediaChannelProxy> media_channel_proxy)
95 : media_channel_proxy_(media_channel_proxy) { 95 : media_channel_proxy_(media_channel_proxy) {
96 DCHECK(media_channel_proxy.get()); 96 DCHECK(media_channel_proxy.get());
97 97
98 // Creation can be done on a different thread. 98 // Creation can be done on a different thread.
99 thread_checker_.DetachFromThread(); 99 thread_checker_.DetachFromThread();
100 } 100 }
101 101
102 VideoPipelineProxyInternal::~VideoPipelineProxyInternal() { 102 VideoPipelineProxyInternal::~VideoPipelineProxyInternal() {
103 } 103 }
104 104
105 void VideoPipelineProxyInternal::Shutdown() { 105 void VideoPipelineProxyInternal::Shutdown() {
106 DCHECK(thread_checker_.CalledOnValidThread()); 106 DCHECK(thread_checker_.CalledOnValidThread());
107 107
108 // Remove any callback on VideoPipelineProxyInternal. 108 // Remove any callback on VideoPipelineProxyInternal.
109 media_channel_proxy_->SetVideoDelegate( 109 media_channel_proxy_->SetVideoDelegate(
110 CmaMessageFilterProxy::VideoDelegate()); 110 CmaMessageFilterProxy::VideoDelegate());
111 } 111 }
112 112
113 void VideoPipelineProxyInternal::NotifyPipeWrite() { 113 void VideoPipelineProxyInternal::NotifyPipeWrite() {
114 DCHECK(thread_checker_.CalledOnValidThread()); 114 DCHECK(thread_checker_.CalledOnValidThread());
115 115
116 // TODO(damienv): An alternative way would be to use a dedicated socket for 116 // TODO(damienv): An alternative way would be to use a dedicated socket for
117 // this event. 117 // this event.
118 bool success = media_channel_proxy_->Send(scoped_ptr<IPC::Message>( 118 bool success = media_channel_proxy_->Send(
119 new CmaHostMsg_NotifyPipeWrite(media_channel_proxy_->GetId(), 119 std::unique_ptr<IPC::Message>(new CmaHostMsg_NotifyPipeWrite(
120 kVideoTrackId))); 120 media_channel_proxy_->GetId(), kVideoTrackId)));
121 VLOG_IF(4, !success) << "Sending msg failed"; 121 VLOG_IF(4, !success) << "Sending msg failed";
122 } 122 }
123 123
124 void VideoPipelineProxyInternal::SetClient( 124 void VideoPipelineProxyInternal::SetClient(
125 const base::Closure& pipe_read_cb, 125 const base::Closure& pipe_read_cb,
126 const VideoPipelineClient& video_client) { 126 const VideoPipelineClient& video_client) {
127 DCHECK(thread_checker_.CalledOnValidThread()); 127 DCHECK(thread_checker_.CalledOnValidThread());
128 128
129 CmaMessageFilterProxy::VideoDelegate delegate; 129 CmaMessageFilterProxy::VideoDelegate delegate;
130 delegate.av_pipe_cb = 130 delegate.av_pipe_cb =
131 base::Bind(&VideoPipelineProxyInternal::OnAvPipeCreated, 131 base::Bind(&VideoPipelineProxyInternal::OnAvPipeCreated,
132 base::Unretained(this)); 132 base::Unretained(this));
133 delegate.state_changed_cb = 133 delegate.state_changed_cb =
134 base::Bind(&VideoPipelineProxyInternal::OnStateChanged, 134 base::Bind(&VideoPipelineProxyInternal::OnStateChanged,
135 base::Unretained(this)); 135 base::Unretained(this));
136 delegate.pipe_read_cb = pipe_read_cb; 136 delegate.pipe_read_cb = pipe_read_cb;
137 delegate.client = video_client; 137 delegate.client = video_client;
138 bool success = media_channel_proxy_->SetVideoDelegate(delegate); 138 bool success = media_channel_proxy_->SetVideoDelegate(delegate);
139 CHECK(success); 139 CHECK(success);
140 } 140 }
141 141
142 void VideoPipelineProxyInternal::CreateAvPipe( 142 void VideoPipelineProxyInternal::CreateAvPipe(
143 const SharedMemCB& shared_mem_cb) { 143 const SharedMemCB& shared_mem_cb) {
144 DCHECK(thread_checker_.CalledOnValidThread()); 144 DCHECK(thread_checker_.CalledOnValidThread());
145 DCHECK(shared_mem_cb_.is_null()); 145 DCHECK(shared_mem_cb_.is_null());
146 bool success = media_channel_proxy_->Send(scoped_ptr<IPC::Message>( 146 bool success = media_channel_proxy_->Send(
147 new CmaHostMsg_CreateAvPipe( 147 std::unique_ptr<IPC::Message>(new CmaHostMsg_CreateAvPipe(
148 media_channel_proxy_->GetId(), kVideoTrackId, kAppVideoBufferSize))); 148 media_channel_proxy_->GetId(), kVideoTrackId, kAppVideoBufferSize)));
149 if (!success) { 149 if (!success) {
150 shared_mem_cb.Run(scoped_ptr<base::SharedMemory>()); 150 shared_mem_cb.Run(std::unique_ptr<base::SharedMemory>());
151 return; 151 return;
152 } 152 }
153 shared_mem_cb_ = shared_mem_cb; 153 shared_mem_cb_ = shared_mem_cb;
154 } 154 }
155 155
156 void VideoPipelineProxyInternal::OnAvPipeCreated( 156 void VideoPipelineProxyInternal::OnAvPipeCreated(
157 bool success, 157 bool success,
158 base::SharedMemoryHandle shared_mem_handle, 158 base::SharedMemoryHandle shared_mem_handle,
159 base::FileDescriptor socket) { 159 base::FileDescriptor socket) {
160 DCHECK(thread_checker_.CalledOnValidThread()); 160 DCHECK(thread_checker_.CalledOnValidThread());
161 DCHECK(!shared_mem_cb_.is_null()); 161 DCHECK(!shared_mem_cb_.is_null());
162 if (!success) { 162 if (!success) {
163 shared_mem_cb_.Run(scoped_ptr<base::SharedMemory>()); 163 shared_mem_cb_.Run(std::unique_ptr<base::SharedMemory>());
164 return; 164 return;
165 } 165 }
166 166
167 CHECK(base::SharedMemory::IsHandleValid(shared_mem_handle)); 167 CHECK(base::SharedMemory::IsHandleValid(shared_mem_handle));
168 shared_mem_cb_.Run(scoped_ptr<base::SharedMemory>( 168 shared_mem_cb_.Run(std::unique_ptr<base::SharedMemory>(
169 new base::SharedMemory(shared_mem_handle, false))); 169 new base::SharedMemory(shared_mem_handle, false)));
170 } 170 }
171 171
172 void VideoPipelineProxyInternal::Initialize( 172 void VideoPipelineProxyInternal::Initialize(
173 const std::vector<::media::VideoDecoderConfig>& configs, 173 const std::vector<::media::VideoDecoderConfig>& configs,
174 const ::media::PipelineStatusCB& status_cb) { 174 const ::media::PipelineStatusCB& status_cb) {
175 DCHECK(thread_checker_.CalledOnValidThread()); 175 DCHECK(thread_checker_.CalledOnValidThread());
176 bool success = media_channel_proxy_->Send(scoped_ptr<IPC::Message>( 176 bool success = media_channel_proxy_->Send(
177 new CmaHostMsg_VideoInitialize(media_channel_proxy_->GetId(), 177 std::unique_ptr<IPC::Message>(new CmaHostMsg_VideoInitialize(
178 kVideoTrackId, configs))); 178 media_channel_proxy_->GetId(), kVideoTrackId, configs)));
179 if (!success) { 179 if (!success) {
180 status_cb.Run( ::media::PIPELINE_ERROR_INITIALIZATION_FAILED); 180 status_cb.Run( ::media::PIPELINE_ERROR_INITIALIZATION_FAILED);
181 return; 181 return;
182 } 182 }
183 DCHECK(status_cb_.is_null()); 183 DCHECK(status_cb_.is_null());
184 status_cb_ = status_cb; 184 status_cb_ = status_cb;
185 } 185 }
186 186
187 void VideoPipelineProxyInternal::OnStateChanged( 187 void VideoPipelineProxyInternal::OnStateChanged(
188 ::media::PipelineStatus status) { 188 ::media::PipelineStatus status) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 void VideoPipelineProxy::SetClient(const VideoPipelineClient& video_client) { 220 void VideoPipelineProxy::SetClient(const VideoPipelineClient& video_client) {
221 DCHECK(thread_checker_.CalledOnValidThread()); 221 DCHECK(thread_checker_.CalledOnValidThread());
222 base::Closure pipe_read_cb = 222 base::Closure pipe_read_cb =
223 ::media::BindToCurrentLoop( 223 ::media::BindToCurrentLoop(
224 base::Bind(&VideoPipelineProxy::OnPipeRead, weak_this_)); 224 base::Bind(&VideoPipelineProxy::OnPipeRead, weak_this_));
225 FORWARD_ON_IO_THREAD(SetClient, pipe_read_cb, video_client); 225 FORWARD_ON_IO_THREAD(SetClient, pipe_read_cb, video_client);
226 } 226 }
227 227
228 void VideoPipelineProxy::Initialize( 228 void VideoPipelineProxy::Initialize(
229 const std::vector<::media::VideoDecoderConfig>& configs, 229 const std::vector<::media::VideoDecoderConfig>& configs,
230 scoped_ptr<CodedFrameProvider> frame_provider, 230 std::unique_ptr<CodedFrameProvider> frame_provider,
231 const ::media::PipelineStatusCB& status_cb) { 231 const ::media::PipelineStatusCB& status_cb) {
232 CMALOG(kLogControl) << "VideoPipelineProxy::Initialize"; 232 CMALOG(kLogControl) << "VideoPipelineProxy::Initialize";
233 DCHECK(thread_checker_.CalledOnValidThread()); 233 DCHECK(thread_checker_.CalledOnValidThread());
234 video_streamer_->SetCodedFrameProvider(std::move(frame_provider)); 234 video_streamer_->SetCodedFrameProvider(std::move(frame_provider));
235 235
236 VideoPipelineProxyInternal::SharedMemCB shared_mem_cb = 236 VideoPipelineProxyInternal::SharedMemCB shared_mem_cb =
237 ::media::BindToCurrentLoop(base::Bind( 237 ::media::BindToCurrentLoop(base::Bind(
238 &VideoPipelineProxy::OnAvPipeCreated, weak_this_, 238 &VideoPipelineProxy::OnAvPipeCreated, weak_this_,
239 configs, status_cb)); 239 configs, status_cb));
240 FORWARD_ON_IO_THREAD(CreateAvPipe, shared_mem_cb); 240 FORWARD_ON_IO_THREAD(CreateAvPipe, shared_mem_cb);
241 } 241 }
242 242
243 void VideoPipelineProxy::OnAvPipeCreated( 243 void VideoPipelineProxy::OnAvPipeCreated(
244 const std::vector<::media::VideoDecoderConfig>& configs, 244 const std::vector<::media::VideoDecoderConfig>& configs,
245 const ::media::PipelineStatusCB& status_cb, 245 const ::media::PipelineStatusCB& status_cb,
246 scoped_ptr<base::SharedMemory> shared_memory) { 246 std::unique_ptr<base::SharedMemory> shared_memory) {
247 CMALOG(kLogControl) << "VideoPipelineProxy::OnAvPipeCreated"; 247 CMALOG(kLogControl) << "VideoPipelineProxy::OnAvPipeCreated";
248 DCHECK(thread_checker_.CalledOnValidThread()); 248 DCHECK(thread_checker_.CalledOnValidThread());
249 if (!shared_memory || 249 if (!shared_memory ||
250 !shared_memory->Map(kAppVideoBufferSize)) { 250 !shared_memory->Map(kAppVideoBufferSize)) {
251 status_cb.Run(::media::PIPELINE_ERROR_INITIALIZATION_FAILED); 251 status_cb.Run(::media::PIPELINE_ERROR_INITIALIZATION_FAILED);
252 return; 252 return;
253 } 253 }
254 CHECK(shared_memory->memory()); 254 CHECK(shared_memory->memory());
255 255
256 scoped_ptr<MediaMemoryChunk> shared_memory_chunk( 256 std::unique_ptr<MediaMemoryChunk> shared_memory_chunk(
257 new SharedMemoryChunk(std::move(shared_memory), kAppVideoBufferSize)); 257 new SharedMemoryChunk(std::move(shared_memory), kAppVideoBufferSize));
258 scoped_ptr<MediaMessageFifo> video_pipe( 258 std::unique_ptr<MediaMessageFifo> video_pipe(
259 new MediaMessageFifo(std::move(shared_memory_chunk), false)); 259 new MediaMessageFifo(std::move(shared_memory_chunk), false));
260 video_pipe->ObserveWriteActivity( 260 video_pipe->ObserveWriteActivity(
261 base::Bind(&VideoPipelineProxy::OnPipeWrite, weak_this_)); 261 base::Bind(&VideoPipelineProxy::OnPipeWrite, weak_this_));
262 262
263 video_streamer_->SetMediaMessageFifo(std::move(video_pipe)); 263 video_streamer_->SetMediaMessageFifo(std::move(video_pipe));
264 264
265 // Now proceed to the decoder/renderer initialization. 265 // Now proceed to the decoder/renderer initialization.
266 FORWARD_ON_IO_THREAD(Initialize, configs, status_cb); 266 FORWARD_ON_IO_THREAD(Initialize, configs, status_cb);
267 } 267 }
268 268
(...skipping 22 matching lines...) Expand all
291 } 291 }
292 292
293 void VideoPipelineProxy::OnPipeRead() { 293 void VideoPipelineProxy::OnPipeRead() {
294 DCHECK(thread_checker_.CalledOnValidThread()); 294 DCHECK(thread_checker_.CalledOnValidThread());
295 if (video_streamer_) 295 if (video_streamer_)
296 video_streamer_->OnFifoReadEvent(); 296 video_streamer_->OnFifoReadEvent();
297 } 297 }
298 298
299 } // namespace media 299 } // namespace media
300 } // namespace chromecast 300 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/renderer/media/video_pipeline_proxy.h ('k') | chromecast/service/cast_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698