ソースを参照

1.优化相册扫码
2.文件上传调试中

huangxiaodong 1 年間 前
コミット
d8e691f2d4
共有20 個のファイルを変更した481 個の追加23 個の削除を含む
  1. 24 0
      创维盒子/双子星云手机.xcodeproj/project.pbxproj
  2. 3 0
      创维盒子/双子星云手机/AppDelegate/Config/Notification.h
  3. 19 5
      创维盒子/双子星云手机/Class/Guide/QRCodeScanViewController.m
  4. 21 5
      创维盒子/双子星云手机/Class/Set/ChangeDevice/QRCodeScanForChangeDeviceViewController.m
  5. 4 2
      创维盒子/双子星云手机/Class/Set/uploadFile/PhotoPreviewViewController.m
  6. 2 0
      创维盒子/双子星云手机/Class/Set/uploadFile/model/TZAssetModel+imageData.h
  7. 10 0
      创维盒子/双子星云手机/Class/Set/uploadFile/photoView/photoPreViewBottomView.m
  8. 3 0
      创维盒子/双子星云手机/Class/Set/uploadFile/photoView/uploadFileBottomView.h
  9. 15 2
      创维盒子/双子星云手机/Class/Set/uploadFile/photoView/uploadFileBottomView.m
  10. 19 0
      创维盒子/双子星云手机/Class/Set/uploadFile/uoloadFileRecordViewController.h
  11. 45 0
      创维盒子/双子星云手机/Class/Set/uploadFile/uoloadFileRecordViewController.m
  12. 42 7
      创维盒子/双子星云手机/Class/Set/uploadFile/uploadImageOrVideoViewController.m
  13. 7 0
      创维盒子/双子星云手机/CloudPlayer/PlayerViewController+otherDelegate.h
  14. 215 0
      创维盒子/双子星云手机/CloudPlayer/PlayerViewController+otherDelegate.m
  15. 9 1
      创维盒子/双子星云手机/CloudPlayer/PlayerViewController.h
  16. 8 1
      创维盒子/双子星云手机/CloudPlayer/PlayerViewController.mm
  17. 8 0
      创维盒子/双子星云手机/CloudPlayer/RCCommandHelp.h
  18. 17 0
      创维盒子/双子星云手机/CloudPlayer/RCCommandHelp.m
  19. 3 0
      创维盒子/双子星云手机/Helpers/iTools.h
  20. 7 0
      创维盒子/双子星云手机/Helpers/iTools.m

+ 24 - 0
创维盒子/双子星云手机.xcodeproj/project.pbxproj

@@ -155,6 +155,10 @@
 		6B0582642AFF4B7D00D37290 /* PhotoPreviewViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B0582622AFF4B7D00D37290 /* PhotoPreviewViewController.m */; };
 		6B05826F2AFF692700D37290 /* photoPreViewBottomView.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B05826D2AFF692700D37290 /* photoPreViewBottomView.h */; };
 		6B0582702AFF692700D37290 /* photoPreViewBottomView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B05826E2AFF692700D37290 /* photoPreViewBottomView.m */; };
+		6B0582782AFF7C6D00D37290 /* TZAssetModel+imageData.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B0582762AFF7C6D00D37290 /* TZAssetModel+imageData.h */; };
+		6B0582792AFF7C6D00D37290 /* TZAssetModel+imageData.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B0582772AFF7C6D00D37290 /* TZAssetModel+imageData.m */; };
+		6B0582802B01C67400D37290 /* uoloadFileRecordViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B05827E2B01C67400D37290 /* uoloadFileRecordViewController.h */; };
+		6B0582812B01C67400D37290 /* uoloadFileRecordViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B05827F2B01C67400D37290 /* uoloadFileRecordViewController.m */; };
 		6B3F96342AD2A15A008E349E /* netWorkManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B3F96322AD2A15A008E349E /* netWorkManager.h */; };
 		6B3F96352AD2A15A008E349E /* netWorkManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B3F96332AD2A15A008E349E /* netWorkManager.m */; };
 		6B3F963A2AD2AD0B008E349E /* newWorkInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B3F96392AD2AD0B008E349E /* newWorkInterface.h */; };
