Skip to content

Commit

Permalink
report 数据优化
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleychen committed May 14, 2024
1 parent dc7ea49 commit 1e12637
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
8 changes: 4 additions & 4 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
26 changes: 11 additions & 15 deletions Source/SDK/LinkVideo/TIoTCoreXP2PBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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;
}
Expand All @@ -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"];
Expand All @@ -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"];
Expand All @@ -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];
Expand Down
9 changes: 6 additions & 3 deletions Source/SDK/LinkVideo/log/TIoTCoreLogger.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -59,7 +60,9 @@ - (void)reportLog {
}];
[task resume];

[self.log setString:@""]; // 清空日志
@synchronized(self.log) {
[self.log setString:@""]; // 清空日志
}
}

@end
Expand Down
2 changes: 1 addition & 1 deletion TIoTLinkVideo.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 1e12637

Please sign in to comment.