| 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_SENDER_H_ | 5 #ifndef MEDIA_CAST_AUDIO_SENDER_H_ |
| 6 #define MEDIA_CAST_AUDIO_SENDER_H_ | 6 #define MEDIA_CAST_AUDIO_SENDER_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 "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/threading/non_thread_safe.h" | 12 #include "base/threading/non_thread_safe.h" |
| 13 #include "base/time/tick_clock.h" | 13 #include "base/time/tick_clock.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "media/cast/cast_config.h" | 15 #include "media/cast/cast_config.h" |
| 16 #include "media/cast/cast_environment.h" |
| 16 #include "media/cast/rtcp/rtcp.h" | 17 #include "media/cast/rtcp/rtcp.h" |
| 17 #include "media/cast/transport/rtp_sender/rtp_sender.h" | 18 #include "media/cast/transport/rtp_sender/rtp_sender.h" |
| 18 | 19 |
| 19 namespace crypto { | 20 namespace crypto { |
| 20 class Encryptor; | 21 class Encryptor; |
| 21 class SymmetricKey; | 22 class SymmetricKey; |
| 22 } | 23 } |
| 23 | 24 |
| 24 namespace media { | 25 namespace media { |
| 25 class AudioBus; | 26 class AudioBus; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 48 // done with |audio_bus|; it does not mean that the encoded data has been | 49 // done with |audio_bus|; it does not mean that the encoded data has been |
| 49 // sent out. | 50 // sent out. |
| 50 void InsertAudio(const AudioBus* audio_bus, | 51 void InsertAudio(const AudioBus* audio_bus, |
| 51 const base::TimeTicks& recorded_time, | 52 const base::TimeTicks& recorded_time, |
| 52 const base::Closure& done_callback); | 53 const base::Closure& done_callback); |
| 53 | 54 |
| 54 // The audio_frame must be valid until the closure callback is called. | 55 // The audio_frame must be valid until the closure callback is called. |
| 55 // The closure callback is called from the main cast thread as soon as | 56 // The closure callback is called from the main cast thread as soon as |
| 56 // the cast sender is done with the frame; it does not mean that the encoded | 57 // the cast sender is done with the frame; it does not mean that the encoded |
| 57 // frame has been sent out. | 58 // frame has been sent out. |
| 58 void InsertCodedAudioFrame( | 59 void InsertCodedAudioFrame(const EncodedAudioFrame* audio_frame, |
| 59 const transport::EncodedAudioFrame* audio_frame, | 60 const base::TimeTicks& recorded_time, |
| 60 const base::TimeTicks& recorded_time, | 61 const base::Closure callback); |
| 61 const base::Closure callback); | |
| 62 | 62 |
| 63 // Only called from the main cast thread. | 63 // Only called from the main cast thread. |
| 64 void IncomingRtcpPacket(const uint8* packet, size_t length, | 64 void IncomingRtcpPacket(const uint8* packet, size_t length, |
| 65 const base::Closure callback); | 65 const base::Closure callback); |
| 66 | 66 |
| 67 protected: | 67 protected: |
| 68 void SendEncodedAudioFrame( | 68 void SendEncodedAudioFrame(scoped_ptr<EncodedAudioFrame> audio_frame, |
| 69 scoped_ptr<transport::EncodedAudioFrame> audio_frame, | 69 const base::TimeTicks& recorded_time); |
| 70 const base::TimeTicks& recorded_time); | |
| 71 | 70 |
| 72 private: | 71 private: |
| 73 friend class LocalRtcpAudioSenderFeedback; | 72 friend class LocalRtcpAudioSenderFeedback; |
| 74 | 73 |
| 75 void ResendPackets( | 74 void ResendPackets( |
| 76 const MissingFramesAndPacketsMap& missing_frames_and_packets); | 75 const MissingFramesAndPacketsMap& missing_frames_and_packets); |
| 77 | 76 |
| 78 // Caller must allocate the destination |encrypted_frame|. The data member | 77 // Caller must allocate the destination |encrypted_frame|. The data member |
| 79 // will be resized to hold the encrypted size. | 78 // will be resized to hold the encrypted size. |
| 80 bool EncryptAudioFrame(const transport::EncodedAudioFrame& audio_frame, | 79 bool EncryptAudioFrame(const EncodedAudioFrame& audio_frame, |
| 81 transport::EncodedAudioFrame* encrypted_frame); | 80 EncodedAudioFrame* encrypted_frame); |
| 82 | 81 |
| 83 void ScheduleNextRtcpReport(); | 82 void ScheduleNextRtcpReport(); |
| 84 void SendRtcpReport(); | 83 void SendRtcpReport(); |
| 85 | 84 |
| 86 void InitializeTimers(); | 85 void InitializeTimers(); |
| 87 | 86 |
| 88 base::WeakPtrFactory<AudioSender> weak_factory_; | 87 base::WeakPtrFactory<AudioSender> weak_factory_; |
| 89 | 88 |
| 90 scoped_refptr<CastEnvironment> cast_environment_; | 89 scoped_refptr<CastEnvironment> cast_environment_; |
| 91 scoped_refptr<AudioEncoder> audio_encoder_; | 90 scoped_refptr<AudioEncoder> audio_encoder_; |
| 92 transport::RtpSender rtp_sender_; | 91 transport::RtpSender rtp_sender_; |
| 93 scoped_ptr<LocalRtpSenderStatistics> rtp_audio_sender_statistics_; | 92 scoped_ptr<LocalRtpSenderStatistics> rtp_audio_sender_statistics_; |
| 94 scoped_ptr<LocalRtcpAudioSenderFeedback> rtcp_feedback_; | 93 scoped_ptr<LocalRtcpAudioSenderFeedback> rtcp_feedback_; |
| 95 Rtcp rtcp_; | 94 Rtcp rtcp_; |
| 96 bool initialized_; | 95 bool initialized_; |
| 97 scoped_ptr<crypto::Encryptor> encryptor_; | 96 scoped_ptr<crypto::Encryptor> encryptor_; |
| 98 scoped_ptr<crypto::SymmetricKey> encryption_key_; | 97 scoped_ptr<crypto::SymmetricKey> encryption_key_; |
| 99 std::string iv_mask_; | 98 std::string iv_mask_; |
| 100 | 99 |
| 101 DISALLOW_COPY_AND_ASSIGN(AudioSender); | 100 DISALLOW_COPY_AND_ASSIGN(AudioSender); |
| 102 }; | 101 }; |
| 103 | 102 |
| 104 } // namespace cast | 103 } // namespace cast |
| 105 } // namespace media | 104 } // namespace media |
| 106 | 105 |
| 107 #endif // MEDIA_CAST_AUDIO_SENDER_H_ | 106 #endif // MEDIA_CAST_AUDIO_SENDER_H_ |
| OLD | NEW |