@@ -494,6 +498,10 @@
 		6B0582622AFF4B7D00D37290 /* PhotoPreviewViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PhotoPreviewViewController.m; sourceTree = "<group>"; };
 		6B05826D2AFF692700D37290 /* photoPreViewBottomView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = photoPreViewBottomView.h; sourceTree = "<group>"; };
 		6B05826E2AFF692700D37290 /* photoPreViewBottomView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = photoPreViewBottomView.m; sourceTree = "<group>"; };
+		6B0582762AFF7C6D00D37290 /* TZAssetModel+imageData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "TZAssetModel+imageData.h"; sourceTree = "<group>"; };
+		6B0582772AFF7C6D00D37290 /* TZAssetModel+imageData.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "TZAssetModel+imageData.m"; sourceTree = "<group>"; };
+		6B05827E2B01C67400D37290 /* uoloadFileRecordViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = uoloadFileRecordViewController.h; sourceTree = "<group>"; };
+		6B05827F2B01C67400D37290 /* uoloadFileRecordViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = uoloadFileRecordViewController.m; sourceTree = "<group>"; };
 		6B3F96322AD2A15A008E349E /* netWorkManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = netWorkManager.h; sourceTree = "<group>"; };
 		6B3F96332AD2A15A008E349E /* netWorkManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = netWorkManager.m; sourceTree = "<group>"; };
 		6B3F96392AD2AD0B008E349E /* newWorkInterface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = newWorkInterface.h; sourceTree = "<group>"; };
@@ -1102,11 +1110,14 @@
 		6B05815D2AFCD0A900D37290 /* uploadFile */ = {
 			isa = PBXGroup;
 			children = (
+				6B0582712AFF79E100D37290 /* model */,
 				6B0581622AFCDB4300D37290 /* photoView */,
 				6B05815E2AFCD0DF00D37290 /* uploadImageOrVideoViewController.h */,
 				6B05815F2AFCD0DF00D37290 /* uploadImageOrVideoViewController.m */,
 				6B0582612AFF4B7D00D37290 /* PhotoPreviewViewController.h */,
 				6B0582622AFF4B7D00D37290 /* PhotoPreviewViewController.m */,
+				6B05827E2B01C67400D37290 /* uoloadFileRecordViewController.h */,
+				6B05827F2B01C67400D37290 /* uoloadFileRecordViewController.m */,
 			);
 			path = uploadFile;
 			sourceTree = "<group>";
@@ -1130,6 +1141,15 @@
 			path = photoView;
 			sourceTree = "<group>";
 		};
+		6B0582712AFF79E100D37290 /* model */ = {
+			isa = PBXGroup;
+			children = (
+				6B0582762AFF7C6D00D37290 /* TZAssetModel+imageData.h */,
+				6B0582772AFF7C6D00D37290 /* TZAssetModel+imageData.m */,
+			);
+			path = model;
+			sourceTree = "<group>";
+		};
 		6B3F96312AD2A0FA008E349E /* netWork */ = {
 			isa = PBXGroup;
 			children = (
@@ -1566,6 +1586,8 @@
 				6BFF26912AF9D88200FCB4F7 /* AuthCodeTextField.h in Headers */,
 				184C8ADA2A949DAC00F26650 /* HaveNewVersionView.h in Headers */,
 				6BBB35DD2AE76AD800E4A59B /* AudioSessionObject.h in Headers */,
+				6B0582782AFF7C6D00D37290 /* TZAssetModel+imageData.h in Headers */,
+				6B0582802B01C67400D37290 /* uoloadFileRecordViewController.h in Headers */,
 				183AE6D12A8CA98C00B11CB0 /* CloudPhoneAPI.h in Headers */,
 				1868201D2AB97BE1005702A6 /* TipsQRCodeViewController.h in Headers */,
 				181E85002A8F6B1800292B96 /* LogoSelectView.h in Headers */,
@@ -1945,6 +1967,7 @@
 				183AE64E2A8A2CF000B11CB0 /* AFNetworkActivityIndicatorManager.m in Sources */,
 				6B0581B32AFE02B100D37290 /* uploadFileBottomView.m in Sources */,
 				181E85012A8F6B1800292B96 /* LogoSelectView.m in Sources */,
+				6B0582792AFF7C6D00D37290 /* TZAssetModel+imageData.m in Sources */,
 				A031DD6827EC195400909527 /* HWBookmarkViewController.m in Sources */,
 				183AE6572A8A2CF000B11CB0 /* AFURLRequestSerialization.m in Sources */,
 				6B0581AC2AFCF57300D37290 /* AJPhotoGroupCell.m in Sources */,
@@ -2033,6 +2056,7 @@
 				184C8ACD2A94557200F26650 /* HidenMaskSetViewController.m in Sources */,
 				18963B472AB84398006E7C50 /* GuideView.m in Sources */,
 				18FCE5452AD136FF0020F623 /* ShortcutManager.m in Sources */,
+				6B0582812B01C67400D37290 /* uoloadFileRecordViewController.m in Sources */,
 				A003F6A827D841C800715CBF /* BaseModel.m in Sources */,
 				A0295B1627EDA0EC009C5D8B /* HWHistoryModel.m in Sources */,
 				183AE6B42A8CA00300B11CB0 /* PlayerView.m in Sources */,

+ 3 - 0
创维盒子/双子星云手机/AppDelegate/Config/Notification.h

@@ -56,6 +56,9 @@
 /*主动上锁通知*/
 #define lockBypwdNotification                 @"lockBypwdNot"
 
+/* 上传文件通知*/
+#define uploadFileBeginNotification                 @"uploadFileBeginNot"
+
 #define PlayerViewControlBtnTouchBeganNotification        @"PlayerViewControlBtnTouchBeganNotification"        // 云手机推流界面 控制按钮开始点击
 #define PlayerViewControlBtnTouchEndNotification          @"PlayerViewControlBtnTouchEndNotification"        /// // 云手机推流界面 控制按钮结束点击
 ///

+ 19 - 5
创维盒子/双子星云手机/Class/Guide/QRCodeScanViewController.m

@@ -285,6 +285,9 @@ bool isDownType = YES;
         //移除扫描层layer
         [self.layer removeFromSuperlayer];
     }
+    else{
+        [[iToast makeText:NSLocalizedString(@"guide_qrcoede_tips_error",nil)] show];
+    }
 
 }
 
