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 #ifndef WEBRTC_ORTC_RTPTRANSPORTADAPTER_H_ | 11 #ifndef WEBRTC_ORTC_RTPTRANSPORTADAPTER_H_ |
12 #define WEBRTC_ORTC_RTPTRANSPORTADAPTER_H_ | 12 #define WEBRTC_ORTC_RTPTRANSPORTADAPTER_H_ |
13 | 13 |
14 #include <memory> | 14 #include <memory> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "webrtc/api/ortc/rtptransportinterface.h" | 17 #include "webrtc/api/ortc/srtptransportinterface.h" |
18 #include "webrtc/api/rtcerror.h" | 18 #include "webrtc/api/rtcerror.h" |
19 #include "webrtc/base/constructormagic.h" | 19 #include "webrtc/base/constructormagic.h" |
20 #include "webrtc/base/sigslot.h" | 20 #include "webrtc/base/sigslot.h" |
21 #include "webrtc/media/base/streamparams.h" | 21 #include "webrtc/media/base/streamparams.h" |
22 #include "webrtc/ortc/rtptransportcontrolleradapter.h" | 22 #include "webrtc/ortc/rtptransportcontrolleradapter.h" |
23 #include "webrtc/pc/channel.h" | 23 #include "webrtc/pc/channel.h" |
24 | 24 |
25 namespace webrtc { | 25 namespace webrtc { |
26 | 26 |
27 // Implementation of RtpTransportInterface to be used with RtpSenderAdapter, | 27 // Implementation of SrtpTransportInterface to be used with RtpSenderAdapter, |
28 // RtpReceiverAdapter, and RtpTransportControllerAdapter classes. | 28 // RtpReceiverAdapter, and RtpTransportControllerAdapter classes. This class |
| 29 // is used to implement both a secure and insecure RTP transport. |
29 // | 30 // |
30 // TODO(deadbeef): When BaseChannel is split apart into separate | 31 // TODO(deadbeef): When BaseChannel is split apart into separate |
31 // "RtpTransport"/"RtpTransceiver"/"RtpSender"/"RtpReceiver" objects, this | 32 // "RtpTransport"/"RtpTransceiver"/"RtpSender"/"RtpReceiver" objects, this |
32 // adapter object can be removed. | 33 // adapter object can be removed. |
33 class RtpTransportAdapter : public RtpTransportInterface { | 34 class RtpTransportAdapter : public SrtpTransportInterface { |
34 public: | 35 public: |
35 // |rtp| can't be null. |rtcp| can if RTCP muxing is used immediately (meaning | 36 // |rtp| can't be null. |rtcp| can if RTCP muxing is used immediately (meaning |
36 // |rtcp_parameters.mux| is also true). | 37 // |rtcp_parameters.mux| is also true). |
37 static RTCErrorOr<std::unique_ptr<RtpTransportInterface>> CreateProxied( | 38 static RTCErrorOr<std::unique_ptr<RtpTransportInterface>> CreateProxied( |
38 const RtcpParameters& rtcp_parameters, | 39 const RtcpParameters& rtcp_parameters, |
39 PacketTransportInterface* rtp, | 40 PacketTransportInterface* rtp, |
40 PacketTransportInterface* rtcp, | 41 PacketTransportInterface* rtcp, |
41 RtpTransportControllerAdapter* rtp_transport_controller); | 42 RtpTransportControllerAdapter* rtp_transport_controller); |
| 43 |
| 44 static RTCErrorOr<std::unique_ptr<SrtpTransportInterface>> CreateSrtpProxied( |
| 45 const RtcpParameters& rtcp_parameters, |
| 46 PacketTransportInterface* rtp, |
| 47 PacketTransportInterface* rtcp, |
| 48 RtpTransportControllerAdapter* rtp_transport_controller); |
| 49 |
42 ~RtpTransportAdapter() override; | 50 ~RtpTransportAdapter() override; |
43 | 51 |
44 // RtpTransportInterface implementation. | 52 // RtpTransportInterface implementation. |
45 PacketTransportInterface* GetRtpPacketTransport() const override; | 53 PacketTransportInterface* GetRtpPacketTransport() const override; |
46 PacketTransportInterface* GetRtcpPacketTransport() const override; | 54 PacketTransportInterface* GetRtcpPacketTransport() const override; |
47 RTCError SetRtcpParameters(const RtcpParameters& parameters) override; | 55 RTCError SetRtcpParameters(const RtcpParameters& parameters) override; |
48 RtcpParameters GetRtcpParameters() const override { return rtcp_parameters_; } | 56 RtcpParameters GetRtcpParameters() const override { return rtcp_parameters_; } |
49 | 57 |
| 58 // SRTP specific implementation. |
| 59 RTCError SetSrtpSendKey(const cricket::CryptoParams& params) override; |
| 60 RTCError SetSrtpReceiveKey(const cricket::CryptoParams& params) override; |
| 61 |
50 // Methods used internally by OrtcFactory. | 62 // Methods used internally by OrtcFactory. |
51 RtpTransportControllerAdapter* rtp_transport_controller() { | 63 RtpTransportControllerAdapter* rtp_transport_controller() { |
52 return rtp_transport_controller_; | 64 return rtp_transport_controller_; |
53 } | 65 } |
54 void TakeOwnershipOfRtpTransportController( | 66 void TakeOwnershipOfRtpTransportController( |
55 std::unique_ptr<RtpTransportControllerInterface> controller); | 67 std::unique_ptr<RtpTransportControllerInterface> controller); |
56 | 68 |
57 // Used by RtpTransportControllerAdapter to tell when it should stop | 69 // Used by RtpTransportControllerAdapter to tell when it should stop |
58 // returning this transport from GetTransports(). | 70 // returning this transport from GetTransports(). |
59 sigslot::signal1<RtpTransportAdapter*> SignalDestroyed; | 71 sigslot::signal1<RtpTransportAdapter*> SignalDestroyed; |
60 | 72 |
| 73 // Used by the RtpTransportControllerAdapter to tell if an rtp sender or |
| 74 // receiver can be created. |
| 75 bool is_srtp_transport() { return is_srtp_transport_; } |
| 76 // Used by the RtpTransportControllerAdapter to set keys for senders and |
| 77 // receivers. |
| 78 rtc::Optional<cricket::CryptoParams> send_key() { return send_key_; } |
| 79 rtc::Optional<cricket::CryptoParams> receive_key() { return receive_key_; } |
| 80 |
61 protected: | 81 protected: |
62 RtpTransportAdapter* GetInternal() override { return this; } | 82 RtpTransportAdapter* GetInternal() override { return this; } |
63 | 83 |
64 private: | 84 private: |
65 RtpTransportAdapter(const RtcpParameters& rtcp_parameters, | 85 RtpTransportAdapter(const RtcpParameters& rtcp_parameters, |
66 PacketTransportInterface* rtp, | 86 PacketTransportInterface* rtp, |
67 PacketTransportInterface* rtcp, | 87 PacketTransportInterface* rtcp, |
68 RtpTransportControllerAdapter* rtp_transport_controller); | 88 RtpTransportControllerAdapter* rtp_transport_controller, |
| 89 bool is_srtp_transport); |
69 | 90 |
70 PacketTransportInterface* rtp_packet_transport_; | 91 PacketTransportInterface* rtp_packet_transport_; |
71 PacketTransportInterface* rtcp_packet_transport_; | 92 PacketTransportInterface* rtcp_packet_transport_; |
72 RtpTransportControllerAdapter* rtp_transport_controller_; | 93 RtpTransportControllerAdapter* rtp_transport_controller_; |
73 // Non-null if this class owns the transport controller. | 94 // Non-null if this class owns the transport controller. |
74 std::unique_ptr<RtpTransportControllerInterface> | 95 std::unique_ptr<RtpTransportControllerInterface> |
75 owned_rtp_transport_controller_; | 96 owned_rtp_transport_controller_; |
76 RtcpParameters rtcp_parameters_; | 97 RtcpParameters rtcp_parameters_; |
77 | 98 |
| 99 // SRTP specific members. |
| 100 rtc::Optional<cricket::CryptoParams> send_key_; |
| 101 rtc::Optional<cricket::CryptoParams> receive_key_; |
| 102 bool is_srtp_transport_; |
| 103 |
78 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RtpTransportAdapter); | 104 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RtpTransportAdapter); |
79 }; | 105 }; |
80 | 106 |
81 } // namespace webrtc | 107 } // namespace webrtc |
82 | 108 |
83 #endif // WEBRTC_ORTC_RTPTRANSPORTADAPTER_H_ | 109 #endif // WEBRTC_ORTC_RTPTRANSPORTADAPTER_H_ |
OLD | NEW |