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

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: Rework allocation methods 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 "base/numerics/safe_math.h"
13 #include "content/common/content_export.h"
14 #include "ppapi/c/pp_codecs.h"
15 #include "ppapi/host/host_message_context.h"
16 #include "ppapi/host/resource_host.h"
17 #include "ppapi/proxy/resource_message_params.h"
18 #include "ppapi/proxy/serialized_structs.h"
19 #include "ppapi/shared_impl/media_stream_buffer_manager.h"
20
21 namespace content {
22
23 class RendererPpapiHost;
24
25 class CONTENT_EXPORT PepperAudioEncoderHost
26 : public ppapi::host::ResourceHost,
27 public ppapi::MediaStreamBufferManager::Delegate {
28 public:
29 class AudioEncoderImpl;
bbudge 2015/11/13 20:37:56 should be first private decl.
llandwerlin-old 2015/11/16 11:23:57 Done.
30
31 PepperAudioEncoderHost(RendererPpapiHost* host,
32 PP_Instance instance,
33 PP_Resource resource);
34 ~PepperAudioEncoderHost() override;
35
36 private:
37 // ResourceHost implementation.
38 int32_t OnResourceMessageReceived(
39 const IPC::Message& msg,
40 ppapi::host::HostMessageContext* context) override;
41
42 int32_t OnHostMsgGetSupportedProfiles(
43 ppapi::host::HostMessageContext* context);
44 int32_t OnHostMsgInitialize(
45 ppapi::host::HostMessageContext* context,
46 const ppapi::proxy::PPB_AudioEncodeParameters& parameters);
47 int32_t OnHostMsgGetAudioBuffers(ppapi::host::HostMessageContext* context);
48 int32_t OnHostMsgEncode(ppapi::host::HostMessageContext* context,
49 int32_t buffer_id);
50 int32_t OnHostMsgRecycleBitstreamBuffer(
51 ppapi::host::HostMessageContext* context,
52 int32_t buffer_id);
53 int32_t OnHostMsgRequestBitrateChange(
54 ppapi::host::HostMessageContext* context,
55 uint32_t bitrate);
56 int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context);
57
58 void GetSupportedProfiles(std::vector<PP_AudioProfileDescription>* profiles);
59 bool IsInitializationValid(
60 const ppapi::proxy::PPB_AudioEncodeParameters& parameters);
61 base::CheckedNumeric<size_t> GetAudioBufferSize();
62 bool AllocateBuffers(
63 const ppapi::proxy::PPB_AudioEncodeParameters& parameters,
64 int32_t samples_per_frame);
65 void DoEncode();
66 void BitstreamBufferReady(int32_t audio_buffer_id,
67 int32_t bitstream_buffer_id,
68 int32_t size);
69 void NotifyPepperError(int32_t error);
70 void Close();
71
72 // Non-owning pointer.
73 RendererPpapiHost* renderer_ppapi_host_;
74
75 // Whether the encoder has been successfully initialized.
76 bool initialized_;
77
78 // Last error reported by the encoder.
79 // This represents the current error state of the encoder, i.e. PP_OK
80 // normally, or a Pepper error code if the encoder is uninitialized,
81 // has been notified of an encoder error, has encountered some
82 // other unrecoverable error, or has been closed by the plugin.
83 // This field is checked in most message handlers to decide whether
84 // operations should proceed or fail.
85 int32_t encoder_last_error_;
86
87 // Encoder's parameters, only valid if |initialized_| is true.
88 ppapi::proxy::PPB_AudioEncodeParameters parameters_;
89
90 // Manages buffers containing audio samples from the plugin.
91 scoped_ptr<ppapi::MediaStreamBufferManager> audio_buffer_manager_;
92
93 // Manages buffers containing encoded audio from the browser.
94 scoped_ptr<ppapi::MediaStreamBufferManager> bitstream_buffer_manager_;
95
96 // Media task used to run the encoder.
97 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_;
98
99 // The encoder actually doing the work.
100 scoped_ptr<AudioEncoderImpl> encoder_;
101
102 base::WeakPtrFactory<PepperAudioEncoderHost> weak_ptr_factory_;
103
104 DISALLOW_COPY_AND_ASSIGN(PepperAudioEncoderHost);
105 };
106
107 } // namespace content
108
109 #endif // CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_ENCODER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698