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

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: Add bitstream buffer type to MediaStreamBuffer 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 bool AllocateBuffers(
62 const ppapi::proxy::PPB_AudioEncodeParameters& parameters,
63 int32_t samples_per_frame);
64 void DoEncode();
65 void BitstreamBufferReady(int32_t audio_buffer_id,
66 int32_t bitstream_buffer_id,
67 int32_t size);
68 void NotifyPepperError(int32_t error);
69 void Close();
70
71 static void StopAudioEncoder(
72 scoped_ptr<AudioEncoderImpl> encoder,
73 scoped_ptr<ppapi::MediaStreamBufferManager> audio_buffer_manager,
74 scoped_ptr<ppapi::MediaStreamBufferManager> bitstream_buffer_manager);
75
76 // Non-owning pointer.
77 RendererPpapiHost* renderer_ppapi_host_;
78
79 // Whether the encoder has been successfully initialized.
80 bool initialized_;
81
82 // Last error reported by the encoder.
83 // This represents the current error state of the encoder, i.e. PP_OK
84 // normally, or a Pepper error code if the encoder is uninitialized,
85 // has been notified of an encoder error, has encountered some
86 // other unrecoverable error, or has been closed by the plugin.
87 // This field is checked in most message handlers to decide whether
88 // operations should proceed or fail.
89 int32_t encoder_last_error_;
90
91 // Manages buffers containing audio samples from the plugin.
92 scoped_ptr<ppapi::MediaStreamBufferManager> audio_buffer_manager_;
93
94 // Manages buffers containing encoded audio from the browser.
95 scoped_ptr<ppapi::MediaStreamBufferManager> bitstream_buffer_manager_;
96
97 // Media task runner used to run the encoder.
98 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_;
99
100 // The encoder actually doing the work.
101 scoped_ptr<AudioEncoderImpl> encoder_;
102
103 base::WeakPtrFactory<PepperAudioEncoderHost> weak_ptr_factory_;
104
105 DISALLOW_COPY_AND_ASSIGN(PepperAudioEncoderHost);
106 };
107
108 } // namespace content
109
110 #endif // CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_ENCODER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698