瀏覽代碼

1.需求:盒子链接日志上传功能

huangxiaodong 6 月之前
父節點
當前提交
bf8e5fb3bc

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

@@ -11,6 +11,7 @@
 #import "couldPhoneBaseInfoModel.h"
 #import "TvStatusModel.h"
 #import "webRtcMsgModel.h"
+#import <WebRTC/RTCFileLogger.h>
 
 @interface AppDelegate : UIResponder <UIApplicationDelegate>
 
@@ -51,6 +52,8 @@
 
 @property (nonatomic, assign)  BOOL needToPushWebRtcVCType;//云机横屏 后台 被推出来
 
+@property(nonatomic,strong) RTCFileLogger *WebRtcLogger;//webRTC日志
+
 +(AppDelegate*)sharedAppDelegate;
 
 #pragma mark 更换设备 重新设置地址

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

@@ -144,6 +144,23 @@
     TencentOAuth *tencentOAuth =[[TencentOAuth alloc] initWithAppId:QQAPPid andUniversalLink:QQUniversalLink andDelegate:self];
     
     [self imageLoadingSettings];
+    
+    //写WebRct日志到本地
+    NSString *logFilePath = [kSHPath_logs stringByAppendingPathComponent:@"iOSWebRtc.log"];
+      
+    // 创建或打开文件
+    NSFileManager *fileManager = [NSFileManager defaultManager];
+    if (![fileManager fileExistsAtPath:logFilePath]) {
+        // 如果文件不存在,则创建它
+        if (![[NSFileManager defaultManager] createFileAtPath:logFilePath contents:nil attributes:nil]) {
+            HLog(@"Unable to create file: %@", logFilePath);
+        }
+    }
+    
+  
+    //_WebRtcLogger = [[RTC_OBJC_TYPE(RTCFileLogger) alloc] initWithDirPath:logFilePath maxFileSize:10*1024*1024];
+    _WebRtcLogger = [[RTCFileLogger alloc] initWithDirPath:kSHPath_logs maxFileSize:10*1024*1024];
+    HLog(@"_WebRtcLogger: %@", _WebRtcLogger);
     return YES;
 }
 

+ 4 - 4
创维盒子/双子星云手机/AppDelegate/PrefixHeader.pch

@@ -112,16 +112,16 @@ isBangsScreen; \
 //#define shareService   @"http://testprivacy.phone.androidscloud.com:1801/h5/#/pages/fileSharing/index?productType=Private-X&token="
 
 //预生产环境
-//#define CloudService   @"http://testprivacy.phone.androidscloud.com:10900"
-//#define shareService   @"http://testprivacy.phone.androidscloud.com:10900/h5/#/pages/fileSharing/index?productType=Private-X&token="
+#define CloudService   @"http://testprivacy.phone.androidscloud.com:10900"
+#define shareService   @"http://testprivacy.phone.androidscloud.com:10900/h5/#/pages/fileSharing/index?productType=Private-X&token="
 
 //生产环境 弃用
 //弃用 #define CloudService   @"http://hiboxde.armclouding.com:7780"
 //弃用 #define shareService   @"http://hiboxde.armclouding.com:7780/h5/#/pages/fileSharing/index?productType=Private-X&token="
 
 //生产环境 1.4.3 开始使用
-#define CloudService   @"http://hiboxde.androidscloud.com:7780"
-#define shareService   @"http://hiboxde.androidscloud.com:7780/h5/#/pages/fileSharing/index?productType=Private-X&token="
+//#define CloudService   @"http://hiboxde.androidscloud.com:7780"
+//#define shareService   @"http://hiboxde.androidscloud.com:7780/h5/#/pages/fileSharing/index?productType=Private-X&token="
 
 
 #define AESCODEKEEYY @"fvO8gAfNSr1tbdQe"

+ 2 - 1
创维盒子/双子星云手机/Class/Set/CustomerWebViewController.m

