Skip to content

Commit d57d987

Browse files
committed
format code style with unscrusify
1 parent 204aaa6 commit d57d987

31 files changed

+4503
-2190
lines changed

LFLiveKit.xcodeproj/project.pbxproj

+2,338-678
Large diffs are not rendered by default.

LFLiveKit/LFLiveSession.h

+14-14
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
/** live status changed will callback */
2424
- (void)liveSession:(nullable LFLiveSession *)session liveStateDidChange:(LFLiveState)state;
2525
/** live debug info callback */
26-
- (void)liveSession:(nullable LFLiveSession *)session debugInfo:(nullable LFLiveDebug*)debugInfo;
26+
- (void)liveSession:(nullable LFLiveSession *)session debugInfo:(nullable LFLiveDebug *)debugInfo;
2727
/** callback socket errorcode */
28-
- (void)liveSession:(nullable LFLiveSession*)session errorCode:(LFLiveSocketErrorCode)errorCode;
28+
- (void)liveSession:(nullable LFLiveSession *)session errorCode:(LFLiveSocketErrorCode)errorCode;
2929
@end
3030

3131
@class LFLiveStreamInfo;
@@ -37,13 +37,13 @@
3737
/// @name Attribute
3838
///=============================================================================
3939
/** The delegate of the capture. captureData callback */
40-
@property (nullable,nonatomic, weak) id<LFLiveSessionDelegate> delegate;
40+
@property (nullable, nonatomic, weak) id<LFLiveSessionDelegate> delegate;
4141

4242
/** The running control start capture or stop capture*/
4343
@property (nonatomic, assign) BOOL running;
4444

4545
/** The preView will show OpenGL ES view*/
46-
@property (nonatomic, strong,null_resettable) UIView *preView;
46+
@property (nonatomic, strong, null_resettable) UIView *preView;
4747

4848
/** The captureDevicePosition control camraPosition ,default front*/
4949
@property (nonatomic, assign) AVCaptureDevicePosition captureDevicePosition;
@@ -67,22 +67,22 @@
6767
@property (nonatomic, assign) BOOL mirror;
6868

6969
/** The muted control callbackAudioData,muted will memset 0.*/
70-
@property (nonatomic,assign) BOOL muted;
70+
@property (nonatomic, assign) BOOL muted;
7171

7272
/** The stream control upload and package*/
73-
@property (nullable,nonatomic, strong,readonly) LFLiveStreamInfo * streamInfo;
73+
@property (nullable, nonatomic, strong, readonly) LFLiveStreamInfo *streamInfo;
7474

7575
/** The status of the stream .*/
76-
@property (nonatomic,assign,readonly) LFLiveState state;
76+
@property (nonatomic, assign, readonly) LFLiveState state;
7777

7878
/** The showDebugInfo control streamInfo and uploadInfo(1s) *.*/
79-
@property (nonatomic,assign) BOOL showDebugInfo;
79+
@property (nonatomic, assign) BOOL showDebugInfo;
8080

8181
/** The reconnectInterval control reconnect timeInterval(重连间隔) *.*/
82-
@property (nonatomic,assign) NSUInteger reconnectInterval;
82+
@property (nonatomic, assign) NSUInteger reconnectInterval;
8383

8484
/** The reconnectCount control reconnect count (重连次数) *.*/
85-
@property (nonatomic,assign) NSUInteger reconnectCount;
85+
@property (nonatomic, assign) NSUInteger reconnectCount;
8686

8787
#pragma mark - Initializer
8888
///=============================================================================
@@ -92,13 +92,13 @@
9292
+ (nullable instancetype)new UNAVAILABLE_ATTRIBUTE;
9393

9494
/**
95-
The designated initializer. Multiple instances with the same configuration will make the
96-
capture unstable.
95+
The designated initializer. Multiple instances with the same configuration will make the
96+
capture unstable.
9797
*/
98-
- (nullable instancetype)initWithAudioConfiguration:(nullable LFLiveAudioConfiguration*)audioConfiguration videoConfiguration:(nullable LFLiveVideoConfiguration*)videoConfiguration NS_DESIGNATED_INITIALIZER;
98+
- (nullable instancetype)initWithAudioConfiguration:(nullable LFLiveAudioConfiguration *)audioConfiguration videoConfiguration:(nullable LFLiveVideoConfiguration *)videoConfiguration NS_DESIGNATED_INITIALIZER;
9999

