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

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

Issue 2697643003: media: Clean up MediaCodecBridge and remove subclasses (Closed)
Patch Set: 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 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 #ifndef MEDIA_GPU_AVDA_CODEC_ALLOCATOR_H_ 5 #ifndef MEDIA_GPU_AVDA_CODEC_ALLOCATOR_H_
6 #define MEDIA_GPU_AVDA_CODEC_ALLOCATOR_H_ 6 #define MEDIA_GPU_AVDA_CODEC_ALLOCATOR_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 // Called when the allocated surface is being destroyed. This must either 93 // Called when the allocated surface is being destroyed. This must either
94 // replace the surface with MediaCodec#setSurface, or release the MediaCodec 94 // replace the surface with MediaCodec#setSurface, or release the MediaCodec
95 // it's attached to. The client no longer owns the surface and doesn't 95 // it's attached to. The client no longer owns the surface and doesn't
96 // need to call DeallocateSurface(); 96 // need to call DeallocateSurface();
97 virtual void OnSurfaceDestroyed() = 0; 97 virtual void OnSurfaceDestroyed() = 0;
98 98
99 // Called on the main thread when a new MediaCodec is configured. 99 // Called on the main thread when a new MediaCodec is configured.
100 // |media_codec| will be null if configuration failed. 100 // |media_codec| will be null if configuration failed.
101 virtual void OnCodecConfigured( 101 virtual void OnCodecConfigured(
102 std::unique_ptr<VideoCodecBridge> media_codec) = 0; 102 std::unique_ptr<MediaCodecBridge> media_codec) = 0;
103 103
104 protected: 104 protected:
105 ~AVDACodecAllocatorClient() {} 105 ~AVDACodecAllocatorClient() {}
106 }; 106 };
107 107
108 // AVDACodecAllocator manages threads for allocating and releasing MediaCodec 108 // AVDACodecAllocator manages threads for allocating and releasing MediaCodec
109 // instances. These activities can hang, depending on android version, due 109 // instances. These activities can hang, depending on android version, due
110 // to mediaserver bugs. AVDACodecAllocator detects these cases, and reports 110 // to mediaserver bugs. AVDACodecAllocator detects these cases, and reports
111 // on them to allow software fallback if the HW path is hung up. 111 // on them to allow software fallback if the HW path is hung up.
112 class MEDIA_GPU_EXPORT AVDACodecAllocator { 112 class MEDIA_GPU_EXPORT AVDACodecAllocator {
(...skipping 15 matching lines...) Expand all
128 // via OnSurfaceAvailable(). 128 // via OnSurfaceAvailable().
129 bool AllocateSurface(AVDACodecAllocatorClient* client, int surface_id); 129 bool AllocateSurface(AVDACodecAllocatorClient* client, int surface_id);
130 130
131 // Relinquish ownership of the surface or stop waiting for it to be available. 131 // Relinquish ownership of the surface or stop waiting for it to be available.
132 // The caller must guarantee that when calling this the surface is either no 132 // The caller must guarantee that when calling this the surface is either no
133 // longer attached to a MediaCodec, or the MediaCodec it was attached to is 133 // longer attached to a MediaCodec, or the MediaCodec it was attached to is
134 // was released with ReleaseMediaCodec(). 134 // was released with ReleaseMediaCodec().
135 void DeallocateSurface(AVDACodecAllocatorClient* client, int surface_id); 135 void DeallocateSurface(AVDACodecAllocatorClient* client, int surface_id);
136 136
137 // Create and configure a MediaCodec synchronously. 137 // Create and configure a MediaCodec synchronously.
138 std::unique_ptr<VideoCodecBridge> CreateMediaCodecSync( 138 std::unique_ptr<MediaCodecBridge> CreateMediaCodecSync(
139 scoped_refptr<CodecConfig> codec_config); 139 scoped_refptr<CodecConfig> codec_config);
140 140
141 // Create and configure a MediaCodec asynchronously. The result is delivered 141 // Create and configure a MediaCodec asynchronously. The result is delivered
142 // via OnCodecConfigured(). 142 // via OnCodecConfigured().
143 void CreateMediaCodecAsync(base::WeakPtr<AVDACodecAllocatorClient> client, 143 void CreateMediaCodecAsync(base::WeakPtr<AVDACodecAllocatorClient> client,
144 scoped_refptr<CodecConfig> codec_config); 144 scoped_refptr<CodecConfig> codec_config);
145 145
146 // Asynchronously release |media_codec| with the attached surface. 146 // Asynchronously release |media_codec| with the attached surface.
147 // TODO(watk): Bundle the MediaCodec and surface together so you can't get 147 // TODO(watk): Bundle the MediaCodec and surface together so you can't get
148 // this pairing wrong. 148 // this pairing wrong.
149 void ReleaseMediaCodec(std::unique_ptr<VideoCodecBridge> media_codec, 149 void ReleaseMediaCodec(std::unique_ptr<MediaCodecBridge> media_codec,
150 TaskType task_type, 150 TaskType task_type,
151 int surface_id); 151 int surface_id);
152 152
153 // Returns a hint about whether the construction thread has hung for 153 // Returns a hint about whether the construction thread has hung for
154 // |task_type|. Note that if a thread isn't started, then we'll just return 154 // |task_type|. Note that if a thread isn't started, then we'll just return
155 // "not hung", since it'll run on the current thread anyway. The hang 155 // "not hung", since it'll run on the current thread anyway. The hang
156 // detector will see no pending jobs in that case, so it's automatic. 156 // detector will see no pending jobs in that case, so it's automatic.
157 bool IsThreadLikelyHung(TaskType task_type); 157 bool IsThreadLikelyHung(TaskType task_type);
158 158
159 // Return true if and only if there is any AVDA registered. 159 // Return true if and only if there is any AVDA registered.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 234
235 // For canceling pending StopThreadTask()s. 235 // For canceling pending StopThreadTask()s.
236 base::WeakPtrFactory<AVDACodecAllocator> weak_this_factory_; 236 base::WeakPtrFactory<AVDACodecAllocator> weak_this_factory_;
237 237
238 DISALLOW_COPY_AND_ASSIGN(AVDACodecAllocator); 238 DISALLOW_COPY_AND_ASSIGN(AVDACodecAllocator);
239 }; 239 };
240 240
241 } // namespace media 241 } // namespace media
242 242
243 #endif // MEDIA_GPU_AVDA_CODEC_ALLOCATOR_H_ 243 #endif // MEDIA_GPU_AVDA_CODEC_ALLOCATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698