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

Side by Side Diff: content/renderer/media/rtc_video_decoder.h

Issue 1850063003: Dynamic error tracking in RTCVideoDecoder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_
6 #define CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_ 6 #define CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 BufferData(); 101 BufferData();
102 ~BufferData(); 102 ~BufferData();
103 int32_t bitstream_buffer_id; 103 int32_t bitstream_buffer_id;
104 uint32_t timestamp; // in 90KHz 104 uint32_t timestamp; // in 90KHz
105 size_t size; // buffer size 105 size_t size; // buffer size
106 gfx::Rect visible_rect; 106 gfx::Rect visible_rect;
107 }; 107 };
108 108
109 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, IsBufferAfterReset); 109 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, IsBufferAfterReset);
110 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, IsFirstBufferAfterReset); 110 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, IsFirstBufferAfterReset);
111 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, GetVDAErrorCounter);
111 112
112 RTCVideoDecoder(webrtc::VideoCodecType type, 113 RTCVideoDecoder(webrtc::VideoCodecType type,
113 media::GpuVideoAcceleratorFactories* factories); 114 media::GpuVideoAcceleratorFactories* factories);
114 115
115 // Requests a buffer to be decoded by VDA. 116 // Requests a buffer to be decoded by VDA.
116 void RequestBufferDecode(); 117 void RequestBufferDecode();
117 118
118 bool CanMoreDecodeWorkBeDone(); 119 bool CanMoreDecodeWorkBeDone();
119 120
120 // Returns true if bitstream buffer id |id_buffer| comes after |id_reset|. 121 // Returns true if bitstream buffer id |id_buffer| comes after |id_reset|.
121 // This handles the wraparound. 122 // This handles the wraparound.
122 bool IsBufferAfterReset(int32_t id_buffer, int32_t id_reset); 123 bool IsBufferAfterReset(int32_t id_buffer, int32_t id_reset);
123 124
124 // Returns true if bitstream buffer |id_buffer| is the first buffer after 125 // Returns true if bitstream buffer |id_buffer| is the first buffer after
125 // |id_reset|. 126 // |id_reset|.
126 bool IsFirstBufferAfterReset(int32_t id_buffer, int32_t id_reset); 127 bool IsFirstBufferAfterReset(int32_t id_buffer, int32_t id_reset);
127 128
129 int GetVDAErrorCounter() { return vda_error_counter_; }
mcasas 2016/04/05 21:32:01 GetVDAErrorCounterForTesting() ? (The suffix ForTe
emircan 2016/04/05 23:18:06 Done.
130
128 // Saves a WebRTC buffer in |decode_buffers_| for decode. 131 // Saves a WebRTC buffer in |decode_buffers_| for decode.
129 void SaveToDecodeBuffers_Locked(const webrtc::EncodedImage& input_image, 132 void SaveToDecodeBuffers_Locked(const webrtc::EncodedImage& input_image,
130 scoped_ptr<base::SharedMemory> shm_buffer, 133 scoped_ptr<base::SharedMemory> shm_buffer,
131 const BufferData& buffer_data); 134 const BufferData& buffer_data);
132 135
133 // Saves a WebRTC buffer in |pending_buffers_| waiting for SHM available. 136 // Saves a WebRTC buffer in |pending_buffers_| waiting for SHM available.
134 // Returns true on success. 137 // Returns true on success.
135 bool SaveToPendingBuffers_Locked(const webrtc::EncodedImage& input_image, 138 bool SaveToPendingBuffers_Locked(const webrtc::EncodedImage& input_image,
136 const BufferData& buffer_data); 139 const BufferData& buffer_data);
137 140
(...skipping 11 matching lines...) Expand all
149 152
150 // Static method is to allow it to run even after RVD is deleted. 153 // Static method is to allow it to run even after RVD is deleted.
151 static void ReleaseMailbox(base::WeakPtr<RTCVideoDecoder> decoder, 154 static void ReleaseMailbox(base::WeakPtr<RTCVideoDecoder> decoder,
152 media::GpuVideoAcceleratorFactories* factories, 155 media::GpuVideoAcceleratorFactories* factories,
153 int64_t picture_buffer_id, 156 int64_t picture_buffer_id,
154 uint32_t texture_id, 157 uint32_t texture_id,
155 const gpu::SyncToken& release_sync_token); 158 const gpu::SyncToken& release_sync_token);
156 // Tells VDA that a picture buffer can be recycled. 159 // Tells VDA that a picture buffer can be recycled.
157 void ReusePictureBuffer(int64_t picture_buffer_id); 160 void ReusePictureBuffer(int64_t picture_buffer_id);
158 161
159 // Create |vda_| on |vda_loop_proxy_|. 162 // Creates |vda_| on |vda_loop_proxy_|.
160 void CreateVDA(media::VideoCodecProfile profile, base::WaitableEvent* waiter); 163 void CreateVDA(media::VideoCodecProfile profile, base::WaitableEvent* waiter);
161 164
162 void DestroyTextures(); 165 void DestroyTextures();
163 void DestroyVDA(); 166 void DestroyVDA();
164 167
165 // Gets a shared-memory segment of at least |min_size| bytes from 168 // Gets a shared-memory segment of at least |min_size| bytes from
166 // |available_shm_segments_|. Returns NULL if there is no buffer or the 169 // |available_shm_segments_|. Returns NULL if there is no buffer or the
167 // buffer is not big enough. 170 // buffer is not big enough.
168 scoped_ptr<base::SharedMemory> GetSHM_Locked(size_t min_size); 171 scoped_ptr<base::SharedMemory> GetSHM_Locked(size_t min_size);
169 172
170 // Returns a shared-memory segment to the available pool. 173 // Returns a shared-memory segment to the available pool.
171 void PutSHM_Locked(scoped_ptr<base::SharedMemory> shm_buffer); 174 void PutSHM_Locked(scoped_ptr<base::SharedMemory> shm_buffer);
172 175
173 // Allocates |count| shared memory buffers of |size| bytes. 176 // Allocates |count| shared memory buffers of |size| bytes.
174 void CreateSHM(size_t count, size_t size); 177 void CreateSHM(size_t count, size_t size);
175 178
176 // Stores the buffer metadata to |input_buffer_data_|. 179 // Stores the buffer metadata to |input_buffer_data_|.
177 void RecordBufferData(const BufferData& buffer_data); 180 void RecordBufferData(const BufferData& buffer_data);
178 // Gets the buffer metadata from |input_buffer_data_|. 181 // Gets the buffer metadata from |input_buffer_data_|.
179 void GetBufferData(int32_t bitstream_buffer_id, 182 void GetBufferData(int32_t bitstream_buffer_id,
180 uint32_t* timestamp, 183 uint32_t* timestamp,
181 gfx::Rect* visible_rect); 184 gfx::Rect* visible_rect);
182 185
183 // Records the result of InitDecode to UMA and returns |status|. 186 // Records the result of InitDecode to UMA and returns |status|.
184 int32_t RecordInitDecodeUMA(int32_t status); 187 int32_t RecordInitDecodeUMA(int32_t status);
185 188
186 // Assert the contract that this class is operated on the right thread. 189 // Asserts the contract that this class is operated on the right thread.
187 void DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() const; 190 void DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() const;
188 191
189 // Query factories_ whether |profile| is supported and return true is so, 192 // Queries factories_ whether |profile| is supported and return true is so,
190 // false otherwise. If true, also set resolution limits for |profile| 193 // false otherwise. If true, also set resolution limits for |profile|
191 // in min/max_resolution_. 194 // in min/max_resolution_.
192 bool IsProfileSupported(media::VideoCodecProfile profile); 195 bool IsProfileSupported(media::VideoCodecProfile profile);
193 196
194 // Clear the pending_buffers_ queue, freeing memory. 197 // Clears the pending_buffers_ queue, freeing memory.
195 void ClearPendingBuffers(); 198 void ClearPendingBuffers();
196 199
200 // Resets |vda_error_counter_| after a successfull run of decode.
201 void TryResetVDAErrorCounter_Locked();
202
197 enum State { 203 enum State {
198 UNINITIALIZED, // The decoder has not initialized. 204 UNINITIALIZED, // The decoder has not initialized.
199 INITIALIZED, // The decoder has initialized. 205 INITIALIZED, // The decoder has initialized.
200 RESETTING, // The decoder is being reset. 206 RESETTING, // The decoder is being reset.
201 DECODE_ERROR, // Decoding error happened. 207 DECODE_ERROR, // Decoding error happened.
202 }; 208 };
203 209
204 static const int32_t ID_LAST; // maximum bitstream buffer id 210 static const int32_t ID_LAST; // maximum bitstream buffer id
205 static const int32_t ID_HALF; // half of the maximum bitstream buffer id 211 static const int32_t ID_HALF; // half of the maximum bitstream buffer id
206 static const int32_t ID_INVALID; // indicates Reset or Release never occurred 212 static const int32_t ID_INVALID; // indicates Reset or Release never occurred
207 213
208 // The hardware video decoder. 214 // The hardware video decoder.
209 scoped_ptr<media::VideoDecodeAccelerator> vda_; 215 scoped_ptr<media::VideoDecodeAccelerator> vda_;
210 216
211 media::VideoCodecProfile vda_codec_profile_; 217 media::VideoCodecProfile vda_codec_profile_;
212 218
213 // Number of times that |vda_| notified of an error. 219 // Number of times that |vda_| notified of an error.
214 uint32_t num_vda_errors_; 220 uint32_t vda_error_counter_;
215 221
216 // The video codec type, as reported by WebRTC. 222 // The video codec type, as reported by WebRTC.
217 const webrtc::VideoCodecType video_codec_type_; 223 const webrtc::VideoCodecType video_codec_type_;
218 224
219 // The size of the incoming video frames. 225 // The size of the incoming video frames.
220 gfx::Size frame_size_; 226 gfx::Size frame_size_;
221 227
222 media::GpuVideoAcceleratorFactories* const factories_; 228 media::GpuVideoAcceleratorFactories* const factories_;
223 229
224 // The texture target used for decoded pictures. 230 // The texture target used for decoded pictures.
(...skipping 14 matching lines...) Expand all
239 // to us via ReusePictureBuffer. 245 // to us via ReusePictureBuffer.
240 typedef std::map<int32_t /* picture_buffer_id */, uint32_t /* texture_id */> 246 typedef std::map<int32_t /* picture_buffer_id */, uint32_t /* texture_id */>
241 PictureBufferTextureMap; 247 PictureBufferTextureMap;
242 PictureBufferTextureMap picture_buffers_at_display_; 248 PictureBufferTextureMap picture_buffers_at_display_;
243 249
244 // The id that will be given to the next picture buffer. 250 // The id that will be given to the next picture buffer.
245 int32_t next_picture_buffer_id_; 251 int32_t next_picture_buffer_id_;
246 252
247 // Protects |state_|, |decode_complete_callback_| , |num_shm_buffers_|, 253 // Protects |state_|, |decode_complete_callback_| , |num_shm_buffers_|,
248 // |available_shm_segments_|, |pending_buffers_|, |decode_buffers_|, 254 // |available_shm_segments_|, |pending_buffers_|, |decode_buffers_|,
249 // |next_bitstream_buffer_id_| and |reset_bitstream_buffer_id_|. 255 // |next_bitstream_buffer_id_|, |reset_bitstream_buffer_id_| and
256 // |vda_error_counter_|.
250 base::Lock lock_; 257 base::Lock lock_;
251 258
252 // The state of RTCVideoDecoder. Guarded by |lock_|. 259 // The state of RTCVideoDecoder. Guarded by |lock_|.
253 State state_; 260 State state_;
254 261
255 // Guarded by |lock_|. 262 // Guarded by |lock_|.
256 webrtc::DecodedImageCallback* decode_complete_callback_; 263 webrtc::DecodedImageCallback* decode_complete_callback_;
257 264
258 // Total number of allocated SHM buffers. Guarded by |lock_|. 265 // Total number of allocated SHM buffers. Guarded by |lock_|.
259 size_t num_shm_buffers_; 266 size_t num_shm_buffers_;
(...skipping 26 matching lines...) Expand all
286 // Must be destroyed, or invalidated, on |vda_loop_proxy_| 293 // Must be destroyed, or invalidated, on |vda_loop_proxy_|
287 // NOTE: Weak pointers must be invalidated before all other member variables. 294 // NOTE: Weak pointers must be invalidated before all other member variables.
288 base::WeakPtrFactory<RTCVideoDecoder> weak_factory_; 295 base::WeakPtrFactory<RTCVideoDecoder> weak_factory_;
289 296
290 DISALLOW_COPY_AND_ASSIGN(RTCVideoDecoder); 297 DISALLOW_COPY_AND_ASSIGN(RTCVideoDecoder);
291 }; 298 };
292 299
293 } // namespace content 300 } // namespace content
294 301
295 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_ 302 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_
OLDNEW
« no previous file with comments | « no previous file | content/renderer/media/rtc_video_decoder.cc » ('j') | content/renderer/media/rtc_video_decoder.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698