### Start Audio Mixing Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/RtcEngine/startAudioMixing Starts playing a music file on the client. This method supports local playback or publishing the music to remote users. It handles various file path formats and provides options for looping and starting playback at a specific position. ```APIDOC ## POST /startAudioMixing ### Description Starts playing a music file on the client. This method can be used for local playback only or for publishing the music to remote users. It supports various audio file formats and provides flexibility in handling file paths, looping, and playback position. ### Method POST ### Endpoint /startAudioMixing ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **filePath** (String) - Required - The path to the music file. Supports URL addresses, absolute paths, or paths starting with /assets/ on Android. For iOS/macOS and Windows, it accepts absolute paths or URL addresses. - **loopback** (Boolean) - Required - Determines if the music is played only on the local client (true) or published to remote clients (false). - **cycle** (Integer) - Required - The number of times the music file should play. Use -1 for infinite playback. - **startPos** (Integer) - Optional - The playback position in milliseconds. Defaults to 0. ### Request Example ```json { "filePath": "content://com.android.providers.media.documents/document/audio%3A14441", "loopback": false, "cycle": -1, "startPos": 5000 } ``` ### Response #### Success Response (200) - **(void)** - No return value upon successful execution. #### Response Example None (Method returns void on success) #### Error Handling - **AgoraRtcException** - Thrown when the method fails, e.g., cannot open the file, unsupported format, or inaccessible URL. ``` -------------------------------- ### Configure App Settings for Agora Chat CallKit Example Source: https://pub.dev/documentation/agora_chat_callkit/latest/index This Dart configuration class, `Config`, is used in the example project for Agora Chat CallKit. It holds static string variables for essential API keys and server domains required to initialize and authenticate the application with Agora services. ```dart class Config { static String agoraAppId = ""; static String appkey = ""; static String appServerDomain = ""; static String appServerRegister = ''; static String appServerGetAgoraToken = ''; static String appServerTokenURL = ""; static String appServerUserMapperURL = ""; } ``` -------------------------------- ### Start Screen Capture by Source Type Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/RtcEngine/startScreenCaptureBySourceType Starts screen capture from the specified video source. This method is applicable to macOS and Windows platforms only. It requires a video source type and a screen capture configuration. ```APIDOC ## POST /websites/pub_dev_agora_chat_callkit/startScreenCaptureBySourceType ### Description Starts screen capture from the specified video source. This method applies to the macOS and Windows only. ### Method POST ### Endpoint /websites/pub_dev_agora_chat_callkit/startScreenCaptureBySourceType ### Parameters #### Query Parameters - **sourceType** (VideoSourceType) - Required - The type of the video source. On the macOS platform, this parameter can only be set to videoSourceScreen (2). - **config** (ScreenCaptureConfiguration) - Required - The configuration of the captured screen. ### Request Example ```json { "sourceType": "videoSourceScreen", "config": { "dimensions": {"width": 1920, "height": 1080}, "frameRate": 30, "bitrate": 2000, "priority": "High" } } ``` ### Response #### Success Response (200) - **message** (string) - Indicates the screen capture has started successfully. #### Response Example ```json { "message": "Screen capture started successfully." } ``` #### Error Response (400) - **error** (string) - Description of the error (e.g., "Invalid sourceType", "Invalid config"). #### Error Response Example ```json { "error": "Invalid sourceType specified for macOS platform." } ``` ``` -------------------------------- ### ChatCallKitObserver Callbacks Source: https://pub.dev/documentation/agora_chat_callkit/latest/index This section details the callback events provided by the ChatCallKitObserver for handling real-time call events. ```APIDOC ## ChatCallKitObserver Callbacks ### Description Implement the `ChatCallKitObserver` to receive and handle various events related to chat and voice calls managed by the Agora CallKit. ### Method Observers are added via `ChatCallKitManager.addObserver(this)` and removed via `ChatCallKitManager.removeObserver(this)`. ### Endpoints N/A (This is an observer pattern, not a direct API endpoint) ### Callback Events **onError** * **Description**: Callback when the call fails. For example, the callee fails to join the channel or the call invitation fails to be sent. The operator receives the event. This event is applicable to one-to-one calls and group calls. * **Parameters**: `error` (ChatCallKitError) - Details of the error. **onCallEnd** * **Description**: Callback when the call ends. This event is applicable only to one-to-one calls. Both the caller and callee receive this event. * **Parameters**: * `callId` (String?) - The ID of the call. * `reason` (ChatCallKitCallEndReason) - The reason for the call ending. **onReceiveCall** * **Description**: Callback when a call invitation is received. This event is applicable to both one-to-one calls and group calls. The callee receives this event. * **Parameters**: * `userId` (String) - The Agora Chat user ID of the caller. * `callId` (String) - The ID of the current call. * `callType` (ChatCallKitCallType) - The type of the current call. * `ext` (Map?) - Optional extension data. **onJoinedChannel** * **Description**: Callback when the current user successfully joins the call channel. This event is applicable only to group calls. All other users in the call receive this event. * **Parameters**: * `channel` (String) - The channel ID that the user joined. **onUserLeaved** * **Description**: Callback when an active user leaves a call. This event is applicable only to group calls. All other users in the call receive this event. `agoraUid` is the Agora RTC user ID and `userId` is the Agora Chat user ID. * **Parameters**: * `agoraUid` (int) - The Agora RTC user ID of the leaving user. * `userId` (String?) - The Agora Chat user ID of the leaving user. **onUserJoined** * **Description**: Callback when a user joins a call. The user that joins the call receives this event. This event is applicable only to group calls. `agoraUid` is the Agora RTC user ID and `userId` is the Agora Chat user ID. * **Parameters**: * `agoraUid` (int) - The Agora RTC user ID of the joining user. * `userId` (String?) - The Agora Chat user ID of the joining user. **onUserMuteAudio** * **Description**: Callback when the peer user's microphone status changes. This event is applicable to both one-to-one calls and group calls. `agoraUid` is the Agora RTC user ID of the peer user and `muted` indicates whether the peer microphone is muted. * **Parameters**: * `agoraUid` (int) - The Agora RTC user ID of the peer user. * `muted` (bool) - True if the peer's microphone is muted, false otherwise. **onUserMuteVideo** * **Description**: Callback when the peer user's camera status changes. This event is applicable to both one-to-one calls and group calls. `agoraUid` is the Agora RTC user ID of the peer user and `muted` indicates whether the peer camera is disabled. * **Parameters**: * `agoraUid` (int) - The Agora RTC user ID of the peer user. * `muted` (bool) - True if the peer's camera is disabled, false otherwise. **onUserRemoved** * **Description**: Callback when a user is removed from the call (e.g., rejects call or times out). * **Parameters**: * `callId` (String) - The ID of the call. * `userId` (String) - The ID of the removed user. * `reason` (ChatCallKitCallEndReason) - The reason for removal. **onAnswer** * **Description**: Callback when a call is answered. This event is applicable only to one-to-one calls. Both the caller and callee receive this event. * **Parameters**: * `callId` (String) - The ID of the answered call. ### Request Example N/A ### Response N/A (Callback events) ``` -------------------------------- ### Start Group Call with ChatCallKit Source: https://pub.dev/documentation/agora_chat_callkit/latest/index Initiates a group call by inviting a list of users using ChatCallKitManager. Requires prior initialization of Agora RTC. Returns a callId for managing the call. Handles potential ChatCallKitError exceptions. ```dart await ChatCallKitManager.initRTC(); try { // userList: The Agora Chat user IDs of the callees. String callId = await ChatCallKitManager.startInviteUsers(userList); } on ChatCallKitError catch (e) { ... ``` -------------------------------- ### Start One-to-One Call with ChatCallKit Source: https://pub.dev/documentation/agora_chat_callkit/latest/index Initiates a one-to-one audio call using ChatCallKitManager. Requires prior initialization of Agora RTC. Returns a callId for managing the call. Handles potential ChatCallKitError exceptions. ```dart await ChatCallKitManager.initRTC(); try { // userId: The Agora Chat user ID of the callee. // type: The call type, which can be `ChatCallKitCallType.audio_1v1` or `ChatCallKitCallType.video_1v1`. String callId = await ChatCallKitManager.startSingleCall( userId, type: ChatCallKitCallType.audio_1v1, ); } on ChatCallKitError catch (e) { ... } ``` -------------------------------- ### Start Local Video Preview (Dart) Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/RtcEngine/startPreview Enables the local video preview and specifies the video source for the preview. This method is used to start local video preview and specify the video source that appears in the preview screen. It returns void on success or throws an AgoraRtcException on failure. ```dart Future startPreview({ VideoSourceType sourceType = VideoSourceType.videoSourceCameraPrimary }); ``` -------------------------------- ### Start Audio Device Loopback Test (Dart) Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/AudioDeviceManager/startAudioDeviceLoopbackTest Starts an audio device loopback test to verify local audio capture and playback devices. The SDK triggers `onAudioVolumeIndication` callbacks at the specified interval. This method is intended for Windows and macOS and must be called by the host. ```dart Future startAudioDeviceLoopbackTest(int indicationInterval) ``` -------------------------------- ### Get Screen Capture Sources Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/RtcEngine-class Gets a list of shareable screen and window sources for screen sharing. Requires thumbnail and icon sizes, and a boolean indicating whether to include the screen itself. ```dart Future> getScreenCaptureSources({required SIZE thumbSize, required SIZE iconSize, required bool includeScreen}) ``` -------------------------------- ### Start Audio Recording with Configuration (Dart) Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/RtcEngine/startAudioRecording Initiates audio recording on the client with specified configurations. Supports WAV and AAC formats, with automatic stopping when the user leaves the channel. Throws AgoraRtcException on failure. ```Dart Future startAudioRecording(AudioRecordingConfiguration config); ``` -------------------------------- ### Start Screen Capture by Source Type (Dart) Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/RtcEngine/startScreenCaptureBySourceType Initiates screen capture using the `startScreenCaptureBySourceType` method. This method is platform-specific to macOS and Windows. It requires a `VideoSourceType` and a `ScreenCaptureConfiguration` object. The method returns void on success or throws an `AgoraRtcException` on failure. ```dart Future startScreenCaptureBySourceType({ required VideoSourceType sourceType, required ScreenCaptureConfiguration config, }); ``` -------------------------------- ### Implement setupView for Video View Configuration Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/VideoViewController/setupView The setupView method is an override function responsible for configuring the video view using provided platform view ID and native view pointer. It interacts with the RTC engine to set up the video view and handles platform view referencing. Dependencies include the RTC engine instance and potentially canvas and connection objects. ```dart @override Future setupView(int platformViewId, int nativeViewPtr) async { _platformViewId = platformViewId; _viewHandle = nativeViewPtr; if (_platformViewId != kInvalidPlatformViewId) { await addPlatformRenderRef(_platformViewId); } await rtcEngine.globalVideoViewController ?.setupVideoView(nativeViewPtr, canvas, connection: connection); } ``` -------------------------------- ### Setup Video View Rendering with setupView Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/VideoViewController-class This method sets up the video view rendering using platform view ID and a native view pointer. It is typically used after initializing the render to associate it with a specific native view. ```dart await videoViewController.setupView(platformViewId, nativeViewPtr); ``` -------------------------------- ### Start Camera Capture (Dart) Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/RtcEngine/startCameraCapture Initiates video capture from specified camera sources. Requires `VideoSourceType` and `CameraCapturerConfiguration`. iOS users must enable multi-camera capture beforehand. The method returns `void` on success or throws an `AgoraRtcException` on failure. ```dart Future startCameraCapture({ required VideoSourceType sourceType, required CameraCapturerConfiguration config, }); ``` -------------------------------- ### Control Speaker with ChatCallKit Source: https://pub.dev/documentation/agora_chat_callkit/latest/index Toggles the speakerphone on or off during a call using `speakerOn` and `speakerOff` methods. ```dart await ChatCallKitManager.speakerOn(); await ChatCallKitManager.speakerOff(); ``` -------------------------------- ### Start Screen Capture by Source Type - Dart Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/RtcEngine-class Starts screen capture using a specified video source type. This function requires a VideoSourceType and a ScreenCaptureConfiguration object. Returns a Future. ```Dart startScreenCaptureBySourceType({required VideoSourceType sourceType, required ScreenCaptureConfiguration config}) → Future Starts screen capture from the specified video source. ``` -------------------------------- ### Initialize MediaPlayer Instance Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/MediaPlayer-class Creates a new instance of the MediaPlayer. This is the entry point for all media playback operations. No specific dependencies are mentioned, and the constructor returns a MediaPlayer object. ```dart final player = MediaPlayer.new(); ``` -------------------------------- ### Audio Device Loopback Test Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/AudioDeviceManager/startAudioDeviceLoopbackTest Starts an audio device loopback test to verify local audio capture and playback devices. This method is supported only on Windows and macOS and can be called by the host either before or after joining a channel. ```APIDOC ## POST /startAudioDeviceLoopbackTest ### Description Starts an audio device loopback test. This method tests whether the local audio capture device and playback device are working properly. The SDK triggers two independent onAudioVolumeIndication callbacks at the time interval set in this method, which reports the volume information of the capture device (uid = 0) and the volume information of the playback device (uid = 1) respectively. This method is for Windows and macOS only. You can call this method either before or after joining a channel. This method only takes effect when called by the host. This method tests local audio devices and does not report the network conditions. When you finished testing, call stopAudioDeviceLoopbackTest to stop the audio device loopback test. ### Method POST ### Endpoint /startAudioDeviceLoopbackTest ### Parameters #### Query Parameters - **indicationInterval** (int) - Required - The time interval (ms) at which the SDK triggers the onAudioVolumeIndication callback. Agora recommends setting a value greater than 200 ms. This value must not be less than 10 ms; otherwise, you can not receive the onAudioVolumeIndication callback. ### Request Body (No request body specified for this method) ### Request Example (No request example provided) ### Response #### Success Response (200) - **None** - This method does not return a value upon success. #### Response Example (No response example provided) #### Error Handling - **AgoraRtcException**: Thrown when the method call fails. ``` -------------------------------- ### Setup Local Video Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/RtcEngine/setupLocalVideo Initializes the local video view, binding the local video stream to a video view and setting rendering and mirror modes. ```APIDOC ## setupLocalVideo ### Description Initializes the local video view. This method initializes the video view of a local stream on the local device. It only affects the video seen by the local user and does not impact the publishing of the local video. Call this method to bind the local video stream to a video view (view) and to set the rendering and mirror modes of the video view. The binding remains valid after leaving the channel. To stop rendering or unbind the local video from the view, set view as NULL. In Flutter, you don't need to call this method. Use AgoraVideoView instead to render local and remote views. To update only the rendering or mirror mode of the local video view during a call, call setLocalRenderMode instead. ### Method Future ### Endpoint N/A (This is a client-side SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **canvas** (VideoCanvas) - Required - The local video view and settings. See VideoCanvas. ### Request Example ```dart // Example for Dart/Flutter await agoraRtcEngine.setupLocalVideo(VideoCanvas(uid: 0)); // For local user ``` ### Response #### Success Response (void) No return value on success. #### Response Example N/A ``` -------------------------------- ### Get Local Video Preview Widget in Agora Chat CallKit Source: https://pub.dev/documentation/agora_chat_callkit/latest/index Obtain the local camera preview using `ChatCallKitManager.getLocalVideoView()`. This method returns a `Widget?` which can be displayed to show the user their own video feed. It's applicable for both one-to-one and group calls. ```dart Widget? localPreviewWidget = ChatCallKitManager.getLocalVideoView(); ``` -------------------------------- ### GET /audio/mixing/position Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/RtcEngine/getAudioMixingCurrentPosition Retrieves the playback position (in milliseconds) of the currently playing audio file used for mixing. This method should be called after starting audio mixing and receiving the 'audioMixingStatePlaying' callback. A minimum interval of 500ms is recommended between successive calls. ```APIDOC ## GET /audio/mixing/position ### Description Retrieves the playback position (ms) of the audio mixing. This method should be called after `startAudioMixing` and receiving the `onAudioMixingStateChanged` (audioMixingStatePlaying) callback. For repeated calls, ensure a time interval of at least 500 ms between them. ### Method GET ### Endpoint /audio/mixing/position ### Parameters ### Request Body None ### Request Example None ### Response #### Success Response (200) - **position** (integer) - The current playback position (ms) of the audio mixing. Returns 0 if the audio has not started playing. Returns a negative value if the call fails. #### Response Example ```json { "position": 12345 } ``` ``` -------------------------------- ### MediaPlayer Constructors and Operators Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/MediaPlayer-class Information on how to construct a MediaPlayer instance and the equality operator. ```APIDOC ## MediaPlayer Constructors and Operators ### Description Details the constructor for creating a MediaPlayer instance and the equality operator for comparison. ### Constructors - **MediaPlayer.new()**: Creates a new instance of the MediaPlayer class. ### Operators - **operator ==(Object other) → bool**: The equality operator, used to compare this object with another. ``` -------------------------------- ### Initialize ChatGroupManager Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/ChatGroupManager-class Creates a new instance of the ChatGroupManager. This is the primary way to start managing chat groups. No specific dependencies are mentioned, and it takes no arguments. ```dart ChatGroupManager.new() ``` -------------------------------- ### Event Listener Management Source: https://pub.dev/documentation/agora_chat_callkit/latest/index Methods for managing event listeners, including adding and removing observers to handle call-related events. ```APIDOC ## POST ChatCallKitManager.removeObserver ### Description Removes a previously registered observer to stop receiving callback events. ### Method POST ### Endpoint ChatCallKitManager.removeObserver(this) ### Parameters None ### Request Example ```dart ChatCallKitManager.removeObserver(this); ``` ### Response None ``` -------------------------------- ### ChatDeviceInfo Class Constructor and Properties Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/ChatDeviceInfo-class Demonstrates the constructor and properties of the ChatDeviceInfo class. It includes how to create an instance from a Map and access device-related information like deviceName, deviceUUID, and resource. ```dart class ChatDeviceInfo { final String? deviceName; final String? deviceUUID; final String? resource; ChatDeviceInfo.fromJson(Map map) : deviceName = map['deviceName'], deviceUUID = map['deviceUUID'], resource = map['resource']; // ... other methods and operators } ``` -------------------------------- ### Video View Management API Source: https://pub.dev/documentation/agora_chat_callkit/latest/index APIs to retrieve local and remote video preview widgets for display within the application. ```APIDOC ## GET ChatCallKitManager.getLocalVideoView ### Description Retrieves the widget for the local camera preview. ### Method GET ### Endpoint ChatCallKitManager.getLocalVideoView() ### Parameters None ### Request Example ```dart Widget? localPreviewWidget = ChatCallKitManager.getLocalVideoView(); ``` ### Response - **localPreviewWidget** (Widget?) - The local video preview widget, or null if not available. ## GET ChatCallKitManager.getRemoteVideoView ### Description Retrieves the widget for a remote user's video stream. ### Method GET ### Endpoint ChatCallKitManager.getRemoteVideoView(agoraUid) ### Parameters #### Path Parameters - **agoraUid** (String) - Required - The Agora RTF user ID of the user whose video view is requested. ### Request Example ```dart // agoraUid: The Agora RTF user ID of a user in the call. Widget? remoteVideoWidget = ChatCallKitManager.getRemoteVideoView(agoraUid); ``` ### Response - **remoteVideoWidget** (Widget?) - The remote video widget, or null if not available. ``` -------------------------------- ### Get Remote Video View Widget in Agora Chat CallKit Source: https://pub.dev/documentation/agora_chat_callkit/latest/index Retrieve the video widget for a specific remote user with `ChatCallKitManager.getRemoteVideoView(agoraUid)`. The `agoraUid` parameter is the Agora RTF user ID of the participant whose video feed you want to display. This is used in one-to-one and group calls. ```dart // agoraUid: The Agora RTF user ID of a user in the call. Widget? remoteVideoWidget = ChatCallKitManager.getRemoteVideoView(agoraUid); ``` -------------------------------- ### Start Audio Mixing (Dart) Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/RtcEngine/startAudioMixing Initiates playback of a music file. Supports local-only or remote playback, infinite looping, and specifies the starting playback position. It requires a valid file path, loopback configuration, and playback cycle count. The SDK reports an error if the file cannot be opened or is in an unsupported format. ```dart Future startAudioMixing({ required String filePath, required bool loopback, required int cycle, int startPos = 0, }); ``` -------------------------------- ### Add Dependencies for Agora Chat CallKit Source: https://pub.dev/documentation/agora_chat_callkit/latest/index Add the agora_chat_sdk and agora_rtc_engine dependencies to your pubspec.yaml file to utilize Agora Chat and RTC functionalities. ```yaml agora_chat_sdk: 1.2.0 agora_rtc_engine: 6.2.6 ``` -------------------------------- ### Start Inviting Users to a Call (Dart) Source: https://pub.dev/documentation/agora_chat_callkit/latest/inherited_chat_callkit_chat_manager/AgoraChatManager/startInviteUsers This Dart method initiates a call and invites a list of users. It checks for existing calls, sends invitation messages, and sets up timers to handle user responses or timeouts. Dependencies include utility functions for message sending and call management within the ChatCallKit framework. ```dart Future startInviteUsers( List userIds, Map? ext, ) async { if (userIds.isEmpty) { throw ChatCallKitError.process( ChatCallKitErrorProcessCode.invalidParam, 'Require remote userId'); } if (model.curCall != null) { for (var element in userIds) { if (model.curCall!.allUserAccounts.values.contains(element)) { continue; } sendInviteMsgToCallee( element, model.curCall!.callType, model.curCall!.callId, model.curCall!.channel, ext, ); callTimerDic[element] = Timer.periodic(timeoutDuration, (timer) { timer.cancel(); callTimerDic.remove(element); if (model.curCall != null) { sendCancelCallMsgToCallee(element, model.curCall!.callId); removeUser(element, ChatCallKitCallEndReason.remoteNoResponse); } }); } } else { model.curCall = ChatCallKitCall( callId: ChatCallKitTools.randomStr, callType: ChatCallKitCallType.multi, isCaller: true, channel: ChatCallKitTools.randomStr, ext: ext, ); model.state = ChatCallKitCallState.answering; for (var element in userIds) { sendInviteMsgToCallee( element, model.curCall!.callType, model.curCall!.callId, model.curCall!.channel, ext, ); callTimerDic[element] = Timer.periodic(timeoutDuration, (timer) { timer.cancel(); callTimerDic.remove(element); if (model.curCall != null) { sendCancelCallMsgToCallee(element, model.curCall!.callId); removeUser(element, ChatCallKitCallEndReason.remoteNoResponse); } }); } } return model.curCall!.callId; } ``` -------------------------------- ### Camera Control API Source: https://pub.dev/documentation/agora_chat_callkit/latest/index Methods to turn the camera on/off and switch between front/rear cameras during a call. Changes are reflected for other participants and trigger an observer event. ```APIDOC ## POST ChatCallKitManager.cameraOn ### Description Turns on the camera for the local user. ### Method POST ### Endpoint ChatCallKitManager.cameraOn() ### Parameters None ### Request Example ```dart await ChatCallKitManager.cameraOn(); ``` ### Response None ## POST ChatCallKitManager.cameraOff ### Description Turns off the camera for the local user. ### Method POST ### Endpoint ChatCallKitManager.cameraOff() ### Parameters None ### Request Example ```dart await ChatCallKitManager.cameraOff(); ``` ### Response None ## POST ChatCallKitManager.switchCamera ### Description Switches between the front and rear cameras. ### Method POST ### Endpoint ChatCallKitManager.switchCamera() ### Parameters None ### Request Example ```dart await ChatCallKitManager.switchCamera(); ``` ### Response None ``` -------------------------------- ### startCameraCapture Method Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/RtcEngine/startCameraCapture Initiates video capture from specified camera sources with provided configuration. This method is crucial for enabling video in calls. ```APIDOC ## POST /startCameraCapture ### Description Starts camera capture. You can call this method to start capturing video from one or more cameras by specifying sourceType. On the iOS platform, if you want to enable multi-camera capture, you need to call enableMultiCamera and set enabled to true before calling this method. ### Method POST ### Endpoint /startCameraCapture ### Parameters #### Request Body - **sourceType** (VideoSourceType) - Required - The type of the video source. On iOS devices, you can capture video from up to 2 cameras. On Android devices, you can capture video from up to 4 cameras. On desktop platforms, you can capture video from up to 4 cameras. - **config** (CameraCapturerConfiguration) - Required - The configuration of the video capture. On the iOS platform, this parameter has no practical function. Use the config parameter in enableMultiCamera instead to set the video capture configuration. ### Request Example ```json { "sourceType": "CAMERA_FRONT_FACING", "config": { "frameRate": 30, "bitrate": 1000, "dimensions": { "width": 1280, "height": 720 } } } ``` ### Response #### Success Response (200) - **No return value** - Indicates the method call succeeded. #### Response Example (No specific JSON response body for success, an empty response or a success status code is expected) #### Error Response - **AgoraRtcException** - Thrown when the method call fails. This exception needs to be caught and handled. ``` -------------------------------- ### Answer Call with ChatCallKit Source: https://pub.dev/documentation/agora_chat_callkit/latest/index Answers an incoming call after initializing Agora RTC. The `callId` is obtained from the `onReceiveCall` event. Handles potential ChatCallKitError exceptions. ```dart await ChatCallKitManager.initRTC(); try { // callId: The call ID which can be obtained from the onReceiveCall callback. await ChatCallKitManager.answer(callId); } on ChatCallKitError catch (e) { ... ``` -------------------------------- ### Switch Camera in Agora Chat CallKit Source: https://pub.dev/documentation/agora_chat_callkit/latest/index The `ChatCallKitManager.switchCamera()` method allows users to toggle between the front and rear cameras during a call. This action is asynchronous and does not require any arguments. ```dart await ChatCallKitManager.switchCamera(); ``` -------------------------------- ### Initialize AudioDeviceManager Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/AudioDeviceManager-class Creates a new instance of the AudioDeviceManager. This is the entry point for managing audio devices within the application. ```dart AudioDeviceManager.new() ``` -------------------------------- ### Setup Remote Video Ex Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/RtcEngineEx/setupRemoteVideoEx Initializes the video view of a remote user. This method binds the remote video stream to a video view and sets the rendering and mirror modes. ```APIDOC ## POST /websites/pub_dev_agora_chat_callkit ### Description Initializes the video view of a remote user. This method binds the remote video stream to a video view and sets the rendering and mirror modes. ### Method POST ### Endpoint /websites/pub_dev_agora_chat_callkit ### Parameters #### Request Body - **canvas** (VideoCanvas) - Required - The remote video view settings. - **connection** (RtcConnection) - Required - The connection information. ### Request Example ```json { "canvas": { "view": "video_view_id", "uid": 12345 }, "connection": { "channelName": "my_channel", "localUid": 67890 } } ``` ### Response #### Success Response (200) - **result** (string) - Indicates success or failure. #### Response Example ```json { "result": "success" } ``` ``` -------------------------------- ### Mute/Unmute Microphone with ChatCallKit Source: https://pub.dev/documentation/agora_chat_callkit/latest/index Mutes or unmutes the microphone during a call using the `mute` and `unMute` methods. Changes in microphone status trigger the `onUserMuteAudio` event for other participants. ```dart await ChatCallKitManager.mute(); await ChatCallKitManager.unMute(); ``` -------------------------------- ### Get Audio Mixing Current Position (Dart) Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/RtcEngine/getAudioMixingCurrentPosition Retrieves the playback position in milliseconds of the music file currently being mixed. This method should be called after starting audio mixing and receiving the onAudioMixingStateChanged (audioMixingStatePlaying) callback. A minimum interval of 500 ms is required between successive calls. It returns the playback position (>= 0) on success, or a negative value on failure. ```dart Future getAudioMixingCurrentPosition(); ``` -------------------------------- ### Start Screen Capture by Source Type Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/RtcEngineEx-class Initiates screen capture using a specified video source type and configuration. This function is inherited and requires VideoSourceType and ScreenCaptureConfiguration as parameters. ```dart startScreenCaptureBySourceType({required VideoSourceType sourceType, required ScreenCaptureConfiguration config}) → Future ``` -------------------------------- ### Reject Call with ChatCallKit Source: https://pub.dev/documentation/agora_chat_callkit/latest/index Rejects an incoming call using the `hangup` method and then releases RTC resources. The `callId` is obtained from the `onReceiveCall` event. Handles potential ChatCallKitError exceptions. ```dart try { // callId: The call ID which can be obtained via the `onReceiveCall` callback. await ChatCallKitManager.hangup(callId); } on ChatCallKitError catch (e) { ... } await ChatCallKitManager.releaseRTC(); ``` -------------------------------- ### Setup Local Video - Dart Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/RtcEngine-class Initializes the local video view, preparing it to display the local user's video feed. This involves setting up the canvas where the local video will be rendered. ```Dart setupLocalVideo(VideoCanvas canvas) → Future ``` -------------------------------- ### Account and Initialization API Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/ChatClient-class APIs for initializing the SDK, managing user accounts, and updating application keys. ```APIDOC ## POST /app/key ### Description Updates the App Key, which is the unique identifier used to access Agora Chat services. ### Method POST ### Endpoint /app/key ### Parameters #### Request Body - **newAppKey** (String) - Required - The new App Key to be set. ### Request Example ```json { "newAppKey": "your_new_app_key" } ``` ### Response #### Success Response (200) - **success** (Boolean) - True if the App Key was updated successfully, false otherwise. #### Response Example ```json { "success": true } ``` ## POST /init ### Description Initializes the Agora Chat SDK with the provided options. ### Method POST ### Endpoint /init ### Parameters #### Request Body - **options** (ChatOptions) - Required - An object containing initialization configurations. ### Request Example ```json { "options": { "appKey": "your_app_key", "userId": "default_user_id" } } ``` ### Response #### Success Response (200) - **status** (String) - Indicates the successful initialization. #### Response Example ```json { "status": "initialized" } ``` ## POST /account/register ### Description Registers a new user with the provided user ID and password. ### Method POST ### Endpoint /account/register ### Parameters #### Request Body - **userId** (String) - Required - The desired user ID for the new account. - **password** (String) - Required - The password for the new account. ### Request Example ```json { "userId": "new_user", "password": "secure_password" } ``` ### Response #### Success Response (200) - **status** (String) - Indicates successful user registration. #### Response Example ```json { "status": "registered" } ``` ``` -------------------------------- ### Get Public Groups with Cursor (Chinese) Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/ChatCursorResult-class Provides an example of retrieving public groups from the server using a cursor for pagination in Chinese. It fetches group data and the cursor for subsequent requests, utilizing the ChatClient.groupManager. ```dart String? cursor; ChatCursorResult result = await ChatClient.getInstance.groupManager.getPublicGroupsFromServer(pageSize: 10, cursor: cursor); List? group = result.data; cursor = result.cursor; ``` -------------------------------- ### Start Audio Loopback Test (Dart) Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/RtcEngine/startEchoTest Initiates an audio device loopback test to verify local sending and receiving streams, audio/video devices, and network connectivity. The test requires user input (sound or facing the camera) and provides output after approximately two seconds. Returns 0 for success, and a negative value for failure. Dependencies: EchoTestConfiguration. ```dart Future startEchoTest(EchoTestConfiguration config); ``` -------------------------------- ### Control Camera On/Off in Agora Chat CallKit Source: https://pub.dev/documentation/agora_chat_callkit/latest/index Use `ChatCallKitManager.cameraOn()` and `ChatCallKitManager.cameraOff()` to control the camera during calls. The opposing user will receive an `onUserMuteVideo` event when the camera state changes. These methods are asynchronous. ```dart await ChatCallKitManager.cameraOn(); await ChatCallKitManager.cameraOff(); ``` -------------------------------- ### End Call with ChatCallKit Source: https://pub.dev/documentation/agora_chat_callkit/latest/index Ends a call by calling `releaseRTC`. For one-to-one calls, this ends the call for both participants. For group calls, it makes the local user leave, and other users receive an `onUserLeaved` event. ```dart await ChatCallKitManager.releaseRTC(); ``` -------------------------------- ### Media Relay and Preview Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/RtcEngine-class Functions for starting media stream relaying, enabling local video preview, and tracing rendering processes. ```APIDOC ## startMediaRenderingTracing ### Description Enables tracing the video frame rendering process. ### Method POST ### Endpoint /startMediaRenderingTracing ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) - **message** (string) - Indicates success. #### Response Example ```json { "message": "Successfully started media rendering tracing." } ``` ## startOrUpdateChannelMediaRelay ### Description Starts relaying media streams across channels or updates channels for media relay. ### Method POST ### Endpoint /startOrUpdateChannelMediaRelay ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **configuration** (ChannelMediaRelayConfiguration) - Required - The configuration for media relay. ### Request Example ```json { "configuration": { "srcChannelName": "source_channel", "srcToken": "", "destChannelName": "destination_channel", "destToken": "" } } ``` ### Response #### Success Response (200) - **message** (string) - Indicates success. #### Response Example ```json { "message": "Successfully started or updated channel media relay." } ``` ## startPreview ### Description Enables the local video preview and specifies the video source for the preview. ### Method POST ### Endpoint /startPreview ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **sourceType** (VideoSourceType) - Optional - The video source type for the preview. Defaults to 'videoSourceCameraPrimary'. ### Request Example ```json { "sourceType": "camera1" } ``` ### Response #### Success Response (200) - **message** (string) - Indicates success. #### Response Example ```json { "message": "Successfully started local video preview." } ``` ## startPreviewWithoutSourceType ### Description Enables the local video preview. ### Method POST ### Endpoint /startPreviewWithoutSourceType ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) - **message** (string) - Indicates success. #### Response Example ```json { "message": "Successfully started local video preview without source type." } ``` ``` -------------------------------- ### Media Engine and Device Management Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/RtcEngine-class Methods for initializing the SDK, managing media engines, and retrieving information about audio and video devices. ```APIDOC ## initialize ### Description Initializes the RtcEngine. ### Method POST ### Endpoint /initialize ### Parameters #### Request Body - **context** (RtcEngineContext) - Required - The context for initializing the RtcEngine. ### Request Example ```json { "context": { ... } } ``` ### Response #### Success Response (200) - **void** - Indicates successful initialization. ## getAudioDeviceInfo ### Description Gets the audio device information. ### Method GET ### Endpoint /audioDeviceInfo ### Response #### Success Response (200) - **DeviceInfo** - The information about the audio device. ## getAudioDeviceManager ### Description Gets the AudioDeviceManager object to manage audio devices. ### Method GET ### Endpoint /audioDeviceManager ### Response #### Success Response (200) - **AudioDeviceManager** - The AudioDeviceManager object. ## getVideoDeviceManager ### Description Gets the VideoDeviceManager object to manage video devices. ### Method GET ### Endpoint /videoDeviceManager ### Response #### Success Response (200) - **VideoDeviceManager** - The VideoDeviceManager object. ## getMediaEngine ### Description Gets one MediaEngine object. ### Method GET ### Endpoint /mediaEngine ### Response #### Success Response (200) - **MediaEngine** - The MediaEngine object. ``` -------------------------------- ### Android Project Permissions for Agora Source: https://pub.dev/documentation/agora_chat_callkit/latest/index Configure necessary Android permissions in your AndroidManifest.xml file to allow Agora services to function correctly, including network access, audio/video recording, and phone state. ```xml ... ... ``` -------------------------------- ### Initialize Remote Video View (Dart) Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/RtcEngine/setupRemoteVideo Initializes the video view for a remote user, binding the video stream and setting rendering/mirror modes. This method is specific to certain platforms; in Flutter, use AgoraVideoView. ```dart Future setupRemoteVideo(VideoCanvas canvas); ``` -------------------------------- ### Receive Incoming Call with ChatCallKit Observer Source: https://pub.dev/documentation/agora_chat_callkit/latest/index Listens for incoming call invitations by adding a ChatCallKitObserver. The `onReceiveCall` callback is triggered for both one-to-one and group calls. Remember to remove the observer when it's no longer needed. ```dart class _MyHomePageState extends State with ChatCallKitObserver { @override void initState() { super.initState(); ChatCallKitManager.addObserver(this); } @override void onReceiveCall( String userId, String callId, ChatCallKitCallType callType, Map? ext, ) async { // show receive call page. } @override void dispose() { ChatCallKitManager.removeObserver(this); super.dispose(); } } ``` -------------------------------- ### Local and Remote Video Setup Source: https://pub.dev/documentation/agora_chat_callkit/latest/agora_chat_callkit/RtcEngine-class Functions for initializing and setting up local and remote video canvases. ```APIDOC ## setupLocalVideo ### Description Initializes the local video view. ### Method POST ### Endpoint /setupLocalVideo ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **canvas** (VideoCanvas) - Required - The canvas configuration for the local video view. ### Request Example ```json { "canvas": { "view": "", "uid": 0 } } ``` ### Response #### Success Response (200) - **message** (string) - Indicates success. #### Response Example ```json { "message": "Successfully set up local video." } ``` ## setupRemoteVideo ### Description Initializes the video view of a remote user. ### Method POST ### Endpoint /setupRemoteVideo ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **canvas** (VideoCanvas) - Required - The canvas configuration for the remote video view. ### Request Example ```json { "canvas": { "view": "", "uid": 12345 } } ``` ### Response #### Success Response (200) - **message** (string) - Indicates success. #### Response Example ```json { "message": "Successfully set up remote video." } ``` ``` -------------------------------- ### Add and Remove ChatCallKitObserver in Flutter Source: https://pub.dev/documentation/agora_chat_callkit/latest/index Demonstrates how to integrate ChatCallKitObserver within a Flutter widget's lifecycle. It covers adding the observer in `initState` and removing it in `dispose` to prevent memory leaks and ensure proper event handling. ```dart class _MyHomePageState extends State with ChatCallKitObserver { @override void initState() { super.initState(); ChatCallKitManager.addObserver(this); } @override void dispose() { ChatCallKitManager.removeObserver(this); super.dispose(); } } ``` -------------------------------- ### Remove Listener Handler in Agora Chat CallKit Source: https://pub.dev/documentation/agora_chat_callkit/latest/index When the CallKit is no longer required, it's essential to clean up by removing observers. Use `ChatCallKitManager.removeObserver(this);` to detach the current object as a listener, preventing memory leaks and ensuring proper resource management. ```dart ChatCallKitManager.removeObserver(this); ```