Commit cf9d068670867445cdd403fe6109093a7e969e95

Authored by 张旭
2 parents 43b0a017 0b9e891a

Merge branch 'master' of bj.gitlab.cnlive.com:ios-team/LiveVideoCloud

LiveVideoCloud/LiveVideoCloud.xcodeproj/project.pbxproj
... ... @@ -22,7 +22,6 @@
22 22 810B650A1E77B39D00133E15 /* LVCFullScreenPlayerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 810B65091E77B39D00133E15 /* LVCFullScreenPlayerController.m */; };
23 23 8112D4311E7927A5002E00F6 /* LVCPlayerLoadingView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8112D4301E7927A5002E00F6 /* LVCPlayerLoadingView.m */; };
24 24 812E50531E7699DC004F5FCD /* CNLivePlayerSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 812E50501E7699DC004F5FCD /* CNLivePlayerSDK.framework */; };
25   - 812E50541E7699DC004F5FCD /* KSYGPUResource.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 812E50511E7699DC004F5FCD /* KSYGPUResource.bundle */; };
26 25 812E50551E7699E9004F5FCD /* CNLiveMsgTools.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 812E504F1E7699DC004F5FCD /* CNLiveMsgTools.framework */; };
27 26 812E50561E7699E9004F5FCD /* CNLiveMsgTools.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 812E504F1E7699DC004F5FCD /* CNLiveMsgTools.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
28 27 812E50581E7699E9004F5FCD /* CNLivePlayerSDK.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 812E50501E7699DC004F5FCD /* CNLivePlayerSDK.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
... ... @@ -146,6 +145,9 @@
146 145 D2575C7E1E76A4F300E3A8FC /* NHPlaneViews.m in Sources */ = {isa = PBXBuildFile; fileRef = D2575C771E76A4F300E3A8FC /* NHPlaneViews.m */; };
147 146 D2575C7F1E76A4F300E3A8FC /* NHPlaneViews.xib in Resources */ = {isa = PBXBuildFile; fileRef = D2575C781E76A4F300E3A8FC /* NHPlaneViews.xib */; };
148 147 D2575C801E76A4F300E3A8FC /* resource.bundle in Resources */ = {isa = PBXBuildFile; fileRef = D2575C791E76A4F300E3A8FC /* resource.bundle */; };
  148 + D25BF87A1E7B8A82007FB138 /* FilterFunctionView.m in Sources */ = {isa = PBXBuildFile; fileRef = D25BF8771E7B8A82007FB138 /* FilterFunctionView.m */; };
  149 + D25BF87B1E7B8A82007FB138 /* SliderView.m in Sources */ = {isa = PBXBuildFile; fileRef = D25BF8791E7B8A82007FB138 /* SliderView.m */; };
  150 + D25BF87D1E7B8C78007FB138 /* KSYGPUResource.bundle in Resources */ = {isa = PBXBuildFile; fileRef = D25BF87C1E7B8C78007FB138 /* KSYGPUResource.bundle */; };
