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 #include "media/cast/audio_sender/audio_sender.h" | 5 #include "media/cast/audio_sender/audio_sender.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "crypto/encryptor.h" | 10 #include "crypto/encryptor.h" |
11 #include "crypto/symmetric_key.h" | 11 #include "crypto/symmetric_key.h" |
12 #include "media/cast/audio_sender/audio_encoder.h" | 12 #include "media/cast/audio_sender/audio_encoder.h" |
13 #include "media/cast/cast_environment.h" | 13 #include "media/cast/cast_environment.h" |
14 #include "media/cast/net/rtp_sender/rtp_sender.h" | |
15 #include "media/cast/rtcp/rtcp.h" | 14 #include "media/cast/rtcp/rtcp.h" |
| 15 #include "media/cast/transport/rtp_sender/rtp_sender.h" |
16 | 16 |
17 namespace media { | 17 namespace media { |
18 namespace cast { | 18 namespace cast { |
19 | 19 |
20 const int64 kMinSchedulingDelayMs = 1; | 20 const int64 kMinSchedulingDelayMs = 1; |
21 | 21 |
22 class LocalRtcpAudioSenderFeedback : public RtcpSenderFeedback { | 22 class LocalRtcpAudioSenderFeedback : public RtcpSenderFeedback { |
23 public: | 23 public: |
24 explicit LocalRtcpAudioSenderFeedback(AudioSender* audio_sender) | 24 explicit LocalRtcpAudioSenderFeedback(AudioSender* audio_sender) |
25 : audio_sender_(audio_sender) { | 25 : audio_sender_(audio_sender) { |
26 } | 26 } |
27 | 27 |
28 virtual void OnReceivedCastFeedback( | 28 virtual void OnReceivedCastFeedback( |
29 const RtcpCastMessage& cast_feedback) OVERRIDE { | 29 const RtcpCastMessage& cast_feedback) OVERRIDE { |
30 if (!cast_feedback.missing_frames_and_packets_.empty()) { | 30 if (!cast_feedback.missing_frames_and_packets_.empty()) { |
31 audio_sender_->ResendPackets(cast_feedback.missing_frames_and_packets_); | 31 audio_sender_->ResendPackets(cast_feedback.missing_frames_and_packets_); |
32 } | 32 } |
33 VLOG(1) << "Received audio ACK " | 33 VLOG(1) << "Received audio ACK " |
34 << static_cast<int>(cast_feedback.ack_frame_id_); | 34 << static_cast<int>(cast_feedback.ack_frame_id_); |
35 } | 35 } |
36 | 36 |
37 private: | 37 private: |
38 AudioSender* audio_sender_; | 38 AudioSender* audio_sender_; |
39 }; | 39 }; |
40 | 40 |
41 class LocalRtpSenderStatistics : public RtpSenderStatistics { | 41 class LocalRtpSenderStatistics : public RtpSenderStatistics { |
42 public: | 42 public: |
43 explicit LocalRtpSenderStatistics(RtpSender* rtp_sender) | 43 explicit LocalRtpSenderStatistics(transport::RtpSender* rtp_sender) |
44 : rtp_sender_(rtp_sender) { | 44 : rtp_sender_(rtp_sender) { |
45 } | 45 } |
46 | 46 |
47 virtual void GetStatistics(const base::TimeTicks& now, | 47 virtual void GetStatistics(const base::TimeTicks& now, |
48 RtcpSenderInfo* sender_info) OVERRIDE { | 48 transport::RtcpSenderInfo* sender_info) OVERRIDE { |
49 rtp_sender_->RtpStatistics(now, sender_info); | 49 rtp_sender_->RtpStatistics(now, sender_info); |
50 } | 50 } |
51 | 51 |
52 private: | 52 private: |
53 RtpSender* rtp_sender_; | 53 transport::RtpSender* rtp_sender_; |
54 }; | 54 }; |
55 | 55 |
56 AudioSender::AudioSender(scoped_refptr<CastEnvironment> cast_environment, | 56 AudioSender::AudioSender( |
57 const AudioSenderConfig& audio_config, | 57 scoped_refptr<CastEnvironment> cast_environment, |
58 PacedPacketSender* const paced_packet_sender) | 58 const AudioSenderConfig& audio_config, |
| 59 transport::PacedPacketSender* const paced_packet_sender) |
59 : cast_environment_(cast_environment), | 60 : cast_environment_(cast_environment), |
60 rtp_sender_(cast_environment, &audio_config, NULL, | 61 rtp_sender_(cast_environment, &audio_config, NULL, |
61 paced_packet_sender), | 62 paced_packet_sender), |
62 rtcp_feedback_(new LocalRtcpAudioSenderFeedback(this)), | 63 rtcp_feedback_(new LocalRtcpAudioSenderFeedback(this)), |
63 rtp_audio_sender_statistics_( | 64 rtp_audio_sender_statistics_( |
64 new LocalRtpSenderStatistics(&rtp_sender_)), | 65 new LocalRtpSenderStatistics(&rtp_sender_)), |
65 rtcp_(cast_environment, | 66 rtcp_(cast_environment, |
66 rtcp_feedback_.get(), | 67 rtcp_feedback_.get(), |
67 paced_packet_sender, | 68 paced_packet_sender, |
68 rtp_audio_sender_statistics_.get(), | 69 rtp_audio_sender_statistics_.get(), |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 void AudioSender::SendRtcpReport() { | 206 void AudioSender::SendRtcpReport() { |
206 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 207 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
207 // We don't send audio logging messages since all captured audio frames will | 208 // We don't send audio logging messages since all captured audio frames will |
208 // be sent. | 209 // be sent. |
209 rtcp_.SendRtcpFromRtpSender(NULL); | 210 rtcp_.SendRtcpFromRtpSender(NULL); |
210 ScheduleNextRtcpReport(); | 211 ScheduleNextRtcpReport(); |
211 } | 212 } |
212 | 213 |
213 } // namespace cast | 214 } // namespace cast |
214 } // namespace media | 215 } // namespace media |
OLD | NEW |