| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_CAST_NET_RTCP_RTCP_SENDER_H_ | 5 #ifndef MEDIA_CAST_NET_RTCP_RTCP_SENDER_H_ |
| 6 #define MEDIA_CAST_NET_RTCP_RTCP_SENDER_H_ | 6 #define MEDIA_CAST_NET_RTCP_RTCP_SENDER_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <list> | 9 #include <list> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 kReceiveLogMessageHistorySize, | 38 kReceiveLogMessageHistorySize, |
| 39 redundancy_offset_out_of_range); | 39 redundancy_offset_out_of_range); |
| 40 | 40 |
| 41 class PacedPacketSender; | 41 class PacedPacketSender; |
| 42 | 42 |
| 43 // TODO(hclam): This should be renamed to RtcpPacketBuilder. The function | 43 // TODO(hclam): This should be renamed to RtcpPacketBuilder. The function |
| 44 // of this class is to only to build a RTCP packet but not to send it. | 44 // of this class is to only to build a RTCP packet but not to send it. |
| 45 class RtcpSender { | 45 class RtcpSender { |
| 46 public: | 46 public: |
| 47 RtcpSender(PacedPacketSender* outgoing_transport, | 47 RtcpSender(PacedPacketSender* outgoing_transport, |
| 48 uint32 sending_ssrc, | 48 uint32 sending_ssrc); |
| 49 const std::string& c_name); | |
| 50 ~RtcpSender(); | 49 ~RtcpSender(); |
| 51 | 50 |
| 52 // TODO(hclam): This method should be to build a packet instead of | 51 // TODO(hclam): This method should be to build a packet instead of |
| 53 // sending it. | 52 // sending it. |
| 54 void SendRtcpFromRtpReceiver( | 53 void SendRtcpFromRtpReceiver( |
| 55 uint32 packet_type_flags, | 54 uint32 packet_type_flags, |
| 56 const RtcpReportBlock* report_block, | 55 const RtcpReportBlock* report_block, |
| 57 const RtcpReceiverReferenceTimeReport* rrtr, | 56 const RtcpReceiverReferenceTimeReport* rrtr, |
| 58 const RtcpCastMessage* cast_message, | 57 const RtcpCastMessage* cast_message, |
| 59 const ReceiverRtcpEventSubscriber::RtcpEventMultiMap* rtcp_events, | 58 const ReceiverRtcpEventSubscriber::RtcpEventMultiMap* rtcp_events, |
| 60 base::TimeDelta target_delay); | 59 base::TimeDelta target_delay); |
| 61 | 60 |
| 62 // TODO(hclam): This method should be to build a packet instead of | 61 // TODO(hclam): This method should be to build a packet instead of |
| 63 // sending it. | 62 // sending it. |
| 64 void SendRtcpFromRtpSender(uint32 packet_type_flags, | 63 void SendRtcpFromRtpSender(uint32 packet_type_flags, |
| 65 const RtcpSenderInfo& sender_info, | 64 const RtcpSenderInfo& sender_info, |
| 66 const RtcpDlrrReportBlock& dlrr); | 65 const RtcpDlrrReportBlock& dlrr); |
| 67 | 66 |
| 68 private: | 67 private: |
| 69 void BuildRR(const RtcpReportBlock* report_block, | 68 void BuildRR(const RtcpReportBlock* report_block, |
| 70 Packet* packet) const; | 69 Packet* packet) const; |
| 71 | 70 |
| 72 void AddReportBlocks(const RtcpReportBlock& report_block, | 71 void AddReportBlocks(const RtcpReportBlock& report_block, |
| 73 Packet* packet) const; | 72 Packet* packet) const; |
| 74 | 73 |
| 75 void BuildSdec(Packet* packet) const; | |
| 76 | |
| 77 void BuildPli(uint32 remote_ssrc, Packet* packet) const; | |
| 78 | |
| 79 void BuildRemb(const RtcpRembMessage* remb, Packet* packet) const; | |
| 80 | |
| 81 void BuildRpsi(const RtcpRpsiMessage* rpsi, Packet* packet) const; | |
| 82 | |
| 83 void BuildNack(const RtcpNackMessage* nack, Packet* packet) const; | |
| 84 | |
| 85 void BuildBye(Packet* packet) const; | |
| 86 | |
| 87 void BuildRrtr(const RtcpReceiverReferenceTimeReport* rrtr, | 74 void BuildRrtr(const RtcpReceiverReferenceTimeReport* rrtr, |
| 88 Packet* packet) const; | 75 Packet* packet) const; |
| 89 | 76 |
| 90 void BuildCast(const RtcpCastMessage* cast_message, | 77 void BuildCast(const RtcpCastMessage* cast_message, |
| 91 base::TimeDelta target_delay, | 78 base::TimeDelta target_delay, |
| 92 Packet* packet) const; | 79 Packet* packet) const; |
| 93 | 80 |
| 94 void BuildSR(const RtcpSenderInfo& sender_info, Packet* packet) const; | 81 void BuildSR(const RtcpSenderInfo& sender_info, Packet* packet) const; |
| 95 | 82 |
| 96 void BuildDlrrRb(const RtcpDlrrReportBlock& dlrr, Packet* packet) const; | 83 void BuildDlrrRb(const RtcpDlrrReportBlock& dlrr, Packet* packet) const; |
| 97 | 84 |
| 98 void BuildReceiverLog( | 85 void BuildReceiverLog( |
| 99 const ReceiverRtcpEventSubscriber::RtcpEventMultiMap& rtcp_events, | 86 const ReceiverRtcpEventSubscriber::RtcpEventMultiMap& rtcp_events, |
| 100 Packet* packet); | 87 Packet* packet); |
| 101 | 88 |
| 102 bool BuildRtcpReceiverLogMessage( | 89 bool BuildRtcpReceiverLogMessage( |
| 103 const ReceiverRtcpEventSubscriber::RtcpEventMultiMap& rtcp_events, | 90 const ReceiverRtcpEventSubscriber::RtcpEventMultiMap& rtcp_events, |
| 104 size_t start_size, | 91 size_t start_size, |
| 105 RtcpReceiverLogMessage* receiver_log_message, | 92 RtcpReceiverLogMessage* receiver_log_message, |
| 106 size_t* number_of_frames, | 93 size_t* number_of_frames, |
| 107 size_t* total_number_of_messages_to_send, | 94 size_t* total_number_of_messages_to_send, |
| 108 size_t* rtcp_log_size); | 95 size_t* rtcp_log_size); |
| 109 | 96 |
| 110 inline void BitrateToRembExponentBitrate(uint32 bitrate, | 97 const uint32 ssrc_; |
| 111 uint8* exponent, | |
| 112 uint32* mantissa) const { | |
| 113 // 6 bit exponent and a 18 bit mantissa. | |
| 114 *exponent = 0; | |
| 115 for (int i = 0; i < 64; ++i) { | |
| 116 if (bitrate <= (262143u << i)) { | |
| 117 *exponent = i; | |
| 118 break; | |
| 119 } | |
| 120 } | |
| 121 *mantissa = (bitrate >> *exponent); | |
| 122 } | |
| 123 | 98 |
| 124 const uint32 ssrc_; | 99 // Not owned by this class. |
| 125 const std::string c_name_; | |
| 126 | |
| 127 // Not owned by this class. | |
| 128 PacedPacketSender* const transport_; | 100 PacedPacketSender* const transport_; |
| 129 | 101 |
| 130 std::deque<RtcpReceiverLogMessage> rtcp_events_history_; | 102 std::deque<RtcpReceiverLogMessage> rtcp_events_history_; |
| 131 | 103 |
| 132 DISALLOW_COPY_AND_ASSIGN(RtcpSender); | 104 DISALLOW_COPY_AND_ASSIGN(RtcpSender); |
| 133 }; | 105 }; |
| 134 | 106 |
| 135 } // namespace cast | 107 } // namespace cast |
| 136 } // namespace media | 108 } // namespace media |
| 137 | 109 |
| 138 #endif // MEDIA_CAST_NET_RTCP_RTCP_SENDER_H_ | 110 #endif // MEDIA_CAST_NET_RTCP_RTCP_SENDER_H_ |
| OLD | NEW |