Commit e621f237202a08383e3db3c46c23632eecce8dd1
1 parent
c696910a
提交0.1.18代码对齐
Showing
1 changed file
with
105 additions
and
105 deletions
CNLiveUploadManager/Classes/CNLiveUploadManager.m
| ... | ... | @@ -240,9 +240,9 @@ static CNLiveUploadManager *_uploadManager; |
| 240 | 240 | NSString *total = [NSString stringWithFormat:@"1"]; |
| 241 | 241 | NSString *current = [NSString stringWithFormat:@"1"]; |
| 242 | 242 | NSDictionary *dic = @{ |
| 243 | - @"x:total":total, | |
| 244 | - @"x:current":current | |
| 245 | - }.copy; | |
| 243 | + @"x:total":total, | |
| 244 | + @"x:current":current | |
| 245 | + }.copy; | |
| 246 | 246 | |
| 247 | 247 | QNUploadOption *opt = [[QNUploadOption alloc] initWithMime:nil progressHandler:^(NSString *key, float percent) { |
| 248 | 248 | |
| ... | ... | @@ -299,9 +299,9 @@ static CNLiveUploadManager *_uploadManager; |
| 299 | 299 | NSString *total = [NSString stringWithFormat:@"1"]; |
| 300 | 300 | NSString *current = [NSString stringWithFormat:@"1"]; |
| 301 | 301 | NSDictionary *dic = @{ |
| 302 | - @"x:total":total, | |
| 303 | - @"x:current":current | |
| 304 | - }.copy; | |
| 302 | + @"x:total":total, | |
| 303 | + @"x:current":current | |
| 304 | + }.copy; | |
| 305 | 305 | __block CGFloat currentPresent =0;//当前进度 |
| 306 | 306 | QNUploadOption *opt = [[QNUploadOption alloc] initWithMime:nil progressHandler:^(NSString *key, float percent) { |
| 307 | 307 | currentPresent += percent; |
| ... | ... | @@ -352,9 +352,9 @@ static CNLiveUploadManager *_uploadManager; |
| 352 | 352 | NSString *total = [NSString stringWithFormat:@"1"]; |
| 353 | 353 | NSString *current = [NSString stringWithFormat:@"1"]; |
| 354 | 354 | NSDictionary *dic = @{ |
| 355 | - @"x:total":total, | |
| 356 | - @"x:current":current | |
| 357 | - }.copy; | |
| 355 | + @"x:total":total, | |
| 356 | + @"x:current":current | |
| 357 | + }.copy; | |
| 358 | 358 | |
| 359 | 359 | QNUploadOption *opt = [[QNUploadOption alloc] initWithMime:nil progressHandler:^(NSString *key, float percent) { |
| 360 | 360 | |
| ... | ... | @@ -429,9 +429,9 @@ static CNLiveUploadManager *_uploadManager; |
| 429 | 429 | NSString *total = [NSString stringWithFormat:@"%ld",(unsigned long)dataArr.count]; |
| 430 | 430 | NSString *current = [NSString stringWithFormat:@"%ld",index+1]; |
| 431 | 431 | NSDictionary *dic = @{ |
| 432 | - @"x:total":total, | |
| 433 | - @"x:current":current | |
| 434 | - }.copy; | |
| 432 | + @"x:total":total, | |
| 433 | + @"x:current":current | |
| 434 | + }.copy; | |
| 435 | 435 | QNUploadOption *opt = [[QNUploadOption alloc] initWithMime:nil progressHandler:^(NSString *key, float percent) { |
| 436 | 436 | |
| 437 | 437 | } params:dic checkCrc:YES cancellationSignal:nil]; |
| ... | ... | @@ -500,7 +500,7 @@ static CNLiveUploadManager *_uploadManager; |
| 500 | 500 | }]; |
| 501 | 501 | !success ? : success(fileArray); |
| 502 | 502 | }else{ |
| 503 | -// !success ? : success(fileArray); | |
| 503 | + // !success ? : success(fileArray); | |
| 504 | 504 | NSError *error = [NSError errorWithDomain:@"上传出现错误" code:400 userInfo:@{NSLocalizedDescriptionKey:@"上传出现错误,请重新上传失败图片"}]; |
| 505 | 505 | !failure ? : failure(errorArray,error); |
| 506 | 506 | } |
| ... | ... | @@ -797,7 +797,7 @@ static CNLiveUploadManager *_uploadManager; |
| 797 | 797 | !failure ? : failure(nil,error); |
| 798 | 798 | return; |
| 799 | 799 | } |
| 800 | - | |
| 800 | + | |
| 801 | 801 | //回调数组 |
| 802 | 802 | NSMutableArray *fileArray = [NSMutableArray array];//成功数组 CNLiveUploadModel |
| 803 | 803 | NSMutableArray *errorArray = [NSMutableArray array];//失败数组 CNLiveUploadModel |
| ... | ... | @@ -877,7 +877,7 @@ static CNLiveUploadManager *_uploadManager; |
| 877 | 877 | }]; |
| 878 | 878 | !success ? : success(fileArray); |
| 879 | 879 | }else{ |
| 880 | -// !success ? : success(fileArray); | |
| 880 | + // !success ? : success(fileArray); | |
| 881 | 881 | NSError *error = [NSError errorWithDomain:@"上传出现错误" code:400 userInfo:@{NSLocalizedDescriptionKey:@"上传出现错误,请重新上传失败图片"}]; |
| 882 | 882 | !failure ? : failure(errorArray,error); |
| 883 | 883 | } |
| ... | ... | @@ -982,7 +982,7 @@ static CNLiveUploadManager *_uploadManager; |
| 982 | 982 | !failure ? : failure(nil,error); |
| 983 | 983 | return; |
| 984 | 984 | } |
| 985 | - | |
| 985 | + | |
| 986 | 986 | PHVideoRequestOptions* options = [[PHVideoRequestOptions alloc] init]; |
| 987 | 987 | options.version = PHVideoRequestOptionsVersionOriginal; |
| 988 | 988 | options.deliveryMode = PHVideoRequestOptionsDeliveryModeAutomatic; |
| ... | ... | @@ -1013,7 +1013,7 @@ static CNLiveUploadManager *_uploadManager; |
| 1013 | 1013 | return; |
| 1014 | 1014 | }]; |
| 1015 | 1015 | }]; |
| 1016 | - | |
| 1016 | + | |
| 1017 | 1017 | |
| 1018 | 1018 | } |
| 1019 | 1019 | |
| ... | ... | @@ -1651,14 +1651,14 @@ static CNLiveUploadManager *_uploadManager; |
| 1651 | 1651 | |
| 1652 | 1652 | NSInteger code = error.code; |
| 1653 | 1653 | NSString * errorStr = error.localizedDescription; |
| 1654 | - NSError *error; | |
| 1655 | - if (code == - 1001 || code == -1009) { | |
| 1656 | - error = [NSError errorWithDomain:@"网络连接错误,请检查您的网络" code:code userInfo:@{NSLocalizedDescriptionKey:@"网络连接错误,请检查您的网络"}]; | |
| 1657 | - }else { | |
| 1658 | - error = [NSError errorWithDomain:errorStr code:code userInfo:@{NSLocalizedDescriptionKey:errorStr}]; | |
| 1659 | - } | |
| 1660 | - !failure ? : failure(nil,error); | |
| 1661 | - return; | |
| 1654 | + NSError *error; | |
| 1655 | + if (code == - 1001 || code == -1009) { | |
| 1656 | + error = [NSError errorWithDomain:@"网络连接错误,请检查您的网络" code:code userInfo:@{NSLocalizedDescriptionKey:@"网络连接错误,请检查您的网络"}]; | |
| 1657 | + }else { | |
| 1658 | + error = [NSError errorWithDomain:errorStr code:code userInfo:@{NSLocalizedDescriptionKey:errorStr}]; | |
| 1659 | + } | |
| 1660 | + !failure ? : failure(nil,error); | |
| 1661 | + return; | |
| 1662 | 1662 | } |
| 1663 | 1663 | |
| 1664 | 1664 | }]; |
| ... | ... | @@ -1689,14 +1689,14 @@ static CNLiveUploadManager *_uploadManager; |
| 1689 | 1689 | |
| 1690 | 1690 | NSInteger code = error.code; |
| 1691 | 1691 | NSString * errorStr = error.localizedDescription; |
| 1692 | - NSError *error; | |
| 1693 | - if (code == - 1001 || code == -1009) { | |
| 1694 | - error = [NSError errorWithDomain:@"网络连接错误,请检查您的网络" code:code userInfo:@{NSLocalizedDescriptionKey:@"网络连接错误,请检查您的网络"}]; | |
| 1695 | - }else { | |
| 1696 | - error = [NSError errorWithDomain:errorStr code:code userInfo:@{NSLocalizedDescriptionKey:errorStr}]; | |
| 1697 | - } | |
| 1698 | - !failure ? : failure(nil,error); | |
| 1699 | - return; | |
| 1692 | + NSError *error; | |
| 1693 | + if (code == - 1001 || code == -1009) { | |
| 1694 | + error = [NSError errorWithDomain:@"网络连接错误,请检查您的网络" code:code userInfo:@{NSLocalizedDescriptionKey:@"网络连接错误,请检查您的网络"}]; | |
| 1695 | + }else { | |
| 1696 | + error = [NSError errorWithDomain:errorStr code:code userInfo:@{NSLocalizedDescriptionKey:errorStr}]; | |
| 1697 | + } | |
| 1698 | + !failure ? : failure(nil,error); | |
| 1699 | + return; | |
| 1700 | 1700 | } |
| 1701 | 1701 | |
| 1702 | 1702 | }]; |
| ... | ... | @@ -1726,16 +1726,16 @@ static CNLiveUploadManager *_uploadManager; |
| 1726 | 1726 | } else {//请求token失败 |
| 1727 | 1727 | |
| 1728 | 1728 | |
| 1729 | - NSInteger code = error.code; | |
| 1730 | - NSString * errorStr = error.localizedDescription; | |
| 1731 | - NSError *error; | |
| 1732 | - if (code == - 1001 || code == -1009) { | |
| 1733 | - error = [NSError errorWithDomain:@"网络连接错误,请检查您的网络" code:code userInfo:@{NSLocalizedDescriptionKey:@"网络连接错误,请检查您的网络"}]; | |
| 1734 | - }else { | |
| 1735 | - error = [NSError errorWithDomain:errorStr code:code userInfo:@{NSLocalizedDescriptionKey:errorStr}]; | |
| 1736 | - } | |
| 1737 | - !failure ? : failure(nil,error); | |
| 1738 | - return; | |
| 1729 | + NSInteger code = error.code; | |
| 1730 | + NSString * errorStr = error.localizedDescription; | |
| 1731 | + NSError *error; | |
| 1732 | + if (code == - 1001 || code == -1009) { | |
| 1733 | + error = [NSError errorWithDomain:@"网络连接错误,请检查您的网络" code:code userInfo:@{NSLocalizedDescriptionKey:@"网络连接错误,请检查您的网络"}]; | |
| 1734 | + }else { | |
| 1735 | + error = [NSError errorWithDomain:errorStr code:code userInfo:@{NSLocalizedDescriptionKey:errorStr}]; | |
| 1736 | + } | |
| 1737 | + !failure ? : failure(nil,error); | |
| 1738 | + return; | |
| 1739 | 1739 | } |
| 1740 | 1740 | |
| 1741 | 1741 | }]; |
| ... | ... | @@ -1765,14 +1765,14 @@ static CNLiveUploadManager *_uploadManager; |
| 1765 | 1765 | |
| 1766 | 1766 | NSInteger code = error.code; |
| 1767 | 1767 | NSString * errorStr = error.localizedDescription; |
| 1768 | - NSError *error; | |
| 1769 | - if (code == - 1001 || code == -1009) { | |
| 1770 | - error = [NSError errorWithDomain:@"网络连接错误,请检查您的网络" code:code userInfo:@{NSLocalizedDescriptionKey:@"网络连接错误,请检查您的网络"}]; | |
| 1771 | - }else { | |
| 1772 | - error = [NSError errorWithDomain:errorStr code:code userInfo:@{NSLocalizedDescriptionKey:errorStr}]; | |
| 1773 | - } | |
| 1774 | - !failure ? : failure(nil,error); | |
| 1775 | - return; | |
| 1768 | + NSError *error; | |
| 1769 | + if (code == - 1001 || code == -1009) { | |
| 1770 | + error = [NSError errorWithDomain:@"网络连接错误,请检查您的网络" code:code userInfo:@{NSLocalizedDescriptionKey:@"网络连接错误,请检查您的网络"}]; | |
| 1771 | + }else { | |
| 1772 | + error = [NSError errorWithDomain:errorStr code:code userInfo:@{NSLocalizedDescriptionKey:errorStr}]; | |
| 1773 | + } | |
| 1774 | + !failure ? : failure(nil,error); | |
| 1775 | + return; | |
| 1776 | 1776 | } |
| 1777 | 1777 | |
| 1778 | 1778 | }]; |
| ... | ... | @@ -1802,14 +1802,14 @@ static CNLiveUploadManager *_uploadManager; |
| 1802 | 1802 | } else {//请求token失败 |
| 1803 | 1803 | NSInteger code = error.code; |
| 1804 | 1804 | NSString * errorStr = error.localizedDescription; |
| 1805 | - NSError *error; | |
| 1806 | - if (code == - 1001 || code == -1009) { | |
| 1807 | - error = [NSError errorWithDomain:@"网络连接错误,请检查您的网络" code:code userInfo:@{NSLocalizedDescriptionKey:@"网络连接错误,请检查您的网络"}]; | |
| 1808 | - }else { | |
| 1809 | - error = [NSError errorWithDomain:errorStr code:code userInfo:@{NSLocalizedDescriptionKey:errorStr}]; | |
| 1810 | - } | |
| 1811 | - !failure ? : failure(nil,error); | |
| 1812 | - return; | |
| 1805 | + NSError *error; | |
| 1806 | + if (code == - 1001 || code == -1009) { | |
| 1807 | + error = [NSError errorWithDomain:@"网络连接错误,请检查您的网络" code:code userInfo:@{NSLocalizedDescriptionKey:@"网络连接错误,请检查您的网络"}]; | |
| 1808 | + }else { | |
| 1809 | + error = [NSError errorWithDomain:errorStr code:code userInfo:@{NSLocalizedDescriptionKey:errorStr}]; | |
| 1810 | + } | |
| 1811 | + !failure ? : failure(nil,error); | |
| 1812 | + return; | |
| 1813 | 1813 | } |
| 1814 | 1814 | |
| 1815 | 1815 | }]; |
| ... | ... | @@ -1837,14 +1837,14 @@ static CNLiveUploadManager *_uploadManager; |
| 1837 | 1837 | } else {//请求token失败 |
| 1838 | 1838 | NSInteger code = error.code; |
| 1839 | 1839 | NSString * errorStr = error.localizedDescription; |
| 1840 | - NSError *error; | |
| 1841 | - if (code == - 1001 || code == -1009) { | |
| 1842 | - error = [NSError errorWithDomain:@"网络连接错误,请检查您的网络" code:code userInfo:@{NSLocalizedDescriptionKey:@"网络连接错误,请检查您的网络"}]; | |
| 1843 | - }else { | |
| 1844 | - error = [NSError errorWithDomain:errorStr code:code userInfo:@{NSLocalizedDescriptionKey:errorStr}]; | |
| 1845 | - } | |
| 1846 | - !failure ? : failure(nil,error); | |
| 1847 | - return; | |
| 1840 | + NSError *error; | |
| 1841 | + if (code == - 1001 || code == -1009) { | |
| 1842 | + error = [NSError errorWithDomain:@"网络连接错误,请检查您的网络" code:code userInfo:@{NSLocalizedDescriptionKey:@"网络连接错误,请检查您的网络"}]; | |
| 1843 | + }else { | |
| 1844 | + error = [NSError errorWithDomain:errorStr code:code userInfo:@{NSLocalizedDescriptionKey:errorStr}]; | |
| 1845 | + } | |
| 1846 | + !failure ? : failure(nil,error); | |
| 1847 | + return; | |
| 1848 | 1848 | } |
| 1849 | 1849 | |
| 1850 | 1850 | }]; |
| ... | ... | @@ -2246,43 +2246,43 @@ static CNLiveUploadManager *_uploadManager; |
| 2246 | 2246 | shortVideoTranscoder.videoFrameRate = 0; //帧率 |
| 2247 | 2247 | |
| 2248 | 2248 | [PLShortVideoRecorder checkAuthentication:^(PLSAuthenticationResult result) { |
| 2249 | - | |
| 2250 | - if (PLSAuthenticationResultAuthorized == result || PLSAuthenticationResultNotDetermined == result) {//授权 | |
| 2251 | - //成功 | |
| 2252 | - [shortVideoTranscoder setCompletionBlock:^(NSURL *url){ | |
| 2253 | - NSLog(@"输出转码后视频路径%@",url.path); | |
| 2254 | - NSLog(@"输出转码后数据大小%ld",[NSData dataWithContentsOfURL:url].length / (1024*1024)); | |
| 2255 | - dispatch_async(dispatch_get_main_queue(), ^{ | |
| 2256 | - !success ? : success(url); | |
| 2257 | - }); | |
| 2258 | - | |
| 2259 | - }]; | |
| 2260 | - | |
| 2261 | - //失败 | |
| 2262 | - [shortVideoTranscoder setFailureBlock:^(NSError *error){ | |
| 2263 | - NSLog(@"输出错误%@",error); | |
| 2264 | - dispatch_async(dispatch_get_main_queue(), ^{ | |
| 2265 | - !failure ? : failure(); | |
| 2266 | - }); | |
| 2267 | - | |
| 2268 | - }]; | |
| 2269 | - | |
| 2270 | - [shortVideoTranscoder setProcessingBlock:^(float progress){ | |
| 2271 | - // 更新压缩进度的 UI | |
| 2272 | - | |
| 2273 | - NSLog(@"transCoding progress: %f", progress); | |
| 2274 | - !progressCount ? : progressCount(progress); | |
| 2275 | - }]; | |
| 2276 | - | |
| 2277 | - [shortVideoTranscoder startTranscoding]; | |
| 2278 | - }else { | |
| 2279 | - dispatch_async(dispatch_get_main_queue(), ^{ | |
| 2280 | - !failure ? : failure(); | |
| 2281 | - }); | |
| 2282 | - } | |
| 2249 | + | |
| 2250 | + if (PLSAuthenticationResultAuthorized == result || PLSAuthenticationResultNotDetermined == result) {//授权 | |
| 2251 | + //成功 | |
| 2252 | + [shortVideoTranscoder setCompletionBlock:^(NSURL *url){ | |
| 2253 | + NSLog(@"输出转码后视频路径%@",url.path); | |
| 2254 | + NSLog(@"输出转码后数据大小%ld",[NSData dataWithContentsOfURL:url].length / (1024*1024)); | |
| 2255 | + dispatch_async(dispatch_get_main_queue(), ^{ | |
| 2256 | + !success ? : success(url); | |
| 2257 | + }); | |
| 2258 | + | |
| 2259 | + }]; | |
| 2260 | + | |
| 2261 | + //失败 | |
| 2262 | + [shortVideoTranscoder setFailureBlock:^(NSError *error){ | |
| 2263 | + NSLog(@"输出错误%@",error); | |
| 2264 | + dispatch_async(dispatch_get_main_queue(), ^{ | |
| 2265 | + !failure ? : failure(); | |
| 2266 | + }); | |
| 2267 | + | |
| 2268 | + }]; | |
| 2269 | + | |
| 2270 | + [shortVideoTranscoder setProcessingBlock:^(float progress){ | |
| 2271 | + // 更新压缩进度的 UI | |
| 2272 | + | |
| 2273 | + NSLog(@"transCoding progress: %f", progress); | |
| 2274 | + !progressCount ? : progressCount(progress); | |
| 2275 | + }]; | |
| 2276 | + | |
| 2277 | + [shortVideoTranscoder startTranscoding]; | |
| 2278 | + }else { | |
| 2279 | + dispatch_async(dispatch_get_main_queue(), ^{ | |
| 2280 | + !failure ? : failure(); | |
| 2281 | + }); | |
| 2282 | + } | |
| 2283 | 2283 | }]; |
| 2284 | 2284 | |
| 2285 | - | |
| 2285 | + | |
| 2286 | 2286 | |
| 2287 | 2287 | |
| 2288 | 2288 | } |
| ... | ... | @@ -2321,7 +2321,7 @@ static CNLiveUploadManager *_uploadManager; |
| 2321 | 2321 | NSInteger rand = random(); |
| 2322 | 2322 | NSString *filaName = [NSString stringWithFormat:@"/output-%@_fileType=videoType_%zi.mp4",[formater stringFromDate:[NSDate date]],rand]; |
| 2323 | 2323 | editOutputPath = [[CNLiveUploadManager createVideoFolderOutputPath:outputPath] stringByAppendingString:filaName]; |
| 2324 | - | |
| 2324 | + | |
| 2325 | 2325 | NSLog(@"输出转码前视频路径%@",editOutputPath); |
| 2326 | 2326 | shortVideoTranscoder.outputURL = [NSURL fileURLWithPath:editOutputPath]; |
| 2327 | 2327 | shortVideoTranscoder.outputFileType = PLSFileTypeMPEG4; |
| ... | ... | @@ -2337,7 +2337,7 @@ static CNLiveUploadManager *_uploadManager; |
| 2337 | 2337 | [PLShortVideoRecorder checkAuthentication:^(PLSAuthenticationResult result) { |
| 2338 | 2338 | |
| 2339 | 2339 | if (PLSAuthenticationResultAuthorized == result || PLSAuthenticationResultNotDetermined == result) {//授权 |
| 2340 | - | |
| 2340 | + | |
| 2341 | 2341 | //成功 |
| 2342 | 2342 | [shortVideoTranscoder setCompletionBlock:^(NSURL *url){ |
| 2343 | 2343 | NSLog(@"输出转码后视频路径%@",url.path); |
| ... | ... | @@ -2496,7 +2496,7 @@ static CNLiveUploadManager *_uploadManager; |
| 2496 | 2496 | } |
| 2497 | 2497 | |
| 2498 | 2498 | } |
| 2499 | - | |
| 2499 | + | |
| 2500 | 2500 | } |
| 2501 | 2501 | |
| 2502 | 2502 | } | ... | ... |