@@ -370,12 +373,23 @@ bool isDownType = YES;
     CIImage*detectImage = [CIImage imageWithData:UIImagePNGRepresentation(pickedImage)];
     //解析扫描二维码结果字符串
     CIDetector *detector = [CIDetector detectorOfType:CIDetectorTypeQRCode context:nil options:@{CIDetectorAccuracy: CIDetectorAccuracyLow}];
-    CIQRCodeFeature*feature = (CIQRCodeFeature*)[detector featuresInImage:detectImage options:nil].firstObject;
+    //CIQRCodeFeature*feature = (CIQRCodeFeature*)[detector featuresInImage:detectImage options:nil].firstObject;
+    NSArray *messageStringArr = (CIQRCodeFeature*)[detector featuresInImage:detectImage options:nil];
+    
+    //排除掉 http的
+    __block NSString *curQRCodeStr = nil;
+    for(CIQRCodeFeature*feature in messageStringArr){
+       
+        if([feature.messageString  rangeOfString:@"http"].location == NSNotFound){
+            curQRCodeStr = feature.messageString;
+            break;
+        }
+    }
     [picker dismissViewControllerAnimated:YES completion:^{
-        if(feature.messageString) {
-            NSLog(@"=================二维码结果为%@",feature.messageString);
-            [self handleScanCodeResultFun:feature.messageString];
-            
+        if(curQRCodeStr) {
+            NSLog(@"=================二维码结果为%@",curQRCodeStr);
+            [self handleScanCodeResultFun:curQRCodeStr];
+
         }else{
             [[iToast makeText:NSLocalizedString(@"guide_qrcoede_tips_error",nil)] show];
             NSLog(@"没有扫描到数据");

+ 21 - 5
创维盒子/双子星云手机/Class/Set/ChangeDevice/QRCodeScanForChangeDeviceViewController.m

@@ -319,6 +319,9 @@ bool isDownType22 = YES;
             }
         }];
     }
+    else{
+        [[iToast makeText:NSLocalizedString(@"guide_qrcoede_tips_error",nil)] show];
+    }
 }
 
 //光感传感器代理
@@ -394,16 +397,29 @@ bool isDownType22 = YES;
     CIImage*detectImage = [CIImage imageWithData:UIImagePNGRepresentation(pickedImage)];
     //解析扫描二维码结果字符串
     CIDetector *detector = [CIDetector detectorOfType:CIDetectorTypeQRCode context:nil options:@{CIDetectorAccuracy: CIDetectorAccuracyLow}];
