OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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/rtcp/rtcp_sender.h" | 5 #include "media/cast/rtcp/rtcp_sender.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 12 matching lines...) Expand all Loading... | |
23 uint32 sending_ssrc, | 23 uint32 sending_ssrc, |
24 const std::string& c_name) | 24 const std::string& c_name) |
25 : ssrc_(sending_ssrc), | 25 : ssrc_(sending_ssrc), |
26 c_name_(c_name), | 26 c_name_(c_name), |
27 transport_(outgoing_transport) { | 27 transport_(outgoing_transport) { |
28 DCHECK_LT(c_name_.length(), kRtcpCnameSize) << "Invalid config"; | 28 DCHECK_LT(c_name_.length(), kRtcpCnameSize) << "Invalid config"; |
29 } | 29 } |
30 | 30 |
31 RtcpSender::~RtcpSender() {} | 31 RtcpSender::~RtcpSender() {} |
32 | 32 |
33 void RtcpSender::SendRtcp(uint32 packet_type_flags, | 33 void RtcpSender::SendRtcpFromRtpSender(uint32 packet_type_flags, |
34 const RtcpSenderInfo* sender_info, | 34 const RtcpSenderInfo* sender_info, |
35 const RtcpReportBlock* report_block, | 35 const RtcpDlrrReportBlock* dlrr, |
36 uint32 pli_remote_ssrc, | 36 const RtcpSenderLogMessage* sender_log) { |
37 const RtcpDlrrReportBlock* dlrr, | 37 if (packet_type_flags & kRtcpRr || |
Alpha Left Google
2013/11/13 23:58:40
This condition in incorrect. It should be the oppo
pwestin
2013/11/15 00:20:32
Please clarify; this does what I want it to do. If
| |
38 const RtcpReceiverReferenceTimeReport* rrtr, | 38 packet_type_flags & kRtcpPli || |
39 const RtcpCastMessage* cast_message) { | 39 packet_type_flags & kRtcpRrtr || |
40 packet_type_flags & kRtcpCast || | |
41 packet_type_flags & kRtcpReceiverLog || | |
42 packet_type_flags & kRtcpRpsi || | |
43 packet_type_flags & kRtcpRemb || | |
44 packet_type_flags & kRtcpNack) { | |
45 NOTREACHED() << "Invalid argument"; | |
46 } | |
47 | |
40 std::vector<uint8> packet; | 48 std::vector<uint8> packet; |
41 packet.reserve(kIpPacketSize); | 49 packet.reserve(kIpPacketSize); |
42 if (packet_type_flags & kRtcpSr) { | 50 if (packet_type_flags & kRtcpSr) { |
43 DCHECK(sender_info) << "Invalid argument"; | 51 DCHECK(sender_info) << "Invalid argument"; |
44 BuildSR(*sender_info, report_block, &packet); | 52 BuildSR(*sender_info, NULL, &packet); |
45 BuildSdec(&packet); | 53 BuildSdec(&packet); |
46 } else if (packet_type_flags & kRtcpRr) { | 54 } |
55 if (packet_type_flags & kRtcpBye) { | |
56 BuildBye(&packet); | |
57 } | |
58 if (packet_type_flags & kRtcpDlrr) { | |
59 DCHECK(dlrr) << "Invalid argument"; | |
60 BuildDlrrRb(dlrr, &packet); | |
61 } | |
62 if (packet_type_flags & kRtcpSenderLog) { | |
63 DCHECK(sender_log) << "Invalid argument"; | |
64 BuildSenderLog(sender_log, &packet); | |
65 } | |
66 if (packet.empty()) return; // Sanity don't send empty packets. | |
Alpha Left Google
2013/11/13 23:58:40
nit: drop return to next line.
pwestin
2013/11/15 00:20:32
Done.
| |
67 | |
68 transport_->SendRtcpPacket(packet); | |
69 } | |
70 | |
71 void RtcpSender::SendRtcpFromRtpReceiver( | |
72 uint32 packet_type_flags, | |
73 const RtcpReportBlock* report_block, | |
74 const RtcpReceiverReferenceTimeReport* rrtr, | |
75 const RtcpCastMessage* cast_message, | |
76 const RtcpReceiverLogMessage* receiver_log) { | |
77 if (packet_type_flags & kRtcpSr || | |
Alpha Left Google
2013/11/13 23:58:40
This condition is not correct. It should be the op
pwestin
2013/11/15 00:20:32
Please clarify; this does what I want it to do. If
| |
78 packet_type_flags & kRtcpDlrr || | |
79 packet_type_flags & kRtcpSenderLog) { | |
80 NOTREACHED() << "Invalid argument"; | |
81 } | |
82 if (packet_type_flags & kRtcpPli || | |
83 packet_type_flags & kRtcpRpsi || | |
84 packet_type_flags & kRtcpRemb || | |
85 packet_type_flags & kRtcpNack) { | |
86 // Implement these for webrtc interop. | |
87 NOTIMPLEMENTED(); | |
88 } | |
89 std::vector<uint8> packet; | |
90 packet.reserve(kIpPacketSize); | |
91 | |
92 if (packet_type_flags & kRtcpRr) { | |
47 BuildRR(report_block, &packet); | 93 BuildRR(report_block, &packet); |
48 if (!c_name_.empty()) { | 94 if (!c_name_.empty()) { |
49 BuildSdec(&packet); | 95 BuildSdec(&packet); |
50 } | 96 } |
51 } | 97 } |
52 if (packet_type_flags & kRtcpPli) { | |
53 BuildPli(pli_remote_ssrc, &packet); | |
54 } | |
55 if (packet_type_flags & kRtcpBye) { | 98 if (packet_type_flags & kRtcpBye) { |
56 BuildBye(&packet); | 99 BuildBye(&packet); |
57 } | 100 } |
58 if (packet_type_flags & kRtcpRpsi) { | |
59 // Implement this for webrtc interop. | |
60 NOTIMPLEMENTED(); | |
61 } | |
62 if (packet_type_flags & kRtcpRemb) { | |
63 // Implement this for webrtc interop. | |
64 NOTIMPLEMENTED(); | |
65 } | |
66 if (packet_type_flags & kRtcpNack) { | |
67 // Implement this for webrtc interop. | |
68 NOTIMPLEMENTED(); | |
69 } | |
70 if (packet_type_flags & kRtcpDlrr) { | |
71 DCHECK(dlrr) << "Invalid argument"; | |
72 BuildDlrrRb(dlrr, &packet); | |
73 } | |
74 if (packet_type_flags & kRtcpRrtr) { | 101 if (packet_type_flags & kRtcpRrtr) { |
75 DCHECK(rrtr) << "Invalid argument"; | 102 DCHECK(rrtr) << "Invalid argument"; |
76 BuildRrtr(rrtr, &packet); | 103 BuildRrtr(rrtr, &packet); |
77 } | 104 } |
78 if (packet_type_flags & kRtcpCast) { | 105 if (packet_type_flags & kRtcpCast) { |
79 DCHECK(cast_message) << "Invalid argument"; | 106 DCHECK(cast_message) << "Invalid argument"; |
80 BuildCast(cast_message, &packet); | 107 BuildCast(cast_message, &packet); |
81 } | 108 } |
82 | 109 if (packet_type_flags & kRtcpReceiverLog) { |
110 DCHECK(receiver_log) << "Invalid argument"; | |
111 BuildReceiverLog(receiver_log, &packet); | |
112 } | |
83 if (packet.empty()) return; // Sanity don't send empty packets. | 113 if (packet.empty()) return; // Sanity don't send empty packets. |
84 | 114 |
85 transport_->SendRtcpPacket(packet); | 115 transport_->SendRtcpPacket(packet); |
86 } | 116 } |
87 | 117 |
88 void RtcpSender::BuildSR(const RtcpSenderInfo& sender_info, | 118 void RtcpSender::BuildSR(const RtcpSenderInfo& sender_info, |
89 const RtcpReportBlock* report_block, | 119 const RtcpReportBlock* report_block, |
90 std::vector<uint8>* packet) const { | 120 std::vector<uint8>* packet) const { |
91 // Sender report. | 121 // Sender report. |
92 size_t start_size = packet->size(); | 122 size_t start_size = packet->size(); |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
535 } | 565 } |
536 DCHECK_LE(number_of_loss_fields, kRtcpMaxCastLossFields); | 566 DCHECK_LE(number_of_loss_fields, kRtcpMaxCastLossFields); |
537 (*packet)[cast_size_pos] = static_cast<uint8>(4 + number_of_loss_fields); | 567 (*packet)[cast_size_pos] = static_cast<uint8>(4 + number_of_loss_fields); |
538 (*packet)[cast_loss_field_pos] = static_cast<uint8>(number_of_loss_fields); | 568 (*packet)[cast_loss_field_pos] = static_cast<uint8>(number_of_loss_fields); |
539 | 569 |
540 // Frames with missing packets. | 570 // Frames with missing packets. |
541 TRACE_COUNTER_ID1("cast_rtcp", "RtcpSender::CastNACK", ssrc_, | 571 TRACE_COUNTER_ID1("cast_rtcp", "RtcpSender::CastNACK", ssrc_, |
542 cast->missing_frames_and_packets_.size()); | 572 cast->missing_frames_and_packets_.size()); |
543 } | 573 } |
544 | 574 |
575 void RtcpSender::BuildSenderLog(const RtcpSenderLogMessage* sender_log_message, | |
576 std::vector<uint8>* packet) const { | |
577 // TODO(pwestin): Implement. | |
578 NOTIMPLEMENTED(); | |
579 } | |
580 | |
581 void RtcpSender::BuildReceiverLog( | |
582 const RtcpReceiverLogMessage* receiver_log_message, | |
583 std::vector<uint8>* packet) const { | |
584 // TODO(pwestin): Implement. | |
585 NOTIMPLEMENTED(); | |
586 } | |
587 | |
545 } // namespace cast | 588 } // namespace cast |
546 } // namespace media | 589 } // namespace media |
OLD | NEW |