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_PEPPER_AUDIO_ENCODER_HOST_H_ | |
6 #define CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_ENCODER_HOST_H_ | |
7 | |
8 #include <deque> | |
bbudge
2015/10/23 23:18:41
Is this needed now?
llandwerlin-old
2015/11/02 16:12:04
Removing.
| |
9 | |
10 #include "base/memory/ref_counted.h" | |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/memory/scoped_vector.h" | |
13 #include "content/common/content_export.h" | |
14 #include "content/renderer/pepper/audio_encoder_shim.h" | |
15 #include "ppapi/c/pp_codecs.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/proxy/serialized_structs.h" | |
20 #include "ppapi/shared_impl/media_stream_buffer_manager.h" | |
21 | |
22 namespace content { | |
23 | |
24 class RendererPpapiHost; | |
25 | |
26 class CONTENT_EXPORT PepperAudioEncoderHost | |
27 : public ppapi::host::ResourceHost, | |
28 public ppapi::MediaStreamBufferManager::Delegate { | |
29 public: | |
30 PepperAudioEncoderHost(RendererPpapiHost* host, | |
31 PP_Instance instance, | |
32 PP_Resource resource); | |
33 ~PepperAudioEncoderHost() override; | |
34 | |
35 private: | |
36 class AudioData; | |
37 class BufferManager; | |
38 class BitstreamBufferManager; | |
39 class PcmBufferManager; | |
bbudge
2015/10/23 23:18:41
Not defined any more.
llandwerlin-old
2015/11/02 16:12:04
Done.
| |
40 | |
41 // ResourceHost implementation. | |
42 int32_t OnResourceMessageReceived( | |
43 const IPC::Message& msg, | |
44 ppapi::host::HostMessageContext* context) override; | |
45 | |
46 int32_t OnHostMsgGetSupportedProfiles( | |
47 ppapi::host::HostMessageContext* context); | |
48 int32_t OnHostMsgInitialize( | |
49 ppapi::host::HostMessageContext* context, | |
50 const ppapi::proxy::PPB_AudioEncodeParameters& parameters); | |
51 int32_t OnHostMsgGetAudioBuffers(ppapi::host::HostMessageContext* context); | |
52 int32_t OnHostMsgEncode(ppapi::host::HostMessageContext* context, | |
53 uint32_t buffer_id); | |
54 int32_t OnHostMsgRecycleBitstreamBuffer( | |
55 ppapi::host::HostMessageContext* context, | |
56 uint32_t buffer_id); | |
57 int32_t OnHostMsgRequestBitrateChange( | |
58 ppapi::host::HostMessageContext* context, | |
59 uint32_t bitrate); | |
60 int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context); | |
61 | |
62 void GetSupportedProfiles(std::vector<PP_AudioProfileDescription>* profiles); | |
63 bool IsInitializationValid( | |
64 const ppapi::proxy::PPB_AudioEncodeParameters& parameters); | |
65 bool AllocateAudioBuffers(uint32_t number_of_samples); | |
66 bool AllocateBitstreamBuffers(size_t buffer_size); | |
67 AudioEncoderShim::AudioData GetAudioData(uint32_t* buffer_id); | |
68 AudioEncoderShim::AudioData GetBitstreamData(uint32_t* buffer_id); | |
69 void DoEncode(); | |
70 void BitstreamBufferReady(uint32_t audio_buffer_id, | |
71 uint32_t bitstream_buffer_id, | |
72 const AudioEncoderShim::AudioData& output, | |
73 int64_t size); | |
74 void NotifyPepperError(int32_t error); | |
75 void Close(); | |
76 | |
77 // Non-owning pointer. | |
78 RendererPpapiHost* renderer_ppapi_host_; | |
79 | |
80 // Whether the encoder has been successfully initialized. | |
81 bool initialized_; | |
82 | |
83 // Last error reported by the encoder. | |
84 // This represents the current error state of the encoder, i.e. PP_OK | |
85 // normally, or a Pepper error code if the encoder is uninitialized, | |
86 // has been notified of an encoder error, has encountered some | |
87 // other unrecoverable error, or has been closed by the plugin. | |
88 // This field is checked in most message handlers to decide whether | |
89 // operations should proceed or fail. | |
90 int32_t encoder_last_error_; | |
91 | |
92 // Encoder's parameters, only valid if |initialized_| is true. | |
93 ppapi::proxy::PPB_AudioEncodeParameters encode_parameters_; | |
94 | |
95 // Buffer manager for the audio buffers handed by the plugin. | |
96 ppapi::MediaStreamBufferManager audio_buffer_manager_; | |
97 | |
98 // Buffer manager for bitstream buffers handed to the plugin. | |
99 ppapi::MediaStreamBufferManager bitstream_buffer_manager_; | |
100 | |
101 // The encoder actually doing the work. This need to be after | |
102 // |audio_buffer_manager_| and |bitstream_buffer_manager_| so the encoder | |
103 // is shutdown before the buffers' memory is freed. | |
104 scoped_ptr<AudioEncoderShim> encoder_; | |
105 | |
106 base::WeakPtrFactory<PepperAudioEncoderHost> weak_ptr_factory_; | |
107 | |
108 DISALLOW_COPY_AND_ASSIGN(PepperAudioEncoderHost); | |
109 }; | |
110 | |
111 } // namespace content | |
112 | |
113 #endif // CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_ENCODER_HOST_H_ | |
OLD | NEW |