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/video_sender/video_sender.h" | 5 #include "media/cast/video_sender/video_sender.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 transport::CastTransportSender* const transport_sender) | 48 transport::CastTransportSender* const transport_sender) |
49 : transport_sender_(transport_sender), sender_info_(), rtp_timestamp_(0) { | 49 : transport_sender_(transport_sender), sender_info_(), rtp_timestamp_(0) { |
50 transport_sender_->SubscribeVideoRtpStatsCallback( | 50 transport_sender_->SubscribeVideoRtpStatsCallback( |
51 base::Bind(&LocalRtpVideoSenderStatistics::StoreStatistics, | 51 base::Bind(&LocalRtpVideoSenderStatistics::StoreStatistics, |
52 base::Unretained(this))); | 52 base::Unretained(this))); |
53 } | 53 } |
54 | 54 |
55 virtual void GetStatistics(const base::TimeTicks& now, | 55 virtual void GetStatistics(const base::TimeTicks& now, |
56 transport::RtcpSenderInfo* sender_info) OVERRIDE { | 56 transport::RtcpSenderInfo* sender_info) OVERRIDE { |
57 // Update RTP timestamp and return last stored statistics. | 57 // Update RTP timestamp and return last stored statistics. |
58 if (rtp_timestamp_) { | 58 uint32 ntp_seconds = 0; |
| 59 uint32 ntp_fraction = 0; |
| 60 uint32 rtp_timestamp = 0; |
| 61 if (rtp_timestamp_ > 0) { |
59 base::TimeDelta time_since_last_send = now - time_sent_; | 62 base::TimeDelta time_since_last_send = now - time_sent_; |
60 sender_info_.rtp_timestamp = | 63 rtp_timestamp = rtp_timestamp_ + time_since_last_send.InMilliseconds() * |
61 rtp_timestamp_ + | 64 (kVideoFrequency / 1000); |
62 time_since_last_send.InMilliseconds() * (kVideoFrequency / 1000); | 65 // Update NTP time to current time. |
63 } else { | 66 ConvertTimeTicksToNtp(now, &ntp_seconds, &ntp_fraction); |
64 sender_info_.rtp_timestamp = 0; | |
65 } | 67 } |
66 memcpy(sender_info, &sender_info_, sizeof(transport::RtcpSenderInfo)); | 68 // Populate sender info. |
| 69 sender_info->rtp_timestamp = rtp_timestamp; |
| 70 sender_info->ntp_seconds = ntp_seconds; |
| 71 sender_info->ntp_fraction = ntp_fraction; |
| 72 sender_info->send_packet_count = sender_info_.send_packet_count; |
| 73 sender_info->send_octet_count = sender_info_.send_octet_count; |
67 } | 74 } |
68 | 75 |
69 void StoreStatistics(transport::RtcpSenderInfo& sender_info, | 76 void StoreStatistics(transport::RtcpSenderInfo& sender_info, |
70 base::TimeTicks time_sent, | 77 base::TimeTicks time_sent, |
71 uint32 rtp_timestamp) { | 78 uint32 rtp_timestamp) { |
72 sender_info_ = sender_info; | 79 sender_info_ = sender_info; |
73 time_sent_ = time_sent; | 80 time_sent_ = time_sent; |
74 rtp_timestamp_ = rtp_timestamp; | 81 rtp_timestamp_ = rtp_timestamp; |
75 } | 82 } |
76 | 83 |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 | 483 |
477 void VideoSender::ResendPacketsOnTransportThread( | 484 void VideoSender::ResendPacketsOnTransportThread( |
478 const transport::MissingFramesAndPacketsMap& missing_packets) { | 485 const transport::MissingFramesAndPacketsMap& missing_packets) { |
479 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::TRANSPORT)); | 486 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::TRANSPORT)); |
480 last_send_time_ = cast_environment_->Clock()->NowTicks(); | 487 last_send_time_ = cast_environment_->Clock()->NowTicks(); |
481 transport_sender_->ResendPackets(false, missing_packets); | 488 transport_sender_->ResendPackets(false, missing_packets); |
482 } | 489 } |
483 | 490 |
484 } // namespace cast | 491 } // namespace cast |
485 } // namespace media | 492 } // namespace media |
OLD | NEW |