149 151 D2888D941E6EB8B4003A77C8 /* LVCTabBar.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888D931E6EB8B4003A77C8 /* LVCTabBar.m */; };
150 152 D2888D9E1E6EBF1B003A77C8 /* LVCLiveViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888D9B1E6EBF1B003A77C8 /* LVCLiveViewController.m */; };
151 153 D2888DB11E6EC05F003A77C8 /* TempViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888DB01E6EC05F003A77C8 /* TempViewController.m */; };
... ... @@ -477,6 +479,11 @@
477 479 D2575C771E76A4F300E3A8FC /* NHPlaneViews.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NHPlaneViews.m; sourceTree = "<group>"; };
478 480 D2575C781E76A4F300E3A8FC /* NHPlaneViews.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = NHPlaneViews.xib; sourceTree = "<group>"; };
479 481 D2575C791E76A4F300E3A8FC /* resource.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = resource.bundle; sourceTree = "<group>"; };
  482 + D25BF8761E7B8A82007FB138 /* FilterFunctionView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FilterFunctionView.h; sourceTree = "<group>"; };
  483 + D25BF8771E7B8A82007FB138 /* FilterFunctionView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FilterFunctionView.m; sourceTree = "<group>"; };
  484 + D25BF8781E7B8A82007FB138 /* SliderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SliderView.h; sourceTree = "<group>"; };
  485 + D25BF8791E7B8A82007FB138 /* SliderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SliderView.m; sourceTree = "<group>"; };
  486 + D25BF87C1E7B8C78007FB138 /* KSYGPUResource.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = KSYGPUResource.bundle; sourceTree = "<group>"; };
480 487 D2888D921E6EB8B4003A77C8 /* LVCTabBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCTabBar.h; sourceTree = "<group>"; };
481 488 D2888D931E6EB8B4003A77C8 /* LVCTabBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCTabBar.m; sourceTree = "<group>"; };
482 489 D2888D9A1E6EBF1B003A77C8 /* LVCLiveViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCLiveViewController.h; sourceTree = "<group>"; };
... ... @@ -560,9 +567,9 @@
560 567 812E504E1E7699B9004F5FCD /* CNLiveSDK */ = {
561 568 isa = PBXGroup;
562 569 children = (
  570 + D25BF87C1E7B8C78007FB138 /* KSYGPUResource.bundle */,
563 571 812E504F1E7699DC004F5FCD /* CNLiveMsgTools.framework */,
564 572 812E50501E7699DC004F5FCD /* CNLivePlayerSDK.framework */,
565   - 812E50511E7699DC004F5FCD /* KSYGPUResource.bundle */,
566 573 );
567 574 path = CNLiveSDK;
568 575 sourceTree = "<group>";
... ... @@ -1319,6 +1326,24 @@
1319 1326 path = GiftResource;
1320 1327 sourceTree = "<group>";
1321 1328 };
  1329 + D25BF8741E7B8A59007FB138 /* Model */ = {
  1330 + isa = PBXGroup;
  1331 + children = (
  1332 + );
  1333 + path = Model;
  1334 + sourceTree = "<group>";
  1335 + };
  1336 + D25BF8751E7B8A59007FB138 /* View */ = {
  1337 + isa = PBXGroup;
  1338 + children = (
  1339 + D25BF8761E7B8A82007FB138 /* FilterFunctionView.h */,
  1340 + D25BF8771E7B8A82007FB138 /* FilterFunctionView.m */,
  1341 + D25BF8781E7B8A82007FB138 /* SliderView.h */,
  1342 + D25BF8791E7B8A82007FB138 /* SliderView.m */,
  1343 + );
  1344 + path = View;
  1345 + sourceTree = "<group>";
  1346 + };
