One-to-one video call (VOIP)

7.1 Get XHVoipManager instance and add the VOIP event protocol function.

[[XHClient sharedClient].voipManager addDelegate:self];

/*
*Receive a call
* @fromID the ID of who calls
*/
- (void)onCalling:(NSString *)fromID
{
}
/*
*The other side has hung up
* @fromID the other side ID
*/
- (void)onHangup:(NSString *)fromID
{
}
/*
*the other side has canceled the call
* @fromID the other side ID
*/
- (void)onCancled:(NSString *)fromID
{
}
/*
*The call has been refused
* @fromID the other side ID
*/
- (void)onRefused:(NSString *)fromID
{
}


/*
*the other side is busy now
* @fromID the other side ID
*/
- (void)onBusy:(NSString *)fromID
{
}
/*
*the other side has been connected now
* @fromID the other side ID
*/
- (void)onConnected:(NSString *)fromID
{
}
/*
*Connection error
* @error error information
*/
- (void)onError:(NSError *)error
{
}
/*
* Hang up successfully,and you can close the connection normally
* @code stop information
*/
-(void)onStop:(NSString *)code
{
}

/**
* Missed calls during a call
* @fromID the other side ID
*/
-(void)onMiss:(NSString *)fromID;

7.2 XHVoipManager API Description

/**
Set video parameters

@param config config parameters
*/
- (void)setVideoConfig:(XHVideoConfig *)config;

/**
Switch camera direction
@return Camera orientation after switching
*/
- (XHCameraDirection)switchCamera;

/*
*Set up your own and the other side's video view
@param selfPreview Preview
@param targetView target view
*/
- (void)setupView:(UIView *)selfPreview targetView:(UIView *)targetView;

// --- Caller ---

/**
Start a video call
@param toID The called user ID
@param completion Callback
*/
- (void)call:(NSString *)toID completion:(void(^)(NSError *error))completion;

/**
cancel the video call
@param toID the cancelling target
@param completion callback
*/
- (void)cancel:(NSString *)toID completion:(void(^)(NSError *error))completion;

// --- callee ---

/**
Accept a video call
@param fromID caller ID
@param completion callback
*/
- (void)accept:(NSString *)fromID completion:(void(^)(NSError *error))completion;

/**
Refuse a video call
@param fromID caller ID
@param completion callback
*/
- (void)refuse:(NSString *)fromID completion:(void(^)(NSError *error))completion;

// --- Both sides ---

/**
Hang up the video call
@param fromID the user ID who wants yo hange up
@param completion callback
*/
- (void)hangup:(NSString *)fromID completion:(void(^)(NSError *error))completion;

/**
* Switch audio
@param enable switch
*/
- (void)setAudioEnable:(BOOL) enable;

/**
* Switch video
@param enable switch
*/
- (void)setVideoEnable:(BOOL) enable;