我在我的应用程序中使用Quickblox进行视频通话,我成功注册并登录,但是当我尝试使用以下代码创建QBRTCSession时,总是出现错误,请帮帮我。

QBRTCSession* videoSession = [QBRTCClient.instance createNewSessionWithOpponents:opponentsIDs withConferenceType:QBRTCConferenceTypeVideo];


下面是我的总代码:

    [QBRequest logInWithUserEmail:[userDefaults valueForKey:@"loginEmail"] password:[userDefaults valueForKey:@"loginPassword"] successBlock:^(QBResponse * _Nonnull response, QBUUser * _Nullable user) {

    NSError* error;
    QBUUser* theUser = [QBUUser user];
    theUser.ID = 00000;
    [QBChat.instance connectWithUser:theUser completion:^(NSError * _Nullable error) {
    }];

    [userDefaults setInteger:user.ID forKey:@"userId"];
    [userDefaults synchronize];
    [QBRTCClient initializeRTC];

    [QBRTCConfig setAnswerTimeInterval:60];
    [QBRTCConfig setDialingTimeInterval:10];
    [QBRTCConfig setDisconnectTimeInterval:30];//        [QBRTCConfig setDTLSEnabled:false];

    [[QBRTCMediaStreamConfiguration alloc] init];
    configurations.audioCodec = QBRTCAudioCodeciLBC;
    configurations.videoCodec = QBRTCVideoCodecH264;
    [QBRTCConfig setICEServers:[self quickbloxICE]];
    [QBRTCConfig setMediaStreamConfiguration:configurations];
    [QBRTCConfig setStatsReportTimeInterval:1.f];

    [QBRTCClient.instance addDelegate:self];
    NSArray* opponentsIDs = @[@000000];
    [QBSettings setAutoReconnectEnabled:YES];

    QBRTCSession* videoSession = [QBRTCClient.instance createNewSessionWithOpponents:opponentsIDs withConferenceType:QBRTCConferenceTypeVideo];

    CallViewController *callViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"CallViewController"];
    callViewController.session = videoSession;
    callViewController.initiator = user;
 [self presentViewController:callViewController animated:NO completion:nil];
} errorBlock:^(QBResponse * _Nonnull response) {

    NSLog(@"%@",[response.error description]);
}];

- (NSArray *)quickbloxICE {

NSString *password = @"baccb97ba2d92d71e26eb9886da5f1e0";
NSString *userName = @"quickblox";

QBRTCICEServer *server = [QBRTCICEServer serverWithURL:@"https://myserver:port" username:@"" password:@""];

QBRTCICEServer * stunServer = [QBRTCICEServer serverWithURL:@"stun:turn.quickblox.com"
                                                   username:@""
                                                   password:@""];

QBRTCICEServer * turnUDPServer = [QBRTCICEServer serverWithURL:@"turn:turn.quickblox.com:3478?transport=udp"
                                                      username:userName
                                                      password:password];

QBRTCICEServer * turnTCPServer = [QBRTCICEServer serverWithURL:@"turn:turn.quickblox.com:3478?transport=tcp"
                                                      username:userName
                                                      password:password];


return@[server,stunServer, turnTCPServer, turnUDPServer];}

最佳答案

连接到聊天后,请创建新的QBRTCSession实例:

[QBChat.instance connectWithUser:theUser completion:^(NSError * _Nullable error) {
    QBRTCSession* videoSession = [QBRTCClient.instance createNewSessionWithOpponents:opponentsIDs withConferenceType:QBRTCConferenceTypeVideo];
}];

关于ios - QBRTCSession总是为零,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34960607/

10-10 23:25