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..c5ab47af8511dc35623cfbb9ac6ec27193ebcca9 |
--- /dev/null |
+++ b/content/renderer/pepper/audio_encoder_shim.h |
@@ -0,0 +1,84 @@ |
+// 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 base::RefCountedThreadSafe<AudioData> { |
+ public: |
+ virtual uint8_t* GetData() = 0; |
+ virtual size_t GetSize() = 0; |
+ |
+ protected: |
+ AudioData() {} |
+ virtual ~AudioData() {} |
+ |
+ private: |
+ friend class base::RefCountedThreadSafe<AudioData>; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(AudioData); |
+ }; |
+ |
+ // Callback to signal encoded data. If |size| is negative, an error |
+ // occured. |
+ typedef base::Callback<void(const scoped_refptr<AudioData>& output, |
+ int32_t size)> BitstreamBufferReadyCB; |
+ |
+ AudioEncoderShim(); |
+ ~AudioEncoderShim(); |
+ |
+ std::vector<PP_AudioProfileDescription> GetSupportedProfiles(); |
+ bool Initialize(const ppapi::proxy::PPB_AudioEncodeParameters& parameters); |
+ int32_t GetNumberOfSamplesPerFrame(); |
+ void Encode(const scoped_refptr<AudioData>& input, |
+ const scoped_refptr<AudioData>& output, |
+ BitstreamBufferReadyCB callback); |
+ void RequestBitrateChange(uint32_t bitrate); |
+ |
+ private: |
+ class EncoderImpl; |
+ class OpusEncoderImpl; |
+ class SpeexEncoderImpl; |
+ |
+ void OnEncodeDone(const scoped_refptr<AudioData>& output, |
+ int32_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_ |