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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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;
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,
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 class SpeexEncoderImpl;
67
68 void OnEncodeDone(const scoped_refptr<AudioData>& output,
69 int32_t output_size,
70 BitstreamBufferReadyCB callback);
71
72 scoped_ptr<EncoderImpl> encoder_impl_;
73
74 // Task doing the encoding.
75 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_;
76
77 base::WeakPtrFactory<AudioEncoderShim> weak_ptr_factory_;
78
79 DISALLOW_COPY_AND_ASSIGN(AudioEncoderShim);
80 };
81
82 } // namespace content
83
84 #endif // CONTENT_RENDERER_PEPPER_VIDEO_ENCODER_SHIM_H_
OLDNEW
« 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