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 <memory> |
| 9 |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "base/threading/thread_checker.h" | 12 #include "base/threading/thread_checker.h" |
12 #include "media/base/audio_bus.h" | 13 #include "media/base/audio_bus.h" |
13 #include "media/cast/cast_environment.h" | 14 #include "media/cast/cast_environment.h" |
14 #include "media/cast/constants.h" | 15 #include "media/cast/constants.h" |
15 #include "media/cast/sender/sender_encoded_frame.h" | 16 #include "media/cast/sender/sender_encoded_frame.h" |
16 | 17 |
17 namespace base { | 18 namespace base { |
18 class TimeTicks; | 19 class TimeTicks; |
19 } | 20 } |
20 | 21 |
21 namespace media { | 22 namespace media { |
22 namespace cast { | 23 namespace cast { |
23 | 24 |
24 class AudioEncoder { | 25 class AudioEncoder { |
25 public: | 26 public: |
26 // Callback to deliver each SenderEncodedFrame, plus the number of audio | 27 // Callback to deliver each SenderEncodedFrame, plus the number of audio |
27 // samples skipped since the last frame. | 28 // samples skipped since the last frame. |
28 using FrameEncodedCallback = | 29 using FrameEncodedCallback = |
29 base::Callback<void(scoped_ptr<SenderEncodedFrame>, int)>; | 30 base::Callback<void(std::unique_ptr<SenderEncodedFrame>, int)>; |
30 | 31 |
31 AudioEncoder(const scoped_refptr<CastEnvironment>& cast_environment, | 32 AudioEncoder(const scoped_refptr<CastEnvironment>& cast_environment, |
32 int num_channels, | 33 int num_channels, |
33 int sampling_rate, | 34 int sampling_rate, |
34 int bitrate, | 35 int bitrate, |
35 Codec codec, | 36 Codec codec, |
36 const FrameEncodedCallback& frame_encoded_callback); | 37 const FrameEncodedCallback& frame_encoded_callback); |
37 virtual ~AudioEncoder(); | 38 virtual ~AudioEncoder(); |
38 | 39 |
39 OperationalStatus InitializationResult() const; | 40 OperationalStatus InitializationResult() const; |
40 | 41 |
41 int GetSamplesPerFrame() const; | 42 int GetSamplesPerFrame() const; |
42 base::TimeDelta GetFrameDuration() const; | 43 base::TimeDelta GetFrameDuration() const; |
43 | 44 |
44 void InsertAudio(scoped_ptr<AudioBus> audio_bus, | 45 void InsertAudio(std::unique_ptr<AudioBus> audio_bus, |
45 const base::TimeTicks& recorded_time); | 46 const base::TimeTicks& recorded_time); |
46 | 47 |
47 private: | 48 private: |
48 class ImplBase; | 49 class ImplBase; |
49 class OpusImpl; | 50 class OpusImpl; |
50 class Pcm16Impl; | 51 class Pcm16Impl; |
51 class AppleAacImpl; | 52 class AppleAacImpl; |
52 | 53 |
53 const scoped_refptr<CastEnvironment> cast_environment_; | 54 const scoped_refptr<CastEnvironment> cast_environment_; |
54 scoped_refptr<ImplBase> impl_; | 55 scoped_refptr<ImplBase> impl_; |
55 | 56 |
56 // Used to ensure only one thread invokes InsertAudio(). | 57 // Used to ensure only one thread invokes InsertAudio(). |
57 base::ThreadChecker insert_thread_checker_; | 58 base::ThreadChecker insert_thread_checker_; |
58 | 59 |
59 DISALLOW_COPY_AND_ASSIGN(AudioEncoder); | 60 DISALLOW_COPY_AND_ASSIGN(AudioEncoder); |
60 }; | 61 }; |
61 | 62 |
62 } // namespace cast | 63 } // namespace cast |
63 } // namespace media | 64 } // namespace media |
64 | 65 |
65 #endif // MEDIA_CAST_SENDER_AUDIO_ENCODER_H_ | 66 #endif // MEDIA_CAST_SENDER_AUDIO_ENCODER_H_ |
OLD | NEW |