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

Side by Side Diff: content/common/gpu/media/video_decode_accelerator_unittest.cc

Issue 10749019: VideoDecodeAccelerator now SupportsWeakPtr instead of being RefCountedThreadSafe. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // The bulk of this file is support code; sorry about that. Here's an overview 5 // The bulk of this file is support code; sorry about that. Here's an overview
6 // to hopefully help readers of this code: 6 // to hopefully help readers of this code:
7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or 7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or
8 // Win/EGL. 8 // Win/EGL.
9 // - ClientState is an enum for the state of the decode client used by the test. 9 // - ClientState is an enum for the state of the decode client used by the test.
10 // - ClientStateNotification is a barrier abstraction that allows the test code 10 // - ClientStateNotification is a barrier abstraction that allows the test code
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 virtual void NotifyEndOfBitstreamBuffer(int32 bitstream_buffer_id); 217 virtual void NotifyEndOfBitstreamBuffer(int32 bitstream_buffer_id);
218 virtual void NotifyFlushDone(); 218 virtual void NotifyFlushDone();
219 virtual void NotifyResetDone(); 219 virtual void NotifyResetDone();
220 virtual void NotifyError(VideoDecodeAccelerator::Error error); 220 virtual void NotifyError(VideoDecodeAccelerator::Error error);
221 221
222 // Simple getters for inspecting the state of the Client. 222 // Simple getters for inspecting the state of the Client.
223 ClientState state() { return state_; } 223 ClientState state() { return state_; }
224 int num_done_bitstream_buffers() { return num_done_bitstream_buffers_; } 224 int num_done_bitstream_buffers() { return num_done_bitstream_buffers_; }
225 int num_decoded_frames() { return num_decoded_frames_; } 225 int num_decoded_frames() { return num_decoded_frames_; }
226 double frames_per_second(); 226 double frames_per_second();
227 bool decoder_deleted() { return !decoder_; } 227 bool decoder_deleted() { return !decoder_.get(); }
228 228
229 private: 229 private:
230 typedef std::map<int, media::PictureBuffer*> PictureBufferById; 230 typedef std::map<int, media::PictureBuffer*> PictureBufferById;
231 231
232 void SetState(ClientState new_state); 232 void SetState(ClientState new_state);
233 233
234 // Delete the associated OMX decoder helper. 234 // Delete the associated OMX decoder helper.
235 void DeleteDecoder(); 235 void DeleteDecoder();
236 236
237 // Compute & return in |*end_pos| the end position for the next batch of NALUs 237 // Compute & return in |*end_pos| the end position for the next batch of NALUs
238 // to ship to the decoder (based on |start_pos| & |num_NALUs_per_decode_|). 238 // to ship to the decoder (based on |start_pos| & |num_NALUs_per_decode_|).
239 void GetRangeForNextNALUs(size_t start_pos, size_t* end_pos); 239 void GetRangeForNextNALUs(size_t start_pos, size_t* end_pos);
240 240
241 // Request decode of the next batch of NALUs in the encoded data. 241 // Request decode of the next batch of NALUs in the encoded data.
242 void DecodeNextNALUs(); 242 void DecodeNextNALUs();
243 243
244 RenderingHelper* rendering_helper_; 244 RenderingHelper* rendering_helper_;
245 int rendering_window_id_; 245 int rendering_window_id_;
246 std::string encoded_data_; 246 std::string encoded_data_;
247 const int num_NALUs_per_decode_; 247 const int num_NALUs_per_decode_;
248 const int num_in_flight_decodes_; 248 const int num_in_flight_decodes_;
249 int outstanding_decodes_; 249 int outstanding_decodes_;
250 size_t encoded_data_next_pos_to_decode_; 250 size_t encoded_data_next_pos_to_decode_;
251 int next_bitstream_buffer_id_; 251 int next_bitstream_buffer_id_;
252 ClientStateNotification* note_; 252 ClientStateNotification* note_;
253 scoped_refptr<VideoDecodeAccelerator> decoder_; 253 scoped_ptr<VideoDecodeAccelerator> decoder_;
254 std::set<int> outstanding_texture_ids_; 254 std::set<int> outstanding_texture_ids_;
255 int remaining_play_throughs_; 255 int remaining_play_throughs_;
256 int reset_after_frame_num_; 256 int reset_after_frame_num_;
257 int delete_decoder_state_; 257 int delete_decoder_state_;
258 ClientState state_; 258 ClientState state_;
259 int num_decoded_frames_; 259 int num_decoded_frames_;
260 int num_done_bitstream_buffers_; 260 int num_done_bitstream_buffers_;
261 PictureBufferById picture_buffers_by_id_; 261 PictureBufferById picture_buffers_by_id_;
262 base::TimeTicks initialize_done_ticks_; 262 base::TimeTicks initialize_done_ticks_;
263 base::TimeTicks last_frame_delivered_ticks_; 263 base::TimeTicks last_frame_delivered_ticks_;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 SetState(CS_DESTROYED); 301 SetState(CS_DESTROYED);
302 } 302 }
303 303
304 #if !defined(OS_WIN) && !defined(OS_MACOSX) && defined(ARCH_CPU_X86_FAMILY) 304 #if !defined(OS_WIN) && !defined(OS_MACOSX) && defined(ARCH_CPU_X86_FAMILY)
305 static bool DoNothingReturnTrue() { return true; } 305 static bool DoNothingReturnTrue() { return true; }
306 #endif 306 #endif
307 307
308 void GLRenderingVDAClient::CreateDecoder() { 308 void GLRenderingVDAClient::CreateDecoder() {
309 CHECK(decoder_deleted()); 309 CHECK(decoder_deleted());
310 #if defined(OS_WIN) 310 #if defined(OS_WIN)
311 scoped_refptr<DXVAVideoDecodeAccelerator> decoder = 311 scoped_ptr<DXVAVideoDecodeAccelerator> decoder(
312 new DXVAVideoDecodeAccelerator(this); 312 new DXVAVideoDecodeAccelerator(this));
313 #elif defined(OS_MACOSX) 313 #elif defined(OS_MACOSX)
314 scoped_refptr<MacVideoDecodeAccelerator> decoder = 314 scoped_ptr<MacVideoDecodeAccelerator> decoder(
315 new MacVideoDecodeAccelerator(this); 315 new MacVideoDecodeAccelerator(this));
316 decoder->SetCGLContext( 316 decoder->SetCGLContext(
317 static_cast<CGLContextObj>(rendering_helper_->GetGLContext())); 317 static_cast<CGLContextObj>(rendering_helper_->GetGLContext()));
318 #elif defined(ARCH_CPU_ARMEL) 318 #elif defined(ARCH_CPU_ARMEL)
319 scoped_refptr<OmxVideoDecodeAccelerator> decoder = 319 scoped_ptr<OmxVideoDecodeAccelerator> decoder(
320 new OmxVideoDecodeAccelerator(this); 320 new OmxVideoDecodeAccelerator(this));
321 decoder->SetEglState( 321 decoder->SetEglState(
322 static_cast<EGLDisplay>(rendering_helper_->GetGLDisplay()), 322 static_cast<EGLDisplay>(rendering_helper_->GetGLDisplay()),
323 static_cast<EGLContext>(rendering_helper_->GetGLContext())); 323 static_cast<EGLContext>(rendering_helper_->GetGLContext()));
324 #elif defined(ARCH_CPU_X86_FAMILY) 324 #elif defined(ARCH_CPU_X86_FAMILY)
325 scoped_refptr<VaapiVideoDecodeAccelerator> decoder = 325 scoped_ptr<VaapiVideoDecodeAccelerator> decoder(
326 new VaapiVideoDecodeAccelerator(this, base::Bind(&DoNothingReturnTrue)); 326 new VaapiVideoDecodeAccelerator(this, base::Bind(&DoNothingReturnTrue)));
327 decoder->SetGlxState( 327 decoder->SetGlxState(
328 static_cast<Display*>(rendering_helper_->GetGLDisplay()), 328 static_cast<Display*>(rendering_helper_->GetGLDisplay()),
329 static_cast<GLXContext>(rendering_helper_->GetGLContext())); 329 static_cast<GLXContext>(rendering_helper_->GetGLContext()));
330 #endif // OS_WIN 330 #endif // OS_WIN
331 decoder_ = decoder.release(); 331 decoder_ = decoder.Pass();
332 SetState(CS_DECODER_SET); 332 SetState(CS_DECODER_SET);
333 if (decoder_deleted()) 333 if (decoder_deleted())
334 return; 334 return;
335 335
336 // Configure the decoder. 336 // Configure the decoder.
337 media::VideoCodecProfile profile = media::H264PROFILE_BASELINE; 337 media::VideoCodecProfile profile = media::H264PROFILE_BASELINE;
338 if (profile_ != -1) 338 if (profile_ != -1)
339 profile = static_cast<media::VideoCodecProfile>(profile_); 339 profile = static_cast<media::VideoCodecProfile>(profile_);
340 CHECK(decoder_->Initialize(profile)); 340 CHECK(decoder_->Initialize(profile));
341 } 341 }
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 state_ = new_state; 476 state_ = new_state;
477 if (!remaining_play_throughs_ && new_state == delete_decoder_state_) { 477 if (!remaining_play_throughs_ && new_state == delete_decoder_state_) {
478 CHECK(!decoder_deleted()); 478 CHECK(!decoder_deleted());
479 DeleteDecoder(); 479 DeleteDecoder();
480 } 480 }
481 } 481 }
482 482
483 void GLRenderingVDAClient::DeleteDecoder() { 483 void GLRenderingVDAClient::DeleteDecoder() {
484 if (decoder_deleted()) 484 if (decoder_deleted())
485 return; 485 return;
486 decoder_->Destroy(); 486 decoder_->Destroy(decoder_.Pass());
487 decoder_ = NULL;
488 STLClearObject(&encoded_data_); 487 STLClearObject(&encoded_data_);
489 for (std::set<int>::iterator it = outstanding_texture_ids_.begin(); 488 for (std::set<int>::iterator it = outstanding_texture_ids_.begin();
490 it != outstanding_texture_ids_.end(); ++it) { 489 it != outstanding_texture_ids_.end(); ++it) {
491 rendering_helper_->DeleteTexture(*it); 490 rendering_helper_->DeleteTexture(*it);
492 } 491 }
493 outstanding_texture_ids_.clear(); 492 outstanding_texture_ids_.clear();
494 // Cascade through the rest of the states to simplify test code below. 493 // Cascade through the rest of the states to simplify test code below.
495 for (int i = state_ + 1; i < CS_MAX; ++i) 494 for (int i = state_ + 1; i < CS_MAX; ++i)
496 SetState(static_cast<ClientState>(i)); 495 SetState(static_cast<ClientState>(i));
497 } 496 }
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 855
857 base::ShadowingAtExitManager at_exit_manager; 856 base::ShadowingAtExitManager at_exit_manager;
858 RenderingHelper::InitializePlatform(); 857 RenderingHelper::InitializePlatform();
859 858
860 #if defined(OS_WIN) 859 #if defined(OS_WIN)
861 DXVAVideoDecodeAccelerator::PreSandboxInitialization(); 860 DXVAVideoDecodeAccelerator::PreSandboxInitialization();
862 #endif 861 #endif
863 862
864 return RUN_ALL_TESTS(); 863 return RUN_ALL_TESTS();
865 } 864 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698