Report errors from ChromiumEnv::GetChildren in Posix.
[chromium-blink-merge.git] / media / cast / rtcp / rtcp_sender.h
blob7dbbc0f95b514bfce8d875669c2a5be0333dba92
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_
8 #include <list>
9 #include <string>
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"
16 namespace media {
17 namespace cast {
19 class RtcpSender {
20 public:
21 RtcpSender(PacedPacketSender* const paced_packet_sender,
22 uint32 sending_ssrc,
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);
35 enum RtcpPacketType {
36 kRtcpSr = 0x0002,
37 kRtcpRr = 0x0004,
38 kRtcpBye = 0x0008,
39 kRtcpPli = 0x0010,
40 kRtcpNack = 0x0020,
41 kRtcpFir = 0x0040,
42 kRtcpSrReq = 0x0200,
43 kRtcpDlrr = 0x0400,
44 kRtcpRrtr = 0x0800,
45 kRtcpRpsi = 0x8000,
46 kRtcpRemb = 0x10000,
47 kRtcpCast = 0x20000,
50 private:
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,
87 uint8* exponent,
88 uint32* mantissa) const {
89 // 6 bit exponent and a 18 bit mantissa.
90 *exponent = 0;
91 for (int i = 0; i < 64; ++i) {
92 if (bitrate <= (262143u << i)) {
93 *exponent = i;
94 break;
97 *mantissa = (bitrate >> *exponent);
100 const uint32 ssrc_;
101 const std::string c_name_;
103 // Not owned by this class.
104 PacedPacketSender* transport_;
106 DISALLOW_COPY_AND_ASSIGN(RtcpSender);
109 } // namespace cast
110 } // namespace media
111 #endif // MEDIA_CAST_RTCP_RTCP_SENDER_H_