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 || |
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()) |
| 67 return; // Sanity don't send empty packets. |
| 68 |
| 69 transport_->SendRtcpPacket(packet); |
| 70 } |
| 71 |
| 72 void RtcpSender::SendRtcpFromRtpReceiver( |
| 73 uint32 packet_type_flags, |
| 74 const RtcpReportBlock* report_block, |
| 75 const RtcpReceiverReferenceTimeReport* rrtr, |
| 76 const RtcpCastMessage* cast_message, |
| 77 const RtcpReceiverLogMessage* receiver_log) { |
| 78 if (packet_type_flags & kRtcpSr || |
| 79 packet_type_flags & kRtcpDlrr || |
| 80 packet_type_flags & kRtcpSenderLog) { |
| 81 NOTREACHED() << "Invalid argument"; |
| 82 } |
| 83 if (packet_type_flags & kRtcpPli || |
| 84 packet_type_flags & kRtcpRpsi || |
| 85 packet_type_flags & kRtcpRemb || |
| 86 packet_type_flags & kRtcpNack) { |
| 87 // Implement these for webrtc interop. |
| 88 NOTIMPLEMENTED(); |
| 89 } |
| 90 std::vector<uint8> packet; |
| 91 packet.reserve(kIpPacketSize); |
| 92 |
| 93 if (packet_type_flags & kRtcpRr) { |
47 BuildRR(report_block, &packet); | 94 BuildRR(report_block, &packet); |
48 if (!c_name_.empty()) { | 95 if (!c_name_.empty()) { |
49 BuildSdec(&packet); | 96 BuildSdec(&packet); |
50 } | 97 } |
51 } | 98 } |
52 if (packet_type_flags & kRtcpPli) { | |
53 BuildPli(pli_remote_ssrc, &packet); | |
54 } | |
55 if (packet_type_flags & kRtcpBye) { | 99 if (packet_type_flags & kRtcpBye) { |
56 BuildBye(&packet); | 100 BuildBye(&packet); |
57 } | 101 } |
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) { | 102 if (packet_type_flags & kRtcpRrtr) { |
75 DCHECK(rrtr) << "Invalid argument"; | 103 DCHECK(rrtr) << "Invalid argument"; |
76 BuildRrtr(rrtr, &packet); | 104 BuildRrtr(rrtr, &packet); |
77 } | 105 } |
78 if (packet_type_flags & kRtcpCast) { | 106 if (packet_type_flags & kRtcpCast) { |
79 DCHECK(cast_message) << "Invalid argument"; | 107 DCHECK(cast_message) << "Invalid argument"; |
80 BuildCast(cast_message, &packet); | 108 BuildCast(cast_message, &packet); |
81 } | 109 } |
82 | 110 if (packet_type_flags & kRtcpReceiverLog) { |
| 111 DCHECK(receiver_log) << "Invalid argument"; |
| 112 BuildReceiverLog(receiver_log, &packet); |
| 113 } |
83 if (packet.empty()) return; // Sanity don't send empty packets. | 114 if (packet.empty()) return; // Sanity don't send empty packets. |
84 | 115 |
85 transport_->SendRtcpPacket(packet); | 116 transport_->SendRtcpPacket(packet); |
86 } | 117 } |
87 | 118 |
88 void RtcpSender::BuildSR(const RtcpSenderInfo& sender_info, | 119 void RtcpSender::BuildSR(const RtcpSenderInfo& sender_info, |
89 const RtcpReportBlock* report_block, | 120 const RtcpReportBlock* report_block, |
90 std::vector<uint8>* packet) const { | 121 std::vector<uint8>* packet) const { |
91 // Sender report. | 122 // Sender report. |
92 size_t start_size = packet->size(); | 123 size_t start_size = packet->size(); |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 } | 566 } |
536 DCHECK_LE(number_of_loss_fields, kRtcpMaxCastLossFields); | 567 DCHECK_LE(number_of_loss_fields, kRtcpMaxCastLossFields); |
537 (*packet)[cast_size_pos] = static_cast<uint8>(4 + number_of_loss_fields); | 568 (*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); | 569 (*packet)[cast_loss_field_pos] = static_cast<uint8>(number_of_loss_fields); |
539 | 570 |
540 // Frames with missing packets. | 571 // Frames with missing packets. |
541 TRACE_COUNTER_ID1("cast_rtcp", "RtcpSender::CastNACK", ssrc_, | 572 TRACE_COUNTER_ID1("cast_rtcp", "RtcpSender::CastNACK", ssrc_, |
542 cast->missing_frames_and_packets_.size()); | 573 cast->missing_frames_and_packets_.size()); |
543 } | 574 } |
544 | 575 |
| 576 void RtcpSender::BuildSenderLog(const RtcpSenderLogMessage* sender_log_message, |
| 577 std::vector<uint8>* packet) const { |
| 578 // TODO(pwestin): Implement. |
| 579 NOTIMPLEMENTED(); |
| 580 } |
| 581 |
| 582 void RtcpSender::BuildReceiverLog( |
| 583 const RtcpReceiverLogMessage* receiver_log_message, |
| 584 std::vector<uint8>* packet) const { |
| 585 // TODO(pwestin): Implement. |
| 586 NOTIMPLEMENTED(); |
| 587 } |
| 588 |
545 } // namespace cast | 589 } // namespace cast |
546 } // namespace media | 590 } // namespace media |
OLD | NEW |