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/rtcp/rtcp.h" | 5 #include "media/cast/rtcp/rtcp.h" |
6 | 6 |
7 #include "base/rand_util.h" | 7 #include "base/rand_util.h" |
8 #include "media/cast/cast_config.h" | 8 #include "media/cast/cast_config.h" |
9 #include "media/cast/cast_defines.h" | 9 #include "media/cast/cast_defines.h" |
10 #include "media/cast/cast_environment.h" | 10 #include "media/cast/cast_environment.h" |
| 11 #include "media/cast/net/rtcp/rtcp_builder.h" |
11 #include "media/cast/rtcp/rtcp_defines.h" | 12 #include "media/cast/rtcp/rtcp_defines.h" |
12 #include "media/cast/rtcp/rtcp_receiver.h" | 13 #include "media/cast/rtcp/rtcp_receiver.h" |
13 #include "media/cast/rtcp/rtcp_sender.h" | 14 #include "media/cast/rtcp/rtcp_sender.h" |
14 #include "media/cast/rtcp/rtcp_utility.h" | 15 #include "media/cast/rtcp/rtcp_utility.h" |
15 #include "net/base/big_endian.h" | 16 #include "net/base/big_endian.h" |
16 | 17 |
17 namespace media { | 18 namespace media { |
18 namespace cast { | 19 namespace cast { |
19 | 20 |
20 static const int kMaxRttMs = 10000; // 10 seconds. | 21 static const int kMaxRttMs = 10000; // 10 seconds. |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 : rtcp_interval_(rtcp_interval), | 183 : rtcp_interval_(rtcp_interval), |
183 rtcp_mode_(rtcp_mode), | 184 rtcp_mode_(rtcp_mode), |
184 local_ssrc_(local_ssrc), | 185 local_ssrc_(local_ssrc), |
185 remote_ssrc_(remote_ssrc), | 186 remote_ssrc_(remote_ssrc), |
186 rtp_sender_statistics_(rtp_sender_statistics), | 187 rtp_sender_statistics_(rtp_sender_statistics), |
187 rtp_receiver_statistics_(rtp_receiver_statistics), | 188 rtp_receiver_statistics_(rtp_receiver_statistics), |
188 receiver_feedback_(new LocalRtcpReceiverFeedback(this, cast_environment)), | 189 receiver_feedback_(new LocalRtcpReceiverFeedback(this, cast_environment)), |
189 rtt_feedback_(new LocalRtcpRttFeedback(this)), | 190 rtt_feedback_(new LocalRtcpRttFeedback(this)), |
190 rtcp_sender_(new RtcpSender(cast_environment, paced_packet_sender, | 191 rtcp_sender_(new RtcpSender(cast_environment, paced_packet_sender, |
191 local_ssrc, c_name)), | 192 local_ssrc, c_name)), |
| 193 rtcp_builder_(new RtcpBuilder(paced_packet_sender, local_ssrc, c_name)), |
192 last_report_received_(0), | 194 last_report_received_(0), |
193 last_received_rtp_timestamp_(0), | 195 last_received_rtp_timestamp_(0), |
194 last_received_ntp_seconds_(0), | 196 last_received_ntp_seconds_(0), |
195 last_received_ntp_fraction_(0), | 197 last_received_ntp_fraction_(0), |
196 min_rtt_(base::TimeDelta::FromMilliseconds(kMaxRttMs)), | 198 min_rtt_(base::TimeDelta::FromMilliseconds(kMaxRttMs)), |
197 number_of_rtt_in_avg_(0), | 199 number_of_rtt_in_avg_(0), |
198 cast_environment_(cast_environment) { | 200 cast_environment_(cast_environment) { |
199 rtcp_receiver_.reset(new RtcpReceiver(cast_environment, | 201 rtcp_receiver_.reset(new RtcpReceiver(cast_environment, |
200 sender_feedback, | 202 sender_feedback, |
201 receiver_feedback_.get(), | 203 receiver_feedback_.get(), |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 uint32 delay_seconds = 0; | 331 uint32 delay_seconds = 0; |
330 uint32 delay_fraction = 0; | 332 uint32 delay_fraction = 0; |
331 base::TimeDelta delta = now - time_last_report_received_; | 333 base::TimeDelta delta = now - time_last_report_received_; |
332 ConvertTimeToFractions(delta.InMicroseconds(), | 334 ConvertTimeToFractions(delta.InMicroseconds(), |
333 &delay_seconds, | 335 &delay_seconds, |
334 &delay_fraction); | 336 &delay_fraction); |
335 | 337 |
336 dlrr.delay_since_last_rr = ConvertToNtpDiff(delay_seconds, delay_fraction); | 338 dlrr.delay_since_last_rr = ConvertToNtpDiff(delay_seconds, delay_fraction); |
337 } | 339 } |
338 | 340 |
339 rtcp_sender_->SendRtcpFromRtpSender(packet_type_flags, | 341 rtcp_builder_->SendRtcpFromRtpSender(packet_type_flags, |
340 &sender_info, | 342 &sender_info, |
341 &dlrr, | 343 &dlrr, |
342 sender_log_message); | 344 sender_log_message); |
343 UpdateNextTimeToSendRtcp(); | 345 UpdateNextTimeToSendRtcp(); |
344 } | 346 } |
345 | 347 |
346 void Rtcp::OnReceivedNtp(uint32 ntp_seconds, uint32 ntp_fraction) { | 348 void Rtcp::OnReceivedNtp(uint32 ntp_seconds, uint32 ntp_fraction) { |
347 last_report_received_ = (ntp_seconds << 16) + (ntp_fraction >> 16); | 349 last_report_received_ = (ntp_seconds << 16) + (ntp_fraction >> 16); |
348 | 350 |
349 base::TimeTicks now = cast_environment_->Clock()->NowTicks(); | 351 base::TimeTicks now = cast_environment_->Clock()->NowTicks(); |
350 time_last_report_received_ = now; | 352 time_last_report_received_ = now; |
351 } | 353 } |
352 | 354 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 int random = base::RandInt(0, 999); | 499 int random = base::RandInt(0, 999); |
498 base::TimeDelta time_to_next = (rtcp_interval_ / 2) + | 500 base::TimeDelta time_to_next = (rtcp_interval_ / 2) + |
499 (rtcp_interval_ * random / 1000); | 501 (rtcp_interval_ * random / 1000); |
500 | 502 |
501 base::TimeTicks now = cast_environment_->Clock()->NowTicks(); | 503 base::TimeTicks now = cast_environment_->Clock()->NowTicks(); |
502 next_time_to_send_rtcp_ = now + time_to_next; | 504 next_time_to_send_rtcp_ = now + time_to_next; |
503 } | 505 } |
504 | 506 |
505 } // namespace cast | 507 } // namespace cast |
506 } // namespace media | 508 } // namespace media |
OLD | NEW |