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

Side by Side Diff: ppapi/proxy/audio_encoder_resource.h

Issue 1151973003: ppapi: implement PPB_AudioEncoder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More Windows fixes in proxy code Created 5 years, 6 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
« no previous file with comments | « ppapi/proxy/BUILD.gn ('k') | ppapi/proxy/audio_encoder_resource.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 PPAPI_PROXY_AUDIO_ENCODER_RESOURCE_H_
6 #define PPAPI_PROXY_AUDIO_ENCODER_RESOURCE_H_
7
8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/scoped_vector.h"
12 #include "ppapi/proxy/connection.h"
13 #include "ppapi/proxy/plugin_resource.h"
14 #include "ppapi/shared_impl/media_stream_buffer_manager.h"
15 #include "ppapi/shared_impl/resource.h"
16 #include "ppapi/thunk/ppb_audio_encoder_api.h"
17
18 namespace ppapi {
19
20 class TrackedCallback;
21
22 namespace proxy {
23
24 class AudioBufferResource;
25
26 class PPAPI_PROXY_EXPORT AudioEncoderResource
27 : public PluginResource,
28 public thunk::PPB_AudioEncoder_API,
29 public ppapi::MediaStreamBufferManager::Delegate {
30 public:
31 AudioEncoderResource(Connection connection, PP_Instance instance);
32 ~AudioEncoderResource() override;
33
34 thunk::PPB_AudioEncoder_API* AsPPB_AudioEncoder_API() override;
35
36 private:
37 class BitstreamBufferManager;
38
39 // MediaStreamBufferManager::Delegate implementation.
40 void OnNewBufferEnqueued() override {}
41
42 // PPB_AduioEncoder_API implementation.
43 int32_t GetSupportedProfiles(
44 const PP_ArrayOutput& output,
45 const scoped_refptr<TrackedCallback>& callback) override;
46 int32_t Initialize(uint32_t channels,
47 PP_AudioBuffer_SampleRate input_sample_rate,
48 PP_AudioBuffer_SampleSize input_sample_size,
49 PP_AudioProfile output_profile,
50 uint32_t initial_bitrate,
51 PP_HardwareAcceleration acceleration,
52 const scoped_refptr<TrackedCallback>& callback) override;
53 int32_t GetNumberOfSamples() override;
54 int32_t GetBuffer(PP_Resource* audio_buffer,
55 const scoped_refptr<TrackedCallback>& callback) override;
56 int32_t Encode(PP_Resource audio_buffer,
57 const scoped_refptr<TrackedCallback>& callback) override;
58 int32_t GetBitstreamBuffer(
59 PP_AudioBitstreamBuffer* bitstream_buffer,
60 const scoped_refptr<TrackedCallback>& callback) override;
61 void RecycleBitstreamBuffer(
62 const PP_AudioBitstreamBuffer* bitstream_buffer) override;
63 void RequestBitrateChange(uint32_t bitrate) override;
64 void Close() override;
65
66 // PluginResource implementation.
67 void OnReplyReceived(const ResourceMessageReplyParams& params,
68 const IPC::Message& msg) override;
69
70 // Message handlers for the host's messages.
71 void OnPluginMsgGetSupportedProfilesReply(
72 const PP_ArrayOutput& output,
73 const ResourceMessageReplyParams& params,
74 const std::vector<PP_AudioProfileDescription>& profiles);
75 void OnPluginMsgInitializeReply(const ResourceMessageReplyParams& params,
76 uint32_t number_of_samples,
77 uint32_t buffer_count,
78 uint32_t buffer_size);
79 void OnPluginMsgGetAudioFramesReply(const ResourceMessageReplyParams& params,
80 uint32_t frame_count,
81 uint32_t frame_length);
82 void OnPluginMsgEncodeReply(const ResourceMessageReplyParams& params,
83 uint32_t buffer_id);
84 void OnPluginMsgBitstreamBufferReady(const ResourceMessageReplyParams& params,
85 uint32_t buffer_id,
86 uint32_t buffer_size);
87 void OnPluginMsgNotifyError(const ResourceMessageReplyParams& params,
88 int32_t error);
89
90 // Internal utility functions.
91 void NotifyError(int32_t error);
92 void TryWriteAudioBuffer();
93 void TryWriteBitstreamBuffer();
94 void ReleaseBuffers();
95
96 int32_t encoder_last_error_;
97
98 bool initialized_;
99 bool closed_;
100
101 uint32_t number_of_samples_;
102
103 typedef std::map<PP_Resource, scoped_refptr<AudioBufferResource> >
104 AudioBufferMap;
105 AudioBufferMap audio_buffers_;
106
107 scoped_refptr<TrackedCallback> get_supported_profiles_callback_;
108 scoped_refptr<TrackedCallback> initialize_callback_;
109 scoped_refptr<TrackedCallback> get_buffer_callback_;
110 PP_Resource* get_buffer_data_;
111
112 typedef std::map<int32_t, scoped_refptr<TrackedCallback> > EncodeMap;
113 EncodeMap encode_callbacks_;
114
115 scoped_refptr<TrackedCallback> get_bitstream_buffer_callback_;
116 PP_AudioBitstreamBuffer* get_bitstream_buffer_data_;
117
118 // Buffer manager for audio frames.
119 MediaStreamBufferManager buffer_manager_;
120
121 // Buffer manager for bitstream buffers.
122 scoped_ptr<BitstreamBufferManager> bitstream_buffer_manager_;
123
124 DISALLOW_COPY_AND_ASSIGN(AudioEncoderResource);
125 };
126
127 } // namespace proxy
128 } // namespace ppapi
129
130 #endif // PPAPI_PROXY_AUDIO_ENCODER_RESOURCE_H_
OLDNEW
« no previous file with comments | « ppapi/proxy/BUILD.gn ('k') | ppapi/proxy/audio_encoder_resource.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698