xref: /aosp_15_r20/external/webrtc/sdk/objc/api/peerconnection/RTCRtpReceiver.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
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,
24   RTCRtpMediaTypeUnsupported,
25 };
26 
27 @class RTC_OBJC_TYPE(RTCRtpReceiver);
28 
29 RTC_OBJC_EXPORT
30 @protocol RTC_OBJC_TYPE
31 (RTCRtpReceiverDelegate)<NSObject>
32 
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;
48 
49 @end
50 
51 RTC_OBJC_EXPORT
52 @protocol RTC_OBJC_TYPE
53 (RTCRtpReceiver)<NSObject>
54 
55     /** A unique identifier for this receiver. */
56     @property(nonatomic, readonly) NSString *receiverId;
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  */
65 @property(nonatomic, readonly) RTC_OBJC_TYPE(RTCRtpParameters) * parameters;
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  */
72 @property(nonatomic, readonly, nullable) RTC_OBJC_TYPE(RTCMediaStreamTrack) * track;
73 
74 /** The delegate for this RtpReceiver. */
75 @property(nonatomic, weak) id<RTC_OBJC_TYPE(RTCRtpReceiverDelegate)> delegate;
76 
77 @end
78 
79 RTC_OBJC_EXPORT
80 @interface RTC_OBJC_TYPE (RTCRtpReceiver) : NSObject <RTC_OBJC_TYPE(RTCRtpReceiver)>
81 
82 - (instancetype)init NS_UNAVAILABLE;
83 
84 @end
85 
86 NS_ASSUME_NONNULL_END
87