Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 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 API_RTPTRANSCEIVERINTERFACE_H_ |
| 12 | #define API_RTPTRANSCEIVERINTERFACE_H_ |
| 13 | |
| 14 | #include <string> |
Steve Anton | 9158ef6 | 2017-11-27 13:01:52 -0800 | [diff] [blame] | 15 | #include <vector> |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 16 | |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame^] | 17 | #include "absl/types/optional.h" |
Danil Chapovalov | 6e9d895 | 2018-04-09 20:30:51 +0200 | [diff] [blame] | 18 | #include "api/array_view.h" |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 19 | #include "api/rtpreceiverinterface.h" |
| 20 | #include "api/rtpsenderinterface.h" |
| 21 | #include "rtc_base/refcount.h" |
| 22 | |
| 23 | namespace webrtc { |
| 24 | |
Steve Anton | 9158ef6 | 2017-11-27 13:01:52 -0800 | [diff] [blame] | 25 | // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiverdirection |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 26 | enum class RtpTransceiverDirection { |
| 27 | kSendRecv, |
| 28 | kSendOnly, |
| 29 | kRecvOnly, |
| 30 | kInactive |
| 31 | }; |
| 32 | |
Steve Anton | 9158ef6 | 2017-11-27 13:01:52 -0800 | [diff] [blame] | 33 | // Structure for initializing an RtpTransceiver in a call to |
| 34 | // PeerConnectionInterface::AddTransceiver. |
| 35 | // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiverinit |
| 36 | struct RtpTransceiverInit final { |
| 37 | // Direction of the RtpTransceiver. See RtpTransceiverInterface::direction(). |
| 38 | RtpTransceiverDirection direction = RtpTransceiverDirection::kSendRecv; |
| 39 | |
| 40 | // The added RtpTransceiver will be added to these streams. |
Seth Hampson | 513449e | 2018-03-06 09:35:56 -0800 | [diff] [blame] | 41 | std::vector<std::string> stream_ids; |
Steve Anton | 9158ef6 | 2017-11-27 13:01:52 -0800 | [diff] [blame] | 42 | |
| 43 | // TODO(bugs.webrtc.org/7600): Not implemented. |
| 44 | std::vector<RtpEncodingParameters> send_encodings; |
| 45 | }; |
| 46 | |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 47 | // The RtpTransceiverInterface maps to the RTCRtpTransceiver defined by the |
| 48 | // WebRTC specification. A transceiver represents a combination of an RtpSender |
| 49 | // and an RtpReceiver than share a common mid. As defined in JSEP, an |
| 50 | // RtpTransceiver is said to be associated with a media description if its mid |
| 51 | // property is non-null; otherwise, it is said to be disassociated. |
| 52 | // JSEP: https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-24 |
| 53 | // |
| 54 | // Note that RtpTransceivers are only supported when using PeerConnection with |
| 55 | // Unified Plan SDP. |
| 56 | // |
| 57 | // This class is thread-safe. |
| 58 | // |
| 59 | // WebRTC specification for RTCRtpTransceiver, the JavaScript analog: |
| 60 | // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver |
| 61 | class RtpTransceiverInterface : public rtc::RefCountInterface { |
| 62 | public: |
Steve Anton | 6947025 | 2018-02-09 11:43:08 -0800 | [diff] [blame] | 63 | // Media type of the transceiver. Any sender(s)/receiver(s) will have this |
| 64 | // type as well. |
| 65 | virtual cricket::MediaType media_type() const = 0; |
| 66 | |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 67 | // The mid attribute is the mid negotiated and present in the local and |
| 68 | // remote descriptions. Before negotiation is complete, the mid value may be |
| 69 | // null. After rollbacks, the value may change from a non-null value to null. |
| 70 | // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-mid |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame^] | 71 | virtual absl::optional<std::string> mid() const = 0; |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 72 | |
| 73 | // The sender attribute exposes the RtpSender corresponding to the RTP media |
| 74 | // that may be sent with the transceiver's mid. The sender is always present, |
| 75 | // regardless of the direction of media. |
| 76 | // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-sender |
| 77 | virtual rtc::scoped_refptr<RtpSenderInterface> sender() const = 0; |
| 78 | |
| 79 | // The receiver attribute exposes the RtpReceiver corresponding to the RTP |
| 80 | // media that may be received with the transceiver's mid. The receiver is |
| 81 | // always present, regardless of the direction of media. |
| 82 | // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-receiver |
| 83 | virtual rtc::scoped_refptr<RtpReceiverInterface> receiver() const = 0; |
| 84 | |
| 85 | // The stopped attribute indicates that the sender of this transceiver will no |
| 86 | // longer send, and that the receiver will no longer receive. It is true if |
| 87 | // either stop has been called or if setting the local or remote description |
| 88 | // has caused the RtpTransceiver to be stopped. |
| 89 | // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-stopped |
| 90 | virtual bool stopped() const = 0; |
| 91 | |
| 92 | // The direction attribute indicates the preferred direction of this |
| 93 | // transceiver, which will be used in calls to CreateOffer and CreateAnswer. |
| 94 | // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-direction |
| 95 | virtual RtpTransceiverDirection direction() const = 0; |
| 96 | |
| 97 | // Sets the preferred direction of this transceiver. An update of |
| 98 | // directionality does not take effect immediately. Instead, future calls to |
| 99 | // CreateOffer and CreateAnswer mark the corresponding media descriptions as |
| 100 | // sendrecv, sendonly, recvonly, or inactive. |
| 101 | // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-direction |
| 102 | virtual void SetDirection(RtpTransceiverDirection new_direction) = 0; |
| 103 | |
| 104 | // The current_direction attribute indicates the current direction negotiated |
| 105 | // for this transceiver. If this transceiver has never been represented in an |
| 106 | // offer/answer exchange, or if the transceiver is stopped, the value is null. |
| 107 | // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-currentdirection |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame^] | 108 | virtual absl::optional<RtpTransceiverDirection> current_direction() const = 0; |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 109 | |
| 110 | // The Stop method irreversibly stops the RtpTransceiver. The sender of this |
| 111 | // transceiver will no longer send, the receiver will no longer receive. |
| 112 | // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-stop |
| 113 | virtual void Stop() = 0; |
| 114 | |
| 115 | // The SetCodecPreferences method overrides the default codec preferences used |
| 116 | // by WebRTC for this transceiver. |
| 117 | // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-setcodecpreferences |
| 118 | // TODO(steveanton): Not implemented. |
| 119 | virtual void SetCodecPreferences( |
| 120 | rtc::ArrayView<RtpCodecCapability> codecs) = 0; |
| 121 | |
| 122 | protected: |
| 123 | virtual ~RtpTransceiverInterface() = default; |
| 124 | }; |
| 125 | |
| 126 | } // namespace webrtc |
| 127 | |
| 128 | #endif // API_RTPTRANSCEIVERINTERFACE_H_ |