RTCRtpReceiver.h 2.5 KB

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