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

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

Issue 1348563003: ppapi: implement PPB_AudioEncoder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fold internal classes into AudioEncoderImpl Created 5 years, 1 month 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_AUDIO_ENCODER_HOST_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_ENCODER_HOST_H_
7
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/scoped_vector.h"
12 #include "content/common/content_export.h"
13 #include "ppapi/c/pp_codecs.h"
14 #include "ppapi/host/host_message_context.h"
15 #include "ppapi/host/resource_host.h"
16 #include "ppapi/proxy/resource_message_params.h"
17 #include "ppapi/proxy/serialized_structs.h"
18 #include "ppapi/shared_impl/media_stream_buffer_manager.h"
19
20 namespace content {
21
22 class RendererPpapiHost;
23
24 class CONTENT_EXPORT PepperAudioEncoderHost
25 : public ppapi::host::ResourceHost,
26 public ppapi::MediaStreamBufferManager::Delegate {
27 public:
28 class AudioEncoderImpl;
bbudge 2015/11/04 01:00:00 Make this private.
29
30 PepperAudioEncoderHost(RendererPpapiHost* host,
31 PP_Instance instance,
32 PP_Resource resource);
33 ~PepperAudioEncoderHost() override;
34
35 private:
36 // ResourceHost implementation.
37 int32_t OnResourceMessageReceived(
38 const IPC::Message& msg,
39 ppapi::host::HostMessageContext* context) override;
40
41 int32_t OnHostMsgGetSupportedProfiles(
42 ppapi::host::HostMessageContext* context);
43 int32_t OnHostMsgInitialize(
44 ppapi::host::HostMessageContext* context,
45 const ppapi::proxy::PPB_AudioEncodeParameters& parameters);
46 int32_t OnHostMsgGetAudioBuffers(ppapi::host::HostMessageContext* context);
47 int32_t OnHostMsgEncode(ppapi::host::HostMessageContext* context,
48 uint32_t buffer_id);
49 int32_t OnHostMsgRecycleBitstreamBuffer(
50 ppapi::host::HostMessageContext* context,
51 uint32_t buffer_id);
52 int32_t OnHostMsgRequestBitrateChange(
53 ppapi::host::HostMessageContext* context,
54 uint32_t bitrate);
55 int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context);
56
57 void GetSupportedProfiles(std::vector<PP_AudioProfileDescription>* profiles);
58 bool IsInitializationValid(
59 const ppapi::proxy::PPB_AudioEncodeParameters& parameters);
60 bool AllocateAudioBuffers(uint32_t number_of_samples);
61 bool AllocateBitstreamBuffers(size_t buffer_size);
62 void DoEncode();
63 void BitstreamBufferReady(uint32_t audio_buffer_id,
64 uint32_t bitstream_buffer_id,
65 int32_t size);
66 void NotifyPepperError(int32_t error);
67 void Close();
68
69 // Non-owning pointer.
70 RendererPpapiHost* renderer_ppapi_host_;
71
72 // Whether the encoder has been successfully initialized.
73 bool initialized_;
74
75 // Last error reported by the encoder.
76 // This represents the current error state of the encoder, i.e. PP_OK
77 // normally, or a Pepper error code if the encoder is uninitialized,
78 // has been notified of an encoder error, has encountered some
79 // other unrecoverable error, or has been closed by the plugin.
80 // This field is checked in most message handlers to decide whether
81 // operations should proceed or fail.
82 int32_t encoder_last_error_;
83
84 // Encoder's parameters, only valid if |initialized_| is true.
85 ppapi::proxy::PPB_AudioEncodeParameters encode_parameters_;
86
87 // Manages buffers containing audio samples from the plugin.
88 ppapi::MediaStreamBufferManager audio_buffer_manager_;
89
90 // Manages buffers containing encoded audio from the browser.
91 ppapi::MediaStreamBufferManager bitstream_buffer_manager_;
92
93 // The encoder actually doing the work. This needs to be after
94 // |audio_buffer_manager_| and |bitstream_buffer_manager_| so the encoder
95 // is shutdown before the buffers' memory is freed.
96 scoped_ptr<AudioEncoderImpl> encoder_;
97
98 DISALLOW_COPY_AND_ASSIGN(PepperAudioEncoderHost);
99 };
100
101 } // namespace content
102
103 #endif // CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_ENCODER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698