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

Side by Side Diff: content/renderer/pepper/video_encoder_shim.h

Issue 956893002: content: pepper: VideoEncoder: add software encoder support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add modifications to the example to expose different profiles Created 5 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
OLDNEW
(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::SoftwareVideoEncoder so that it
28 // can be used by PepperVideoEncoderHost in place of a
29 // media::VideoEncodeAccelerator. This class should be constructed, used, and
30 // destructed on the main (render) 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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698