From 1e12637057c2570e1b83af14f4bf157ec6d82089 Mon Sep 17 00:00:00 2001 From: eagleychen Date: Tue, 14 May 2024 18:18:00 +0800 Subject: [PATCH] =?UTF-8?q?report=20=E6=95=B0=E6=8D=AE=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Podfile.lock | 8 +++---- Source/SDK/LinkVideo/TIoTCoreXP2PBridge.mm | 26 +++++++++------------- Source/SDK/LinkVideo/log/TIoTCoreLogger.m | 9 +++++--- TIoTLinkVideo.podspec | 2 +- 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/Podfile.lock b/Podfile.lock index 47a98eb4..abe6b2ec 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -35,13 +35,13 @@ PODS: - TIoTLinkKit_SoundTouch (1.0.0) - TIoTLinkKit_TPNS (1.0.1) - TIoTLinkKit_WechatOpenSDK (1.0.1) - - TIoTLinkKit_XP2P (2.4.49-beta.202404260903) + - TIoTLinkKit_XP2P (2.4.49-beta.202405140951) - TIoTLinkVideo (1.0.0): - CocoaAsyncSocket (= 7.6.5) - TIoTLinkKit_FLV (= 2.2.3) - TIoTLinkKit_GVoiceSE (>= 1.0.7) - TIoTLinkKit_SoundTouch (= 1.0.0) - - TIoTLinkKit_XP2P (= 2.4.49-beta.202404260903) + - TIoTLinkKit_XP2P (= 2.4.49-beta.202405140951) - TPCircularBuffer (= 1.6.1) - TPCircularBuffer (1.6.1) - TrueTime (5.0.3) @@ -133,8 +133,8 @@ SPEC CHECKSUMS: TIoTLinkKit_SoundTouch: cf79ae182b6c2349ff65bac7a338974bc538fa77 TIoTLinkKit_TPNS: 7cea4fc1d20ef6c4c11c4f0b66bbb10ecf4ed968 TIoTLinkKit_WechatOpenSDK: 7822d68cc5c46edf3f6020422202e7b65ea87614 - TIoTLinkKit_XP2P: 24e210fd96fd88c991c98b8ddc8a3c91bb823981 - TIoTLinkVideo: 99852d5bd081a8774b341b86181680346928be1b + TIoTLinkKit_XP2P: c99d4c39788069c8c469c836ded075da5cf316ab + TIoTLinkVideo: 1ddb809a95a2b788db4d5ceb297cb6d817f1f948 TPCircularBuffer: c13243556527551c4d320709c7b14a6d20cdc30a TrueTime: b49551ffafb28a9dee04e51b226f42a416010842 TXLiteAVSDK_TRTC: e3383a81565e8bb2aaaaab4bd099ad5239cd5b2d diff --git a/Source/SDK/LinkVideo/TIoTCoreXP2PBridge.mm b/Source/SDK/LinkVideo/TIoTCoreXP2PBridge.mm index 104eaf3c..d86ddb12 100644 --- a/Source/SDK/LinkVideo/TIoTCoreXP2PBridge.mm +++ b/Source/SDK/LinkVideo/TIoTCoreXP2PBridge.mm @@ -39,9 +39,7 @@ - (void)doTick:(data_report_t)data_buf; if (type == XP2PTypeLog) { if (logEnable) { fwrite(msg, 1, strlen(msg)>300?300:strlen(msg), p2pOutLogFile); - @autoreleasepool { - [[TIoTCoreXP2PBridge sharedInstance].logger addLog:[NSString stringWithCString:msg encoding:NSASCIIStringEncoding]]; - } + [[TIoTCoreXP2PBridge sharedInstance].logger addLog:[NSString stringWithCString:msg encoding:NSASCIIStringEncoding]]; } return nullptr; }else if (type == XP2PTypeSaveFileOn) { @@ -290,7 +288,6 @@ - (XP2PErrCode)setXp2pInfo:(NSString *)dev_name sec_id:(NSString *)sec_id sec_ke int ret = setDeviceXp2pInfo(dev_name.UTF8String, xp2pinfo.UTF8String); self.startTime = [[TIoTCoreXP2PBridge getNowTimeTimestamp] integerValue]; - [self reportUserList:0 status:@"start"]; return (XP2PErrCode)ret; } @@ -517,7 +514,6 @@ - (void)stopService:(NSString *)dev_name { [self stopVoiceToServer]; stopService(dev_name.UTF8String); - [self reportUserList:0 status:@"end"]; // [self.logger stopLogging]; //关闭文件 // [fileHandle closeFile]; @@ -620,6 +616,8 @@ - (NSString *)readKeychainValue:(NSString *)sKey } - (void)doTick:(data_report_t)data_buf { + [self reportUserList:data_buf]; + if (data_buf.report_size < 2) { return; } @@ -638,19 +636,17 @@ - (void)doTick:(data_report_t)data_buf { } }]; [task resume]; - - if (data_buf.xntp_size > 0) { - [self reportUserList:data_buf.xntp_size status:@"bytecount"]; - } } -- (void)reportUserList:(size_t)xntp_size status:(NSString *)status { +- (void)reportUserList:(data_report_t)report { - static NSString *reqid = [[NSUUID UUID] UUIDString]; + NSString *reqid = [NSString stringWithCString:(const char *)report.uniqueId encoding:NSASCIIStringEncoding];//@"8f3d545eabe165ed52247f1c89ad5acd";//[[NSUUID UUID] UUIDString]; + NSString *status = [NSString stringWithCString:(const char *)report.status encoding:NSASCIIStringEncoding]; + NSString *dataaction = [NSString stringWithCString:(const char *)report.data_action encoding:NSASCIIStringEncoding]; NSMutableDictionary *accessParam = [NSMutableDictionary dictionary]; [accessParam setValue:@"P2PReport" forKey:@"Action"]; [accessParam setValue:status forKey:@"Status"]; - [accessParam setValue:@"live" forKey:@"DataAction"]; + [accessParam setValue:dataaction forKey:@"DataAction"]; [accessParam setValue:reqid forKey:@"UniqueId"]; [accessParam setValue:@(self.startTime) forKey:@"StartTime"]; [accessParam setValue:@([[TIoTCoreXP2PBridge getNowTimeTimestamp] integerValue]) forKey:@"Time"]; @@ -660,8 +656,8 @@ - (void)reportUserList:(size_t)xntp_size status:(NSString *)status { [accessParam setValue:[self getAppUUID] forKey:@"UserId"]; [accessParam setValue:self.pro_id forKey:@"ProductId"]; [accessParam setValue:self.dev_name forKey:@"DeviceName"]; - [accessParam setValue:@(xntp_size) forKey:@"ByteCount"]; - [accessParam setValue:@(1) forKey:@"Channel"]; + [accessParam setValue:@(report.live_size) forKey:@"ByteCount"]; + [accessParam setValue:@(0) forKey:@"Channel"]; NSURL *url = [NSURL URLWithString:@"https://applog.iotcloud.tencentiotcloud.com/api/xp2p_ops/applog"]; NSMutableURLRequest *reqlog = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:5]; [reqlog setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; @@ -671,7 +667,7 @@ - (void)reportUserList:(size_t)xntp_size status:(NSString *)status { NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response; if (httpResponse.statusCode == 200) { -// NSLog(@"app log: %@",response); +// NSLog(@"app log: %@---req-%@",response, accessParam); } }]; [tasklog resume]; diff --git a/Source/SDK/LinkVideo/log/TIoTCoreLogger.m b/Source/SDK/LinkVideo/log/TIoTCoreLogger.m index e6d5a033..f1ffe1aa 100644 --- a/Source/SDK/LinkVideo/log/TIoTCoreLogger.m +++ b/Source/SDK/LinkVideo/log/TIoTCoreLogger.m @@ -35,8 +35,9 @@ - (void)stopLogging { } - (void)addLog:(NSString *)message { - [self.log appendString:message]; -// [self.log appendString:@"\n"]; + @synchronized(self.log) { + [self.log appendString:message]; + } } - (void)reportLog { @@ -59,7 +60,9 @@ - (void)reportLog { }]; [task resume]; - [self.log setString:@""]; // 清空日志 + @synchronized(self.log) { + [self.log setString:@""]; // 清空日志 + } } @end diff --git a/TIoTLinkVideo.podspec b/TIoTLinkVideo.podspec index 13c9b472..03423c21 100644 --- a/TIoTLinkVideo.podspec +++ b/TIoTLinkVideo.podspec @@ -19,7 +19,7 @@ Pod::Spec.new do |s| s.source_files = 'Source/SDK/LinkVideo/**/*.{h,m,c,mm}' s.resource = 'Source/SDK/LinkVideo/FLV/asset/GvoiceSE_v1_239-119-oneref-e.nn' - s.dependency 'TIoTLinkKit_XP2P', '2.4.49-beta.202404260903' + s.dependency 'TIoTLinkKit_XP2P', '2.4.49-beta.202405140951' s.dependency 'TIoTLinkKit_FLV', '2.2.3' s.dependency 'CocoaAsyncSocket', '7.6.5' s.dependency 'TIoTLinkKit_SoundTouch', '1.0.0'