|
|
@@ -8,7 +8,7 @@
|
|
|
#import "webRtcPlayerViewController.h"
|
|
|
#import "webRtcPlayerViewController+AdjustBtnFrame.h"
|
|
|
#import "webRtcPlayerViewController+AdjustPlayerViewFrame.h"
|
|
|
-
|
|
|
+#import "webRtcPlayerViewController+AppDelegate.h"
|
|
|
|
|
|
#import "UIInterface+HXRotation.h"
|
|
|
#import "playerSetView.h"
|
|
|
@@ -341,8 +341,7 @@
|
|
|
|
|
|
[self startForceStartTimerFun];
|
|
|
|
|
|
- //最后一帧 没显示正在重启问题
|
|
|
- //_canShowImgAndVoiceType = YES;
|
|
|
+ [self pauseStream];
|
|
|
|
|
|
[webRtcManager shareManager].isRebootIngType = YES;
|
|
|
}
|
|
|
@@ -468,6 +467,88 @@
|
|
|
[[webRtcManager shareManager] offTvFun];
|
|
|
}
|
|
|
|
|
|
+#pragma mark 挤下线功能
|
|
|
+-(void)offlineOtherPhoneFun
|
|
|
+{
|
|
|
+ NSString *curOaidStr = [RcGameWQKeyChain getOaidStringFun];
|
|
|
+ if(!curOaidStr){
|
|
|
+ curOaidStr = @"";
|
|
|
+ }
|
|
|
+ NSString *commondStr = [[NSString alloc] initWithFormat:@"{\"type\":\"login\",\"value\":\"%@\"}",curOaidStr];
|
|
|
+ [self send_dataInPlayer:commondStr];
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark 单点登录被挤下线弹框
|
|
|
+- (void)LogoutByOtherFun:(NSString*)oaid
|
|
|
+{
|
|
|
+
|
|
|
+ if(logoutAlertVC){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ NSString *curOaidStr = [RcGameWQKeyChain getOaidStringFun];
|
|
|
+
|
|
|
+ if(oaid
|
|
|
+ && oaid.length >0
|
|
|
+ && [oaid isEqualToString:curOaidStr]){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ //[self didReceiveLogoutMsgFun];
|
|
|
+
|
|
|
+
|
|
|
+ //yyyy-MM-dd HH:mm:ss
|
|
|
+ NSString*dateStr = [iTools getNowTimeString2];
|
|
|
+ if(dateStr && dateStr.length == 19){
|
|
|
+ dateStr = [dateStr substringWithRange:NSMakeRange(11, 5)];
|
|
|
+ }
|
|
|
+
|
|
|
+ NSString *LogoutTimerStr = [[NSString alloc] initWithFormat:@"%@%@%@",NSLocalizedString(@"single_sign_on_Tips_one",nil),dateStr,NSLocalizedString(@"single_sign_on_Tips_two",nil)];
|
|
|
+
|
|
|
+
|
|
|
+ NSString * loginAgainStr = NSLocalizedString(@"single_sign_on_login_again",nil);
|
|
|
+ BOOL isOkBtnHighlight = YES;
|
|
|
+ if(!ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode){
|
|
|
+ loginAgainStr = @"";
|
|
|
+ isOkBtnHighlight = NO;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ KWeakSelf
|
|
|
+
|
|
|
+ if(ksharedAppDelegate.isDidShowPwdType){
|
|
|
+
|
|
|
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+ [weakSelf LogoutByOtherFun:oaid];
|
|
|
+ HLog(@"weakSelf LogoutByOtherFun")
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ //被挤下线 停止拉流
|
|
|
+ [self pauseStream];
|
|
|
+
|
|
|
+ /*弹窗提示重启*/
|
|
|
+ //KWeakSelf
|
|
|
+ logoutAlertVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"single_sign_on_Tips_logout",nil)
|
|
|
+ msg:LogoutTimerStr
|
|
|
+ imageStr:@""
|
|
|
+ cancelTitle:NSLocalizedString(@"single_sign_on_exit",nil)
|
|
|
+ okTitle:loginAgainStr isOkBtnHighlight:isOkBtnHighlight
|
|
|
+ didClickOk:^{
|
|
|
+ self->logoutAlertVC = nil;
|
|
|
+ [[NSNotificationCenter defaultCenter] postNotificationName:lockBypwdNotification object:nil];
|
|
|
+
|
|
|
+ } didClickCancel:^{
|
|
|
+ exit(0);/*强制退出app*/
|
|
|
+ }];
|
|
|
+ logoutAlertVC.modalPresentationStyle = UIModalPresentationCustom;
|
|
|
+
|
|
|
+ [[iTools appRootViewController] presentViewController:logoutAlertVC animated:YES completion:^{
|
|
|
+ self->logoutAlertVC.view.superview.backgroundColor = [UIColor clearColor];
|
|
|
+ }];
|
|
|
+
|
|
|
+}
|
|
|
#pragma mark 底部按钮事件
|
|
|
- (void)didClickBottomFunBy:(NSInteger)tag
|
|
|
{
|
|
|
@@ -494,12 +575,18 @@
|
|
|
[_mediaStream sendKey:keyType];
|
|
|
}
|
|
|
|
|
|
-#pragma mark 云机交互的消息发送
|
|
|
+#pragma mark 云机交互的消息发送 走P2P通道
|
|
|
-(void)send_data:(NSString*)commandStr
|
|
|
{
|
|
|
[[webRtcManager shareManager] send_data:commandStr];
|
|
|
}
|
|
|
|
|
|
+#pragma mark 云机交互的消息发送 走音视频推拉流通道
|
|
|
+-(void)send_dataInPlayer:(NSString*)commandStr
|
|
|
+{
|
|
|
+ [_mediaStream sendData:commandStr];
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark -- /*底部导航栏开关通知*/
|
|
|
- (void)getPlayerBottomNavShowOrHidefun
|
|
|
{
|
|
|
@@ -581,6 +668,15 @@
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getPlayerBottomNavShowOrHidefun) name:getPlayerBottomNavNotification object:nil];
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setPlayerFullScreenNotFun) name:setPlayerFullScreenNotification object:nil];
|
|
|
+
|
|
|
+ //监听系统 前后台事件
|
|
|
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:UIApplicationWillTerminateNotification object:nil];
|
|
|
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil];
|
|
|
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillResignActive:) name:UIApplicationWillResignActiveNotification object:nil];
|
|
|
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidEnterBackground:) name:UIApplicationDidEnterBackgroundNotification object:nil];
|
|
|
+
|
|
|
+ //输入密码完成
|
|
|
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didInpuPwdOkFun) name:didInputPWDNotification object:nil];
|
|
|
}
|
|
|
|
|
|
- (void)removeKVOObserverFun
|
|
|
@@ -651,7 +747,7 @@
|
|
|
#pragma mark WebRTC 回调 MediaStreamClientEventsDelegate
|
|
|
#pragma mark - 宽高变化
|
|
|
-(void)onFrameResolutionChangedFromPeerName:(NSString*)peerName videoWidth:(int)videoWidth videoHeight:(int)videoHeight rotation:(int)rotation {
|
|
|
- HLog(@"onFrameResolutionChangedFromPeerName:%@---%d---%d--%d",peerName,videoWidth,videoHeight,rotation)
|
|
|
+ HLog(@"推拉流 onFrameResolutionChangedFromPeerName:%@---%d---%d--%d",peerName,videoWidth,videoHeight,rotation)
|
|
|
|
|
|
mainBlock(^{
|
|
|
[self handlUIAfterGetCloudPhoneVideoWidth:videoWidth videoHeight:videoHeight rotation:rotation];
|
|
|
@@ -667,7 +763,7 @@
|
|
|
#pragma mark 链接发生变化
|
|
|
-(void)onChangeConnectionStateFromPeerName:(NSString*)peerName didChangeIceConnectionState:(RTCIceConnectionState)state
|
|
|
{
|
|
|
- HLog(@"onChangeConnectionStateFromPeerName: state:%ld",state)
|
|
|
+ HLog(@"推拉流 onChangeConnectionStateFromPeerName: state:%ld",state)
|
|
|
_linkState = state;
|
|
|
switch (state) {
|
|
|
case RTCIceConnectionStateConnected:{
|
|
|
@@ -702,19 +798,87 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
-- (void)dataChannelDidChangeFromPeerName:(NSString*)peerName State:(RTCDataChannelState)state{
|
|
|
- ;
|
|
|
+- (void)dataChannelDidChangeFromPeerName:(NSString*)peerName State:(RTCDataChannelState)state;
|
|
|
+{
|
|
|
+ HLog(@"推拉流 dataChannelDidChangeFromPeerName: state:%ld",state)
|
|
|
+ switch (state) {
|
|
|
+ case RTCDataChannelStateConnecting:
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case RTCDataChannelStateOpen:
|
|
|
+ {
|
|
|
+ //链接成功
|
|
|
+ [self offlineOtherPhoneFun];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case RTCDataChannelStateClosing:
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case RTCDataChannelStateClosed:
|
|
|
+ {
|
|
|
+ //链接断开
|
|
|
+ [self relinkWebRtcFun];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-//-(void)onIceConnectedFromPeerName:(NSString*)peerName{
|
|
|
-// HLog(@"onIceConnectedFromPeerName:%@",peerName);
|
|
|
-// mainBlock(^{
|
|
|
-// [self removeNewIndicator];
|
|
|
-// });
|
|
|
-//}
|
|
|
-
|
|
|
+-(void)onChannelDataFromPeerName:(NSString*)peerName buffer:(RTC_OBJC_TYPE(RTCDataBuffer) *)buffer
|
|
|
+{
|
|
|
+ //HLog(@"onIceConnectedFromPeerName:%@",buffer.data);
|
|
|
+ if(buffer && buffer.data){
|
|
|
+ KWeakSelf
|
|
|
+ mainBlock(^{
|
|
|
+ [weakSelf handleWebRtcMsgResponseBy:buffer.data];
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
-(void)didGetStats:(NSString*)peerName stats:(RTC_OBJC_TYPE(RTCStatisticsReport) *)stats {
|
|
|
- HLog(@"stats:%@",stats);
|
|
|
+ HLog(@"推拉流 stats:%@",stats);
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark 收到的webrtc消息处理
|
|
|
+- (void)handleWebRtcMsgResponseBy:(NSData*)message
|
|
|
+{
|
|
|
+ if([message isKindOfClass:[NSMutableString class]] || [message isKindOfClass:[NSString class]])
|
|
|
+ {
|
|
|
+ message = [(NSString *)message dataUsingEncoding:(NSUTF8StringEncoding)];
|
|
|
+ }
|
|
|
+
|
|
|
+ NSError *error = nil;
|
|
|
+ NSDictionary *dataDict = [NSJSONSerialization JSONObjectWithData:message options:NSJSONReadingMutableContainers error:&error];
|
|
|
+ HLog(@"webRtc 音视频推拉流 通道接收消息:------------------%@",dataDict);
|
|
|
+
|
|
|
+
|
|
|
+ if(!dataDict){
|
|
|
+ //[weakSelf handleDownloadResponseFunBy:message];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(![dataDict isKindOfClass:[NSDictionary class]]){
|
|
|
+ //[__NSCFString allKeys] unrecognized selector sent to ins
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(![[dataDict allKeys] containsObject:@"type"]){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ NSString *messageType = dataDict[@"type"];
|
|
|
+
|
|
|
+ if ([messageType isEqualToString:@"login"]) {
|
|
|
+
|
|
|
+ if([[dataDict allKeys] containsObject:@"value"]){
|
|
|
+ NSString *value = dataDict[@"value"];
|
|
|
+ [self LogoutByOtherFun:value];
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
@end
|