| 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/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/threading/non_thread_safe.h" | 13 #include "base/threading/non_thread_safe.h" |
| 14 #include "base/time/tick_clock.h" | 14 #include "base/time/tick_clock.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "media/cast/cast_config.h" | 16 #include "media/cast/cast_config.h" |
| 17 #include "media/cast/cast_environment.h" | 17 #include "media/cast/cast_environment.h" |
| 18 #include "media/cast/cast_receiver.h" | 18 #include "media/cast/cast_receiver.h" |
| 19 #include "media/cast/rtcp/rtcp.h" // RtcpCastMessage | 19 #include "media/cast/rtcp/rtcp.h" // RtcpCastMessage |
| 20 #include "media/cast/rtp_receiver/rtp_receiver_defines.h" // RtpCastHeader | 20 #include "media/cast/rtp_receiver/rtp_receiver_defines.h" // RtpCastHeader |
| 21 | 21 |
| 22 namespace crypto { | 22 namespace crypto { |
| 23 class Encryptor; | 23 class Encryptor; |
| 24 class SymmetricKey; | 24 class SymmetricKey; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace media { | 27 namespace media { |
| 28 namespace cast { | 28 namespace cast { |
| 29 | 29 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 // Extract an encoded audio frame from the cast receiver. | 62 // Extract an encoded audio frame from the cast receiver. |
| 63 void GetEncodedAudioFrame(const AudioFrameEncodedCallback& callback); | 63 void GetEncodedAudioFrame(const AudioFrameEncodedCallback& callback); |
| 64 | 64 |
| 65 // Should only be called from the main cast thread. | 65 // Should only be called from the main cast thread. |
| 66 void IncomingPacket(scoped_ptr<Packet> packet); | 66 void IncomingPacket(scoped_ptr<Packet> packet); |
| 67 | 67 |
| 68 protected: | 68 protected: |
| 69 void IncomingParsedRtpPacket(const uint8* payload_data, | 69 void IncomingParsedRtpPacket(const uint8* payload_data, |
| 70 size_t payload_size, | 70 size_t payload_size, |
| 71 const RtpCastHeader& rtp_header); | 71 const RtpCastHeader& rtp_header); |
| 72 |
| 72 private: | 73 private: |
| 73 friend class LocalRtpAudioData; | 74 friend class LocalRtpAudioData; |
| 74 friend class LocalRtpAudioFeedback; | 75 friend class LocalRtpAudioFeedback; |
| 75 | 76 |
| 76 void CastFeedback(const RtcpCastMessage& cast_message); | 77 void CastFeedback(const RtcpCastMessage& cast_message); |
| 77 | 78 |
| 78 // Time to pull out the audio even though we are missing data. | 79 // Time to pull out the audio even though we are missing data. |
| 79 void PlayoutTimeout(); | 80 void PlayoutTimeout(); |
| 80 | 81 |
| 81 bool PostEncodedAudioFrame( | 82 bool PostEncodedAudioFrame( |
| 82 const AudioFrameEncodedCallback& callback, | 83 const AudioFrameEncodedCallback& callback, |
| 83 uint32 rtp_timestamp, | 84 uint32 rtp_timestamp, |
| 84 bool next_frame, | 85 bool next_frame, |
| 85 scoped_ptr<transport::EncodedAudioFrame>* encoded_frame); | 86 scoped_ptr<transport::EncodedAudioFrame>* encoded_frame); |
| 86 | 87 |
| 87 // Actual decoding implementation - should be called under the audio decoder | 88 // Actual decoding implementation - should be called under the audio decoder |
| 88 // thread. | 89 // thread. |
| 89 void DecodeAudioFrameThread(int number_of_10ms_blocks, | 90 void DecodeAudioFrameThread(int number_of_10ms_blocks, |
| 90 int desired_frequency, | 91 int desired_frequency, |
| 91 const AudioFrameDecodedCallback callback); | 92 const AudioFrameDecodedCallback callback); |
| 92 void ReturnDecodedFrameWithPlayoutDelay( | 93 void ReturnDecodedFrameWithPlayoutDelay( |
| 93 scoped_ptr<PcmAudioFrame> audio_frame, uint32 rtp_timestamp, | 94 scoped_ptr<PcmAudioFrame> audio_frame, |
| 95 uint32 rtp_timestamp, |
| 94 const AudioFrameDecodedCallback callback); | 96 const AudioFrameDecodedCallback callback); |
| 95 | 97 |
| 96 // Return the playout time based on the current time and rtp timestamp. | 98 // Return the playout time based on the current time and rtp timestamp. |
| 97 base::TimeTicks GetPlayoutTime(base::TimeTicks now, uint32 rtp_timestamp); | 99 base::TimeTicks GetPlayoutTime(base::TimeTicks now, uint32 rtp_timestamp); |
| 98 | 100 |
| 99 void InitializeTimers(); | 101 void InitializeTimers(); |
| 100 | 102 |
| 101 // Decrypts the data within the |audio_frame| and replaces the data with the | 103 // Decrypts the data within the |audio_frame| and replaces the data with the |
| 102 // decrypted string. | 104 // decrypted string. |
| 103 bool DecryptAudioFrame(scoped_ptr<transport::EncodedAudioFrame>* audio_frame); | 105 bool DecryptAudioFrame(scoped_ptr<transport::EncodedAudioFrame>* audio_frame); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 base::TimeTicks last_playout_time_; | 138 base::TimeTicks last_playout_time_; |
| 137 | 139 |
| 138 std::list<AudioFrameEncodedCallback> queued_encoded_callbacks_; | 140 std::list<AudioFrameEncodedCallback> queued_encoded_callbacks_; |
| 139 std::list<DecodedAudioCallbackData> queued_decoded_callbacks_; | 141 std::list<DecodedAudioCallbackData> queued_decoded_callbacks_; |
| 140 }; | 142 }; |
| 141 | 143 |
| 142 } // namespace cast | 144 } // namespace cast |
| 143 } // namespace media | 145 } // namespace media |
| 144 | 146 |
| 145 #endif // MEDIA_CAST_AUDIO_RECEIVER_AUDIO_RECEIVER_H_ | 147 #endif // MEDIA_CAST_AUDIO_RECEIVER_AUDIO_RECEIVER_H_ |
| OLD | NEW |