Implement your first group call
PlanetKit lets you integrate audio and video call functionality for 1-to-1 calls or group calls into your app. This guide shows how to get started with the implementation of a group audio call in your Windows app.
- For faster development, you can implement your app on top of our quick start.
- In this getting started guide, we provide an example of using MFC as the application framework.
Prerequisites
- Make sure that your system meets the system requirements.
- Create an API key. For more information, see Development environment.
- Implement app server code to generate an access token. For more information, see How to generate access tokens.
- Install Visual Studio 2022 or higher and the following components. (If Visual Studio is already installed, you can install components by navigating to Tools > Get Tools and Features.)
- Desktop development with C++ workload: On the Workloads tab, select Desktop development with C++.
- C++ MFC for latest v143 build tools (x86 & x64): On the Individual components tab, select C++ MFC for latest v143 build tools (x86 & x64).
- Download the PlanetKit SDK through PlanetKit Windows.
Create a project
To get started, open Visual Studio and create a new project as follows:
- From the main menu, select File > New > Project.
- In the project creation window, select a project template from the list. To create an MFC application, select MFC App.
- In Project name, enter your application project name. Click Create.
- In the MFC Application window, under Application Type, select Dialog based in the Application type dropdown, and click Finish.
Install the SDK
Install the SDK in your project as follows:
- Right-click the project name in Solution Explorer, and click Properties to configure the following project properties.
- Go to C/C++ > General > Additional Include Directories, click Edit..., and select the location of the
include
directory of the PlanetKit SDK. - Go to Linker > General > Additional Library Directories, click Edit..., and select the location of the
bin
directory of the PlanetKit SDK. - Go to Linker > Input > Additional Dependencies, click Edit..., and enter the name of the PlanetKit library depending on the platform used for the development.
- If the platform is x64, enter
PlanetKit64.lib
. - If the platform is Win32, enter
Planetkit.lib
.
- If the platform is x64, enter
- Go to C/C++ > General > Additional Include Directories, click Edit..., and select the location of the
- Click OK.
Initialize the SDK
To call the PlanetKit APIs, you must initialize PlanetKit first. Initialize PlanetKit using PlanetKitManager::Initialize()
with a Configuration
object.
After that, you must set the server URL (planet_base_url
) with PlanetKitManager::UpdateServerUrl()
. Make sure that you use an appropriate planet_base_url
depending on the development environment that you're using.
void YourApplication::InitializePlanetkit()
{
PlanetKit::ConfigurationPtr pConfiguration = PlanetKit::Configuration::Create(L"./", L"./");
PlanetKit::PlanetKitManager::Initialize(pConfiguration);
PlanetKit::PlanetKitManagerPtr pPlanetKitManager = PlanetKit::PlanetKitManager::GetInstance();
pPlanetKitManager->UpdateServerUrl(planet_base_url);
}
The PlanetKitManager::Initialize()
method must be called once initially in your app. For a dialog-based MFC application, it is recommended to initialize the SDK in the override function of OnInitDialog()
in your app.
Get the access token
In the client app, request your app server to generate an access token and get the generated access token.
You must get a new access token and use it each time you call PlanetKitManager::JoinConference()
.
Join a group audio call
To join a group audio call, implement callbacks of the IConferenceEvent
interface and call PlanetKitManager::JoinConference()
with a ConferenceParamPtr
object.
class YourConferenceEventListener : public IConferenceEvent {
public:
// This is called when the call is connected.
// Write your own code in function.
void OnConnected(PlanetKitConferencePtr pPlanetKitConference, ConferenceConnectedParamPtr pConnectedParam);
// This is called when the call is disconnected.
// Write your own code in function.
void OnDisconnected(PlanetKitConferencePtr pPlanetKitConference, ConferenceDisconnectedParamPtr pDisconnectedParam);
// This is called when the list of peers is updated.
// Write your own code here.
void OnPeerListUpdate(PlanetKitConferencePtr pPlanetKitConference, ConferencePeerUpdateParamPtr pParam)
...
//
// Also, you should implement other override functions.
//
}
class YourApplication {
private :
// Prepare callback event listener instance.
YourConferenceEventListener m_yourConferenceEventListener;
// Prepare PlanetKitConference instance.
PlanetKit::PlanetKitConferencePtr m_pConference;
};
void YourApplication::JoinConferenceExample(const std::wstring strRoomId, const std::wstring strAccessToken) {
// Prepare local user's ID.
std::wstring strUserId = "local user's user id";
std::wstring strServiceId = "local user's service id";
// Create the UserId object.
PlanetKit::UserIdPtr pUserId = PlanetKit::UserId::Create(strUserId.c_str(), strServiceId.c_str());
// Create MakeCallParam with Create API.
PlanetKit::ConferenceParamPtr pConferenceParam = PlanetKit::ConferenceParam::CreateWithAccessToken(
pUserId,
strRoomId.c_str(),
strServiceId.c_str(),
strAccessToken.c_str()
);
// Set required parameter.
pConferenceParam->SetConferenceEvent(&m_yourConferenceEventListener);
// Now you have to create a PlanetKit::PlanetKitConference type object
// through the PlanetKit::PlanetKitManager::JoinConference() function.
// Please note that the PlanetKit::PlanetKitConference type object is the main call instance
// that controls call-related functions after the call setup completion.
PlanetKit::PlanetKitManagerPtr pPlanetKitManager = PlanetKit::PlanetKitManager::GetInstance();
PlanetKit::SStartResult sStartResult = pPlanetKitManager->JoinConference(pConferenceParam, &m_pConference);
if (sStartResult.bSuccess == false) {
// Handle an error by referring to sStartResult.reason
}
}
Users need the room ID to enter the room from the client app, so the room ID must be shared with other users through an application-defined communication channel.
Next steps
See the following documents to learn more about the various features provided by PlanetKit and how to use each feature.
- Call flow: Familiarize yourself with the call flow for each call type.
- Subgroup: Read the guides on subgroups, which allows you to implement advanced features such as multi-subgroup rooms or translation rooms.
- Extended functions: Explore the guides on extended functions, such as screen share and data sessions.
- Code examples: See the code examples that you can use for implementing your own app.
- Reference: Refer to the API reference, API changelog, and release notes.