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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: media/cast/net/rtcp/sender_rtcp_session.h
diff --git a/media/cast/net/rtcp/sender_rtcp_session.h b/media/cast/net/rtcp/sender_rtcp_session.h
new file mode 100644
index 0000000000000000000000000000000000000000..1f3ca3ecc6b6cd94fa2e80086bfcdd5cc7983716
--- /dev/null
+++ b/media/cast/net/rtcp/sender_rtcp_session.h
@@ -0,0 +1,109 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_CAST_NET_RTCP_SENDER_RTCP_SESSION_H_
+#define MEDIA_CAST_NET_RTCP_SENDER_RTCP_SESSION_H_
+
+#include <hash_set>
+#include <map>
+#include <queue>
+#include <utility>
+
+#include "base/time/time.h"
+#include "media/cast/net/pacing/paced_sender.h"
+#include "media/cast/net/rtcp/rtcp_defines.h"
+#include "media/cast/net/rtcp/rtcp_session.h"
+#include "media/cast/net/rtcp/rtcp_utility.h"
+
+namespace media {
+namespace cast {
+
+typedef std::pair<uint32_t, base::TimeTicks> RtcpSendTimePair;
+typedef std::map<uint32_t, base::TimeTicks> RtcpSendTimeMap;
+typedef std::queue<RtcpSendTimePair> RtcpSendTimeQueue;
+
+class SenderRtcpSession : public RtcpSession {
+ public:
+ SenderRtcpSession(const RtcpCastMessageCallback& cast_callback,
+ const RtcpRttCallback& rtt_callback,
+ const RtcpLogMessageCallback& log_callback,
+ base::TickClock* clock, // Not owned.
+ PacedPacketSender* packet_sender, // Not owned.
+ uint32_t local_ssrc,
+ uint32_t remote_ssrc);
+
+ ~SenderRtcpSession() override;
+
+ // If greater than zero, this is the last measured network round trip time.
+ base::TimeDelta current_round_trip_time() const {
+ return current_round_trip_time_;
+ }
+
+ // Send a RTCP sender report.
+ // |current_time| is the current time reported by a tick clock.
+ // |current_time_as_rtp_timestamp| is the corresponding RTP timestamp.
+ // |send_packet_count| is the number of packets sent.
+ // |send_octet_count| is the number of octets sent.
+ void SendRtcpReport(base::TimeTicks current_time,
+ RtpTimeTicks current_time_as_rtp_timestamp,
+ uint32_t send_packet_count,
+ size_t send_octet_count);
+
+ // Handle incoming RTCP packet.
+ // Returns false if it is not a RTCP packet or it is not directed to
+ // this session, e.g. SSRC doesn't match.
+ bool IncomingRtcpPacket(const uint8* data, size_t length) override;
+
+ private:
+ void OnReceivedDelaySinceLastReport(uint32_t last_report,
+ uint32_t delay_since_last_report);
+
+ void OnReceivedReceiverLog(const RtcpReceiverLogMessage& receiver_log);
+
+ void OnReceivedCastFeedback(const RtcpCastMessage& cast_message);
+
+ // Remove duplicate events in |receiver_log|.
+ // Returns true if any events remain.
+ bool DedupeReceiverLog(RtcpReceiverLogMessage* receiver_log);
+
+ void SaveLastSentNtpTime(const base::TimeTicks& now,
+ uint32_t last_ntp_seconds,
+ uint32_t last_ntp_fraction);
+
+ base::TickClock* const clock_; // Not owned.
+ PacedPacketSender* packet_sender_; // Not owned.
+ const uint32_t local_ssrc_;
+ const uint32_t remote_ssrc_;
+
+ const RtcpCastMessageCallback cast_callback_;
+ const RtcpRttCallback rtt_callback_;
+ const RtcpLogMessageCallback log_callback_;
+
+ base::TimeTicks largest_seen_timestamp_;
+
+ RtcpParser parser_;
+
+ // For extending received ACK frame IDs from 8-bit to 32-bit.
+ FrameIdWrapHelper ack_frame_id_wrap_helper_;
+
+ // Maintains a history of receiver events.
+ typedef std::pair<uint64_t, uint64_t> ReceiverEventKey;
+ base::hash_set<ReceiverEventKey> receiver_event_key_set_;
+ std::queue<ReceiverEventKey> receiver_event_key_queue_;
+
+ // The last measured network round trip time. This is updated with each
+ // sender report --> receiver report round trip. If this is zero, then the
+ // round trip time has not been measured yet.
+ base::TimeDelta current_round_trip_time_;
+
+ RtcpSendTimeMap last_reports_sent_map_;
+ RtcpSendTimeQueue last_reports_sent_queue_;
+
+ DISALLOW_COPY_AND_ASSIGN(SenderRtcpSession);
+};
+
+} // namespace cast
+} // namespace media
+
+#endif // MEDIA_CAST_NET_RTCP_SENDER_RTCP_SESSION_H_

Powered by Google App Engine
This is Rietveld 408576698