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