Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // This class maintains a bi-directional RTCP connection with a remote | 5 // This class maintains a bi-directional RTCP connection with a remote |
| 6 // peer. | 6 // peer. |
| 7 | 7 |
| 8 #ifndef MEDIA_CAST_RTCP_RTCP_H_ | 8 #ifndef MEDIA_CAST_RTCP_RTCP_H_ |
| 9 #define MEDIA_CAST_RTCP_RTCP_H_ | 9 #define MEDIA_CAST_RTCP_RTCP_H_ |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 | 31 |
| 32 class LocalRtcpReceiverFeedback; | 32 class LocalRtcpReceiverFeedback; |
| 33 class PacedPacketSender; | 33 class PacedPacketSender; |
| 34 class RtcpReceiver; | 34 class RtcpReceiver; |
| 35 class RtcpBuilder; | 35 class RtcpBuilder; |
| 36 | 36 |
| 37 typedef std::pair<uint32, base::TimeTicks> RtcpSendTimePair; | 37 typedef std::pair<uint32, base::TimeTicks> RtcpSendTimePair; |
| 38 typedef std::map<uint32, base::TimeTicks> RtcpSendTimeMap; | 38 typedef std::map<uint32, base::TimeTicks> RtcpSendTimeMap; |
| 39 typedef std::queue<RtcpSendTimePair> RtcpSendTimeQueue; | 39 typedef std::queue<RtcpSendTimePair> RtcpSendTimeQueue; |
| 40 | 40 |
| 41 struct RtpReceiverStatistics { | |
| 42 RtpReceiverStatistics(); | |
| 43 uint8 fraction_lost; | |
| 44 uint32 cumulative_lost; // 24 bits valid. | |
| 45 uint32 extended_high_sequence_number; | |
| 46 uint32 jitter; | |
| 47 }; | |
| 48 | |
| 49 // TODO(hclam): This should be renamed to RtcpSession. | 41 // TODO(hclam): This should be renamed to RtcpSession. |
| 50 class Rtcp { | 42 class Rtcp { |
| 51 public: | 43 public: |
| 52 Rtcp(const RtcpCastMessageCallback& cast_callback, | 44 Rtcp(const RtcpCastMessageCallback& cast_callback, |
| 53 const RtcpRttCallback& rtt_callback, | 45 const RtcpRttCallback& rtt_callback, |
| 54 const RtcpLogMessageCallback& log_callback, | 46 const RtcpLogMessageCallback& log_callback, |
| 55 base::TickClock* clock, // Not owned. | 47 base::TickClock* clock, // Not owned. |
| 56 PacedPacketSender* packet_sender, // Not owned. | 48 PacedPacketSender* packet_sender, // Not owned. |
| 57 uint32 local_ssrc, | 49 uint32 local_ssrc, |
| 58 uint32 remote_ssrc); | 50 uint32 remote_ssrc); |
| 59 | 51 |
| 60 virtual ~Rtcp(); | 52 virtual ~Rtcp(); |
| 61 | 53 |
| 62 // Send a RTCP sender report. | 54 // Send a RTCP sender report. |
| 63 // |current_time| is the current time reported by a tick clock. | 55 // |current_time| is the current time reported by a tick clock. |
| 64 // |current_time_as_rtp_timestamp| is the corresponding RTP timestamp. | 56 // |current_time_as_rtp_timestamp| is the corresponding RTP timestamp. |
| 65 // |send_packet_count| is the number of packets sent. | 57 // |send_packet_count| is the number of packets sent. |
| 66 // |send_octet_count| is the number of octets sent. | 58 // |send_octet_count| is the number of octets sent. |
| 67 void SendRtcpFromRtpSender( | 59 void SendRtcpFromRtpSender( |
| 68 base::TimeTicks current_time, | 60 base::TimeTicks current_time, |
| 69 uint32 current_time_as_rtp_timestamp, | 61 uint32 current_time_as_rtp_timestamp, |
| 70 uint32 send_packet_count, | 62 uint32 send_packet_count, |
| 71 size_t send_octet_count); | 63 size_t send_octet_count); |
| 72 | 64 |
| 65 RtcpTimeData ConvertToNTPAndSave(base::TimeTicks now); | |
|
miu
2014/12/04 04:18:54
Please provide a short comment to explain how the
hubbe
2014/12/05 23:57:20
Done.
| |
| 66 | |
| 73 // |cast_message| and |rtcp_events| is optional; if |cast_message| is | 67 // |cast_message| and |rtcp_events| is optional; if |cast_message| is |
|
miu
2014/12/04 04:18:54
and |rtp_receiver_statistics| is also optional.
hubbe
2014/12/05 23:57:20
Done.
| |
| 74 // provided the RTCP receiver report will append a Cast message containing | 68 // provided the RTCP receiver report will append a Cast message containing |
| 75 // Acks and Nacks; |target_delay| is sent together with |cast_message|. | 69 // Acks and Nacks; |target_delay| is sent together with |cast_message|. |
| 76 // If |rtcp_events| is provided the RTCP receiver report will append the | 70 // If |rtcp_events| is provided the RTCP receiver report will append the |
| 77 // log messages. | 71 // log messages. |
| 78 void SendRtcpFromRtpReceiver( | 72 void SendRtcpFromRtpReceiver( |
| 73 RtcpTimeData time_data, | |
| 79 const RtcpCastMessage* cast_message, | 74 const RtcpCastMessage* cast_message, |
| 80 base::TimeDelta target_delay, | 75 base::TimeDelta target_delay, |
| 81 const ReceiverRtcpEventSubscriber::RtcpEventMultiMap* rtcp_events, | 76 const ReceiverRtcpEventSubscriber::RtcpEvents* rtcp_events, |
| 82 RtpReceiverStatistics* rtp_receiver_statistics); | 77 const RtpReceiverStatistics* rtp_receiver_statistics) const; |
| 83 | 78 |
| 84 // Submit a received packet to this object. The packet will be parsed | 79 // Submit a received packet to this object. The packet will be parsed |
| 85 // and used to maintain a RTCP session. | 80 // and used to maintain a RTCP session. |
| 86 // Returns false if this is not a RTCP packet or it is not directed to | 81 // Returns false if this is not a RTCP packet or it is not directed to |
| 87 // this session, e.g. SSRC doesn't match. | 82 // this session, e.g. SSRC doesn't match. |
| 88 bool IncomingRtcpPacket(const uint8* data, size_t length); | 83 bool IncomingRtcpPacket(const uint8* data, size_t length); |
| 89 | 84 |
| 90 // If available, returns true and sets the output arguments to the latest | 85 // If available, returns true and sets the output arguments to the latest |
| 91 // lip-sync timestamps gleaned from the sender reports. While the sender | 86 // lip-sync timestamps gleaned from the sender reports. While the sender |
| 92 // provides reference NTP times relative to its own wall clock, the | 87 // provides reference NTP times relative to its own wall clock, the |
| 93 // |reference_time| returned here has been translated to the local | 88 // |reference_time| returned here has been translated to the local |
| 94 // CastEnvironment clock. | 89 // CastEnvironment clock. |
| 95 bool GetLatestLipSyncTimes(uint32* rtp_timestamp, | 90 bool GetLatestLipSyncTimes(uint32* rtp_timestamp, |
| 96 base::TimeTicks* reference_time) const; | 91 base::TimeTicks* reference_time) const; |
| 97 | 92 |
| 98 void OnReceivedReceiverLog(const RtcpReceiverLogMessage& receiver_log); | 93 void OnReceivedReceiverLog(const RtcpReceiverLogMessage& receiver_log); |
| 99 | 94 |
| 100 // If greater than zero, this is the last measured network round trip time. | 95 // If greater than zero, this is the last measured network round trip time. |
| 101 base::TimeDelta current_round_trip_time() const { | 96 base::TimeDelta current_round_trip_time() const { |
| 102 return current_round_trip_time_; | 97 return current_round_trip_time_; |
| 103 } | 98 } |
| 104 | 99 |
| 105 static bool IsRtcpPacket(const uint8* packet, size_t length); | 100 static bool IsRtcpPacket(const uint8* packet, size_t length); |
| 106 static uint32 GetSsrcOfSender(const uint8* rtcp_buffer, size_t length); | 101 static uint32 GetSsrcOfSender(const uint8* rtcp_buffer, size_t length); |
| 107 | 102 |
| 103 uint32 GetLocalSsrc() const { return local_ssrc_; } | |
| 104 uint32 GetRemoteSsrc() const { return remote_ssrc_; } | |
| 105 | |
| 108 protected: | 106 protected: |
| 109 void OnReceivedNtp(uint32 ntp_seconds, uint32 ntp_fraction); | 107 void OnReceivedNtp(uint32 ntp_seconds, uint32 ntp_fraction); |
| 110 void OnReceivedLipSyncInfo(uint32 rtp_timestamp, | 108 void OnReceivedLipSyncInfo(uint32 rtp_timestamp, |
| 111 uint32 ntp_seconds, | 109 uint32 ntp_seconds, |
| 112 uint32 ntp_fraction); | 110 uint32 ntp_fraction); |
| 113 | 111 |
| 114 private: | 112 private: |
| 115 void OnReceivedDelaySinceLastReport(uint32 last_report, | 113 void OnReceivedDelaySinceLastReport(uint32 last_report, |
| 116 uint32 delay_since_last_report); | 114 uint32 delay_since_last_report); |
| 117 | 115 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 base::hash_set<ReceiverEventKey> receiver_event_key_set_; | 170 base::hash_set<ReceiverEventKey> receiver_event_key_set_; |
| 173 std::queue<ReceiverEventKey> receiver_event_key_queue_; | 171 std::queue<ReceiverEventKey> receiver_event_key_queue_; |
| 174 | 172 |
| 175 DISALLOW_COPY_AND_ASSIGN(Rtcp); | 173 DISALLOW_COPY_AND_ASSIGN(Rtcp); |
| 176 }; | 174 }; |
| 177 | 175 |
| 178 } // namespace cast | 176 } // namespace cast |
| 179 } // namespace media | 177 } // namespace media |
| 180 | 178 |
| 181 #endif // MEDIA_CAST_RTCP_RTCP_H_ | 179 #endif // MEDIA_CAST_RTCP_RTCP_H_ |
| OLD | NEW |