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

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

Issue 2707703002: Group AVDA output surface into AVDASurfaceBundle. (Closed)
Patch Set: minor fixes after testing Created 3 years, 10 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 (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.
watk 2017/02/22 20:38:55 Could you give me a mental model for why this is t
liberato (no reviews please) 2017/02/23 18:18:46 after yet more thought after our offline discussio
250 int surface_id() const {
251 return incoming_bundle_ ? incoming_bundle_->surface_id
252 : codec_config_->surface_bundle->surface_id;
253 }
254
243 // Used to DCHECK that we are called on the correct thread. 255 // Used to DCHECK that we are called on the correct thread.
244 base::ThreadChecker thread_checker_; 256 base::ThreadChecker thread_checker_;
245 257
246 // To expose client callbacks from VideoDecodeAccelerator. 258 // To expose client callbacks from VideoDecodeAccelerator.
247 Client* client_; 259 Client* client_;
248 260
249 AVDACodecAllocator* codec_allocator_; 261 AVDACodecAllocator* codec_allocator_;
250 262
251 // Callback to set the correct gl context. 263 // Callback to set the correct gl context.
252 MakeGLContextCurrentCallback make_context_current_cb_; 264 MakeGLContextCurrentCallback make_context_current_cb_;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 358
347 // True if surface creation and |picture_buffer_manager_| initialization has 359 // True if surface creation and |picture_buffer_manager_| initialization has
348 // been defered until the first Decode() call. 360 // been defered until the first Decode() call.
349 bool defer_surface_creation_; 361 bool defer_surface_creation_;
350 362
351 // Has a value if a SetSurface() call has occurred and a new surface should be 363 // 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 364 // switched to when possible. Cleared during OnSurfaceDestroyed() and if all
353 // pictures have been rendered in DequeueOutput(). 365 // pictures have been rendered in DequeueOutput().
354 base::Optional<int32_t> pending_surface_id_; 366 base::Optional<int32_t> pending_surface_id_;
355 367
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. 368 // Copy of the VDA::Config we were given.
361 Config config_; 369 Config config_;
362 370
371 // SurfaceBundle that we're going to use for StartSurfaceCreation. This is
372 // separate than the bundle in |codec_config_|, since we can start surface
373 // creation while another codec is using the old surface. For example, if
374 // we're going to SetSurface, then the current codec will depend on the
375 // current bundle until then.
376 scoped_refptr<AVDASurfaceBundle> incoming_bundle_;
377
363 // WeakPtrFactory for posting tasks back to |this|. 378 // WeakPtrFactory for posting tasks back to |this|.
364 base::WeakPtrFactory<AndroidVideoDecodeAccelerator> weak_this_factory_; 379 base::WeakPtrFactory<AndroidVideoDecodeAccelerator> weak_this_factory_;
365 380
366 friend class AndroidVideoDecodeAcceleratorTest; 381 friend class AndroidVideoDecodeAcceleratorTest;
367 }; 382 };
368 383
369 } // namespace media 384 } // namespace media
370 385
371 #endif // MEDIA_GPU_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ 386 #endif // MEDIA_GPU_ANDROID_VIDEO_DECODE_ACCELERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698