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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // 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
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_RECEIVER_RTCP_SESSION_H_
6 #define MEDIA_CAST_NET_RTCP_RECEIVER_RTCP_SESSION_H_
7
8 #include "base/time/tick_clock.h"
9 #include "media/cast/common/clock_drift_smoother.h"
10 #include "media/cast/net/pacing/paced_sender.h"
11 #include "media/cast/net/rtcp/receiver_rtcp_event_subscriber.h"
12 #include "media/cast/net/rtcp/receiver_rtcp_session.h"
13 #include "media/cast/net/rtcp/rtcp_defines.h"
14 #include "media/cast/net/rtcp/rtcp_session.h"
15 #include "media/cast/net/rtcp/rtcp_utility.h"
16
17 namespace media {
18 namespace cast {
19
20 // This class represents a RTCP session on a RTP receiver. It provides an
21 // interface to send RTCP reports (last report, RRTR, cast feedback, logs).
22 //
23 // The RTCP session on a receiver handles incoming RTCP SR packets and maintains
24 // the offset of local clock from the remote clock and lip sync info (RTP
25 // & NTP timestamps).
26 class ReceiverRtcpSession : public RtcpSession {
27 public:
28 ReceiverRtcpSession(base::TickClock* clock, // Not owned.
29 PacedPacketSender* packet_sender, // Not owned.
30 uint32_t local_ssrc,
31 uint32_t remote_ssrc);
32
33 ~ReceiverRtcpSession() override;
34
35 uint32_t local_ssrc() const { return local_ssrc_; }
36 uint32_t remote_ssrc() const { return remote_ssrc_; }
37
38 // |cast_message|, |rtcp_events| and |rtp_receiver_statistics| are optional;
39 // if |cast_message| is provided the RTCP receiver report will append a Cast
40 // message containing Acks and Nacks; |target_delay| is sent together with
41 // |cast_message|. If |rtcp_events| is provided the RTCP receiver report will
42 // append the log messages.
43 void SendRtcpReport(
44 RtcpTimeData time_data,
45 const RtcpCastMessage* cast_message,
46 base::TimeDelta target_delay,
47 const ReceiverRtcpEventSubscriber::RtcpEvents* rtcp_events,
48 const RtpReceiverStatistics* rtp_receiver_statistics) const;
49
50 // Handle incoming RTCP packet.
51 // Returns false if it is not a RTCP packet or it is not directed to
52 // this session, e.g. SSRC doesn't match.
53 bool IncomingRtcpPacket(const uint8* data, size_t length) override;
54
55 // If available, returns true and sets the output arguments to the latest
56 // lip-sync timestamps gleaned from the sender reports. While the sender
57 // provides reference NTP times relative to its own wall clock, the
58 // |reference_time| returned here has been translated to the local
59 // CastEnvironment clock.
60 bool GetLatestLipSyncTimes(RtpTimeTicks* rtp_timestamp,
61 base::TimeTicks* reference_time) const;
62
63 private:
64 // Received NTP timestamps from RTCP SR packets.
65 void OnReceivedNtp(uint32_t ntp_seconds, uint32_t ntp_fraction);
66
67 // Received RTP and NTP timestamps from RTCP SR packets.
68 void OnReceivedLipSyncInfo(RtpTimeTicks rtp_timestamp,
69 uint32_t ntp_seconds,
70 uint32_t ntp_fraction);
71
72 base::TickClock* const clock_; // Not owned.
73 PacedPacketSender* packet_sender_; // Not owned.
74 const uint32_t local_ssrc_;
75 const uint32_t remote_ssrc_;
76
77 // The truncated (i.e., 64-->32-bit) NTP timestamp provided in the last report
78 // from the remote peer, along with the local time at which the report was
79 // received. These values are used for ping-pong'ing NTP timestamps between
80 // the peers so that they can estimate the network's round-trip time.
81 uint32_t last_report_truncated_ntp_;
82 base::TimeTicks time_last_report_received_;
83
84 // Maintains a smoothed offset between the local clock and the remote clock.
85 // Calling this member's Current() method is only valid if
86 // |time_last_report_received_| has a valid value.
87 ClockDriftSmoother local_clock_ahead_by_;
88
89 // Latest "lip sync" info from the sender. The sender provides the RTP
90 // timestamp of some frame of its choosing and also a corresponding reference
91 // NTP timestamp sampled from a clock common to all media streams. It is
92 // expected that the sender will update this data regularly and in a timely
93 // manner (e.g., about once per second).
94 RtpTimeTicks lip_sync_rtp_timestamp_;
95 uint64_t lip_sync_ntp_timestamp_;
96
97 // The RTCP packet parser is re-used when parsing each RTCP packet. It
98 // remembers state about prior RTP timestamps and other sequence values to
99 // re-construct "expanded" values.
100 RtcpParser parser_;
101
102 DISALLOW_COPY_AND_ASSIGN(ReceiverRtcpSession);
103 };
104
105 } // namespace cast
106 } // namespace media
107
108 #endif // MEDIA_CAST_NET_RTCP_RECEIVER_RTCP_SESSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698