-    CIQRCodeFeature*feature = (CIQRCodeFeature*)[detector featuresInImage:detectImage options:nil].firstObject;
+    //CIQRCodeFeature*feature = (CIQRCodeFeature*)[detector featuresInImage:detectImage options:nil].firstObject;
+    NSArray *messageStringArr = (CIQRCodeFeature*)[detector featuresInImage:detectImage options:nil];
+    
+    //排除掉 http的
+    __block NSString *curQRCodeStr = nil;
+    for(CIQRCodeFeature*feature in messageStringArr){
+       
+        if([feature.messageString  rangeOfString:@"http"].location == NSNotFound){
+            curQRCodeStr = feature.messageString;
+            break;
+        }
+    }
+    
     [picker dismissViewControllerAnimated:YES completion:^{
-        if(feature.messageString) {
-            NSLog(@"=================二维码结果为%@",feature.messageString);
-            [self handleScanCodeResultFun:feature.messageString];
-            
+        if(curQRCodeStr) {
+            NSLog(@"=================二维码结果为%@",curQRCodeStr);
+            [self handleScanCodeResultFun:curQRCodeStr];
+
         }else{
             [[iToast makeText:NSLocalizedString(@"guide_qrcoede_tips_error",nil)] show];
             NSLog(@"没有扫描到数据");
         }
+        
 //        //停止会话对象扫描
 //        [self.session stopRunning];
 //        //移除扫描层layer

+ 4 - 2
创维盒子/双子星云手机/Class/Set/uploadFile/PhotoPreviewViewController.m

@@ -63,6 +63,8 @@
 - (void)didClickButtonFun:(UIButton*)but
 {
     but.selected = !but.selected;
+    
+    [self handlCellSelectFun];
 }
 
 #pragma mark 处理点击选中相关
@@ -83,7 +85,7 @@
     }
     else{//选中
         [self.indexPathsForSelectedItems addObject:model];
-        model.isSelected = NO;
+        model.isSelected = YES;
     
         if(!model.imageData)
         {
@@ -100,7 +102,7 @@
     
     
     [self setDataToBottomViewFun];
-    [self refreshNaviBarAndBottomBarState];
+    //[self refreshNaviBarAndBottomBarState];
 }
 
 #pragma mark 同步数据到底部

+ 2 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/model/TZAssetModel+imageData.h

@@ -9,6 +9,8 @@
 
 NS_ASSUME_NONNULL_BEGIN
 
+//NSString *filename = [model.asset valueForKey:@"filename"];
+//NSLog(@"filename:%@",filename);
 @interface TZAssetModel (imageData)
 @property (nonatomic, retain) NSData *imageData;
 @end

+ 10 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/photoView/photoPreViewBottomView.m

@@ -148,6 +148,16 @@
     [noteStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [totalStr  length])];
 
     _selectNumLabel.attributedText = noteStr;
+    
+    if(_indexPathsForSelectedItems.count > 0){
+        self.uploadButon.enabled = YES;
+        self.uploadButon.alpha = 1;
+    }
+    else
+    {
+        self.uploadButon.enabled = NO;
+        self.uploadButon.alpha = 0.5;
+    }
 }
 
 

+ 3 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/photoView/uploadFileBottomView.h

@@ -13,6 +13,9 @@ NS_ASSUME_NONNULL_BEGIN
 @interface uploadFileBottomView : UIView
 //选中的项 TZAssetModel
 @property (nonatomic,strong) NSMutableArray *indexPathsForSelectedItems;
+
+//点击上传
+@property (nonatomic,copy) void (^didClickUploadFile)(void);
 @end
 
 NS_ASSUME_NONNULL_END

+ 15 - 2
创维盒子/双子星云手机/Class/Set/uploadFile/photoView/uploadFileBottomView.m

@@ -94,7 +94,7 @@
     }];
     
     imageUploadBut.enabled = NO;
-    //imageUploadBut.alpha = 0.5;
+    imageUploadBut.alpha = 0.5;
 }
 
 
@@ -148,12 +148,25 @@
     [noteStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [totalStr  length])];
 
     _selectNumLabel.attributedText = noteStr;
+    
+    if(_indexPathsForSelectedItems.count > 0){
+        self.uploadButon.enabled = YES;
+        self.uploadButon.alpha = 1;
+    }
+    else
+    {
+        self.uploadButon.enabled = NO;
+        self.uploadButon.alpha = 0.5;
+    }
 }
 
 #pragma mark 按钮点击
 - (void)didClickButFun:(UIButton*)but
 {
-    
+    if(_didClickUploadFile)
+    {
+        _didClickUploadFile();
+    }
 }
 
 @end

+ 19 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/uoloadFileRecordViewController.h

@@ -0,0 +1,19 @@
+//
+//  uoloadFileRecordViewController.h
+//  隐私保护
+//
+//  Created by xd h on 2023/11/13.
+//
+
+#import "BaseViewController.h"
+#import "TZImageManager.h"
+#import "TZAssetModel+imageData.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface uoloadFileRecordViewController : BaseViewController
+
+-(void)gotoUploadFile:(NSMutableArray*)indexPathsForSelectedItems;
+@end
+
+NS_ASSUME_NONNULL_END

+ 45 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/uoloadFileRecordViewController.m

