| 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 | |
| 35 // The audio_frame must be valid until the closure callback is called. | 33 // The audio_frame must be valid until the closure callback is called. |
| 36 // The closure callback is called from the main cast thread as soon as | 34 // The closure callback is called from the main cast thread as soon as |
| 37 // the encoder is done with the frame; it does not mean that the encoded frame | 35 // the encoder is done with the frame; it does not mean that the encoded frame |
| 38 // has been sent out. | 36 // has been sent out. |
| 39 void InsertRawAudioFrame(const PcmAudioFrame* audio_frame, | 37 void InsertRawAudioFrame(const PcmAudioFrame* audio_frame, |
| 40 const base::TimeTicks& recorded_time, | 38 const base::TimeTicks& recorded_time, |
| 41 const FrameEncodedCallback& frame_encoded_callback, | 39 const FrameEncodedCallback& frame_encoded_callback, |
| 42 const base::Closure callback); | 40 const base::Closure callback); |
| 43 | 41 |
| 42 protected: |
| 43 virtual ~AudioEncoder(); |
| 44 |
| 44 private: | 45 private: |
| 46 friend class base::RefCountedThreadSafe<AudioEncoder>; |
| 47 |
| 45 void EncodeAudioFrameThread( | 48 void EncodeAudioFrameThread( |
| 46 const PcmAudioFrame* audio_frame, | 49 const PcmAudioFrame* audio_frame, |
| 47 const base::TimeTicks& recorded_time, | 50 const base::TimeTicks& recorded_time, |
| 48 const FrameEncodedCallback& frame_encoded_callback, | 51 const FrameEncodedCallback& frame_encoded_callback, |
| 49 const base::Closure release_callback); | 52 const base::Closure release_callback); |
| 50 | 53 |
| 51 scoped_refptr<CastThread> cast_thread_; | 54 scoped_refptr<CastThread> cast_thread_; |
| 52 // Can't use scoped_ptr due to protected constructor within webrtc. | 55 scoped_ptr<webrtc::AudioCodingModule> audio_encoder_; |
| 53 webrtc::AudioCodingModule* audio_encoder_; | |
| 54 scoped_ptr<WebrtEncodedDataCallback> webrtc_encoder_callback_; | 56 scoped_ptr<WebrtEncodedDataCallback> webrtc_encoder_callback_; |
| 55 uint32 timestamp_; | 57 uint32 timestamp_; |
| 56 | 58 |
| 57 DISALLOW_COPY_AND_ASSIGN(AudioEncoder); | 59 DISALLOW_COPY_AND_ASSIGN(AudioEncoder); |
| 58 }; | 60 }; |
| 59 | 61 |
| 60 } // namespace cast | 62 } // namespace cast |
| 61 } // namespace media | 63 } // namespace media |
| 62 | 64 |
| 63 #endif // MEDIA_CAST_AUDIO_SENDER_AUDIO_ENCODER_H_ | 65 #endif // MEDIA_CAST_AUDIO_SENDER_AUDIO_ENCODER_H_ |
| OLD | NEW |