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

Side by Side Diff: content/renderer/media/android/stream_texture_wrapper_impl.cc

Issue 2192823004: Update StreamTextureProxy to accept a base::Closure (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comments Created 4 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/renderer/media/android/stream_texture_wrapper_impl.h" 5 #include "content/renderer/media/android/stream_texture_wrapper_impl.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "cc/layers/video_frame_provider.h" 8 #include "cc/layers/video_frame_provider.h"
9 #include "gpu/GLES2/gl2extchromium.h" 9 #include "gpu/GLES2/gl2extchromium.h"
10 #include "gpu/command_buffer/client/gles2_interface.h" 10 #include "gpu/command_buffer/client/gles2_interface.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 if (natural_size_ == new_size) 123 if (natural_size_ == new_size)
124 return; 124 return;
125 125
126 natural_size_ = new_size; 126 natural_size_ = new_size;
127 127
128 ReallocateVideoFrame(new_size); 128 ReallocateVideoFrame(new_size);
129 factory_->SetStreamTextureSize(stream_id_, new_size); 129 factory_->SetStreamTextureSize(stream_id_, new_size);
130 } 130 }
131 131
132 void StreamTextureWrapperImpl::Initialize( 132 void StreamTextureWrapperImpl::Initialize(
133 cc::VideoFrameProvider::Client* client, 133 const base::Closure& received_frame_cb,
134 const gfx::Size& natural_size, 134 const gfx::Size& natural_size,
135 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner, 135 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner,
136 const base::Closure& init_cb) { 136 const base::Closure& init_cb) {
137 DVLOG(2) << __FUNCTION__; 137 DVLOG(2) << __FUNCTION__;
138 138
139 compositor_task_runner_ = compositor_task_runner; 139 compositor_task_runner_ = compositor_task_runner;
140 natural_size_ = natural_size; 140 natural_size_ = natural_size;
141 141
142 main_task_runner_->PostTask( 142 main_task_runner_->PostTask(
143 FROM_HERE, base::Bind(&StreamTextureWrapperImpl::InitializeOnMainThread, 143 FROM_HERE, base::Bind(&StreamTextureWrapperImpl::InitializeOnMainThread,
144 weak_factory_.GetWeakPtr(), client, 144 weak_factory_.GetWeakPtr(), received_frame_cb,
145 media::BindToCurrentLoop(init_cb))); 145 media::BindToCurrentLoop(init_cb)));
146 } 146 }
147 147
148 void StreamTextureWrapperImpl::InitializeOnMainThread( 148 void StreamTextureWrapperImpl::InitializeOnMainThread(
149 cc::VideoFrameProvider::Client* client, 149 const base::Closure& received_frame_cb,
150 const base::Closure& init_cb) { 150 const base::Closure& init_cb) {
151 DCHECK(main_task_runner_->BelongsToCurrentThread()); 151 DCHECK(main_task_runner_->BelongsToCurrentThread());
152 DVLOG(2) << __FUNCTION__; 152 DVLOG(2) << __FUNCTION__;
153 153
154 stream_texture_proxy_.reset(factory_->CreateProxy()); 154 stream_texture_proxy_.reset(factory_->CreateProxy());
155 155
156 stream_id_ = factory_->CreateStreamTexture(kGLTextureExternalOES, 156 stream_id_ = factory_->CreateStreamTexture(kGLTextureExternalOES,
157 &texture_id_, &texture_mailbox_); 157 &texture_id_, &texture_mailbox_);
158 ReallocateVideoFrame(natural_size_); 158 ReallocateVideoFrame(natural_size_);
159 159
160 stream_texture_proxy_->BindToLoop(stream_id_, client, 160 stream_texture_proxy_->BindToTaskRunner(stream_id_, received_frame_cb,
161 compositor_task_runner_); 161 compositor_task_runner_);
162 162
163 // TODO(tguilbert): Register the surface properly. See crbug.com/627658. 163 // TODO(tguilbert): Register the surface properly. See crbug.com/627658.
164 164
165 // |init_cb| is bound to the thread that originally called Initialize(). 165 // |init_cb| is bound to the thread that originally called Initialize().
166 init_cb.Run(); 166 init_cb.Run();
167 } 167 }
168 168
169 void StreamTextureWrapperImpl::Destroy() { 169 void StreamTextureWrapperImpl::Destroy() {
170 // Note: StreamTextureProxy will release its reference to |client| 170 // Note: StreamTextureProxy stop calling back the provided frame received
171 // immediately (and stop calling back DidReceiveFrame()). 171 // callback immediately, and delete itself on the right thread.
172 stream_texture_proxy_.reset(); 172 stream_texture_proxy_.reset();
173 173
174 if (!main_task_runner_->BelongsToCurrentThread()) { 174 if (!main_task_runner_->BelongsToCurrentThread()) {
175 // base::Unretained is safe here because this function is the only one that 175 // base::Unretained is safe here because this function is the only one that
176 // can can call delete. 176 // can can call delete.
177 main_task_runner_->PostTask( 177 main_task_runner_->PostTask(
178 FROM_HERE, 178 FROM_HERE,
179 base::Bind(&StreamTextureWrapperImpl::Destroy, base::Unretained(this))); 179 base::Bind(&StreamTextureWrapperImpl::Destroy, base::Unretained(this)));
180 return; 180 return;
181 } 181 }
182 182
183 delete this; 183 delete this;
184 } 184 }
185 185
186 } // namespace content 186 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/android/stream_texture_wrapper_impl.h ('k') | content/renderer/media/android/webmediaplayer_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698