@@ -0,0 +1,45 @@
+//
+//  uoloadFileRecordViewController.m
+//  隐私保护
+//
+//  Created by xd h on 2023/11/13.
+//
+
+#import "uoloadFileRecordViewController.h"
+
+@interface uoloadFileRecordViewController ()
+
+//选中的项 TZAssetModel
+@property (nonatomic, strong) NSMutableArray *indexPathsForSelectedItems;
+@end
+
+@implementation uoloadFileRecordViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    
+    [self.view setBackgroundColor:HWF5F7FAColor];
+    
+    self.titleLabel.text = NSLocalizedString(@"my_set_no_File_upload_record",nil) ;
+    
+    [self.toolBar setHidden:YES];
+    [self.navigationBar setHidden:YES];
+    [self.navBarBGView setHidden:NO];
+    
+    
+}
+
+-(void)gotoUploadFile:(NSMutableArray*)indexPathsForSelectedItems
+{
+    _indexPathsForSelectedItems = indexPathsForSelectedItems;
+    
+    if(indexPathsForSelectedItems.count > 0){
+        TZAssetModel* model = _indexPathsForSelectedItems[0];
+        
+        [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileBeginNotification object:model];
+    }
+
+}
+
+@end

+ 42 - 7
创维盒子/双子星云手机/Class/Set/uploadFile/uploadImageOrVideoViewController.m

@@ -14,6 +14,7 @@
 #import "uploadFileBottomView.h"
 #import "PhotoPreviewViewController.h"
 #import "TZAssetModel+imageData.h"
+#import "uoloadFileRecordViewController.h"
 
 @interface uploadImageOrVideoViewController ()<AJPhotoGroupViewProtocol,UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>
 
@@ -153,6 +154,18 @@
             }
         }];
     }
+    
+    //相册权限
+    if (![[TZImageManager manager] authorizationStatusAuthorized]){
+        [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
+            if(status == PHAuthorizationStatusAuthorized){
+                mainBlock(^{
+                    [self.photoGroupView setupGroup];
+                    [self delayedSetPhotoGroupViewFrameFun];
+                });
+            }
+        }];
+    }
 }
 
 /**
@@ -189,6 +202,11 @@
         make.bottom.mas_equalTo(0);
         make.height.mas_equalTo(60 + safeArea);
     }];
+    
+    KWeakSelf
+    bottomView.didClickUploadFile = ^{
+        [weakSelf gotoUploadFileRecordFun];
+    };
 }
 
 /**
@@ -204,21 +222,27 @@
     
     [self.photoGroupView setupGroup];
     
-    NSInteger maxCount = 6;
-    
-    if(self.photoGroupView.albumGroups.count < maxCount){
-        maxCount = self.photoGroupView.albumGroups.count;
-    }
+    [self delayedSetPhotoGroupViewFrameFun];
+}
+
+#pragma mark 延时设置photoGroupView frame
+- (void)delayedSetPhotoGroupViewFrameFun
+{
     
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-        [photoGroupView mas_makeConstraints:^(MASConstraintMaker *make) {
+        
+        NSInteger maxCount = 6;
+        if(self.photoGroupView.albumGroups.count < maxCount){
+            maxCount = self.photoGroupView.albumGroups.count;
+        }
+        
+        [self.photoGroupView mas_remakeConstraints:^(MASConstraintMaker *make) {
             make.left.mas_equalTo(0);
             make.right.mas_equalTo(0);
             make.height.mas_equalTo(60.0 * maxCount);
             make.top.equalTo(self.navBarBGView.mas_bottom).offset(0.f);
         }];
     });
-    
 }
 
 #pragma mark - 相册切换
@@ -384,6 +408,7 @@
         
         if(!model.imageData)
         {
+            
             [[PHImageManager defaultManager] requestImageDataForAsset:model.asset options:nil resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) {
                     // 直接得到最终的 NSData 数据
                     if (imageData) {
@@ -419,4 +444,14 @@
     }
     return _indexPathsForSelectedItems;
 }
+
+#pragma mark 跳转上传记录
+- (void)gotoUploadFileRecordFun
+{
+    uoloadFileRecordViewController *vc = [uoloadFileRecordViewController new];
+    [self.navigationController pushViewController:vc animated:YES];
+    
+    [vc gotoUploadFile:_indexPathsForSelectedItems];
+}
+
 @end

+ 7 - 0
创维盒子/双子星云手机/CloudPlayer/PlayerViewController+otherDelegate.h

@@ -6,6 +6,8 @@
 //
 
 #import "PlayerViewController.h"
+#import "TZImageManager.h"
+#import "TZAssetModel+imageData.h"
 
 NS_ASSUME_NONNULL_BEGIN
 
@@ -14,6 +16,11 @@ NS_ASSUME_NONNULL_BEGIN
 //ComontAlretViewControllerDelegate
 - (void)CommonAlertokBtnClickPressed;
 - (void)CommonAlertCancelBtnClickPressed;
+
+- (void)beginGotoUploadFileFun:(NSNotification *)notification;
+
+- (void)applyUploadFileServiceResponseFun:(NSDictionary *)dataDict;
+- (void)upLoadFileFun;
 @end
 
 NS_ASSUME_NONNULL_END

+ 215 - 0
创维盒子/双子星云手机/CloudPlayer/PlayerViewController+otherDelegate.m

@@ -6,6 +6,7 @@
 //
 
 #import "PlayerViewController+otherDelegate.h"
+#import "RCCommandHelp.h"
 
 @implementation PlayerViewController (otherDelegate)
 
@@ -22,4 +23,218 @@
     
     exit(0);/*强制退出app*/
 }
