huangxiaodong дней назад: 5
Родитель
Сommit
9590115e11

+ 3 - 0
创维盒子/code/AppDelegate/Config/Notification.h

@@ -163,4 +163,7 @@
 /* 信令通道链接变化*/
 #define webRtcLinkStateChangeNotification                 @"webRtcLinkStateChangeNot"
 
+/*预链接通知 */
+#define preLinkCloudPhoneNotification                 @"preLinkCloudPhoneNot"
+
 #endif /* Notification_h */

+ 4 - 2
创维盒子/code/AppDelegate/SceneDelegate.m

@@ -402,6 +402,8 @@
             
             [[webRtcManager shareManager] beginToLinkWebRtcFun];
             [[webRtcPingManager shareManager] startPingFun];
+            
+            //[[NSNotificationCenter defaultCenter] postNotificationName:preLinkCloudPhoneNotification object:nil];
         }
         else
         {
@@ -591,7 +593,7 @@
         //非隐私模式 直接进入推拉流页
         if(ksharedAppDelegate.DeviceThirdIdMod && !ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode){
             ksharedAppDelegate.isCloudPhoneModeNotPrivacyModeOpenType = YES;
-            [cloudVC queryWebRtcMsgFun:YES];
+            [cloudVC queryWebRtcMsgFun:YES withPreLinkType:NO];
         }
         else{
             ksharedAppDelegate.isCloudPhoneModeAndPrivacyModeOpenType = YES;
@@ -721,7 +723,7 @@
                     webRtcPlayerViewController* vc = (webRtcPlayerViewController*)curVC;
                     if(vc.isLan){
                         ksharedAppDelegate.needToPushWebRtcVCType = YES;
-                        [vc exitCloudPhoneFun];
+                        [vc exitCloudPhoneFun:YES];
                     }
                 }
                 else if([curVC isKindOfClass:[imageDetailsScrollViewController class]]

+ 4 - 0
创维盒子/code/CloudPlayer/View/PasteSelectView.m

@@ -66,6 +66,10 @@
     NSString* curSn = ksharedAppDelegate.DeviceThirdIdMod.data.changeSn;
     pasteDataAry = [HWDataManager getObjectWithKey:curSn];
     
+    if([pasteDataAry isKindOfClass:[NSMutableArray class]] && [pasteDataAry isKindOfClass:[NSArray class]]){
+        pasteDataAry = [[NSMutableArray alloc] initWithArray:pasteDataAry];
+    }
+    
     if (str){
         if (pasteDataAry){
             if (![pasteDataAry containsObject:str]){

+ 1 - 1
创维盒子/code/cloudPhone/cloudPhoneViewController.h

@@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
 @interface cloudPhoneViewController : BaseViewController
 
 #pragma mark 获取webrct 的链接信息
--(void)queryWebRtcMsgFun:(BOOL)isPlayerType;
+-(void)queryWebRtcMsgFun:(BOOL)isPlayerType withPreLinkType:(BOOL)isPreLinkType;
 @end
 
 NS_ASSUME_NONNULL_END

+ 48 - 13
创维盒子/code/cloudPhone/cloudPhoneViewController.m

@@ -20,6 +20,8 @@
 @interface cloudPhoneViewController ()
 @property (nonatomic,strong) cloudPhoneSetView *cloudPhoneSetV;
 @property (nonatomic,strong) webRtcMsgModel *webRtcMsgMod;
+
+@property (nonatomic,strong) webRtcPlayerViewController *preLinkWebRtcPlayerVC;//做预连接处理
 @end
 
 @implementation cloudPhoneViewController
@@ -31,6 +33,8 @@
     //输入密码完成
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didInpuPwdOkFun) name:didInputPWDNotification object:nil];
     
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(preLinkCloudPhoneFun) name:preLinkCloudPhoneNotification object:nil];
+    
     [self.view setBackgroundColor:HWF5F7FAColor];
     
     [self.toolBar setHidden:YES];
@@ -39,6 +43,7 @@
     
     [self drawAnyView];
     
+    [self queryWebRtcMsgFun:YES withPreLinkType:YES];
 }
 
 - (void)drawAnyView{
@@ -255,7 +260,7 @@
 //                [[iToast makeText:NSLocalizedString(@"tv_p2p_ing",nil)] show];
 //            }
             
-            [self queryWebRtcMsgFun:YES];
+            [self queryWebRtcMsgFun:YES withPreLinkType:NO];
             
             //数据埋点
             [[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"Cloud_enter"];
@@ -533,16 +538,18 @@
 
 
 #pragma mark 获取webrct 的链接信息
--(void)queryWebRtcMsgFun:(BOOL)isPlayerType
+-(void)queryWebRtcMsgFun:(BOOL)isPlayerType withPreLinkType:(BOOL)isPreLinkType
 {
     if(isPlayerType){
         
         if(ksharedAppDelegate.DeviceWebRtcMsgMod && ksharedAppDelegate.DeviceWebRtcMsgMod.data.sn){
-            [self gotoWebRtcVcBy:ksharedAppDelegate.DeviceWebRtcMsgMod];
+            [self gotoWebRtcVcBy:ksharedAppDelegate.DeviceWebRtcMsgMod withPreLinkType:isPreLinkType];
             return;
         }
         
-        [self showNewIndicatorWithCanBack:YES canTouch:NO];
+        if (!isPreLinkType) {
+            [self showNewIndicatorWithCanBack:YES canTouch:NO];
+        }
     }
     
     NSMutableDictionary *paraDict = [NSMutableDictionary new];
@@ -551,7 +558,9 @@
     [[netWorkManager shareInstance] CommonPostCallBackCode:webrctQueryByClient Parameters:paraDict success:^(id  _Nonnull responseObject){
         
         if(isPlayerType){
-            [weakSelf removeNewIndicator];
+            if (!isPreLinkType){
+                [weakSelf removeNewIndicator];
+            }
         }
         
         webRtcMsgModel *curModel = [[webRtcMsgModel alloc] initWithDictionary:responseObject error:nil];
@@ -559,7 +568,7 @@
         if(curModel && curModel.status == 0){
             ksharedAppDelegate.DeviceWebRtcMsgMod = curModel;
             if(isPlayerType){
-                [weakSelf gotoWebRtcVcBy:curModel];
+                [weakSelf gotoWebRtcVcBy:curModel withPreLinkType:isPreLinkType];
             }
         }
         else
@@ -571,14 +580,16 @@
         
     } failure:^(NSError * _Nonnull error) {
         if(isPlayerType){
-            [weakSelf removeNewIndicator];
-            [[iToast makeText:NSLocalizedString(@"get_webrtcMsg_fail_tip",nil)] show];
+            if (!isPreLinkType){
+                [weakSelf removeNewIndicator];
+                [[iToast makeText:NSLocalizedString(@"get_webrtcMsg_fail_tip",nil)] show];
+            }
         }
     }];
 }
 
 #pragma mark 跳转webrtc 页面
--  (void)gotoWebRtcVcBy:(webRtcMsgModel*)webRtcMsgMod
+-  (void)gotoWebRtcVcBy:(webRtcMsgModel*)webRtcMsgMod withPreLinkType:(BOOL)isPreLinkType
 {
     
     NSArray * vcArrs = self.navigationController.viewControllers;
@@ -587,9 +598,15 @@
     }
     [cachesFileManager writeLogsWithMsg:@"webRtcPlayer push webRtcPlayerVC"];
     
-    webRtcPlayerViewController *vc = [webRtcPlayerViewController new];
-    vc.webRtcMsgMod = webRtcMsgMod;
-    [self.navigationController pushViewController:vc animated:YES];
+    if(!_preLinkWebRtcPlayerVC){
+        _preLinkWebRtcPlayerVC = [webRtcPlayerViewController new];
+        _preLinkWebRtcPlayerVC.webRtcMsgMod = webRtcMsgMod;
+    }
+    
+    if (!isPreLinkType) {
+        [_preLinkWebRtcPlayerVC setPrelinkPlay];
+        [self.navigationController pushViewController:_preLinkWebRtcPlayerVC animated:YES];
+    }
     
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
         ksharedAppDelegate.isCloudPhoneModeNotPrivacyModeOpenType = NO;
@@ -605,7 +622,7 @@
     mainBlock(^{
         if(ksharedAppDelegate.isCloudPhoneModeAndPrivacyModeOpenType
            || ksharedAppDelegate.needToPushWebRtcVCType){
-            [weakSelf queryWebRtcMsgFun:YES];
+            [weakSelf queryWebRtcMsgFun:YES withPreLinkType:NO];
         }
     });
 }
@@ -616,4 +633,22 @@
     NasPreviewAPPViewController *vc = [NasPreviewAPPViewController new];
     [self.navigationController pushViewController:vc animated:YES];
 }
+
+
+#pragma mark 开始预链接
+- (void)preLinkCloudPhoneFun
+{
+    if(_preLinkWebRtcPlayerVC){
+        [_preLinkWebRtcPlayerVC exitCloudPhoneFun:NO];
+        _preLinkWebRtcPlayerVC = nil;
+    }
+    
+    
+    [self queryWebRtcMsgFun:YES withPreLinkType:YES];
+    
+//    if(ksharedAppDelegate.DeviceWebRtcMsgMod){
+//        _preLinkWebRtcPlayerVC = [webRtcPlayerViewController new];
+//        _preLinkWebRtcPlayerVC.webRtcMsgMod = ksharedAppDelegate.DeviceWebRtcMsgMod;
+//    }
+}
 @end

+ 55 - 9
创维盒子/code/webRtc/WebRTC.framework/Headers/AMediaStream.h

@@ -13,6 +13,7 @@
 #import <WebRTC/RTCDataChannel.h>
 #import <WebRTC/RTCStatisticsReport.h>
 #import <WebRTC/RTCVideoRenderer.h>
+#import "WebRTCPlayerView.h"
 
 RTC_OBJC_EXPORT
 @protocol RTC_OBJC_TYPE(MediaStreamClientEventsDelegate) <NSObject>
@@ -38,10 +39,36 @@ RTC_OBJC_EXPORT
             remoteCandidate:(RTC_OBJC_TYPE(RTCIceCandidate) *)remote
              lastReceivedMs:(int)lastDataReceivedMs
                changeReason:(NSString *)reason;
+@optional
+- (void)virtualMicrophoneCameraOccupiedNotify:(BOOL)microphone camera:(BOOL)camera userData:(NSString *)userData;
+
+@optional
+- (void)customMsgNotify:(NSString *)pusher userData:(NSString *)userData;
+
+@optional
+- (void)virtualMicrophoneStatusNotify:(BOOL)microphoneStatus;
+
+@optional
+- (void)virtualCameraStatusNotify:(BOOL)cameraStatus;
+
 @end
 
+
 RTC_OBJC_EXPORT
-@interface RTC_OBJC_TYPE(AMediaStream) : UIView
+@protocol RTC_OBJC_TYPE(MediaStreamClientEventsDelegateEx) <NSObject>
+
+- (void)dataChannelDidChangeFromPeerNameEx:(NSString*)peerName State:(RTCDataChannelState)state;
+
+-(void)onChangeConnectionStateFromPeerNameEx:(NSString*)peerName didChangeIceConnectionState:(RTCIceConnectionState)state;
+//code 0 成功 1失败
+-(void)onAuthResultFromPeerNameEx:(NSString*)peerName code:(int)code descriptions:(NSString*)descriptions;
+
+@end
+
+
+
+RTC_OBJC_EXPORT
+@interface RTC_OBJC_TYPE(AMediaStream) : NSObject
 
 +(void)globalInitialization;
 
@@ -58,14 +85,15 @@ RTC_OBJC_EXPORT
 //filePathName = /sdcard/webrtc_box.log    captureTime = 30s
 -(void)setCardLogToFile:(NSString*)filePathName captureTime:(NSString*)captureTime;
 
-//NSDictionary *iceMessage=@{
-//    @"CHINANET":@"电信",
-//    @"CMNET":@"移动",
-//    @"UNICOM":@"联通"
-//};
+//start 之前调用是否启用预连接
+-(void)setPrelinkEnable:(BOOL)enable;
+
+//start 之前调用设置中转服务器内网ip
+-(void) setIceInternalIp:(NSString*)internalIp;
 
+//ice ip:port
 -(int)start:(NSURL *)url
-        ice:(NSDictionary*)ice
+        ice:(NSString*)ice
          sn:(NSString*)sn
      direct:(NSInteger)direct
         fmt:(NSInteger)fmt
@@ -79,7 +107,7 @@ cardDensity:(NSInteger)cardDensity
       token:(NSString*)token;
 
 - (int)startUploadChannel:(NSURL *)url
-                      ice:(NSDictionary*)ice
+                      ice:(NSString*)ice
                        sn:(NSString*)sn
                     token:(NSString*)token;
 
@@ -116,9 +144,27 @@ cardDensity:(NSInteger)cardDensity
 - (void)enterBackground;
 - (void)enterForeground;
 
+- (BOOL)setPrelinkPlay;
+
+- (void)startFileRotatingStream:(NSString *)dir_path
+                  max_file_size:(NSInteger)max_file_size;
+
+- (void)stopFileRotatingStream;
+
+//订阅使用相机麦克风。拉流成功,datachannel 连接成功后才能调用
+- (BOOL)subscribeVirtualMicrophoneCamera:(BOOL)microphone camera:(BOOL)camera userData:(NSString *)userData;
+
+//发送自定义消息。拉流成功,datachannel 连接成功后才能调用
+- (BOOL)pushCustomMessages:(NSString *)pusher userData:(NSString *)userData;
+
+//设置自动码率调整区间。拉流成功,datachannel 连接成功后才能调用
+- (BOOL)setAutoBitrateRange:(int)minBitrateKbps maxBitrateKbps:(int)maxBitrateKbps;
+
 @property (nonatomic, weak) id <MediaStreamClientEventsDelegate> eventDelegate;
-@property(nonatomic,readonly) NSString *name;
+@property (nonatomic, weak) id <MediaStreamClientEventsDelegateEx> eventDelegateEx;
+@property(nonatomic, copy, readonly) NSString *name;
 @property(nonatomic, assign) BOOL shouldGetStats;
+@property (nonatomic, strong)WebRTCPlayerView *webRTCPlayerView;
 
 @end
 

+ 2 - 0
创维盒子/code/webRtc/WebRTC.framework/Headers/RTCCameraVideoCapturer.h

@@ -51,6 +51,8 @@ NS_EXTENSION_UNAVAILABLE_IOS("Camera not available in app extensions.")
 // Stops the capture session asynchronously.
 - (void)stopCapture;
 
+- (void)setCameraAec:(int)val1 val2:(int)val2 val3:(float)val3 val4:(int)val4;
+
 @end
 
 NS_ASSUME_NONNULL_END

+ 1 - 0
创维盒子/code/webRtc/WebRTC.framework/Headers/RTCMediaConstraints.h

@@ -25,6 +25,7 @@ RTC_EXTERN NSString *const kRTCMediaConstraintsIceRestart;
 RTC_EXTERN NSString *const kRTCMediaConstraintsOfferToReceiveAudio;
 RTC_EXTERN NSString *const kRTCMediaConstraintsOfferToReceiveVideo;
 RTC_EXTERN NSString *const kRTCMediaConstraintsVoiceActivityDetection;
+RTC_EXTERN NSString *const kRTCMediaConstraintsInitAudioRecordingOnSend;
 
 /** Constraint values for Boolean parameters. */
 RTC_EXTERN NSString *const kRTCMediaConstraintsValueTrue;

+ 2 - 0
创维盒子/code/webRtc/WebRTC.framework/Headers/RTCPeerConnection.h

@@ -340,6 +340,8 @@ RTC_OBJC_EXPORT
 - (BOOL)startRtcEventLogWithFilePath:(NSString *)filePath maxSizeInBytes:(int64_t)maxSizeInBytes;
 - (void)stopRtcEventLog;
 
+- (void)setAudioPlayout:(BOOL)playout;
+
 @end
 
 @interface RTC_OBJC_TYPE (RTCPeerConnection)

+ 1 - 0
创维盒子/code/webRtc/WebRTC.framework/Headers/WebRTC.h

@@ -97,4 +97,5 @@
 #import <WebRTC/RTCCallbackLogger.h>
 #import <WebRTC/RTCFileLogger.h>
 #import <WebRTC/AMediaStream.h>
+#import <WebRTC/WebRTCPlayerView.h>
 #import <WebRTC/ANatsSignalChannel.h>

+ 28 - 0
创维盒子/code/webRtc/WebRTC.framework/Headers/WebRTCPlayerView.h

@@ -0,0 +1,28 @@
+//
+//  WebRTCPlayerView.h
+//  sources
+//
+//  Created by huangchunquan on 2025/3/20.
+//
+
+#import <UIKit/UIKit.h>
+#import <WebRTC/RTCMTLVideoView.h>
+
+NS_ASSUME_NONNULL_BEGIN
+RTC_OBJC_EXPORT
+@protocol WebRTCPlayerViewDelegate <NSObject>
+
+- (void)WebRTCPlayerViewTouchBack:(NSData*) touchesdata;
+
+@end
+
+RTC_OBJC_EXPORT
+@interface WebRTCPlayerView : UIView
+
+@property(nonatomic,readonly) __kindof UIView<RTC_OBJC_TYPE(RTCVideoRenderer)> *remoteVideoView;
+@property(nonatomic,assign) UIViewContentMode videoContentMode;
+@property(nonatomic,weak) id<WebRTCPlayerViewDelegate> delegate;
+
+@end
+
+NS_ASSUME_NONNULL_END

BIN
创维盒子/code/webRtc/WebRTC.framework/Info.plist


BIN
创维盒子/code/webRtc/WebRTC.framework/WebRTC


+ 22 - 11
创维盒子/code/webRtc/WebRTC.framework/_CodeSignature/CodeResources

@@ -6,7 +6,7 @@
 	<dict>
 		<key>Headers/AMediaStream.h</key>
 		<data>
-		otaFvzfy8p6LbYx2yhs1dQzO/+c=
+		RM/sGGmA5PeRUsvq8HDkGb3vvXo=
 		</data>
 		<key>Headers/ANatsSignalChannel.h</key>
 		<data>
@@ -46,7 +46,7 @@
 		</data>
 		<key>Headers/RTCCameraVideoCapturer.h</key>
 		<data>
-		Bc6mx7aLqet1cfj0HowjC29+XOo=
+		M+tdqKKQVYU12eR+mspLqWG0OtM=
 		</data>
 		<key>Headers/RTCCertificate.h</key>
 		<data>
@@ -150,7 +150,7 @@
 		</data>
 		<key>Headers/RTCMediaConstraints.h</key>
 		<data>
-		kfBoTi0vANwQFN+aMvFR0muT5XI=
+		XeUjvtsioQyqEUlW2JDE6QBwY4I=
 		</data>
 		<key>Headers/RTCMediaSource.h</key>
 		<data>
@@ -194,7 +194,7 @@
 		</data>
 		<key>Headers/RTCPeerConnection.h</key>
 		<data>
-		rQmuHbV/DeA/nvZFlh7j5Sot+mc=
+		eqw1GXB746YFr+Mv++nyjGupQuk=
 		</data>
 		<key>Headers/RTCPeerConnectionFactory.h</key>
 		<data>
@@ -366,11 +366,15 @@
 		</data>
 		<key>Headers/WebRTC.h</key>
 		<data>
-		mS/wPCok/B3ne8ZoGIdPmEuWwcQ=
+		AcaRzT+8PR7EBNnh2fnlvmEu1NQ=
+		</data>
+		<key>Headers/WebRTCPlayerView.h</key>
+		<data>
+		FgygSN3BKavq0ff96/7IlINHKMk=
 		</data>
 		<key>Info.plist</key>
 		<data>
-		aBNNXqtrjyRRY7CfhcREMxY/Cv0=
+		VY8H1tj3iCZwJ3nIMFGZk2fF0sQ=
 		</data>
 		<key>Modules/module.modulemap</key>
 		<data>
@@ -387,7 +391,7 @@
 		<dict>
 			<key>hash2</key>
 			<data>
-			eMAh5vOyUVug0G5qjGOEXD0WWvo50X3yXa41KhJl3T4=
+			8swKsAxIq8nbqviLmCCiMvPrKNeztBUiwRXaniySk9w=
 			</data>
 		</dict>
 		<key>Headers/ANatsSignalChannel.h</key>
@@ -457,7 +461,7 @@
 		<dict>
 			<key>hash2</key>
 			<data>
-			AIvwiFq8F/79/eQTURYS/Qr3zAa9JYQOiV8g6e6DsaI=
+			dtsqfl3zQySpFT9aH2lbxTpvWlURDYIpzevVU8U6ta8=
 			</data>
 		</dict>
 		<key>Headers/RTCCertificate.h</key>
@@ -639,7 +643,7 @@
 		<dict>
 			<key>hash2</key>
 			<data>
-			o9o06MYWmKa/rlPHUsA+qJ8ZwIoLOelp3Mxu+uJHu3Q=
+			SR7pNQ3lepqekGl6etgualqmsHs7WMlo0rEcpX79hvY=
 			</data>
 		</dict>
 		<key>Headers/RTCMediaSource.h</key>
@@ -716,7 +720,7 @@
 		<dict>
 			<key>hash2</key>
 			<data>
-			hOfDz517eo4L25aMasLl5l40XBr3rS4WPmoV2iFdNXU=
+			mObxhSeQDKkQKwA9xzl++8lo6Yy5vzlVfJWu0Vh748s=
 			</data>
 		</dict>
 		<key>Headers/RTCPeerConnectionFactory.h</key>
@@ -1017,7 +1021,14 @@
 		<dict>
 			<key>hash2</key>
 			<data>
-			CJ38D+h0rvIP7EeXTDSUn+6bWykSQP4Lh2chAlf3vi8=
+			De+AnvTGzyxY9wNslA1alO0j194xytbJttPCBBWRPwc=
+			</data>
+		</dict>
+		<key>Headers/WebRTCPlayerView.h</key>
+		<dict>
+			<key>hash2</key>
+			<data>
+			iPu43DQ7IMQL28qMOvdd51xb4cn7DaocsG3aRXzpxVY=
 			</data>
 		</dict>
 		<key>Modules/module.modulemap</key>

+ 15 - 8
创维盒子/code/webRtc/webRtcManager/webRtcManager.m

@@ -47,7 +47,9 @@
         
         _webRtcChannelSessionId = [iTools getNowTimeStampString];
         
-        _mediaStream = [[RTC_OBJC_TYPE(AMediaStream) alloc] initWithFrame:CGRectZero];
+        //_mediaStream = [[RTC_OBJC_TYPE(AMediaStream) alloc] initWithFrame:CGRectZero];
+        _mediaStream =[[AMediaStream alloc] init];
+        
         [_mediaStream setEventDelegate:self];
         
         linkCheckSecondTimer = [NSTimer scheduledTimerWithTimeInterval:10.0 target:self selector:@selector(timerChange) userInfo:nil repeats:YES];
@@ -131,12 +133,12 @@
     //ice用
     NSString *iceUrl = [[NSString alloc] initWithFormat:@"%@:%@",webrtcServerMod.turnIp,webrtcServerMod.turnPort];
     
-    NSMutableDictionary *ice = [NSMutableDictionary new];
-    if(iceUrl){
-        [ice setValue:iceUrl forKey:@"CHINANET"];
-        [ice setValue:iceUrl forKey:@"CMNET"];
-        [ice setValue:iceUrl forKey:@"UNICOM"];
-    }
+//    NSMutableDictionary *ice = [NSMutableDictionary new];
+//    if(iceUrl){
+//        [ice setValue:iceUrl forKey:@"CHINANET"];
+//        [ice setValue:iceUrl forKey:@"CMNET"];
+//        [ice setValue:iceUrl forKey:@"UNICOM"];
+//    }
     
     NSString *roomName = _webRtcMsgMod.data.uniqueIdentifier;
     
@@ -150,7 +152,7 @@
     HLog(@"webrtc :%@ --- channl start:%@",ksharedAppDelegate.WebRtcLogger,url)
     
     //vclusters  信令不鉴权  写不写都OK 
-    NSInteger result = [_mediaStream startUploadChannel:url ice:ice sn:roomName token:@"vclusters"];
+    NSInteger result = [_mediaStream startUploadChannel:url ice:iceUrl sn:roomName token:@"vclusters"];
     
     HLog(@"webrtc 发起连接 result:%ld",result)
     [_mediaStream setShouldGetStats:YES];
@@ -493,6 +495,11 @@
     NSString* curSn = ksharedAppDelegate.DeviceThirdIdMod.data.changeSn;
     NSMutableArray *pasteDataAry  = [HWDataManager getObjectWithKey:curSn];
     
+    if(pasteDataAry && [pasteDataAry isKindOfClass:[NSMutableArray class]] /*&& [pasteDataAry isKindOfClass:[NSArray class]]*/)
+    {
+        pasteDataAry = [[NSMutableArray alloc] initWithArray:pasteDataAry];
+    }
+    
     if (str){/*当前剪切板中有内容*/
         if (pasteDataAry){
             if (![pasteDataAry containsObject:str]){

+ 2 - 2
创维盒子/code/webRtc/webRtcPlayerViewController+AdjustBtnFrame.m

@@ -35,7 +35,7 @@
     CGPoint centerPoint = self.controlBtn.center;
 //    HLog(@"云手机推流界面 控制按钮中点%@",NSStringFromCGPoint(centerPoint));
     
-    if (self.mediaStream.hw_w > self.mediaStream.hw_h){//横屏
+    if (self.mediaStream.webRTCPlayerView.hw_w > self.mediaStream.webRTCPlayerView.hw_h){//横屏
        
         CGFloat screen_W = SCREEN_W>SCREEN_H?SCREEN_W:SCREEN_H;/*实际较大的数字*/
         CGFloat screen_H = (SCREEN_W<SCREEN_H?SCREEN_W:SCREEN_H);/*实际较小的数字*/
@@ -129,7 +129,7 @@
         }
         case UIGestureRecognizerStateChanged:{
             self.adjustTime = 2;
-            CGPoint translatedPoint = [panGesture translationInView:self.mediaStream];/*KXLY*/
+            CGPoint translatedPoint = [panGesture translationInView:self.mediaStream.webRTCPlayerView];/*KXLY*/
             CGRect frame = self.controlBtn.frame;
             frame.origin.x = translatedPoint.x + startFrame.origin.x;
             frame.origin.y = translatedPoint.y + startFrame.origin.y;

+ 8 - 8
创维盒子/code/webRtc/webRtcPlayerViewController+AdjustPlayerViewFrame.m

@@ -22,7 +22,7 @@
         scr_H = SCREEN_W;
     }
     
-    [self.mediaStream mas_remakeConstraints:^(MASConstraintMaker *make) {
+    [self.mediaStream.webRTCPlayerView mas_remakeConstraints:^(MASConstraintMaker *make) {
         
         if(fullScreenShow){//全屏
             make.left.mas_equalTo(0.f);
@@ -65,16 +65,16 @@
         make.left.mas_equalTo(0.f);
         if(fullScreenShow){
             if(scr_H == 667){// iphone 6 7 8
-                make.top.equalTo(self.mediaStream.mas_bottom).offset(20);
+                make.top.equalTo(self.mediaStream.webRTCPlayerView.mas_bottom).offset(20);
             }
             else{
                 //make.bottom.mas_equalTo(0);
-                make.top.equalTo(self.mediaStream.mas_bottom);
+                make.top.equalTo(self.mediaStream.webRTCPlayerView.mas_bottom);
             }
             
         }
         else{
-            make.top.equalTo(self.mediaStream.mas_bottom);
+            make.top.equalTo(self.mediaStream.webRTCPlayerView.mas_bottom);
         }
     }];
 
@@ -105,7 +105,7 @@
         scr_H = SCREEN_W;
     }
     
-    [self.mediaStream mas_remakeConstraints:^(MASConstraintMaker *make) {
+    [self.mediaStream.webRTCPlayerView mas_remakeConstraints:^(MASConstraintMaker *make) {
      
         
         if(fullScreenShow){//全屏
@@ -165,16 +165,16 @@
         make.width.mas_equalTo(h_forPhoneBottomView);
         if(fullScreenShow){
             if(scr_W == 667){// iphone 6 7 8
-                make.left.equalTo(self.mediaStream.mas_right).offset(20);
+                make.left.equalTo(self.mediaStream.webRTCPlayerView.mas_right).offset(20);
             }
             else{
                 //make.right.mas_equalTo(0);
-                make.left.equalTo(self.mediaStream.mas_right);
+                make.left.equalTo(self.mediaStream.webRTCPlayerView.mas_right);
             }
             
         }
         else{
-            make.left.equalTo(self.mediaStream.mas_right);
+            make.left.equalTo(self.mediaStream.webRTCPlayerView.mas_right);
         }
         make.top.mas_equalTo(0);
         make.bottom.mas_equalTo(0);

+ 4 - 1
创维盒子/code/webRtc/webRtcPlayerViewController.h

@@ -42,7 +42,10 @@ NS_ASSUME_NONNULL_BEGIN
 - (void)relinkWebRtcFunByBecomeActive;
 
 #pragma mark 退出云机
-- (void)exitCloudPhoneFun;
+- (void)exitCloudPhoneFun:(BOOL)needPreLink;
+
+#pragma mark 预连接开始拉流
+- (void)setPrelinkPlay;
 @end
 
 NS_ASSUME_NONNULL_END

+ 39 - 24
创维盒子/code/webRtc/webRtcPlayerViewController.m

@@ -37,6 +37,7 @@
      * @brief 粘贴列表视图
      */
     PasteSelectView *pasteSelectView;
+    BOOL didPrelinkPlay;/*是否标志过预链接拉流*/
 }
 @property (nonatomic, copy)   NSTimer      *playerSecondTimer; // 定时器-控制按钮
 @property (nonatomic, assign) RTCIceConnectionState linkState;
@@ -141,21 +142,18 @@
 #pragma mark 开始拉流
 - (void)beginWebRtcPlayFun
 {
-    if(_mediaStream){
-        //[_mediaStream disconnect];
-        //[_mediaStream removeFromSuperview];
-        //_mediaStream = nil;
-    }
-    
     //2.客户端开始写日志
     [ksharedAppDelegate.WebRtcLogger start];
     
-    _mediaStream = [[RTC_OBJC_TYPE(AMediaStream) alloc] initWithFrame:CGRectZero];
+    //_mediaStream = [[RTC_OBJC_TYPE(AMediaStream) alloc] initWithFrame:CGRectZero];
+    _mediaStream = [[AMediaStream alloc] init];
+    _mediaStream.webRTCPlayerView = [[RTC_OBJC_TYPE(WebRTCPlayerView) alloc] initWithFrame:CGRectZero];
+    
     [_mediaStream setEventDelegate:self];
-    [self.view addSubview:_mediaStream];
-    HLog(@"_mediaStream:%@",_mediaStream)
+    [self.view addSubview:_mediaStream.webRTCPlayerView];
+    HLog(@"_mediaStream:%@",_mediaStream.webRTCPlayerView)
     
-    [_mediaStream mas_makeConstraints:^(MASConstraintMaker *make) {
+    [_mediaStream.webRTCPlayerView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.left.mas_equalTo(0.f);
         make.bottom.mas_equalTo(0.f);
         make.right.mas_equalTo(0.f);
@@ -209,12 +207,12 @@
     //ice用
     NSString *iceUrl = [[NSString alloc] initWithFormat:@"%@:%@",webrtcServerMod.turnIp,webrtcServerMod.turnPort];
     
-    NSMutableDictionary *ice = [NSMutableDictionary new];
-    if(iceUrl){
-        [ice setValue:iceUrl forKey:@"CHINANET"];
-        [ice setValue:iceUrl forKey:@"CMNET"];
-        [ice setValue:iceUrl forKey:@"UNICOM"];
-    }
+//    NSMutableDictionary *ice = [NSMutableDictionary new];
+//    if(iceUrl){
+//        [ice setValue:iceUrl forKey:@"CHINANET"];
+//        [ice setValue:iceUrl forKey:@"CMNET"];
+//        [ice setValue:iceUrl forKey:@"UNICOM"];
+//    }
    
     NSString *roomName = _webRtcMsgMod.data.uniqueIdentifier;
     
@@ -253,8 +251,16 @@
         curToken = @"mediakit";
     }
     
+    if(!didPrelinkPlay){
+        [_mediaStream setPrelinkEnable:YES];/*设置是否采用预链接*/
+    }
+    else{
+        [_mediaStream setPrelinkEnable:NO];/*设置是否采用预链接*/
+    }
+    
+    
     NSInteger result = [_mediaStream start:url
-                            ice:ice
+                            ice:iceUrl
                              sn:roomName
                          direct:0
                             fmt:1//1(h264) 5(h265)
@@ -270,7 +276,6 @@
     HLog(@"result:%ld",result)
     
     [_mediaStream setShouldGetStats:YES];
-    
     //清晰度码率最大上限 流畅1800 标清2200 高清2800  跟上面的 bitrate是同一个意思
     //[_mediaStream setMaxBitrate:@2800];
 }
@@ -387,8 +392,8 @@
 {
     CGFloat h_w_controlBtn = 60.f;
     /*区分横竖屏*/
-    if (_mediaStream.hw_w > _mediaStream.hw_h){
-        [controlBtn setFrame:CGRectMake((_mediaStream.hw_w - h_w_controlBtn)/2.f, _mediaStream.hw_h - h_w_controlBtn - 20.f, h_w_controlBtn, h_w_controlBtn)];
+    if (_mediaStream.webRTCPlayerView.hw_w > _mediaStream.webRTCPlayerView.hw_h){
+        [controlBtn setFrame:CGRectMake((_mediaStream.webRTCPlayerView.hw_w - h_w_controlBtn)/2.f, _mediaStream.webRTCPlayerView.hw_h - h_w_controlBtn - 20.f, h_w_controlBtn, h_w_controlBtn)];
     }else{
         //默认居右
         //[mPlayerView.controlBtn setFrame:CGRectMake(mPlayerView.width - h_w_controlBtn - 20.f, (SCREEN_H - h_w_controlBtn)/2.f, h_w_controlBtn, h_w_controlBtn)];
@@ -466,7 +471,7 @@
             [weakSelf relinkWebRtcFun];
         }
         else if(tag == 5){
-            [weakSelf exitCloudPhoneFun];
+            [weakSelf exitCloudPhoneFun:YES];
         }
     }];
 }
@@ -531,7 +536,7 @@
                 break;
             case 100:
                 {//退出云机
-                    [weakSelf exitCloudPhoneFun];
+                    [weakSelf exitCloudPhoneFun:YES];
                 }
                 break;
             case 201:
@@ -693,7 +698,7 @@
 
 
 #pragma mark 退出云机
-- (void)exitCloudPhoneFun
+- (void)exitCloudPhoneFun:(BOOL)needPreLink
 {
     [cachesFileManager writeLogsWithMsg:@"webRtcPlayer click exitCloudPhone"];
     //[self setShowImgAndVoiceTypeFun:NO];
@@ -712,6 +717,10 @@
             [[DFPlayer sharedPlayer] df_play];
         });
     }
+    
+    if (needPreLink) {
+        [[NSNotificationCenter defaultCenter] postNotificationName:preLinkCloudPhoneNotification object:nil];
+    }
 }
 
 #pragma mark 显示关闭投屏提示语
@@ -1605,5 +1614,11 @@
     });
 }
 
-
+#pragma mark 预连接开始拉流
+- (void)setPrelinkPlay
+{
+    [_mediaStream setPrelinkPlay];/*预链接状态直接开始推拉流渲染*/
+    
+    didPrelinkPlay = YES;
+}
 @end