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

Unified Diff: media/cast/net/rtcp/receiver_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: Add missing rtcp_session.h and a few comments 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/receiver_rtcp_session.h
diff --git a/media/cast/net/rtcp/receiver_rtcp_session.h b/media/cast/net/rtcp/receiver_rtcp_session.h
new file mode 100644
index 0000000000000000000000000000000000000000..1428c708bb6799446f267df7a3efc10e66e304c1
--- /dev/null
+++ b/media/cast/net/rtcp/receiver_rtcp_session.h
@@ -0,0 +1,108 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
miu 2015/12/12 00:53:25 Can you try re-uploading the patch with the simila
+// 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_RECEIVER_RTCP_SESSION_H_
+#define MEDIA_CAST_NET_RTCP_RECEIVER_RTCP_SESSION_H_
+
+#include "base/time/tick_clock.h"
+#include "media/cast/common/clock_drift_smoother.h"
+#include "media/cast/net/pacing/paced_sender.h"
+#include "media/cast/net/rtcp/receiver_rtcp_event_subscriber.h"
+#include "media/cast/net/rtcp/receiver_rtcp_session.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 {
+
+// This class represents a RTCP session on a RTP receiver. It provides an
+// interface to send RTCP reports (last report, RRTR, cast feedback, logs).
+//
+// The RTCP session on a receiver handles incoming RTCP SR packets and maintains
+// the offset of local clock from the remote clock and lip sync info (RTP
+// & NTP timestamps).
+class ReceiverRtcpSession : public RtcpSession {
+ public:
+ ReceiverRtcpSession(base::TickClock* clock, // Not owned.
+ PacedPacketSender* packet_sender, // Not owned.
+ uint32_t local_ssrc,
+ uint32_t remote_ssrc);
+
+ ~ReceiverRtcpSession() override;
+
+ uint32_t local_ssrc() const { return local_ssrc_; }
+ uint32_t remote_ssrc() const { return remote_ssrc_; }
+
+ // |cast_message|, |rtcp_events| and |rtp_receiver_statistics| are optional;
+ // if |cast_message| is provided the RTCP receiver report will append a Cast
+ // message containing Acks and Nacks; |target_delay| is sent together with
+ // |cast_message|. If |rtcp_events| is provided the RTCP receiver report will
+ // append the log messages.
+ void SendRtcpReport(
+ RtcpTimeData time_data,
+ const RtcpCastMessage* cast_message,
+ base::TimeDelta target_delay,
+ const ReceiverRtcpEventSubscriber::RtcpEvents* rtcp_events,
+ const RtpReceiverStatistics* rtp_receiver_statistics) const;
+
+ // 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;
+
+ // If available, returns true and sets the output arguments to the latest
+ // lip-sync timestamps gleaned from the sender reports. While the sender
+ // provides reference NTP times relative to its own wall clock, the
+ // |reference_time| returned here has been translated to the local
+ // CastEnvironment clock.
+ bool GetLatestLipSyncTimes(RtpTimeTicks* rtp_timestamp,
+ base::TimeTicks* reference_time) const;
+
+ private:
+ // Received NTP timestamps from RTCP SR packets.
+ void OnReceivedNtp(uint32_t ntp_seconds, uint32_t ntp_fraction);
+
+ // Received RTP and NTP timestamps from RTCP SR packets.
+ void OnReceivedLipSyncInfo(RtpTimeTicks rtp_timestamp,
+ uint32_t ntp_seconds,
+ uint32_t ntp_fraction);
+
+ base::TickClock* const clock_; // Not owned.
+ PacedPacketSender* packet_sender_; // Not owned.
+ const uint32_t local_ssrc_;
+ const uint32_t remote_ssrc_;
+
+ // The truncated (i.e., 64-->32-bit) NTP timestamp provided in the last report
+ // from the remote peer, along with the local time at which the report was
+ // received. These values are used for ping-pong'ing NTP timestamps between
+ // the peers so that they can estimate the network's round-trip time.
+ uint32_t last_report_truncated_ntp_;
+ base::TimeTicks time_last_report_received_;
+
+ // Maintains a smoothed offset between the local clock and the remote clock.
+ // Calling this member's Current() method is only valid if
+ // |time_last_report_received_| has a valid value.
+ ClockDriftSmoother local_clock_ahead_by_;
+
+ // Latest "lip sync" info from the sender. The sender provides the RTP
+ // timestamp of some frame of its choosing and also a corresponding reference
+ // NTP timestamp sampled from a clock common to all media streams. It is
+ // expected that the sender will update this data regularly and in a timely
+ // manner (e.g., about once per second).
+ RtpTimeTicks lip_sync_rtp_timestamp_;
+ uint64_t lip_sync_ntp_timestamp_;
+
+ // The RTCP packet parser is re-used when parsing each RTCP packet. It
+ // remembers state about prior RTP timestamps and other sequence values to
+ // re-construct "expanded" values.
+ RtcpParser parser_;
+
+ DISALLOW_COPY_AND_ASSIGN(ReceiverRtcpSession);
+};
+
+} // namespace cast
+} // namespace media
+
+#endif // MEDIA_CAST_NET_RTCP_RECEIVER_RTCP_SESSION_H_

Powered by Google App Engine
This is Rietveld 408576698