OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "webrtc/pc/rtptransport.h" | 11 #include "webrtc/pc/rtptransport.h" |
12 | 12 |
13 #include "webrtc/media/base/rtputils.h" | 13 #include "webrtc/media/base/rtputils.h" |
| 14 #include "webrtc/p2p/base/dtlstransportinternal.h" // For cricket::PF_NORMAL |
14 #include "webrtc/p2p/base/packettransportinterface.h" | 15 #include "webrtc/p2p/base/packettransportinterface.h" |
15 #include "webrtc/rtc_base/checks.h" | 16 #include "webrtc/rtc_base/checks.h" |
16 #include "webrtc/rtc_base/copyonwritebuffer.h" | 17 #include "webrtc/rtc_base/copyonwritebuffer.h" |
17 #include "webrtc/rtc_base/trace_event.h" | 18 #include "webrtc/rtc_base/trace_event.h" |
18 | 19 |
19 namespace webrtc { | 20 namespace webrtc { |
20 | 21 |
21 void RtpTransport::SetRtcpMuxEnabled(bool enable) { | 22 void RtpTransport::SetRtcpMuxEnabled(bool enable) { |
22 rtcp_mux_enabled_ = enable; | 23 rtcp_mux_enabled_ = enable; |
23 MaybeSignalReadyToSend(); | 24 MaybeSignalReadyToSend(); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 rtcp_packet_transport_ && rtcp_packet_transport_->writable()); | 70 rtcp_packet_transport_ && rtcp_packet_transport_->writable()); |
70 } | 71 } |
71 | 72 |
72 bool RtpTransport::IsWritable(bool rtcp) const { | 73 bool RtpTransport::IsWritable(bool rtcp) const { |
73 rtc::PacketTransportInternal* transport = rtcp && !rtcp_mux_enabled_ | 74 rtc::PacketTransportInternal* transport = rtcp && !rtcp_mux_enabled_ |
74 ? rtcp_packet_transport_ | 75 ? rtcp_packet_transport_ |
75 : rtp_packet_transport_; | 76 : rtp_packet_transport_; |
76 return transport && transport->writable(); | 77 return transport && transport->writable(); |
77 } | 78 } |
78 | 79 |
| 80 bool RtpTransport::SendRtpPacket(rtc::CopyOnWriteBuffer* packet, |
| 81 const rtc::PacketOptions& options) { |
| 82 return SendPacket(false, packet, options, cricket::PF_NORMAL); |
| 83 } |
| 84 |
| 85 bool RtpTransport::SendRtcpPacket(rtc::CopyOnWriteBuffer* packet, |
| 86 const rtc::PacketOptions& options) { |
| 87 return SendPacket(true, packet, options, cricket::PF_NORMAL); |
| 88 } |
| 89 |
79 bool RtpTransport::SendPacket(bool rtcp, | 90 bool RtpTransport::SendPacket(bool rtcp, |
80 rtc::CopyOnWriteBuffer* packet, | 91 rtc::CopyOnWriteBuffer* packet, |
81 const rtc::PacketOptions& options, | 92 const rtc::PacketOptions& options, |
82 int flags) { | 93 int flags) { |
83 rtc::PacketTransportInternal* transport = rtcp && !rtcp_mux_enabled_ | 94 rtc::PacketTransportInternal* transport = rtcp && !rtcp_mux_enabled_ |
84 ? rtcp_packet_transport_ | 95 ? rtcp_packet_transport_ |
85 : rtp_packet_transport_; | 96 : rtp_packet_transport_; |
86 int ret = transport->SendPacket(packet->data<char>(), packet->size(), options, | 97 int ret = transport->SendPacket(packet->data<char>(), packet->size(), options, |
87 flags); | 98 flags); |
88 if (ret != static_cast<int>(packet->size())) { | 99 if (ret != static_cast<int>(packet->size())) { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 } | 214 } |
204 if (rtcp) { | 215 if (rtcp) { |
205 // Permit all (seemingly valid) RTCP packets. | 216 // Permit all (seemingly valid) RTCP packets. |
206 return true; | 217 return true; |
207 } | 218 } |
208 // Check whether we handle this payload. | 219 // Check whether we handle this payload. |
209 return HandlesPacket(packet->data(), packet->size()); | 220 return HandlesPacket(packet->data(), packet->size()); |
210 } | 221 } |
211 | 222 |
212 } // namespace webrtc | 223 } // namespace webrtc |
OLD | NEW |