RTCRtpTransceiver.h 5.5 KB

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