OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_CAST_SENDER_AUDIO_ENCODER_H_ | 5 #ifndef MEDIA_CAST_SENDER_AUDIO_ENCODER_H_ |
6 #define MEDIA_CAST_SENDER_AUDIO_ENCODER_H_ | 6 #define MEDIA_CAST_SENDER_AUDIO_ENCODER_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
11 #include "media/base/audio_bus.h" | 11 #include "media/base/audio_bus.h" |
12 #include "media/cast/cast_environment.h" | 12 #include "media/cast/cast_environment.h" |
13 | 13 |
14 namespace base { | 14 namespace base { |
15 class TimeTicks; | 15 class TimeTicks; |
16 } | 16 } |
17 | 17 |
18 namespace media { | 18 namespace media { |
19 namespace cast { | 19 namespace cast { |
20 | 20 |
21 class AudioEncoder { | 21 class AudioEncoder { |
22 public: | 22 public: |
23 typedef base::Callback<void(scoped_ptr<EncodedFrame>)> | 23 // Callback to deliver each EncodedFrame, plus the number of audio samples |
| 24 // skipped since the last frame. |
| 25 typedef base::Callback<void(scoped_ptr<EncodedFrame>, int)> |
24 FrameEncodedCallback; | 26 FrameEncodedCallback; |
25 | 27 |
26 AudioEncoder(const scoped_refptr<CastEnvironment>& cast_environment, | 28 AudioEncoder(const scoped_refptr<CastEnvironment>& cast_environment, |
27 int num_channels, | 29 int num_channels, |
28 int sampling_rate, | 30 int sampling_rate, |
29 int bitrate, | 31 int bitrate, |
30 Codec codec, | 32 Codec codec, |
31 const FrameEncodedCallback& frame_encoded_callback); | 33 const FrameEncodedCallback& frame_encoded_callback); |
32 virtual ~AudioEncoder(); | 34 virtual ~AudioEncoder(); |
33 | 35 |
34 CastInitializationStatus InitializationResult() const; | 36 CastInitializationStatus InitializationResult() const; |
35 | 37 |
| 38 int GetSamplesPerFrame() const; |
| 39 |
36 void InsertAudio(scoped_ptr<AudioBus> audio_bus, | 40 void InsertAudio(scoped_ptr<AudioBus> audio_bus, |
37 const base::TimeTicks& recorded_time); | 41 const base::TimeTicks& recorded_time); |
38 | 42 |
39 private: | 43 private: |
40 class ImplBase; | 44 class ImplBase; |
41 class OpusImpl; | 45 class OpusImpl; |
42 class Pcm16Impl; | 46 class Pcm16Impl; |
43 | 47 |
44 const scoped_refptr<CastEnvironment> cast_environment_; | 48 const scoped_refptr<CastEnvironment> cast_environment_; |
45 scoped_refptr<ImplBase> impl_; | 49 scoped_refptr<ImplBase> impl_; |
46 | 50 |
47 // Used to ensure only one thread invokes InsertAudio(). | 51 // Used to ensure only one thread invokes InsertAudio(). |
48 base::ThreadChecker insert_thread_checker_; | 52 base::ThreadChecker insert_thread_checker_; |
49 | 53 |
50 DISALLOW_COPY_AND_ASSIGN(AudioEncoder); | 54 DISALLOW_COPY_AND_ASSIGN(AudioEncoder); |
51 }; | 55 }; |
52 | 56 |
53 } // namespace cast | 57 } // namespace cast |
54 } // namespace media | 58 } // namespace media |
55 | 59 |
56 #endif // MEDIA_CAST_SENDER_AUDIO_ENCODER_H_ | 60 #endif // MEDIA_CAST_SENDER_AUDIO_ENCODER_H_ |
OLD | NEW |