OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_RENDERER_PEPPER_AUDIO_ENCODER_SHIM_H_ | |
6 #define CONTENT_RENDERER_PEPPER_AUDIO_ENCODER_SHIM_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "base/memory/weak_ptr.h" | |
12 | |
13 struct PP_AudioProfileDescription; | |
14 | |
15 namespace base { | |
16 class SingleThreadTaskRunner; | |
17 } // namespace base | |
18 | |
19 namespace ppapi { | |
20 namespace proxy { | |
21 struct PPB_AudioEncodeParameters; | |
22 } // namespace proxy | |
23 } // namespace ppapi | |
24 | |
25 namespace content { | |
26 | |
27 // This class should be constructed, used, and destructed on the main | |
28 // (render) thread. | |
29 class AudioEncoderShim { | |
30 public: | |
31 // Class used to pass data between the different threads. | |
32 class AudioData : public base::RefCountedThreadSafe<AudioData> { | |
33 public: | |
34 virtual uint8_t* GetData() = 0; | |
Tom Sepez
2015/09/17 18:11:12
nit: indentation.
llandwerlin-old
2015/10/05 16:10:59
Done.
| |
35 virtual size_t GetSize() = 0; | |
36 | |
37 protected: | |
38 AudioData() {} | |
39 virtual ~AudioData() {} | |
40 | |
41 private: | |
42 friend class base::RefCountedThreadSafe<AudioData>; | |
43 | |
44 DISALLOW_COPY_AND_ASSIGN(AudioData); | |
45 }; | |
46 | |
47 // Callback to signal encoded data. If |size| is negative, an error | |
48 // occured. | |
49 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
| |
50 int32_t size)> BitstreamBufferReadyCB; | |
51 | |
52 AudioEncoderShim(); | |
53 ~AudioEncoderShim(); | |
54 | |
55 std::vector<PP_AudioProfileDescription> GetSupportedProfiles(); | |
56 bool Initialize(const ppapi::proxy::PPB_AudioEncodeParameters& parameters); | |
57 int32_t GetNumberOfSamplesPerFrame(); | |
58 void Encode(const scoped_refptr<AudioData>& input, | |
59 const scoped_refptr<AudioData>& output, | |
60 BitstreamBufferReadyCB callback); | |
61 void RequestBitrateChange(uint32_t bitrate); | |
62 | |
63 private: | |
64 class EncoderImpl; | |
65 class OpusEncoderImpl; | |
66 | |
67 void OnEncodeDone(const scoped_refptr<AudioData>& output, | |
68 int32_t output_size, | |
69 BitstreamBufferReadyCB callback); | |
70 | |
71 scoped_ptr<EncoderImpl> encoder_impl_; | |
72 | |
73 // Task doing the encoding. | |
74 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; | |
75 | |
76 base::WeakPtrFactory<AudioEncoderShim> weak_ptr_factory_; | |
77 | |
78 DISALLOW_COPY_AND_ASSIGN(AudioEncoderShim); | |
79 }; | |
80 | |
81 } // namespace content | |
82 | |
83 #endif // CONTENT_RENDERER_PEPPER_VIDEO_ENCODER_SHIM_H_ | |
OLD | NEW |