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_RECEIVER_H_ | 5 #ifndef MEDIA_CAST_AUDIO_RECEIVER_AUDIO_RECEIVER_H_ |
6 #define MEDIA_CAST_AUDIO_RECEIVER_AUDIO_RECEIVER_H_ | 6 #define MEDIA_CAST_AUDIO_RECEIVER_AUDIO_RECEIVER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 public base::SupportsWeakPtr<AudioReceiver> { | 46 public base::SupportsWeakPtr<AudioReceiver> { |
47 public: | 47 public: |
48 AudioReceiver(scoped_refptr<CastEnvironment> cast_environment, | 48 AudioReceiver(scoped_refptr<CastEnvironment> cast_environment, |
49 const AudioReceiverConfig& audio_config, | 49 const AudioReceiverConfig& audio_config, |
50 transport::PacedPacketSender* const packet_sender); | 50 transport::PacedPacketSender* const packet_sender); |
51 | 51 |
52 virtual ~AudioReceiver(); | 52 virtual ~AudioReceiver(); |
53 | 53 |
54 // Extract a raw audio frame from the cast receiver. | 54 // Extract a raw audio frame from the cast receiver. |
55 // Actual decoding will be preformed on a designated audio_decoder thread. | 55 // Actual decoding will be preformed on a designated audio_decoder thread. |
56 void GetRawAudioFrame(int number_of_10ms_blocks, int desired_frequency, | 56 void GetRawAudioFrame(int number_of_10ms_blocks, |
| 57 int desired_frequency, |
57 const AudioFrameDecodedCallback& callback); | 58 const AudioFrameDecodedCallback& callback); |
58 | 59 |
59 // Extract an encoded audio frame from the cast receiver. | 60 // Extract an encoded audio frame from the cast receiver. |
60 void GetEncodedAudioFrame(const AudioFrameEncodedCallback& callback); | 61 void GetEncodedAudioFrame(const AudioFrameEncodedCallback& callback); |
61 | 62 |
62 // Should only be called from the main cast thread. | 63 // Should only be called from the main cast thread. |
63 void IncomingPacket(scoped_ptr<Packet> packet); | 64 void IncomingPacket(scoped_ptr<Packet> packet); |
64 | 65 |
| 66 // Update target audio delay used to compute the playout time. Rtcp |
| 67 // will also be updated (will be included in all outgoing reports). |
| 68 void SetTargetDelay(base::TimeDelta target_delay); |
| 69 |
65 protected: | 70 protected: |
66 void IncomingParsedRtpPacket(const uint8* payload_data, size_t payload_size, | 71 void IncomingParsedRtpPacket(const uint8* payload_data, |
| 72 size_t payload_size, |
67 const RtpCastHeader& rtp_header); | 73 const RtpCastHeader& rtp_header); |
68 | 74 |
69 private: | 75 private: |
70 friend class LocalRtpAudioData; | 76 friend class LocalRtpAudioData; |
71 friend class LocalRtpAudioFeedback; | 77 friend class LocalRtpAudioFeedback; |
72 | 78 |
73 void CastFeedback(const RtcpCastMessage& cast_message); | 79 void CastFeedback(const RtcpCastMessage& cast_message); |
74 | 80 |
75 // Time to pull out the audio even though we are missing data. | 81 // Time to pull out the audio even though we are missing data. |
76 void PlayoutTimeout(); | 82 void PlayoutTimeout(); |
77 | 83 |
78 bool PostEncodedAudioFrame( | 84 bool PostEncodedAudioFrame( |
79 const AudioFrameEncodedCallback& callback, | 85 const AudioFrameEncodedCallback& callback, |
80 bool next_frame, | 86 bool next_frame, |
81 scoped_ptr<transport::EncodedAudioFrame>* encoded_frame); | 87 scoped_ptr<transport::EncodedAudioFrame>* encoded_frame); |
82 | 88 |
83 // Actual decoding implementation - should be called under the audio decoder | 89 // Actual decoding implementation - should be called under the audio decoder |
84 // thread. | 90 // thread. |
85 void DecodeAudioFrameThread(int number_of_10ms_blocks, int desired_frequency, | 91 void DecodeAudioFrameThread(int number_of_10ms_blocks, |
| 92 int desired_frequency, |
86 const AudioFrameDecodedCallback callback); | 93 const AudioFrameDecodedCallback callback); |
87 void ReturnDecodedFrameWithPlayoutDelay( | 94 void ReturnDecodedFrameWithPlayoutDelay( |
88 scoped_ptr<PcmAudioFrame> audio_frame, uint32 rtp_timestamp, | 95 scoped_ptr<PcmAudioFrame> audio_frame, |
| 96 uint32 rtp_timestamp, |
89 const AudioFrameDecodedCallback callback); | 97 const AudioFrameDecodedCallback callback); |
90 | 98 |
91 // Return the playout time based on the current time and rtp timestamp. | 99 // Return the playout time based on the current time and rtp timestamp. |
92 base::TimeTicks GetPlayoutTime(base::TimeTicks now, uint32 rtp_timestamp); | 100 base::TimeTicks GetPlayoutTime(base::TimeTicks now, uint32 rtp_timestamp); |
93 | 101 |
94 void InitializeTimers(); | 102 void InitializeTimers(); |
95 | 103 |
96 // Decrypts the data within the |audio_frame| and replaces the data with the | 104 // Decrypts the data within the |audio_frame| and replaces the data with the |
97 // decrypted string. | 105 // decrypted string. |
98 bool DecryptAudioFrame(scoped_ptr<transport::EncodedAudioFrame>* audio_frame); | 106 bool DecryptAudioFrame(scoped_ptr<transport::EncodedAudioFrame>* audio_frame); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 // it allows the event to be transmitted via RTCP. | 148 // it allows the event to be transmitted via RTCP. |
141 RtpTimestamp frame_id_to_rtp_timestamp_[256]; | 149 RtpTimestamp frame_id_to_rtp_timestamp_[256]; |
142 | 150 |
143 DISALLOW_COPY_AND_ASSIGN(AudioReceiver); | 151 DISALLOW_COPY_AND_ASSIGN(AudioReceiver); |
144 }; | 152 }; |
145 | 153 |
146 } // namespace cast | 154 } // namespace cast |
147 } // namespace media | 155 } // namespace media |
148 | 156 |
149 #endif // MEDIA_CAST_AUDIO_RECEIVER_AUDIO_RECEIVER_H_ | 157 #endif // MEDIA_CAST_AUDIO_RECEIVER_AUDIO_RECEIVER_H_ |
OLD | NEW |