100100
/** The start stream .*/
101-
- (void)startLive:(nonnull LFLiveStreamInfo*)streamInfo;
101+
- (void)startLive:(nonnull LFLiveStreamInfo *)streamInfo;
102102

103103
/** The stop stream .*/
104104
- (void)stopLive;

LFLiveKit/LFLiveSession.m

+53-53
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
#define LFLiveReportKey @"com.youku.liveSessionReport"
1919

20-
@interface LFLiveSession ()<LFAudioCaptureDelegate,LFVideoCaptureDelegate,LFAudioEncodingDelegate,LFVideoEncodingDelegate,LFStreamSocketDelegate>
20+
@interface LFLiveSession ()<LFAudioCaptureDelegate, LFVideoCaptureDelegate, LFAudioEncodingDelegate, LFVideoEncodingDelegate, LFStreamSocketDelegate>
2121
{
2222
dispatch_semaphore_t _lock;
2323
}
@@ -46,7 +46,7 @@ @interface LFLiveSession ()<LFAudioCaptureDelegate,LFVideoCaptureDelegate,LFAudi
4646
/// uploading
4747
@property (nonatomic, assign) BOOL uploading;
4848
/// state
49-
@property (nonatomic,assign,readwrite) LFLiveState state;
49+
@property (nonatomic, assign, readwrite) LFLiveState state;
5050

5151
@end
5252

@@ -63,135 +63,135 @@ @interface LFLiveSession ()
6363
@implementation LFLiveSession
6464

