Commit dcb08329ec475526cfe235e749cf4e3c94df7e4c

Authored by 梁星国
1 parent efd54936

提交0.0.14

CNLiveUploadManager.podspec
@@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
8 8
9 Pod::Spec.new do |s| 9 Pod::Spec.new do |s|
10 s.name = 'CNLiveUploadManager' 10 s.name = 'CNLiveUploadManager'
11 - s.version = '0.1.13' 11 + s.version = '0.1.14'
12 s.summary = '压缩上传,组件化中加入新参数加入outPath,不在直接取' 12 s.summary = '压缩上传,组件化中加入新参数加入outPath,不在直接取'
13 13
14 # This description is used to generate tags and improve search results. 14 # This description is used to generate tags and improve search results.
CNLiveUploadManager/Classes/CNLiveUploadManager.m
@@ -2202,33 +2202,45 @@ static CNLiveUploadManager *_uploadManager; @@ -2202,33 +2202,45 @@ static CNLiveUploadManager *_uploadManager;
2202 shortVideoTranscoder.rotateOrientation = PLSPreviewOrientationPortrait; //视频显示 2202 shortVideoTranscoder.rotateOrientation = PLSPreviewOrientationPortrait; //视频显示
2203 shortVideoTranscoder.videoSelectedRect = CGRectZero; //视频剪裁区域 2203 shortVideoTranscoder.videoSelectedRect = CGRectZero; //视频剪裁区域
2204 shortVideoTranscoder.videoFrameRate = 0; //帧率 2204 shortVideoTranscoder.videoFrameRate = 0; //帧率
2205 - //成功  
2206 - [shortVideoTranscoder setCompletionBlock:^(NSURL *url){  
2207 - NSLog(@"输出转码后视频路径%@",url.path);  
2208 - NSLog(@"输出转码后数据大小%ld",[NSData dataWithContentsOfURL:url].length / (1024*1024));  
2209 - dispatch_async(dispatch_get_main_queue(), ^{  
2210 - !success ? : success(url);  
2211 - });  
2212 -  
2213 - }];  
2214 2205
2215 - //失败  
2216 - [shortVideoTranscoder setFailureBlock:^(NSError *error){  
2217 - NSLog(@"输出错误%@",error);  
2218 - dispatch_async(dispatch_get_main_queue(), ^{  
2219 - !failure ? : failure();  
2220 - });  
2221 - 2206 + [PLShortVideoRecorder checkAuthentication:^(PLSAuthenticationResult result) {
  2207 +
  2208 + if (PLSAuthenticationResultAuthorized == result) {//授权
  2209 + //成功
  2210 + [shortVideoTranscoder setCompletionBlock:^(NSURL *url){
  2211 + NSLog(@"输出转码后视频路径%@",url.path);
  2212 + NSLog(@"输出转码后数据大小%ld",[NSData dataWithContentsOfURL:url].length / (1024*1024));
  2213 + dispatch_async(dispatch_get_main_queue(), ^{
  2214 + !success ? : success(url);
  2215 + });
  2216 +
  2217 + }];
  2218 +
  2219 + //失败
  2220 + [shortVideoTranscoder setFailureBlock:^(NSError *error){
  2221 + NSLog(@"输出错误%@",error);
  2222 + dispatch_async(dispatch_get_main_queue(), ^{
  2223 + !failure ? : failure();
  2224 + });
  2225 +
  2226 + }];
  2227 +
  2228 + [shortVideoTranscoder setProcessingBlock:^(float progress){
  2229 + // 更新压缩进度的 UI
  2230 +
  2231 + NSLog(@"transCoding progress: %f", progress);
  2232 + !progressCount ? : progressCount(progress);
  2233 + }];
  2234 +
  2235 + [shortVideoTranscoder startTranscoding];
  2236 + }else {
  2237 + dispatch_async(dispatch_get_main_queue(), ^{
  2238 + !failure ? : failure();
  2239 + });
  2240 + }
2222 }]; 2241 }];
2223 2242
2224 - [shortVideoTranscoder setProcessingBlock:^(float progress){  
2225 - // 更新压缩进度的 UI  
2226 -  
2227 - NSLog(@"transCoding progress: %f", progress);  
2228 - !progressCount ? : progressCount(progress);  
2229 - }];  
2230 -  
2231 - [shortVideoTranscoder startTranscoding]; 2243 +
2232 2244
2233 2245
2234 } 2246 }
@@ -2278,33 +2290,47 @@ static CNLiveUploadManager *_uploadManager; @@ -2278,33 +2290,47 @@ static CNLiveUploadManager *_uploadManager;
2278 shortVideoTranscoder.videoSelectedRect = CGRectZero; //视频剪裁区域 2290 shortVideoTranscoder.videoSelectedRect = CGRectZero; //视频剪裁区域
2279 shortVideoTranscoder.videoFrameRate = 0; //帧率 2291 shortVideoTranscoder.videoFrameRate = 0; //帧率
2280 2292
2281 - dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);  
2282 - //成功  
2283 - [shortVideoTranscoder setCompletionBlock:^(NSURL *url){  
2284 - NSLog(@"输出转码后视频路径%@",url.path);  
2285 - NSLog(@"输出转码后数据大小%ld",[NSData dataWithContentsOfURL:url].length / (1024*1024));  
2286 - !success ? : success(url);  
2287 - dispatch_semaphore_signal(semaphore);  
2288 -  
2289 - }];  
2290 2293
2291 - //失败  
2292 - [shortVideoTranscoder setFailureBlock:^(NSError *error){  
2293 - NSLog(@"输出错误%@",error);  
2294 - !failure ? : failure();  
2295 - dispatch_semaphore_signal(semaphore);  
2296 -  
2297 - }];  
2298 2294
2299 - [shortVideoTranscoder setProcessingBlock:^(float progress){  
2300 - // 更新压缩进度的 UI 2295 + [PLShortVideoRecorder checkAuthentication:^(PLSAuthenticationResult result) {
  2296 +
  2297 + if (PLSAuthenticationResultAuthorized == result) {//授权
  2298 +
  2299 + dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
  2300 + //成功
  2301 + [shortVideoTranscoder setCompletionBlock:^(NSURL *url){
  2302 + NSLog(@"输出转码后视频路径%@",url.path);
  2303 + NSLog(@"输出转码后数据大小%ld",[NSData dataWithContentsOfURL:url].length / (1024*1024));
  2304 + !success ? : success(url);
  2305 + dispatch_semaphore_signal(semaphore);
  2306 +
  2307 + }];
  2308 +
  2309 + //失败
  2310 + [shortVideoTranscoder setFailureBlock:^(NSError *error){
  2311 + NSLog(@"输出错误%@",error);
  2312 + !failure ? : failure();
  2313 + dispatch_semaphore_signal(semaphore);
  2314 +
  2315 + }];
  2316 +
  2317 + [shortVideoTranscoder setProcessingBlock:^(float progress){
  2318 + // 更新压缩进度的 UI
  2319 +
  2320 + NSLog(@"transCoding progress: %f", progress);
  2321 + !progressCount ? : progressCount(progress);
  2322 + }];
  2323 +
  2324 + [shortVideoTranscoder startTranscoding];
  2325 + dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
  2326 + }else{//未授权
  2327 +
  2328 + !failure ? : failure();
  2329 + }
  2330 +
2301 2331
2302 - NSLog(@"transCoding progress: %f", progress);  
2303 - !progressCount ? : progressCount(progress);  
2304 }]; 2332 }];
2305 2333
2306 - [shortVideoTranscoder startTranscoding];  
2307 - dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);  
2308 2334
2309 2335
2310 } 2336 }