OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_AUDIO_SENDER_AUDIO_ENCODER_H_ | 5 #ifndef MEDIA_CAST_AUDIO_SENDER_AUDIO_ENCODER_H_ |
6 #define MEDIA_CAST_AUDIO_SENDER_AUDIO_ENCODER_H_ | 6 #define MEDIA_CAST_AUDIO_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 "media/cast/cast_config.h" | 10 #include "media/cast/cast_config.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 // Thread safe class. | 23 // Thread safe class. |
24 // It should be called from the main cast thread; however that is not required. | 24 // It should be called from the main cast thread; however that is not required. |
25 class AudioEncoder : public base::RefCountedThreadSafe<AudioEncoder> { | 25 class AudioEncoder : public base::RefCountedThreadSafe<AudioEncoder> { |
26 public: | 26 public: |
27 typedef base::Callback<void(scoped_ptr<EncodedAudioFrame>, | 27 typedef base::Callback<void(scoped_ptr<EncodedAudioFrame>, |
28 const base::TimeTicks&)> FrameEncodedCallback; | 28 const base::TimeTicks&)> FrameEncodedCallback; |
29 | 29 |
30 AudioEncoder(scoped_refptr<CastThread> cast_thread, | 30 AudioEncoder(scoped_refptr<CastThread> cast_thread, |
31 const AudioSenderConfig& audio_config); | 31 const AudioSenderConfig& audio_config); |
32 | 32 |
| 33 virtual ~AudioEncoder(); |
| 34 |
33 // The audio_frame must be valid until the closure callback is called. | 35 // The audio_frame must be valid until the closure callback is called. |
34 // The closure callback is called from the main cast thread as soon as | 36 // The closure callback is called from the main cast thread as soon as |
35 // the encoder is done with the frame; it does not mean that the encoded frame | 37 // the encoder is done with the frame; it does not mean that the encoded frame |
36 // has been sent out. | 38 // has been sent out. |
37 void InsertRawAudioFrame(const PcmAudioFrame* audio_frame, | 39 void InsertRawAudioFrame(const PcmAudioFrame* audio_frame, |
38 const base::TimeTicks& recorded_time, | 40 const base::TimeTicks& recorded_time, |
39 const FrameEncodedCallback& frame_encoded_callback, | 41 const FrameEncodedCallback& frame_encoded_callback, |
40 const base::Closure callback); | 42 const base::Closure callback); |
41 | 43 |
42 protected: | |
43 virtual ~AudioEncoder(); | |
44 | |
45 private: | 44 private: |
46 friend class base::RefCountedThreadSafe<AudioEncoder>; | |
47 | |
48 void EncodeAudioFrameThread( | 45 void EncodeAudioFrameThread( |
49 const PcmAudioFrame* audio_frame, | 46 const PcmAudioFrame* audio_frame, |
50 const base::TimeTicks& recorded_time, | 47 const base::TimeTicks& recorded_time, |
51 const FrameEncodedCallback& frame_encoded_callback, | 48 const FrameEncodedCallback& frame_encoded_callback, |
52 const base::Closure release_callback); | 49 const base::Closure release_callback); |
53 | 50 |
54 scoped_refptr<CastThread> cast_thread_; | 51 scoped_refptr<CastThread> cast_thread_; |
55 scoped_ptr<webrtc::AudioCodingModule> audio_encoder_; | 52 // Can't use scoped_ptr due to protected constructor within webrtc. |
| 53 webrtc::AudioCodingModule* audio_encoder_; |
56 scoped_ptr<WebrtEncodedDataCallback> webrtc_encoder_callback_; | 54 scoped_ptr<WebrtEncodedDataCallback> webrtc_encoder_callback_; |
57 uint32 timestamp_; | 55 uint32 timestamp_; |
58 | 56 |
59 DISALLOW_COPY_AND_ASSIGN(AudioEncoder); | 57 DISALLOW_COPY_AND_ASSIGN(AudioEncoder); |
60 }; | 58 }; |
61 | 59 |
62 } // namespace cast | 60 } // namespace cast |
63 } // namespace media | 61 } // namespace media |
64 | 62 |
65 #endif // MEDIA_CAST_AUDIO_SENDER_AUDIO_ENCODER_H_ | 63 #endif // MEDIA_CAST_AUDIO_SENDER_AUDIO_ENCODER_H_ |
OLD | NEW |