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

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

Issue 859313002: Pepper: Define PPB_VideoEncoder API + Implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 (c) 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 <map>
9 // #include <queue>
10
11 // #include "base/basictypes.h"
12 // #include "base/containers/hash_tables.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 /* #include "base/memory/scoped_vector.h" */
16 #include "content/common/content_export.h"
17 #include "gpu/command_buffer/common/mailbox_holder.h"
18 #include "media/video/video_encode_accelerator.h"
19 #include "ppapi/c/pp_codecs.h"
20 #include "ppapi/c/ppb_video_frame.h"
21 // #include "ppapi/c/ppb_video_encoder.h"
22 #include "ppapi/host/host_message_context.h"
23 #include "ppapi/host/resource_host.h"
24 #include "ppapi/proxy/resource_message_params.h"
25 #include "ppapi/shared_impl/media_stream_buffer_manager.h"
26
27 namespace media {
28 class GpuVideoAcceleratorFactories;
29 }
30
31 namespace content {
32
33 class RendererPpapiHost;
34 class RenderViewImpl;
35
36 class CONTENT_EXPORT PepperVideoEncoderHost
37 : public ppapi::host::ResourceHost,
38 public media::VideoEncodeAccelerator::Client {
39 public:
40 PepperVideoEncoderHost(RendererPpapiHost* host,
41 PP_Instance instance,
42 PP_Resource resource);
43 ~PepperVideoEncoderHost() override;
44
45 private:
46 // media::VideoEncodeAccelerator implementation.
47 virtual void RequireBitstreamBuffers(unsigned int input_count,
48 const gfx::Size& input_coded_size,
49 size_t output_buffer_size) override;
50 virtual void BitstreamBufferReady(int32 bitstream_buffer_id,
51 size_t payload_size,
52 bool key_frame) override;
53 virtual void NotifyError(media::VideoEncodeAccelerator::Error error) override;
54
55 // ResourceHost implementation.
56 virtual int32_t OnResourceMessageReceived(
57 const IPC::Message& msg,
58 ppapi::host::HostMessageContext* context) override;
59
60 // Plugin's IPC calls.
61 int32_t OnHostMsgGetSupportedProfiles(
62 ppapi::host::HostMessageContext* context);
63 int32_t OnHostMsgInitialize(ppapi::host::HostMessageContext* context,
64 PP_VideoFrame_Format input_format,
65 const PP_Size& input_visible_size,
66 PP_VideoProfile output_profile,
67 uint32_t initial_bitrate,
68 PP_HardwareAcceleration acceleration);
69 int32_t OnHostMsgGetVideoFrames(ppapi::host::HostMessageContext* context);
70 int32_t OnHostMsgEncode(ppapi::host::HostMessageContext* context,
71 uint32_t frame_id,
72 PP_Bool force_keyframe);
73 int32_t OnHostMsgRecycleBitstreamBuffer(
74 ppapi::host::HostMessageContext* context,
75 uint32_t buffer_id);
76 int32_t OnHostMsgRequestEncodingParametersChange(
77 ppapi::host::HostMessageContext* context,
78 uint32_t bitrate,
79 uint32_t framerate);
80
81 // Internal methods.
82 // void* BufferIdToAddress(int32_t buffer_id);
83 scoped_refptr<media::VideoFrame> CreateVideoFrame(
84 uint32_t frame_id,
85 const ppapi::host::ReplyMessageContext& reply_context);
86 void EncodeVideoFrameDone(
87 const ppapi::host::ReplyMessageContext& reply_context,
88 uint32_t frame_id);
89
90 // Non-owning pointer.
91 RendererPpapiHost* renderer_ppapi_host_;
92
93 // The message loop on which to post callbacks to |weak_encoder_|.
94 const scoped_refptr<base::MessageLoopProxy> encoder_message_loop_proxy_;
95 base::ThreadChecker thread_checker_;
96
97 ppapi::host::ReplyMessageContext initialize_reply_context_;
98
99 // Shared memory buffers.
100 class ShmBuffer {
101 public:
102 ShmBuffer(int32_t id, scoped_ptr<base::SharedMemory> memory, size_t size);
103 ~ShmBuffer();
104
105 media::BitstreamBuffer toBitstreamBuffer();
106
107 int32_t id;
108 scoped_ptr<base::SharedMemory> shm;
109 bool in_use;
110 };
111
112 // Bitstream buffers.
113 ScopedVector<ShmBuffer> buffers_;
114 size_t buffer_count_hint_;
115
116 // Video frames.
117 scoped_ptr<ppapi::MediaStreamBufferManager::Delegate>
118 buffer_manager_delegate_;
119 scoped_ptr<ppapi::MediaStreamBufferManager> buffer_manager_;
120
121 scoped_ptr<media::VideoEncodeAccelerator> encoder_;
122
123 // Global state
124 bool initialized_;
125 int32_t encoder_last_error_;
126 gfx::Size input_coded_size_;
127 int32_t frame_count_;
128 media::VideoFrame::Format media_format_;
129
130 DISALLOW_COPY_AND_ASSIGN(PepperVideoEncoderHost);
131 };
132
133 } // namespace content
134
135 #endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_ENCODER_HOST_H_
OLDNEW
« no previous file with comments | « content/renderer/pepper/content_renderer_pepper_host_factory.cc ('k') | content/renderer/pepper/pepper_video_encoder_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698