Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: media/cast/rtcp/rtcp.cc

Issue 69603002: Incorporating logging into Cast (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clean up Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/rand_util.h" 8 #include "base/rand_util.h"
9 #include "media/cast/cast_config.h" 9 #include "media/cast/cast_config.h"
10 #include "media/cast/cast_defines.h" 10 #include "media/cast/cast_defines.h"
11 #include "media/cast/cast_environment.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 = 1000000; // 1000 seconds. 21 static const int kMaxRttMs = 1000000; // 1000 seconds.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 78 }
78 79
79 virtual void OnReceivedSendReportRequest() OVERRIDE { 80 virtual void OnReceivedSendReportRequest() OVERRIDE {
80 rtcp_->OnReceivedSendReportRequest(); 81 rtcp_->OnReceivedSendReportRequest();
81 } 82 }
82 83
83 private: 84 private:
84 Rtcp* rtcp_; 85 Rtcp* rtcp_;
85 }; 86 };
86 87
87 Rtcp::Rtcp(base::TickClock* clock, 88 Rtcp::Rtcp(scoped_refptr<CastEnvironment> cast_environment,
88 RtcpSenderFeedback* sender_feedback, 89 RtcpSenderFeedback* sender_feedback,
89 PacedPacketSender* paced_packet_sender, 90 PacedPacketSender* paced_packet_sender,
90 RtpSenderStatistics* rtp_sender_statistics, 91 RtpSenderStatistics* rtp_sender_statistics,
91 RtpReceiverStatistics* rtp_receiver_statistics, 92 RtpReceiverStatistics* rtp_receiver_statistics,
92 RtcpMode rtcp_mode, 93 RtcpMode rtcp_mode,
93 const base::TimeDelta& rtcp_interval, 94 const base::TimeDelta& rtcp_interval,
94 bool sending_media, 95 bool sending_media,
95 uint32 local_ssrc, 96 uint32 local_ssrc,
96 const std::string& c_name) 97 const std::string& c_name)
97 : rtcp_interval_(rtcp_interval), 98 : rtcp_interval_(rtcp_interval),
98 rtcp_mode_(rtcp_mode), 99 rtcp_mode_(rtcp_mode),
99 sending_media_(sending_media), 100 sending_media_(sending_media),
100 local_ssrc_(local_ssrc), 101 local_ssrc_(local_ssrc),
101 rtp_sender_statistics_(rtp_sender_statistics), 102 rtp_sender_statistics_(rtp_sender_statistics),
102 rtp_receiver_statistics_(rtp_receiver_statistics), 103 rtp_receiver_statistics_(rtp_receiver_statistics),
103 receiver_feedback_(new LocalRtcpReceiverFeedback(this)), 104 receiver_feedback_(new LocalRtcpReceiverFeedback(this)),
104 rtt_feedback_(new LocalRtcpRttFeedback(this)), 105 rtt_feedback_(new LocalRtcpRttFeedback(this)),
105 rtcp_sender_(new RtcpSender(paced_packet_sender, local_ssrc, c_name)), 106 rtcp_sender_(new RtcpSender(paced_packet_sender, local_ssrc, c_name)),
106 last_report_sent_(0), 107 last_report_sent_(0),
107 last_report_received_(0), 108 last_report_received_(0),
108 last_received_rtp_timestamp_(0), 109 last_received_rtp_timestamp_(0),
109 last_received_ntp_seconds_(0), 110 last_received_ntp_seconds_(0),
110 last_received_ntp_fraction_(0), 111 last_received_ntp_fraction_(0),
111 min_rtt_(base::TimeDelta::FromMilliseconds(kMaxRttMs)), 112 min_rtt_(base::TimeDelta::FromMilliseconds(kMaxRttMs)),
112 number_of_rtt_in_avg_(0), 113 number_of_rtt_in_avg_(0),
113 clock_(clock) { 114 clock_(cast_environment->Clock()),
Alpha Left Google 2013/11/14 00:29:24 You're removing clock from the constructor paramet
mikhal 2013/11/14 17:42:31 removed On 2013/11/14 00:29:24, Alpha wrote:
115 cast_environment_(cast_environment) {
114 rtcp_receiver_.reset(new RtcpReceiver(sender_feedback, 116 rtcp_receiver_.reset(new RtcpReceiver(sender_feedback,
115 receiver_feedback_.get(), 117 receiver_feedback_.get(),
116 rtt_feedback_.get(), 118 rtt_feedback_.get(),
117 local_ssrc)); 119 local_ssrc));
118 } 120 }
119 121
120 Rtcp::~Rtcp() {} 122 Rtcp::~Rtcp() {}
121 123
122 // static 124 // static
123 bool Rtcp::IsRtcpPacket(const uint8* packet, size_t length) { 125 bool Rtcp::IsRtcpPacket(const uint8* packet, size_t length) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 170
169 if (rtcp_mode_ == kRtcpCompound || now >= next_time_to_send_rtcp_) { 171 if (rtcp_mode_ == kRtcpCompound || now >= next_time_to_send_rtcp_) {
170 if (sending_media_) { 172 if (sending_media_) {
171 packet_type_flags = RtcpSender::kRtcpSr; 173 packet_type_flags = RtcpSender::kRtcpSr;
172 } else { 174 } else {
173 packet_type_flags = RtcpSender::kRtcpRr; 175 packet_type_flags = RtcpSender::kRtcpRr;
174 } 176 }
175 } 177 }
176 packet_type_flags |= RtcpSender::kRtcpCast; 178 packet_type_flags |= RtcpSender::kRtcpCast;
177 179
180 cast_environment_->Logging()->InsertGenericEvent(kAckSent,
181 cast_message.ack_frame_id_);
182
178 SendRtcp(now, packet_type_flags, 0, &cast_message); 183 SendRtcp(now, packet_type_flags, 0, &cast_message);
179 } 184 }
180 185
181 void Rtcp::SendRtcpPli(uint32 pli_remote_ssrc) { 186 void Rtcp::SendRtcpPli(uint32 pli_remote_ssrc) {
182 uint32 packet_type_flags = 0; 187 uint32 packet_type_flags = 0;
183 base::TimeTicks now = clock_->NowTicks(); 188 base::TimeTicks now = clock_->NowTicks();
184 189
185 if (rtcp_mode_ == kRtcpCompound || now >= next_time_to_send_rtcp_) { 190 if (rtcp_mode_ == kRtcpCompound || now >= next_time_to_send_rtcp_) {
186 if (sending_media_) { 191 if (sending_media_) {
187 packet_type_flags = RtcpSender::kRtcpSr; 192 packet_type_flags = RtcpSender::kRtcpSr;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 } else { 253 } else {
249 RtcpReportBlock report_block; 254 RtcpReportBlock report_block;
250 report_block.remote_ssrc = 0; // Not needed to set send side. 255 report_block.remote_ssrc = 0; // Not needed to set send side.
251 report_block.media_ssrc = media_ssrc; // SSRC of the RTP packet sender. 256 report_block.media_ssrc = media_ssrc; // SSRC of the RTP packet sender.
252 if (rtp_receiver_statistics_) { 257 if (rtp_receiver_statistics_) {
253 rtp_receiver_statistics_->GetStatistics( 258 rtp_receiver_statistics_->GetStatistics(
254 &report_block.fraction_lost, 259 &report_block.fraction_lost,
255 &report_block.cumulative_lost, 260 &report_block.cumulative_lost,
256 &report_block.extended_high_sequence_number, 261 &report_block.extended_high_sequence_number,
257 &report_block.jitter); 262 &report_block.jitter);
263 cast_environment_->Logging()->InsertGenericEvent(kJitterMs,
Alpha Left Google 2013/11/14 00:29:24 nit: indent by 2 spaces.
mikhal 2013/11/14 17:42:31 Done.
264 report_block.jitter);
265 cast_environment_->Logging()->InsertGenericEvent(kPacketLoss,
Alpha Left Google 2013/11/14 00:29:24 nit: indent by 2 spaces.
mikhal 2013/11/14 17:42:31 Done.
266 report_block.fraction_lost);
267
258 } 268 }
259 269
260 report_block.last_sr = last_report_received_; 270 report_block.last_sr = last_report_received_;
261 if (!time_last_report_received_.is_null()) { 271 if (!time_last_report_received_.is_null()) {
262 uint32 delay_seconds = 0; 272 uint32 delay_seconds = 0;
263 uint32 delay_fraction = 0; 273 uint32 delay_fraction = 0;
264 base::TimeDelta delta = now - time_last_report_received_; 274 base::TimeDelta delta = now - time_last_report_received_;
265 ConvertTimeToFractions(delta.InMicroseconds(), 275 ConvertTimeToFractions(delta.InMicroseconds(),
266 &delay_seconds, 276 &delay_seconds,
267 &delay_fraction); 277 &delay_fraction);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 382
373 bool Rtcp::Rtt(base::TimeDelta* rtt, 383 bool Rtcp::Rtt(base::TimeDelta* rtt,
374 base::TimeDelta* avg_rtt, 384 base::TimeDelta* avg_rtt,
375 base::TimeDelta* min_rtt, 385 base::TimeDelta* min_rtt,
376 base::TimeDelta* max_rtt) const { 386 base::TimeDelta* max_rtt) const {
377 DCHECK(rtt) << "Invalid argument"; 387 DCHECK(rtt) << "Invalid argument";
378 DCHECK(avg_rtt) << "Invalid argument"; 388 DCHECK(avg_rtt) << "Invalid argument";
379 DCHECK(min_rtt) << "Invalid argument"; 389 DCHECK(min_rtt) << "Invalid argument";
380 DCHECK(max_rtt) << "Invalid argument"; 390 DCHECK(max_rtt) << "Invalid argument";
381 391
382 if (number_of_rtt_in_avg_ == 0) return false; 392 if (number_of_rtt_in_avg_ == 0) return false;
393 cast_environment_->Logging()->InsertGenericEvent(kRttMs,
394 rtt->InMilliseconds());
383 395
384 *rtt = rtt_; 396 *rtt = rtt_;
385 *avg_rtt = base::TimeDelta::FromMilliseconds(avg_rtt_ms_); 397 *avg_rtt = base::TimeDelta::FromMilliseconds(avg_rtt_ms_);
386 *min_rtt = min_rtt_; 398 *min_rtt = min_rtt_;
387 *max_rtt = max_rtt_; 399 *max_rtt = max_rtt_;
388 return true; 400 return true;
389 } 401 }
390 402
391 int Rtcp::CheckForWrapAround(uint32 new_timestamp, 403 int Rtcp::CheckForWrapAround(uint32 new_timestamp,
392 uint32 old_timestamp) const { 404 uint32 old_timestamp) const {
(...skipping 16 matching lines...) Expand all
409 int random = base::RandInt(0, 999); 421 int random = base::RandInt(0, 999);
410 base::TimeDelta time_to_next = (rtcp_interval_ / 2) + 422 base::TimeDelta time_to_next = (rtcp_interval_ / 2) +
411 (rtcp_interval_ * random / 1000); 423 (rtcp_interval_ * random / 1000);
412 424
413 base::TimeTicks now = clock_->NowTicks(); 425 base::TimeTicks now = clock_->NowTicks();
414 next_time_to_send_rtcp_ = now + time_to_next; 426 next_time_to_send_rtcp_ = now + time_to_next;
415 } 427 }
416 428
417 } // namespace cast 429 } // namespace cast
418 } // namespace media 430 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698