1322 1347 D2888D911E6EB897003A77C8 /* View */ = {
1323 1348 isa = PBXGroup;
1324 1349 children = (
... ... @@ -1332,8 +1357,8 @@
1332 1357 isa = PBXGroup;
1333 1358 children = (
1334 1359 D2888D991E6EBF1B003A77C8 /* Controller */,
1335   - D2888D9C1E6EBF1B003A77C8 /* Model */,
1336   - D2888D9D1E6EBF1B003A77C8 /* View */,
  1360 + D25BF8741E7B8A59007FB138 /* Model */,
  1361 + D25BF8751E7B8A59007FB138 /* View */,
1337 1362 );
1338 1363 path = LiveSections;
1339 1364 sourceTree = "<group>";
... ... @@ -1347,20 +1372,6 @@
1347 1372 path = Controller;
1348 1373 sourceTree = "<group>";
1349 1374 };
1350   - D2888D9C1E6EBF1B003A77C8 /* Model */ = {
1351   - isa = PBXGroup;
1352   - children = (
1353   - );
1354   - path = Model;
1355   - sourceTree = "<group>";
1356   - };
1357   - D2888D9D1E6EBF1B003A77C8 /* View */ = {
1358   - isa = PBXGroup;
1359   - children = (
1360   - );
1361   - path = View;
1362   - sourceTree = "<group>";
1363   - };
1364 1375 D2888DA71E6EC014003A77C8 /* homeSections */ = {
1365 1376 isa = PBXGroup;
1366 1377 children = (
... ... @@ -1553,6 +1564,8 @@
1553 1564 D2029B911E6EAAA50027CD92 /* animation.xcassets in Resources */,
1554 1565 D2029CB01E6EADE10027CD92 /* MJRefresh.bundle in Resources */,
1555 1566 D2575C7C1E76A4F300E3A8FC /* NHFighterView.nib in Resources */,
  1567 + D25BF87D1E7B8C78007FB138 /* KSYGPUResource.bundle in Resources */,
  1568 + D2029B8F1E6EAAA50027CD92 /* Main.storyboard in Resources */,
1556 1569 812E50541E7699DC004F5FCD /* KSYGPUResource.bundle in Resources */,
1557 1570 );
1558 1571 runOnlyForDeploymentPostprocessing = 0;
... ... @@ -1669,6 +1682,7 @@
1669 1682 D2029D091E6EAE2E0027CD92 /* Foundation+Log.m in Sources */,
1670 1683 D2029C8E1E6EADE10027CD92 /* AFImageDownloader.m in Sources */,
1671 1684 D2029BCA1E6EADD70027CD92 /* BaseModel.m in Sources */,
  1685 + D25BF87B1E7B8A82007FB138 /* SliderView.m in Sources */,
1672 1686 810B65041E779B1F00133E15 /* NSArray+MASAdditions.m in Sources */,
1673 1687 D2029D031E6EAE2E0027CD92 /* UIImage+ZXExtension.m in Sources */,
1674 1688 D2029D0A1E6EAE2E0027CD92 /* ZXServerUrl.m in Sources */,
... ... @@ -1684,6 +1698,7 @@
1684 1698 D2029BCD1E6EADD70027CD92 /* BaseViewController.m in Sources */,
1685 1699 810B64E01E779AE900133E15 /* LVCPlayer.m in Sources */,
1686 1700 810B64FF1E779B1F00133E15 /* MASConstraint.m in Sources */,
  1701 + D25BF87A1E7B8A82007FB138 /* FilterFunctionView.m in Sources */,
1687 1702 D2029D001E6EAE2E0027CD92 /* NSNumber+ScaleHeight.m in Sources */,
1688 1703 D2888D9E1E6EBF1B003A77C8 /* LVCLiveViewController.m in Sources */,
1689 1704 D2029C951E6EADE10027CD92 /* UIWebView+AFNetworking.m in Sources */,
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/LiveSections/Controller/LVCLiveViewController.m
... ... @@ -9,11 +9,12 @@
9 9 #import "LVCLiveViewController.h"
10 10 #import <CNLivePlayerSDK/CNLiveGPUStreamerKit.h>
11 11 #import <CNLivePlayerSDK/CNLiveWebcastManager.h>
  12 +#import "FilterFunctionView.h"
12 13  
13 14 #define KAppId @"60_irn9edco29"
14 15 #define KAppKey @"69fe70bda67e059286ad509d9f5377f815955645b52f94"
15 16  
16   -@interface LVCLiveViewController () {
  17 +@interface LVCLiveViewController ()<UIGestureRecognizerDelegate> {
17 18 // 开始直播
18 19 UIButton *_startLiveBtn;
19 20 // 缩放因子
... ... @@ -24,6 +25,8 @@
24 25  
25 26 @property (nonatomic,strong) CNLiveGPUStreamerKit *kitCN;
26 27  
  28 +@property (nonatomic,strong) FilterFunctionView *filterView;
  29 +
27 30 @end
28 31  
29 32 @implementation LVCLiveViewController
... ... @@ -69,7 +72,9 @@
69 72 // _kitCN.activityName = @"iOS test";
70 73 // _kitCN.coverImgUrl = @"djfiwooa";
71 74  
  75 + // 设置推流配置
72 76 [self setStreamerCfg];
  77 + // 添加监听
73 78 [self addObservers];
74 79  
75 80 _startLiveBtn = [self addButton:@"开始直播" frame:CGRectMake(100, 40, 80, 40) action:@selector(startCapture:)];
... ... @@ -77,7 +82,7 @@
77 82 [_startLiveBtn setTitle:@"停止直播" forState:UIControlStateSelected];
78 83  
79 84 [self addButton:@"关闭预览" frame:CGRectMake(10, 40, 80, 40) action:@selector(startPreview:)];
80   - [self addButton:@"退出" frame:CGRectMake(190, 40, 80, 40) action:@selector(quit)];
  85 +// [self addButton:@"退出" frame:CGRectMake(190, 40, 80, 40) action:@selector(quit)];
81 86 [self addButton:@"美颜" frame:CGRectMake(10, 100, 80, 40) action:@selector(openFilter:)];
82 87 [self addButton:@"摄像头" frame:CGRectMake(100, 100, 80, 40) action:@selector(changeCamera:)];
83 88 [self addButton:@"闪光灯" frame:CGRectMake(190, 100, 80, 40) action:@selector(openFlash)];
... ... @@ -120,16 +125,16 @@
120 125 [_kitCN startPreview:self.captureView];
121 126  
122 127 //水印图片
123   - _kitCN.watermark.logoPic = [UIImage imageNamed:@"互动电视180x180"];
124   - _kitCN.watermark.logoRect = CGRectMake(0.8, 0.8, 50, 50);
125   - _kitCN.watermark.logoAlpha = 0.6;
  128 +// _kitCN.watermark.logoPic = [UIImage imageNamed:@"互动电视180x180"];
  129 +// _kitCN.watermark.logoRect = CGRectMake(0.8, 0.8, 50, 50);
  130 +// _kitCN.watermark.logoAlpha = 0.6;
126 131  
127 132 //水印文字
128   - _kitCN.watermark.textLabel = [[UILabel alloc] init];
129   - _kitCN.watermark.textLabel.text = [NSString stringWithFormat:@"cnlive"];
130   - _kitCN.watermark.textLabel.font = [UIFont systemFontOfSize:8];
131   - _kitCN.watermark.textRect = CGRectMake(0.78, 0.88, 0.2, 0.04);
132   - [_kitCN.watermark updateTextLabel];
  133 +// _kitCN.watermark.textLabel = [[UILabel alloc] init];
  134 +// _kitCN.watermark.textLabel.text = [NSString stringWithFormat:@"cnlive"];
  135 +// _kitCN.watermark.textLabel.font = [UIFont systemFontOfSize:8];
  136 +// _kitCN.watermark.textRect = CGRectMake(0.78, 0.88, 0.2, 0.04);
  137 +// [_kitCN.watermark updateTextLabel];
133 138  
134 139 }
135 140  
... ... @@ -156,11 +161,13 @@
156 161 [_kitCN startStream:^{
157 162 NSLog(@"开启推流成功 ------- success");
158 163 } failure:^(NSDictionary *errorDic) {
  164 + NSString *str=[[NSMutableString alloc] initWithData:errorDic[@"errorMessage"] encoding:NSUTF8StringEncoding];
  165 + NSLog(@"%@",str);
159 166 [self toast:errorDic[@"errorMessage"]];
160 167 _startLiveBtn.selected = NO;
161 168 }];
162 169 }else{
163   -// _stateLab.text = nil;
  170 +
164 171 [_kitCN stopStream];
165 172 }
166 173 }
... ... @@ -184,6 +191,59 @@
184 191 }
185 192 }
186 193  
  194 +// 美颜滤镜
  195 +- (void)openFilter:(UIButton *)button {
  196 +
  197 + button.selected = !button.selected;
  198 +
  199 + if (button.selected) {
  200 +
  201 + _filterView.hidden = NO;
  202 +
  203 + __weak LVCLiveViewController *weakselff = self;
  204 +
  205 + _filterView.filterViewBlock = ^(float grindRatio , float whitenRatio, float intensity){
  206 +
  207 + [weakselff.kitCN.beautifyFaceFilter filterAdjustingParameterWithGrindRatio:grindRatio
  208 + whitenRatio:whitenRatio
  209 + intensity:intensity];
  210 + };
  211 +
  212 + _filterView.currentTypeBlock = ^(NSInteger currentType){
  213 + [weakselff.kitCN.beautifyFaceFilter setBeautyType:currentType];
  214 + };
  215 +
  216 + _filterView.currentIdxBlock = ^(NSInteger currentIdx){
  217 + weakselff.kitCN.beautifyFaceFilter.curEffectIdx = currentIdx;
  218 + };
  219 +
  220 + } else {
  221 +
  222 + _filterView.hidden = YES;
  223 +
  224 + }
  225 +}
  226 +
  227 +// 转换前后置摄像头
  228 +- (void)changeCamera:(UIButton *)button {
  229 +
  230 +// button.selected = !button.selected;
  231 +// if (button.selected) {
  232 +// _kitCN.cameraPosition = AVCaptureDevicePositionBack;
  233 +// }else{
  234 +// _kitCN.cameraPosition = AVCaptureDevicePositionFront;
  235 +// }
  236 + [_kitCN switchCamera];
  237 +
  238 +}
  239 +
  240 +// 闪光灯
  241 +- (void)openFlash {
  242 +
  243 + [_kitCN toggleTorch];
  244 + // [_kitCN setTorchMode:AVCaptureTorchModeOn];
  245 +}
  246 +
