1 // Copyright 2013 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.
5 #ifndef MEDIA_CAST_RTCP_RTCP_SENDER_H_
6 #define MEDIA_CAST_RTCP_RTCP_SENDER_H_
11 #include "media/cast/cast_config.h"
12 #include "media/cast/cast_defines.h"
13 #include "media/cast/rtcp/rtcp.h"
14 #include "media/cast/rtcp/rtcp_defines.h"
21 RtcpSender(PacedPacketSender* const paced_packet_sender,
23 const std::string& c_name);
25 virtual ~RtcpSender();
27 void SendRtcp(uint32 packet_type_flags,
28 const RtcpSenderInfo* sender_info,
29 const RtcpReportBlock* report_block,
30 uint32 pli_remote_ssrc,
31 const RtcpDlrrReportBlock* dlrr,
32 const RtcpReceiverReferenceTimeReport* rrtr,
33 const RtcpCastMessage* cast_message);
51 void BuildSR(const RtcpSenderInfo& sender_info,
52 const RtcpReportBlock* report_block,
53 std::vector<uint8>* packet) const;
55 void BuildRR(const RtcpReportBlock* report_block,
56 std::vector<uint8>* packet) const;
58 void AddReportBlocks(const RtcpReportBlock& report_block,
59 std::vector<uint8>* packet) const;
61 void BuildSdec(std::vector<uint8>* packet) const;
63 void BuildPli(uint32 remote_ssrc,
64 std::vector<uint8>* packet) const;
66 void BuildRemb(const RtcpRembMessage* remb,
67 std::vector<uint8>* packet) const;
69 void BuildRpsi(const RtcpRpsiMessage* rpsi,
70 std::vector<uint8>* packet) const;
72 void BuildNack(const RtcpNackMessage* nack,
73 std::vector<uint8>* packet) const;
75 void BuildBye(std::vector<uint8>* packet) const;
77 void BuildDlrrRb(const RtcpDlrrReportBlock* dlrr,
78 std::vector<uint8>* packet) const;
80 void BuildRrtr(const RtcpReceiverReferenceTimeReport* rrtr,
81 std::vector<uint8>* packet) const;
83 void BuildCast(const RtcpCastMessage* cast_message,
84 std::vector<uint8>* packet) const;
86 inline void BitrateToRembExponentBitrate(uint32 bitrate,
88 uint32* mantissa) const {
89 // 6 bit exponent and a 18 bit mantissa.
91 for (int i = 0; i < 64; ++i) {
92 if (bitrate <= (262143u << i)) {
97 *mantissa = (bitrate >> *exponent);
101 const std::string c_name_;
103 // Not owned by this class.
104 PacedPacketSender* transport_;
106 DISALLOW_COPY_AND_ASSIGN(RtcpSender);
111 #endif // MEDIA_CAST_RTCP_RTCP_SENDER_H_