+
+
+
+#pragma mark 监听文件开始的的通知
+- (void)beginGotoUploadFileFun:(NSNotification *)notification
+{
+    TZAssetModel *assetModel = [notification object];
+    HLog(@"%@",assetModel);
+    
+    if(!self.taskUid){
+        self.taskUid = [iTools getTaskUidStr];
+        self.fileName = [assetModel.asset valueForKey:@"filename"];
+        self.AllFileData = assetModel.imageData;
+        self.indexOfUploadFlie = 0;
+        
+        HLog(@"%@  %@",self.taskUid,self.fileName);
+        self.cutFileDataArr = [self fileCutPartsBy:self.AllFileData];
+    }
+    
+    NSString * commandStr = [RCCommandHelp applyForUploadFileBy:self.taskUid  filePath:self.fileName];
+    [self.commandChannelManager rc_sendData:commandStr];
+}
+
+- (void)applyUploadFileServiceResponseFun:(NSDictionary *)dataDict
+{
+    if([dataDict isKindOfClass:[NSDictionary class]]){
+        if ([[dataDict allKeys] containsObject:@"data"]) {
+            NSDictionary *data = dataDict[@"data"];
+
+            if ([[data allKeys] containsObject:@"status"]) {
+                NSString  *status = [data objectForKey:@"status"];
+                if(![status isKindOfClass:[NSString class]]){
+                    status = [[NSString  alloc] initWithFormat:@"%@",status];
+                }
+                
+                if ([status isEqualToString:@"1"]) {
+                    mainBlock(^{
+                       // 申请失败;
+                    });
+                }else if ([status isEqualToString:@"0"]){
+                    if ([[data allKeys] containsObject:@"taskUid"]) {
+                        NSString *taskUid = data[@"taskUid"];
+                        if(![status isKindOfClass:[NSString class]]){
+                            taskUid = [[NSString  alloc] initWithFormat:@"%@",taskUid];
+                        }
+                        
+                        if(taskUid &&  [taskUid isEqualToString:self.taskUid]){
+                            //答复的taskUid 跟申请的一致 开发发送内容
+                            [self upLoadFileFun];
+                        }
+                    }
+                    mainBlock(^{
+                        //申请成功;
+                    });
+                }
+            }
+        }
+        else{
+            //异常
+        }
+    }
+    else{
+        //异常
+    }
+}
+
+- (int)getBCC:(NSData*)data
+{
+    int bcc = 0;
+    for (int i = 0; i < [data length]; i++) {
+        Byte buffer;
+        [data getBytes:&buffer range:NSMakeRange(i, 1)];
+        bcc = (UInt8) (bcc ^ buffer);
+        
+        //HLog(@"bcc 222 %d",bcc);
+    }
+    
+    return bcc;
+}
+
+//int getbcc(UInt8 *data, int length) {
+//    int bcc = 0;
+//    for (int i = 0; i < length; i++) {
+//        bcc = (UInt8) (bcc ^ data[i]);
+//    }
+//
+//    return bcc;
+//}
+
+
+#pragma mark 文件切片
+-(NSMutableArray *)fileCutPartsBy:(NSData*)curData{
+ 
+    NSData * data = curData;
+    
+    NSUInteger allLength = data.length;
+    
+    NSUInteger subs = 1*1024;//4096;//要切片的大小,我这里设置的是4096字节
+    
+    NSInteger index = 0;//起始位置
+
+    NSMutableArray *dataArray =[NSMutableArray new];
+    
+    do {
+
+        if (allLength>subs) {
+            
+            NSRange range =NSMakeRange(index*subs, subs);
+            
+            index++;
+            
+            NSLog(@"%@",NSStringFromRange(range));
+            
+            [dataArray addObject:[data subdataWithRange:range]];
+            
+            allLength = allLength - subs;
+
+        }else{
+            
+            NSRange range = NSMakeRange(index*subs, allLength);
+            
+            NSLog(@"%@",NSStringFromRange(range));
+            
+            [dataArray addObject:[data subdataWithRange:range]];
+
+            allLength = 0;
+        }
+
+        
+    } while (allLength>0);
+    
+    NSLog(@"%@",dataArray);//最后得到切片的结果,数组里面是NSData对象
+
+    return dataArray;
+}
+
+#pragma mark 可以发送文件了
+/*
+文件数据字节流byte[]
+  格式1:下载日志文件压缩包
+       |head|msgType|taskId|datalen| curNum | totalNum|   data   |bcc校验|end|
+  长度:  1      1      6      4        2         2      datalen-4   1     1
+       0x68  0x0e                                                        0x16
+    bcc校验从第1位 也就是从msgType起 到 校验位前(不包含校验位)数据作bcc校验
+ */
+- (void)upLoadFileFun
+{
+    
+    //NSMutableArray *sendDataArray =[NSMutableArray new];
+    
+    //head
+    unsigned char headNum = 104;
+    NSData *headData = [NSMutableData dataWithBytes:&headNum length:sizeof(headNum)];
+    HLog(@"headData:%@",headData);
+    
+    //msgType
+    unsigned char msgType = 12;
+    NSData *msgTypeData = [NSMutableData dataWithBytes:&msgType length:sizeof(msgType)];
+    HLog(@"msgTypeData:%@",msgTypeData);
+    
+    //taskId
+    NSData *taskIdData = [self.taskUid dataUsingEncoding:NSUTF8StringEncoding];
+    HLog(@"taskIdData:%@",taskIdData);
+    
+    //datalen
+    int datalenNum = 1024;
+    NSData *datalenData = [NSData dataWithBytes:&datalenNum length:sizeof(datalenNum)];
+    HLog(@"datalenData %@",datalenData);
+    
+    //curNum
+    short curNum = (short)self.indexOfUploadFlie;
+    NSData *curNumData = [NSData dataWithBytes:&curNum length:sizeof(curNum)];
+    HLog(@"curNumData:%@",curNumData);
+    
+    //totalNum
+    short totalNum = (short)self.cutFileDataArr.count;
+    NSData *totalNumData = [NSData dataWithBytes:&totalNum length:sizeof(totalNum)];
+    HLog(@"totalNumData:%@",totalNumData);
+    
+    //data
+    NSData *curData = self.cutFileDataArr[self.indexOfUploadFlie];
+    HLog(@"headData:%@",curData);
+    
+    NSMutableData *checkBCCData = [NSMutableData new];
+    [checkBCCData appendData:msgTypeData];
+    [checkBCCData appendData:taskIdData];
+    [checkBCCData appendData:datalenData];
+    [checkBCCData appendData:curNumData];
+    [checkBCCData appendData:totalNumData];
+    [checkBCCData appendData:curData];
+    
+    int bccCheck = [self getBCC:checkBCCData];
+    HLog(@"bcc 000 %d",bccCheck);
+    
+    //bcc校验
+    unsigned char bccNum = (unsigned char)bccCheck;
+    NSData *bccData = [NSMutableData dataWithBytes:&bccNum length:sizeof(bccNum)];
+    HLog(@"%@",bccData);
+    
+    //end
+    unsigned char endNum = 22;
+    NSData *endData = [NSMutableData dataWithBytes:&endNum length:sizeof(endNum)];
+    HLog(@"%@",endData);
+    
+    NSMutableData *sendData = [NSMutableData new];
+    [sendData appendData:headData];
+    [sendData appendData:checkBCCData];
+    [sendData appendData:bccData];
+    [sendData appendData:endData];
+    
+    [self.commandChannelManager rc_sendData:sendData];
+    HLog(@"文件上传sendData %@",sendData);
+}
+
 @end