@@ -237,7 +237,8 @@
 {
     
     //1.读取日志
-    NSString *ruiyunLogPath = [NSString stringWithFormat:@"%@/logs/debug_0.log",CachesPatch];
+    //NSString *ruiyunLogPath = [NSString stringWithFormat:@"%@/logs/debug_0.log",CachesPatch];
+    NSString *ruiyunLogPath = [NSString stringWithFormat:@"%@/logs/webrtc_log_0",CachesPatch];
     NSData *logData = [NSData dataWithContentsOfFile:ruiyunLogPath];
     HLog(@"%@",logData);
     

+ 1 - 1
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/cachesFileManager.m

@@ -180,7 +180,7 @@
 //写日志
 + (void)writeLogsWithMsg:(NSString *)msg
 {
-    return;
+    //return;
     
     if (![[NSFileManager defaultManager] fileExistsAtPath:kSHPath_logs]) {
         

+ 2 - 1
创维盒子/双子星云手机/netWork/addLog/addLogObject.m

@@ -56,7 +56,8 @@ static addLogObject *addlog_ShareInstance = nil;
     _canUploadNowType = NO;
     
     //1.读取日志
-    NSString *ruiyunLogPath = [NSString stringWithFormat:@"%@/logs/debug_0.log",CachesPatch];
+    //NSString *ruiyunLogPath = [NSString stringWithFormat:@"%@/logs/debug_0.log",CachesPatch];
+    NSString *ruiyunLogPath = [NSString stringWithFormat:@"%@/logs/webrtc_log_0",CachesPatch];
     NSData *logData = [NSData dataWithContentsOfFile:ruiyunLogPath];
     HLog(@"%@",logData);
     

+ 28 - 107
创维盒子/双子星云手机/webRtc/WebRTC.framework/Headers/AMediaStream.h

@@ -30,6 +30,14 @@ RTC_OBJC_EXPORT
 //code 0 成功 1失败
 -(void)onAuthResultFromPeerName:(NSString*)peerName code:(int)code descriptions:(NSString*)descriptions;
 
+-(void)onFirstFrameRendered:(NSString*)peerName;
+
+@optional
+- (void)connectionChange:(NSString*)peerName
+    didChangeLocalCandidate:(RTC_OBJC_TYPE(RTCIceCandidate) *)local
+            remoteCandidate:(RTC_OBJC_TYPE(RTCIceCandidate) *)remote
+             lastReceivedMs:(int)lastDataReceivedMs
+               changeReason:(NSString *)reason;
 @end
 
 RTC_OBJC_EXPORT
@@ -39,107 +47,16 @@ RTC_OBJC_EXPORT
 
 +(void)globalDeinitialization;
 
--(instancetype)initWithFrame:(CGRect)frame;
-
-//NSDictionary *iceMessage=@{
-//    @"CHINANET":@"电信",
-//    @"CMNET":@"移动",
-//    @"UNICOM":@"联通"
-//};
-
--(int)start:(NSURL *)url
-        ice:(NSDictionary*)ice
-         sn:(NSString*)sn
-     direct:(NSInteger)direct
-        fmt:(NSInteger)fmt
- videoWidth:(NSInteger)videoWidth
-videoHeight:(NSInteger)videoHeight
-        fps:(NSInteger)fps
-    bitrate:(NSInteger)bitrate
-  cardWidth:(NSInteger)cardWidth
- cardHeight:(NSInteger)cardHeight
-cardDensity:(NSInteger)cardDensity
-      token:(NSString*)token;
-
-- (int)startUploadChannel:(NSURL *)url
-                      ice:(NSDictionary*)ice
-                       sn:(NSString*)sn
-                    token:(NSString*)token;
-
-- (void)disconnect;
-
-- (BOOL)sendData:(NSString*)strData;
-
-- (BOOL)sendBinary:(NSData*)data;
-
-- (void)sendKey:(int)value;
-
-- (void)pauseStream;
-
-- (void)resumeStream;
-
-- (void)setMaxBitrate:(NSNumber*)rate;
-
-- (void)setShouldGetStats:(BOOL)shouldGetStats;
-
-- (void)setVideoContentMode:(UIViewContentMode)mode;
-
-- (void)setCardSize:(NSInteger)cardWidth
-         cardHeight:(NSInteger)cardHeight
-        cardDensity:(NSInteger)cardDensity;
-
-- (void)setVideoSize:(NSInteger)videoWidth
-        videoHeight:(NSInteger)videoHeight;
-
-@property (nonatomic, weak) id <MediaStreamClientEventsDelegate> eventDelegate;
-@property(nonatomic,readonly) NSString *name;
-@property(nonatomic, assign) BOOL shouldGetStats;
-
-@end
-
-#endif /* AMediaStream_h */
-//
-//  AMediaStream.h
-//  all
-//
-//  Created by admin on 2024/3/14.
-//
-
-#ifndef AMediaStream_h
-#define AMediaStream_h
-
-#import <Foundation/Foundation.h>
-#import <WebRTC/RTCPeerConnection.h>
-#import <WebRTC/RTCDataChannel.h>
-#import <WebRTC/RTCStatisticsReport.h>
-#import <WebRTC/RTCVideoRenderer.h>
-
-RTC_OBJC_EXPORT
-@protocol RTC_OBJC_TYPE(MediaStreamClientEventsDelegate) <NSObject>
-
-- (void)dataChannelDidChangeFromPeerName:(NSString*)peerName State:(RTCDataChannelState)state;
++(NSString*)getSdkVersion;
 
--(void)onChannelDataFromPeerName:(NSString*)peerName buffer:(RTC_OBJC_TYPE(RTCDataBuffer) *)buffer;
-
--(void)onChangeConnectionStateFromPeerName:(NSString*)peerName didChangeIceConnectionState:(RTCIceConnectionState)state;
-
--(void)onFrameResolutionChangedFromPeerName:(NSString*)peerName videoWidth:(int)videoWidth videoHeight:(int)videoHeight rotation:(int)rotation;
-
--(void)didGetStats:(NSString*)peerName stats:(RTC_OBJC_TYPE(RTCStatisticsReport) *)stats;
-
-//code 0 成功 1失败
--(void)onAuthResultFromPeerName:(NSString*)peerName code:(int)code descriptions:(NSString*)descriptions;
-
-@end
-
-RTC_OBJC_EXPORT
-@interface RTC_OBJC_TYPE(AMediaStream) : UIView
+-(instancetype)initWithFrame:(CGRect)frame;
 
-+(void)globalInitialization;
+//start 拉流前调用设置软硬编码,YES硬编码,NO软编码,不调用默认硬编码
+-(void)setVideoCodecHwAcceleration:(BOOL)videoCodecHwAcceleration;
 
-+(void)globalDeinitialization;
-
--(instancetype)initWithFrame:(CGRect)frame;
+//start 拉流前调用设置本次拉流记录推流端日志到指定文件与记录时间 秒 单位。
+//filePathName = /sdcard/webrtc_box.log    captureTime = 30s
+-(void)setCardLogToFile:(NSString*)filePathName captureTime:(NSString*)captureTime;
 
 //NSDictionary *iceMessage=@{
 //    @"CHINANET":@"电信",
@@ -172,25 +89,29 @@ cardDensity:(NSInteger)cardDensity
 
 - (BOOL)sendBinary:(NSData*)data;
 
-- (void)sendKey:(int)value;
+- (BOOL)sendKey:(int)value;
+
+- (BOOL)pauseStream;
 
-- (void)pauseStream;
+- (BOOL)resumeStream;
 
-- (void)resumeStream;
+- (BOOL)setAudioEnable:(BOOL)enable;
 
-- (void)setMaxBitrate:(NSNumber*)rate;
+- (BOOL)setMaxBitrate:(NSNumber*)rate;
+
+- (BOOL)setAutoBitrateEnabled:(BOOL)enable bitrate:(NSNumber*)bitrate;
 
 - (void)setShouldGetStats:(BOOL)shouldGetStats;
 
 - (void)setVideoContentMode:(UIViewContentMode)mode;
 
-- (void)setCardSize:(NSInteger)cardWidth
+- (BOOL)setCardSize:(NSInteger)cardWidth
          cardHeight:(NSInteger)cardHeight
         cardDensity:(NSInteger)cardDensity;
 
-- (void)setVideoSize:(NSInteger)videoWidth
-        videoHeight:(NSInteger)videoHeight;
-
+- (BOOL)setVideoSize:(NSInteger)videoWidth
+        videoHeight:(NSInteger)videoHeight
+          frameRate:(NSInteger)frameRate;
 
 @property (nonatomic, weak) id <MediaStreamClientEventsDelegate> eventDelegate;
 @property(nonatomic,readonly) NSString *name;
@@ -198,4 +119,4 @@ cardDensity:(NSInteger)cardDensity
 
 @end
 
-#endif /* AMediaStream_h */
+#endif 

二進制
创维盒子/双子星云手机/webRtc/WebRTC.framework/WebRTC


+ 2 - 2
创维盒子/双子星云手机/webRtc/WebRTC.framework/_CodeSignature/CodeResources

@@ -6,7 +6,7 @@
 	<dict>
 		<key>Headers/AMediaStream.h</key>
 		<data>
-		msGLG4WoYAkoyXvmiRB7cU/nWG8=
+		iccGd8P+Ogdc55tvecZMrwfuEMg=
 		</data>
 		<key>Headers/ANatsSignalChannel.h</key>
 		<data>
@@ -387,7 +387,7 @@
 		<dict>
 			<key>hash2</key>
 			<data>
-			18fSqR1ZoVfTxuWMK96i9uF0pmBJSGilDdBWxhbs3BU=
+			mhlzbDwvBC+rAWrrAI717Rx5YqBLYiTQ9PUNMlZbW/E=
 			</data>
 		</dict>
 		<key>Headers/ANatsSignalChannel.h</key>

+ 1 - 0
创维盒子/双子星云手机/webRtc/webRtcManager/webRtcManager.h

@@ -10,6 +10,7 @@
 #import <WebRTC/RTCMacros.h>
 #import "webRtcMsgModel.h"
 #import "USBInsertPopView.h"
+#import "addLogObject.h"
 
 NS_ASSUME_NONNULL_BEGIN
 

+ 14 - 0
创维盒子/双子星云手机/webRtc/webRtcManager/webRtcManager.m

@@ -125,6 +125,13 @@
     
     NSString *roomName = _webRtcMsgMod.data.uniqueIdentifier;
     
+    //1.盒子开始写20秒日志
+    [_mediaStream setCardLogToFile:@"/sdcard/webrtc_box.log" captureTime:@"20"];
+    
+    //2.客户端开始写日志
+    [ksharedAppDelegate.WebRtcLogger start];
+    HLog(@"webrtc :%@",ksharedAppDelegate.WebRtcLogger)
+    
     NSInteger result = [_mediaStream startUploadChannel:url ice:ice sn:roomName token:@"vclusters"];
     
     HLog(@"webrtc 发起连接 result:%ld",result)
@@ -135,6 +142,8 @@
     ksharedAppDelegate.isWebSockLinkOKAginType = NO;
     
     if(!_isChangeBoxType){
+        //客户端停止写日志
+        [ksharedAppDelegate.WebRtcLogger stop];
         [self beginToLinkWebRtcFun];
     }
 }
@@ -921,6 +930,8 @@
         case RTCIceConnectionStateClosed:{
             if(!_didReportWebRtcType){//还没上报过通道链接情况
                 [self reportWebRtcRePoportTypeIsChannel:YES withStats:nil];
+                
+                [[addLogObject shareInstance] gotoAddLogFun];
             }
             //链接关闭
             [self relinkWebRtcFun];
@@ -948,6 +959,9 @@
             {
                 //链接成功
                 [self handlAllMsgAfterDidLinkFun];
+                
+                //客户端停止写日志
+                [ksharedAppDelegate.WebRtcLogger stop];
             }
             break;
         case RTCDataChannelStateClosing:

+ 17 - 2
创维盒子/双子星云手机/webRtc/webRtcPlayerViewController.m

@@ -195,6 +195,14 @@
         bitrate = 2*1024;
     }
     
+    //1.盒子开始写20秒日志
+    //start 拉流前调用设置本次拉流记录推流端日志到指定文件与记录时间 秒 单位。
+    //filePathName = /sdcard/webrtc_box.log    captureTime = 30s
+    [_mediaStream setCardLogToFile:@"/sdcard/webrtc_box.log" captureTime:@"20"];
+
+    //2.客户端开始写日志
+    [ksharedAppDelegate.WebRtcLogger start];
+    
     NSInteger result = [_mediaStream start:url
                             ice:ice
                              sn:roomName
@@ -244,6 +252,9 @@
             phoneSize = [RCCommandHelp commondToSetFullScreenPhoneSizeBySize];
         }
         
+        //客户端停止写日志
+        [ksharedAppDelegate.WebRtcLogger stop];
+        
         [weakSelf linkWebRtcFunWithSize:phoneSize];
     });
 }
