Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(225)

Unified Diff: webrtc/ortc/rtptransportadapter.h

Issue 2714813004: Create the SrtpTransportInterface. (Closed)
Patch Set: Merge and modified the tests. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/ortc/rtptransportadapter.h
diff --git a/webrtc/ortc/rtptransportadapter.h b/webrtc/ortc/rtptransportadapter.h
index 169ae613db3385e46a8df36dfc8c2c8906fae137..917c2c6c0673c5e434225f8d76dc9030a3cf8f7f 100644
--- a/webrtc/ortc/rtptransportadapter.h
+++ b/webrtc/ortc/rtptransportadapter.h
@@ -14,7 +14,7 @@
#include <memory>
#include <vector>
-#include "webrtc/api/ortc/rtptransportinterface.h"
+#include "webrtc/api/ortc/srtptransportinterface.h"
#include "webrtc/api/rtcerror.h"
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/sigslot.h"
@@ -24,13 +24,14 @@
namespace webrtc {
-// Implementation of RtpTransportInterface to be used with RtpSenderAdapter,
-// RtpReceiverAdapter, and RtpTransportControllerAdapter classes.
+// Implementation of SrtpTransportInterface to be used with RtpSenderAdapter,
+// RtpReceiverAdapter, and RtpTransportControllerAdapter classes. This class
+// is used to implement both a secure and insecure RTP transport.
//
// TODO(deadbeef): When BaseChannel is split apart into separate
// "RtpTransport"/"RtpTransceiver"/"RtpSender"/"RtpReceiver" objects, this
// adapter object can be removed.
-class RtpTransportAdapter : public RtpTransportInterface {
+class RtpTransportAdapter : public SrtpTransportInterface {
public:
// |rtp| can't be null. |rtcp| can if RTCP muxing is used immediately (meaning
// |rtcp_parameters.mux| is also true).
@@ -39,6 +40,13 @@ class RtpTransportAdapter : public RtpTransportInterface {
PacketTransportInterface* rtp,
PacketTransportInterface* rtcp,
RtpTransportControllerAdapter* rtp_transport_controller);
+
+ static RTCErrorOr<std::unique_ptr<SrtpTransportInterface>> CreateSrtpProxied(
+ const RtcpParameters& rtcp_parameters,
+ PacketTransportInterface* rtp,
+ PacketTransportInterface* rtcp,
+ RtpTransportControllerAdapter* rtp_transport_controller);
+
~RtpTransportAdapter() override;
// RtpTransportInterface implementation.
@@ -47,6 +55,10 @@ class RtpTransportAdapter : public RtpTransportInterface {
RTCError SetRtcpParameters(const RtcpParameters& parameters) override;
RtcpParameters GetRtcpParameters() const override { return rtcp_parameters_; }
+ // SRTP specific implementation.
+ RTCError SetSrtpSendKey(const cricket::CryptoParams& params) override;
+ RTCError SetSrtpReceiveKey(const cricket::CryptoParams& params) override;
+
// Methods used internally by OrtcFactory.
RtpTransportControllerAdapter* rtp_transport_controller() {
return rtp_transport_controller_;
@@ -58,6 +70,15 @@ class RtpTransportAdapter : public RtpTransportInterface {
// returning this transport from GetTransports().
sigslot::signal1<RtpTransportAdapter*> SignalDestroyed;
+ // Used by the RtpTransportControllerAdapter to tell if an rtp sender or
+ // receiver should be created.
Taylor Brandstetter 2017/03/01 19:18:08 nit: "can be created" instead of "should be"?
Zhi Huang 2017/03/02 23:35:39 Done.
+ bool is_srtp_transport() { return is_srtp_transport_; }
+ bool key_set() { return have_send_key_ && have_receive_key_; }
Taylor Brandstetter 2017/03/01 19:18:08 nit: "keys_set"?
Zhi Huang 2017/03/02 23:35:39 Done.
+ // Used by the RtpTransportControllerAdapter to set keys for senders and
+ // receivers.
+ cricket::CryptoParams send_key() { return send_key_; }
+ cricket::CryptoParams receive_key() { return receive_key_; }
+
protected:
RtpTransportAdapter* GetInternal() override { return this; }
@@ -65,7 +86,8 @@ class RtpTransportAdapter : public RtpTransportInterface {
RtpTransportAdapter(const RtcpParameters& rtcp_parameters,
PacketTransportInterface* rtp,
PacketTransportInterface* rtcp,
- RtpTransportControllerAdapter* rtp_transport_controller);
+ RtpTransportControllerAdapter* rtp_transport_controller,
+ bool is_srtp_transport);
PacketTransportInterface* rtp_packet_transport_;
PacketTransportInterface* rtcp_packet_transport_;
@@ -75,6 +97,13 @@ class RtpTransportAdapter : public RtpTransportInterface {
owned_rtp_transport_controller_;
RtcpParameters rtcp_parameters_;
+ // SRTP specific members.
+ cricket::CryptoParams send_key_;
+ cricket::CryptoParams receive_key_;
+ bool is_srtp_transport_;
+ bool have_send_key_;
+ bool have_receive_key_;
Taylor Brandstetter 2017/03/01 19:18:08 nit: have_send_key_ and have_receive_key_ can defa
Zhi Huang 2017/03/02 23:35:39 Done.
+
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RtpTransportAdapter);
};

Powered by Google App Engine
This is Rietveld 408576698