+ 9 - 1
创维盒子/双子星云手机/CloudPlayer/PlayerViewController.h

@@ -14,6 +14,7 @@
 #import "PlayerControlButTipView.h"
 #import "Const.h"
 #import "playerShowSecretkeyView.h"
+
 @protocol PlayerViewControllerDelegate <NSObject>
 
 @optional
@@ -90,10 +91,17 @@
 @property (nonatomic, assign)BOOL isLoginAgainType;
 
 
+//上传文件用到
+@property (nonatomic, copy) NSString * _Nullable taskUid;
+@property (nonatomic, copy) NSString * _Nullable fileName;
+@property (nonatomic, strong) NSData * _Nullable AllFileData;
+@property (nonatomic, strong) NSMutableArray * _Nullable cutFileDataArr;
+@property (nonatomic, assign) NSInteger indexOfUploadFlie;
+
 /**
  * @brief 云手机类型  VIP星动云手机  SVIP星曜云手机  STAR 唔即云手机
  */
-@property(copy,nonatomic)NSString *buyVipType;
+//@property(copy,nonatomic)NSString *buyVipType;
 
 //最后一帧回调
 @property (nonatomic, copy) void (^block)(void);   //saveCIImageAction

+ 8 - 1
创维盒子/双子星云手机/CloudPlayer/PlayerViewController.mm

