_artvcEgnine = [[ARTVCEngine alloc] init];
_artvcEgnine.uid = self.uid;
_artvcEgnine.delegate = self;
#pragma mark - ARTVCEngineDelegate
-(void)didReceiveRoomInfo:(ARTVCRoomInfomation*)roomInfo{
}
-(void)didReceiveLocalFeed:(ARTVCFeed*)localFeed{
self.feedForPreview = localFeed;
}
-(void)didEncounterError:(NSError *)error forFeed:(ARTVCFeed*)feed{
[self showToastWith:[NSString stringWithFormat:@"%@, Error:%@",feed,error] duration:2.0];
}
.....
设置服务端地址代码如下:
_artvcEgnine.roomServerCustomUrl = @"your room server url here";
...
设置视频编码分辨率代码如下:
//设置视频编码分辨率,默认是 ARTVCVideoProfileType_640x360_15Fps。
artvcEgnine.videoProfileType = ARTVCVideoProfileType_640x360_15Fps;
设置自动/手动推拉流开关代码如下,默认为自动推流/拉流。
_artvcEgnine.autoPublish = YES;
_artvcEgnine.autoSubScribe = YES;
ARTVCPublishConfig* config = [[ARTVCPublishConfig alloc] init];
config.videoEnable = YES;//默认是 YES
config.audioEnable = YES;//默认是 YES
config.videoProfile = _artvcEgnine.videoProfileType;
_artvcEgnine.autoPublishConfig = config;
ARTVCSubscribeOptions* options = [[ARTVCSubscribeOptions alloc] init];
_artvcEgnine.autoSubscribeOptions = options;
ARTVCPublishConfig* config = [[ARTVCPublishConfig alloc] init];
config.videoEnable = NO;
config.audioEnable = YES;//默认是 YES
_artvcEgnine.autoPublishConfig = config;
ARTVCSubscribeOptions* options = [[ARTVCSubscribeOptions alloc] init];
options.receiveVideo = NO;
_artvcEgnine.autoSubscribeOptions = options;
对于纯音频通话,跳过此步骤。
//默认使用前置摄像头,如果设置为 YES 则使用后置摄像头。
[_artvcEgnine startCameraPreviewUsingBackCamera:NO];
-(void)didReceiveLocalFeed:(ARTVCFeed*)localFeed forPublishConfig:(ARTVCPublishConfig*)publishConfig{
self.feedForPreview = localFeed;
}
-(void)didVideoRenderViewInitialized:(UIView*)renderView forFeed:(ARTVCFeed*)feed{
if([feed isEqual:self.feedForPreview]){
[self showToastWith:@"video preview view created" duration:1.0];
}else{
self.feedForRemote = feed;
};
//可触发 UI 布局,把 renderView add 到 view 层级中去
}
-(void)didFirstVideoFrameRendered:(UIView*)renderView forFeed:(ARTVCFeed*)feed{
}
ARTVCCreateRoomParams* params = [[ARTVCCreateRoomParams alloc] init];
params.uid = self.uid;
params.bizName = DEMO_BIZ;
params.subBiz = DEMO_SUBBIZ;
params.signature = DEMO_SIGNATURE;
[_artvcEgnine createRoom:params];
-(void)didReceiveRoomInfo:(ARTVCRoomInfomation*)roomInfo{
}
//error.code == ARTVCErrorCodeProtocolErrorCreateRoomFailed
-(void)didEncounterError:(NSError *)error forFeed:(ARTVCFeed*)feed{
}
-(void)didParticepantsEntered:(NSArray<ARTVCParticipantInfo*>*)participants{
}
ARTVCJoinRoomParams* params = [[ARTVCJoinRoomParams alloc] init];
params.uid = self.uid;
params.bizName = DEMO_BIZ;
params.subBiz = DEMO_SUBBIZ;
params.roomId = self.roomId;
params.signature = DEMO_SIGNATURE;
params.rtoken = self.rtoken;
[_artvcEgnine joinRoom:params];
-(void)didJoinroomSuccess{
}
-(void)didParticepantsEntered:(NSArray<ARTVCParticipantInfo*>*)participants{
}
//error.code == ARTVCErrorCodeProtocolErrorJoinRoomFailed
-(void)didEncounterError:(NSError *)error forFeed:(ARTVCFeed*)feed{
}
-(void)didParticepantsEntered:(NSArray<ARTVCParticipantInfo*>*)participants{
}
默认是自动推流与拉流。
-(void)didConnectionStatusChangedTo:(ARTVCConnectionStatus)status forFeed:(ARTVCFeed*)feed{
[self showToastWith:[NSString stringWithFormat:@"connection status:%d\nfeed:%@",status,feed] duration:1.0];
if((status == ARTVCConnectionStatusClosed) && [feed.uid isEqualToString:[self uid]]){
[self.artvcEgnine stopCameraPreview];//音视频通话下,停止摄像头。
[self.artvcEgnine leaveRoom];
}
}
枚举 | 值 | 解释 |
---|---|---|
ARTVCConnectionStatusConnecting | 200 | 开始发布和订阅时,首先回调该状态。 |
ARTVCConnectionStatusConnected | 202 | 发布/订阅成功时回调该状态。 |
ARTVCConnectionStatusDisConnected | 203 | 出现闪断,底层媒体流断开,底层会做自动重连。业务拿到这个回调仅做用户提示,不需要做 leaveRoom 处理。 |
ARTVCConnectionStatusFailed | 204 | 底层 ICE 失败无法继续,是一个终极错误。业务拿到这个回调可做停止摄像头 leaveRoom 处理。 |
ARTVCConnectionStatusClosed | 206 | 每个发布和订阅结束时,回调该状态。它是最后的状态,业务拿到这个回调可做停止摄像头 leaveRoom 处理。 |
-(void)didNewFeedAdded:(ARTVCFeed*)feed{
[self showToastWith:[NSString stringWithFormat:@"new feed published by others:%@",feed] duration:2.0];
}
-(void)didSubscriber:(NSString*)subscriber subscribedAFeed:(ARTVCFeed*)feed{
[self showToastWith:[NSString stringWithFormat:@"subscriber subscribed :%@",feed] duration:2.0];
}
[_artvcEgnine stopCameraPreview];
[_artvcEgnine leaveRoom];
[_artvcEgnine leaveRoom];
-(void)didParticepant:(ARTVCParticipantInfo*)participant leaveRoomWithReason:(ARTVCParticipantLeaveRoomReasonType)reason{
[self showToastWith:[NSString stringWithFormat:@"participant left:%@ reason:%d",participant,reason] duration:2.0];
}
-(void)didFeedRemoved:(ARTVCFeed*)feed{
[self showToastWith:[NSString stringWithFormat:@"feed unpublished by others:%@",feed] duration:2.0];
}
-(void)didSubscriber:(NSString*)subscriber unsubscribedAFeed:(ARTVCFeed*)feed{
[self showToastWith:[NSString stringWithFormat:@"subscriber unsubscribed :%@",feed] duration:2.0];
}
在文档使用中是否遇到以下问题
更多建议
匿名提交