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

Side by Side Diff: media/gpu/android_video_decode_accelerator.h

Issue 2707703002: Group AVDA output surface into AVDASurfaceBundle. (Closed)
Patch Set: rebased 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/BUILD.gn ('k') | media/gpu/android_video_decode_accelerator.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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #ifndef MEDIA_GPU_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ 5 #ifndef MEDIA_GPU_ANDROID_VIDEO_DECODE_ACCELERATOR_H_
6 #define MEDIA_GPU_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ 6 #define MEDIA_GPU_ANDROID_VIDEO_DECODE_ACCELERATOR_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <list> 10 #include <list>
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 DRAIN_FOR_RESET, 108 DRAIN_FOR_RESET,
109 DRAIN_FOR_DESTROY, 109 DRAIN_FOR_DESTROY,
110 }; 110 };
111 111
112 // Entry point for configuring / reconfiguring a codec with a new surface. 112 // Entry point for configuring / reconfiguring a codec with a new surface.
113 // Start surface creation by trying to allocate the surface id. Will either 113 // Start surface creation by trying to allocate the surface id. Will either
114 // InitializePictureBufferManager if the surface is available immediately, or 114 // InitializePictureBufferManager if the surface is available immediately, or
115 // will wait for OnSurfaceAvailable to do it. This will transition |state_| 115 // will wait for OnSurfaceAvailable to do it. This will transition |state_|
116 // to WAITING_FOR_SURFACE or WAITING_FOR_CODEC, as needed (or NO_ERROR if it 116 // to WAITING_FOR_SURFACE or WAITING_FOR_CODEC, as needed (or NO_ERROR if it
117 // gets the surface and the codec without waiting). 117 // gets the surface and the codec without waiting).
118 // Note that this requires that you create a new |incoming_bundle_| with the
119 // appropriate surface id.
118 void StartSurfaceCreation(); 120 void StartSurfaceCreation();
119 121
120 // Initialize of the picture buffer manager to use the current surface, once 122 // Initialize of the picture buffer manager to use the current surface, once
121 // it is available. This is not normally called directly, but rather via 123 // it is available. This is not normally called directly, but rather via
122 // StartSurfaceCreation. If we have a media codec already, then this will 124 // StartSurfaceCreation. If we have a media codec already, then this will
123 // attempt to setSurface the new surface. Otherwise, it will start codec 125 // attempt to setSurface the new surface. Otherwise, it will start codec
124 // config using the new surface. In that case, there might not be a codec 126 // config using the new surface. In that case, there might not be a codec
125 // ready even if this succeeds, but async config will be started. If 127 // ready even if this succeeds, but async config will be started. If
126 // setSurface fails, this will not replace the codec. On failure, this will 128 // setSurface fails, this will not replace the codec. On failure, this will
127 // transition |state_| to ERROR. 129 // transition |state_| to ERROR.
130 // Note that this assumes that there is an |incoming_bundle_| that we'll use.
131 // On success, we'll replace the bundle in |codec_config_|. On failure, we'll
132 // delete the incoming bundle.
128 void InitializePictureBufferManager(); 133 void InitializePictureBufferManager();
129 134
130 // A part of destruction process that is sometimes postponed after the drain. 135 // A part of destruction process that is sometimes postponed after the drain.
131 void ActualDestroy(); 136 void ActualDestroy();
132 137
133 // Configures |media_codec_| with the given codec parameters from the client. 138 // Configures |media_codec_| with the given codec parameters from the client.
134 // This configuration will (probably) not be complete before this call 139 // This configuration will (probably) not be complete before this call
135 // returns. Multiple calls before completion will be ignored. |state_| 140 // returns. Multiple calls before completion will be ignored. |state_|
136 // must be NO_ERROR or WAITING_FOR_CODEC. Note that, once you call this, 141 // must be NO_ERROR or WAITING_FOR_CODEC. Note that, once you call this,
137 // you should be careful to avoid modifying members of |codec_config_| until 142 // you should be careful to avoid modifying members of |codec_config_| until
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 // On platforms which support seamless surface changes, this will reinitialize 238 // On platforms which support seamless surface changes, this will reinitialize
234 // the picture buffer manager with the new surface. This function reads and 239 // the picture buffer manager with the new surface. This function reads and
235 // clears the surface id from |pending_surface_id_|. It will issue a decode 240 // clears the surface id from |pending_surface_id_|. It will issue a decode
236 // error if the surface change fails. Returns false on failure. 241 // error if the surface change fails. Returns false on failure.
237 bool UpdateSurface(); 242 bool UpdateSurface();
238 243
239 // Release |media_codec_| if it's not null, and notify 244 // Release |media_codec_| if it's not null, and notify
240 // |picture_buffer_manager_|. 245 // |picture_buffer_manager_|.
241 void ReleaseCodec(); 246 void ReleaseCodec();
242 247
248 // Returns the surface ID from the incoming bundle, if we have one, or
249 // the current surface bundle if not. The reasoning is that, if we have an
250 // incoming bundle, then the current (outgoing) one has already been returned
251 // to the codec allocator via DeallocateSurface. The only place this happens
252 // is UpdateSurface, which handles it specially.
253 int surface_id() const {
254 return incoming_bundle_ ? incoming_bundle_->surface_id
255 : codec_config_->surface_bundle->surface_id;
256 }
257
243 // Used to DCHECK that we are called on the correct thread. 258 // Used to DCHECK that we are called on the correct thread.
244 base::ThreadChecker thread_checker_; 259 base::ThreadChecker thread_checker_;
245 260
246 // To expose client callbacks from VideoDecodeAccelerator. 261 // To expose client callbacks from VideoDecodeAccelerator.
247 Client* client_; 262 Client* client_;
248 263
249 AVDACodecAllocator* codec_allocator_; 264 AVDACodecAllocator* codec_allocator_;
250 265
251 // Callback to set the correct gl context. 266 // Callback to set the correct gl context.
252 MakeGLContextCurrentCallback make_context_current_cb_; 267 MakeGLContextCurrentCallback make_context_current_cb_;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 361
347 // True if surface creation and |picture_buffer_manager_| initialization has 362 // True if surface creation and |picture_buffer_manager_| initialization has
348 // been defered until the first Decode() call. 363 // been defered until the first Decode() call.
349 bool defer_surface_creation_; 364 bool defer_surface_creation_;
350 365
351 // Has a value if a SetSurface() call has occurred and a new surface should be 366 // Has a value if a SetSurface() call has occurred and a new surface should be
352 // switched to when possible. Cleared during OnSurfaceDestroyed() and if all 367 // switched to when possible. Cleared during OnSurfaceDestroyed() and if all
353 // pictures have been rendered in DequeueOutput(). 368 // pictures have been rendered in DequeueOutput().
354 base::Optional<int32_t> pending_surface_id_; 369 base::Optional<int32_t> pending_surface_id_;
355 370
356 // The task type used for the last codec release. For posting SurfaceTexture
357 // release to the same thread.
358 TaskType last_release_task_type_;
359
360 // Copy of the VDA::Config we were given. 371 // Copy of the VDA::Config we were given.
361 Config config_; 372 Config config_;
362 373
374 // SurfaceBundle that we're going to use for StartSurfaceCreation. This is
375 // separate than the bundle in |codec_config_|, since we can start surface
376 // creation while another codec is using the old surface. For example, if
377 // we're going to SetSurface, then the current codec will depend on the
378 // current bundle until then.
379 scoped_refptr<AVDASurfaceBundle> incoming_bundle_;
380
363 // WeakPtrFactory for posting tasks back to |this|. 381 // WeakPtrFactory for posting tasks back to |this|.
364 base::WeakPtrFactory<AndroidVideoDecodeAccelerator> weak_this_factory_; 382 base::WeakPtrFactory<AndroidVideoDecodeAccelerator> weak_this_factory_;
365 383
366 friend class AndroidVideoDecodeAcceleratorTest; 384 friend class AndroidVideoDecodeAcceleratorTest;
367 }; 385 };
368 386
369 } // namespace media 387 } // namespace media
370 388
371 #endif // MEDIA_GPU_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ 389 #endif // MEDIA_GPU_ANDROID_VIDEO_DECODE_ACCELERATOR_H_
OLDNEW
« no previous file with comments | « media/gpu/BUILD.gn ('k') | media/gpu/android_video_decode_accelerator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698