Dial out with phone audio

The code on this page works with either the default UI or the custom UI.

In some scenarios, you may want to use phone audio instead of VoIP audio. Use the SDK to call your phone number or to get the dial-in phone numbers and dial into the meeting to connect to meeting audio. The ZoomSDKPhoneHelper interface handles most of this functionality.

Prerequisites

The meeting host account must be Pro or above, and must subscribe to the Audio Plan add-on.

Verify feature support

Before using any phone functionality, use the method IsSupportPhoneFeature() to check whether the meeting supports basic phone features such as joining the meeting by phone. Then use the IsDialoutSupported() method to check if the meeting supports call me or invite participants by phone functionality.

IMeetingService* meetingService = nullptr;
SDKError err = CreateMeetingService(&meetingService);
if (err == SDKERR_SUCCESS && meetingService) {
    IMeetingPhoneHelper* phoneHelper =
        meetingService->GetMeetingPhoneHelper();
    if (phoneHelper && phoneHelper->IsSupportPhoneFeature()) {
        // Phone audio is supported
        if (phoneHelper->IsDialoutSupported()) {
            // Support phone dial-out features
        }
    }
}

Call in to the meeting

Instead of directly dialing out to a number, you can display a phone number for the user to call. GetCurrentMeetingCallinNumber provides a list of call-in numbers for the current meeting.

IList<IMeetingCallInPhoneNumberInfo*>* callInNumberInfo =
    phoneHelper->GetCurrentMeetingCallinNumber();
if (callInNumberInfo) {
    // callInNumberInfo: A list of call-in numbers
}

After getting the call in numbers, iterate through them to access data related to each number.

for (int i = 0; i < callInNumberInfo->GetCount(); ++i) {
    IMeetingCallInPhoneNumberInfo* numberInfo =
        callInNumberInfo->GetItem(i);
    if (numberInfo) {
        numberInfo->GetCode();          // country code
        numberInfo->GetDisplayNumber(); // whole display phone number (country code + number)
        numberInfo->GetID();            // country id
        numberInfo->GetName();          // country name
        numberInfo->GetNumber();        // call-in number
        numberInfo->GetType();          // phone number's call type
    }
}

The phone number’s call types can be either toll or toll-free.

  • CALLINNUMTYPE_TOLL - toll numbers
  • CALLINNUMTYPE_TOLLFREE - toll-free number
  • CALLINNUMTYPE_NONE - none of the above

Start the phone call

To initiate phone audio, use the callMe method, providing the current user's phone number and country code, to call the current user's phone as the meeting audio.

// Start the phone call
phoneHelper->CallMe(L"COUNTRY_CODE", L"PHONE_NUMBER");

You can also add a phone-audio-only user by providing the country code, phone number, and username. The username can be any value, but should be something identifiable and related to the user since it's visible to other participants in the meeting.

// Invite a phone-audio-only user
phoneHelper->InviteCallOutUser(
    L"COUNTRY_CODE",
    L"PHONE_NUMBER",
    L"USERNAME"
);

End an in-session call by using the hangUp method.

// End an in-session call
phoneHelper->Hangup();

For Windows SDK, there is a call-out cancellation feature.

phoneHelper->CancelCallOut();

Get status updates

To get updates about the phone audio's call out status, conform your class to the IMeetingPhoneHelperEvent protocol and add the delegate.

class PhoneHelperEvent : public IMeetingPhoneHelperEvent
{
public:
    void onInviteCallOutUserStatus(PhoneStatus status, PhoneFailedReason reason) override
    {
    }
    void onCallMeStatus(PhoneStatus status, PhoneFailedReason reason) override
    {
    }
};
PhoneHelperEvent phoneHelperEvent;
if (phoneHelper) {
    phoneHelper->SetEvent(&phoneHelperEvent);
}

Within the listeners, you can get updates to PhoneStatus to know if a call is active and whether the request was successful.

  • PhoneStatus_Calling - The phone call is connecting.
  • PhoneStatus_Ringing - The phone call is connected and waiting for the other end to answer.
  • PhoneStatus_Accepted - The phone call has been answered.
  • PhoneStatus_Success - The phone call was successful.
  • PhoneStatus_Failed - The phone call has failed.
  • PhoneStatus_Canceling- The phone call is being cancelled.
  • PhoneStatus_Canceled - The phone call has been successfully cancelled.
  • PhoneStatus_Cancel_Failed - The SDK was unable to cancel the call.
  • PhoneStatus_Timeout - The call timed out.
  • PhoneStatus_None - Status unknown.

If a call fails, learn what caused the failure through the PhoneFailedReason enum.

  • PhoneFailedReason_Busy - The number dialed was busy.
  • PhoneFailedReason_Not_Available - The number dialed was disconnected or otherwise unable to connect.
  • PhoneFailedReason_User_Hangup - The phone number terminated the connection by hanging up.
  • PhoneFailedReason_No_Answer The phone call was not answered.
  • PhoneFailedReason_Block_No_Host - The call was not allowed because the host is not present.
  • PhoneFailedReason_Block_High_Rate - // The system blocks invite by phone due to the high cost.
  • PhoneFailedReason_Block_Too_Frequent - The rate limit for this feature has been hit. Please wait and try again later.
  • PhoneFailedReason_Other_Fail - The call failed for another reason.
  • PhoneFailedReason_None - The status was not related to a failure.

Access call data

After a call has started, access additional data about the active call.

  • GetCallMeStatus() - The status of the call started by the callMe method.
  • GetInviteCalloutUserStatus() - The status of the call started by the inviteCallOutUser method.
  • GetSupportCountryInfo() - A list of supported countries for the meeting. Each IMeetingPhoneSupportCountryInfo() object has 3 fields.
  • GetCountryCode() - The country code at the start of the phone number.
  • GetCountryID() - A unique identifier associated with the country.
  • GetCountryName() - A human-readable name of the country.
phoneHelper->GetCallMeStatus();
phoneHelper->GetInviteCalloutUserStatus();
IList<IMeetingPhoneSupportCountryInfo*>* phoneSupportCountryInfoList =
    phoneHelper->GetSupportCountryInfo();
if (phoneSupportCountryInfoList) {
    for (int i = 0; i < phoneSupportCountryInfoList->GetCount(); ++i) {
        IMeetingPhoneSupportCountryInfo* supportCountryInfo =
            phoneSupportCountryInfoList->GetItem(i);
        if (supportCountryInfo) {
            supportCountryInfo->GetCountryCode();
            supportCountryInfo->GetCountryID();
            supportCountryInfo->GetCountryName();
        }
    }
}

End the call and remove the listener

When you are no longer using phone audio, remove the listener.

phoneHelper->SetEvent(nullptr);