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

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

Issue 185403020: Make VEA client of command buffer; move sync. IPC to VDA/VEA::Initialize() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 56683e7a Rebase. Created 6 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 | Annotate | Revision Log
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 #include "base/at_exit.h" 5 #include "base/at_exit.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/memory_mapped_file.h" 9 #include "base/files/memory_mapped_file.h"
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 VEAClient(const TestStream& test_stream, 241 VEAClient(const TestStream& test_stream,
242 ClientStateNotification<ClientState>* note, 242 ClientStateNotification<ClientState>* note,
243 bool save_to_file, 243 bool save_to_file,
244 unsigned int keyframe_period, 244 unsigned int keyframe_period,
245 bool force_bitrate); 245 bool force_bitrate);
246 virtual ~VEAClient(); 246 virtual ~VEAClient();
247 void CreateEncoder(); 247 void CreateEncoder();
248 void DestroyEncoder(); 248 void DestroyEncoder();
249 249
250 // VideoDecodeAccelerator::Client implementation. 250 // VideoDecodeAccelerator::Client implementation.
251 void NotifyInitializeDone() OVERRIDE;
252 void RequireBitstreamBuffers(unsigned int input_count, 251 void RequireBitstreamBuffers(unsigned int input_count,
253 const gfx::Size& input_coded_size, 252 const gfx::Size& input_coded_size,
254 size_t output_buffer_size) OVERRIDE; 253 size_t output_buffer_size) OVERRIDE;
255 void BitstreamBufferReady(int32 bitstream_buffer_id, 254 void BitstreamBufferReady(int32 bitstream_buffer_id,
256 size_t payload_size, 255 size_t payload_size,
257 bool key_frame) OVERRIDE; 256 bool key_frame) OVERRIDE;
258 void NotifyError(VideoEncodeAccelerator::Error error) OVERRIDE; 257 void NotifyError(VideoEncodeAccelerator::Error error) OVERRIDE;
259 258
260 private: 259 private:
261 bool has_encoder() { return encoder_.get(); } 260 bool has_encoder() { return encoder_.get(); }
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 thread_checker_.DetachFromThread(); 384 thread_checker_.DetachFromThread();
386 } 385 }
387 386
388 VEAClient::~VEAClient() { CHECK(!has_encoder()); } 387 VEAClient::~VEAClient() { CHECK(!has_encoder()); }
389 388
390 void VEAClient::CreateEncoder() { 389 void VEAClient::CreateEncoder() {
391 DCHECK(thread_checker_.CalledOnValidThread()); 390 DCHECK(thread_checker_.CalledOnValidThread());
392 CHECK(!has_encoder()); 391 CHECK(!has_encoder());
393 392
394 encoder_.reset(new ExynosVideoEncodeAccelerator()); 393 encoder_.reset(new ExynosVideoEncodeAccelerator());
394 if (!encoder_) {
395 DLOG(ERROR) << "CreateEncoder() failed";
396 SetState(CS_ERROR);
397 return;
398 }
399 SetState(CS_ENCODER_SET);
395 400
396 SetState(CS_ENCODER_SET);
397 DVLOG(1) << "Profile: " << test_stream_.requested_profile 401 DVLOG(1) << "Profile: " << test_stream_.requested_profile
398 << ", requested bitrate: " << test_stream_.requested_bitrate; 402 << ", requested bitrate: " << test_stream_.requested_bitrate;
399 encoder_->Initialize(kInputFormat, 403 if (!encoder_->Initialize(kInputFormat,
400 test_stream_.size, 404 test_stream_.size,
401 test_stream_.requested_profile, 405 test_stream_.requested_profile,
402 test_stream_.requested_bitrate, 406 test_stream_.requested_bitrate,
403 this); 407 this)) {
408 DLOG(ERROR) << "VideoEncodeAccelerator::Initialize() failed";
409 SetState(CS_ERROR);
410 return;
411 }
412 SetInitialConfiguration();
413 SetState(CS_INITIALIZED);
404 } 414 }
405 415
406 void VEAClient::DestroyEncoder() { 416 void VEAClient::DestroyEncoder() {
407 DCHECK(thread_checker_.CalledOnValidThread()); 417 DCHECK(thread_checker_.CalledOnValidThread());
408 if (!has_encoder()) 418 if (!has_encoder())
409 return; 419 return;
410 encoder_.release()->Destroy(); 420 encoder_.release()->Destroy();
411 } 421 }
412 422
413 void VEAClient::NotifyInitializeDone() {
414 DCHECK(thread_checker_.CalledOnValidThread());
415 SetInitialConfiguration();
416 SetState(CS_INITIALIZED);
417 }
418
419 void VEAClient::RequireBitstreamBuffers(unsigned int input_count, 423 void VEAClient::RequireBitstreamBuffers(unsigned int input_count,
420 const gfx::Size& input_coded_size, 424 const gfx::Size& input_coded_size,
421 size_t output_size) { 425 size_t output_size) {
422 DCHECK(thread_checker_.CalledOnValidThread()); 426 DCHECK(thread_checker_.CalledOnValidThread());
423 ASSERT_EQ(state_, CS_INITIALIZED); 427 ASSERT_EQ(state_, CS_INITIALIZED);
424 SetState(CS_ENCODING); 428 SetState(CS_ENCODING);
425 429
426 // TODO(posciak): For now we only support input streams that meet encoder 430 // TODO(posciak): For now we only support input streams that meet encoder
427 // size requirements exactly (i.e. coded size == visible size). 431 // size requirements exactly (i.e. coded size == visible size).
428 input_coded_size_ = input_coded_size; 432 input_coded_size_ = input_coded_size;
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 } 765 }
762 if (it->first == "v" || it->first == "vmodule") 766 if (it->first == "v" || it->first == "vmodule")
763 continue; 767 continue;
764 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; 768 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second;
765 } 769 }
766 770
767 base::ShadowingAtExitManager at_exit_manager; 771 base::ShadowingAtExitManager at_exit_manager;
768 772
769 return RUN_ALL_TESTS(); 773 return RUN_ALL_TESTS();
770 } 774 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698