Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: media/cast/net/rtcp/sender_rtcp_session.h

Issue 1520613004: cast: Split Rtcp into two for sender and receiver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@timestamp
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_CAST_NET_RTCP_SENDER_RTCP_SESSION_H_
6 #define MEDIA_CAST_NET_RTCP_SENDER_RTCP_SESSION_H_
7
8 #include <hash_set>
9 #include <map>
10 #include <queue>
11 #include <utility>
12
13 #include "base/time/time.h"
14 #include "media/cast/net/pacing/paced_sender.h"
15 #include "media/cast/net/rtcp/rtcp_defines.h"
16 #include "media/cast/net/rtcp/rtcp_session.h"
17 #include "media/cast/net/rtcp/rtcp_utility.h"
18
19 namespace media {
20 namespace cast {
21
22 typedef std::pair<uint32_t, base::TimeTicks> RtcpSendTimePair;
23 typedef std::map<uint32_t, base::TimeTicks> RtcpSendTimeMap;
24 typedef std::queue<RtcpSendTimePair> RtcpSendTimeQueue;
25
26 class SenderRtcpSession : public RtcpSession {
27 public:
28 SenderRtcpSession(const RtcpCastMessageCallback& cast_callback,
29 const RtcpRttCallback& rtt_callback,
30 const RtcpLogMessageCallback& log_callback,
31 base::TickClock* clock, // Not owned.
32 PacedPacketSender* packet_sender, // Not owned.
33 uint32_t local_ssrc,
34 uint32_t remote_ssrc);
35
36 ~SenderRtcpSession() override;
37
38 // If greater than zero, this is the last measured network round trip time.
39 base::TimeDelta current_round_trip_time() const {
40 return current_round_trip_time_;
41 }
42
43 // Send a RTCP sender report.
44 // |current_time| is the current time reported by a tick clock.
45 // |current_time_as_rtp_timestamp| is the corresponding RTP timestamp.
46 // |send_packet_count| is the number of packets sent.
47 // |send_octet_count| is the number of octets sent.
48 void SendRtcpReport(base::TimeTicks current_time,
49 RtpTimeTicks current_time_as_rtp_timestamp,
50 uint32_t send_packet_count,
51 size_t send_octet_count);
52
53 // Handle incoming RTCP packet.
54 // Returns false if it is not a RTCP packet or it is not directed to
55 // this session, e.g. SSRC doesn't match.
56 bool IncomingRtcpPacket(const uint8* data, size_t length) override;
57
58 private:
59 void OnReceivedDelaySinceLastReport(uint32_t last_report,
60 uint32_t delay_since_last_report);
61
62 void OnReceivedReceiverLog(const RtcpReceiverLogMessage& receiver_log);
63
64 void OnReceivedCastFeedback(const RtcpCastMessage& cast_message);
65
66 // Remove duplicate events in |receiver_log|.
67 // Returns true if any events remain.
68 bool DedupeReceiverLog(RtcpReceiverLogMessage* receiver_log);
69
70 void SaveLastSentNtpTime(const base::TimeTicks& now,
71 uint32_t last_ntp_seconds,
72 uint32_t last_ntp_fraction);
73
74 base::TickClock* const clock_; // Not owned.
75 PacedPacketSender* packet_sender_; // Not owned.
76 const uint32_t local_ssrc_;
77 const uint32_t remote_ssrc_;
78
79 const RtcpCastMessageCallback cast_callback_;
80 const RtcpRttCallback rtt_callback_;
81 const RtcpLogMessageCallback log_callback_;
82
83 base::TimeTicks largest_seen_timestamp_;
84
85 RtcpParser parser_;
86
87 // For extending received ACK frame IDs from 8-bit to 32-bit.
88 FrameIdWrapHelper ack_frame_id_wrap_helper_;
89
90 // Maintains a history of receiver events.
91 typedef std::pair<uint64_t, uint64_t> ReceiverEventKey;
92 base::hash_set<ReceiverEventKey> receiver_event_key_set_;
93 std::queue<ReceiverEventKey> receiver_event_key_queue_;
94
95 // The last measured network round trip time. This is updated with each
96 // sender report --> receiver report round trip. If this is zero, then the
97 // round trip time has not been measured yet.
98 base::TimeDelta current_round_trip_time_;
99
100 RtcpSendTimeMap last_reports_sent_map_;
101 RtcpSendTimeQueue last_reports_sent_queue_;
102
103 DISALLOW_COPY_AND_ASSIGN(SenderRtcpSession);
104 };
105
106 } // namespace cast
107 } // namespace media
108
109 #endif // MEDIA_CAST_NET_RTCP_SENDER_RTCP_SESSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698