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

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: Drop bitstream buffer manager from proxy 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 PepperAudioEncoderHost(RendererPpapiHost* host,
30 PP_Instance instance,
31 PP_Resource resource);
32 ~PepperAudioEncoderHost() override;
33
34 private:
35 class AudioEncoderImpl;
36
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();
bbudge 2015/11/17 00:53:40 Delete this.
llandwerlin-old 2015/11/17 15:22:30 Sorry, done.
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 static void StopAudioEncoder(
73 scoped_ptr<AudioEncoderImpl> encoder,
74 scoped_ptr<ppapi::MediaStreamBufferManager> audio_buffer_manager,
75 scoped_ptr<ppapi::MediaStreamBufferManager> bitstream_buffer_manager);
bbudge 2015/11/17 00:53:40 Sorry I didn't think of this earlier, but couldn't
llandwerlin-old 2015/11/17 15:22:30 The problem is that AudioEncoderImpl is private to
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 parameters_;
94
95 // Manages buffers containing audio samples from the plugin.
96 scoped_ptr<ppapi::MediaStreamBufferManager> audio_buffer_manager_;
97
98 // Manages buffers containing encoded audio from the browser.
99 scoped_ptr<ppapi::MediaStreamBufferManager> bitstream_buffer_manager_;
100
101 // Media task used to run the encoder.
bbudge 2015/11/17 00:53:40 s/task/task runner
llandwerlin-old 2015/11/17 15:22:30 Done.
102 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_;
103
104 // The encoder actually doing the work.
105 scoped_ptr<AudioEncoderImpl> encoder_;
106
107 base::WeakPtrFactory<PepperAudioEncoderHost> weak_ptr_factory_;
108
109 DISALLOW_COPY_AND_ASSIGN(PepperAudioEncoderHost);
110 };
111
112 } // namespace content
113
114 #endif // CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_ENCODER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698