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 "media/cast/audio_sender/audio_encoder.h" | 10 #include "media/cast/audio_sender/audio_encoder.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 rtp_sender_->RtpStatistics(now, sender_info); | 46 rtp_sender_->RtpStatistics(now, sender_info); |
47 } | 47 } |
48 | 48 |
49 private: | 49 private: |
50 RtpSender* rtp_sender_; | 50 RtpSender* rtp_sender_; |
51 }; | 51 }; |
52 | 52 |
53 AudioSender::AudioSender(scoped_refptr<CastEnvironment> cast_environment, | 53 AudioSender::AudioSender(scoped_refptr<CastEnvironment> cast_environment, |
54 const AudioSenderConfig& audio_config, | 54 const AudioSenderConfig& audio_config, |
55 PacedPacketSender* const paced_packet_sender) | 55 PacedPacketSender* const paced_packet_sender) |
56 : incoming_feedback_ssrc_(audio_config.incoming_feedback_ssrc), | 56 : cast_environment_(cast_environment), |
57 cast_environment_(cast_environment), | |
58 rtp_sender_(cast_environment->Clock(), &audio_config, NULL, | 57 rtp_sender_(cast_environment->Clock(), &audio_config, NULL, |
59 paced_packet_sender), | 58 paced_packet_sender), |
60 rtcp_feedback_(new LocalRtcpAudioSenderFeedback(this)), | 59 rtcp_feedback_(new LocalRtcpAudioSenderFeedback(this)), |
61 rtp_audio_sender_statistics_( | 60 rtp_audio_sender_statistics_( |
62 new LocalRtpSenderStatistics(&rtp_sender_)), | 61 new LocalRtpSenderStatistics(&rtp_sender_)), |
63 rtcp_(cast_environment->Clock(), | 62 rtcp_(cast_environment->Clock(), |
64 rtcp_feedback_.get(), | 63 rtcp_feedback_.get(), |
65 paced_packet_sender, | 64 paced_packet_sender, |
66 rtp_audio_sender_statistics_.get(), | 65 rtp_audio_sender_statistics_.get(), |
67 NULL, | 66 NULL, |
68 audio_config.rtcp_mode, | 67 audio_config.rtcp_mode, |
69 base::TimeDelta::FromMilliseconds(audio_config.rtcp_interval), | 68 base::TimeDelta::FromMilliseconds(audio_config.rtcp_interval), |
70 true, | |
71 audio_config.sender_ssrc, | 69 audio_config.sender_ssrc, |
| 70 audio_config.incoming_feedback_ssrc, |
72 audio_config.rtcp_c_name), | 71 audio_config.rtcp_c_name), |
73 initialized_(false), | 72 initialized_(false), |
74 weak_factory_(this) { | 73 weak_factory_(this) { |
75 rtcp_.SetRemoteSSRC(audio_config.incoming_feedback_ssrc); | |
76 | |
77 if (!audio_config.use_external_encoder) { | 74 if (!audio_config.use_external_encoder) { |
78 audio_encoder_ = new AudioEncoder( | 75 audio_encoder_ = new AudioEncoder( |
79 cast_environment, audio_config, | 76 cast_environment, audio_config, |
80 base::Bind(&AudioSender::SendEncodedAudioFrame, | 77 base::Bind(&AudioSender::SendEncodedAudioFrame, |
81 weak_factory_.GetWeakPtr())); | 78 weak_factory_.GetWeakPtr())); |
82 } | 79 } |
83 } | 80 } |
84 | 81 |
85 AudioSender::~AudioSender() {} | 82 AudioSender::~AudioSender() {} |
86 | 83 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 time_to_next = std::max(time_to_next, | 135 time_to_next = std::max(time_to_next, |
139 base::TimeDelta::FromMilliseconds(kMinSchedulingDelayMs)); | 136 base::TimeDelta::FromMilliseconds(kMinSchedulingDelayMs)); |
140 | 137 |
141 cast_environment_->PostDelayedTask(CastEnvironment::MAIN, FROM_HERE, | 138 cast_environment_->PostDelayedTask(CastEnvironment::MAIN, FROM_HERE, |
142 base::Bind(&AudioSender::SendRtcpReport, weak_factory_.GetWeakPtr()), | 139 base::Bind(&AudioSender::SendRtcpReport, weak_factory_.GetWeakPtr()), |
143 time_to_next); | 140 time_to_next); |
144 } | 141 } |
145 | 142 |
146 void AudioSender::SendRtcpReport() { | 143 void AudioSender::SendRtcpReport() { |
147 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 144 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
148 rtcp_.SendRtcpReport(incoming_feedback_ssrc_); | 145 rtcp_.SendRtcpFromRtpSender(NULL); // TODO(pwestin): add logging. |
149 ScheduleNextRtcpReport(); | 146 ScheduleNextRtcpReport(); |
150 } | 147 } |
151 | 148 |
152 } // namespace cast | 149 } // namespace cast |
153 } // namespace media | 150 } // namespace media |
OLD | NEW |