| 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_RECEIVER_AUDIO_DECODER_H_ | 5 #ifndef MEDIA_CAST_AUDIO_RECEIVER_AUDIO_DECODER_H_ |
| 6 #define MEDIA_CAST_AUDIO_RECEIVER_AUDIO_DECODER_H_ | 6 #define MEDIA_CAST_AUDIO_RECEIVER_AUDIO_DECODER_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/synchronization/lock.h" |
| 10 #include "media/cast/cast_config.h" | 10 #include "media/cast/cast_config.h" |
| 11 #include "media/cast/rtp_common/rtp_defines.h" | 11 #include "media/cast/rtp_common/rtp_defines.h" |
| 12 | 12 |
| 13 namespace webrtc { | 13 namespace webrtc { |
| 14 class AudioCodingModule; | 14 class AudioCodingModule; |
| 15 } | 15 } |
| 16 | 16 |
| 17 namespace media { | 17 namespace media { |
| 18 namespace cast { | 18 namespace cast { |
| 19 | 19 |
| 20 // Thread safe class. | 20 // Thread safe class. |
| 21 class AudioDecoder : public base::RefCountedThreadSafe<AudioDecoder> { | 21 class AudioDecoder { |
| 22 public: | 22 public: |
| 23 explicit AudioDecoder(const AudioReceiverConfig& audio_config); | 23 explicit AudioDecoder(const AudioReceiverConfig& audio_config); |
| 24 virtual ~AudioDecoder(); |
| 24 | 25 |
| 25 // Extract a raw audio frame from the decoder. | 26 // Extract a raw audio frame from the decoder. |
| 26 // Set the number of desired 10ms blocks and frequency. | 27 // Set the number of desired 10ms blocks and frequency. |
| 27 // Should be called from the cast audio decoder thread; however that is not | 28 // Should be called from the cast audio decoder thread; however that is not |
| 28 // required. | 29 // required. |
| 29 bool GetRawAudioFrame(int number_of_10ms_blocks, | 30 bool GetRawAudioFrame(int number_of_10ms_blocks, |
| 30 int desired_frequency, | 31 int desired_frequency, |
| 31 PcmAudioFrame* audio_frame, | 32 PcmAudioFrame* audio_frame, |
| 32 uint32* rtp_timestamp); | 33 uint32* rtp_timestamp); |
| 33 | 34 |
| 34 // Insert an RTP packet to the decoder. | 35 // Insert an RTP packet to the decoder. |
| 35 // Should be called from the main cast thread; however that is not required. | 36 // Should be called from the main cast thread; however that is not required. |
| 36 void IncomingParsedRtpPacket(const uint8* payload_data, | 37 void IncomingParsedRtpPacket(const uint8* payload_data, |
| 37 size_t payload_size, | 38 size_t payload_size, |
| 38 const RtpCastHeader& rtp_header); | 39 const RtpCastHeader& rtp_header); |
| 39 | 40 |
| 40 protected: | |
| 41 virtual ~AudioDecoder(); | |
| 42 | |
| 43 private: | 41 private: |
| 44 friend class base::RefCountedThreadSafe<AudioDecoder>; | 42 // The webrtc AudioCodingModule is threadsafe. |
| 45 | |
| 46 scoped_ptr<webrtc::AudioCodingModule> audio_decoder_; | 43 scoped_ptr<webrtc::AudioCodingModule> audio_decoder_; |
| 44 // TODO(pwestin): Refactor to avoid this. Call IncomingParsedRtpPacket from |
| 45 // audio decoder thread that way this class does not have to be thread safe. |
| 46 base::Lock lock_; |
| 47 bool have_received_packets_; | 47 bool have_received_packets_; |
| 48 | 48 |
| 49 DISALLOW_COPY_AND_ASSIGN(AudioDecoder); | 49 DISALLOW_COPY_AND_ASSIGN(AudioDecoder); |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 } // namespace cast | 52 } // namespace cast |
| 53 } // namespace media | 53 } // namespace media |
| 54 | 54 |
| 55 #endif // MEDIA_CAST_AUDIO_RECEIVER_AUDIO_DECODER_H_ | 55 #endif // MEDIA_CAST_AUDIO_RECEIVER_AUDIO_DECODER_H_ |
| OLD | NEW |