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 the Client: |
miu
2016/04/25 23:23:54
s/the Client/a SenderRtcpObserver/
xjz
2016/04/29 19:15:49
Done.
| |
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(std::unique_ptr<SenderRtcpObserver> observer, |
miu
2016/04/25 23:23:54
The object ownership graph is a bit weird around t
xjz
2016/04/29 19:15:49
Done.
| |
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. | 45 base::TickClock* clock, // Not owned. |
48 PacedPacketSender* packet_sender, // Not owned. | 46 PacedPacketSender* packet_sender, // 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_; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 // Save last sent NTP time on RTPC SR. This helps map the sent time when a | 89 // Save last sent NTP time on RTPC SR. This helps map the sent time when a |
92 // last report is received from RTP receiver to compute RTT. | 90 // last report is received from RTP receiver to compute RTT. |
93 void SaveLastSentNtpTime(const base::TimeTicks& now, | 91 void SaveLastSentNtpTime(const base::TimeTicks& now, |
94 uint32_t last_ntp_seconds, | 92 uint32_t last_ntp_seconds, |
95 uint32_t last_ntp_fraction); | 93 uint32_t last_ntp_fraction); |
96 | 94 |
97 base::TickClock* const clock_; // Not owned. | 95 base::TickClock* const clock_; // Not owned. |
98 PacedPacketSender* packet_sender_; // Not owned. | 96 PacedPacketSender* packet_sender_; // Not owned. |
99 const uint32_t local_ssrc_; | 97 const uint32_t local_ssrc_; |
100 const uint32_t remote_ssrc_; | 98 const uint32_t remote_ssrc_; |
101 | 99 const std::unique_ptr<SenderRtcpObserver> sender_rtcp_observer_; |
102 const RtcpCastMessageCallback cast_callback_; | |
103 const RtcpRttCallback rtt_callback_; | |
104 const RtcpLogMessageCallback log_callback_; | |
105 const RtcpPliCallback pli_callback_; | |
106 | 100 |
107 // Computed from RTCP RRTR report. | 101 // Computed from RTCP RRTR report. |
108 base::TimeTicks largest_seen_timestamp_; | 102 base::TimeTicks largest_seen_timestamp_; |
109 | 103 |
110 // The RTCP packet parser is re-used when parsing each RTCP packet. It | 104 // The RTCP packet parser is re-used when parsing each RTCP packet. It |
111 // remembers state about prior RTP timestamps and other sequence values to | 105 // remembers state about prior RTP timestamps and other sequence values to |
112 // re-construct "expanded" values. | 106 // re-construct "expanded" values. |
113 RtcpParser parser_; | 107 RtcpParser parser_; |
114 | 108 |
115 // For extending received ACK frame IDs from 8-bit to 32-bit. | 109 // For extending received ACK frame IDs from 8-bit to 32-bit. |
(...skipping 14 matching lines...) Expand all Loading... | |
130 RtcpSendTimeMap last_reports_sent_map_; | 124 RtcpSendTimeMap last_reports_sent_map_; |
131 RtcpSendTimeQueue last_reports_sent_queue_; | 125 RtcpSendTimeQueue last_reports_sent_queue_; |
132 | 126 |
133 DISALLOW_COPY_AND_ASSIGN(SenderRtcpSession); | 127 DISALLOW_COPY_AND_ASSIGN(SenderRtcpSession); |
134 }; | 128 }; |
135 | 129 |
136 } // namespace cast | 130 } // namespace cast |
137 } // namespace media | 131 } // namespace media |
138 | 132 |
139 #endif // MEDIA_CAST_NET_RTCP_SENDER_RTCP_SESSION_H_ | 133 #endif // MEDIA_CAST_NET_RTCP_SENDER_RTCP_SESSION_H_ |
OLD | NEW |