Commit 27efad8b9218a332e99cb0e74da28c4fc4219151
1 parent
de05ddb6
no message
Showing
18 changed files
with
473 additions
and
527 deletions
CNLivePlayer/Classes/Streamer/CNLiveStreamerKit.h
| ... | ... | @@ -329,7 +329,7 @@ FOUNDATION_EXPORT NSString *const CNLiveStreamerReconnectStatusChangedNotificati |
| 329 | 329 | @discussion 横屏时: width > height |
| 330 | 330 | @discussion 需要与UI方向一致 |
| 331 | 331 | */ |
| 332 | -- (void)setVideoOrientationBy:(UIInterfaceOrientation)uiOrien; | |
| 332 | +- (void)setVideoOrientation:(UIInterfaceOrientation)orientation; | |
| 333 | 333 | |
| 334 | 334 | /** |
| 335 | 335 | @abstract 启动预览 |
| ... | ... | @@ -403,13 +403,13 @@ FOUNDATION_EXPORT NSString *const CNLiveStreamerReconnectStatusChangedNotificati |
| 403 | 403 | @param orie 旋转到目标朝向, 需要从demo中获取UI的朝向传入 |
| 404 | 404 | @discussion 采集到的图像的朝向还是和启动时的朝向一致 |
| 405 | 405 | */ |
| 406 | -- (void)rotatePreviewTo:(UIInterfaceOrientation) orie; | |
| 406 | +- (void)rotatePreviewTo:(UIInterfaceOrientation)orie; | |
| 407 | 407 | |
| 408 | 408 | /** |
| 409 | 409 | @abstract 根据UI的朝向旋转推流画面 |
| 410 | 410 | @param orie 旋转到目标朝向, 需要从demo中获取UI的朝向传入 |
| 411 | 411 | */ |
| 412 | -- (void)rotateStreamTo:(UIInterfaceOrientation) orie; | |
| 412 | +- (void)rotateStreamTo:(UIInterfaceOrientation)orie; | |
| 413 | 413 | |
| 414 | 414 | /** |
| 415 | 415 | @abstract 当前采集设备是否支持自动变焦 | ... | ... |
CNLivePlayer/Classes/Streamer/CNLiveStreamerKit.m
| ... | ... | @@ -271,7 +271,7 @@ NSString * const CNLiveServiceConnectBreakNotification = @"CNLiveServiceConnectB |
| 271 | 271 | _captureState = (CNLiveCaptureState)_manager.kit.captureState; |
| 272 | 272 | |
| 273 | 273 | if (self.logPrintEnable) { |
| 274 | - NSLog(@"CNLiveGPUStreamerKit-->采集设备工作状态CNLiveCaptureState:%ld", (unsigned long)self.captureState); | |
| 274 | + NSLog(@"CNLiveStreamerKit-->采集设备工作状态CNLiveCaptureState:%ld", (unsigned long)self.captureState); | |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | [[NSNotificationCenter defaultCenter] postNotificationName:CNLiveCaptureStateDidChangeNotification |
| ... | ... | @@ -388,10 +388,7 @@ NSString * const CNLiveServiceConnectBreakNotification = @"CNLiveServiceConnectB |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | - (void)enterForeground { |
| 391 | - | |
| 392 | - // BOOL enterForeground = [_manager.kit.aCapDev startCapture]; | |
| 393 | - // NSLog(@"CNLiveGPUStreamerKit-->重新开启音频采集状态,ret:%@",enterForeground ? @"YES" : @"NO"); | |
| 394 | - | |
| 391 | + | |
| 395 | 392 | if (!_activitySuccess) return; |
| 396 | 393 | _enterBackground = NO; |
| 397 | 394 | |
| ... | ... | @@ -475,8 +472,8 @@ NSString * const CNLiveServiceConnectBreakNotification = @"CNLiveServiceConnectB |
| 475 | 472 | } |
| 476 | 473 | |
| 477 | 474 | //摄像头朝向 |
| 478 | --(void)setVideoOrientationBy:(UIInterfaceOrientation)uiOrien { | |
| 479 | - _manager.kit.videoOrientation = uiOrien; | |
| 475 | +-(void)setVideoOrientation:(UIInterfaceOrientation)orientation { | |
| 476 | + _manager.kit.videoOrientation = orientation; | |
| 480 | 477 | } |
| 481 | 478 | |
| 482 | 479 | #pragma mark - mirror & rotate |
| ... | ... | @@ -1063,13 +1060,8 @@ NSString * const CNLiveServiceConnectBreakNotification = @"CNLiveServiceConnectB |
| 1063 | 1060 | |
| 1064 | 1061 | //启动直播活动 |
| 1065 | 1062 | - (void)requestStartStreamer:(void (^)(void))successBlock failure:(void (^)(NSDictionary *))failureBlock timeString:(NSString *)timeString { |
| 1066 | - | |
| 1067 | 1063 | _reteying = NO; |
| 1068 | 1064 | |
| 1069 | - // NSDate *date = [NSDate date]; | |
| 1070 | - // NSInteger time = [date timeIntervalSince1970]; | |
| 1071 | - // NSString *timeString = [NSString stringWithFormat:@"%ld", (long)time]; | |
| 1072 | - | |
| 1073 | 1065 | NSMutableDictionary *parameter = [@{@"appId": PLAYER_AppID, |
| 1074 | 1066 | @"activityId": _activityId, |
| 1075 | 1067 | @"timestamp":timeString, | ... | ... |
Example/CNLivePlayer.xcodeproj/project.pbxproj
| ... | ... | @@ -13,17 +13,17 @@ |
| 13 | 13 | 086413C222EAE591008713D3 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 086413C122EAE591008713D3 /* OpenGLES.framework */; }; |
| 14 | 14 | 086413C422EAEC11008713D3 /* libstdc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 086413C322EAEC11008713D3 /* libstdc++.tbd */; }; |
| 15 | 15 | 08740E51230E7DFB00B5D28D /* CNLiveStreamerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 08740E3F230E7DFA00B5D28D /* CNLiveStreamerController.m */; }; |
| 16 | - 08740E52230E7DFB00B5D28D /* StreamerDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 08740E40230E7DFA00B5D28D /* StreamerDetailViewController.m */; }; | |
| 16 | + 08740E52230E7DFB00B5D28D /* CNLiveStreamerDetailController.m in Sources */ = {isa = PBXBuildFile; fileRef = 08740E40230E7DFA00B5D28D /* CNLiveStreamerDetailController.m */; }; | |
| 17 | 17 | 08740E53230E7DFB00B5D28D /* FilterFunctionView.m in Sources */ = {isa = PBXBuildFile; fileRef = 08740E41230E7DFA00B5D28D /* FilterFunctionView.m */; }; |
| 18 | 18 | 08740E54230E7DFB00B5D28D /* SliderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 08740E44230E7DFA00B5D28D /* SliderView.m */; }; |
| 19 | 19 | 08740E55230E7DFB00B5D28D /* FloatingViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 08740E45230E7DFA00B5D28D /* FloatingViewController.m */; }; |
| 20 | 20 | 08740E56230E7DFB00B5D28D /* AudioStreamingViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 08740E46230E7DFA00B5D28D /* AudioStreamingViewController.m */; }; |
| 21 | - 08740E57230E7DFB00B5D28D /* MoreFunctionsView.m in Sources */ = {isa = PBXBuildFile; fileRef = 08740E47230E7DFA00B5D28D /* MoreFunctionsView.m */; }; | |
| 22 | - 08740E58230E7DFB00B5D28D /* AudioCfgView.m in Sources */ = {isa = PBXBuildFile; fileRef = 08740E48230E7DFA00B5D28D /* AudioCfgView.m */; }; | |
| 23 | 21 | 08740E59230E7DFB00B5D28D /* BgmPlayerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 08740E4D230E7DFA00B5D28D /* BgmPlayerView.m */; }; |
| 24 | - 08740E5C230E83B100B5D28D /* LoadingView.m in Sources */ = {isa = PBXBuildFile; fileRef = 08740E5B230E83B100B5D28D /* LoadingView.m */; }; | |
| 25 | 22 | 08740E5E230E8A0700B5D28D /* house.gif in Resources */ = {isa = PBXBuildFile; fileRef = 08740E5D230E8A0700B5D28D /* house.gif */; }; |
| 26 | 23 | 08740E62230E8C6500B5D28D /* CNLivePlayerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 08740E60230E8C6500B5D28D /* CNLivePlayerController.m */; }; |
| 24 | + 08740E66230E935300B5D28D /* CNLiveLoadingView.m in Sources */ = {isa = PBXBuildFile; fileRef = 08740E65230E935300B5D28D /* CNLiveLoadingView.m */; }; | |
| 25 | + 08740E69230E989000B5D28D /* CNLiveMoreFunctionsView.m in Sources */ = {isa = PBXBuildFile; fileRef = 08740E68230E989000B5D28D /* CNLiveMoreFunctionsView.m */; }; | |
| 26 | + 08740E6D230EBA6800B5D28D /* CNLiveVoiceSettingView.m in Sources */ = {isa = PBXBuildFile; fileRef = 08740E6B230EBA6800B5D28D /* CNLiveVoiceSettingView.m */; }; | |
| 27 | 27 | 1D258610626B544AFEEFD2F9 /* Pods_CNLivePlayer_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E14DC7AF4B1116AA5BC01855 /* Pods_CNLivePlayer_Example.framework */; }; |
| 28 | 28 | 2A57832D4B5A8EF9638641C3 /* Pods_CNLivePlayer_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DDD4ACEE076815DE64A1FE2E /* Pods_CNLivePlayer_Tests.framework */; }; |
| 29 | 29 | 6003F58E195388D20070C39A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58D195388D20070C39A /* Foundation.framework */; }; |
| ... | ... | @@ -60,28 +60,28 @@ |
| 60 | 60 | 086413C122EAE591008713D3 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; |
| 61 | 61 | 086413C322EAEC11008713D3 /* libstdc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libstdc++.tbd"; path = "usr/lib/libstdc++.tbd"; sourceTree = SDKROOT; }; |
| 62 | 62 | 08740E3F230E7DFA00B5D28D /* CNLiveStreamerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CNLiveStreamerController.m; sourceTree = "<group>"; }; |
| 63 | - 08740E40230E7DFA00B5D28D /* StreamerDetailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StreamerDetailViewController.m; sourceTree = "<group>"; }; | |
| 63 | + 08740E40230E7DFA00B5D28D /* CNLiveStreamerDetailController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CNLiveStreamerDetailController.m; sourceTree = "<group>"; }; | |
| 64 | 64 | 08740E41230E7DFA00B5D28D /* FilterFunctionView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FilterFunctionView.m; sourceTree = "<group>"; }; |
| 65 | - 08740E42230E7DFA00B5D28D /* AudioCfgView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioCfgView.h; sourceTree = "<group>"; }; | |
| 66 | 65 | 08740E43230E7DFA00B5D28D /* BgmPlayerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BgmPlayerView.h; sourceTree = "<group>"; }; |
| 67 | 66 | 08740E44230E7DFA00B5D28D /* SliderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SliderView.m; sourceTree = "<group>"; }; |
| 68 | 67 | 08740E45230E7DFA00B5D28D /* FloatingViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FloatingViewController.m; sourceTree = "<group>"; }; |
| 69 | 68 | 08740E46230E7DFA00B5D28D /* AudioStreamingViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AudioStreamingViewController.m; sourceTree = "<group>"; }; |
| 70 | - 08740E47230E7DFA00B5D28D /* MoreFunctionsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MoreFunctionsView.m; sourceTree = "<group>"; }; | |
| 71 | - 08740E48230E7DFA00B5D28D /* AudioCfgView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AudioCfgView.m; sourceTree = "<group>"; }; | |
| 72 | 69 | 08740E49230E7DFA00B5D28D /* FilterFunctionView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FilterFunctionView.h; sourceTree = "<group>"; }; |
| 73 | - 08740E4A230E7DFA00B5D28D /* StreamerDetailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StreamerDetailViewController.h; sourceTree = "<group>"; }; | |
| 70 | + 08740E4A230E7DFA00B5D28D /* CNLiveStreamerDetailController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNLiveStreamerDetailController.h; sourceTree = "<group>"; }; | |
| 74 | 71 | 08740E4B230E7DFA00B5D28D /* CNLiveStreamerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNLiveStreamerController.h; sourceTree = "<group>"; }; |
| 75 | 72 | 08740E4C230E7DFA00B5D28D /* SliderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SliderView.h; sourceTree = "<group>"; }; |
| 76 | 73 | 08740E4D230E7DFA00B5D28D /* BgmPlayerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BgmPlayerView.m; sourceTree = "<group>"; }; |
| 77 | 74 | 08740E4E230E7DFA00B5D28D /* FloatingViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FloatingViewController.h; sourceTree = "<group>"; }; |
| 78 | - 08740E4F230E7DFA00B5D28D /* MoreFunctionsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MoreFunctionsView.h; sourceTree = "<group>"; }; | |
| 79 | 75 | 08740E50230E7DFA00B5D28D /* AudioStreamingViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioStreamingViewController.h; sourceTree = "<group>"; }; |
| 80 | - 08740E5A230E83B100B5D28D /* LoadingView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoadingView.h; sourceTree = "<group>"; }; | |
| 81 | - 08740E5B230E83B100B5D28D /* LoadingView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LoadingView.m; sourceTree = "<group>"; }; | |
| 82 | 76 | 08740E5D230E8A0700B5D28D /* house.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = house.gif; sourceTree = "<group>"; }; |
| 83 | 77 | 08740E60230E8C6500B5D28D /* CNLivePlayerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CNLivePlayerController.m; sourceTree = "<group>"; }; |
| 84 | 78 | 08740E61230E8C6500B5D28D /* CNLivePlayerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNLivePlayerController.h; sourceTree = "<group>"; }; |
| 79 | + 08740E64230E935300B5D28D /* CNLiveLoadingView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNLiveLoadingView.h; sourceTree = "<group>"; }; | |
| 80 | + 08740E65230E935300B5D28D /* CNLiveLoadingView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CNLiveLoadingView.m; sourceTree = "<group>"; }; | |
| 81 | + 08740E67230E989000B5D28D /* CNLiveMoreFunctionsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNLiveMoreFunctionsView.h; sourceTree = "<group>"; }; | |
| 82 | + 08740E68230E989000B5D28D /* CNLiveMoreFunctionsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CNLiveMoreFunctionsView.m; sourceTree = "<group>"; }; | |
| 83 | + 08740E6B230EBA6800B5D28D /* CNLiveVoiceSettingView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CNLiveVoiceSettingView.m; sourceTree = "<group>"; }; | |
| 84 | + 08740E6C230EBA6800B5D28D /* CNLiveVoiceSettingView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNLiveVoiceSettingView.h; sourceTree = "<group>"; }; | |
| 85 | 85 | 17E088CE7F3FDB52D35B374B /* CNLivePlayer.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = CNLivePlayer.podspec; path = ../CNLivePlayer.podspec; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; |
| 86 | 86 | 26B97BD3DF7A4A551798F5CA /* Pods-CNLivePlayer_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CNLivePlayer_Tests.release.xcconfig"; path = "Target Support Files/Pods-CNLivePlayer_Tests/Pods-CNLivePlayer_Tests.release.xcconfig"; sourceTree = "<group>"; }; |
| 87 | 87 | 32AFD179FF73966F488CAFA0 /* Pods-CNLivePlayer_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CNLivePlayer_Example.debug.xcconfig"; path = "Target Support Files/Pods-CNLivePlayer_Example/Pods-CNLivePlayer_Example.debug.xcconfig"; sourceTree = "<group>"; }; |
| ... | ... | @@ -159,27 +159,23 @@ |
| 159 | 159 | 08740E3E230E7DFA00B5D28D /* Streamer */ = { |
| 160 | 160 | isa = PBXGroup; |
| 161 | 161 | children = ( |
| 162 | + 08740E6A230E9EA200B5D28D /* Controller */, | |
| 163 | + 08740E63230E932600B5D28D /* View */, | |
| 162 | 164 | 08740E5D230E8A0700B5D28D /* house.gif */, |
| 163 | 165 | 08740E4B230E7DFA00B5D28D /* CNLiveStreamerController.h */, |
| 164 | 166 | 08740E3F230E7DFA00B5D28D /* CNLiveStreamerController.m */, |
| 165 | - 08740E4A230E7DFA00B5D28D /* StreamerDetailViewController.h */, | |
| 166 | - 08740E40230E7DFA00B5D28D /* StreamerDetailViewController.m */, | |
| 167 | - 08740E5A230E83B100B5D28D /* LoadingView.h */, | |
| 168 | - 08740E5B230E83B100B5D28D /* LoadingView.m */, | |
| 167 | + 08740E4A230E7DFA00B5D28D /* CNLiveStreamerDetailController.h */, | |
| 168 | + 08740E40230E7DFA00B5D28D /* CNLiveStreamerDetailController.m */, | |
| 169 | 169 | 08740E50230E7DFA00B5D28D /* AudioStreamingViewController.h */, |
| 170 | 170 | 08740E46230E7DFA00B5D28D /* AudioStreamingViewController.m */, |
| 171 | 171 | 08740E4E230E7DFA00B5D28D /* FloatingViewController.h */, |
| 172 | 172 | 08740E45230E7DFA00B5D28D /* FloatingViewController.m */, |
| 173 | 173 | 08740E49230E7DFA00B5D28D /* FilterFunctionView.h */, |
| 174 | 174 | 08740E41230E7DFA00B5D28D /* FilterFunctionView.m */, |
| 175 | - 08740E42230E7DFA00B5D28D /* AudioCfgView.h */, | |
| 176 | - 08740E48230E7DFA00B5D28D /* AudioCfgView.m */, | |
| 177 | 175 | 08740E43230E7DFA00B5D28D /* BgmPlayerView.h */, |
| 178 | 176 | 08740E4D230E7DFA00B5D28D /* BgmPlayerView.m */, |
| 179 | 177 | 08740E4C230E7DFA00B5D28D /* SliderView.h */, |
| 180 | 178 | 08740E44230E7DFA00B5D28D /* SliderView.m */, |
| 181 | - 08740E4F230E7DFA00B5D28D /* MoreFunctionsView.h */, | |
| 182 | - 08740E47230E7DFA00B5D28D /* MoreFunctionsView.m */, | |
| 183 | 179 | ); |
| 184 | 180 | path = Streamer; |
| 185 | 181 | sourceTree = "<group>"; |
| ... | ... | @@ -187,12 +183,32 @@ |
| 187 | 183 | 08740E5F230E8C6500B5D28D /* Player */ = { |
| 188 | 184 | isa = PBXGroup; |
| 189 | 185 | children = ( |
| 190 | - 08740E60230E8C6500B5D28D /* CNLivePlayerController.m */, | |
| 191 | 186 | 08740E61230E8C6500B5D28D /* CNLivePlayerController.h */, |
| 187 | + 08740E60230E8C6500B5D28D /* CNLivePlayerController.m */, | |
| 192 | 188 | ); |
| 193 | 189 | path = Player; |
| 194 | 190 | sourceTree = "<group>"; |
| 195 | 191 | }; |
| 192 | + 08740E63230E932600B5D28D /* View */ = { | |
| 193 | + isa = PBXGroup; | |
| 194 | + children = ( | |
| 195 | + 08740E6C230EBA6800B5D28D /* CNLiveVoiceSettingView.h */, | |
| 196 | + 08740E6B230EBA6800B5D28D /* CNLiveVoiceSettingView.m */, | |
| 197 | + 08740E64230E935300B5D28D /* CNLiveLoadingView.h */, | |
| 198 | + 08740E65230E935300B5D28D /* CNLiveLoadingView.m */, | |
| 199 | + 08740E67230E989000B5D28D /* CNLiveMoreFunctionsView.h */, | |
| 200 | + 08740E68230E989000B5D28D /* CNLiveMoreFunctionsView.m */, | |
| 201 | + ); | |
| 202 | + path = View; | |
| 203 | + sourceTree = "<group>"; | |
| 204 | + }; | |
| 205 | + 08740E6A230E9EA200B5D28D /* Controller */ = { | |
| 206 | + isa = PBXGroup; | |
| 207 | + children = ( | |
| 208 | + ); | |
| 209 | + path = Controller; | |
| 210 | + sourceTree = "<group>"; | |
| 211 | + }; | |
| 196 | 212 | 6003F581195388D10070C39A = { |
| 197 | 213 | isa = PBXGroup; |
| 198 | 214 | children = ( |
| ... | ... | @@ -408,7 +424,7 @@ |
| 408 | 424 | ); |
| 409 | 425 | runOnlyForDeploymentPostprocessing = 0; |
| 410 | 426 | shellPath = /bin/sh; |
| 411 | - shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nif [ \"${ACTION}\" = \"build\" ]\nthen\nINSTALL_DIR=${SRCROOT}/Products/${PROJECT_NAME}.framework\nDEVICE_DIR=${SRCROOT}/\"build\"/Debug-iphoneos/${PROJECT_NAME}/${PROJECT_NAME}.framework \nSIMULATOR_DIR=${SRCROOT}/\"build\"/Debug-iphonesimulator/${PROJECT_NAME}/${PROJECT_NAME}.framework \nif [ -d \"${INSTALL_DIR}\" ]\nthen\nrm -rf \"${INSTALL_DIR}\"\nfi\nmkdir -p \"${INSTALL_DIR}\"\ncp -R \"${DEVICE_DIR}/\" \"${INSTALL_DIR}/\"\nlipo -create \"${DEVICE_DIR}/${PROJECT_NAME}\" \"${SIMULATOR_DIR}/${PROJECT_NAME}\" -output \"${INSTALL_DIR}/${PROJECT_NAME}\"\nopen \"${SRCROOT}/Products\"\nfi\n"; | |
| 427 | + shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nif [ \"${ACTION}\" = \"build\" ]\nthen\nINSTALL_DIR=${SRCROOT}/Products/${PROJECT_NAME}.framework\nDEVICE_DIR=${SRCROOT}/\"build\"/Debug-iphoneos/${PROJECT_NAME}/${PROJECT_NAME}.framework \nSIMULATOR_DIR=${SRCROOT}/\"build\"/Debug-iphonesimulator/${PROJECT_NAME}/${PROJECT_NAME}.framework \nif [ -d \"${INSTALL_DIR}\" ]\nthen\nrm -rf \"${INSTALL_DIR}\"\nfi\nmkdir -p \"${INSTALL_DIR}\"\ncp -R \"${DEVICE_DIR}/\" \"${INSTALL_DIR}/\"\nlipo -create \"${DEVICE_DIR}/${PROJECT_NAME}\" \"${SIMULATOR_DIR}/${PROJECT_NAME}\" -output \"${INSTALL_DIR}/${PROJECT_NAME}\"\n#open \"${SRCROOT}/Products\"\nfi\n"; | |
| 412 | 428 | }; |
| 413 | 429 | 5113AD1A1A6CE60F5F11067D /* [CP] Check Pods Manifest.lock */ = { |
| 414 | 430 | isa = PBXShellScriptBuildPhase; |
| ... | ... | @@ -495,19 +511,19 @@ |
| 495 | 511 | isa = PBXSourcesBuildPhase; |
| 496 | 512 | buildActionMask = 2147483647; |
| 497 | 513 | files = ( |
| 498 | - 08740E58230E7DFB00B5D28D /* AudioCfgView.m in Sources */, | |
| 499 | - 08740E5C230E83B100B5D28D /* LoadingView.m in Sources */, | |
| 500 | 514 | 08740E55230E7DFB00B5D28D /* FloatingViewController.m in Sources */, |
| 515 | + 08740E69230E989000B5D28D /* CNLiveMoreFunctionsView.m in Sources */, | |
| 501 | 516 | 6003F59E195388D20070C39A /* CNLiveAppDelegate.m in Sources */, |
| 502 | - 08740E52230E7DFB00B5D28D /* StreamerDetailViewController.m in Sources */, | |
| 517 | + 08740E52230E7DFB00B5D28D /* CNLiveStreamerDetailController.m in Sources */, | |
| 503 | 518 | 6003F5A7195388D20070C39A /* CNLiveViewController.m in Sources */, |
| 519 | + 08740E6D230EBA6800B5D28D /* CNLiveVoiceSettingView.m in Sources */, | |
| 504 | 520 | 08740E56230E7DFB00B5D28D /* AudioStreamingViewController.m in Sources */, |
| 505 | 521 | 08740E62230E8C6500B5D28D /* CNLivePlayerController.m in Sources */, |
| 506 | 522 | 08740E54230E7DFB00B5D28D /* SliderView.m in Sources */, |
| 507 | 523 | 6003F59A195388D20070C39A /* main.m in Sources */, |
| 508 | 524 | 08740E59230E7DFB00B5D28D /* BgmPlayerView.m in Sources */, |
| 509 | - 08740E57230E7DFB00B5D28D /* MoreFunctionsView.m in Sources */, | |
| 510 | 525 | 08740E53230E7DFB00B5D28D /* FilterFunctionView.m in Sources */, |
| 526 | + 08740E66230E935300B5D28D /* CNLiveLoadingView.m in Sources */, | |
| 511 | 527 | 08740E51230E7DFB00B5D28D /* CNLiveStreamerController.m in Sources */, |
| 512 | 528 | ); |
| 513 | 529 | runOnlyForDeploymentPostprocessing = 0; | ... | ... |
Example/CNLivePlayer/CNLivePlayer-Info.plist
| ... | ... | @@ -2,10 +2,14 @@ |
| 2 | 2 | <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
| 3 | 3 | <plist version="1.0"> |
| 4 | 4 | <dict> |
| 5 | - <key>NSMicrophoneUsageDescription</key> | |
| 5 | + <key>NSPhotoLibraryUsageDescription</key> | |
| 6 | + <string></string> | |
| 7 | + <key>NSPhotoLibraryAddUsageDescription</key> | |
| 6 | 8 | <string></string> |
| 7 | 9 | <key>NSCameraUsageDescription</key> |
| 8 | 10 | <string></string> |
| 11 | + <key>NSMicrophoneUsageDescription</key> | |
| 12 | + <string></string> | |
| 9 | 13 | <key>CFBundleDevelopmentRegion</key> |
| 10 | 14 | <string>en</string> |
| 11 | 15 | <key>CFBundleDisplayName</key> | ... | ... |
Example/CNLivePlayer/Images.xcassets/Streamer/互动电视180x180.imageset/Contents.json renamed to Example/CNLivePlayer/Images.xcassets/Streamer/logo.imageset/Contents.json
Example/CNLivePlayer/Images.xcassets/Streamer/互动电视180x180.imageset/互动电视180x180.png renamed to Example/CNLivePlayer/Images.xcassets/Streamer/logo.imageset/互动电视180x180.png
21.2 KB
Example/CNLivePlayer/Player/CNLivePlayerController.m
| ... | ... | @@ -24,8 +24,8 @@ |
| 24 | 24 | // Do any additional setup after loading the view. |
| 25 | 25 | |
| 26 | 26 | self.player = [[CNLivePlayer alloc]initVodPlayerWithVideoId:@"82_c8ff347048414b7295cef882f8361073" authSuccess:^{ |
| 27 | - _player.view.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.width*9/16.0); | |
| 28 | - [_player prepareToPlay]; | |
| 27 | + self.player.view.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.width*9/16.0); | |
| 28 | + [self.player prepareToPlay]; | |
| 29 | 29 | } authFailure:^(NSDictionary * _Nonnull errorInfo) { |
| 30 | 30 | |
| 31 | 31 | }]; | ... | ... |
Example/CNLivePlayer/Streamer/AudioStreamingViewController.m
| ... | ... | @@ -9,7 +9,7 @@ |
| 9 | 9 | #import "AudioStreamingViewController.h" |
| 10 | 10 | #import "CNLiveStreamerManager.h" |
| 11 | 11 | #import "CNLiveStreamerKit.h" |
| 12 | -#import "AudioCfgView.h" | |
| 12 | +#import "CNLiveVoiceSettingView.h" | |
| 13 | 13 | #import "BgmPlayerView.h" |
| 14 | 14 | #import "CNLiveStreamerBase.h" |
| 15 | 15 | #import "CNLiveWatermark.h" |
| ... | ... | @@ -30,7 +30,7 @@ |
| 30 | 30 | |
| 31 | 31 | @property (nonatomic,strong) CNLiveStreamerKit *kitCN; //直播推流 |
| 32 | 32 | @property (nonatomic,strong) UILabel *stateLab; |
| 33 | -@property (nonatomic,strong) AudioCfgView *audioCfgView; //声音相关设置 | |
| 33 | +@property (nonatomic,strong) CNLiveVoiceSettingView *audioCfgView; //声音相关设置 | |
| 34 | 34 | @property (nonatomic,strong) BgmPlayerView *bgmPlayerView; //背景音乐 |
| 35 | 35 | |
| 36 | 36 | @end |
| ... | ... | @@ -426,10 +426,10 @@ |
| 426 | 426 | return _stateLab; |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | -- (AudioCfgView *)audioCfgView | |
| 429 | +- (CNLiveVoiceSettingView *)audioCfgView | |
| 430 | 430 | { |
| 431 | 431 | if (!_audioCfgView) { |
| 432 | - _audioCfgView = [[AudioCfgView alloc] initWithFrame:CGRectMake(0, 160, Width, 200)]; | |
| 432 | + _audioCfgView = [[CNLiveVoiceSettingView alloc] initWithFrame:CGRectMake(0, 160, Width, 200)]; | |
| 433 | 433 | _audioCfgView.hidden = YES; |
| 434 | 434 | } |
| 435 | 435 | return _audioCfgView; | ... | ... |
Example/CNLivePlayer/Streamer/CNLiveStreamerController.h
| 1 | 1 | // |
| 2 | -// StreamerViewController.h | |
| 3 | -// CNLivePlayerSDKTest | |
| 2 | +// CNLiveStreamerController.h | |
| 3 | +// CNLivePlayer_Example | |
| 4 | 4 | // |
| 5 | -// Created by 雷浩杰 on 16/8/10. | |
| 6 | -// Copyright © 2016年 雷浩杰. All rights reserved. | |
| 5 | +// Created by CNLive-zxw on 2019/8/17. | |
| 6 | +// Copyright © 2019 153993236@qq.com. All rights reserved. | |
| 7 | 7 | // |
| 8 | 8 | |
| 9 | 9 | #import <UIKit/UIKit.h> | ... | ... |
Example/CNLivePlayer/Streamer/CNLiveStreamerController.m
| 1 | 1 | // |
| 2 | -// StreamerViewController.m | |
| 3 | -// CNLivePlayerSDKTest | |
| 2 | +// CNLiveStreamerController.m | |
| 3 | +// CNLivePlayer_Example | |
| 4 | 4 | // |
| 5 | -// Created by 雷浩杰 on 16/8/10. | |
| 6 | -// Copyright © 2016年 雷浩杰. All rights reserved. | |
| 5 | +// Created by CNLive-zxw on 2019/8/17. | |
| 6 | +// Copyright © 2019 153993236@qq.com. All rights reserved. | |
| 7 | 7 | // |
| 8 | 8 | |
| 9 | 9 | #import "CNLiveStreamerController.h" |
| 10 | -#import "StreamerDetailViewController.h" | |
| 10 | +#import "CNLiveStreamerDetailController.h" | |
| 11 | 11 | #import "AudioStreamingViewController.h" |
| 12 | 12 | |
| 13 | 13 | #define KScreenWidth [UIScreen mainScreen].bounds.size.width |
| ... | ... | @@ -61,7 +61,7 @@ |
| 61 | 61 | [self presentViewController:vc animated:YES completion:NULL]; |
| 62 | 62 | } |
| 63 | 63 | else { |
| 64 | - StreamerDetailViewController *vc = [[StreamerDetailViewController alloc] init]; | |
| 64 | + CNLiveStreamerDetailController *vc = [[CNLiveStreamerDetailController alloc] init]; | |
| 65 | 65 | vc.isAuthLive = NO; |
| 66 | 66 | vc.url = [NSURL URLWithString:[NSString stringWithFormat:@"%@",self.urlTextField.text]]; |
| 67 | 67 | [self presentViewController:vc animated:YES completion:NULL]; |
| ... | ... | @@ -77,7 +77,7 @@ |
| 77 | 77 | [self presentViewController:vc animated:YES completion:NULL]; |
| 78 | 78 | } |
| 79 | 79 | else { |
| 80 | - StreamerDetailViewController *vc = [[StreamerDetailViewController alloc] init]; | |
| 80 | + CNLiveStreamerDetailController *vc = [[CNLiveStreamerDetailController alloc] init]; | |
| 81 | 81 | vc.isAuthLive = YES; |
| 82 | 82 | vc.url = [NSURL URLWithString:[NSString stringWithFormat:@"%@",self.urlTextField.text]]; |
| 83 | 83 | [self presentViewController:vc animated:YES completion:NULL]; |
| ... | ... | @@ -85,7 +85,7 @@ |
| 85 | 85 | |
| 86 | 86 | } |
| 87 | 87 | else if (sender.selectedSegmentIndex == 2) { |
| 88 | - StreamerDetailViewController *vc = [[StreamerDetailViewController alloc] init]; | |
| 88 | + CNLiveStreamerDetailController *vc = [[CNLiveStreamerDetailController alloc] init]; | |
| 89 | 89 | vc.isRecord = YES; |
| 90 | 90 | [self presentViewController:vc animated:YES completion:NULL]; |
| 91 | 91 | |
| ... | ... | @@ -107,6 +107,7 @@ |
| 107 | 107 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(duration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ |
| 108 | 108 | [toast dismissWithClickedButtonIndex:0 animated:NO]; |
| 109 | 109 | }); |
| 110 | + | |
| 110 | 111 | } |
| 111 | 112 | |
| 112 | 113 | - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { |
| ... | ... | @@ -131,7 +132,7 @@ |
| 131 | 132 | _urlTextField.delegate = self; |
| 132 | 133 | _urlTextField.text = @"rtmp://jsrtmp.up.cnlive.com/live/ceshi"; |
| 133 | 134 | UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, -30, 80, 30)]; |
| 134 | - label.text = @"推流地址:"; | |
| 135 | + label.text = @"推流地址:"; | |
| 135 | 136 | label.font = [UIFont systemFontOfSize:15]; |
| 136 | 137 | [_urlTextField addSubview:label]; |
| 137 | 138 | } |
| ... | ... | @@ -154,7 +155,6 @@ |
| 154 | 155 | NSArray *items = @[ @"普通直播", |
| 155 | 156 | @"鉴权直播", |
| 156 | 157 | @"本地录制"]; |
| 157 | - | |
| 158 | 158 | _liveType = [[UISegmentedControl alloc] initWithItems:items]; |
| 159 | 159 | _liveType.frame = CGRectMake(10, self.view.bounds.size.height-80, self.view.bounds.size.width-20, 40); |
| 160 | 160 | _liveType.tintColor= [UIColor blackColor]; | ... | ... |
Example/CNLivePlayer/Streamer/StreamerDetailViewController.h renamed to Example/CNLivePlayer/Streamer/CNLiveStreamerDetailController.h
| 1 | 1 | // |
| 2 | -// LiveViewController.h | |
| 2 | +// CNLiveStreamerDetailController.h | |
| 3 | 3 | // CNLiveLiveDemo |
| 4 | 4 | // |
| 5 | 5 | // Created by Android on 16/8/10. |
| ... | ... | @@ -8,7 +8,7 @@ |
| 8 | 8 | |
| 9 | 9 | #import <UIKit/UIKit.h> |
| 10 | 10 | |
| 11 | -@interface StreamerDetailViewController : UIViewController | |
| 11 | +@interface CNLiveStreamerDetailController : UIViewController | |
| 12 | 12 | |
| 13 | 13 | @property (nonatomic, assign) BOOL isAuthLive; |
| 14 | 14 | @property (nonatomic, assign) BOOL isRecord; | ... | ... |
Example/CNLivePlayer/Streamer/StreamerDetailViewController.m renamed to Example/CNLivePlayer/Streamer/CNLiveStreamerDetailController.m
| 1 | 1 | // |
| 2 | -// LiveViewController.m | |
| 2 | +// CNLiveStreamerDetailController.m | |
| 3 | 3 | // CNLiveLiveDemo |
| 4 | 4 | // |
| 5 | 5 | // Created by Android on 16/8/10. |
| 6 | 6 | // Copyright © 2016年 Android. All rights reserved. |
| 7 | 7 | // |
| 8 | 8 | |
| 9 | -#import "StreamerDetailViewController.h" | |
| 9 | +#import "CNLiveStreamerDetailController.h" | |
| 10 | 10 | #import "FilterFunctionView.h" |
| 11 | 11 | #import "CNLivePlayerManager.h" |
| 12 | -#import "AudioCfgView.h" | |
| 13 | -#import "LoadingView.h" | |
| 14 | -#import "MoreFunctionsView.h" | |
| 12 | +#import "CNLiveVoiceSettingView.h" | |
| 13 | + | |
| 15 | 14 | #import <GPUImage/GPUImage.h> |
| 16 | 15 | #import <YYImage/YYImage.h> |
| 17 | 16 | #import "FloatingViewController.h" |
| 18 | 17 | #import "CNLiveStreamerKit.h" |
| 19 | 18 | |
| 19 | +#import "CNLiveLoadingView.h" | |
| 20 | +#import "CNLiveMoreFunctionsView.h" | |
| 21 | + | |
| 20 | 22 | #import "CNLiveAudioCapture.h" |
| 21 | 23 | #import "CNLiveBeautifyFaceFilter.h" |
| 22 | 24 | #import "CNLiveStreamerBase.h" |
| 23 | 25 | #import "CNLiveWatermark.h" |
| 24 | 26 | |
| 25 | -#define Width [UIScreen mainScreen].bounds.size.width | |
| 26 | -#define Height [UIScreen mainScreen].bounds.size.height | |
| 27 | +#define Status_Bar_Height [[UIApplication sharedApplication] statusBarFrame].size.height | |
| 28 | +#define Bottom_Safe_Distance Status_Bar_Height >= 44 ? 59:10 | |
| 29 | +#define Screen_Width [UIScreen mainScreen].bounds.size.width | |
| 30 | +#define Screen_Height [UIScreen mainScreen].bounds.size.height | |
| 27 | 31 | |
| 28 | 32 | #define SYSTEM_VERSION_GE_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) |
| 29 | 33 | |
| 30 | -@interface StreamerDetailViewController ()<UIGestureRecognizerDelegate,LoadingViewDelegate> | |
| 31 | -{ | |
| 32 | - UIButton *_startLiveBtn; | |
| 33 | - UIButton *_flashBtn; | |
| 34 | - UIButton *_previewBtn; | |
| 35 | - CGFloat _currentPinchZoomFactor;//当前触摸缩放因子 | |
| 34 | +@interface CNLiveStreamerDetailController()<UIGestureRecognizerDelegate, CNLiveLoadingViewDelegate> { | |
| 35 | + UIButton *_startLiveBtn; //开始推流 | |
| 36 | + UIButton *_previewBtn; //预览按钮 | |
| 37 | + | |
| 38 | + UIButton *_backBtn; //返回 | |
| 39 | + UIButton *_cameraBtn; //相机 | |
| 40 | + UIButton *_flashBtn; //打开闪光灯 | |
| 41 | + UIButton *_filterBtn; //滤镜 | |
| 42 | + UIButton *_voiceBtn; //声音 | |
| 43 | + UIButton *_moreBtn; //更多 | |
| 44 | + | |
| 36 | 45 | |
| 37 | - NSString *_bypassRecFile; // 旁路录制 | |
| 46 | + CGFloat _currentPinchZoomFactor; //当前触摸缩放因子 | |
| 47 | + | |
| 48 | + NSString *_bypassRecFile; // 旁路录制 | |
| 38 | 49 | |
| 39 | - YYImageDecoder * _animateDecoder; | |
| 50 | + YYImageDecoder * _animateDecoder; | |
| 40 | 51 | int _animateIdx; |
| 41 | 52 | |
| 42 | - NSTimeInterval _dlTime; | |
| 53 | + NSTimeInterval _dlTime; | |
| 43 | 54 | |
| 44 | 55 | } |
| 45 | 56 | |
| 46 | -@property (nonatomic,strong) UIView *captureView; | |
| 47 | -@property (nonatomic,strong) UILabel *stateLab; | |
| 48 | -@property (nonatomic,strong) NSURL *hostURL; | |
| 49 | -@property (nonatomic,strong) FilterFunctionView *filterView; | |
| 50 | -@property (nonatomic,strong) CNLiveStreamerKit *kitCN; //直播推流 | |
| 51 | -@property (nonatomic,strong) AudioCfgView *audioCfgView; //声音相关设置 | |
| 52 | -@property (nonatomic, strong) LoadingView *loadingView; | |
| 53 | -@property (nonatomic, strong) MoreFunctionsView *moreFuncsView; | |
| 57 | +@property (nonatomic, strong) UIView *captureView; | |
| 58 | + | |
| 59 | +@property (nonatomic, strong) UILabel *stateLabel; | |
| 60 | + | |
| 61 | +@property (nonatomic, strong) NSURL *hostURL; | |
| 62 | +@property (nonatomic, strong) FilterFunctionView *filterView; | |
| 63 | +@property (nonatomic, strong) CNLiveStreamerKit *kitCN; //直播推流 | |
| 64 | +@property (nonatomic, strong) CNLiveVoiceSettingView *voiceView; //声音相关设置 | |
| 65 | + | |
| 66 | +@property (nonatomic, strong) CNLiveLoadingView *loadingView; | |
| 67 | +@property (nonatomic, strong) CNLiveMoreFunctionsView *moreView; | |
| 54 | 68 | |
| 55 | 69 | @property (nonatomic, strong) NSLock *dlLock; |
| 56 | 70 | @property (nonatomic, strong) GPUImagePicture *logoPicure; |
| ... | ... | @@ -58,17 +72,17 @@ |
| 58 | 72 | |
| 59 | 73 | @end |
| 60 | 74 | |
| 61 | -@implementation StreamerDetailViewController | |
| 62 | - | |
| 75 | +@implementation CNLiveStreamerDetailController | |
| 76 | +#pragma mark - 旋转 | |
| 63 | 77 | // 旋转处理,通过旋转bgView来做到画面相对手机静止不动 |
| 64 | -- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator NS_AVAILABLE_IOS(8_0) | |
| 65 | -{ | |
| 78 | +- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator { | |
| 66 | 79 | [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; |
| 67 | 80 | |
| 68 | 81 | // size |
| 69 | 82 | CGSize screenSize = [UIScreen mainScreen].bounds.size; |
| 70 | 83 | CGFloat minLength = MIN(screenSize.width, screenSize.height); |
| 71 | 84 | CGFloat maxLength = MAX(screenSize.width, screenSize.height); |
| 85 | + | |
| 72 | 86 | CGRect newFrame; |
| 73 | 87 | |
| 74 | 88 | // frame |
| ... | ... | @@ -84,15 +98,19 @@ |
| 84 | 98 | if (toDeviceOrientation == UIDeviceOrientationPortrait) { |
| 85 | 99 | newTransform = CGAffineTransformIdentity; |
| 86 | 100 | newFrame = CGRectMake(0, 0, minLength, maxLength); |
| 87 | - } else { | |
| 101 | + } | |
| 102 | + else { | |
| 103 | + | |
| 88 | 104 | if (currentInterfaceOrientation == UIInterfaceOrientationPortrait) { |
| 89 | 105 | newTransform = CGAffineTransformMakeRotation(M_PI_2*(toDeviceOrientation == UIDeviceOrientationLandscapeRight ? 1 : -1)); |
| 90 | - } else { | |
| 106 | + } | |
| 107 | + else { | |
| 91 | 108 | needStay = YES; |
| 92 | 109 | if (currentInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) { |
| 93 | 110 | newTransform = CGAffineTransformRotate(_captureView.transform, M_PI * 1.00001); |
| 94 | 111 | newTransformOfStay = CGAffineTransformRotate(_captureView.transform, M_PI); |
| 95 | - }else{ | |
| 112 | + } | |
| 113 | + else{ | |
| 96 | 114 | newTransform = CGAffineTransformRotate(_captureView.transform, SYSTEM_VERSION_GE_TO(@"8.0") ? 1.00001 * M_PI : M_PI * 0.99999); |
| 97 | 115 | newTransformOfStay = CGAffineTransformRotate(_captureView.transform, M_PI); |
| 98 | 116 | } |
| ... | ... | @@ -102,17 +120,16 @@ |
| 102 | 120 | |
| 103 | 121 | __weak typeof(self) weakSelf = self; |
| 104 | 122 | [coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) { |
| 105 | - | |
| 106 | 123 | if(SYSTEM_VERSION_GE_TO(@"8.0")) { |
| 107 | 124 | [self onViewRotate]; |
| 108 | 125 | } |
| 109 | - | |
| 110 | 126 | __strong __typeof(weakSelf) strongSelf = weakSelf; |
| 111 | 127 | if (!strongSelf) { |
| 112 | 128 | return ; |
| 113 | 129 | } |
| 114 | 130 | _captureView.transform = newTransform; |
| 115 | 131 | _captureView.frame = newFrame; |
| 132 | + | |
| 116 | 133 | } completion:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) { |
| 117 | 134 | __strong __typeof(weakSelf)strongSelf = weakSelf; |
| 118 | 135 | if (!strongSelf) { |
| ... | ... | @@ -123,10 +140,8 @@ |
| 123 | 140 | _captureView.frame = newFrame; |
| 124 | 141 | needStay = NO; |
| 125 | 142 | } |
| 126 | - | |
| 127 | - _previewBtn.frame = CGRectMake(5, Height-40, 90, 30); | |
| 128 | - _startLiveBtn.frame = CGRectMake(Width-95, Height-40, 90, 30); | |
| 129 | - _stateLab.frame = CGRectMake(0, Height/2-50, Width, 100); | |
| 143 | + _previewBtn.frame = CGRectMake(20, Screen_Height-60, 90, 30); | |
| 144 | + _startLiveBtn.frame = CGRectMake(Screen_Width-90-20, Screen_Height-60, 90, 30); | |
| 130 | 145 | |
| 131 | 146 | }]; |
| 132 | 147 | } |
| ... | ... | @@ -138,23 +153,22 @@ |
| 138 | 153 | [self onViewRotate]; |
| 139 | 154 | } |
| 140 | 155 | |
| 156 | +- (void)onViewRotate { | |
| 157 | + UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; | |
| 158 | + [_kitCN rotateStreamTo:orientation]; | |
| 159 | + | |
| 160 | +} | |
| 161 | + | |
| 141 | 162 | - (void)viewDidLoad { |
| 142 | 163 | [super viewDidLoad]; |
| 143 | 164 | |
| 144 | 165 | self.view.backgroundColor = [UIColor whiteColor]; |
| 145 | 166 | |
| 146 | - [self.view addSubview:self.captureView]; | |
| 147 | - [self.view addSubview:self.filterView]; | |
| 148 | - [self.view addSubview:self.stateLab]; | |
| 149 | - [self.view addSubview:self.audioCfgView]; | |
| 150 | - [self.captureView addSubview:self.loadingView]; | |
| 151 | - [self.view addSubview:self.moreFuncsView]; | |
| 152 | 167 | [self createUI]; |
| 153 | 168 | |
| 154 | 169 | _bypassRecFile =[NSHomeDirectory() stringByAppendingString:@"/Library/Caches/rec.mp4"]; |
| 155 | 170 | |
| 156 | 171 | if (_isAuthLive) { |
| 157 | - | |
| 158 | 172 | NSDate *date = [NSDate date]; |
| 159 | 173 | NSInteger time = [date timeIntervalSince1970]; |
| 160 | 174 | NSString *activityId = [NSString stringWithFormat:@"%ld", (long)time]; |
| ... | ... | @@ -162,62 +176,89 @@ |
| 162 | 176 | _kitCN = [[CNLiveStreamerKit alloc] initVodStreamerWithDefaultConfig]; |
| 163 | 177 | _kitCN.activityId = activityId; |
| 164 | 178 | _kitCN.channelId = @"498122"; |
| 165 | -// _kitCN.isHorizontalScreen = YES; | |
| 166 | 179 | |
| 167 | 180 | //设置重连参数 |
| 168 | 181 | _kitCN.maxAutoRetry = 3; |
| 169 | 182 | _kitCN.autoRetryDelay = 5; |
| 170 | - | |
| 171 | - [self setStreamerCfg]; | |
| 172 | - [self addObservers]; | |
| 173 | - | |
| 174 | - //声音相关设置 | |
| 175 | - [self audioCfg]; | |
| 176 | - [self moreFunctionCfg]; | |
| 177 | - | |
| 178 | 183 | |
| 179 | 184 | }else{ |
| 180 | - | |
| 181 | 185 | _kitCN = [[CNLiveStreamerKit alloc] initWithDefaultConfig:NO]; |
| 182 | 186 | _hostURL = _url; |
| 183 | 187 | |
| 184 | - [self setStreamerCfg]; | |
| 185 | - [self addObservers]; | |
| 186 | - [self audioCfg]; | |
| 187 | - [self moreFunctionCfg]; | |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - __weak StreamerDetailViewController *weakself = self; | |
| 190 | + //通知 | |
| 191 | + [self addObservers]; | |
| 192 | + | |
| 193 | + //推流器配置 | |
| 194 | + [self setStreamerConfig]; | |
| 195 | + //声音相关设置 | |
| 196 | + [self voiceConfig]; | |
| 197 | + //更多配置 | |
| 198 | + [self moreFunctionsConfig]; | |
| 199 | + | |
| 200 | + __weak typeof(self) weakSelf = self; | |
| 191 | 201 | _kitCN.streamerBase.bypassRecordStateChange = ^(CNLiveRecordState state) { |
| 192 | 202 | //旁路录制状态改变会调用该block |
| 193 | - [weakself onBypassRecordStateChange:state]; | |
| 203 | + __strong typeof(self) strongSelf = weakSelf; | |
| 204 | + if(!strongSelf){ | |
| 205 | + return ; | |
| 206 | + } | |
| 207 | + [strongSelf onBypassRecordStateChange:state]; | |
| 208 | + | |
| 194 | 209 | }; |
| 195 | 210 | |
| 196 | 211 | } |
| 197 | 212 | |
| 213 | +#pragma mark - UI | |
| 198 | 214 | - (void)createUI { |
| 199 | - _startLiveBtn = [self addTextButton:@"开始推流" selectedTitle:@"停止推流" frame:CGRectMake(Width-95, Height-40, 90, 30) radius:7 action:@selector(startStreaming:)]; | |
| 200 | - _previewBtn = [self addTextButton:@"关闭预览" selectedTitle:@"开启预览" frame:CGRectMake(5, Height-40, 90, 30) radius:7 action:@selector(startPreview:)]; | |
| 215 | + //预览视图 | |
| 216 | + [self.view addSubview:self.captureView]; | |
| 217 | + //滤镜视图 | |
| 218 | + [self.view addSubview:self.filterView]; | |
| 219 | + //状态提示 | |
| 220 | + [self.view addSubview:self.stateLabel]; | |
| 221 | + //声音设置 | |
| 222 | + [self.view addSubview:self.voiceView]; | |
| 223 | + //加载loading | |
| 224 | + [self.captureView addSubview:self.loadingView]; | |
| 225 | + //更多视图 | |
| 226 | + [self.view addSubview:self.moreView]; | |
| 201 | 227 | |
| 202 | - [self addImageBtn:[UIImage imageNamed:@"back"] selectedImg:nil frame:CGRectMake(20, 20, 33, 33) action:@selector(quit)]; | |
| 203 | - [self addImageBtn:[UIImage imageNamed:@"camera"] selectedImg:nil frame:CGRectMake(70, 20, 33, 33) action:@selector(changeCamera:)]; | |
| 204 | - _flashBtn = [self addImageBtn:[UIImage imageNamed:@"flash close"] selectedImg:[UIImage imageNamed:@"flash open"] frame:CGRectMake(120, 20, 33, 33) action:@selector(flash:)]; | |
| 205 | - [self addImageBtn:[UIImage imageNamed:@"filter"] selectedImg:[UIImage imageNamed:@"filter"] frame:CGRectMake(170, 20, 33, 33) action:@selector(openFilter:)]; | |
| 206 | - [self addImageBtn:[UIImage imageNamed:@"voice"] selectedImg:[UIImage imageNamed:@"voice"] frame:CGRectMake(220, 20, 33, 33) action:@selector(voiceCfg:)]; | |
| 207 | - [self addImageBtn:[UIImage imageNamed:@"更多"] selectedImg:[UIImage imageNamed:@"更多"] frame:CGRectMake(Width-53, 20, 33, 33) action:@selector(moreFunction:)]; | |
| 228 | + CGFloat btnWidth = 90; | |
| 229 | + CGFloat btnHeight = 30; | |
| 208 | 230 | |
| 209 | - UITapGestureRecognizer * singleRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTap:)]; | |
| 210 | - singleRecognizer.delegate = self; | |
| 211 | - [self.captureView addGestureRecognizer:singleRecognizer]; | |
| 231 | + CGFloat btnMargin = Status_Bar_Height+10; | |
| 232 | + | |
| 233 | + //开始推流 | |
| 234 | + _startLiveBtn = [self addTextButton:@"开始推流" selectedTitle:@"停止推流" frame:CGRectMake(Screen_Width-btnWidth-10, Screen_Height-btnHeight-30, btnWidth, btnHeight) radius:7 action:@selector(startLiving:)]; | |
| 235 | + //关闭预览 | |
| 236 | + _previewBtn = [self addTextButton:@"关闭预览" selectedTitle:@"开启预览" frame:CGRectMake(10, Screen_Height-btnHeight-30, btnWidth, btnHeight) radius:7 action:@selector(startPreview:)]; | |
| 237 | + //返回 | |
| 238 | + _backBtn = [self addImageBtn:[UIImage imageNamed:@"back"] selectedImg:nil frame:CGRectMake(10, btnMargin, btnHeight, btnHeight) action:@selector(backBtnDidClicked)]; | |
| 239 | + //相机 | |
| 240 | + _cameraBtn = [self addImageBtn:[UIImage imageNamed:@"camera"] selectedImg:nil frame:CGRectMake(70, btnMargin, btnHeight, btnHeight) action:@selector(cameraBtnDidClicked:)]; | |
| 241 | + //闪光灯 | |
| 242 | + _flashBtn = [self addImageBtn:[UIImage imageNamed:@"flash close"] selectedImg:[UIImage imageNamed:@"flash open"] frame:CGRectMake(120, btnMargin, btnHeight, btnHeight) action:@selector(flashBtnDidClicked:)]; | |
| 212 | 243 | |
| 213 | - UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(pinchDetected:)]; | |
| 244 | + //滤镜 | |
| 245 | + _filterBtn = [self addImageBtn:[UIImage imageNamed:@"filter"] selectedImg:[UIImage imageNamed:@"filter"] frame:CGRectMake(170, btnMargin, btnHeight, btnHeight) action:@selector(filterBtnDidClicked:)]; | |
| 246 | + //声音 | |
| 247 | + _voiceBtn = [self addImageBtn:[UIImage imageNamed:@"voice"] selectedImg:[UIImage imageNamed:@"voice"] frame:CGRectMake(220, btnMargin, btnHeight, btnHeight) action:@selector(voiceBtnDidClicked:)]; | |
| 248 | + //更多 | |
| 249 | + _moreBtn = [self addImageBtn:[UIImage imageNamed:@"更多"] selectedImg:[UIImage imageNamed:@"更多"] frame:CGRectMake(Screen_Width-btnHeight-10, btnMargin, btnHeight, btnHeight) action:@selector(moreBtnDidClicked:)]; | |
| 250 | + | |
| 251 | + UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTap:)]; | |
| 252 | + tapRecognizer.delegate = self; | |
| 253 | + [self.captureView addGestureRecognizer:tapRecognizer]; | |
| 254 | + | |
| 255 | + UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(onPinch:)]; | |
| 214 | 256 | [self.view addGestureRecognizer:pinch]; |
| 215 | 257 | |
| 216 | 258 | } |
| 217 | 259 | |
| 218 | 260 | #pragma mark - initialization |
| 219 | -- (void)setStreamerCfg | |
| 220 | -{ | |
| 261 | +- (void)setStreamerConfig { | |
| 221 | 262 | //采集配置 |
| 222 | 263 | _kitCN.capPreset = AVCaptureSessionPreset1280x720; |
| 223 | 264 | _kitCN.previewDimension = CGSizeMake(720, 1280); |
| ... | ... | @@ -234,12 +275,11 @@ |
| 234 | 275 | _kitCN.streamerBase.audiokBPS = 48; |
| 235 | 276 | |
| 236 | 277 | //设置画面朝向 |
| 237 | - [_kitCN setVideoOrientationBy:[[UIApplication sharedApplication] statusBarOrientation]]; | |
| 278 | + [_kitCN setVideoOrientation:[[UIApplication sharedApplication] statusBarOrientation]]; | |
| 238 | 279 | [_kitCN startPreview:self.captureView]; |
| 239 | 280 | |
| 240 | 281 | //水印图片 |
| 241 | - _kitCN.watermark.logoPic = [[GPUImagePicture alloc] initWithImage:[UIImage imageNamed:@"互动电视180x180"]]; | |
| 242 | -; | |
| 282 | + _kitCN.watermark.logoPic = [[GPUImagePicture alloc] initWithImage:[UIImage imageNamed:@"logo"]]; | |
| 243 | 283 | _kitCN.watermark.logoRect = CGRectMake(0.05, 0.05, 60, 60); |
| 244 | 284 | _kitCN.watermark.logoAlpha = 0.6; |
| 245 | 285 | |
| ... | ... | @@ -251,19 +291,130 @@ |
| 251 | 291 | [_kitCN.watermark updateTextLabel]; |
| 252 | 292 | |
| 253 | 293 | } |
| 254 | - | |
| 255 | -#pragma mark - | |
| 256 | -#pragma mark - 旋转 | |
| 257 | -- (void)onViewRotate { | |
| 258 | - UIInterfaceOrientation orie = [[UIApplication sharedApplication] statusBarOrientation]; | |
| 259 | - [_kitCN rotateStreamTo:orie]; | |
| 260 | - | |
| 294 | +- (void)voiceConfig{ | |
| 295 | + //声音相关设置 | |
| 296 | + __weak typeof(self) weakSelf = self; | |
| 297 | + _voiceView.audioEffectBlock = ^(int type) { //音效 | |
| 298 | + __strong typeof(self) strongSelf = weakSelf; | |
| 299 | + if(!strongSelf){ | |
| 300 | + return ; | |
| 301 | + } | |
| 302 | + strongSelf.kitCN.audioCapture.audioEffectType = type; | |
| 303 | + }; | |
| 304 | + | |
| 305 | + _voiceView.reverbTypeBlock = ^(int type) { //混响 | |
| 306 | + __strong typeof(self) strongSelf = weakSelf; | |
| 307 | + if(!strongSelf){ | |
| 308 | + return ; | |
| 309 | + } | |
| 310 | + strongSelf.kitCN.audioCapture.reverbType = type; | |
| 311 | + }; | |
| 312 | + | |
| 313 | + _voiceView.bPlayCapturedAudio = ^(BOOL isOn) { //耳返 | |
| 314 | + __strong typeof(self) strongSelf = weakSelf; | |
| 315 | + if(!strongSelf){ | |
| 316 | + return ; | |
| 317 | + } | |
| 318 | + if ([CNLiveAudioCapture isHeadsetPluggedIn]) { | |
| 319 | + [strongSelf.kitCN.audioCapture setBPlayCapturedAudio:isOn]; | |
| 320 | + } | |
| 321 | + else { | |
| 322 | + strongSelf.voiceView.bPlaySwitch.on = NO; | |
| 323 | + [strongSelf toast:@"未检测到耳机"]; | |
| 324 | + } | |
| 325 | + }; | |
| 326 | + | |
| 327 | + _voiceView.micVolumeBlock = ^(float micVolume) { //麦克风音量 | |
| 328 | + __strong typeof(self) strongSelf = weakSelf; | |
| 329 | + if(!strongSelf){ | |
| 330 | + return ; | |
| 331 | + } | |
| 332 | + strongSelf.kitCN.audioCapture.micVolume = micVolume; | |
| 333 | + }; | |
| 334 | + | |
| 335 | + _voiceView.bPlayVolumeBlock = ^(float bPlayVolume) { //耳返音量 | |
| 336 | + __strong typeof(self) strongSelf = weakSelf; | |
| 337 | + if(!strongSelf){ | |
| 338 | + return ; | |
| 339 | + } | |
| 340 | + strongSelf.kitCN.audioCapture.bPlayVolume = bPlayVolume; | |
| 341 | + }; | |
| 342 | + | |
| 261 | 343 | } |
| 262 | 344 | |
| 263 | -#pragma mark - Action | |
| 345 | +- (void)moreFunctionsConfig{ | |
| 346 | + __weak typeof(self) weakSelf = self; | |
| 347 | + | |
| 348 | + _moreView.moreBlock = ^(CNLiveMoreFunctionsType type, NSInteger idx, UISegmentedControl *seg) { | |
| 349 | + __strong typeof(self) strongSelf = weakSelf; | |
| 350 | + if(!strongSelf){ | |
| 351 | + return ; | |
| 352 | + } | |
| 353 | + if (type == CNLiveMoreFunctionsScreenshot) { //截图 | |
| 354 | + seg.selectedSegmentIndex = -1; | |
| 355 | + | |
| 356 | + switch (idx) { | |
| 357 | + case 0: { | |
| 358 | + NSDate *date = [NSDate date]; | |
| 359 | + NSInteger time = [date timeIntervalSince1970]; | |
| 360 | + NSString *path = [NSString stringWithFormat:@"snapshot/%ld.jpg", (long)time]; | |
| 361 | + [strongSelf.kitCN.streamerBase takePhotoWithQuality:1 fileName:path]; | |
| 362 | + } | |
| 363 | + break; | |
| 364 | + case 1: { | |
| 365 | + [strongSelf.kitCN.streamerBase getSnapshotWithCompletion:^(UIImage *img){ | |
| 366 | + //所截图片 | |
| 367 | + }]; | |
| 368 | + } | |
| 369 | + break; | |
| 370 | + | |
| 371 | + default: | |
| 372 | + break; | |
| 373 | + } | |
| 374 | + | |
| 375 | + } else if (type == CNLiveMoreFunctionsLiveScene) { | |
| 376 | + //直播场景 | |
| 377 | + strongSelf.kitCN.streamerBase.liveScene = (CNLiveLiveScene)idx; | |
| 378 | + | |
| 379 | + } else if (type == CNLiveMoreFunctionsRecordScene) { | |
| 380 | + //录制场景 | |
| 381 | + strongSelf.kitCN.streamerBase.recScene = (CNLiveRecScene)idx; | |
| 382 | + | |
| 383 | + } else { | |
| 384 | + //logo | |
| 385 | + switch (idx) { | |
| 386 | + case 0: { | |
| 387 | + [strongSelf.dlLock lock]; | |
| 388 | + _animateDecoder = nil; | |
| 389 | + strongSelf.kitCN.watermark.logoPic = nil; | |
| 390 | + [strongSelf.dlLock unlock]; | |
| 391 | + } | |
| 392 | + break; | |
| 393 | + case 1: { | |
| 394 | + [strongSelf.dlLock lock]; | |
| 395 | + _animateDecoder = nil; | |
| 396 | + strongSelf.kitCN.watermark.logoPic = [[GPUImagePicture alloc] initWithImage:[UIImage imageNamed:@"logo"]]; | |
| 397 | + [strongSelf.dlLock unlock]; | |
| 398 | + } | |
| 399 | + break; | |
| 400 | + case 2: { | |
| 401 | + [strongSelf setupAnimateLogo:[[NSBundle mainBundle] pathForResource:@"house" ofType:@"gif"]]; | |
| 402 | + | |
| 403 | + } | |
| 404 | + break; | |
| 405 | + | |
| 406 | + default: | |
| 407 | + break; | |
| 408 | + } | |
| 409 | + } | |
| 410 | + | |
| 411 | + }; | |
| 412 | + | |
| 413 | + | |
| 414 | +} | |
| 264 | 415 | |
| 265 | -- (void)startPreview:(UIButton *)button | |
| 266 | -{ | |
| 416 | +#pragma mark - 响应方法 | |
| 417 | +- (void)startPreview:(UIButton *)button { | |
| 267 | 418 | button.selected = !button.selected; |
| 268 | 419 | if (button.selected) { |
| 269 | 420 | _startLiveBtn.enabled = NO; |
| ... | ... | @@ -278,75 +429,62 @@ |
| 278 | 429 | } |
| 279 | 430 | } |
| 280 | 431 | |
| 281 | -- (void)startStreaming:(UIButton *)button | |
| 282 | -{ | |
| 432 | +- (void)startLiving:(UIButton *)button { | |
| 283 | 433 | button.selected = !button.selected; |
| 284 | 434 | |
| 285 | 435 | if (button.selected) { |
| 286 | - | |
| 287 | 436 | if (!_isRecord) { //若不是本地录制 |
| 288 | - | |
| 289 | 437 | if (_isAuthLive) { |
| 290 | - | |
| 291 | 438 | [_loadingView setLoadingViewStyle:LoadingViewStyleStartLoading]; |
| 292 | - | |
| 293 | 439 | //SDK内部创建活动并开启推流 |
| 294 | 440 | [_kitCN startStream:^{ |
| 295 | 441 | [_loadingView setLoadingViewStyle:LoadingViewStyleStopLoading]; |
| 296 | 442 | NSLog(@"开启推流成功 ------- success"); |
| 443 | + | |
| 297 | 444 | } failure:^(NSDictionary *errorDic) { |
| 298 | 445 | [_loadingView setLoadingViewStyle:LoadingViewStyleStopLoading]; |
| 299 | 446 | [self toast:errorDic[@"errorMessage"]]; |
| 300 | 447 | _startLiveBtn.selected = NO; |
| 301 | 448 | }]; |
| 302 | 449 | |
| 303 | - //由后台创建活动,SDK只负责开启活动 | |
| 304 | -// [_kitCN startStreamWithUrl:@"rtmp://jsrtmp.up.cnlive.com/live/60_iostest?vdoid=60_1496281944" activityId:@"60_1496281944" success:^{ | |
| 305 | -// [_loadingView setLoadingViewStyle:LoadingViewStyleStopLoading]; | |
| 306 | -// NSLog(@"开启推流成功 ------- success"); | |
| 307 | -// } failure:^(NSDictionary *errorDic) { | |
| 308 | -// [_loadingView setLoadingViewStyle:LoadingViewStyleStopLoading]; | |
| 309 | -// [self toast:errorDic[@"errorMessage"]]; | |
| 310 | -// _startLiveBtn.selected = NO; | |
| 311 | -// }]; | |
| 312 | - | |
| 313 | 450 | }else{ |
| 314 | 451 | [_kitCN startStream:_hostURL]; |
| 315 | 452 | } |
| 316 | 453 | |
| 317 | - } else { | |
| 318 | - | |
| 454 | + } | |
| 455 | + else { | |
| 319 | 456 | NSDate *date = [NSDate date]; |
| 320 | 457 | NSInteger time = [date timeIntervalSince1970]; |
| 321 | 458 | NSString *videoName = [NSString stringWithFormat:@"%ld", (long)time]; |
| 322 | - | |
| 323 | 459 | //存储地址 |
| 324 | 460 | NSString *path = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.mp4", videoName]]; |
| 325 | 461 | _hostURL = [NSURL URLWithString:path]; |
| 326 | 462 | [_kitCN startStream:_hostURL]; |
| 463 | + | |
| 327 | 464 | } |
| 328 | 465 | |
| 329 | - }else{ | |
| 330 | - | |
| 466 | + } | |
| 467 | + else{ | |
| 331 | 468 | if (!_isRecord) { |
| 332 | 469 | [_kitCN stopStream]; |
| 333 | - } else { | |
| 470 | + } | |
| 471 | + else { | |
| 334 | 472 | [_kitCN stopRecord]; |
| 335 | 473 | |
| 336 | 474 | [self saveVideoToAlbum:[_hostURL absoluteString]]; |
| 337 | 475 | } |
| 338 | - _stateLab.text = nil; | |
| 476 | + _stateLabel.text = nil; | |
| 339 | 477 | } |
| 340 | 478 | } |
| 341 | 479 | |
| 342 | -- (void)openFilter:(UIButton *)button { | |
| 343 | - _audioCfgView.hidden = YES; | |
| 344 | - _moreFuncsView.hidden = YES; | |
| 480 | +- (void)filterBtnDidClicked:(UIButton *)button { | |
| 481 | + _voiceView.hidden = YES; | |
| 482 | + _moreView.hidden = YES; | |
| 345 | 483 | _filterView.hidden = !_filterView.hidden; |
| 346 | 484 | |
| 347 | 485 | if (_filterView.hidden == NO) { |
| 348 | 486 | |
| 349 | - __weak StreamerDetailViewController *weakself = self; | |
| 487 | + __weak CNLiveStreamerDetailController *weakself = self; | |
| 350 | 488 | |
| 351 | 489 | _filterView.filterViewBlock = ^(float grindRatio , float whitenRatio, float intensity){ |
| 352 | 490 | |
| ... | ... | @@ -369,21 +507,21 @@ |
| 369 | 507 | } |
| 370 | 508 | } |
| 371 | 509 | |
| 372 | -- (void)changeCamera:(UIButton *)button { | |
| 510 | +- (void)cameraBtnDidClicked:(UIButton *)button { | |
| 373 | 511 | [_kitCN switchCamera]; |
| 374 | 512 | if (![_kitCN isTorchSupported]) { |
| 375 | 513 | _flashBtn.selected = NO; |
| 376 | 514 | } |
| 377 | 515 | } |
| 378 | 516 | |
| 379 | -- (void)flash:(UIButton *)button { | |
| 517 | +- (void)flashBtnDidClicked:(UIButton *)button { | |
| 380 | 518 | if ([_kitCN isTorchSupported]) { |
| 381 | 519 | [_kitCN toggleTorch]; |
| 382 | 520 | button.selected = !button.selected; |
| 383 | 521 | } |
| 384 | 522 | } |
| 385 | 523 | |
| 386 | -- (void)quit { | |
| 524 | +- (void)backBtnDidClicked { | |
| 387 | 525 | if (_kitCN.streamState == CNLiveStreamStateConnected) { |
| 388 | 526 | [_kitCN stopStream]; |
| 389 | 527 | } |
| ... | ... | @@ -403,7 +541,7 @@ |
| 403 | 541 | - (void)bypassRecordOn:(UISwitch *)sender { |
| 404 | 542 | |
| 405 | 543 | BOOL bRec = _kitCN.streamerBase.bypassRecordState == CNLiveRecordStateRecording; |
| 406 | - if (_moreFuncsView.bypassRecord.on){ | |
| 544 | + if (_moreView.bypassRecord.on){ | |
| 407 | 545 | if ( _kitCN.streamerBase.isStreaming && !bRec){ |
| 408 | 546 | // 如果启动录像时使用和上次相同的路径,则会覆盖掉上一次录像的文件内容 |
| 409 | 547 | [self deleteFile:_bypassRecFile]; |
| ... | ... | @@ -414,7 +552,7 @@ |
| 414 | 552 | else { |
| 415 | 553 | NSString * msg = @"推流过程中才能旁路录像"; |
| 416 | 554 | [self toast:msg]; |
| 417 | - _moreFuncsView.bypassRecord.on = NO; | |
| 555 | + _moreView.bypassRecord.on = NO; | |
| 418 | 556 | } |
| 419 | 557 | } |
| 420 | 558 | else if (bRec){ |
| ... | ... | @@ -423,7 +561,7 @@ |
| 423 | 561 | |
| 424 | 562 | } |
| 425 | 563 | |
| 426 | -- (void)floatingWindowBtnAction { | |
| 564 | +- (void)floatingWindowBtnClicked { | |
| 427 | 565 | FloatingViewController *vc = [[FloatingViewController alloc] init]; |
| 428 | 566 | vc.kit = _kitCN; |
| 429 | 567 | [self presentViewController:vc animated:YES completion:NULL]; |
| ... | ... | @@ -431,8 +569,7 @@ |
| 431 | 569 | |
| 432 | 570 | |
| 433 | 571 | //对焦与曝光 |
| 434 | -- (void)onTap:(UIGestureRecognizer *)sender | |
| 435 | -{ | |
| 572 | +- (void)onTap:(UIGestureRecognizer *)sender { | |
| 436 | 573 | CGPoint current = [sender locationInView:self.view]; |
| 437 | 574 | CGPoint point = [self convertToPointOfInterestFromViewCoordinates:current]; |
| 438 | 575 | [_kitCN exposureAtPoint:point]; |
| ... | ... | @@ -440,7 +577,7 @@ |
| 440 | 577 | } |
| 441 | 578 | |
| 442 | 579 | //缩放 |
| 443 | -- (void)pinchDetected:(UIPinchGestureRecognizer *)recognizer{ | |
| 580 | +- (void)onPinch:(UIPinchGestureRecognizer *)recognizer{ | |
| 444 | 581 | if (recognizer.state == UIGestureRecognizerStateBegan) { |
| 445 | 582 | _currentPinchZoomFactor = _kitCN.pinchZoomFactor; |
| 446 | 583 | } |
| ... | ... | @@ -448,118 +585,16 @@ |
| 448 | 585 | [_kitCN setPinchZoomFactor:zoomFactor]; |
| 449 | 586 | } |
| 450 | 587 | |
| 451 | -- (void)voiceCfg:(UIButton *)button { | |
| 588 | +- (void)voiceBtnDidClicked:(UIButton *)button { | |
| 452 | 589 | _filterView.hidden = YES; |
| 453 | - _moreFuncsView.hidden = YES; | |
| 454 | - _audioCfgView.hidden = !_audioCfgView.hidden; | |
| 590 | + _moreView.hidden = YES; | |
| 591 | + _voiceView.hidden = !_voiceView.hidden; | |
| 455 | 592 | } |
| 456 | 593 | |
| 457 | -- (void)moreFunction:(UIButton *)button { | |
| 594 | +- (void)moreBtnDidClicked:(UIButton *)button { | |
| 458 | 595 | _filterView.hidden = YES; |
| 459 | - _audioCfgView.hidden = YES; | |
| 460 | - _moreFuncsView.hidden = !_moreFuncsView.hidden; | |
| 461 | -} | |
| 462 | - | |
| 463 | -- (void)audioCfg { | |
| 464 | - //声音相关设置 | |
| 465 | - __weak StreamerDetailViewController *weakself = self; | |
| 466 | - | |
| 467 | - _audioCfgView.audioEffectBlock = ^(int type) { //音效 | |
| 468 | - weakself.kitCN.audioCapture.audioEffectType = type; | |
| 469 | - }; | |
| 470 | - | |
| 471 | - _audioCfgView.reverbTypeBlock = ^(int type) { //混响 | |
| 472 | - weakself.kitCN.audioCapture.reverbType = type; | |
| 473 | - }; | |
| 474 | - | |
| 475 | - _audioCfgView.bPlayCapturedAudio = ^(BOOL isOn) { //耳返 | |
| 476 | - if ([CNLiveAudioCapture isHeadsetPluggedIn]) { | |
| 477 | - [weakself.kitCN.audioCapture setBPlayCapturedAudio:isOn]; | |
| 478 | - } else { | |
| 479 | - weakself.audioCfgView.bPlaySwitch.on = NO; | |
| 480 | - [weakself toast:@"未检测到耳机"]; | |
| 481 | - } | |
| 482 | - }; | |
| 483 | - | |
| 484 | - _audioCfgView.micVolumeBlock = ^(float micVolume) { //麦克风音量 | |
| 485 | - weakself.kitCN.audioCapture.micVolume = micVolume; | |
| 486 | - }; | |
| 487 | - | |
| 488 | - _audioCfgView.bPlayVolumeBlock = ^(float bPlayVolume) { //耳返音量 | |
| 489 | - weakself.kitCN.audioCapture.bPlayVolume = bPlayVolume; | |
| 490 | - }; | |
| 491 | - | |
| 492 | -} | |
| 493 | - | |
| 494 | -- (void)moreFunctionCfg { | |
| 495 | - | |
| 496 | - __weak StreamerDetailViewController *weakself = self; | |
| 497 | - | |
| 498 | - _moreFuncsView.moreFuncBlock = ^(MoreFuncType type, NSInteger idx, UISegmentedControl *seg) { | |
| 499 | - | |
| 500 | - NSLog(@"type:%lu--idx:%ld", (unsigned long)type,(long)idx); | |
| 501 | - | |
| 502 | - if (type == MoreFuncTypeScreenshot) { //截图 | |
| 503 | - | |
| 504 | - seg.selectedSegmentIndex = -1; | |
| 505 | - | |
| 506 | - switch (idx) { | |
| 507 | - case 0: { | |
| 508 | - NSString *path = @"snapshot/c.jpg"; | |
| 509 | - [weakself.kitCN.streamerBase takePhotoWithQuality:1 fileName:path]; | |
| 510 | - NSLog(@"Snapshot save to %@", path); | |
| 511 | - } | |
| 512 | - break; | |
| 513 | - case 1: { | |
| 514 | - [weakself.kitCN.streamerBase getSnapshotWithCompletion:^(UIImage * img){ | |
| 515 | - //所截图片 | |
| 516 | - }]; | |
| 517 | - } | |
| 518 | - break; | |
| 519 | - | |
| 520 | - default: | |
| 521 | - break; | |
| 522 | - } | |
| 523 | - | |
| 524 | - } else if (type == MoreFuncTypeLiveScene) { //直播场景 | |
| 525 | - | |
| 526 | - weakself.kitCN.streamerBase.liveScene = (CNLiveLiveScene)idx; | |
| 527 | - | |
| 528 | - } else if (type == MoreFuncTypeRecordScene) { //录制场景 | |
| 529 | - | |
| 530 | - weakself.kitCN.streamerBase.recScene = (CNLiveRecScene)idx; | |
| 531 | - | |
| 532 | - } else { //logo | |
| 533 | - | |
| 534 | - switch (idx) { | |
| 535 | - case 0: { | |
| 536 | - [weakself.dlLock lock]; | |
| 537 | - _animateDecoder = nil; | |
| 538 | - weakself.kitCN.watermark.logoPic = nil; | |
| 539 | - [weakself.dlLock unlock]; | |
| 540 | - } | |
| 541 | - break; | |
| 542 | - case 1: { | |
| 543 | - [weakself.dlLock lock]; | |
| 544 | - _animateDecoder = nil; | |
| 545 | - weakself.kitCN.watermark.logoPic = [[GPUImagePicture alloc] initWithImage:[UIImage imageNamed:@"互动电视180x180"]]; | |
| 546 | - [weakself.dlLock unlock]; | |
| 547 | - } | |
| 548 | - break; | |
| 549 | - case 2: { | |
| 550 | - | |
| 551 | - [weakself setupAnimateLogo:[[NSBundle mainBundle] pathForResource:@"house" ofType:@"gif"]]; | |
| 552 | - } | |
| 553 | - break; | |
| 554 | - | |
| 555 | - default: | |
| 556 | - break; | |
| 557 | - } | |
| 558 | - } | |
| 559 | - | |
| 560 | - }; | |
| 561 | - | |
| 562 | - | |
| 596 | + _voiceView.hidden = YES; | |
| 597 | + _moreView.hidden = !_moreView.hidden; | |
| 563 | 598 | } |
| 564 | 599 | |
| 565 | 600 | - (void)setupAnimateLogo:(NSString *)path { |
| ... | ... | @@ -583,7 +618,7 @@ |
| 583 | 618 | return; |
| 584 | 619 | } |
| 585 | 620 | [_dlLock lock]; |
| 586 | - YYImageFrame* frame = [_animateDecoder frameAtIndex:_animateIdx | |
| 621 | + YYImageFrame * frame = [_animateDecoder frameAtIndex:_animateIdx | |
| 587 | 622 | decodeForDisplay:NO]; |
| 588 | 623 | if (frame.image) { |
| 589 | 624 | _kitCN.watermark.logoPic = [[GPUImagePicture alloc] initWithImage:frame.image]; |
| ... | ... | @@ -609,17 +644,15 @@ |
| 609 | 644 | }); |
| 610 | 645 | } |
| 611 | 646 | |
| 612 | -#pragma mark - | |
| 613 | -#pragma mark - nitification | |
| 614 | -- (void)addObservers | |
| 615 | -{ | |
| 647 | +#pragma mark - 通知 | |
| 648 | +- (void)addObservers { | |
| 616 | 649 | [[NSNotificationCenter defaultCenter] addObserver:self |
| 617 | - selector:@selector(captureStateChange) | |
| 650 | + selector:@selector(captureStateChanged) | |
| 618 | 651 | name:CNLiveCaptureStateDidChangeNotification |
| 619 | 652 | object:nil]; |
| 620 | 653 | |
| 621 | 654 | [[NSNotificationCenter defaultCenter] addObserver:self |
| 622 | - selector:@selector(streamStateChange) | |
| 655 | + selector:@selector(streamStateChanged) | |
| 623 | 656 | name:CNLiveStreamerStateDidChangeNotification |
| 624 | 657 | object:nil]; |
| 625 | 658 | |
| ... | ... | @@ -627,90 +660,64 @@ |
| 627 | 660 | selector:@selector(reconnectStatusChanged) |
| 628 | 661 | name:CNLiveStreamerReconnectStatusChangedNotification |
| 629 | 662 | object:nil]; |
| 630 | - | |
| 631 | - [[NSNotificationCenter defaultCenter] addObserver:self | |
| 632 | - selector:@selector(enterBg) | |
| 633 | - name:UIApplicationDidEnterBackgroundNotification | |
| 634 | - object:nil]; | |
| 635 | - | |
| 636 | - [[NSNotificationCenter defaultCenter] addObserver:self | |
| 637 | - selector:@selector(becameActive) | |
| 638 | - name:UIApplicationDidBecomeActiveNotification | |
| 639 | - object:nil]; | |
| 640 | 663 | } |
| 641 | 664 | |
| 642 | -#pragma mark - notification | |
| 643 | - | |
| 644 | -- (void)enterBg | |
| 645 | -{ | |
| 646 | -// [_kitCN appEnterBackground]; | |
| 647 | -} | |
| 648 | - | |
| 649 | -- (void)becameActive | |
| 650 | -{ | |
| 651 | -// [_kitCN appBecomeActive]; | |
| 652 | -} | |
| 653 | - | |
| 654 | -- (void)captureStateChange | |
| 655 | -{ | |
| 656 | - | |
| 665 | +- (void)captureStateChanged { | |
| 657 | 666 | if ( _kitCN.captureState == CNLiveCaptureStateIdle){ |
| 658 | 667 | //初始化时状态为空闲 |
| 659 | - _stateLab.text = @"CNLiveCaptureStateIdle"; | |
| 668 | + _stateLabel.text = @"CNLiveCaptureStateIdle"; | |
| 660 | 669 | |
| 661 | 670 | return; |
| 662 | 671 | } |
| 663 | 672 | else if (_kitCN.captureState == CNLiveCaptureStateCapturing ) { |
| 664 | 673 | //设备工作中 |
| 665 | - _stateLab.text = @"CNLiveCaptureStateCapturing"; | |
| 674 | + _stateLabel.text = @"CNLiveCaptureStateCapturing"; | |
| 666 | 675 | |
| 667 | 676 | return; |
| 668 | 677 | } |
| 669 | 678 | else if (_kitCN.captureState == CNLiveCaptureStateClosingCapture ) { |
| 670 | 679 | //关闭采集设备中 |
| 671 | - _stateLab.text = @"CNLiveCaptureStateClosingCapture"; | |
| 680 | + _stateLabel.text = @"CNLiveCaptureStateClosingCapture"; | |
| 672 | 681 | |
| 673 | 682 | return; |
| 674 | 683 | } |
| 675 | 684 | else if (_kitCN.captureState == CNLiveCaptureStateDevAuthDenied ) { |
| 676 | 685 | //设备授权被拒绝 |
| 677 | 686 | NSLog(@"---------CNLiveCaptureStateDevAuthDenied"); |
| 678 | - _stateLab.text = @"camera/mic Authorization Denied"; | |
| 687 | + _stateLabel.text = @"camera/mic Authorization Denied"; | |
| 679 | 688 | |
| 680 | 689 | return; |
| 681 | 690 | } |
| 682 | 691 | else if (_kitCN.captureState == CNLiveCaptureStateParameterError ) { |
| 683 | 692 | // 参数错误,无法打开 |
| 684 | 693 | NSLog(@"---------CNLiveCaptureStateParameterError"); |
| 685 | - _stateLab.text = @"capture devices ParameterError"; | |
| 694 | + _stateLabel.text = @"capture devices ParameterError"; | |
| 686 | 695 | |
| 687 | 696 | return; |
| 688 | 697 | } |
| 689 | 698 | else if (_kitCN.captureState == CNLiveCaptureStateDevBusy ) { |
| 690 | 699 | //设备正忙,请稍后尝试 |
| 691 | 700 | NSLog(@"---------CNLiveCaptureStateDevBusy"); |
| 692 | - _stateLab.text = @"device busy, try later"; | |
| 701 | + _stateLabel.text = @"device busy, try later"; | |
| 693 | 702 | |
| 694 | 703 | } |
| 695 | 704 | } |
| 696 | 705 | |
| 697 | -- (void)streamStateChange | |
| 698 | -{ | |
| 699 | - | |
| 706 | +- (void)streamStateChanged { | |
| 700 | 707 | if (_kitCN.streamState == CNLiveStreamStateIdle) { |
| 701 | 708 | NSLog(@"---------CNLiveStreamStateIdle"); |
| 702 | - _stateLab.text = @"CNLiveStreamStateIdle"; | |
| 709 | + _stateLabel.text = @"CNLiveStreamStateIdle"; | |
| 703 | 710 | } |
| 704 | 711 | |
| 705 | 712 | if (_kitCN.streamState == CNLiveStreamStateConnected) { |
| 706 | 713 | _startLiveBtn.selected = YES; |
| 707 | 714 | NSLog(@"---------CNLiveStreamStateConnected"); |
| 708 | - _stateLab.text = [NSString stringWithFormat:@"CNLiveStreamStateConnected------%@",_hostURL]; | |
| 715 | + _stateLabel.text = [NSString stringWithFormat:@"CNLiveStreamStateConnected------%@",_hostURL]; | |
| 709 | 716 | } |
| 710 | 717 | |
| 711 | 718 | if (_kitCN.streamState == CNLiveStreamStateConnecting) { |
| 712 | 719 | NSLog(@"---------CNLiveStreamStateConnecting"); |
| 713 | - _stateLab.text = @"CNLiveStreamStateConnecting"; | |
| 720 | + _stateLabel.text = @"CNLiveStreamStateConnecting"; | |
| 714 | 721 | } |
| 715 | 722 | |
| 716 | 723 | //推流出错 |
| ... | ... | @@ -722,41 +729,39 @@ |
| 722 | 729 | //断开推流 |
| 723 | 730 | if ( _kitCN.streamState == CNLiveStreamStateDisconnecting) { |
| 724 | 731 | NSLog(@"---------CNLiveStreamStateDisconnecting"); |
| 725 | - _stateLab.text = @"CNLiveStreamStateDisconnecting"; | |
| 726 | - | |
| 732 | + _stateLabel.text = @"CNLiveStreamStateDisconnecting"; | |
| 727 | 733 | } |
| 728 | 734 | |
| 729 | 735 | //结束推流成功 |
| 730 | 736 | if ( _kitCN.streamState == CNLiveStopStreamSuccess) { |
| 731 | 737 | NSLog(@"---------CNLiveStopStreamSuccess"); |
| 732 | - _stateLab.text = @"CNLiveStopStreamSuccess"; | |
| 733 | - | |
| 738 | + _stateLabel.text = @"CNLiveStopStreamSuccess"; | |
| 734 | 739 | } |
| 740 | + | |
| 735 | 741 | } |
| 736 | 742 | |
| 737 | 743 | - (void)onStreamError { |
| 738 | - | |
| 739 | 744 | _startLiveBtn.selected = NO; |
| 740 | 745 | |
| 741 | 746 | CNLiveStreamErrorCode err = _kitCN.streamErrorCode; |
| 742 | 747 | [self toast:[NSString stringWithFormat:@"error ------ %lu",(unsigned long)err]]; |
| 743 | 748 | |
| 744 | - NSLog(@"onErr: %lu [%@]", (unsigned long) err, _stateLab.text); | |
| 749 | + NSLog(@"onErr: %lu [%@]", (unsigned long) err, _stateLabel.text); | |
| 745 | 750 | |
| 746 | 751 | if ( CNLiveStreamErrorCode_CNLiveAUTHFAILED == err ) { |
| 747 | - _stateLab.text = @"SDK auth failed, \npls check ak/sk"; | |
| 752 | + _stateLabel.text = @"SDK auth failed, \npls check ak/sk"; | |
| 748 | 753 | } |
| 749 | 754 | else if ( CNLiveStreamErrorCode_CODEC_OPEN_FAILED == err) { |
| 750 | - _stateLab.text = @"Selected Codec not supported \n in this version"; | |
| 755 | + _stateLabel.text = @"Selected Codec not supported \n in this version"; | |
| 751 | 756 | } |
| 752 | 757 | else if ( CNLiveStreamErrorCode_CONNECT_FAILED == err) { |
| 753 | - _stateLab.text = @"Connecting error, pls check host url \nor network"; | |
| 758 | + _stateLabel.text = @"Connecting error, pls check host url \nor network"; | |
| 754 | 759 | } |
| 755 | 760 | else if ( CNLiveStreamErrorCode_CONNECT_BREAK == err) { |
| 756 | - _stateLab.text = @"Connection break"; | |
| 761 | + _stateLabel.text = @"Connection break"; | |
| 757 | 762 | } |
| 758 | 763 | else if ( CNLiveStreamErrorCode_ABNORMAL == err) { |
| 759 | - _stateLab.text = @"CNLiveStreamErrorCode_ABNORMAL"; | |
| 764 | + _stateLabel.text = @"CNLiveStreamErrorCode_ABNORMAL"; | |
| 760 | 765 | [self toast:@"推流异常中断~~"]; |
| 761 | 766 | _startLiveBtn.selected = NO; |
| 762 | 767 | |
| ... | ... | @@ -775,8 +780,7 @@ |
| 775 | 780 | } |
| 776 | 781 | } |
| 777 | 782 | |
| 778 | -- (void) tryReconnect | |
| 779 | -{ | |
| 783 | +- (void)tryReconnect { | |
| 780 | 784 | dispatch_time_t delay = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)); |
| 781 | 785 | dispatch_after(delay, dispatch_get_main_queue(), ^{ |
| 782 | 786 | |
| ... | ... | @@ -830,26 +834,23 @@ |
| 830 | 834 | else if (newState == CNLiveRecordStateStopped) { |
| 831 | 835 | NSLog(@"stop bypass record"); |
| 832 | 836 | [self saveVideoToAlbum:_bypassRecFile]; |
| 833 | - _moreFuncsView.bypassRecord.on = NO; | |
| 837 | + _moreView.bypassRecord.on = NO; | |
| 834 | 838 | } |
| 835 | 839 | else if (newState == CNLiveRecordStateError) { |
| 836 | 840 | NSLog(@"bypass record error %@", _kitCN.streamerBase.bypassRecordErrorName); |
| 837 | 841 | } |
| 838 | 842 | } |
| 839 | 843 | |
| 840 | -#pragma mark - | |
| 841 | 844 | #pragma mark - LoadingViewDelegate |
| 842 | -- (void)loadingView:(LoadingView *)loadingViewRetryAction { | |
| 843 | - [self startStreaming:_startLiveBtn]; | |
| 845 | +- (void)loadingView:(CNLiveLoadingView *)view { | |
| 846 | + [self startLiving:_startLiveBtn]; | |
| 847 | + | |
| 844 | 848 | } |
| 845 | 849 | |
| 846 | -#pragma mark - | |
| 847 | -#pragma mark - | |
| 848 | 850 | /** |
| 849 | 851 | @abstract 将UI的坐标转换成相机坐标 |
| 850 | 852 | */ |
| 851 | -- (CGPoint)convertToPointOfInterestFromViewCoordinates:(CGPoint)viewCoordinates | |
| 852 | -{ | |
| 853 | +- (CGPoint)convertToPointOfInterestFromViewCoordinates:(CGPoint)viewCoordinates { | |
| 853 | 854 | CGPoint pointOfInterest = CGPointMake(.5f, .5f); |
| 854 | 855 | CGSize frameSize = self.view.frame.size; |
| 855 | 856 | CGSize apertureSize = [_kitCN captureDimension]; |
| ... | ... | @@ -882,27 +883,19 @@ |
| 882 | 883 | return pointOfInterest; |
| 883 | 884 | } |
| 884 | 885 | |
| 885 | -- (void)toast:(NSString*)message | |
| 886 | -{ | |
| 887 | - | |
| 888 | - UIAlertView *toast = [[UIAlertView alloc] initWithTitle:nil | |
| 889 | - message:message | |
| 890 | - delegate:nil | |
| 891 | - cancelButtonTitle:nil | |
| 892 | - otherButtonTitles:nil, nil]; | |
| 886 | +#pragma mark - 工具方法 | |
| 887 | +- (void)toast:(NSString *)message { | |
| 888 | + UIAlertView *toast = [[UIAlertView alloc] initWithTitle:nil message:message delegate:nil cancelButtonTitle:nil otherButtonTitles:nil, nil]; | |
| 893 | 889 | [toast show]; |
| 894 | - double duration = 2.5; | |
| 890 | + double duration = 2.0; | |
| 895 | 891 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(duration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ |
| 896 | 892 | [toast dismissWithClickedButtonIndex:0 animated:NO]; |
| 897 | 893 | }); |
| 894 | + | |
| 898 | 895 | } |
| 899 | 896 | |
| 900 | 897 | |
| 901 | -- (UIButton *)addTextButton:(NSString *)title | |
| 902 | - selectedTitle:(NSString *)selectedTitle | |
| 903 | - frame:(CGRect)frame | |
| 904 | - radius:(CGFloat)radius | |
| 905 | - action:(SEL)action { | |
| 898 | +- (UIButton *)addTextButton:(NSString *)title selectedTitle:(NSString *)selectedTitle frame:(CGRect)frame radius:(CGFloat)radius action:(SEL)action { | |
| 906 | 899 | UIButton * button; |
| 907 | 900 | button = [UIButton buttonWithType:UIButtonTypeCustom]; |
| 908 | 901 | button.frame = frame; |
| ... | ... | @@ -913,17 +906,14 @@ |
| 913 | 906 | [button setTitleColor:[UIColor colorWithRed:23/255.0 green:110/255.0 blue:254/255.0 alpha:1] forState:UIControlStateNormal]; |
| 914 | 907 | button.layer.cornerRadius = radius; |
| 915 | 908 | button.layer.masksToBounds = YES; |
| 916 | - button.layer.borderColor = [UIColor blackColor].CGColor; | |
| 909 | + button.layer.borderColor = [UIColor colorWithRed:23/255.0 green:110/255.0 blue:254/255.0 alpha:1].CGColor; | |
| 917 | 910 | button.layer.borderWidth = 1; |
| 918 | 911 | [self.view addSubview:button]; |
| 919 | 912 | return button; |
| 920 | 913 | |
| 921 | 914 | } |
| 922 | 915 | |
| 923 | -- (UIButton *)addImageBtn:(UIImage *)normalImg | |
| 924 | - selectedImg:(UIImage *)selectedImg | |
| 925 | - frame:(CGRect)frame | |
| 926 | - action:(SEL)action { | |
| 916 | +- (UIButton *)addImageBtn:(UIImage *)normalImg selectedImg:(UIImage *)selectedImg frame:(CGRect)frame action:(SEL)action { | |
| 927 | 917 | UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; |
| 928 | 918 | button.frame = frame; |
| 929 | 919 | [button setImage:normalImg forState:UIControlStateNormal]; |
| ... | ... | @@ -931,11 +921,11 @@ |
| 931 | 921 | [button addTarget:self action:action forControlEvents:UIControlEventTouchUpInside]; |
| 932 | 922 | [self.view addSubview:button]; |
| 933 | 923 | return button; |
| 924 | + | |
| 934 | 925 | } |
| 935 | 926 | |
| 936 | - | |
| 937 | 927 | //保存视频到相簿 |
| 938 | -- (void) saveVideoToAlbum: (NSString*) path { | |
| 928 | +- (void)saveVideoToAlbum:(NSString *)path { | |
| 939 | 929 | NSFileManager *fileManager = [NSFileManager defaultManager]; |
| 940 | 930 | if (![fileManager fileExistsAtPath:path]) { |
| 941 | 931 | return; |
| ... | ... | @@ -949,7 +939,7 @@ |
| 949 | 939 | } |
| 950 | 940 | |
| 951 | 941 | //删除文件,保证保存到相册里面的视频时间是最新的 |
| 952 | --(void)deleteFile:(NSString *)file{ | |
| 942 | +- (void)deleteFile:(NSString *)file{ | |
| 953 | 943 | NSFileManager *fileManager = [NSFileManager defaultManager]; |
| 954 | 944 | if ([fileManager fileExistsAtPath:file]) { |
| 955 | 945 | [fileManager removeItemAtPath:file error:nil]; |
| ... | ... | @@ -969,10 +959,8 @@ |
| 969 | 959 | [self toast:message]; |
| 970 | 960 | } |
| 971 | 961 | |
| 972 | -#pragma mark - GetMethod | |
| 973 | - | |
| 974 | -- (UIView *)captureView | |
| 975 | -{ | |
| 962 | +#pragma mark - 懒加载 | |
| 963 | +- (UIView *)captureView { | |
| 976 | 964 | if (!_captureView) { |
| 977 | 965 | _captureView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)]; |
| 978 | 966 | _captureView.backgroundColor = [UIColor whiteColor]; |
| ... | ... | @@ -980,50 +968,48 @@ |
| 980 | 968 | return _captureView; |
| 981 | 969 | } |
| 982 | 970 | |
| 983 | -- (UILabel *)stateLab | |
| 984 | -{ | |
| 985 | - if (!_stateLab) { | |
| 986 | - _stateLab = [[UILabel alloc] initWithFrame:CGRectMake(0, Height/2-50, Width, 100)]; | |
| 987 | - _stateLab.backgroundColor = [UIColor clearColor]; | |
| 988 | - _stateLab.numberOfLines = 0; | |
| 989 | - _stateLab.textColor = [UIColor redColor]; | |
| 971 | +- (UILabel *)stateLabel { | |
| 972 | + if (!_stateLabel) { | |
| 973 | + _stateLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, 100)]; | |
| 974 | + _stateLabel.backgroundColor = [UIColor clearColor]; | |
| 975 | + _stateLabel.center = self.view.center; | |
| 976 | + _stateLabel.textAlignment = NSTextAlignmentCenter; | |
| 977 | + _stateLabel.numberOfLines = 0; | |
| 978 | + _stateLabel.textColor = [UIColor redColor]; | |
| 990 | 979 | } |
| 991 | - return _stateLab; | |
| 980 | + return _stateLabel; | |
| 992 | 981 | } |
| 993 | 982 | |
| 994 | -- (FilterFunctionView *)filterView | |
| 995 | -{ | |
| 983 | +- (FilterFunctionView *)filterView { | |
| 996 | 984 | if (!_filterView) { |
| 997 | - _filterView = [[FilterFunctionView alloc] initWithFrame:CGRectMake(0, 80, Width, 240)]; | |
| 985 | + _filterView = [[FilterFunctionView alloc] initWithFrame:CGRectMake(0, 80, Screen_Width, 240)]; | |
| 998 | 986 | _filterView.hidden = YES; |
| 999 | 987 | } |
| 1000 | 988 | return _filterView; |
| 1001 | 989 | } |
| 1002 | 990 | |
| 1003 | -- (AudioCfgView *)audioCfgView | |
| 1004 | -{ | |
| 1005 | - if (!_audioCfgView) { | |
| 1006 | - _audioCfgView = [[AudioCfgView alloc] initWithFrame:CGRectMake(0, 80, Width, 200)]; | |
| 1007 | - _audioCfgView.hidden = YES; | |
| 991 | +- (CNLiveVoiceSettingView *)voiceView { | |
| 992 | + if (!_voiceView) { | |
| 993 | + _voiceView = [[CNLiveVoiceSettingView alloc] initWithFrame:CGRectMake(0, 80, Screen_Width, 200)]; | |
| 994 | + _voiceView.hidden = YES; | |
| 1008 | 995 | } |
| 1009 | - return _audioCfgView; | |
| 996 | + return _voiceView; | |
| 1010 | 997 | } |
| 1011 | 998 | |
| 1012 | -- (MoreFunctionsView *)moreFuncsView | |
| 1013 | -{ | |
| 1014 | - if (!_moreFuncsView) { | |
| 1015 | - _moreFuncsView = [[MoreFunctionsView alloc] initWithFrame:CGRectMake(0, 80, Width, 240)]; | |
| 1016 | - [_moreFuncsView.bypassRecord addTarget:self action:@selector(bypassRecordOn:) forControlEvents:UIControlEventValueChanged]; | |
| 1017 | - [_moreFuncsView.floatingWindowBtn addTarget:self action:@selector(floatingWindowBtnAction) forControlEvents:UIControlEventTouchUpInside]; | |
| 1018 | - _moreFuncsView.hidden = YES; | |
| 999 | +- (CNLiveMoreFunctionsView *)moreView { | |
| 1000 | + if (!_moreView) { | |
| 1001 | + _moreView = [[CNLiveMoreFunctionsView alloc] initWithFrame:CGRectMake(0, 80, Screen_Width, 240)]; | |
| 1002 | + [_moreView.bypassRecord addTarget:self action:@selector(bypassRecordOn:) forControlEvents:UIControlEventValueChanged]; | |
| 1003 | + [_moreView.floatingWindowBtn addTarget:self action:@selector(floatingWindowBtnClicked) forControlEvents:UIControlEventTouchUpInside]; | |
| 1004 | + _moreView.hidden = YES; | |
| 1019 | 1005 | } |
| 1020 | - return _moreFuncsView; | |
| 1006 | + return _moreView; | |
| 1021 | 1007 | } |
| 1022 | 1008 | |
| 1023 | -- (LoadingView *)loadingView | |
| 1024 | -{ | |
| 1009 | +//loadingview | |
| 1010 | +- (CNLiveLoadingView *)loadingView { | |
| 1025 | 1011 | if (!_loadingView) { |
| 1026 | - _loadingView = [[LoadingView alloc] initWithFrame:CGRectMake(0, 0, 70, 70)]; | |
| 1012 | + _loadingView = [[CNLiveLoadingView alloc] initWithFrame:CGRectMake(0, 0, 70, 70)]; | |
| 1027 | 1013 | _loadingView.center = self.view.center; |
| 1028 | 1014 | [_loadingView setLoadingViewStyle:LoadingViewStyleStopLoading]; |
| 1029 | 1015 | _loadingView.delegate = self; |
| ... | ... | @@ -1031,8 +1017,7 @@ |
| 1031 | 1017 | return _loadingView; |
| 1032 | 1018 | } |
| 1033 | 1019 | |
| 1034 | -- (void)dealloc | |
| 1035 | -{ | |
| 1020 | +- (void)dealloc { | |
| 1036 | 1021 | [_kitCN quitStreaming]; |
| 1037 | 1022 | self.kitCN = nil; |
| 1038 | 1023 | [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| ... | ... | @@ -1041,19 +1026,4 @@ |
| 1041 | 1026 | |
| 1042 | 1027 | } |
| 1043 | 1028 | |
| 1044 | -- (void)didReceiveMemoryWarning { | |
| 1045 | - [super didReceiveMemoryWarning]; | |
| 1046 | - // Dispose of any resources that can be recreated. | |
| 1047 | -} | |
| 1048 | - | |
| 1049 | -/* | |
| 1050 | - #pragma mark - Navigation | |
| 1051 | - | |
| 1052 | - // In a storyboard-based application, you will often want to do a little preparation before navigation | |
| 1053 | - - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { | |
| 1054 | - // Get the new view controller using [segue destinationViewController]. | |
| 1055 | - // Pass the selected object to the new view controller. | |
| 1056 | - } | |
| 1057 | - */ | |
| 1058 | - | |
| 1059 | 1029 | @end | ... | ... |
Example/CNLivePlayer/Streamer/LoadingView.h renamed to Example/CNLivePlayer/Streamer/View/CNLiveLoadingView.h
| 1 | 1 | // |
| 2 | -// LoadingView.h | |
| 3 | -// CNLivePlayerSDKDemo | |
| 2 | +// CNLiveLoadingView.h | |
| 3 | +// CNLivePlayer | |
| 4 | 4 | // |
| 5 | -// Created by iOS on 17/3/8. | |
| 6 | -// Copyright © 2017年 雷浩杰. All rights reserved. | |
| 5 | +// Created by 153993236@qq.com on 07/26/2019. | |
| 6 | +// Copyright (c) 2019 153993236@qq.com. All rights reserved. | |
| 7 | 7 | // |
| 8 | 8 | |
| 9 | 9 | #import <UIKit/UIKit.h> |
| ... | ... | @@ -14,17 +14,17 @@ typedef NS_ENUM(NSUInteger, LoadingViewStyle) { |
| 14 | 14 | LoadingViewStyleRetry, |
| 15 | 15 | }; |
| 16 | 16 | |
| 17 | -@class LoadingView; | |
| 17 | +@class CNLiveLoadingView; | |
| 18 | 18 | |
| 19 | -@protocol LoadingViewDelegate <NSObject> | |
| 19 | +@protocol CNLiveLoadingViewDelegate <NSObject> | |
| 20 | 20 | |
| 21 | -- (void)loadingView:(LoadingView *)loadingViewRetryAction; | |
| 21 | +- (void)loadingView:(CNLiveLoadingView *)view; | |
| 22 | 22 | |
| 23 | 23 | @end |
| 24 | 24 | |
| 25 | -@interface LoadingView : UIView | |
| 25 | +@interface CNLiveLoadingView : UIView | |
| 26 | 26 | |
| 27 | -@property (nonatomic, assign) id<LoadingViewDelegate> delegate; | |
| 27 | +@property (nonatomic, assign) id<CNLiveLoadingViewDelegate> delegate; | |
| 28 | 28 | |
| 29 | 29 | - (void)setLoadingViewStyle:(LoadingViewStyle)style; |
| 30 | 30 | ... | ... |
Example/CNLivePlayer/Streamer/LoadingView.m renamed to Example/CNLivePlayer/Streamer/View/CNLiveLoadingView.m
| 1 | 1 | // |
| 2 | -// LoadingView.m | |
| 3 | -// CNLivePlayerSDKDemo | |
| 2 | +// CNLiveLoadingView.m | |
| 3 | +// CNLivePlayer | |
| 4 | 4 | // |
| 5 | -// Created by iOS on 17/3/8. | |
| 6 | -// Copyright © 2017年 雷浩杰. All rights reserved. | |
| 5 | +// Created by 153993236@qq.com on 07/26/2019. | |
| 6 | +// Copyright (c) 2019 153993236@qq.com. All rights reserved. | |
| 7 | 7 | // |
| 8 | 8 | |
| 9 | -#import "LoadingView.h" | |
| 9 | +#import "CNLiveLoadingView.h" | |
| 10 | 10 | |
| 11 | -@interface LoadingView () | |
| 11 | +@interface CNLiveLoadingView () | |
| 12 | 12 | |
| 13 | 13 | @property (nonatomic, strong) UIActivityIndicatorView *activityIndicator; |
| 14 | 14 | @property (nonatomic, strong) UIButton *retryBtn; |
| 15 | 15 | |
| 16 | 16 | @end |
| 17 | 17 | |
| 18 | -@implementation LoadingView | |
| 18 | +@implementation CNLiveLoadingView | |
| 19 | 19 | |
| 20 | -- (instancetype)initWithFrame:(CGRect)frame | |
| 21 | -{ | |
| 20 | +- (instancetype)initWithFrame:(CGRect)frame { | |
| 22 | 21 | self = [super initWithFrame:frame]; |
| 23 | 22 | if (self) { |
| 24 | 23 | [self addSubview:self.activityIndicator]; |
| ... | ... | @@ -29,7 +28,6 @@ |
| 29 | 28 | return self; |
| 30 | 29 | } |
| 31 | 30 | |
| 32 | -#pragma mark - | |
| 33 | 31 | #pragma mark - action |
| 34 | 32 | - (void)retryBtnAction { |
| 35 | 33 | if (self.delegate && [self.delegate respondsToSelector:@selector(loadingView:)]) { |
| ... | ... | @@ -60,9 +58,6 @@ |
| 60 | 58 | } |
| 61 | 59 | } |
| 62 | 60 | |
| 63 | - | |
| 64 | - | |
| 65 | -#pragma mark - | |
| 66 | 61 | #pragma mark - getter |
| 67 | 62 | - (UIActivityIndicatorView *)activityIndicator { |
| 68 | 63 | if (!_activityIndicator) { | ... | ... |
Example/CNLivePlayer/Streamer/MoreFunctionsView.h renamed to Example/CNLivePlayer/Streamer/View/CNLiveMoreFunctionsView.h
| 1 | 1 | // |
| 2 | -// MoreFunctionsView.h | |
| 2 | +// CNLiveMoreFunctionsView.h | |
| 3 | 3 | // CNLivePlayerSDKDemo |
| 4 | 4 | // |
| 5 | 5 | // Created by iOS on 2017/9/19. |
| ... | ... | @@ -8,18 +8,18 @@ |
| 8 | 8 | |
| 9 | 9 | #import <UIKit/UIKit.h> |
| 10 | 10 | |
| 11 | -typedef NS_ENUM(NSUInteger, MoreFuncType) { | |
| 12 | - MoreFuncTypeScreenshot = 0, | |
| 13 | - MoreFuncTypeLiveScene, | |
| 14 | - MoreFuncTypeRecordScene, | |
| 15 | - MoreFuncTypeLogo | |
| 11 | +typedef NS_ENUM(NSUInteger, CNLiveMoreFunctionsType) { | |
| 12 | + CNLiveMoreFunctionsScreenshot = 0, | |
| 13 | + CNLiveMoreFunctionsLiveScene, | |
| 14 | + CNLiveMoreFunctionsRecordScene, | |
| 15 | + CNLiveMoreFunctionsLogo | |
| 16 | 16 | }; |
| 17 | 17 | |
| 18 | -typedef void(^MoreFuncBlock)(MoreFuncType type, NSInteger idx, UISegmentedControl *seg); | |
| 18 | +typedef void(^MoreFunctionsBlock)(CNLiveMoreFunctionsType type, NSInteger idx, UISegmentedControl *seg); | |
| 19 | 19 | |
| 20 | -@interface MoreFunctionsView : UIView | |
| 20 | +@interface CNLiveMoreFunctionsView : UIView | |
| 21 | 21 | |
| 22 | -@property (nonatomic, copy) MoreFuncBlock moreFuncBlock; | |
| 22 | +@property (nonatomic, copy) MoreFunctionsBlock moreBlock; | |
| 23 | 23 | @property (nonatomic, strong) UISwitch *bypassRecord; |
| 24 | 24 | @property (nonatomic, strong) UIButton *floatingWindowBtn; |
| 25 | 25 | ... | ... |
Example/CNLivePlayer/Streamer/MoreFunctionsView.m renamed to Example/CNLivePlayer/Streamer/View/CNLiveMoreFunctionsView.m
| 1 | 1 | // |
| 2 | -// MoreFunctionsView.m | |
| 2 | +// CNLiveMoreFunctionsView.m | |
| 3 | 3 | // CNLivePlayerSDKDemo |
| 4 | 4 | // |
| 5 | 5 | // Created by iOS on 2017/9/19. |
| 6 | 6 | // Copyright © 2017年 雷浩杰. All rights reserved. |
| 7 | 7 | // |
| 8 | 8 | |
| 9 | -#import "MoreFunctionsView.h" | |
| 9 | +#import "CNLiveMoreFunctionsView.h" | |
| 10 | 10 | |
| 11 | -@interface MoreFunctionsView () | |
| 11 | +@interface CNLiveMoreFunctionsView () | |
| 12 | 12 | |
| 13 | 13 | @property (nonatomic, strong) UISegmentedControl *screenshotSeg; |
| 14 | 14 | @property (nonatomic, strong) UISegmentedControl *liveSceneSeg; |
| ... | ... | @@ -17,10 +17,9 @@ |
| 17 | 17 | |
| 18 | 18 | @end |
| 19 | 19 | |
| 20 | -@implementation MoreFunctionsView | |
| 20 | +@implementation CNLiveMoreFunctionsView | |
| 21 | 21 | |
| 22 | -- (instancetype)initWithFrame:(CGRect)frame | |
| 23 | -{ | |
| 22 | +- (instancetype)initWithFrame:(CGRect)frame { | |
| 24 | 23 | self = [super initWithFrame:frame]; |
| 25 | 24 | if (self) { |
| 26 | 25 | |
| ... | ... | @@ -35,18 +34,15 @@ |
| 35 | 34 | return self; |
| 36 | 35 | } |
| 37 | 36 | |
| 38 | -#pragma mark - | |
| 39 | 37 | #pragma mark - action |
| 40 | 38 | - (void)onSegCtrl:(UISegmentedControl *)seg { |
| 41 | - if (self.moreFuncBlock) { | |
| 42 | - self.moreFuncBlock(seg.tag, seg.selectedSegmentIndex, seg); | |
| 39 | + if (self.moreBlock) { | |
| 40 | + self.moreBlock(seg.tag, seg.selectedSegmentIndex, seg); | |
| 43 | 41 | } |
| 44 | 42 | } |
| 45 | 43 | |
| 46 | -#pragma mark - | |
| 47 | 44 | #pragma mark - getter |
| 48 | -- (UISegmentedControl *)screenshotSeg | |
| 49 | -{ | |
| 45 | +- (UISegmentedControl *)screenshotSeg { | |
| 50 | 46 | if (!_screenshotSeg) { |
| 51 | 47 | NSArray *items = @[ @"截图为文件", |
| 52 | 48 | @"截图为UIImage"]; |
| ... | ... | @@ -56,7 +52,7 @@ |
| 56 | 52 | _screenshotSeg.tintColor= [UIColor blackColor]; |
| 57 | 53 | _screenshotSeg.layer.cornerRadius = 5; |
| 58 | 54 | _screenshotSeg.selectedSegmentIndex = -1; |
| 59 | - _screenshotSeg.tag = MoreFuncTypeScreenshot; | |
| 55 | + _screenshotSeg.tag = CNLiveMoreFunctionsScreenshot; | |
| 60 | 56 | [_screenshotSeg addTarget:self action:@selector(onSegCtrl:) forControlEvents:UIControlEventValueChanged]; |
| 61 | 57 | |
| 62 | 58 | UILabel *titleLab = [[UILabel alloc] initWithFrame:CGRectMake(-85, 0, 80, 30)]; |
| ... | ... | @@ -70,8 +66,7 @@ |
| 70 | 66 | return _screenshotSeg; |
| 71 | 67 | } |
| 72 | 68 | |
| 73 | -- (UISegmentedControl *)liveSceneSeg | |
| 74 | -{ | |
| 69 | +- (UISegmentedControl *)liveSceneSeg { | |
| 75 | 70 | if (!_liveSceneSeg) { |
| 76 | 71 | NSArray *items = @[ @"默认", |
| 77 | 72 | @"秀场", |
| ... | ... | @@ -84,7 +79,7 @@ |
| 84 | 79 | _liveSceneSeg.selectedSegmentIndex = 0; |
| 85 | 80 | _liveSceneSeg.layer.cornerRadius = 5; |
| 86 | 81 | _liveSceneSeg.selectedSegmentIndex = 1; |
| 87 | - _liveSceneSeg.tag = MoreFuncTypeLiveScene; | |
| 82 | + _liveSceneSeg.tag = CNLiveMoreFunctionsLiveScene; | |
| 88 | 83 | [_liveSceneSeg addTarget:self action:@selector(onSegCtrl:) forControlEvents:UIControlEventValueChanged]; |
| 89 | 84 | |
| 90 | 85 | UILabel *titleLab = [[UILabel alloc] initWithFrame:CGRectMake(-85, 0, 80, 30)]; |
| ... | ... | @@ -98,8 +93,7 @@ |
| 98 | 93 | return _liveSceneSeg; |
| 99 | 94 | } |
| 100 | 95 | |
| 101 | -- (UISegmentedControl *)recordSceneSeg | |
| 102 | -{ | |
| 96 | +- (UISegmentedControl *)recordSceneSeg { | |
| 103 | 97 | if (!_recordSceneSeg) { |
| 104 | 98 | NSArray *items = @[ @"恒定码率", |
| 105 | 99 | @"恒定质量", |
| ... | ... | @@ -111,7 +105,7 @@ |
| 111 | 105 | _recordSceneSeg.selectedSegmentIndex = 0; |
| 112 | 106 | _recordSceneSeg.layer.cornerRadius = 5; |
| 113 | 107 | _recordSceneSeg.selectedSegmentIndex = 1; |
| 114 | - _recordSceneSeg.tag = MoreFuncTypeRecordScene; | |
| 108 | + _recordSceneSeg.tag = CNLiveMoreFunctionsRecordScene; | |
| 115 | 109 | [_recordSceneSeg addTarget:self action:@selector(onSegCtrl:) forControlEvents:UIControlEventValueChanged]; |
| 116 | 110 | |
| 117 | 111 | UILabel *titleLab = [[UILabel alloc] initWithFrame:CGRectMake(-85, 0, 80, 30)]; |
| ... | ... | @@ -123,10 +117,10 @@ |
| 123 | 117 | [_recordSceneSeg addSubview:titleLab]; |
| 124 | 118 | } |
| 125 | 119 | return _recordSceneSeg; |
| 120 | + | |
| 126 | 121 | } |
| 127 | 122 | |
| 128 | -- (UISegmentedControl *)logoSeg | |
| 129 | -{ | |
| 123 | +- (UISegmentedControl *)logoSeg { | |
| 130 | 124 | if (!_logoSeg) { |
| 131 | 125 | NSArray *items = @[ @"清除logo", |
| 132 | 126 | @"图片logo", |
| ... | ... | @@ -139,7 +133,7 @@ |
| 139 | 133 | _logoSeg.selectedSegmentIndex = 0; |
| 140 | 134 | _logoSeg.layer.cornerRadius = 5; |
| 141 | 135 | _logoSeg.selectedSegmentIndex = 1; |
| 142 | - _logoSeg.tag = MoreFuncTypeLogo; | |
| 136 | + _logoSeg.tag = CNLiveMoreFunctionsLogo; | |
| 143 | 137 | [_logoSeg addTarget:self action:@selector(onSegCtrl:) forControlEvents:UIControlEventValueChanged]; |
| 144 | 138 | |
| 145 | 139 | UILabel *titleLab = [[UILabel alloc] initWithFrame:CGRectMake(-85, 0, 80, 30)]; |
| ... | ... | @@ -153,8 +147,7 @@ |
| 153 | 147 | return _logoSeg; |
| 154 | 148 | } |
| 155 | 149 | |
| 156 | -- (UISwitch *)bypassRecord | |
| 157 | -{ | |
| 150 | +- (UISwitch *)bypassRecord { | |
| 158 | 151 | if (!_bypassRecord) { |
| 159 | 152 | _bypassRecord = [[UISwitch alloc] initWithFrame:CGRectMake(95, 160, 100, 30)]; |
| 160 | 153 | |
| ... | ... | @@ -169,8 +162,7 @@ |
| 169 | 162 | return _bypassRecord; |
| 170 | 163 | } |
| 171 | 164 | |
| 172 | -- (UIButton *)floatingWindowBtn | |
| 173 | -{ | |
| 165 | +- (UIButton *)floatingWindowBtn { | |
| 174 | 166 | if (!_floatingWindowBtn) { |
| 175 | 167 | _floatingWindowBtn = [UIButton buttonWithType:UIButtonTypeCustom]; |
| 176 | 168 | _floatingWindowBtn.frame = CGRectMake(220, 160, 80, 30); |
| ... | ... | @@ -186,12 +178,4 @@ |
| 186 | 178 | return _floatingWindowBtn; |
| 187 | 179 | } |
| 188 | 180 | |
| 189 | -/* | |
| 190 | -// Only override drawRect: if you perform custom drawing. | |
| 191 | -// An empty implementation adversely affects performance during animation. | |
| 192 | -- (void)drawRect:(CGRect)rect { | |
| 193 | - // Drawing code | |
| 194 | -} | |
| 195 | -*/ | |
| 196 | - | |
| 197 | 181 | @end | ... | ... |
Example/CNLivePlayer/Streamer/AudioCfgView.h renamed to Example/CNLivePlayer/Streamer/View/CNLiveVoiceSettingView.h
| 1 | 1 | // |
| 2 | -// AudioCfgView.h | |
| 2 | +// CNLiveVoiceSettingView.h | |
| 3 | 3 | // CNLivePlayerSDKDemo |
| 4 | 4 | // |
| 5 | 5 | // Created by iOS on 17/4/26. |
| ... | ... | @@ -14,7 +14,7 @@ typedef void(^BPlayCapturedAudioBlock)(BOOL isOn); //是否开启耳返 |
| 14 | 14 | typedef void(^MicVolumeBlock)(float micVolume); //麦克风音量 |
| 15 | 15 | typedef void(^BPlayVolumeBlock)(float bPlayVolume); //耳返音量 |
| 16 | 16 | |
| 17 | -@interface AudioCfgView : UIView | |
| 17 | +@interface CNLiveVoiceSettingView : UIView | |
| 18 | 18 | |
| 19 | 19 | @property (nonatomic, strong) UISwitch *bPlaySwitch; |
| 20 | 20 | |
| ... | ... | @@ -24,4 +24,5 @@ typedef void(^BPlayVolumeBlock)(float bPlayVolume); //耳返音量 |
| 24 | 24 | @property (nonatomic, copy) MicVolumeBlock micVolumeBlock; |
| 25 | 25 | @property (nonatomic, copy) BPlayVolumeBlock bPlayVolumeBlock; |
| 26 | 26 | |
| 27 | + | |
| 27 | 28 | @end | ... | ... |
Example/CNLivePlayer/Streamer/AudioCfgView.m renamed to Example/CNLivePlayer/Streamer/View/CNLiveVoiceSettingView.m
| 1 | 1 | // |
| 2 | -// AudioCfgView.m | |
| 2 | +// CNLiveVoiceSettingView.m | |
| 3 | 3 | // CNLivePlayerSDKDemo |
| 4 | 4 | // |
| 5 | 5 | // Created by iOS on 17/4/26. |
| 6 | 6 | // Copyright © 2017年 雷浩杰. All rights reserved. |
| 7 | 7 | // |
| 8 | 8 | |
| 9 | -#import "AudioCfgView.h" | |
| 9 | +#import "CNLiveVoiceSettingView.h" | |
| 10 | 10 | |
| 11 | -@interface AudioCfgView () | |
| 12 | - | |
| 13 | -@property (nonatomic, strong) UISegmentedControl *audioEffectType; | |
| 14 | -@property (nonatomic, strong) UISegmentedControl *reverbType; | |
| 11 | +@interface CNLiveVoiceSettingView () | |
| 12 | +@property (nonatomic, strong) UISegmentedControl *audioEffectType; | |
| 13 | +@property (nonatomic, strong) UISegmentedControl *reverbType; | |
| 15 | 14 | @property (nonatomic, strong) UISlider *micVolumeSlider; |
| 16 | 15 | @property (nonatomic, strong) UISlider *bPlayVolumeSlider; |
| 17 | 16 | |
| 18 | 17 | @end |
| 19 | 18 | |
| 20 | -@implementation AudioCfgView | |
| 19 | +@implementation CNLiveVoiceSettingView | |
| 21 | 20 | |
| 22 | -- (instancetype)initWithFrame:(CGRect)frame | |
| 23 | -{ | |
| 21 | +- (instancetype)initWithFrame:(CGRect)frame { | |
| 24 | 22 | self = [super initWithFrame:frame]; |
| 25 | 23 | if (self) { |
| 26 | 24 | self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.1]; |
| ... | ... | @@ -33,7 +31,6 @@ |
| 33 | 31 | return self; |
| 34 | 32 | } |
| 35 | 33 | |
| 36 | -#pragma mark - | |
| 37 | 34 | #pragma mark - action |
| 38 | 35 | - (void)audioEffect:(UISegmentedControl *)sender { |
| 39 | 36 | self.audioEffectBlock ? self.audioEffectBlock((int)sender.selectedSegmentIndex) : nil; |
| ... | ... | @@ -43,7 +40,7 @@ |
| 43 | 40 | self.reverbTypeBlock ? self.reverbTypeBlock((int)sender.selectedSegmentIndex) : nil; |
| 44 | 41 | } |
| 45 | 42 | |
| 46 | --(void)switchAction:(id)sender { | |
| 43 | +- (void)switchAction:(id)sender { | |
| 47 | 44 | UISwitch *swi = (UISwitch *)sender; |
| 48 | 45 | self.bPlayCapturedAudio ? self.bPlayCapturedAudio(swi.on) : nil; |
| 49 | 46 | } |
| ... | ... | @@ -56,10 +53,8 @@ |
| 56 | 53 | self.bPlayVolumeBlock ? self.bPlayVolumeBlock(slider.value) : nil; |
| 57 | 54 | } |
| 58 | 55 | |
| 59 | -#pragma mark - | |
| 60 | 56 | #pragma mark - getter |
| 61 | -- (UISegmentedControl *)audioEffectType | |
| 62 | -{ | |
| 57 | +- (UISegmentedControl *)audioEffectType { | |
| 63 | 58 | if (!_audioEffectType) { |
| 64 | 59 | NSArray *items = @[ @"关闭", |
| 65 | 60 | @"大叔", |
| ... | ... | @@ -81,8 +76,7 @@ |
| 81 | 76 | return _audioEffectType; |
| 82 | 77 | } |
| 83 | 78 | |
| 84 | -- (UISegmentedControl *)reverbType | |
| 85 | -{ | |
| 79 | +- (UISegmentedControl *)reverbType { | |
| 86 | 80 | if (!_reverbType) { |
| 87 | 81 | NSArray *items = @[ @"关闭", |
| 88 | 82 | @"录音棚", |
| ... | ... | @@ -104,8 +98,7 @@ |
| 104 | 98 | return _reverbType; |
| 105 | 99 | } |
| 106 | 100 | |
| 107 | -- (UISwitch *)bPlaySwitch | |
| 108 | -{ | |
| 101 | +- (UISwitch *)bPlaySwitch { | |
| 109 | 102 | if (!_bPlaySwitch) { |
| 110 | 103 | _bPlaySwitch = [[UISwitch alloc] initWithFrame:CGRectMake(60, 10, 100, 30)]; |
| 111 | 104 | [_bPlaySwitch addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventValueChanged]; |
| ... | ... | @@ -117,8 +110,7 @@ |
| 117 | 110 | return _bPlaySwitch; |
| 118 | 111 | } |
| 119 | 112 | |
| 120 | -- (UISlider *)micVolumeSlider | |
| 121 | -{ | |
| 113 | +- (UISlider *)micVolumeSlider { | |
| 122 | 114 | if (!_micVolumeSlider) { |
| 123 | 115 | _micVolumeSlider = [[UISlider alloc] initWithFrame:CGRectMake(100, 135, self.bounds.size.width-110, 24)]; |
| 124 | 116 | [_micVolumeSlider setMinimumTrackTintColor:[UIColor redColor]]; |
| ... | ... | @@ -136,8 +128,7 @@ |
| 136 | 128 | return _micVolumeSlider; |
| 137 | 129 | } |
| 138 | 130 | |
| 139 | -- (UISlider *)bPlayVolumeSlider | |
| 140 | -{ | |
| 131 | +- (UISlider *)bPlayVolumeSlider { | |
| 141 | 132 | if (!_bPlayVolumeSlider) { |
| 142 | 133 | _bPlayVolumeSlider = [[UISlider alloc] initWithFrame:CGRectMake(100, 170, self.bounds.size.width-110, 24)]; |
| 143 | 134 | _bPlayVolumeSlider.value = 1.0; |
| ... | ... | @@ -154,12 +145,5 @@ |
| 154 | 145 | return _bPlayVolumeSlider; |
| 155 | 146 | } |
| 156 | 147 | |
| 157 | -/* | |
| 158 | -// Only override drawRect: if you perform custom drawing. | |
| 159 | -// An empty implementation adversely affects performance during animation. | |
| 160 | -- (void)drawRect:(CGRect)rect { | |
| 161 | - // Drawing code | |
| 162 | -} | |
| 163 | -*/ | |
| 164 | 148 | |
| 165 | 149 | @end | ... | ... |