首页 > 解决方案 > 在 iOS 中注册房间服务器 Webrtc 失败

问题描述

我正在尝试webrtc在 ios 中使用视频和音频通话应用程序。我已经按照这里的教程

当我运行我的应用程序时,我在控制台中收到此错误。

无法注册房间服务器。结果:0。

我很困惑为什么它会显示,以及对手将如何在我的屏幕上显示。我也有疯狂的远程视图和本地视图。这是我的视频聊天代码。

/* Initializes the ARDAppClient with the delegate assignment */
self.client = [[ARDAppClient alloc] initWithDelegate:self];

/* RTCEAGLVideoViewDelegate provides notifications on video frame dimensions */
[self.remoteView setDelegate:self];
[self.localView setDelegate:self];

[self.client setServerHostUrl:@"https://apprtc.appspot.com"];
[self.client connectToRoomWithId:@"512415354" options:nil];

- (void)appClient:(ARDAppClient *)client didChangeState:(ARDAppClientState)state {
switch (state) {
    case kARDAppClientStateConnected:
        NSLog(@"Client connected.");
        break;
    case kARDAppClientStateConnecting:
        NSLog(@"Client connecting.");
        break;
    case kARDAppClientStateDisconnected:
        NSLog(@"Client disconnected.");
        [self remoteDisconnected];
        break;
}
}

- (void)appClient:(ARDAppClient *)client didReceiveLocalVideoTrack:(RTCVideoTrack *)localVideoTrack {
self.localVideoTrack = localVideoTrack;
[self.localVideoTrack addRenderer:self.localView];
}

- (void)appClient:(ARDAppClient *)client didReceiveRemoteVideoTrack:(RTCVideoTrack *)remoteVideoTrack {
self.remoteVideoTrack = remoteVideoTrack;
[self.remoteVideoTrack addRenderer:self.remoteView];
}

- (void)appClient:(ARDAppClient *)client didError:(NSError *)error {
/* Handle the error */
NSLog(@"Error");
}

- (void)videoView:(RTCEAGLVideoView *)videoView didChangeVideoSize:(CGSize)size {
/* resize self.localView or self.remoteView based on the size returned */
}

- (void)remoteDisconnected {
if (self.remoteVideoTrack) [self.remoteVideoTrack removeRenderer:self.remoteView];
self.remoteVideoTrack = nil;
[self.remoteView renderFrame:nil];
[self videoView:self.localView didChangeVideoSize:self.localVideoSize];

}

标签: iosswiftwebrtc

解决方案


推荐阅读