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"
15 #include "media/cast/transport/cast_transport_defines.h"
16 #include "media/cast/transport/rtcp/rtcp_builder.h"
21 class ReceiverRtcpEventSubscriber
;
23 // TODO(mikhal): Resolve duplication between this and RtcpBuilder.
26 RtcpSender(scoped_refptr
<CastEnvironment
> cast_environment
,
27 transport::PacedPacketSender
* outgoing_transport
,
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
);
55 kRtcpSenderLog
= 0x40000,
56 kRtcpReceiverLog
= 0x80000,
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
,
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 transport::PacedPacketSender
* const transport_
;
105 scoped_refptr
<CastEnvironment
> cast_environment_
;
107 DISALLOW_COPY_AND_ASSIGN(RtcpSender
);
112 #endif // MEDIA_CAST_RTCP_RTCP_SENDER_H_