OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef MEDIA_CAST_NET_RTCP_SENDER_RTCP_SESSION_H_ | 5 #ifndef MEDIA_CAST_NET_RTCP_SENDER_RTCP_SESSION_H_ |
6 #define MEDIA_CAST_NET_RTCP_SENDER_RTCP_SESSION_H_ | 6 #define MEDIA_CAST_NET_RTCP_SENDER_RTCP_SESSION_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <queue> | 9 #include <queue> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/containers/hash_tables.h" | 12 #include "base/containers/hash_tables.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "media/cast/net/cast_transport.h" |
14 #include "media/cast/net/pacing/paced_sender.h" | 15 #include "media/cast/net/pacing/paced_sender.h" |
15 #include "media/cast/net/rtcp/rtcp_defines.h" | 16 #include "media/cast/net/rtcp/rtcp_defines.h" |
16 #include "media/cast/net/rtcp/rtcp_session.h" | 17 #include "media/cast/net/rtcp/rtcp_session.h" |
17 #include "media/cast/net/rtcp/rtcp_utility.h" | 18 #include "media/cast/net/rtcp/rtcp_utility.h" |
18 | 19 |
19 namespace media { | 20 namespace media { |
20 namespace cast { | 21 namespace cast { |
21 | 22 |
22 typedef std::pair<uint32_t, base::TimeTicks> RtcpSendTimePair; | 23 using RtcpSendTimePair = std::pair<uint32_t, base::TimeTicks>; |
23 typedef std::map<uint32_t, base::TimeTicks> RtcpSendTimeMap; | 24 using RtcpSendTimeMap = std::map<uint32_t, base::TimeTicks>; |
24 typedef std::queue<RtcpSendTimePair> RtcpSendTimeQueue; | 25 using RtcpSendTimeQueue = std::queue<RtcpSendTimePair>; |
25 | 26 |
26 // This class represents a RTCP session on a RTP sender. It provides an | 27 // This class represents a RTCP session on a RTP sender. It provides an |
27 // interface to send RTCP sender report (SR). RTCP SR packets allow | 28 // interface to send RTCP sender report (SR). RTCP SR packets allow |
28 // receiver to maintain clock offsets and synchronize between audio and video. | 29 // receiver to maintain clock offsets and synchronize between audio and video. |
29 // | 30 // |
30 // RTCP session on sender handles the following incoming RTCP reports | 31 // RTCP session on sender handles the following incoming RTCP reports |
31 // from receiver: | 32 // from receiver and passes the information to a RtcpObserver: |
32 // - Receiver reference time report: Helps with tracking largest timestamp | 33 // - Receiver reference time report: Helps with tracking largest timestamp |
33 // seen and as a result rejecting old RTCP reports. | 34 // seen and as a result rejecting old RTCP reports. |
34 // - Receiver logs: The sender receives log events from the receiver and | 35 // - Receiver logs: The sender receives log events from the receiver. |
35 // invokes a callback passed. | 36 // - cast message: Receives feedback from receiver on missing packets/frames, |
36 // - cast message: Receives feedback from receiver on missing packets/frames | 37 // later frames received, and last frame id. |
37 // and last frame id received and invokes a callback passed. | |
38 // - Last report: The receiver provides feedback on delay since last report | 38 // - Last report: The receiver provides feedback on delay since last report |
39 // received which helps it compute round trip time and invoke a callback. | 39 // received which helps it compute round trip time. |
| 40 // - PLI: Receiver sends PLI when decoding error exists on ultra-low latency |
| 41 // applications. |
40 class SenderRtcpSession : public RtcpSession { | 42 class SenderRtcpSession : public RtcpSession { |
41 public: | 43 public: |
42 // TODO(xjz): Simplify the interface. http://crbug.com/588275. | 44 SenderRtcpSession(base::TickClock* clock, // Not owned. |
43 SenderRtcpSession(const RtcpCastMessageCallback& cast_callback, | |
44 const RtcpRttCallback& rtt_callback, | |
45 const RtcpLogMessageCallback& log_callback, | |
46 const RtcpPliCallback pli_callback, | |
47 base::TickClock* clock, // Not owned. | |
48 PacedPacketSender* packet_sender, // Not owned. | 45 PacedPacketSender* packet_sender, // Not owned. |
| 46 RtcpObserver* observer, // Not owned. |
49 uint32_t local_ssrc, | 47 uint32_t local_ssrc, |
50 uint32_t remote_ssrc); | 48 uint32_t remote_ssrc); |
51 | 49 |
52 ~SenderRtcpSession() override; | 50 ~SenderRtcpSession() override; |
53 | 51 |
54 // If greater than zero, this is the last measured network round trip time. | 52 // If greater than zero, this is the last measured network round trip time. |
55 base::TimeDelta current_round_trip_time() const { | 53 base::TimeDelta current_round_trip_time() const { |
56 return current_round_trip_time_; | 54 return current_round_trip_time_; |
57 } | 55 } |
58 | 56 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // Save last sent NTP time on RTPC SR. This helps map the sent time when a | 95 // Save last sent NTP time on RTPC SR. This helps map the sent time when a |
98 // last report is received from RTP receiver to compute RTT. | 96 // last report is received from RTP receiver to compute RTT. |
99 void SaveLastSentNtpTime(const base::TimeTicks& now, | 97 void SaveLastSentNtpTime(const base::TimeTicks& now, |
100 uint32_t last_ntp_seconds, | 98 uint32_t last_ntp_seconds, |
101 uint32_t last_ntp_fraction); | 99 uint32_t last_ntp_fraction); |
102 | 100 |
103 base::TickClock* const clock_; // Not owned. | 101 base::TickClock* const clock_; // Not owned. |
104 PacedPacketSender* packet_sender_; // Not owned. | 102 PacedPacketSender* packet_sender_; // Not owned. |
105 const uint32_t local_ssrc_; | 103 const uint32_t local_ssrc_; |
106 const uint32_t remote_ssrc_; | 104 const uint32_t remote_ssrc_; |
107 | 105 RtcpObserver* const rtcp_observer_; // Owned by |CastTransportImpl|. |
108 const RtcpCastMessageCallback cast_callback_; | |
109 const RtcpRttCallback rtt_callback_; | |
110 const RtcpLogMessageCallback log_callback_; | |
111 const RtcpPliCallback pli_callback_; | |
112 | 106 |
113 // Computed from RTCP RRTR report. | 107 // Computed from RTCP RRTR report. |
114 base::TimeTicks largest_seen_timestamp_; | 108 base::TimeTicks largest_seen_timestamp_; |
115 | 109 |
116 // The RTCP packet parser is re-used when parsing each RTCP packet. It | 110 // The RTCP packet parser is re-used when parsing each RTCP packet. It |
117 // remembers state about prior RTP timestamps and other sequence values to | 111 // remembers state about prior RTP timestamps and other sequence values to |
118 // re-construct "expanded" values. | 112 // re-construct "expanded" values. |
119 RtcpParser parser_; | 113 RtcpParser parser_; |
120 | 114 |
121 // Maintains a history of receiver events. | 115 // Maintains a history of receiver events. |
(...skipping 11 matching lines...) Expand all Loading... |
133 RtcpSendTimeMap last_reports_sent_map_; | 127 RtcpSendTimeMap last_reports_sent_map_; |
134 RtcpSendTimeQueue last_reports_sent_queue_; | 128 RtcpSendTimeQueue last_reports_sent_queue_; |
135 | 129 |
136 DISALLOW_COPY_AND_ASSIGN(SenderRtcpSession); | 130 DISALLOW_COPY_AND_ASSIGN(SenderRtcpSession); |
137 }; | 131 }; |
138 | 132 |
139 } // namespace cast | 133 } // namespace cast |
140 } // namespace media | 134 } // namespace media |
141 | 135 |
142 #endif // MEDIA_CAST_NET_RTCP_SENDER_RTCP_SESSION_H_ | 136 #endif // MEDIA_CAST_NET_RTCP_SENDER_RTCP_SESSION_H_ |
OLD | NEW |