OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #import <Foundation/Foundation.h> | 11 #import <Foundation/Foundation.h> |
12 | 12 |
13 #import <WebRTC/RTCMacros.h> | 13 #import <WebRTC/RTCMacros.h> |
14 | 14 |
15 @class RTCVideoFrame; | 15 @class RTCVideoFrame; |
16 | 16 |
17 NS_ASSUME_NONNULL_BEGIN | 17 NS_ASSUME_NONNULL_BEGIN |
18 | 18 |
19 /** Represents an encoded frame's type. */ | 19 /** Represents an encoded frame's type. */ |
20 typedef NS_ENUM(NSUInteger, RTCFrameType) { | 20 typedef NS_ENUM(NSUInteger, RTCFrameType) { |
21 RTCFrameTypeEmptyFrame, | 21 RTCFrameTypeEmptyFrame = 0, |
22 RTCFrameTypeVideoFrameKey, | 22 RTCFrameTypeAudioFrameSpeech = 1, |
23 RTCFrameTypeVideoFrameDelta, | 23 RTCFrameTypeAudioFrameCN = 2, |
| 24 RTCFrameTypeVideoFrameKey = 3, |
| 25 RTCFrameTypeVideoFrameDelta = 4, |
| 26 }; |
| 27 |
| 28 typedef NS_ENUM(NSUInteger, RTCVideoContentType) { |
| 29 RTCVideoContentTypeUnspecified, |
| 30 RTCVideoContentTypeScreenshare, |
24 }; | 31 }; |
25 | 32 |
26 /** Represents an encoded frame. Corresponds to webrtc::EncodedImage. */ | 33 /** Represents an encoded frame. Corresponds to webrtc::EncodedImage. */ |
27 RTC_EXPORT | 34 RTC_EXPORT |
28 @interface RTCEncodedImage : NSObject | 35 @interface RTCEncodedImage : NSObject |
29 | 36 |
30 @property(nonatomic, strong) NSData *buffer; | 37 @property(nonatomic, strong) NSData *buffer; |
31 @property(nonatomic, assign) int encodedWidth; | 38 @property(nonatomic, assign) int encodedWidth; |
32 @property(nonatomic, assign) int encodedHeight; | 39 @property(nonatomic, assign) int encodedHeight; |
33 @property(nonatomic, assign) uint32_t timeStamp; | 40 @property(nonatomic, assign) uint32_t timeStamp; |
34 @property(nonatomic, assign) long captureTimeMs; | 41 @property(nonatomic, assign) long captureTimeMs; |
35 @property(nonatomic, assign) long ntpTimeMs; | 42 @property(nonatomic, assign) long ntpTimeMs; |
36 @property(nonatomic, assign) BOOL isTimingFrame; | 43 @property(nonatomic, assign) BOOL isTimingFrame; |
37 @property(nonatomic, assign) long encodeStartMs; | 44 @property(nonatomic, assign) long encodeStartMs; |
38 @property(nonatomic, assign) long encodeFinishMs; | 45 @property(nonatomic, assign) long encodeFinishMs; |
39 @property(nonatomic, assign) RTCFrameType frameType; | 46 @property(nonatomic, assign) RTCFrameType frameType; |
40 @property(nonatomic, assign) int rotation; | 47 @property(nonatomic, assign) int rotation; |
41 @property(nonatomic, assign) BOOL completeFrame; | 48 @property(nonatomic, assign) BOOL completeFrame; |
42 @property(nonatomic, strong) NSNumber *qp; | 49 @property(nonatomic, strong) NSNumber *qp; |
| 50 @property(nonatomic, assign) RTCVideoContentType contentType; |
43 | 51 |
44 @end | 52 @end |
45 | 53 |
46 /** Information for header. Corresponds to webrtc::RTPFragmentationHeader. */ | 54 /** Information for header. Corresponds to webrtc::RTPFragmentationHeader. */ |
47 RTC_EXPORT | 55 RTC_EXPORT |
48 @interface RTCRtpFragmentationHeader : NSObject | 56 @interface RTCRtpFragmentationHeader : NSObject |
49 | 57 |
50 @property(nonatomic, strong) NSArray<NSNumber *> *fragmentationOffset; | 58 @property(nonatomic, strong) NSArray<NSNumber *> *fragmentationOffset; |
51 @property(nonatomic, strong) NSArray<NSNumber *> *fragmentationLength; | 59 @property(nonatomic, strong) NSArray<NSNumber *> *fragmentationLength; |
52 @property(nonatomic, strong) NSArray<NSNumber *> *fragmentationTimeDiff; | 60 @property(nonatomic, strong) NSArray<NSNumber *> *fragmentationTimeDiff; |
53 @property(nonatomic, strong) NSArray<NSNumber *> *fragmentationPlType; | 61 @property(nonatomic, strong) NSArray<NSNumber *> *fragmentationPlType; |
54 | 62 |
55 @end | 63 @end |
56 | 64 |
57 /** Implement this protocol to pass codec specific info from the encoder. | 65 /** Implement this protocol to pass codec specific info from the encoder. |
58 * Corresponds to webrtc::CodecSpecificInfo. | 66 * Corresponds to webrtc::CodecSpecificInfo. |
59 */ | 67 */ |
60 RTC_EXPORT | 68 RTC_EXPORT |
61 @protocol RTCCodecSpecificInfo <NSObject> | 69 @protocol RTCCodecSpecificInfo <NSObject> |
62 | 70 |
63 @end | 71 @end |
64 | 72 |
| 73 /** Class for H264 specific config. */ |
| 74 typedef NS_ENUM(NSUInteger, RTCH264PacketizationMode) { |
| 75 RTCH264PacketizationModeNonInterleaved = 0, // Mode 1 - STAP-A, FU-A is allow
ed |
| 76 RTCH264PacketizationModeSingleNalUnit // Mode 0 - only single NALU allo
wed |
| 77 }; |
| 78 |
| 79 RTC_EXPORT |
| 80 @interface RTCCodecSpecificInfoH264 : NSObject<RTCCodecSpecificInfo> |
| 81 |
| 82 @property(nonatomic, assign) RTCH264PacketizationMode packetizationMode; |
| 83 |
| 84 @end |
| 85 |
65 /** Callback block for encoder. */ | 86 /** Callback block for encoder. */ |
66 typedef void (^RTCVideoEncoderCallback)(RTCEncodedImage *frame, | 87 typedef BOOL (^RTCVideoEncoderCallback)(RTCEncodedImage *frame, |
67 id<RTCCodecSpecificInfo> info, | 88 id<RTCCodecSpecificInfo> info, |
68 RTCRtpFragmentationHeader *header); | 89 RTCRtpFragmentationHeader *header); |
69 | 90 |
70 /** Callback block for decoder. */ | 91 /** Callback block for decoder. */ |
71 typedef void (^RTCVideoDecoderCallback)(RTCVideoFrame *frame); | 92 typedef void (^RTCVideoDecoderCallback)(RTCVideoFrame *frame); |
72 | 93 |
| 94 typedef NS_ENUM(NSUInteger, RTCVideoCodecMode) { |
| 95 RTCVideoCodecModeRealtimeVideo, |
| 96 RTCVideoCodecModeScreensharing, |
| 97 }; |
| 98 |
73 /** Holds information to identify a codec. Corresponds to cricket::VideoCodec. *
/ | 99 /** Holds information to identify a codec. Corresponds to cricket::VideoCodec. *
/ |
74 RTC_EXPORT | 100 RTC_EXPORT |
75 @interface RTCVideoCodecInfo : NSObject | 101 @interface RTCVideoCodecInfo : NSObject |
76 | 102 |
77 - (instancetype)initWithPayload:(NSInteger)payload | 103 - (instancetype)initWithPayload:(NSInteger)payload |
78 name:(NSString *)name | 104 name:(NSString *)name |
79 parameters:(NSDictionary<NSString *, NSString *> *)paramete
rs; | 105 parameters:(NSDictionary<NSString *, NSString *> *)paramete
rs; |
80 | 106 |
81 @property(nonatomic, readonly) NSInteger payload; | 107 @property(nonatomic, readonly) NSInteger payload; |
82 @property(nonatomic, readonly) NSString *name; | 108 @property(nonatomic, readonly) NSString *name; |
(...skipping 11 matching lines...) Expand all Loading... |
94 @property(nonatomic, assign) unsigned short height; | 120 @property(nonatomic, assign) unsigned short height; |
95 | 121 |
96 @property(nonatomic, assign) unsigned int startBitrate; // kilobits/sec. | 122 @property(nonatomic, assign) unsigned int startBitrate; // kilobits/sec. |
97 @property(nonatomic, assign) unsigned int maxBitrate; | 123 @property(nonatomic, assign) unsigned int maxBitrate; |
98 @property(nonatomic, assign) unsigned int minBitrate; | 124 @property(nonatomic, assign) unsigned int minBitrate; |
99 @property(nonatomic, assign) unsigned int targetBitrate; | 125 @property(nonatomic, assign) unsigned int targetBitrate; |
100 | 126 |
101 @property(nonatomic, assign) uint32_t maxFramerate; | 127 @property(nonatomic, assign) uint32_t maxFramerate; |
102 | 128 |
103 @property(nonatomic, assign) unsigned int qpMax; | 129 @property(nonatomic, assign) unsigned int qpMax; |
| 130 @property(nonatomic, assign) RTCVideoCodecMode mode; |
104 | 131 |
105 @end | 132 @end |
106 | 133 |
107 /** QP thresholds for encoder. Corresponds to webrtc::VideoEncoder::QpThresholds
. */ | 134 /** QP thresholds for encoder. Corresponds to webrtc::VideoEncoder::QpThresholds
. */ |
108 RTC_EXPORT | 135 RTC_EXPORT |
109 @interface RTCVideoEncoderQpThresholds : NSObject | 136 @interface RTCVideoEncoderQpThresholds : NSObject |
110 | 137 |
111 - (instancetype)initWithThresholdsLow:(NSInteger)low high:(NSInteger)high; | 138 - (instancetype)initWithThresholdsLow:(NSInteger)low high:(NSInteger)high; |
112 | 139 |
113 @property(nonatomic, readonly) NSInteger low; | 140 @property(nonatomic, readonly) NSInteger low; |
114 @property(nonatomic, readonly) NSInteger high; | 141 @property(nonatomic, readonly) NSInteger high; |
115 | 142 |
116 @end | 143 @end |
117 | 144 |
118 /** Protocol for encoder implementations. */ | 145 /** Protocol for encoder implementations. */ |
119 RTC_EXPORT | 146 RTC_EXPORT |
120 @protocol RTCVideoEncoder <NSObject> | 147 @protocol RTCVideoEncoder <NSObject> |
121 | 148 |
122 - (void)setCallback:(RTCVideoEncoderCallback)callback; | 149 - (void)setCallback:(RTCVideoEncoderCallback)callback; |
123 - (NSInteger)startEncodeWithSettings:(RTCVideoEncoderSettings *)settings | 150 - (NSInteger)startEncodeWithSettings:(RTCVideoEncoderSettings *)settings |
124 numberOfCores:(int)numberOfCores; | 151 numberOfCores:(int)numberOfCores; |
125 - (NSInteger)releaseEncoder; | 152 - (NSInteger)releaseEncoder; |
126 - (void)destroy; | |
127 - (NSInteger)encode:(RTCVideoFrame *)frame | 153 - (NSInteger)encode:(RTCVideoFrame *)frame |
128 codecSpecificInfo:(id<RTCCodecSpecificInfo>)info | 154 codecSpecificInfo:(id<RTCCodecSpecificInfo>)info |
129 frameTypes:(NSArray<NSNumber *> *)frameTypes; | 155 frameTypes:(NSArray<NSNumber *> *)frameTypes; |
130 - (BOOL)setBitrate:(uint32_t)bitrateKbit framerate:(uint32_t)framerate; | 156 - (int)setBitrate:(uint32_t)bitrateKbit framerate:(uint32_t)framerate; |
131 - (NSString *)implementationName; | 157 - (NSString *)implementationName; |
132 | 158 |
133 /** Returns QP scaling settings for encoder. The quality scaler adjusts the reso
lution in order to | 159 /** Returns QP scaling settings for encoder. The quality scaler adjusts the reso
lution in order to |
134 * keep the QP from the encoded images within the given range. Returning nil fr
om this function | 160 * keep the QP from the encoded images within the given range. Returning nil fr
om this function |
135 * disables quality scaling. */ | 161 * disables quality scaling. */ |
136 - (RTCVideoEncoderQpThresholds *)scalingSettings; | 162 - (RTCVideoEncoderQpThresholds *)scalingSettings; |
137 | 163 |
138 @end | 164 @end |
139 | 165 |
140 /** Protocol for decoder implementations. */ | 166 /** Protocol for decoder implementations. */ |
141 RTC_EXPORT | 167 RTC_EXPORT |
142 @protocol RTCVideoDecoder <NSObject> | 168 @protocol RTCVideoDecoder <NSObject> |
143 | 169 |
144 - (void)setCallback:(RTCVideoDecoderCallback)callback; | 170 - (void)setCallback:(RTCVideoDecoderCallback)callback; |
145 - (NSInteger)startDecodeWithSettings:(RTCVideoEncoderSettings *)settings | 171 - (NSInteger)startDecodeWithSettings:(RTCVideoEncoderSettings *)settings |
146 numberOfCores:(int)numberOfCores; | 172 numberOfCores:(int)numberOfCores; |
147 - (NSInteger)releaseDecoder; | 173 - (NSInteger)releaseDecoder; |
148 - (void)destroy; | |
149 - (NSInteger)decode:(RTCEncodedImage *)encodedImage | 174 - (NSInteger)decode:(RTCEncodedImage *)encodedImage |
150 missingFrames:(BOOL)missingFrames | 175 missingFrames:(BOOL)missingFrames |
151 fragmentationHeader:(RTCRtpFragmentationHeader *)fragmentationHeader | 176 fragmentationHeader:(RTCRtpFragmentationHeader *)fragmentationHeader |
152 codecSpecificInfo:(__nullable id<RTCCodecSpecificInfo>)info | 177 codecSpecificInfo:(__nullable id<RTCCodecSpecificInfo>)info |
153 renderTimeMs:(int64_t)renderTimeMs; | 178 renderTimeMs:(int64_t)renderTimeMs; |
154 - (NSString *)implementationName; | 179 - (NSString *)implementationName; |
155 | 180 |
156 @end | 181 @end |
157 | 182 |
158 NS_ASSUME_NONNULL_END | 183 NS_ASSUME_NONNULL_END |
OLD | NEW |