Chromium Code Reviews| 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/synchronization/lock.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "media/base/audio_bus.h" | |
| 10 #include "media/cast/cast_config.h" | 11 #include "media/cast/cast_config.h" |
| 11 #include "media/cast/cast_environment.h" | 12 #include "media/cast/cast_environment.h" |
| 12 #include "media/cast/framer/cast_message_builder.h" | 13 #include "media/cast/transport/cast_transport_config.h" |
| 13 #include "media/cast/framer/frame_id_map.h" | |
| 14 #include "media/cast/rtp_receiver/rtp_receiver_defines.h" | |
| 15 | |
| 16 namespace webrtc { | |
| 17 class AudioCodingModule; | |
| 18 } | |
| 19 | 14 |
| 20 namespace media { | 15 namespace media { |
| 21 namespace cast { | 16 namespace cast { |
| 22 | 17 |
| 23 typedef std::map<uint32, uint32> FrameIdRtpTimestampMap; | |
| 24 | |
| 25 // Thread safe class. | |
| 26 class AudioDecoder { | 18 class AudioDecoder { |
| 27 public: | 19 public: |
| 28 AudioDecoder(scoped_refptr<CastEnvironment> cast_environment, | 20 AudioDecoder(const scoped_refptr<CastEnvironment>& cast_environment, |
| 29 const AudioReceiverConfig& audio_config, | 21 const AudioReceiverConfig& audio_config); |
| 30 RtpPayloadFeedback* incoming_payload_feedback); | |
| 31 virtual ~AudioDecoder(); | 22 virtual ~AudioDecoder(); |
| 32 | 23 |
| 33 // Extract a raw audio frame from the decoder. | 24 CastInitializationStatus InitializationResult() const; |
|
hubbe
2014/03/28 19:50:59
Add a comment for this function.
miu
2014/03/28 23:51:58
Done.
| |
| 34 // Set the number of desired 10ms blocks and frequency. | |
| 35 // Should be called from the cast audio decoder thread; however that is not | |
| 36 // required. | |
| 37 bool GetRawAudioFrame(int number_of_10ms_blocks, | |
| 38 int desired_frequency, | |
| 39 PcmAudioFrame* audio_frame, | |
| 40 uint32* rtp_timestamp); | |
| 41 | 25 |
| 42 // Insert an RTP packet to the decoder. | 26 // In the normal case, |encoded_frame->frame_id| will be |
| 43 // Should be called from the main cast thread; however that is not required. | 27 // monotonically-increasing by 1 for each successive call to this method. |
| 44 void IncomingParsedRtpPacket(const uint8* payload_data, | 28 // When it is not, the decoder will assume one or more packets have been |
| 45 size_t payload_size, | 29 // dropped, and will perform recovery actions. |
| 46 const RtpCastHeader& rtp_header); | 30 typedef base::Callback<void(scoped_ptr<AudioBus>, |
|
hubbe
2014/03/28 19:50:59
I think you should move the typedef before the com
miu
2014/03/28 23:51:58
Done. IIRC, Chromium style wants type decls befor
| |
| 47 | 31 bool is_continuous)> DecodeFrameCallback; |
| 48 bool TimeToSendNextCastMessage(base::TimeTicks* time_to_send); | 32 void DecodeFrame(scoped_ptr<transport::EncodedAudioFrame> encoded_frame, |
|
hubbe
2014/03/28 19:50:59
Why does this function take a callback at all?
Cou
miu
2014/03/28 23:51:58
Done.
| |
| 49 void SendCastMessage(); | 33 const DecodeFrameCallback& callback); |
| 50 | 34 |
| 51 private: | 35 private: |
| 52 scoped_refptr<CastEnvironment> cast_environment_; | 36 class ImplBase; |
| 37 class OpusImpl; | |
| 38 class Pcm16Impl; | |
| 53 | 39 |
| 54 // The webrtc AudioCodingModule is thread safe. | 40 const scoped_refptr<CastEnvironment> cast_environment_; |
| 55 scoped_ptr<webrtc::AudioCodingModule> audio_decoder_; | 41 scoped_refptr<ImplBase> impl_; |
| 56 | |
| 57 FrameIdMap frame_id_map_; | |
| 58 CastMessageBuilder cast_message_builder_; | |
| 59 | |
| 60 base::Lock lock_; | |
| 61 bool have_received_packets_; | |
| 62 FrameIdRtpTimestampMap frame_id_rtp_timestamp_map_; | |
| 63 uint32 last_played_out_timestamp_; | |
| 64 | 42 |
| 65 DISALLOW_COPY_AND_ASSIGN(AudioDecoder); | 43 DISALLOW_COPY_AND_ASSIGN(AudioDecoder); |
| 66 }; | 44 }; |
| 67 | 45 |
| 68 } // namespace cast | 46 } // namespace cast |
| 69 } // namespace media | 47 } // namespace media |
| 70 | 48 |
| 71 #endif // MEDIA_CAST_AUDIO_RECEIVER_AUDIO_DECODER_H_ | 49 #endif // MEDIA_CAST_AUDIO_RECEIVER_AUDIO_DECODER_H_ |
| OLD | NEW |