RTCRtpReceiver.h 2.7 KB

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