RTCRtpReceiver.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright 2016 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/RTCMediaStreamTrack.h>
  13. #import <WebRTC/RTCRtpParameters.h>
  14. NS_ASSUME_NONNULL_BEGIN
  15. /** Represents the media type of the RtpReceiver. */
  16. typedef NS_ENUM(NSInteger, RTCRtpMediaType) {
  17. RTCRtpMediaTypeAudio,
  18. RTCRtpMediaTypeVideo,
  19. RTCRtpMediaTypeData,
  20. RTCRtpMediaTypeUnsupported,
  21. };
  22. @class RTC_OBJC_TYPE(RTCRtpReceiver);
  23. RTC_OBJC_EXPORT
  24. @protocol RTC_OBJC_TYPE
  25. (RTCRtpReceiverDelegate)<NSObject>
  26. /** Called when the first RTP packet is received.
  27. *
  28. * Note: Currently if there are multiple RtpReceivers of the same media type,
  29. * they will all call OnFirstPacketReceived at once.
  30. *
  31. * For example, if we create three audio receivers, A/B/C, they will listen to
  32. * the same signal from the underneath network layer. Whenever the first audio packet
  33. * is received, the underneath signal will be fired. All the receivers A/B/C will be
  34. * notified and the callback of the receiver's delegate will be called.
  35. *
  36. * The process is the same for video receivers.
  37. */
  38. - (void)rtpReceiver
  39. : (RTC_OBJC_TYPE(RTCRtpReceiver) *)rtpReceiver didReceiveFirstPacketForMediaType
  40. : (RTCRtpMediaType)mediaType;
  41. @end
  42. RTC_OBJC_EXPORT
  43. @protocol RTC_OBJC_TYPE
  44. (RTCRtpReceiver)<NSObject>
  45. /** A unique identifier for this receiver. */
  46. @property(nonatomic, readonly) NSString *receiverId;
  47. /** The currently active RTCRtpParameters, as defined in
  48. * https://www.w3.org/TR/webrtc/#idl-def-RTCRtpParameters.
  49. *
  50. * The WebRTC specification only defines RTCRtpParameters in terms of senders,
  51. * but this API also applies them to receivers, similar to ORTC:
  52. * http://ortc.org/wp-content/uploads/2016/03/ortc.html#rtcrtpparameters*.
  53. */
  54. @property(nonatomic, readonly) RTC_OBJC_TYPE(RTCRtpParameters) * parameters;
  55. /** The RTCMediaStreamTrack associated with the receiver.
  56. * Note: reading this property returns a new instance of
  57. * RTCMediaStreamTrack. Use isEqual: instead of == to compare
  58. * RTCMediaStreamTrack instances.
  59. */
  60. @property(nonatomic, readonly, nullable) RTC_OBJC_TYPE(RTCMediaStreamTrack) * track;
  61. /** The delegate for this RtpReceiver. */
  62. @property(nonatomic, weak) id<RTC_OBJC_TYPE(RTCRtpReceiverDelegate)> delegate;
  63. @end
  64. RTC_OBJC_EXPORT
  65. @interface RTC_OBJC_TYPE (RTCRtpReceiver) : NSObject <RTC_OBJC_TYPE(RTCRtpReceiver)>
  66. - (instancetype)init NS_UNAVAILABLE;
  67. @end
  68. NS_ASSUME_NONNULL_END