Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 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 | #import <Foundation/Foundation.h> |
| 12 | |
| 13 | #import "RTCMacros.h" |
| 14 | #import "RTCRtpReceiver.h" |
| 15 | #import "RTCRtpSender.h" |
| 16 | |
| 17 | NS_ASSUME_NONNULL_BEGIN |
| 18 | |
Harald Alvestrand | fcf5e7b | 2020-08-17 10:07:26 +0200 | [diff] [blame^] | 19 | extern NSString *const kRTCRtpTransceiverErrorDomain; |
| 20 | |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 21 | /** https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiverdirection */ |
| 22 | typedef NS_ENUM(NSInteger, RTCRtpTransceiverDirection) { |
| 23 | RTCRtpTransceiverDirectionSendRecv, |
| 24 | RTCRtpTransceiverDirectionSendOnly, |
| 25 | RTCRtpTransceiverDirectionRecvOnly, |
| 26 | RTCRtpTransceiverDirectionInactive, |
Markus Handell | 45c104b | 2020-03-11 10:51:13 +0100 | [diff] [blame] | 27 | RTCRtpTransceiverDirectionStopped |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 28 | }; |
| 29 | |
| 30 | /** Structure for initializing an RTCRtpTransceiver in a call to |
| 31 | * RTCPeerConnection.addTransceiver. |
| 32 | * https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiverinit |
| 33 | */ |
Piasy | e6caa9f | 2018-10-15 20:48:01 +0800 | [diff] [blame] | 34 | RTC_OBJC_EXPORT |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 35 | @interface RTC_OBJC_TYPE (RTCRtpTransceiverInit) : NSObject |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 36 | |
| 37 | /** Direction of the RTCRtpTransceiver. See RTCRtpTransceiver.direction. */ |
| 38 | @property(nonatomic) RTCRtpTransceiverDirection direction; |
| 39 | |
| 40 | /** The added RTCRtpTransceiver will be added to these streams. */ |
| 41 | @property(nonatomic) NSArray<NSString *> *streamIds; |
| 42 | |
| 43 | /** TODO(bugs.webrtc.org/7600): Not implemented. */ |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 44 | @property(nonatomic) NSArray<RTC_OBJC_TYPE(RTCRtpEncodingParameters) *> *sendEncodings; |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 45 | |
| 46 | @end |
| 47 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 48 | @class RTC_OBJC_TYPE(RTCRtpTransceiver); |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 49 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 50 | /** The RTCRtpTransceiver maps to the RTCRtpTransceiver defined by the |
| 51 | * WebRTC specification. A transceiver represents a combination of an RTCRtpSender |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 52 | * and an RTCRtpReceiver that share a common mid. As defined in JSEP, an |
| 53 | * RTCRtpTransceiver is said to be associated with a media description if its |
| 54 | * mid property is non-nil; otherwise, it is said to be disassociated. |
| 55 | * JSEP: https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-24 |
| 56 | * |
| 57 | * Note that RTCRtpTransceivers are only supported when using |
| 58 | * RTCPeerConnection with Unified Plan SDP. |
| 59 | * |
| 60 | * WebRTC specification for RTCRtpTransceiver, the JavaScript analog: |
| 61 | * https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver |
| 62 | */ |
Mirko Bonadei | e8d5724 | 2018-09-17 10:22:56 +0200 | [diff] [blame] | 63 | RTC_OBJC_EXPORT |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 64 | @protocol RTC_OBJC_TYPE |
| 65 | (RTCRtpTransceiver)<NSObject> |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 66 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 67 | /** Media type of the transceiver. The sender and receiver will also have this |
| 68 | * type. |
| 69 | */ |
| 70 | @property(nonatomic, readonly) RTCRtpMediaType mediaType; |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 71 | |
| 72 | /** The mid attribute is the mid negotiated and present in the local and |
| 73 | * remote descriptions. Before negotiation is complete, the mid value may be |
| 74 | * nil. After rollbacks, the value may change from a non-nil value to nil. |
| 75 | * https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-mid |
| 76 | */ |
| 77 | @property(nonatomic, readonly) NSString *mid; |
| 78 | |
| 79 | /** The sender attribute exposes the RTCRtpSender corresponding to the RTP |
| 80 | * media that may be sent with the transceiver's mid. The sender is always |
| 81 | * present, regardless of the direction of media. |
| 82 | * https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-sender |
| 83 | */ |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 84 | @property(nonatomic, readonly) RTC_OBJC_TYPE(RTCRtpSender) * sender; |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 85 | |
| 86 | /** The receiver attribute exposes the RTCRtpReceiver corresponding to the RTP |
| 87 | * media that may be received with the transceiver's mid. The receiver is |
| 88 | * always present, regardless of the direction of media. |
| 89 | * https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-receiver |
| 90 | */ |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 91 | @property(nonatomic, readonly) RTC_OBJC_TYPE(RTCRtpReceiver) * receiver; |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 92 | |
| 93 | /** The isStopped attribute indicates that the sender of this transceiver will |
| 94 | * no longer send, and that the receiver will no longer receive. It is true if |
| 95 | * either stop has been called or if setting the local or remote description |
| 96 | * has caused the RTCRtpTransceiver to be stopped. |
| 97 | * https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-stopped |
| 98 | */ |
| 99 | @property(nonatomic, readonly) BOOL isStopped; |
| 100 | |
| 101 | /** The direction attribute indicates the preferred direction of this |
| 102 | * transceiver, which will be used in calls to createOffer and createAnswer. |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 103 | * https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-direction |
| 104 | */ |
Harald Alvestrand | fcf5e7b | 2020-08-17 10:07:26 +0200 | [diff] [blame^] | 105 | @property(nonatomic, readonly) RTCRtpTransceiverDirection direction; |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 106 | |
| 107 | /** The currentDirection attribute indicates the current direction negotiated |
| 108 | * for this transceiver. If this transceiver has never been represented in an |
| 109 | * offer/answer exchange, or if the transceiver is stopped, the value is not |
| 110 | * present and this method returns NO. |
| 111 | * https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-currentdirection |
| 112 | */ |
| 113 | - (BOOL)currentDirection:(RTCRtpTransceiverDirection *)currentDirectionOut; |
| 114 | |
| 115 | /** The stop method irreversibly stops the RTCRtpTransceiver. The sender of |
| 116 | * this transceiver will no longer send, the receiver will no longer receive. |
| 117 | * https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-stop |
| 118 | */ |
Harald Alvestrand | 6060df5 | 2020-08-11 09:54:02 +0200 | [diff] [blame] | 119 | - (void)stopInternal; |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 120 | |
Harald Alvestrand | fcf5e7b | 2020-08-17 10:07:26 +0200 | [diff] [blame^] | 121 | /** An update of directionality does not take effect immediately. Instead, |
| 122 | * future calls to createOffer and createAnswer mark the corresponding media |
| 123 | * descriptions as sendrecv, sendonly, recvonly, or inactive. |
| 124 | * https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-direction |
| 125 | */ |
| 126 | - (void)setDirection:(RTCRtpTransceiverDirection)direction error:(NSError **)error; |
| 127 | |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 128 | @end |
| 129 | |
Mirko Bonadei | e8d5724 | 2018-09-17 10:22:56 +0200 | [diff] [blame] | 130 | RTC_OBJC_EXPORT |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 131 | @interface RTC_OBJC_TYPE (RTCRtpTransceiver) : NSObject <RTC_OBJC_TYPE(RTCRtpTransceiver)> |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 132 | |
| 133 | - (instancetype)init NS_UNAVAILABLE; |
| 134 | |
| 135 | @end |
| 136 | |
| 137 | NS_ASSUME_NONNULL_END |