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/memory/ref_counted.h" |
10 #include "media/cast/cast_config.h" | 10 #include "media/cast/cast_config.h" |
11 #include "media/cast/cast_thread.h" | 11 #include "media/cast/cast_thread.h" |
12 #include "media/cast/rtp_common/rtp_defines.h" | 12 #include "media/cast/rtp_common/rtp_defines.h" |
13 | 13 |
14 namespace webrtc { | 14 namespace webrtc { |
15 class AudioCodingModule; | 15 class AudioCodingModule; |
16 } | 16 } |
17 | 17 |
18 namespace media { | 18 namespace media { |
19 namespace cast { | 19 namespace cast { |
20 | 20 |
21 // Thread safe class. | 21 // Thread safe class. |
22 // It should be called from the main cast thread; however that is not required. | 22 // It should be called from the main cast thread; however that is not required. |
23 class AudioDecoder : public base::RefCountedThreadSafe<AudioDecoder> { | 23 class AudioDecoder : public base::RefCountedThreadSafe<AudioDecoder> { |
24 public: | 24 public: |
25 explicit AudioDecoder(scoped_refptr<CastThread> cast_thread, | 25 explicit AudioDecoder(scoped_refptr<CastThread> cast_thread, |
26 const AudioReceiverConfig& audio_config); | 26 const AudioReceiverConfig& audio_config); |
27 | 27 |
28 virtual ~AudioDecoder(); | |
29 | |
30 // Extract a raw audio frame from the decoder. | 28 // Extract a raw audio frame from the decoder. |
31 // Set the number of desired 10ms blocks and frequency. | 29 // Set the number of desired 10ms blocks and frequency. |
32 bool GetRawAudioFrame(int number_of_10ms_blocks, | 30 bool GetRawAudioFrame(int number_of_10ms_blocks, |
33 int desired_frequency, | 31 int desired_frequency, |
34 PcmAudioFrame* audio_frame, | 32 PcmAudioFrame* audio_frame, |
35 uint32* rtp_timestamp); | 33 uint32* rtp_timestamp); |
36 | 34 |
37 // Insert an RTP packet to the decoder. | 35 // Insert an RTP packet to the decoder. |
38 void IncomingParsedRtpPacket(const uint8* payload_data, | 36 void IncomingParsedRtpPacket(const uint8* payload_data, |
39 int payload_size, | 37 int payload_size, |
40 const RtpCastHeader& rtp_header); | 38 const RtpCastHeader& rtp_header); |
41 | 39 |
| 40 protected: |
| 41 virtual ~AudioDecoder(); |
| 42 |
42 private: | 43 private: |
43 // Can't use scoped_ptr due to protected constructor within webrtc. | 44 friend class base::RefCountedThreadSafe<AudioDecoder>; |
44 webrtc::AudioCodingModule* audio_decoder_; | 45 |
| 46 scoped_ptr<webrtc::AudioCodingModule> audio_decoder_; |
45 bool have_received_packets_; | 47 bool have_received_packets_; |
46 scoped_refptr<CastThread> cast_thread_; | 48 scoped_refptr<CastThread> cast_thread_; |
47 | 49 |
48 DISALLOW_COPY_AND_ASSIGN(AudioDecoder); | 50 DISALLOW_COPY_AND_ASSIGN(AudioDecoder); |
49 }; | 51 }; |
50 | 52 |
51 } // namespace cast | 53 } // namespace cast |
52 } // namespace media | 54 } // namespace media |
53 | 55 |
54 #endif // MEDIA_CAST_AUDIO_RECEIVER_AUDIO_DECODER_H_ | 56 #endif // MEDIA_CAST_AUDIO_RECEIVER_AUDIO_DECODER_H_ |
OLD | NEW |