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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/pepper/pepper_audio_encoder_host.h
diff --git a/content/renderer/pepper/pepper_audio_encoder_host.h b/content/renderer/pepper/pepper_audio_encoder_host.h
new file mode 100644
index 0000000000000000000000000000000000000000..cfffd6f4f975d586980c074e5922ebc5fb55d62c
--- /dev/null
+++ b/content/renderer/pepper/pepper_audio_encoder_host.h
@@ -0,0 +1,114 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_ENCODER_HOST_H_
+#define CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_ENCODER_HOST_H_
+
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/scoped_vector.h"
+#include "base/numerics/safe_math.h"
+#include "content/common/content_export.h"
+#include "ppapi/c/pp_codecs.h"
+#include "ppapi/host/host_message_context.h"
+#include "ppapi/host/resource_host.h"
+#include "ppapi/proxy/resource_message_params.h"
+#include "ppapi/proxy/serialized_structs.h"
+#include "ppapi/shared_impl/media_stream_buffer_manager.h"
+
+namespace content {
+
+class RendererPpapiHost;
+
+class CONTENT_EXPORT PepperAudioEncoderHost
+ : public ppapi::host::ResourceHost,
+ public ppapi::MediaStreamBufferManager::Delegate {
+ public:
+ PepperAudioEncoderHost(RendererPpapiHost* host,
+ PP_Instance instance,
+ PP_Resource resource);
+ ~PepperAudioEncoderHost() override;
+
+ private:
+ class AudioEncoderImpl;
+
+ // ResourceHost implementation.
+ int32_t OnResourceMessageReceived(
+ const IPC::Message& msg,
+ ppapi::host::HostMessageContext* context) override;
+
+ int32_t OnHostMsgGetSupportedProfiles(
+ ppapi::host::HostMessageContext* context);
+ int32_t OnHostMsgInitialize(
+ ppapi::host::HostMessageContext* context,
+ const ppapi::proxy::PPB_AudioEncodeParameters& parameters);
+ int32_t OnHostMsgGetAudioBuffers(ppapi::host::HostMessageContext* context);
+ int32_t OnHostMsgEncode(ppapi::host::HostMessageContext* context,
+ int32_t buffer_id);
+ int32_t OnHostMsgRecycleBitstreamBuffer(
+ ppapi::host::HostMessageContext* context,
+ int32_t buffer_id);
+ int32_t OnHostMsgRequestBitrateChange(
+ ppapi::host::HostMessageContext* context,
+ uint32_t bitrate);
+ int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context);
+
+ void GetSupportedProfiles(std::vector<PP_AudioProfileDescription>* profiles);
+ bool IsInitializationValid(
+ const ppapi::proxy::PPB_AudioEncodeParameters& parameters);
+ base::CheckedNumeric<size_t> GetAudioBufferSize();
bbudge 2015/11/17 00:53:40 Delete this.
llandwerlin-old 2015/11/17 15:22:30 Sorry, done.
+ bool AllocateBuffers(
+ const ppapi::proxy::PPB_AudioEncodeParameters& parameters,
+ int32_t samples_per_frame);
+ void DoEncode();
+ void BitstreamBufferReady(int32_t audio_buffer_id,
+ int32_t bitstream_buffer_id,
+ int32_t size);
+ void NotifyPepperError(int32_t error);
+ void Close();
+
+ static void StopAudioEncoder(
+ scoped_ptr<AudioEncoderImpl> encoder,
+ scoped_ptr<ppapi::MediaStreamBufferManager> audio_buffer_manager,
+ 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
+
+ // Non-owning pointer.
+ RendererPpapiHost* renderer_ppapi_host_;
+
+ // Whether the encoder has been successfully initialized.
+ bool initialized_;
+
+ // Last error reported by the encoder.
+ // This represents the current error state of the encoder, i.e. PP_OK
+ // normally, or a Pepper error code if the encoder is uninitialized,
+ // has been notified of an encoder error, has encountered some
+ // other unrecoverable error, or has been closed by the plugin.
+ // This field is checked in most message handlers to decide whether
+ // operations should proceed or fail.
+ int32_t encoder_last_error_;
+
+ // Encoder's parameters, only valid if |initialized_| is true.
+ ppapi::proxy::PPB_AudioEncodeParameters parameters_;
+
+ // Manages buffers containing audio samples from the plugin.
+ scoped_ptr<ppapi::MediaStreamBufferManager> audio_buffer_manager_;
+
+ // Manages buffers containing encoded audio from the browser.
+ scoped_ptr<ppapi::MediaStreamBufferManager> bitstream_buffer_manager_;
+
+ // 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.
+ scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_;
+
+ // The encoder actually doing the work.
+ scoped_ptr<AudioEncoderImpl> encoder_;
+
+ base::WeakPtrFactory<PepperAudioEncoderHost> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(PepperAudioEncoderHost);
+};
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_ENCODER_HOST_H_

Powered by Google App Engine
This is Rietveld 408576698