Chromium Code Reviews| 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_API_ORTC_RTPTRANSPORTINTERFACE_H_ | 11 #ifndef WEBRTC_API_ORTC_RTPTRANSPORTINTERFACE_H_ |
| 12 #define WEBRTC_API_ORTC_RTPTRANSPORTINTERFACE_H_ | 12 #define WEBRTC_API_ORTC_RTPTRANSPORTINTERFACE_H_ |
| 13 | 13 |
| 14 #include <string> | 14 #include <string> |
| 15 | 15 |
| 16 #include "webrtc/api/ortc/packettransportinterface.h" | 16 #include "webrtc/api/ortc/packettransportinterface.h" |
| 17 #include "webrtc/api/rtcerror.h" | 17 #include "webrtc/api/rtcerror.h" |
| 18 #include "webrtc/common_types.h" | |
| 18 #include "webrtc/rtc_base/optional.h" | 19 #include "webrtc/rtc_base/optional.h" |
| 19 | 20 |
| 20 namespace webrtc { | 21 namespace webrtc { |
| 21 | 22 |
| 22 class RtpTransportAdapter; | 23 class RtpTransportAdapter; |
| 23 | 24 |
| 24 struct RtcpParameters { | 25 struct RtcpParameters final { |
| 25 // The SSRC to be used in the "SSRC of packet sender" field. If not set, one | 26 // The SSRC to be used in the "SSRC of packet sender" field. If not set, one |
| 26 // will be chosen by the implementation. | 27 // will be chosen by the implementation. |
| 27 // TODO(deadbeef): Not implemented. | 28 // TODO(deadbeef): Not implemented. |
| 28 rtc::Optional<uint32_t> ssrc; | 29 rtc::Optional<uint32_t> ssrc; |
| 29 | 30 |
| 30 // The Canonical Name (CNAME) used by RTCP (e.g. in SDES messages). | 31 // The Canonical Name (CNAME) used by RTCP (e.g. in SDES messages). |
| 31 // | 32 // |
| 32 // If empty in the construction of the RtpTransport, one will be generated by | 33 // If empty in the construction of the RtpTransport, one will be generated by |
| 33 // the implementation, and returned in GetRtcpParameters. Multiple | 34 // the implementation, and returned in GetRtcpParameters. Multiple |
| 34 // RtpTransports created by the same OrtcFactory will use the same generated | 35 // RtpTransports created by the same OrtcFactory will use the same generated |
| 35 // CNAME. | 36 // CNAME. |
| 36 // | 37 // |
| 37 // If empty when passed into SetRtcpParameters, the CNAME simply won't be | 38 // If empty when passed into SetParameters, the CNAME simply won't be |
| 38 // modified. | 39 // modified. |
| 39 std::string cname; | 40 std::string cname; |
| 40 | 41 |
| 41 // Send reduced-size RTCP? | 42 // Send reduced-size RTCP? |
| 42 bool reduced_size = false; | 43 bool reduced_size = false; |
| 43 | 44 |
| 44 // Send RTCP multiplexed on the RTP transport? | 45 // Send RTCP multiplexed on the RTP transport? |
| 45 bool mux = true; | 46 bool mux = true; |
| 46 | 47 |
| 47 bool operator==(const RtcpParameters& o) const { | 48 bool operator==(const RtcpParameters& o) const { |
| 48 return ssrc == o.ssrc && cname == o.cname && | 49 return ssrc == o.ssrc && cname == o.cname && |
| 49 reduced_size == o.reduced_size && mux == o.mux; | 50 reduced_size == o.reduced_size && mux == o.mux; |
| 50 } | 51 } |
| 51 bool operator!=(const RtcpParameters& o) const { return !(*this == o); } | 52 bool operator!=(const RtcpParameters& o) const { return !(*this == o); } |
| 52 }; | 53 }; |
| 53 | 54 |
| 55 struct RtpTransportParameters final { | |
| 56 RtcpParameters rtcp; | |
| 57 | |
| 58 // Enabled periodic sending of keep-alive packets, that help prevent timeouts | |
| 59 // on the network level, such as NAT bindings. See RFC6263 section 4.6. | |
| 60 RtpKeepAliveConfig keepalive; | |
| 61 | |
| 62 bool operator==(const RtpTransportParameters& o) const { | |
| 63 return rtcp == o.rtcp && keepalive == o.keepalive; | |
| 64 } | |
| 65 bool operator!=(const RtpTransportParameters& o) const { | |
| 66 return !(*this == o); | |
| 67 } | |
| 68 }; | |
| 69 | |
| 54 // Base class for different types of RTP transports that can be created by an | 70 // Base class for different types of RTP transports that can be created by an |
| 55 // OrtcFactory. Used by RtpSenders/RtpReceivers. | 71 // OrtcFactory. Used by RtpSenders/RtpReceivers. |
| 56 // | 72 // |
| 57 // This is not present in the standard ORTC API, but exists here for a few | 73 // This is not present in the standard ORTC API, but exists here for a few |
| 58 // reasons. Firstly, it allows different types of RTP transports to be used: | 74 // reasons. Firstly, it allows different types of RTP transports to be used: |
| 59 // DTLS-SRTP (which is required for the web), but also SDES-SRTP and | 75 // DTLS-SRTP (which is required for the web), but also SDES-SRTP and |
| 60 // unencrypted RTP. It also simplifies the handling of RTCP muxing, and | 76 // unencrypted RTP. It also simplifies the handling of RTCP muxing, and |
| 61 // provides a better API point for it. | 77 // provides a better API point for it. |
| 62 // | 78 // |
| 63 // Note that Edge's implementation of ORTC provides a similar API point, called | 79 // Note that Edge's implementation of ORTC provides a similar API point, called |
| 64 // RTCSrtpSdesTransport: | 80 // RTCSrtpSdesTransport: |
| 65 // https://msdn.microsoft.com/en-us/library/mt502527(v=vs.85).aspx | 81 // https://msdn.microsoft.com/en-us/library/mt502527(v=vs.85).aspx |
| 66 class RtpTransportInterface { | 82 class RtpTransportInterface { |
| 67 public: | 83 public: |
| 68 virtual ~RtpTransportInterface() {} | 84 virtual ~RtpTransportInterface() {} |
| 69 | 85 |
| 70 // Returns packet transport that's used to send RTP packets. | 86 // Returns packet transport that's used to send RTP packets. |
| 71 virtual PacketTransportInterface* GetRtpPacketTransport() const = 0; | 87 virtual PacketTransportInterface* GetRtpPacketTransport() const = 0; |
| 72 | 88 |
| 73 // Returns separate packet transport that's used to send RTCP packets. If | 89 // Returns separate packet transport that's used to send RTCP packets. If |
| 74 // RTCP multiplexing is being used, returns null. | 90 // RTCP multiplexing is being used, returns null. |
| 75 virtual PacketTransportInterface* GetRtcpPacketTransport() const = 0; | 91 virtual PacketTransportInterface* GetRtcpPacketTransport() const = 0; |
| 76 | 92 |
| 77 // Set/get RTCP params. Can be used to enable RTCP muxing or reduced-size | 93 // Set/get RTP/RTCP transport params. Can be used to enable RTCP muxing or |
| 78 // RTCP if initially not enabled. | 94 // reduced-size RTCP if initially not enabled. |
| 79 // | 95 // |
| 80 // Changing |mux| from "true" to "false" is not allowed, and changing the | 96 // Changing |mux| from "true" to "false" is not allowed, and changing the |
| 81 // CNAME is currently unsupported. | 97 // CNAME is currently unsupported. |
| 82 virtual RTCError SetRtcpParameters(const RtcpParameters& parameters) = 0; | 98 // RTP keep-alive settings need to be set before creating any send-streams, |
|
Taylor Brandstetter
2017/08/03 01:18:03
nit: Someone using this API probably doesn't know
sprang_webrtc
2017/08/03 13:08:14
How about changing "send stream" to "media channel
Taylor Brandstetter
2017/08/03 16:50:36
Again, we don't define what a "media channel" is i
sprang_webrtc
2017/08/07 10:39:36
Alright, "before an RtpSender has started sending"
| |
| 99 // altering the payload type or timeout interval after this point is not | |
| 100 // supported. | |
| 101 virtual RTCError SetParameters(const RtpTransportParameters& parameters) = 0; | |
| 83 // Returns last set or constructed-with parameters. If |cname| was empty in | 102 // Returns last set or constructed-with parameters. If |cname| was empty in |
| 84 // construction, the generated CNAME will be present in the returned | 103 // construction, the generated CNAME will be present in the returned |
| 85 // parameters (see above). | 104 // parameters (see above). |
| 86 virtual RtcpParameters GetRtcpParameters() const = 0; | 105 virtual RtpTransportParameters GetParameters() const = 0; |
| 87 | 106 |
| 88 protected: | 107 protected: |
| 89 // Only for internal use. Returns a pointer to an internal interface, for use | 108 // Only for internal use. Returns a pointer to an internal interface, for use |
| 90 // by the implementation. | 109 // by the implementation. |
| 91 virtual RtpTransportAdapter* GetInternal() = 0; | 110 virtual RtpTransportAdapter* GetInternal() = 0; |
| 92 | 111 |
| 93 // Classes that can use this internal interface. | 112 // Classes that can use this internal interface. |
| 94 friend class OrtcFactory; | 113 friend class OrtcFactory; |
| 95 friend class OrtcRtpSenderAdapter; | 114 friend class OrtcRtpSenderAdapter; |
| 96 friend class OrtcRtpReceiverAdapter; | 115 friend class OrtcRtpReceiverAdapter; |
| 97 friend class RtpTransportControllerAdapter; | 116 friend class RtpTransportControllerAdapter; |
| 98 friend class RtpTransportAdapter; | 117 friend class RtpTransportAdapter; |
| 99 }; | 118 }; |
| 100 | 119 |
| 101 } // namespace webrtc | 120 } // namespace webrtc |
| 102 | 121 |
| 103 #endif // WEBRTC_API_ORTC_RTPTRANSPORTINTERFACE_H_ | 122 #endif // WEBRTC_API_ORTC_RTPTRANSPORTINTERFACE_H_ |
| OLD | NEW |