# Call Management

# Call mute

The JCSDK provides two muting methods for muting speakers and muting microphones. Mute speakers will not hear each other, and muted microphones will not hear the other person's voice.

# Mute the speaker

Follow these steps to implement the mute speaker feature:

  1. Get the speaker mute status through the speakerMute property in the JCCallItem object. Returns true to mute and false to not mute.
  2. Call the muteSpeaker method in JCCall to enable/unmute the speaker.

Sample code:

JCCallItem *item = [call getActiveCallItem];
if(item != nil){
    if(item.speakerMute){
        // Unmute the speaker
        [call muteSpeaker:item mute:false];
    }else{
        // Turn on speaker mute
        [call muteSpeaker:item mute:true];
    }
}

# Mute the microphone

Follow these steps to implement the mute microphone feature:

  1. Get the microphone mute status through the microphoneMute property in the JCCallItem object. Returns true to mute and false to not mute.
  2. Call the muteMicrophone method in JCCall to turn on/off the microphone mute function.

Sample code:

JCCallItem *item = [call getActiveCallItem];
if(item != nil){
    if(item.microphoneMute){
        // nmute the microphone
        [call muteMicrophone:item mute:false];
    }else{
        // Turn on microphone mute
        [call muteMicrophone:item mute:true];
    }
}

# Call recording

You can record during a call. Turn on/off recording depends on the current recording status. If recording is in progress or the call is hanged or suspended, audio recording cannot be performed. The recording status can be obtained through the JCCallItem (opens new window) object.

Turn on/off the recording interface as follows:

/**
 * Voice call recording, decide to turn on or off recording through the audioRecord state in the JCCallItem object
 *
 * @param item              JCCallItem object
 * @param enable            turn on/off recording
 * @param filePath          recording file path
 * @return                  return true to indicate the normal execution of the call flow, and false to indicate call failed
 */
-(bool)audioRecord:(JCCallItem* __nonnull)item enable:(bool)enable filePath:(NSString* __nullable)filePath;

Sample code:

// Voice recording
- (void)audioRecord:(JCCallItem* __nonnull)item {
    if (item.audioRecord) { // Recording
        //Process the end of recording
        [call audioRecord:item enable:false filePath:@"your filePath"];
            ...
    } else { // Not recording
        // Create a recording file
        NSString *filePath; // Absolute path of the recording file, the SDK will automatically create the recording file
        if (filePath != nil) {
            // Start recording
            [call audioRecord:item enable:true filePath:filePath];
            ...
        } else {
            // Handling recording failure
        }
    }
}

When the recording is turned on or off, the recording status will be changed and reported through the onCallItemUpdate callback:

/**
 *  @brief The callback triggers when updating call status (When the upper layer receives this callback, you can obtain all the information and status of the call according to the JCCallItem object, thereby updating the call-related UI)
 *  @param item JCCallItem object
 *  @param changeParam update symbol class
 */
-(void)onCallItemUpdate:(JCCallItem* __nonnull)item changeParam:(JCCallChangeParam * __nullable)changeParam;

# Turn on/off call hold

Call the following method to maintain call hold or release call hold for the call object (this operation cannot be performed when the call object is held). Turn on/off call hold needs to be based on the call hold of the JCCallItem object (hold (opens new window))

/**
 *  @brief                  Call hold, decide to turn on/off call hold through the call hold state in the JCCallItem object
 *  @param item             JCCallItem object
 *  @return                 return true to indicate the normal execution of the call flow, and false to indicate call failed
 */
-(bool)hold:(JCCallItem* __nonnull)item;

# Switch active call

Call the following method to change the call on hold to the active call:

/**
 *  @brief Switch active call
 *  @param item object needs to become active JCCallItem object
 *  @return return true to indicate the normal execution of the call flow, and false to indicate call failed
 */
-(bool)becomeActive:(JCCallItem* __nonnull)item;

# Send messages during a call

Call the following interface to realize the function of sending messages during a call:

/**
 *  @brief Send data through the channel established by the call
 *  @param item JCCallItem object that needs to send data
 *  @param type the user can customize text message types, like text, xml, etc.
 *  @param content message content
 *  @return return true to indicate the normal execution of the call flow, and false to indicate call failed
 */
-(bool)sendMessage:(JCCallItem * __nonnull)item type:(NSString * __nonnull)type content:(NSString * __nonnull)content;

When messages are received during a call, an onMessageReceive callback is received:

/**
 *  @brief the callback triggers when receiving messages during a call
 *  @param item JCCallItem object
 *  @param type message type
 *  @param content message content
 */
-(void)onMessageReceive:(JCCallItem * __nonnull)item type:(NSString * __nonnull)type content:(NSString * __nonnull)content;

Sample code:

[call sendMessage:item type:@"text" content:@"message content"];

TIP

Sending picture-type messages in calls is not recommended

During a call, if the call status changes, like turning on/off mute, turning on/off call hold, switching active status, network change, etc., the callback of updating call status will be triggered:

/**
 *  @brief the callback triggers when updating call status (When the upper layer receives this callback, you can obtain all the information and status of the call according to the JCCallItem object, thereby updating the call-related UI)
 *  @param item JCCallItem object
 *  @param changeParam update symbol class
 */
-(void)onCallItemUpdate:(JCCallItem* __nonnull)item changeParam:(JCCallChangeParam * __nullable)changeParam;

For the description of JCCallChangeParam, please refer to the JCCallItem.h file.

TIP

The mute state, call hold state, and active state can be obtained through the JCCallItem object.

Sample code:

-(void)onCallItemUpdate:(JCCallItem* __nonnull)item changeParam:(JCCallChangeParam * __nullable)changeParam {
    JCCallItem* callItem = item;
    if (changeParam.mute) { // Turn on mute
        ...
    } else if (changeParam.state) { // hang up
        ...
    } else if (changeParam.held) { // suspended
        ...
    } else if (changeParam.active) { // active state
        ...
    } else if (changeParam.netStatus) { // normal network status
        ...
    }
    ...
}
最后更新时间: 1/17/2023, 5:17:17 PM