@@ -10,6 +10,7 @@
 #import "PlayerViewController+TouchPointXD.h"
 #import "PlayerViewController+AdjustBtnFrame.h"
 #import "PlayerViewController+AppDelegate.h"
+#import "PlayerViewController+otherDelegate.h"
 
 #import "AFNetworkReachabilityManager.h"
 #import <AVFoundation/AVFoundation.h>
@@ -684,7 +685,10 @@ ComontAlretViewControllerDelegate>
                 [self->hidenTextField becomeFirstResponder];
 //                [self->hidenTextField setText:@"1234"];
                 [self->hidenTextField setEnabled:YES];
+            }else if ([messageType isEqualToString:@"FileReady"]){/*申请文件上传得到答复*/
+                [weakSelf applyUploadFileServiceResponseFun:dataDict];
             }
+            
         } failure:^(NSError *error) {
             
         }];
@@ -888,7 +892,7 @@ ComontAlretViewControllerDelegate>
     [self.view setBackgroundColor:[UIColor whiteColor]];
 
     mPlayerView = [[PlayerView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
-    mPlayerView.buyVipType = self.buyVipType;
+    //mPlayerView.buyVipType = self.buyVipType;
     [mPlayerView initPoMas_makeWithImageRate:YES isUsageMode:NO];
     [mPlayerView setBackgroundColor:[UIColor blackColor]];
     mPlayerView.delegate = self;
@@ -2188,6 +2192,8 @@ BOOL inReconnect = NO;
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setShowImgAndVoiceTypeFun) name:ShowImgAndVoiceNotification object:nil];
     
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setShowPwdVCTypeFun) name:ShowPwdVCNotification object:nil];
+    
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(beginGotoUploadFileFun:) name:uploadFileBeginNotification object:nil];
 }
 
 - (void)removeNSNotification
@@ -2200,6 +2206,7 @@ BOOL inReconnect = NO;
     [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillResignActiveNotification object:nil];
     [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil];
 
+    [[NSNotificationCenter defaultCenter] removeObserver:self name:uploadFileBeginNotification     object:nil];
     
     if (outputVolumeKVO)
     {

+ 8 - 0
创维盒子/双子星云手机/CloudPlayer/RCCommandHelp.h

@@ -187,6 +187,14 @@ NS_ASSUME_NONNULL_BEGIN
  * @param appurl app下载链接 appid  app标识符
  */
 + (NSString *)downLoadAppWithAppUrl:(NSString*)appurl appId:(NSString *)appid;
+
+/**
+ * @brief 申请上传文件 请求
+ *
+ * @param taskUid
+ * @param filePath 传file name
+ */
++ (NSString *)applyForUploadFileBy:(NSString*)taskUid filePath:(NSString *)filePath;
 @end
 
 NS_ASSUME_NONNULL_END

+ 17 - 0
创维盒子/双子星云手机/CloudPlayer/RCCommandHelp.m

@@ -978,4 +978,21 @@
     
     return dataStr;
 }
+
++ (NSString *)applyForUploadFileBy:(NSString*)taskUid filePath:(NSString *)filePath
+{
+    NSString *dataStr =[NSString stringWithFormat:@"{\"data\":{\"taskUid\":\"%@\",\"filePath\":\"%@\"},\"type\":\"uploadFile\"}",taskUid,filePath];
+    
+    if (USENEWCONTROLLCOMMONDNO500)
+    {
+//        dataStr = [self commondAppendingHeadAndEndStrWithSourStr:dataStr];
+    }
+    else
+    {
+        dataStr = [self commandAppending00StringWithSourStr:dataStr];
+    }
+    
+    return dataStr;
+}
+
 @end

+ 3 - 0
创维盒子/双子星云手机/Helpers/iTools.h

@@ -145,6 +145,9 @@ NS_ASSUME_NONNULL_BEGIN
 + (NSString *)getInternetDateString;
 
 + (UIWindow *)getKeyWindow;
+
+//ypp add 推流业务随机生成6位数的字符串
++ (NSString *)getTaskUidStr;
 @end
 
 NS_ASSUME_NONNULL_END

+ 7 - 0
创维盒子/双子星云手机/Helpers/iTools.m

@@ -950,4 +950,11 @@ static const char encodingTable[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopq
     return img;
 }
 
+
+//ypp add 推流业务随机生成6位数的字符串
++ (NSString *)getTaskUidStr {
+    int randomNumber = (int) arc4random_uniform(999999) + 100000;
+    NSString *strRandom = [NSString stringWithFormat:@"%d",randomNumber];
+    return strRandom;
+}
 @end