Home | History | Annotate | Download | only in test
      1 // Copyright 2014 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef MEDIA_CAST_TEST_FAKE_MOCK_VIDEO_ENCODE_ACCELERATOR_H_
      6 #define MEDIA_CAST_TEST_FAKE_MOCK_VIDEO_ENCODE_ACCELERATOR_H_
      7 
      8 #include "media/video/video_encode_accelerator.h"
      9 
     10 #include <list>
     11 #include <vector>
     12 
     13 #include "base/memory/weak_ptr.h"
     14 #include "media/base/bitstream_buffer.h"
     15 
     16 namespace base {
     17 class SingleThreadTaskRunner;
     18 }  // namespace base
     19 
     20 namespace media {
     21 namespace cast {
     22 namespace test {
     23 
     24 class FakeVideoEncodeAccelerator : public VideoEncodeAccelerator {
     25  public:
     26   explicit FakeVideoEncodeAccelerator(
     27       const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
     28       std::vector<uint32>* stored_bitrates);
     29   virtual ~FakeVideoEncodeAccelerator();
     30 
     31   virtual std::vector<VideoEncodeAccelerator::SupportedProfile>
     32       GetSupportedProfiles() OVERRIDE;
     33   virtual bool Initialize(media::VideoFrame::Format input_format,
     34                           const gfx::Size& input_visible_size,
     35                           VideoCodecProfile output_profile,
     36                           uint32 initial_bitrate,
     37                           Client* client) OVERRIDE;
     38 
     39   virtual void Encode(const scoped_refptr<VideoFrame>& frame,
     40                       bool force_keyframe) OVERRIDE;
     41 
     42   virtual void UseOutputBitstreamBuffer(const BitstreamBuffer& buffer) OVERRIDE;
     43 
     44   virtual void RequestEncodingParametersChange(uint32 bitrate,
     45                                                uint32 framerate) OVERRIDE;
     46 
     47   virtual void Destroy() OVERRIDE;
     48 
     49   void SendDummyFrameForTesting(bool key_frame);
     50   void SetWillInitializationSucceed(bool will_initialization_succeed) {
     51     will_initialization_succeed_ = will_initialization_succeed;
     52   }
     53 
     54  private:
     55   void DoRequireBitstreamBuffers(unsigned int input_count,
     56                                  const gfx::Size& input_coded_size,
     57                                  size_t output_buffer_size) const;
     58   void DoBitstreamBufferReady(int32 bitstream_buffer_id,
     59                               size_t payload_size,
     60                               bool key_frame) const;
     61 
     62   const scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
     63   std::vector<uint32>* const stored_bitrates_;
     64   VideoEncodeAccelerator::Client* client_;
     65   bool first_;
     66   bool will_initialization_succeed_;
     67 
     68   std::list<int32> available_buffer_ids_;
     69 
     70   base::WeakPtrFactory<FakeVideoEncodeAccelerator> weak_this_factory_;
     71 
     72   DISALLOW_COPY_AND_ASSIGN(FakeVideoEncodeAccelerator);
     73 };
     74 
     75 }  // namespace test
     76 }  // namespace cast
     77 }  // namespace media
     78 
     79 #endif  // MEDIA_CAST_TEST_FAKE_MOCK_VIDEO_ENCODE_ACCELERATOR_H_
     80