|
|
@@ -11,51 +11,147 @@
|
|
|
// IsChannel:是否是P2P通道
|
|
|
- (void)reportWebRtcRePoportTypeIsChannel:(BOOL)IsChannel withStats:(RTC_OBJC_TYPE(RTCStatisticsReport) *)stats
|
|
|
{
|
|
|
+ HLog(@"444444 %@",stats)
|
|
|
if(!stats){
|
|
|
- [self reportWebRtcRePoportTypeIsChannel:IsChannel withStatus:0];
|
|
|
+ [self reportWebRtcRePoportTypeIsChannel:IsChannel withStatus:0 withPublicIp:@"" withPublicPort:@"" withPrivateIp:@"" withPrivatePort:@""];
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- NSDictionary *remoteCandidateDict = nil;
|
|
|
- NSDictionary *localCandidateDict = nil;
|
|
|
+ //
|
|
|
+ NSDictionary *jsonTransport = nil;
|
|
|
+ NSMutableArray *pairMapArr = [NSMutableArray new];
|
|
|
+ NSMutableArray *remoteCandidateMapArr = [NSMutableArray new];
|
|
|
+ NSMutableArray *localCandidateMapArr = [NSMutableArray new];
|
|
|
+
|
|
|
+ //1.先拿到 jsonTransport 的信息
|
|
|
for (NSString *key in [stats.statistics allKeys]) {
|
|
|
RTCStatistics *rtcStatistics = [stats.statistics objectForKey:key];
|
|
|
- //HLog(@"%@",rtcStatistics)
|
|
|
+
|
|
|
+ HLog(@"222 %@",rtcStatistics.type)
|
|
|
+
|
|
|
+ if ([rtcStatistics.type isEqualToString:@"transport"]) {
|
|
|
+ jsonTransport = rtcStatistics.values;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ([rtcStatistics.type isEqualToString:@"candidate-pair"]) {
|
|
|
+ [pairMapArr addObject:rtcStatistics];
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
if ([rtcStatistics.type isEqualToString:@"remote-candidate"]) {
|
|
|
- remoteCandidateDict = rtcStatistics.values;
|
|
|
+ [remoteCandidateMapArr addObject:rtcStatistics];
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
if ([rtcStatistics.type isEqualToString:@"local-candidate"]) {
|
|
|
- localCandidateDict = rtcStatistics.values;
|
|
|
+ [localCandidateMapArr addObject:rtcStatistics];
|
|
|
continue;
|
|
|
}
|
|
|
-
|
|
|
- if(localCandidateDict && remoteCandidateDict){
|
|
|
- break;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ NSString *selectedCandidatePairId = @"";
|
|
|
+ NSString *localCandidateId = @"";
|
|
|
+ NSString *remoteCandidateId = @"";
|
|
|
+
|
|
|
+ if([[jsonTransport allKeys] containsObject:@"selectedCandidatePairId"]){
|
|
|
+ selectedCandidatePairId = jsonTransport[@"selectedCandidatePairId"];
|
|
|
+ }
|
|
|
+
|
|
|
+ //2.找到 localCandidateId remoteCandidateId
|
|
|
+ for (RTCStatistics *rtcStatistics in pairMapArr) {
|
|
|
+ if([rtcStatistics isKindOfClass:[RTCStatistics class]]){
|
|
|
+ NSString *curId = rtcStatistics.id;
|
|
|
+ if([curId isEqualToString:selectedCandidatePairId]){
|
|
|
+ NSDictionary *valuesDict = rtcStatistics.values;
|
|
|
+ if([valuesDict isKindOfClass:[NSDictionary class]]){
|
|
|
+ if ([[valuesDict allKeys] containsObject:@"localCandidateId"]) {
|
|
|
+ localCandidateId = valuesDict[@"localCandidateId"];
|
|
|
+ }
|
|
|
+
|
|
|
+ if ([[valuesDict allKeys] containsObject:@"remoteCandidateId"]) {
|
|
|
+ remoteCandidateId = valuesDict[@"remoteCandidateId"];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if([[localCandidateDict allKeys] containsObject:@"candidateType"]
|
|
|
- &&[[remoteCandidateDict allKeys] containsObject:@"candidateType"]){
|
|
|
- NSString *localCandidateType = localCandidateDict[@"candidateType"];
|
|
|
- NSString *remoteCandidateType = remoteCandidateDict[@"candidateType"];
|
|
|
-
|
|
|
- if([localCandidateType isEqualToString:@"relay"]
|
|
|
- ||[remoteCandidateType isEqualToString:@"relay"]){
|
|
|
- [self reportWebRtcRePoportTypeIsChannel:IsChannel withStatus:2];
|
|
|
+
|
|
|
+ //3.找到 localCandidateDict
|
|
|
+ NSDictionary *localCandidateDict = nil;
|
|
|
+
|
|
|
+ NSString*privateIp = @"";
|
|
|
+ NSString*privatePort = @"";
|
|
|
+ NSString *localCandidateType = @"";
|
|
|
+
|
|
|
+ for (RTCStatistics *rtcStatistics in localCandidateMapArr) {
|
|
|
+ if([rtcStatistics isKindOfClass:[RTCStatistics class]]){
|
|
|
+ NSString *curId = rtcStatistics.id;
|
|
|
+ if([curId isEqualToString:localCandidateId]){
|
|
|
+ localCandidateDict = rtcStatistics.values;
|
|
|
+ if([localCandidateDict isKindOfClass:[NSDictionary class]]){
|
|
|
+ if([[localCandidateDict allKeys] containsObject:@"ip"]){
|
|
|
+ privateIp = localCandidateDict[@"ip"];
|
|
|
+ }
|
|
|
+
|
|
|
+ if([[localCandidateDict allKeys] containsObject:@"port"]){
|
|
|
+ privatePort = localCandidateDict[@"port"];
|
|
|
+ }
|
|
|
+
|
|
|
+ if([[localCandidateDict allKeys] containsObject:@"candidateType"]){
|
|
|
+ localCandidateType = localCandidateDict[@"candidateType"];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
- else{
|
|
|
- [self reportWebRtcRePoportTypeIsChannel:IsChannel withStatus:1];
|
|
|
+ }
|
|
|
+
|
|
|
+ //4.找到 remoteCandidateDict
|
|
|
+
|
|
|
+ NSDictionary *remoteCandidateDict = nil;
|
|
|
+
|
|
|
+ NSString*publicIp = @"";
|
|
|
+ NSString*publicPort = @"";
|
|
|
+ NSString *remoteCandidateType = @"";
|
|
|
+
|
|
|
+ for (RTCStatistics *rtcStatistics in remoteCandidateMapArr) {
|
|
|
+ if([rtcStatistics isKindOfClass:[RTCStatistics class]]){
|
|
|
+ NSString *curId = rtcStatistics.id;
|
|
|
+ if([curId isEqualToString:remoteCandidateId]){
|
|
|
+ remoteCandidateDict = rtcStatistics.values;
|
|
|
+ if([remoteCandidateDict isKindOfClass:[NSDictionary class]]){
|
|
|
+ if([[remoteCandidateDict allKeys] containsObject:@"ip"]){
|
|
|
+ publicIp = remoteCandidateDict[@"ip"];
|
|
|
+ }
|
|
|
+
|
|
|
+ if([[remoteCandidateDict allKeys] containsObject:@"port"]){
|
|
|
+ publicPort = remoteCandidateDict[@"port"];
|
|
|
+ }
|
|
|
+
|
|
|
+ if([[remoteCandidateDict allKeys] containsObject:@"candidateType"]){
|
|
|
+ remoteCandidateType = remoteCandidateDict[@"candidateType"];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- }else{
|
|
|
- [self reportWebRtcRePoportTypeIsChannel:IsChannel withStatus:2];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if([localCandidateType isEqualToString:@"relay"]
|
|
|
+ ||[remoteCandidateType isEqualToString:@"relay"]){
|
|
|
+ [self reportWebRtcRePoportTypeIsChannel:IsChannel withStatus:2 withPublicIp:publicIp withPublicPort:publicPort withPrivateIp:privateIp withPrivatePort:privatePort];
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ [self reportWebRtcRePoportTypeIsChannel:IsChannel withStatus:1 withPublicIp:publicIp withPublicPort:publicPort withPrivateIp:privateIp withPrivatePort:privatePort];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-- (void)reportWebRtcRePoportTypeIsChannel:(BOOL)IsChannel withStatus:(int)linkState
|
|
|
+- (void)reportWebRtcRePoportTypeIsChannel:(BOOL)IsChannel withStatus:(int)linkState withPublicIp:(NSString*)publicIp withPublicPort:(NSString*)publicPort withPrivateIp:(NSString*)privateIp withPrivatePort:(NSString*)privatePort
|
|
|
{
|
|
|
|
|
|
NSMutableDictionary *paraDict = [NSMutableDictionary new];
|
|
|
@@ -66,6 +162,22 @@
|
|
|
int clientNetworkStatus = [pingManager shareManager].isPingOk ? 0 : 1;
|
|
|
[paraDict setValue:[NSNumber numberWithInt:clientNetworkStatus] forKey:@"clientNetworkStatus"];
|
|
|
|
|
|
+ if(publicIp){
|
|
|
+ [paraDict setValue:publicIp forKey:@"publicIp"];
|
|
|
+ }
|
|
|
+
|
|
|
+ if(publicPort){
|
|
|
+ [paraDict setValue:publicPort forKey:@"publicPort"];
|
|
|
+ }
|
|
|
+
|
|
|
+ if(privateIp){
|
|
|
+ [paraDict setValue:privateIp forKey:@"privateIp"];
|
|
|
+ }
|
|
|
+
|
|
|
+ if(privatePort){
|
|
|
+ [paraDict setValue:privatePort forKey:@"privatePort"];
|
|
|
+ }
|
|
|
+
|
|
|
[[netWorkManager shareInstance] CommonPostCallBackCode:webrctLogAdd Parameters:paraDict success:^(id _Nonnull responseObject){
|
|
|
|
|
|
SuperModel *curModel = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
|