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 
     12 #include "base/memory/weak_ptr.h"
     13 #include "media/base/bitstream_buffer.h"
     14 
     15 namespace base {
     16 class SingleThreadTaskRunner;
     17 }  // namespace base
     18 
     19 namespace media {
     20 namespace cast {
     21 namespace test {
     22 
     23 class FakeVideoEncodeAccelerator : public VideoEncodeAccelerator {
     24  public:
     25   explicit FakeVideoEncodeAccelerator(
     26       const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
     27   virtual ~FakeVideoEncodeAccelerator();
     28 
     29   virtual bool Initialize(media::VideoFrame::Format input_format,
     30                           const gfx::Size& input_visible_size,
     31                           VideoCodecProfile output_profile,
     32                           uint32 initial_bitrate,
     33                           Client* client) OVERRIDE;
     34 
     35   virtual void Encode(const scoped_refptr<VideoFrame>& frame,
     36                       bool force_keyframe) OVERRIDE;
     37 
     38   virtual void UseOutputBitstreamBuffer(const BitstreamBuffer& buffer) OVERRIDE;
     39 
     40   virtual void RequestEncodingParametersChange(uint32 bitrate,
     41                                                uint32 framerate) OVERRIDE;
     42 
     43   virtual void Destroy() OVERRIDE;
     44 
     45   void SendDummyFrameForTesting(bool key_frame);
     46 
     47  private:
     48   void DoRequireBitstreamBuffers(unsigned int input_count,
     49                                  const gfx::Size& input_coded_size,
     50                                  size_t output_buffer_size) const;
     51   void DoBitstreamBufferReady(int32 bitstream_buffer_id,
     52                               size_t payload_size,
     53                               bool key_frame) const;
     54 
     55   scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
     56 
     57   VideoEncodeAccelerator::Client* client_;
     58   bool first_;
     59 
     60   std::list<int32> available_buffer_ids_;
     61 
     62   base::WeakPtrFactory<FakeVideoEncodeAccelerator> weak_this_factory_;
     63 
     64   DISALLOW_COPY_AND_ASSIGN(FakeVideoEncodeAccelerator);
     65 };
     66 
     67 }  // namespace test
     68 }  // namespace cast
     69 }  // namespace media
     70 
     71 #endif  // MEDIA_CAST_TEST_FAKE_MOCK_VIDEO_ENCODE_ACCELERATOR_H_
     72