OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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 CONTENT_RENDERER_PEPPER_VIDEO_ENCODER_SHIM_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_VIDEO_ENCODER_SHIM_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/memory/weak_ptr.h" |
| 12 #include "media/video/video_encode_accelerator.h" |
| 13 |
| 14 namespace base { |
| 15 class SingleThreadTaskRunner; |
| 16 } |
| 17 |
| 18 namespace gfx { |
| 19 class Size; |
| 20 } |
| 21 |
| 22 namespace content { |
| 23 |
| 24 class PepperVideoEncoderHost; |
| 25 |
| 26 // This class is a shim to wrap a media::cast::SoftwareVideoEncoder so that it |
| 27 // can be used by PepperVideoEncoderHost in place of a |
| 28 // media::VideoEncodeAccelerator. This class should be constructed, used, and |
| 29 // destructed on the main (render) thread. |
| 30 class VideoEncoderShim : public media::VideoEncodeAccelerator { |
| 31 public: |
| 32 explicit VideoEncoderShim(PepperVideoEncoderHost* host); |
| 33 ~VideoEncoderShim() override; |
| 34 |
| 35 // media::VideoEncodeAccelerator implementation. |
| 36 std::vector<media::VideoEncodeAccelerator::SupportedProfile> |
| 37 GetSupportedProfiles() override; |
| 38 bool Initialize(media::VideoFrame::Format input_format, |
| 39 const gfx::Size& input_visible_size, |
| 40 media::VideoCodecProfile output_profile, |
| 41 uint32 initial_bitrate, |
| 42 media::VideoEncodeAccelerator::Client* client) override; |
| 43 void Encode(const scoped_refptr<media::VideoFrame>& frame, |
| 44 bool force_keyframe) override; |
| 45 void UseOutputBitstreamBuffer(const media::BitstreamBuffer& buffer) override; |
| 46 void RequestEncodingParametersChange(uint32 bitrate, |
| 47 uint32 framerate) override; |
| 48 void Destroy() override; |
| 49 |
| 50 private: |
| 51 class EncoderImpl; |
| 52 |
| 53 void OnRequireBitstreamBuffers(unsigned int input_count, |
| 54 const gfx::Size& input_coded_size, |
| 55 size_t output_buffer_size); |
| 56 void OnBitstreamBufferReady(scoped_refptr<media::VideoFrame> frame, |
| 57 int32 bitstream_buffer_id, |
| 58 size_t payload_size, |
| 59 bool key_frame); |
| 60 void OnNotifyError(media::VideoEncodeAccelerator::Error error); |
| 61 |
| 62 scoped_ptr<EncoderImpl> encoder_impl_; |
| 63 |
| 64 PepperVideoEncoderHost* host_; |
| 65 |
| 66 // Task doing the encoding. |
| 67 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; |
| 68 |
| 69 base::WeakPtrFactory<VideoEncoderShim> weak_ptr_factory_; |
| 70 |
| 71 DISALLOW_COPY_AND_ASSIGN(VideoEncoderShim); |
| 72 }; |
| 73 |
| 74 } // namespace content |
| 75 |
| 76 #endif // CONTENT_RENDERER_PEPPER_VIDEO_ENCODER_SHIM_H_ |
OLD | NEW |