Pārlūkot izejas kodu

1.瑞云SDK调通 逻辑待优化

huangxiaodong 1 gadu atpakaļ
vecāks
revīzija
ecfeb6cbdc

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

@@ -38,6 +38,7 @@
 
 #import "MySetViewController.h"
 #import "PhoneTimeInfoModel.h"
+#import "connectDeviceManager.h"
 
 typedef enum : NSUInteger {
     BITRATE_EXTREME_SPEED = 2,//极速
@@ -132,6 +133,8 @@ UITextFieldDelegate>
 /**是否是收入进入云手机*/
 @property (nonatomic, assign) BOOL          isFirstEnterPhone;
 
+@property (nonatomic, strong)   NSTimer            *checkThridConnectTimer; // 检查瑞云那边连接完成没
+
 @end
 
 @implementation PlayerViewController
@@ -149,9 +152,9 @@ UITextFieldDelegate>
     if (@available(iOS 11.0, *)) {  // 兼容低版本ios
         [self setNeedsUpdateOfHomeIndicatorAutoHidden];
     }
-    
-    [self opencommandChannelManagerrc_openURL];
-    [self openbusinessCommandChannelManagerrc_openURL];
+    canControl = YES;
+    //[self opencommandChannelManagerrc_openURL];
+    //[self openbusinessCommandChannelManagerrc_openURL];
 
     portConnect = [self->internetVideoPort intValue];
     ipConnect   = self->ip;
@@ -186,6 +189,27 @@ UITextFieldDelegate>
     
     mySelf   = self;
     haveBack = NO;
+    
+    _checkThridConnectTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(checkThridRuiYunFun) userInfo:nil repeats:YES];
+    [[NSRunLoop currentRunLoop] addTimer:_checkThridConnectTimer forMode:NSRunLoopCommonModes];
+}
+
+#pragma mark 检测融云链接是否完成
+- (void)checkThridRuiYunFun{
+    
+    HLog(@"瑞云连接状态:%d",[[connectDeviceManager shareInstance] curConnectDeviceState]);
+    
+    if([[connectDeviceManager shareInstance] curConnectDeviceState] == DeviceConnectDeciceOk){
+        ip = @"127.0.0.1";
+        internetVideoPort = [[connectDeviceManager shareInstance] tcpPortStr];
+        [_checkThridConnectTimer invalidate];
+        
+        [self connectVideoServer];
+        [self opencommandChannelManagerrc_openURL];
+        
+        _timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timerChange) userInfo:nil repeats:YES];
+        [[NSRunLoop currentRunLoop] addTimer:_timer forMode:NSRunLoopCommonModes];
+    }
 }
 
 - (void)initData
@@ -305,8 +329,8 @@ UITextFieldDelegate>
             self.liveStreamManager = [[RCLiveSteamManager alloc] init];
             self.liveStreamManager.delegate = self;
             
-            [self opencommandChannelManagerrc_openURL];
-            [self openbusinessCommandChannelManagerrc_openURL];
+            //[self opencommandChannelManagerrc_openURL];
+            //[self openbusinessCommandChannelManagerrc_openURL];
 
             portConnect = [internetVideoPort intValue];
             ipConnect   = ip;
@@ -334,7 +358,7 @@ UITextFieldDelegate>
     KWeakSelf
     //初始化指令通道
     self.commandChannelManager = [[RCCommandChannelManager alloc] init];
-    NSString *instructionsChannelUrl = @"";
+    NSString *instructionsChannelUrl = [NSString stringWithFormat:@"ws://%@:%@/businessChannel",ip,internetVideoPort];
     if (instructionsChannelUrl && instructionsChannelUrl.length > 0) { //当都有值才可连接
         HLog(@"WebSocket11111指令通道连接开始11111 url = %@ ",instructionsChannelUrl);
         [self.commandChannelManager rc_openURL:instructionsChannelUrl connected:^{
@@ -565,6 +589,7 @@ UITextFieldDelegate>
     }
 }
 
+//盒子没有云手机类似的业务处理  暂不需要
 - (void)openbusinessCommandChannelManagerrc_openURL
 {
     KWeakSelf
@@ -1246,9 +1271,11 @@ NSDate *lastVideoTome;/*上一帧数据时间*/
     RCStateInt result = -1;
     
     NSString *tempIP = ip;
+    
+    HLog(@"__连接ip__%@,端口__%@",ip,internetVideoPort);
     result = [self.liveStreamManager rc_openWithIp:ip
                                                          port:internetVideoPort.intValue
-                                                  connectType:RCCloudPhoneConnectType_udp
+                                                  connectType:RCCloudPhoneConnectType_websocket
                                                  videoQuality:RCCloudPhoneVideoQuality_High
                                                        verify:@"123456"
                                                  streamAESKey:nil];
@@ -2141,8 +2168,8 @@ static int  couneeee = 0;
     self.concentTime = [iTools getNowTimeStamp];
     self.currentTime = 0;
     
-    _timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timerChange) userInfo:nil repeats:YES];
-    [[NSRunLoop currentRunLoop] addTimer:_timer forMode:NSRunLoopCommonModes];
+//    _timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timerChange) userInfo:nil repeats:YES];
+//    [[NSRunLoop currentRunLoop] addTimer:_timer forMode:NSRunLoopCommonModes];
 }
 
 - (void)cancelTimer {