RTCRtpTransceiver.h 5.0 KB

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