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

Unified Diff: content/renderer/pepper/audio_encoder_shim.h

Issue 1348563003: ppapi: implement PPB_AudioEncoder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Drop checks on buffers already queued Created 5 years, 2 months 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/audio_encoder_shim.h
diff --git a/content/renderer/pepper/audio_encoder_shim.h b/content/renderer/pepper/audio_encoder_shim.h
new file mode 100644
index 0000000000000000000000000000000000000000..f3b917bd05cc98fa282d50011171ea1cb5f00dd8
--- /dev/null
+++ b/content/renderer/pepper/audio_encoder_shim.h
@@ -0,0 +1,78 @@
+// 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_AUDIO_ENCODER_SHIM_H_
+#define CONTENT_RENDERER_PEPPER_AUDIO_ENCODER_SHIM_H_
+
+#include <vector>
+
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+
+struct PP_AudioProfileDescription;
+
+namespace base {
+class SingleThreadTaskRunner;
+} // namespace base
+
+namespace ppapi {
+namespace proxy {
+struct PPB_AudioEncodeParameters;
+} // namespace proxy
+} // namespace ppapi
+
+namespace content {
+
+// This class should be constructed, used, and destructed on the main
+// (render) thread.
+class AudioEncoderShim {
+ public:
+ // Class used to pass data between the different threads.
+ class AudioData {
+ public:
+ AudioData(const AudioData& other) : data(other.data), size(other.size) {}
+ AudioData(uint8_t* data, size_t size) : data(data), size(size) {}
+ ~AudioData() {}
+
+ uint8_t* data;
+ size_t size;
+ };
+
+ // Callback used to signal encoded data. If |size| is negative, an error
+ // occured.
+ using BitstreamBufferReadyCB =
+ base::Callback<void(const AudioData& output, int64_t size)>;
+
+ AudioEncoderShim();
+ ~AudioEncoderShim();
+
+ std::vector<PP_AudioProfileDescription> GetSupportedProfiles();
+ bool Initialize(const ppapi::proxy::PPB_AudioEncodeParameters& parameters);
+ int32_t GetNumberOfSamplesPerFrame();
+ void Encode(const AudioData& input,
+ const AudioData& output,
+ BitstreamBufferReadyCB callback);
+ void RequestBitrateChange(uint32_t bitrate);
+
+ private:
+ class EncoderImpl;
+ class OpusEncoderImpl;
+
+ void OnEncodeDone(const AudioData& output,
+ int64_t output_size,
+ BitstreamBufferReadyCB callback);
+
+ scoped_ptr<EncoderImpl> encoder_impl_;
+
+ // Task doing the encoding.
+ scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_;
+
+ base::WeakPtrFactory<AudioEncoderShim> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(AudioEncoderShim);
+};
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_PEPPER_VIDEO_ENCODER_SHIM_H_

Powered by Google App Engine
This is Rietveld 408576698