| 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_
|
|
|