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