blob: 4d2ecb813b917e887499ccabff5dc8b7ebd200a8 [file] [log] [blame]
zstein398c3fd2017-07-19 13:38:02 -07001/*
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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef PC_SRTPTRANSPORT_H_
12#define PC_SRTPTRANSPORT_H_
zstein398c3fd2017-07-19 13:38:02 -070013
14#include <memory>
15#include <string>
16#include <utility>
17
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020018#include "pc/rtptransportinternal.h"
19#include "pc/srtpfilter.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020020#include "rtc_base/checks.h"
zstein398c3fd2017-07-19 13:38:02 -070021
22namespace webrtc {
23
24// This class will eventually be a wrapper around RtpTransportInternal
zhihuangeb23e172017-09-19 01:12:52 -070025// 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.
zstein398c3fd2017-07-19 13:38:02 -070028class SrtpTransport : public RtpTransportInternal {
29 public:
30 SrtpTransport(bool rtcp_mux_enabled, const std::string& content_name);
31
zhihuangeb23e172017-09-19 01:12:52 -070032 // TODO(zstein): Consider taking an RtpTransport instead of an
33 // RtpTransportInternal.
zstein398c3fd2017-07-19 13:38:02 -070034 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
zhihuangeb23e172017-09-19 01:12:52 -070068 bool SendPacket(bool rtcp,
69 rtc::CopyOnWriteBuffer* packet,
70 const rtc::PacketOptions& options,
71 int flags) override;
zstein398c3fd2017-07-19 13:38:02 -070072
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
sprangdb2a9fc2017-08-09 06:42:32 -070081 RTCError SetParameters(const RtpTransportParameters& parameters) override {
82 return rtp_transport_->SetParameters(parameters);
zstein398c3fd2017-07-19 13:38:02 -070083 }
84
sprangdb2a9fc2017-08-09 06:42:32 -070085 RtpTransportParameters GetParameters() const override {
86 return rtp_transport_->GetParameters();
zstein398c3fd2017-07-19 13:38:02 -070087 }
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
zhihuange683c682017-08-31 16:00:07 -0700101 const std::string content_name_;
zhihuangeb23e172017-09-19 01:12:52 -0700102
zstein398c3fd2017-07-19 13:38:02 -0700103 std::unique_ptr<RtpTransportInternal> rtp_transport_;
zstein398c3fd2017-07-19 13:38:02 -0700104};
105
106} // namespace webrtc
107
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200108#endif // PC_SRTPTRANSPORT_H_