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 #ifndef MEDIA_CAST_RTCP_RTCP_H_ | 5 #ifndef MEDIA_CAST_RTCP_RTCP_H_ |
6 #define MEDIA_CAST_RTCP_RTCP_H_ | 6 #define MEDIA_CAST_RTCP_RTCP_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <queue> | 10 #include <queue> |
11 #include <set> | 11 #include <set> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/time/tick_clock.h" | 16 #include "base/time/tick_clock.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
18 #include "media/cast/cast_config.h" | 18 #include "media/cast/cast_config.h" |
19 #include "media/cast/cast_defines.h" | 19 #include "media/cast/cast_defines.h" |
20 #include "media/cast/cast_environment.h" | 20 #include "media/cast/cast_environment.h" |
21 #include "media/cast/rtcp/rtcp_defines.h" | 21 #include "media/cast/rtcp/rtcp_defines.h" |
| 22 #include "media/cast/transport/cast_transport_defines.h" |
| 23 #include "media/cast/transport/pacing/paced_sender.h" |
| 24 #include "media/cast/transport/rtcp/rtcp_builder.h" |
22 | 25 |
23 namespace media { | 26 namespace media { |
24 namespace cast { | 27 namespace cast { |
25 | 28 |
26 class LocalRtcpReceiverFeedback; | 29 class LocalRtcpReceiverFeedback; |
27 class LocalRtcpRttFeedback; | 30 class LocalRtcpRttFeedback; |
28 class RtcpBuilder; | |
29 class PacedPacketSender; | 31 class PacedPacketSender; |
30 class RtcpReceiver; | 32 class RtcpReceiver; |
31 class RtcpSender; | 33 class RtcpSender; |
32 | 34 |
33 typedef std::pair<uint32, base::TimeTicks> RtcpSendTimePair; | 35 typedef std::pair<uint32, base::TimeTicks> RtcpSendTimePair; |
34 typedef std::map<uint32, base::TimeTicks> RtcpSendTimeMap; | 36 typedef std::map<uint32, base::TimeTicks> RtcpSendTimeMap; |
35 typedef std::queue<RtcpSendTimePair> RtcpSendTimeQueue; | 37 typedef std::queue<RtcpSendTimePair> RtcpSendTimeQueue; |
36 | 38 |
37 class RtcpSenderFeedback { | 39 class RtcpSenderFeedback { |
38 public: | 40 public: |
39 virtual void OnReceivedCastFeedback(const RtcpCastMessage& cast_feedback) = 0; | 41 virtual void OnReceivedCastFeedback(const RtcpCastMessage& cast_feedback) = 0; |
40 | 42 |
41 virtual ~RtcpSenderFeedback() {} | 43 virtual ~RtcpSenderFeedback() {} |
42 }; | 44 }; |
43 | 45 |
44 class RtpSenderStatistics { | 46 class RtpSenderStatistics { |
45 public: | 47 public: |
46 virtual void GetStatistics(const base::TimeTicks& now, | 48 virtual void GetStatistics(const base::TimeTicks& now, |
47 RtcpSenderInfo* sender_info) = 0; | 49 transport::RtcpSenderInfo* sender_info) = 0; |
48 | 50 |
49 virtual ~RtpSenderStatistics() {} | 51 virtual ~RtpSenderStatistics() {} |
50 }; | 52 }; |
51 | 53 |
52 class RtpReceiverStatistics { | 54 class RtpReceiverStatistics { |
53 public: | 55 public: |
54 virtual void GetStatistics(uint8* fraction_lost, | 56 virtual void GetStatistics(uint8* fraction_lost, |
55 uint32* cumulative_lost, // 24 bits valid. | 57 uint32* cumulative_lost, // 24 bits valid. |
56 uint32* extended_high_sequence_number, | 58 uint32* extended_high_sequence_number, |
57 uint32* jitter) = 0; | 59 uint32* jitter) = 0; |
58 | 60 |
59 virtual ~RtpReceiverStatistics() {} | 61 virtual ~RtpReceiverStatistics() {} |
60 }; | 62 }; |
61 | 63 |
62 class Rtcp { | 64 class Rtcp { |
63 public: | 65 public: |
64 Rtcp(scoped_refptr<CastEnvironment> cast_environment, | 66 Rtcp(scoped_refptr<CastEnvironment> cast_environment, |
65 RtcpSenderFeedback* sender_feedback, | 67 RtcpSenderFeedback* sender_feedback, |
66 PacedPacketSender* paced_packet_sender, | 68 transport::PacedPacketSender* paced_packet_sender, |
67 RtpSenderStatistics* rtp_sender_statistics, | 69 RtpSenderStatistics* rtp_sender_statistics, |
68 RtpReceiverStatistics* rtp_receiver_statistics, | 70 RtpReceiverStatistics* rtp_receiver_statistics, |
69 RtcpMode rtcp_mode, | 71 RtcpMode rtcp_mode, |
70 const base::TimeDelta& rtcp_interval, | 72 const base::TimeDelta& rtcp_interval, |
71 uint32 local_ssrc, | 73 uint32 local_ssrc, |
72 uint32 remote_ssrc, | 74 uint32 remote_ssrc, |
73 const std::string& c_name); | 75 const std::string& c_name); |
74 | 76 |
75 virtual ~Rtcp(); | 77 virtual ~Rtcp(); |
76 | 78 |
77 static bool IsRtcpPacket(const uint8* rtcp_buffer, size_t length); | 79 static bool IsRtcpPacket(const uint8* rtcp_buffer, size_t length); |
78 | 80 |
79 static uint32 GetSsrcOfSender(const uint8* rtcp_buffer, size_t length); | 81 static uint32 GetSsrcOfSender(const uint8* rtcp_buffer, size_t length); |
80 | 82 |
81 base::TimeTicks TimeToSendNextRtcpReport(); | 83 base::TimeTicks TimeToSendNextRtcpReport(); |
82 // |sender_log_message| is optional; without it no log messages will be | 84 // |sender_log_message| is optional; without it no log messages will be |
83 // attached to the RTCP report; instead a normal RTCP send report will be | 85 // attached to the RTCP report; instead a normal RTCP send report will be |
84 // sent. | 86 // sent. |
85 // Additionally if all messages in |sender_log_message| does | 87 // Additionally if all messages in |sender_log_message| does |
86 // not fit in the packet the |sender_log_message| will contain the remaining | 88 // not fit in the packet the |sender_log_message| will contain the remaining |
87 // unsent messages. | 89 // unsent messages. |
88 void SendRtcpFromRtpSender(RtcpSenderLogMessage* sender_log_message); | 90 void SendRtcpFromRtpSender( |
| 91 transport::RtcpSenderLogMessage* sender_log_message); |
89 | 92 |
90 // |cast_message| and |receiver_log| is optional; if |cast_message| is | 93 // |cast_message| and |receiver_log| is optional; if |cast_message| is |
91 // provided the RTCP receiver report will append a Cast message containing | 94 // provided the RTCP receiver report will append a Cast message containing |
92 // Acks and Nacks; if |receiver_log| is provided the RTCP receiver report will | 95 // Acks and Nacks; if |receiver_log| is provided the RTCP receiver report will |
93 // append the log messages. If no argument is set a normal RTCP receiver | 96 // append the log messages. If no argument is set a normal RTCP receiver |
94 // report will be sent. Additionally if all messages in |receiver_log| does | 97 // report will be sent. Additionally if all messages in |receiver_log| does |
95 // not fit in the packet the |receiver_log| will contain the remaining unsent | 98 // not fit in the packet the |receiver_log| will contain the remaining unsent |
96 // messages. | 99 // messages. |
97 void SendRtcpFromRtpReceiver(const RtcpCastMessage* cast_message, | 100 void SendRtcpFromRtpReceiver(const RtcpCastMessage* cast_message, |
98 RtcpReceiverLogMessage* receiver_log); | 101 RtcpReceiverLogMessage* receiver_log); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 const uint32 local_ssrc_; | 146 const uint32 local_ssrc_; |
144 const uint32 remote_ssrc_; | 147 const uint32 remote_ssrc_; |
145 | 148 |
146 // Not owned by this class. | 149 // Not owned by this class. |
147 RtpSenderStatistics* const rtp_sender_statistics_; | 150 RtpSenderStatistics* const rtp_sender_statistics_; |
148 RtpReceiverStatistics* const rtp_receiver_statistics_; | 151 RtpReceiverStatistics* const rtp_receiver_statistics_; |
149 | 152 |
150 scoped_ptr<LocalRtcpRttFeedback> rtt_feedback_; | 153 scoped_ptr<LocalRtcpRttFeedback> rtt_feedback_; |
151 scoped_ptr<LocalRtcpReceiverFeedback> receiver_feedback_; | 154 scoped_ptr<LocalRtcpReceiverFeedback> receiver_feedback_; |
152 scoped_ptr<RtcpSender> rtcp_sender_; | 155 scoped_ptr<RtcpSender> rtcp_sender_; |
153 scoped_ptr<RtcpBuilder> rtcp_builder_; | 156 scoped_ptr<transport::RtcpBuilder> rtcp_builder_; |
154 scoped_ptr<RtcpReceiver> rtcp_receiver_; | 157 scoped_ptr<RtcpReceiver> rtcp_receiver_; |
155 | 158 |
156 base::TimeTicks next_time_to_send_rtcp_; | 159 base::TimeTicks next_time_to_send_rtcp_; |
157 RtcpSendTimeMap last_reports_sent_map_; | 160 RtcpSendTimeMap last_reports_sent_map_; |
158 RtcpSendTimeQueue last_reports_sent_queue_; | 161 RtcpSendTimeQueue last_reports_sent_queue_; |
159 base::TimeTicks time_last_report_received_; | 162 base::TimeTicks time_last_report_received_; |
160 uint32 last_report_received_; | 163 uint32 last_report_received_; |
161 | 164 |
162 uint32 last_received_rtp_timestamp_; | 165 uint32 last_received_rtp_timestamp_; |
163 uint32 last_received_ntp_seconds_; | 166 uint32 last_received_ntp_seconds_; |
164 uint32 last_received_ntp_fraction_; | 167 uint32 last_received_ntp_fraction_; |
165 | 168 |
166 base::TimeDelta rtt_; | 169 base::TimeDelta rtt_; |
167 base::TimeDelta min_rtt_; | 170 base::TimeDelta min_rtt_; |
168 base::TimeDelta max_rtt_; | 171 base::TimeDelta max_rtt_; |
169 int number_of_rtt_in_avg_; | 172 int number_of_rtt_in_avg_; |
170 float avg_rtt_ms_; | 173 float avg_rtt_ms_; |
171 | 174 |
172 DISALLOW_COPY_AND_ASSIGN(Rtcp); | 175 DISALLOW_COPY_AND_ASSIGN(Rtcp); |
173 }; | 176 }; |
174 | 177 |
175 } // namespace cast | 178 } // namespace cast |
176 } // namespace media | 179 } // namespace media |
177 | 180 |
178 #endif // MEDIA_CAST_RTCP_RTCP_H_ | 181 #endif // MEDIA_CAST_RTCP_RTCP_H_ |
OLD | NEW |