Chromium Code Reviews| 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..2dc6a67935e6ceed91bfad42ab562843359b7274 |
| --- /dev/null |
| +++ b/content/renderer/pepper/audio_encoder_shim.h |
| @@ -0,0 +1,83 @@ |
| +// 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; |
|
Tom Sepez
2015/09/17 18:11:12
nit: indentation.
llandwerlin-old
2015/10/05 16:10:59
Done.
|
| + 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, |
|
Tom Sepez
2015/09/17 18:11:12
nit: using.
llandwerlin-old
2015/10/05 16:10:59
Done.
Tom Sepez
2015/10/05 16:54:16
No :), I meant that our style guide prefers |using
llandwerlin-old
2015/10/05 17:16:31
Right, I was a bit puzzled with this nit, makes se
|
| + 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; |
| + |
| + 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_ |