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

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: Update after bbudge's review 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"
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;
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 // media::VideoEncodeAccelerator implementation.
44 virtual void RequireBitstreamBuffers(unsigned int input_count,
45 const gfx::Size& input_coded_size,
46 size_t output_buffer_size) override;
47 virtual void BitstreamBufferReady(int32 bitstream_buffer_id,
48 size_t payload_size,
49 bool key_frame) override;
50 virtual void NotifyError(media::VideoEncodeAccelerator::Error error) override;
51
52 // ResourceHost implementation.
53 virtual int32_t OnResourceMessageReceived(
54 const IPC::Message& msg,
55 ppapi::host::HostMessageContext* context) override;
56
57 // Plugin's IPC calls.
58 int32_t OnHostMsgGetSupportedProfiles(
59 ppapi::host::HostMessageContext* context);
60 int32_t OnHostMsgInitialize(ppapi::host::HostMessageContext* context,
61 PP_VideoFrame_Format input_format,
62 const PP_Size& input_visible_size,
63 PP_VideoProfile output_profile,
64 uint32_t initial_bitrate,
65 PP_HardwareAcceleration acceleration);
66 int32_t OnHostMsgGetVideoFrames(ppapi::host::HostMessageContext* context);
67 int32_t OnHostMsgEncode(ppapi::host::HostMessageContext* context,
68 uint32_t frame_id,
69 bool force_keyframe);
70 int32_t OnHostMsgRecycleBitstreamBuffer(
71 ppapi::host::HostMessageContext* context,
72 uint32_t buffer_id);
73 int32_t OnHostMsgRequestEncodingParametersChange(
74 ppapi::host::HostMessageContext* context,
75 uint32_t bitrate,
76 uint32_t framerate);
77 int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context);
78
79 // Internal methods.
80 // void* BufferIdToAddress(int32_t buffer_id);
bbudge 2015/02/10 22:47:37 remove
llandwerlin-old 2015/02/11 18:42:24 Done.
81 scoped_refptr<media::VideoFrame> CreateVideoFrame(
82 uint32_t frame_id,
83 const ppapi::host::ReplyMessageContext& reply_context);
84 void EncodeVideoFrameDone(
bbudge 2015/02/10 22:47:37 'EncodeDone' might be better.
85 const ppapi::host::ReplyMessageContext& reply_context,
86 uint32_t frame_id);
87 void NotifyPepperError(int32_t error);
88
89 // Non-owning pointer.
90 RendererPpapiHost* renderer_ppapi_host_;
91
92 ppapi::host::ReplyMessageContext initialize_reply_context_;
93
94 // Shared memory buffers.
bbudge 2015/02/10 22:47:38 Child class definitions are done as the first priv
llandwerlin-old 2015/02/11 18:42:24 Using struct instead.
95 class ShmBuffer {
96 public:
97 ShmBuffer(int32_t id, scoped_ptr<base::SharedMemory> memory, size_t size);
98 ~ShmBuffer();
99
100 media::BitstreamBuffer toBitstreamBuffer();
101
102 int32_t id;
103 scoped_ptr<base::SharedMemory> shm;
104 bool in_use;
105 };
106
107 // Bitstream buffers.
108 ScopedVector<ShmBuffer> buffers_;
bbudge 2015/02/10 22:47:38 Rename this shm_buffers_ for clarity.
109 size_t buffer_count_hint_;
bbudge 2015/02/10 22:47:38 Unused.
llandwerlin-old 2015/02/11 18:42:24 Done.
110
111 // Video frames.
112 ppapi::MediaStreamBufferManager buffer_manager_;
113
114 scoped_ptr<media::VideoEncodeAccelerator> encoder_;
115
116 // Global state
bbudge 2015/02/10 22:47:37 Not really global. Why not remove this and documen
llandwerlin-old 2015/02/11 18:42:24 Done.
117 bool initialized_;
118 int32_t encoder_last_error_;
119 gfx::Size input_coded_size_;
120 int32_t frame_count_;
121 media::VideoFrame::Format media_format_;
122
123 scoped_refptr<GpuChannelHost> channel_;
124 CommandBufferProxyImpl* command_buffer_;
125
126 base::WeakPtrFactory<PepperVideoEncoderHost> weak_ptr_factory_;
127
128 DISALLOW_COPY_AND_ASSIGN(PepperVideoEncoderHost);
129 };
130
131 } // namespace content
132
133 #endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_ENCODER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698