Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: webrtc/sdk/objc/Framework/Headers/WebRTC/RTCVideoCodec.h

Issue 2978623002: Implement H264 codec in Objective-C classes. (Closed)
Patch Set: Fix test after rebase. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 EmptyFrame, 21 EmptyFrame = 0,
22 VideoFrameKey, 22 AudioFrameSpeech = 1,
23 VideoFrameDelta, 23 AudioFrameCN = 2,
24 VideoFrameKey = 3,
25 VideoFrameDelta = 4,
26 };
27
28 typedef NS_ENUM(NSUInteger, RTCVideoContentType) {
29 Unspecified,
30 Screenshare,
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, retain) NSData *buffer; 37 @property(nonatomic, retain) 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, retain) NSNumber *qp; 49 @property(nonatomic, retain) 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, retain) NSArray<NSNumber *> *fragmentationOffset; 58 @property(nonatomic, retain) NSArray<NSNumber *> *fragmentationOffset;
51 @property(nonatomic, retain) NSArray<NSNumber *> *fragmentationLength; 59 @property(nonatomic, retain) NSArray<NSNumber *> *fragmentationLength;
52 @property(nonatomic, retain) NSArray<NSNumber *> *fragmentationTimeDiff; 60 @property(nonatomic, retain) NSArray<NSNumber *> *fragmentationTimeDiff;
53 @property(nonatomic, retain) NSArray<NSNumber *> *fragmentationPlType; 61 @property(nonatomic, retain) 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
65 /** Callback block for encoder. */ 73 /** Callback block for encoder. */
66 typedef void (^RTCVideoEncoderCallback)(RTCEncodedImage *frame, 74 typedef BOOL (^RTCVideoEncoderCallback)(RTCEncodedImage *frame,
67 id<RTCCodecSpecificInfo> info, 75 id<RTCCodecSpecificInfo> info,
68 RTCRtpFragmentationHeader *header); 76 RTCRtpFragmentationHeader *header);
69 77
70 /** Callback block for decoder. */ 78 /** Callback block for decoder. */
71 typedef void (^RTCVideoDecoderCallback)(RTCVideoFrame *frame); 79 typedef void (^RTCVideoDecoderCallback)(RTCVideoFrame *frame);
72 80
81 typedef NS_ENUM(NSUInteger, RTCVideoCodecMode) {
82 RealtimeVideo,
83 Screensharing,
84 };
85
73 /** Settings for encoder. Corresponds to webrtc::VideoCodec. */ 86 /** Settings for encoder. Corresponds to webrtc::VideoCodec. */
74 RTC_EXPORT 87 RTC_EXPORT
75 @interface RTCVideoEncoderSettings : NSObject 88 @interface RTCVideoEncoderSettings : NSObject
76 89
77 @property(nonatomic, retain) NSString *name; 90 @property(nonatomic, retain) NSString *name;
78 91
79 @property(nonatomic, assign) unsigned short width; 92 @property(nonatomic, assign) unsigned short width;
80 @property(nonatomic, assign) unsigned short height; 93 @property(nonatomic, assign) unsigned short height;
81 94
82 @property(nonatomic, assign) unsigned int startBitrate; // kilobits/sec. 95 @property(nonatomic, assign) unsigned int startBitrate; // kilobits/sec.
83 @property(nonatomic, assign) unsigned int maxBitrate; 96 @property(nonatomic, assign) unsigned int maxBitrate;
84 @property(nonatomic, assign) unsigned int minBitrate; 97 @property(nonatomic, assign) unsigned int minBitrate;
85 @property(nonatomic, assign) unsigned int targetBitrate; 98 @property(nonatomic, assign) unsigned int targetBitrate;
86 99
87 @property(nonatomic, assign) uint32_t maxFramerate; 100 @property(nonatomic, assign) uint32_t maxFramerate;
88 101
89 @property(nonatomic, assign) unsigned int qpMax; 102 @property(nonatomic, assign) unsigned int qpMax;
103 @property(nonatomic, assign) RTCVideoCodecMode mode;
90 104
91 @end 105 @end
92 106
93 /** Holds information to identify a codec. Corresponds to cricket::VideoCodec. * / 107 /** Holds information to identify a codec. Corresponds to cricket::VideoCodec. * /
94 RTC_EXPORT 108 RTC_EXPORT
95 @interface RTCVideoCodecInfo : NSObject 109 @interface RTCVideoCodecInfo : NSObject
96 110
97 - (instancetype)initWithPayload:(int)payload 111 - (instancetype)initWithPayload:(int)payload
98 name:(NSString *)name 112 name:(NSString *)name
99 parameters:(NSDictionary<NSString *, NSString *> *)paramete rs; 113 parameters:(NSDictionary<NSString *, NSString *> *)paramete rs;
100 114
101 @property(nonatomic, readonly) int payload; 115 @property(nonatomic, readonly) int payload;
102 @property(nonatomic, readonly) NSString *name; 116 @property(nonatomic, readonly) NSString *name;
103 @property(nonatomic, readonly) NSDictionary<NSString *, NSString *> *parameters; 117 @property(nonatomic, readonly) NSDictionary<NSString *, NSString *> *parameters;
104 118
105 @end 119 @end
106 120
107 /** Protocol for encoder implementations. */ 121 /** Protocol for encoder implementations. */
108 RTC_EXPORT 122 RTC_EXPORT
109 @protocol RTCVideoEncoder <NSObject> 123 @protocol RTCVideoEncoder <NSObject>
110 124
111 - (instancetype)initWithCodecInfo:(RTCVideoCodecInfo *)codecInfo; 125 - (instancetype)initWithCodecInfo:(RTCVideoCodecInfo *)codecInfo;
112 - (void)setCallback:(RTCVideoEncoderCallback)callback; 126 - (void)setCallback:(RTCVideoEncoderCallback)callback;
113 - (int)initEncodeWithSettings:(RTCVideoEncoderSettings *)settings numberOfCores: (int)numberOfCores; 127 - (int)initEncodeWithSettings:(RTCVideoEncoderSettings *)settings numberOfCores: (int)numberOfCores;
114 - (int)releaseEncode; 128 - (int)releaseEncode;
115 - (int)encode:(RTCVideoFrame *)frame 129 - (int)encode:(RTCVideoFrame *)frame
116 codecSpecificInfo:(id<RTCCodecSpecificInfo>)info 130 codecSpecificInfo:(id<RTCCodecSpecificInfo>)info
117 frameTypes:(NSArray<NSNumber *> *)frameTypes; 131 frameTypes:(NSArray<NSNumber *> *)frameTypes;
118 - (BOOL)setBitrate:(uint32_t)bitrateKbit framerate:(uint32_t)framerate; 132 - (int)setBitrate:(uint32_t)bitrateKbit framerate:(uint32_t)framerate;
119 133
120 @end 134 @end
121 135
122 /** Protocol for decoder implementations. */ 136 /** Protocol for decoder implementations. */
123 RTC_EXPORT 137 RTC_EXPORT
124 @protocol RTCVideoDecoder <NSObject> 138 @protocol RTCVideoDecoder <NSObject>
125 139
126 - (void)setCallback:(RTCVideoDecoderCallback)callback; 140 - (void)setCallback:(RTCVideoDecoderCallback)callback;
127 - (int)initDecodeWithSettings:(RTCVideoEncoderSettings *)settings numberOfCores: (int)numberOfCores; 141 - (int)initDecodeWithSettings:(RTCVideoEncoderSettings *)settings numberOfCores: (int)numberOfCores;
128 - (int)releaseDecode; 142 - (int)releaseDecode;
129 - (int)decode:(RTCEncodedImage *)encodedImage 143 - (int)decode:(RTCEncodedImage *)encodedImage
130 missingFrames:(BOOL)missingFrames 144 missingFrames:(BOOL)missingFrames
131 fragmentationHeader:(RTCRtpFragmentationHeader *)fragmentationHeader 145 fragmentationHeader:(RTCRtpFragmentationHeader *)fragmentationHeader
132 codecSpecificInfo:(__nullable id<RTCCodecSpecificInfo>)info 146 codecSpecificInfo:(__nullable id<RTCCodecSpecificInfo>)info
133 renderTimeMs:(int64_t)renderTimeMs; 147 renderTimeMs:(int64_t)renderTimeMs;
134 148
135 @end 149 @end
136 150
137 NS_ASSUME_NONNULL_END 151 NS_ASSUME_NONNULL_END
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698