@@ -817,12 +828,12 @@
     if(isLan){
         HLog(@"云机屏幕 设置 宽:%ld 高:%ld",cardHeight,cardWidth);
         [_mediaStream setCardSize:cardHeight cardHeight:cardWidth cardDensity:cardDensit];
-        [_mediaStream setVideoSize:cardHeight videoHeight:cardWidth];
+        [_mediaStream setVideoSize:cardHeight videoHeight:cardWidth frameRate:0];
     }
     else{
         HLog(@"云机屏幕 设置 宽:%ld 高:%ld",cardWidth,cardHeight);
         [_mediaStream setCardSize:cardWidth cardHeight:cardHeight cardDensity:cardDensit];
-        [_mediaStream setVideoSize:cardWidth videoHeight:cardHeight];
+        [_mediaStream setVideoSize:cardWidth videoHeight:cardHeight frameRate:0];
     }
     
 }
@@ -981,6 +992,8 @@
             //链接成功
             mainBlock(^{
                 [self removeNewIndicator];
+                //客户端停止写日志
+                [ksharedAppDelegate.WebRtcLogger stop];
             });
         }
             break;
@@ -992,6 +1005,8 @@
         case RTCIceConnectionStateClosed:{
             if(!_didReportWebRtcType){//还没上报过通道链接情况
                 [[webRtcManager shareManager] reportWebRtcRePoportTypeIsChannel:YES withStats:nil];
+                
+                [[addLogObject shareInstance] gotoAddLogFun];
             }
             //链接关闭
             [self relinkWebRtcFun];