Question about participants in azure.android.communication

yangjianyi 0 Reputation points
2023-01-28T08:11:04.23+00:00

I am new in communication services.

I am using azure.android.communication.calling.CallAgent to make a call. I don't know how to get the ID of the receiver.

Is this ID also a registered user of azure? And does this user also need to register the azure communication service?

The sample connection I use is:

https://learn.microsoft.com/en-us/azure/communication-services/quickstarts/voice-video-calling/get-started-with-video-calling?pivots=platform-android

User's image

Azure Communication Services
Azure Communication Services
An Azure communication platform for deploying applications across devices and platforms.
678 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Grmacjon-MSFT 15,856 Reputation points
    2023-02-02T01:30:58.2566667+00:00

    Hi yangjianyi

    Thanks for using Azure. Yes, both the caller and the receiver need to be registered with Azure Communication Services to establish a call. The receiver's ID is typically provided by the caller when initiating the call

    first step: Create an agent from the user access token as shown in the documentation you shared:

    You need a user token to create an authenticated call agent. Generally, this token is generated from a service with authentication specific to the application. For more information on user access tokens and how to create them please see User access tokens.

    For the quickstart, replace <User_Access_Token> with a user access token generated for your Azure Communication Services resource.

    /**
     * Create the call agent for placing calls
     */
    private void createAgent() {
        Context context = this.getApplicationContext();
        String userToken = "<USER_ACCESS_TOKEN>";
        try {
            CommunicationTokenCredential credential = new CommunicationTokenCredential(userToken);
            CallClient callClient = new CallClient();
            deviceManager = callClient.getDeviceManager(context).get();
            callAgent = callClient.createCallAgent(getApplicationContext(), credential).get(); 
        } catch (Exception ex) {
            Toast.makeText(context, "Failed to create call agent.", Toast.LENGTH_SHORT).show();
        }
    }
    
    

    second step: Start a video call by using the call agent

    You can place the call by using the call agent. All you need to do is provide a list of callee IDs and the call options.

    To place a call with video, you have to enumerate local cameras by using the deviceManager getCameras API. After you select a desired camera, use it to construct a LocalVideoStream instance. Then pass it into videoOptions as an item in the localVideoStream array to a call method. When the call connects, it automatically starts sending a video stream from the selected camera to the other participant.

    private void startCall() {
        Context context = this.getApplicationContext();
        EditText callIdView = findViewById(R.id.call_id);
        String callId = callIdView.getText().toString();
        ArrayList<CommunicationIdentifier> participants = new ArrayList<CommunicationIdentifier>();
        List<VideoDeviceInfo> cameras = deviceManager.getCameras();
    
    
        StartCallOptions options = new StartCallOptions();
        if(!cameras.isEmpty()) {
            currentCamera = getNextAvailableCamera(null);
            currentVideoStream = new LocalVideoStream(currentCamera, context);
            LocalVideoStream[] videoStreams = new LocalVideoStream[1];
            videoStreams[0] = currentVideoStream;
            VideoOptions videoOptions = new VideoOptions(videoStreams);
            options.setVideoOptions(videoOptions);
            showPreview(currentVideoStream);
        }
        participants.add(new CommunicationUserIdentifier(callId));
    
        call = callAgent.startCall(
                context,
                participants,
                options);
    
        //Subscribe to events on updates of call state and remote participants
        remoteParticipantUpdatedListener = this::handleRemoteParticipantsUpdate;
        onStateChangedListener = this::handleCallOnStateChanged;
        call.addOnRemoteParticipantsUpdatedListener(remoteParticipantUpdatedListener);
        call.addOnStateChangedListener(onStateChangedListener);
    }
    

    Hope that helps. Please let us know if you have further questions

    0 comments No comments