187 247 // 退出
188 248 - (void)closeBtnClivk {
189 249  
... ... @@ -200,8 +260,8 @@
200 260  
201 261 #pragma mark - UIGestureRecognizer Action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
202 262 //对焦与曝光
203   -- (void)onTap:(UIGestureRecognizer *)sender
204   -{
  263 +- (void)onTap:(UIGestureRecognizer *)sender {
  264 +
205 265 CGPoint current = [sender locationInView:self.view];
206 266 CGPoint point = [self convertToPointOfInterestFromViewCoordinates:current];
207 267 [_kitCN exposureAtPoint:point];
... ... @@ -209,7 +269,8 @@
209 269 }
210 270  
211 271 //缩放
212   -- (void)pinchDetected:(UIPinchGestureRecognizer *)recognizer{
  272 +- (void)pinchDetected:(UIPinchGestureRecognizer *)recognizer {
  273 +
213 274 if (recognizer.state == UIGestureRecognizerStateBegan) {
214 275 _currentPinchZoomFactor = _kitCN.pinchZoomFactor;
215 276 }
... ... @@ -228,45 +289,39 @@
228 289  
229 290 [_kitCN appBecomeActive];
230 291 }
231   -// 拍摄状态改变
  292 +// 采集状态改变
232 293 - (void)captureStateChange {
233 294  
234 295 if ( _kitCN.captureState == CNLiveCaptureStateIdle){
235 296 //初始化时状态为空闲
236   -// _stateLab.text = @"CNLiveCaptureStateIdle";
237 297  
238 298 return;
239 299 }
240 300 else if (_kitCN.captureState == CNLiveCaptureStateCapturing ) {
241 301 //设备工作中
242   -// _stateLab.text = @"CNLiveCaptureStateCapturing";
243 302  
244 303 return;
245 304 }
246 305 else if (_kitCN.captureState == CNLiveCaptureStateClosingCapture ) {
247 306 //关闭采集设备中
248   -// _stateLab.text = @"CNLiveCaptureStateClosingCapture";
249 307  
250 308 return;
251 309 }
252 310 else if (_kitCN.captureState == CNLiveCaptureStateDevAuthDenied ) {
253 311 //设备授权被拒绝
254 312 NSLog(@"---------CNLiveCaptureStateDevAuthDenied");
255   -// _stateLab.text = @"camera/mic Authorization Denied";
256 313  
257 314 return;
258 315 }
259 316 else if (_kitCN.captureState == CNLiveCaptureStateParameterError ) {
260 317 // 参数错误,无法打开
261 318 NSLog(@"---------CNLiveCaptureStateParameterError");
262   -// _stateLab.text = @"capture devices ParameterError";
263 319  
264 320 return;
265 321 }
266 322 else if (_kitCN.captureState == CNLiveCaptureStateDevBusy ) {
267 323 //设备正忙,请稍后尝试
268 324 NSLog(@"---------CNLiveCaptureStateDevBusy");
269   -// _stateLab.text = @"device busy, try later";
270 325  
271 326 }
272 327 }
... ... @@ -276,19 +331,16 @@
276 331 if (_kitCN.streamState == CNLiveStreamStateIdle) {
277 332  
278 333 NSLog(@"---------CNLiveStreamStateIdle");
279   -// _stateLab.text = @"CNLiveStreamStateIdle";
280 334 }
281 335  
282 336 if (_kitCN.streamState == CNLiveStreamStateConnected) {
283 337  
284 338 NSLog(@"---------CNLiveStreamStateConnected");
285   -// _stateLab.text = [NSString stringWithFormat:@"CNLiveStreamStateConnected------%@",_hostURL];
286 339 }
287 340  
288 341 if (_kitCN.streamState == CNLiveStreamStateConnecting) {
289 342  
290 343 NSLog(@"---------CNLiveStreamStateConnecting");
291   -// _stateLab.text = @"CNLiveStreamStateConnecting";
292 344 }
293 345  
294 346 //推流出错
... ... @@ -302,14 +354,12 @@
302 354 if ( _kitCN.streamState == CNLiveStreamStateDisconnecting) {
303 355  
304 356 NSLog(@"---------CNLiveStreamStateDisconnecting");
305   -// _stateLab.text = @"CNLiveStreamStateDisconnecting";
306 357 }
307 358  
308 359 //结束推流成功
309 360 if ( _kitCN.streamState == CNLiveStopStreamSuccess) {
310 361  
311 362 NSLog(@"---------CNLiveStopStreamSuccess");
312   -// _stateLab.text = @"CNLiveStopStreamSuccess";
313 363 }
314 364 }
315 365 // 推流失败
... ... @@ -320,19 +370,19 @@
320 370 NSLog(@"onErr: %lu ", (unsigned long) err);
321 371  
322 372 if ( CNLiveStreamErrorCode_CNLiveAUTHFAILED == err ) {
323   -// _stateLab.text = @"SDK auth failed, \npls check ak/sk";
  373 +
324 374 }
325 375 else if ( CNLiveStreamErrorCode_CODEC_OPEN_FAILED == err) {
326   -// _stateLab.text = @"Selected Codec not supported \n in this version";
  376 +
327 377 }
328 378 else if ( CNLiveStreamErrorCode_CONNECT_FAILED == err) {
329   -// _stateLab.text = @"Connecting error, pls check host url \nor network";
  379 +
330 380 }
331 381 else if ( CNLiveStreamErrorCode_CONNECT_BREAK == err) {
332   -// _stateLab.text = @"Connection break";
  382 +
333 383 }
334 384 else if ( CNLiveStreamErrorCode_ABNORMAL == err) {
335   -// _stateLab.text = @"CNLiveStreamErrorCode_ABNORMAL";
  385 +
336 386 [self toast:@"推流异常中断~~"];
337 387 _startLiveBtn.selected = NO;
338 388  
... ... @@ -376,8 +426,7 @@
376 426 }
377 427  
378 428 // 提示框
379   -- (void)toast:(NSString*)message
380   -{
  429 +- (void)toast:(NSString*)message {
381 430  
382 431 UIAlertView *toast = [[UIAlertView alloc] initWithTitle:nil
383 432 message:message
... ... @@ -393,8 +442,8 @@
393 442  
394 443  
395 444 // 将UI的坐标转换成相机坐标
396   -- (CGPoint)convertToPointOfInterestFromViewCoordinates:(CGPoint)viewCoordinates
397   -{
  445 +- (CGPoint)convertToPointOfInterestFromViewCoordinates:(CGPoint)viewCoordinates {
  446 +
398 447 CGPoint pointOfInterest = CGPointMake(.5f, .5f);
399 448 CGSize frameSize = self.view.frame.size;
400 449 CGSize apertureSize = [_kitCN captureDimension];
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/LiveSections/View/FilterFunctionView.h 0 → 100755
  1 +//
  2 +// FilterFunctionView.h
  3 +// CNLivePlayerSDKDemo
  4 +//
  5 +// Created by iOS on 16/12/21.
  6 +// Copyright © 2016年 雷浩杰. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +typedef void(^FilterViewBlock)(float grindRatio , float whitenRatio, float intensity);
  12 +
  13 +typedef void(^FilterCurrentType)(NSInteger currentType);
  14 +
  15 +typedef void(^FilterCurrentIdx)(NSInteger currentIdx);
  16 +
  17 +@interface FilterFunctionView : UIView
  18 +
  19 +@property (nonatomic, copy) FilterViewBlock filterViewBlock;
  20 +
  21 +@property (nonatomic, copy) FilterCurrentType currentTypeBlock;
  22 +
  23 +@property (nonatomic, copy) FilterCurrentIdx currentIdxBlock;
  24 +
  25 +@end
  26 +
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/LiveSections/View/FilterFunctionView.m 0 → 100755
  1 +//
  2 +// FilterFunctionView.m
  3 +// CNLivePlayerSDKDemo
  4 +//
  5 +// Created by iOS on 16/12/21.
  6 +// Copyright © 2016年 雷浩杰. All rights reserved.
  7 +//
  8 +
  9 +#import "FilterFunctionView.h"
  10 +#import "SliderView.h"
  11 +
  12 +@interface FilterFunctionView ()<SliderViewDelegate,UIPickerViewDelegate,UIPickerViewDataSource>
  13 +{
  14 + NSArray *_dataArr;
  15 +}
  16 +
  17 +@property (nonatomic, strong) SliderView *slider1;
  18 +@property (nonatomic, strong) SliderView *slider2;
  19 +@property (nonatomic, strong) SliderView *slider3;
  20 +@property (nonatomic, strong) UISegmentedControl * filterGroupType;
  21 +@property (nonatomic, strong) UIPickerView *effectPicker;
  22 +
  23 +@end
  24 +
  25 +@implementation FilterFunctionView
  26 +
  27 +- (instancetype)initWithFrame:(CGRect)frame
  28 +{
  29 + self = [super initWithFrame:frame];
  30 + if (self) {
  31 + [self addSubview:self.slider1];
  32 + [self addSubview:self.slider2];
  33 + [self addSubview:self.slider3];
  34 + [self addSubview:self.effectPicker];
  35 + [self addSubview:self.filterGroupType];
  36 +
  37 + _dataArr = @[@"小清新",@"靓丽",@"甜美可人",@"怀旧",@"蓝调",@"老照片"];
  38 +
  39 + }
  40 + return self;
  41 +}
  42 +
  43 +#pragma mark -
  44 +#pragma mark - SliderViewDelegate
  45 +
  46 +- (void)sliderValueChenged
  47 +{
  48 + if (_filterViewBlock) {
  49 + _filterViewBlock(_slider1.currentValue, _slider2.currentValue, _slider3.currentValue);
  50 + }
  51 +}
  52 +
  53 +- (void)onSegCtrl:(UISegmentedControl *)sender
  54 +{
  55 +
  56 + if (sender.selectedSegmentIndex == 0) {
  57 + _slider1.hidden = YES;
  58 + _slider2.hidden = YES;
  59 + _slider3.hidden = YES;
  60 + _effectPicker.hidden = YES;
  61 +
  62 + } else if (sender.selectedSegmentIndex == 1) {
  63 + _slider1.hidden = NO;
  64 + _slider2.hidden = YES;
  65 + _slider3.hidden = YES;
  66 + _effectPicker.hidden = YES;
  67 + } else if (sender.selectedSegmentIndex == 2) {
  68 + _slider1.hidden = NO;
  69 + _slider2.hidden = NO;
  70 + _slider3.hidden = NO;
  71 + _effectPicker.hidden = YES;
  72 + } else {
  73 + _slider1.hidden = NO;
  74 + _slider2.hidden = NO;
  75 + _slider3.hidden = NO;
  76 + _effectPicker.hidden = NO;
  77 + }
  78 +
  79 + _currentTypeBlock ? _currentTypeBlock(sender.selectedSegmentIndex) : nil;
  80 +
  81 +}
  82 +
  83 +#pragma mark -
  84 +#pragma mark - effectPicker
  85 +- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
  86 +{
  87 + return 1;
  88 +}
  89 +
  90 +- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
  91 +{
  92 + return _dataArr.count;
  93 +}
  94 +
  95 +- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
  96 +{
  97 + return _dataArr[row];
  98 +}
  99 +
  100 +- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
  101 +{
  102 + _currentIdxBlock ? _currentIdxBlock(row) : nil;
  103 +}
  104 +
  105 +#pragma mark -
  106 +#pragma mark - getter
  107 +
  108 +- (SliderView *)slider1
  109 +{
  110 + if (!_slider1) {
  111 + _slider1 = [[SliderView alloc] initWithFrame:CGRectMake(8, 50, self.bounds.size.width-16, 24) title:@"磨皮"];
  112 + _slider1.delagate = self;
  113 + }
  114 + return _slider1;
  115 +}
  116 +
  117 +- (SliderView *)slider2
  118 +{
  119 + if (!_slider2) {
  120 + _slider2 = [[SliderView alloc] initWithFrame:CGRectMake(8, 80, self.bounds.size.width-16, 24) title:@"美白"];
  121 + _slider2.delagate = self;
  122 + }
  123 + return _slider2;
  124 +}
  125 +
  126 +- (SliderView *)slider3
  127 +{
  128 + if (!_slider3) {
  129 + _slider3 = [[SliderView alloc] initWithFrame:CGRectMake(8, 110, self.bounds.size.width-16, 24) title:@"特效"];
  130 + _slider3.delagate = self;
  131 + }
  132 + return _slider3;
  133 +}
  134 +
  135 +- (UIPickerView *)effectPicker
  136 +{
  137 + if (!_effectPicker) {
  138 + _effectPicker = [[UIPickerView alloc] initWithFrame:CGRectMake(8, 130, self.bounds.size.width-16, 100)];
  139 + _effectPicker.showsSelectionIndicator=YES;
  140 + _effectPicker.tintColor = [UIColor whiteColor];
  141 + _effectPicker.dataSource = self;
  142 + _effectPicker.delegate = self;
  143 + _effectPicker.hidden = YES;
  144 + }
  145 + return _effectPicker;
  146 +}
  147 +
  148 +- (UISegmentedControl *)filterGroupType
  149 +{
  150 + if (!_filterGroupType) {
  151 + NSArray *items = @[ @"关",
  152 + @"旧美颜",
  153 + @"红润美颜",
  154 + @"美颜特效",
  155 + ];
  156 +
  157 + _filterGroupType = [[UISegmentedControl alloc] initWithItems:items];
  158 + _filterGroupType.frame = CGRectMake(10, 0, self.bounds.size.width-20, 30);
  159 + _filterGroupType.tintColor= [UIColor blackColor];
  160 + _filterGroupType.selectedSegmentIndex = 0;
  161 + _filterGroupType.layer.cornerRadius = 5;
  162 + _filterGroupType.selectedSegmentIndex = 1;
  163 + [_filterGroupType addTarget:self action:@selector(onSegCtrl:) forControlEvents:UIControlEventValueChanged];
  164 + }
  165 + return _filterGroupType;
  166 +}
  167 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/LiveSections/View/SliderView.h 0 → 100755
  1 +//
  2 +// SliderView.h
  3 +// CNLivePlayerSDKDemo
  4 +//
  5 +// Created by iOS on 16/12/21.
  6 +// Copyright © 2016年 雷浩杰. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +@protocol SliderViewDelegate <NSObject>
  12 +
  13 +- (void)sliderValueChenged;
  14 +
  15 +@end
  16 +
  17 +@interface SliderView : UIView
  18 +
  19 +@property (nonatomic, strong) UILabel* nameL; // 滑块对应参数名称
  20 +@property (nonatomic, strong) UISlider* slider; // 滑块
  21 +@property (nonatomic, strong) UILabel* valueL; // 滑块当前的值
  22 +@property (nonatomic, assign, readonly) float currentValue;
  23 +@property (nonatomic, assign) id<SliderViewDelegate> delagate;
  24 +
  25 +- (instancetype)initWithFrame:(CGRect)frame title:(NSString *)title;
  26 +
  27 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/LiveSections/View/SliderView.m 0 → 100755
  1 +//
  2 +// SliderView.m
  3 +// CNLivePlayerSDKDemo
  4 +//
  5 +// Created by iOS on 16/12/21.
  6 +// Copyright © 2016年 雷浩杰. All rights reserved.
  7 +//
  8 +
  9 +#import "SliderView.h"
  10 +
  11 +@implementation SliderView
  12 +{
  13 + NSString *_title;
  14 +}
  15 +
  16 +- (instancetype)initWithFrame:(CGRect)frame title:(NSString *)title{
  17 + self = [super initWithFrame:frame];
  18 + if (self) {
  19 + _title = title;
  20 + [self addSubview:self.nameL];
  21 + [self addSubview:self.valueL];
  22 + [self addSubview:self.slider];
  23 + }
  24 + return self;
  25 +}
  26 +
  27 +- (float)currentValue
  28 +{
  29 + return _slider.value;
  30 +}
  31 +
  32 +#pragma mark -
  33 +#pragma mark - action
  34 +
  35 +- (void)onSlider:(UISlider *)slider
  36 +{
  37 + _valueL.text = [NSString stringWithFormat:@"%d",(int)(slider.value * 100)];
  38 + if (self.delagate && [self.delagate respondsToSelector:@selector(sliderValueChenged)]) {
  39 + [self.delagate sliderValueChenged];
  40 + }
  41 +}
  42 +
  43 +#pragma mark -
  44 +#pragma mark - getter
  45 +
  46 +- (UILabel *)nameL
  47 +{
  48 + if (!_nameL) {
  49 + _nameL = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 24)];
  50 + _nameL.text = _title;
  51 + _nameL.textAlignment = NSTextAlignmentCenter;
  52 + _nameL.textColor = [UIColor whiteColor];
  53 + _nameL.backgroundColor = [UIColor colorWithRed:192/255.0 green:192/255.0 blue:192/255.0 alpha:1];
  54 + _nameL.layer.cornerRadius = 5;
  55 + _nameL.layer.masksToBounds = YES;
  56 + }
  57 + return _nameL;
  58 +}
  59 +
  60 +- (UILabel *)valueL
  61 +{
  62 + if (!_valueL) {
  63 + _valueL = [[UILabel alloc] initWithFrame:CGRectMake(self.bounds.size.width-40, 0, 40, 24)];
  64 + _valueL.text = @"50";
  65 + _valueL.textAlignment = NSTextAlignmentCenter;
  66 + _valueL.textColor = [UIColor whiteColor];
  67 + _valueL.backgroundColor = [UIColor colorWithRed:192/255.0 green:192/255.0 blue:192/255.0 alpha:1];
  68 + _valueL.layer.cornerRadius = 5;
  69 + _valueL.layer.masksToBounds = YES;
  70 +
  71 + }
  72 + return _valueL;
  73 +}
  74 +
  75 +- (UISlider *)slider
  76 +{
  77 + if (!_slider) {
  78 + _slider = [[UISlider alloc] initWithFrame:CGRectMake(40, 0, self.bounds.size.width-80, 24)];
  79 + _slider.value = 0.5;
  80 + [_slider addTarget:self action:@selector(onSlider:) forControlEvents:UIControlEventValueChanged];
  81 + }
  82 + return _slider;
  83 +}
  84 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Info.plist
... ... @@ -6,6 +6,15 @@
6 6 <false/>
7 7 <key>CFBundleDevelopmentRegion</key>
8 8 <string>en</string>
  9 + <key>NSAppTransportSecurity</key>
  10 + <dict>
  11 + <key>NSAllowsArbitraryLoads</key>
  12 + <true/>
  13 + </dict>
  14 + <key>NSCameraUsageDescription</key>
  15 + <string></string>
  16 + <key>NSMicrophoneUsageDescription</key>
  17 + <string></string>
9 18 <key>CFBundleExecutable</key>
10 19 <string>$(EXECUTABLE_NAME)</string>
11 20 <key>CFBundleIdentifier</key>
... ...