6565
#pragma mark -- LifeCycle
66-
- (instancetype)initWithAudioConfiguration:(LFLiveAudioConfiguration *)audioConfiguration videoConfiguration:(LFLiveVideoConfiguration *)videoConfiguration{
67-
if(!audioConfiguration || !videoConfiguration) @throw [NSException exceptionWithName:@"LFLiveSession init error" reason:@"audioConfiguration or videoConfiguration is nil " userInfo:nil];
68-
if(self = [super init]){
66+
- (instancetype)initWithAudioConfiguration:(LFLiveAudioConfiguration *)audioConfiguration videoConfiguration:(LFLiveVideoConfiguration *)videoConfiguration {
67+
if (!audioConfiguration || !videoConfiguration) @throw [NSException exceptionWithName:@"LFLiveSession init error" reason:@"audioConfiguration or videoConfiguration is nil " userInfo:nil];
68+
if (self = [super init]) {
6969
_audioConfiguration = audioConfiguration;
7070
_videoConfiguration = videoConfiguration;
7171
_lock = dispatch_semaphore_create(1);
7272
}
7373
return self;
7474
}
7575

76-
- (void)dealloc{
76+
- (void)dealloc {
7777
self.audioCaptureSource.running = NO;
7878
self.videoCaptureSource.running = NO;
7979
}
8080

8181
#pragma mark -- CustomMethod
82-
- (void)startLive:(LFLiveStreamInfo*)streamInfo{
83-
if(!streamInfo) return;
82+
- (void)startLive:(LFLiveStreamInfo *)streamInfo {
83+
if (!streamInfo) return;
8484
_streamInfo = streamInfo;
8585
_streamInfo.videoConfiguration = _videoConfiguration;
8686
_streamInfo.audioConfiguration = _audioConfiguration;
8787
[self.socket start];
8888
}
8989

90-
- (void)stopLive{
90+
- (void)stopLive {
9191
self.uploading = NO;
9292
[self.socket stop];
9393
}
9494

9595
#pragma mark -- CaptureDelegate
96-
- (void)captureOutput:(nullable LFAudioCapture*)capture audioBuffer:(AudioBufferList)inBufferList{
96+
- (void)captureOutput:(nullable LFAudioCapture *)capture audioBuffer:(AudioBufferList)inBufferList {
9797
[self.audioEncoder encodeAudioData:inBufferList timeStamp:self.currentTimestamp];
9898
}
9999

100-
- (void)captureOutput:(nullable LFVideoCapture*)capture pixelBuffer:(nullable CVImageBufferRef)pixelBuffer{
100+
- (void)captureOutput:(nullable LFVideoCapture *)capture pixelBuffer:(nullable CVImageBufferRef)pixelBuffer {
101101
[self.videoEncoder encodeVideoData:pixelBuffer timeStamp:self.currentTimestamp];
102102
}
103103

104104
#pragma mark -- EncoderDelegate
105-
- (void)audioEncoder:(nullable id<LFAudioEncoding>)encoder audioFrame:(nullable LFAudioFrame*)frame{
106-
if(self.uploading) [self.socket sendFrame:frame];//<上传
105+
- (void)audioEncoder:(nullable id<LFAudioEncoding>)encoder audioFrame:(nullable LFAudioFrame *)frame {
106+
if (self.uploading) [self.socket sendFrame:frame]; //<上传
107107
}
108108

109-
- (void)videoEncoder:(nullable id<LFVideoEncoding>)encoder videoFrame:(nullable LFVideoFrame*)frame{
110-
if(self.uploading) [self.socket sendFrame:frame];//<上传
109+
- (void)videoEncoder:(nullable id<LFVideoEncoding>)encoder videoFrame:(nullable LFVideoFrame *)frame {
110+
if (self.uploading) [self.socket sendFrame:frame]; //<上传
111111
}
112112

113113
#pragma mark -- LFStreamTcpSocketDelegate
114-
- (void)socketStatus:(nullable id<LFStreamSocket>)socket status:(LFLiveState)status{
115-
if(status == LFLiveStart){
116-
if(!self.uploading){
114+
- (void)socketStatus:(nullable id<LFStreamSocket>)socket status:(LFLiveState)status {
115+
if (status == LFLiveStart) {
116+
if (!self.uploading) {
117117
self.timestamp = 0;
118118
self.isFirstFrame = YES;
119119
self.uploading = YES;
120120
}
121121
}
122122
dispatch_async(dispatch_get_main_queue(), ^{
123123
self.state = status;
124-
if(self.delegate && [self.delegate respondsToSelector:@selector(liveSession:liveStateDidChange:)]){
124+
if (self.delegate && [self.delegate respondsToSelector:@selector(liveSession:liveStateDidChange:)]) {
125125
[self.delegate liveSession:self liveStateDidChange:status];
126126
}
127127
});
128128
}
129129

130-
- (void)socketDidError:(nullable id<LFStreamSocket>)socket errorCode:(LFLiveSocketErrorCode)errorCode{
130+
- (void)socketDidError:(nullable id<LFStreamSocket>)socket errorCode:(LFLiveSocketErrorCode)errorCode {
131131
dispatch_async(dispatch_get_main_queue(), ^{
132-
if(self.delegate && [self.delegate respondsToSelector:@selector(liveSession:errorCode:)]){
132+
if (self.delegate && [self.delegate respondsToSelector:@selector(liveSession:errorCode:)]) {
133133
[self.delegate liveSession:self errorCode:errorCode];
134134
}
135135
});
136136
}
137137

138-
- (void)socketDebug:(nullable id<LFStreamSocket>)socket debugInfo:(nullable LFLiveDebug*)debugInfo{
138+
- (void)socketDebug:(nullable id<LFStreamSocket>)socket debugInfo:(nullable LFLiveDebug *)debugInfo {
139139
self.debugInfo = debugInfo;
140-
if(self.showDebugInfo){
140+
if (self.showDebugInfo) {
141141
dispatch_async(dispatch_get_main_queue(), ^{
142-
if(self.delegate && [self.delegate respondsToSelector:@selector(liveSession:debugInfo:)]){
142+
if (self.delegate && [self.delegate respondsToSelector:@selector(liveSession:debugInfo:)]) {
143143
[self.delegate liveSession:self debugInfo:debugInfo];
144144
}
145145
});
146146
}
147147
}
148148

149-
- (void)socketBufferStatus:(nullable id<LFStreamSocket>)socket status:(LFLiveBuffferState)status{
149+
- (void)socketBufferStatus:(nullable id<LFStreamSocket>)socket status:(LFLiveBuffferState)status {
150150
NSUInteger videoBitRate = [_videoEncoder videoBitRate];
151-
if(status == LFLiveBuffferIncrease){
152-
if(videoBitRate < _videoConfiguration.videoMaxBitRate){
151+
if (status == LFLiveBuffferIncrease) {
152+
if (videoBitRate < _videoConfiguration.videoMaxBitRate) {
153153
videoBitRate = videoBitRate + 50 * 1000;
154154
[_videoEncoder setVideoBitRate:videoBitRate];
155155
}
156-
}else{
157-
if(videoBitRate > _videoConfiguration.videoMinBitRate){
156+
} else {
157+
if (videoBitRate > _videoConfiguration.videoMinBitRate) {
158158
videoBitRate = videoBitRate - 100 * 1000;
159159
[_videoEncoder setVideoBitRate:videoBitRate];
160160
}
161161
}
162162
}
163163

164164
#pragma mark -- Getter Setter
165-
- (void)setRunning:(BOOL)running{
166-
if(_running == running) return;
165+
- (void)setRunning:(BOOL)running {
166+
if (_running == running) return;
167167
[self willChangeValueForKey:@"running"];
168168
_running = running;
169169
[self didChangeValueForKey:@"running"];
170170
self.videoCaptureSource.running = _running;
171171
self.audioCaptureSource.running = _running;
172172
}
173173

174-
- (void)setPreView:(UIView *)preView{
174+
- (void)setPreView:(UIView *)preView {
175175
[self.videoCaptureSource setPreView:preView];
176176
}
177177

178-
- (UIView*)preView{
178+
- (UIView *)preView {
179179
return self.videoCaptureSource.preView;
180180
}
181181

182-
- (void)setCaptureDevicePosition:(AVCaptureDevicePosition)captureDevicePosition{
182+
- (void)setCaptureDevicePosition:(AVCaptureDevicePosition)captureDevicePosition {
183183
[self.videoCaptureSource setCaptureDevicePosition:captureDevicePosition];
184184
}
185185

186-
- (AVCaptureDevicePosition)captureDevicePosition{
186+
- (AVCaptureDevicePosition)captureDevicePosition {
187187
return self.videoCaptureSource.captureDevicePosition;
188188
}
189189

190-
- (void)setBeautyFace:(BOOL)beautyFace{
190+
- (void)setBeautyFace:(BOOL)beautyFace {
191191
[self.videoCaptureSource setBeautyFace:beautyFace];
192192
}
193193

194-
- (BOOL)beautyFace{
194+
- (BOOL)beautyFace {
195195
return self.videoCaptureSource.beautyFace;
196196
}
197197

@@ -235,65 +235,65 @@ - (BOOL)mirror {
235235
return self.videoCaptureSource.mirror;
236236
}
237237

238-
- (void)setMuted:(BOOL)muted{
238+
- (void)setMuted:(BOOL)muted {
239239
[self.audioCaptureSource setMuted:muted];
240240
}
241241

242-
- (BOOL)muted{
242+
- (BOOL)muted {
243243
return self.audioCaptureSource.muted;
244244
}
245245

246-
- (LFAudioCapture*)audioCaptureSource{
247-
if(!_audioCaptureSource){
246+
- (LFAudioCapture *)audioCaptureSource {
247+
if (!_audioCaptureSource) {
248248
_audioCaptureSource = [[LFAudioCapture alloc] initWithAudioConfiguration:_audioConfiguration];
249249
_audioCaptureSource.delegate = self;
250250
}
251251
return _audioCaptureSource;
252252
}
253253

254-
- (LFVideoCapture*)videoCaptureSource{
255-
if(!_videoCaptureSource){
254+
- (LFVideoCapture *)videoCaptureSource {
255+
if (!_videoCaptureSource) {
256256
_videoCaptureSource = [[LFVideoCapture alloc] initWithVideoConfiguration:_videoConfiguration];
257257
_videoCaptureSource.delegate = self;
258258
}
259259
return _videoCaptureSource;
260260
}
261261

262-
- (id<LFAudioEncoding>)audioEncoder{
263-
if(!_audioEncoder){
262+
- (id<LFAudioEncoding>)audioEncoder {
263+
if (!_audioEncoder) {
264264
_audioEncoder = [[LFHardwareAudioEncoder alloc] initWithAudioStreamConfiguration:_audioConfiguration];
265265
[_audioEncoder setDelegate:self];
266266
}
267267
return _audioEncoder;
268268
}
269269

270-
- (id<LFVideoEncoding>)videoEncoder{
271-
if(!_videoEncoder){
270+
- (id<LFVideoEncoding>)videoEncoder {
271+
if (!_videoEncoder) {
272272
_videoEncoder = [[LFHardwareVideoEncoder alloc] initWithVideoStreamConfiguration:_videoConfiguration];
273273
[_videoEncoder setDelegate:self];
274274
}
275275
return _videoEncoder;
276276
}
277277

278-
- (id<LFStreamSocket>)socket{
279-
if(!_socket){
278+
- (id<LFStreamSocket>)socket {
279+
if (!_socket) {
280280
_socket = [[LFStreamRtmpSocket alloc] initWithStream:self.streamInfo videoSize:self.videoConfiguration.videoSize reconnectInterval:self.reconnectInterval reconnectCount:self.reconnectCount];
281281
[_socket setDelegate:self];
282282
}
283283
return _socket;
284284
}
285285

286-
- (LFLiveStreamInfo*)streamInfo{
287-
if(!_streamInfo){
286+
- (LFLiveStreamInfo *)streamInfo {
287+
if (!_streamInfo) {
288288
_streamInfo = [[LFLiveStreamInfo alloc] init];
289289
}
290290
return _streamInfo;
291291
}
292292

293-
- (uint64_t)currentTimestamp{
293+
- (uint64_t)currentTimestamp {
294294
dispatch_semaphore_wait(_lock, DISPATCH_TIME_FOREVER);
295295
uint64_t currentts = 0;
296-
if(_isFirstFrame == true) {
296+
if (_isFirstFrame == true) {
297297
_timestamp = NOW;
298298
_isFirstFrame = false;
299299
currentts = 0;

LFLiveKit/capture/LFAudioCapture.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ extern NSString *_Nullable const LFAudioComponentFailedToCreateNotification;
1717
@class LFAudioCapture;
1818
/** LFAudioCapture callback audioData */
1919
@protocol LFAudioCaptureDelegate <NSObject>
20-
- (void)captureOutput:(nullable LFAudioCapture*)capture audioBuffer:(AudioBufferList)inBufferList;
20+
- (void)captureOutput:(nullable LFAudioCapture *)capture audioBuffer:(AudioBufferList)inBufferList;
2121
@end
2222

2323

@@ -29,10 +29,10 @@ extern NSString *_Nullable const LFAudioComponentFailedToCreateNotification;
2929
///=============================================================================
3030

3131
/** The delegate of the capture. captureData callback */
32-
@property (nullable,nonatomic, weak) id<LFAudioCaptureDelegate> delegate;
32+
@property (nullable, nonatomic, weak) id<LFAudioCaptureDelegate> delegate;
3333

3434
/** The muted control callbackAudioData,muted will memset 0.*/
35-
@property (nonatomic,assign) BOOL muted;
35+
@property (nonatomic, assign) BOOL muted;
3636

3737
/** The running control start capture or stop capture*/
3838
@property (nonatomic, assign) BOOL running;
@@ -45,8 +45,8 @@ extern NSString *_Nullable const LFAudioComponentFailedToCreateNotification;
4545
+ (nullable instancetype)new UNAVAILABLE_ATTRIBUTE;
4646

4747
/**
48-
The designated initializer. Multiple instances with the same configuration will make the
49-
capture unstable.
48+
The designated initializer. Multiple instances with the same configuration will make the
49+
capture unstable.
5050
*/
5151
- (nullable instancetype)initWithAudioConfiguration:(nullable LFLiveAudioConfiguration *)configuration NS_DESIGNATED_INITIALIZER;
5252

0 commit comments

Comments
 (0)