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 #include "media/cast/net/rtcp/rtcp_sender.h" | 5 #include "media/cast/net/rtcp/rtcp_sender.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <vector> | 10 #include <vector> |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 | 147 |
148 RtcpSender::RtcpSender(PacedPacketSender* outgoing_transport, | 148 RtcpSender::RtcpSender(PacedPacketSender* outgoing_transport, |
149 uint32 sending_ssrc) | 149 uint32 sending_ssrc) |
150 : ssrc_(sending_ssrc), | 150 : ssrc_(sending_ssrc), |
151 transport_(outgoing_transport) { | 151 transport_(outgoing_transport) { |
152 } | 152 } |
153 | 153 |
154 RtcpSender::~RtcpSender() {} | 154 RtcpSender::~RtcpSender() {} |
155 | 155 |
156 void RtcpSender::SendRtcpFromRtpReceiver( | 156 void RtcpSender::SendRtcpFromRtpReceiver( |
157 uint32 packet_type_flags, | |
158 const RtcpReportBlock* report_block, | 157 const RtcpReportBlock* report_block, |
159 const RtcpReceiverReferenceTimeReport* rrtr, | 158 const RtcpReceiverReferenceTimeReport* rrtr, |
160 const RtcpCastMessage* cast_message, | 159 const RtcpCastMessage* cast_message, |
161 const ReceiverRtcpEventSubscriber::RtcpEventMultiMap* rtcp_events, | 160 const ReceiverRtcpEventSubscriber::RtcpEventMultiMap* rtcp_events, |
162 base::TimeDelta target_delay) { | 161 base::TimeDelta target_delay) { |
163 if (packet_type_flags & kRtcpDlrr) { | |
164 NOTREACHED() << "Invalid argument"; | |
165 } | |
166 PacketRef packet(new base::RefCountedData<Packet>); | 162 PacketRef packet(new base::RefCountedData<Packet>); |
167 packet->data.reserve(kMaxIpPacketSize); | 163 packet->data.reserve(kMaxIpPacketSize); |
168 if (packet_type_flags & kRtcpRr) { | 164 if (report_block) |
169 BuildRR(report_block, &packet->data); | 165 BuildRR(report_block, &packet->data); |
170 } | 166 if (rrtr) |
171 if (packet_type_flags & kRtcpRrtr) { | |
172 DCHECK(rrtr) << "Invalid argument"; | |
173 BuildRrtr(rrtr, &packet->data); | 167 BuildRrtr(rrtr, &packet->data); |
174 } | 168 if (cast_message) |
175 if (packet_type_flags & kRtcpCast) { | |
176 DCHECK(cast_message) << "Invalid argument"; | |
177 BuildCast(cast_message, target_delay, &packet->data); | 169 BuildCast(cast_message, target_delay, &packet->data); |
178 } | 170 if (rtcp_events) |
179 if (packet_type_flags & kRtcpReceiverLog) { | |
180 DCHECK(rtcp_events) << "Invalid argument"; | |
181 BuildReceiverLog(*rtcp_events, &packet->data); | 171 BuildReceiverLog(*rtcp_events, &packet->data); |
182 } | |
183 | 172 |
184 if (packet->data.empty()) { | 173 if (packet->data.empty()) { |
185 NOTREACHED() << "Empty packet."; | 174 NOTREACHED() << "Empty packet."; |
186 return; // Sanity don't send empty packets. | 175 return; // Sanity don't send empty packets. |
187 } | 176 } |
188 | 177 |
189 transport_->SendRtcpPacket(ssrc_, packet); | 178 transport_->SendRtcpPacket(ssrc_, packet); |
190 } | 179 } |
191 | 180 |
192 void RtcpSender::SendRtcpFromRtpSender( | 181 void RtcpSender::SendRtcpFromRtpSender( |
193 uint32 packet_type_flags, | 182 const RtcpSenderInfo* sender_info, |
194 const RtcpSenderInfo& sender_info, | 183 const RtcpDlrrReportBlock* dlrr) { |
195 const RtcpDlrrReportBlock& dlrr) { | |
196 if (packet_type_flags & kRtcpRr || | |
197 packet_type_flags & kRtcpRrtr || | |
198 packet_type_flags & kRtcpCast || | |
199 packet_type_flags & kRtcpReceiverLog) { | |
200 NOTREACHED() << "Invalid argument"; | |
201 } | |
202 PacketRef packet(new base::RefCountedData<Packet>); | 184 PacketRef packet(new base::RefCountedData<Packet>); |
203 packet->data.reserve(kMaxIpPacketSize); | 185 packet->data.reserve(kMaxIpPacketSize); |
204 if (packet_type_flags & kRtcpSr) { | 186 if (sender_info) |
205 BuildSR(sender_info, &packet->data); | 187 BuildSR(*sender_info, &packet->data); |
206 } | 188 if (dlrr) |
Alpha Left Google
2014/08/21 20:18:23
DLRR can be removed.
hubbe
2014/08/21 21:34:14
Done.
| |
207 if (packet_type_flags & kRtcpDlrr) { | 189 BuildDlrrRb(*dlrr, &packet->data); |
208 BuildDlrrRb(dlrr, &packet->data); | 190 |
209 } | |
210 if (packet->data.empty()) { | 191 if (packet->data.empty()) { |
211 NOTREACHED() << "Empty packet."; | 192 NOTREACHED() << "Empty packet."; |
212 return; // Sanity - don't send empty packets. | 193 return; // Sanity - don't send empty packets. |
213 } | 194 } |
214 | 195 |
215 transport_->SendRtcpPacket(ssrc_, packet); | 196 transport_->SendRtcpPacket(ssrc_, packet); |
216 } | 197 } |
217 | 198 |
218 void RtcpSender::BuildRR(const RtcpReportBlock* report_block, | 199 void RtcpSender::BuildRR(const RtcpReportBlock* report_block, |
219 Packet* packet) const { | 200 Packet* packet) const { |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
650 << "Not enough buffer space."; | 631 << "Not enough buffer space."; |
651 | 632 |
652 VLOG(3) << "number of frames: " << *number_of_frames; | 633 VLOG(3) << "number of frames: " << *number_of_frames; |
653 VLOG(3) << "total messages to send: " << *total_number_of_messages_to_send; | 634 VLOG(3) << "total messages to send: " << *total_number_of_messages_to_send; |
654 VLOG(3) << "rtcp log size: " << *rtcp_log_size; | 635 VLOG(3) << "rtcp log size: " << *rtcp_log_size; |
655 return *number_of_frames > 0; | 636 return *number_of_frames > 0; |
656 } | 637 } |
657 | 638 |
658 } // namespace cast | 639 } // namespace cast |
659 } // namespace media | 640 } // namespace media |
OLD | NEW |