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

Side by Side Diff: media/gpu/avda_codec_allocator.cc

Issue 2692863011: Add ContentVideoViewOverlay to AVDA. (Closed)
Patch Set: fixed avda unittest Created 3 years, 9 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 | « media/gpu/avda_codec_allocator.h ('k') | media/gpu/avda_codec_allocator_unittest.cc » ('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 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 "media/gpu/avda_codec_allocator.h" 5 #include "media/gpu/avda_codec_allocator.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 135 }
136 } 136 }
137 137
138 // Return the task runner for tasks of type |type|. 138 // Return the task runner for tasks of type |type|.
139 scoped_refptr<base::SingleThreadTaskRunner> AVDACodecAllocator::TaskRunnerFor( 139 scoped_refptr<base::SingleThreadTaskRunner> AVDACodecAllocator::TaskRunnerFor(
140 TaskType task_type) { 140 TaskType task_type) {
141 DCHECK(thread_checker_.CalledOnValidThread()); 141 DCHECK(thread_checker_.CalledOnValidThread());
142 return threads_[task_type]->thread.task_runner(); 142 return threads_[task_type]->thread.task_runner();
143 } 143 }
144 144
145 bool AVDACodecAllocator::AllocateSurface(AVDACodecAllocatorClient* client, 145 bool AVDACodecAllocator::AllocateSurface(AVDASurfaceAllocatorClient* client,
146 int surface_id) { 146 int surface_id) {
147 DVLOG(1) << __func__ << ": " << surface_id; 147 DVLOG(1) << __func__ << ": " << surface_id;
148 DCHECK(thread_checker_.CalledOnValidThread()); 148 DCHECK(thread_checker_.CalledOnValidThread());
149 149
150 if (surface_id == SurfaceManager::kNoSurfaceID) 150 if (surface_id == SurfaceManager::kNoSurfaceID)
151 return true; 151 return true;
152 152
153 // If it's not owned or being released, |client| now owns it. 153 // If it's not owned or being released, |client| now owns it.
154 if (!surface_owners_.count(surface_id) && 154 if (!surface_owners_.count(surface_id) &&
155 !pending_codec_releases_.count(surface_id)) { 155 !pending_codec_releases_.count(surface_id)) {
156 surface_owners_[surface_id].owner = client; 156 surface_owners_[surface_id].owner = client;
157 return true; 157 return true;
158 } 158 }
159 159
160 // Otherwise |client| replaces the previous waiter (if any). 160 // Otherwise |client| replaces the previous waiter (if any).
161 OwnerRecord& record = surface_owners_[surface_id]; 161 OwnerRecord& record = surface_owners_[surface_id];
162 if (record.waiter) 162 if (record.waiter)
163 record.waiter->OnSurfaceAvailable(false); 163 record.waiter->OnSurfaceAvailable(false);
164 record.waiter = client; 164 record.waiter = client;
165 return false; 165 return false;
166 } 166 }
167 167
168 void AVDACodecAllocator::DeallocateSurface(AVDACodecAllocatorClient* client, 168 void AVDACodecAllocator::DeallocateSurface(AVDASurfaceAllocatorClient* client,
169 int surface_id) { 169 int surface_id) {
170 DCHECK(thread_checker_.CalledOnValidThread()); 170 DCHECK(thread_checker_.CalledOnValidThread());
171 if (surface_id == SurfaceManager::kNoSurfaceID || 171 if (surface_id == SurfaceManager::kNoSurfaceID ||
172 !surface_owners_.count(surface_id)) { 172 !surface_owners_.count(surface_id)) {
173 return; 173 return;
174 } 174 }
175 175
176 OwnerRecord& record = surface_owners_[surface_id]; 176 OwnerRecord& record = surface_owners_[surface_id];
177 if (record.owner == client) 177 if (record.owner == client)
178 record.owner = nullptr; 178 record.owner = nullptr;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 codec_config->media_crypto ? codec_config->media_crypto->obj() : nullptr; 247 codec_config->media_crypto ? codec_config->media_crypto->obj() : nullptr;
248 248
249 // |needs_protected_surface| implies encrypted stream. 249 // |needs_protected_surface| implies encrypted stream.
250 DCHECK(!codec_config->needs_protected_surface || media_crypto); 250 DCHECK(!codec_config->needs_protected_surface || media_crypto);
251 251
252 const bool require_software_codec = codec_config->task_type == SW_CODEC; 252 const bool require_software_codec = codec_config->task_type == SW_CODEC;
253 std::unique_ptr<MediaCodecBridge> codec( 253 std::unique_ptr<MediaCodecBridge> codec(
254 MediaCodecBridgeImpl::CreateVideoDecoder( 254 MediaCodecBridgeImpl::CreateVideoDecoder(
255 codec_config->codec, codec_config->needs_protected_surface, 255 codec_config->codec, codec_config->needs_protected_surface,
256 codec_config->initial_expected_coded_size, 256 codec_config->initial_expected_coded_size,
257 codec_config->surface_bundle->surface.j_surface().obj(), media_crypto, 257 codec_config->surface_bundle->j_surface().obj(), media_crypto,
258 codec_config->csd0, codec_config->csd1, true, 258 codec_config->csd0, codec_config->csd1, true,
259 require_software_codec)); 259 require_software_codec));
260 260
261 return codec; 261 return codec;
262 } 262 }
263 263
264 void AVDACodecAllocator::CreateMediaCodecAsync( 264 void AVDACodecAllocator::CreateMediaCodecAsync(
265 base::WeakPtr<AVDACodecAllocatorClient> client, 265 base::WeakPtr<AVDACodecAllocatorClient> client,
266 scoped_refptr<CodecConfig> codec_config) { 266 scoped_refptr<CodecConfig> codec_config) {
267 // Allocate the codec on the appropriate thread, and reply to this one with 267 // Allocate the codec on the appropriate thread, and reply to this one with
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 void AVDACodecAllocator::StopThreadTask(size_t index) { 399 void AVDACodecAllocator::StopThreadTask(size_t index) {
400 threads_[index]->thread.Stop(); 400 threads_[index]->thread.Stop();
401 // Signal the stop event after both threads are stopped. 401 // Signal the stop event after both threads are stopped.
402 if (stop_event_for_testing_ && !threads_[AUTO_CODEC]->thread.IsRunning() && 402 if (stop_event_for_testing_ && !threads_[AUTO_CODEC]->thread.IsRunning() &&
403 !threads_[SW_CODEC]->thread.IsRunning()) { 403 !threads_[SW_CODEC]->thread.IsRunning()) {
404 stop_event_for_testing_->Signal(); 404 stop_event_for_testing_->Signal();
405 } 405 }
406 } 406 }
407 407
408 } // namespace media 408 } // namespace media
OLDNEW
« no previous file with comments | « media/gpu/avda_codec_allocator.h ('k') | media/gpu/avda_codec_allocator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698