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

Side by Side Diff: content/renderer/pepper/audio_encoder_shim.h

Issue 1348563003: ppapi: implement PPB_AudioEncoder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Drop checks on buffers already queued Created 5 years, 2 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
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 {
33 public:
34 AudioData(const AudioData& other) : data(other.data), size(other.size) {}
35 AudioData(uint8_t* data, size_t size) : data(data), size(size) {}
36 ~AudioData() {}
37
38 uint8_t* data;
39 size_t size;
40 };
41
42 // Callback used to signal encoded data. If |size| is negative, an error
43 // occured.
44 using BitstreamBufferReadyCB =
45 base::Callback<void(const AudioData& output, int64_t size)>;
46
47 AudioEncoderShim();
48 ~AudioEncoderShim();
49
50 std::vector<PP_AudioProfileDescription> GetSupportedProfiles();
51 bool Initialize(const ppapi::proxy::PPB_AudioEncodeParameters& parameters);
52 int32_t GetNumberOfSamplesPerFrame();
53 void Encode(const AudioData& input,
54 const AudioData& output,
55 BitstreamBufferReadyCB callback);
56 void RequestBitrateChange(uint32_t bitrate);
57
58 private:
59 class EncoderImpl;
60 class OpusEncoderImpl;
61
62 void OnEncodeDone(const AudioData& output,
63 int64_t output_size,
64 BitstreamBufferReadyCB callback);
65
66 scoped_ptr<EncoderImpl> encoder_impl_;
67
68 // Task doing the encoding.
69 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_;
70
71 base::WeakPtrFactory<AudioEncoderShim> weak_ptr_factory_;
72
73 DISALLOW_COPY_AND_ASSIGN(AudioEncoderShim);
74 };
75
76 } // namespace content
77
78 #endif // CONTENT_RENDERER_PEPPER_VIDEO_ENCODER_SHIM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698