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