OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2017 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 <WebRTC/RTCMacros.h> |
| 14 |
| 15 @class RTCVideoFrame; |
| 16 |
| 17 NS_ASSUME_NONNULL_BEGIN |
| 18 |
| 19 /** Represents an encoded frame's type. */ |
| 20 typedef NS_ENUM(NSUInteger, RTCFrameType) { |
| 21 EmptyFrame, |
| 22 VideoFrameKey, |
| 23 VideoFrameDelta, |
| 24 }; |
| 25 |
| 26 /** Represents an encoded frame. Corresponds to webrtc::EncodedImage. */ |
| 27 RTC_EXPORT |
| 28 @interface RTCEncodedImage : NSObject |
| 29 |
| 30 @property(nonatomic, retain) NSData *buffer; |
| 31 @property(nonatomic, assign) int encodedWidth; |
| 32 @property(nonatomic, assign) int encodedHeight; |
| 33 @property(nonatomic, assign) uint32_t timeStamp; |
| 34 @property(nonatomic, assign) long captureTimeMs; |
| 35 @property(nonatomic, assign) long ntpTimeMs; |
| 36 @property(nonatomic, assign) BOOL isTimingFrame; |
| 37 @property(nonatomic, assign) long encodeStartMs; |
| 38 @property(nonatomic, assign) long encodeFinishMs; |
| 39 @property(nonatomic, assign) RTCFrameType frameType; |
| 40 @property(nonatomic, assign) int rotation; |
| 41 @property(nonatomic, assign) BOOL completeFrame; |
| 42 @property(nonatomic, retain) NSNumber *qp; |
| 43 |
| 44 @end |
| 45 |
| 46 /** Information for header. Corresponds to webrtc::RTPFragmentationHeader. */ |
| 47 RTC_EXPORT |
| 48 @interface RTCRtpFragmentationHeader : NSObject |
| 49 |
| 50 @property(nonatomic, retain) NSArray<NSNumber *> *fragmentationOffset; |
| 51 @property(nonatomic, retain) NSArray<NSNumber *> *fragmentationLength; |
| 52 @property(nonatomic, retain) NSArray<NSNumber *> *fragmentationTimeDiff; |
| 53 @property(nonatomic, retain) NSArray<NSNumber *> *fragmentationPlType; |
| 54 |
| 55 @end |
| 56 |
| 57 /** Implement this protocol to pass codec specific info from the encoder. |
| 58 * Corresponds to webrtc::CodecSpecificInfo. |
| 59 */ |
| 60 RTC_EXPORT |
| 61 @protocol RTCCodecSpecificInfo <NSObject> |
| 62 |
| 63 @end |
| 64 |
| 65 /** Callback block for encoder. */ |
| 66 typedef void (^RTCVideoEncoderCallback)(RTCEncodedImage *frame, |
| 67 id<RTCCodecSpecificInfo> info, |
| 68 RTCRtpFragmentationHeader *header); |
| 69 |
| 70 /** Callback block for decoder. */ |
| 71 typedef void (^RTCVideoDecoderCallback)(RTCVideoFrame *frame); |
| 72 |
| 73 /** Settings for encoder. Corresponds to webrtc::VideoCodec. */ |
| 74 RTC_EXPORT |
| 75 @interface RTCVideoEncoderSettings : NSObject |
| 76 |
| 77 @property(nonatomic, retain) NSString *name; |
| 78 |
| 79 @property(nonatomic, assign) unsigned short width; |
| 80 @property(nonatomic, assign) unsigned short height; |
| 81 |
| 82 @property(nonatomic, assign) unsigned int startBitrate; // kilobits/sec. |
| 83 @property(nonatomic, assign) unsigned int maxBitrate; |
| 84 @property(nonatomic, assign) unsigned int minBitrate; |
| 85 @property(nonatomic, assign) unsigned int targetBitrate; |
| 86 |
| 87 @property(nonatomic, assign) uint32_t maxFramerate; |
| 88 |
| 89 @property(nonatomic, assign) unsigned int qpMax; |
| 90 |
| 91 @end |
| 92 |
| 93 /** Holds information to identify a codec. Corresponds to cricket::VideoCodec. *
/ |
| 94 RTC_EXPORT |
| 95 @interface RTCVideoCodecInfo : NSObject |
| 96 |
| 97 - (instancetype)initWithPayload:(int)payload |
| 98 name:(NSString *)name |
| 99 parameters:(NSDictionary<NSString *, NSString *> *)paramete
rs; |
| 100 |
| 101 @property(nonatomic, readonly) int payload; |
| 102 @property(nonatomic, readonly) NSString *name; |
| 103 @property(nonatomic, readonly) NSDictionary<NSString *, NSString *> *parameters; |
| 104 |
| 105 @end |
| 106 |
| 107 /** Protocol for encoder implementations. */ |
| 108 RTC_EXPORT |
| 109 @protocol RTCVideoEncoder <NSObject> |
| 110 |
| 111 - (instancetype)initWithCodecInfo:(RTCVideoCodecInfo *)codecInfo; |
| 112 - (void)setCallback:(RTCVideoEncoderCallback)callback; |
| 113 - (int)initEncodeWithSettings:(RTCVideoEncoderSettings *)settings numberOfCores:
(int)numberOfCores; |
| 114 - (int)releaseEncode; |
| 115 - (int)encode:(RTCVideoFrame *)frame |
| 116 codecSpecificInfo:(id<RTCCodecSpecificInfo>)info |
| 117 frameTypes:(NSArray<NSNumber *> *)frameTypes; |
| 118 - (BOOL)setBitrate:(uint32_t)bitrateKbit framerate:(uint32_t)framerate; |
| 119 |
| 120 @end |
| 121 |
| 122 /** Protocol for decoder implementations. */ |
| 123 RTC_EXPORT |
| 124 @protocol RTCVideoDecoder <NSObject> |
| 125 |
| 126 - (void)setCallback:(RTCVideoDecoderCallback)callback; |
| 127 - (int)initDecodeWithSettings:(RTCVideoEncoderSettings *)settings numberOfCores:
(int)numberOfCores; |
| 128 - (int)releaseDecode; |
| 129 - (int)decode:(RTCEncodedImage *)encodedImage |
| 130 missingFrames:(BOOL)missingFrames |
| 131 fragmentationHeader:(RTCRtpFragmentationHeader *)fragmentationHeader |
| 132 codecSpecificInfo:(__nullable id<RTCCodecSpecificInfo>)info |
| 133 renderTimeMs:(int64_t)renderTimeMs; |
| 134 |
| 135 @end |
| 136 |
| 137 NS_ASSUME_NONNULL_END |
OLD | NEW |