Remove Unused AsTextButtonBorder RTTI helper.
[chromium-blink-merge.git] / media / cast / rtcp / rtcp_sender.h
blobef253bd8a0f191ec8ad2c2e9244c0200cfe726bd
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"
15 #include "media/cast/transport/cast_transport_defines.h"
16 #include "media/cast/transport/rtcp/rtcp_builder.h"
18 namespace media {
19 namespace cast {
21 class ReceiverRtcpEventSubscriber;
23 // TODO(mikhal): Resolve duplication between this and RtcpBuilder.
24 class RtcpSender {
25 public:
26 RtcpSender(scoped_refptr<CastEnvironment> cast_environment,
27 transport::PacedPacketSender* outgoing_transport,
28 uint32 sending_ssrc,
29 const std::string& c_name);
31 virtual ~RtcpSender();
33 // Returns true if |event| is an interesting receiver event.
34 // Such an event should be sent via RTCP.
35 static bool IsReceiverEvent(const media::cast::CastLoggingEvent& event);
37 void SendRtcpFromRtpReceiver(uint32 packet_type_flags,
38 const transport::RtcpReportBlock* report_block,
39 const RtcpReceiverReferenceTimeReport* rrtr,
40 const RtcpCastMessage* cast_message,
41 ReceiverRtcpEventSubscriber* event_subscriber);
42 enum RtcpPacketType {
43 kRtcpSr = 0x0002,
44 kRtcpRr = 0x0004,
45 kRtcpBye = 0x0008,
46 kRtcpPli = 0x0010,
47 kRtcpNack = 0x0020,
48 kRtcpFir = 0x0040,
49 kRtcpSrReq = 0x0200,
50 kRtcpDlrr = 0x0400,
51 kRtcpRrtr = 0x0800,
52 kRtcpRpsi = 0x8000,
53 kRtcpRemb = 0x10000,
54 kRtcpCast = 0x20000,
55 kRtcpSenderLog = 0x40000,
56 kRtcpReceiverLog = 0x80000,
59 private:
60 void BuildRR(const transport::RtcpReportBlock* report_block,
61 Packet* packet) const;
63 void AddReportBlocks(const transport::RtcpReportBlock& report_block,
64 Packet* packet) const;
66 void BuildSdec(Packet* packet) const;
68 void BuildPli(uint32 remote_ssrc, Packet* packet) const;
70 void BuildRemb(const RtcpRembMessage* remb, Packet* packet) const;
72 void BuildRpsi(const RtcpRpsiMessage* rpsi, Packet* packet) const;
74 void BuildNack(const RtcpNackMessage* nack, Packet* packet) const;
76 void BuildBye(Packet* packet) const;
78 void BuildRrtr(const RtcpReceiverReferenceTimeReport* rrtr,
79 Packet* packet) const;
81 void BuildCast(const RtcpCastMessage* cast_message, Packet* packet) const;
83 void BuildReceiverLog(RtcpReceiverLogMessage* receiver_log_message,
84 Packet* 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 transport::PacedPacketSender* const transport_;
105 scoped_refptr<CastEnvironment> cast_environment_;
107 DISALLOW_COPY_AND_ASSIGN(RtcpSender);
110 } // namespace cast
111 } // namespace media
112 #endif // MEDIA_CAST_RTCP_RTCP_SENDER_H_