OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. |
| 3 * |
| 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 |
| 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ |
| 10 |
| 11 #ifndef WEBRTC_PC_SRTPTRANSPORT_H_ |
| 12 #define WEBRTC_PC_SRTPTRANSPORT_H_ |
| 13 |
| 14 #include <memory> |
| 15 #include <string> |
| 16 #include <utility> |
| 17 |
| 18 #include "webrtc/pc/rtptransportinternal.h" |
| 19 #include "webrtc/pc/srtpfilter.h" |
| 20 #include "webrtc/rtc_base/checks.h" |
| 21 |
| 22 namespace webrtc { |
| 23 |
| 24 // This class will eventually be a wrapper around RtpTransportInternal |
| 25 // that protects and unprotects sent and received RTP packets. This |
| 26 // functionality is currently implemented by SrtpFilter and BaseChannel, but |
| 27 // will be moved here in the future. |
| 28 class SrtpTransport : public RtpTransportInternal { |
| 29 public: |
| 30 SrtpTransport(bool rtcp_mux_enabled, const std::string& content_name); |
| 31 |
| 32 // TODO(zstein): Consider taking an RtpTransport instead of an |
| 33 // RtpTransportInternal. |
| 34 SrtpTransport(std::unique_ptr<RtpTransportInternal> transport, |
| 35 const std::string& content_name); |
| 36 |
| 37 void SetRtcpMuxEnabled(bool enable) override { |
| 38 rtp_transport_->SetRtcpMuxEnabled(enable); |
| 39 } |
| 40 |
| 41 rtc::PacketTransportInternal* rtp_packet_transport() const override { |
| 42 return rtp_transport_->rtp_packet_transport(); |
| 43 } |
| 44 |
| 45 void SetRtpPacketTransport(rtc::PacketTransportInternal* rtp) override { |
| 46 rtp_transport_->SetRtpPacketTransport(rtp); |
| 47 } |
| 48 |
| 49 PacketTransportInterface* GetRtpPacketTransport() const override { |
| 50 return rtp_transport_->GetRtpPacketTransport(); |
| 51 } |
| 52 |
| 53 rtc::PacketTransportInternal* rtcp_packet_transport() const override { |
| 54 return rtp_transport_->rtcp_packet_transport(); |
| 55 } |
| 56 void SetRtcpPacketTransport(rtc::PacketTransportInternal* rtcp) override { |
| 57 rtp_transport_->SetRtcpPacketTransport(rtcp); |
| 58 } |
| 59 |
| 60 PacketTransportInterface* GetRtcpPacketTransport() const override { |
| 61 return rtp_transport_->GetRtcpPacketTransport(); |
| 62 } |
| 63 |
| 64 bool IsWritable(bool rtcp) const override { |
| 65 return rtp_transport_->IsWritable(rtcp); |
| 66 } |
| 67 |
| 68 bool SendPacket(bool rtcp, |
| 69 rtc::CopyOnWriteBuffer* packet, |
| 70 const rtc::PacketOptions& options, |
| 71 int flags) override; |
| 72 |
| 73 bool HandlesPayloadType(int payload_type) const override { |
| 74 return rtp_transport_->HandlesPayloadType(payload_type); |
| 75 } |
| 76 |
| 77 void AddHandledPayloadType(int payload_type) override { |
| 78 rtp_transport_->AddHandledPayloadType(payload_type); |
| 79 } |
| 80 |
| 81 RtcpParameters GetRtcpParameters() const override { |
| 82 return rtp_transport_->GetRtcpParameters(); |
| 83 } |
| 84 |
| 85 RTCError SetRtcpParameters(const RtcpParameters& parameters) override { |
| 86 return rtp_transport_->SetRtcpParameters(parameters); |
| 87 } |
| 88 |
| 89 // TODO(zstein): Remove this when we remove RtpTransportAdapter. |
| 90 RtpTransportAdapter* GetInternal() override { return nullptr; } |
| 91 |
| 92 private: |
| 93 void ConnectToRtpTransport(); |
| 94 |
| 95 void OnPacketReceived(bool rtcp, |
| 96 rtc::CopyOnWriteBuffer* packet, |
| 97 const rtc::PacketTime& packet_time); |
| 98 |
| 99 void OnReadyToSend(bool ready) { SignalReadyToSend(ready); } |
| 100 |
| 101 const std::string content_name_; |
| 102 |
| 103 std::unique_ptr<RtpTransportInternal> rtp_transport_; |
| 104 }; |
| 105 |
| 106 } // namespace webrtc |
| 107 |
| 108 #endif // WEBRTC_PC_SRTPTRANSPORT_H_ |
OLD | NEW |