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

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

Issue 1151973003: ppapi: implement PPB_AudioEncoder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More Windows fixes in proxy code Created 5 years, 6 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
« no previous file with comments | « content/renderer/pepper/DEPS ('k') | content/renderer/pepper/audio_encoder_shim.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
« no previous file with comments | « content/renderer/pepper/DEPS ('k') | content/renderer/pepper/audio_encoder_shim.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698