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

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

Issue 905023005: Pepper: PPB_VideoEncoder implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Send bitstream buffers in their own ppapi ipc message Created 5 years, 10 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_PEPPER_VIDEO_ENCODER_HOST_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_ENCODER_HOST_H_
7
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/scoped_vector.h"
11 #include "content/common/content_export.h"
12 #include "gpu/command_buffer/common/mailbox_holder.h"
bbudge 2015/02/18 22:53:01 This doesn't appear to get used.
llandwerlin-old 2015/02/19 15:55:45 Done.
13 #include "media/video/video_encode_accelerator.h"
14 #include "ppapi/c/pp_codecs.h"
15 #include "ppapi/c/ppb_video_frame.h"
16 #include "ppapi/host/host_message_context.h"
17 #include "ppapi/host/resource_host.h"
18 #include "ppapi/proxy/resource_message_params.h"
19 #include "ppapi/shared_impl/media_stream_buffer_manager.h"
20
21 namespace media {
22 class GpuVideoAcceleratorFactories;
23 }
24
25 namespace content {
26
27 class CommandBufferProxyImpl;
28 class GpuChannelHost;
29 class RendererPpapiHost;
30 class RenderViewImpl;
bbudge 2015/02/18 22:53:01 Not used.
llandwerlin-old 2015/02/19 15:55:45 Done.
31
32 class CONTENT_EXPORT PepperVideoEncoderHost
33 : public ppapi::host::ResourceHost,
34 public media::VideoEncodeAccelerator::Client,
35 public ppapi::MediaStreamBufferManager::Delegate {
36 public:
37 PepperVideoEncoderHost(RendererPpapiHost* host,
38 PP_Instance instance,
39 PP_Resource resource);
40 ~PepperVideoEncoderHost() override;
41
42 private:
43 // Shared memory buffers.
44 struct ShmBuffer {
45 ShmBuffer(int32_t id, scoped_ptr<base::SharedMemory> shm);
46 ~ShmBuffer();
47
48 media::BitstreamBuffer ToBitstreamBuffer();
49
bbudge 2015/02/18 22:53:01 I think it would be helpful to repeat the comment
llandwerlin-old 2015/02/19 15:55:45 Done.
50 int32_t id;
51 scoped_ptr<base::SharedMemory> shm;
52 bool in_use;
53 };
54
55 // media::VideoEncodeAccelerator implementation.
56 virtual void RequireBitstreamBuffers(unsigned int input_count,
57 const gfx::Size& input_coded_size,
58 size_t output_buffer_size) override;
59 virtual void BitstreamBufferReady(int32 bitstream_buffer_id,
60 size_t payload_size,
61 bool key_frame) override;
62 virtual void NotifyError(media::VideoEncodeAccelerator::Error error) override;
63
64 // ResourceHost implementation.
65 virtual int32_t OnResourceMessageReceived(
66 const IPC::Message& msg,
67 ppapi::host::HostMessageContext* context) override;
68
69 int32_t OnHostMsgGetSupportedProfiles(
70 ppapi::host::HostMessageContext* context);
71 int32_t OnHostMsgInitialize(ppapi::host::HostMessageContext* context,
72 PP_VideoFrame_Format input_format,
73 const PP_Size& input_visible_size,
74 PP_VideoProfile output_profile,
75 uint32_t initial_bitrate,
76 PP_HardwareAcceleration acceleration);
77 int32_t OnHostMsgGetVideoFrames(ppapi::host::HostMessageContext* context);
78 int32_t OnHostMsgEncode(ppapi::host::HostMessageContext* context,
79 uint32_t frame_id,
80 bool force_keyframe);
81 int32_t OnHostMsgRecycleBitstreamBuffer(
82 ppapi::host::HostMessageContext* context,
83 uint32_t buffer_id);
84 int32_t OnHostMsgRequestEncodingParametersChange(
85 ppapi::host::HostMessageContext* context,
86 uint32_t bitrate,
87 uint32_t framerate);
88 int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context);
89
90 // Internal methods.
91 void GetSupportedProfiles(
92 std::vector<PP_VideoProfileDescription>* pp_profiles);
93 bool IsInitializationValid(const PP_Size& input_size,
94 PP_VideoProfile ouput_profile,
95 PP_HardwareAcceleration acceleration);
96 void AllocateVideoFrames();
97 scoped_refptr<media::VideoFrame> CreateVideoFrame(
98 uint32_t frame_id,
99 const ppapi::host::ReplyMessageContext& reply_context);
100 void FrameReleased(const ppapi::host::ReplyMessageContext& reply_context,
101 uint32_t frame_id);
102 void NotifyPepperError(int32_t error);
103 void Close();
104
105 // Non-owning pointer.
106 RendererPpapiHost* renderer_ppapi_host_;
107
108 ScopedVector<ShmBuffer> shm_buffers_;
109
110 // Buffer manager for shared memory that holds video frames.
111 ppapi::MediaStreamBufferManager buffer_manager_;
112
113 scoped_refptr<GpuChannelHost> channel_;
114 CommandBufferProxyImpl* command_buffer_;
115
116 scoped_ptr<media::VideoEncodeAccelerator> encoder_;
117
118 // Whether the encoder has been successfully initialized.
119 bool initialized_;
120
121 // Saved context to answer a Initialize message from the plugin.
122 ppapi::host::ReplyMessageContext initialize_context_;
bbudge 2015/02/18 22:53:01 nit: s/initialize_context_/initialize_reply_contex
llandwerlin-old 2015/02/19 15:55:45 Done.
123
124 // Saved context to answer a GetVideoFrames message from the plugin.
125 ppapi::host::ReplyMessageContext get_video_frames_context_;
126
127 // Last error encountered by the encoder or failure encountered by
128 // this class or termination triggered by the plugin. This variables
129 // is checked at most ipc entry point to decide whether operations
130 // on the encoder should proceed or fail.
bbudge 2015/02/18 22:53:01 Could we reword this a bit? e.g. // This represen
llandwerlin-old 2015/02/19 15:55:45 Done.
131 int32_t encoder_last_error_;
132
133 // Size of the frames allocated for the encoder (matching hardware
134 // constraints).
135 gfx::Size input_coded_size_;
136
137 // Number of frames the encoder needs.
138 uint32_t frame_count_;
139
140 // Format of the frames to give to the encoder.
141 media::VideoFrame::Format media_input_format_;
142
143 base::WeakPtrFactory<PepperVideoEncoderHost> weak_ptr_factory_;
144
145 DISALLOW_COPY_AND_ASSIGN(PepperVideoEncoderHost);
146 };
147
148 } // namespace content
149
150 #endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_ENCODER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698