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 |
28 // Extract a raw audio frame from the decoder. | 30 // Extract a raw audio frame from the decoder. |
29 // Set the number of desired 10ms blocks and frequency. | 31 // Set the number of desired 10ms blocks and frequency. |
30 bool GetRawAudioFrame(int number_of_10ms_blocks, | 32 bool GetRawAudioFrame(int number_of_10ms_blocks, |
31 int desired_frequency, | 33 int desired_frequency, |
32 PcmAudioFrame* audio_frame, | 34 PcmAudioFrame* audio_frame, |
33 uint32* rtp_timestamp); | 35 uint32* rtp_timestamp); |
34 | 36 |
35 // Insert an RTP packet to the decoder. | 37 // Insert an RTP packet to the decoder. |
36 void IncomingParsedRtpPacket(const uint8* payload_data, | 38 void IncomingParsedRtpPacket(const uint8* payload_data, |
37 int payload_size, | 39 int payload_size, |
38 const RtpCastHeader& rtp_header); | 40 const RtpCastHeader& rtp_header); |
39 | 41 |
40 protected: | |
41 virtual ~AudioDecoder(); | |
42 | |
43 private: | 42 private: |
44 friend class base::RefCountedThreadSafe<AudioDecoder>; | 43 // Can't use scoped_ptr due to protected constructor within webrtc. |
45 | 44 webrtc::AudioCodingModule* audio_decoder_; |
46 scoped_ptr<webrtc::AudioCodingModule> audio_decoder_; | |
47 bool have_received_packets_; | 45 bool have_received_packets_; |
48 scoped_refptr<CastThread> cast_thread_; | 46 scoped_refptr<CastThread> cast_thread_; |
49 | 47 |
50 DISALLOW_COPY_AND_ASSIGN(AudioDecoder); | 48 DISALLOW_COPY_AND_ASSIGN(AudioDecoder); |
51 }; | 49 }; |
52 | 50 |
53 } // namespace cast | 51 } // namespace cast |
54 } // namespace media | 52 } // namespace media |
55 | 53 |
56 #endif // MEDIA_CAST_AUDIO_RECEIVER_AUDIO_DECODER_H_ | 54 #endif // MEDIA_CAST_AUDIO_RECEIVER_AUDIO_DECODER_H_ |
OLD | NEW |