RTCRtpTransceiver.h 5.4 KB

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