From 411d3a0f016412527c81f4f0e5034e7451391997 Mon Sep 17 00:00:00 2001 From: xucz Date: Wed, 7 Aug 2024 19:35:59 +0800 Subject: [PATCH 01/21] Update sdk to 4.4.1 --- Android/APIExample-Audio/app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Android/APIExample-Audio/app/build.gradle b/Android/APIExample-Audio/app/build.gradle index 4e7742343..d4d1a595a 100644 --- a/Android/APIExample-Audio/app/build.gradle +++ b/Android/APIExample-Audio/app/build.gradle @@ -1,7 +1,7 @@ apply plugin: 'com.android.application' def localSdkPath= "${rootProject.projectDir.absolutePath}/../../sdk" -def agoraSdkVersion = '4.4.0' +def agoraSdkVersion = '4.4.1' android { compileSdkVersion 32 From 6b7f2c4a7d2dce8536e823fcc74a0ec100e3579b Mon Sep 17 00:00:00 2001 From: xucz Date: Wed, 7 Aug 2024 19:36:42 +0800 Subject: [PATCH 02/21] Update sdk to 4.4.1 --- Android/APIExample-Compose/gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Android/APIExample-Compose/gradle/libs.versions.toml b/Android/APIExample-Compose/gradle/libs.versions.toml index da320982f..5e7d7eb30 100644 --- a/Android/APIExample-Compose/gradle/libs.versions.toml +++ b/Android/APIExample-Compose/gradle/libs.versions.toml @@ -12,7 +12,7 @@ composeBom = "2023.08.00" loggingInterceptor = "4.10.0" materialIconsExtended = "1.6.0" navigationCompose = "2.7.7" -agoraSdk = "4.4.0" +agoraSdk = "4.4.1" okhttp = "4.10.0" [libraries] From 331da1c09ce515975a7b191d9c58fe52065270bc Mon Sep 17 00:00:00 2001 From: xucz Date: Wed, 7 Aug 2024 19:37:12 +0800 Subject: [PATCH 03/21] Update sdk to 4.4.1 --- Android/APIExample/app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Android/APIExample/app/build.gradle b/Android/APIExample/app/build.gradle index 9e1952a3b..efbde21a0 100644 --- a/Android/APIExample/app/build.gradle +++ b/Android/APIExample/app/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'kotlin-android' apply from: "${rootDir.absolutePath}/git-hooks.gradle" apply from: 'vendors.gradle' -def agoraSdkVersion = "4.4.0" +def agoraSdkVersion = "4.4.1" def localSdkPath= "${rootProject.projectDir.absolutePath}/../../sdk" From 0f7792cb533c99fa4a77b6550b433b50265dd57a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BC=BA?= Date: Mon, 30 Sep 2024 14:41:35 +0800 Subject: [PATCH 04/21] for change --- .../APIExample/entry/oh-package-lock.json5 | 8 ++-- .../ets/pages/advance/ChannelEncryption.ets | 6 +-- .../ets/pages/advance/CustomVideoSource.ets | 10 ++--- .../ets/pages/advance/HostCrossChannel.ets | 12 +++--- .../ets/pages/advance/JoinMultiChannel.ets | 6 +-- .../main/ets/pages/advance/LiveStreaming.ets | 4 +- .../pages/advance/LocalVideoTranscoding.ets | 41 ++++++++++++++----- .../ets/pages/advance/MediaMetadataWrap.ets | 4 +- .../main/ets/pages/advance/MediaRecorder.ets | 4 +- .../ets/pages/advance/OriginVideoDataWrap.ets | 4 +- .../main/ets/pages/advance/PreCallTest.ets | 2 +- .../main/ets/pages/advance/RTMPStreaming.ets | 29 +++++++------ .../main/ets/pages/advance/ScreenSharing.ets | 4 +- .../main/ets/pages/basic/JoinVideoChannel.ets | 4 +- .../ets/pages/basic/JoinVideoChannelToken.ets | 4 +- 15 files changed, 83 insertions(+), 59 deletions(-) diff --git a/HarmonyOS_NEXT/APIExample/entry/oh-package-lock.json5 b/HarmonyOS_NEXT/APIExample/entry/oh-package-lock.json5 index 71a5ea407..60fc2b12c 100644 --- a/HarmonyOS_NEXT/APIExample/entry/oh-package-lock.json5 +++ b/HarmonyOS_NEXT/APIExample/entry/oh-package-lock.json5 @@ -6,12 +6,12 @@ "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", "specifiers": { "AgoraRtcSdk@libs/AgoraRtcSdk.har": "AgoraRtcSdk@libs/AgoraRtcSdk.har", - "libagora_rtc_sdk.so@../oh_modules/.ohpm/AgoraRtcSdk@gnhkbsqhvur0p1kaytsefmbpezi=/oh_modules/AgoraRtcSdk/src/main/cpp/types/libagora_rtc_sdk": "libagora_rtc_sdk.so@../oh_modules/.ohpm/AgoraRtcSdk@gnhkbsqhvur0p1kaytsefmbpezi=/oh_modules/AgoraRtcSdk/src/main/cpp/types/libagora_rtc_sdk", + "libagora_rtc_sdk.so@../oh_modules/.ohpm/AgoraRtcSdk@psqmdffzbvli66vvuhpgemb+uuiby9okskr7kzozry4=/oh_modules/AgoraRtcSdk/src/main/cpp/types/libagora_rtc_sdk": "libagora_rtc_sdk.so@../oh_modules/.ohpm/AgoraRtcSdk@psqmdffzbvli66vvuhpgemb+uuiby9okskr7kzozry4=/oh_modules/AgoraRtcSdk/src/main/cpp/types/libagora_rtc_sdk", "librawdataprocessing.so@src/main/cpp/types/librawdataprocessing": "librawdataprocessing.so@src/main/cpp/types/librawdataprocessing" }, "packages": { "AgoraRtcSdk@libs/AgoraRtcSdk.har": { - "name": "agora_rtc_sdk", + "name": "AgoraRtcSdk", "version": "v4.3.0-beta.1", "resolved": "libs/AgoraRtcSdk.har", "registryType": "local", @@ -19,10 +19,10 @@ "libagora_rtc_sdk.so": "file:./src/main/cpp/types/libagora_rtc_sdk" } }, - "libagora_rtc_sdk.so@../oh_modules/.ohpm/AgoraRtcSdk@gnhkbsqhvur0p1kaytsefmbpezi=/oh_modules/AgoraRtcSdk/src/main/cpp/types/libagora_rtc_sdk": { + "libagora_rtc_sdk.so@../oh_modules/.ohpm/AgoraRtcSdk@psqmdffzbvli66vvuhpgemb+uuiby9okskr7kzozry4=/oh_modules/AgoraRtcSdk/src/main/cpp/types/libagora_rtc_sdk": { "name": "libagora_rtc_sdk.so", "version": "0.0.0", - "resolved": "../oh_modules/.ohpm/AgoraRtcSdk@gnhkbsqhvur0p1kaytsefmbpezi=/oh_modules/AgoraRtcSdk/src/main/cpp/types/libagora_rtc_sdk", + "resolved": "../oh_modules/.ohpm/AgoraRtcSdk@psqmdffzbvli66vvuhpgemb+uuiby9okskr7kzozry4=/oh_modules/AgoraRtcSdk/src/main/cpp/types/libagora_rtc_sdk", "registryType": "local" }, "librawdataprocessing.so@src/main/cpp/types/librawdataprocessing": { diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ChannelEncryption.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ChannelEncryption.ets index e44fd4bd7..b1cfde0c8 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ChannelEncryption.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ChannelEncryption.ets @@ -125,7 +125,7 @@ struct ChannelEncryption { if (this.localUid != -1) { XComponent({ id: 'preview_local', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_local"); @@ -139,7 +139,7 @@ struct ChannelEncryption { if (this.remoteUid != -1) { XComponent({ id: 'preview_remote', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_remote"); @@ -219,7 +219,7 @@ struct ChannelEncryption { config.encryptionMode = this.encryptionModeOptions[this.encryptionModeSelectIndex] config.encryptionKey = this.encryptionKey let base64 = new util.Base64Helper(); - config.encryptionKdfSalt = base64.decodeSync("NiIeJ08AbtcQVjvV+oOEvF/4Dz5dy1CIwa805C8J2w0=", util.Type.BASIC) + config.encryptionKdfSalt = base64.decodeSync("NiIeJ08AbtcQVjvV+oOEvF/4Dz5dy1CIwa805C8J2w0=", util.Type.BASIC).buffer as ArrayBuffer this.rtcEngine?.enableEncryption(true, config) let mediaOption: ChannelMediaOptions = new ChannelMediaOptions(); diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/CustomVideoSource.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/CustomVideoSource.ets index 27de9dd2c..723408c70 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/CustomVideoSource.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/CustomVideoSource.ets @@ -122,11 +122,11 @@ struct CustomVideoSource { let frameBuffer: Uint8Array = buffer.slice(readStart, readStart + frame_size) readStart += frame_size let frame: VideoFrame = new VideoFrame( - VideoBufferType.VIDEO_BUFFER_RAW_DATA, + VideoBufferType.RAW_DATA, VideoPixelFormat.VIDEO_PIXEL_I420); frame.buffer = frameBuffer.buffer as ArrayBuffer; frame.rotation = 0; - frame.stride = width; + frame.yStride = width; frame.height = height; frame.timestamp = 0; let ret = this.rtcEngine?.pushExternalVideoFrameById(frame, this.customVideoTrack) @@ -159,7 +159,7 @@ struct CustomVideoSource { if (this.localUid != 0) { XComponent({ id: 'preview_local', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_local"); @@ -167,7 +167,7 @@ struct CustomVideoSource { localCanvas.renderMode = VideoCanvas.RENDER_MODE_HIDDEN; localCanvas.mirrorMode = 0; // TODO set source type - // localCanvas.sourceType = Constants.VideoSourceType.VIDEO_SOURCE_CUSTOM + localCanvas.sourceType = Constants.VideoSourceType.CUSTOM this.rtcEngine?.setupLocalVideo(localCanvas); }).width('50%') } @@ -175,7 +175,7 @@ struct CustomVideoSource { if (this.remoteUid != 0) { XComponent({ id: 'preview_remote', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_remote"); diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/HostCrossChannel.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/HostCrossChannel.ets index 66c9e3ef4..4b7d6e25f 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/HostCrossChannel.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/HostCrossChannel.ets @@ -115,7 +115,7 @@ struct HostCrossChannel { if (this.localUid != 0) { XComponent({ id: 'preview_local', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_local"); @@ -129,7 +129,7 @@ struct HostCrossChannel { if (this.remoteUid != 0) { XComponent({ id: 'preview_remote', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_remote"); @@ -186,12 +186,12 @@ struct HostCrossChannel { let config = new ChannelMediaRelayConfiguration() config.srcInfo.channelName = this.channelName config.srcInfo.uid = this.localUid - config.srcInfo.token = await TokenUtils.genRtcToken(this.channelName, '') - config.destInfos[this.relayChannelName] = { + config.srcInfo.token = "" + config.destInfos.set(this.relayChannelName, { channelName: this.relayChannelName, uid: 999, - token: await TokenUtils.genRtcToken(this.relayChannelName, '999') - } + token: "" + }) this.rtcEngine?.startOrUpdateChannelMediaRelay(config) } }) diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/JoinMultiChannel.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/JoinMultiChannel.ets index 9364d8ce0..37915eafa 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/JoinMultiChannel.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/JoinMultiChannel.ets @@ -108,7 +108,7 @@ struct JoinMultiChannel { if (this.mainLocalUid != 0) { XComponent({ id: 'preview_local', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_local"); @@ -122,7 +122,7 @@ struct JoinMultiChannel { if (this.mainRemoteUid != 0) { XComponent({ id: 'preview_remote', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_remote"); @@ -141,7 +141,7 @@ struct JoinMultiChannel { if (this.exRemoteUid != 0) { XComponent({ id: 'preview_remote_ex', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LiveStreaming.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LiveStreaming.ets index ce7d7ea9f..a2781edf9 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LiveStreaming.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LiveStreaming.ets @@ -166,7 +166,7 @@ struct LiveStreaming { if (this.localUid != -1) { XComponent({ id: 'preview_local', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_local"); @@ -180,7 +180,7 @@ struct LiveStreaming { if (this.remoteUid != -1) { XComponent({ id: 'preview_remote', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_remote"); diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LocalVideoTranscoding.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LocalVideoTranscoding.ets index 464a11043..7309dd6a6 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LocalVideoTranscoding.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LocalVideoTranscoding.ets @@ -19,6 +19,10 @@ import { common } from '@kit.AbilityKit'; import { GlobalInfo } from '../Data'; import { TokenUtils } from '../../util/TokenUtils'; import { LengthMetrics } from '@kit.ArkUI'; +import { TranscodingVideoStream } from 'AgoraRtcSdk'; +import { JSON } from '@kit.ArkTS'; +import { camera } from '@kit.CameraKit'; +import { VideoDimensions } from 'AgoraRtcSdk'; const TAG: string = 'LocalVideoTranscoding' @@ -65,6 +69,15 @@ struct LocalVideoTranscoding { Logger.info(TAG, "mEventHandler.onError: " + err + " message " + message); ShowToast.longToast("onError " + err + " : " + message) } + config.mEventHandler.onLocalVideoTranscoderError = (stream:TranscodingVideoStream, error:Constants.VideoTranscoderError) => { + Logger.info(TAG, "mEventHandler.onLocalVideoTranscoderError stream "+JSON.stringify(stream) + " error: "+error); + ShowToast.longToast("onLocalVideoTranscoderError " + error ) + } + + config.mEventHandler.onTranscodingUpdated = () => { + Logger.info(TAG, "mEventHandler.onTranscodingUpdated"); + } + config.mContext = context; Logger.info(TAG, "in thread create engine begin: "); this.rtcEngine = RtcEngine.create(config); @@ -119,12 +132,12 @@ struct LocalVideoTranscoding { if (this.localUid != -1) { XComponent({ id: 'preview_local', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_local"); localCanvas.uid = this.localUid; - localCanvas.renderMode = VideoCanvas.RENDER_MODE_HIDDEN; + localCanvas.renderMode = VideoCanvas.RENDER_MODE_FIT; localCanvas.mirrorMode = 0; localCanvas.sourceType = Constants.VideoSourceType.TRANSCODED this.rtcEngine?.setupLocalVideo(localCanvas); @@ -134,13 +147,14 @@ struct LocalVideoTranscoding { if (this.remoteUid != -1) { XComponent({ id: 'preview_remote', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_remote"); localCanvas.uid = this.remoteUid; localCanvas.renderMode = VideoCanvas.RENDER_MODE_HIDDEN; localCanvas.mirrorMode = 0; + localCanvas.sourceType = Constants.VideoSourceType.TRANSCODED; this.rtcEngine?.setupRemoteVideo(localCanvas); }).width('30%').height('30%').margin({ top: 12, right: 12 }) } @@ -176,8 +190,8 @@ struct LocalVideoTranscoding { } - let width = 720; - let height = 1280; + let width = 960; + let height = 540; let screenConfig = new ScreenCaptureParameters() this.rtcEngine?.startScreenCapture(screenConfig) @@ -187,16 +201,21 @@ struct LocalVideoTranscoding { let config = new LocalTranscoderConfiguration() config.transcodingVideoStreams = new Array(2) + config.videoOutputConfiguration.dimensions = new VideoDimensions(width,height) + config.transcodingVideoStreams[0] = new TranscodingVideoStream(); config.transcodingVideoStreams[0].sourceType = Constants.VideoSourceType.SCREEN_PRIMARY - config.transcodingVideoStreams[0].width = width + config.transcodingVideoStreams[0].width = width/2 config.transcodingVideoStreams[0].height = height + config.transcodingVideoStreams[0].x = 0 + config.transcodingVideoStreams[0].y = 0 config.transcodingVideoStreams[0].zOrder = 1 + config.transcodingVideoStreams[1] = new TranscodingVideoStream() config.transcodingVideoStreams[1].sourceType = Constants.VideoSourceType.CAMERA_PRIMARY - config.transcodingVideoStreams[1].width = width / 2 - config.transcodingVideoStreams[1].height = height / 2 - config.transcodingVideoStreams[1].x = 0 - config.transcodingVideoStreams[1].y = height / 2 + config.transcodingVideoStreams[1].width = width/2 + config.transcodingVideoStreams[1].height = height + config.transcodingVideoStreams[1].x = width/2 + config.transcodingVideoStreams[1].y = 0 config.transcodingVideoStreams[1].zOrder = 2 config.transcodingVideoStreams[1].mirror = true @@ -213,7 +232,7 @@ struct LocalVideoTranscoding { mediaOption.channelProfile = Constants.ChannelProfile.LIVE_BROADCASTING; mediaOption.clientRoleType = Constants.ClientRole.BROADCASTER; - let token = await TokenUtils.genRtcToken(this.channelName, "") + let token = "" let ret = this.rtcEngine?.joinChannelWithOptions(token, this.channelName, 0, mediaOption) if (ret != Constants.ErrorCode.ERR_OK) { ShowToast.longToast("joinChannelWithOptions error " + ret + " : " + diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/MediaMetadataWrap.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/MediaMetadataWrap.ets index ebbc082d7..81eb83e30 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/MediaMetadataWrap.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/MediaMetadataWrap.ets @@ -102,7 +102,7 @@ struct MediaMetadataWrap { if (this.localUid != 0) { XComponent({ id: 'preview_local', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_local"); @@ -116,7 +116,7 @@ struct MediaMetadataWrap { if (this.remoteUid != 0) { XComponent({ id: 'preview_remote', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_remote"); diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/MediaRecorder.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/MediaRecorder.ets index 82962ba01..c884cbb39 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/MediaRecorder.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/MediaRecorder.ets @@ -118,7 +118,7 @@ struct MediaRecorder { Stack() { XComponent({ id: 'preview_local', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_local"); @@ -191,7 +191,7 @@ struct MediaRecorder { Stack() { XComponent({ id: 'preview_remote', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_remote"); diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/OriginVideoDataWrap.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/OriginVideoDataWrap.ets index 88852ef9f..8ba298074 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/OriginVideoDataWrap.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/OriginVideoDataWrap.ets @@ -100,7 +100,7 @@ struct OriginVideoDataWrap { if (this.localUid != 0) { XComponent({ id: 'preview_local', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_local"); @@ -114,7 +114,7 @@ struct OriginVideoDataWrap { if (this.remoteUid != 0) { XComponent({ id: 'preview_remote', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_remote"); diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/PreCallTest.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/PreCallTest.ets index d72c38d2c..46d6d0cff 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/PreCallTest.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/PreCallTest.ets @@ -204,7 +204,7 @@ struct PlayAudioFiles { }) XComponent({ id: 'preview_local', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_local"); diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/RTMPStreaming.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/RTMPStreaming.ets index ba4f67ac4..38d2d818b 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/RTMPStreaming.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/RTMPStreaming.ets @@ -42,14 +42,16 @@ struct RTMPStreaming { Logger.info(TAG, "mEventHandler.onUserJoined: " + uid + " , " + collapse); if (this.remoteUid == -1) { this.remoteUid = uid - this.transcodingParameters.transcodingUsers[uid] = { - uid: uid, - x: 0, - y: this.transcodingParameters.height / 2, - width: this.transcodingParameters.width, - height: this.transcodingParameters.height / 2, - zOrder: 1 - } + let user = new TranscodingUser(); + user.uid = uid; + user.x = 0; + user.y = this.transcodingParameters.height / 2; + user.width = this.transcodingParameters.width; + user.height = this.transcodingParameters.height / 2; + user.zOrder = 1; + user.alpha = 1.0 + user.audioChannel = 2; + this.transcodingParameters.transcodingUsers.set(uid,user) } }; config.mEventHandler.onUserOffline = (uid: number, reason: number) => { @@ -62,14 +64,17 @@ struct RTMPStreaming { config.mEventHandler.onJoinChannelSuccess = (cid: string, uid: number, elapsed: number) => { Logger.info(TAG, "mEventHandler.onJoinChannelSuccess: " + uid); this.transcodingParameters.transcodingUsers = new Map(); - this.transcodingParameters.transcodingUsers[uid] = { + let localUser:TranscodingUser = { uid: uid, x: 0, y: 0, width: this.transcodingParameters.width, height: this.transcodingParameters.height / 2, - zOrder: 1 + zOrder: 1, + alpha:1.0, + audioChannel:2, } + this.transcodingParameters.transcodingUsers.set(uid,localUser) this.isJoin = true this.localUid = uid } @@ -130,7 +135,7 @@ struct RTMPStreaming { if (this.localUid != -1) { XComponent({ id: 'preview_local', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_local"); @@ -144,7 +149,7 @@ struct RTMPStreaming { if (this.remoteUid != -1) { XComponent({ id: 'preview_remote', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_remote"); diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ScreenSharing.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ScreenSharing.ets index 5798be078..8134a5944 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ScreenSharing.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ScreenSharing.ets @@ -118,7 +118,7 @@ struct ScreenSharing { if (this.localUid != -1) { XComponent({ id: 'preview_local', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_local"); @@ -133,7 +133,7 @@ struct ScreenSharing { if (this.remoteUid != -1) { XComponent({ id: 'preview_remote', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_remote"); diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/basic/JoinVideoChannel.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/basic/JoinVideoChannel.ets index e3c252ef0..56ea46e4a 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/basic/JoinVideoChannel.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/basic/JoinVideoChannel.ets @@ -93,7 +93,7 @@ struct JoinVideoChannel { if (this.localUid != 0) { XComponent({ id: 'preview_local', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_local"); @@ -107,7 +107,7 @@ struct JoinVideoChannel { if (this.remoteUid != 0) { XComponent({ id: 'preview_remote', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_remote"); diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/basic/JoinVideoChannelToken.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/basic/JoinVideoChannelToken.ets index 908a15e4e..83da234b2 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/basic/JoinVideoChannelToken.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/basic/JoinVideoChannelToken.ets @@ -119,7 +119,7 @@ struct JoinVideoChannelToken { if (this.localUid != 0) { XComponent({ id: 'preview_local', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_local"); @@ -133,7 +133,7 @@ struct JoinVideoChannelToken { if (this.remoteUid != 0) { XComponent({ id: 'preview_remote', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_remote"); From b9c35fc5567754ff6472b2de9d650646b36188d1 Mon Sep 17 00:00:00 2001 From: weileifrank <1138289316@qq.com> Date: Mon, 30 Sep 2024 14:52:43 +0800 Subject: [PATCH 05/21] =?UTF-8?q?feat:=20=E8=A7=A3=E5=86=B3=E5=AA=92?= =?UTF-8?q?=E4=BD=93=E5=8A=A0=E5=AF=86=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/cpp/include/AgoraAtomicOps.h | 0 .../entry/src/main/cpp/include/AgoraBase.h | 417 ++++++++++++++-- .../cpp/include/AgoraExtensionProviderEntry.h | 0 .../main/cpp/include/AgoraExtensionVersion.h | 8 + .../src/main/cpp/include/AgoraMediaBase.h | 358 ++++++++++++- .../main/cpp/include/AgoraMediaPlayerTypes.h | 0 .../src/main/cpp/include/AgoraOptional.h | 0 .../main/cpp/include/AgoraRefCountedObject.h | 0 .../entry/src/main/cpp/include/AgoraRefPtr.h | 0 .../src/main/cpp/include/IAgoraFileUploader.h | 0 .../main/cpp/include/IAgoraH265Transcoder.h | 0 .../entry/src/main/cpp/include/IAgoraLog.h | 1 + .../cpp/include/IAgoraMediaComponentFactory.h | 0 .../src/main/cpp/include/IAgoraMediaEngine.h | 15 + .../src/main/cpp/include/IAgoraMediaPlayer.h | 11 - .../cpp/include/IAgoraMediaPlayerSource.h | 11 - .../main/cpp/include/IAgoraMediaRecorder.h | 0 .../cpp/include/IAgoraMediaRelayService.h | 6 +- .../cpp/include/IAgoraMediaStreamingSource.h | 0 .../src/main/cpp/include/IAgoraParameter.h | 6 +- .../src/main/cpp/include/IAgoraRhythmPlayer.h | 0 .../src/main/cpp/include/IAgoraRtcEngine.h | 472 ++++++++++-------- .../src/main/cpp/include/IAgoraRtcEngineEx.h | 84 ++-- .../src/main/cpp/include/IAgoraRtmService.h | 0 .../cpp/include/IAgoraRtmpStreamingService.h | 0 .../src/main/cpp/include/IAgoraService.h | 46 +- .../main/cpp/include/IAudioDeviceManager.h | 50 ++ .../cpp/include/NGIAgoraAudioDeviceManager.h | 6 + .../cpp/include/NGIAgoraAudioMixerSource.h | 0 .../src/main/cpp/include/NGIAgoraAudioTrack.h | 65 ++- .../main/cpp/include/NGIAgoraCameraCapturer.h | 32 ++ .../main/cpp/include/NGIAgoraConfigCenter.h | 0 .../main/cpp/include/NGIAgoraDataChannel.h | 0 .../NGIAgoraExtensionAINoiseSuppressor.h | 9 +- .../main/cpp/include/NGIAgoraExtensionAiAec.h | 8 +- .../cpp/include/NGIAgoraExtensionControl.h | 0 .../cpp/include/NGIAgoraExtensionProvider.h | 2 +- .../include/NGIAgoraExtensionScreenSource.h | 6 +- .../main/cpp/include/NGIAgoraExtensionVQA.h | 0 .../src/main/cpp/include/NGIAgoraLocalUser.h | 28 ++ .../src/main/cpp/include/NGIAgoraMediaNode.h | 92 +++- .../cpp/include/NGIAgoraMediaNodeFactory.h | 4 +- .../include/NGIAgoraRemoteAudioMixerSource.h | 0 .../main/cpp/include/NGIAgoraRtcConnection.h | 0 .../main/cpp/include/NGIAgoraRtmpConnection.h | 0 .../main/cpp/include/NGIAgoraRtmpLocalUser.h | 0 .../main/cpp/include/NGIAgoraScreenCapturer.h | 0 .../src/main/cpp/include/NGIAgoraSyncClient.h | 139 ++++++ .../src/main/cpp/include/NGIAgoraVideoFrame.h | 85 +--- .../cpp/include/NGIAgoraVideoMixerSource.h | 0 .../src/main/cpp/include/NGIAgoraVideoTrack.h | 80 ++- .../entry/src/main/cpp/include/PLACEHOLDER | 1 - .../entry/src/main/cpp/include/api/Makefile | 0 .../src/main/cpp/include/api/aosl_alloca.h | 0 .../src/main/cpp/include/api/aosl_angel.h | 0 .../src/main/cpp/include/api/aosl_ares.h | 0 .../src/main/cpp/include/api/aosl_async.h | 0 .../src/main/cpp/include/api/aosl_atomic.h | 0 .../src/main/cpp/include/api/aosl_audio.h | 0 .../src/main/cpp/include/api/aosl_byteswap.h | 0 .../src/main/cpp/include/api/aosl_data.h | 42 +- .../src/main/cpp/include/api/aosl_defs.h | 0 .../src/main/cpp/include/api/aosl_display.h | 0 .../entry/src/main/cpp/include/api/aosl_dq.h | 0 .../src/main/cpp/include/api/aosl_errno.h | 0 .../src/main/cpp/include/api/aosl_fcntl.h | 0 .../src/main/cpp/include/api/aosl_file.h | 3 +- .../src/main/cpp/include/api/aosl_http.h | 0 .../src/main/cpp/include/api/aosl_input.h | 0 .../cpp/include/api/aosl_integer_wrappings.h | 0 .../entry/src/main/cpp/include/api/aosl_jni.h | 3 +- .../src/main/cpp/include/api/aosl_kobj.h | 20 +- .../src/main/cpp/include/api/aosl_list.h | 0 .../entry/src/main/cpp/include/api/aosl_log.h | 0 .../main/cpp/include/api/aosl_marshalling.h | 0 .../entry/src/main/cpp/include/api/aosl_mm.h | 250 ++++++++++ .../src/main/cpp/include/api/aosl_module.h | 0 .../entry/src/main/cpp/include/api/aosl_mpq.h | 37 +- .../src/main/cpp/include/api/aosl_mpq_fd.h | 46 +- .../src/main/cpp/include/api/aosl_mpq_net.h | 6 +- .../src/main/cpp/include/api/aosl_mpq_timer.h | 0 .../src/main/cpp/include/api/aosl_mpqp.h | 0 .../entry/src/main/cpp/include/api/aosl_os.h | 0 .../src/main/cpp/include/api/aosl_pmdf.h | 0 .../src/main/cpp/include/api/aosl_poll.h | 0 .../src/main/cpp/include/api/aosl_profile.h | 0 .../entry/src/main/cpp/include/api/aosl_psb.h | 0 .../src/main/cpp/include/api/aosl_rbtree.h | 0 .../entry/src/main/cpp/include/api/aosl_ref.h | 30 ++ .../src/main/cpp/include/api/aosl_route.h | 0 .../src/main/cpp/include/api/aosl_sbus.h | 121 ++++- .../entry/src/main/cpp/include/api/aosl_so.h | 21 +- .../src/main/cpp/include/api/aosl_socket.h | 0 .../src/main/cpp/include/api/aosl_task.h | 0 .../src/main/cpp/include/api/aosl_thread.h | 14 + .../src/main/cpp/include/api/aosl_time.h | 0 .../src/main/cpp/include/api/aosl_types.h | 0 .../src/main/cpp/include/api/aosl_utils.h | 0 .../src/main/cpp/include/api/aosl_value.h | 0 .../src/main/cpp/include/api/aosl_vcodec.h | 0 .../src/main/cpp/include/api/aosl_version.h | 0 .../src/main/cpp/include/api/aosl_video.h | 0 .../src/main/cpp/include/api/aosl_xdump.h | 6 + .../src/main/cpp/include/api/cpp/Makefile | 1 - .../cpp/include/api/cpp/aosl_ares_class.h | 0 .../cpp/include/api/cpp/aosl_async_class.h | 0 .../cpp/include/api/cpp/aosl_data_class.h | 273 +++++++--- .../cpp/include/api/cpp/aosl_file_class.h | 4 +- .../cpp/include/api/cpp/aosl_input_class.h | 0 .../cpp/include/api/cpp/aosl_kobj_class.h | 6 +- .../main/cpp/include/api/cpp/aosl_mm_class.h | 45 ++ .../cpp/include/api/cpp/aosl_mpq_fd_class.h | 40 +- .../cpp/include/api/cpp/aosl_mpq_sk_lambda.h | 161 +++++- .../include/api/cpp/aosl_mpq_timer_lambda.h | 0 .../cpp/include/api/cpp/aosl_poll_class.h | 14 +- .../main/cpp/include/api/cpp/aosl_ref_class.h | 161 ++++-- .../cpp/include/api/cpp/aosl_sbus_class.h | 180 +++++++ .../cpp/include/api/cpp/aosl_task_class.h | 0 .../cpp/include/api/cpp/aosl_thread_class.h | 0 .../cpp/include/api/cpp/aosl_usage_class.h | 84 ---- .../cpp/include/api/cpp/aosl_value_class.h | 0 .../src/main/cpp/include/api/objc/Makefile | 0 .../src/main/cpp/include/api/objc/aosl_log.h | 0 .../src/main/cpp/include/api/objc/aosl_objc.h | 0 .../entry/src/main/cpp/include/time_utils.h | 0 .../entry/src/main/cpp/origin_video_data.cpp | 2 +- .../main/ets/entryability/EntryAbility.ets | 2 +- .../ets/pages/advance/ChannelEncryption.ets | 2 +- .../entry/src/main/ets/util/Logger.ts | 2 +- 129 files changed, 2928 insertions(+), 690 deletions(-) mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraAtomicOps.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraBase.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraExtensionProviderEntry.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraExtensionVersion.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraMediaBase.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraMediaPlayerTypes.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraOptional.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraRefCountedObject.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraRefPtr.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraFileUploader.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraH265Transcoder.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraLog.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaComponentFactory.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaEngine.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaPlayer.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaPlayerSource.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaRecorder.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaRelayService.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaStreamingSource.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraParameter.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRhythmPlayer.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtcEngine.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtcEngineEx.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtmService.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtmpStreamingService.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraService.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAudioDeviceManager.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioDeviceManager.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioMixerSource.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioTrack.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraCameraCapturer.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraConfigCenter.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraDataChannel.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionAINoiseSuppressor.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionAiAec.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionControl.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionProvider.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionScreenSource.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionVQA.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraLocalUser.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraMediaNode.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraMediaNodeFactory.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRemoteAudioMixerSource.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRtcConnection.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRtmpConnection.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRtmpLocalUser.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraScreenCapturer.h create mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraSyncClient.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoFrame.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoMixerSource.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoTrack.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/PLACEHOLDER mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/Makefile mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_alloca.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_angel.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_ares.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_async.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_atomic.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_audio.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_byteswap.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_data.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_defs.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_display.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_dq.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_errno.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_fcntl.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_file.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_http.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_input.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_integer_wrappings.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_jni.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_kobj.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_list.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_log.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_marshalling.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mm.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_module.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_fd.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_net.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_timer.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpqp.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_os.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_pmdf.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_poll.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_profile.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_psb.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_rbtree.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_ref.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_route.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_sbus.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_so.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_socket.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_task.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_thread.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_time.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_types.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_utils.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_value.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_vcodec.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_version.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_video.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_xdump.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/Makefile mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_ares_class.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_async_class.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_data_class.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_file_class.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_input_class.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_kobj_class.h create mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mm_class.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_fd_class.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_sk_lambda.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_timer_lambda.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_poll_class.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_ref_class.h create mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_sbus_class.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_task_class.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_thread_class.h delete mode 100755 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_usage_class.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_value_class.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/objc/Makefile mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/objc/aosl_log.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/objc/aosl_objc.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/time_utils.h diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraAtomicOps.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraAtomicOps.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraBase.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraBase.h old mode 100755 new mode 100644 index ed9308d1a..96ae67d96 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraBase.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraBase.h @@ -43,6 +43,8 @@ #define __deprecated +#define AGORA_CPP_INTERNAL_API extern + #elif defined(__APPLE__) #include @@ -51,6 +53,8 @@ #define AGORA_CPP_API __attribute__((visibility("default"))) #define AGORA_CALL +#define AGORA_CPP_INTERNAL_API __attribute__((visibility("hidden"))) + #elif defined(__ANDROID__) || defined(__linux__) #define AGORA_API extern "C" __attribute__((visibility("default"))) @@ -59,6 +63,8 @@ #define __deprecated +#define AGORA_CPP_INTERNAL_API __attribute__((visibility("hidden"))) + #else // !_WIN32 && !__APPLE__ && !(__ANDROID__ || __linux__) #define AGORA_API extern "C" @@ -636,7 +642,7 @@ enum ERROR_CODE_TYPE { */ ERR_SET_CLIENT_ROLE_NOT_AUTHORIZED = 119, /** - * 120: Decryption fails. The user may have tried to join the channel with a wrong + * 120: MediaStream decryption fails. The user may have tried to join the channel with a wrong * password. Check your settings or try rejoining the channel. */ ERR_DECRYPTION_FAILED = 120, @@ -644,6 +650,11 @@ enum ERROR_CODE_TYPE { * 121: The user ID is invalid. */ ERR_INVALID_USER_ID = 121, + /** + * 122: DataStream decryption fails. The peer may have tried to join the channel with a wrong + * password, or did't enable datastream encryption + */ + ERR_DATASTREAM_DECRYPTION_FAILED = 122, /** * 123: The app is banned by the server. */ @@ -1167,8 +1178,9 @@ enum VIDEO_CODEC_TYPE { */ VIDEO_CODEC_GENERIC_H264 = 7, /** - * 12: AV1. - */ + * 12: AV1. + * @technical preview + */ VIDEO_CODEC_AV1 = 12, /** * 13: VP9. @@ -1180,6 +1192,28 @@ enum VIDEO_CODEC_TYPE { VIDEO_CODEC_GENERIC_JPEG = 20, }; +/** + * Camera focal length type. + */ +enum CAMERA_FOCAL_LENGTH_TYPE { + /** + * By default, there are no wide-angle and ultra-wide-angle properties. + */ + CAMERA_FOCAL_LENGTH_DEFAULT = 0, + /** + * Lens with focal length from 24mm to 35mm. + */ + CAMERA_FOCAL_LENGTH_WIDE_ANGLE = 1, + /** + * Lens with focal length of less than 24mm. + */ + CAMERA_FOCAL_LENGTH_ULTRA_WIDE = 2, + /** + * Telephoto lens. + */ + CAMERA_FOCAL_LENGTH_TELEPHOTO = 3, +}; + /** * The CC (Congestion Control) mode options. */ @@ -1315,6 +1349,10 @@ enum AUDIO_CODEC_TYPE { * 12: LPCNET. */ AUDIO_CODEC_LPCNET = 12, + /** + * 13: Opus codec, supporting 3 to 8 channels audio. + */ + AUDIO_CODEC_OPUSMC = 13, }; /** @@ -1515,13 +1553,38 @@ enum H264PacketizeMode { */ enum VIDEO_STREAM_TYPE { /** - * 0: The high-quality video stream, which has a higher resolution and bitrate. + * 0: The high-quality video stream, which has the highest resolution and bitrate. */ VIDEO_STREAM_HIGH = 0, /** - * 1: The low-quality video stream, which has a lower resolution and bitrate. + * 1: The low-quality video stream, which has the lowest resolution and bitrate. */ VIDEO_STREAM_LOW = 1, + /** + * 4: The video stream of layer_1, which has a lower resolution and bitrate than VIDEO_STREAM_HIGH. + */ + VIDEO_STREAM_LAYER_1 = 4, + /** + * 5: The video stream of layer_2, which has a lower resolution and bitrate than VIDEO_STREAM_LAYER_1. + */ + VIDEO_STREAM_LAYER_2 = 5, + /** + * 6: The video stream of layer_3, which has a lower resolution and bitrate than VIDEO_STREAM_LAYER_2. + */ + VIDEO_STREAM_LAYER_3 = 6, + /** + * 7: The video stream of layer_4, which has a lower resolution and bitrate than VIDEO_STREAM_LAYER_3. + */ + VIDEO_STREAM_LAYER_4 = 7, + /** + * 8: The video stream of layer_5, which has a lower resolution and bitrate than VIDEO_STREAM_LAYER_4. + */ + VIDEO_STREAM_LAYER_5 = 8, + /** + * 9: The video stream of layer_6, which has a lower resolution and bitrate than VIDEO_STREAM_LAYER_5. + */ + VIDEO_STREAM_LAYER_6 = 9, + }; struct VideoSubscriptionOptions { @@ -1567,7 +1630,8 @@ struct EncodedVideoFrameInfo { trackId(0), captureTimeMs(0), decodeTimeMs(0), - streamType(VIDEO_STREAM_HIGH) {} + streamType(VIDEO_STREAM_HIGH), + presentationMs(-1) {} EncodedVideoFrameInfo(const EncodedVideoFrameInfo& rhs) : uid(rhs.uid), @@ -1580,7 +1644,8 @@ struct EncodedVideoFrameInfo { trackId(rhs.trackId), captureTimeMs(rhs.captureTimeMs), decodeTimeMs(rhs.decodeTimeMs), - streamType(rhs.streamType) {} + streamType(rhs.streamType), + presentationMs(rhs.presentationMs) {} EncodedVideoFrameInfo& operator=(const EncodedVideoFrameInfo& rhs) { if (this == &rhs) return *this; @@ -1595,6 +1660,7 @@ struct EncodedVideoFrameInfo { captureTimeMs = rhs.captureTimeMs; decodeTimeMs = rhs.decodeTimeMs; streamType = rhs.streamType; + presentationMs = rhs.presentationMs; return *this; } @@ -1646,6 +1712,8 @@ struct EncodedVideoFrameInfo { */ VIDEO_STREAM_TYPE streamType; + // @technical preview + int64_t presentationMs; }; /** @@ -1695,17 +1763,27 @@ struct AdvanceOptions { */ COMPRESSION_PREFERENCE compressionPreference; + /** + * Whether to encode and send the alpha data to the remote when alpha data is present. + * The default value is false. + */ + bool encodeAlpha; + AdvanceOptions() : encodingPreference(PREFER_AUTO), - compressionPreference(PREFER_LOW_LATENCY) {} + compressionPreference(PREFER_LOW_LATENCY), + encodeAlpha(false) {} AdvanceOptions(ENCODING_PREFERENCE encoding_preference, - COMPRESSION_PREFERENCE compression_preference) : + COMPRESSION_PREFERENCE compression_preference, + bool encode_alpha) : encodingPreference(encoding_preference), - compressionPreference(compression_preference) {} + compressionPreference(compression_preference), + encodeAlpha(encode_alpha) {} bool operator==(const AdvanceOptions& rhs) const { return encodingPreference == rhs.encodingPreference && - compressionPreference == rhs.compressionPreference; + compressionPreference == rhs.compressionPreference && + encodeAlpha == rhs.encodeAlpha; } }; @@ -1728,6 +1806,17 @@ enum VIDEO_MIRROR_MODE_TYPE { VIDEO_MIRROR_MODE_DISABLED = 2, }; +#if defined(__APPLE__) && TARGET_OS_IOS +/** + * Camera capturer configuration for format type. + */ +enum CAMERA_FORMAT_TYPE { + /** 0: (Default) NV12. */ + CAMERA_FORMAT_NV12, + /** 1: BGRA. */ + CAMERA_FORMAT_BGRA, +}; +#endif /** Supported codec type bit mask. */ enum CODEC_CAP_MASK { @@ -1766,6 +1855,14 @@ struct CodecCapInfo { CodecCapInfo(): codecType(VIDEO_CODEC_NONE), codecCapMask(0) {} }; +/** FocalLengthInfo contains the IDs of the front and rear cameras, along with the wide-angle types. */ +struct FocalLengthInfo { + /** The camera direction. */ + int cameraDirection; + /** Camera focal segment type. */ + CAMERA_FOCAL_LENGTH_TYPE focalLengthType; +}; + /** * The definition of the VideoEncoderConfiguration struct. */ @@ -1885,7 +1982,7 @@ struct VideoEncoderConfiguration { orientationMode(m), degradationPreference(MAINTAIN_QUALITY), mirrorMode(mirror), - advanceOptions(PREFER_AUTO, PREFER_LOW_LATENCY) {} + advanceOptions(PREFER_AUTO, PREFER_LOW_LATENCY, false) {} VideoEncoderConfiguration(int width, int height, int f, int b, ORIENTATION_MODE m, VIDEO_MIRROR_MODE_TYPE mirror = VIDEO_MIRROR_MODE_DISABLED) : codecType(VIDEO_CODEC_NONE), dimensions(width, height), @@ -1895,7 +1992,7 @@ struct VideoEncoderConfiguration { orientationMode(m), degradationPreference(MAINTAIN_QUALITY), mirrorMode(mirror), - advanceOptions(PREFER_AUTO, PREFER_LOW_LATENCY) {} + advanceOptions(PREFER_AUTO, PREFER_LOW_LATENCY, false) {} VideoEncoderConfiguration(const VideoEncoderConfiguration& config) : codecType(config.codecType), dimensions(config.dimensions), @@ -1915,7 +2012,7 @@ struct VideoEncoderConfiguration { orientationMode(ORIENTATION_MODE_ADAPTIVE), degradationPreference(MAINTAIN_QUALITY), mirrorMode(VIDEO_MIRROR_MODE_DISABLED), - advanceOptions(PREFER_AUTO, PREFER_LOW_LATENCY) {} + advanceOptions(PREFER_AUTO, PREFER_LOW_LATENCY, false) {} VideoEncoderConfiguration& operator=(const VideoEncoderConfiguration& rhs) { if (this == &rhs) return *this; @@ -1989,15 +2086,78 @@ struct SimulcastStreamConfig { */ int kBitrate; /** - * he capture frame rate (fps) of the local video. The default value is 5. + * The capture frame rate (fps) of the local video. The default value is 5. */ int framerate; SimulcastStreamConfig() : dimensions(160, 120), kBitrate(65), framerate(5) {} + SimulcastStreamConfig(const SimulcastStreamConfig& other) : dimensions(other.dimensions), kBitrate(other.kBitrate), framerate(other.framerate) {} bool operator==(const SimulcastStreamConfig& rhs) const { return dimensions == rhs.dimensions && kBitrate == rhs.kBitrate && framerate == rhs.framerate; } }; +/** + * The configuration of the multi-layer video stream. + */ +struct SimulcastConfig { + /** + * The index of multi-layer video stream + */ + enum StreamLayerIndex { + /** + * 0: video stream index of layer_1 + */ + STREAM_LAYER_1 = 0, + /** + * 1: video stream index of layer_2 + */ + STREAM_LAYER_2 = 1, + /** + * 2: video stream index of layer_3 + */ + STREAM_LAYER_3 = 2, + /** + * 3: video stream index of layer_4 + */ + STREAM_LAYER_4 = 3, + /** + * 4: video stream index of layer_5 + */ + STREAM_LAYER_5 = 4, + /** + * 5: video stream index of layer_6 + */ + STREAM_LAYER_6 = 5, + /** + * 6: video stream index of low + */ + STREAM_LOW = 6, + /** + * 7: max count of video stream layers + */ + STREAM_LAYER_COUNT_MAX = 7 + }; + struct StreamLayerConfig { + /** + * The video frame dimension. The default value is 0. + */ + VideoDimensions dimensions; + /** + * The capture frame rate (fps) of the local video. The default value is 0. + */ + int framerate; + /** + * Whether to enable the corresponding layer of video stream. The default value is false. + */ + bool enable; + StreamLayerConfig() : dimensions(0, 0), framerate(0), enable(false) {} + }; + + /** + * The array of StreamLayerConfig, which contains STREAM_LAYER_COUNT_MAX layers of video stream at most. + */ + StreamLayerConfig configs[STREAM_LAYER_COUNT_MAX]; +}; /** * The location of the target area relative to the screen or window. If you do not set this parameter, * the SDK selects the whole screen or window. @@ -2595,6 +2755,10 @@ enum VIDEO_APPLICATION_SCENARIO_TYPE { * 1: Meeting Scenario. This scenario is the best QoE practice of meeting application. */ APPLICATION_SCENARIO_MEETING = 1, + /** + * 2: Video Call Scenario. This scenario is used to optimize the video experience in video application, like 1v1 video call. + */ + APPLICATION_SCENARIO_1V1 = 2, }; /** @@ -2639,6 +2803,27 @@ enum CAPTURE_BRIGHTNESS_LEVEL_TYPE { CAPTURE_BRIGHTNESS_LEVEL_DARK = 2, }; +enum CAMERA_STABILIZATION_MODE { + /** The camera stabilization mode is disabled. + */ + CAMERA_STABILIZATION_MODE_OFF = -1, + /** device choose stabilization mode automatically. + */ + CAMERA_STABILIZATION_MODE_AUTO = 0, + /** stabilization mode level 1. + */ + CAMERA_STABILIZATION_MODE_LEVEL_1 = 1, + /** stabilization mode level 2. + */ + CAMERA_STABILIZATION_MODE_LEVEL_2 = 2, + /** stabilization mode level 3. + */ + CAMERA_STABILIZATION_MODE_LEVEL_3 = 3, + /** The maximum level of the camera stabilization mode. + */ + CAMERA_STABILIZATION_MODE_MAX_LEVEL = CAMERA_STABILIZATION_MODE_LEVEL_3, +}; + /** * Local audio states. */ @@ -2792,6 +2977,16 @@ enum LOCAL_VIDEO_STREAM_REASON { * Check whether the ID of the video device is valid. */ LOCAL_VIDEO_STREAM_REASON_DEVICE_INVALID_ID = 10, + /** + * 14: (Android only) Video capture was interrupted, possibly due to the camera being occupied + * or some policy reasons such as background termination. + */ + LOCAL_VIDEO_STREAM_REASON_DEVICE_INTERRUPT = 14, + /** + * 15: (Android only) The device may need to be shut down and restarted to restore camera function, + * or there may be a persistent hardware problem. + */ + LOCAL_VIDEO_STREAM_REASON_DEVICE_FATAL_ERROR = 15, /** * 101: The current video capture device is unavailable due to excessive system pressure. */ @@ -2835,7 +3030,7 @@ enum LOCAL_VIDEO_STREAM_REASON { LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_WINDOW_HIDDEN = 25, /** 26: (Windows only) The local screen capture window is recovered from its hidden state. */ LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_WINDOW_RECOVER_FROM_HIDDEN = 26, - /** 27:(Windows only) The window is recovered from miniminzed */ + /** 27: (Windows and macOS only) The window is recovered from miniminzed */ LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_WINDOW_RECOVER_FROM_MINIMIZED = 27, /** * 28: The screen capture paused. @@ -2847,7 +3042,14 @@ enum LOCAL_VIDEO_STREAM_REASON { LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_PAUSED = 28, /** 29: The screen capture is resumed. */ LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_RESUMED = 29, - + /** 30: The shared display has been disconnected */ + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_DISPLAY_DISCONNECTED = 30, + /* 30: (HMOS only) ScreenCapture stopped by user */ + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_STOPPED_BY_USER = 31, + /* 31: (HMOS only) ScreenCapture interrupted by other screen capture */ + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_INTERRUPTED_BY_OTHER = 32, + /* 32: (HMOS only) ScreenCapture stopped by SIM call */ + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_STOPPED_BY_CALL = 33, }; /** @@ -2924,6 +3126,14 @@ enum REMOTE_AUDIO_STATE_REASON * 7: The remote user leaves the channel. */ REMOTE_AUDIO_REASON_REMOTE_OFFLINE = 7, + /** + * 8: The local user does not receive any audio packet from remote user. + */ + REMOTE_AUDIO_REASON_NO_PACKET_RECEIVE = 8, + /** + * 9: The local user receives remote audio packet but fails to play. + */ + REMOTE_AUDIO_REASON_LOCAL_PLAY_FAILED = 9, }; /** @@ -3044,7 +3254,7 @@ enum REMOTE_USER_STATE { struct VideoTrackInfo { VideoTrackInfo() : isLocal(false), ownerUid(0), trackId(0), channelId(OPTIONAL_NULLPTR) - , streamType(VIDEO_STREAM_HIGH), codecType(VIDEO_CODEC_H265) + , codecType(VIDEO_CODEC_H265) , encodedFrameOnly(false), sourceType(VIDEO_SOURCE_CAMERA_PRIMARY) , observationPosition(agora::media::base::POSITION_POST_CAPTURER) {} /** @@ -3065,10 +3275,6 @@ struct VideoTrackInfo { * The channel ID of the video track. */ const char* channelId; - /** - * The video stream type: #VIDEO_STREAM_TYPE. - */ - VIDEO_STREAM_TYPE streamType; /** * The video codec type: #VIDEO_CODEC_TYPE. */ @@ -4116,12 +4322,14 @@ enum CLIENT_ROLE_CHANGE_FAILED_REASON { CLIENT_ROLE_CHANGE_FAILED_NOT_AUTHORIZED = 2, /** * 3: The operation of changing role is timeout. + * @deprecated This reason is deprecated. */ - CLIENT_ROLE_CHANGE_FAILED_REQUEST_TIME_OUT = 3, + CLIENT_ROLE_CHANGE_FAILED_REQUEST_TIME_OUT __deprecated = 3, /** * 4: The operation of changing role is interrupted since we lost connection with agora service. + * @deprecated This reason is deprecated. */ - CLIENT_ROLE_CHANGE_FAILED_CONNECTION_FAILED = 4, + CLIENT_ROLE_CHANGE_FAILED_CONNECTION_FAILED __deprecated = 4, }; /** @@ -4363,6 +4571,85 @@ struct BeautyOptions { BeautyOptions() : lighteningContrastLevel(LIGHTENING_CONTRAST_NORMAL), lighteningLevel(0), smoothnessLevel(0), rednessLevel(0), sharpnessLevel(0) {} }; +/** Face shape area options. This structure defines options for facial adjustments on different facial areas. + * + * @technical preview + */ +struct FaceShapeAreaOptions { + /** The specific facial area to be adjusted. + */ + enum FACE_SHAPE_AREA { + /** (Default) Invalid area. */ + FACE_SHAPE_AREA_NONE = -1, + /** Head Scale, reduces the size of head. */ + FACE_SHAPE_AREA_HEADSCALE = 0, + /** Forehead, adjusts the size of forehead. */ + FACE_SHAPE_AREA_FOREHEAD = 1, + /** Face Contour, slims the facial contour. */ + FACE_SHAPE_AREA_FACECONTOUR = 2, + /** Face Length, adjusts the length of face. */ + FACE_SHAPE_AREA_FACELENGTH = 3, + /** Face Width, narrows the width of face. */ + FACE_SHAPE_AREA_FACEWIDTH = 4, + /** Cheekbone, adjusts the size of cheekbone. */ + FACE_SHAPE_AREA_CHEEKBONE = 5, + /** Cheek, adjusts the size of cheek. */ + FACE_SHAPE_AREA_CHEEK = 6, + /** Chin, adjusts the length of chin. */ + FACE_SHAPE_AREA_CHIN = 7, + /** Eye Scale, adjusts the size of eyes. */ + FACE_SHAPE_AREA_EYESCALE = 8, + /** Nose Length, adjusts the length of nose. */ + FACE_SHAPE_AREA_NOSELENGTH = 9, + /** Nose Width, adjusts the width of nose. */ + FACE_SHAPE_AREA_NOSEWIDTH = 10, + /** Mouth Scale, adjusts the size of mouth. */ + FACE_SHAPE_AREA_MOUTHSCALE = 11, + }; + + /** The specific facial area to be adjusted, See #FACE_SHAPE_AREA. + */ + FACE_SHAPE_AREA shapeArea; + + /** The intensity of the pinching effect applied to the specified facial area. + * For the following area values: #FACE_SHAPE_AREA_FOREHEAD, #FACE_SHAPE_AREA_FACELENGTH, #FACE_SHAPE_AREA_CHIN, #FACE_SHAPE_AREA_NOSELENGTH, #FACE_SHAPE_AREA_NOSEWIDTH, #FACE_SHAPE_AREA_MOUTHSCALE, the value ranges from -100 to 100. + * The default value is 0. The greater the absolute value, the stronger the intensity applied to the specified facial area, and negative values indicate the opposite direction. + * For enumeration values other than the above, the value ranges from 0 to 100. The default value is 0. The greater the value, the stronger the intensity applied to the specified facial area. + */ + int shapeIntensity; + + FaceShapeAreaOptions(FACE_SHAPE_AREA shapeArea, int areaIntensity) : shapeArea(shapeArea), shapeIntensity(areaIntensity) {} + + FaceShapeAreaOptions() : shapeArea(FACE_SHAPE_AREA_NONE), shapeIntensity(0) {} +}; + +/** Face shape beauty options. This structure defines options for facial adjustments of different facial styles. + * + * @technical preview + */ +struct FaceShapeBeautyOptions { + /** The face shape style. + */ + enum FACE_SHAPE_BEAUTY_STYLE { + /** (Default) Female face shape style. */ + FACE_SHAPE_BEAUTY_STYLE_FEMALE = 0, + /** Male face shape style. */ + FACE_SHAPE_BEAUTY_STYLE_MALE = 1, + }; + + /** The face shape style, See #FACE_SHAPE_BEAUTY_STYLE. + */ + FACE_SHAPE_BEAUTY_STYLE shapeStyle; + + /** The intensity of the pinching effect applied to the specified facial style. The value ranges from 0 (original) to 100. The default value is 0. The greater the value, the stronger the intensity applied to face pinching. + */ + int styleIntensity; + + FaceShapeBeautyOptions(FACE_SHAPE_BEAUTY_STYLE shapeStyle, int styleIntensity) : shapeStyle(shapeStyle), styleIntensity(styleIntensity) {} + + FaceShapeBeautyOptions() : shapeStyle(FACE_SHAPE_BEAUTY_STYLE_FEMALE), styleIntensity(50) {} +}; + struct LowlightEnhanceOptions { /** * The low-light enhancement mode. @@ -4686,6 +4973,7 @@ enum VOICE_BEAUTIFIER_PRESET { * - `ROOM_ACOUSTICS_PHONOGRAPH` * - `ROOM_ACOUSTICS_SPACIAL` * - `ROOM_ACOUSTICS_ETHEREAL` + * - `ROOM_ACOUSTICS_CHORUS` * - `VOICE_CHANGER_EFFECT_UNCLE` * - `VOICE_CHANGER_EFFECT_OLDMAN` * - `VOICE_CHANGER_EFFECT_BOY` @@ -4747,6 +5035,14 @@ enum AUDIO_EFFECT_PRESET { * setting this enumerator. */ ROOM_ACOUSTICS_VIRTUAL_SURROUND_SOUND = 0x02010900, + /** The voice effect for chorus. + * + * @note: To achieve better audio effect quality, Agora recommends calling \ref + * IRtcEngine::setAudioProfile "setAudioProfile" and setting the `profile` parameter to + * `AUDIO_PROFILE_MUSIC_HIGH_QUALITY(4)` or `AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO(5)` before + * setting this enumerator. + */ + ROOM_ACOUSTICS_CHORUS = 0x02010D00, /** A middle-aged man's voice. * * @note @@ -4879,6 +5175,41 @@ enum HEADPHONE_EQUALIZER_PRESET { HEADPHONE_EQUALIZER_INEAR = 0x04000002 }; +/** The options for SDK voice AI tuner. + */ +enum VOICE_AI_TUNER_TYPE { + /** Uncle, deep and magnetic male voice. + */ + VOICE_AI_TUNER_MATURE_MALE, + /** Fresh male, refreshing and sweet male voice. + */ + VOICE_AI_TUNER_FRESH_MALE, + /** Big sister, deep and charming female voice. + */ + VOICE_AI_TUNER_ELEGANT_FEMALE, + /** Lolita, high-pitched and cute female voice. + */ + VOICE_AI_TUNER_SWEET_FEMALE, + /** Warm man singing, warm and melodic male voice that is suitable for male lyrical songs. + */ + VOICE_AI_TUNER_WARM_MALE_SINGING, + /** Gentle female singing, soft and delicate female voice that is suitable for female lyrical songs. + */ + VOICE_AI_TUNER_GENTLE_FEMALE_SINGING, + /** Smoky uncle singing, unique husky male voice that is suitable for rock or blues songs. + */ + VOICE_AI_TUNER_HUSKY_MALE_SINGING, + /** Warm big sister singing, warm and mature female voice that is suitable for emotionally powerful songs. + */ + VOICE_AI_TUNER_WARM_ELEGANT_FEMALE_SINGING, + /** Forceful male singing, strong and powerful male voice that is suitable for passionate songs. + */ + VOICE_AI_TUNER_POWERFUL_MALE_SINGING, + /** Dreamy female singing, dreamlike and soft female voice that is suitable for airy and dream-like songs. + */ + VOICE_AI_TUNER_DREAMY_FEMALE_SINGING, +}; + /** * Screen sharing configurations. */ @@ -5191,6 +5522,10 @@ enum AREA_CODE { AREA_CODE_GLOB = (0xFFFFFFFF) }; +/** + Extra region code + @technical preview +*/ enum AREA_CODE_EX { /** * Oceania @@ -5216,6 +5551,10 @@ enum AREA_CODE_EX { * United States */ AREA_CODE_US = 0x00000800, + /** + * Russia + */ + AREA_CODE_RU = 0x00001000, /** * The global area (except China) */ @@ -5534,10 +5873,13 @@ struct EncryptionConfig { * In this case, ensure that this parameter is not 0. */ uint8_t encryptionKdfSalt[32]; + + bool datastreamEncryptionEnabled; EncryptionConfig() : encryptionMode(AES_128_GCM2), - encryptionKey(OPTIONAL_NULLPTR) + encryptionKey(OPTIONAL_NULLPTR), + datastreamEncryptionEnabled(false) { memset(encryptionKdfSalt, 0, sizeof(encryptionKdfSalt)); } @@ -5577,13 +5919,21 @@ enum ENCRYPTION_ERROR_TYPE { */ ENCRYPTION_ERROR_INTERNAL_FAILURE = 0, /** - * 1: Decryption errors. Ensure that the receiver and the sender use the same encryption mode and key. + * 1: MediaStream decryption errors. Ensure that the receiver and the sender use the same encryption mode and key. */ ENCRYPTION_ERROR_DECRYPTION_FAILURE = 1, /** - * 2: Encryption errors. + * 2: MediaStream encryption errors. */ ENCRYPTION_ERROR_ENCRYPTION_FAILURE = 2, + /** + * 3: DataStream decryption errors. Ensure that the receiver and the sender use the same encryption mode and key. + */ + ENCRYPTION_ERROR_DATASTREAM_DECRYPTION_FAILURE = 3, + /** + * 4: DataStream encryption errors. + */ + ENCRYPTION_ERROR_DATASTREAM_ENCRYPTION_FAILURE = 4, }; enum UPLOAD_ERROR_REASON @@ -5625,8 +5975,8 @@ enum STREAM_SUBSCRIBE_STATE { * - Calls `enableLocalAudio(false)` or `enableLocalVideo(false)` to disable the local audio or video capture. * - The role of the remote user is audience. * - The local user calls the following methods to stop receiving remote streams: - * - Calls `muteRemoteAudioStream(true)`, `muteAllRemoteAudioStreams(true)` or `setDefaultMuteAllRemoteAudioStreams(true)` to stop receiving the remote audio streams. - * - Calls `muteRemoteVideoStream(true)`, `muteAllRemoteVideoStreams(true)` or `setDefaultMuteAllRemoteVideoStreams(true)` to stop receiving the remote video streams. + * - Calls `muteRemoteAudioStream(true)`, `muteAllRemoteAudioStreams(true)` to stop receiving the remote audio streams. + * - Calls `muteRemoteVideoStream(true)`, `muteAllRemoteVideoStreams(true)` to stop receiving the remote video streams. */ SUB_STATE_NO_SUBSCRIBED = 1, /** @@ -5717,7 +6067,12 @@ enum EAR_MONITORING_FILTER_TYPE { /** * 4: Enable noise suppression to the in-ear monitor. */ - EAR_MONITORING_FILTER_NOISE_SUPPRESSION = (1<<2) + EAR_MONITORING_FILTER_NOISE_SUPPRESSION = (1<<2), + /** + * 32768: Enable audio filters by reuse post-processing filter to the in-ear monitor. + * This bit is intended to be used in exclusive mode, which means, if this bit is set, all other bits will be disregarded. + */ + EAR_MONITORING_FILTER_REUSE_POST_PROCESSING_FILTER = (1<<15), }; /** @@ -5750,7 +6105,7 @@ enum THREAD_PRIORITY_TYPE { CRITICAL = 5, }; -#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) +#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) || defined(__OHOS__) /** * The video configuration for the shared screen stream. diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraExtensionProviderEntry.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraExtensionProviderEntry.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraExtensionVersion.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraExtensionVersion.h old mode 100755 new mode 100644 index 988e5ecc8..da4d563a3 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraExtensionVersion.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraExtensionVersion.h @@ -58,6 +58,7 @@ class IExtensionProvider; class IExtensionProviderV2; class IExtensionProviderV3; class IAudioFilter; +class IAudioFilterV2; class IExtensionVideoFilter; class IScreenCaptureSource; @@ -85,6 +86,13 @@ struct ExtensionInterfaceVersion { } }; +template <> +struct ExtensionInterfaceVersion { + static ExtensionVersion Version() { + return BUMP_MAJOR_VERSION(ExtensionInterfaceVersion::Version()); + } +}; + template <> struct ExtensionInterfaceVersion { static ExtensionVersion Version() { diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraMediaBase.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraMediaBase.h old mode 100755 new mode 100644 index d56337745..8120acb3f --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraMediaBase.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraMediaBase.h @@ -35,6 +35,32 @@ static const unsigned int DEFAULT_CONNECTION_ID = 0; static const unsigned int DUMMY_CONNECTION_ID = (std::numeric_limits::max)(); struct EncodedVideoFrameInfo; +/** +* The definition of extension context types. +**/ +struct ExtensionContext { + /** + * Whether the uid is valid. + * - true: The uid is valid. + * - false: The uid is invalid. + */ + bool isValid; + /** + * The ID of the user. + * A uid of 0 indicates the local user, and a uid greater than 0 represents a remote user. + */ + uid_t uid; + /** + * The provider name of the current extension. + */ + const char *providerName; + /** + * The extension name of the current extension. + */ + const char *extensionName; + ExtensionContext():isValid(false), uid(0), providerName(NULL), extensionName(NULL) {} +}; + /** * Video source types definition. @@ -88,6 +114,9 @@ enum VIDEO_SOURCE_TYPE { /** Video for fourth screen sharing. */ VIDEO_SOURCE_SCREEN_FOURTH = 14, + /** Video for voice drive. + */ + VIDEO_SOURCE_SPEECH_DRIVEN = 15, VIDEO_SOURCE_UNKNOWN = 100 }; @@ -242,6 +271,10 @@ enum MEDIA_SOURCE_TYPE { * 12: Video for transcoded. */ TRANSCODED_VIDEO_SOURCE = 12, + /** + * 13: Video for voice drive. + */ + SPEECH_DRIVEN_VIDEO_SOURCE = 13, /** * 100: Internal Usage only. */ @@ -395,24 +428,31 @@ struct AudioPcmFrame { rtc::BYTES_PER_SAMPLE bytes_per_sample; /** The audio frame data. */ int16_t data_[kMaxDataSizeSamples]; + + /** + * @technical preview + * data_[kMaxDataSizeSamples] is real stereo data + */ + bool is_stereo_; AudioPcmFrame& operator=(const AudioPcmFrame& src) { - if(this == &src) { + if (this == &src) { return *this; } - this->capture_timestamp = src.capture_timestamp; - this->samples_per_channel_ = src.samples_per_channel_; - this->sample_rate_hz_ = src.sample_rate_hz_; - this->bytes_per_sample = src.bytes_per_sample; - this->num_channels_ = src.num_channels_; + capture_timestamp = src.capture_timestamp; + samples_per_channel_ = src.samples_per_channel_; + sample_rate_hz_ = src.sample_rate_hz_; + bytes_per_sample = src.bytes_per_sample; + num_channels_ = src.num_channels_; + is_stereo_ = src.is_stereo_; size_t length = src.samples_per_channel_ * src.num_channels_; if (length > kMaxDataSizeSamples) { length = kMaxDataSizeSamples; } - memcpy(this->data_, src.data_, length * sizeof(int16_t)); + memcpy(data_, src.data_, length * sizeof(int16_t)); return *this; } @@ -422,7 +462,8 @@ struct AudioPcmFrame { samples_per_channel_(0), sample_rate_hz_(0), num_channels_(0), - bytes_per_sample(rtc::TWO_BYTES_PER_SAMPLE) { + bytes_per_sample(rtc::TWO_BYTES_PER_SAMPLE), + is_stereo_(false) { memset(data_, 0, sizeof(data_)); } @@ -431,7 +472,8 @@ struct AudioPcmFrame { samples_per_channel_(src.samples_per_channel_), sample_rate_hz_(src.sample_rate_hz_), num_channels_(src.num_channels_), - bytes_per_sample(src.bytes_per_sample) { + bytes_per_sample(src.bytes_per_sample), + is_stereo_(src.is_stereo_) { size_t length = src.samples_per_channel_ * src.num_channels_; if (length > kMaxDataSizeSamples) { length = kMaxDataSizeSamples; @@ -502,6 +544,10 @@ enum VIDEO_PIXEL_FORMAT { 14: pixel format for iOS CVPixelBuffer BGRA */ VIDEO_CVPIXEL_BGRA = 14, + /** + 15: pixel format for iOS CVPixelBuffer P010(10bit NV12) + */ + VIDEO_CVPIXEL_P010 = 15, /** * 16: I422. */ @@ -510,6 +556,11 @@ enum VIDEO_PIXEL_FORMAT { * 17: ID3D11Texture2D, only support DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_TYPELESS, DXGI_FORMAT_NV12 texture format */ VIDEO_TEXTURE_ID3D11TEXTURE2D = 17, + /** + * 18: I010. 10bit I420 data. + * @technical preview + */ + VIDEO_PIXEL_I010 = 18, }; /** @@ -565,6 +616,191 @@ class IVideoFrameMetaInfo { virtual const char* getMetaInfoStr(META_INFO_KEY key) const = 0; }; +struct ColorSpace { + enum PrimaryID { + // The indices are equal to the values specified in T-REC H.273 Table 2. + PRIMARYID_BT709 = 1, + PRIMARYID_UNSPECIFIED = 2, + PRIMARYID_BT470M = 4, + PRIMARYID_BT470BG = 5, + PRIMARYID_SMPTE170M = 6, // Identical to BT601 + PRIMARYID_SMPTE240M = 7, + PRIMARYID_FILM = 8, + PRIMARYID_BT2020 = 9, + PRIMARYID_SMPTEST428 = 10, + PRIMARYID_SMPTEST431 = 11, + PRIMARYID_SMPTEST432 = 12, + PRIMARYID_JEDECP22 = 22, // Identical to EBU3213-E + }; + + enum RangeID { + // The indices are equal to the values specified at + // https://www.webmproject.org/docs/container/#colour for the element Range. + RANGEID_INVALID = 0, + // Limited Rec. 709 color range with RGB values ranging from 16 to 235. + RANGEID_LIMITED = 1, + // Full RGB color range with RGB valees from 0 to 255. + RANGEID_FULL = 2, + // Range is defined by MatrixCoefficients/TransferCharacteristics. + RANGEID_DERIVED = 3, + }; + + enum MatrixID { + // The indices are equal to the values specified in T-REC H.273 Table 4. + MATRIXID_RGB = 0, + MATRIXID_BT709 = 1, + MATRIXID_UNSPECIFIED = 2, + MATRIXID_FCC = 4, + MATRIXID_BT470BG = 5, + MATRIXID_SMPTE170M = 6, + MATRIXID_SMPTE240M = 7, + MATRIXID_YCOCG = 8, + MATRIXID_BT2020_NCL = 9, + MATRIXID_BT2020_CL = 10, + MATRIXID_SMPTE2085 = 11, + MATRIXID_CDNCLS = 12, + MATRIXID_CDCLS = 13, + MATRIXID_BT2100_ICTCP = 14, + }; + + enum TransferID { + // The indices are equal to the values specified in T-REC H.273 Table 3. + TRANSFERID_BT709 = 1, + TRANSFERID_UNSPECIFIED = 2, + TRANSFERID_GAMMA22 = 4, + TRANSFERID_GAMMA28 = 5, + TRANSFERID_SMPTE170M = 6, + TRANSFERID_SMPTE240M = 7, + TRANSFERID_LINEAR = 8, + TRANSFERID_LOG = 9, + TRANSFERID_LOG_SQRT = 10, + TRANSFERID_IEC61966_2_4 = 11, + TRANSFERID_BT1361_ECG = 12, + TRANSFERID_IEC61966_2_1 = 13, + TRANSFERID_BT2020_10 = 14, + TRANSFERID_BT2020_12 = 15, + TRANSFERID_SMPTEST2084 = 16, + TRANSFERID_SMPTEST428 = 17, + TRANSFERID_ARIB_STD_B67 = 18, + }; + + PrimaryID primaries; + TransferID transfer; + MatrixID matrix; + RangeID range; + + ColorSpace() + : primaries(PRIMARYID_UNSPECIFIED), transfer(TRANSFERID_UNSPECIFIED), + matrix(MATRIXID_UNSPECIFIED), range(RANGEID_INVALID) {} + + bool validate() const { + return primaries != PRIMARYID_UNSPECIFIED || transfer != TRANSFERID_UNSPECIFIED || + matrix != MATRIXID_UNSPECIFIED || + range != RANGEID_INVALID; + } +}; + +/** + * The definition of the Hdr10MetadataInfo struct. + */ +struct Hdr10MetadataInfo { + /** + * The x coordinates of the red value in the CIE1931 color space. The values need to normalized to 50,000. + */ + uint16_t redPrimaryX; + /** + * The y coordinates of the red value in the CIE1931 color space. The values need to normalized to 50,000. + */ + uint16_t redPrimaryY; + /** + * The x coordinates of the green value in the CIE1931 color space. The values need to normalized to 50,000. + */ + uint16_t greenPrimaryX; + /** + * The y coordinates of the green value in the CIE1931 color space. The values need to normalized to 50,000. + */ + uint16_t greenPrimaryY; + /** + * The x coordinates of the blue value in the CIE1931 color space. The values need to normalized to 50,000. + */ + uint16_t bluePrimaryX; + /** + * The y coordinates of the blue value in the CIE1931 color space. The values need to normalized to 50,000. + */ + uint16_t bluePrimaryY; + /** + * The x coordinates of the white point in the CIE1931 color space.The values need to normalized to 50,000. + */ + uint16_t whitePointX; + /** + * The y coordinates of the white point in the CIE1931 color space.The values need to normalized to 50,000. + */ + uint16_t whitePointY; + /** + * The maximum number of nits of the display used to master the content. The values need to normalized to 10,000. + */ + unsigned int maxMasteringLuminance; + /** + * The minimum number of nits of the display used to master the content. The values need to normalized to 10,000. + */ + unsigned int minMasteringLuminance; + /** + * The maximum content light level (MaxCLL). This is the nit value corresponding to the brightest pixel used anywhere in the content. + */ + uint16_t maxContentLightLevel; + /** + * The maximum frame average light level (MaxFALL). This is the nit value corresponding to the average luminance of the frame which has the brightest average luminance anywhere in the content. + */ + uint16_t maxFrameAverageLightLevel; + + Hdr10MetadataInfo() + : redPrimaryX(0), + redPrimaryY(0), + greenPrimaryX(0), + greenPrimaryY(0), + bluePrimaryX(0), + bluePrimaryY(0), + whitePointX(0), + whitePointY(0), + maxMasteringLuminance(0), + minMasteringLuminance(0), + maxContentLightLevel(0), + maxFrameAverageLightLevel(0){} + + bool validate() const { + return maxContentLightLevel >= 0 && maxContentLightLevel <= 20000 && + maxFrameAverageLightLevel >= 0 && + maxFrameAverageLightLevel <= 20000; + } +}; + +/** + * The relative position between alphabuffer and the frame. + */ +enum ALPHA_STITCH_MODE { + /** + * 0: Normal frame without alphabuffer stitched + */ + NO_ALPHA_STITCH = 0, + /** + * 1: Alphabuffer is above the frame + */ + ALPHA_STITCH_UP = 1, + /** + * 2: Alphabuffer is below the frame + */ + ALPHA_STITCH_BELOW = 2, + /** + * 3: Alphabuffer is on the left of frame + */ + ALPHA_STITCH_LEFT = 3, + /** + * 4: Alphabuffer is on the right of frame + */ + ALPHA_STITCH_RIGHT = 4, +}; + + /** * The definition of the ExternalVideoFrame struct. */ @@ -584,11 +820,14 @@ struct ExternalVideoFrame { eglContext(NULL), eglType(EGL_CONTEXT10), textureId(0), - metadata_buffer(NULL), - metadata_size(0), + fenceObject(0), + metadataBuffer(NULL), + metadataSize(0), alphaBuffer(NULL), - d3d11_texture_2d(NULL), - texture_slice_index(0){} + fillAlphaBuffer(false), + alphaStitchMode(NO_ALPHA_STITCH), + d3d11Texture2d(NULL), + textureSliceIndex(0){} /** * The EGL context type. @@ -690,6 +929,11 @@ struct ExternalVideoFrame { * [Texture related parameter] Incoming 4 × 4 transformational matrix. The typical value is a unit matrix. */ int textureId; + /** + * [Texture related parameter] The fence object related to the textureId parameter, indicating the synchronization status of the video data in Texture format. + * The default value is 0 + */ + long long fenceObject; /** * [Texture related parameter] Incoming 4 × 4 transformational matrix. The typical value is a unit matrix. */ @@ -698,28 +942,53 @@ struct ExternalVideoFrame { * [Texture related parameter] The MetaData buffer. * The default value is NULL */ - uint8_t* metadata_buffer; + uint8_t* metadataBuffer; /** * [Texture related parameter] The MetaData size. * The default value is 0 */ - int metadata_size; + int metadataSize; /** - * Indicates the output data of the portrait segmentation algorithm, which is consistent with the size of the video frame. - * The value range of each pixel is [0,255], where 0 represents the background; 255 represents the foreground (portrait). - * The default value is NULL + * Indicates the alpha channel of current frame, which is consistent with the dimension of the video frame. + * The value range of each pixel is [0,255], where 0 represents the background; 255 represents the foreground. + * The default value is NULL. */ uint8_t* alphaBuffer; + /** + * [For bgra or rgba only] Extract alphaBuffer from bgra or rgba data. Set it true if you do not explicitly specify the alphabuffer. + * The default value is false + */ + bool fillAlphaBuffer; + /** + * The relative position between alphabuffer and the frame. + * 0: Normal frame; + * 1: Alphabuffer is above the frame; + * 2: Alphabuffer is below the frame; + * 3: Alphabuffer is on the left of frame; + * 4: Alphabuffer is on the right of frame; + * The default value is 0. + */ + ALPHA_STITCH_MODE alphaStitchMode; /** * [For Windows only] The pointer of ID3D11Texture2D used by the video frame. */ - void *d3d11_texture_2d; + void *d3d11Texture2d; /** * [For Windows only] The index of ID3D11Texture2D array used by the video frame. */ - int texture_slice_index; + int textureSliceIndex; + + /** + * metadata info used for hdr video data + */ + Hdr10MetadataInfo hdr10MetadataInfo; + + /** + * The ColorSpace of the video frame. + */ + ColorSpace colorSpace; }; /** @@ -745,6 +1014,7 @@ struct VideoFrame { textureId(0), d3d11Texture2d(NULL), alphaBuffer(NULL), + alphaStitchMode(NO_ALPHA_STITCH), pixelBuffer(NULL), metaInfo(NULL){ memset(matrix, 0, sizeof(matrix)); @@ -827,11 +1097,21 @@ struct VideoFrame { */ float matrix[16]; /** - * Indicates the output data of the portrait segmentation algorithm, which is consistent with the size of the video frame. - * The value range of each pixel is [0,255], where 0 represents the background; 255 represents the foreground (portrait). - * The default value is NULL + * Indicates the alpha channel of current frame, which is consistent with the dimension of the video frame. + * The value range of each pixel is [0,255], where 0 represents the background; 255 represents the foreground. + * The default value is NULL. */ uint8_t* alphaBuffer; + /** + * The relative position between alphabuffer and the frame. + * 0: Normal frame; + * 1: Alphabuffer is above the frame; + * 2: Alphabuffer is below the frame; + * 3: Alphabuffer is on the left of frame; + * 4: Alphabuffer is on the right of frame; + * The default value is 0. + */ + ALPHA_STITCH_MODE alphaStitchMode; /** *The type of CVPixelBufferRef, for iOS and macOS only. */ @@ -840,6 +1120,16 @@ struct VideoFrame { * The pointer to IVideoFrameMetaInfo, which is the interface to get metainfo contents from VideoFrame. */ IVideoFrameMetaInfo* metaInfo; + + /** + * metadata info used for hdr video data + */ + Hdr10MetadataInfo hdr10MetadataInfo; + + /** + * The ColorSpace of the video frame + */ + ColorSpace colorSpace; }; /** @@ -981,6 +1271,10 @@ class IAudioFrameObserverBase { * The number of the audio track. */ int audioTrackNumber; + /** + * RTP timestamp of the first sample in the audio frame + */ + uint32_t rtpTimestamp; AudioFrame() : type(FRAME_TYPE_PCM16), samplesPerChannel(0), @@ -991,7 +1285,8 @@ class IAudioFrameObserverBase { renderTimeMs(0), avsync_type(0), presentationMs(0), - audioTrackNumber(0) {} + audioTrackNumber(0), + rtpTimestamp(0) {} }; enum AUDIO_FRAME_POSITION { @@ -1609,6 +1904,21 @@ struct MediaRecorderConfiguration { MediaRecorderConfiguration() : storagePath(NULL), containerFormat(FORMAT_MP4), streamType(STREAM_TYPE_BOTH), maxDurationMs(120000), recorderInfoUpdateInterval(0) {} MediaRecorderConfiguration(const char* path, MediaRecorderContainerFormat format, MediaRecorderStreamType type, int duration, int interval) : storagePath(path), containerFormat(format), streamType(type), maxDurationMs(duration), recorderInfoUpdateInterval(interval) {} }; + +class IFaceInfoObserver { +public: + /** + * Occurs when the face info is received. + * @param outFaceInfo The output face info. + * @return + * - true: The face info is valid. + * - false: The face info is invalid. + */ + virtual bool onFaceInfo(const char* outFaceInfo) = 0; + + virtual ~IFaceInfoObserver() {} +}; + /** * Information for the recording file. * diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraMediaPlayerTypes.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraMediaPlayerTypes.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraOptional.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraOptional.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraRefCountedObject.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraRefCountedObject.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraRefPtr.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraRefPtr.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraFileUploader.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraFileUploader.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraH265Transcoder.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraH265Transcoder.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraLog.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraLog.h old mode 100755 new mode 100644 index 2fae3aa13..20b6416ef --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraLog.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraLog.h @@ -37,6 +37,7 @@ OPTIONAL_ENUM_CLASS LOG_LEVEL { LOG_LEVEL_ERROR = 0x0004, LOG_LEVEL_FATAL = 0x0008, LOG_LEVEL_API_CALL = 0x0010, + LOG_LEVEL_DEBUG = 0x0020, }; /* diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaComponentFactory.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaComponentFactory.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaEngine.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaEngine.h old mode 100755 new mode 100644 index e57404a22..b3b92e9e4 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaEngine.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaEngine.h @@ -72,6 +72,21 @@ class IMediaEngine { * - < 0: Failure. */ virtual int registerVideoEncodedFrameObserver(IVideoEncodedFrameObserver* observer) = 0; + + /** + * Registers a face info observer object. + * + * @note + * Ensure that you call this method before \ref IRtcEngine::joinChannel "joinChannel". + * + * @param observer A pointer to the face info observer object: IFaceInfoObserver. + * + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int registerFaceInfoObserver(IFaceInfoObserver* observer) = 0; + /** * Pushes the external audio data to the app. * diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaPlayer.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaPlayer.h old mode 100755 new mode 100644 index bd3c7597c..25f48a4a2 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaPlayer.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaPlayer.h @@ -49,17 +49,6 @@ class IMediaPlayer : public RefCountInterface { */ virtual int open(const char* url, int64_t startPos) = 0; - /** - * @deprecated - * @brief Open media file or stream with custom soucrce. - * @param startPos Set the starting position for playback, in seconds - * @param observer dataProvider object - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int openWithCustomSource(int64_t startPos, media::base::IMediaPlayerCustomDataProvider* provider) __deprecated = 0; - /** * @brief Open a media file with a media file source. * @param source Media file source that you want to play, see `MediaSource` diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaPlayerSource.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaPlayerSource.h old mode 100755 new mode 100644 index 00be02233..99da405bc --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaPlayerSource.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaPlayerSource.h @@ -42,17 +42,6 @@ class IMediaPlayerSource : public RefCountInterface { * - < 0: Failure. */ virtual int open(const char* url, int64_t startPos) = 0; - - /** - * @deprecated - * @brief Open media file or stream with custom soucrce. - * @param startPos Set the starting position for playback, in seconds - * @param observer dataProvider object - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int openWithCustomSource(int64_t startPos, media::base::IMediaPlayerCustomDataProvider* provider) __deprecated = 0; /** * Opens a media file with a media file source. diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaRecorder.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaRecorder.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaRelayService.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaRelayService.h old mode 100755 new mode 100644 index c646eeaf3..7e5a18495 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaRelayService.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaRelayService.h @@ -41,7 +41,7 @@ class IMediaRelayService : public RefCountInterface { * - -2(ERR_INVALID_ARGUMENT): The argument is invalid. * - -5(ERR_REFUSED): The request is rejected. */ - virtual int stopChannelMediaRelay() = 0; + virtual int stopChannelMediaRelay(aosl_ref_t ares = AOSL_REF_INVALID) = 0; /** pause the channels for media stream relay. * @return @@ -51,7 +51,7 @@ class IMediaRelayService : public RefCountInterface { * - -2(ERR_INVALID_ARGUMENT): The argument is invalid. * - -5(ERR_REFUSED): The request is rejected. */ - virtual int pauseAllChannelMediaRelay() = 0; + virtual int pauseAllChannelMediaRelay(aosl_ref_t ares = AOSL_REF_INVALID) = 0; /** resume the channels for media stream relay. * @return @@ -61,7 +61,7 @@ class IMediaRelayService : public RefCountInterface { * - -2(ERR_INVALID_ARGUMENT): The argument is invalid. * - -5(ERR_REFUSED): The request is rejected. */ - virtual int resumeAllChannelMediaRelay() = 0; + virtual int resumeAllChannelMediaRelay(aosl_ref_t ares = AOSL_REF_INVALID) = 0; virtual void registerEventHandler(IMediaRelayObserver* eventObserver, void(*safeDeleter)(IMediaRelayObserver*) = NULL) = 0; virtual void unregisterEventHandler(IMediaRelayObserver* eventObserver) = 0; diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaStreamingSource.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaStreamingSource.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraParameter.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraParameter.h old mode 100755 new mode 100644 index 3114a11d0..f50afe9b5 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraParameter.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraParameter.h @@ -39,8 +39,7 @@ * set the video encoder mode (hardware or software) */ #define KEY_RTC_VIDEO_ENABLED_HW_ENCODER "engine.video.enable_hw_encoder" -#define KEY_RTC_VIDEO_HARDWARE_ENCODEING "che.hardware_encoding" -#define KEY_RTC_VIDEO_H264_HWENC "che.video.h264.hwenc" +#define KEY_RTC_VIDEO_HARDWARE_ENCODEING "che.hardware_encoding" // deprecated, please use engine.video.enable_hw_encoder /** * set the hardware video encoder provider (nv for nvidia or qsv for intel) */ @@ -50,7 +49,7 @@ * set the video decoder mode (hardware or software) */ #define KEY_RTC_VIDEO_ENABLED_HW_DECODER "engine.video.enable_hw_decoder" -#define KEY_RTC_VIDEO_HARDWARE_DECODING "che.hardware_decoding" +#define KEY_RTC_VIDEO_HARDWARE_DECODING "che.hardware_decoding" // deprecated, please use engine.video.enable_hw_decoder /** * set the hardware video decoder provider (h264_cuvid(default) or h264_qsv) @@ -115,7 +114,6 @@ /** * set the video codec type, such as "H264", "JPEG" */ -#define KEY_RTC_VIDEO_CODEC_TYPE "engine.video.codec_type" #define KEY_RTC_VIDEO_MINOR_STREAM_CODEC_INDEX "engine.video.minor_stream_codec_index" #define KEY_RTC_VIDEO_CODEC_INDEX "che.video.videoCodecIndex" /** diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRhythmPlayer.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRhythmPlayer.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtcEngine.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtcEngine.h old mode 100755 new mode 100644 index 25763dc3e..b4746d898 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtcEngine.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtcEngine.h @@ -230,19 +230,30 @@ enum AUDIO_REVERB_TYPE { }; enum STREAM_FALLBACK_OPTIONS { - /** 0: No fallback operation for the stream when the network - condition is poor. The stream quality cannot be guaranteed. */ - + /** 0: No fallback operation to a lower resolution stream when the network + condition is poor. Fallback to Scalable Video Coding (e.g. SVC) + is still possible, but the resolution remains in high stream. + The stream quality cannot be guaranteed. */ STREAM_FALLBACK_OPTION_DISABLED = 0, - /** 1: (Default) Under poor network conditions, the SDK will send or receive + /** 1: (Default) Under poor network conditions, the receiver SDK will receive agora::rtc::VIDEO_STREAM_LOW. You can only set this option in RtcEngineParameters::setRemoteSubscribeFallbackOption. Nothing happens when you set this in RtcEngineParameters::setLocalPublishFallbackOption. */ STREAM_FALLBACK_OPTION_VIDEO_STREAM_LOW = 1, - /** 2: Under poor network conditions, the SDK may receive - agora::rtc::VIDEO_STREAM_LOW first, but if the network still does - not allow displaying the video, the SDK will send or receive audio only. */ + /** 2: Under poor network conditions, the SDK may receive agora::rtc::VIDEO_STREAM_LOW first, + then agora::rtc::VIDEO_STREAM_LAYER_1 to agora::rtc::VIDEO_STREAM_LAYER_6 if the related layer exists. + If the network still does not allow displaying the video, the SDK will receive audio only. */ STREAM_FALLBACK_OPTION_AUDIO_ONLY = 2, + /** 3~8: If the receiver SDK uses RtcEngineParameters::setRemoteSubscribeFallbackOption,it will receive + one of the streams from agora::rtc::VIDEO_STREAM_LAYER_1 to agora::rtc::VIDEO_STREAM_LAYER_6 + if the related layer exists when the network condition is poor. The lower bound of fallback depends on + the STREAM_FALLBACK_OPTION_VIDEO_STREAM_LAYER_X. */ + STREAM_FALLBACK_OPTION_VIDEO_STREAM_LAYER_1 = 3, + STREAM_FALLBACK_OPTION_VIDEO_STREAM_LAYER_2 = 4, + STREAM_FALLBACK_OPTION_VIDEO_STREAM_LAYER_3 = 5, + STREAM_FALLBACK_OPTION_VIDEO_STREAM_LAYER_4 = 6, + STREAM_FALLBACK_OPTION_VIDEO_STREAM_LAYER_5 = 7, + STREAM_FALLBACK_OPTION_VIDEO_STREAM_LAYER_6 = 8, }; enum PRIORITY_TYPE { @@ -341,6 +352,9 @@ struct LocalVideoStats * - hardware = 1. */ int hwEncoderAccelerating; + /** The dimensions of the simulcast streams's encoding frame. + */ + VideoDimensions simulcastDimensions[SimulcastConfig::STREAM_LAYER_COUNT_MAX]; }; /** @@ -443,6 +457,10 @@ struct RemoteAudioStats * The total number of audio bytes received (bytes), inluding the FEC bytes, represented by an aggregate value. */ unsigned int rxAudioBytes; + /** + * The end-to-end delay (ms) from the sender to the receiver. + */ + int e2eDelay; RemoteAudioStats() : uid(0), @@ -462,7 +480,8 @@ struct RemoteAudioStats publishDuration(0), qoeQuality(0), qualityChangedReason(0), - rxAudioBytes(0) {} + rxAudioBytes(0), + e2eDelay(0) {} }; /** @@ -497,6 +516,9 @@ struct RemoteVideoStats { * Bitrate (Kbps) received since the last count. */ int receivedBitrate; + /** The decoder input frame rate (fps) of the remote video. + */ + int decoderInputFrameRate; /** The decoder output frame rate (fps) of the remote video. */ int decoderOutputFrameRate; @@ -788,25 +810,36 @@ enum CLOUD_PROXY_TYPE { /** Camera capturer configuration.*/ struct CameraCapturerConfiguration { /** Camera direction settings (for Android/iOS only). See: #CAMERA_DIRECTION. */ -#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) || defined (__OHOS__) +#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) || defined(__OHOS__) /** * The camera direction. */ - CAMERA_DIRECTION cameraDirection; + Optional cameraDirection; + + /*- CAMERA_FOCAL_LENGTH_TYPE.CAMERA_FOCAL_LENGTH_DEFAULT: + For iOS, if iPhone/iPad has 3 or 2 back camera, it means combination of triple (wide + ultra wide + telephoto) camera + or dual wide(wide + ultra wide) camera.In this situation, you can apply for ultra wide len by set smaller zoom fator + and bigger zoom fator for telephoto len.Otherwise, it always means wide back/front camera. + + - CAMERA_FOCAL_LENGTH_TYPE.CAMERA_FOCAL_LENGTH_WIDE_ANGLE:wide camera + - CAMERA_FOCAL_LENGTH_TYPE.CAMERA_FOCAL_LENGTH_ULTRA_WIDE:ultra wide camera + - CAMERA_FOCAL_LENGTH_TYPE.CAMERA_FOCAL_LENGTH_TELEPHOTO:telephoto camera*/ + Optional cameraFocalLengthType; #else - /** For windows. The device ID of the playback device. The maximum length is #MAX_DEVICE_ID_LENGTH. */ - char deviceId[MAX_DEVICE_ID_LENGTH]; + /** For windows. The device ID of the playback device. */ + Optional deviceId; #endif - /** The video format. See VideoFormat. */ - VideoFormat format; - bool followEncodeDimensionRatio; - CameraCapturerConfiguration() : followEncodeDimensionRatio(true) { -#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) || defined (__OHOS__) - cameraDirection = CAMERA_REAR; -#else - memset(deviceId, 0, sizeof(deviceId)); + +#if defined(__ANDROID__) + /** + * The camera id. + */ + Optional cameraId; #endif - } + Optional followEncodeDimensionRatio; + /** The video format. See VideoFormat. */ + VideoFormat format; + CameraCapturerConfiguration() : format(VideoFormat(0, 0, 0)) {} }; /** * The configuration of the captured screen. @@ -1054,7 +1087,7 @@ struct ChannelMediaOptions { */ Optional publishMicrophoneTrack; - #if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) + #if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || defined(__OHOS__) /** * Whether to publish the video track of the screen capturer: * - `true`: Publish the video track of the screen capture. @@ -1140,6 +1173,12 @@ struct ChannelMediaOptions { * - `false`: (Default) Do not publish the local mixed track. */ Optional publishMixedAudioTrack; + /** + * Whether to publish the local lip sync video track. + * - `true`: Publish the video track of local lip sync video track. + * - `false`: (Default) Do not publish the local lip sync video track. + */ + Optional publishLipSyncTrack; /** * Whether to automatically subscribe to all remote audio streams when the user joins a channel: * - `true`: (Default) Subscribe to all remote audio streams. @@ -1234,6 +1273,12 @@ struct ChannelMediaOptions { */ Optional isAudioFilterable; + /** Provides the technical preview functionalities or special customizations by configuring the SDK with JSON options. + Pointer to the set parameters in a JSON string. + * @technical preview + */ + Optional parameters; + ChannelMediaOptions() {} ~ChannelMediaOptions() {} @@ -1245,7 +1290,7 @@ struct ChannelMediaOptions { SET_FROM(publishThirdCameraTrack); SET_FROM(publishFourthCameraTrack); SET_FROM(publishMicrophoneTrack); -#if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) +#if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || defined(__OHOS__) SET_FROM(publishScreenCaptureVideo); SET_FROM(publishScreenCaptureAudio); #else @@ -1256,6 +1301,7 @@ struct ChannelMediaOptions { #endif SET_FROM(publishTranscodedVideoTrack); SET_FROM(publishMixedAudioTrack); + SET_FROM(publishLipSyncTrack); SET_FROM(publishCustomAudioTrack); SET_FROM(publishCustomAudioTrackId); SET_FROM(publishCustomVideoTrack); @@ -1278,6 +1324,7 @@ struct ChannelMediaOptions { SET_FROM(customVideoTrackId); SET_FROM(isAudioFilterable); SET_FROM(isInteractiveAudience); + SET_FROM(parameters); #undef SET_FROM } @@ -1292,7 +1339,7 @@ struct ChannelMediaOptions { ADD_COMPARE(publishThirdCameraTrack); ADD_COMPARE(publishFourthCameraTrack); ADD_COMPARE(publishMicrophoneTrack); -#if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) +#if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || defined(__OHOS__) ADD_COMPARE(publishScreenCaptureVideo); ADD_COMPARE(publishScreenCaptureAudio); #else @@ -1303,6 +1350,7 @@ struct ChannelMediaOptions { #endif ADD_COMPARE(publishTranscodedVideoTrack); ADD_COMPARE(publishMixedAudioTrack); + ADD_COMPARE(publishLipSyncTrack); ADD_COMPARE(publishCustomAudioTrack); ADD_COMPARE(publishCustomAudioTrackId); ADD_COMPARE(publishCustomVideoTrack); @@ -1325,6 +1373,7 @@ struct ChannelMediaOptions { ADD_COMPARE(customVideoTrackId); ADD_COMPARE(isAudioFilterable); ADD_COMPARE(isInteractiveAudience); + ADD_COMPARE(parameters); END_COMPARE(); #undef BEGIN_COMPARE @@ -1342,7 +1391,7 @@ struct ChannelMediaOptions { REPLACE_BY(publishThirdCameraTrack); REPLACE_BY(publishFourthCameraTrack); REPLACE_BY(publishMicrophoneTrack); -#if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) +#if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || defined(__OHOS__) REPLACE_BY(publishScreenCaptureVideo); REPLACE_BY(publishScreenCaptureAudio); #else @@ -1353,6 +1402,7 @@ struct ChannelMediaOptions { #endif REPLACE_BY(publishTranscodedVideoTrack); REPLACE_BY(publishMixedAudioTrack); + REPLACE_BY(publishLipSyncTrack); REPLACE_BY(publishCustomAudioTrack); REPLACE_BY(publishCustomAudioTrackId); REPLACE_BY(publishCustomVideoTrack); @@ -1375,6 +1425,7 @@ struct ChannelMediaOptions { REPLACE_BY(customVideoTrackId); REPLACE_BY(isAudioFilterable); REPLACE_BY(isInteractiveAudience); + REPLACE_BY(parameters); #undef REPLACE_BY } return *this; @@ -2069,7 +2120,7 @@ class IRtcEngineEventHandler { (void)width; (void)height; } -#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) || defined (__OHOS__) +#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) || defined(__OHOS__) /** * Reports the face detection result of the local user. * @@ -2826,19 +2877,31 @@ class IRtcEngineEventHandler { (void)layoutlist; } + /** + * Occurs when the SDK receives audio metadata. + * @since v4.3.1 + * @param uid ID of the remote user. + * @param metadata The pointer of metadata + * @param length Size of metadata + * @technical preview + */ + virtual void onAudioMetadataReceived(uid_t uid, const char* metadata, size_t length) { + (void)uid; + (void)metadata; + (void)length; + } + /** * The event callback of the extension. * * To listen for events while the extension is running, you need to register this callback. * - * @param provider The name of the extension provider. - * @param extension The name of the extension. + * @param context The context of the extension. * @param key The key of the extension. * @param value The value of the extension key. */ - virtual void onExtensionEvent(const char* provider, const char* extension, const char* key, const char* value) { - (void)provider; - (void)extension; + virtual void onExtensionEventWithContext(const ExtensionContext &context, const char* key, const char* value) { + (void)context; (void)key; (void)value; } @@ -2846,43 +2909,37 @@ class IRtcEngineEventHandler { /** * Occurs when the extension is enabled. * - * After a successful call of `enableExtension(true)`, the extension triggers this callback. + * After a successful creation of filter , the extension triggers this callback. * - * @param provider The name of the extension provider. - * @param extension The name of the extension. + * @param context The context of the extension. */ - virtual void onExtensionStarted(const char* provider, const char* extension) { - (void)provider; - (void)extension; + virtual void onExtensionStartedWithContext(const ExtensionContext &context) { + (void)context; } /** * Occurs when the extension is disabled. * - * After a successful call of `enableExtension(false)`, the extension triggers this callback. + * After a successful destroy filter, the extension triggers this callback. * - * @param provider The name of the extension provider. - * @param extension The name of the extension. + * @param context The context of the extension. */ - virtual void onExtensionStopped(const char* provider, const char* extension) { - (void)provider; - (void)extension; + virtual void onExtensionStoppedWithContext(const ExtensionContext &context) { + (void)context; } /** * Occurs when the extension runs incorrectly. * - * When calling `enableExtension(true)` fails or the extension runs in error, the extension triggers + * When the extension runs in error, the extension triggers * this callback and reports the error code and reason. * - * @param provider The name of the extension provider. - * @param extension The name of the extension. + * @param context The context of the extension. * @param error The error code. For details, see the extension documentation provided by the extension provider. * @param message The error message. For details, see the extension documentation provided by the extension provider. */ - virtual void onExtensionError(const char* provider, const char* extension, int error, const char* message) { - (void)provider; - (void)extension; + virtual void onExtensionErrorWithContext(const ExtensionContext &context, int error, const char* message) { + (void)context; (void)error; (void)message; } @@ -3185,23 +3242,26 @@ class IMetadataObserver { */ struct Metadata { - /** The User ID that sent the metadata. - * - For the receiver: The user ID of the user who sent the `metadata`. - * - For the sender: Ignore this value. - */ - unsigned int uid; - /** The buffer size of the sent or received `metadata`. - */ - unsigned int size; - /** The buffer address of the sent or received `metadata`. - */ - unsigned char* buffer; - /** The timestamp (ms) of the `metadata`. - * - */ - long long timeStampMs; - - Metadata() : uid(0), size(0), buffer(NULL), timeStampMs(0) {} + /** The channel ID of the `metadata`. + */ + const char* channelId; + /** The User ID that sent the metadata. + * - For the receiver: The user ID of the user who sent the `metadata`. + * - For the sender: Ignore this value. + */ + unsigned int uid; + /** The buffer size of the sent or received `metadata`. + */ + unsigned int size; + /** The buffer address of the sent or received `metadata`. + */ + unsigned char *buffer; + /** The NTP timestamp (ms) when the metadata is sent. + * @note If the receiver is audience, the receiver cannot get the NTP timestamp (ms). + */ + long long timeStampMs; + + Metadata() : channelId(NULL), uid(0), size(0), buffer(NULL), timeStampMs(0) {} }; /** Occurs when the SDK requests the maximum size of the metadata. @@ -3875,6 +3935,7 @@ class IRtcEngine : public agora::base::IEngineBase { * @return * - 0: Success. * - < 0: Failure. + * - -8(ERR_INVALID_STATE): The current status is invalid, only allowed to be called when the connection is disconnected. */ virtual int setChannelProfile(CHANNEL_PROFILE_TYPE profile) = 0; @@ -3923,48 +3984,10 @@ class IRtcEngine : public agora::base::IEngineBase { * - -1(ERR_FAILED): A general error occurs (no specified reason). * - -2(ERR_INALID_ARGUMENT): The parameter is invalid. * - -7(ERR_NOT_INITIALIZED): The SDK is not initialized. + * - -8(ERR_INVALID_STATE): The channel profile is not `LIVE_BROADCASTING`. */ virtual int setClientRole(CLIENT_ROLE_TYPE role, const ClientRoleOptions& options) = 0; - /** Starts an audio call test. - - This method launches an audio call test to determine whether the audio devices - (for example, headset and speaker) and the network connection are working - properly. - - In the test, the user first speaks, and the recording is played back - in 10 seconds. If the user can hear the recording in 10 seconds, it indicates - that the audio devices and network connection work properly. - - @note - After calling the startEchoTest() method, always call stopEchoTest() to end - the test. Otherwise, the app cannot run the next echo test, nor can - it call the joinChannel() method. - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int startEchoTest() = 0; - - /** Starts an audio call test. - - This method starts an audio call test to determine whether the audio devices (for example, headset and speaker) and the network connection are working properly. - - In the audio call test, you record your voice. If the recording plays back within the set time interval, the audio devices and the network connection are working properly. - - @note - - Call this method before joining a channel. - - After calling this method, call the \ref IRtcEngine::stopEchoTest "stopEchoTest" method to end the test. Otherwise, the app cannot run the next echo test, or call the \ref IRtcEngine::joinChannel "joinChannel" method. - - In the `LIVE_BROADCASTING` profile, only a host can call this method. - @param intervalInSeconds The time interval (s) between when you speak and when the recording plays back. - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int startEchoTest(int intervalInSeconds) = 0; - /** Starts a video call test. * * @param config: configuration for video call test. @@ -4129,6 +4152,41 @@ class IRtcEngine : public agora::base::IEngineBase { * @param options Sets the image enhancement option. See BeautyOptions. */ virtual int setBeautyEffectOptions(bool enabled, const BeautyOptions& options, agora::media::MEDIA_SOURCE_TYPE type = agora::media::PRIMARY_CAMERA_SOURCE) = 0; + /** Enables/Disables face shape and sets the beauty options. + * + * @note Call this method after calling the \ref IRtcEngine::enableVideo "enableVideo" method. + * + * @param enabled Sets whether or not to enable face shape: + * - true: enables face shape. + * - false: disables face shape. + * @param options Sets the face shape beauty option. See FaceShapeBeautyOptions. + */ + virtual int setFaceShapeBeautyOptions(bool enabled, const FaceShapeBeautyOptions& options, agora::media::MEDIA_SOURCE_TYPE type = agora::media::PRIMARY_CAMERA_SOURCE) = 0; + /** Enables/Disables face shape and sets the area options. + * + * @note Call this method after calling the \ref IRtcEngine::setFaceShapeBeautyOptions "setFaceShapeBeautyOptions" method. + * + * @param options Sets the face shape area option. See FaceShapeAreaOptions. + */ + virtual int setFaceShapeAreaOptions(const FaceShapeAreaOptions& options, agora::media::MEDIA_SOURCE_TYPE type = agora::media::PRIMARY_CAMERA_SOURCE) = 0; + + /** Gets the face shape beauty options. + * + * @note Call this method after calling the \ref IRtcEngine::enableVideo "enableVideo" method. + * + * @param options Gets the face shape beauty option. See FaceShapeBeautyOptions. + */ + virtual int getFaceShapeBeautyOptions(FaceShapeBeautyOptions& options, agora::media::MEDIA_SOURCE_TYPE type = agora::media::PRIMARY_CAMERA_SOURCE) = 0; + + /** Gets the face shape area options. + * + * @note Call this method after calling the \ref IRtcEngine::enableVideo "enableVideo" method. + * + * @param shapeArea The face area. See FaceShapeAreaOptions::FACE_SHAPE_AREA. + * @param options Gets the face area beauty option. See FaceShapeAreaOptions. + */ + virtual int getFaceShapeAreaOptions(agora::rtc::FaceShapeAreaOptions::FACE_SHAPE_AREA shapeArea, FaceShapeAreaOptions& options, agora::media::MEDIA_SOURCE_TYPE type = agora::media::PRIMARY_CAMERA_SOURCE) = 0; + /** * Sets low-light enhancement. * @@ -4497,29 +4555,6 @@ class IRtcEngine : public agora::base::IEngineBase { */ virtual int muteAllRemoteAudioStreams(bool mute) = 0; - /** - * Determines whether to receive all remote audio streams by default. - * - * @deprecated This method is deprecated. To set whether to receive remote - * audio streams by default, call - * \ref IRtcEngine::muteAllRemoteAudioStreams "muteAllRemoteAudioStreams" - * before calling `joinChannel` - * - * Use this method to set whether to receive audio streams of subsequent peer - * users. Agora recommends calling it before joining a channel. - * - * A successful call of setDefaultMuteAllRemoteAudioStreams(true) results in - * that the local user not receiving any audio stream after joining a channel. - * @param mute Whether to receive remote audio streams by default: - * - true: Do not receive any remote audio stream by default. - * - false: (Default) Receive remote audio streams by default. - * - * @return int - * - 0: Success. - * - < 0: Failure. - */ - virtual int setDefaultMuteAllRemoteAudioStreams(bool mute) __deprecated = 0; - /** * Stops or resumes receiving the audio stream of a specified user. * @@ -4618,29 +4653,6 @@ class IRtcEngine : public agora::base::IEngineBase { */ virtual int muteAllRemoteVideoStreams(bool mute) = 0; - /** - Determines whether to receive all remote video streams by default. - - @deprecated This method is deprecated. To set whether to receive remote - video streams by default, call - \ref IRtcEngine::muteAllRemoteVideoStreams "muteAllRemoteVideoStreams" - before calling `joinChannel`. - - Use this method to set whether to receive video streams of subsequent peer - users. Agora recommends calling it before joining a channel. - - A successful call of setDefaultMuteAllRemoteVideoStreams(true) results in - that the local user not receiving any video stream after joining a channel. - - @param mute Whether to receive remote video streams by default: - - true: Do not receive any remote video stream by default. - - false: (Default) Receive remote video streams by default. - @return int - - 0: Success. - - < 0: Failure. - */ - virtual int setDefaultMuteAllRemoteVideoStreams(bool mute) __deprecated = 0; - /** * Sets the default stream type of the remote video if the remote user has enabled dual-stream. * @@ -5196,7 +5208,7 @@ class IRtcEngine : public agora::base::IEngineBase { * - < 0: Failure. */ virtual int setAudioMixingPlaybackSpeed(int speed) = 0; - + /** * Gets the volume of audio effects. * @@ -5831,6 +5843,19 @@ class IRtcEngine : public agora::base::IEngineBase { */ virtual int setHeadphoneEQParameters(int lowGain, int highGain) = 0; + /** Enables or disables the voice AI tuner. + * + * @param enabled Determines whether to enable the voice AI tuner: + * - true: Enable the voice AI tuner + * - false: (default) Disable the voice AI tuner. + * + * @param type. The options for SDK voice AI tuner types. See #VOICE_AI_TUNER_TYPE. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int enableVoiceAITuner(bool enabled, VOICE_AI_TUNER_TYPE type) = 0; + /** **DEPRECATED** Specifies an SDK output log file. * * The log file records all log data for the SDK’s operation. Ensure that the @@ -5916,6 +5941,23 @@ class IRtcEngine : public agora::base::IEngineBase { */ virtual int uploadLogFile(agora::util::AString& requestId) = 0; + /** * Write the log to SDK . @technical preview + * + * You can Write the log to SDK log files of the specified level. + * + * @param level The log level: + * - `LOG_LEVEL_NONE (0x0000)`: Do not output any log file. + * - `LOG_LEVEL_INFO (0x0001)`: (Recommended) Output log files of the INFO level. + * - `LOG_LEVEL_WARN (0x0002)`: Output log files of the WARN level. + * - `LOG_LEVEL_ERROR (0x0004)`: Output log files of the ERROR level. + * - `LOG_LEVEL_FATAL (0x0008)`: Output log files of the FATAL level. + * + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int writeLog(commons::LOG_LEVEL level, const char* fmt, ...) = 0; + /** * Updates the display mode of the local video view. * @@ -5978,7 +6020,7 @@ class IRtcEngine : public agora::base::IEngineBase { * - 0: Success. * - < 0: Failure. */ - virtual int setLocalRenderMode(media::base::RENDER_MODE_TYPE renderMode) = 0; + virtual int setLocalRenderMode(media::base::RENDER_MODE_TYPE renderMode) __deprecated = 0; /** * Sets the local video mirror mode. @@ -5991,7 +6033,7 @@ class IRtcEngine : public agora::base::IEngineBase { * - 0: Success. * - < 0: Failure. */ - virtual int setLocalVideoMirrorMode(VIDEO_MIRROR_MODE_TYPE mirrorMode) = 0; + virtual int setLocalVideoMirrorMode(VIDEO_MIRROR_MODE_TYPE mirrorMode) __deprecated = 0; /** * Enables or disables the dual video stream mode. @@ -6043,6 +6085,23 @@ class IRtcEngine : public agora::base::IEngineBase { */ virtual int setDualStreamMode(SIMULCAST_STREAM_MODE mode) = 0; + /** + * Sets the multi-layer video stream configuration. + * + * If multi-layer is configured, the subscriber can choose to receive the coresponding layer + * of video stream using {@link setRemoteVideoStreamType setRemoteVideoStreamType}. + * + * @param simulcastConfig + * - The configuration for multi-layer video stream. It includes seven layers, ranging from + * STREAM_LAYER_1 to STREAM_LOW. A maximum of 3 layers can be enabled simultaneously. + * + * @return + * - 0: Success. + * - < 0: Failure. + * @technical preview + */ + virtual int setSimulcastConfig(const SimulcastConfig& simulcastConfig) = 0; + /** * Enables, disables or auto enable the dual video stream mode. * @@ -6463,7 +6522,7 @@ class IRtcEngine : public agora::base::IEngineBase { */ virtual int setInEarMonitoringVolume(int volume) = 0; -#if defined (_WIN32) || defined(__linux__) || defined(__ANDROID__) +#if defined(_WIN32) || defined(__linux__) || defined(__ANDROID__) virtual int loadExtensionProvider(const char* path, bool unload_after_use = false) = 0; #endif @@ -6600,7 +6659,7 @@ class IRtcEngine : public agora::base::IEngineBase { */ virtual int destroyCustomEncodedVideoTrack(video_track_id_t video_track_id) = 0; -#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) || defined (__OHOS__) +#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) || defined(__OHOS__) /** * Switches between front and rear cameras. * @@ -6787,6 +6846,13 @@ class IRtcEngine : public agora::base::IEngineBase { * - false: Do not enable the auto exposure face function. */ virtual int setCameraAutoExposureFaceModeEnabled(bool enabled) = 0; + + /** + * set camera stabilization mode.If open stabilization mode, fov will be smaller and capture latency will be longer. + * + * @param mode specifies the camera stabilization mode. + */ + virtual int setCameraStabilizationMode(CAMERA_STABILIZATION_MODE mode) = 0; #endif /** Sets the default audio route (for Android and iOS only). @@ -6870,6 +6936,27 @@ class IRtcEngine : public agora::base::IEngineBase { virtual int setRouteInCommunicationMode(int route) = 0; #endif // __ANDROID__ || (__APPLE__ && TARGET_OS_IOS) || __OHOS__ +#if defined(__APPLE__) + /** + * Checks whether the center stage is supported. Use this method after starting the camera. + * + * @return + * - true: The center stage is supported. + * - false: The center stage is not supported. + */ + virtual bool isCameraCenterStageSupported() = 0; + + /** Enables the camera Center Stage. + * @param enabled enable Center Stage: + * - true: Enable Center Stage. + * - false: Disable Center Stage. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int enableCameraCenterStage(bool enabled) = 0; +#endif + #if defined(_WIN32) || (defined(__APPLE__) && TARGET_OS_MAC && !TARGET_OS_IPHONE) /** Get \ref ScreenCaptureSourceInfo list including available windows and screens. * @@ -6975,7 +7062,6 @@ class IRtcEngine : public agora::base::IEngineBase { * - < 0: Failure.. */ virtual int getAudioDeviceInfo(DeviceInfo& deviceInfo) = 0; - #endif // __ANDROID__ #if defined(_WIN32) || (defined(__APPLE__) && TARGET_OS_MAC && !TARGET_OS_IPHONE) @@ -7051,7 +7137,7 @@ class IRtcEngine : public agora::base::IEngineBase { virtual int updateScreenCaptureParameters(const ScreenCaptureParameters& captureParams) = 0; #endif // _WIN32 || (__APPLE__ && !TARGET_OS_IPHONE && TARGET_OS_MAC) -#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) +#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) || defined(__OHOS__) /** * Starts screen sharing. * @@ -7086,7 +7172,22 @@ class IRtcEngine : public agora::base::IEngineBase { * - < 0: Failure. */ virtual int queryScreenCaptureCapability() = 0; -#endif + +#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) + /** + * Query all focal attributes supported by the camera. + * + * @param focalLengthInfos The camera supports the collection of focal segments.Ensure the size of array is not less than 8. + * + * @param size The camera supports the size of the focal segment set. Ensure the size is not less than 8. + * + * @return + * - 0: Success. + * - < 0: Failure.. + */ + virtual int queryCameraFocalLengthCapability(agora::rtc::FocalLengthInfo* focalLengthInfos, int& size) = 0; +#endif // defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) +#endif // defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) || defined(__OHOS__) #if defined(_WIN32) || defined(__APPLE__) || defined(__ANDROID__) /** @@ -7340,47 +7441,6 @@ class IRtcEngine : public agora::base::IEngineBase { */ virtual int registerPacketObserver(IPacketObserver* observer) = 0; - /** - * Sets the built-in encryption mode. - * - * @deprecated This method is deprecated. Use enableEncryption(bool enabled, const EncryptionConfig&) instead. - * - * The Agora Native SDK supports built-in encryption. - * Call this API to set the encryption mode. - * - * All users in the same channel must use the same encryption mode and password. - * Refer to information related to the encryption algorithm on the differences - * between encryption modes. - * - * @note - * Call \ref setEncryptionSecret "setEncryptionSecret" to enable the built-in encryption function - * before calling this API. - * @param encryptionMode Encryption mode: - * - "sm4-128-ecb": 128-bit SM4 encryption, ECB mode. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setEncryptionMode(const char* encryptionMode) __deprecated = 0; - - /** - * Enables built-in encryption. - * - * @deprecated This method is deprecated. Use enableEncryption(bool enabled, const EncryptionConfig&) instead. - * - * Use this method to specify an encryption password to enable built-in - * encryption before joining a channel. All users in a channel must set the same - * encryption password. The encryption password is automatically cleared once a - * user has left the channel. If the encryption password is not specified or set to - * empty, the encryption function will be disabled. - * - * @param secret The encryption password. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setEncryptionSecret(const char* secret) __deprecated = 0; /** Enables/Disables the built-in encryption. * @@ -8261,6 +8321,18 @@ class IRtcEngine : public agora::base::IEngineBase { * - false: not available. */ virtual bool isFeatureAvailableOnDevice(FeatureType type) = 0; + + /** + * @brief send audio metadata + * @since v4.3.1 + * @param metadata The pointer of metadata + * @param length Size of metadata + * @return + * - 0: success + * - <0: failure + * @technical preview + */ + virtual int sendAudioMetadata(const char* metadata, size_t length) = 0; }; // The following types are either deprecated or not implmented yet. diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtcEngineEx.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtcEngineEx.h old mode 100755 new mode 100644 index 9b5670f7e..423d1964a --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtcEngineEx.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtcEngineEx.h @@ -101,6 +101,7 @@ class IRtcEngineEventHandlerEx : public IRtcEngineEventHandler { using IRtcEngineEventHandler::onVideoRenderingTracingResult; using IRtcEngineEventHandler::onSetRtmFlagResult; using IRtcEngineEventHandler::onTranscodedStreamLayoutInfo; + using IRtcEngineEventHandler::onAudioMetadataReceived; virtual const char* eventHandlerType() const { return "event_handler_ex"; } @@ -317,40 +318,6 @@ class IRtcEngineEventHandlerEx : public IRtcEngineEventHandler { (void)rotation; } - /** Occurs when the local video stream state changes. - * - * When the state of the local video stream changes (including the state of the video capture and - * encoding), the SDK triggers this callback to report the current state. This callback indicates - * the state of the local video stream, including camera capturing and video encoding, and allows - * you to troubleshoot issues when exceptions occur. - * - * The SDK triggers the onLocalVideoStateChanged callback with the state code of `LOCAL_VIDEO_STREAM_STATE_FAILED` - * and error code of `LOCAL_VIDEO_STREAM_REASON_CAPTURE_FAILURE` in the following situations: - * - The app switches to the background, and the system gets the camera resource. - * - The camera starts normally, but does not output video for four consecutive seconds. - * - * When the camera outputs the captured video frames, if the video frames are the same for 15 - * consecutive frames, the SDK triggers the `onLocalVideoStateChanged` callback with the state code - * of `LOCAL_VIDEO_STREAM_STATE_CAPTURING` and error code of `LOCAL_VIDEO_STREAM_REASON_CAPTURE_FAILURE`. - * Note that the video frame duplication detection is only available for video frames with a resolution - * greater than 200 × 200, a frame rate greater than or equal to 10 fps, and a bitrate less than 20 Kbps. - * - * @note For some device models, the SDK does not trigger this callback when the state of the local - * video changes while the local video capturing device is in use, so you have to make your own - * timeout judgment. - * - * @param connection The RtcConnection object. - * @param state The state of the local video. See #LOCAL_VIDEO_STREAM_STATE. - * @param reason The detailed error information. See #LOCAL_VIDEO_STREAM_REASON. - */ - virtual void onLocalVideoStateChanged(const RtcConnection& connection, - LOCAL_VIDEO_STREAM_STATE state, - LOCAL_VIDEO_STREAM_REASON reason) { - (void)connection; - (void)state; - (void)reason; - } - /** * Occurs when the remote video state changes. * @@ -1059,6 +1026,20 @@ class IRtcEngineEventHandlerEx : public IRtcEngineEventHandler { (void)layoutCount; (void)layoutlist; } + + /** + * The audio metadata received. + * + * @param connection The RtcConnection object. + * @param uid ID of the remote user. + * @param metadata The pointer of metadata + * @param length Size of metadata + * @technical preview + */ + virtual void onAudioMetadataReceived(const RtcConnection& connection, uid_t uid, const char* metadata, size_t length) { + (void)metadata; + (void)length; + } }; class IRtcEngineEx : public IRtcEngine { @@ -1864,7 +1845,25 @@ class IRtcEngineEx : public IRtcEngine { virtual int setDualStreamModeEx(SIMULCAST_STREAM_MODE mode, const SimulcastStreamConfig& streamConfig, const RtcConnection& connection) = 0; - + + /** + * Set the multi-layer video stream configuration. + * + * If multi-layer is configed, the subscriber can choose to receive the coresponding layer + * of video stream using {@link setRemoteVideoStreamType setRemoteVideoStreamType}. + * + * @param simulcastConfig + * - The configuration for multi-layer video stream. It includes seven layers, ranging from + * STREAM_LAYER_1 to STREAM_LOW. A maximum of 3 layers can be enabled simultaneously. + * @param connection The RtcConnection object. + * @return + * - 0: Success. + * - < 0: Failure. + * @technical preview + */ + virtual int setSimulcastConfigEx(const SimulcastConfig& simulcastConfig, + const RtcConnection& connection) = 0; + /** * Set the high priority user list and their fallback level in weak network condition. * @@ -1955,7 +1954,7 @@ class IRtcEngineEx : public IRtcEngine { - < 0: Failure. */ virtual int setParametersEx(const RtcConnection& connection, const char* parameters) = 0; - + /** * Gets the current call ID. * @@ -1974,6 +1973,19 @@ class IRtcEngineEx : public IRtcEngine { * - < 0: Failure. */ virtual int getCallIdEx(agora::util::AString& callId, const RtcConnection& connection) = 0; + + /** + * send audio metadata + * @since v4.3.1 + * @param connection The RtcConnection object. + * @param metadata The pointer of metadata + * @param length Size of metadata + * @return + * - 0: success + * - <0: failure + * @technical preview + */ + virtual int sendAudioMetadataEx(const RtcConnection& connection, const char* metadata, size_t length) = 0; }; } // namespace rtc diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtmService.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtmService.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtmpStreamingService.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtmpStreamingService.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraService.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraService.h old mode 100755 new mode 100644 index 0b1de7840..b5c036340 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraService.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraService.h @@ -71,6 +71,8 @@ class IRtmService; namespace base { class IServiceObserver; +class ISyncClient; +struct SyncConfig; /** * The global configurations for \ref agora::base::IAgoraService "AgoraService". @@ -286,6 +288,13 @@ struct AudioSessionConfiguration { */ Optional outputNumberOfChannels; +#if defined(WEBRTC_IOS) + /** + * Initialize the AudioSession with the value for category. (iOS only) + */ + Optional category; +#endif + void SetAll(const AudioSessionConfiguration& change) { SetFrom(&playbackAndRecord, change.playbackAndRecord); SetFrom(&chatMode, change.chatMode); @@ -299,6 +308,9 @@ struct AudioSessionConfiguration { SetFrom(&ioBufferDuration, change.ioBufferDuration); SetFrom(&inputNumberOfChannels, change.inputNumberOfChannels); SetFrom(&outputNumberOfChannels, change.outputNumberOfChannels); +#if defined(WEBRTC_IOS) + SetFrom(&category, change.category); +#endif } bool operator==(const AudioSessionConfiguration& o) const { @@ -308,7 +320,12 @@ struct AudioSessionConfiguration { allowBluetooth == o.allowBluetooth && allowBluetoothA2DP == o.allowBluetoothA2DP && sampleRate == o.sampleRate && ioBufferDuration == o.ioBufferDuration && inputNumberOfChannels == o.inputNumberOfChannels && +#if defined(WEBRTC_IOS) + outputNumberOfChannels == o.outputNumberOfChannels && + category == o.category; +#else outputNumberOfChannels == o.outputNumberOfChannels; +#endif } bool operator!=(const AudioSessionConfiguration& o) const { return !(*this == o); } @@ -635,12 +652,13 @@ class IAgoraService { * @param audioSource The pointer to the recording device source. See \ref agora::rtc::IRecordingDeviceSource "IRecordingDeviceSource". * @param enableAec Whether enable audio echo cancellation for loopback recording. If loopback * recording device is a virtual sound card, it should be false, or it should be true. + * @param overlap Whether overlap playout signal. * @return * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success. * - A null pointer: Failure. */ virtual agora_refptr createRecordingDeviceAudioTrack( - agora_refptr audioSource, bool enableAec) = 0; + agora_refptr audioSource, bool enableAec, bool overlap) = 0; /** * Creates an audio device manager object and returns the pointer. @@ -956,6 +974,32 @@ class IAgoraService { * - A null pointer: Failure. */ virtual agora_refptr getConfigCenter() = 0; + + /** + * Get the \ref agora::rtc::ISyncClient "ISyncClient" object and return the pointer. + * + * @return + * - The pointer to \ref rtc::ISyncClient "ISyncClient": Success. + * - A null pointer: Failure. + */ + virtual agora_refptr createSyncClient(const base::SyncConfig& config) = 0; + + /** + * Set the logWriter for the sdk log. + * @param logWriter the log writer + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int32_t setLogWriter(agora::commons::ILogWriter* logWriter) = 0; + + /** + * Release logWriter for the sdk log. + * @return + * -The pointer to \ref agora::commons::ILogWriter + * - A null pointer: Failure. + */ + virtual agora::commons::ILogWriter* releaseLogWriter() = 0; protected: virtual ~IAgoraService() {} diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAudioDeviceManager.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAudioDeviceManager.h old mode 100755 new mode 100644 index 77667b827..6537f0990 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAudioDeviceManager.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAudioDeviceManager.h @@ -50,6 +50,20 @@ class IAudioDeviceCollection { virtual int getDevice(int index, char deviceName[MAX_DEVICE_ID_LENGTH], char deviceId[MAX_DEVICE_ID_LENGTH]) = 0; + /** + * Gets the information of a specified audio device. + * @note + * @param index An input parameter that specifies the audio device. + * @param deviceName An output parameter that indicates the device name. + * @param deviceTypeName An output parameter that indicates the device type name. such as Built-in, USB, HDMI, etc. (MacOS only) + * @param deviceId An output parameter that indicates the device ID. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int getDevice(int index, char deviceName[MAX_DEVICE_ID_LENGTH], char deviceTypeName[MAX_DEVICE_ID_LENGTH], + char deviceId[MAX_DEVICE_ID_LENGTH]) = 0; + /** * Specifies a device with the device ID. * @param deviceId The device ID. @@ -71,6 +85,19 @@ class IAudioDeviceCollection { */ virtual int getDefaultDevice(char deviceName[MAX_DEVICE_ID_LENGTH], char deviceId[MAX_DEVICE_ID_LENGTH]) = 0; + /** + * Gets the default audio device of the system (for macOS and Windows only). + * + * @param deviceName The name of the system default audio device. + * @param deviceTypeName The device type name of the the system default audio device, such as Built-in, USB, HDMI, etc. (MacOS only) + * @param deviceId The device ID of the the system default audio device. + * + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int getDefaultDevice(char deviceName[MAX_DEVICE_ID_LENGTH], char deviceTypeName[MAX_DEVICE_ID_LENGTH], char deviceId[MAX_DEVICE_ID_LENGTH]) = 0; + /** * Sets the volume of the app. * @@ -199,6 +226,17 @@ class IAudioDeviceManager : public RefCountInterface { virtual int getPlaybackDeviceInfo(char deviceId[MAX_DEVICE_ID_LENGTH], char deviceName[MAX_DEVICE_ID_LENGTH]) = 0; + /** + * Gets the device ID and device name and device type name of the audio playback device. + * @param deviceId An output parameter that specifies the ID of the audio playback device. + * @param deviceName An output parameter that specifies the name of the audio playback device. + * @param deviceTypeName An output parameter that specifies the device type name. such as Built-in, USB, HDMI, etc. (MacOS only) + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int getPlaybackDeviceInfo(char deviceId[MAX_DEVICE_ID_LENGTH], char deviceName[MAX_DEVICE_ID_LENGTH], char deviceTypeName[MAX_DEVICE_ID_LENGTH]) = 0; + /** * Sets the volume of the audio playback device. * @param volume The volume of the audio playing device. The value range is @@ -254,6 +292,18 @@ class IAudioDeviceManager : public RefCountInterface { virtual int getRecordingDeviceInfo(char deviceId[MAX_DEVICE_ID_LENGTH], char deviceName[MAX_DEVICE_ID_LENGTH]) = 0; + /** + * Gets the device ID and device name and device type name of the audio recording device. + * + * @param deviceId An output parameter that indicates the device id. + * @param deviceName An output parameter that indicates the device name. + * @param deviceTypeName An output parameter that indicates the device type name. such as Built-in, USB, HDMI, etc. (MacOS only) + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int getRecordingDeviceInfo(char deviceId[MAX_DEVICE_ID_LENGTH], char deviceName[MAX_DEVICE_ID_LENGTH], char deviceTypeName[MAX_DEVICE_ID_LENGTH]) = 0; + /** * Sets the volume of the recording device. * @param volume The volume of the recording device. The value range is [0, diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioDeviceManager.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioDeviceManager.h old mode 100755 new mode 100644 index cb54fc77f..0c41470ef --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioDeviceManager.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioDeviceManager.h @@ -37,6 +37,11 @@ struct AudioDeviceInfo { * The name of the device. The maximum name size is 128 bytes. The default value is 0. */ char deviceName[kAdmMaxDeviceNameSize]; + /** + * The type name of the device. such as Built-in, USB, HDMI, etc. The maximum size is 128 bytes. The default value is 0. + * @note This member applies to macOS only. + */ + char deviceTypeName[kAdmMaxDeviceNameSize]; /** * The ID of the device. The maximum size is 128 bytes. The default value is 0. */ @@ -57,6 +62,7 @@ struct AudioDeviceInfo { AudioDeviceInfo() : isCurrentSelected(false), isPlayoutDevice(true) { memset(deviceName, 0, sizeof(deviceName)); + memset(deviceTypeName, 0, sizeof(deviceTypeName)); memset(deviceId, 0, sizeof(deviceId)); } }; diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioMixerSource.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioMixerSource.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioTrack.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioTrack.h old mode 100755 new mode 100644 index 7b5c6b42c..e877e370e --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioTrack.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioTrack.h @@ -104,11 +104,12 @@ class IAudioTrack : public RefCountInterface { * By adding an audio filter, you can apply various audio effects to the audio, for example, voice change. * @param filter A pointer to the audio filter. See \ref agora::rtc::IAudioFilter "IAudioFilter". * @param position The position of the audio filter. See \ref agora::rtc::IAudioTrack::AudioFilterPosition "AudioFilterPosition". + * @param extContext The context of current filter. See \ref agora::rtc::ExtensionContext "ExtensionContext". * @return * - `true`: Success. * - `false`: Failure. */ - virtual bool addAudioFilter(agora_refptr filter, AudioFilterPosition position, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual bool addAudioFilter(agora_refptr filter, AudioFilterPosition position, ExtensionContext *extContext = NULL, aosl_ref_t ares = AOSL_REF_INVALID) = 0; /** * Removes the audio filter added by callling `addAudioFilter`. * @@ -401,6 +402,21 @@ class ILocalAudioTrack : public IAudioTrack { */ virtual int unregisterTrackObserver(ILocalAudioTrackObserver* observer) = 0; + /** set Max buffered audio frame number + * + * @param number : the buffer number set,unit is 10ms + * + */ + virtual void setMaxBufferedAudioFrameNumber(int number) = 0; + + /** clear sender buffer + * + * @return + * - >= 0: Frame number in sender buffer. + * - < 0: Failure. + */ + virtual int ClearSenderBuffer() = 0; + protected: ~ILocalAudioTrack() {} }; @@ -535,6 +551,14 @@ struct RemoteAudioTrackStats { * The time of 200 ms frozen in 2 seconds */ uint16_t frozen_time_200_ms; + /** + * The full time of 80 ms frozen in 2 seconds + */ + uint16_t full_frozen_time_80_ms; + /** + * The full time of 200 ms frozen in 2 seconds + */ + uint16_t full_frozen_time_200_ms; /** * The estimate delay */ @@ -617,6 +641,8 @@ struct RemoteAudioTrackStats { frozen_time_80_ms(0), frozen_count_200_ms(0), frozen_time_200_ms(0), + full_frozen_time_80_ms(0), + full_frozen_time_200_ms(0), delay_estimate_ms(0), mos_value(0), frozen_rate_by_custom_plc_count(0), @@ -711,6 +737,43 @@ class IRemoteAudioTrack : public IAudioTrack { */ virtual int setRemoteVoicePosition(float pan, float gain, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + /** Sets the volume of each audio decoded channel + + @param decoded_index The channel index of the remote user. The value ranges from 0 to 100: + @param volume The channel index of the remote user. The value ranges from 0 to 100. + - 0: mute the channel. + - 100: keep the origin volume of the channel. + + @return + - 0: Success. + - < 0: Failure. + */ + virtual int adjustDecodedAudioVolume(int decoded_index, int volume, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + + /** mute remote stream from timestamp + + @note + - unmuteRemoteFromTimestamp should be called after muteRemoteFromTimestamp, othewise this stream will be muted all time + + @param timestamp The rtp timestamp of start mute + @return + - 0: Success. + - < 0: Failure. + */ + virtual int muteRemoteFromTimestamp(uint32_t timestamp) = 0; + + /** unmute remote stream from timestamp + + @note + - unmuteRemoteFromTimestamp should be called after muteRemoteFromTimestamp, othewise this stream will be muted all time + + @param timestamp The rtp timestamp of start unmute + @return + - 0: Success. + - < 0: Failure. + */ + virtual int unmuteRemoteFromTimestamp(uint32_t timestamp) = 0; + /** set percentage of audio acceleration during poor network @note diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraCameraCapturer.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraCameraCapturer.h old mode 100755 new mode 100644 index 54e4c4647..022a6c181 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraCameraCapturer.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraCameraCapturer.h @@ -32,6 +32,10 @@ class ICameraCapturer : public RefCountInterface { * The camera source is the front camera. */ CAMERA_FRONT, + /** + * The camera source is the extra camera. + */ + CAMERA_EXTRA, }; /** @@ -369,6 +373,13 @@ class ICameraCapturer : public RefCountInterface { * */ virtual int setCameraAutoExposureFaceModeEnabled(bool enabled, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + + /** + * set camera stabilization mode.If open stabilization mode, fov will be smaller and capture latency will be longer. + * + * @param mode specifies the camera stabilization mode. + */ + virtual int setCameraStabilizationMode(CAMERA_STABILIZATION_MODE mode) = 0; #endif #elif defined(_WIN32) || (defined(__linux__) && !defined(__ANDROID__) && !defined (__OHOS__)) || \ @@ -410,6 +421,27 @@ class ICameraCapturer : public RefCountInterface { virtual int initWithDeviceName(const char* deviceName) = 0; #endif +#if defined(__APPLE__) + /** + * Checks whether the center stage is supported. Use this method after starting the camera. + * + * @return + * - true: The center stage is supported. + * - false: The center stage is not supported. + */ + virtual bool isCenterStageSupported() = 0; + + /** Enables the camera Center Stage. + * @param enabled enable Center Stage: + * - true: Enable Center Stage. + * - false: Disable Center Stage. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int enableCenterStage(bool enabled) = 0; +#endif + /** * Set the device orientation of the capture device * @param VIDEO_ORIENTATION orientaion of the device 0(by default), 90, 180, 270 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraConfigCenter.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraConfigCenter.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraDataChannel.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraDataChannel.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionAINoiseSuppressor.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionAINoiseSuppressor.h old mode 100755 new mode 100644 index 2cb977831..5826a6ca3 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionAINoiseSuppressor.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionAINoiseSuppressor.h @@ -13,11 +13,12 @@ namespace rtc { class AINoiseSuppressorExtension : public RefCountInterface { public: virtual ~AINoiseSuppressorExtension() {}; - - virtual int ProcessDenoiseFrame(float* input, float* output) = 0; - virtual int ClearHiddenState() = 0; - virtual const char* GetLibVersion(int mode) = 0; + virtual int Init(const char* weight_raw_buffer, size_t raw_buffer_bytes) = 0; + virtual int ProcessDenoiseFrame(float* input, float* output, int stage) = 0; + virtual int ClearHiddenState(bool clear_hidden, int clear_lpsbuffer_nframe) = 0; + virtual const char* GetLibVersion(int mode = 0) = 0; }; + } // namespace rtc } // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionAiAec.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionAiAec.h old mode 100755 new mode 100644 index cebd1debf..fec96b6a1 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionAiAec.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionAiAec.h @@ -17,10 +17,10 @@ namespace rtc { class AiEchoCancellationExtension : public RefCountInterface { public: virtual ~AiEchoCancellationExtension() {}; - - virtual int ProcessAiNlpFrame(float* input, float* output) = 0; - virtual int ClearHiddenState(float scale_factor = 0.0) = 0; - virtual void Version(char ver[MAX_VERSION_LEN]) = 0; + virtual int Init(const char* weight_raw_buffer, size_t raw_buffer_bytes) = 0; + virtual int ProcessAiNlpFrame(const float* linear, const float* nearin, const float* far_ref, float* out_mask) = 0; + virtual int ClearHiddenState(float scale_factor = 0.0,int clear_lpsbuffer_nframe = 0) = 0; + virtual const char* GetLibVersion(int mode = 0) = 0; }; } // namespace rtc diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionControl.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionControl.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionProvider.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionProvider.h old mode 100755 new mode 100644 index 9a1a54141..4dff21248 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionProvider.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionProvider.h @@ -106,7 +106,7 @@ class IExtensionProvider : public RefCountInterface { virtual agora_refptr createVideoSink(const char* name) { return NULL; } - + virtual void setProperty(const char* key, const char* value) {} protected: diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionScreenSource.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionScreenSource.h old mode 100755 new mode 100644 index 82fe0a504..0b12be254 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionScreenSource.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionScreenSource.h @@ -83,8 +83,11 @@ class IScreenCaptureSource : public RefCountInterface { uint32_t display_id; view_t window_id; + // Mac only + bool disable_avf; + VideoCaptureConfig() - : type(CaptureScreen), screen_rect(), region_offset(), display_id(0), window_id(NULL) { } + : type(CaptureScreen), screen_rect(), region_offset(), display_id(0), window_id(NULL), disable_avf(false) { } }; #endif @@ -95,6 +98,7 @@ class IScreenCaptureSource : public RefCountInterface { int icon_height; bool include_screen; bool unfiltered; + bool unskip_system_window; }; enum CaptureMode { diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionVQA.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionVQA.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraLocalUser.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraLocalUser.h old mode 100755 new mode 100644 index 2138d76a7..2db3c9dcf --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraLocalUser.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraLocalUser.h @@ -41,6 +41,7 @@ struct LocalVideoTrackStats; struct RemoteVideoTrackStats; class IMediaPacketReceiver; class IVideoSinkBase; + /** * The ILocalUser class defines the behavior and state of a local user. * @@ -811,6 +812,8 @@ class ILocalUser { virtual int getHighPriorityUserList(std::vector& vipList, int& option) = 0; + virtual int setRemoteSubscribeFallbackOption(int option, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + /** * Sets the blocklist of subscribe remote stream audio. * @@ -1158,6 +1161,17 @@ class ILocalUser { * - < 0: Failure. */ virtual int takeDataChannelSnapshot(aosl_ref_t ares = AOSL_REF_INVALID) = 0; + /** + * send audio metadata + * + * @param metadata The pointer of metadata + * @param length Size of metadata + * @return + * - 0: success + * - <0: failure + * @technical preview + */ + virtual int sendAudioMetadata(const char* metadata, size_t length, aosl_ref_t ares = AOSL_REF_INVALID) = 0; }; /** @@ -1494,6 +1508,20 @@ class ILocalUserObserver { */ virtual void onVideoSizeChanged(user_id_t userId, int width, int height, int rotation) = 0; + /** + * The audio metadata received. + * + * @param userId ID of the remote user. + * @param metadata The pointer of metadata + * @param length Size of metadata + * @technical preview + */ + virtual void onAudioMetadataReceived(user_id_t userId, const char* metadata, size_t length) { + (void)userId; + (void)metadata; + (void)length; + } + /** * The media information of a specified user. */ diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraMediaNode.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraMediaNode.h old mode 100755 new mode 100644 index 682437793..0b2bc0152 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraMediaNode.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraMediaNode.h @@ -140,6 +140,32 @@ class IAudioFilter : public IAudioFilterBase { ~IAudioFilter() {} }; +class IAudioFilterV2 : public IAudioFilter { +public: + class Control : public RefCountInterface { + public: + /** + * @brief Post an event and notify the end users. + * @param key '\0' ended string that describes the key of the event + * @param value '\0' ended string that describes the value of the event + */ + virtual int postEvent(const char* key, const char* value) = 0; + /** + * @brief print log to the SDK. + * @param level Log level @ref agora::commons::LOG_LEVEL + * @param format log formatter string + * @param ... variadic arguments + */ + virtual void printLog(commons::LOG_LEVEL level, const char* format, ...) = 0; + }; +public: + /** + * @brief AgoraSDK set IAudioFilterV2::Control to filter + * @param control IAudioFilterV2::Control + */ + virtual void setExtensionControl(agora::agora_refptr control) = 0; +}; + /** * The `IVideoFilterBase` class is the base class for video filters. You can use this class to implement your own filter * and add the filter to a video track. @@ -365,6 +391,64 @@ class IExtensionVideoFilter : public IVideoFilter { } }; +class ILipSyncFilter : public RefCountInterface { + public: + enum ProcessResult { + kSuccess, // Video frame data is successfully processed + kBypass, // Video frame data should bypass the current filter and flow to its successsors + kDrop, // Video Frame data should be discarded + }; + + class Control : public RefCountInterface { + public: + /** + * @brief Post an event and notify the end users. + * @param key '\0' ended string that describes the key of the event + * @param value '\0' ended string that describes the value of the event + */ + virtual int postEvent(const char* key, const char* value) = 0; + /** + * @brief print log to the SDK. + * @param level Log level @ref agora::commons::LOG_LEVEL + * @param format log formatter string + * @param ... variadic arguments + */ + virtual void printLog(commons::LOG_LEVEL level, const char* format, ...) = 0; + /** + * @brief Ask SDK to disable the current filter if a fatal error is detected + * @param error error code + * @param msg error message + */ + virtual void disableMe(int error, const char* msg) = 0; + /** + * @brief report counter to the SDK. + * @param counter_id counter id + * @param value counter value + */ + virtual void ReportCounter(int32_t counter_id, int32_t value) = 0; + /** + * @brief get stats to the SDK. + * @param counter_id counter id + */ + virtual int GetStats(int32_t counter_id) = 0; + }; + + virtual int start(agora::agora_refptr control) = 0; + + virtual int stop() = 0; + + virtual int setProperty(const char* key, const void* buf, size_t buf_size) { return -1; } + /** + * Convert the audio frame to face info. + * @param inAudioFrame The reference to the audio frame that you want to convert. + * @param outFaceInfo The reference to the face info. + * @return see @ref ProcessResult + */ + virtual ProcessResult convertAudioFrameToFaceInfo(const agora::media::base::AudioPcmFrame& inAudioFrame, char* outFaceInfo) { + return kBypass; + } +}; + /** * The `IVideoSinkBase` class is the base class for the custom video sink. */ @@ -434,10 +518,10 @@ class IVideoSinkBase : public RefCountInterface { class IMediaExtensionObserver : public RefCountInterface { public: virtual ~IMediaExtensionObserver() {} - virtual void onEvent(const char* provider, const char* extension, const char* key, const char* json_value) {} - virtual void onExtensionStopped(const char* provider, const char* extension) {} - virtual void onExtensionStarted(const char* provider, const char* extension) {} - virtual void onExtensionError(const char* provider, const char* extension, int error, const char* message) {} + virtual void onEventWithContext(const ExtensionContext& context, const char* key, const char* json_value) {} + virtual void onExtensionStoppedWithContext(const ExtensionContext& context) {} + virtual void onExtensionStartedWithContext(const ExtensionContext& context) {} + virtual void onExtensionErrorWithContext(const ExtensionContext& context, int error, const char* message) {} }; /** diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraMediaNodeFactory.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraMediaNodeFactory.h old mode 100755 new mode 100644 index a22242b23..90806b543 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraMediaNodeFactory.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraMediaNodeFactory.h @@ -70,7 +70,7 @@ class IMediaNodeFactory : public RefCountInterface { */ virtual agora_refptr createCameraCapturer() = 0; -#if !defined(__ANDROID__) && !(defined(__APPLE__) && TARGET_OS_IPHONE) +#if !defined(__ANDROID__) && !(defined(__APPLE__) && TARGET_OS_IPHONE) && !defined(__OHOS__) /** * Creates a screen capturer. * @@ -218,7 +218,7 @@ class IMediaNodeFactory : public RefCountInterface { */ virtual agora_refptr createMediaPacketSender() = 0; -#if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) +#if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || defined(__OHOS__) /** * Creates screen capture source extension with given provider&extension names * @param provider_name provider name string. diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRemoteAudioMixerSource.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRemoteAudioMixerSource.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRtcConnection.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRtcConnection.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRtmpConnection.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRtmpConnection.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRtmpLocalUser.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRtmpLocalUser.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraScreenCapturer.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraScreenCapturer.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraSyncClient.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraSyncClient.h new file mode 100644 index 000000000..7c8880de2 --- /dev/null +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraSyncClient.h @@ -0,0 +1,139 @@ +// Copyright (c) 2020 Agora.io. All rights reserved + +// This program is confidential and proprietary to Agora.io. +// And may not be copied, reproduced, modified, disclosed to others, published +// or used, in whole or in part, without the express prior written permission +// of Agora.io. + +#pragma once // NOLINT(build/header_guard) +#include "AgoraRefPtr.h" +#include "AgoraBase.h" +#include +#include + +namespace agora { +namespace base { + +enum SyncClientError { + kOk = 0, + kFail = -1, + kConnectSyncFailed = -2, + kConnectDatabaseFailed = -3, + kDisconnectDatabaseFailed = -4, + kDatabaseNotConnected = -5, + kCreateCollectionFailed = -6, + kCollectionNotCreated = -7, + kCollectionExisted = -8, + kInvalidParams = -9, + kNotLoggedIn = -10, + kQueryDocFailed = -11, + kDocNotCreated = -12, +}; + +typedef void(*syncClientCallback)(SyncClientError, void*); +typedef void(*dataBaseOpCallback)(SyncClientError, const char*, void*); +typedef void(*collectionOpCallback)(SyncClientError, const char*, const char*, void*); +typedef void(*queryDocCallback)(SyncClientError error, const char* resultJson, size_t count, bool more, void* userData); + +enum SyncEventType { + kInserted = 0, + kPut = 1, + kDeleted = 2, + + kToBeInserted = 3, + kToBePut = 4, + kToBeDeleted = 5, + + kTransactionBegin = 6, + kTransactionEnd = 7, + kDocSyncEnd = 8, +}; + +/** + * sync client observer + */ +class ISyncClientObserver { + public: + struct CollectionEvent { + SyncEventType type; + const char* path; + const char* value; + }; + virtual void onCollectionEvent(const char* previousJson, const char* curJson, const char* collection, const char* docName, + const CollectionEvent* events, int eventSize) = 0; + virtual void onDatabaseEvent(const char* databaseName, SyncClientError error) = 0; + virtual void onDataException(const char* databaseName, const char* collectionName) = 0; + virtual ~ISyncClientObserver() {}; +}; + +/** + * sync configuration + */ +struct SyncConfig { + const char* appId; + /* shakehand interval in seconds, 0 means enable manual shake hand */ + uint32_t shakehand_interval; + /* connection timeout in seconds */ + uint32_t connection_timeout; + /* compact interval in seconds */ + uint32_t compact_interval; + SyncConfig() : shakehand_interval(1), connection_timeout(10), compact_interval(3600 * 1000) {} +}; + +class ISyncClient : public RefCountInterface { +protected: + virtual ~ISyncClient() {} +public: + + virtual int32_t registerSyncClientObserver(ISyncClientObserver* observer, void(*safeDeleter)(ISyncClientObserver*) = OPTIONAL_NULLPTR, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual int32_t unregisterSyncClientObserver(ISyncClientObserver* observer) = 0; + // client operations + virtual int32_t login(const char* token, const char* channelName, user_id_t userId, syncClientCallback callback, void* userData, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual int32_t queryDoc(const char* database, const char* coll, const char* range_start, const char* range_end, int64_t limits, bool doc_only, bool count_only, queryDocCallback callback, void* userData, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual int32_t logout(aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual int32_t renewToken(const char* token, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + + // database operations + virtual int32_t connectDatabase(const char* database, dataBaseOpCallback callback, void* userData, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual int32_t disconnectDatabase(const char* database, + dataBaseOpCallback callback, void* userData, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual int32_t createCollection(const char* database, const char* collection, + const char** readable, int readSize, + collectionOpCallback callback, void* userData, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual int32_t deleteCollection(const char* database, const char* collection, + collectionOpCallback callback, void* userData, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + + // collection operations + virtual int32_t subscribe(const char* database, const char* collection, + util::AString& snapshotJson) = 0; + virtual int32_t unsubscribe(const char* database, const char* collection, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual int32_t putDoc(const char* database, const char* collection, + const char* docName, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual int32_t deleteDoc(const char* database, const char* collection, + const char* docName, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual int32_t getDocs(const char* database, const char* collection, + util::AString* docNames, uint32_t docSize) = 0; + + // document operations + virtual int32_t putDocValue(const char* database, const char* collection, + const char* docName, const char* jsonValue, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual int32_t updateDocValue(const char* database, const char* collection, + const char* docName, const char* path, + const char* jsonValue, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual int32_t deleteDocValue(const char* database, const char* collection, + const char* docName, const char* path, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual int32_t deleteDocValues(const char* database, const char* collection, const char* docName, + const char** path, uint32_t pathSize, + aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual int32_t getDocValue(const char* database, const char* collection, + const char* docName, util::AString& jsonValue) = 0; + virtual int32_t hasPath(const char* database, const char* collection, + const char* docName, const char* path, bool& result) = 0; + virtual int32_t keepAliveDoc(const char* database, const char* collection, + const char* docName, uint32_t ttl, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + + // sync operations + virtual int32_t shakehand(aosl_ref_t ares = AOSL_REF_INVALID) = 0; +}; +}// namespace base +}// namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoFrame.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoFrame.h old mode 100755 new mode 100644 index 9b114002f..9be3e9cbe --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoFrame.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoFrame.h @@ -40,6 +40,8 @@ struct TextureInfo { EglContextType context_type; void* shared_context; int texture_id; + int64_t fence_object; + int frame_buffer_id; float transform_matrix[16]; }; @@ -57,7 +59,8 @@ struct RawPixelBuffer { kI010, kRGBA, kARGB, - kBGRA + kBGRA, + kABGR }; Format format; uint8_t* data; @@ -73,84 +76,6 @@ struct PaddedRawPixelBuffer { : data(NULL), size(0), stride(0) {} }; -struct ColorSpace { - enum PrimaryID { - // The indices are equal to the values specified in T-REC H.273 Table 2. - PRIMARYID_BT709 = 1, - PRIMARYID_UNSPECIFIED = 2, - PRIMARYID_BT470M = 4, - PRIMARYID_BT470BG = 5, - PRIMARYID_SMPTE170M = 6, // Identical to BT601 - PRIMARYID_SMPTE240M = 7, - PRIMARYID_FILM = 8, - PRIMARYID_BT2020 = 9, - PRIMARYID_SMPTEST428 = 10, - PRIMARYID_SMPTEST431 = 11, - PRIMARYID_SMPTEST432 = 12, - PRIMARYID_JEDECP22 = 22, // Identical to EBU3213-E - }; - - enum RangeID { - // The indices are equal to the values specified at - // https://www.webmproject.org/docs/container/#colour for the element Range. - RANGEID_INVALID = 0, - // Limited Rec. 709 color range with RGB values ranging from 16 to 235. - RANGEID_LIMITED = 1, - // Full RGB color range with RGB valees from 0 to 255. - RANGEID_FULL = 2, - // Range is defined by MatrixCoefficients/TransferCharacteristics. - RANGEID_DERIVED = 3, - }; - - enum MatrixID { - // The indices are equal to the values specified in T-REC H.273 Table 4. - MATRIXID_RGB = 0, - MATRIXID_BT709 = 1, - MATRIXID_UNSPECIFIED = 2, - MATRIXID_FCC = 4, - MATRIXID_BT470BG = 5, - MATRIXID_SMPTE170M = 6, - MATRIXID_SMPTE240M = 7, - MATRIXID_YCOCG = 8, - MATRIXID_BT2020_NCL = 9, - MATRIXID_BT2020_CL = 10, - MATRIXID_SMPTE2085 = 11, - MATRIXID_CDNCLS = 12, - MATRIXID_CDCLS = 13, - MATRIXID_BT2100_ICTCP = 14, - }; - - enum TransferID { - // The indices are equal to the values specified in T-REC H.273 Table 3. - TRANSFERID_BT709 = 1, - TRANSFERID_UNSPECIFIED = 2, - TRANSFERID_GAMMA22 = 4, - TRANSFERID_GAMMA28 = 5, - TRANSFERID_SMPTE170M = 6, - TRANSFERID_SMPTE240M = 7, - TRANSFERID_LINEAR = 8, - TRANSFERID_LOG = 9, - TRANSFERID_LOG_SQRT = 10, - TRANSFERID_IEC61966_2_4 = 11, - TRANSFERID_BT1361_ECG = 12, - TRANSFERID_IEC61966_2_1 = 13, - TRANSFERID_BT2020_10 = 14, - TRANSFERID_BT2020_12 = 15, - TRANSFERID_SMPTEST2084 = 16, - TRANSFERID_SMPTEST428 = 17, - TRANSFERID_ARIB_STD_B67 = 18, - }; - - PrimaryID primaries; - TransferID transfer; - MatrixID matrix; - RangeID range; - - ColorSpace() - : primaries(PRIMARYID_UNSPECIFIED), transfer(TRANSFERID_UNSPECIFIED), - matrix(MATRIXID_UNSPECIFIED), range(RANGEID_INVALID) {} -}; - /** * This structure defines underlying detailed video frame data of @ref agora::rtc::IVideoFrame * @@ -173,7 +98,7 @@ struct VideoFrameData { int width; int height; int rotation; - ColorSpace color_space; + agora::media::base::ColorSpace color_space; int64_t timestamp_ms; // Capture time in milli-seconds }; diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoMixerSource.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoMixerSource.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoTrack.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoTrack.h old mode 100755 new mode 100644 index 628329dbc..ea36ee93e --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoTrack.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoTrack.h @@ -26,6 +26,65 @@ class IVideoEncodedFrameObserver; class IMediaPacketReceiver; class IVideoSinkBase; +enum StreamLayerIndexInternal { + STREAM_LAYER_1 = 1, + STREAM_LAYER_2 = 2, + STREAM_LAYER_3 = 3, + STREAM_LAYER_4 = 4, + STREAM_LAYER_5 = 5, + STREAM_LAYER_6 = 6, + STREAM_LOW = 7, + STREAM_LAYER_COUNT_MAX = 8 + }; + +struct StreamLayerConfigInternal { + VideoDimensions dimensions; + int framerate; + int bitrate_kbps; + bool enable; + StreamLayerConfigInternal() : dimensions(0, 0), framerate(0), bitrate_kbps(STANDARD_BITRATE), enable(false) {} + StreamLayerConfigInternal(const StreamLayerConfigInternal& other) : dimensions(other.dimensions), framerate(other.framerate), bitrate_kbps(other.bitrate_kbps), enable(other.enable) {} + bool operator==(const StreamLayerConfigInternal& rhs) const { + return dimensions == rhs.dimensions && bitrate_kbps == rhs.bitrate_kbps && framerate == rhs.framerate && enable == rhs.enable; + } + + StreamLayerConfigInternal& operator=(const SimulcastConfig::StreamLayerConfig& slc) { + dimensions = slc.dimensions; + framerate = slc.framerate; + enable = slc.enable; + return *this; + } + + void reset() { + dimensions.width = 0; + dimensions.height = 0; + framerate = 0; + bitrate_kbps = STANDARD_BITRATE; + enable = false; + } +}; + +struct SimulcastConfigInternal { + StreamLayerConfigInternal simulcastlayerConfigs[STREAM_LAYER_COUNT_MAX]; + + void reset() { + for (int i = STREAM_LAYER_1; i < STREAM_LAYER_COUNT_MAX; i++) { + simulcastlayerConfigs[i].reset(); + } + } + + bool operator==(const SimulcastConfigInternal& rhs) const { + for (int i = 0; i < STREAM_LAYER_COUNT_MAX; i++) { + if (simulcastlayerConfigs[i] == rhs.simulcastlayerConfigs[i]) { + continue; + } else { + return false; + } + } + return true; + } +}; + enum VideoTrackType { LOCAL_VIDEO_TRACK, REMOTE_VIDEO_TRACK, @@ -149,6 +208,12 @@ class IVideoTrack : public RefCountInterface { ~IVideoTrack() {} }; +struct SimulcastStreamProfile { + int width; + int height; + int framerate; + int bitrate; +}; /** * The statistics of the local video track. */ @@ -255,6 +320,8 @@ struct LocalVideoTrackStats { /** The brightness level of the video image captured by the local camera. See #CAPTURE_BRIGHTNESS_LEVEL_TYPE. */ CAPTURE_BRIGHTNESS_LEVEL_TYPE capture_brightness_level; + + SimulcastStreamProfile simulcast_stream_profile[STREAM_LAYER_COUNT_MAX]; LocalVideoTrackStats() : number_of_streams(0), bytes_major_stream(0), @@ -336,7 +403,7 @@ class ILocalVideoTrack : public IVideoTrack { * - 0: Success. * - < 0: Failure. */ - virtual int setSimulcastStreamMode(SIMULCAST_STREAM_MODE mode, const SimulcastStreamConfig& config, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual int setSimulcastStreamMode(SIMULCAST_STREAM_MODE mode, const SimulcastConfigInternal& config, aosl_ref_t ares = AOSL_REF_INVALID) = 0; /** * Gets the state of the local video stream. @@ -388,6 +455,9 @@ struct RemoteVideoTrackStats { * The bitrate (Kbps) received in the reported interval. */ int receivedBitrate; + /** The decoder input frame rate (fps) of the remote video track. + */ + int decoderInputFrameRate; /** The decoder output frame rate (fps) of the remote video track. */ int decoderOutputFrameRate; @@ -457,13 +527,17 @@ struct RemoteVideoTrackStats { decoder vender id, VideoCodecVenderId */ uint32_t decoder_vender_id; + /** + The decoder codec type of the remote video track + */ + uint32_t decoder_type; RemoteVideoTrackStats() : uid(0), delay(0), width(0), height(0), - receivedBitrate(0), decoderOutputFrameRate(0), rendererOutputFrameRate(0), + receivedBitrate(0), decoderInputFrameRate(0), decoderOutputFrameRate(0), rendererOutputFrameRate(0), frameLossRate(0), packetLossRate(0), rxStreamType(VIDEO_STREAM_HIGH), totalFrozenTime(0), frozenRate(0), received_bytes(0), totalDecodedFrames(0), avSyncTimeMs(0), downlink_process_time_ms(0), frame_render_delay_ms(0), totalActiveTime(0), - publishDuration(0), vqa_mos(0), vqa_avg_cost_ms(0), decoder_vender_id(0) {} + publishDuration(0), vqa_mos(0), vqa_avg_cost_ms(0), decoder_vender_id(0), decoder_type(0) {} }; /** diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/PLACEHOLDER b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/PLACEHOLDER deleted file mode 100644 index ae2c9d75b..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/PLACEHOLDER +++ /dev/null @@ -1 +0,0 @@ -# copy agora headers here \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/Makefile b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/Makefile old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_alloca.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_alloca.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_angel.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_angel.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_ares.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_ares.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_async.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_async.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_atomic.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_atomic.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_audio.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_audio.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_byteswap.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_byteswap.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_data.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_data.h old mode 100755 new mode 100644 index 5bc7cbe5b..3eca075eb --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_data.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_data.h @@ -30,15 +30,46 @@ typedef enum { aosl_dt_vbuf, } aosl_dt_t; +/* data destructor */ +typedef void (*aosl_data_dtor_t) (void *ptr, size_t len); + /** * Create an data object with the specified parameters. * Parameters: * len: the data length; + * dtor: the data buffer destructor function: + * you may want to free some members or call + * the C++ destructor function here; * Return value: * non-NULL: the data object pointer; * NULL: failed with aosl_errno set; **/ -extern __aosl_api__ aosl_data_t aosl_data_create (size_t len); +extern __aosl_api__ aosl_data_t aosl_data_create (size_t len, aosl_data_dtor_t dtor); + +/* user defined data free function */ +typedef void (*aosl_data_user_free_t) (void *ptr, size_t len); + +/** + * Create an data object from the user data buffer pointer. + * Parameters: + * ptr: the data pointer; + * len: the data length; + * dtor: the data buffer free function: + * 1. A libc 'free' like function + * We will take the ownership of the memory pointed by + * ptr, and will invoke the specified destructor when + * finished using. + * 2. An empty function like void myfree (void *ptr, size_t len) {} + * If the memory pointed by ptr is a long life cycle + * memory but does not need to be freed at all, like + * a global data segment based memory, then you can + * pass an empty function pointer as the dtor arg. + * + * Return value: + * non-NULL: the data object pointer; + * NULL: failed with aosl_errno set; + **/ +extern __aosl_api__ aosl_data_t aosl_data_user_create (void *ptr, size_t len, aosl_data_user_free_t dtor); /** * Get the data object type. @@ -70,6 +101,15 @@ extern __aosl_api__ int aosl_data_get (aosl_data_t d); **/ extern __aosl_api__ int aosl_data_put (aosl_data_t d); +/** + * Get the data object usage count. + * Parameters: + * data: the data object; + * Return value: + * the current usage count; + **/ +extern __aosl_api__ int aosl_data_usage (aosl_data_t d); + /** * Get the data pointer of a data object. * Parameters: diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_defs.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_defs.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_display.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_display.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_dq.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_dq.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_errno.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_errno.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_fcntl.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_fcntl.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_file.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_file.h old mode 100755 new mode 100644 index 6847472ae..dcf163ebd --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_file.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_file.h @@ -227,11 +227,12 @@ extern __aosl_api__ int aosl_file_alseek_argv (aosl_fd_t fd, off_t offset, int w * d_ret: the data object for holding return value, the * length must >= sizeof (ssize_t); * d_buf: the buffer for holding the read data; + * buf_off: the buffer offset for holding the read data; * Return value: * <0: failed with aosl_errno set; * 0: async read issued successfully; **/ -extern __aosl_api__ int aosl_co_file_read (aosl_fd_t fd, aosl_data_t d_ret, aosl_data_t d_buf); +extern __aosl_api__ int aosl_co_file_read (aosl_fd_t fd, aosl_data_t d_ret, aosl_data_t d_buf, uintptr_t buf_off); /** * The regular file write function which supports coroutine. diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_http.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_http.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_input.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_input.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_integer_wrappings.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_integer_wrappings.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_jni.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_jni.h old mode 100755 new mode 100644 index cd5164930..43a7d2946 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_jni.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_jni.h @@ -28,7 +28,7 @@ extern "C" { extern __aosl_api__ JavaVM *aosl_java_vm (); extern __aosl_api__ int aosl_set_java_vm (JavaVM *jvm); -extern __aosl_api__ JNIEnv *aosl_this_jni_env (); +extern __aosl_api__ JNIEnv *aosl_this_jni_env (int *attached_p); /** * Set Java Application Context. @@ -44,6 +44,7 @@ extern __aosl_api__ JNIEnv *aosl_this_jni_env (); **/ extern __aosl_api__ int aosl_java_set_context (jobject ctxt); +extern __aosl_api__ void aosl_thread_java_detach (); #ifdef __cplusplus diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_kobj.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_kobj.h old mode 100755 new mode 100644 index 8023e8f6d..ccb86f8c1 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_kobj.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_kobj.h @@ -398,11 +398,9 @@ typedef struct { * argc: the various args count, passed when registering; * argv: the various args vector, passed as various args when registering; * Return value: - * 0: successfully; - * <0: failed with aosl_errno set accordingly. + * None. **/ typedef void (*aosl_kobj_notify_t) (aosl_refobj_t robj, const char *dirpath, const char *name, void *notif_data, uintptr_t argc, uintptr_t argv []); -typedef void (*aosl_kobj_notify_dtor_t) (uintptr_t argc, uintptr_t argv []); /** * Register a notification of the kobject specified by dfd + name for monitoring changes. @@ -410,7 +408,7 @@ typedef void (*aosl_kobj_notify_dtor_t) (uintptr_t argc, uintptr_t argv []); * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: * 1. if the name starts with a '/', then directory is root; * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; + * name: the object name; * touch: 0: notify only when changed; !0: notify anyway; * qid: the mpq you want the target function to be invoked in, must be valid; * ref: specify a ref object just like the queue operation of an mpq; @@ -424,7 +422,7 @@ typedef void (*aosl_kobj_notify_dtor_t) (uintptr_t argc, uintptr_t argv []); * NULL: failed with aosl_errno set accordingly. * The return value only used for unregister, no other usage. **/ -extern __aosl_api__ void *aosl_kobj_notify_register (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_t f, aosl_kobj_notify_dtor_t dtor, uintptr_t argc, ...); +extern __aosl_api__ void *aosl_kobj_notify_register (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_t f, aosl_obj_dtor_t dtor, uintptr_t argc, ...); /** * Register a notification of the kobject specified by dfd + name for monitoring changes. @@ -432,7 +430,7 @@ extern __aosl_api__ void *aosl_kobj_notify_register (aosl_kfd_t dfd, const char * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: * 1. if the name starts with a '/', then directory is root; * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; + * name: the object name; * touch: 0: notify only when changed; !0: notify anyway; * qid: the mpq you want the target function to be invoked in, must be valid; * ref: specify a ref object just like the queue operation of an mpq; @@ -447,7 +445,7 @@ extern __aosl_api__ void *aosl_kobj_notify_register (aosl_kfd_t dfd, const char * NULL: failed with aosl_errno set accordingly. * The return value only used for unregister, no other usage. **/ -extern __aosl_api__ void *aosl_kobj_notify_register_args (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_t f, aosl_kobj_notify_dtor_t dtor, uintptr_t argc, va_list args); +extern __aosl_api__ void *aosl_kobj_notify_register_args (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_t f, aosl_obj_dtor_t dtor, uintptr_t argc, va_list args); /** * Register a notification of the kobject specified by dfd + name for monitoring changes. @@ -455,7 +453,7 @@ extern __aosl_api__ void *aosl_kobj_notify_register_args (aosl_kfd_t dfd, const * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: * 1. if the name starts with a '/', then directory is root; * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; + * name: the object name; * touch: 0: notify only when changed; !0: notify anyway; * qid: the mpq you want the target function to be invoked in, must be valid; * ref: specify a ref object just like the queue operation of an mpq; @@ -470,15 +468,15 @@ extern __aosl_api__ void *aosl_kobj_notify_register_args (aosl_kfd_t dfd, const * NULL: failed with aosl_errno set accordingly. * The return value only used for unregister, no other usage. **/ -extern __aosl_api__ void *aosl_kobj_notify_register_argv (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_t f, aosl_kobj_notify_dtor_t dtor, uintptr_t argc, uintptr_t argv []); +extern __aosl_api__ void *aosl_kobj_notify_register_argv (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_t f, aosl_obj_dtor_t dtor, uintptr_t argc, uintptr_t argv []); /** - * Unregister a notification of the kobject specified by dfd + name for monitoring changes. + * Unregister a notification of the kobject specified by dfd + name. * Parameters: * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: * 1. if the name starts with a '/', then directory is root; * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; + * name: the object name; * handle: the handle returned by above register functions; * Return value: * 0: successfully; diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_list.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_list.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_log.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_log.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_marshalling.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_marshalling.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mm.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mm.h old mode 100755 new mode 100644 index 5d58b35b9..97b7b0fe4 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mm.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mm.h @@ -22,6 +22,256 @@ extern "C" { #endif +/** + * aosl memory management malloc like function + * Note: this is memory pool based implementation, so it + * can decrease the fragmentation. + * Parameters: + * size: the allocation size in bytes; + * Return Value: + * non-NULL: success + * NULL: failure with aosl_errno set + * Remarks: + * The memory allocated by this function must be freed + * via aosl_mm_free when finished using. + **/ +extern __aosl_api__ void *aosl_mm_malloc (size_t size); + +/** + * aosl memory management realloc like function + * Note: this is memory pool based implementation, so it + * can decrease the fragmentation. + * Parameters: + * ptr: the old pointer wanting to realloc; + * size: the new allocation size in bytes; + * Return Value: + * non-NULL: success + * NULL: failure with aosl_errno set + * Remarks: + * The contents will be unchanged in the range from the + * start of the region up to the minimum of the old and + * new sizes; + * If the new size is larger than the old size, the added + * memory will not be initialized; + * If ptr is NULL, then the call is equivalent to + * aosl_mm_malloc(size), for all values of size; + * If size is equal to zero, and ptr is not NULL, then the + * call is equivalent to aosl_mm_free(ptr); + * Unless ptr is NULL, it must have been returned by an + * earlier call to aosl_mm_malloc, aosl_mm_calloc, or + * aosl_mm_realloc; + * If this function fails, the original block is left + * untouched, it is not freed or moved; + * The memory allocated by this function must be freed + * via aosl_mm_free when finished using. + **/ +extern __aosl_api__ void *aosl_mm_realloc (void *ptr, size_t size); + +/** + * aosl memory management calloc like function + * Note: this is memory pool based implementation, so it + * can decrease the fragmentation. + * Parameters: + * nmemb: number of array elements count; + * size: the element size in bytes; + * Return Value: + * non-NULL: success + * NULL: failure with aosl_errno set + * Remarks: + * This function allocates memory for an array of nmemb + * elements of size bytes each and returns a pointer to + * the allocated memory, and the memory is set to zero; + * If nmemb or size is 0, then returns NULL; + * The memory allocated by this function must be freed + * via aosl_mm_free when finished using. + **/ +extern __aosl_api__ void *aosl_mm_calloc (size_t nmemb, size_t size); + +/** + * aosl memory management free like function + * Note: this is memory pool based implementation, so it + * can decrease the fragmentation. + * Parameters: + * ptr: the allocated pointer by aosl_mm_malloc; + * Return Value: + * None. + * Remarks: + * Do NOT try to free a pointer which is not allocated + * by aosl_mm_malloc via this function. + **/ +extern __aosl_api__ void aosl_mm_free (void *ptr); + +/** + * Preallocate the objects count to threshold for the memory pool specified by size. + * Note: this is memory pool based implementation, so it + * can decrease the fragmentation. + * Parameters: + * size: specify which the memory pool will be set threshold; + * threshold: specify the memory objects count will be preallocated; + * Return Value: + * 0: success + * <0: failure with aosl_errno set + * Remarks: + * If set the threshold first, then the following first time + * allocation operation will be faster than normal. + **/ +extern __aosl_api__ int aosl_mm_set_threshold (size_t size, size_t threshold); + +/** + * Set the max objects count to max_val for the memory pool specified by size. + * Note: this is memory pool based implementation, so it + * can decrease the fragmentation. + * Parameters: + * size: specify which the memory pool will be set threshold; + * max_val: specify the max memory objects count; + * Return Value: + * 0: success + * <0: failure with aosl_errno set + * Remarks: + * If the max objects were allocated, and the following allocation + * will return NULL if no objects was freed. + **/ +extern __aosl_api__ int aosl_mm_set_max (size_t size, size_t max_val); + +/** + * Shrink the memory pool specified by the size parameter. + * Parameters: + * size: specify which the memory pool will be shrinked; + * Return Value: + * None. + **/ +extern __aosl_api__ void aosl_mm_shrink (size_t size); + +/** + * Shrink all the created memory pools. + * Parameters: + * None. + * Return Value: + * None. + **/ +extern __aosl_api__ void aosl_mm_shrink_all (void); + +/* the aosl freelist object type */ +typedef struct _aosl_freelist_ *aosl_freelist_t; + +/** + * Create a freelist object for efficient memory management. + * Note: this is memory pool based implementation, so it + * can decrease the fragmentation. + * Parameters: + * obj_size: the memory object size in bytes for this freelist; + * namefmt: printf like format for the freelist object name; + * ...: printf like ... args; + * Return Value: + * non-NULL: success + * NULL: failure with aosl_errno set + * Remarks: + * The max name length of freelist object is 32 including + * the final '\0'. + **/ +extern __aosl_api__ aosl_freelist_t aosl_freelist_create (size_t obj_size, const char *namefmt, ...); + +/** + * Create a freelist object for efficient memory management. + * Note: this is memory pool based implementation, so it + * can decrease the fragmentation. + * Parameters: + * obj_size: the memory object size in bytes for this freelist; + * namefmt: vprintf like format for the freelist object name; + * args: vprintf like args; + * Return Value: + * non-NULL: success + * NULL: failure with aosl_errno set + * Remarks: + * The max name length of freelist object is 32 including + * the final '\0'. + **/ +extern __aosl_api__ aosl_freelist_t aosl_freelist_create_args (size_t obj_size, const char *namefmt, va_list args); + +/** + * Allocate memory from the specified freelist object. + * Note: this is memory pool based implementation, so it + * can decrease the fragmentation. + * Parameters: + * fl: the freelist object; + * Return Value: + * non-NULL: success + * NULL: failure with aosl_errno set + * Remarks: + * The allocated memory must be freed by aosl_freelist_free + * after finished using. + **/ +extern __aosl_api__ void *aosl_freelist_alloc (aosl_freelist_t fl); + +/** + * Free memory to the specified freelist object. + * Note: this is memory pool based implementation, so it + * can decrease the fragmentation. + * Parameters: + * fl: the freelist object; + * ptr: the memory pointer will be freed; + * Return Value: + * None. + * Remarks: + * The ptr must be allocated from fl. + **/ +extern __aosl_api__ void aosl_freelist_free (aosl_freelist_t fl, void *ptr); + +/** + * Preallocate the objects count to threshold for the specified freelist object. + * Note: this is memory pool based implementation, so it + * can decrease the fragmentation. + * Parameters: + * fl: the freelist object which will be set threshold; + * threshold: specify the memory objects count will be preallocated; + * Return Value: + * 0: success + * <0: failure with aosl_errno set + * Remarks: + * If set the threshold first, then the following first time + * allocation operation will be faster than normal. + **/ +extern __aosl_api__ int aosl_freelist_set_threshold (aosl_freelist_t fl, size_t threshold); + +/** + * Set the max objects count to max_val for the specified freelist object. + * Note: this is memory pool based implementation, so it + * can decrease the fragmentation. + * Parameters: + * fl: the freelist object which will be set max memory objects count; + * max_val: specify the max memory objects count; + * Return Value: + * 0: success + * <0: failure with aosl_errno set + * Remarks: + * If the max objects were allocated, and the following allocation + * will return NULL if no objects was freed. + **/ +extern __aosl_api__ int aosl_freelist_set_max (aosl_freelist_t fl, size_t max_val); + +/** + * Shrink the freelist specified by the fl. + * Parameters: + * fl: the freelist object which will be shrinked; + * Return Value: + * None. + **/ +extern __aosl_api__ void aosl_freelist_shrink (aosl_freelist_t fl); + +/** + * Destroy the freelist specified by the fl. + * Parameters: + * fl: the freelist object which will be destroyed; + * Return Value: + * 0: success + * <0: failure with aosl_errno set + * Remarks: + * If there are allocated objects from this freelist, then it + * could not be destroyed, so the destroy call would fail. + **/ +extern __aosl_api__ int aosl_freelist_destroy (aosl_freelist_t fl); + + extern __aosl_api__ void *aosl_malloc (size_t size); extern __aosl_api__ void aosl_free (void *ptr); extern __aosl_api__ void *aosl_calloc (size_t nmemb, size_t size); diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_module.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_module.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq.h old mode 100755 new mode 100644 index dcda4bc6f..3dc8c1b95 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq.h @@ -409,19 +409,50 @@ extern __aosl_api__ int aosl_mpq_last_costs (aosl_ts_t *load_p, aosl_ts_t *idle_ */ extern __aosl_api__ int aosl_mpq_exec_counters (uint64_t *funcs_count_p, uint64_t *timers_count_p, uint64_t *fds_count_p); + +typedef struct { + uint32_t fw_avg; /* function average wait time */ + uint32_t fw_worst; /* function worst wait time */ + uint32_t fe_avg; /* function average exec time */ + uint32_t fe_worst; /* function worst exec time */ + uint32_t f_count; /* executed functions count */ +} aosl_ftimes_t; + +/** + * Get the average & worst function wait & execution times of this mpq + * Parameters: + * qid: the mpq id + * ftimes: the variable address for saving the function times + * reset: whether reset the counters, 0 for not clear, other values clear + * Return value: + * <0: indicates error, check aosl_errno for detail + * 0: the average function execution time was saved to *fe_*_p + */ +extern __aosl_api__ int aosl_mpq_ftimes (aosl_mpq_t qid, aosl_ftimes_t *ftimes, int reset); + /** * Get the average & worst function wait time of this mpq * Parameters: * qid: the mpq id - * fw_avg_p: the variable for saving the average function wait time - * fw_worst_p: the variable for saving the worst function wait time + * fw_avg_p: the variable address for saving the average function wait time + * fw_worst_p: the variable address for saving the worst function wait time * reset: whether reset the counters, 0 for not clear, other values clear * Return value: * <0: indicates error, check aosl_errno for detail - * 0: the average function wait time was saved to *fwtime_p + * 0: the average function wait time was saved to *fw_*_p */ extern __aosl_api__ int aosl_mpq_fwtime (aosl_mpq_t qid, uint32_t *fw_avg_p, uint32_t *fw_worst_p, int reset); +/** + * Get the name of the current running mpq + * Parameters: + * None. + * Return value: + * non-NULL: the running mpq name; + * NULL: the running thread is not an mpq thread; + */ +extern __aosl_api__ const char *aosl_mpq_this_name (void); + /** * Invoking this function will enter the infinite run loop of current thread's multiplex queue. * Generally, this function is only used in the non-mpq thread, such as the main thread. diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_fd.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_fd.h old mode 100755 new mode 100644 index 96dfd3e0a..2ac67539d --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_fd.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_fd.h @@ -112,10 +112,44 @@ extern __aosl_api__ int aosl_mpq_enable_fd (aosl_fd_t fd); extern __aosl_api__ ssize_t aosl_write (aosl_fd_t fd, const void *buf, size_t len); -#define AOSL_MPQ_FD_IN 0x1 -#define AOSL_MPQ_FD_OUT 0x2 +#define AOSL_FD_EVM_SET 0 /* fd event mask set */ +#define AOSL_FD_EVM_ADD 1 /* fd event mask add */ +#define AOSL_FD_EVM_DEL 2 /* fd event mask del */ -extern __aosl_api__ int aosl_mpq_modify_fd (aosl_fd_t fd, int eventmask); +#define AOSL_FD_EV_I 0x1 /* fd event input */ +#define AOSL_FD_EV_O 0x2 /* fd event output */ + +/** + * Modify the fd listening event mask. + * Parameters: + * fd: the fd you want to modify event mask + * ctrl: one of AOSL_FD_EVM_SET, AOSL_FD_EVM_ADD or AOSL_FD_EVM_DEL + * for setting, adding or deleting event mask respectively + * eventmask: bitmask of AOSL_FD_EV_I and AOSL_FD_EV_O + * Return value: + * <0: error occured, and aosl_errno indicates which error; + * 0: call successful, and '*arg' is value of the N-th argument; + * Remarks: + * This function is used for flow control normally, if we do not + * want to receive data from fd now, then we can remove the bit + * AOSL_FD_EV_I from the event mask, and add it again later + * when needed. + **/ +extern __aosl_api__ int aosl_fd_evm_ctrl (aosl_fd_t fd, int ctrl, int eventmask); + +/** + * Clear the fd error. + * Parameters: + * fd: the fd you want to clear error + * Return value: + * <0: error occured, and aosl_errno indicates which error; + * 0: call successful, and '*arg' is value of the N-th argument; + * Remarks: + * The fd errors are also edge triggered, so if some error is not real + * error in fact, you must clear the error manually, otherwise the fd + * would be in an incorrect state and could not work normally. + **/ +extern __aosl_api__ int aosl_fd_clear_err (aosl_fd_t fd); /** * Get the N-th argument of the mpq attached fd. @@ -131,9 +165,6 @@ extern __aosl_api__ int aosl_mpq_fd_arg (aosl_fd_t fd, uintptr_t n, uintptr_t *a extern __aosl_api__ int aosl_mpq_disable_fd (aosl_fd_t fd); extern __aosl_api__ int aosl_mpq_del_fd (aosl_fd_t fd); -extern __aosl_api__ int aosl_fd_clear_err (aosl_fd_t fd); -extern __aosl_api__ int aosl_fd_no_auto_disable (aosl_fd_t fd); -extern __aosl_api__ int aosl_fd_ignore_err (aosl_fd_t fd, int err); extern __aosl_api__ int aosl_close (aosl_fd_t fd); @@ -144,11 +175,12 @@ extern __aosl_api__ int aosl_close (aosl_fd_t fd); * d_ret: the data object for holding return value, the * length must >= sizeof (ssize_t); * d_buf: the buffer for holding the read data; + * buf_off: the buffer offset for holding the read data; * Return value: * <0: failed with aosl_errno set; * 0: async read issued successfully; **/ -extern __aosl_api__ int aosl_co_read (aosl_fd_t fd, aosl_data_t d_ret, aosl_data_t d_buf); +extern __aosl_api__ int aosl_co_read (aosl_fd_t fd, aosl_data_t d_ret, aosl_data_t d_buf, uintptr_t buf_off); /** * The I/O device write function which supports coroutine. diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_net.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_net.h old mode 100755 new mode 100644 index 69c2f3c3f..82763e049 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_net.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_net.h @@ -240,12 +240,13 @@ extern __aosl_api__ int aosl_co_accept (aosl_fd_t fd, aosl_data_t d_ret, aosl_da * d_ret: the data object for holding return value, the * length must >= sizeof (ssize_t); * d_buf: the buffer for holding the read data; + * buf_off: the buffer offset for holding the read data; * flags: the flags same as recv syscall; * Return value: * <0: failed with aosl_errno set; * 0: async read issued successfully; **/ -extern __aosl_api__ int aosl_co_recv (aosl_fd_t fd, aosl_data_t d_ret, aosl_data_t d_buf, int flags); +extern __aosl_api__ int aosl_co_recv (aosl_fd_t fd, aosl_data_t d_ret, aosl_data_t d_buf, uintptr_t buf_off, int flags); /** * The socket recv function which supports coroutine. @@ -254,6 +255,7 @@ extern __aosl_api__ int aosl_co_recv (aosl_fd_t fd, aosl_data_t d_ret, aosl_data * d_ret: the data object for holding return value, the * length must >= sizeof (ssize_t); * d_buf: the buffer for holding the read data; + * buf_off: the buffer offset for holding the read data; * flags: the flags same as recvfrom syscall; * d_addr: the data object for holding the remote address, * the len must >= sizeof (aosl_sk_addr_and_len_t); @@ -261,7 +263,7 @@ extern __aosl_api__ int aosl_co_recv (aosl_fd_t fd, aosl_data_t d_ret, aosl_data * <0: failed with aosl_errno set; * 0: async read issued successfully; **/ -extern __aosl_api__ int aosl_co_recvfrom (aosl_fd_t fd, aosl_data_t d_ret, aosl_data_t d_buf, int flags, aosl_data_t d_addr); +extern __aosl_api__ int aosl_co_recvfrom (aosl_fd_t fd, aosl_data_t d_ret, aosl_data_t d_buf, uintptr_t buf_off, int flags, aosl_data_t d_addr); /** * The socket connect function which supports coroutine. diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_timer.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_timer.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpqp.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpqp.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_os.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_os.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_pmdf.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_pmdf.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_poll.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_poll.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_profile.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_profile.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_psb.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_psb.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_rbtree.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_rbtree.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_ref.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_ref.h old mode 100755 new mode 100644 index 166a9da3b..4a2f439fa --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_ref.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_ref.h @@ -114,6 +114,21 @@ extern __aosl_api__ int aosl_ref_write (aosl_ref_t ref, aosl_ref_func_t f, uintp extern __aosl_api__ int aosl_ref_write_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args); extern __aosl_api__ int aosl_ref_write_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []); +/** + * Hold the ref object and set it unsafe, then invoke the specified callback function. + * Parameter: + * ref: the ref object id; + * f: the callback function; + * argc: the args count + * ...: variable args + * Return value: + * 0: success + * <0: failure with aosl_errno set + **/ +extern __aosl_api__ int aosl_ref_unsafe (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...); +extern __aosl_api__ int aosl_ref_unsafe_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args); +extern __aosl_api__ int aosl_ref_unsafe_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []); + /** * Hold the ref object and set it maystall, then invoke the specified callback function. * Parameter: @@ -168,6 +183,21 @@ extern __aosl_api__ int aosl_refobj_read (aosl_refobj_t robj, aosl_ref_func_t f, extern __aosl_api__ int aosl_refobj_read_args (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, va_list args); extern __aosl_api__ int aosl_refobj_read_argv (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []); +/** + * Make sure set the ref object specified by robj unsafe, then invoke the specified callback function. + * Parameter: + * robj: the ref object itself; + * f: the callback function; + * argc: the args count + * ...: variable args + * Return value: + * 0: success + * <0: failure with aosl_errno set + **/ +extern __aosl_api__ int aosl_refobj_unsafe (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, ...); +extern __aosl_api__ int aosl_refobj_unsafe_args (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, va_list args); +extern __aosl_api__ int aosl_refobj_unsafe_argv (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []); + /** * Make sure set the ref object specified by robj maystall, then invoke the specified callback function. * Parameter: diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_route.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_route.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_sbus.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_sbus.h old mode 100755 new mode 100644 index b35123f2e..8e047859f --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_sbus.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_sbus.h @@ -16,6 +16,9 @@ #include #include +#include +#include +#include #ifdef __cplusplus @@ -25,15 +28,127 @@ extern "C" { /** - * Create a software bus. + * Create a software bus object. * Parameters: - * name: the software bus name; + * name: the software bus name; * Return value: - * the current reference count after get; + * 0: successfully; + * <0: failed with aosl_errno set accordingly. **/ extern __aosl_api__ int aosl_sbus_create (const char *name); +/** + * Action callback function for a bus object, which will be invoked when the bus has data to deliver. + * Parameters: + * robj: the ref object specified when registering; + * name: the bus object name; + * data: the bus data; + * argc: the various args count, passed when registering; + * argv: the various args vector, passed as various args when registering; + * Return value: + * None. + * Remarks: + * If we issue async operation which uses the data object in this callback function, we must increase + * the usage before issuing. + **/ +typedef void (*aosl_sbus_data_t) (aosl_refobj_t robj, const char *name, aosl_data_t data, uintptr_t argc, uintptr_t argv []); + + +/** + * Add an action of the bus object specified by name for processing data. + * Parameters: + * name: the bus object name; + * qid: the mpq you want the target function to be invoked in, if invalid, arbitrary general pool mpq; + * ref: specify a ref object just like the queue operation of an mpq; + * max: the max queued data object count, if exceeds then drop the eldest one automatically; + * f_name: specify the target function name; + * f: the target function; + * dtor: destructor which be invoked when delete the action; + * argc: the various args count; + * ...: the various args; + * Return value: + * non-NULL: successfully; + * NULL: failed with aosl_errno set accordingly. + * The return value only used for unregister, no other usage. + **/ +extern __aosl_api__ void *aosl_sbus_action_add (const char *name, aosl_mpq_t qid, aosl_ref_t ref, uintptr_t max, const char *f_name, aosl_sbus_data_t f, aosl_obj_dtor_t dtor, uintptr_t argc, ...); + +/** + * Add an action of the kobject specified by name for processing data. + * Parameters: + * name: the bus object name; + * qid: the mpq you want the target function to be invoked in, if invalid, arbitrary general pool mpq; + * ref: specify a ref object just like the queue operation of an mpq; + * max: the max queued data object count, if exceeds then drop the eldest one automatically; + * f_name: specify the target function name; + * f: the target function; + * dtor: destructor which be invoked when delete the action; + * argc: the various args count; + * args: the various args; + * Return value: + * Return value: + * non-NULL: successfully; + * NULL: failed with aosl_errno set accordingly. + * The return value only used for unregister, no other usage. + **/ +extern __aosl_api__ void *aosl_sbus_action_add_args (const char *name, aosl_mpq_t qid, aosl_ref_t ref, uintptr_t max, const char *f_name, aosl_sbus_data_t f, aosl_obj_dtor_t dtor, uintptr_t argc, va_list args); + +/** + * Add an action of the bus object specified by name for processing data. + * Parameters: + * name: the bus object name; + * qid: the mpq you want the target function to be invoked in, if invalid, arbitrary general pool mpq; + * ref: specify a ref object just like the queue operation of an mpq; + * max: the max queued data object count, if exceeds then drop the eldest one automatically; + * f_name: specify the target function name; + * f: the target function; + * dtor: destructor which be invoked when delete the action; + * argc: the various args count; + * argv: the various args vector; + * Return value: + * Return value: + * non-NULL: successfully; + * NULL: failed with aosl_errno set accordingly. + * The return value only used for unregister, no other usage. + **/ +extern __aosl_api__ void *aosl_sbus_action_add_argv (const char *name, aosl_mpq_t qid, aosl_ref_t ref, uintptr_t max, const char *f_name, aosl_sbus_data_t f, aosl_obj_dtor_t dtor, uintptr_t argc, uintptr_t argv []); + +/** + * Delete an action of the bus object specified by name. + * Parameters: + * name: the bus object name; + * h_action: the handle returned by the above add functions; + * Return value: + * 0: successfully; + * <0: failed with aosl_errno set accordingly. + **/ +extern __aosl_api__ int aosl_sbus_action_del (const char *name, void *h_action); +/** + * Send data to the bus object. + * Parameters: + * name: the bus object name; + * data: the data will be sent to bus; + * Return value: + * 0: successfully; + * <0: failed with aosl_errno set accordingly. + * Remarks: + * The function will increase the usage of data automatically, + * so the calling function can decrease the usage just after + * this function returns, and no need to worry about the async + * operations triggerd by this function. + **/ +extern __aosl_api__ int aosl_sbus_send (const char *name, aosl_data_t data); + +/** + * Delete the bus object specified by name. + * Parameters: + * name: the bus object name; + * Return value: + * 0: successfully; + * <0: failed with aosl_errno set accordingly. + **/ +extern __aosl_api__ int aosl_sbus_delete (const char *name); #ifdef __cplusplus diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_so.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_so.h old mode 100755 new mode 100644 index d3b922d16..049567700 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_so.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_so.h @@ -15,29 +15,31 @@ #include #include +#include #ifdef __cplusplus extern "C" { #endif +#define AOSL_SO_DEFAULT_VER (0) -extern __aosl_api__ int aosl_so_register (const char *name, const void *mod); +extern __aosl_api__ int aosl_so_register (const char *name, const void *mod, uintptr_t version); #if defined (__GNUC__) -#define AOSL_SO_REGISTER(name) \ +#define AOSL_SO_REGISTER_VER(name, version) \ static void __attribute__ ((constructor, used)) _##name##_so_reg_ctor (void) \ { \ - if (aosl_so_register (#name, (const void *)_##name##_so_reg_ctor) < 0) \ - aosl_printf ("SO register failed, so could not monitor it."); \ + if (aosl_so_register (#name, (const void *)_##name##_so_reg_ctor, version) < 0) \ + aosl_log (AOSL_LOG_WARNING, "so lib %s register failed, err %d.", #name, aosl_errno); \ } #elif defined (_MSC_VER) #pragma section (".CRT$XIG", long, read) -#define AOSL_SO_REGISTER(name) \ +#define AOSL_SO_REGISTER_VER(name, version) \ static int _##name##_so_reg_ctor (void) \ { \ - if (aosl_so_register (#name, (const void *)_##name##_so_reg_ctor) < 0) \ - aosl_printf ("SO register failed, so could not monitor it."); \ + if (aosl_so_register (#name, (const void *)_##name##_so_reg_ctor, version) < 0) \ + aosl_log (AOSL_LOG_WARNING, "so lib %s register failed, err %d.", #name, aosl_errno); \ return 0; \ } \ __declspec(allocate(".CRT$XIG")) int (*_##name##_so_module_ctor_f) (void) = _##name##_so_reg_ctor; @@ -45,6 +47,11 @@ extern __aosl_api__ int aosl_so_register (const char *name, const void *mod); #error Unsupported Toolchain! #endif +#if defined(AOSL_SO_REGISTER_VER) +#define AOSL_SO_REGISTER(name) \ + AOSL_SO_REGISTER_VER(name, AOSL_SO_DEFAULT_VER) +#endif + #ifdef __cplusplus } diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_socket.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_socket.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_task.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_task.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_thread.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_thread.h old mode 100755 new mode 100644 index 3a28c693a..ecfbb25ec --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_thread.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_thread.h @@ -72,6 +72,20 @@ extern __aosl_api__ int aosl_thrd_getname (aosl_thrdid_t thrd, char *namebuf, si **/ extern __aosl_api__ int aosl_get_thread_times (aosl_osthrd_t thrd, int *running, uint64_t *system_us, uint64_t *user_us); +/** + * Get the mpq thread flags. + * Parameters: + * thrd: the retrieving thread id + * Linux: the thread tid + * XNU: the mach thread id, type is mach_port_t + * Windows: the Windows thread id, type is DWORD + * q_flags: the mpq flags + * Return Value: + * 0: success + * <0: failure with aosl_errno set + **/ +extern __aosl_api__ int aosl_thrd_getflags (aosl_thrdid_t thrd_id, int *q_flags); + typedef uintptr_t aosl_tls_key_t; extern __aosl_api__ int aosl_tls_key_create (aosl_tls_key_t *key, void (*dtor) (void *)); diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_time.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_time.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_types.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_types.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_utils.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_utils.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_value.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_value.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_vcodec.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_vcodec.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_version.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_version.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_video.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_video.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_xdump.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_xdump.h old mode 100755 new mode 100644 index ee886dd52..7aa932755 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_xdump.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_xdump.h @@ -2,6 +2,7 @@ #define __AOSL_XDUMP_H__ #include +#include #ifdef __cplusplus extern "C" { @@ -10,6 +11,8 @@ extern "C" { /** * xdump callback info about crash: + * @module_ver: the module version + * @module_name: the module name * @log_file: the full path of log_file * @type: the dump type: * 0: crash @@ -20,11 +23,14 @@ extern "C" { #define AOSL_XDUMP_CRASH 0 #define AOSL_XDUMP_DEAD 1 typedef struct { + uintptr_t module_ver; + const char *module_name; const char *log_file; int type; void *crash_at; void *ld_begin; void *ld_end; + int q_flags; } xdump_info_t; typedef void (*xdump_cb_t)(const xdump_info_t *log_file); diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/Makefile b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/Makefile old mode 100755 new mode 100644 index a9acdd19e..14376d9c2 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/Makefile +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/Makefile @@ -6,7 +6,6 @@ header-y += aosl_mpq_timer_lambda.h header-y += aosl_ref_class.h header-y += aosl_task_class.h header-y += aosl_thread_class.h -header-y += aosl_usage_class.h header-y += aosl_kobj_class.h header-y += aosl_value_class.h header-y += aosl_data_class.h diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_ares_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_ares_class.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_async_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_async_class.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_data_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_data_class.h old mode 100755 new mode 100644 index f8cd8054b..edf9b265a --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_data_class.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_data_class.h @@ -15,6 +15,7 @@ #include +#include #include #include @@ -26,26 +27,30 @@ class aosl_data_class { aosl_data_t d; public: - aosl_data_class () + aosl_data_class (void) { d = NULL; } aosl_data_class (const aosl_data_class &src) { - d = src.d; - if (d != NULL) - aosl_data_get (d); + if (this != &src) { + d = src.d; + if (d != NULL) + aosl_data_get (d); + } } aosl_data_class &operator = (const aosl_data_class &src) { - if (d != NULL) - aosl_data_put (d); + if (this != &src) { + if (d != NULL) + aosl_data_put (d); - d = src.d; - if (d != NULL) - aosl_data_get (d); + d = src.d; + if (d != NULL) + aosl_data_get (d); + } return *this; } @@ -55,13 +60,6 @@ class aosl_data_class { return d; } - aosl_data_t detach () - { - aosl_data_t data = d; - d = NULL; - return data; - } - void *ptr () const { if (d != NULL) @@ -87,17 +85,22 @@ class aosl_data_class { #if (__cplusplus >= 201103) || defined (_MSC_VER) aosl_data_class (aosl_data_class &&src) { - d = src.d; - src.d = NULL; + if (this != &src) { + d = src.d; + src.d = NULL; + } } aosl_data_class &operator = (aosl_data_class &&src) { - if (d != NULL) - aosl_data_put (d); + if (this != &src) { + if (d != NULL) + aosl_data_put (d); + + d = src.d; + src.d = NULL; + } - d = src.d; - src.d = NULL; return *this; } #endif /* C++11 */ @@ -105,31 +108,39 @@ class aosl_data_class { class aosl_data_buf: public aosl_data_class { public: + aosl_data_buf (void) + { + } + aosl_data_buf (size_t sz) { - if (sz > 0) { - d = aosl_data_create (sz); - if (d == NULL) - abort (); - } + d = aosl_data_create (sz, NULL); + if (d == NULL) + abort (); } aosl_data_buf (const void *src, size_t len) { - if (len > 0) { - d = aosl_data_create (len); - if (d == NULL) - abort (); + d = aosl_data_create (len, NULL); + if (d == NULL) + abort (); + if (len > 0) memcpy (ptr (), src, len); - } + } + + aosl_data_buf (void *ptr, size_t len, aosl_data_user_free_t dtor) + { + d = aosl_data_user_create (ptr, len, dtor); + if (d == NULL) + abort (); } aosl_data_buf (const char *str) { if (str != NULL) { size_t str_l = strlen (str); - d = aosl_data_create (str_l + 1); + d = aosl_data_create (str_l + 1, NULL); if (d == NULL) abort (); @@ -137,6 +148,20 @@ class aosl_data_buf: public aosl_data_class { } } + aosl_data_buf (char *str, aosl_data_user_free_t dtor) + { + size_t len; + if (str != NULL) { + len = strlen (str) + 1; + } else { + len = 0; + } + + d = aosl_data_user_create (str, len, dtor); + if (d == NULL) + abort (); + } + aosl_data_buf (aosl_data_t src) { d = src; @@ -146,9 +171,11 @@ class aosl_data_buf: public aosl_data_class { aosl_data_buf (const aosl_data_buf &src) { - d = src.d; - if (d != NULL) - aosl_data_get (d); + if (this != &src) { + d = src.d; + if (d != NULL) + aosl_data_get (d); + } } aosl_data_buf &operator = (const char *str) @@ -160,7 +187,7 @@ class aosl_data_buf: public aosl_data_class { if (str != NULL) { size_t str_l = strlen (str); - d = aosl_data_create (str_l + 1); + d = aosl_data_create (str_l + 1, NULL); if (d == NULL) abort (); @@ -184,12 +211,14 @@ class aosl_data_buf: public aosl_data_class { aosl_data_buf &operator = (const aosl_data_buf &src) { - if (d != NULL) - aosl_data_put (d); + if (this != &src) { + if (d != NULL) + aosl_data_put (d); - d = src.d; - if (d != NULL) - aosl_data_get (d); + d = src.d; + if (d != NULL) + aosl_data_get (d); + } return *this; } @@ -212,66 +241,151 @@ class aosl_data_buf: public aosl_data_class { return (unsigned char *)ptr (); } + void attach (aosl_data_t src) + { + if (d != NULL) + aosl_data_put (d); + + d = src; + } + + aosl_data_t detach () + { + aosl_data_t data = d; + d = NULL; + return data; + } + #if (__cplusplus >= 201103) || defined (_MSC_VER) aosl_data_buf (aosl_data_buf &&src) { - d = src.d; - src.d = NULL; + if (this != &src) { + d = src.d; + src.d = NULL; + } } aosl_data_buf &operator = (aosl_data_buf &&src) { - if (d != NULL) - aosl_data_put (d); + if (this != &src) { + if (d != NULL) + aosl_data_put (d); + + d = src.d; + src.d = NULL; + } - d = src.d; - src.d = NULL; return *this; } #endif /* C++11 */ }; +/** + * This class is only used in the constructor of aosl_data_var + * to differentiate constructor with variadic args, do not use + * it in any other scenario. + **/ +template +class aosl_data_arg { +private: + const T var; + +public: + aosl_data_arg (T arg): var (arg) {} + operator T () + { + return var; + } +}; + template class aosl_data_var: public aosl_data_class { public: - aosl_data_var () + aosl_data_var (void) { - d = aosl_data_create (sizeof (T)); + d = aosl_data_create (sizeof (T), __data_var_dtor); if (d == NULL) abort (); + + new (aosl_data_ptr_get (d)) T; + } + + /** + * We prefer to using this kind of special class arg rather + * than naked aosl_data_t just for differentiating from the + * constructor with variadic args. + **/ + aosl_data_var (aosl_data_arg src_arg) + { + aosl_data_t src = src_arg; + if (src == NULL) + abort (); + + /* The prerequisite is that the src must be a valid T data */ + if (aosl_data_len (src) < sizeof (T)) + abort (); + + aosl_data_get (src); + d = src; } - aosl_data_var (size_t nelems) + /** + * We prefer to using this kind of special class arg rather + * than naked size_t. + **/ + aosl_data_var (aosl_data_arg nelems) { - if (nelems == 0) + size_t count = nelems; + if (count == 0) + abort (); + + d = aosl_data_create (sizeof (T) * count, __data_var_dtor); + if (d == NULL) abort (); - d = aosl_data_create (sizeof (T) * nelems); + new (aosl_data_ptr_get (d)) T [count]; + } + +#if (__cplusplus >= 201103) || defined (_MSC_VER) + template + aosl_data_var (Targs... args) + { + d = aosl_data_create (sizeof (T), __data_var_dtor); if (d == NULL) abort (); + + new (aosl_data_ptr_get (d)) T (args...); } +#endif aosl_data_var (const aosl_data_var &src) { - d = src.d; - if (d != NULL) - aosl_data_get (d); + if (this != &src) { + d = src.d; + if (d != NULL) + aosl_data_get (d); + } } aosl_data_var &operator = (const aosl_data_var &src) { - if (d != NULL) - aosl_data_put (d); + if (this != &src) { + if (d != NULL) + aosl_data_put (d); - d = src.d; - if (d != NULL) - aosl_data_get (d); + d = src.d; + if (d != NULL) + aosl_data_get (d); + } return *this; } aosl_data_var &operator = (const T &v) { + if (d == NULL) + abort (); + *(T *)aosl_data_ptr_get (d) = v; return *this; } @@ -292,6 +406,14 @@ class aosl_data_var: public aosl_data_class { return *(T *)aosl_data_ptr_get (d); } + T *operator -> () const + { + if (d == NULL) + abort (); + + return (T *)aosl_data_ptr_get (d); + } + T operator [] (size_t i) const { size_t count; @@ -324,20 +446,37 @@ class aosl_data_var: public aosl_data_class { return arr [i]; } +private: + static void __data_var_dtor (void *ptr, size_t len) + { + size_t n = len / sizeof (T); + T *o = (T *)ptr; + T *e = o + n; + while (e > o) { + e--; + e->~T (); + } + } + #if (__cplusplus >= 201103) || defined (_MSC_VER) aosl_data_var (aosl_data_var &&src) { - d = src.d; - src.d = NULL; + if (this != &src) { + d = src.d; + src.d = NULL; + } } aosl_data_var &operator = (aosl_data_var &&src) { - if (d != NULL) - aosl_data_put (d); + if (this != &src) { + if (d != NULL) + aosl_data_put (d); + + d = src.d; + src.d = NULL; + } - d = src.d; - src.d = NULL; return *this; } #endif /* C++11 */ diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_file_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_file_class.h old mode 100755 new mode 100644 index 125fd99e7..a8776df9b --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_file_class.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_file_class.h @@ -234,9 +234,9 @@ class aosl_file_class { #endif /* C++11 */ public: - int co_read (aosl_data_t d_ret, aosl_data_t d_buf) + int co_read (aosl_data_t d_ret, aosl_data_t d_buf, uintptr_t buf_off = 0) { - return aosl_co_file_read (fd, d_ret, d_buf); + return aosl_co_file_read (fd, d_ret, d_buf, buf_off); } int co_write (aosl_data_t d_ret, aosl_data_t d_buf) diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_input_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_input_class.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_kobj_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_kobj_class.h old mode 100755 new mode 100644 index 7f301ea3a..011e68b07 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_kobj_class.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_kobj_class.h @@ -42,7 +42,7 @@ class aosl_kobj_class { #endif public: - static void *notify_register (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_t f, aosl_kobj_notify_dtor_t dtor, uintptr_t argc, ...) + static void *notify_register (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_t f, aosl_obj_dtor_t dtor, uintptr_t argc, ...) { va_list args; void *err; @@ -53,12 +53,12 @@ class aosl_kobj_class { return err; } - static void *notify_register_args (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_t f, aosl_kobj_notify_dtor_t dtor, uintptr_t argc, va_list args) + static void *notify_register_args (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_t f, aosl_obj_dtor_t dtor, uintptr_t argc, va_list args) { return aosl_kobj_notify_register_args (dfd, name, touch, qid, ref, f_name, f, dtor, argc, args); } - static void *notify_register_argv (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_t f, aosl_kobj_notify_dtor_t dtor, uintptr_t argc, uintptr_t argv []) + static void *notify_register_argv (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_t f, aosl_obj_dtor_t dtor, uintptr_t argc, uintptr_t argv []) { return aosl_kobj_notify_register_argv (dfd, name, touch, qid, ref, f_name, f, dtor, argc, argv); } diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mm_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mm_class.h new file mode 100644 index 000000000..15c9e020d --- /dev/null +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mm_class.h @@ -0,0 +1,45 @@ +/************************************************************* + * Author: Lionfore Hao (haolianfu@agora.io) + * Date : Jun 17th, 2024 + * Module: AOSL memory management for C++ definition file + * + * + * This is a part of the Advanced Operating System Layer. + * Copyright (C) 2018 ~ 2024 Agora IO + * All rights reserved. + * + *************************************************************/ + +#ifndef __AOSL_MM_CLASS_H__ +#define __AOSL_MM_CLASS_H__ + + +#include +#include + + +class aosl_mm_class { +public: + static void *operator new (size_t size) + { + return aosl_mm_malloc (size); + } + + static void *operator new [] (size_t size) + { + return aosl_mm_malloc (size); + } + + static void operator delete (void *ptr) + { + aosl_mm_free (ptr); + } + + static void operator delete [] (void *ptr) + { + aosl_mm_free (ptr); + } +}; + + +#endif /* __AOSL_MM_CLASS_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_fd_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_fd_class.h old mode 100755 new mode 100644 index 606effcf8..a03a74e7d --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_fd_class.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_fd_class.h @@ -17,26 +17,57 @@ #include #include +#include class aosl_mpq_fd_class { public: aosl_mpq_fd_class (aosl_fd_t fd): attached_fd (fd) { + ref_id = aosl_ref_create (this, NULL, 1/* MUST BE CALLER-FREE */); + if (aosl_ref_invalid (ref_id)) + abort (); } virtual ~aosl_mpq_fd_class () { + /** + * Please make sure this is the first action in the destructor of + * each final derived class of this class and its' derivatives. + **/ + ref_destroy (); if (!aosl_fd_invalid (attached_fd)) aosl_close (attached_fd); } - aosl_fd_t get_fd () + aosl_ref_t ref (void) + { + return ref_id; + } + + /** + * Please call this function first before freeing any resource relative + * with this class and its' derivatives. + **/ + void ref_destroy (void) + { + if (!aosl_ref_invalid (ref_id)) { + /** + * For caller-free ref object, the destroy will wait other threads + * to release the ref usage count, so this will guarantee the safe + * accessing of 'this' object. + **/ + aosl_ref_destroy (ref_id, 1); + ref_id = AOSL_REF_INVALID; + } + } + + aosl_fd_t get_fd (void) { return attached_fd; } - aosl_fd_t detach () + aosl_fd_t detach (void) { if (!aosl_fd_invalid (attached_fd)) { aosl_fd_t fd = attached_fd; @@ -48,9 +79,9 @@ class aosl_mpq_fd_class { } public: - int co_read (aosl_data_t d_ret, aosl_data_t d_buf) + int co_read (aosl_data_t d_ret, aosl_data_t d_buf, uintptr_t buf_off = 0) { - return aosl_co_read (attached_fd, d_ret, d_buf); + return aosl_co_read (attached_fd, d_ret, d_buf, buf_off); } ssize_t co_write (aosl_data_t d_ret, aosl_data_t d_buf) @@ -64,6 +95,7 @@ class aosl_mpq_fd_class { } private: + aosl_ref_t ref_id; aosl_fd_t attached_fd; #if (__cplusplus >= 201103) || defined (_MSC_VER) diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_sk_lambda.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_sk_lambda.h old mode 100755 new mode 100644 index 8dfc4c900..477488177 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_sk_lambda.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_sk_lambda.h @@ -16,9 +16,11 @@ #include #include +#include #include #include #include +#include #if (__cplusplus >= 201103) || defined (_MSC_VER) #include @@ -26,6 +28,8 @@ typedef std::function aosl_fd_chk_pkt_lambda_t; typedef std::function aosl_fd_data_lambda_t; typedef std::function aosl_dgram_sk_data_lambda_t; +typedef std::function aosl_fd_d_data_lambda_t; /* lambda with aosl_data_t */ +typedef std::function aosl_dgram_sk_d_data_lambda_t; /* lambda with aosl_data_t */ typedef std::function aosl_fd_event_lambda_t; typedef std::function aosl_listen_sk_accept_lambda_t; @@ -37,27 +41,61 @@ class aosl_mpq_dgram_sk: public aosl_mpq_fd_class { aosl_fd_event_lambda_t&& event_cb, aosl_mpq_t qid = aosl_mpq_this ()) : aosl_mpq_fd_class (sk), - on_data (std::move (data_cb)), + on_data (std::move (data_cb)), on_event (std::move (event_cb)) { - if (aosl_mpq_add_dgram_socket (qid, sk, max_pkt_size, &__on_data, &__on_event, 1, this) < 0) + if (aosl_mpq_add_dgram_socket (qid, sk, max_pkt_size, &__on_data, &__on_event, 1, ref ()) < 0) abort (); } + aosl_mpq_dgram_sk (aosl_fd_t sk, size_t max_pkt_size, + aosl_dgram_sk_d_data_lambda_t&& data_cb, + aosl_fd_event_lambda_t&& event_cb, + aosl_mpq_t qid = aosl_mpq_this ()) + : aosl_mpq_fd_class (sk), + on_d_data (std::move (data_cb)), + on_event (std::move (event_cb)) + { + if (aosl_mpq_add_dgram_socket (qid, sk, max_pkt_size, &__on_d_data, &__on_event, 1, ref ()) < 0) + abort (); + } + + virtual ~aosl_mpq_dgram_sk () + { + /** + * Please make sure this is the first action in the destructor of + * each final derived class of this class and its' derivatives. + **/ + ref_destroy (); + } + private: static void __on_data (void *data, size_t len, uintptr_t argc, uintptr_t argv [], const aosl_sk_addr_t *addr) { - aosl_mpq_dgram_sk *__this = (aosl_mpq_dgram_sk *)argv [0]; - __this->on_data (data, len, addr); + aosl_ref_class::hold ((aosl_ref_t)argv [0], [&] (void *arg) { + aosl_mpq_dgram_sk *__this = (aosl_mpq_dgram_sk *)(aosl_mpq_fd_class *)arg; + __this->on_data (data, len, addr); + }); + } + + static void __on_d_data (void *data, size_t len, uintptr_t argc, uintptr_t argv [], const aosl_sk_addr_t *addr) + { + aosl_ref_class::hold ((aosl_ref_t)argv [0], [&] (void *arg) { + aosl_mpq_dgram_sk *__this = (aosl_mpq_dgram_sk *)(aosl_mpq_fd_class *)arg; + __this->on_d_data ((aosl_data_t)argv [argc], data, len, addr); + }); } static void __on_event (aosl_fd_t sk, int event, uintptr_t argc, uintptr_t argv []) { - aosl_mpq_dgram_sk *__this = (aosl_mpq_dgram_sk *)argv [0]; - __this->on_event (sk, event); + aosl_ref_class::hold ((aosl_ref_t)argv [0], [&] (void *arg) { + aosl_mpq_dgram_sk *__this = (aosl_mpq_dgram_sk *)(aosl_mpq_fd_class *)arg; + __this->on_event (sk, event); + }); } const aosl_dgram_sk_data_lambda_t on_data; + const aosl_dgram_sk_d_data_lambda_t on_d_data; const aosl_fd_event_lambda_t on_event; private: @@ -77,34 +115,76 @@ class aosl_mpq_stream_sk: public aosl_mpq_fd_class { aosl_mpq_t qid = aosl_mpq_this ()) : aosl_mpq_fd_class (sk), on_chk_pkt (std::move (chk_pkt_cb)), - on_data (std::move (data_cb)), + on_data (std::move (data_cb)), on_event (std::move (event_cb)) { - if (aosl_mpq_add_stream_socket (qid, sk, enable, max_pkt_size, &__on_chk_pkt, &__on_data, &__on_event, 1, this) < 0) + if (aosl_mpq_add_stream_socket (qid, sk, enable, max_pkt_size, &__on_chk_pkt, &__on_data, &__on_event, 1, ref ()) < 0) abort (); } + aosl_mpq_stream_sk (aosl_fd_t sk, int enable, size_t max_pkt_size, + aosl_fd_chk_pkt_lambda_t&& chk_pkt_cb, + aosl_fd_d_data_lambda_t&& data_cb, + aosl_fd_event_lambda_t&& event_cb, + aosl_mpq_t qid = aosl_mpq_this ()) + : aosl_mpq_fd_class (sk), + on_chk_pkt (std::move (chk_pkt_cb)), + on_d_data (std::move (data_cb)), + on_event (std::move (event_cb)) + { + if (aosl_mpq_add_stream_socket (qid, sk, enable, max_pkt_size, &__on_chk_pkt, &__on_d_data, &__on_event, 1, ref ()) < 0) + abort (); + } + + virtual ~aosl_mpq_stream_sk () + { + /** + * Please make sure this is the first action in the destructor of + * each final derived class of this class and its' derivatives. + **/ + ref_destroy (); + } + private: static ssize_t __on_chk_pkt (const void *data, size_t len, uintptr_t argc, uintptr_t argv []) { - aosl_mpq_stream_sk *__this = (aosl_mpq_stream_sk *)argv [0]; - return __this->on_chk_pkt (data, len); + ssize_t ret = -1; + + aosl_ref_class::hold ((aosl_ref_t)argv [0], [&] (void *arg) { + aosl_mpq_stream_sk *__this = (aosl_mpq_stream_sk *)(aosl_mpq_fd_class *)arg; + ret = __this->on_chk_pkt (data, len); + }); + + return ret; } static void __on_data (void *data, size_t len, uintptr_t argc, uintptr_t argv []) { - aosl_mpq_stream_sk *__this = (aosl_mpq_stream_sk *)argv [0]; - __this->on_data (data, len); + aosl_ref_class::hold ((aosl_ref_t)argv [0], [&] (void *arg) { + aosl_mpq_stream_sk *__this = (aosl_mpq_stream_sk *)(aosl_mpq_fd_class *)arg; + __this->on_data (data, len); + }); + } + + static void __on_d_data (void *data, size_t len, uintptr_t argc, uintptr_t argv []) + { + aosl_ref_class::hold ((aosl_ref_t)argv [0], [&] (void *arg) { + aosl_mpq_stream_sk *__this = (aosl_mpq_stream_sk *)(aosl_mpq_fd_class *)arg; + __this->on_d_data ((aosl_data_t)argv [argc], data, len); + }); } static void __on_event (aosl_fd_t sk, int event, uintptr_t argc, uintptr_t argv []) { - aosl_mpq_stream_sk *__this = (aosl_mpq_stream_sk *)argv [0]; - __this->on_event (sk, event); + aosl_ref_class::hold ((aosl_ref_t)argv [0], [&] (void *arg) { + aosl_mpq_stream_sk *__this = (aosl_mpq_stream_sk *)(aosl_mpq_fd_class *)arg; + __this->on_event (sk, event); + }); } const aosl_fd_chk_pkt_lambda_t on_chk_pkt; const aosl_fd_data_lambda_t on_data; + const aosl_fd_d_data_lambda_t on_d_data; const aosl_fd_event_lambda_t on_event; private: @@ -128,6 +208,17 @@ class aosl_mpq_connect_stream_sk: public aosl_mpq_stream_sk { std::move (data_cb), std::move (event_cb), qid) {} + aosl_mpq_connect_stream_sk (aosl_fd_t sk, size_t max_pkt_size, + aosl_fd_chk_pkt_lambda_t&& chk_pkt_cb, + aosl_fd_d_data_lambda_t&& data_cb, + aosl_fd_event_lambda_t&& event_cb, + aosl_mpq_t qid = aosl_mpq_this ()) + : aosl_mpq_stream_sk (sk, 0/* !enable */, + max_pkt_size, + std::move (chk_pkt_cb), + std::move (data_cb), + std::move (event_cb), qid) {} + int connect (const struct sockaddr *dest_addr, socklen_t addrlen, int timeo) { return aosl_mpq_connect (get_fd (), dest_addr, addrlen, timeo); @@ -154,6 +245,17 @@ class aosl_mpq_accepted_stream_sk: public aosl_mpq_stream_sk { std::move (data_cb), std::move (event_cb), qid) {} + aosl_mpq_accepted_stream_sk (aosl_fd_t sk, size_t max_pkt_size, + aosl_fd_chk_pkt_lambda_t&& chk_pkt_cb, + aosl_fd_d_data_lambda_t&& data_cb, + aosl_fd_event_lambda_t&& event_cb, + aosl_mpq_t qid = aosl_mpq_this ()) + : aosl_mpq_stream_sk (sk, 1/*enable*/, + max_pkt_size, + std::move (chk_pkt_cb), + std::move (data_cb), + std::move (event_cb), qid) {} + private: aosl_mpq_accepted_stream_sk () = delete; aosl_mpq_accepted_stream_sk (const aosl_mpq_accepted_stream_sk &) = delete; @@ -172,21 +274,34 @@ class aosl_mpq_listen_sk: public aosl_mpq_fd_class { on_accept (std::move (accept_cb)), on_event (std::move (event_cb)) { - if (aosl_mpq_add_listen_socket (qid, sk, backlog, __on_accept, __on_event, 1, this) < 0) + if (aosl_mpq_add_listen_socket (qid, sk, backlog, __on_accept, __on_event, 1, ref ()) < 0) abort (); } + virtual ~aosl_mpq_listen_sk () + { + /** + * Please make sure this is the first action in the destructor of + * each final derived class of this class and its' derivatives. + **/ + ref_destroy (); + } + private: static void __on_accept (aosl_accept_data_t *accept_data, size_t len, uintptr_t argc, uintptr_t argv []) { - aosl_mpq_listen_sk *__this = (aosl_mpq_listen_sk *)argv [0]; - __this->on_accept (accept_data); + aosl_ref_class::hold ((aosl_ref_t)argv [0], [&] (void *arg) { + aosl_mpq_listen_sk *__this = (aosl_mpq_listen_sk *)(aosl_mpq_fd_class *)arg; + __this->on_accept (accept_data); + }); } static void __on_event (aosl_fd_t sk, int event, uintptr_t argc, uintptr_t argv []) { - aosl_mpq_listen_sk *__this = (aosl_mpq_listen_sk *)argv [0]; - __this->on_event (sk, event); + aosl_ref_class::hold ((aosl_ref_t)argv [0], [&] (void *arg) { + aosl_mpq_listen_sk *__this = (aosl_mpq_listen_sk *)(aosl_mpq_fd_class *)arg; + __this->on_event (sk, event); + }); } const aosl_listen_sk_accept_lambda_t on_accept; @@ -222,14 +337,14 @@ class aosl_co_sk: public aosl_mpq_fd_class { return aosl_co_accept (get_fd (), d_ret, d_addr); } - int co_recv (aosl_data_t d_ret, aosl_data_t d_buf, int flags) + int co_recv (aosl_data_t d_ret, aosl_data_t d_buf, uintptr_t buf_off = 0, int flags = 0) { - return aosl_co_recv (get_fd (), d_ret, d_buf, flags); + return aosl_co_recv (get_fd (), d_ret, d_buf, buf_off, flags); } - int co_recvfrom (aosl_data_t d_ret, aosl_data_t d_buf, int flags, aosl_data_t d_addr) + int co_recvfrom (aosl_data_t d_ret, aosl_data_t d_buf, aosl_data_t d_addr, uintptr_t buf_off = 0, int flags = 0) { - return aosl_co_recvfrom (get_fd (), d_ret, d_buf, flags, d_addr); + return aosl_co_recvfrom (get_fd (), d_ret, d_buf, buf_off, flags, d_addr); } int co_connect (aosl_data_t d_ret, const struct sockaddr *dest_addr, socklen_t addrlen, int timeo) diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_timer_lambda.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_timer_lambda.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_poll_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_poll_class.h old mode 100755 new mode 100644 index 0e7007dbb..54d1a0560 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_poll_class.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_poll_class.h @@ -35,18 +35,17 @@ class aosl_poll_class { std::vector signaled_refs; public: - int add (const aosl_ares_class &tail) + void add (const aosl_ares_class &tail) { poll_refs [tail.ref ()] = &tail; - return 0; } #if (__cplusplus >= 201103) || defined (_MSC_VER) template - int add (const T &head, const Targs&... rest) + void add (const T &head, const Targs&... rest) { poll_refs [head.ref ()] = &head; - return add (rest...); + add (rest...); } /* constructor with variable args */ @@ -57,6 +56,13 @@ class aosl_poll_class { } #endif /* C++11 */ + aosl_poll_class (const aosl_ares_class * const areses [], size_t count) + { + size_t i; + for (i = 0; i < count; i++) + add (*areses [i]); + } + /* poll the constructed async results */ int poll (size_t min, intptr_t timeo) { diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_ref_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_ref_class.h old mode 100755 new mode 100644 index c3c905721..4dab3878b --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_ref_class.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_ref_class.h @@ -138,26 +138,26 @@ class aosl_ref_class { return aosl_ref_write_argv (ref (), f, argc, argv); } - int maystall (aosl_ref_func_t f, uintptr_t argc, ...) + int unsafe (aosl_ref_func_t f, uintptr_t argc, ...) { va_list args; int err; va_start (args, argc); - err = aosl_ref_maystall_args (ref (), f, argc, args); + err = aosl_ref_unsafe_args (ref (), f, argc, args); va_end (args); return err; } - int maystall_args (aosl_ref_func_t f, uintptr_t argc, va_list args) + int unsafe_args (aosl_ref_func_t f, uintptr_t argc, va_list args) { - return aosl_ref_maystall_args (ref (), f, argc, args); + return aosl_ref_unsafe_args (ref (), f, argc, args); } - int maystall_argv (aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) + int unsafe_argv (aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) { - return aosl_ref_maystall_argv (ref (), f, argc, argv); + return aosl_ref_unsafe_argv (ref (), f, argc, argv); } /* The static version of member functions */ @@ -227,26 +227,26 @@ class aosl_ref_class { return aosl_ref_write_argv (ref, f, argc, argv); } - static int maystall (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...) + static int unsafe (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...) { va_list args; int err; va_start (args, argc); - err = aosl_ref_maystall_args (ref, f, argc, args); + err = aosl_ref_unsafe_args (ref, f, argc, args); va_end (args); return err; } - static int maystall_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args) + static int unsafe_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args) { - return aosl_ref_maystall_args (ref, f, argc, args); + return aosl_ref_unsafe_args (ref, f, argc, args); } - static int maystall_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) + static int unsafe_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) { - return aosl_ref_maystall_argv (ref, f, argc, argv); + return aosl_ref_unsafe_argv (ref, f, argc, argv); } static int read (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, ...) @@ -271,26 +271,26 @@ class aosl_ref_class { return aosl_refobj_read_argv (robj, f, argc, argv); } - static int maystall (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, ...) + static int unsafe (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, ...) { va_list args; int err; va_start (args, argc); - err = aosl_refobj_maystall_args (robj, f, argc, args); + err = aosl_refobj_unsafe_args (robj, f, argc, args); va_end (args); return err; } - static int maystall_args (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, va_list args) + static int unsafe_args (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, va_list args) { - return aosl_refobj_maystall_args (robj, f, argc, args); + return aosl_refobj_unsafe_args (robj, f, argc, args); } - static int maystall_argv (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) + static int unsafe_argv (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) { - return aosl_refobj_maystall_argv (robj, f, argc, argv); + return aosl_refobj_unsafe_argv (robj, f, argc, argv); } /* set the living scope ref object of this ref object */ @@ -519,10 +519,10 @@ class aosl_ref_class { return aosl_ref_t_oop::write (____ref_f, 1, &lambda_obj); } - int maystall (aosl_ref_lambda_f &&lambda_f) + int unsafe (aosl_ref_lambda_f &&lambda_f) { aosl_ref_lambda_f lambda_obj (std::move (lambda_f)); - return aosl_ref_t_oop::maystall (____ref_f, 1, &lambda_obj); + return aosl_ref_t_oop::unsafe (____ref_f, 1, &lambda_obj); } static int hold (aosl_ref_t ref, aosl_ref_lambda_f &&lambda_f) @@ -543,10 +543,10 @@ class aosl_ref_class { return aosl_ref_t_oop::write (ref, ____ref_f, 1, &lambda_obj); } - static int maystall (aosl_ref_t ref, aosl_ref_lambda_f &&lambda_f) + static int unsafe (aosl_ref_t ref, aosl_ref_lambda_f &&lambda_f) { aosl_ref_lambda_f lambda_obj (std::move (lambda_f)); - return aosl_ref_t_oop::maystall (ref, ____ref_f, 1, &lambda_obj); + return aosl_ref_t_oop::unsafe (ref, ____ref_f, 1, &lambda_obj); } static int read (aosl_refobj_t robj, aosl_ref_lambda_f &&lambda_f) @@ -555,10 +555,10 @@ class aosl_ref_class { return aosl_ref_t_oop::read (robj, ____ref_f, 1, &lambda_obj); } - static int maystall (aosl_refobj_t robj, aosl_ref_lambda_f &&lambda_f) + static int unsafe (aosl_refobj_t robj, aosl_ref_lambda_f &&lambda_f) { aosl_ref_lambda_f lambda_obj (std::move (lambda_f)); - return aosl_ref_t_oop::maystall (robj, ____ref_f, 1, &lambda_obj); + return aosl_ref_t_oop::unsafe (robj, ____ref_f, 1, &lambda_obj); } private: @@ -1083,13 +1083,35 @@ class aosl_ref_class { return refoop->write_argv (f, argc, argv); } + int unsafe (aosl_ref_func_t f, uintptr_t argc, ...) + { + va_list args; + int err; + + va_start (args, argc); + err = refoop->unsafe_args (f, argc, args); + va_end (args); + + return err; + } + + int unsafe_args (aosl_ref_func_t f, uintptr_t argc, va_list args) + { + return refoop->unsafe_args (f, argc, args); + } + + int unsafe_argv (aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) + { + return refoop->unsafe_argv (f, argc, argv); + } + int maystall (aosl_ref_func_t f, uintptr_t argc, ...) { va_list args; int err; va_start (args, argc); - err = refoop->maystall_args (f, argc, args); + err = refoop->unsafe_args (f, argc, args); va_end (args); return err; @@ -1097,12 +1119,12 @@ class aosl_ref_class { int maystall_args (aosl_ref_func_t f, uintptr_t argc, va_list args) { - return refoop->maystall_args (f, argc, args); + return refoop->unsafe_args (f, argc, args); } int maystall_argv (aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) { - return refoop->maystall_argv (f, argc, argv); + return refoop->unsafe_argv (f, argc, argv); } /* The static version of member functions */ @@ -1172,13 +1194,35 @@ class aosl_ref_class { return aosl_ref_t_oop::write_argv (ref, f, argc, argv); } + static int unsafe (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...) + { + va_list args; + int err; + + va_start (args, argc); + err = aosl_ref_t_oop::unsafe_args (ref, f, argc, args); + va_end (args); + + return err; + } + + static int unsafe_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args) + { + return aosl_ref_t_oop::unsafe_args (ref, f, argc, args); + } + + static int unsafe_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) + { + return aosl_ref_t_oop::unsafe_argv (ref, f, argc, argv); + } + static int maystall (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...) { va_list args; int err; va_start (args, argc); - err = aosl_ref_t_oop::maystall_args (ref, f, argc, args); + err = aosl_ref_t_oop::unsafe_args (ref, f, argc, args); va_end (args); return err; @@ -1186,12 +1230,12 @@ class aosl_ref_class { static int maystall_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args) { - return aosl_ref_t_oop::maystall_args (ref, f, argc, args); + return aosl_ref_t_oop::unsafe_args (ref, f, argc, args); } static int maystall_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) { - return aosl_ref_t_oop::maystall_argv (ref, f, argc, argv); + return aosl_ref_t_oop::unsafe_argv (ref, f, argc, argv); } static int read (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, ...) @@ -1216,13 +1260,35 @@ class aosl_ref_class { return aosl_ref_t_oop::read_argv (robj, f, argc, argv); } + static int unsafe (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, ...) + { + va_list args; + int err; + + va_start (args, argc); + err = aosl_ref_t_oop::unsafe_args (robj, f, argc, args); + va_end (args); + + return err; + } + + static int unsafe_args (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, va_list args) + { + return aosl_ref_t_oop::unsafe_args (robj, f, argc, args); + } + + static int unsafe_argv (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) + { + return aosl_ref_t_oop::unsafe_argv (robj, f, argc, argv); + } + static int maystall (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, ...) { va_list args; int err; va_start (args, argc); - err = aosl_ref_t_oop::maystall_args (robj, f, argc, args); + err = aosl_ref_t_oop::unsafe_args (robj, f, argc, args); va_end (args); return err; @@ -1230,12 +1296,12 @@ class aosl_ref_class { static int maystall_args (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, va_list args) { - return aosl_ref_t_oop::maystall_args (robj, f, argc, args); + return aosl_ref_t_oop::unsafe_args (robj, f, argc, args); } static int maystall_argv (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) { - return aosl_ref_t_oop::maystall_argv (robj, f, argc, argv); + return aosl_ref_t_oop::unsafe_argv (robj, f, argc, argv); } static aosl_ref_class *from_refobj (aosl_refobj_t robj) @@ -1492,9 +1558,14 @@ class aosl_ref_class { return refoop->write (std::move (lambda_f)); } + int unsafe (aosl_ref_lambda_f &&lambda_f) + { + return refoop->unsafe (std::move (lambda_f)); + } + int maystall (aosl_ref_lambda_f &&lambda_f) { - return refoop->maystall (std::move (lambda_f)); + return refoop->unsafe (std::move (lambda_f)); } static int hold (aosl_ref_t ref, aosl_ref_lambda_f &&lambda_f) @@ -1512,9 +1583,14 @@ class aosl_ref_class { return aosl_ref_t_oop::write (ref, std::move (lambda_f)); } + static int unsafe (aosl_ref_t ref, aosl_ref_lambda_f &&lambda_f) + { + return aosl_ref_t_oop::unsafe (ref, std::move (lambda_f)); + } + static int maystall (aosl_ref_t ref, aosl_ref_lambda_f &&lambda_f) { - return aosl_ref_t_oop::maystall (ref, std::move (lambda_f)); + return aosl_ref_t_oop::unsafe (ref, std::move (lambda_f)); } static int read (aosl_refobj_t robj, aosl_ref_lambda_f &&lambda_f) @@ -1522,9 +1598,14 @@ class aosl_ref_class { return aosl_ref_t_oop::read (robj, std::move (lambda_f)); } + static int unsafe (aosl_refobj_t robj, aosl_ref_lambda_f &&lambda_f) + { + return aosl_ref_t_oop::unsafe (robj, std::move (lambda_f)); + } + static int maystall (aosl_refobj_t robj, aosl_ref_lambda_f &&lambda_f) { - return aosl_ref_t_oop::maystall (robj, std::move (lambda_f)); + return aosl_ref_t_oop::unsafe (robj, std::move (lambda_f)); } #ifdef __AOSL_MPQ_H__ @@ -1844,25 +1925,25 @@ inline bool operator != (intptr_t _null, const aosl_ref_unique_ptr &p #if (__cplusplus >= 201103) || defined (_MSC_VER) template -inline bool operator == (const aosl_ref_unique_ptr &ptr, nullptr_t) +inline bool operator == (const aosl_ref_unique_ptr &ptr, std::nullptr_t) { return !ptr; } template -inline bool operator != (const aosl_ref_unique_ptr &ptr, nullptr_t) +inline bool operator != (const aosl_ref_unique_ptr &ptr, std::nullptr_t) { return ptr; } template -inline bool operator == (nullptr_t, const aosl_ref_unique_ptr &ptr) +inline bool operator == (std::nullptr_t, const aosl_ref_unique_ptr &ptr) { return !ptr; } template -inline bool operator != (nullptr_t, const aosl_ref_unique_ptr &ptr) +inline bool operator != (std::nullptr_t, const aosl_ref_unique_ptr &ptr) { return ptr; } diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_sbus_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_sbus_class.h new file mode 100644 index 000000000..fe853a1fc --- /dev/null +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_sbus_class.h @@ -0,0 +1,180 @@ +/************************************************************* + * Author: Lionfore Hao (haolianfu@agora.io) + * Date : May 6th, 2024 + * Module: AOSL software bus relative API C++ definition file + * + * + * This is a part of the Advanced Operating System Layer. + * Copyright (C) 2018 ~ 2024 Agora IO + * All rights reserved. + * + *************************************************************/ + +#ifndef __AOSL_SBUS_CPP_H__ +#define __AOSL_SBUS_CPP_H__ + + +/* C++11 lambda encapsulations */ +#if (__cplusplus >= 201103) || defined (_MSC_VER) +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + + +class aosl_sbus_class_base { +private: + aosl_sbus_class_base () = delete; + aosl_sbus_class_base (const aosl_sbus_class_base &) = delete; + aosl_sbus_class_base (aosl_sbus_class_base &&) = delete; + aosl_sbus_class_base &operator = (const aosl_sbus_class_base &) = delete; + aosl_sbus_class_base &operator = (aosl_sbus_class_base &&) = delete; + ~aosl_sbus_class_base () = delete; + +public: + typedef std::function aosl_sbus_data_lambda_f; + /* simple version without robj arg, so it means no "free only" for this callback */ + typedef std::function aosl_sbus_data_lambda_2args_f; + + static void *action_add (const char *name, aosl_mpq_t qid, aosl_ref_t ref, uintptr_t max, const char *f_name, aosl_sbus_data_lambda_f&& task) + { + aosl_sbus_data_lambda_f *task_obj = new aosl_sbus_data_lambda_f (std::move (task)); + void *err = aosl_sbus_action_add (name, qid, ref, max, f_name, ____sbus_data, ____action_dtor, 1, task_obj); + if (err == NULL) + delete task_obj; + + return err; + } + + static void *action_add (const char *name, aosl_mpq_t qid, aosl_ref_t ref, uintptr_t max, const char *f_name, aosl_sbus_data_lambda_2args_f&& task) + { + aosl_sbus_data_lambda_2args_f *task_obj = new aosl_sbus_data_lambda_2args_f (std::move (task)); + void *err = aosl_sbus_action_add (name, qid, ref, max, f_name, ____sbus_data_2args, ____action_dtor_2args, 1, task_obj); + if (err == NULL) + delete task_obj; + + return err; + } + + static int action_del (const char *name, void *h_action) + { + return aosl_sbus_action_del (name, h_action); + } + + static int send (const char *name, aosl_data_class &data) + { + return aosl_sbus_send (name, data); + } + +private: + static void ____sbus_data (aosl_refobj_t robj, const char *name, aosl_data_t data, uintptr_t argc, uintptr_t argv []) + { + aosl_sbus_data_lambda_f *task_obj = reinterpret_cast(argv [0]); + (*task_obj) (robj, name, data); + } + + static void ____action_dtor (uintptr_t argc, uintptr_t argv []) + { + aosl_sbus_data_lambda_f *task_obj = reinterpret_cast(argv [0]); + delete task_obj; + } + + static void ____sbus_data_2args (aosl_refobj_t robj, const char *name, aosl_data_t data, uintptr_t argc, uintptr_t argv []) + { + if (!aosl_is_free_only (robj)) { + aosl_sbus_data_lambda_2args_f *task_obj = reinterpret_cast(argv [0]); + (*task_obj) (name, data); + } + } + + static void ____action_dtor_2args (uintptr_t argc, uintptr_t argv []) + { + aosl_sbus_data_lambda_2args_f *task_obj = reinterpret_cast(argv [0]); + delete task_obj; + } +}; + +/** + * Template class for accessing a software bus with the data var format + * specified by type T. + **/ +template +class aosl_sbus_class: public aosl_sbus_class_base { +private: + aosl_sbus_class () = delete; + aosl_sbus_class (const aosl_sbus_class &) = delete; + aosl_sbus_class (aosl_sbus_class &&) = delete; + aosl_sbus_class &operator = (const aosl_sbus_class &) = delete; + aosl_sbus_class &operator = (aosl_sbus_class &&) = delete; + ~aosl_sbus_class () = delete; + +public: + typedef std::function &var)> aosl_sbus_var_lambda_f; + /* simple version without robj arg, so it means no "free only" for this callback */ + typedef std::function &var)> aosl_sbus_var_lambda_2args_f; + + static void *action_add (const char *name, aosl_mpq_t qid, aosl_ref_t ref, uintptr_t max, const char *f_name, aosl_sbus_var_lambda_f&& task) + { + aosl_sbus_var_lambda_f *task_obj = new aosl_sbus_var_lambda_f (std::move (task)); + void *err = aosl_sbus_action_add (name, qid, ref, max, f_name, ____sbus_var, ____action_var_dtor, 1, task_obj); + if (err == NULL) + delete task_obj; + + return err; + } + + static void *action_add (const char *name, aosl_mpq_t qid, aosl_ref_t ref, uintptr_t max, const char *f_name, aosl_sbus_var_lambda_2args_f&& task) + { + aosl_sbus_var_lambda_2args_f *task_obj = new aosl_sbus_var_lambda_2args_f (std::move (task)); + void *err = aosl_sbus_action_add (name, qid, ref, max, f_name, ____sbus_var_2args, ____action_var_dtor_2args, 1, task_obj); + if (err == NULL) + delete task_obj; + + return err; + } + + static int send (const char *name, aosl_data_var &var) + { + return aosl_sbus_send (name, var); + } + +private: + static void ____sbus_var (aosl_refobj_t robj, const char *name, aosl_data_t data, uintptr_t argc, uintptr_t argv []) + { + aosl_sbus_var_lambda_f *task_obj = reinterpret_cast(argv [0]); + aosl_data_var var ((aosl_data_arg (data))); + (*task_obj) (robj, name, var); + } + + static void ____action_var_dtor (uintptr_t argc, uintptr_t argv []) + { + aosl_sbus_var_lambda_f *task_obj = reinterpret_cast(argv [0]); + delete task_obj; + } + + static void ____sbus_var_2args (aosl_refobj_t robj, const char *name, aosl_data_t data, uintptr_t argc, uintptr_t argv []) + { + if (!aosl_is_free_only (robj)) { + aosl_sbus_var_lambda_2args_f *task_obj = reinterpret_cast(argv [0]); + aosl_data_var var ((aosl_data_arg (data))); + (*task_obj) (name, var); + } + } + + static void ____action_var_dtor_2args (uintptr_t argc, uintptr_t argv []) + { + aosl_sbus_var_lambda_2args_f *task_obj = reinterpret_cast(argv [0]); + delete task_obj; + } +}; +#endif /* C++11 */ + + +#endif /* __AOSL_SBUS_CPP_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_task_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_task_class.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_thread_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_thread_class.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_usage_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_usage_class.h deleted file mode 100755 index fa7e3954c..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_usage_class.h +++ /dev/null @@ -1,84 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jan 6th, 2019 - * Module: AOSL simple usage object for C++ definition file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2019 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_USAGE_OBJ_CPP_H__ -#define __AOSL_USAGE_OBJ_CPP_H__ - - -#include - -#include -#include - - -class aosl_usage_class { -private: - bool atomic; - int usage; - -protected: - /* We do not allow delete this object directly. */ - virtual ~aosl_usage_class () {} - -public: - /** - * The parameter 'atomic_op' indicates whether the operations - * on the usage should be atomic operations, true for atomic, - * and false for non-atomic. The default value is false. - **/ - aosl_usage_class (bool atomic_op = false) - { - atomic = atomic_op; - - if (atomic_op) { - aosl_atomic_set ((aosl_atomic_t *)&usage, 1); - } else { - usage = 1; - } - } - - void inc_ref () - { - if (atomic) { - aosl_atomic_inc ((aosl_atomic_t *)&usage); - } else { - usage++; - } - } - - /** - * Return values: - * true: the usage count reached zero, and deleted 'this' object already; - * false: the usage count still greater than zero, 'this' object is still alive; - **/ - bool dec_ref () - { - bool b_val; - - if (atomic) { - b_val = (bool)!!aosl_atomic_dec_and_test ((aosl_atomic_t *)&usage); - } else { - usage--; - b_val = (bool)(usage == 0); - } - - if (b_val) { - delete this; - return true; - } - - return false; - } -}; - - -#endif /* __AOSL_USAGE_OBJ_CPP_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_value_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_value_class.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/objc/Makefile b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/objc/Makefile old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/objc/aosl_log.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/objc/aosl_log.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/objc/aosl_objc.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/objc/aosl_objc.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/time_utils.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/time_utils.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/origin_video_data.cpp b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/origin_video_data.cpp index 9eba8b6b7..05f6c7f87 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/origin_video_data.cpp +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/origin_video_data.cpp @@ -8,7 +8,7 @@ #include OriginVideoData::OriginVideoData(uintptr_t rtcEngineHandler) - : rtcEngine_(reinterpret_cast(rtcEngineHandler)), env_(nullptr), wrapper_(nullptr) {} + : rtcEngine_(reinterpret_cast(rtcEngineHandler)), env_(nullptr), wrapper_(nullptr),takeSnapshot_(false) {} OriginVideoData::~OriginVideoData() { napi_delete_reference(env_, wrapper_); } diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/entryability/EntryAbility.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/entryability/EntryAbility.ets index c573324ad..152ba472e 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/entryability/EntryAbility.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/entryability/EntryAbility.ets @@ -44,7 +44,7 @@ export default class EntryAbility extends UIAbility { } windowStage.loadContent('pages/Index', (err, data) => { - if (err) { + if (err.code) { Logger.error(TAG, `Failed to load the content. Cause: ${JSON.stringify(err)}`) return } diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ChannelEncryption.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ChannelEncryption.ets index e44fd4bd7..8741ff78a 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ChannelEncryption.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ChannelEncryption.ets @@ -219,7 +219,7 @@ struct ChannelEncryption { config.encryptionMode = this.encryptionModeOptions[this.encryptionModeSelectIndex] config.encryptionKey = this.encryptionKey let base64 = new util.Base64Helper(); - config.encryptionKdfSalt = base64.decodeSync("NiIeJ08AbtcQVjvV+oOEvF/4Dz5dy1CIwa805C8J2w0=", util.Type.BASIC) + config.encryptionKdfSalt = base64.decodeSync("NiIeJ08AbtcQVjvV+oOEvF/4Dz5dy1CIwa805C8J2w0=", util.Type.BASIC).buffer as ArrayBuffer this.rtcEngine?.enableEncryption(true, config) let mediaOption: ChannelMediaOptions = new ChannelMediaOptions(); diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/util/Logger.ts b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/util/Logger.ts index ce9357b42..5007df7fa 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/util/Logger.ts +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/util/Logger.ts @@ -42,4 +42,4 @@ class Logger { } } -export default new Logger('APIExample') \ No newline at end of file +export default new Logger('AppTag') \ No newline at end of file From 5092aead17da2c7f0ac0beb9ef5c3f2cbf986aa3 Mon Sep 17 00:00:00 2001 From: weileifrank <1138289316@qq.com> Date: Mon, 30 Sep 2024 16:04:16 +0800 Subject: [PATCH 06/21] =?UTF-8?q?feat:=20=E5=8D=87=E7=BA=A7=E4=BA=86sdk?= =?UTF-8?q?=E5=B9=B6=E9=80=82=E9=85=8D=E4=BA=86=E7=9B=B8=E5=85=B3=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ets/pages/advance/CustomVideoSource.ets | 10 ++--- .../ets/pages/advance/HostCrossChannel.ets | 12 +++--- .../ets/pages/advance/JoinMultiChannel.ets | 6 +-- .../main/ets/pages/advance/LiveStreaming.ets | 4 +- .../pages/advance/LocalVideoTranscoding.ets | 41 ++++++++++++++----- .../main/ets/pages/advance/RTMPStreaming.ets | 35 +++++++++------- .../main/ets/pages/advance/ScreenSharing.ets | 4 +- 7 files changed, 68 insertions(+), 44 deletions(-) diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/CustomVideoSource.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/CustomVideoSource.ets index 27de9dd2c..723408c70 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/CustomVideoSource.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/CustomVideoSource.ets @@ -122,11 +122,11 @@ struct CustomVideoSource { let frameBuffer: Uint8Array = buffer.slice(readStart, readStart + frame_size) readStart += frame_size let frame: VideoFrame = new VideoFrame( - VideoBufferType.VIDEO_BUFFER_RAW_DATA, + VideoBufferType.RAW_DATA, VideoPixelFormat.VIDEO_PIXEL_I420); frame.buffer = frameBuffer.buffer as ArrayBuffer; frame.rotation = 0; - frame.stride = width; + frame.yStride = width; frame.height = height; frame.timestamp = 0; let ret = this.rtcEngine?.pushExternalVideoFrameById(frame, this.customVideoTrack) @@ -159,7 +159,7 @@ struct CustomVideoSource { if (this.localUid != 0) { XComponent({ id: 'preview_local', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_local"); @@ -167,7 +167,7 @@ struct CustomVideoSource { localCanvas.renderMode = VideoCanvas.RENDER_MODE_HIDDEN; localCanvas.mirrorMode = 0; // TODO set source type - // localCanvas.sourceType = Constants.VideoSourceType.VIDEO_SOURCE_CUSTOM + localCanvas.sourceType = Constants.VideoSourceType.CUSTOM this.rtcEngine?.setupLocalVideo(localCanvas); }).width('50%') } @@ -175,7 +175,7 @@ struct CustomVideoSource { if (this.remoteUid != 0) { XComponent({ id: 'preview_remote', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_remote"); diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/HostCrossChannel.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/HostCrossChannel.ets index 66c9e3ef4..4b7d6e25f 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/HostCrossChannel.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/HostCrossChannel.ets @@ -115,7 +115,7 @@ struct HostCrossChannel { if (this.localUid != 0) { XComponent({ id: 'preview_local', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_local"); @@ -129,7 +129,7 @@ struct HostCrossChannel { if (this.remoteUid != 0) { XComponent({ id: 'preview_remote', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_remote"); @@ -186,12 +186,12 @@ struct HostCrossChannel { let config = new ChannelMediaRelayConfiguration() config.srcInfo.channelName = this.channelName config.srcInfo.uid = this.localUid - config.srcInfo.token = await TokenUtils.genRtcToken(this.channelName, '') - config.destInfos[this.relayChannelName] = { + config.srcInfo.token = "" + config.destInfos.set(this.relayChannelName, { channelName: this.relayChannelName, uid: 999, - token: await TokenUtils.genRtcToken(this.relayChannelName, '999') - } + token: "" + }) this.rtcEngine?.startOrUpdateChannelMediaRelay(config) } }) diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/JoinMultiChannel.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/JoinMultiChannel.ets index 9364d8ce0..37915eafa 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/JoinMultiChannel.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/JoinMultiChannel.ets @@ -108,7 +108,7 @@ struct JoinMultiChannel { if (this.mainLocalUid != 0) { XComponent({ id: 'preview_local', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_local"); @@ -122,7 +122,7 @@ struct JoinMultiChannel { if (this.mainRemoteUid != 0) { XComponent({ id: 'preview_remote', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_remote"); @@ -141,7 +141,7 @@ struct JoinMultiChannel { if (this.exRemoteUid != 0) { XComponent({ id: 'preview_remote_ex', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LiveStreaming.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LiveStreaming.ets index ce7d7ea9f..a2781edf9 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LiveStreaming.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LiveStreaming.ets @@ -166,7 +166,7 @@ struct LiveStreaming { if (this.localUid != -1) { XComponent({ id: 'preview_local', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_local"); @@ -180,7 +180,7 @@ struct LiveStreaming { if (this.remoteUid != -1) { XComponent({ id: 'preview_remote', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_remote"); diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LocalVideoTranscoding.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LocalVideoTranscoding.ets index 464a11043..32a4fcebf 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LocalVideoTranscoding.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LocalVideoTranscoding.ets @@ -18,7 +18,11 @@ import PermissionHelper from '../../util/PermissionHelper'; import { common } from '@kit.AbilityKit'; import { GlobalInfo } from '../Data'; import { TokenUtils } from '../../util/TokenUtils'; -import { LengthMetrics } from '@kit.ArkUI'; +import { display, LengthMetrics } from '@kit.ArkUI'; +import { TranscodingVideoStream } from 'AgoraRtcSdk'; +import { JSON } from '@kit.ArkTS'; +import { camera } from '@kit.CameraKit'; +import { VideoDimensions } from 'AgoraRtcSdk'; const TAG: string = 'LocalVideoTranscoding' @@ -65,6 +69,15 @@ struct LocalVideoTranscoding { Logger.info(TAG, "mEventHandler.onError: " + err + " message " + message); ShowToast.longToast("onError " + err + " : " + message) } + config.mEventHandler.onLocalVideoTranscoderError = (stream:TranscodingVideoStream, error:Constants.VideoTranscoderError) => { + Logger.info(TAG, "mEventHandler.onLocalVideoTranscoderError stream "+JSON.stringify(stream) + " error: "+error); + ShowToast.longToast("onLocalVideoTranscoderError " + error ) + } + + config.mEventHandler.onTranscodingUpdated = () => { + Logger.info(TAG, "mEventHandler.onTranscodingUpdated"); + } + config.mContext = context; Logger.info(TAG, "in thread create engine begin: "); this.rtcEngine = RtcEngine.create(config); @@ -111,7 +124,7 @@ struct LocalVideoTranscoding { build() { Column() { TitleBar({ - title: $r('app.string.item_livestreaming'), + title: $r('app.string.item_localvideotranscoding'), showBack: true }) @@ -119,13 +132,13 @@ struct LocalVideoTranscoding { if (this.localUid != -1) { XComponent({ id: 'preview_local', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_local"); localCanvas.uid = this.localUid; - localCanvas.renderMode = VideoCanvas.RENDER_MODE_HIDDEN; - localCanvas.mirrorMode = 0; + localCanvas.renderMode = VideoCanvas.RENDER_MODE_FIT; + localCanvas.mirrorMode = VideoCanvas.VIDEO_MIRROR_MODE_DISABLED; localCanvas.sourceType = Constants.VideoSourceType.TRANSCODED this.rtcEngine?.setupLocalVideo(localCanvas); }).width('100%').height('100%') @@ -134,13 +147,14 @@ struct LocalVideoTranscoding { if (this.remoteUid != -1) { XComponent({ id: 'preview_remote', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_remote"); localCanvas.uid = this.remoteUid; localCanvas.renderMode = VideoCanvas.RENDER_MODE_HIDDEN; localCanvas.mirrorMode = 0; + localCanvas.sourceType = Constants.VideoSourceType.TRANSCODED; this.rtcEngine?.setupRemoteVideo(localCanvas); }).width('30%').height('30%').margin({ top: 12, right: 12 }) } @@ -176,8 +190,8 @@ struct LocalVideoTranscoding { } - let width = 720; - let height = 1280; + let width = GlobalInfo.settings.dimensions.height + let height = GlobalInfo.settings.dimensions.width let screenConfig = new ScreenCaptureParameters() this.rtcEngine?.startScreenCapture(screenConfig) @@ -187,14 +201,19 @@ struct LocalVideoTranscoding { let config = new LocalTranscoderConfiguration() config.transcodingVideoStreams = new Array(2) + config.videoOutputConfiguration.dimensions = new VideoDimensions(width,height) + config.transcodingVideoStreams[0] = new TranscodingVideoStream(); config.transcodingVideoStreams[0].sourceType = Constants.VideoSourceType.SCREEN_PRIMARY config.transcodingVideoStreams[0].width = width config.transcodingVideoStreams[0].height = height + config.transcodingVideoStreams[0].x = 0 + config.transcodingVideoStreams[0].y = 0 config.transcodingVideoStreams[0].zOrder = 1 + config.transcodingVideoStreams[1] = new TranscodingVideoStream() config.transcodingVideoStreams[1].sourceType = Constants.VideoSourceType.CAMERA_PRIMARY - config.transcodingVideoStreams[1].width = width / 2 - config.transcodingVideoStreams[1].height = height / 2 + config.transcodingVideoStreams[1].width = width/2 + config.transcodingVideoStreams[1].height = height/2 config.transcodingVideoStreams[1].x = 0 config.transcodingVideoStreams[1].y = height / 2 config.transcodingVideoStreams[1].zOrder = 2 @@ -213,7 +232,7 @@ struct LocalVideoTranscoding { mediaOption.channelProfile = Constants.ChannelProfile.LIVE_BROADCASTING; mediaOption.clientRoleType = Constants.ClientRole.BROADCASTER; - let token = await TokenUtils.genRtcToken(this.channelName, "") + let token = "" let ret = this.rtcEngine?.joinChannelWithOptions(token, this.channelName, 0, mediaOption) if (ret != Constants.ErrorCode.ERR_OK) { ShowToast.longToast("joinChannelWithOptions error " + ret + " : " + diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/RTMPStreaming.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/RTMPStreaming.ets index ba4f67ac4..18e4477f7 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/RTMPStreaming.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/RTMPStreaming.ets @@ -40,17 +40,19 @@ struct RTMPStreaming { config.mEventHandler = {}; config.mEventHandler.onUserJoined = (uid: number, collapse: number) => { Logger.info(TAG, "mEventHandler.onUserJoined: " + uid + " , " + collapse); - if (this.remoteUid == -1) { - this.remoteUid = uid - this.transcodingParameters.transcodingUsers[uid] = { - uid: uid, - x: 0, - y: this.transcodingParameters.height / 2, - width: this.transcodingParameters.width, - height: this.transcodingParameters.height / 2, - zOrder: 1 - } - } + // if (this.remoteUid == -1) { + // this.remoteUid = uid + // let user = new TranscodingUser(); + // user.uid = uid; + // user.x = 0; + // user.y = this.transcodingParameters.height / 2; + // user.width = this.transcodingParameters.width; + // user.height = this.transcodingParameters.height / 2; + // user.zOrder = 1; + // user.alpha = 1.0 + // user.audioChannel = 2; + // this.transcodingParameters.transcodingUsers.set(uid,user) + // } }; config.mEventHandler.onUserOffline = (uid: number, reason: number) => { Logger.info(TAG, "mEventHandler.onUserOffline: " + uid + " , " + reason) @@ -62,14 +64,17 @@ struct RTMPStreaming { config.mEventHandler.onJoinChannelSuccess = (cid: string, uid: number, elapsed: number) => { Logger.info(TAG, "mEventHandler.onJoinChannelSuccess: " + uid); this.transcodingParameters.transcodingUsers = new Map(); - this.transcodingParameters.transcodingUsers[uid] = { + let localUser:TranscodingUser = { uid: uid, x: 0, y: 0, width: this.transcodingParameters.width, height: this.transcodingParameters.height / 2, - zOrder: 1 + zOrder: 1, + alpha:1.0, + audioChannel:0, } + this.transcodingParameters.transcodingUsers.set(uid,localUser) this.isJoin = true this.localUid = uid } @@ -130,7 +135,7 @@ struct RTMPStreaming { if (this.localUid != -1) { XComponent({ id: 'preview_local', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_local"); @@ -144,7 +149,7 @@ struct RTMPStreaming { if (this.remoteUid != -1) { XComponent({ id: 'preview_remote', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_remote"); diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ScreenSharing.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ScreenSharing.ets index 5798be078..8134a5944 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ScreenSharing.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ScreenSharing.ets @@ -118,7 +118,7 @@ struct ScreenSharing { if (this.localUid != -1) { XComponent({ id: 'preview_local', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_local"); @@ -133,7 +133,7 @@ struct ScreenSharing { if (this.remoteUid != -1) { XComponent({ id: 'preview_remote', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_remote"); From 7f28b7ea6006a208cfa7cb5e7a7846bdce823edd Mon Sep 17 00:00:00 2001 From: weileifrank <1138289316@qq.com> Date: Mon, 30 Sep 2024 16:58:52 +0800 Subject: [PATCH 07/21] =?UTF-8?q?feat:=20=E9=9A=90=E8=97=8F=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E6=9C=AA=E5=AE=9E=E7=8E=B0=E7=9A=84api=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/ets/pages/advance/PlayAudioFiles.ets | 80 +++++++---- .../main/ets/pages/advance/PreCallTest.ets | 131 +++++++++--------- 2 files changed, 118 insertions(+), 93 deletions(-) diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/PlayAudioFiles.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/PlayAudioFiles.ets index 2c99aa24f..c317473a3 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/PlayAudioFiles.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/PlayAudioFiles.ets @@ -133,9 +133,13 @@ struct PlayAudioFiles { Text($r('app.string.audio_mixing')).padding({ top: 6, bottom: 6 }) Divider() Row() { - Button($r('app.string.start')).layoutWeight(1).fontColor(Color.Blue).buttonStyle(ButtonStyleMode.NORMAL).onClick(() => { - this.rtcEngine?.startAudioMixing("https://webdemo.agora.io/audiomixing.mp3", false, -1, 0) - }) + Button($r('app.string.start')) + .layoutWeight(1) + .fontColor(Color.Blue) + .buttonStyle(ButtonStyleMode.NORMAL) + .onClick(() => { + this.rtcEngine?.startAudioMixing("https://webdemo.agora.io/audiomixing.mp3", false, -1, 0) + }) Button($r('app.string.resume')) .layoutWeight(1) .fontColor(Color.Blue) @@ -143,9 +147,13 @@ struct PlayAudioFiles { .onClick(() => { this.rtcEngine?.resumeAudioMixing() }) - Button($r('app.string.pause')).layoutWeight(1).fontColor(Color.Blue).buttonStyle(ButtonStyleMode.NORMAL).onClick(() => { - this.rtcEngine?.pauseAudioMixing() - }) + Button($r('app.string.pause')) + .layoutWeight(1) + .fontColor(Color.Blue) + .buttonStyle(ButtonStyleMode.NORMAL) + .onClick(() => { + this.rtcEngine?.pauseAudioMixing() + }) Button($r('app.string.stop')) .layoutWeight(1) .fontColor(Color.Blue) @@ -176,33 +184,47 @@ struct PlayAudioFiles { }) }.alignItems(VerticalAlign.Center) - Text($r('app.string.audio_effect')).padding({ top: 12, bottom: 6 }) - Divider() - Row() { - Button($r('app.string.start')).layoutWeight(1).fontColor(Color.Blue).buttonStyle(ButtonStyleMode.NORMAL).onClick(() => { - this.rtcEngine?.playEffect(0, "https://webdemo.agora.io/ding.mp3", -1, 1, 0.0, 100, true, 0) - }) - Button($r('app.string.resume')) - .layoutWeight(1) - .fontColor(Color.Blue) - .buttonStyle(ButtonStyleMode.NORMAL) - .onClick(() => { - - }) - Button($r('app.string.pause')).layoutWeight(1).fontColor(Color.Blue).buttonStyle(ButtonStyleMode.NORMAL).onClick(() => { + //todo + if (false) { + Text($r('app.string.audio_effect')).padding({ top: 12, bottom: 6 }) + Divider() + Row() { + Button($r('app.string.start')) + .layoutWeight(1) + .fontColor(Color.Blue) + .buttonStyle(ButtonStyleMode.NORMAL) + .onClick(() => { + this.rtcEngine?.playEffect(0, "https://webdemo.agora.io/ding.mp3", -1, 1, 0.0, 100, true, 0) + }) + Button($r('app.string.resume')) + .layoutWeight(1) + .fontColor(Color.Blue) + .buttonStyle(ButtonStyleMode.NORMAL) + .onClick(() => { - }) - Button($r('app.string.stop')).layoutWeight(1).fontColor(Color.Blue).buttonStyle(ButtonStyleMode.NORMAL).onClick(() => { + }) + Button($r('app.string.pause')) + .layoutWeight(1) + .fontColor(Color.Blue) + .buttonStyle(ButtonStyleMode.NORMAL) + .onClick(() => { - }) - }.alignItems(VerticalAlign.Center).padding({ top: 12, bottom: 6 }) + }) + Button($r('app.string.stop')) + .layoutWeight(1) + .fontColor(Color.Blue) + .buttonStyle(ButtonStyleMode.NORMAL) + .onClick(() => { - Row() { - Text($r('app.string.volume')).layoutWeight(1) - Slider({ value: 100 }).layoutWeight(1.5).onChange((value) => { + }) + }.alignItems(VerticalAlign.Center).padding({ top: 12, bottom: 6 }) + Row() { + Text($r('app.string.volume')).layoutWeight(1) + Slider({ value: 100 }).layoutWeight(1.5).onChange((value) => { - }) - }.alignItems(VerticalAlign.Center) + }) + }.alignItems(VerticalAlign.Center) + } } .alignItems(HorizontalAlign.Start) .layoutWeight(3) diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/PreCallTest.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/PreCallTest.ets index d72c38d2c..5c3b8d303 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/PreCallTest.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/PreCallTest.ets @@ -151,74 +151,77 @@ struct PlayAudioFiles { bottom: 6 }) - Column() { - Text('Audio Echo Pretest').padding({ top: 6, bottom: 6 }) - Divider() - Button(this.isAudioEchoTesting ? this.audioEchoTestingText : $r('app.string.start')) - .margin({ top: 6, bottom: 6 }) - .enabled(!this.isAudioEchoTesting && !this.isVideoEchoTesting) - .onClick(() => { + //todo + if (false) { + Column() { + Text('Audio Echo Pretest').padding({ top: 6, bottom: 6 }) + Divider() + Button(this.isAudioEchoTesting ? this.audioEchoTestingText : $r('app.string.start')) + .margin({ top: 6, bottom: 6 }) + .enabled(!this.isAudioEchoTesting && !this.isVideoEchoTesting) + .onClick(() => { - // TODO - // this.rtcEngine?.startEchoTest() - let countDownCount = 10 - let revert = false - let countDownIndex = countDownCount - this.audioEchoTestingText = 'Recording(' + countDownIndex + 's)' - this.isAudioEchoTesting = true - this.audioEchoCountDown = setInterval(() => { - if (!revert) { - if (countDownIndex > 0) { - this.audioEchoTestingText = 'Recording(' + countDownIndex + 's)' - countDownIndex-- - } else { - revert = true + // TODO + // this.rtcEngine?.startEchoTest() + let countDownCount = 10 + let revert = false + let countDownIndex = countDownCount + this.audioEchoTestingText = 'Recording(' + countDownIndex + 's)' + this.isAudioEchoTesting = true + this.audioEchoCountDown = setInterval(() => { + if (!revert) { + if (countDownIndex > 0) { + this.audioEchoTestingText = 'Recording(' + countDownIndex + 's)' + countDownIndex-- + } else { + revert = true + } } - } - if (revert) { - if (countDownIndex < countDownCount) { - countDownIndex++ - this.audioEchoTestingText = 'Playing(' + countDownIndex + 's)' - } else { - clearInterval(this.audioEchoCountDown) - this.audioEchoCountDown = undefined - this.isAudioEchoTesting = false + if (revert) { + if (countDownIndex < countDownCount) { + countDownIndex++ + this.audioEchoTestingText = 'Playing(' + countDownIndex + 's)' + } else { + clearInterval(this.audioEchoCountDown) + this.audioEchoCountDown = undefined + this.isAudioEchoTesting = false + } } + }, 1000) + }) + Text('Video Echo Pretest').padding({ top: 6, bottom: 6 }) + Divider() + Button($r(this.isVideoEchoTesting ? 'app.string.stop' : 'app.string.start')) + .margin({ top: 6, bottom: 12 }) + .enabled(!this.isAudioEchoTesting) + .onClick(() => { + this.isVideoEchoTesting = !this.isVideoEchoTesting + // TODO + // this.rtcEngine?.startEchoTest() + if (this.isVideoEchoTesting) { + this.rtcEngine?.startPreview() + } else { + this.rtcEngine?.stopPreview() } - }, 1000) - }) - Text('Video Echo Pretest').padding({ top: 6, bottom: 6 }) - Divider() - Button($r(this.isVideoEchoTesting ? 'app.string.stop' : 'app.string.start')) - .margin({ top: 6, bottom: 12 }) - .enabled(!this.isAudioEchoTesting) - .onClick(() => { - this.isVideoEchoTesting = !this.isVideoEchoTesting - // TODO - // this.rtcEngine?.startEchoTest() - if (this.isVideoEchoTesting) { - this.rtcEngine?.startPreview() - } else { - this.rtcEngine?.stopPreview() - } - }) - XComponent({ - id: 'preview_local', - type: 'surface', - libraryname: Constants.AGORA_LIB_NAME, - }).onLoad(() => { - let localCanvas = new VideoCanvas("preview_local"); - localCanvas.renderMode = VideoCanvas.RENDER_MODE_HIDDEN; - this.rtcEngine?.setupLocalVideo(localCanvas); - }).width(150).height(150) - }.alignItems(HorizontalAlign.Start) - .layoutWeight(1.3) - .padding({ - left: 12, - right: 12, - top: 6, - bottom: 6 - }) + }) + XComponent({ + id: 'preview_local', + type: XComponentType.SURFACE, + libraryname: Constants.AGORA_LIB_NAME, + }).onLoad(() => { + let localCanvas = new VideoCanvas("preview_local"); + localCanvas.renderMode = VideoCanvas.RENDER_MODE_HIDDEN; + this.rtcEngine?.setupLocalVideo(localCanvas); + }).width(150).height(150) + }.alignItems(HorizontalAlign.Start) + .layoutWeight(1.3) + .padding({ + left: 12, + right: 12, + top: 6, + bottom: 6 + }) + } } From 5985813ee24c77171be4100746402ca3e5515207 Mon Sep 17 00:00:00 2001 From: weileifrank <1138289316@qq.com> Date: Mon, 30 Sep 2024 14:52:43 +0800 Subject: [PATCH 08/21] feat: adapter sdk 4.4.0 --- .../src/main/cpp/include/AgoraAtomicOps.h | 0 .../entry/src/main/cpp/include/AgoraBase.h | 417 ++++++++++++++-- .../cpp/include/AgoraExtensionProviderEntry.h | 0 .../main/cpp/include/AgoraExtensionVersion.h | 8 + .../src/main/cpp/include/AgoraMediaBase.h | 358 ++++++++++++- .../main/cpp/include/AgoraMediaPlayerTypes.h | 0 .../src/main/cpp/include/AgoraOptional.h | 0 .../main/cpp/include/AgoraRefCountedObject.h | 0 .../entry/src/main/cpp/include/AgoraRefPtr.h | 0 .../src/main/cpp/include/IAgoraFileUploader.h | 0 .../main/cpp/include/IAgoraH265Transcoder.h | 0 .../entry/src/main/cpp/include/IAgoraLog.h | 1 + .../cpp/include/IAgoraMediaComponentFactory.h | 0 .../src/main/cpp/include/IAgoraMediaEngine.h | 15 + .../src/main/cpp/include/IAgoraMediaPlayer.h | 11 - .../cpp/include/IAgoraMediaPlayerSource.h | 11 - .../main/cpp/include/IAgoraMediaRecorder.h | 0 .../cpp/include/IAgoraMediaRelayService.h | 6 +- .../cpp/include/IAgoraMediaStreamingSource.h | 0 .../src/main/cpp/include/IAgoraParameter.h | 6 +- .../src/main/cpp/include/IAgoraRhythmPlayer.h | 0 .../src/main/cpp/include/IAgoraRtcEngine.h | 472 ++++++++++-------- .../src/main/cpp/include/IAgoraRtcEngineEx.h | 84 ++-- .../src/main/cpp/include/IAgoraRtmService.h | 0 .../cpp/include/IAgoraRtmpStreamingService.h | 0 .../src/main/cpp/include/IAgoraService.h | 46 +- .../main/cpp/include/IAudioDeviceManager.h | 50 ++ .../cpp/include/NGIAgoraAudioDeviceManager.h | 6 + .../cpp/include/NGIAgoraAudioMixerSource.h | 0 .../src/main/cpp/include/NGIAgoraAudioTrack.h | 65 ++- .../main/cpp/include/NGIAgoraCameraCapturer.h | 32 ++ .../main/cpp/include/NGIAgoraConfigCenter.h | 0 .../main/cpp/include/NGIAgoraDataChannel.h | 0 .../NGIAgoraExtensionAINoiseSuppressor.h | 9 +- .../main/cpp/include/NGIAgoraExtensionAiAec.h | 8 +- .../cpp/include/NGIAgoraExtensionControl.h | 0 .../cpp/include/NGIAgoraExtensionProvider.h | 2 +- .../include/NGIAgoraExtensionScreenSource.h | 6 +- .../main/cpp/include/NGIAgoraExtensionVQA.h | 0 .../src/main/cpp/include/NGIAgoraLocalUser.h | 28 ++ .../src/main/cpp/include/NGIAgoraMediaNode.h | 92 +++- .../cpp/include/NGIAgoraMediaNodeFactory.h | 4 +- .../include/NGIAgoraRemoteAudioMixerSource.h | 0 .../main/cpp/include/NGIAgoraRtcConnection.h | 0 .../main/cpp/include/NGIAgoraRtmpConnection.h | 0 .../main/cpp/include/NGIAgoraRtmpLocalUser.h | 0 .../main/cpp/include/NGIAgoraScreenCapturer.h | 0 .../src/main/cpp/include/NGIAgoraSyncClient.h | 139 ++++++ .../src/main/cpp/include/NGIAgoraVideoFrame.h | 85 +--- .../cpp/include/NGIAgoraVideoMixerSource.h | 0 .../src/main/cpp/include/NGIAgoraVideoTrack.h | 80 ++- .../entry/src/main/cpp/include/PLACEHOLDER | 1 - .../entry/src/main/cpp/include/api/Makefile | 0 .../src/main/cpp/include/api/aosl_alloca.h | 0 .../src/main/cpp/include/api/aosl_angel.h | 0 .../src/main/cpp/include/api/aosl_ares.h | 0 .../src/main/cpp/include/api/aosl_async.h | 0 .../src/main/cpp/include/api/aosl_atomic.h | 0 .../src/main/cpp/include/api/aosl_audio.h | 0 .../src/main/cpp/include/api/aosl_byteswap.h | 0 .../src/main/cpp/include/api/aosl_data.h | 42 +- .../src/main/cpp/include/api/aosl_defs.h | 0 .../src/main/cpp/include/api/aosl_display.h | 0 .../entry/src/main/cpp/include/api/aosl_dq.h | 0 .../src/main/cpp/include/api/aosl_errno.h | 0 .../src/main/cpp/include/api/aosl_fcntl.h | 0 .../src/main/cpp/include/api/aosl_file.h | 3 +- .../src/main/cpp/include/api/aosl_http.h | 0 .../src/main/cpp/include/api/aosl_input.h | 0 .../cpp/include/api/aosl_integer_wrappings.h | 0 .../entry/src/main/cpp/include/api/aosl_jni.h | 3 +- .../src/main/cpp/include/api/aosl_kobj.h | 20 +- .../src/main/cpp/include/api/aosl_list.h | 0 .../entry/src/main/cpp/include/api/aosl_log.h | 0 .../main/cpp/include/api/aosl_marshalling.h | 0 .../entry/src/main/cpp/include/api/aosl_mm.h | 250 ++++++++++ .../src/main/cpp/include/api/aosl_module.h | 0 .../entry/src/main/cpp/include/api/aosl_mpq.h | 37 +- .../src/main/cpp/include/api/aosl_mpq_fd.h | 46 +- .../src/main/cpp/include/api/aosl_mpq_net.h | 6 +- .../src/main/cpp/include/api/aosl_mpq_timer.h | 0 .../src/main/cpp/include/api/aosl_mpqp.h | 0 .../entry/src/main/cpp/include/api/aosl_os.h | 0 .../src/main/cpp/include/api/aosl_pmdf.h | 0 .../src/main/cpp/include/api/aosl_poll.h | 0 .../src/main/cpp/include/api/aosl_profile.h | 0 .../entry/src/main/cpp/include/api/aosl_psb.h | 0 .../src/main/cpp/include/api/aosl_rbtree.h | 0 .../entry/src/main/cpp/include/api/aosl_ref.h | 30 ++ .../src/main/cpp/include/api/aosl_route.h | 0 .../src/main/cpp/include/api/aosl_sbus.h | 121 ++++- .../entry/src/main/cpp/include/api/aosl_so.h | 21 +- .../src/main/cpp/include/api/aosl_socket.h | 0 .../src/main/cpp/include/api/aosl_task.h | 0 .../src/main/cpp/include/api/aosl_thread.h | 14 + .../src/main/cpp/include/api/aosl_time.h | 0 .../src/main/cpp/include/api/aosl_types.h | 0 .../src/main/cpp/include/api/aosl_utils.h | 0 .../src/main/cpp/include/api/aosl_value.h | 0 .../src/main/cpp/include/api/aosl_vcodec.h | 0 .../src/main/cpp/include/api/aosl_version.h | 0 .../src/main/cpp/include/api/aosl_video.h | 0 .../src/main/cpp/include/api/aosl_xdump.h | 6 + .../src/main/cpp/include/api/cpp/Makefile | 1 - .../cpp/include/api/cpp/aosl_ares_class.h | 0 .../cpp/include/api/cpp/aosl_async_class.h | 0 .../cpp/include/api/cpp/aosl_data_class.h | 273 +++++++--- .../cpp/include/api/cpp/aosl_file_class.h | 4 +- .../cpp/include/api/cpp/aosl_input_class.h | 0 .../cpp/include/api/cpp/aosl_kobj_class.h | 6 +- .../main/cpp/include/api/cpp/aosl_mm_class.h | 45 ++ .../cpp/include/api/cpp/aosl_mpq_fd_class.h | 40 +- .../cpp/include/api/cpp/aosl_mpq_sk_lambda.h | 161 +++++- .../include/api/cpp/aosl_mpq_timer_lambda.h | 0 .../cpp/include/api/cpp/aosl_poll_class.h | 14 +- .../main/cpp/include/api/cpp/aosl_ref_class.h | 161 ++++-- .../cpp/include/api/cpp/aosl_sbus_class.h | 180 +++++++ .../cpp/include/api/cpp/aosl_task_class.h | 0 .../cpp/include/api/cpp/aosl_thread_class.h | 0 .../cpp/include/api/cpp/aosl_usage_class.h | 84 ---- .../cpp/include/api/cpp/aosl_value_class.h | 0 .../src/main/cpp/include/api/objc/Makefile | 0 .../src/main/cpp/include/api/objc/aosl_log.h | 0 .../src/main/cpp/include/api/objc/aosl_objc.h | 0 .../entry/src/main/cpp/include/time_utils.h | 0 .../entry/src/main/cpp/origin_video_data.cpp | 2 +- .../main/ets/entryability/EntryAbility.ets | 2 +- .../ets/pages/advance/ChannelEncryption.ets | 2 +- .../ets/pages/advance/CustomVideoSource.ets | 10 +- .../ets/pages/advance/HostCrossChannel.ets | 12 +- .../ets/pages/advance/JoinMultiChannel.ets | 6 +- .../main/ets/pages/advance/LiveStreaming.ets | 4 +- .../pages/advance/LocalVideoTranscoding.ets | 41 +- .../main/ets/pages/advance/PlayAudioFiles.ets | 80 +-- .../main/ets/pages/advance/PreCallTest.ets | 131 ++--- .../main/ets/pages/advance/RTMPStreaming.ets | 35 +- .../main/ets/pages/advance/ScreenSharing.ets | 4 +- .../entry/src/main/ets/util/Logger.ts | 2 +- 138 files changed, 3114 insertions(+), 827 deletions(-) mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraAtomicOps.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraBase.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraExtensionProviderEntry.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraExtensionVersion.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraMediaBase.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraMediaPlayerTypes.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraOptional.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraRefCountedObject.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraRefPtr.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraFileUploader.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraH265Transcoder.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraLog.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaComponentFactory.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaEngine.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaPlayer.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaPlayerSource.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaRecorder.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaRelayService.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaStreamingSource.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraParameter.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRhythmPlayer.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtcEngine.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtcEngineEx.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtmService.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtmpStreamingService.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraService.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAudioDeviceManager.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioDeviceManager.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioMixerSource.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioTrack.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraCameraCapturer.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraConfigCenter.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraDataChannel.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionAINoiseSuppressor.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionAiAec.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionControl.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionProvider.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionScreenSource.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionVQA.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraLocalUser.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraMediaNode.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraMediaNodeFactory.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRemoteAudioMixerSource.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRtcConnection.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRtmpConnection.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRtmpLocalUser.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraScreenCapturer.h create mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraSyncClient.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoFrame.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoMixerSource.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoTrack.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/PLACEHOLDER mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/Makefile mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_alloca.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_angel.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_ares.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_async.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_atomic.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_audio.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_byteswap.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_data.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_defs.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_display.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_dq.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_errno.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_fcntl.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_file.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_http.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_input.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_integer_wrappings.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_jni.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_kobj.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_list.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_log.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_marshalling.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mm.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_module.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_fd.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_net.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_timer.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpqp.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_os.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_pmdf.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_poll.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_profile.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_psb.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_rbtree.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_ref.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_route.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_sbus.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_so.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_socket.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_task.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_thread.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_time.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_types.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_utils.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_value.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_vcodec.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_version.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_video.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_xdump.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/Makefile mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_ares_class.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_async_class.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_data_class.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_file_class.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_input_class.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_kobj_class.h create mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mm_class.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_fd_class.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_sk_lambda.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_timer_lambda.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_poll_class.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_ref_class.h create mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_sbus_class.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_task_class.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_thread_class.h delete mode 100755 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_usage_class.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_value_class.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/objc/Makefile mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/objc/aosl_log.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/objc/aosl_objc.h mode change 100755 => 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/time_utils.h diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraAtomicOps.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraAtomicOps.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraBase.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraBase.h old mode 100755 new mode 100644 index ed9308d1a..96ae67d96 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraBase.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraBase.h @@ -43,6 +43,8 @@ #define __deprecated +#define AGORA_CPP_INTERNAL_API extern + #elif defined(__APPLE__) #include @@ -51,6 +53,8 @@ #define AGORA_CPP_API __attribute__((visibility("default"))) #define AGORA_CALL +#define AGORA_CPP_INTERNAL_API __attribute__((visibility("hidden"))) + #elif defined(__ANDROID__) || defined(__linux__) #define AGORA_API extern "C" __attribute__((visibility("default"))) @@ -59,6 +63,8 @@ #define __deprecated +#define AGORA_CPP_INTERNAL_API __attribute__((visibility("hidden"))) + #else // !_WIN32 && !__APPLE__ && !(__ANDROID__ || __linux__) #define AGORA_API extern "C" @@ -636,7 +642,7 @@ enum ERROR_CODE_TYPE { */ ERR_SET_CLIENT_ROLE_NOT_AUTHORIZED = 119, /** - * 120: Decryption fails. The user may have tried to join the channel with a wrong + * 120: MediaStream decryption fails. The user may have tried to join the channel with a wrong * password. Check your settings or try rejoining the channel. */ ERR_DECRYPTION_FAILED = 120, @@ -644,6 +650,11 @@ enum ERROR_CODE_TYPE { * 121: The user ID is invalid. */ ERR_INVALID_USER_ID = 121, + /** + * 122: DataStream decryption fails. The peer may have tried to join the channel with a wrong + * password, or did't enable datastream encryption + */ + ERR_DATASTREAM_DECRYPTION_FAILED = 122, /** * 123: The app is banned by the server. */ @@ -1167,8 +1178,9 @@ enum VIDEO_CODEC_TYPE { */ VIDEO_CODEC_GENERIC_H264 = 7, /** - * 12: AV1. - */ + * 12: AV1. + * @technical preview + */ VIDEO_CODEC_AV1 = 12, /** * 13: VP9. @@ -1180,6 +1192,28 @@ enum VIDEO_CODEC_TYPE { VIDEO_CODEC_GENERIC_JPEG = 20, }; +/** + * Camera focal length type. + */ +enum CAMERA_FOCAL_LENGTH_TYPE { + /** + * By default, there are no wide-angle and ultra-wide-angle properties. + */ + CAMERA_FOCAL_LENGTH_DEFAULT = 0, + /** + * Lens with focal length from 24mm to 35mm. + */ + CAMERA_FOCAL_LENGTH_WIDE_ANGLE = 1, + /** + * Lens with focal length of less than 24mm. + */ + CAMERA_FOCAL_LENGTH_ULTRA_WIDE = 2, + /** + * Telephoto lens. + */ + CAMERA_FOCAL_LENGTH_TELEPHOTO = 3, +}; + /** * The CC (Congestion Control) mode options. */ @@ -1315,6 +1349,10 @@ enum AUDIO_CODEC_TYPE { * 12: LPCNET. */ AUDIO_CODEC_LPCNET = 12, + /** + * 13: Opus codec, supporting 3 to 8 channels audio. + */ + AUDIO_CODEC_OPUSMC = 13, }; /** @@ -1515,13 +1553,38 @@ enum H264PacketizeMode { */ enum VIDEO_STREAM_TYPE { /** - * 0: The high-quality video stream, which has a higher resolution and bitrate. + * 0: The high-quality video stream, which has the highest resolution and bitrate. */ VIDEO_STREAM_HIGH = 0, /** - * 1: The low-quality video stream, which has a lower resolution and bitrate. + * 1: The low-quality video stream, which has the lowest resolution and bitrate. */ VIDEO_STREAM_LOW = 1, + /** + * 4: The video stream of layer_1, which has a lower resolution and bitrate than VIDEO_STREAM_HIGH. + */ + VIDEO_STREAM_LAYER_1 = 4, + /** + * 5: The video stream of layer_2, which has a lower resolution and bitrate than VIDEO_STREAM_LAYER_1. + */ + VIDEO_STREAM_LAYER_2 = 5, + /** + * 6: The video stream of layer_3, which has a lower resolution and bitrate than VIDEO_STREAM_LAYER_2. + */ + VIDEO_STREAM_LAYER_3 = 6, + /** + * 7: The video stream of layer_4, which has a lower resolution and bitrate than VIDEO_STREAM_LAYER_3. + */ + VIDEO_STREAM_LAYER_4 = 7, + /** + * 8: The video stream of layer_5, which has a lower resolution and bitrate than VIDEO_STREAM_LAYER_4. + */ + VIDEO_STREAM_LAYER_5 = 8, + /** + * 9: The video stream of layer_6, which has a lower resolution and bitrate than VIDEO_STREAM_LAYER_5. + */ + VIDEO_STREAM_LAYER_6 = 9, + }; struct VideoSubscriptionOptions { @@ -1567,7 +1630,8 @@ struct EncodedVideoFrameInfo { trackId(0), captureTimeMs(0), decodeTimeMs(0), - streamType(VIDEO_STREAM_HIGH) {} + streamType(VIDEO_STREAM_HIGH), + presentationMs(-1) {} EncodedVideoFrameInfo(const EncodedVideoFrameInfo& rhs) : uid(rhs.uid), @@ -1580,7 +1644,8 @@ struct EncodedVideoFrameInfo { trackId(rhs.trackId), captureTimeMs(rhs.captureTimeMs), decodeTimeMs(rhs.decodeTimeMs), - streamType(rhs.streamType) {} + streamType(rhs.streamType), + presentationMs(rhs.presentationMs) {} EncodedVideoFrameInfo& operator=(const EncodedVideoFrameInfo& rhs) { if (this == &rhs) return *this; @@ -1595,6 +1660,7 @@ struct EncodedVideoFrameInfo { captureTimeMs = rhs.captureTimeMs; decodeTimeMs = rhs.decodeTimeMs; streamType = rhs.streamType; + presentationMs = rhs.presentationMs; return *this; } @@ -1646,6 +1712,8 @@ struct EncodedVideoFrameInfo { */ VIDEO_STREAM_TYPE streamType; + // @technical preview + int64_t presentationMs; }; /** @@ -1695,17 +1763,27 @@ struct AdvanceOptions { */ COMPRESSION_PREFERENCE compressionPreference; + /** + * Whether to encode and send the alpha data to the remote when alpha data is present. + * The default value is false. + */ + bool encodeAlpha; + AdvanceOptions() : encodingPreference(PREFER_AUTO), - compressionPreference(PREFER_LOW_LATENCY) {} + compressionPreference(PREFER_LOW_LATENCY), + encodeAlpha(false) {} AdvanceOptions(ENCODING_PREFERENCE encoding_preference, - COMPRESSION_PREFERENCE compression_preference) : + COMPRESSION_PREFERENCE compression_preference, + bool encode_alpha) : encodingPreference(encoding_preference), - compressionPreference(compression_preference) {} + compressionPreference(compression_preference), + encodeAlpha(encode_alpha) {} bool operator==(const AdvanceOptions& rhs) const { return encodingPreference == rhs.encodingPreference && - compressionPreference == rhs.compressionPreference; + compressionPreference == rhs.compressionPreference && + encodeAlpha == rhs.encodeAlpha; } }; @@ -1728,6 +1806,17 @@ enum VIDEO_MIRROR_MODE_TYPE { VIDEO_MIRROR_MODE_DISABLED = 2, }; +#if defined(__APPLE__) && TARGET_OS_IOS +/** + * Camera capturer configuration for format type. + */ +enum CAMERA_FORMAT_TYPE { + /** 0: (Default) NV12. */ + CAMERA_FORMAT_NV12, + /** 1: BGRA. */ + CAMERA_FORMAT_BGRA, +}; +#endif /** Supported codec type bit mask. */ enum CODEC_CAP_MASK { @@ -1766,6 +1855,14 @@ struct CodecCapInfo { CodecCapInfo(): codecType(VIDEO_CODEC_NONE), codecCapMask(0) {} }; +/** FocalLengthInfo contains the IDs of the front and rear cameras, along with the wide-angle types. */ +struct FocalLengthInfo { + /** The camera direction. */ + int cameraDirection; + /** Camera focal segment type. */ + CAMERA_FOCAL_LENGTH_TYPE focalLengthType; +}; + /** * The definition of the VideoEncoderConfiguration struct. */ @@ -1885,7 +1982,7 @@ struct VideoEncoderConfiguration { orientationMode(m), degradationPreference(MAINTAIN_QUALITY), mirrorMode(mirror), - advanceOptions(PREFER_AUTO, PREFER_LOW_LATENCY) {} + advanceOptions(PREFER_AUTO, PREFER_LOW_LATENCY, false) {} VideoEncoderConfiguration(int width, int height, int f, int b, ORIENTATION_MODE m, VIDEO_MIRROR_MODE_TYPE mirror = VIDEO_MIRROR_MODE_DISABLED) : codecType(VIDEO_CODEC_NONE), dimensions(width, height), @@ -1895,7 +1992,7 @@ struct VideoEncoderConfiguration { orientationMode(m), degradationPreference(MAINTAIN_QUALITY), mirrorMode(mirror), - advanceOptions(PREFER_AUTO, PREFER_LOW_LATENCY) {} + advanceOptions(PREFER_AUTO, PREFER_LOW_LATENCY, false) {} VideoEncoderConfiguration(const VideoEncoderConfiguration& config) : codecType(config.codecType), dimensions(config.dimensions), @@ -1915,7 +2012,7 @@ struct VideoEncoderConfiguration { orientationMode(ORIENTATION_MODE_ADAPTIVE), degradationPreference(MAINTAIN_QUALITY), mirrorMode(VIDEO_MIRROR_MODE_DISABLED), - advanceOptions(PREFER_AUTO, PREFER_LOW_LATENCY) {} + advanceOptions(PREFER_AUTO, PREFER_LOW_LATENCY, false) {} VideoEncoderConfiguration& operator=(const VideoEncoderConfiguration& rhs) { if (this == &rhs) return *this; @@ -1989,15 +2086,78 @@ struct SimulcastStreamConfig { */ int kBitrate; /** - * he capture frame rate (fps) of the local video. The default value is 5. + * The capture frame rate (fps) of the local video. The default value is 5. */ int framerate; SimulcastStreamConfig() : dimensions(160, 120), kBitrate(65), framerate(5) {} + SimulcastStreamConfig(const SimulcastStreamConfig& other) : dimensions(other.dimensions), kBitrate(other.kBitrate), framerate(other.framerate) {} bool operator==(const SimulcastStreamConfig& rhs) const { return dimensions == rhs.dimensions && kBitrate == rhs.kBitrate && framerate == rhs.framerate; } }; +/** + * The configuration of the multi-layer video stream. + */ +struct SimulcastConfig { + /** + * The index of multi-layer video stream + */ + enum StreamLayerIndex { + /** + * 0: video stream index of layer_1 + */ + STREAM_LAYER_1 = 0, + /** + * 1: video stream index of layer_2 + */ + STREAM_LAYER_2 = 1, + /** + * 2: video stream index of layer_3 + */ + STREAM_LAYER_3 = 2, + /** + * 3: video stream index of layer_4 + */ + STREAM_LAYER_4 = 3, + /** + * 4: video stream index of layer_5 + */ + STREAM_LAYER_5 = 4, + /** + * 5: video stream index of layer_6 + */ + STREAM_LAYER_6 = 5, + /** + * 6: video stream index of low + */ + STREAM_LOW = 6, + /** + * 7: max count of video stream layers + */ + STREAM_LAYER_COUNT_MAX = 7 + }; + struct StreamLayerConfig { + /** + * The video frame dimension. The default value is 0. + */ + VideoDimensions dimensions; + /** + * The capture frame rate (fps) of the local video. The default value is 0. + */ + int framerate; + /** + * Whether to enable the corresponding layer of video stream. The default value is false. + */ + bool enable; + StreamLayerConfig() : dimensions(0, 0), framerate(0), enable(false) {} + }; + + /** + * The array of StreamLayerConfig, which contains STREAM_LAYER_COUNT_MAX layers of video stream at most. + */ + StreamLayerConfig configs[STREAM_LAYER_COUNT_MAX]; +}; /** * The location of the target area relative to the screen or window. If you do not set this parameter, * the SDK selects the whole screen or window. @@ -2595,6 +2755,10 @@ enum VIDEO_APPLICATION_SCENARIO_TYPE { * 1: Meeting Scenario. This scenario is the best QoE practice of meeting application. */ APPLICATION_SCENARIO_MEETING = 1, + /** + * 2: Video Call Scenario. This scenario is used to optimize the video experience in video application, like 1v1 video call. + */ + APPLICATION_SCENARIO_1V1 = 2, }; /** @@ -2639,6 +2803,27 @@ enum CAPTURE_BRIGHTNESS_LEVEL_TYPE { CAPTURE_BRIGHTNESS_LEVEL_DARK = 2, }; +enum CAMERA_STABILIZATION_MODE { + /** The camera stabilization mode is disabled. + */ + CAMERA_STABILIZATION_MODE_OFF = -1, + /** device choose stabilization mode automatically. + */ + CAMERA_STABILIZATION_MODE_AUTO = 0, + /** stabilization mode level 1. + */ + CAMERA_STABILIZATION_MODE_LEVEL_1 = 1, + /** stabilization mode level 2. + */ + CAMERA_STABILIZATION_MODE_LEVEL_2 = 2, + /** stabilization mode level 3. + */ + CAMERA_STABILIZATION_MODE_LEVEL_3 = 3, + /** The maximum level of the camera stabilization mode. + */ + CAMERA_STABILIZATION_MODE_MAX_LEVEL = CAMERA_STABILIZATION_MODE_LEVEL_3, +}; + /** * Local audio states. */ @@ -2792,6 +2977,16 @@ enum LOCAL_VIDEO_STREAM_REASON { * Check whether the ID of the video device is valid. */ LOCAL_VIDEO_STREAM_REASON_DEVICE_INVALID_ID = 10, + /** + * 14: (Android only) Video capture was interrupted, possibly due to the camera being occupied + * or some policy reasons such as background termination. + */ + LOCAL_VIDEO_STREAM_REASON_DEVICE_INTERRUPT = 14, + /** + * 15: (Android only) The device may need to be shut down and restarted to restore camera function, + * or there may be a persistent hardware problem. + */ + LOCAL_VIDEO_STREAM_REASON_DEVICE_FATAL_ERROR = 15, /** * 101: The current video capture device is unavailable due to excessive system pressure. */ @@ -2835,7 +3030,7 @@ enum LOCAL_VIDEO_STREAM_REASON { LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_WINDOW_HIDDEN = 25, /** 26: (Windows only) The local screen capture window is recovered from its hidden state. */ LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_WINDOW_RECOVER_FROM_HIDDEN = 26, - /** 27:(Windows only) The window is recovered from miniminzed */ + /** 27: (Windows and macOS only) The window is recovered from miniminzed */ LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_WINDOW_RECOVER_FROM_MINIMIZED = 27, /** * 28: The screen capture paused. @@ -2847,7 +3042,14 @@ enum LOCAL_VIDEO_STREAM_REASON { LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_PAUSED = 28, /** 29: The screen capture is resumed. */ LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_RESUMED = 29, - + /** 30: The shared display has been disconnected */ + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_DISPLAY_DISCONNECTED = 30, + /* 30: (HMOS only) ScreenCapture stopped by user */ + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_STOPPED_BY_USER = 31, + /* 31: (HMOS only) ScreenCapture interrupted by other screen capture */ + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_INTERRUPTED_BY_OTHER = 32, + /* 32: (HMOS only) ScreenCapture stopped by SIM call */ + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_STOPPED_BY_CALL = 33, }; /** @@ -2924,6 +3126,14 @@ enum REMOTE_AUDIO_STATE_REASON * 7: The remote user leaves the channel. */ REMOTE_AUDIO_REASON_REMOTE_OFFLINE = 7, + /** + * 8: The local user does not receive any audio packet from remote user. + */ + REMOTE_AUDIO_REASON_NO_PACKET_RECEIVE = 8, + /** + * 9: The local user receives remote audio packet but fails to play. + */ + REMOTE_AUDIO_REASON_LOCAL_PLAY_FAILED = 9, }; /** @@ -3044,7 +3254,7 @@ enum REMOTE_USER_STATE { struct VideoTrackInfo { VideoTrackInfo() : isLocal(false), ownerUid(0), trackId(0), channelId(OPTIONAL_NULLPTR) - , streamType(VIDEO_STREAM_HIGH), codecType(VIDEO_CODEC_H265) + , codecType(VIDEO_CODEC_H265) , encodedFrameOnly(false), sourceType(VIDEO_SOURCE_CAMERA_PRIMARY) , observationPosition(agora::media::base::POSITION_POST_CAPTURER) {} /** @@ -3065,10 +3275,6 @@ struct VideoTrackInfo { * The channel ID of the video track. */ const char* channelId; - /** - * The video stream type: #VIDEO_STREAM_TYPE. - */ - VIDEO_STREAM_TYPE streamType; /** * The video codec type: #VIDEO_CODEC_TYPE. */ @@ -4116,12 +4322,14 @@ enum CLIENT_ROLE_CHANGE_FAILED_REASON { CLIENT_ROLE_CHANGE_FAILED_NOT_AUTHORIZED = 2, /** * 3: The operation of changing role is timeout. + * @deprecated This reason is deprecated. */ - CLIENT_ROLE_CHANGE_FAILED_REQUEST_TIME_OUT = 3, + CLIENT_ROLE_CHANGE_FAILED_REQUEST_TIME_OUT __deprecated = 3, /** * 4: The operation of changing role is interrupted since we lost connection with agora service. + * @deprecated This reason is deprecated. */ - CLIENT_ROLE_CHANGE_FAILED_CONNECTION_FAILED = 4, + CLIENT_ROLE_CHANGE_FAILED_CONNECTION_FAILED __deprecated = 4, }; /** @@ -4363,6 +4571,85 @@ struct BeautyOptions { BeautyOptions() : lighteningContrastLevel(LIGHTENING_CONTRAST_NORMAL), lighteningLevel(0), smoothnessLevel(0), rednessLevel(0), sharpnessLevel(0) {} }; +/** Face shape area options. This structure defines options for facial adjustments on different facial areas. + * + * @technical preview + */ +struct FaceShapeAreaOptions { + /** The specific facial area to be adjusted. + */ + enum FACE_SHAPE_AREA { + /** (Default) Invalid area. */ + FACE_SHAPE_AREA_NONE = -1, + /** Head Scale, reduces the size of head. */ + FACE_SHAPE_AREA_HEADSCALE = 0, + /** Forehead, adjusts the size of forehead. */ + FACE_SHAPE_AREA_FOREHEAD = 1, + /** Face Contour, slims the facial contour. */ + FACE_SHAPE_AREA_FACECONTOUR = 2, + /** Face Length, adjusts the length of face. */ + FACE_SHAPE_AREA_FACELENGTH = 3, + /** Face Width, narrows the width of face. */ + FACE_SHAPE_AREA_FACEWIDTH = 4, + /** Cheekbone, adjusts the size of cheekbone. */ + FACE_SHAPE_AREA_CHEEKBONE = 5, + /** Cheek, adjusts the size of cheek. */ + FACE_SHAPE_AREA_CHEEK = 6, + /** Chin, adjusts the length of chin. */ + FACE_SHAPE_AREA_CHIN = 7, + /** Eye Scale, adjusts the size of eyes. */ + FACE_SHAPE_AREA_EYESCALE = 8, + /** Nose Length, adjusts the length of nose. */ + FACE_SHAPE_AREA_NOSELENGTH = 9, + /** Nose Width, adjusts the width of nose. */ + FACE_SHAPE_AREA_NOSEWIDTH = 10, + /** Mouth Scale, adjusts the size of mouth. */ + FACE_SHAPE_AREA_MOUTHSCALE = 11, + }; + + /** The specific facial area to be adjusted, See #FACE_SHAPE_AREA. + */ + FACE_SHAPE_AREA shapeArea; + + /** The intensity of the pinching effect applied to the specified facial area. + * For the following area values: #FACE_SHAPE_AREA_FOREHEAD, #FACE_SHAPE_AREA_FACELENGTH, #FACE_SHAPE_AREA_CHIN, #FACE_SHAPE_AREA_NOSELENGTH, #FACE_SHAPE_AREA_NOSEWIDTH, #FACE_SHAPE_AREA_MOUTHSCALE, the value ranges from -100 to 100. + * The default value is 0. The greater the absolute value, the stronger the intensity applied to the specified facial area, and negative values indicate the opposite direction. + * For enumeration values other than the above, the value ranges from 0 to 100. The default value is 0. The greater the value, the stronger the intensity applied to the specified facial area. + */ + int shapeIntensity; + + FaceShapeAreaOptions(FACE_SHAPE_AREA shapeArea, int areaIntensity) : shapeArea(shapeArea), shapeIntensity(areaIntensity) {} + + FaceShapeAreaOptions() : shapeArea(FACE_SHAPE_AREA_NONE), shapeIntensity(0) {} +}; + +/** Face shape beauty options. This structure defines options for facial adjustments of different facial styles. + * + * @technical preview + */ +struct FaceShapeBeautyOptions { + /** The face shape style. + */ + enum FACE_SHAPE_BEAUTY_STYLE { + /** (Default) Female face shape style. */ + FACE_SHAPE_BEAUTY_STYLE_FEMALE = 0, + /** Male face shape style. */ + FACE_SHAPE_BEAUTY_STYLE_MALE = 1, + }; + + /** The face shape style, See #FACE_SHAPE_BEAUTY_STYLE. + */ + FACE_SHAPE_BEAUTY_STYLE shapeStyle; + + /** The intensity of the pinching effect applied to the specified facial style. The value ranges from 0 (original) to 100. The default value is 0. The greater the value, the stronger the intensity applied to face pinching. + */ + int styleIntensity; + + FaceShapeBeautyOptions(FACE_SHAPE_BEAUTY_STYLE shapeStyle, int styleIntensity) : shapeStyle(shapeStyle), styleIntensity(styleIntensity) {} + + FaceShapeBeautyOptions() : shapeStyle(FACE_SHAPE_BEAUTY_STYLE_FEMALE), styleIntensity(50) {} +}; + struct LowlightEnhanceOptions { /** * The low-light enhancement mode. @@ -4686,6 +4973,7 @@ enum VOICE_BEAUTIFIER_PRESET { * - `ROOM_ACOUSTICS_PHONOGRAPH` * - `ROOM_ACOUSTICS_SPACIAL` * - `ROOM_ACOUSTICS_ETHEREAL` + * - `ROOM_ACOUSTICS_CHORUS` * - `VOICE_CHANGER_EFFECT_UNCLE` * - `VOICE_CHANGER_EFFECT_OLDMAN` * - `VOICE_CHANGER_EFFECT_BOY` @@ -4747,6 +5035,14 @@ enum AUDIO_EFFECT_PRESET { * setting this enumerator. */ ROOM_ACOUSTICS_VIRTUAL_SURROUND_SOUND = 0x02010900, + /** The voice effect for chorus. + * + * @note: To achieve better audio effect quality, Agora recommends calling \ref + * IRtcEngine::setAudioProfile "setAudioProfile" and setting the `profile` parameter to + * `AUDIO_PROFILE_MUSIC_HIGH_QUALITY(4)` or `AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO(5)` before + * setting this enumerator. + */ + ROOM_ACOUSTICS_CHORUS = 0x02010D00, /** A middle-aged man's voice. * * @note @@ -4879,6 +5175,41 @@ enum HEADPHONE_EQUALIZER_PRESET { HEADPHONE_EQUALIZER_INEAR = 0x04000002 }; +/** The options for SDK voice AI tuner. + */ +enum VOICE_AI_TUNER_TYPE { + /** Uncle, deep and magnetic male voice. + */ + VOICE_AI_TUNER_MATURE_MALE, + /** Fresh male, refreshing and sweet male voice. + */ + VOICE_AI_TUNER_FRESH_MALE, + /** Big sister, deep and charming female voice. + */ + VOICE_AI_TUNER_ELEGANT_FEMALE, + /** Lolita, high-pitched and cute female voice. + */ + VOICE_AI_TUNER_SWEET_FEMALE, + /** Warm man singing, warm and melodic male voice that is suitable for male lyrical songs. + */ + VOICE_AI_TUNER_WARM_MALE_SINGING, + /** Gentle female singing, soft and delicate female voice that is suitable for female lyrical songs. + */ + VOICE_AI_TUNER_GENTLE_FEMALE_SINGING, + /** Smoky uncle singing, unique husky male voice that is suitable for rock or blues songs. + */ + VOICE_AI_TUNER_HUSKY_MALE_SINGING, + /** Warm big sister singing, warm and mature female voice that is suitable for emotionally powerful songs. + */ + VOICE_AI_TUNER_WARM_ELEGANT_FEMALE_SINGING, + /** Forceful male singing, strong and powerful male voice that is suitable for passionate songs. + */ + VOICE_AI_TUNER_POWERFUL_MALE_SINGING, + /** Dreamy female singing, dreamlike and soft female voice that is suitable for airy and dream-like songs. + */ + VOICE_AI_TUNER_DREAMY_FEMALE_SINGING, +}; + /** * Screen sharing configurations. */ @@ -5191,6 +5522,10 @@ enum AREA_CODE { AREA_CODE_GLOB = (0xFFFFFFFF) }; +/** + Extra region code + @technical preview +*/ enum AREA_CODE_EX { /** * Oceania @@ -5216,6 +5551,10 @@ enum AREA_CODE_EX { * United States */ AREA_CODE_US = 0x00000800, + /** + * Russia + */ + AREA_CODE_RU = 0x00001000, /** * The global area (except China) */ @@ -5534,10 +5873,13 @@ struct EncryptionConfig { * In this case, ensure that this parameter is not 0. */ uint8_t encryptionKdfSalt[32]; + + bool datastreamEncryptionEnabled; EncryptionConfig() : encryptionMode(AES_128_GCM2), - encryptionKey(OPTIONAL_NULLPTR) + encryptionKey(OPTIONAL_NULLPTR), + datastreamEncryptionEnabled(false) { memset(encryptionKdfSalt, 0, sizeof(encryptionKdfSalt)); } @@ -5577,13 +5919,21 @@ enum ENCRYPTION_ERROR_TYPE { */ ENCRYPTION_ERROR_INTERNAL_FAILURE = 0, /** - * 1: Decryption errors. Ensure that the receiver and the sender use the same encryption mode and key. + * 1: MediaStream decryption errors. Ensure that the receiver and the sender use the same encryption mode and key. */ ENCRYPTION_ERROR_DECRYPTION_FAILURE = 1, /** - * 2: Encryption errors. + * 2: MediaStream encryption errors. */ ENCRYPTION_ERROR_ENCRYPTION_FAILURE = 2, + /** + * 3: DataStream decryption errors. Ensure that the receiver and the sender use the same encryption mode and key. + */ + ENCRYPTION_ERROR_DATASTREAM_DECRYPTION_FAILURE = 3, + /** + * 4: DataStream encryption errors. + */ + ENCRYPTION_ERROR_DATASTREAM_ENCRYPTION_FAILURE = 4, }; enum UPLOAD_ERROR_REASON @@ -5625,8 +5975,8 @@ enum STREAM_SUBSCRIBE_STATE { * - Calls `enableLocalAudio(false)` or `enableLocalVideo(false)` to disable the local audio or video capture. * - The role of the remote user is audience. * - The local user calls the following methods to stop receiving remote streams: - * - Calls `muteRemoteAudioStream(true)`, `muteAllRemoteAudioStreams(true)` or `setDefaultMuteAllRemoteAudioStreams(true)` to stop receiving the remote audio streams. - * - Calls `muteRemoteVideoStream(true)`, `muteAllRemoteVideoStreams(true)` or `setDefaultMuteAllRemoteVideoStreams(true)` to stop receiving the remote video streams. + * - Calls `muteRemoteAudioStream(true)`, `muteAllRemoteAudioStreams(true)` to stop receiving the remote audio streams. + * - Calls `muteRemoteVideoStream(true)`, `muteAllRemoteVideoStreams(true)` to stop receiving the remote video streams. */ SUB_STATE_NO_SUBSCRIBED = 1, /** @@ -5717,7 +6067,12 @@ enum EAR_MONITORING_FILTER_TYPE { /** * 4: Enable noise suppression to the in-ear monitor. */ - EAR_MONITORING_FILTER_NOISE_SUPPRESSION = (1<<2) + EAR_MONITORING_FILTER_NOISE_SUPPRESSION = (1<<2), + /** + * 32768: Enable audio filters by reuse post-processing filter to the in-ear monitor. + * This bit is intended to be used in exclusive mode, which means, if this bit is set, all other bits will be disregarded. + */ + EAR_MONITORING_FILTER_REUSE_POST_PROCESSING_FILTER = (1<<15), }; /** @@ -5750,7 +6105,7 @@ enum THREAD_PRIORITY_TYPE { CRITICAL = 5, }; -#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) +#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) || defined(__OHOS__) /** * The video configuration for the shared screen stream. diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraExtensionProviderEntry.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraExtensionProviderEntry.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraExtensionVersion.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraExtensionVersion.h old mode 100755 new mode 100644 index 988e5ecc8..da4d563a3 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraExtensionVersion.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraExtensionVersion.h @@ -58,6 +58,7 @@ class IExtensionProvider; class IExtensionProviderV2; class IExtensionProviderV3; class IAudioFilter; +class IAudioFilterV2; class IExtensionVideoFilter; class IScreenCaptureSource; @@ -85,6 +86,13 @@ struct ExtensionInterfaceVersion { } }; +template <> +struct ExtensionInterfaceVersion { + static ExtensionVersion Version() { + return BUMP_MAJOR_VERSION(ExtensionInterfaceVersion::Version()); + } +}; + template <> struct ExtensionInterfaceVersion { static ExtensionVersion Version() { diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraMediaBase.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraMediaBase.h old mode 100755 new mode 100644 index d56337745..8120acb3f --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraMediaBase.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraMediaBase.h @@ -35,6 +35,32 @@ static const unsigned int DEFAULT_CONNECTION_ID = 0; static const unsigned int DUMMY_CONNECTION_ID = (std::numeric_limits::max)(); struct EncodedVideoFrameInfo; +/** +* The definition of extension context types. +**/ +struct ExtensionContext { + /** + * Whether the uid is valid. + * - true: The uid is valid. + * - false: The uid is invalid. + */ + bool isValid; + /** + * The ID of the user. + * A uid of 0 indicates the local user, and a uid greater than 0 represents a remote user. + */ + uid_t uid; + /** + * The provider name of the current extension. + */ + const char *providerName; + /** + * The extension name of the current extension. + */ + const char *extensionName; + ExtensionContext():isValid(false), uid(0), providerName(NULL), extensionName(NULL) {} +}; + /** * Video source types definition. @@ -88,6 +114,9 @@ enum VIDEO_SOURCE_TYPE { /** Video for fourth screen sharing. */ VIDEO_SOURCE_SCREEN_FOURTH = 14, + /** Video for voice drive. + */ + VIDEO_SOURCE_SPEECH_DRIVEN = 15, VIDEO_SOURCE_UNKNOWN = 100 }; @@ -242,6 +271,10 @@ enum MEDIA_SOURCE_TYPE { * 12: Video for transcoded. */ TRANSCODED_VIDEO_SOURCE = 12, + /** + * 13: Video for voice drive. + */ + SPEECH_DRIVEN_VIDEO_SOURCE = 13, /** * 100: Internal Usage only. */ @@ -395,24 +428,31 @@ struct AudioPcmFrame { rtc::BYTES_PER_SAMPLE bytes_per_sample; /** The audio frame data. */ int16_t data_[kMaxDataSizeSamples]; + + /** + * @technical preview + * data_[kMaxDataSizeSamples] is real stereo data + */ + bool is_stereo_; AudioPcmFrame& operator=(const AudioPcmFrame& src) { - if(this == &src) { + if (this == &src) { return *this; } - this->capture_timestamp = src.capture_timestamp; - this->samples_per_channel_ = src.samples_per_channel_; - this->sample_rate_hz_ = src.sample_rate_hz_; - this->bytes_per_sample = src.bytes_per_sample; - this->num_channels_ = src.num_channels_; + capture_timestamp = src.capture_timestamp; + samples_per_channel_ = src.samples_per_channel_; + sample_rate_hz_ = src.sample_rate_hz_; + bytes_per_sample = src.bytes_per_sample; + num_channels_ = src.num_channels_; + is_stereo_ = src.is_stereo_; size_t length = src.samples_per_channel_ * src.num_channels_; if (length > kMaxDataSizeSamples) { length = kMaxDataSizeSamples; } - memcpy(this->data_, src.data_, length * sizeof(int16_t)); + memcpy(data_, src.data_, length * sizeof(int16_t)); return *this; } @@ -422,7 +462,8 @@ struct AudioPcmFrame { samples_per_channel_(0), sample_rate_hz_(0), num_channels_(0), - bytes_per_sample(rtc::TWO_BYTES_PER_SAMPLE) { + bytes_per_sample(rtc::TWO_BYTES_PER_SAMPLE), + is_stereo_(false) { memset(data_, 0, sizeof(data_)); } @@ -431,7 +472,8 @@ struct AudioPcmFrame { samples_per_channel_(src.samples_per_channel_), sample_rate_hz_(src.sample_rate_hz_), num_channels_(src.num_channels_), - bytes_per_sample(src.bytes_per_sample) { + bytes_per_sample(src.bytes_per_sample), + is_stereo_(src.is_stereo_) { size_t length = src.samples_per_channel_ * src.num_channels_; if (length > kMaxDataSizeSamples) { length = kMaxDataSizeSamples; @@ -502,6 +544,10 @@ enum VIDEO_PIXEL_FORMAT { 14: pixel format for iOS CVPixelBuffer BGRA */ VIDEO_CVPIXEL_BGRA = 14, + /** + 15: pixel format for iOS CVPixelBuffer P010(10bit NV12) + */ + VIDEO_CVPIXEL_P010 = 15, /** * 16: I422. */ @@ -510,6 +556,11 @@ enum VIDEO_PIXEL_FORMAT { * 17: ID3D11Texture2D, only support DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_TYPELESS, DXGI_FORMAT_NV12 texture format */ VIDEO_TEXTURE_ID3D11TEXTURE2D = 17, + /** + * 18: I010. 10bit I420 data. + * @technical preview + */ + VIDEO_PIXEL_I010 = 18, }; /** @@ -565,6 +616,191 @@ class IVideoFrameMetaInfo { virtual const char* getMetaInfoStr(META_INFO_KEY key) const = 0; }; +struct ColorSpace { + enum PrimaryID { + // The indices are equal to the values specified in T-REC H.273 Table 2. + PRIMARYID_BT709 = 1, + PRIMARYID_UNSPECIFIED = 2, + PRIMARYID_BT470M = 4, + PRIMARYID_BT470BG = 5, + PRIMARYID_SMPTE170M = 6, // Identical to BT601 + PRIMARYID_SMPTE240M = 7, + PRIMARYID_FILM = 8, + PRIMARYID_BT2020 = 9, + PRIMARYID_SMPTEST428 = 10, + PRIMARYID_SMPTEST431 = 11, + PRIMARYID_SMPTEST432 = 12, + PRIMARYID_JEDECP22 = 22, // Identical to EBU3213-E + }; + + enum RangeID { + // The indices are equal to the values specified at + // https://www.webmproject.org/docs/container/#colour for the element Range. + RANGEID_INVALID = 0, + // Limited Rec. 709 color range with RGB values ranging from 16 to 235. + RANGEID_LIMITED = 1, + // Full RGB color range with RGB valees from 0 to 255. + RANGEID_FULL = 2, + // Range is defined by MatrixCoefficients/TransferCharacteristics. + RANGEID_DERIVED = 3, + }; + + enum MatrixID { + // The indices are equal to the values specified in T-REC H.273 Table 4. + MATRIXID_RGB = 0, + MATRIXID_BT709 = 1, + MATRIXID_UNSPECIFIED = 2, + MATRIXID_FCC = 4, + MATRIXID_BT470BG = 5, + MATRIXID_SMPTE170M = 6, + MATRIXID_SMPTE240M = 7, + MATRIXID_YCOCG = 8, + MATRIXID_BT2020_NCL = 9, + MATRIXID_BT2020_CL = 10, + MATRIXID_SMPTE2085 = 11, + MATRIXID_CDNCLS = 12, + MATRIXID_CDCLS = 13, + MATRIXID_BT2100_ICTCP = 14, + }; + + enum TransferID { + // The indices are equal to the values specified in T-REC H.273 Table 3. + TRANSFERID_BT709 = 1, + TRANSFERID_UNSPECIFIED = 2, + TRANSFERID_GAMMA22 = 4, + TRANSFERID_GAMMA28 = 5, + TRANSFERID_SMPTE170M = 6, + TRANSFERID_SMPTE240M = 7, + TRANSFERID_LINEAR = 8, + TRANSFERID_LOG = 9, + TRANSFERID_LOG_SQRT = 10, + TRANSFERID_IEC61966_2_4 = 11, + TRANSFERID_BT1361_ECG = 12, + TRANSFERID_IEC61966_2_1 = 13, + TRANSFERID_BT2020_10 = 14, + TRANSFERID_BT2020_12 = 15, + TRANSFERID_SMPTEST2084 = 16, + TRANSFERID_SMPTEST428 = 17, + TRANSFERID_ARIB_STD_B67 = 18, + }; + + PrimaryID primaries; + TransferID transfer; + MatrixID matrix; + RangeID range; + + ColorSpace() + : primaries(PRIMARYID_UNSPECIFIED), transfer(TRANSFERID_UNSPECIFIED), + matrix(MATRIXID_UNSPECIFIED), range(RANGEID_INVALID) {} + + bool validate() const { + return primaries != PRIMARYID_UNSPECIFIED || transfer != TRANSFERID_UNSPECIFIED || + matrix != MATRIXID_UNSPECIFIED || + range != RANGEID_INVALID; + } +}; + +/** + * The definition of the Hdr10MetadataInfo struct. + */ +struct Hdr10MetadataInfo { + /** + * The x coordinates of the red value in the CIE1931 color space. The values need to normalized to 50,000. + */ + uint16_t redPrimaryX; + /** + * The y coordinates of the red value in the CIE1931 color space. The values need to normalized to 50,000. + */ + uint16_t redPrimaryY; + /** + * The x coordinates of the green value in the CIE1931 color space. The values need to normalized to 50,000. + */ + uint16_t greenPrimaryX; + /** + * The y coordinates of the green value in the CIE1931 color space. The values need to normalized to 50,000. + */ + uint16_t greenPrimaryY; + /** + * The x coordinates of the blue value in the CIE1931 color space. The values need to normalized to 50,000. + */ + uint16_t bluePrimaryX; + /** + * The y coordinates of the blue value in the CIE1931 color space. The values need to normalized to 50,000. + */ + uint16_t bluePrimaryY; + /** + * The x coordinates of the white point in the CIE1931 color space.The values need to normalized to 50,000. + */ + uint16_t whitePointX; + /** + * The y coordinates of the white point in the CIE1931 color space.The values need to normalized to 50,000. + */ + uint16_t whitePointY; + /** + * The maximum number of nits of the display used to master the content. The values need to normalized to 10,000. + */ + unsigned int maxMasteringLuminance; + /** + * The minimum number of nits of the display used to master the content. The values need to normalized to 10,000. + */ + unsigned int minMasteringLuminance; + /** + * The maximum content light level (MaxCLL). This is the nit value corresponding to the brightest pixel used anywhere in the content. + */ + uint16_t maxContentLightLevel; + /** + * The maximum frame average light level (MaxFALL). This is the nit value corresponding to the average luminance of the frame which has the brightest average luminance anywhere in the content. + */ + uint16_t maxFrameAverageLightLevel; + + Hdr10MetadataInfo() + : redPrimaryX(0), + redPrimaryY(0), + greenPrimaryX(0), + greenPrimaryY(0), + bluePrimaryX(0), + bluePrimaryY(0), + whitePointX(0), + whitePointY(0), + maxMasteringLuminance(0), + minMasteringLuminance(0), + maxContentLightLevel(0), + maxFrameAverageLightLevel(0){} + + bool validate() const { + return maxContentLightLevel >= 0 && maxContentLightLevel <= 20000 && + maxFrameAverageLightLevel >= 0 && + maxFrameAverageLightLevel <= 20000; + } +}; + +/** + * The relative position between alphabuffer and the frame. + */ +enum ALPHA_STITCH_MODE { + /** + * 0: Normal frame without alphabuffer stitched + */ + NO_ALPHA_STITCH = 0, + /** + * 1: Alphabuffer is above the frame + */ + ALPHA_STITCH_UP = 1, + /** + * 2: Alphabuffer is below the frame + */ + ALPHA_STITCH_BELOW = 2, + /** + * 3: Alphabuffer is on the left of frame + */ + ALPHA_STITCH_LEFT = 3, + /** + * 4: Alphabuffer is on the right of frame + */ + ALPHA_STITCH_RIGHT = 4, +}; + + /** * The definition of the ExternalVideoFrame struct. */ @@ -584,11 +820,14 @@ struct ExternalVideoFrame { eglContext(NULL), eglType(EGL_CONTEXT10), textureId(0), - metadata_buffer(NULL), - metadata_size(0), + fenceObject(0), + metadataBuffer(NULL), + metadataSize(0), alphaBuffer(NULL), - d3d11_texture_2d(NULL), - texture_slice_index(0){} + fillAlphaBuffer(false), + alphaStitchMode(NO_ALPHA_STITCH), + d3d11Texture2d(NULL), + textureSliceIndex(0){} /** * The EGL context type. @@ -690,6 +929,11 @@ struct ExternalVideoFrame { * [Texture related parameter] Incoming 4 × 4 transformational matrix. The typical value is a unit matrix. */ int textureId; + /** + * [Texture related parameter] The fence object related to the textureId parameter, indicating the synchronization status of the video data in Texture format. + * The default value is 0 + */ + long long fenceObject; /** * [Texture related parameter] Incoming 4 × 4 transformational matrix. The typical value is a unit matrix. */ @@ -698,28 +942,53 @@ struct ExternalVideoFrame { * [Texture related parameter] The MetaData buffer. * The default value is NULL */ - uint8_t* metadata_buffer; + uint8_t* metadataBuffer; /** * [Texture related parameter] The MetaData size. * The default value is 0 */ - int metadata_size; + int metadataSize; /** - * Indicates the output data of the portrait segmentation algorithm, which is consistent with the size of the video frame. - * The value range of each pixel is [0,255], where 0 represents the background; 255 represents the foreground (portrait). - * The default value is NULL + * Indicates the alpha channel of current frame, which is consistent with the dimension of the video frame. + * The value range of each pixel is [0,255], where 0 represents the background; 255 represents the foreground. + * The default value is NULL. */ uint8_t* alphaBuffer; + /** + * [For bgra or rgba only] Extract alphaBuffer from bgra or rgba data. Set it true if you do not explicitly specify the alphabuffer. + * The default value is false + */ + bool fillAlphaBuffer; + /** + * The relative position between alphabuffer and the frame. + * 0: Normal frame; + * 1: Alphabuffer is above the frame; + * 2: Alphabuffer is below the frame; + * 3: Alphabuffer is on the left of frame; + * 4: Alphabuffer is on the right of frame; + * The default value is 0. + */ + ALPHA_STITCH_MODE alphaStitchMode; /** * [For Windows only] The pointer of ID3D11Texture2D used by the video frame. */ - void *d3d11_texture_2d; + void *d3d11Texture2d; /** * [For Windows only] The index of ID3D11Texture2D array used by the video frame. */ - int texture_slice_index; + int textureSliceIndex; + + /** + * metadata info used for hdr video data + */ + Hdr10MetadataInfo hdr10MetadataInfo; + + /** + * The ColorSpace of the video frame. + */ + ColorSpace colorSpace; }; /** @@ -745,6 +1014,7 @@ struct VideoFrame { textureId(0), d3d11Texture2d(NULL), alphaBuffer(NULL), + alphaStitchMode(NO_ALPHA_STITCH), pixelBuffer(NULL), metaInfo(NULL){ memset(matrix, 0, sizeof(matrix)); @@ -827,11 +1097,21 @@ struct VideoFrame { */ float matrix[16]; /** - * Indicates the output data of the portrait segmentation algorithm, which is consistent with the size of the video frame. - * The value range of each pixel is [0,255], where 0 represents the background; 255 represents the foreground (portrait). - * The default value is NULL + * Indicates the alpha channel of current frame, which is consistent with the dimension of the video frame. + * The value range of each pixel is [0,255], where 0 represents the background; 255 represents the foreground. + * The default value is NULL. */ uint8_t* alphaBuffer; + /** + * The relative position between alphabuffer and the frame. + * 0: Normal frame; + * 1: Alphabuffer is above the frame; + * 2: Alphabuffer is below the frame; + * 3: Alphabuffer is on the left of frame; + * 4: Alphabuffer is on the right of frame; + * The default value is 0. + */ + ALPHA_STITCH_MODE alphaStitchMode; /** *The type of CVPixelBufferRef, for iOS and macOS only. */ @@ -840,6 +1120,16 @@ struct VideoFrame { * The pointer to IVideoFrameMetaInfo, which is the interface to get metainfo contents from VideoFrame. */ IVideoFrameMetaInfo* metaInfo; + + /** + * metadata info used for hdr video data + */ + Hdr10MetadataInfo hdr10MetadataInfo; + + /** + * The ColorSpace of the video frame + */ + ColorSpace colorSpace; }; /** @@ -981,6 +1271,10 @@ class IAudioFrameObserverBase { * The number of the audio track. */ int audioTrackNumber; + /** + * RTP timestamp of the first sample in the audio frame + */ + uint32_t rtpTimestamp; AudioFrame() : type(FRAME_TYPE_PCM16), samplesPerChannel(0), @@ -991,7 +1285,8 @@ class IAudioFrameObserverBase { renderTimeMs(0), avsync_type(0), presentationMs(0), - audioTrackNumber(0) {} + audioTrackNumber(0), + rtpTimestamp(0) {} }; enum AUDIO_FRAME_POSITION { @@ -1609,6 +1904,21 @@ struct MediaRecorderConfiguration { MediaRecorderConfiguration() : storagePath(NULL), containerFormat(FORMAT_MP4), streamType(STREAM_TYPE_BOTH), maxDurationMs(120000), recorderInfoUpdateInterval(0) {} MediaRecorderConfiguration(const char* path, MediaRecorderContainerFormat format, MediaRecorderStreamType type, int duration, int interval) : storagePath(path), containerFormat(format), streamType(type), maxDurationMs(duration), recorderInfoUpdateInterval(interval) {} }; + +class IFaceInfoObserver { +public: + /** + * Occurs when the face info is received. + * @param outFaceInfo The output face info. + * @return + * - true: The face info is valid. + * - false: The face info is invalid. + */ + virtual bool onFaceInfo(const char* outFaceInfo) = 0; + + virtual ~IFaceInfoObserver() {} +}; + /** * Information for the recording file. * diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraMediaPlayerTypes.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraMediaPlayerTypes.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraOptional.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraOptional.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraRefCountedObject.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraRefCountedObject.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraRefPtr.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraRefPtr.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraFileUploader.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraFileUploader.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraH265Transcoder.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraH265Transcoder.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraLog.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraLog.h old mode 100755 new mode 100644 index 2fae3aa13..20b6416ef --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraLog.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraLog.h @@ -37,6 +37,7 @@ OPTIONAL_ENUM_CLASS LOG_LEVEL { LOG_LEVEL_ERROR = 0x0004, LOG_LEVEL_FATAL = 0x0008, LOG_LEVEL_API_CALL = 0x0010, + LOG_LEVEL_DEBUG = 0x0020, }; /* diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaComponentFactory.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaComponentFactory.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaEngine.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaEngine.h old mode 100755 new mode 100644 index e57404a22..b3b92e9e4 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaEngine.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaEngine.h @@ -72,6 +72,21 @@ class IMediaEngine { * - < 0: Failure. */ virtual int registerVideoEncodedFrameObserver(IVideoEncodedFrameObserver* observer) = 0; + + /** + * Registers a face info observer object. + * + * @note + * Ensure that you call this method before \ref IRtcEngine::joinChannel "joinChannel". + * + * @param observer A pointer to the face info observer object: IFaceInfoObserver. + * + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int registerFaceInfoObserver(IFaceInfoObserver* observer) = 0; + /** * Pushes the external audio data to the app. * diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaPlayer.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaPlayer.h old mode 100755 new mode 100644 index bd3c7597c..25f48a4a2 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaPlayer.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaPlayer.h @@ -49,17 +49,6 @@ class IMediaPlayer : public RefCountInterface { */ virtual int open(const char* url, int64_t startPos) = 0; - /** - * @deprecated - * @brief Open media file or stream with custom soucrce. - * @param startPos Set the starting position for playback, in seconds - * @param observer dataProvider object - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int openWithCustomSource(int64_t startPos, media::base::IMediaPlayerCustomDataProvider* provider) __deprecated = 0; - /** * @brief Open a media file with a media file source. * @param source Media file source that you want to play, see `MediaSource` diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaPlayerSource.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaPlayerSource.h old mode 100755 new mode 100644 index 00be02233..99da405bc --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaPlayerSource.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaPlayerSource.h @@ -42,17 +42,6 @@ class IMediaPlayerSource : public RefCountInterface { * - < 0: Failure. */ virtual int open(const char* url, int64_t startPos) = 0; - - /** - * @deprecated - * @brief Open media file or stream with custom soucrce. - * @param startPos Set the starting position for playback, in seconds - * @param observer dataProvider object - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int openWithCustomSource(int64_t startPos, media::base::IMediaPlayerCustomDataProvider* provider) __deprecated = 0; /** * Opens a media file with a media file source. diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaRecorder.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaRecorder.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaRelayService.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaRelayService.h old mode 100755 new mode 100644 index c646eeaf3..7e5a18495 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaRelayService.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaRelayService.h @@ -41,7 +41,7 @@ class IMediaRelayService : public RefCountInterface { * - -2(ERR_INVALID_ARGUMENT): The argument is invalid. * - -5(ERR_REFUSED): The request is rejected. */ - virtual int stopChannelMediaRelay() = 0; + virtual int stopChannelMediaRelay(aosl_ref_t ares = AOSL_REF_INVALID) = 0; /** pause the channels for media stream relay. * @return @@ -51,7 +51,7 @@ class IMediaRelayService : public RefCountInterface { * - -2(ERR_INVALID_ARGUMENT): The argument is invalid. * - -5(ERR_REFUSED): The request is rejected. */ - virtual int pauseAllChannelMediaRelay() = 0; + virtual int pauseAllChannelMediaRelay(aosl_ref_t ares = AOSL_REF_INVALID) = 0; /** resume the channels for media stream relay. * @return @@ -61,7 +61,7 @@ class IMediaRelayService : public RefCountInterface { * - -2(ERR_INVALID_ARGUMENT): The argument is invalid. * - -5(ERR_REFUSED): The request is rejected. */ - virtual int resumeAllChannelMediaRelay() = 0; + virtual int resumeAllChannelMediaRelay(aosl_ref_t ares = AOSL_REF_INVALID) = 0; virtual void registerEventHandler(IMediaRelayObserver* eventObserver, void(*safeDeleter)(IMediaRelayObserver*) = NULL) = 0; virtual void unregisterEventHandler(IMediaRelayObserver* eventObserver) = 0; diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaStreamingSource.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaStreamingSource.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraParameter.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraParameter.h old mode 100755 new mode 100644 index 3114a11d0..f50afe9b5 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraParameter.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraParameter.h @@ -39,8 +39,7 @@ * set the video encoder mode (hardware or software) */ #define KEY_RTC_VIDEO_ENABLED_HW_ENCODER "engine.video.enable_hw_encoder" -#define KEY_RTC_VIDEO_HARDWARE_ENCODEING "che.hardware_encoding" -#define KEY_RTC_VIDEO_H264_HWENC "che.video.h264.hwenc" +#define KEY_RTC_VIDEO_HARDWARE_ENCODEING "che.hardware_encoding" // deprecated, please use engine.video.enable_hw_encoder /** * set the hardware video encoder provider (nv for nvidia or qsv for intel) */ @@ -50,7 +49,7 @@ * set the video decoder mode (hardware or software) */ #define KEY_RTC_VIDEO_ENABLED_HW_DECODER "engine.video.enable_hw_decoder" -#define KEY_RTC_VIDEO_HARDWARE_DECODING "che.hardware_decoding" +#define KEY_RTC_VIDEO_HARDWARE_DECODING "che.hardware_decoding" // deprecated, please use engine.video.enable_hw_decoder /** * set the hardware video decoder provider (h264_cuvid(default) or h264_qsv) @@ -115,7 +114,6 @@ /** * set the video codec type, such as "H264", "JPEG" */ -#define KEY_RTC_VIDEO_CODEC_TYPE "engine.video.codec_type" #define KEY_RTC_VIDEO_MINOR_STREAM_CODEC_INDEX "engine.video.minor_stream_codec_index" #define KEY_RTC_VIDEO_CODEC_INDEX "che.video.videoCodecIndex" /** diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRhythmPlayer.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRhythmPlayer.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtcEngine.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtcEngine.h old mode 100755 new mode 100644 index 25763dc3e..b4746d898 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtcEngine.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtcEngine.h @@ -230,19 +230,30 @@ enum AUDIO_REVERB_TYPE { }; enum STREAM_FALLBACK_OPTIONS { - /** 0: No fallback operation for the stream when the network - condition is poor. The stream quality cannot be guaranteed. */ - + /** 0: No fallback operation to a lower resolution stream when the network + condition is poor. Fallback to Scalable Video Coding (e.g. SVC) + is still possible, but the resolution remains in high stream. + The stream quality cannot be guaranteed. */ STREAM_FALLBACK_OPTION_DISABLED = 0, - /** 1: (Default) Under poor network conditions, the SDK will send or receive + /** 1: (Default) Under poor network conditions, the receiver SDK will receive agora::rtc::VIDEO_STREAM_LOW. You can only set this option in RtcEngineParameters::setRemoteSubscribeFallbackOption. Nothing happens when you set this in RtcEngineParameters::setLocalPublishFallbackOption. */ STREAM_FALLBACK_OPTION_VIDEO_STREAM_LOW = 1, - /** 2: Under poor network conditions, the SDK may receive - agora::rtc::VIDEO_STREAM_LOW first, but if the network still does - not allow displaying the video, the SDK will send or receive audio only. */ + /** 2: Under poor network conditions, the SDK may receive agora::rtc::VIDEO_STREAM_LOW first, + then agora::rtc::VIDEO_STREAM_LAYER_1 to agora::rtc::VIDEO_STREAM_LAYER_6 if the related layer exists. + If the network still does not allow displaying the video, the SDK will receive audio only. */ STREAM_FALLBACK_OPTION_AUDIO_ONLY = 2, + /** 3~8: If the receiver SDK uses RtcEngineParameters::setRemoteSubscribeFallbackOption,it will receive + one of the streams from agora::rtc::VIDEO_STREAM_LAYER_1 to agora::rtc::VIDEO_STREAM_LAYER_6 + if the related layer exists when the network condition is poor. The lower bound of fallback depends on + the STREAM_FALLBACK_OPTION_VIDEO_STREAM_LAYER_X. */ + STREAM_FALLBACK_OPTION_VIDEO_STREAM_LAYER_1 = 3, + STREAM_FALLBACK_OPTION_VIDEO_STREAM_LAYER_2 = 4, + STREAM_FALLBACK_OPTION_VIDEO_STREAM_LAYER_3 = 5, + STREAM_FALLBACK_OPTION_VIDEO_STREAM_LAYER_4 = 6, + STREAM_FALLBACK_OPTION_VIDEO_STREAM_LAYER_5 = 7, + STREAM_FALLBACK_OPTION_VIDEO_STREAM_LAYER_6 = 8, }; enum PRIORITY_TYPE { @@ -341,6 +352,9 @@ struct LocalVideoStats * - hardware = 1. */ int hwEncoderAccelerating; + /** The dimensions of the simulcast streams's encoding frame. + */ + VideoDimensions simulcastDimensions[SimulcastConfig::STREAM_LAYER_COUNT_MAX]; }; /** @@ -443,6 +457,10 @@ struct RemoteAudioStats * The total number of audio bytes received (bytes), inluding the FEC bytes, represented by an aggregate value. */ unsigned int rxAudioBytes; + /** + * The end-to-end delay (ms) from the sender to the receiver. + */ + int e2eDelay; RemoteAudioStats() : uid(0), @@ -462,7 +480,8 @@ struct RemoteAudioStats publishDuration(0), qoeQuality(0), qualityChangedReason(0), - rxAudioBytes(0) {} + rxAudioBytes(0), + e2eDelay(0) {} }; /** @@ -497,6 +516,9 @@ struct RemoteVideoStats { * Bitrate (Kbps) received since the last count. */ int receivedBitrate; + /** The decoder input frame rate (fps) of the remote video. + */ + int decoderInputFrameRate; /** The decoder output frame rate (fps) of the remote video. */ int decoderOutputFrameRate; @@ -788,25 +810,36 @@ enum CLOUD_PROXY_TYPE { /** Camera capturer configuration.*/ struct CameraCapturerConfiguration { /** Camera direction settings (for Android/iOS only). See: #CAMERA_DIRECTION. */ -#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) || defined (__OHOS__) +#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) || defined(__OHOS__) /** * The camera direction. */ - CAMERA_DIRECTION cameraDirection; + Optional cameraDirection; + + /*- CAMERA_FOCAL_LENGTH_TYPE.CAMERA_FOCAL_LENGTH_DEFAULT: + For iOS, if iPhone/iPad has 3 or 2 back camera, it means combination of triple (wide + ultra wide + telephoto) camera + or dual wide(wide + ultra wide) camera.In this situation, you can apply for ultra wide len by set smaller zoom fator + and bigger zoom fator for telephoto len.Otherwise, it always means wide back/front camera. + + - CAMERA_FOCAL_LENGTH_TYPE.CAMERA_FOCAL_LENGTH_WIDE_ANGLE:wide camera + - CAMERA_FOCAL_LENGTH_TYPE.CAMERA_FOCAL_LENGTH_ULTRA_WIDE:ultra wide camera + - CAMERA_FOCAL_LENGTH_TYPE.CAMERA_FOCAL_LENGTH_TELEPHOTO:telephoto camera*/ + Optional cameraFocalLengthType; #else - /** For windows. The device ID of the playback device. The maximum length is #MAX_DEVICE_ID_LENGTH. */ - char deviceId[MAX_DEVICE_ID_LENGTH]; + /** For windows. The device ID of the playback device. */ + Optional deviceId; #endif - /** The video format. See VideoFormat. */ - VideoFormat format; - bool followEncodeDimensionRatio; - CameraCapturerConfiguration() : followEncodeDimensionRatio(true) { -#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) || defined (__OHOS__) - cameraDirection = CAMERA_REAR; -#else - memset(deviceId, 0, sizeof(deviceId)); + +#if defined(__ANDROID__) + /** + * The camera id. + */ + Optional cameraId; #endif - } + Optional followEncodeDimensionRatio; + /** The video format. See VideoFormat. */ + VideoFormat format; + CameraCapturerConfiguration() : format(VideoFormat(0, 0, 0)) {} }; /** * The configuration of the captured screen. @@ -1054,7 +1087,7 @@ struct ChannelMediaOptions { */ Optional publishMicrophoneTrack; - #if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) + #if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || defined(__OHOS__) /** * Whether to publish the video track of the screen capturer: * - `true`: Publish the video track of the screen capture. @@ -1140,6 +1173,12 @@ struct ChannelMediaOptions { * - `false`: (Default) Do not publish the local mixed track. */ Optional publishMixedAudioTrack; + /** + * Whether to publish the local lip sync video track. + * - `true`: Publish the video track of local lip sync video track. + * - `false`: (Default) Do not publish the local lip sync video track. + */ + Optional publishLipSyncTrack; /** * Whether to automatically subscribe to all remote audio streams when the user joins a channel: * - `true`: (Default) Subscribe to all remote audio streams. @@ -1234,6 +1273,12 @@ struct ChannelMediaOptions { */ Optional isAudioFilterable; + /** Provides the technical preview functionalities or special customizations by configuring the SDK with JSON options. + Pointer to the set parameters in a JSON string. + * @technical preview + */ + Optional parameters; + ChannelMediaOptions() {} ~ChannelMediaOptions() {} @@ -1245,7 +1290,7 @@ struct ChannelMediaOptions { SET_FROM(publishThirdCameraTrack); SET_FROM(publishFourthCameraTrack); SET_FROM(publishMicrophoneTrack); -#if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) +#if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || defined(__OHOS__) SET_FROM(publishScreenCaptureVideo); SET_FROM(publishScreenCaptureAudio); #else @@ -1256,6 +1301,7 @@ struct ChannelMediaOptions { #endif SET_FROM(publishTranscodedVideoTrack); SET_FROM(publishMixedAudioTrack); + SET_FROM(publishLipSyncTrack); SET_FROM(publishCustomAudioTrack); SET_FROM(publishCustomAudioTrackId); SET_FROM(publishCustomVideoTrack); @@ -1278,6 +1324,7 @@ struct ChannelMediaOptions { SET_FROM(customVideoTrackId); SET_FROM(isAudioFilterable); SET_FROM(isInteractiveAudience); + SET_FROM(parameters); #undef SET_FROM } @@ -1292,7 +1339,7 @@ struct ChannelMediaOptions { ADD_COMPARE(publishThirdCameraTrack); ADD_COMPARE(publishFourthCameraTrack); ADD_COMPARE(publishMicrophoneTrack); -#if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) +#if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || defined(__OHOS__) ADD_COMPARE(publishScreenCaptureVideo); ADD_COMPARE(publishScreenCaptureAudio); #else @@ -1303,6 +1350,7 @@ struct ChannelMediaOptions { #endif ADD_COMPARE(publishTranscodedVideoTrack); ADD_COMPARE(publishMixedAudioTrack); + ADD_COMPARE(publishLipSyncTrack); ADD_COMPARE(publishCustomAudioTrack); ADD_COMPARE(publishCustomAudioTrackId); ADD_COMPARE(publishCustomVideoTrack); @@ -1325,6 +1373,7 @@ struct ChannelMediaOptions { ADD_COMPARE(customVideoTrackId); ADD_COMPARE(isAudioFilterable); ADD_COMPARE(isInteractiveAudience); + ADD_COMPARE(parameters); END_COMPARE(); #undef BEGIN_COMPARE @@ -1342,7 +1391,7 @@ struct ChannelMediaOptions { REPLACE_BY(publishThirdCameraTrack); REPLACE_BY(publishFourthCameraTrack); REPLACE_BY(publishMicrophoneTrack); -#if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) +#if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || defined(__OHOS__) REPLACE_BY(publishScreenCaptureVideo); REPLACE_BY(publishScreenCaptureAudio); #else @@ -1353,6 +1402,7 @@ struct ChannelMediaOptions { #endif REPLACE_BY(publishTranscodedVideoTrack); REPLACE_BY(publishMixedAudioTrack); + REPLACE_BY(publishLipSyncTrack); REPLACE_BY(publishCustomAudioTrack); REPLACE_BY(publishCustomAudioTrackId); REPLACE_BY(publishCustomVideoTrack); @@ -1375,6 +1425,7 @@ struct ChannelMediaOptions { REPLACE_BY(customVideoTrackId); REPLACE_BY(isAudioFilterable); REPLACE_BY(isInteractiveAudience); + REPLACE_BY(parameters); #undef REPLACE_BY } return *this; @@ -2069,7 +2120,7 @@ class IRtcEngineEventHandler { (void)width; (void)height; } -#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) || defined (__OHOS__) +#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) || defined(__OHOS__) /** * Reports the face detection result of the local user. * @@ -2826,19 +2877,31 @@ class IRtcEngineEventHandler { (void)layoutlist; } + /** + * Occurs when the SDK receives audio metadata. + * @since v4.3.1 + * @param uid ID of the remote user. + * @param metadata The pointer of metadata + * @param length Size of metadata + * @technical preview + */ + virtual void onAudioMetadataReceived(uid_t uid, const char* metadata, size_t length) { + (void)uid; + (void)metadata; + (void)length; + } + /** * The event callback of the extension. * * To listen for events while the extension is running, you need to register this callback. * - * @param provider The name of the extension provider. - * @param extension The name of the extension. + * @param context The context of the extension. * @param key The key of the extension. * @param value The value of the extension key. */ - virtual void onExtensionEvent(const char* provider, const char* extension, const char* key, const char* value) { - (void)provider; - (void)extension; + virtual void onExtensionEventWithContext(const ExtensionContext &context, const char* key, const char* value) { + (void)context; (void)key; (void)value; } @@ -2846,43 +2909,37 @@ class IRtcEngineEventHandler { /** * Occurs when the extension is enabled. * - * After a successful call of `enableExtension(true)`, the extension triggers this callback. + * After a successful creation of filter , the extension triggers this callback. * - * @param provider The name of the extension provider. - * @param extension The name of the extension. + * @param context The context of the extension. */ - virtual void onExtensionStarted(const char* provider, const char* extension) { - (void)provider; - (void)extension; + virtual void onExtensionStartedWithContext(const ExtensionContext &context) { + (void)context; } /** * Occurs when the extension is disabled. * - * After a successful call of `enableExtension(false)`, the extension triggers this callback. + * After a successful destroy filter, the extension triggers this callback. * - * @param provider The name of the extension provider. - * @param extension The name of the extension. + * @param context The context of the extension. */ - virtual void onExtensionStopped(const char* provider, const char* extension) { - (void)provider; - (void)extension; + virtual void onExtensionStoppedWithContext(const ExtensionContext &context) { + (void)context; } /** * Occurs when the extension runs incorrectly. * - * When calling `enableExtension(true)` fails or the extension runs in error, the extension triggers + * When the extension runs in error, the extension triggers * this callback and reports the error code and reason. * - * @param provider The name of the extension provider. - * @param extension The name of the extension. + * @param context The context of the extension. * @param error The error code. For details, see the extension documentation provided by the extension provider. * @param message The error message. For details, see the extension documentation provided by the extension provider. */ - virtual void onExtensionError(const char* provider, const char* extension, int error, const char* message) { - (void)provider; - (void)extension; + virtual void onExtensionErrorWithContext(const ExtensionContext &context, int error, const char* message) { + (void)context; (void)error; (void)message; } @@ -3185,23 +3242,26 @@ class IMetadataObserver { */ struct Metadata { - /** The User ID that sent the metadata. - * - For the receiver: The user ID of the user who sent the `metadata`. - * - For the sender: Ignore this value. - */ - unsigned int uid; - /** The buffer size of the sent or received `metadata`. - */ - unsigned int size; - /** The buffer address of the sent or received `metadata`. - */ - unsigned char* buffer; - /** The timestamp (ms) of the `metadata`. - * - */ - long long timeStampMs; - - Metadata() : uid(0), size(0), buffer(NULL), timeStampMs(0) {} + /** The channel ID of the `metadata`. + */ + const char* channelId; + /** The User ID that sent the metadata. + * - For the receiver: The user ID of the user who sent the `metadata`. + * - For the sender: Ignore this value. + */ + unsigned int uid; + /** The buffer size of the sent or received `metadata`. + */ + unsigned int size; + /** The buffer address of the sent or received `metadata`. + */ + unsigned char *buffer; + /** The NTP timestamp (ms) when the metadata is sent. + * @note If the receiver is audience, the receiver cannot get the NTP timestamp (ms). + */ + long long timeStampMs; + + Metadata() : channelId(NULL), uid(0), size(0), buffer(NULL), timeStampMs(0) {} }; /** Occurs when the SDK requests the maximum size of the metadata. @@ -3875,6 +3935,7 @@ class IRtcEngine : public agora::base::IEngineBase { * @return * - 0: Success. * - < 0: Failure. + * - -8(ERR_INVALID_STATE): The current status is invalid, only allowed to be called when the connection is disconnected. */ virtual int setChannelProfile(CHANNEL_PROFILE_TYPE profile) = 0; @@ -3923,48 +3984,10 @@ class IRtcEngine : public agora::base::IEngineBase { * - -1(ERR_FAILED): A general error occurs (no specified reason). * - -2(ERR_INALID_ARGUMENT): The parameter is invalid. * - -7(ERR_NOT_INITIALIZED): The SDK is not initialized. + * - -8(ERR_INVALID_STATE): The channel profile is not `LIVE_BROADCASTING`. */ virtual int setClientRole(CLIENT_ROLE_TYPE role, const ClientRoleOptions& options) = 0; - /** Starts an audio call test. - - This method launches an audio call test to determine whether the audio devices - (for example, headset and speaker) and the network connection are working - properly. - - In the test, the user first speaks, and the recording is played back - in 10 seconds. If the user can hear the recording in 10 seconds, it indicates - that the audio devices and network connection work properly. - - @note - After calling the startEchoTest() method, always call stopEchoTest() to end - the test. Otherwise, the app cannot run the next echo test, nor can - it call the joinChannel() method. - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int startEchoTest() = 0; - - /** Starts an audio call test. - - This method starts an audio call test to determine whether the audio devices (for example, headset and speaker) and the network connection are working properly. - - In the audio call test, you record your voice. If the recording plays back within the set time interval, the audio devices and the network connection are working properly. - - @note - - Call this method before joining a channel. - - After calling this method, call the \ref IRtcEngine::stopEchoTest "stopEchoTest" method to end the test. Otherwise, the app cannot run the next echo test, or call the \ref IRtcEngine::joinChannel "joinChannel" method. - - In the `LIVE_BROADCASTING` profile, only a host can call this method. - @param intervalInSeconds The time interval (s) between when you speak and when the recording plays back. - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int startEchoTest(int intervalInSeconds) = 0; - /** Starts a video call test. * * @param config: configuration for video call test. @@ -4129,6 +4152,41 @@ class IRtcEngine : public agora::base::IEngineBase { * @param options Sets the image enhancement option. See BeautyOptions. */ virtual int setBeautyEffectOptions(bool enabled, const BeautyOptions& options, agora::media::MEDIA_SOURCE_TYPE type = agora::media::PRIMARY_CAMERA_SOURCE) = 0; + /** Enables/Disables face shape and sets the beauty options. + * + * @note Call this method after calling the \ref IRtcEngine::enableVideo "enableVideo" method. + * + * @param enabled Sets whether or not to enable face shape: + * - true: enables face shape. + * - false: disables face shape. + * @param options Sets the face shape beauty option. See FaceShapeBeautyOptions. + */ + virtual int setFaceShapeBeautyOptions(bool enabled, const FaceShapeBeautyOptions& options, agora::media::MEDIA_SOURCE_TYPE type = agora::media::PRIMARY_CAMERA_SOURCE) = 0; + /** Enables/Disables face shape and sets the area options. + * + * @note Call this method after calling the \ref IRtcEngine::setFaceShapeBeautyOptions "setFaceShapeBeautyOptions" method. + * + * @param options Sets the face shape area option. See FaceShapeAreaOptions. + */ + virtual int setFaceShapeAreaOptions(const FaceShapeAreaOptions& options, agora::media::MEDIA_SOURCE_TYPE type = agora::media::PRIMARY_CAMERA_SOURCE) = 0; + + /** Gets the face shape beauty options. + * + * @note Call this method after calling the \ref IRtcEngine::enableVideo "enableVideo" method. + * + * @param options Gets the face shape beauty option. See FaceShapeBeautyOptions. + */ + virtual int getFaceShapeBeautyOptions(FaceShapeBeautyOptions& options, agora::media::MEDIA_SOURCE_TYPE type = agora::media::PRIMARY_CAMERA_SOURCE) = 0; + + /** Gets the face shape area options. + * + * @note Call this method after calling the \ref IRtcEngine::enableVideo "enableVideo" method. + * + * @param shapeArea The face area. See FaceShapeAreaOptions::FACE_SHAPE_AREA. + * @param options Gets the face area beauty option. See FaceShapeAreaOptions. + */ + virtual int getFaceShapeAreaOptions(agora::rtc::FaceShapeAreaOptions::FACE_SHAPE_AREA shapeArea, FaceShapeAreaOptions& options, agora::media::MEDIA_SOURCE_TYPE type = agora::media::PRIMARY_CAMERA_SOURCE) = 0; + /** * Sets low-light enhancement. * @@ -4497,29 +4555,6 @@ class IRtcEngine : public agora::base::IEngineBase { */ virtual int muteAllRemoteAudioStreams(bool mute) = 0; - /** - * Determines whether to receive all remote audio streams by default. - * - * @deprecated This method is deprecated. To set whether to receive remote - * audio streams by default, call - * \ref IRtcEngine::muteAllRemoteAudioStreams "muteAllRemoteAudioStreams" - * before calling `joinChannel` - * - * Use this method to set whether to receive audio streams of subsequent peer - * users. Agora recommends calling it before joining a channel. - * - * A successful call of setDefaultMuteAllRemoteAudioStreams(true) results in - * that the local user not receiving any audio stream after joining a channel. - * @param mute Whether to receive remote audio streams by default: - * - true: Do not receive any remote audio stream by default. - * - false: (Default) Receive remote audio streams by default. - * - * @return int - * - 0: Success. - * - < 0: Failure. - */ - virtual int setDefaultMuteAllRemoteAudioStreams(bool mute) __deprecated = 0; - /** * Stops or resumes receiving the audio stream of a specified user. * @@ -4618,29 +4653,6 @@ class IRtcEngine : public agora::base::IEngineBase { */ virtual int muteAllRemoteVideoStreams(bool mute) = 0; - /** - Determines whether to receive all remote video streams by default. - - @deprecated This method is deprecated. To set whether to receive remote - video streams by default, call - \ref IRtcEngine::muteAllRemoteVideoStreams "muteAllRemoteVideoStreams" - before calling `joinChannel`. - - Use this method to set whether to receive video streams of subsequent peer - users. Agora recommends calling it before joining a channel. - - A successful call of setDefaultMuteAllRemoteVideoStreams(true) results in - that the local user not receiving any video stream after joining a channel. - - @param mute Whether to receive remote video streams by default: - - true: Do not receive any remote video stream by default. - - false: (Default) Receive remote video streams by default. - @return int - - 0: Success. - - < 0: Failure. - */ - virtual int setDefaultMuteAllRemoteVideoStreams(bool mute) __deprecated = 0; - /** * Sets the default stream type of the remote video if the remote user has enabled dual-stream. * @@ -5196,7 +5208,7 @@ class IRtcEngine : public agora::base::IEngineBase { * - < 0: Failure. */ virtual int setAudioMixingPlaybackSpeed(int speed) = 0; - + /** * Gets the volume of audio effects. * @@ -5831,6 +5843,19 @@ class IRtcEngine : public agora::base::IEngineBase { */ virtual int setHeadphoneEQParameters(int lowGain, int highGain) = 0; + /** Enables or disables the voice AI tuner. + * + * @param enabled Determines whether to enable the voice AI tuner: + * - true: Enable the voice AI tuner + * - false: (default) Disable the voice AI tuner. + * + * @param type. The options for SDK voice AI tuner types. See #VOICE_AI_TUNER_TYPE. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int enableVoiceAITuner(bool enabled, VOICE_AI_TUNER_TYPE type) = 0; + /** **DEPRECATED** Specifies an SDK output log file. * * The log file records all log data for the SDK’s operation. Ensure that the @@ -5916,6 +5941,23 @@ class IRtcEngine : public agora::base::IEngineBase { */ virtual int uploadLogFile(agora::util::AString& requestId) = 0; + /** * Write the log to SDK . @technical preview + * + * You can Write the log to SDK log files of the specified level. + * + * @param level The log level: + * - `LOG_LEVEL_NONE (0x0000)`: Do not output any log file. + * - `LOG_LEVEL_INFO (0x0001)`: (Recommended) Output log files of the INFO level. + * - `LOG_LEVEL_WARN (0x0002)`: Output log files of the WARN level. + * - `LOG_LEVEL_ERROR (0x0004)`: Output log files of the ERROR level. + * - `LOG_LEVEL_FATAL (0x0008)`: Output log files of the FATAL level. + * + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int writeLog(commons::LOG_LEVEL level, const char* fmt, ...) = 0; + /** * Updates the display mode of the local video view. * @@ -5978,7 +6020,7 @@ class IRtcEngine : public agora::base::IEngineBase { * - 0: Success. * - < 0: Failure. */ - virtual int setLocalRenderMode(media::base::RENDER_MODE_TYPE renderMode) = 0; + virtual int setLocalRenderMode(media::base::RENDER_MODE_TYPE renderMode) __deprecated = 0; /** * Sets the local video mirror mode. @@ -5991,7 +6033,7 @@ class IRtcEngine : public agora::base::IEngineBase { * - 0: Success. * - < 0: Failure. */ - virtual int setLocalVideoMirrorMode(VIDEO_MIRROR_MODE_TYPE mirrorMode) = 0; + virtual int setLocalVideoMirrorMode(VIDEO_MIRROR_MODE_TYPE mirrorMode) __deprecated = 0; /** * Enables or disables the dual video stream mode. @@ -6043,6 +6085,23 @@ class IRtcEngine : public agora::base::IEngineBase { */ virtual int setDualStreamMode(SIMULCAST_STREAM_MODE mode) = 0; + /** + * Sets the multi-layer video stream configuration. + * + * If multi-layer is configured, the subscriber can choose to receive the coresponding layer + * of video stream using {@link setRemoteVideoStreamType setRemoteVideoStreamType}. + * + * @param simulcastConfig + * - The configuration for multi-layer video stream. It includes seven layers, ranging from + * STREAM_LAYER_1 to STREAM_LOW. A maximum of 3 layers can be enabled simultaneously. + * + * @return + * - 0: Success. + * - < 0: Failure. + * @technical preview + */ + virtual int setSimulcastConfig(const SimulcastConfig& simulcastConfig) = 0; + /** * Enables, disables or auto enable the dual video stream mode. * @@ -6463,7 +6522,7 @@ class IRtcEngine : public agora::base::IEngineBase { */ virtual int setInEarMonitoringVolume(int volume) = 0; -#if defined (_WIN32) || defined(__linux__) || defined(__ANDROID__) +#if defined(_WIN32) || defined(__linux__) || defined(__ANDROID__) virtual int loadExtensionProvider(const char* path, bool unload_after_use = false) = 0; #endif @@ -6600,7 +6659,7 @@ class IRtcEngine : public agora::base::IEngineBase { */ virtual int destroyCustomEncodedVideoTrack(video_track_id_t video_track_id) = 0; -#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) || defined (__OHOS__) +#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) || defined(__OHOS__) /** * Switches between front and rear cameras. * @@ -6787,6 +6846,13 @@ class IRtcEngine : public agora::base::IEngineBase { * - false: Do not enable the auto exposure face function. */ virtual int setCameraAutoExposureFaceModeEnabled(bool enabled) = 0; + + /** + * set camera stabilization mode.If open stabilization mode, fov will be smaller and capture latency will be longer. + * + * @param mode specifies the camera stabilization mode. + */ + virtual int setCameraStabilizationMode(CAMERA_STABILIZATION_MODE mode) = 0; #endif /** Sets the default audio route (for Android and iOS only). @@ -6870,6 +6936,27 @@ class IRtcEngine : public agora::base::IEngineBase { virtual int setRouteInCommunicationMode(int route) = 0; #endif // __ANDROID__ || (__APPLE__ && TARGET_OS_IOS) || __OHOS__ +#if defined(__APPLE__) + /** + * Checks whether the center stage is supported. Use this method after starting the camera. + * + * @return + * - true: The center stage is supported. + * - false: The center stage is not supported. + */ + virtual bool isCameraCenterStageSupported() = 0; + + /** Enables the camera Center Stage. + * @param enabled enable Center Stage: + * - true: Enable Center Stage. + * - false: Disable Center Stage. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int enableCameraCenterStage(bool enabled) = 0; +#endif + #if defined(_WIN32) || (defined(__APPLE__) && TARGET_OS_MAC && !TARGET_OS_IPHONE) /** Get \ref ScreenCaptureSourceInfo list including available windows and screens. * @@ -6975,7 +7062,6 @@ class IRtcEngine : public agora::base::IEngineBase { * - < 0: Failure.. */ virtual int getAudioDeviceInfo(DeviceInfo& deviceInfo) = 0; - #endif // __ANDROID__ #if defined(_WIN32) || (defined(__APPLE__) && TARGET_OS_MAC && !TARGET_OS_IPHONE) @@ -7051,7 +7137,7 @@ class IRtcEngine : public agora::base::IEngineBase { virtual int updateScreenCaptureParameters(const ScreenCaptureParameters& captureParams) = 0; #endif // _WIN32 || (__APPLE__ && !TARGET_OS_IPHONE && TARGET_OS_MAC) -#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) +#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) || defined(__OHOS__) /** * Starts screen sharing. * @@ -7086,7 +7172,22 @@ class IRtcEngine : public agora::base::IEngineBase { * - < 0: Failure. */ virtual int queryScreenCaptureCapability() = 0; -#endif + +#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) + /** + * Query all focal attributes supported by the camera. + * + * @param focalLengthInfos The camera supports the collection of focal segments.Ensure the size of array is not less than 8. + * + * @param size The camera supports the size of the focal segment set. Ensure the size is not less than 8. + * + * @return + * - 0: Success. + * - < 0: Failure.. + */ + virtual int queryCameraFocalLengthCapability(agora::rtc::FocalLengthInfo* focalLengthInfos, int& size) = 0; +#endif // defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) +#endif // defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) || defined(__OHOS__) #if defined(_WIN32) || defined(__APPLE__) || defined(__ANDROID__) /** @@ -7340,47 +7441,6 @@ class IRtcEngine : public agora::base::IEngineBase { */ virtual int registerPacketObserver(IPacketObserver* observer) = 0; - /** - * Sets the built-in encryption mode. - * - * @deprecated This method is deprecated. Use enableEncryption(bool enabled, const EncryptionConfig&) instead. - * - * The Agora Native SDK supports built-in encryption. - * Call this API to set the encryption mode. - * - * All users in the same channel must use the same encryption mode and password. - * Refer to information related to the encryption algorithm on the differences - * between encryption modes. - * - * @note - * Call \ref setEncryptionSecret "setEncryptionSecret" to enable the built-in encryption function - * before calling this API. - * @param encryptionMode Encryption mode: - * - "sm4-128-ecb": 128-bit SM4 encryption, ECB mode. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setEncryptionMode(const char* encryptionMode) __deprecated = 0; - - /** - * Enables built-in encryption. - * - * @deprecated This method is deprecated. Use enableEncryption(bool enabled, const EncryptionConfig&) instead. - * - * Use this method to specify an encryption password to enable built-in - * encryption before joining a channel. All users in a channel must set the same - * encryption password. The encryption password is automatically cleared once a - * user has left the channel. If the encryption password is not specified or set to - * empty, the encryption function will be disabled. - * - * @param secret The encryption password. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setEncryptionSecret(const char* secret) __deprecated = 0; /** Enables/Disables the built-in encryption. * @@ -8261,6 +8321,18 @@ class IRtcEngine : public agora::base::IEngineBase { * - false: not available. */ virtual bool isFeatureAvailableOnDevice(FeatureType type) = 0; + + /** + * @brief send audio metadata + * @since v4.3.1 + * @param metadata The pointer of metadata + * @param length Size of metadata + * @return + * - 0: success + * - <0: failure + * @technical preview + */ + virtual int sendAudioMetadata(const char* metadata, size_t length) = 0; }; // The following types are either deprecated or not implmented yet. diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtcEngineEx.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtcEngineEx.h old mode 100755 new mode 100644 index 9b5670f7e..423d1964a --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtcEngineEx.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtcEngineEx.h @@ -101,6 +101,7 @@ class IRtcEngineEventHandlerEx : public IRtcEngineEventHandler { using IRtcEngineEventHandler::onVideoRenderingTracingResult; using IRtcEngineEventHandler::onSetRtmFlagResult; using IRtcEngineEventHandler::onTranscodedStreamLayoutInfo; + using IRtcEngineEventHandler::onAudioMetadataReceived; virtual const char* eventHandlerType() const { return "event_handler_ex"; } @@ -317,40 +318,6 @@ class IRtcEngineEventHandlerEx : public IRtcEngineEventHandler { (void)rotation; } - /** Occurs when the local video stream state changes. - * - * When the state of the local video stream changes (including the state of the video capture and - * encoding), the SDK triggers this callback to report the current state. This callback indicates - * the state of the local video stream, including camera capturing and video encoding, and allows - * you to troubleshoot issues when exceptions occur. - * - * The SDK triggers the onLocalVideoStateChanged callback with the state code of `LOCAL_VIDEO_STREAM_STATE_FAILED` - * and error code of `LOCAL_VIDEO_STREAM_REASON_CAPTURE_FAILURE` in the following situations: - * - The app switches to the background, and the system gets the camera resource. - * - The camera starts normally, but does not output video for four consecutive seconds. - * - * When the camera outputs the captured video frames, if the video frames are the same for 15 - * consecutive frames, the SDK triggers the `onLocalVideoStateChanged` callback with the state code - * of `LOCAL_VIDEO_STREAM_STATE_CAPTURING` and error code of `LOCAL_VIDEO_STREAM_REASON_CAPTURE_FAILURE`. - * Note that the video frame duplication detection is only available for video frames with a resolution - * greater than 200 × 200, a frame rate greater than or equal to 10 fps, and a bitrate less than 20 Kbps. - * - * @note For some device models, the SDK does not trigger this callback when the state of the local - * video changes while the local video capturing device is in use, so you have to make your own - * timeout judgment. - * - * @param connection The RtcConnection object. - * @param state The state of the local video. See #LOCAL_VIDEO_STREAM_STATE. - * @param reason The detailed error information. See #LOCAL_VIDEO_STREAM_REASON. - */ - virtual void onLocalVideoStateChanged(const RtcConnection& connection, - LOCAL_VIDEO_STREAM_STATE state, - LOCAL_VIDEO_STREAM_REASON reason) { - (void)connection; - (void)state; - (void)reason; - } - /** * Occurs when the remote video state changes. * @@ -1059,6 +1026,20 @@ class IRtcEngineEventHandlerEx : public IRtcEngineEventHandler { (void)layoutCount; (void)layoutlist; } + + /** + * The audio metadata received. + * + * @param connection The RtcConnection object. + * @param uid ID of the remote user. + * @param metadata The pointer of metadata + * @param length Size of metadata + * @technical preview + */ + virtual void onAudioMetadataReceived(const RtcConnection& connection, uid_t uid, const char* metadata, size_t length) { + (void)metadata; + (void)length; + } }; class IRtcEngineEx : public IRtcEngine { @@ -1864,7 +1845,25 @@ class IRtcEngineEx : public IRtcEngine { virtual int setDualStreamModeEx(SIMULCAST_STREAM_MODE mode, const SimulcastStreamConfig& streamConfig, const RtcConnection& connection) = 0; - + + /** + * Set the multi-layer video stream configuration. + * + * If multi-layer is configed, the subscriber can choose to receive the coresponding layer + * of video stream using {@link setRemoteVideoStreamType setRemoteVideoStreamType}. + * + * @param simulcastConfig + * - The configuration for multi-layer video stream. It includes seven layers, ranging from + * STREAM_LAYER_1 to STREAM_LOW. A maximum of 3 layers can be enabled simultaneously. + * @param connection The RtcConnection object. + * @return + * - 0: Success. + * - < 0: Failure. + * @technical preview + */ + virtual int setSimulcastConfigEx(const SimulcastConfig& simulcastConfig, + const RtcConnection& connection) = 0; + /** * Set the high priority user list and their fallback level in weak network condition. * @@ -1955,7 +1954,7 @@ class IRtcEngineEx : public IRtcEngine { - < 0: Failure. */ virtual int setParametersEx(const RtcConnection& connection, const char* parameters) = 0; - + /** * Gets the current call ID. * @@ -1974,6 +1973,19 @@ class IRtcEngineEx : public IRtcEngine { * - < 0: Failure. */ virtual int getCallIdEx(agora::util::AString& callId, const RtcConnection& connection) = 0; + + /** + * send audio metadata + * @since v4.3.1 + * @param connection The RtcConnection object. + * @param metadata The pointer of metadata + * @param length Size of metadata + * @return + * - 0: success + * - <0: failure + * @technical preview + */ + virtual int sendAudioMetadataEx(const RtcConnection& connection, const char* metadata, size_t length) = 0; }; } // namespace rtc diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtmService.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtmService.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtmpStreamingService.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtmpStreamingService.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraService.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraService.h old mode 100755 new mode 100644 index 0b1de7840..b5c036340 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraService.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraService.h @@ -71,6 +71,8 @@ class IRtmService; namespace base { class IServiceObserver; +class ISyncClient; +struct SyncConfig; /** * The global configurations for \ref agora::base::IAgoraService "AgoraService". @@ -286,6 +288,13 @@ struct AudioSessionConfiguration { */ Optional outputNumberOfChannels; +#if defined(WEBRTC_IOS) + /** + * Initialize the AudioSession with the value for category. (iOS only) + */ + Optional category; +#endif + void SetAll(const AudioSessionConfiguration& change) { SetFrom(&playbackAndRecord, change.playbackAndRecord); SetFrom(&chatMode, change.chatMode); @@ -299,6 +308,9 @@ struct AudioSessionConfiguration { SetFrom(&ioBufferDuration, change.ioBufferDuration); SetFrom(&inputNumberOfChannels, change.inputNumberOfChannels); SetFrom(&outputNumberOfChannels, change.outputNumberOfChannels); +#if defined(WEBRTC_IOS) + SetFrom(&category, change.category); +#endif } bool operator==(const AudioSessionConfiguration& o) const { @@ -308,7 +320,12 @@ struct AudioSessionConfiguration { allowBluetooth == o.allowBluetooth && allowBluetoothA2DP == o.allowBluetoothA2DP && sampleRate == o.sampleRate && ioBufferDuration == o.ioBufferDuration && inputNumberOfChannels == o.inputNumberOfChannels && +#if defined(WEBRTC_IOS) + outputNumberOfChannels == o.outputNumberOfChannels && + category == o.category; +#else outputNumberOfChannels == o.outputNumberOfChannels; +#endif } bool operator!=(const AudioSessionConfiguration& o) const { return !(*this == o); } @@ -635,12 +652,13 @@ class IAgoraService { * @param audioSource The pointer to the recording device source. See \ref agora::rtc::IRecordingDeviceSource "IRecordingDeviceSource". * @param enableAec Whether enable audio echo cancellation for loopback recording. If loopback * recording device is a virtual sound card, it should be false, or it should be true. + * @param overlap Whether overlap playout signal. * @return * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success. * - A null pointer: Failure. */ virtual agora_refptr createRecordingDeviceAudioTrack( - agora_refptr audioSource, bool enableAec) = 0; + agora_refptr audioSource, bool enableAec, bool overlap) = 0; /** * Creates an audio device manager object and returns the pointer. @@ -956,6 +974,32 @@ class IAgoraService { * - A null pointer: Failure. */ virtual agora_refptr getConfigCenter() = 0; + + /** + * Get the \ref agora::rtc::ISyncClient "ISyncClient" object and return the pointer. + * + * @return + * - The pointer to \ref rtc::ISyncClient "ISyncClient": Success. + * - A null pointer: Failure. + */ + virtual agora_refptr createSyncClient(const base::SyncConfig& config) = 0; + + /** + * Set the logWriter for the sdk log. + * @param logWriter the log writer + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int32_t setLogWriter(agora::commons::ILogWriter* logWriter) = 0; + + /** + * Release logWriter for the sdk log. + * @return + * -The pointer to \ref agora::commons::ILogWriter + * - A null pointer: Failure. + */ + virtual agora::commons::ILogWriter* releaseLogWriter() = 0; protected: virtual ~IAgoraService() {} diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAudioDeviceManager.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAudioDeviceManager.h old mode 100755 new mode 100644 index 77667b827..6537f0990 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAudioDeviceManager.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAudioDeviceManager.h @@ -50,6 +50,20 @@ class IAudioDeviceCollection { virtual int getDevice(int index, char deviceName[MAX_DEVICE_ID_LENGTH], char deviceId[MAX_DEVICE_ID_LENGTH]) = 0; + /** + * Gets the information of a specified audio device. + * @note + * @param index An input parameter that specifies the audio device. + * @param deviceName An output parameter that indicates the device name. + * @param deviceTypeName An output parameter that indicates the device type name. such as Built-in, USB, HDMI, etc. (MacOS only) + * @param deviceId An output parameter that indicates the device ID. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int getDevice(int index, char deviceName[MAX_DEVICE_ID_LENGTH], char deviceTypeName[MAX_DEVICE_ID_LENGTH], + char deviceId[MAX_DEVICE_ID_LENGTH]) = 0; + /** * Specifies a device with the device ID. * @param deviceId The device ID. @@ -71,6 +85,19 @@ class IAudioDeviceCollection { */ virtual int getDefaultDevice(char deviceName[MAX_DEVICE_ID_LENGTH], char deviceId[MAX_DEVICE_ID_LENGTH]) = 0; + /** + * Gets the default audio device of the system (for macOS and Windows only). + * + * @param deviceName The name of the system default audio device. + * @param deviceTypeName The device type name of the the system default audio device, such as Built-in, USB, HDMI, etc. (MacOS only) + * @param deviceId The device ID of the the system default audio device. + * + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int getDefaultDevice(char deviceName[MAX_DEVICE_ID_LENGTH], char deviceTypeName[MAX_DEVICE_ID_LENGTH], char deviceId[MAX_DEVICE_ID_LENGTH]) = 0; + /** * Sets the volume of the app. * @@ -199,6 +226,17 @@ class IAudioDeviceManager : public RefCountInterface { virtual int getPlaybackDeviceInfo(char deviceId[MAX_DEVICE_ID_LENGTH], char deviceName[MAX_DEVICE_ID_LENGTH]) = 0; + /** + * Gets the device ID and device name and device type name of the audio playback device. + * @param deviceId An output parameter that specifies the ID of the audio playback device. + * @param deviceName An output parameter that specifies the name of the audio playback device. + * @param deviceTypeName An output parameter that specifies the device type name. such as Built-in, USB, HDMI, etc. (MacOS only) + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int getPlaybackDeviceInfo(char deviceId[MAX_DEVICE_ID_LENGTH], char deviceName[MAX_DEVICE_ID_LENGTH], char deviceTypeName[MAX_DEVICE_ID_LENGTH]) = 0; + /** * Sets the volume of the audio playback device. * @param volume The volume of the audio playing device. The value range is @@ -254,6 +292,18 @@ class IAudioDeviceManager : public RefCountInterface { virtual int getRecordingDeviceInfo(char deviceId[MAX_DEVICE_ID_LENGTH], char deviceName[MAX_DEVICE_ID_LENGTH]) = 0; + /** + * Gets the device ID and device name and device type name of the audio recording device. + * + * @param deviceId An output parameter that indicates the device id. + * @param deviceName An output parameter that indicates the device name. + * @param deviceTypeName An output parameter that indicates the device type name. such as Built-in, USB, HDMI, etc. (MacOS only) + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int getRecordingDeviceInfo(char deviceId[MAX_DEVICE_ID_LENGTH], char deviceName[MAX_DEVICE_ID_LENGTH], char deviceTypeName[MAX_DEVICE_ID_LENGTH]) = 0; + /** * Sets the volume of the recording device. * @param volume The volume of the recording device. The value range is [0, diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioDeviceManager.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioDeviceManager.h old mode 100755 new mode 100644 index cb54fc77f..0c41470ef --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioDeviceManager.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioDeviceManager.h @@ -37,6 +37,11 @@ struct AudioDeviceInfo { * The name of the device. The maximum name size is 128 bytes. The default value is 0. */ char deviceName[kAdmMaxDeviceNameSize]; + /** + * The type name of the device. such as Built-in, USB, HDMI, etc. The maximum size is 128 bytes. The default value is 0. + * @note This member applies to macOS only. + */ + char deviceTypeName[kAdmMaxDeviceNameSize]; /** * The ID of the device. The maximum size is 128 bytes. The default value is 0. */ @@ -57,6 +62,7 @@ struct AudioDeviceInfo { AudioDeviceInfo() : isCurrentSelected(false), isPlayoutDevice(true) { memset(deviceName, 0, sizeof(deviceName)); + memset(deviceTypeName, 0, sizeof(deviceTypeName)); memset(deviceId, 0, sizeof(deviceId)); } }; diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioMixerSource.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioMixerSource.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioTrack.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioTrack.h old mode 100755 new mode 100644 index 7b5c6b42c..e877e370e --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioTrack.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioTrack.h @@ -104,11 +104,12 @@ class IAudioTrack : public RefCountInterface { * By adding an audio filter, you can apply various audio effects to the audio, for example, voice change. * @param filter A pointer to the audio filter. See \ref agora::rtc::IAudioFilter "IAudioFilter". * @param position The position of the audio filter. See \ref agora::rtc::IAudioTrack::AudioFilterPosition "AudioFilterPosition". + * @param extContext The context of current filter. See \ref agora::rtc::ExtensionContext "ExtensionContext". * @return * - `true`: Success. * - `false`: Failure. */ - virtual bool addAudioFilter(agora_refptr filter, AudioFilterPosition position, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual bool addAudioFilter(agora_refptr filter, AudioFilterPosition position, ExtensionContext *extContext = NULL, aosl_ref_t ares = AOSL_REF_INVALID) = 0; /** * Removes the audio filter added by callling `addAudioFilter`. * @@ -401,6 +402,21 @@ class ILocalAudioTrack : public IAudioTrack { */ virtual int unregisterTrackObserver(ILocalAudioTrackObserver* observer) = 0; + /** set Max buffered audio frame number + * + * @param number : the buffer number set,unit is 10ms + * + */ + virtual void setMaxBufferedAudioFrameNumber(int number) = 0; + + /** clear sender buffer + * + * @return + * - >= 0: Frame number in sender buffer. + * - < 0: Failure. + */ + virtual int ClearSenderBuffer() = 0; + protected: ~ILocalAudioTrack() {} }; @@ -535,6 +551,14 @@ struct RemoteAudioTrackStats { * The time of 200 ms frozen in 2 seconds */ uint16_t frozen_time_200_ms; + /** + * The full time of 80 ms frozen in 2 seconds + */ + uint16_t full_frozen_time_80_ms; + /** + * The full time of 200 ms frozen in 2 seconds + */ + uint16_t full_frozen_time_200_ms; /** * The estimate delay */ @@ -617,6 +641,8 @@ struct RemoteAudioTrackStats { frozen_time_80_ms(0), frozen_count_200_ms(0), frozen_time_200_ms(0), + full_frozen_time_80_ms(0), + full_frozen_time_200_ms(0), delay_estimate_ms(0), mos_value(0), frozen_rate_by_custom_plc_count(0), @@ -711,6 +737,43 @@ class IRemoteAudioTrack : public IAudioTrack { */ virtual int setRemoteVoicePosition(float pan, float gain, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + /** Sets the volume of each audio decoded channel + + @param decoded_index The channel index of the remote user. The value ranges from 0 to 100: + @param volume The channel index of the remote user. The value ranges from 0 to 100. + - 0: mute the channel. + - 100: keep the origin volume of the channel. + + @return + - 0: Success. + - < 0: Failure. + */ + virtual int adjustDecodedAudioVolume(int decoded_index, int volume, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + + /** mute remote stream from timestamp + + @note + - unmuteRemoteFromTimestamp should be called after muteRemoteFromTimestamp, othewise this stream will be muted all time + + @param timestamp The rtp timestamp of start mute + @return + - 0: Success. + - < 0: Failure. + */ + virtual int muteRemoteFromTimestamp(uint32_t timestamp) = 0; + + /** unmute remote stream from timestamp + + @note + - unmuteRemoteFromTimestamp should be called after muteRemoteFromTimestamp, othewise this stream will be muted all time + + @param timestamp The rtp timestamp of start unmute + @return + - 0: Success. + - < 0: Failure. + */ + virtual int unmuteRemoteFromTimestamp(uint32_t timestamp) = 0; + /** set percentage of audio acceleration during poor network @note diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraCameraCapturer.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraCameraCapturer.h old mode 100755 new mode 100644 index 54e4c4647..022a6c181 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraCameraCapturer.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraCameraCapturer.h @@ -32,6 +32,10 @@ class ICameraCapturer : public RefCountInterface { * The camera source is the front camera. */ CAMERA_FRONT, + /** + * The camera source is the extra camera. + */ + CAMERA_EXTRA, }; /** @@ -369,6 +373,13 @@ class ICameraCapturer : public RefCountInterface { * */ virtual int setCameraAutoExposureFaceModeEnabled(bool enabled, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + + /** + * set camera stabilization mode.If open stabilization mode, fov will be smaller and capture latency will be longer. + * + * @param mode specifies the camera stabilization mode. + */ + virtual int setCameraStabilizationMode(CAMERA_STABILIZATION_MODE mode) = 0; #endif #elif defined(_WIN32) || (defined(__linux__) && !defined(__ANDROID__) && !defined (__OHOS__)) || \ @@ -410,6 +421,27 @@ class ICameraCapturer : public RefCountInterface { virtual int initWithDeviceName(const char* deviceName) = 0; #endif +#if defined(__APPLE__) + /** + * Checks whether the center stage is supported. Use this method after starting the camera. + * + * @return + * - true: The center stage is supported. + * - false: The center stage is not supported. + */ + virtual bool isCenterStageSupported() = 0; + + /** Enables the camera Center Stage. + * @param enabled enable Center Stage: + * - true: Enable Center Stage. + * - false: Disable Center Stage. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int enableCenterStage(bool enabled) = 0; +#endif + /** * Set the device orientation of the capture device * @param VIDEO_ORIENTATION orientaion of the device 0(by default), 90, 180, 270 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraConfigCenter.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraConfigCenter.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraDataChannel.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraDataChannel.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionAINoiseSuppressor.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionAINoiseSuppressor.h old mode 100755 new mode 100644 index 2cb977831..5826a6ca3 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionAINoiseSuppressor.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionAINoiseSuppressor.h @@ -13,11 +13,12 @@ namespace rtc { class AINoiseSuppressorExtension : public RefCountInterface { public: virtual ~AINoiseSuppressorExtension() {}; - - virtual int ProcessDenoiseFrame(float* input, float* output) = 0; - virtual int ClearHiddenState() = 0; - virtual const char* GetLibVersion(int mode) = 0; + virtual int Init(const char* weight_raw_buffer, size_t raw_buffer_bytes) = 0; + virtual int ProcessDenoiseFrame(float* input, float* output, int stage) = 0; + virtual int ClearHiddenState(bool clear_hidden, int clear_lpsbuffer_nframe) = 0; + virtual const char* GetLibVersion(int mode = 0) = 0; }; + } // namespace rtc } // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionAiAec.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionAiAec.h old mode 100755 new mode 100644 index cebd1debf..fec96b6a1 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionAiAec.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionAiAec.h @@ -17,10 +17,10 @@ namespace rtc { class AiEchoCancellationExtension : public RefCountInterface { public: virtual ~AiEchoCancellationExtension() {}; - - virtual int ProcessAiNlpFrame(float* input, float* output) = 0; - virtual int ClearHiddenState(float scale_factor = 0.0) = 0; - virtual void Version(char ver[MAX_VERSION_LEN]) = 0; + virtual int Init(const char* weight_raw_buffer, size_t raw_buffer_bytes) = 0; + virtual int ProcessAiNlpFrame(const float* linear, const float* nearin, const float* far_ref, float* out_mask) = 0; + virtual int ClearHiddenState(float scale_factor = 0.0,int clear_lpsbuffer_nframe = 0) = 0; + virtual const char* GetLibVersion(int mode = 0) = 0; }; } // namespace rtc diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionControl.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionControl.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionProvider.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionProvider.h old mode 100755 new mode 100644 index 9a1a54141..4dff21248 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionProvider.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionProvider.h @@ -106,7 +106,7 @@ class IExtensionProvider : public RefCountInterface { virtual agora_refptr createVideoSink(const char* name) { return NULL; } - + virtual void setProperty(const char* key, const char* value) {} protected: diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionScreenSource.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionScreenSource.h old mode 100755 new mode 100644 index 82fe0a504..0b12be254 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionScreenSource.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionScreenSource.h @@ -83,8 +83,11 @@ class IScreenCaptureSource : public RefCountInterface { uint32_t display_id; view_t window_id; + // Mac only + bool disable_avf; + VideoCaptureConfig() - : type(CaptureScreen), screen_rect(), region_offset(), display_id(0), window_id(NULL) { } + : type(CaptureScreen), screen_rect(), region_offset(), display_id(0), window_id(NULL), disable_avf(false) { } }; #endif @@ -95,6 +98,7 @@ class IScreenCaptureSource : public RefCountInterface { int icon_height; bool include_screen; bool unfiltered; + bool unskip_system_window; }; enum CaptureMode { diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionVQA.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionVQA.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraLocalUser.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraLocalUser.h old mode 100755 new mode 100644 index 2138d76a7..2db3c9dcf --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraLocalUser.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraLocalUser.h @@ -41,6 +41,7 @@ struct LocalVideoTrackStats; struct RemoteVideoTrackStats; class IMediaPacketReceiver; class IVideoSinkBase; + /** * The ILocalUser class defines the behavior and state of a local user. * @@ -811,6 +812,8 @@ class ILocalUser { virtual int getHighPriorityUserList(std::vector& vipList, int& option) = 0; + virtual int setRemoteSubscribeFallbackOption(int option, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + /** * Sets the blocklist of subscribe remote stream audio. * @@ -1158,6 +1161,17 @@ class ILocalUser { * - < 0: Failure. */ virtual int takeDataChannelSnapshot(aosl_ref_t ares = AOSL_REF_INVALID) = 0; + /** + * send audio metadata + * + * @param metadata The pointer of metadata + * @param length Size of metadata + * @return + * - 0: success + * - <0: failure + * @technical preview + */ + virtual int sendAudioMetadata(const char* metadata, size_t length, aosl_ref_t ares = AOSL_REF_INVALID) = 0; }; /** @@ -1494,6 +1508,20 @@ class ILocalUserObserver { */ virtual void onVideoSizeChanged(user_id_t userId, int width, int height, int rotation) = 0; + /** + * The audio metadata received. + * + * @param userId ID of the remote user. + * @param metadata The pointer of metadata + * @param length Size of metadata + * @technical preview + */ + virtual void onAudioMetadataReceived(user_id_t userId, const char* metadata, size_t length) { + (void)userId; + (void)metadata; + (void)length; + } + /** * The media information of a specified user. */ diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraMediaNode.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraMediaNode.h old mode 100755 new mode 100644 index 682437793..0b2bc0152 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraMediaNode.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraMediaNode.h @@ -140,6 +140,32 @@ class IAudioFilter : public IAudioFilterBase { ~IAudioFilter() {} }; +class IAudioFilterV2 : public IAudioFilter { +public: + class Control : public RefCountInterface { + public: + /** + * @brief Post an event and notify the end users. + * @param key '\0' ended string that describes the key of the event + * @param value '\0' ended string that describes the value of the event + */ + virtual int postEvent(const char* key, const char* value) = 0; + /** + * @brief print log to the SDK. + * @param level Log level @ref agora::commons::LOG_LEVEL + * @param format log formatter string + * @param ... variadic arguments + */ + virtual void printLog(commons::LOG_LEVEL level, const char* format, ...) = 0; + }; +public: + /** + * @brief AgoraSDK set IAudioFilterV2::Control to filter + * @param control IAudioFilterV2::Control + */ + virtual void setExtensionControl(agora::agora_refptr control) = 0; +}; + /** * The `IVideoFilterBase` class is the base class for video filters. You can use this class to implement your own filter * and add the filter to a video track. @@ -365,6 +391,64 @@ class IExtensionVideoFilter : public IVideoFilter { } }; +class ILipSyncFilter : public RefCountInterface { + public: + enum ProcessResult { + kSuccess, // Video frame data is successfully processed + kBypass, // Video frame data should bypass the current filter and flow to its successsors + kDrop, // Video Frame data should be discarded + }; + + class Control : public RefCountInterface { + public: + /** + * @brief Post an event and notify the end users. + * @param key '\0' ended string that describes the key of the event + * @param value '\0' ended string that describes the value of the event + */ + virtual int postEvent(const char* key, const char* value) = 0; + /** + * @brief print log to the SDK. + * @param level Log level @ref agora::commons::LOG_LEVEL + * @param format log formatter string + * @param ... variadic arguments + */ + virtual void printLog(commons::LOG_LEVEL level, const char* format, ...) = 0; + /** + * @brief Ask SDK to disable the current filter if a fatal error is detected + * @param error error code + * @param msg error message + */ + virtual void disableMe(int error, const char* msg) = 0; + /** + * @brief report counter to the SDK. + * @param counter_id counter id + * @param value counter value + */ + virtual void ReportCounter(int32_t counter_id, int32_t value) = 0; + /** + * @brief get stats to the SDK. + * @param counter_id counter id + */ + virtual int GetStats(int32_t counter_id) = 0; + }; + + virtual int start(agora::agora_refptr control) = 0; + + virtual int stop() = 0; + + virtual int setProperty(const char* key, const void* buf, size_t buf_size) { return -1; } + /** + * Convert the audio frame to face info. + * @param inAudioFrame The reference to the audio frame that you want to convert. + * @param outFaceInfo The reference to the face info. + * @return see @ref ProcessResult + */ + virtual ProcessResult convertAudioFrameToFaceInfo(const agora::media::base::AudioPcmFrame& inAudioFrame, char* outFaceInfo) { + return kBypass; + } +}; + /** * The `IVideoSinkBase` class is the base class for the custom video sink. */ @@ -434,10 +518,10 @@ class IVideoSinkBase : public RefCountInterface { class IMediaExtensionObserver : public RefCountInterface { public: virtual ~IMediaExtensionObserver() {} - virtual void onEvent(const char* provider, const char* extension, const char* key, const char* json_value) {} - virtual void onExtensionStopped(const char* provider, const char* extension) {} - virtual void onExtensionStarted(const char* provider, const char* extension) {} - virtual void onExtensionError(const char* provider, const char* extension, int error, const char* message) {} + virtual void onEventWithContext(const ExtensionContext& context, const char* key, const char* json_value) {} + virtual void onExtensionStoppedWithContext(const ExtensionContext& context) {} + virtual void onExtensionStartedWithContext(const ExtensionContext& context) {} + virtual void onExtensionErrorWithContext(const ExtensionContext& context, int error, const char* message) {} }; /** diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraMediaNodeFactory.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraMediaNodeFactory.h old mode 100755 new mode 100644 index a22242b23..90806b543 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraMediaNodeFactory.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraMediaNodeFactory.h @@ -70,7 +70,7 @@ class IMediaNodeFactory : public RefCountInterface { */ virtual agora_refptr createCameraCapturer() = 0; -#if !defined(__ANDROID__) && !(defined(__APPLE__) && TARGET_OS_IPHONE) +#if !defined(__ANDROID__) && !(defined(__APPLE__) && TARGET_OS_IPHONE) && !defined(__OHOS__) /** * Creates a screen capturer. * @@ -218,7 +218,7 @@ class IMediaNodeFactory : public RefCountInterface { */ virtual agora_refptr createMediaPacketSender() = 0; -#if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) +#if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || defined(__OHOS__) /** * Creates screen capture source extension with given provider&extension names * @param provider_name provider name string. diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRemoteAudioMixerSource.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRemoteAudioMixerSource.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRtcConnection.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRtcConnection.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRtmpConnection.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRtmpConnection.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRtmpLocalUser.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRtmpLocalUser.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraScreenCapturer.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraScreenCapturer.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraSyncClient.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraSyncClient.h new file mode 100644 index 000000000..7c8880de2 --- /dev/null +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraSyncClient.h @@ -0,0 +1,139 @@ +// Copyright (c) 2020 Agora.io. All rights reserved + +// This program is confidential and proprietary to Agora.io. +// And may not be copied, reproduced, modified, disclosed to others, published +// or used, in whole or in part, without the express prior written permission +// of Agora.io. + +#pragma once // NOLINT(build/header_guard) +#include "AgoraRefPtr.h" +#include "AgoraBase.h" +#include +#include + +namespace agora { +namespace base { + +enum SyncClientError { + kOk = 0, + kFail = -1, + kConnectSyncFailed = -2, + kConnectDatabaseFailed = -3, + kDisconnectDatabaseFailed = -4, + kDatabaseNotConnected = -5, + kCreateCollectionFailed = -6, + kCollectionNotCreated = -7, + kCollectionExisted = -8, + kInvalidParams = -9, + kNotLoggedIn = -10, + kQueryDocFailed = -11, + kDocNotCreated = -12, +}; + +typedef void(*syncClientCallback)(SyncClientError, void*); +typedef void(*dataBaseOpCallback)(SyncClientError, const char*, void*); +typedef void(*collectionOpCallback)(SyncClientError, const char*, const char*, void*); +typedef void(*queryDocCallback)(SyncClientError error, const char* resultJson, size_t count, bool more, void* userData); + +enum SyncEventType { + kInserted = 0, + kPut = 1, + kDeleted = 2, + + kToBeInserted = 3, + kToBePut = 4, + kToBeDeleted = 5, + + kTransactionBegin = 6, + kTransactionEnd = 7, + kDocSyncEnd = 8, +}; + +/** + * sync client observer + */ +class ISyncClientObserver { + public: + struct CollectionEvent { + SyncEventType type; + const char* path; + const char* value; + }; + virtual void onCollectionEvent(const char* previousJson, const char* curJson, const char* collection, const char* docName, + const CollectionEvent* events, int eventSize) = 0; + virtual void onDatabaseEvent(const char* databaseName, SyncClientError error) = 0; + virtual void onDataException(const char* databaseName, const char* collectionName) = 0; + virtual ~ISyncClientObserver() {}; +}; + +/** + * sync configuration + */ +struct SyncConfig { + const char* appId; + /* shakehand interval in seconds, 0 means enable manual shake hand */ + uint32_t shakehand_interval; + /* connection timeout in seconds */ + uint32_t connection_timeout; + /* compact interval in seconds */ + uint32_t compact_interval; + SyncConfig() : shakehand_interval(1), connection_timeout(10), compact_interval(3600 * 1000) {} +}; + +class ISyncClient : public RefCountInterface { +protected: + virtual ~ISyncClient() {} +public: + + virtual int32_t registerSyncClientObserver(ISyncClientObserver* observer, void(*safeDeleter)(ISyncClientObserver*) = OPTIONAL_NULLPTR, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual int32_t unregisterSyncClientObserver(ISyncClientObserver* observer) = 0; + // client operations + virtual int32_t login(const char* token, const char* channelName, user_id_t userId, syncClientCallback callback, void* userData, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual int32_t queryDoc(const char* database, const char* coll, const char* range_start, const char* range_end, int64_t limits, bool doc_only, bool count_only, queryDocCallback callback, void* userData, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual int32_t logout(aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual int32_t renewToken(const char* token, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + + // database operations + virtual int32_t connectDatabase(const char* database, dataBaseOpCallback callback, void* userData, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual int32_t disconnectDatabase(const char* database, + dataBaseOpCallback callback, void* userData, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual int32_t createCollection(const char* database, const char* collection, + const char** readable, int readSize, + collectionOpCallback callback, void* userData, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual int32_t deleteCollection(const char* database, const char* collection, + collectionOpCallback callback, void* userData, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + + // collection operations + virtual int32_t subscribe(const char* database, const char* collection, + util::AString& snapshotJson) = 0; + virtual int32_t unsubscribe(const char* database, const char* collection, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual int32_t putDoc(const char* database, const char* collection, + const char* docName, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual int32_t deleteDoc(const char* database, const char* collection, + const char* docName, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual int32_t getDocs(const char* database, const char* collection, + util::AString* docNames, uint32_t docSize) = 0; + + // document operations + virtual int32_t putDocValue(const char* database, const char* collection, + const char* docName, const char* jsonValue, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual int32_t updateDocValue(const char* database, const char* collection, + const char* docName, const char* path, + const char* jsonValue, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual int32_t deleteDocValue(const char* database, const char* collection, + const char* docName, const char* path, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual int32_t deleteDocValues(const char* database, const char* collection, const char* docName, + const char** path, uint32_t pathSize, + aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual int32_t getDocValue(const char* database, const char* collection, + const char* docName, util::AString& jsonValue) = 0; + virtual int32_t hasPath(const char* database, const char* collection, + const char* docName, const char* path, bool& result) = 0; + virtual int32_t keepAliveDoc(const char* database, const char* collection, + const char* docName, uint32_t ttl, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + + // sync operations + virtual int32_t shakehand(aosl_ref_t ares = AOSL_REF_INVALID) = 0; +}; +}// namespace base +}// namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoFrame.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoFrame.h old mode 100755 new mode 100644 index 9b114002f..9be3e9cbe --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoFrame.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoFrame.h @@ -40,6 +40,8 @@ struct TextureInfo { EglContextType context_type; void* shared_context; int texture_id; + int64_t fence_object; + int frame_buffer_id; float transform_matrix[16]; }; @@ -57,7 +59,8 @@ struct RawPixelBuffer { kI010, kRGBA, kARGB, - kBGRA + kBGRA, + kABGR }; Format format; uint8_t* data; @@ -73,84 +76,6 @@ struct PaddedRawPixelBuffer { : data(NULL), size(0), stride(0) {} }; -struct ColorSpace { - enum PrimaryID { - // The indices are equal to the values specified in T-REC H.273 Table 2. - PRIMARYID_BT709 = 1, - PRIMARYID_UNSPECIFIED = 2, - PRIMARYID_BT470M = 4, - PRIMARYID_BT470BG = 5, - PRIMARYID_SMPTE170M = 6, // Identical to BT601 - PRIMARYID_SMPTE240M = 7, - PRIMARYID_FILM = 8, - PRIMARYID_BT2020 = 9, - PRIMARYID_SMPTEST428 = 10, - PRIMARYID_SMPTEST431 = 11, - PRIMARYID_SMPTEST432 = 12, - PRIMARYID_JEDECP22 = 22, // Identical to EBU3213-E - }; - - enum RangeID { - // The indices are equal to the values specified at - // https://www.webmproject.org/docs/container/#colour for the element Range. - RANGEID_INVALID = 0, - // Limited Rec. 709 color range with RGB values ranging from 16 to 235. - RANGEID_LIMITED = 1, - // Full RGB color range with RGB valees from 0 to 255. - RANGEID_FULL = 2, - // Range is defined by MatrixCoefficients/TransferCharacteristics. - RANGEID_DERIVED = 3, - }; - - enum MatrixID { - // The indices are equal to the values specified in T-REC H.273 Table 4. - MATRIXID_RGB = 0, - MATRIXID_BT709 = 1, - MATRIXID_UNSPECIFIED = 2, - MATRIXID_FCC = 4, - MATRIXID_BT470BG = 5, - MATRIXID_SMPTE170M = 6, - MATRIXID_SMPTE240M = 7, - MATRIXID_YCOCG = 8, - MATRIXID_BT2020_NCL = 9, - MATRIXID_BT2020_CL = 10, - MATRIXID_SMPTE2085 = 11, - MATRIXID_CDNCLS = 12, - MATRIXID_CDCLS = 13, - MATRIXID_BT2100_ICTCP = 14, - }; - - enum TransferID { - // The indices are equal to the values specified in T-REC H.273 Table 3. - TRANSFERID_BT709 = 1, - TRANSFERID_UNSPECIFIED = 2, - TRANSFERID_GAMMA22 = 4, - TRANSFERID_GAMMA28 = 5, - TRANSFERID_SMPTE170M = 6, - TRANSFERID_SMPTE240M = 7, - TRANSFERID_LINEAR = 8, - TRANSFERID_LOG = 9, - TRANSFERID_LOG_SQRT = 10, - TRANSFERID_IEC61966_2_4 = 11, - TRANSFERID_BT1361_ECG = 12, - TRANSFERID_IEC61966_2_1 = 13, - TRANSFERID_BT2020_10 = 14, - TRANSFERID_BT2020_12 = 15, - TRANSFERID_SMPTEST2084 = 16, - TRANSFERID_SMPTEST428 = 17, - TRANSFERID_ARIB_STD_B67 = 18, - }; - - PrimaryID primaries; - TransferID transfer; - MatrixID matrix; - RangeID range; - - ColorSpace() - : primaries(PRIMARYID_UNSPECIFIED), transfer(TRANSFERID_UNSPECIFIED), - matrix(MATRIXID_UNSPECIFIED), range(RANGEID_INVALID) {} -}; - /** * This structure defines underlying detailed video frame data of @ref agora::rtc::IVideoFrame * @@ -173,7 +98,7 @@ struct VideoFrameData { int width; int height; int rotation; - ColorSpace color_space; + agora::media::base::ColorSpace color_space; int64_t timestamp_ms; // Capture time in milli-seconds }; diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoMixerSource.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoMixerSource.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoTrack.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoTrack.h old mode 100755 new mode 100644 index 628329dbc..ea36ee93e --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoTrack.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoTrack.h @@ -26,6 +26,65 @@ class IVideoEncodedFrameObserver; class IMediaPacketReceiver; class IVideoSinkBase; +enum StreamLayerIndexInternal { + STREAM_LAYER_1 = 1, + STREAM_LAYER_2 = 2, + STREAM_LAYER_3 = 3, + STREAM_LAYER_4 = 4, + STREAM_LAYER_5 = 5, + STREAM_LAYER_6 = 6, + STREAM_LOW = 7, + STREAM_LAYER_COUNT_MAX = 8 + }; + +struct StreamLayerConfigInternal { + VideoDimensions dimensions; + int framerate; + int bitrate_kbps; + bool enable; + StreamLayerConfigInternal() : dimensions(0, 0), framerate(0), bitrate_kbps(STANDARD_BITRATE), enable(false) {} + StreamLayerConfigInternal(const StreamLayerConfigInternal& other) : dimensions(other.dimensions), framerate(other.framerate), bitrate_kbps(other.bitrate_kbps), enable(other.enable) {} + bool operator==(const StreamLayerConfigInternal& rhs) const { + return dimensions == rhs.dimensions && bitrate_kbps == rhs.bitrate_kbps && framerate == rhs.framerate && enable == rhs.enable; + } + + StreamLayerConfigInternal& operator=(const SimulcastConfig::StreamLayerConfig& slc) { + dimensions = slc.dimensions; + framerate = slc.framerate; + enable = slc.enable; + return *this; + } + + void reset() { + dimensions.width = 0; + dimensions.height = 0; + framerate = 0; + bitrate_kbps = STANDARD_BITRATE; + enable = false; + } +}; + +struct SimulcastConfigInternal { + StreamLayerConfigInternal simulcastlayerConfigs[STREAM_LAYER_COUNT_MAX]; + + void reset() { + for (int i = STREAM_LAYER_1; i < STREAM_LAYER_COUNT_MAX; i++) { + simulcastlayerConfigs[i].reset(); + } + } + + bool operator==(const SimulcastConfigInternal& rhs) const { + for (int i = 0; i < STREAM_LAYER_COUNT_MAX; i++) { + if (simulcastlayerConfigs[i] == rhs.simulcastlayerConfigs[i]) { + continue; + } else { + return false; + } + } + return true; + } +}; + enum VideoTrackType { LOCAL_VIDEO_TRACK, REMOTE_VIDEO_TRACK, @@ -149,6 +208,12 @@ class IVideoTrack : public RefCountInterface { ~IVideoTrack() {} }; +struct SimulcastStreamProfile { + int width; + int height; + int framerate; + int bitrate; +}; /** * The statistics of the local video track. */ @@ -255,6 +320,8 @@ struct LocalVideoTrackStats { /** The brightness level of the video image captured by the local camera. See #CAPTURE_BRIGHTNESS_LEVEL_TYPE. */ CAPTURE_BRIGHTNESS_LEVEL_TYPE capture_brightness_level; + + SimulcastStreamProfile simulcast_stream_profile[STREAM_LAYER_COUNT_MAX]; LocalVideoTrackStats() : number_of_streams(0), bytes_major_stream(0), @@ -336,7 +403,7 @@ class ILocalVideoTrack : public IVideoTrack { * - 0: Success. * - < 0: Failure. */ - virtual int setSimulcastStreamMode(SIMULCAST_STREAM_MODE mode, const SimulcastStreamConfig& config, aosl_ref_t ares = AOSL_REF_INVALID) = 0; + virtual int setSimulcastStreamMode(SIMULCAST_STREAM_MODE mode, const SimulcastConfigInternal& config, aosl_ref_t ares = AOSL_REF_INVALID) = 0; /** * Gets the state of the local video stream. @@ -388,6 +455,9 @@ struct RemoteVideoTrackStats { * The bitrate (Kbps) received in the reported interval. */ int receivedBitrate; + /** The decoder input frame rate (fps) of the remote video track. + */ + int decoderInputFrameRate; /** The decoder output frame rate (fps) of the remote video track. */ int decoderOutputFrameRate; @@ -457,13 +527,17 @@ struct RemoteVideoTrackStats { decoder vender id, VideoCodecVenderId */ uint32_t decoder_vender_id; + /** + The decoder codec type of the remote video track + */ + uint32_t decoder_type; RemoteVideoTrackStats() : uid(0), delay(0), width(0), height(0), - receivedBitrate(0), decoderOutputFrameRate(0), rendererOutputFrameRate(0), + receivedBitrate(0), decoderInputFrameRate(0), decoderOutputFrameRate(0), rendererOutputFrameRate(0), frameLossRate(0), packetLossRate(0), rxStreamType(VIDEO_STREAM_HIGH), totalFrozenTime(0), frozenRate(0), received_bytes(0), totalDecodedFrames(0), avSyncTimeMs(0), downlink_process_time_ms(0), frame_render_delay_ms(0), totalActiveTime(0), - publishDuration(0), vqa_mos(0), vqa_avg_cost_ms(0), decoder_vender_id(0) {} + publishDuration(0), vqa_mos(0), vqa_avg_cost_ms(0), decoder_vender_id(0), decoder_type(0) {} }; /** diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/PLACEHOLDER b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/PLACEHOLDER deleted file mode 100644 index ae2c9d75b..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/PLACEHOLDER +++ /dev/null @@ -1 +0,0 @@ -# copy agora headers here \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/Makefile b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/Makefile old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_alloca.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_alloca.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_angel.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_angel.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_ares.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_ares.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_async.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_async.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_atomic.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_atomic.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_audio.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_audio.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_byteswap.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_byteswap.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_data.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_data.h old mode 100755 new mode 100644 index 5bc7cbe5b..3eca075eb --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_data.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_data.h @@ -30,15 +30,46 @@ typedef enum { aosl_dt_vbuf, } aosl_dt_t; +/* data destructor */ +typedef void (*aosl_data_dtor_t) (void *ptr, size_t len); + /** * Create an data object with the specified parameters. * Parameters: * len: the data length; + * dtor: the data buffer destructor function: + * you may want to free some members or call + * the C++ destructor function here; * Return value: * non-NULL: the data object pointer; * NULL: failed with aosl_errno set; **/ -extern __aosl_api__ aosl_data_t aosl_data_create (size_t len); +extern __aosl_api__ aosl_data_t aosl_data_create (size_t len, aosl_data_dtor_t dtor); + +/* user defined data free function */ +typedef void (*aosl_data_user_free_t) (void *ptr, size_t len); + +/** + * Create an data object from the user data buffer pointer. + * Parameters: + * ptr: the data pointer; + * len: the data length; + * dtor: the data buffer free function: + * 1. A libc 'free' like function + * We will take the ownership of the memory pointed by + * ptr, and will invoke the specified destructor when + * finished using. + * 2. An empty function like void myfree (void *ptr, size_t len) {} + * If the memory pointed by ptr is a long life cycle + * memory but does not need to be freed at all, like + * a global data segment based memory, then you can + * pass an empty function pointer as the dtor arg. + * + * Return value: + * non-NULL: the data object pointer; + * NULL: failed with aosl_errno set; + **/ +extern __aosl_api__ aosl_data_t aosl_data_user_create (void *ptr, size_t len, aosl_data_user_free_t dtor); /** * Get the data object type. @@ -70,6 +101,15 @@ extern __aosl_api__ int aosl_data_get (aosl_data_t d); **/ extern __aosl_api__ int aosl_data_put (aosl_data_t d); +/** + * Get the data object usage count. + * Parameters: + * data: the data object; + * Return value: + * the current usage count; + **/ +extern __aosl_api__ int aosl_data_usage (aosl_data_t d); + /** * Get the data pointer of a data object. * Parameters: diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_defs.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_defs.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_display.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_display.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_dq.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_dq.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_errno.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_errno.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_fcntl.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_fcntl.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_file.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_file.h old mode 100755 new mode 100644 index 6847472ae..dcf163ebd --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_file.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_file.h @@ -227,11 +227,12 @@ extern __aosl_api__ int aosl_file_alseek_argv (aosl_fd_t fd, off_t offset, int w * d_ret: the data object for holding return value, the * length must >= sizeof (ssize_t); * d_buf: the buffer for holding the read data; + * buf_off: the buffer offset for holding the read data; * Return value: * <0: failed with aosl_errno set; * 0: async read issued successfully; **/ -extern __aosl_api__ int aosl_co_file_read (aosl_fd_t fd, aosl_data_t d_ret, aosl_data_t d_buf); +extern __aosl_api__ int aosl_co_file_read (aosl_fd_t fd, aosl_data_t d_ret, aosl_data_t d_buf, uintptr_t buf_off); /** * The regular file write function which supports coroutine. diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_http.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_http.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_input.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_input.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_integer_wrappings.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_integer_wrappings.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_jni.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_jni.h old mode 100755 new mode 100644 index cd5164930..43a7d2946 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_jni.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_jni.h @@ -28,7 +28,7 @@ extern "C" { extern __aosl_api__ JavaVM *aosl_java_vm (); extern __aosl_api__ int aosl_set_java_vm (JavaVM *jvm); -extern __aosl_api__ JNIEnv *aosl_this_jni_env (); +extern __aosl_api__ JNIEnv *aosl_this_jni_env (int *attached_p); /** * Set Java Application Context. @@ -44,6 +44,7 @@ extern __aosl_api__ JNIEnv *aosl_this_jni_env (); **/ extern __aosl_api__ int aosl_java_set_context (jobject ctxt); +extern __aosl_api__ void aosl_thread_java_detach (); #ifdef __cplusplus diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_kobj.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_kobj.h old mode 100755 new mode 100644 index 8023e8f6d..ccb86f8c1 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_kobj.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_kobj.h @@ -398,11 +398,9 @@ typedef struct { * argc: the various args count, passed when registering; * argv: the various args vector, passed as various args when registering; * Return value: - * 0: successfully; - * <0: failed with aosl_errno set accordingly. + * None. **/ typedef void (*aosl_kobj_notify_t) (aosl_refobj_t robj, const char *dirpath, const char *name, void *notif_data, uintptr_t argc, uintptr_t argv []); -typedef void (*aosl_kobj_notify_dtor_t) (uintptr_t argc, uintptr_t argv []); /** * Register a notification of the kobject specified by dfd + name for monitoring changes. @@ -410,7 +408,7 @@ typedef void (*aosl_kobj_notify_dtor_t) (uintptr_t argc, uintptr_t argv []); * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: * 1. if the name starts with a '/', then directory is root; * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; + * name: the object name; * touch: 0: notify only when changed; !0: notify anyway; * qid: the mpq you want the target function to be invoked in, must be valid; * ref: specify a ref object just like the queue operation of an mpq; @@ -424,7 +422,7 @@ typedef void (*aosl_kobj_notify_dtor_t) (uintptr_t argc, uintptr_t argv []); * NULL: failed with aosl_errno set accordingly. * The return value only used for unregister, no other usage. **/ -extern __aosl_api__ void *aosl_kobj_notify_register (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_t f, aosl_kobj_notify_dtor_t dtor, uintptr_t argc, ...); +extern __aosl_api__ void *aosl_kobj_notify_register (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_t f, aosl_obj_dtor_t dtor, uintptr_t argc, ...); /** * Register a notification of the kobject specified by dfd + name for monitoring changes. @@ -432,7 +430,7 @@ extern __aosl_api__ void *aosl_kobj_notify_register (aosl_kfd_t dfd, const char * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: * 1. if the name starts with a '/', then directory is root; * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; + * name: the object name; * touch: 0: notify only when changed; !0: notify anyway; * qid: the mpq you want the target function to be invoked in, must be valid; * ref: specify a ref object just like the queue operation of an mpq; @@ -447,7 +445,7 @@ extern __aosl_api__ void *aosl_kobj_notify_register (aosl_kfd_t dfd, const char * NULL: failed with aosl_errno set accordingly. * The return value only used for unregister, no other usage. **/ -extern __aosl_api__ void *aosl_kobj_notify_register_args (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_t f, aosl_kobj_notify_dtor_t dtor, uintptr_t argc, va_list args); +extern __aosl_api__ void *aosl_kobj_notify_register_args (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_t f, aosl_obj_dtor_t dtor, uintptr_t argc, va_list args); /** * Register a notification of the kobject specified by dfd + name for monitoring changes. @@ -455,7 +453,7 @@ extern __aosl_api__ void *aosl_kobj_notify_register_args (aosl_kfd_t dfd, const * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: * 1. if the name starts with a '/', then directory is root; * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; + * name: the object name; * touch: 0: notify only when changed; !0: notify anyway; * qid: the mpq you want the target function to be invoked in, must be valid; * ref: specify a ref object just like the queue operation of an mpq; @@ -470,15 +468,15 @@ extern __aosl_api__ void *aosl_kobj_notify_register_args (aosl_kfd_t dfd, const * NULL: failed with aosl_errno set accordingly. * The return value only used for unregister, no other usage. **/ -extern __aosl_api__ void *aosl_kobj_notify_register_argv (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_t f, aosl_kobj_notify_dtor_t dtor, uintptr_t argc, uintptr_t argv []); +extern __aosl_api__ void *aosl_kobj_notify_register_argv (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_t f, aosl_obj_dtor_t dtor, uintptr_t argc, uintptr_t argv []); /** - * Unregister a notification of the kobject specified by dfd + name for monitoring changes. + * Unregister a notification of the kobject specified by dfd + name. * Parameters: * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: * 1. if the name starts with a '/', then directory is root; * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; + * name: the object name; * handle: the handle returned by above register functions; * Return value: * 0: successfully; diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_list.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_list.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_log.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_log.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_marshalling.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_marshalling.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mm.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mm.h old mode 100755 new mode 100644 index 5d58b35b9..97b7b0fe4 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mm.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mm.h @@ -22,6 +22,256 @@ extern "C" { #endif +/** + * aosl memory management malloc like function + * Note: this is memory pool based implementation, so it + * can decrease the fragmentation. + * Parameters: + * size: the allocation size in bytes; + * Return Value: + * non-NULL: success + * NULL: failure with aosl_errno set + * Remarks: + * The memory allocated by this function must be freed + * via aosl_mm_free when finished using. + **/ +extern __aosl_api__ void *aosl_mm_malloc (size_t size); + +/** + * aosl memory management realloc like function + * Note: this is memory pool based implementation, so it + * can decrease the fragmentation. + * Parameters: + * ptr: the old pointer wanting to realloc; + * size: the new allocation size in bytes; + * Return Value: + * non-NULL: success + * NULL: failure with aosl_errno set + * Remarks: + * The contents will be unchanged in the range from the + * start of the region up to the minimum of the old and + * new sizes; + * If the new size is larger than the old size, the added + * memory will not be initialized; + * If ptr is NULL, then the call is equivalent to + * aosl_mm_malloc(size), for all values of size; + * If size is equal to zero, and ptr is not NULL, then the + * call is equivalent to aosl_mm_free(ptr); + * Unless ptr is NULL, it must have been returned by an + * earlier call to aosl_mm_malloc, aosl_mm_calloc, or + * aosl_mm_realloc; + * If this function fails, the original block is left + * untouched, it is not freed or moved; + * The memory allocated by this function must be freed + * via aosl_mm_free when finished using. + **/ +extern __aosl_api__ void *aosl_mm_realloc (void *ptr, size_t size); + +/** + * aosl memory management calloc like function + * Note: this is memory pool based implementation, so it + * can decrease the fragmentation. + * Parameters: + * nmemb: number of array elements count; + * size: the element size in bytes; + * Return Value: + * non-NULL: success + * NULL: failure with aosl_errno set + * Remarks: + * This function allocates memory for an array of nmemb + * elements of size bytes each and returns a pointer to + * the allocated memory, and the memory is set to zero; + * If nmemb or size is 0, then returns NULL; + * The memory allocated by this function must be freed + * via aosl_mm_free when finished using. + **/ +extern __aosl_api__ void *aosl_mm_calloc (size_t nmemb, size_t size); + +/** + * aosl memory management free like function + * Note: this is memory pool based implementation, so it + * can decrease the fragmentation. + * Parameters: + * ptr: the allocated pointer by aosl_mm_malloc; + * Return Value: + * None. + * Remarks: + * Do NOT try to free a pointer which is not allocated + * by aosl_mm_malloc via this function. + **/ +extern __aosl_api__ void aosl_mm_free (void *ptr); + +/** + * Preallocate the objects count to threshold for the memory pool specified by size. + * Note: this is memory pool based implementation, so it + * can decrease the fragmentation. + * Parameters: + * size: specify which the memory pool will be set threshold; + * threshold: specify the memory objects count will be preallocated; + * Return Value: + * 0: success + * <0: failure with aosl_errno set + * Remarks: + * If set the threshold first, then the following first time + * allocation operation will be faster than normal. + **/ +extern __aosl_api__ int aosl_mm_set_threshold (size_t size, size_t threshold); + +/** + * Set the max objects count to max_val for the memory pool specified by size. + * Note: this is memory pool based implementation, so it + * can decrease the fragmentation. + * Parameters: + * size: specify which the memory pool will be set threshold; + * max_val: specify the max memory objects count; + * Return Value: + * 0: success + * <0: failure with aosl_errno set + * Remarks: + * If the max objects were allocated, and the following allocation + * will return NULL if no objects was freed. + **/ +extern __aosl_api__ int aosl_mm_set_max (size_t size, size_t max_val); + +/** + * Shrink the memory pool specified by the size parameter. + * Parameters: + * size: specify which the memory pool will be shrinked; + * Return Value: + * None. + **/ +extern __aosl_api__ void aosl_mm_shrink (size_t size); + +/** + * Shrink all the created memory pools. + * Parameters: + * None. + * Return Value: + * None. + **/ +extern __aosl_api__ void aosl_mm_shrink_all (void); + +/* the aosl freelist object type */ +typedef struct _aosl_freelist_ *aosl_freelist_t; + +/** + * Create a freelist object for efficient memory management. + * Note: this is memory pool based implementation, so it + * can decrease the fragmentation. + * Parameters: + * obj_size: the memory object size in bytes for this freelist; + * namefmt: printf like format for the freelist object name; + * ...: printf like ... args; + * Return Value: + * non-NULL: success + * NULL: failure with aosl_errno set + * Remarks: + * The max name length of freelist object is 32 including + * the final '\0'. + **/ +extern __aosl_api__ aosl_freelist_t aosl_freelist_create (size_t obj_size, const char *namefmt, ...); + +/** + * Create a freelist object for efficient memory management. + * Note: this is memory pool based implementation, so it + * can decrease the fragmentation. + * Parameters: + * obj_size: the memory object size in bytes for this freelist; + * namefmt: vprintf like format for the freelist object name; + * args: vprintf like args; + * Return Value: + * non-NULL: success + * NULL: failure with aosl_errno set + * Remarks: + * The max name length of freelist object is 32 including + * the final '\0'. + **/ +extern __aosl_api__ aosl_freelist_t aosl_freelist_create_args (size_t obj_size, const char *namefmt, va_list args); + +/** + * Allocate memory from the specified freelist object. + * Note: this is memory pool based implementation, so it + * can decrease the fragmentation. + * Parameters: + * fl: the freelist object; + * Return Value: + * non-NULL: success + * NULL: failure with aosl_errno set + * Remarks: + * The allocated memory must be freed by aosl_freelist_free + * after finished using. + **/ +extern __aosl_api__ void *aosl_freelist_alloc (aosl_freelist_t fl); + +/** + * Free memory to the specified freelist object. + * Note: this is memory pool based implementation, so it + * can decrease the fragmentation. + * Parameters: + * fl: the freelist object; + * ptr: the memory pointer will be freed; + * Return Value: + * None. + * Remarks: + * The ptr must be allocated from fl. + **/ +extern __aosl_api__ void aosl_freelist_free (aosl_freelist_t fl, void *ptr); + +/** + * Preallocate the objects count to threshold for the specified freelist object. + * Note: this is memory pool based implementation, so it + * can decrease the fragmentation. + * Parameters: + * fl: the freelist object which will be set threshold; + * threshold: specify the memory objects count will be preallocated; + * Return Value: + * 0: success + * <0: failure with aosl_errno set + * Remarks: + * If set the threshold first, then the following first time + * allocation operation will be faster than normal. + **/ +extern __aosl_api__ int aosl_freelist_set_threshold (aosl_freelist_t fl, size_t threshold); + +/** + * Set the max objects count to max_val for the specified freelist object. + * Note: this is memory pool based implementation, so it + * can decrease the fragmentation. + * Parameters: + * fl: the freelist object which will be set max memory objects count; + * max_val: specify the max memory objects count; + * Return Value: + * 0: success + * <0: failure with aosl_errno set + * Remarks: + * If the max objects were allocated, and the following allocation + * will return NULL if no objects was freed. + **/ +extern __aosl_api__ int aosl_freelist_set_max (aosl_freelist_t fl, size_t max_val); + +/** + * Shrink the freelist specified by the fl. + * Parameters: + * fl: the freelist object which will be shrinked; + * Return Value: + * None. + **/ +extern __aosl_api__ void aosl_freelist_shrink (aosl_freelist_t fl); + +/** + * Destroy the freelist specified by the fl. + * Parameters: + * fl: the freelist object which will be destroyed; + * Return Value: + * 0: success + * <0: failure with aosl_errno set + * Remarks: + * If there are allocated objects from this freelist, then it + * could not be destroyed, so the destroy call would fail. + **/ +extern __aosl_api__ int aosl_freelist_destroy (aosl_freelist_t fl); + + extern __aosl_api__ void *aosl_malloc (size_t size); extern __aosl_api__ void aosl_free (void *ptr); extern __aosl_api__ void *aosl_calloc (size_t nmemb, size_t size); diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_module.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_module.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq.h old mode 100755 new mode 100644 index dcda4bc6f..3dc8c1b95 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq.h @@ -409,19 +409,50 @@ extern __aosl_api__ int aosl_mpq_last_costs (aosl_ts_t *load_p, aosl_ts_t *idle_ */ extern __aosl_api__ int aosl_mpq_exec_counters (uint64_t *funcs_count_p, uint64_t *timers_count_p, uint64_t *fds_count_p); + +typedef struct { + uint32_t fw_avg; /* function average wait time */ + uint32_t fw_worst; /* function worst wait time */ + uint32_t fe_avg; /* function average exec time */ + uint32_t fe_worst; /* function worst exec time */ + uint32_t f_count; /* executed functions count */ +} aosl_ftimes_t; + +/** + * Get the average & worst function wait & execution times of this mpq + * Parameters: + * qid: the mpq id + * ftimes: the variable address for saving the function times + * reset: whether reset the counters, 0 for not clear, other values clear + * Return value: + * <0: indicates error, check aosl_errno for detail + * 0: the average function execution time was saved to *fe_*_p + */ +extern __aosl_api__ int aosl_mpq_ftimes (aosl_mpq_t qid, aosl_ftimes_t *ftimes, int reset); + /** * Get the average & worst function wait time of this mpq * Parameters: * qid: the mpq id - * fw_avg_p: the variable for saving the average function wait time - * fw_worst_p: the variable for saving the worst function wait time + * fw_avg_p: the variable address for saving the average function wait time + * fw_worst_p: the variable address for saving the worst function wait time * reset: whether reset the counters, 0 for not clear, other values clear * Return value: * <0: indicates error, check aosl_errno for detail - * 0: the average function wait time was saved to *fwtime_p + * 0: the average function wait time was saved to *fw_*_p */ extern __aosl_api__ int aosl_mpq_fwtime (aosl_mpq_t qid, uint32_t *fw_avg_p, uint32_t *fw_worst_p, int reset); +/** + * Get the name of the current running mpq + * Parameters: + * None. + * Return value: + * non-NULL: the running mpq name; + * NULL: the running thread is not an mpq thread; + */ +extern __aosl_api__ const char *aosl_mpq_this_name (void); + /** * Invoking this function will enter the infinite run loop of current thread's multiplex queue. * Generally, this function is only used in the non-mpq thread, such as the main thread. diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_fd.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_fd.h old mode 100755 new mode 100644 index 96dfd3e0a..2ac67539d --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_fd.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_fd.h @@ -112,10 +112,44 @@ extern __aosl_api__ int aosl_mpq_enable_fd (aosl_fd_t fd); extern __aosl_api__ ssize_t aosl_write (aosl_fd_t fd, const void *buf, size_t len); -#define AOSL_MPQ_FD_IN 0x1 -#define AOSL_MPQ_FD_OUT 0x2 +#define AOSL_FD_EVM_SET 0 /* fd event mask set */ +#define AOSL_FD_EVM_ADD 1 /* fd event mask add */ +#define AOSL_FD_EVM_DEL 2 /* fd event mask del */ -extern __aosl_api__ int aosl_mpq_modify_fd (aosl_fd_t fd, int eventmask); +#define AOSL_FD_EV_I 0x1 /* fd event input */ +#define AOSL_FD_EV_O 0x2 /* fd event output */ + +/** + * Modify the fd listening event mask. + * Parameters: + * fd: the fd you want to modify event mask + * ctrl: one of AOSL_FD_EVM_SET, AOSL_FD_EVM_ADD or AOSL_FD_EVM_DEL + * for setting, adding or deleting event mask respectively + * eventmask: bitmask of AOSL_FD_EV_I and AOSL_FD_EV_O + * Return value: + * <0: error occured, and aosl_errno indicates which error; + * 0: call successful, and '*arg' is value of the N-th argument; + * Remarks: + * This function is used for flow control normally, if we do not + * want to receive data from fd now, then we can remove the bit + * AOSL_FD_EV_I from the event mask, and add it again later + * when needed. + **/ +extern __aosl_api__ int aosl_fd_evm_ctrl (aosl_fd_t fd, int ctrl, int eventmask); + +/** + * Clear the fd error. + * Parameters: + * fd: the fd you want to clear error + * Return value: + * <0: error occured, and aosl_errno indicates which error; + * 0: call successful, and '*arg' is value of the N-th argument; + * Remarks: + * The fd errors are also edge triggered, so if some error is not real + * error in fact, you must clear the error manually, otherwise the fd + * would be in an incorrect state and could not work normally. + **/ +extern __aosl_api__ int aosl_fd_clear_err (aosl_fd_t fd); /** * Get the N-th argument of the mpq attached fd. @@ -131,9 +165,6 @@ extern __aosl_api__ int aosl_mpq_fd_arg (aosl_fd_t fd, uintptr_t n, uintptr_t *a extern __aosl_api__ int aosl_mpq_disable_fd (aosl_fd_t fd); extern __aosl_api__ int aosl_mpq_del_fd (aosl_fd_t fd); -extern __aosl_api__ int aosl_fd_clear_err (aosl_fd_t fd); -extern __aosl_api__ int aosl_fd_no_auto_disable (aosl_fd_t fd); -extern __aosl_api__ int aosl_fd_ignore_err (aosl_fd_t fd, int err); extern __aosl_api__ int aosl_close (aosl_fd_t fd); @@ -144,11 +175,12 @@ extern __aosl_api__ int aosl_close (aosl_fd_t fd); * d_ret: the data object for holding return value, the * length must >= sizeof (ssize_t); * d_buf: the buffer for holding the read data; + * buf_off: the buffer offset for holding the read data; * Return value: * <0: failed with aosl_errno set; * 0: async read issued successfully; **/ -extern __aosl_api__ int aosl_co_read (aosl_fd_t fd, aosl_data_t d_ret, aosl_data_t d_buf); +extern __aosl_api__ int aosl_co_read (aosl_fd_t fd, aosl_data_t d_ret, aosl_data_t d_buf, uintptr_t buf_off); /** * The I/O device write function which supports coroutine. diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_net.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_net.h old mode 100755 new mode 100644 index 69c2f3c3f..82763e049 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_net.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_net.h @@ -240,12 +240,13 @@ extern __aosl_api__ int aosl_co_accept (aosl_fd_t fd, aosl_data_t d_ret, aosl_da * d_ret: the data object for holding return value, the * length must >= sizeof (ssize_t); * d_buf: the buffer for holding the read data; + * buf_off: the buffer offset for holding the read data; * flags: the flags same as recv syscall; * Return value: * <0: failed with aosl_errno set; * 0: async read issued successfully; **/ -extern __aosl_api__ int aosl_co_recv (aosl_fd_t fd, aosl_data_t d_ret, aosl_data_t d_buf, int flags); +extern __aosl_api__ int aosl_co_recv (aosl_fd_t fd, aosl_data_t d_ret, aosl_data_t d_buf, uintptr_t buf_off, int flags); /** * The socket recv function which supports coroutine. @@ -254,6 +255,7 @@ extern __aosl_api__ int aosl_co_recv (aosl_fd_t fd, aosl_data_t d_ret, aosl_data * d_ret: the data object for holding return value, the * length must >= sizeof (ssize_t); * d_buf: the buffer for holding the read data; + * buf_off: the buffer offset for holding the read data; * flags: the flags same as recvfrom syscall; * d_addr: the data object for holding the remote address, * the len must >= sizeof (aosl_sk_addr_and_len_t); @@ -261,7 +263,7 @@ extern __aosl_api__ int aosl_co_recv (aosl_fd_t fd, aosl_data_t d_ret, aosl_data * <0: failed with aosl_errno set; * 0: async read issued successfully; **/ -extern __aosl_api__ int aosl_co_recvfrom (aosl_fd_t fd, aosl_data_t d_ret, aosl_data_t d_buf, int flags, aosl_data_t d_addr); +extern __aosl_api__ int aosl_co_recvfrom (aosl_fd_t fd, aosl_data_t d_ret, aosl_data_t d_buf, uintptr_t buf_off, int flags, aosl_data_t d_addr); /** * The socket connect function which supports coroutine. diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_timer.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_timer.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpqp.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpqp.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_os.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_os.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_pmdf.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_pmdf.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_poll.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_poll.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_profile.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_profile.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_psb.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_psb.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_rbtree.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_rbtree.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_ref.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_ref.h old mode 100755 new mode 100644 index 166a9da3b..4a2f439fa --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_ref.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_ref.h @@ -114,6 +114,21 @@ extern __aosl_api__ int aosl_ref_write (aosl_ref_t ref, aosl_ref_func_t f, uintp extern __aosl_api__ int aosl_ref_write_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args); extern __aosl_api__ int aosl_ref_write_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []); +/** + * Hold the ref object and set it unsafe, then invoke the specified callback function. + * Parameter: + * ref: the ref object id; + * f: the callback function; + * argc: the args count + * ...: variable args + * Return value: + * 0: success + * <0: failure with aosl_errno set + **/ +extern __aosl_api__ int aosl_ref_unsafe (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...); +extern __aosl_api__ int aosl_ref_unsafe_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args); +extern __aosl_api__ int aosl_ref_unsafe_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []); + /** * Hold the ref object and set it maystall, then invoke the specified callback function. * Parameter: @@ -168,6 +183,21 @@ extern __aosl_api__ int aosl_refobj_read (aosl_refobj_t robj, aosl_ref_func_t f, extern __aosl_api__ int aosl_refobj_read_args (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, va_list args); extern __aosl_api__ int aosl_refobj_read_argv (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []); +/** + * Make sure set the ref object specified by robj unsafe, then invoke the specified callback function. + * Parameter: + * robj: the ref object itself; + * f: the callback function; + * argc: the args count + * ...: variable args + * Return value: + * 0: success + * <0: failure with aosl_errno set + **/ +extern __aosl_api__ int aosl_refobj_unsafe (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, ...); +extern __aosl_api__ int aosl_refobj_unsafe_args (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, va_list args); +extern __aosl_api__ int aosl_refobj_unsafe_argv (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []); + /** * Make sure set the ref object specified by robj maystall, then invoke the specified callback function. * Parameter: diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_route.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_route.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_sbus.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_sbus.h old mode 100755 new mode 100644 index b35123f2e..8e047859f --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_sbus.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_sbus.h @@ -16,6 +16,9 @@ #include #include +#include +#include +#include #ifdef __cplusplus @@ -25,15 +28,127 @@ extern "C" { /** - * Create a software bus. + * Create a software bus object. * Parameters: - * name: the software bus name; + * name: the software bus name; * Return value: - * the current reference count after get; + * 0: successfully; + * <0: failed with aosl_errno set accordingly. **/ extern __aosl_api__ int aosl_sbus_create (const char *name); +/** + * Action callback function for a bus object, which will be invoked when the bus has data to deliver. + * Parameters: + * robj: the ref object specified when registering; + * name: the bus object name; + * data: the bus data; + * argc: the various args count, passed when registering; + * argv: the various args vector, passed as various args when registering; + * Return value: + * None. + * Remarks: + * If we issue async operation which uses the data object in this callback function, we must increase + * the usage before issuing. + **/ +typedef void (*aosl_sbus_data_t) (aosl_refobj_t robj, const char *name, aosl_data_t data, uintptr_t argc, uintptr_t argv []); + + +/** + * Add an action of the bus object specified by name for processing data. + * Parameters: + * name: the bus object name; + * qid: the mpq you want the target function to be invoked in, if invalid, arbitrary general pool mpq; + * ref: specify a ref object just like the queue operation of an mpq; + * max: the max queued data object count, if exceeds then drop the eldest one automatically; + * f_name: specify the target function name; + * f: the target function; + * dtor: destructor which be invoked when delete the action; + * argc: the various args count; + * ...: the various args; + * Return value: + * non-NULL: successfully; + * NULL: failed with aosl_errno set accordingly. + * The return value only used for unregister, no other usage. + **/ +extern __aosl_api__ void *aosl_sbus_action_add (const char *name, aosl_mpq_t qid, aosl_ref_t ref, uintptr_t max, const char *f_name, aosl_sbus_data_t f, aosl_obj_dtor_t dtor, uintptr_t argc, ...); + +/** + * Add an action of the kobject specified by name for processing data. + * Parameters: + * name: the bus object name; + * qid: the mpq you want the target function to be invoked in, if invalid, arbitrary general pool mpq; + * ref: specify a ref object just like the queue operation of an mpq; + * max: the max queued data object count, if exceeds then drop the eldest one automatically; + * f_name: specify the target function name; + * f: the target function; + * dtor: destructor which be invoked when delete the action; + * argc: the various args count; + * args: the various args; + * Return value: + * Return value: + * non-NULL: successfully; + * NULL: failed with aosl_errno set accordingly. + * The return value only used for unregister, no other usage. + **/ +extern __aosl_api__ void *aosl_sbus_action_add_args (const char *name, aosl_mpq_t qid, aosl_ref_t ref, uintptr_t max, const char *f_name, aosl_sbus_data_t f, aosl_obj_dtor_t dtor, uintptr_t argc, va_list args); + +/** + * Add an action of the bus object specified by name for processing data. + * Parameters: + * name: the bus object name; + * qid: the mpq you want the target function to be invoked in, if invalid, arbitrary general pool mpq; + * ref: specify a ref object just like the queue operation of an mpq; + * max: the max queued data object count, if exceeds then drop the eldest one automatically; + * f_name: specify the target function name; + * f: the target function; + * dtor: destructor which be invoked when delete the action; + * argc: the various args count; + * argv: the various args vector; + * Return value: + * Return value: + * non-NULL: successfully; + * NULL: failed with aosl_errno set accordingly. + * The return value only used for unregister, no other usage. + **/ +extern __aosl_api__ void *aosl_sbus_action_add_argv (const char *name, aosl_mpq_t qid, aosl_ref_t ref, uintptr_t max, const char *f_name, aosl_sbus_data_t f, aosl_obj_dtor_t dtor, uintptr_t argc, uintptr_t argv []); + +/** + * Delete an action of the bus object specified by name. + * Parameters: + * name: the bus object name; + * h_action: the handle returned by the above add functions; + * Return value: + * 0: successfully; + * <0: failed with aosl_errno set accordingly. + **/ +extern __aosl_api__ int aosl_sbus_action_del (const char *name, void *h_action); +/** + * Send data to the bus object. + * Parameters: + * name: the bus object name; + * data: the data will be sent to bus; + * Return value: + * 0: successfully; + * <0: failed with aosl_errno set accordingly. + * Remarks: + * The function will increase the usage of data automatically, + * so the calling function can decrease the usage just after + * this function returns, and no need to worry about the async + * operations triggerd by this function. + **/ +extern __aosl_api__ int aosl_sbus_send (const char *name, aosl_data_t data); + +/** + * Delete the bus object specified by name. + * Parameters: + * name: the bus object name; + * Return value: + * 0: successfully; + * <0: failed with aosl_errno set accordingly. + **/ +extern __aosl_api__ int aosl_sbus_delete (const char *name); #ifdef __cplusplus diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_so.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_so.h old mode 100755 new mode 100644 index d3b922d16..049567700 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_so.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_so.h @@ -15,29 +15,31 @@ #include #include +#include #ifdef __cplusplus extern "C" { #endif +#define AOSL_SO_DEFAULT_VER (0) -extern __aosl_api__ int aosl_so_register (const char *name, const void *mod); +extern __aosl_api__ int aosl_so_register (const char *name, const void *mod, uintptr_t version); #if defined (__GNUC__) -#define AOSL_SO_REGISTER(name) \ +#define AOSL_SO_REGISTER_VER(name, version) \ static void __attribute__ ((constructor, used)) _##name##_so_reg_ctor (void) \ { \ - if (aosl_so_register (#name, (const void *)_##name##_so_reg_ctor) < 0) \ - aosl_printf ("SO register failed, so could not monitor it."); \ + if (aosl_so_register (#name, (const void *)_##name##_so_reg_ctor, version) < 0) \ + aosl_log (AOSL_LOG_WARNING, "so lib %s register failed, err %d.", #name, aosl_errno); \ } #elif defined (_MSC_VER) #pragma section (".CRT$XIG", long, read) -#define AOSL_SO_REGISTER(name) \ +#define AOSL_SO_REGISTER_VER(name, version) \ static int _##name##_so_reg_ctor (void) \ { \ - if (aosl_so_register (#name, (const void *)_##name##_so_reg_ctor) < 0) \ - aosl_printf ("SO register failed, so could not monitor it."); \ + if (aosl_so_register (#name, (const void *)_##name##_so_reg_ctor, version) < 0) \ + aosl_log (AOSL_LOG_WARNING, "so lib %s register failed, err %d.", #name, aosl_errno); \ return 0; \ } \ __declspec(allocate(".CRT$XIG")) int (*_##name##_so_module_ctor_f) (void) = _##name##_so_reg_ctor; @@ -45,6 +47,11 @@ extern __aosl_api__ int aosl_so_register (const char *name, const void *mod); #error Unsupported Toolchain! #endif +#if defined(AOSL_SO_REGISTER_VER) +#define AOSL_SO_REGISTER(name) \ + AOSL_SO_REGISTER_VER(name, AOSL_SO_DEFAULT_VER) +#endif + #ifdef __cplusplus } diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_socket.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_socket.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_task.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_task.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_thread.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_thread.h old mode 100755 new mode 100644 index 3a28c693a..ecfbb25ec --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_thread.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_thread.h @@ -72,6 +72,20 @@ extern __aosl_api__ int aosl_thrd_getname (aosl_thrdid_t thrd, char *namebuf, si **/ extern __aosl_api__ int aosl_get_thread_times (aosl_osthrd_t thrd, int *running, uint64_t *system_us, uint64_t *user_us); +/** + * Get the mpq thread flags. + * Parameters: + * thrd: the retrieving thread id + * Linux: the thread tid + * XNU: the mach thread id, type is mach_port_t + * Windows: the Windows thread id, type is DWORD + * q_flags: the mpq flags + * Return Value: + * 0: success + * <0: failure with aosl_errno set + **/ +extern __aosl_api__ int aosl_thrd_getflags (aosl_thrdid_t thrd_id, int *q_flags); + typedef uintptr_t aosl_tls_key_t; extern __aosl_api__ int aosl_tls_key_create (aosl_tls_key_t *key, void (*dtor) (void *)); diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_time.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_time.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_types.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_types.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_utils.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_utils.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_value.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_value.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_vcodec.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_vcodec.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_version.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_version.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_video.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_video.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_xdump.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_xdump.h old mode 100755 new mode 100644 index ee886dd52..7aa932755 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_xdump.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_xdump.h @@ -2,6 +2,7 @@ #define __AOSL_XDUMP_H__ #include +#include #ifdef __cplusplus extern "C" { @@ -10,6 +11,8 @@ extern "C" { /** * xdump callback info about crash: + * @module_ver: the module version + * @module_name: the module name * @log_file: the full path of log_file * @type: the dump type: * 0: crash @@ -20,11 +23,14 @@ extern "C" { #define AOSL_XDUMP_CRASH 0 #define AOSL_XDUMP_DEAD 1 typedef struct { + uintptr_t module_ver; + const char *module_name; const char *log_file; int type; void *crash_at; void *ld_begin; void *ld_end; + int q_flags; } xdump_info_t; typedef void (*xdump_cb_t)(const xdump_info_t *log_file); diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/Makefile b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/Makefile old mode 100755 new mode 100644 index a9acdd19e..14376d9c2 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/Makefile +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/Makefile @@ -6,7 +6,6 @@ header-y += aosl_mpq_timer_lambda.h header-y += aosl_ref_class.h header-y += aosl_task_class.h header-y += aosl_thread_class.h -header-y += aosl_usage_class.h header-y += aosl_kobj_class.h header-y += aosl_value_class.h header-y += aosl_data_class.h diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_ares_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_ares_class.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_async_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_async_class.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_data_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_data_class.h old mode 100755 new mode 100644 index f8cd8054b..edf9b265a --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_data_class.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_data_class.h @@ -15,6 +15,7 @@ #include +#include #include #include @@ -26,26 +27,30 @@ class aosl_data_class { aosl_data_t d; public: - aosl_data_class () + aosl_data_class (void) { d = NULL; } aosl_data_class (const aosl_data_class &src) { - d = src.d; - if (d != NULL) - aosl_data_get (d); + if (this != &src) { + d = src.d; + if (d != NULL) + aosl_data_get (d); + } } aosl_data_class &operator = (const aosl_data_class &src) { - if (d != NULL) - aosl_data_put (d); + if (this != &src) { + if (d != NULL) + aosl_data_put (d); - d = src.d; - if (d != NULL) - aosl_data_get (d); + d = src.d; + if (d != NULL) + aosl_data_get (d); + } return *this; } @@ -55,13 +60,6 @@ class aosl_data_class { return d; } - aosl_data_t detach () - { - aosl_data_t data = d; - d = NULL; - return data; - } - void *ptr () const { if (d != NULL) @@ -87,17 +85,22 @@ class aosl_data_class { #if (__cplusplus >= 201103) || defined (_MSC_VER) aosl_data_class (aosl_data_class &&src) { - d = src.d; - src.d = NULL; + if (this != &src) { + d = src.d; + src.d = NULL; + } } aosl_data_class &operator = (aosl_data_class &&src) { - if (d != NULL) - aosl_data_put (d); + if (this != &src) { + if (d != NULL) + aosl_data_put (d); + + d = src.d; + src.d = NULL; + } - d = src.d; - src.d = NULL; return *this; } #endif /* C++11 */ @@ -105,31 +108,39 @@ class aosl_data_class { class aosl_data_buf: public aosl_data_class { public: + aosl_data_buf (void) + { + } + aosl_data_buf (size_t sz) { - if (sz > 0) { - d = aosl_data_create (sz); - if (d == NULL) - abort (); - } + d = aosl_data_create (sz, NULL); + if (d == NULL) + abort (); } aosl_data_buf (const void *src, size_t len) { - if (len > 0) { - d = aosl_data_create (len); - if (d == NULL) - abort (); + d = aosl_data_create (len, NULL); + if (d == NULL) + abort (); + if (len > 0) memcpy (ptr (), src, len); - } + } + + aosl_data_buf (void *ptr, size_t len, aosl_data_user_free_t dtor) + { + d = aosl_data_user_create (ptr, len, dtor); + if (d == NULL) + abort (); } aosl_data_buf (const char *str) { if (str != NULL) { size_t str_l = strlen (str); - d = aosl_data_create (str_l + 1); + d = aosl_data_create (str_l + 1, NULL); if (d == NULL) abort (); @@ -137,6 +148,20 @@ class aosl_data_buf: public aosl_data_class { } } + aosl_data_buf (char *str, aosl_data_user_free_t dtor) + { + size_t len; + if (str != NULL) { + len = strlen (str) + 1; + } else { + len = 0; + } + + d = aosl_data_user_create (str, len, dtor); + if (d == NULL) + abort (); + } + aosl_data_buf (aosl_data_t src) { d = src; @@ -146,9 +171,11 @@ class aosl_data_buf: public aosl_data_class { aosl_data_buf (const aosl_data_buf &src) { - d = src.d; - if (d != NULL) - aosl_data_get (d); + if (this != &src) { + d = src.d; + if (d != NULL) + aosl_data_get (d); + } } aosl_data_buf &operator = (const char *str) @@ -160,7 +187,7 @@ class aosl_data_buf: public aosl_data_class { if (str != NULL) { size_t str_l = strlen (str); - d = aosl_data_create (str_l + 1); + d = aosl_data_create (str_l + 1, NULL); if (d == NULL) abort (); @@ -184,12 +211,14 @@ class aosl_data_buf: public aosl_data_class { aosl_data_buf &operator = (const aosl_data_buf &src) { - if (d != NULL) - aosl_data_put (d); + if (this != &src) { + if (d != NULL) + aosl_data_put (d); - d = src.d; - if (d != NULL) - aosl_data_get (d); + d = src.d; + if (d != NULL) + aosl_data_get (d); + } return *this; } @@ -212,66 +241,151 @@ class aosl_data_buf: public aosl_data_class { return (unsigned char *)ptr (); } + void attach (aosl_data_t src) + { + if (d != NULL) + aosl_data_put (d); + + d = src; + } + + aosl_data_t detach () + { + aosl_data_t data = d; + d = NULL; + return data; + } + #if (__cplusplus >= 201103) || defined (_MSC_VER) aosl_data_buf (aosl_data_buf &&src) { - d = src.d; - src.d = NULL; + if (this != &src) { + d = src.d; + src.d = NULL; + } } aosl_data_buf &operator = (aosl_data_buf &&src) { - if (d != NULL) - aosl_data_put (d); + if (this != &src) { + if (d != NULL) + aosl_data_put (d); + + d = src.d; + src.d = NULL; + } - d = src.d; - src.d = NULL; return *this; } #endif /* C++11 */ }; +/** + * This class is only used in the constructor of aosl_data_var + * to differentiate constructor with variadic args, do not use + * it in any other scenario. + **/ +template +class aosl_data_arg { +private: + const T var; + +public: + aosl_data_arg (T arg): var (arg) {} + operator T () + { + return var; + } +}; + template class aosl_data_var: public aosl_data_class { public: - aosl_data_var () + aosl_data_var (void) { - d = aosl_data_create (sizeof (T)); + d = aosl_data_create (sizeof (T), __data_var_dtor); if (d == NULL) abort (); + + new (aosl_data_ptr_get (d)) T; + } + + /** + * We prefer to using this kind of special class arg rather + * than naked aosl_data_t just for differentiating from the + * constructor with variadic args. + **/ + aosl_data_var (aosl_data_arg src_arg) + { + aosl_data_t src = src_arg; + if (src == NULL) + abort (); + + /* The prerequisite is that the src must be a valid T data */ + if (aosl_data_len (src) < sizeof (T)) + abort (); + + aosl_data_get (src); + d = src; } - aosl_data_var (size_t nelems) + /** + * We prefer to using this kind of special class arg rather + * than naked size_t. + **/ + aosl_data_var (aosl_data_arg nelems) { - if (nelems == 0) + size_t count = nelems; + if (count == 0) + abort (); + + d = aosl_data_create (sizeof (T) * count, __data_var_dtor); + if (d == NULL) abort (); - d = aosl_data_create (sizeof (T) * nelems); + new (aosl_data_ptr_get (d)) T [count]; + } + +#if (__cplusplus >= 201103) || defined (_MSC_VER) + template + aosl_data_var (Targs... args) + { + d = aosl_data_create (sizeof (T), __data_var_dtor); if (d == NULL) abort (); + + new (aosl_data_ptr_get (d)) T (args...); } +#endif aosl_data_var (const aosl_data_var &src) { - d = src.d; - if (d != NULL) - aosl_data_get (d); + if (this != &src) { + d = src.d; + if (d != NULL) + aosl_data_get (d); + } } aosl_data_var &operator = (const aosl_data_var &src) { - if (d != NULL) - aosl_data_put (d); + if (this != &src) { + if (d != NULL) + aosl_data_put (d); - d = src.d; - if (d != NULL) - aosl_data_get (d); + d = src.d; + if (d != NULL) + aosl_data_get (d); + } return *this; } aosl_data_var &operator = (const T &v) { + if (d == NULL) + abort (); + *(T *)aosl_data_ptr_get (d) = v; return *this; } @@ -292,6 +406,14 @@ class aosl_data_var: public aosl_data_class { return *(T *)aosl_data_ptr_get (d); } + T *operator -> () const + { + if (d == NULL) + abort (); + + return (T *)aosl_data_ptr_get (d); + } + T operator [] (size_t i) const { size_t count; @@ -324,20 +446,37 @@ class aosl_data_var: public aosl_data_class { return arr [i]; } +private: + static void __data_var_dtor (void *ptr, size_t len) + { + size_t n = len / sizeof (T); + T *o = (T *)ptr; + T *e = o + n; + while (e > o) { + e--; + e->~T (); + } + } + #if (__cplusplus >= 201103) || defined (_MSC_VER) aosl_data_var (aosl_data_var &&src) { - d = src.d; - src.d = NULL; + if (this != &src) { + d = src.d; + src.d = NULL; + } } aosl_data_var &operator = (aosl_data_var &&src) { - if (d != NULL) - aosl_data_put (d); + if (this != &src) { + if (d != NULL) + aosl_data_put (d); + + d = src.d; + src.d = NULL; + } - d = src.d; - src.d = NULL; return *this; } #endif /* C++11 */ diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_file_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_file_class.h old mode 100755 new mode 100644 index 125fd99e7..a8776df9b --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_file_class.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_file_class.h @@ -234,9 +234,9 @@ class aosl_file_class { #endif /* C++11 */ public: - int co_read (aosl_data_t d_ret, aosl_data_t d_buf) + int co_read (aosl_data_t d_ret, aosl_data_t d_buf, uintptr_t buf_off = 0) { - return aosl_co_file_read (fd, d_ret, d_buf); + return aosl_co_file_read (fd, d_ret, d_buf, buf_off); } int co_write (aosl_data_t d_ret, aosl_data_t d_buf) diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_input_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_input_class.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_kobj_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_kobj_class.h old mode 100755 new mode 100644 index 7f301ea3a..011e68b07 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_kobj_class.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_kobj_class.h @@ -42,7 +42,7 @@ class aosl_kobj_class { #endif public: - static void *notify_register (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_t f, aosl_kobj_notify_dtor_t dtor, uintptr_t argc, ...) + static void *notify_register (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_t f, aosl_obj_dtor_t dtor, uintptr_t argc, ...) { va_list args; void *err; @@ -53,12 +53,12 @@ class aosl_kobj_class { return err; } - static void *notify_register_args (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_t f, aosl_kobj_notify_dtor_t dtor, uintptr_t argc, va_list args) + static void *notify_register_args (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_t f, aosl_obj_dtor_t dtor, uintptr_t argc, va_list args) { return aosl_kobj_notify_register_args (dfd, name, touch, qid, ref, f_name, f, dtor, argc, args); } - static void *notify_register_argv (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_t f, aosl_kobj_notify_dtor_t dtor, uintptr_t argc, uintptr_t argv []) + static void *notify_register_argv (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_t f, aosl_obj_dtor_t dtor, uintptr_t argc, uintptr_t argv []) { return aosl_kobj_notify_register_argv (dfd, name, touch, qid, ref, f_name, f, dtor, argc, argv); } diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mm_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mm_class.h new file mode 100644 index 000000000..15c9e020d --- /dev/null +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mm_class.h @@ -0,0 +1,45 @@ +/************************************************************* + * Author: Lionfore Hao (haolianfu@agora.io) + * Date : Jun 17th, 2024 + * Module: AOSL memory management for C++ definition file + * + * + * This is a part of the Advanced Operating System Layer. + * Copyright (C) 2018 ~ 2024 Agora IO + * All rights reserved. + * + *************************************************************/ + +#ifndef __AOSL_MM_CLASS_H__ +#define __AOSL_MM_CLASS_H__ + + +#include +#include + + +class aosl_mm_class { +public: + static void *operator new (size_t size) + { + return aosl_mm_malloc (size); + } + + static void *operator new [] (size_t size) + { + return aosl_mm_malloc (size); + } + + static void operator delete (void *ptr) + { + aosl_mm_free (ptr); + } + + static void operator delete [] (void *ptr) + { + aosl_mm_free (ptr); + } +}; + + +#endif /* __AOSL_MM_CLASS_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_fd_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_fd_class.h old mode 100755 new mode 100644 index 606effcf8..a03a74e7d --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_fd_class.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_fd_class.h @@ -17,26 +17,57 @@ #include #include +#include class aosl_mpq_fd_class { public: aosl_mpq_fd_class (aosl_fd_t fd): attached_fd (fd) { + ref_id = aosl_ref_create (this, NULL, 1/* MUST BE CALLER-FREE */); + if (aosl_ref_invalid (ref_id)) + abort (); } virtual ~aosl_mpq_fd_class () { + /** + * Please make sure this is the first action in the destructor of + * each final derived class of this class and its' derivatives. + **/ + ref_destroy (); if (!aosl_fd_invalid (attached_fd)) aosl_close (attached_fd); } - aosl_fd_t get_fd () + aosl_ref_t ref (void) + { + return ref_id; + } + + /** + * Please call this function first before freeing any resource relative + * with this class and its' derivatives. + **/ + void ref_destroy (void) + { + if (!aosl_ref_invalid (ref_id)) { + /** + * For caller-free ref object, the destroy will wait other threads + * to release the ref usage count, so this will guarantee the safe + * accessing of 'this' object. + **/ + aosl_ref_destroy (ref_id, 1); + ref_id = AOSL_REF_INVALID; + } + } + + aosl_fd_t get_fd (void) { return attached_fd; } - aosl_fd_t detach () + aosl_fd_t detach (void) { if (!aosl_fd_invalid (attached_fd)) { aosl_fd_t fd = attached_fd; @@ -48,9 +79,9 @@ class aosl_mpq_fd_class { } public: - int co_read (aosl_data_t d_ret, aosl_data_t d_buf) + int co_read (aosl_data_t d_ret, aosl_data_t d_buf, uintptr_t buf_off = 0) { - return aosl_co_read (attached_fd, d_ret, d_buf); + return aosl_co_read (attached_fd, d_ret, d_buf, buf_off); } ssize_t co_write (aosl_data_t d_ret, aosl_data_t d_buf) @@ -64,6 +95,7 @@ class aosl_mpq_fd_class { } private: + aosl_ref_t ref_id; aosl_fd_t attached_fd; #if (__cplusplus >= 201103) || defined (_MSC_VER) diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_sk_lambda.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_sk_lambda.h old mode 100755 new mode 100644 index 8dfc4c900..477488177 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_sk_lambda.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_sk_lambda.h @@ -16,9 +16,11 @@ #include #include +#include #include #include #include +#include #if (__cplusplus >= 201103) || defined (_MSC_VER) #include @@ -26,6 +28,8 @@ typedef std::function aosl_fd_chk_pkt_lambda_t; typedef std::function aosl_fd_data_lambda_t; typedef std::function aosl_dgram_sk_data_lambda_t; +typedef std::function aosl_fd_d_data_lambda_t; /* lambda with aosl_data_t */ +typedef std::function aosl_dgram_sk_d_data_lambda_t; /* lambda with aosl_data_t */ typedef std::function aosl_fd_event_lambda_t; typedef std::function aosl_listen_sk_accept_lambda_t; @@ -37,27 +41,61 @@ class aosl_mpq_dgram_sk: public aosl_mpq_fd_class { aosl_fd_event_lambda_t&& event_cb, aosl_mpq_t qid = aosl_mpq_this ()) : aosl_mpq_fd_class (sk), - on_data (std::move (data_cb)), + on_data (std::move (data_cb)), on_event (std::move (event_cb)) { - if (aosl_mpq_add_dgram_socket (qid, sk, max_pkt_size, &__on_data, &__on_event, 1, this) < 0) + if (aosl_mpq_add_dgram_socket (qid, sk, max_pkt_size, &__on_data, &__on_event, 1, ref ()) < 0) abort (); } + aosl_mpq_dgram_sk (aosl_fd_t sk, size_t max_pkt_size, + aosl_dgram_sk_d_data_lambda_t&& data_cb, + aosl_fd_event_lambda_t&& event_cb, + aosl_mpq_t qid = aosl_mpq_this ()) + : aosl_mpq_fd_class (sk), + on_d_data (std::move (data_cb)), + on_event (std::move (event_cb)) + { + if (aosl_mpq_add_dgram_socket (qid, sk, max_pkt_size, &__on_d_data, &__on_event, 1, ref ()) < 0) + abort (); + } + + virtual ~aosl_mpq_dgram_sk () + { + /** + * Please make sure this is the first action in the destructor of + * each final derived class of this class and its' derivatives. + **/ + ref_destroy (); + } + private: static void __on_data (void *data, size_t len, uintptr_t argc, uintptr_t argv [], const aosl_sk_addr_t *addr) { - aosl_mpq_dgram_sk *__this = (aosl_mpq_dgram_sk *)argv [0]; - __this->on_data (data, len, addr); + aosl_ref_class::hold ((aosl_ref_t)argv [0], [&] (void *arg) { + aosl_mpq_dgram_sk *__this = (aosl_mpq_dgram_sk *)(aosl_mpq_fd_class *)arg; + __this->on_data (data, len, addr); + }); + } + + static void __on_d_data (void *data, size_t len, uintptr_t argc, uintptr_t argv [], const aosl_sk_addr_t *addr) + { + aosl_ref_class::hold ((aosl_ref_t)argv [0], [&] (void *arg) { + aosl_mpq_dgram_sk *__this = (aosl_mpq_dgram_sk *)(aosl_mpq_fd_class *)arg; + __this->on_d_data ((aosl_data_t)argv [argc], data, len, addr); + }); } static void __on_event (aosl_fd_t sk, int event, uintptr_t argc, uintptr_t argv []) { - aosl_mpq_dgram_sk *__this = (aosl_mpq_dgram_sk *)argv [0]; - __this->on_event (sk, event); + aosl_ref_class::hold ((aosl_ref_t)argv [0], [&] (void *arg) { + aosl_mpq_dgram_sk *__this = (aosl_mpq_dgram_sk *)(aosl_mpq_fd_class *)arg; + __this->on_event (sk, event); + }); } const aosl_dgram_sk_data_lambda_t on_data; + const aosl_dgram_sk_d_data_lambda_t on_d_data; const aosl_fd_event_lambda_t on_event; private: @@ -77,34 +115,76 @@ class aosl_mpq_stream_sk: public aosl_mpq_fd_class { aosl_mpq_t qid = aosl_mpq_this ()) : aosl_mpq_fd_class (sk), on_chk_pkt (std::move (chk_pkt_cb)), - on_data (std::move (data_cb)), + on_data (std::move (data_cb)), on_event (std::move (event_cb)) { - if (aosl_mpq_add_stream_socket (qid, sk, enable, max_pkt_size, &__on_chk_pkt, &__on_data, &__on_event, 1, this) < 0) + if (aosl_mpq_add_stream_socket (qid, sk, enable, max_pkt_size, &__on_chk_pkt, &__on_data, &__on_event, 1, ref ()) < 0) abort (); } + aosl_mpq_stream_sk (aosl_fd_t sk, int enable, size_t max_pkt_size, + aosl_fd_chk_pkt_lambda_t&& chk_pkt_cb, + aosl_fd_d_data_lambda_t&& data_cb, + aosl_fd_event_lambda_t&& event_cb, + aosl_mpq_t qid = aosl_mpq_this ()) + : aosl_mpq_fd_class (sk), + on_chk_pkt (std::move (chk_pkt_cb)), + on_d_data (std::move (data_cb)), + on_event (std::move (event_cb)) + { + if (aosl_mpq_add_stream_socket (qid, sk, enable, max_pkt_size, &__on_chk_pkt, &__on_d_data, &__on_event, 1, ref ()) < 0) + abort (); + } + + virtual ~aosl_mpq_stream_sk () + { + /** + * Please make sure this is the first action in the destructor of + * each final derived class of this class and its' derivatives. + **/ + ref_destroy (); + } + private: static ssize_t __on_chk_pkt (const void *data, size_t len, uintptr_t argc, uintptr_t argv []) { - aosl_mpq_stream_sk *__this = (aosl_mpq_stream_sk *)argv [0]; - return __this->on_chk_pkt (data, len); + ssize_t ret = -1; + + aosl_ref_class::hold ((aosl_ref_t)argv [0], [&] (void *arg) { + aosl_mpq_stream_sk *__this = (aosl_mpq_stream_sk *)(aosl_mpq_fd_class *)arg; + ret = __this->on_chk_pkt (data, len); + }); + + return ret; } static void __on_data (void *data, size_t len, uintptr_t argc, uintptr_t argv []) { - aosl_mpq_stream_sk *__this = (aosl_mpq_stream_sk *)argv [0]; - __this->on_data (data, len); + aosl_ref_class::hold ((aosl_ref_t)argv [0], [&] (void *arg) { + aosl_mpq_stream_sk *__this = (aosl_mpq_stream_sk *)(aosl_mpq_fd_class *)arg; + __this->on_data (data, len); + }); + } + + static void __on_d_data (void *data, size_t len, uintptr_t argc, uintptr_t argv []) + { + aosl_ref_class::hold ((aosl_ref_t)argv [0], [&] (void *arg) { + aosl_mpq_stream_sk *__this = (aosl_mpq_stream_sk *)(aosl_mpq_fd_class *)arg; + __this->on_d_data ((aosl_data_t)argv [argc], data, len); + }); } static void __on_event (aosl_fd_t sk, int event, uintptr_t argc, uintptr_t argv []) { - aosl_mpq_stream_sk *__this = (aosl_mpq_stream_sk *)argv [0]; - __this->on_event (sk, event); + aosl_ref_class::hold ((aosl_ref_t)argv [0], [&] (void *arg) { + aosl_mpq_stream_sk *__this = (aosl_mpq_stream_sk *)(aosl_mpq_fd_class *)arg; + __this->on_event (sk, event); + }); } const aosl_fd_chk_pkt_lambda_t on_chk_pkt; const aosl_fd_data_lambda_t on_data; + const aosl_fd_d_data_lambda_t on_d_data; const aosl_fd_event_lambda_t on_event; private: @@ -128,6 +208,17 @@ class aosl_mpq_connect_stream_sk: public aosl_mpq_stream_sk { std::move (data_cb), std::move (event_cb), qid) {} + aosl_mpq_connect_stream_sk (aosl_fd_t sk, size_t max_pkt_size, + aosl_fd_chk_pkt_lambda_t&& chk_pkt_cb, + aosl_fd_d_data_lambda_t&& data_cb, + aosl_fd_event_lambda_t&& event_cb, + aosl_mpq_t qid = aosl_mpq_this ()) + : aosl_mpq_stream_sk (sk, 0/* !enable */, + max_pkt_size, + std::move (chk_pkt_cb), + std::move (data_cb), + std::move (event_cb), qid) {} + int connect (const struct sockaddr *dest_addr, socklen_t addrlen, int timeo) { return aosl_mpq_connect (get_fd (), dest_addr, addrlen, timeo); @@ -154,6 +245,17 @@ class aosl_mpq_accepted_stream_sk: public aosl_mpq_stream_sk { std::move (data_cb), std::move (event_cb), qid) {} + aosl_mpq_accepted_stream_sk (aosl_fd_t sk, size_t max_pkt_size, + aosl_fd_chk_pkt_lambda_t&& chk_pkt_cb, + aosl_fd_d_data_lambda_t&& data_cb, + aosl_fd_event_lambda_t&& event_cb, + aosl_mpq_t qid = aosl_mpq_this ()) + : aosl_mpq_stream_sk (sk, 1/*enable*/, + max_pkt_size, + std::move (chk_pkt_cb), + std::move (data_cb), + std::move (event_cb), qid) {} + private: aosl_mpq_accepted_stream_sk () = delete; aosl_mpq_accepted_stream_sk (const aosl_mpq_accepted_stream_sk &) = delete; @@ -172,21 +274,34 @@ class aosl_mpq_listen_sk: public aosl_mpq_fd_class { on_accept (std::move (accept_cb)), on_event (std::move (event_cb)) { - if (aosl_mpq_add_listen_socket (qid, sk, backlog, __on_accept, __on_event, 1, this) < 0) + if (aosl_mpq_add_listen_socket (qid, sk, backlog, __on_accept, __on_event, 1, ref ()) < 0) abort (); } + virtual ~aosl_mpq_listen_sk () + { + /** + * Please make sure this is the first action in the destructor of + * each final derived class of this class and its' derivatives. + **/ + ref_destroy (); + } + private: static void __on_accept (aosl_accept_data_t *accept_data, size_t len, uintptr_t argc, uintptr_t argv []) { - aosl_mpq_listen_sk *__this = (aosl_mpq_listen_sk *)argv [0]; - __this->on_accept (accept_data); + aosl_ref_class::hold ((aosl_ref_t)argv [0], [&] (void *arg) { + aosl_mpq_listen_sk *__this = (aosl_mpq_listen_sk *)(aosl_mpq_fd_class *)arg; + __this->on_accept (accept_data); + }); } static void __on_event (aosl_fd_t sk, int event, uintptr_t argc, uintptr_t argv []) { - aosl_mpq_listen_sk *__this = (aosl_mpq_listen_sk *)argv [0]; - __this->on_event (sk, event); + aosl_ref_class::hold ((aosl_ref_t)argv [0], [&] (void *arg) { + aosl_mpq_listen_sk *__this = (aosl_mpq_listen_sk *)(aosl_mpq_fd_class *)arg; + __this->on_event (sk, event); + }); } const aosl_listen_sk_accept_lambda_t on_accept; @@ -222,14 +337,14 @@ class aosl_co_sk: public aosl_mpq_fd_class { return aosl_co_accept (get_fd (), d_ret, d_addr); } - int co_recv (aosl_data_t d_ret, aosl_data_t d_buf, int flags) + int co_recv (aosl_data_t d_ret, aosl_data_t d_buf, uintptr_t buf_off = 0, int flags = 0) { - return aosl_co_recv (get_fd (), d_ret, d_buf, flags); + return aosl_co_recv (get_fd (), d_ret, d_buf, buf_off, flags); } - int co_recvfrom (aosl_data_t d_ret, aosl_data_t d_buf, int flags, aosl_data_t d_addr) + int co_recvfrom (aosl_data_t d_ret, aosl_data_t d_buf, aosl_data_t d_addr, uintptr_t buf_off = 0, int flags = 0) { - return aosl_co_recvfrom (get_fd (), d_ret, d_buf, flags, d_addr); + return aosl_co_recvfrom (get_fd (), d_ret, d_buf, buf_off, flags, d_addr); } int co_connect (aosl_data_t d_ret, const struct sockaddr *dest_addr, socklen_t addrlen, int timeo) diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_timer_lambda.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_timer_lambda.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_poll_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_poll_class.h old mode 100755 new mode 100644 index 0e7007dbb..54d1a0560 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_poll_class.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_poll_class.h @@ -35,18 +35,17 @@ class aosl_poll_class { std::vector signaled_refs; public: - int add (const aosl_ares_class &tail) + void add (const aosl_ares_class &tail) { poll_refs [tail.ref ()] = &tail; - return 0; } #if (__cplusplus >= 201103) || defined (_MSC_VER) template - int add (const T &head, const Targs&... rest) + void add (const T &head, const Targs&... rest) { poll_refs [head.ref ()] = &head; - return add (rest...); + add (rest...); } /* constructor with variable args */ @@ -57,6 +56,13 @@ class aosl_poll_class { } #endif /* C++11 */ + aosl_poll_class (const aosl_ares_class * const areses [], size_t count) + { + size_t i; + for (i = 0; i < count; i++) + add (*areses [i]); + } + /* poll the constructed async results */ int poll (size_t min, intptr_t timeo) { diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_ref_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_ref_class.h old mode 100755 new mode 100644 index c3c905721..4dab3878b --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_ref_class.h +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_ref_class.h @@ -138,26 +138,26 @@ class aosl_ref_class { return aosl_ref_write_argv (ref (), f, argc, argv); } - int maystall (aosl_ref_func_t f, uintptr_t argc, ...) + int unsafe (aosl_ref_func_t f, uintptr_t argc, ...) { va_list args; int err; va_start (args, argc); - err = aosl_ref_maystall_args (ref (), f, argc, args); + err = aosl_ref_unsafe_args (ref (), f, argc, args); va_end (args); return err; } - int maystall_args (aosl_ref_func_t f, uintptr_t argc, va_list args) + int unsafe_args (aosl_ref_func_t f, uintptr_t argc, va_list args) { - return aosl_ref_maystall_args (ref (), f, argc, args); + return aosl_ref_unsafe_args (ref (), f, argc, args); } - int maystall_argv (aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) + int unsafe_argv (aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) { - return aosl_ref_maystall_argv (ref (), f, argc, argv); + return aosl_ref_unsafe_argv (ref (), f, argc, argv); } /* The static version of member functions */ @@ -227,26 +227,26 @@ class aosl_ref_class { return aosl_ref_write_argv (ref, f, argc, argv); } - static int maystall (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...) + static int unsafe (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...) { va_list args; int err; va_start (args, argc); - err = aosl_ref_maystall_args (ref, f, argc, args); + err = aosl_ref_unsafe_args (ref, f, argc, args); va_end (args); return err; } - static int maystall_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args) + static int unsafe_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args) { - return aosl_ref_maystall_args (ref, f, argc, args); + return aosl_ref_unsafe_args (ref, f, argc, args); } - static int maystall_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) + static int unsafe_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) { - return aosl_ref_maystall_argv (ref, f, argc, argv); + return aosl_ref_unsafe_argv (ref, f, argc, argv); } static int read (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, ...) @@ -271,26 +271,26 @@ class aosl_ref_class { return aosl_refobj_read_argv (robj, f, argc, argv); } - static int maystall (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, ...) + static int unsafe (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, ...) { va_list args; int err; va_start (args, argc); - err = aosl_refobj_maystall_args (robj, f, argc, args); + err = aosl_refobj_unsafe_args (robj, f, argc, args); va_end (args); return err; } - static int maystall_args (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, va_list args) + static int unsafe_args (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, va_list args) { - return aosl_refobj_maystall_args (robj, f, argc, args); + return aosl_refobj_unsafe_args (robj, f, argc, args); } - static int maystall_argv (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) + static int unsafe_argv (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) { - return aosl_refobj_maystall_argv (robj, f, argc, argv); + return aosl_refobj_unsafe_argv (robj, f, argc, argv); } /* set the living scope ref object of this ref object */ @@ -519,10 +519,10 @@ class aosl_ref_class { return aosl_ref_t_oop::write (____ref_f, 1, &lambda_obj); } - int maystall (aosl_ref_lambda_f &&lambda_f) + int unsafe (aosl_ref_lambda_f &&lambda_f) { aosl_ref_lambda_f lambda_obj (std::move (lambda_f)); - return aosl_ref_t_oop::maystall (____ref_f, 1, &lambda_obj); + return aosl_ref_t_oop::unsafe (____ref_f, 1, &lambda_obj); } static int hold (aosl_ref_t ref, aosl_ref_lambda_f &&lambda_f) @@ -543,10 +543,10 @@ class aosl_ref_class { return aosl_ref_t_oop::write (ref, ____ref_f, 1, &lambda_obj); } - static int maystall (aosl_ref_t ref, aosl_ref_lambda_f &&lambda_f) + static int unsafe (aosl_ref_t ref, aosl_ref_lambda_f &&lambda_f) { aosl_ref_lambda_f lambda_obj (std::move (lambda_f)); - return aosl_ref_t_oop::maystall (ref, ____ref_f, 1, &lambda_obj); + return aosl_ref_t_oop::unsafe (ref, ____ref_f, 1, &lambda_obj); } static int read (aosl_refobj_t robj, aosl_ref_lambda_f &&lambda_f) @@ -555,10 +555,10 @@ class aosl_ref_class { return aosl_ref_t_oop::read (robj, ____ref_f, 1, &lambda_obj); } - static int maystall (aosl_refobj_t robj, aosl_ref_lambda_f &&lambda_f) + static int unsafe (aosl_refobj_t robj, aosl_ref_lambda_f &&lambda_f) { aosl_ref_lambda_f lambda_obj (std::move (lambda_f)); - return aosl_ref_t_oop::maystall (robj, ____ref_f, 1, &lambda_obj); + return aosl_ref_t_oop::unsafe (robj, ____ref_f, 1, &lambda_obj); } private: @@ -1083,13 +1083,35 @@ class aosl_ref_class { return refoop->write_argv (f, argc, argv); } + int unsafe (aosl_ref_func_t f, uintptr_t argc, ...) + { + va_list args; + int err; + + va_start (args, argc); + err = refoop->unsafe_args (f, argc, args); + va_end (args); + + return err; + } + + int unsafe_args (aosl_ref_func_t f, uintptr_t argc, va_list args) + { + return refoop->unsafe_args (f, argc, args); + } + + int unsafe_argv (aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) + { + return refoop->unsafe_argv (f, argc, argv); + } + int maystall (aosl_ref_func_t f, uintptr_t argc, ...) { va_list args; int err; va_start (args, argc); - err = refoop->maystall_args (f, argc, args); + err = refoop->unsafe_args (f, argc, args); va_end (args); return err; @@ -1097,12 +1119,12 @@ class aosl_ref_class { int maystall_args (aosl_ref_func_t f, uintptr_t argc, va_list args) { - return refoop->maystall_args (f, argc, args); + return refoop->unsafe_args (f, argc, args); } int maystall_argv (aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) { - return refoop->maystall_argv (f, argc, argv); + return refoop->unsafe_argv (f, argc, argv); } /* The static version of member functions */ @@ -1172,13 +1194,35 @@ class aosl_ref_class { return aosl_ref_t_oop::write_argv (ref, f, argc, argv); } + static int unsafe (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...) + { + va_list args; + int err; + + va_start (args, argc); + err = aosl_ref_t_oop::unsafe_args (ref, f, argc, args); + va_end (args); + + return err; + } + + static int unsafe_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args) + { + return aosl_ref_t_oop::unsafe_args (ref, f, argc, args); + } + + static int unsafe_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) + { + return aosl_ref_t_oop::unsafe_argv (ref, f, argc, argv); + } + static int maystall (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...) { va_list args; int err; va_start (args, argc); - err = aosl_ref_t_oop::maystall_args (ref, f, argc, args); + err = aosl_ref_t_oop::unsafe_args (ref, f, argc, args); va_end (args); return err; @@ -1186,12 +1230,12 @@ class aosl_ref_class { static int maystall_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args) { - return aosl_ref_t_oop::maystall_args (ref, f, argc, args); + return aosl_ref_t_oop::unsafe_args (ref, f, argc, args); } static int maystall_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) { - return aosl_ref_t_oop::maystall_argv (ref, f, argc, argv); + return aosl_ref_t_oop::unsafe_argv (ref, f, argc, argv); } static int read (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, ...) @@ -1216,13 +1260,35 @@ class aosl_ref_class { return aosl_ref_t_oop::read_argv (robj, f, argc, argv); } + static int unsafe (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, ...) + { + va_list args; + int err; + + va_start (args, argc); + err = aosl_ref_t_oop::unsafe_args (robj, f, argc, args); + va_end (args); + + return err; + } + + static int unsafe_args (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, va_list args) + { + return aosl_ref_t_oop::unsafe_args (robj, f, argc, args); + } + + static int unsafe_argv (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) + { + return aosl_ref_t_oop::unsafe_argv (robj, f, argc, argv); + } + static int maystall (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, ...) { va_list args; int err; va_start (args, argc); - err = aosl_ref_t_oop::maystall_args (robj, f, argc, args); + err = aosl_ref_t_oop::unsafe_args (robj, f, argc, args); va_end (args); return err; @@ -1230,12 +1296,12 @@ class aosl_ref_class { static int maystall_args (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, va_list args) { - return aosl_ref_t_oop::maystall_args (robj, f, argc, args); + return aosl_ref_t_oop::unsafe_args (robj, f, argc, args); } static int maystall_argv (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) { - return aosl_ref_t_oop::maystall_argv (robj, f, argc, argv); + return aosl_ref_t_oop::unsafe_argv (robj, f, argc, argv); } static aosl_ref_class *from_refobj (aosl_refobj_t robj) @@ -1492,9 +1558,14 @@ class aosl_ref_class { return refoop->write (std::move (lambda_f)); } + int unsafe (aosl_ref_lambda_f &&lambda_f) + { + return refoop->unsafe (std::move (lambda_f)); + } + int maystall (aosl_ref_lambda_f &&lambda_f) { - return refoop->maystall (std::move (lambda_f)); + return refoop->unsafe (std::move (lambda_f)); } static int hold (aosl_ref_t ref, aosl_ref_lambda_f &&lambda_f) @@ -1512,9 +1583,14 @@ class aosl_ref_class { return aosl_ref_t_oop::write (ref, std::move (lambda_f)); } + static int unsafe (aosl_ref_t ref, aosl_ref_lambda_f &&lambda_f) + { + return aosl_ref_t_oop::unsafe (ref, std::move (lambda_f)); + } + static int maystall (aosl_ref_t ref, aosl_ref_lambda_f &&lambda_f) { - return aosl_ref_t_oop::maystall (ref, std::move (lambda_f)); + return aosl_ref_t_oop::unsafe (ref, std::move (lambda_f)); } static int read (aosl_refobj_t robj, aosl_ref_lambda_f &&lambda_f) @@ -1522,9 +1598,14 @@ class aosl_ref_class { return aosl_ref_t_oop::read (robj, std::move (lambda_f)); } + static int unsafe (aosl_refobj_t robj, aosl_ref_lambda_f &&lambda_f) + { + return aosl_ref_t_oop::unsafe (robj, std::move (lambda_f)); + } + static int maystall (aosl_refobj_t robj, aosl_ref_lambda_f &&lambda_f) { - return aosl_ref_t_oop::maystall (robj, std::move (lambda_f)); + return aosl_ref_t_oop::unsafe (robj, std::move (lambda_f)); } #ifdef __AOSL_MPQ_H__ @@ -1844,25 +1925,25 @@ inline bool operator != (intptr_t _null, const aosl_ref_unique_ptr &p #if (__cplusplus >= 201103) || defined (_MSC_VER) template -inline bool operator == (const aosl_ref_unique_ptr &ptr, nullptr_t) +inline bool operator == (const aosl_ref_unique_ptr &ptr, std::nullptr_t) { return !ptr; } template -inline bool operator != (const aosl_ref_unique_ptr &ptr, nullptr_t) +inline bool operator != (const aosl_ref_unique_ptr &ptr, std::nullptr_t) { return ptr; } template -inline bool operator == (nullptr_t, const aosl_ref_unique_ptr &ptr) +inline bool operator == (std::nullptr_t, const aosl_ref_unique_ptr &ptr) { return !ptr; } template -inline bool operator != (nullptr_t, const aosl_ref_unique_ptr &ptr) +inline bool operator != (std::nullptr_t, const aosl_ref_unique_ptr &ptr) { return ptr; } diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_sbus_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_sbus_class.h new file mode 100644 index 000000000..fe853a1fc --- /dev/null +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_sbus_class.h @@ -0,0 +1,180 @@ +/************************************************************* + * Author: Lionfore Hao (haolianfu@agora.io) + * Date : May 6th, 2024 + * Module: AOSL software bus relative API C++ definition file + * + * + * This is a part of the Advanced Operating System Layer. + * Copyright (C) 2018 ~ 2024 Agora IO + * All rights reserved. + * + *************************************************************/ + +#ifndef __AOSL_SBUS_CPP_H__ +#define __AOSL_SBUS_CPP_H__ + + +/* C++11 lambda encapsulations */ +#if (__cplusplus >= 201103) || defined (_MSC_VER) +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + + +class aosl_sbus_class_base { +private: + aosl_sbus_class_base () = delete; + aosl_sbus_class_base (const aosl_sbus_class_base &) = delete; + aosl_sbus_class_base (aosl_sbus_class_base &&) = delete; + aosl_sbus_class_base &operator = (const aosl_sbus_class_base &) = delete; + aosl_sbus_class_base &operator = (aosl_sbus_class_base &&) = delete; + ~aosl_sbus_class_base () = delete; + +public: + typedef std::function aosl_sbus_data_lambda_f; + /* simple version without robj arg, so it means no "free only" for this callback */ + typedef std::function aosl_sbus_data_lambda_2args_f; + + static void *action_add (const char *name, aosl_mpq_t qid, aosl_ref_t ref, uintptr_t max, const char *f_name, aosl_sbus_data_lambda_f&& task) + { + aosl_sbus_data_lambda_f *task_obj = new aosl_sbus_data_lambda_f (std::move (task)); + void *err = aosl_sbus_action_add (name, qid, ref, max, f_name, ____sbus_data, ____action_dtor, 1, task_obj); + if (err == NULL) + delete task_obj; + + return err; + } + + static void *action_add (const char *name, aosl_mpq_t qid, aosl_ref_t ref, uintptr_t max, const char *f_name, aosl_sbus_data_lambda_2args_f&& task) + { + aosl_sbus_data_lambda_2args_f *task_obj = new aosl_sbus_data_lambda_2args_f (std::move (task)); + void *err = aosl_sbus_action_add (name, qid, ref, max, f_name, ____sbus_data_2args, ____action_dtor_2args, 1, task_obj); + if (err == NULL) + delete task_obj; + + return err; + } + + static int action_del (const char *name, void *h_action) + { + return aosl_sbus_action_del (name, h_action); + } + + static int send (const char *name, aosl_data_class &data) + { + return aosl_sbus_send (name, data); + } + +private: + static void ____sbus_data (aosl_refobj_t robj, const char *name, aosl_data_t data, uintptr_t argc, uintptr_t argv []) + { + aosl_sbus_data_lambda_f *task_obj = reinterpret_cast(argv [0]); + (*task_obj) (robj, name, data); + } + + static void ____action_dtor (uintptr_t argc, uintptr_t argv []) + { + aosl_sbus_data_lambda_f *task_obj = reinterpret_cast(argv [0]); + delete task_obj; + } + + static void ____sbus_data_2args (aosl_refobj_t robj, const char *name, aosl_data_t data, uintptr_t argc, uintptr_t argv []) + { + if (!aosl_is_free_only (robj)) { + aosl_sbus_data_lambda_2args_f *task_obj = reinterpret_cast(argv [0]); + (*task_obj) (name, data); + } + } + + static void ____action_dtor_2args (uintptr_t argc, uintptr_t argv []) + { + aosl_sbus_data_lambda_2args_f *task_obj = reinterpret_cast(argv [0]); + delete task_obj; + } +}; + +/** + * Template class for accessing a software bus with the data var format + * specified by type T. + **/ +template +class aosl_sbus_class: public aosl_sbus_class_base { +private: + aosl_sbus_class () = delete; + aosl_sbus_class (const aosl_sbus_class &) = delete; + aosl_sbus_class (aosl_sbus_class &&) = delete; + aosl_sbus_class &operator = (const aosl_sbus_class &) = delete; + aosl_sbus_class &operator = (aosl_sbus_class &&) = delete; + ~aosl_sbus_class () = delete; + +public: + typedef std::function &var)> aosl_sbus_var_lambda_f; + /* simple version without robj arg, so it means no "free only" for this callback */ + typedef std::function &var)> aosl_sbus_var_lambda_2args_f; + + static void *action_add (const char *name, aosl_mpq_t qid, aosl_ref_t ref, uintptr_t max, const char *f_name, aosl_sbus_var_lambda_f&& task) + { + aosl_sbus_var_lambda_f *task_obj = new aosl_sbus_var_lambda_f (std::move (task)); + void *err = aosl_sbus_action_add (name, qid, ref, max, f_name, ____sbus_var, ____action_var_dtor, 1, task_obj); + if (err == NULL) + delete task_obj; + + return err; + } + + static void *action_add (const char *name, aosl_mpq_t qid, aosl_ref_t ref, uintptr_t max, const char *f_name, aosl_sbus_var_lambda_2args_f&& task) + { + aosl_sbus_var_lambda_2args_f *task_obj = new aosl_sbus_var_lambda_2args_f (std::move (task)); + void *err = aosl_sbus_action_add (name, qid, ref, max, f_name, ____sbus_var_2args, ____action_var_dtor_2args, 1, task_obj); + if (err == NULL) + delete task_obj; + + return err; + } + + static int send (const char *name, aosl_data_var &var) + { + return aosl_sbus_send (name, var); + } + +private: + static void ____sbus_var (aosl_refobj_t robj, const char *name, aosl_data_t data, uintptr_t argc, uintptr_t argv []) + { + aosl_sbus_var_lambda_f *task_obj = reinterpret_cast(argv [0]); + aosl_data_var var ((aosl_data_arg (data))); + (*task_obj) (robj, name, var); + } + + static void ____action_var_dtor (uintptr_t argc, uintptr_t argv []) + { + aosl_sbus_var_lambda_f *task_obj = reinterpret_cast(argv [0]); + delete task_obj; + } + + static void ____sbus_var_2args (aosl_refobj_t robj, const char *name, aosl_data_t data, uintptr_t argc, uintptr_t argv []) + { + if (!aosl_is_free_only (robj)) { + aosl_sbus_var_lambda_2args_f *task_obj = reinterpret_cast(argv [0]); + aosl_data_var var ((aosl_data_arg (data))); + (*task_obj) (name, var); + } + } + + static void ____action_var_dtor_2args (uintptr_t argc, uintptr_t argv []) + { + aosl_sbus_var_lambda_2args_f *task_obj = reinterpret_cast(argv [0]); + delete task_obj; + } +}; +#endif /* C++11 */ + + +#endif /* __AOSL_SBUS_CPP_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_task_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_task_class.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_thread_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_thread_class.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_usage_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_usage_class.h deleted file mode 100755 index fa7e3954c..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_usage_class.h +++ /dev/null @@ -1,84 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jan 6th, 2019 - * Module: AOSL simple usage object for C++ definition file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2019 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_USAGE_OBJ_CPP_H__ -#define __AOSL_USAGE_OBJ_CPP_H__ - - -#include - -#include -#include - - -class aosl_usage_class { -private: - bool atomic; - int usage; - -protected: - /* We do not allow delete this object directly. */ - virtual ~aosl_usage_class () {} - -public: - /** - * The parameter 'atomic_op' indicates whether the operations - * on the usage should be atomic operations, true for atomic, - * and false for non-atomic. The default value is false. - **/ - aosl_usage_class (bool atomic_op = false) - { - atomic = atomic_op; - - if (atomic_op) { - aosl_atomic_set ((aosl_atomic_t *)&usage, 1); - } else { - usage = 1; - } - } - - void inc_ref () - { - if (atomic) { - aosl_atomic_inc ((aosl_atomic_t *)&usage); - } else { - usage++; - } - } - - /** - * Return values: - * true: the usage count reached zero, and deleted 'this' object already; - * false: the usage count still greater than zero, 'this' object is still alive; - **/ - bool dec_ref () - { - bool b_val; - - if (atomic) { - b_val = (bool)!!aosl_atomic_dec_and_test ((aosl_atomic_t *)&usage); - } else { - usage--; - b_val = (bool)(usage == 0); - } - - if (b_val) { - delete this; - return true; - } - - return false; - } -}; - - -#endif /* __AOSL_USAGE_OBJ_CPP_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_value_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_value_class.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/objc/Makefile b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/objc/Makefile old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/objc/aosl_log.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/objc/aosl_log.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/objc/aosl_objc.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/objc/aosl_objc.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/time_utils.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/time_utils.h old mode 100755 new mode 100644 diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/origin_video_data.cpp b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/origin_video_data.cpp index 9eba8b6b7..05f6c7f87 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/origin_video_data.cpp +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/origin_video_data.cpp @@ -8,7 +8,7 @@ #include OriginVideoData::OriginVideoData(uintptr_t rtcEngineHandler) - : rtcEngine_(reinterpret_cast(rtcEngineHandler)), env_(nullptr), wrapper_(nullptr) {} + : rtcEngine_(reinterpret_cast(rtcEngineHandler)), env_(nullptr), wrapper_(nullptr),takeSnapshot_(false) {} OriginVideoData::~OriginVideoData() { napi_delete_reference(env_, wrapper_); } diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/entryability/EntryAbility.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/entryability/EntryAbility.ets index c573324ad..152ba472e 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/entryability/EntryAbility.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/entryability/EntryAbility.ets @@ -44,7 +44,7 @@ export default class EntryAbility extends UIAbility { } windowStage.loadContent('pages/Index', (err, data) => { - if (err) { + if (err.code) { Logger.error(TAG, `Failed to load the content. Cause: ${JSON.stringify(err)}`) return } diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ChannelEncryption.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ChannelEncryption.ets index e44fd4bd7..8741ff78a 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ChannelEncryption.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ChannelEncryption.ets @@ -219,7 +219,7 @@ struct ChannelEncryption { config.encryptionMode = this.encryptionModeOptions[this.encryptionModeSelectIndex] config.encryptionKey = this.encryptionKey let base64 = new util.Base64Helper(); - config.encryptionKdfSalt = base64.decodeSync("NiIeJ08AbtcQVjvV+oOEvF/4Dz5dy1CIwa805C8J2w0=", util.Type.BASIC) + config.encryptionKdfSalt = base64.decodeSync("NiIeJ08AbtcQVjvV+oOEvF/4Dz5dy1CIwa805C8J2w0=", util.Type.BASIC).buffer as ArrayBuffer this.rtcEngine?.enableEncryption(true, config) let mediaOption: ChannelMediaOptions = new ChannelMediaOptions(); diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/CustomVideoSource.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/CustomVideoSource.ets index 27de9dd2c..723408c70 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/CustomVideoSource.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/CustomVideoSource.ets @@ -122,11 +122,11 @@ struct CustomVideoSource { let frameBuffer: Uint8Array = buffer.slice(readStart, readStart + frame_size) readStart += frame_size let frame: VideoFrame = new VideoFrame( - VideoBufferType.VIDEO_BUFFER_RAW_DATA, + VideoBufferType.RAW_DATA, VideoPixelFormat.VIDEO_PIXEL_I420); frame.buffer = frameBuffer.buffer as ArrayBuffer; frame.rotation = 0; - frame.stride = width; + frame.yStride = width; frame.height = height; frame.timestamp = 0; let ret = this.rtcEngine?.pushExternalVideoFrameById(frame, this.customVideoTrack) @@ -159,7 +159,7 @@ struct CustomVideoSource { if (this.localUid != 0) { XComponent({ id: 'preview_local', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_local"); @@ -167,7 +167,7 @@ struct CustomVideoSource { localCanvas.renderMode = VideoCanvas.RENDER_MODE_HIDDEN; localCanvas.mirrorMode = 0; // TODO set source type - // localCanvas.sourceType = Constants.VideoSourceType.VIDEO_SOURCE_CUSTOM + localCanvas.sourceType = Constants.VideoSourceType.CUSTOM this.rtcEngine?.setupLocalVideo(localCanvas); }).width('50%') } @@ -175,7 +175,7 @@ struct CustomVideoSource { if (this.remoteUid != 0) { XComponent({ id: 'preview_remote', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_remote"); diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/HostCrossChannel.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/HostCrossChannel.ets index 66c9e3ef4..4b7d6e25f 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/HostCrossChannel.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/HostCrossChannel.ets @@ -115,7 +115,7 @@ struct HostCrossChannel { if (this.localUid != 0) { XComponent({ id: 'preview_local', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_local"); @@ -129,7 +129,7 @@ struct HostCrossChannel { if (this.remoteUid != 0) { XComponent({ id: 'preview_remote', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_remote"); @@ -186,12 +186,12 @@ struct HostCrossChannel { let config = new ChannelMediaRelayConfiguration() config.srcInfo.channelName = this.channelName config.srcInfo.uid = this.localUid - config.srcInfo.token = await TokenUtils.genRtcToken(this.channelName, '') - config.destInfos[this.relayChannelName] = { + config.srcInfo.token = "" + config.destInfos.set(this.relayChannelName, { channelName: this.relayChannelName, uid: 999, - token: await TokenUtils.genRtcToken(this.relayChannelName, '999') - } + token: "" + }) this.rtcEngine?.startOrUpdateChannelMediaRelay(config) } }) diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/JoinMultiChannel.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/JoinMultiChannel.ets index 9364d8ce0..37915eafa 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/JoinMultiChannel.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/JoinMultiChannel.ets @@ -108,7 +108,7 @@ struct JoinMultiChannel { if (this.mainLocalUid != 0) { XComponent({ id: 'preview_local', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_local"); @@ -122,7 +122,7 @@ struct JoinMultiChannel { if (this.mainRemoteUid != 0) { XComponent({ id: 'preview_remote', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_remote"); @@ -141,7 +141,7 @@ struct JoinMultiChannel { if (this.exRemoteUid != 0) { XComponent({ id: 'preview_remote_ex', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LiveStreaming.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LiveStreaming.ets index ce7d7ea9f..a2781edf9 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LiveStreaming.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LiveStreaming.ets @@ -166,7 +166,7 @@ struct LiveStreaming { if (this.localUid != -1) { XComponent({ id: 'preview_local', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_local"); @@ -180,7 +180,7 @@ struct LiveStreaming { if (this.remoteUid != -1) { XComponent({ id: 'preview_remote', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_remote"); diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LocalVideoTranscoding.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LocalVideoTranscoding.ets index 464a11043..32a4fcebf 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LocalVideoTranscoding.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LocalVideoTranscoding.ets @@ -18,7 +18,11 @@ import PermissionHelper from '../../util/PermissionHelper'; import { common } from '@kit.AbilityKit'; import { GlobalInfo } from '../Data'; import { TokenUtils } from '../../util/TokenUtils'; -import { LengthMetrics } from '@kit.ArkUI'; +import { display, LengthMetrics } from '@kit.ArkUI'; +import { TranscodingVideoStream } from 'AgoraRtcSdk'; +import { JSON } from '@kit.ArkTS'; +import { camera } from '@kit.CameraKit'; +import { VideoDimensions } from 'AgoraRtcSdk'; const TAG: string = 'LocalVideoTranscoding' @@ -65,6 +69,15 @@ struct LocalVideoTranscoding { Logger.info(TAG, "mEventHandler.onError: " + err + " message " + message); ShowToast.longToast("onError " + err + " : " + message) } + config.mEventHandler.onLocalVideoTranscoderError = (stream:TranscodingVideoStream, error:Constants.VideoTranscoderError) => { + Logger.info(TAG, "mEventHandler.onLocalVideoTranscoderError stream "+JSON.stringify(stream) + " error: "+error); + ShowToast.longToast("onLocalVideoTranscoderError " + error ) + } + + config.mEventHandler.onTranscodingUpdated = () => { + Logger.info(TAG, "mEventHandler.onTranscodingUpdated"); + } + config.mContext = context; Logger.info(TAG, "in thread create engine begin: "); this.rtcEngine = RtcEngine.create(config); @@ -111,7 +124,7 @@ struct LocalVideoTranscoding { build() { Column() { TitleBar({ - title: $r('app.string.item_livestreaming'), + title: $r('app.string.item_localvideotranscoding'), showBack: true }) @@ -119,13 +132,13 @@ struct LocalVideoTranscoding { if (this.localUid != -1) { XComponent({ id: 'preview_local', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_local"); localCanvas.uid = this.localUid; - localCanvas.renderMode = VideoCanvas.RENDER_MODE_HIDDEN; - localCanvas.mirrorMode = 0; + localCanvas.renderMode = VideoCanvas.RENDER_MODE_FIT; + localCanvas.mirrorMode = VideoCanvas.VIDEO_MIRROR_MODE_DISABLED; localCanvas.sourceType = Constants.VideoSourceType.TRANSCODED this.rtcEngine?.setupLocalVideo(localCanvas); }).width('100%').height('100%') @@ -134,13 +147,14 @@ struct LocalVideoTranscoding { if (this.remoteUid != -1) { XComponent({ id: 'preview_remote', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_remote"); localCanvas.uid = this.remoteUid; localCanvas.renderMode = VideoCanvas.RENDER_MODE_HIDDEN; localCanvas.mirrorMode = 0; + localCanvas.sourceType = Constants.VideoSourceType.TRANSCODED; this.rtcEngine?.setupRemoteVideo(localCanvas); }).width('30%').height('30%').margin({ top: 12, right: 12 }) } @@ -176,8 +190,8 @@ struct LocalVideoTranscoding { } - let width = 720; - let height = 1280; + let width = GlobalInfo.settings.dimensions.height + let height = GlobalInfo.settings.dimensions.width let screenConfig = new ScreenCaptureParameters() this.rtcEngine?.startScreenCapture(screenConfig) @@ -187,14 +201,19 @@ struct LocalVideoTranscoding { let config = new LocalTranscoderConfiguration() config.transcodingVideoStreams = new Array(2) + config.videoOutputConfiguration.dimensions = new VideoDimensions(width,height) + config.transcodingVideoStreams[0] = new TranscodingVideoStream(); config.transcodingVideoStreams[0].sourceType = Constants.VideoSourceType.SCREEN_PRIMARY config.transcodingVideoStreams[0].width = width config.transcodingVideoStreams[0].height = height + config.transcodingVideoStreams[0].x = 0 + config.transcodingVideoStreams[0].y = 0 config.transcodingVideoStreams[0].zOrder = 1 + config.transcodingVideoStreams[1] = new TranscodingVideoStream() config.transcodingVideoStreams[1].sourceType = Constants.VideoSourceType.CAMERA_PRIMARY - config.transcodingVideoStreams[1].width = width / 2 - config.transcodingVideoStreams[1].height = height / 2 + config.transcodingVideoStreams[1].width = width/2 + config.transcodingVideoStreams[1].height = height/2 config.transcodingVideoStreams[1].x = 0 config.transcodingVideoStreams[1].y = height / 2 config.transcodingVideoStreams[1].zOrder = 2 @@ -213,7 +232,7 @@ struct LocalVideoTranscoding { mediaOption.channelProfile = Constants.ChannelProfile.LIVE_BROADCASTING; mediaOption.clientRoleType = Constants.ClientRole.BROADCASTER; - let token = await TokenUtils.genRtcToken(this.channelName, "") + let token = "" let ret = this.rtcEngine?.joinChannelWithOptions(token, this.channelName, 0, mediaOption) if (ret != Constants.ErrorCode.ERR_OK) { ShowToast.longToast("joinChannelWithOptions error " + ret + " : " + diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/PlayAudioFiles.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/PlayAudioFiles.ets index 2c99aa24f..c317473a3 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/PlayAudioFiles.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/PlayAudioFiles.ets @@ -133,9 +133,13 @@ struct PlayAudioFiles { Text($r('app.string.audio_mixing')).padding({ top: 6, bottom: 6 }) Divider() Row() { - Button($r('app.string.start')).layoutWeight(1).fontColor(Color.Blue).buttonStyle(ButtonStyleMode.NORMAL).onClick(() => { - this.rtcEngine?.startAudioMixing("https://webdemo.agora.io/audiomixing.mp3", false, -1, 0) - }) + Button($r('app.string.start')) + .layoutWeight(1) + .fontColor(Color.Blue) + .buttonStyle(ButtonStyleMode.NORMAL) + .onClick(() => { + this.rtcEngine?.startAudioMixing("https://webdemo.agora.io/audiomixing.mp3", false, -1, 0) + }) Button($r('app.string.resume')) .layoutWeight(1) .fontColor(Color.Blue) @@ -143,9 +147,13 @@ struct PlayAudioFiles { .onClick(() => { this.rtcEngine?.resumeAudioMixing() }) - Button($r('app.string.pause')).layoutWeight(1).fontColor(Color.Blue).buttonStyle(ButtonStyleMode.NORMAL).onClick(() => { - this.rtcEngine?.pauseAudioMixing() - }) + Button($r('app.string.pause')) + .layoutWeight(1) + .fontColor(Color.Blue) + .buttonStyle(ButtonStyleMode.NORMAL) + .onClick(() => { + this.rtcEngine?.pauseAudioMixing() + }) Button($r('app.string.stop')) .layoutWeight(1) .fontColor(Color.Blue) @@ -176,33 +184,47 @@ struct PlayAudioFiles { }) }.alignItems(VerticalAlign.Center) - Text($r('app.string.audio_effect')).padding({ top: 12, bottom: 6 }) - Divider() - Row() { - Button($r('app.string.start')).layoutWeight(1).fontColor(Color.Blue).buttonStyle(ButtonStyleMode.NORMAL).onClick(() => { - this.rtcEngine?.playEffect(0, "https://webdemo.agora.io/ding.mp3", -1, 1, 0.0, 100, true, 0) - }) - Button($r('app.string.resume')) - .layoutWeight(1) - .fontColor(Color.Blue) - .buttonStyle(ButtonStyleMode.NORMAL) - .onClick(() => { - - }) - Button($r('app.string.pause')).layoutWeight(1).fontColor(Color.Blue).buttonStyle(ButtonStyleMode.NORMAL).onClick(() => { + //todo + if (false) { + Text($r('app.string.audio_effect')).padding({ top: 12, bottom: 6 }) + Divider() + Row() { + Button($r('app.string.start')) + .layoutWeight(1) + .fontColor(Color.Blue) + .buttonStyle(ButtonStyleMode.NORMAL) + .onClick(() => { + this.rtcEngine?.playEffect(0, "https://webdemo.agora.io/ding.mp3", -1, 1, 0.0, 100, true, 0) + }) + Button($r('app.string.resume')) + .layoutWeight(1) + .fontColor(Color.Blue) + .buttonStyle(ButtonStyleMode.NORMAL) + .onClick(() => { - }) - Button($r('app.string.stop')).layoutWeight(1).fontColor(Color.Blue).buttonStyle(ButtonStyleMode.NORMAL).onClick(() => { + }) + Button($r('app.string.pause')) + .layoutWeight(1) + .fontColor(Color.Blue) + .buttonStyle(ButtonStyleMode.NORMAL) + .onClick(() => { - }) - }.alignItems(VerticalAlign.Center).padding({ top: 12, bottom: 6 }) + }) + Button($r('app.string.stop')) + .layoutWeight(1) + .fontColor(Color.Blue) + .buttonStyle(ButtonStyleMode.NORMAL) + .onClick(() => { - Row() { - Text($r('app.string.volume')).layoutWeight(1) - Slider({ value: 100 }).layoutWeight(1.5).onChange((value) => { + }) + }.alignItems(VerticalAlign.Center).padding({ top: 12, bottom: 6 }) + Row() { + Text($r('app.string.volume')).layoutWeight(1) + Slider({ value: 100 }).layoutWeight(1.5).onChange((value) => { - }) - }.alignItems(VerticalAlign.Center) + }) + }.alignItems(VerticalAlign.Center) + } } .alignItems(HorizontalAlign.Start) .layoutWeight(3) diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/PreCallTest.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/PreCallTest.ets index d72c38d2c..5c3b8d303 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/PreCallTest.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/PreCallTest.ets @@ -151,74 +151,77 @@ struct PlayAudioFiles { bottom: 6 }) - Column() { - Text('Audio Echo Pretest').padding({ top: 6, bottom: 6 }) - Divider() - Button(this.isAudioEchoTesting ? this.audioEchoTestingText : $r('app.string.start')) - .margin({ top: 6, bottom: 6 }) - .enabled(!this.isAudioEchoTesting && !this.isVideoEchoTesting) - .onClick(() => { + //todo + if (false) { + Column() { + Text('Audio Echo Pretest').padding({ top: 6, bottom: 6 }) + Divider() + Button(this.isAudioEchoTesting ? this.audioEchoTestingText : $r('app.string.start')) + .margin({ top: 6, bottom: 6 }) + .enabled(!this.isAudioEchoTesting && !this.isVideoEchoTesting) + .onClick(() => { - // TODO - // this.rtcEngine?.startEchoTest() - let countDownCount = 10 - let revert = false - let countDownIndex = countDownCount - this.audioEchoTestingText = 'Recording(' + countDownIndex + 's)' - this.isAudioEchoTesting = true - this.audioEchoCountDown = setInterval(() => { - if (!revert) { - if (countDownIndex > 0) { - this.audioEchoTestingText = 'Recording(' + countDownIndex + 's)' - countDownIndex-- - } else { - revert = true + // TODO + // this.rtcEngine?.startEchoTest() + let countDownCount = 10 + let revert = false + let countDownIndex = countDownCount + this.audioEchoTestingText = 'Recording(' + countDownIndex + 's)' + this.isAudioEchoTesting = true + this.audioEchoCountDown = setInterval(() => { + if (!revert) { + if (countDownIndex > 0) { + this.audioEchoTestingText = 'Recording(' + countDownIndex + 's)' + countDownIndex-- + } else { + revert = true + } } - } - if (revert) { - if (countDownIndex < countDownCount) { - countDownIndex++ - this.audioEchoTestingText = 'Playing(' + countDownIndex + 's)' - } else { - clearInterval(this.audioEchoCountDown) - this.audioEchoCountDown = undefined - this.isAudioEchoTesting = false + if (revert) { + if (countDownIndex < countDownCount) { + countDownIndex++ + this.audioEchoTestingText = 'Playing(' + countDownIndex + 's)' + } else { + clearInterval(this.audioEchoCountDown) + this.audioEchoCountDown = undefined + this.isAudioEchoTesting = false + } } + }, 1000) + }) + Text('Video Echo Pretest').padding({ top: 6, bottom: 6 }) + Divider() + Button($r(this.isVideoEchoTesting ? 'app.string.stop' : 'app.string.start')) + .margin({ top: 6, bottom: 12 }) + .enabled(!this.isAudioEchoTesting) + .onClick(() => { + this.isVideoEchoTesting = !this.isVideoEchoTesting + // TODO + // this.rtcEngine?.startEchoTest() + if (this.isVideoEchoTesting) { + this.rtcEngine?.startPreview() + } else { + this.rtcEngine?.stopPreview() } - }, 1000) - }) - Text('Video Echo Pretest').padding({ top: 6, bottom: 6 }) - Divider() - Button($r(this.isVideoEchoTesting ? 'app.string.stop' : 'app.string.start')) - .margin({ top: 6, bottom: 12 }) - .enabled(!this.isAudioEchoTesting) - .onClick(() => { - this.isVideoEchoTesting = !this.isVideoEchoTesting - // TODO - // this.rtcEngine?.startEchoTest() - if (this.isVideoEchoTesting) { - this.rtcEngine?.startPreview() - } else { - this.rtcEngine?.stopPreview() - } - }) - XComponent({ - id: 'preview_local', - type: 'surface', - libraryname: Constants.AGORA_LIB_NAME, - }).onLoad(() => { - let localCanvas = new VideoCanvas("preview_local"); - localCanvas.renderMode = VideoCanvas.RENDER_MODE_HIDDEN; - this.rtcEngine?.setupLocalVideo(localCanvas); - }).width(150).height(150) - }.alignItems(HorizontalAlign.Start) - .layoutWeight(1.3) - .padding({ - left: 12, - right: 12, - top: 6, - bottom: 6 - }) + }) + XComponent({ + id: 'preview_local', + type: XComponentType.SURFACE, + libraryname: Constants.AGORA_LIB_NAME, + }).onLoad(() => { + let localCanvas = new VideoCanvas("preview_local"); + localCanvas.renderMode = VideoCanvas.RENDER_MODE_HIDDEN; + this.rtcEngine?.setupLocalVideo(localCanvas); + }).width(150).height(150) + }.alignItems(HorizontalAlign.Start) + .layoutWeight(1.3) + .padding({ + left: 12, + right: 12, + top: 6, + bottom: 6 + }) + } } diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/RTMPStreaming.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/RTMPStreaming.ets index ba4f67ac4..18e4477f7 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/RTMPStreaming.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/RTMPStreaming.ets @@ -40,17 +40,19 @@ struct RTMPStreaming { config.mEventHandler = {}; config.mEventHandler.onUserJoined = (uid: number, collapse: number) => { Logger.info(TAG, "mEventHandler.onUserJoined: " + uid + " , " + collapse); - if (this.remoteUid == -1) { - this.remoteUid = uid - this.transcodingParameters.transcodingUsers[uid] = { - uid: uid, - x: 0, - y: this.transcodingParameters.height / 2, - width: this.transcodingParameters.width, - height: this.transcodingParameters.height / 2, - zOrder: 1 - } - } + // if (this.remoteUid == -1) { + // this.remoteUid = uid + // let user = new TranscodingUser(); + // user.uid = uid; + // user.x = 0; + // user.y = this.transcodingParameters.height / 2; + // user.width = this.transcodingParameters.width; + // user.height = this.transcodingParameters.height / 2; + // user.zOrder = 1; + // user.alpha = 1.0 + // user.audioChannel = 2; + // this.transcodingParameters.transcodingUsers.set(uid,user) + // } }; config.mEventHandler.onUserOffline = (uid: number, reason: number) => { Logger.info(TAG, "mEventHandler.onUserOffline: " + uid + " , " + reason) @@ -62,14 +64,17 @@ struct RTMPStreaming { config.mEventHandler.onJoinChannelSuccess = (cid: string, uid: number, elapsed: number) => { Logger.info(TAG, "mEventHandler.onJoinChannelSuccess: " + uid); this.transcodingParameters.transcodingUsers = new Map(); - this.transcodingParameters.transcodingUsers[uid] = { + let localUser:TranscodingUser = { uid: uid, x: 0, y: 0, width: this.transcodingParameters.width, height: this.transcodingParameters.height / 2, - zOrder: 1 + zOrder: 1, + alpha:1.0, + audioChannel:0, } + this.transcodingParameters.transcodingUsers.set(uid,localUser) this.isJoin = true this.localUid = uid } @@ -130,7 +135,7 @@ struct RTMPStreaming { if (this.localUid != -1) { XComponent({ id: 'preview_local', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_local"); @@ -144,7 +149,7 @@ struct RTMPStreaming { if (this.remoteUid != -1) { XComponent({ id: 'preview_remote', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_remote"); diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ScreenSharing.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ScreenSharing.ets index 5798be078..8134a5944 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ScreenSharing.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ScreenSharing.ets @@ -118,7 +118,7 @@ struct ScreenSharing { if (this.localUid != -1) { XComponent({ id: 'preview_local', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_local"); @@ -133,7 +133,7 @@ struct ScreenSharing { if (this.remoteUid != -1) { XComponent({ id: 'preview_remote', - type: 'surface', + type: XComponentType.SURFACE, libraryname: Constants.AGORA_LIB_NAME, }).onLoad(() => { let localCanvas = new VideoCanvas("preview_remote"); diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/util/Logger.ts b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/util/Logger.ts index ce9357b42..5007df7fa 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/util/Logger.ts +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/util/Logger.ts @@ -42,4 +42,4 @@ class Logger { } } -export default new Logger('APIExample') \ No newline at end of file +export default new Logger('AppTag') \ No newline at end of file From 500b7894633321fc4d94663b575bc928e03999b9 Mon Sep 17 00:00:00 2001 From: weileifrank <1138289316@qq.com> Date: Mon, 30 Sep 2024 18:31:48 +0800 Subject: [PATCH 09/21] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E4=BA=86?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E8=BD=AC=E7=A0=81=E7=9A=84=E5=B1=8F=E5=B9=95?= =?UTF-8?q?=E9=87=87=E9=9B=86=E5=8F=82=E6=95=B0=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entry/src/main/ets/pages/advance/LocalVideoTranscoding.ets | 1 + 1 file changed, 1 insertion(+) diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LocalVideoTranscoding.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LocalVideoTranscoding.ets index 32a4fcebf..e6b88c618 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LocalVideoTranscoding.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LocalVideoTranscoding.ets @@ -194,6 +194,7 @@ struct LocalVideoTranscoding { let height = GlobalInfo.settings.dimensions.width let screenConfig = new ScreenCaptureParameters() + screenConfig.videoParams.dimensions = new VideoDimensions(width,height) this.rtcEngine?.startScreenCapture(screenConfig) let cameraConfig = new CameraCapturerConfiguration() From 5c2cff4903561c2150c04649668857dd3f79872c Mon Sep 17 00:00:00 2001 From: weileifrank <1138289316@qq.com> Date: Mon, 14 Oct 2024 19:47:30 +0800 Subject: [PATCH 10/21] feat: update hm sdk to 12 --- HarmonyOS_NEXT/APIExample/AppScope/app.json5 | 2 +- HarmonyOS_NEXT/APIExample/build-profile.json5 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/HarmonyOS_NEXT/APIExample/AppScope/app.json5 b/HarmonyOS_NEXT/APIExample/AppScope/app.json5 index 485bd0939..d74402112 100644 --- a/HarmonyOS_NEXT/APIExample/AppScope/app.json5 +++ b/HarmonyOS_NEXT/APIExample/AppScope/app.json5 @@ -1,6 +1,6 @@ { "app": { - "bundleName": "io.agora.hmos.apiexample", + "bundleName": "io.agora.api.example", "vendor": "example", "versionCode": 1000000, "versionName": "1.0.0", diff --git a/HarmonyOS_NEXT/APIExample/build-profile.json5 b/HarmonyOS_NEXT/APIExample/build-profile.json5 index 4d540b2b1..a26322be0 100644 --- a/HarmonyOS_NEXT/APIExample/build-profile.json5 +++ b/HarmonyOS_NEXT/APIExample/build-profile.json5 @@ -6,8 +6,8 @@ { "name": "default", "signingConfig": "default", - "compatibleSdkVersion": "4.1.0(11)", - "runtimeOS": "HarmonyOS", + "compatibleSdkVersion": "5.0.0(12)", + "runtimeOS": "HarmonyOS" } ], "buildModeSet": [ From cb0183fcd746834b4163995bcbca76996bb7cb65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BC=BA?= Date: Wed, 16 Oct 2024 12:31:55 +0800 Subject: [PATCH 11/21] change package name to @shengwang/rtc-full --- HarmonyOS_NEXT/APIExample/entry/oh-package.json5 | 2 +- .../APIExample/entry/src/main/cpp/CMakeLists.txt | 2 +- .../entry/src/main/ets/common/KeyCenter.ets | 4 ++-- .../entry/src/main/ets/model/DataType.ets | 2 +- .../APIExample/entry/src/main/ets/pages/Data.ets | 2 +- .../entry/src/main/ets/pages/Settings.ets | 2 +- .../main/ets/pages/advance/ChannelEncryption.ets | 2 +- .../ets/pages/advance/CustomAudioRenderWrap.ets | 2 +- .../main/ets/pages/advance/CustomAudioSource.ets | 2 +- .../main/ets/pages/advance/CustomVideoSource.ets | 14 +++++--------- .../main/ets/pages/advance/HostCrossChannel.ets | 2 +- .../main/ets/pages/advance/JoinMultiChannel.ets | 2 +- .../src/main/ets/pages/advance/LiveStreaming.ets | 2 +- .../ets/pages/advance/LocalVideoTranscoding.ets | 10 +++++----- .../main/ets/pages/advance/MediaMetadataWrap.ets | 2 +- .../src/main/ets/pages/advance/MediaRecorder.ets | 2 +- .../main/ets/pages/advance/OriginAudioDataWrap.ets | 2 +- .../main/ets/pages/advance/OriginVideoDataWrap.ets | 2 +- .../src/main/ets/pages/advance/PlayAudioFiles.ets | 2 +- .../src/main/ets/pages/advance/PreCallTest.ets | 2 +- .../src/main/ets/pages/advance/RTMPStreaming.ets | 2 +- .../src/main/ets/pages/advance/ScreenSharing.ets | 2 +- .../src/main/ets/pages/basic/JoinAudioChannel.ets | 2 +- .../src/main/ets/pages/basic/JoinVideoChannel.ets | 2 +- .../main/ets/pages/basic/JoinVideoChannelToken.ets | 2 +- .../entry/src/main/ets/util/AudioConfigContant.ets | 2 +- 26 files changed, 35 insertions(+), 39 deletions(-) diff --git a/HarmonyOS_NEXT/APIExample/entry/oh-package.json5 b/HarmonyOS_NEXT/APIExample/entry/oh-package.json5 index cc2d344da..24e606565 100644 --- a/HarmonyOS_NEXT/APIExample/entry/oh-package.json5 +++ b/HarmonyOS_NEXT/APIExample/entry/oh-package.json5 @@ -6,7 +6,7 @@ "author": "", "license": "", "dependencies": { - "AgoraRtcSdk": "file:./libs/AgoraRtcSdk.har", + "@shengwang/rtc-full": "file:./libs/AgoraRtcSdk.har", "librawdataprocessing.so": "file:./src/main/cpp/types/librawdataprocessing" } } diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/CMakeLists.txt b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/CMakeLists.txt index ad18be409..7ae131518 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/CMakeLists.txt +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/CMakeLists.txt @@ -11,7 +11,7 @@ endif() include_directories(${ROOT_PATH} ${ROOT_PATH}/include) -set(AGORA_LIB_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules/AgoraRtcSdk/libs) +set(AGORA_LIB_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules/@shengwang/rtc-full/libs) add_library(agora_rtc_sdk SHARED IMPORTED) set_target_properties(agora_rtc_sdk PROPERTIES IMPORTED_LOCATION ${AGORA_LIB_PATH}/${CMAKE_OHOS_ARCH_ABI}/libagora_rtc_sdk.so) diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/common/KeyCenter.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/common/KeyCenter.ets index 8cd76ba30..f8d675bba 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/common/KeyCenter.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/common/KeyCenter.ets @@ -2,10 +2,10 @@ // Agora APP ID. // 声网APP ID。 -export const AppID: string = YOUR APP ID +export const AppID: string = "aab8b8f5a8cd4469a63042fcfafe7063" // Agora APP Certificate. If the project does not have certificates enabled, leave this field blank. // PS:It is unsafe to place the App Certificate on the client side, it is recommended to place it on the server side to ensure that the App Certificate is not leaked. // 声网APP证书。如果项目没有开启证书鉴权,这个字段留空。 // 注意:App证书放在客户端不安全,推荐放在服务端以确保 App 证书不会泄露。 -export const AppCertificate: string = YOUR APP CERTIFICATE \ No newline at end of file +export const AppCertificate: string = "" \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/model/DataType.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/model/DataType.ets index 2380a9ab0..6aa3d91e5 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/model/DataType.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/model/DataType.ets @@ -1,4 +1,4 @@ -import { OrientationMode, VideoDimensions } from 'AgoraRtcSdk' +import { OrientationMode, VideoDimensions } from '@shengwang/rtc-full' export interface ExampleCategory{ title: Resource, diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/Data.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/Data.ets index 9a9dafb57..682eec7a3 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/Data.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/Data.ets @@ -1,4 +1,4 @@ -import { OrientationMode, VideoDimensions } from 'AgoraRtcSdk' +import { OrientationMode, VideoDimensions } from '@shengwang/rtc-full' import { ExampleCategory, ExampleItem, SettingsInfo } from '../model/DataType' export const BASIC_ITEMS: ExampleItem[] = diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/Settings.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/Settings.ets index 0115351e1..e6d6755df 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/Settings.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/Settings.ets @@ -1,4 +1,4 @@ -import { OrientationMode, RtcEngine, VideoDimensions } from 'AgoraRtcSdk' +import { OrientationMode, RtcEngine, VideoDimensions } from '@shengwang/rtc-full' import { TitleBar } from '../common/TitleBar' import { CommonItemSelect } from '../common/Widgets' import { GlobalInfo } from './Data' diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ChannelEncryption.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ChannelEncryption.ets index b1cfde0c8..f85bb4915 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ChannelEncryption.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ChannelEncryption.ets @@ -4,7 +4,7 @@ import { EncryptionMode, RtcEngine, RtcEngineConfig, VideoCanvas, VideoEncoderConfiguration -} from 'AgoraRtcSdk'; +} from '@shengwang/rtc-full'; import { TitleBar } from '../../common/TitleBar'; import Logger from '../../util/Logger'; import ShowToast from '../../util/ShowToast'; diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/CustomAudioRenderWrap.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/CustomAudioRenderWrap.ets index 1826ae278..0db1755d7 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/CustomAudioRenderWrap.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/CustomAudioRenderWrap.ets @@ -3,7 +3,7 @@ import { Constants, RtcEngine, RtcEngineConfig -} from 'AgoraRtcSdk'; +} from '@shengwang/rtc-full'; import { TitleBar } from '../../common/TitleBar'; import Logger from '../../util/Logger'; import ShowToast from '../../util/ShowToast'; diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/CustomAudioSource.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/CustomAudioSource.ets index 93d333552..27f9c16ae 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/CustomAudioSource.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/CustomAudioSource.ets @@ -1,5 +1,5 @@ import { AudioTrackConfig, ChannelMediaOptions, Constants, RtcEngine, RtcEngineConfig, - VideoEncoderConfiguration } from 'AgoraRtcSdk'; + VideoEncoderConfiguration } from '@shengwang/rtc-full'; import { common } from '@kit.AbilityKit'; import { AppID } from '../../common/KeyCenter'; import Logger from '../../util/Logger'; diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/CustomVideoSource.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/CustomVideoSource.ets index 723408c70..1ab4a38a8 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/CustomVideoSource.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/CustomVideoSource.ets @@ -9,7 +9,7 @@ import { VideoEncoderConfiguration, VideoFrame, VideoPixelFormat -} from 'AgoraRtcSdk'; +} from '@shengwang/rtc-full'; import { TitleBar } from '../../common/TitleBar'; import Logger from '../../util/Logger'; import ShowToast from '../../util/ShowToast'; @@ -27,7 +27,6 @@ struct CustomVideoSource { private rtcEngine: RtcEngineEx | undefined = undefined; private pushingVideoFrame = false private intervalVideoNum = -1; - private customVideoTrack = -1; @State message: string = 'Hello World'; @State channelName: string = '' @State isJoin: boolean = false @@ -77,7 +76,7 @@ struct CustomVideoSource { this.rtcEngine.enableVideo() - this.customVideoTrack = this.rtcEngine.createCustomVideoTrack() + this.rtcEngine.setExternalVideoSource(true,false,Constants.ExternalVideoSourceType.VIDEO_FRAME); } aboutToDisappear(): void { @@ -87,8 +86,6 @@ struct CustomVideoSource { this.rtcEngine.leaveChannel(); } this.stopPushVideo() - this.rtcEngine.destroyCustomVideoTrack(this.customVideoTrack) - this.customVideoTrack = -1 Logger.info(TAG, "destroy begin") RtcEngine.destroy().then(() => { Logger.info(TAG, "destroy done") @@ -129,8 +126,8 @@ struct CustomVideoSource { frame.yStride = width; frame.height = height; frame.timestamp = 0; - let ret = this.rtcEngine?.pushExternalVideoFrameById(frame, this.customVideoTrack) - if (ret != 0) { + let ret = this.rtcEngine?.pushExternalVideoFrame(frame) + if (!ret) { Logger.error(TAG, "pushExternalVideoFrameEx failed: " + ret) } }, frame_interval_ms) @@ -165,7 +162,7 @@ struct CustomVideoSource { let localCanvas = new VideoCanvas("preview_local"); localCanvas.uid = this.localUid; localCanvas.renderMode = VideoCanvas.RENDER_MODE_HIDDEN; - localCanvas.mirrorMode = 0; + localCanvas.mirrorMode = VideoCanvas.VIDEO_MIRROR_MODE_DISABLED; // TODO set source type localCanvas.sourceType = Constants.VideoSourceType.CUSTOM this.rtcEngine?.setupLocalVideo(localCanvas); @@ -232,7 +229,6 @@ struct CustomVideoSource { } let mediaOption: ChannelMediaOptions = new ChannelMediaOptions(); mediaOption.publishCustomVideoTrack = true - mediaOption.customVideoTrackId = this.customVideoTrack mediaOption.publishMicrophoneTrack = true; mediaOption.autoSubscribeVideo = true; mediaOption.autoSubscribeAudio = true; diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/HostCrossChannel.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/HostCrossChannel.ets index 4b7d6e25f..ef669626d 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/HostCrossChannel.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/HostCrossChannel.ets @@ -6,7 +6,7 @@ import { RtcEngineConfig, VideoCanvas, VideoEncoderConfiguration -} from 'AgoraRtcSdk'; +} from '@shengwang/rtc-full'; import { TitleBar } from '../../common/TitleBar'; import Logger from '../../util/Logger'; import ShowToast from '../../util/ShowToast'; diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/JoinMultiChannel.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/JoinMultiChannel.ets index 37915eafa..38038f1e9 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/JoinMultiChannel.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/JoinMultiChannel.ets @@ -8,7 +8,7 @@ import { RtcEngineEx, VideoCanvas, VideoEncoderConfiguration -} from 'AgoraRtcSdk'; +} from '@shengwang/rtc-full'; import { TitleBar } from '../../common/TitleBar'; import Logger from '../../util/Logger'; import { common } from '@kit.AbilityKit'; diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LiveStreaming.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LiveStreaming.ets index a2781edf9..b1b0f65b3 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LiveStreaming.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LiveStreaming.ets @@ -6,7 +6,7 @@ import { RtcEngineConfig, VideoCanvas, VideoEncoderConfiguration -} from 'AgoraRtcSdk'; +} from '@shengwang/rtc-full'; import { TitleBar } from '../../common/TitleBar'; import Logger from '../../util/Logger'; import ShowToast from '../../util/ShowToast'; diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LocalVideoTranscoding.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LocalVideoTranscoding.ets index 7309dd6a6..7f8831132 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LocalVideoTranscoding.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LocalVideoTranscoding.ets @@ -9,7 +9,7 @@ import { VideoCanvas, VideoEncoderConfiguration, ScreenCaptureParameters -} from 'AgoraRtcSdk'; +} from '@shengwang/rtc-full'; import { TitleBar } from '../../common/TitleBar'; import Logger from '../../util/Logger'; import ShowToast from '../../util/ShowToast'; @@ -19,10 +19,10 @@ import { common } from '@kit.AbilityKit'; import { GlobalInfo } from '../Data'; import { TokenUtils } from '../../util/TokenUtils'; import { LengthMetrics } from '@kit.ArkUI'; -import { TranscodingVideoStream } from 'AgoraRtcSdk'; +import { TranscodingVideoStream } from '@shengwang/rtc-full'; import { JSON } from '@kit.ArkTS'; import { camera } from '@kit.CameraKit'; -import { VideoDimensions } from 'AgoraRtcSdk'; +import { VideoDimensions } from '@shengwang/rtc-full'; const TAG: string = 'LocalVideoTranscoding' @@ -190,8 +190,8 @@ struct LocalVideoTranscoding { } - let width = 960; - let height = 540; + let width = 540; + let height = 960; let screenConfig = new ScreenCaptureParameters() this.rtcEngine?.startScreenCapture(screenConfig) diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/MediaMetadataWrap.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/MediaMetadataWrap.ets index 81eb83e30..30992e746 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/MediaMetadataWrap.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/MediaMetadataWrap.ets @@ -4,7 +4,7 @@ import { RtcEngineConfig, VideoCanvas, VideoEncoderConfiguration -} from 'AgoraRtcSdk'; +} from '@shengwang/rtc-full'; import { TitleBar } from '../../common/TitleBar'; import Logger from '../../util/Logger'; import ShowToast from '../../util/ShowToast'; diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/MediaRecorder.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/MediaRecorder.ets index c884cbb39..57b92c7b3 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/MediaRecorder.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/MediaRecorder.ets @@ -10,7 +10,7 @@ import { RtcEngineConfig, VideoCanvas, VideoEncoderConfiguration -} from 'AgoraRtcSdk'; +} from '@shengwang/rtc-full'; import { TitleBar } from '../../common/TitleBar'; import Logger from '../../util/Logger'; import ShowToast from '../../util/ShowToast'; diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/OriginAudioDataWrap.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/OriginAudioDataWrap.ets index 8cb6e6163..2b37421bc 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/OriginAudioDataWrap.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/OriginAudioDataWrap.ets @@ -3,7 +3,7 @@ import { Constants, RtcEngine, RtcEngineConfig -} from 'AgoraRtcSdk'; +} from '@shengwang/rtc-full'; import { TitleBar } from '../../common/TitleBar'; import Logger from '../../util/Logger'; import ShowToast from '../../util/ShowToast'; diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/OriginVideoDataWrap.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/OriginVideoDataWrap.ets index 8ba298074..a85797bd0 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/OriginVideoDataWrap.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/OriginVideoDataWrap.ets @@ -4,7 +4,7 @@ import { RtcEngineConfig, VideoCanvas, VideoEncoderConfiguration -} from 'AgoraRtcSdk'; +} from '@shengwang/rtc-full'; import { TitleBar } from '../../common/TitleBar'; import Logger from '../../util/Logger'; import ShowToast from '../../util/ShowToast'; diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/PlayAudioFiles.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/PlayAudioFiles.ets index 2c99aa24f..95fe67c07 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/PlayAudioFiles.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/PlayAudioFiles.ets @@ -1,4 +1,4 @@ -import { ChannelMediaOptions, Constants, RtcEngine, RtcEngineConfig } from 'AgoraRtcSdk'; +import { ChannelMediaOptions, Constants, RtcEngine, RtcEngineConfig } from '@shengwang/rtc-full'; import { TitleBar } from '../../common/TitleBar'; import Logger from '../../util/Logger'; import ShowToast from '../../util/ShowToast'; diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/PreCallTest.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/PreCallTest.ets index 46d6d0cff..5813fc909 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/PreCallTest.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/PreCallTest.ets @@ -5,7 +5,7 @@ import { RtcEngine, RtcEngineConfig, VideoCanvas -} from 'AgoraRtcSdk'; +} from '@shengwang/rtc-full'; import { AppID } from '../../common/KeyCenter'; import Logger from '../../util/Logger'; import { common } from '@kit.AbilityKit'; diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/RTMPStreaming.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/RTMPStreaming.ets index 38d2d818b..295313fd5 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/RTMPStreaming.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/RTMPStreaming.ets @@ -6,7 +6,7 @@ import { TranscodingUser, VideoCanvas, VideoEncoderConfiguration -} from 'AgoraRtcSdk'; +} from '@shengwang/rtc-full'; import { TitleBar } from '../../common/TitleBar'; import Logger from '../../util/Logger'; import ShowToast from '../../util/ShowToast'; diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ScreenSharing.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ScreenSharing.ets index 8134a5944..8414ebc88 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ScreenSharing.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/ScreenSharing.ets @@ -7,7 +7,7 @@ import { ScreenCaptureParameters, VideoCanvas, VideoEncoderConfiguration -} from 'AgoraRtcSdk'; +} from '@shengwang/rtc-full'; import { TitleBar } from '../../common/TitleBar'; import Logger from '../../util/Logger'; import ShowToast from '../../util/ShowToast'; diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/basic/JoinAudioChannel.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/basic/JoinAudioChannel.ets index e8a70bbd9..02cdb295f 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/basic/JoinAudioChannel.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/basic/JoinAudioChannel.ets @@ -1,4 +1,4 @@ -import { ChannelMediaOptions, Constants, RtcEngine, RtcEngineEx, RtcEngineConfig, AudioVolumeInfo } from 'AgoraRtcSdk'; +import { ChannelMediaOptions, Constants, RtcEngine, RtcEngineEx, RtcEngineConfig, AudioVolumeInfo } from '@shengwang/rtc-full'; import { TitleBar } from '../../common/TitleBar'; import Logger from '../../util/Logger'; import ShowToast from '../../util/ShowToast'; diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/basic/JoinVideoChannel.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/basic/JoinVideoChannel.ets index 56ea46e4a..451216568 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/basic/JoinVideoChannel.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/basic/JoinVideoChannel.ets @@ -1,5 +1,5 @@ import { ChannelMediaOptions, Constants, RtcEngine, RtcEngineConfig, VideoCanvas, - VideoEncoderConfiguration } from 'AgoraRtcSdk'; + VideoEncoderConfiguration } from '@shengwang/rtc-full'; import { TitleBar } from '../../common/TitleBar'; import Logger from '../../util/Logger'; import ShowToast from '../../util/ShowToast'; diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/basic/JoinVideoChannelToken.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/basic/JoinVideoChannelToken.ets index 83da234b2..0d489e23d 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/basic/JoinVideoChannelToken.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/basic/JoinVideoChannelToken.ets @@ -5,7 +5,7 @@ import { RtcEngineConfig, VideoCanvas, VideoEncoderConfiguration -} from 'AgoraRtcSdk'; +} from '@shengwang/rtc-full'; import { TitleBar } from '../../common/TitleBar'; import Logger from '../../util/Logger'; import ShowToast from '../../util/ShowToast'; diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/util/AudioConfigContant.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/util/AudioConfigContant.ets index 30116f271..9217c9b0d 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/util/AudioConfigContant.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/util/AudioConfigContant.ets @@ -1,4 +1,4 @@ -import { Constants } from 'AgoraRtcSdk'; +import { Constants } from '@shengwang/rtc-full'; export class AudioConfigHelper { public static readonly AUDIO_SCENARIO_DEFAULT = 'DEFAULT' From 9272795f7b396d8f00a83f95decc2d6252241b05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BC=BA?= Date: Wed, 16 Oct 2024 12:32:17 +0800 Subject: [PATCH 12/21] change compatibleSdkVersion to 12 --- HarmonyOS_NEXT/APIExample/build-profile.json5 | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/HarmonyOS_NEXT/APIExample/build-profile.json5 b/HarmonyOS_NEXT/APIExample/build-profile.json5 index 4d540b2b1..54ddd3528 100644 --- a/HarmonyOS_NEXT/APIExample/build-profile.json5 +++ b/HarmonyOS_NEXT/APIExample/build-profile.json5 @@ -1,12 +1,25 @@ { "app": { "signingConfigs": [ + { + "name": "default", + "type": "HarmonyOS", + "material": { + "certpath": "/Users/cq/.ohos/config/default_APIExample_axMKKS64cQDQsQ6bHFnXMUpgiiWWvdAiYIAQRESXFcE=.cer", + "storePassword": "0000001B29F4B597AE24E5DFA695B70A98E876AD80EBAC66A7A107C5B98378DA1F7C3446A142560E622057", + "keyAlias": "debugKey", + "keyPassword": "0000001B636D85EE406DD60B7DFB648047967EF17C9D98A2FA5C207C4F810B2E9CFB715DEAE140F72BD0AE", + "profile": "/Users/cq/.ohos/config/default_APIExample_axMKKS64cQDQsQ6bHFnXMUpgiiWWvdAiYIAQRESXFcE=.p7b", + "signAlg": "SHA256withECDSA", + "storeFile": "/Users/cq/.ohos/config/default_APIExample_axMKKS64cQDQsQ6bHFnXMUpgiiWWvdAiYIAQRESXFcE=.p12" + } + } ], "products": [ { "name": "default", "signingConfig": "default", - "compatibleSdkVersion": "4.1.0(11)", + "compatibleSdkVersion": "5.0.0(12)", "runtimeOS": "HarmonyOS", } ], From 13e4296731ea549b2eadf2ec0b388147e99f136d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BC=BA?= Date: Wed, 16 Oct 2024 12:38:57 +0800 Subject: [PATCH 13/21] fix mistake --- .../pages/advance/LocalVideoTranscoding.ets | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LocalVideoTranscoding.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LocalVideoTranscoding.ets index 7f8831132..2959ae3cf 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LocalVideoTranscoding.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LocalVideoTranscoding.ets @@ -18,7 +18,7 @@ import PermissionHelper from '../../util/PermissionHelper'; import { common } from '@kit.AbilityKit'; import { GlobalInfo } from '../Data'; import { TokenUtils } from '../../util/TokenUtils'; -import { LengthMetrics } from '@kit.ArkUI'; +import { display,LengthMetrics } from '@kit.ArkUI'; import { TranscodingVideoStream } from '@shengwang/rtc-full'; import { JSON } from '@kit.ArkTS'; import { camera } from '@kit.CameraKit'; @@ -124,7 +124,7 @@ struct LocalVideoTranscoding { build() { Column() { TitleBar({ - title: $r('app.string.item_livestreaming'), + title: $r('app.string.item_localvideotranscoding'), showBack: true }) @@ -138,7 +138,7 @@ struct LocalVideoTranscoding { let localCanvas = new VideoCanvas("preview_local"); localCanvas.uid = this.localUid; localCanvas.renderMode = VideoCanvas.RENDER_MODE_FIT; - localCanvas.mirrorMode = 0; + localCanvas.mirrorMode = VideoCanvas.VIDEO_MIRROR_MODE_DISABLED; localCanvas.sourceType = Constants.VideoSourceType.TRANSCODED this.rtcEngine?.setupLocalVideo(localCanvas); }).width('100%').height('100%') @@ -190,10 +190,11 @@ struct LocalVideoTranscoding { } - let width = 540; - let height = 960; + let width = GlobalInfo.settings.dimensions.height + let height = GlobalInfo.settings.dimensions.width let screenConfig = new ScreenCaptureParameters() + screenConfig.videoParams.dimensions = new VideoDimensions(width,height) this.rtcEngine?.startScreenCapture(screenConfig) let cameraConfig = new CameraCapturerConfiguration() @@ -204,7 +205,7 @@ struct LocalVideoTranscoding { config.videoOutputConfiguration.dimensions = new VideoDimensions(width,height) config.transcodingVideoStreams[0] = new TranscodingVideoStream(); config.transcodingVideoStreams[0].sourceType = Constants.VideoSourceType.SCREEN_PRIMARY - config.transcodingVideoStreams[0].width = width/2 + config.transcodingVideoStreams[0].width = width config.transcodingVideoStreams[0].height = height config.transcodingVideoStreams[0].x = 0 config.transcodingVideoStreams[0].y = 0 @@ -213,9 +214,9 @@ struct LocalVideoTranscoding { config.transcodingVideoStreams[1] = new TranscodingVideoStream() config.transcodingVideoStreams[1].sourceType = Constants.VideoSourceType.CAMERA_PRIMARY config.transcodingVideoStreams[1].width = width/2 - config.transcodingVideoStreams[1].height = height - config.transcodingVideoStreams[1].x = width/2 - config.transcodingVideoStreams[1].y = 0 + config.transcodingVideoStreams[1].height = height/2 + config.transcodingVideoStreams[1].x = 0 + config.transcodingVideoStreams[1].y = height / 2 config.transcodingVideoStreams[1].zOrder = 2 config.transcodingVideoStreams[1].mirror = true From ed8775dccd1f6d14d105cd195b2c6ecdb0dbdfc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BC=BA?= Date: Wed, 16 Oct 2024 12:43:00 +0800 Subject: [PATCH 14/21] fix mistake --- HarmonyOS_NEXT/APIExample/build-profile.json5 | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/HarmonyOS_NEXT/APIExample/build-profile.json5 b/HarmonyOS_NEXT/APIExample/build-profile.json5 index 54ddd3528..b2cc02977 100644 --- a/HarmonyOS_NEXT/APIExample/build-profile.json5 +++ b/HarmonyOS_NEXT/APIExample/build-profile.json5 @@ -1,19 +1,6 @@ { "app": { "signingConfigs": [ - { - "name": "default", - "type": "HarmonyOS", - "material": { - "certpath": "/Users/cq/.ohos/config/default_APIExample_axMKKS64cQDQsQ6bHFnXMUpgiiWWvdAiYIAQRESXFcE=.cer", - "storePassword": "0000001B29F4B597AE24E5DFA695B70A98E876AD80EBAC66A7A107C5B98378DA1F7C3446A142560E622057", - "keyAlias": "debugKey", - "keyPassword": "0000001B636D85EE406DD60B7DFB648047967EF17C9D98A2FA5C207C4F810B2E9CFB715DEAE140F72BD0AE", - "profile": "/Users/cq/.ohos/config/default_APIExample_axMKKS64cQDQsQ6bHFnXMUpgiiWWvdAiYIAQRESXFcE=.p7b", - "signAlg": "SHA256withECDSA", - "storeFile": "/Users/cq/.ohos/config/default_APIExample_axMKKS64cQDQsQ6bHFnXMUpgiiWWvdAiYIAQRESXFcE=.p12" - } - } ], "products": [ { From 09f297d3c732ed4739f634ff7f99debb28a23b26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BC=BA?= Date: Wed, 16 Oct 2024 13:23:57 +0800 Subject: [PATCH 15/21] fix mistake --- .../APIExample/entry/src/main/ets/common/KeyCenter.ets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/common/KeyCenter.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/common/KeyCenter.ets index f8d675bba..8cd76ba30 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/common/KeyCenter.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/common/KeyCenter.ets @@ -2,10 +2,10 @@ // Agora APP ID. // 声网APP ID。 -export const AppID: string = "aab8b8f5a8cd4469a63042fcfafe7063" +export const AppID: string = YOUR APP ID // Agora APP Certificate. If the project does not have certificates enabled, leave this field blank. // PS:It is unsafe to place the App Certificate on the client side, it is recommended to place it on the server side to ensure that the App Certificate is not leaked. // 声网APP证书。如果项目没有开启证书鉴权,这个字段留空。 // 注意:App证书放在客户端不安全,推荐放在服务端以确保 App 证书不会泄露。 -export const AppCertificate: string = "" \ No newline at end of file +export const AppCertificate: string = YOUR APP CERTIFICATE \ No newline at end of file From 1067eb04563d1ae5d165a1aa34bd574e853fb074 Mon Sep 17 00:00:00 2001 From: weileifrank <1138289316@qq.com> Date: Wed, 16 Oct 2024 16:07:39 +0800 Subject: [PATCH 16/21] feat: fix import for LocalVideoTranscoding.ets --- .../main/ets/pages/advance/LocalVideoTranscoding.ets | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LocalVideoTranscoding.ets b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LocalVideoTranscoding.ets index 863565e85..184618613 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LocalVideoTranscoding.ets +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/ets/pages/advance/LocalVideoTranscoding.ets @@ -1,14 +1,15 @@ import { CameraCapturerConfiguration, ChannelMediaOptions, - ClientRoleOptions, Constants, LocalTranscoderConfiguration, RtcEngine, RtcEngineConfig, + ScreenCaptureParameters, + TranscodingVideoStream, VideoCanvas, - VideoEncoderConfiguration, - ScreenCaptureParameters + VideoDimensions, + VideoEncoderConfiguration } from '@shengwang/rtc-full'; import { TitleBar } from '../../common/TitleBar'; import Logger from '../../util/Logger'; @@ -17,12 +18,7 @@ import { AppID } from '../../common/KeyCenter'; import PermissionHelper from '../../util/PermissionHelper'; import { common } from '@kit.AbilityKit'; import { GlobalInfo } from '../Data'; -import { TokenUtils } from '../../util/TokenUtils'; -import { display, LengthMetrics } from '@kit.ArkUI'; -import { TranscodingVideoStream } from 'AgoraRtcSdk'; import { JSON } from '@kit.ArkTS'; -import { camera } from '@kit.CameraKit'; -import { VideoDimensions } from 'AgoraRtcSdk'; const TAG: string = 'LocalVideoTranscoding' From aed35dcd9557be5ee50268e44e709b03dfcd197a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BC=BA?= Date: Tue, 22 Oct 2024 18:24:37 +0800 Subject: [PATCH 17/21] enable useNormalizedOHMUrl and use header file in har --- HarmonyOS_NEXT/APIExample/build-profile.json5 | 7 +- .../entry/src/main/cpp/CMakeLists.txt | 2 +- .../src/main/cpp/include/AgoraAtomicOps.h | 73 - .../entry/src/main/cpp/include/AgoraBase.h | 6576 ------------- .../cpp/include/AgoraExtensionProviderEntry.h | 77 - .../main/cpp/include/AgoraExtensionVersion.h | 111 - .../src/main/cpp/include/AgoraMediaBase.h | 1981 ---- .../main/cpp/include/AgoraMediaPlayerTypes.h | 516 - .../src/main/cpp/include/AgoraOptional.h | 891 -- .../main/cpp/include/AgoraRefCountedObject.h | 137 - .../entry/src/main/cpp/include/AgoraRefPtr.h | 156 - .../src/main/cpp/include/IAgoraFileUploader.h | 45 - .../main/cpp/include/IAgoraH265Transcoder.h | 178 - .../entry/src/main/cpp/include/IAgoraLog.h | 99 - .../cpp/include/IAgoraMediaComponentFactory.h | 41 - .../src/main/cpp/include/IAgoraMediaEngine.h | 285 - .../src/main/cpp/include/IAgoraMediaPlayer.h | 633 -- .../cpp/include/IAgoraMediaPlayerSource.h | 493 - .../main/cpp/include/IAgoraMediaRecorder.h | 90 - .../cpp/include/IAgoraMediaRelayService.h | 87 - .../cpp/include/IAgoraMediaStreamingSource.h | 332 - .../src/main/cpp/include/IAgoraParameter.h | 308 - .../src/main/cpp/include/IAgoraRhythmPlayer.h | 92 - .../src/main/cpp/include/IAgoraRtcEngine.h | 8558 ----------------- .../src/main/cpp/include/IAgoraRtcEngineEx.h | 1992 ---- .../src/main/cpp/include/IAgoraRtmService.h | 716 -- .../cpp/include/IAgoraRtmpStreamingService.h | 193 - .../src/main/cpp/include/IAgoraService.h | 1024 -- .../main/cpp/include/IAudioDeviceManager.h | 532 - .../cpp/include/NGIAgoraAudioDeviceManager.h | 570 -- .../cpp/include/NGIAgoraAudioMixerSource.h | 46 - .../src/main/cpp/include/NGIAgoraAudioTrack.h | 830 -- .../main/cpp/include/NGIAgoraCameraCapturer.h | 569 -- .../main/cpp/include/NGIAgoraConfigCenter.h | 32 - .../main/cpp/include/NGIAgoraDataChannel.h | 166 - .../NGIAgoraExtensionAINoiseSuppressor.h | 24 - .../main/cpp/include/NGIAgoraExtensionAiAec.h | 27 - .../cpp/include/NGIAgoraExtensionControl.h | 99 - .../cpp/include/NGIAgoraExtensionProvider.h | 122 - .../include/NGIAgoraExtensionScreenSource.h | 186 - .../main/cpp/include/NGIAgoraExtensionVQA.h | 41 - .../src/main/cpp/include/NGIAgoraLocalUser.h | 1601 --- .../src/main/cpp/include/NGIAgoraMediaNode.h | 944 -- .../cpp/include/NGIAgoraMediaNodeFactory.h | 248 - .../include/NGIAgoraRemoteAudioMixerSource.h | 45 - .../main/cpp/include/NGIAgoraRtcConnection.h | 858 -- .../main/cpp/include/NGIAgoraRtmpConnection.h | 392 - .../main/cpp/include/NGIAgoraRtmpLocalUser.h | 299 - .../main/cpp/include/NGIAgoraScreenCapturer.h | 203 - .../src/main/cpp/include/NGIAgoraSyncClient.h | 139 - .../src/main/cpp/include/NGIAgoraVideoFrame.h | 192 - .../cpp/include/NGIAgoraVideoMixerSource.h | 159 - .../src/main/cpp/include/NGIAgoraVideoTrack.h | 620 -- .../entry/src/main/cpp/include/api/Makefile | 48 - .../src/main/cpp/include/api/aosl_alloca.h | 22 - .../src/main/cpp/include/api/aosl_angel.h | 54 - .../src/main/cpp/include/api/aosl_ares.h | 77 - .../src/main/cpp/include/api/aosl_async.h | 86 - .../src/main/cpp/include/api/aosl_atomic.h | 70 - .../src/main/cpp/include/api/aosl_audio.h | 182 - .../src/main/cpp/include/api/aosl_byteswap.h | 38 - .../src/main/cpp/include/api/aosl_data.h | 155 - .../src/main/cpp/include/api/aosl_defs.h | 171 - .../src/main/cpp/include/api/aosl_display.h | 54 - .../entry/src/main/cpp/include/api/aosl_dq.h | 77 - .../src/main/cpp/include/api/aosl_errno.h | 91 - .../src/main/cpp/include/api/aosl_fcntl.h | 87 - .../src/main/cpp/include/api/aosl_file.h | 289 - .../src/main/cpp/include/api/aosl_http.h | 289 - .../src/main/cpp/include/api/aosl_input.h | 115 - .../cpp/include/api/aosl_integer_wrappings.h | 163 - .../entry/src/main/cpp/include/api/aosl_jni.h | 56 - .../src/main/cpp/include/api/aosl_kobj.h | 494 - .../src/main/cpp/include/api/aosl_list.h | 912 -- .../entry/src/main/cpp/include/api/aosl_log.h | 135 - .../main/cpp/include/api/aosl_marshalling.h | 170 - .../entry/src/main/cpp/include/api/aosl_mm.h | 295 - .../src/main/cpp/include/api/aosl_module.h | 81 - .../entry/src/main/cpp/include/api/aosl_mpq.h | 549 -- .../src/main/cpp/include/api/aosl_mpq_fd.h | 220 - .../src/main/cpp/include/api/aosl_mpq_net.h | 408 - .../src/main/cpp/include/api/aosl_mpq_timer.h | 230 - .../src/main/cpp/include/api/aosl_mpqp.h | 303 - .../entry/src/main/cpp/include/api/aosl_os.h | 42 - .../src/main/cpp/include/api/aosl_pmdf.h | 122 - .../src/main/cpp/include/api/aosl_poll.h | 51 - .../src/main/cpp/include/api/aosl_profile.h | 71 - .../entry/src/main/cpp/include/api/aosl_psb.h | 67 - .../src/main/cpp/include/api/aosl_rbtree.h | 73 - .../entry/src/main/cpp/include/api/aosl_ref.h | 260 - .../src/main/cpp/include/api/aosl_route.h | 123 - .../src/main/cpp/include/api/aosl_sbus.h | 160 - .../entry/src/main/cpp/include/api/aosl_so.h | 60 - .../src/main/cpp/include/api/aosl_socket.h | 172 - .../src/main/cpp/include/api/aosl_task.h | 168 - .../src/main/cpp/include/api/aosl_thread.h | 144 - .../src/main/cpp/include/api/aosl_time.h | 79 - .../src/main/cpp/include/api/aosl_types.h | 96 - .../src/main/cpp/include/api/aosl_utils.h | 45 - .../src/main/cpp/include/api/aosl_value.h | 518 - .../src/main/cpp/include/api/aosl_vcodec.h | 144 - .../src/main/cpp/include/api/aosl_version.h | 34 - .../src/main/cpp/include/api/aosl_video.h | 245 - .../src/main/cpp/include/api/aosl_xdump.h | 44 - .../src/main/cpp/include/api/cpp/Makefile | 14 - .../cpp/include/api/cpp/aosl_ares_class.h | 91 - .../cpp/include/api/cpp/aosl_async_class.h | 129 - .../cpp/include/api/cpp/aosl_data_class.h | 486 - .../cpp/include/api/cpp/aosl_file_class.h | 284 - .../cpp/include/api/cpp/aosl_input_class.h | 193 - .../cpp/include/api/cpp/aosl_kobj_class.h | 101 - .../main/cpp/include/api/cpp/aosl_mm_class.h | 45 - .../cpp/include/api/cpp/aosl_mpq_fd_class.h | 117 - .../cpp/include/api/cpp/aosl_mpq_sk_lambda.h | 393 - .../include/api/cpp/aosl_mpq_timer_lambda.h | 143 - .../cpp/include/api/cpp/aosl_poll_class.h | 135 - .../main/cpp/include/api/cpp/aosl_ref_class.h | 1956 ---- .../cpp/include/api/cpp/aosl_sbus_class.h | 180 - .../cpp/include/api/cpp/aosl_task_class.h | 454 - .../cpp/include/api/cpp/aosl_thread_class.h | 279 - .../cpp/include/api/cpp/aosl_value_class.h | 471 - .../src/main/cpp/include/api/objc/Makefile | 1 - .../src/main/cpp/include/api/objc/aosl_log.h | 28 - .../src/main/cpp/include/api/objc/aosl_objc.h | 32 - .../entry/src/main/cpp/include/time_utils.h | 85 - 125 files changed, 7 insertions(+), 48886 deletions(-) delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraAtomicOps.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraBase.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraExtensionProviderEntry.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraExtensionVersion.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraMediaBase.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraMediaPlayerTypes.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraOptional.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraRefCountedObject.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraRefPtr.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraFileUploader.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraH265Transcoder.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraLog.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaComponentFactory.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaEngine.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaPlayer.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaPlayerSource.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaRecorder.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaRelayService.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaStreamingSource.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraParameter.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRhythmPlayer.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtcEngine.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtcEngineEx.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtmService.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtmpStreamingService.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraService.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAudioDeviceManager.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioDeviceManager.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioMixerSource.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioTrack.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraCameraCapturer.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraConfigCenter.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraDataChannel.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionAINoiseSuppressor.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionAiAec.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionControl.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionProvider.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionScreenSource.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionVQA.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraLocalUser.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraMediaNode.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraMediaNodeFactory.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRemoteAudioMixerSource.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRtcConnection.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRtmpConnection.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRtmpLocalUser.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraScreenCapturer.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraSyncClient.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoFrame.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoMixerSource.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoTrack.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/Makefile delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_alloca.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_angel.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_ares.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_async.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_atomic.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_audio.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_byteswap.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_data.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_defs.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_display.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_dq.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_errno.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_fcntl.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_file.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_http.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_input.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_integer_wrappings.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_jni.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_kobj.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_list.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_log.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_marshalling.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mm.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_module.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_fd.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_net.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_timer.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpqp.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_os.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_pmdf.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_poll.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_profile.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_psb.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_rbtree.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_ref.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_route.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_sbus.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_so.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_socket.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_task.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_thread.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_time.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_types.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_utils.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_value.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_vcodec.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_version.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_video.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_xdump.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/Makefile delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_ares_class.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_async_class.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_data_class.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_file_class.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_input_class.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_kobj_class.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mm_class.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_fd_class.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_sk_lambda.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_timer_lambda.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_poll_class.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_ref_class.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_sbus_class.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_task_class.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_thread_class.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_value_class.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/objc/Makefile delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/objc/aosl_log.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/objc/aosl_objc.h delete mode 100644 HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/time_utils.h diff --git a/HarmonyOS_NEXT/APIExample/build-profile.json5 b/HarmonyOS_NEXT/APIExample/build-profile.json5 index a26322be0..1cc7a6cdc 100644 --- a/HarmonyOS_NEXT/APIExample/build-profile.json5 +++ b/HarmonyOS_NEXT/APIExample/build-profile.json5 @@ -7,7 +7,12 @@ "name": "default", "signingConfig": "default", "compatibleSdkVersion": "5.0.0(12)", - "runtimeOS": "HarmonyOS" + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "useNormalizedOHMUrl": true + }, + } } ], "buildModeSet": [ diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/CMakeLists.txt b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/CMakeLists.txt index 7ae131518..a7743a629 100644 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/CMakeLists.txt +++ b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/CMakeLists.txt @@ -9,7 +9,7 @@ if(DEFINED PACKAGE_FIND_FILE) endif() include_directories(${ROOT_PATH} - ${ROOT_PATH}/include) + ${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules/@shengwang/rtc-full/include) set(AGORA_LIB_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules/@shengwang/rtc-full/libs) diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraAtomicOps.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraAtomicOps.h deleted file mode 100644 index f0c46109b..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraAtomicOps.h +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) 2020 Agora.io. All rights reserved - -// This program is confidential and proprietary to Agora.io. -// And may not be copied, reproduced, modified, disclosed to others, published -// or used, in whole or in part, without the express prior written permission -// of Agora.io. -#pragma once - -#if defined(_WIN32) -// clang-format off -// clang formating would change include order. - -// Include WinSock2.h before including to maintain consistency with -// win32.h. To include win32.h directly, it must be broken out into its own -// build target. -#include -#include -// clang-format on -#endif // _WIN32 - -namespace agora { - -class AtomicOps { - public: -#if defined(_WIN32) - // Assumes sizeof(int) == sizeof(LONG), which it is on Win32 and Win64. - static int Increment(volatile int* i) { - return ::InterlockedIncrement(reinterpret_cast(i)); - } - static int Decrement(volatile int* i) { - return ::InterlockedDecrement(reinterpret_cast(i)); - } - static int AcquireLoad(volatile const int* i) { return *i; } - static void ReleaseStore(volatile int* i, int value) { *i = value; } - static int CompareAndSwap(volatile int* i, int old_value, int new_value) { - return ::InterlockedCompareExchange(reinterpret_cast(i), - new_value, old_value); - } - // Pointer variants. - template - static T* AcquireLoadPtr(T* volatile* ptr) { - return *ptr; - } - template - static T* CompareAndSwapPtr(T* volatile* ptr, T* old_value, T* new_value) { - return static_cast(::InterlockedCompareExchangePointer( - reinterpret_cast(ptr), new_value, old_value)); - } -#else - static int Increment(volatile int* i) { return __sync_add_and_fetch(i, 1); } - static int Decrement(volatile int* i) { return __sync_sub_and_fetch(i, 1); } - static int AcquireLoad(volatile const int* i) { - return __atomic_load_n(i, __ATOMIC_ACQUIRE); - } - static void ReleaseStore(volatile int* i, int value) { - __atomic_store_n(i, value, __ATOMIC_RELEASE); - } - static int CompareAndSwap(volatile int* i, int old_value, int new_value) { - return __sync_val_compare_and_swap(i, old_value, new_value); - } - // Pointer variants. - template - static T* AcquireLoadPtr(T* volatile* ptr) { - return __atomic_load_n(ptr, __ATOMIC_ACQUIRE); - } - template - static T* CompareAndSwapPtr(T* volatile* ptr, T* old_value, T* new_value) { - return __sync_val_compare_and_swap(ptr, old_value, new_value); - } -#endif // _WIN32 -}; - -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraBase.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraBase.h deleted file mode 100644 index 96ae67d96..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraBase.h +++ /dev/null @@ -1,6576 +0,0 @@ -// -// Agora Engine SDK -// -// Created by Sting Feng in 2017-11. -// Copyright (c) 2017 Agora.io. All rights reserved. -// - -// This header file is included by both high level and low level APIs, -#pragma once // NOLINT(build/header_guard) - -#include -#include -#include -#include -#include - -#include "IAgoraParameter.h" -#include "AgoraMediaBase.h" -#include "AgoraRefPtr.h" -#include "AgoraOptional.h" - -#define MAX_PATH_260 (260) - -#if defined(_WIN32) - -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif // !WIN32_LEAN_AND_MEAN -#if defined(__aarch64__) -#include -#endif -#include - -#if defined(AGORARTC_EXPORT) -#define AGORA_API extern "C" __declspec(dllexport) -#define AGORA_CPP_API __declspec(dllexport) -#else -#define AGORA_API extern "C" __declspec(dllimport) -#define AGORA_CPP_API __declspec(dllimport) -#endif // AGORARTC_EXPORT - -#define AGORA_CALL __cdecl - -#define __deprecated - -#define AGORA_CPP_INTERNAL_API extern - -#elif defined(__APPLE__) - -#include - -#define AGORA_API extern "C" __attribute__((visibility("default"))) -#define AGORA_CPP_API __attribute__((visibility("default"))) -#define AGORA_CALL - -#define AGORA_CPP_INTERNAL_API __attribute__((visibility("hidden"))) - -#elif defined(__ANDROID__) || defined(__linux__) - -#define AGORA_API extern "C" __attribute__((visibility("default"))) -#define AGORA_CPP_API __attribute__((visibility("default"))) -#define AGORA_CALL - -#define __deprecated - -#define AGORA_CPP_INTERNAL_API __attribute__((visibility("hidden"))) - -#else // !_WIN32 && !__APPLE__ && !(__ANDROID__ || __linux__) - -#define AGORA_API extern "C" -#define AGORA_CPP_API -#define AGORA_CALL - -#define __deprecated - -#endif // _WIN32 - -#ifndef OPTIONAL_ENUM_SIZE_T -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) -#define OPTIONAL_ENUM_SIZE_T enum : size_t -#else -#define OPTIONAL_ENUM_SIZE_T enum -#endif -#endif - -#ifndef OPTIONAL_NULLPTR -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) -#define OPTIONAL_NULLPTR nullptr -#else -#define OPTIONAL_NULLPTR NULL -#endif -#endif - -#define INVALID_DISPLAY_ID (-2) - -namespace agora { -namespace util { - -template -class AutoPtr { - protected: - typedef T value_type; - typedef T* pointer_type; - - public: - explicit AutoPtr(pointer_type p = OPTIONAL_NULLPTR) : ptr_(p) {} - - ~AutoPtr() { - if (ptr_) { - ptr_->release(); - ptr_ = OPTIONAL_NULLPTR; - } - } - - operator bool() const { return (ptr_ != OPTIONAL_NULLPTR); } - - value_type& operator*() const { return *get(); } - - pointer_type operator->() const { return get(); } - - pointer_type get() const { return ptr_; } - - pointer_type release() { - pointer_type ret = ptr_; - ptr_ = 0; - return ret; - } - - void reset(pointer_type ptr = OPTIONAL_NULLPTR) { - if (ptr != ptr_ && ptr_) { - ptr_->release(); - } - - ptr_ = ptr; - } - - template - bool queryInterface(C1* c, C2 iid) { - pointer_type p = OPTIONAL_NULLPTR; - if (c && !c->queryInterface(iid, reinterpret_cast(&p))) { - reset(p); - } - - return (p != OPTIONAL_NULLPTR); - } - - private: - AutoPtr(const AutoPtr&); - AutoPtr& operator=(const AutoPtr&); - - private: - pointer_type ptr_; -}; - -template -class CopyableAutoPtr : public AutoPtr { - typedef typename AutoPtr::pointer_type pointer_type; - - public: - explicit CopyableAutoPtr(pointer_type p = 0) : AutoPtr(p) {} - CopyableAutoPtr(const CopyableAutoPtr& rhs) { this->reset(rhs.clone()); } - CopyableAutoPtr& operator=(const CopyableAutoPtr& rhs) { - if (this != &rhs) this->reset(rhs.clone()); - return *this; - } - pointer_type clone() const { - if (!this->get()) return OPTIONAL_NULLPTR; - return this->get()->clone(); - } -}; - -class IString { - public: - virtual bool empty() const = 0; - virtual const char* c_str() = 0; - virtual const char* data() = 0; - virtual size_t length() = 0; - virtual IString* clone() = 0; - virtual void release() = 0; - virtual ~IString() {} -}; -typedef CopyableAutoPtr AString; - -class IIterator { - public: - virtual void* current() = 0; - virtual const void* const_current() const = 0; - virtual bool next() = 0; - virtual void release() = 0; - virtual ~IIterator() {} -}; - -class IContainer { - public: - virtual IIterator* begin() = 0; - virtual size_t size() const = 0; - virtual void release() = 0; - virtual ~IContainer() {} -}; - -template -class AOutputIterator { - IIterator* p; - - public: - typedef T value_type; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef value_type* pointer; - typedef const value_type* const_pointer; - explicit AOutputIterator(IIterator* it = OPTIONAL_NULLPTR) : p(it) {} - ~AOutputIterator() { - if (p) p->release(); - } - AOutputIterator(const AOutputIterator& rhs) : p(rhs.p) {} - AOutputIterator& operator++() { - p->next(); - return *this; - } - bool operator==(const AOutputIterator& rhs) const { - if (p && rhs.p) - return p->current() == rhs.p->current(); - else - return valid() == rhs.valid(); - } - bool operator!=(const AOutputIterator& rhs) const { return !this->operator==(rhs); } - reference operator*() { return *reinterpret_cast(p->current()); } - const_reference operator*() const { return *reinterpret_cast(p->const_current()); } - bool valid() const { return p && p->current() != OPTIONAL_NULLPTR; } -}; - -template -class AList { - IContainer* container; - bool owner; - - public: - typedef T value_type; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef size_t size_type; - typedef AOutputIterator iterator; - typedef const AOutputIterator const_iterator; - - public: - AList() : container(OPTIONAL_NULLPTR), owner(false) {} - AList(IContainer* c, bool take_ownership) : container(c), owner(take_ownership) {} - ~AList() { reset(); } - void reset(IContainer* c = OPTIONAL_NULLPTR, bool take_ownership = false) { - if (owner && container) container->release(); - container = c; - owner = take_ownership; - } - iterator begin() { return container ? iterator(container->begin()) : iterator(OPTIONAL_NULLPTR); } - iterator end() { return iterator(OPTIONAL_NULLPTR); } - size_type size() const { return container ? container->size() : 0; } - bool empty() const { return size() == 0; } -}; - -} // namespace util - -/** - * The channel profile. - */ -enum CHANNEL_PROFILE_TYPE { - /** - * 0: Communication. - * - * This profile prioritizes smoothness and applies to the one-to-one scenario. - */ - CHANNEL_PROFILE_COMMUNICATION = 0, - /** - * 1: (Default) Live Broadcast. - * - * This profile prioritizes supporting a large audience in a live broadcast channel. - */ - CHANNEL_PROFILE_LIVE_BROADCASTING = 1, - /** - * 2: Gaming. - * @deprecated This profile is deprecated. - */ - CHANNEL_PROFILE_GAME __deprecated = 2, - /** - * 3: Cloud Gaming. - * - * @deprecated This profile is deprecated. - */ - CHANNEL_PROFILE_CLOUD_GAMING __deprecated = 3, - - /** - * 4: Communication 1v1. - * @deprecated This profile is deprecated. - */ - CHANNEL_PROFILE_COMMUNICATION_1v1 __deprecated = 4, -}; - -/** - * The warning codes. - */ -enum WARN_CODE_TYPE { - /** - * 8: The specified view is invalid. To use the video function, you need to specify - * a valid view. - */ - WARN_INVALID_VIEW = 8, - /** - * 16: Fails to initialize the video function, probably due to a lack of - * resources. Users fail to see each other, but can still communicate with voice. - */ - WARN_INIT_VIDEO = 16, - /** - * 20: The request is pending, usually because some module is not ready, - * and the SDK postpones processing the request. - */ - WARN_PENDING = 20, - /** - * 103: No channel resources are available, probably because the server cannot - * allocate any channel resource. - */ - WARN_NO_AVAILABLE_CHANNEL = 103, - /** - * 104: A timeout occurs when looking for the channel. When joining a channel, - * the SDK looks up the specified channel. This warning usually occurs when the - * network condition is too poor to connect to the server. - */ - WARN_LOOKUP_CHANNEL_TIMEOUT = 104, - /** - * 105: The server rejects the request to look for the channel. The server - * cannot process this request or the request is illegal. - */ - WARN_LOOKUP_CHANNEL_REJECTED = 105, - /** - * 106: A timeout occurs when opening the channel. Once the specific channel - * is found, the SDK opens the channel. This warning usually occurs when the - * network condition is too poor to connect to the server. - */ - WARN_OPEN_CHANNEL_TIMEOUT = 106, - /** - * 107: The server rejects the request to open the channel. The server - * cannot process this request or the request is illegal. - */ - WARN_OPEN_CHANNEL_REJECTED = 107, - - // sdk: 100~1000 - /** - * 111: A timeout occurs when switching the live video. - */ - WARN_SWITCH_LIVE_VIDEO_TIMEOUT = 111, - /** - * 118: A timeout occurs when setting the user role. - */ - WARN_SET_CLIENT_ROLE_TIMEOUT = 118, - /** - * 121: The ticket to open the channel is invalid. - */ - WARN_OPEN_CHANNEL_INVALID_TICKET = 121, - /** - * 122: The SDK is trying connecting to another server. - */ - WARN_OPEN_CHANNEL_TRY_NEXT_VOS = 122, - /** - * 131: The channel connection cannot be recovered. - */ - WARN_CHANNEL_CONNECTION_UNRECOVERABLE = 131, - /** - * 132: The SDK connection IP has changed. - */ - WARN_CHANNEL_CONNECTION_IP_CHANGED = 132, - /** - * 133: The SDK connection port has changed. - */ - WARN_CHANNEL_CONNECTION_PORT_CHANGED = 133, - /** 134: The socket error occurs, try to rejoin channel. - */ - WARN_CHANNEL_SOCKET_ERROR = 134, - /** - * 701: An error occurs when opening the file for audio mixing. - */ - WARN_AUDIO_MIXING_OPEN_ERROR = 701, - /** - * 1014: Audio Device Module: An exception occurs in the playback device. - */ - WARN_ADM_RUNTIME_PLAYOUT_WARNING = 1014, - /** - * 1016: Audio Device Module: A warning occurs in the recording device. - */ - WARN_ADM_RUNTIME_RECORDING_WARNING = 1016, - /** - * 1019: Audio Device Module: No valid audio data is collected. - */ - WARN_ADM_RECORD_AUDIO_SILENCE = 1019, - /** - * 1020: Audio Device Module: The playback device fails to start. - */ - WARN_ADM_PLAYOUT_MALFUNCTION = 1020, - /** - * 1021: Audio Device Module: The recording device fails to start. - */ - WARN_ADM_RECORD_MALFUNCTION = 1021, - /** - * 1031: Audio Device Module: The recorded audio volume is too low. - */ - WARN_ADM_RECORD_AUDIO_LOWLEVEL = 1031, - /** - * 1032: Audio Device Module: The playback audio volume is too low. - */ - WARN_ADM_PLAYOUT_AUDIO_LOWLEVEL = 1032, - /** - * 1040: Audio device module: An exception occurs with the audio drive. - * Choose one of the following solutions: - * - Disable or re-enable the audio device. - * - Re-enable your device. - * - Update the sound card drive. - */ - WARN_ADM_WINDOWS_NO_DATA_READY_EVENT = 1040, - /** - * 1051: Audio Device Module: The SDK detects howling. - */ - WARN_APM_HOWLING = 1051, - /** - * 1052: Audio Device Module: The audio device is in a glitching state. - */ - WARN_ADM_GLITCH_STATE = 1052, - /** - * 1053: Audio Device Module: The settings are improper. - */ - WARN_ADM_IMPROPER_SETTINGS = 1053, - /** - * 1322: No recording device. - */ - WARN_ADM_WIN_CORE_NO_RECORDING_DEVICE = 1322, - /** - * 1323: Audio device module: No available playback device. - * You can try plugging in the audio device. - */ - WARN_ADM_WIN_CORE_NO_PLAYOUT_DEVICE = 1323, - /** - * 1324: Audio device module: The capture device is released improperly. - * Choose one of the following solutions: - * - Disable or re-enable the audio device. - * - Re-enable your audio device. - * - Update the sound card drive. - */ - WARN_ADM_WIN_CORE_IMPROPER_CAPTURE_RELEASE = 1324, -}; - -/** - * The error codes. - */ -enum ERROR_CODE_TYPE { - /** - * 0: No error occurs. - */ - ERR_OK = 0, - // 1~1000 - /** - * 1: A general error occurs (no specified reason). - */ - ERR_FAILED = 1, - /** - * 2: The argument is invalid. For example, the specific channel name - * includes illegal characters. - */ - ERR_INVALID_ARGUMENT = 2, - /** - * 3: The SDK module is not ready. Choose one of the following solutions: - * - Check the audio device. - * - Check the completeness of the app. - * - Reinitialize the RTC engine. - */ - ERR_NOT_READY = 3, - /** - * 4: The SDK does not support this function. - */ - ERR_NOT_SUPPORTED = 4, - /** - * 5: The request is rejected. - */ - ERR_REFUSED = 5, - /** - * 6: The buffer size is not big enough to store the returned data. - */ - ERR_BUFFER_TOO_SMALL = 6, - /** - * 7: The SDK is not initialized before calling this method. - */ - ERR_NOT_INITIALIZED = 7, - /** - * 8: The state is invalid. - */ - ERR_INVALID_STATE = 8, - /** - * 9: No permission. This is for internal use only, and does - * not return to the app through any method or callback. - */ - ERR_NO_PERMISSION = 9, - /** - * 10: An API timeout occurs. Some API methods require the SDK to return the - * execution result, and this error occurs if the request takes too long - * (more than 10 seconds) for the SDK to process. - */ - ERR_TIMEDOUT = 10, - /** - * 11: The request is cancelled. This is for internal use only, - * and does not return to the app through any method or callback. - */ - ERR_CANCELED = 11, - /** - * 12: The method is called too often. This is for internal use - * only, and does not return to the app through any method or - * callback. - */ - ERR_TOO_OFTEN = 12, - /** - * 13: The SDK fails to bind to the network socket. This is for internal - * use only, and does not return to the app through any method or - * callback. - */ - ERR_BIND_SOCKET = 13, - /** - * 14: The network is unavailable. This is for internal use only, and - * does not return to the app through any method or callback. - */ - ERR_NET_DOWN = 14, - /** - * 17: The request to join the channel is rejected. This error usually occurs - * when the user is already in the channel, and still calls the method to join - * the channel, for example, \ref agora::rtc::IRtcEngine::joinChannel "joinChannel()". - */ - ERR_JOIN_CHANNEL_REJECTED = 17, - /** - * 18: The request to leave the channel is rejected. This error usually - * occurs when the user has already left the channel, and still calls the - * method to leave the channel, for example, \ref agora::rtc::IRtcEngine::leaveChannel - * "leaveChannel". - */ - ERR_LEAVE_CHANNEL_REJECTED = 18, - /** - * 19: The resources have been occupied and cannot be reused. - */ - ERR_ALREADY_IN_USE = 19, - /** - * 20: The SDK gives up the request due to too many requests. This is for - * internal use only, and does not return to the app through any method or callback. - */ - ERR_ABORTED = 20, - /** - * 21: On Windows, specific firewall settings can cause the SDK to fail to - * initialize and crash. - */ - ERR_INIT_NET_ENGINE = 21, - /** - * 22: The app uses too much of the system resource and the SDK - * fails to allocate any resource. - */ - ERR_RESOURCE_LIMITED = 22, - /** - * 101: The App ID is invalid, usually because the data format of the App ID is incorrect. - * - * Solution: Check the data format of your App ID. Ensure that you use the correct App ID to initialize the Agora service. - */ - ERR_INVALID_APP_ID = 101, - /** - * 102: The specified channel name is invalid. Please try to rejoin the - * channel with a valid channel name. - */ - ERR_INVALID_CHANNEL_NAME = 102, - /** - * 103: Fails to get server resources in the specified region. Please try to - * specify another region when calling \ref agora::rtc::IRtcEngine::initialize - * "initialize". - */ - ERR_NO_SERVER_RESOURCES = 103, - /** - * 109: The token has expired, usually for the following reasons: - * - Timeout for token authorization: Once a token is generated, you must use it to access the - * Agora service within 24 hours. Otherwise, the token times out and you can no longer use it. - * - The token privilege expires: To generate a token, you need to set a timestamp for the token - * privilege to expire. For example, If you set it as seven days, the token expires seven days after - * its usage. In that case, you can no longer access the Agora service. The users cannot make calls, - * or are kicked out of the channel. - * - * Solution: Regardless of whether token authorization times out or the token privilege expires, - * you need to generate a new token on your server, and try to join the channel. - */ - ERR_TOKEN_EXPIRED = 109, - /** - * 110: The token is invalid, usually for one of the following reasons: - * - Did not provide a token when joining a channel in a situation where the project has enabled the - * App Certificate. - * - Tried to join a channel with a token in a situation where the project has not enabled the App - * Certificate. - * - The App ID, user ID and channel name that you use to generate the token on the server do not match - * those that you use when joining a channel. - * - * Solution: - * - Before joining a channel, check whether your project has enabled the App certificate. If yes, you - * must provide a token when joining a channel; if no, join a channel without a token. - * - When using a token to join a channel, ensure that the App ID, user ID, and channel name that you - * use to generate the token is the same as the App ID that you use to initialize the Agora service, and - * the user ID and channel name that you use to join the channel. - */ - ERR_INVALID_TOKEN = 110, - /** - * 111: The internet connection is interrupted. This applies to the Agora Web - * SDK only. - */ - ERR_CONNECTION_INTERRUPTED = 111, // only used in web sdk - /** - * 112: The internet connection is lost. This applies to the Agora Web SDK - * only. - */ - ERR_CONNECTION_LOST = 112, // only used in web sdk - /** - * 113: The user is not in the channel when calling the - * \ref agora::rtc::IRtcEngine::sendStreamMessage "sendStreamMessage()" method. - */ - ERR_NOT_IN_CHANNEL = 113, - /** - * 114: The data size is over 1024 bytes when the user calls the - * \ref agora::rtc::IRtcEngine::sendStreamMessage "sendStreamMessage()" method. - */ - ERR_SIZE_TOO_LARGE = 114, - /** - * 115: The bitrate of the sent data exceeds the limit of 6 Kbps when the - * user calls the \ref agora::rtc::IRtcEngine::sendStreamMessage "sendStreamMessage()". - */ - ERR_BITRATE_LIMIT = 115, - /** - * 116: Too many data streams (over 5) are created when the user - * calls the \ref agora::rtc::IRtcEngine::createDataStream "createDataStream()" method. - */ - ERR_TOO_MANY_DATA_STREAMS = 116, - /** - * 117: A timeout occurs for the data stream transmission. - */ - ERR_STREAM_MESSAGE_TIMEOUT = 117, - /** - * 119: Switching the user role fails. Please try to rejoin the channel. - */ - ERR_SET_CLIENT_ROLE_NOT_AUTHORIZED = 119, - /** - * 120: MediaStream decryption fails. The user may have tried to join the channel with a wrong - * password. Check your settings or try rejoining the channel. - */ - ERR_DECRYPTION_FAILED = 120, - /** - * 121: The user ID is invalid. - */ - ERR_INVALID_USER_ID = 121, - /** - * 122: DataStream decryption fails. The peer may have tried to join the channel with a wrong - * password, or did't enable datastream encryption - */ - ERR_DATASTREAM_DECRYPTION_FAILED = 122, - /** - * 123: The app is banned by the server. - */ - ERR_CLIENT_IS_BANNED_BY_SERVER = 123, - /** - * 130: Encryption is enabled when the user calls the - * \ref agora::rtc::IRtcEngine::addPublishStreamUrl "addPublishStreamUrl()" method - * (CDN live streaming does not support encrypted streams). - */ - ERR_ENCRYPTED_STREAM_NOT_ALLOWED_PUBLISH = 130, - - /** - * 131: License credential is invalid - */ - ERR_LICENSE_CREDENTIAL_INVALID = 131, - - /** - * 134: The user account is invalid, usually because the data format of the user account is incorrect. - */ - ERR_INVALID_USER_ACCOUNT = 134, - - /** 157: The necessary dynamical library is not integrated. For example, if you call - * the \ref agora::rtc::IRtcEngine::enableDeepLearningDenoise "enableDeepLearningDenoise" but do not integrate the dynamical - * library for the deep-learning noise reduction into your project, the SDK reports this error code. - * - */ - ERR_MODULE_NOT_FOUND = 157, - - // Licensing, keep the license error code same as the main version - ERR_CERT_RAW = 157, - ERR_CERT_JSON_PART = 158, - ERR_CERT_JSON_INVAL = 159, - ERR_CERT_JSON_NOMEM = 160, - ERR_CERT_CUSTOM = 161, - ERR_CERT_CREDENTIAL = 162, - ERR_CERT_SIGN = 163, - ERR_CERT_FAIL = 164, - ERR_CERT_BUF = 165, - ERR_CERT_NULL = 166, - ERR_CERT_DUEDATE = 167, - ERR_CERT_REQUEST = 168, - - // PcmSend Error num - ERR_PCMSEND_FORMAT = 200, // unsupport pcm format - ERR_PCMSEND_BUFFEROVERFLOW = 201, // buffer overflow, the pcm send rate too quickly - - /// @cond - // signaling: 400~600 - ERR_LOGIN_ALREADY_LOGIN = 428, - - /// @endcond - // 1001~2000 - /** - * 1001: Fails to load the media engine. - */ - ERR_LOAD_MEDIA_ENGINE = 1001, - /** - * 1005: Audio device module: A general error occurs in the Audio Device Module (no specified - * reason). Check if the audio device is used by another app, or try - * rejoining the channel. - */ - ERR_ADM_GENERAL_ERROR = 1005, - /** - * 1008: Audio Device Module: An error occurs in initializing the playback - * device. - */ - ERR_ADM_INIT_PLAYOUT = 1008, - /** - * 1009: Audio Device Module: An error occurs in starting the playback device. - */ - ERR_ADM_START_PLAYOUT = 1009, - /** - * 1010: Audio Device Module: An error occurs in stopping the playback device. - */ - ERR_ADM_STOP_PLAYOUT = 1010, - /** - * 1011: Audio Device Module: An error occurs in initializing the recording - * device. - */ - ERR_ADM_INIT_RECORDING = 1011, - /** - * 1012: Audio Device Module: An error occurs in starting the recording device. - */ - ERR_ADM_START_RECORDING = 1012, - /** - * 1013: Audio Device Module: An error occurs in stopping the recording device. - */ - ERR_ADM_STOP_RECORDING = 1013, - /** - * 1501: Video Device Module: The camera is not authorized. - */ - ERR_VDM_CAMERA_NOT_AUTHORIZED = 1501, -}; - -enum LICENSE_ERROR_TYPE { - /** - * 1: Invalid license - */ - LICENSE_ERR_INVALID = 1, - /** - * 2: License expired - */ - LICENSE_ERR_EXPIRE = 2, - /** - * 3: Exceed license minutes limit - */ - LICENSE_ERR_MINUTES_EXCEED = 3, - /** - * 4: License use in limited period - */ - LICENSE_ERR_LIMITED_PERIOD = 4, - /** - * 5: Same license used in different devices at the same time - */ - LICENSE_ERR_DIFF_DEVICES = 5, - /** - * 99: SDK internal error - */ - LICENSE_ERR_INTERNAL = 99, -}; - -/** - * The operational permission of the SDK on the audio session. - */ -enum AUDIO_SESSION_OPERATION_RESTRICTION { - /** - * 0: No restriction; the SDK can change the audio session. - */ - AUDIO_SESSION_OPERATION_RESTRICTION_NONE = 0, - /** - * 1: The SDK cannot change the audio session category. - */ - AUDIO_SESSION_OPERATION_RESTRICTION_SET_CATEGORY = 1, - /** - * 2: The SDK cannot change the audio session category, mode, or categoryOptions. - */ - AUDIO_SESSION_OPERATION_RESTRICTION_CONFIGURE_SESSION = 1 << 1, - /** - * 4: The SDK keeps the audio session active when the user leaves the - * channel, for example, to play an audio file in the background. - */ - AUDIO_SESSION_OPERATION_RESTRICTION_DEACTIVATE_SESSION = 1 << 2, - /** - * 128: Completely restricts the operational permission of the SDK on the - * audio session; the SDK cannot change the audio session. - */ - AUDIO_SESSION_OPERATION_RESTRICTION_ALL = 1 << 7, -}; - -typedef const char* user_id_t; -typedef void* view_t; - -/** - * The definition of the UserInfo struct. - */ -struct UserInfo { - /** - * ID of the user. - */ - util::AString userId; - /** - * Whether the user has enabled audio: - * - true: The user has enabled audio. - * - false: The user has disabled audio. - */ - bool hasAudio; - /** - * Whether the user has enabled video: - * - true: The user has enabled video. - * - false: The user has disabled video. - */ - bool hasVideo; - - UserInfo() : hasAudio(false), hasVideo(false) {} -}; - -typedef util::AList UserList; - -// Shared between Agora Service and Rtc Engine -namespace rtc { - -/** - * Reasons for a user being offline. - */ -enum USER_OFFLINE_REASON_TYPE { - /** - * 0: The user leaves the current channel. - */ - USER_OFFLINE_QUIT = 0, - /** - * 1: The SDK times out and the user drops offline because no data packet was received within a certain - * period of time. If a user quits the call and the message is not passed to the SDK (due to an - * unreliable channel), the SDK assumes that the user drops offline. - */ - USER_OFFLINE_DROPPED = 1, - /** - * 2: The user switches the client role from the host to the audience. - */ - USER_OFFLINE_BECOME_AUDIENCE = 2, -}; - -enum INTERFACE_ID_TYPE { - AGORA_IID_AUDIO_DEVICE_MANAGER = 1, - AGORA_IID_VIDEO_DEVICE_MANAGER = 2, - AGORA_IID_PARAMETER_ENGINE = 3, - AGORA_IID_MEDIA_ENGINE = 4, - AGORA_IID_AUDIO_ENGINE = 5, - AGORA_IID_VIDEO_ENGINE = 6, - AGORA_IID_RTC_CONNECTION = 7, - AGORA_IID_SIGNALING_ENGINE = 8, - AGORA_IID_MEDIA_ENGINE_REGULATOR = 9, - AGORA_IID_LOCAL_SPATIAL_AUDIO = 11, - AGORA_IID_STATE_SYNC = 13, - AGORA_IID_META_SERVICE = 14, - AGORA_IID_MUSIC_CONTENT_CENTER = 15, - AGORA_IID_H265_TRANSCODER = 16, -}; - -/** - * The network quality types. - */ -enum QUALITY_TYPE { - /** - * 0: The network quality is unknown. - * @deprecated This member is deprecated. - */ - QUALITY_UNKNOWN __deprecated = 0, - /** - * 1: The quality is excellent. - */ - QUALITY_EXCELLENT = 1, - /** - * 2: The quality is quite good, but the bitrate may be slightly - * lower than excellent. - */ - QUALITY_GOOD = 2, - /** - * 3: Users can feel the communication slightly impaired. - */ - QUALITY_POOR = 3, - /** - * 4: Users cannot communicate smoothly. - */ - QUALITY_BAD = 4, - /** - * 5: Users can barely communicate. - */ - QUALITY_VBAD = 5, - /** - * 6: Users cannot communicate at all. - */ - QUALITY_DOWN = 6, - /** - * 7: (For future use) The network quality cannot be detected. - */ - QUALITY_UNSUPPORTED = 7, - /** - * 8: Detecting the network quality. - */ - QUALITY_DETECTING = 8, -}; - -/** - * Content fit modes. - */ -enum FIT_MODE_TYPE { - /** - * 1: Uniformly scale the video until it fills the visible boundaries (cropped). - * One dimension of the video may have clipped contents. - */ - MODE_COVER = 1, - - /** - * 2: Uniformly scale the video until one of its dimension fits the boundary - * (zoomed to fit). Areas that are not filled due to disparity in the aspect - * ratio are filled with black. - */ - MODE_CONTAIN = 2, -}; - -/** - * The rotation information. - */ -enum VIDEO_ORIENTATION { - /** - * 0: Rotate the video by 0 degree clockwise. - */ - VIDEO_ORIENTATION_0 = 0, - /** - * 90: Rotate the video by 90 degrees clockwise. - */ - VIDEO_ORIENTATION_90 = 90, - /** - * 180: Rotate the video by 180 degrees clockwise. - */ - VIDEO_ORIENTATION_180 = 180, - /** - * 270: Rotate the video by 270 degrees clockwise. - */ - VIDEO_ORIENTATION_270 = 270 -}; - -/** - * The video frame rate. - */ -enum FRAME_RATE { - /** - * 1: 1 fps. - */ - FRAME_RATE_FPS_1 = 1, - /** - * 7: 7 fps. - */ - FRAME_RATE_FPS_7 = 7, - /** - * 10: 10 fps. - */ - FRAME_RATE_FPS_10 = 10, - /** - * 15: 15 fps. - */ - FRAME_RATE_FPS_15 = 15, - /** - * 24: 24 fps. - */ - FRAME_RATE_FPS_24 = 24, - /** - * 30: 30 fps. - */ - FRAME_RATE_FPS_30 = 30, - /** - * 60: 60 fps. Applies to Windows and macOS only. - */ - FRAME_RATE_FPS_60 = 60, -}; - -enum FRAME_WIDTH { - FRAME_WIDTH_960 = 960, -}; - -enum FRAME_HEIGHT { - FRAME_HEIGHT_540 = 540, -}; - - -/** - * Types of the video frame. - */ -enum VIDEO_FRAME_TYPE { - /** 0: A black frame. */ - VIDEO_FRAME_TYPE_BLANK_FRAME = 0, - /** 3: Key frame. */ - VIDEO_FRAME_TYPE_KEY_FRAME = 3, - /** 4: Delta frame. */ - VIDEO_FRAME_TYPE_DELTA_FRAME = 4, - /** 5: The B frame.*/ - VIDEO_FRAME_TYPE_B_FRAME = 5, - /** 6: A discarded frame. */ - VIDEO_FRAME_TYPE_DROPPABLE_FRAME = 6, - /** Unknown frame. */ - VIDEO_FRAME_TYPE_UNKNOW -}; - -/** - * Video output orientation modes. - */ -enum ORIENTATION_MODE { - /** - * 0: The output video always follows the orientation of the captured video. The receiver takes - * the rotational information passed on from the video encoder. This mode applies to scenarios - * where video orientation can be adjusted on the receiver: - * - If the captured video is in landscape mode, the output video is in landscape mode. - * - If the captured video is in portrait mode, the output video is in portrait mode. - */ - ORIENTATION_MODE_ADAPTIVE = 0, - /** - * 1: Landscape mode. In this mode, the SDK always outputs videos in landscape (horizontal) mode. - * If the captured video is in portrait mode, the video encoder crops it to fit the output. Applies - * to situations where the receiving end cannot process the rotational information. For example, - * CDN live streaming. - */ - ORIENTATION_MODE_FIXED_LANDSCAPE = 1, - /** - * 2: Portrait mode. In this mode, the SDK always outputs video in portrait (portrait) mode. If - * the captured video is in landscape mode, the video encoder crops it to fit the output. Applies - * to situations where the receiving end cannot process the rotational information. For example, - * CDN live streaming. - */ - ORIENTATION_MODE_FIXED_PORTRAIT = 2, -}; - -/** - * (For future use) Video degradation preferences under limited bandwidth. - */ -enum DEGRADATION_PREFERENCE { - /** - * 0: (Default) Prefers to reduce the video frame rate while maintaining video quality during video - * encoding under limited bandwidth. This degradation preference is suitable for scenarios where - * video quality is prioritized. - * @note In the COMMUNICATION channel profile, the resolution of the video sent may change, so - * remote users need to handle this issue. - */ - MAINTAIN_QUALITY = 0, - /** - * 1: Prefers to reduce the video quality while maintaining the video frame rate during video - * encoding under limited bandwidth. This degradation preference is suitable for scenarios where - * smoothness is prioritized and video quality is allowed to be reduced. - */ - MAINTAIN_FRAMERATE = 1, - /** - * 2: Reduces the video frame rate and video quality simultaneously during video encoding under - * limited bandwidth. MAINTAIN_BALANCED has a lower reduction than MAINTAIN_QUALITY and MAINTAIN_FRAMERATE, - * and this preference is suitable for scenarios where both smoothness and video quality are a - * priority. - */ - MAINTAIN_BALANCED = 2, - /** - * 3: Degrade framerate in order to maintain resolution. - */ - MAINTAIN_RESOLUTION = 3, - /** - * 4: Disable VQC adjustion. - */ - DISABLED = 100, -}; - -/** - * The definition of the VideoDimensions struct. - */ -struct VideoDimensions { - /** - * The width of the video, in pixels. - */ - int width; - /** - * The height of the video, in pixels. - */ - int height; - VideoDimensions() : width(640), height(480) {} - VideoDimensions(int w, int h) : width(w), height(h) {} - bool operator==(const VideoDimensions& rhs) const { - return width == rhs.width && height == rhs.height; - } -}; - -/** - * (Recommended) 0: Standard bitrate mode. - * - * In this mode, the video bitrate is twice the base bitrate. - */ -const int STANDARD_BITRATE = 0; - -/** - * -1: Compatible bitrate mode. - * - * In this mode, the video bitrate is the same as the base bitrate.. If you choose - * this mode in the live-broadcast profile, the video frame rate may be lower - * than the set value. - */ -const int COMPATIBLE_BITRATE = -1; - -/** - * -1: (For future use) The default minimum bitrate. - */ -const int DEFAULT_MIN_BITRATE = -1; - -/** - * -2: (For future use) Set minimum bitrate the same as target bitrate. - */ -const int DEFAULT_MIN_BITRATE_EQUAL_TO_TARGET_BITRATE = -2; - -/** - * screen sharing supported capability level. - */ -enum SCREEN_CAPTURE_FRAMERATE_CAPABILITY { - SCREEN_CAPTURE_FRAMERATE_CAPABILITY_15_FPS = 0, - SCREEN_CAPTURE_FRAMERATE_CAPABILITY_30_FPS = 1, - SCREEN_CAPTURE_FRAMERATE_CAPABILITY_60_FPS = 2, -}; - -/** - * Video codec capability levels. - */ -enum VIDEO_CODEC_CAPABILITY_LEVEL { - /** No specified level */ - CODEC_CAPABILITY_LEVEL_UNSPECIFIED = -1, - /** Only provide basic support for the codec type */ - CODEC_CAPABILITY_LEVEL_BASIC_SUPPORT = 5, - /** Can process 1080p video at a rate of approximately 30 fps. */ - CODEC_CAPABILITY_LEVEL_1080P30FPS = 10, - /** Can process 1080p video at a rate of approximately 60 fps. */ - CODEC_CAPABILITY_LEVEL_1080P60FPS = 20, - /** Can process 4k video at a rate of approximately 30 fps. */ - CODEC_CAPABILITY_LEVEL_4K60FPS = 30, -}; - -/** - * The video codec types. - */ -enum VIDEO_CODEC_TYPE { - VIDEO_CODEC_NONE = 0, - /** - * 1: Standard VP8. - */ - VIDEO_CODEC_VP8 = 1, - /** - * 2: Standard H.264. - */ - VIDEO_CODEC_H264 = 2, - /** - * 3: Standard H.265. - */ - VIDEO_CODEC_H265 = 3, - /** - * 6: Generic. This type is used for transmitting raw video data, such as encrypted video frames. - * The SDK returns this type of video frames in callbacks, and you need to decode and render the frames yourself. - */ - VIDEO_CODEC_GENERIC = 6, - /** - * 7: Generic H264. - */ - VIDEO_CODEC_GENERIC_H264 = 7, - /** - * 12: AV1. - * @technical preview - */ - VIDEO_CODEC_AV1 = 12, - /** - * 13: VP9. - */ - VIDEO_CODEC_VP9 = 13, - /** - * 20: Generic JPEG. This type consumes minimum computing resources and applies to IoT devices. - */ - VIDEO_CODEC_GENERIC_JPEG = 20, -}; - -/** - * Camera focal length type. - */ -enum CAMERA_FOCAL_LENGTH_TYPE { - /** - * By default, there are no wide-angle and ultra-wide-angle properties. - */ - CAMERA_FOCAL_LENGTH_DEFAULT = 0, - /** - * Lens with focal length from 24mm to 35mm. - */ - CAMERA_FOCAL_LENGTH_WIDE_ANGLE = 1, - /** - * Lens with focal length of less than 24mm. - */ - CAMERA_FOCAL_LENGTH_ULTRA_WIDE = 2, - /** - * Telephoto lens. - */ - CAMERA_FOCAL_LENGTH_TELEPHOTO = 3, -}; - -/** - * The CC (Congestion Control) mode options. - */ -enum TCcMode { - /** - * Enable CC mode. - */ - CC_ENABLED, - /** - * Disable CC mode. - */ - CC_DISABLED, -}; - -/** - * The configuration for creating a local video track with an encoded image sender. - */ -struct SenderOptions { - /** - * Whether to enable CC mode. See #TCcMode. - */ - TCcMode ccMode; - /** - * The codec type used for the encoded images: \ref agora::rtc::VIDEO_CODEC_TYPE "VIDEO_CODEC_TYPE". - */ - VIDEO_CODEC_TYPE codecType; - - /** - * Target bitrate (Kbps) for video encoding. - * - * Choose one of the following options: - * - * - \ref agora::rtc::STANDARD_BITRATE "STANDARD_BITRATE": (Recommended) Standard bitrate. - * - Communication profile: The encoding bitrate equals the base bitrate. - * - Live-broadcast profile: The encoding bitrate is twice the base bitrate. - * - \ref agora::rtc::COMPATIBLE_BITRATE "COMPATIBLE_BITRATE": Compatible bitrate. The bitrate stays the same - * regardless of the profile. - * - * The Communication profile prioritizes smoothness, while the Live Broadcast - * profile prioritizes video quality (requiring a higher bitrate). Agora - * recommends setting the bitrate mode as \ref agora::rtc::STANDARD_BITRATE "STANDARD_BITRATE" or simply to - * address this difference. - * - * The following table lists the recommended video encoder configurations, - * where the base bitrate applies to the communication profile. Set your - * bitrate based on this table. If the bitrate you set is beyond the proper - * range, the SDK automatically sets it to within the range. - - | Resolution | Frame Rate (fps) | Base Bitrate (Kbps, for Communication) | Live Bitrate (Kbps, for Live Broadcast)| - |------------------------|------------------|----------------------------------------|----------------------------------------| - | 160 × 120 | 15 | 65 | 130 | - | 120 × 120 | 15 | 50 | 100 | - | 320 × 180 | 15 | 140 | 280 | - | 180 × 180 | 15 | 100 | 200 | - | 240 × 180 | 15 | 120 | 240 | - | 320 × 240 | 15 | 200 | 400 | - | 240 × 240 | 15 | 140 | 280 | - | 424 × 240 | 15 | 220 | 440 | - | 640 × 360 | 15 | 400 | 800 | - | 360 × 360 | 15 | 260 | 520 | - | 640 × 360 | 30 | 600 | 1200 | - | 360 × 360 | 30 | 400 | 800 | - | 480 × 360 | 15 | 320 | 640 | - | 480 × 360 | 30 | 490 | 980 | - | 640 × 480 | 15 | 500 | 1000 | - | 480 × 480 | 15 | 400 | 800 | - | 640 × 480 | 30 | 750 | 1500 | - | 480 × 480 | 30 | 600 | 1200 | - | 848 × 480 | 15 | 610 | 1220 | - | 848 × 480 | 30 | 930 | 1860 | - | 640 × 480 | 10 | 400 | 800 | - | 1280 × 720 | 15 | 1130 | 2260 | - | 1280 × 720 | 30 | 1710 | 3420 | - | 960 × 720 | 15 | 910 | 1820 | - | 960 × 720 | 30 | 1380 | 2760 | - | 1920 × 1080 | 15 | 2080 | 4160 | - | 1920 × 1080 | 30 | 3150 | 6300 | - | 1920 × 1080 | 60 | 4780 | 6500 | - | 2560 × 1440 | 30 | 4850 | 6500 | - | 2560 × 1440 | 60 | 6500 | 6500 | - | 3840 × 2160 | 30 | 6500 | 6500 | - | 3840 × 2160 | 60 | 6500 | 6500 | - */ - int targetBitrate; - - SenderOptions() - : ccMode(CC_ENABLED), - codecType(VIDEO_CODEC_H265), - targetBitrate(6500) {} -}; - -/** - * Audio codec types. - */ -enum AUDIO_CODEC_TYPE { - /** - * 1: OPUS. - */ - AUDIO_CODEC_OPUS = 1, - // kIsac = 2, - /** - * 3: PCMA. - */ - AUDIO_CODEC_PCMA = 3, - /** - * 4: PCMU. - */ - AUDIO_CODEC_PCMU = 4, - /** - * 5: G722. - */ - AUDIO_CODEC_G722 = 5, - // kIlbc = 6, - /** 7: AAC. */ - // AUDIO_CODEC_AAC = 7, - /** - * 8: AAC LC. - */ - AUDIO_CODEC_AACLC = 8, - /** - * 9: HE AAC. - */ - AUDIO_CODEC_HEAAC = 9, - /** - * 10: JC1. - */ - AUDIO_CODEC_JC1 = 10, - /** - * 11: HE-AAC v2. - */ - AUDIO_CODEC_HEAAC2 = 11, - /** - * 12: LPCNET. - */ - AUDIO_CODEC_LPCNET = 12, - /** - * 13: Opus codec, supporting 3 to 8 channels audio. - */ - AUDIO_CODEC_OPUSMC = 13, -}; - -/** - * Audio encoding types of the audio encoded frame observer. - */ -enum AUDIO_ENCODING_TYPE { - /** - * AAC encoding format, 16000 Hz sampling rate, bass quality. A file with an audio duration of 10 - * minutes is approximately 1.2 MB after encoding. - */ - AUDIO_ENCODING_TYPE_AAC_16000_LOW = 0x010101, - /** - * AAC encoding format, 16000 Hz sampling rate, medium sound quality. A file with an audio duration - * of 10 minutes is approximately 2 MB after encoding. - */ - AUDIO_ENCODING_TYPE_AAC_16000_MEDIUM = 0x010102, - /** - * AAC encoding format, 32000 Hz sampling rate, bass quality. A file with an audio duration of 10 - * minutes is approximately 1.2 MB after encoding. - */ - AUDIO_ENCODING_TYPE_AAC_32000_LOW = 0x010201, - /** - * AAC encoding format, 32000 Hz sampling rate, medium sound quality. A file with an audio duration - * of 10 minutes is approximately 2 MB after encoding. - */ - AUDIO_ENCODING_TYPE_AAC_32000_MEDIUM = 0x010202, - /** - * AAC encoding format, 32000 Hz sampling rate, high sound quality. A file with an audio duration of - * 10 minutes is approximately 3.5 MB after encoding. - */ - AUDIO_ENCODING_TYPE_AAC_32000_HIGH = 0x010203, - /** - * AAC encoding format, 48000 Hz sampling rate, medium sound quality. A file with an audio duration - * of 10 minutes is approximately 2 MB after encoding. - */ - AUDIO_ENCODING_TYPE_AAC_48000_MEDIUM = 0x010302, - /** - * AAC encoding format, 48000 Hz sampling rate, high sound quality. A file with an audio duration - * of 10 minutes is approximately 3.5 MB after encoding. - */ - AUDIO_ENCODING_TYPE_AAC_48000_HIGH = 0x010303, - /** - * OPUS encoding format, 16000 Hz sampling rate, bass quality. A file with an audio duration of 10 - * minutes is approximately 2 MB after encoding. - */ - AUDIO_ENCODING_TYPE_OPUS_16000_LOW = 0x020101, - /** - * OPUS encoding format, 16000 Hz sampling rate, medium sound quality. A file with an audio duration - * of 10 minutes is approximately 2 MB after encoding. - */ - AUDIO_ENCODING_TYPE_OPUS_16000_MEDIUM = 0x020102, - /** - * OPUS encoding format, 48000 Hz sampling rate, medium sound quality. A file with an audio duration - * of 10 minutes is approximately 2 MB after encoding. - */ - AUDIO_ENCODING_TYPE_OPUS_48000_MEDIUM = 0x020302, - /** - * OPUS encoding format, 48000 Hz sampling rate, high sound quality. A file with an audio duration of - * 10 minutes is approximately 3.5 MB after encoding. - */ - AUDIO_ENCODING_TYPE_OPUS_48000_HIGH = 0x020303, -}; - -/** - * The adaptation mode of the watermark. - */ -enum WATERMARK_FIT_MODE { - /** - * Use the `positionInLandscapeMode` and `positionInPortraitMode` values you set in #WatermarkOptions. - * The settings in `WatermarkRatio` are invalid. - */ - FIT_MODE_COVER_POSITION, - /** - * Use the value you set in `WatermarkRatio`. The settings in `positionInLandscapeMode` and `positionInPortraitMode` - * in `WatermarkOptions` are invalid. - */ - FIT_MODE_USE_IMAGE_RATIO -}; - -/** - * The advanced settings of encoded audio frame. - */ -struct EncodedAudioFrameAdvancedSettings { - EncodedAudioFrameAdvancedSettings() - : speech(true), - sendEvenIfEmpty(true) {} - - /** - * Determines whether the audio source is speech. - * - true: (Default) The audio source is speech. - * - false: The audio source is not speech. - */ - bool speech; - /** - * Whether to send the audio frame even when it is empty. - * - true: (Default) Send the audio frame even when it is empty. - * - false: Do not send the audio frame when it is empty. - */ - bool sendEvenIfEmpty; -}; - -/** - * The definition of the EncodedAudioFrameInfo struct. - */ -struct EncodedAudioFrameInfo { - EncodedAudioFrameInfo() - : codec(AUDIO_CODEC_AACLC), - sampleRateHz(0), - samplesPerChannel(0), - numberOfChannels(0), - captureTimeMs(0) {} - - EncodedAudioFrameInfo(const EncodedAudioFrameInfo& rhs) - : codec(rhs.codec), - sampleRateHz(rhs.sampleRateHz), - samplesPerChannel(rhs.samplesPerChannel), - numberOfChannels(rhs.numberOfChannels), - advancedSettings(rhs.advancedSettings), - captureTimeMs(rhs.captureTimeMs) {} - /** - * The audio codec: #AUDIO_CODEC_TYPE. - */ - AUDIO_CODEC_TYPE codec; - /** - * The sample rate (Hz) of the audio frame. - */ - int sampleRateHz; - /** - * The number of samples per audio channel. - * - * If this value is not set, it is 1024 for AAC, or 960 for OPUS by default. - */ - int samplesPerChannel; - /** - * The number of audio channels of the audio frame. - */ - int numberOfChannels; - /** - * The advanced settings of the audio frame. - */ - EncodedAudioFrameAdvancedSettings advancedSettings; - - /** - * This is a input parameter which means the timestamp for capturing the audio frame. - */ - int64_t captureTimeMs; -}; -/** - * The definition of the AudioPcmDataInfo struct. - */ -struct AudioPcmDataInfo { - AudioPcmDataInfo() : samplesPerChannel(0), channelNum(0), samplesOut(0), elapsedTimeMs(0), ntpTimeMs(0) {} - - AudioPcmDataInfo(const AudioPcmDataInfo& rhs) - : samplesPerChannel(rhs.samplesPerChannel), - channelNum(rhs.channelNum), - samplesOut(rhs.samplesOut), - elapsedTimeMs(rhs.elapsedTimeMs), - ntpTimeMs(rhs.ntpTimeMs) {} - - /** - * The sample count of the PCM data that you expect. - */ - size_t samplesPerChannel; - - int16_t channelNum; - - // Output - /** - * The number of output samples. - */ - size_t samplesOut; - /** - * The rendering time (ms). - */ - int64_t elapsedTimeMs; - /** - * The NTP (Network Time Protocol) timestamp (ms). - */ - int64_t ntpTimeMs; -}; -/** - * Packetization modes. Applies to H.264 only. - */ -enum H264PacketizeMode { - /** - * Non-interleaved mode. See RFC 6184. - */ - NonInterleaved = 0, // Mode 1 - STAP-A, FU-A is allowed - /** - * Single NAL unit mode. See RFC 6184. - */ - SingleNalUnit, // Mode 0 - only single NALU allowed -}; - -/** - * Video stream types. - */ -enum VIDEO_STREAM_TYPE { - /** - * 0: The high-quality video stream, which has the highest resolution and bitrate. - */ - VIDEO_STREAM_HIGH = 0, - /** - * 1: The low-quality video stream, which has the lowest resolution and bitrate. - */ - VIDEO_STREAM_LOW = 1, - /** - * 4: The video stream of layer_1, which has a lower resolution and bitrate than VIDEO_STREAM_HIGH. - */ - VIDEO_STREAM_LAYER_1 = 4, - /** - * 5: The video stream of layer_2, which has a lower resolution and bitrate than VIDEO_STREAM_LAYER_1. - */ - VIDEO_STREAM_LAYER_2 = 5, - /** - * 6: The video stream of layer_3, which has a lower resolution and bitrate than VIDEO_STREAM_LAYER_2. - */ - VIDEO_STREAM_LAYER_3 = 6, - /** - * 7: The video stream of layer_4, which has a lower resolution and bitrate than VIDEO_STREAM_LAYER_3. - */ - VIDEO_STREAM_LAYER_4 = 7, - /** - * 8: The video stream of layer_5, which has a lower resolution and bitrate than VIDEO_STREAM_LAYER_4. - */ - VIDEO_STREAM_LAYER_5 = 8, - /** - * 9: The video stream of layer_6, which has a lower resolution and bitrate than VIDEO_STREAM_LAYER_5. - */ - VIDEO_STREAM_LAYER_6 = 9, - -}; - -struct VideoSubscriptionOptions { - /** - * The type of the video stream to subscribe to. - * - * The default value is `VIDEO_STREAM_HIGH`, which means the high-quality - * video stream. - */ - Optional type; - /** - * Whether to subscribe to encoded video data only: - * - `true`: Subscribe to encoded video data only. - * - `false`: (Default) Subscribe to decoded video data. - */ - Optional encodedFrameOnly; - - VideoSubscriptionOptions() {} -}; - - -/** The maximum length of the user account. - */ -enum MAX_USER_ACCOUNT_LENGTH_TYPE -{ - /** The maximum length of the user account is 256 bytes. - */ - MAX_USER_ACCOUNT_LENGTH = 256 -}; - -/** - * The definition of the EncodedVideoFrameInfo struct, which contains the information of the external encoded video frame. - */ -struct EncodedVideoFrameInfo { - EncodedVideoFrameInfo() - : uid(0), - codecType(VIDEO_CODEC_H264), - width(0), - height(0), - framesPerSecond(0), - frameType(VIDEO_FRAME_TYPE_BLANK_FRAME), - rotation(VIDEO_ORIENTATION_0), - trackId(0), - captureTimeMs(0), - decodeTimeMs(0), - streamType(VIDEO_STREAM_HIGH), - presentationMs(-1) {} - - EncodedVideoFrameInfo(const EncodedVideoFrameInfo& rhs) - : uid(rhs.uid), - codecType(rhs.codecType), - width(rhs.width), - height(rhs.height), - framesPerSecond(rhs.framesPerSecond), - frameType(rhs.frameType), - rotation(rhs.rotation), - trackId(rhs.trackId), - captureTimeMs(rhs.captureTimeMs), - decodeTimeMs(rhs.decodeTimeMs), - streamType(rhs.streamType), - presentationMs(rhs.presentationMs) {} - - EncodedVideoFrameInfo& operator=(const EncodedVideoFrameInfo& rhs) { - if (this == &rhs) return *this; - uid = rhs.uid; - codecType = rhs.codecType; - width = rhs.width; - height = rhs.height; - framesPerSecond = rhs.framesPerSecond; - frameType = rhs.frameType; - rotation = rhs.rotation; - trackId = rhs.trackId; - captureTimeMs = rhs.captureTimeMs; - decodeTimeMs = rhs.decodeTimeMs; - streamType = rhs.streamType; - presentationMs = rhs.presentationMs; - return *this; - } - - /** - * ID of the user that pushes the the external encoded video frame.. - */ - uid_t uid; - /** - * The codec type of the local video stream. See #VIDEO_CODEC_TYPE. The default value is `VIDEO_CODEC_H265 (3)`. - */ - VIDEO_CODEC_TYPE codecType; - /** - * The width (px) of the video frame. - */ - int width; - /** - * The height (px) of the video frame. - */ - int height; - /** - * The number of video frames per second. - * When this parameter is not 0, you can use it to calculate the Unix timestamp of the external - * encoded video frames. - */ - int framesPerSecond; - /** - * The video frame type: #VIDEO_FRAME_TYPE. - */ - VIDEO_FRAME_TYPE frameType; - /** - * The rotation information of the video frame: #VIDEO_ORIENTATION. - */ - VIDEO_ORIENTATION rotation; - /** - * The track ID of the video frame. - */ - int trackId; // This can be reserved for multiple video tracks, we need to create different ssrc - // and additional payload for later implementation. - /** - * This is a input parameter which means the timestamp for capturing the video. - */ - int64_t captureTimeMs; - /** - * The timestamp for decoding the video. - */ - int64_t decodeTimeMs; - /** - * The stream type of video frame. - */ - VIDEO_STREAM_TYPE streamType; - - // @technical preview - int64_t presentationMs; -}; - -/** -* Video compression preference. -*/ -enum COMPRESSION_PREFERENCE { - /** - * (Default) Low latency is preferred, usually used in real-time communication where low latency is the number one priority. - */ - PREFER_LOW_LATENCY, - /** - * Prefer quality in sacrifice of a degree of latency, usually around 30ms ~ 150ms, depends target fps - */ - PREFER_QUALITY, -}; - -/** -* The video encoder type preference. -*/ -enum ENCODING_PREFERENCE { - /** - *Default . - */ - PREFER_AUTO = -1, - /** - * Software encoding. - */ - PREFER_SOFTWARE = 0, - /** - * Hardware encoding - */ - PREFER_HARDWARE = 1, -}; - -/** - * The definition of the AdvanceOptions struct. - */ -struct AdvanceOptions { - - /** - * The video encoder type preference.. - */ - ENCODING_PREFERENCE encodingPreference; - - /** - * Video compression preference. - */ - COMPRESSION_PREFERENCE compressionPreference; - - /** - * Whether to encode and send the alpha data to the remote when alpha data is present. - * The default value is false. - */ - bool encodeAlpha; - - AdvanceOptions() : encodingPreference(PREFER_AUTO), - compressionPreference(PREFER_LOW_LATENCY), - encodeAlpha(false) {} - - AdvanceOptions(ENCODING_PREFERENCE encoding_preference, - COMPRESSION_PREFERENCE compression_preference, - bool encode_alpha) : - encodingPreference(encoding_preference), - compressionPreference(compression_preference), - encodeAlpha(encode_alpha) {} - - bool operator==(const AdvanceOptions& rhs) const { - return encodingPreference == rhs.encodingPreference && - compressionPreference == rhs.compressionPreference && - encodeAlpha == rhs.encodeAlpha; - } - -}; - -/** - * Video mirror mode types. - */ -enum VIDEO_MIRROR_MODE_TYPE { - /** - * 0: The mirror mode determined by the SDK. - */ - VIDEO_MIRROR_MODE_AUTO = 0, - /** - * 1: Enable the mirror mode. - */ - VIDEO_MIRROR_MODE_ENABLED = 1, - /** - * 2: Disable the mirror mode. - */ - VIDEO_MIRROR_MODE_DISABLED = 2, -}; - -#if defined(__APPLE__) && TARGET_OS_IOS -/** - * Camera capturer configuration for format type. - */ -enum CAMERA_FORMAT_TYPE { - /** 0: (Default) NV12. */ - CAMERA_FORMAT_NV12, - /** 1: BGRA. */ - CAMERA_FORMAT_BGRA, -}; -#endif - -/** Supported codec type bit mask. */ -enum CODEC_CAP_MASK { - /** 0: No codec support. */ - CODEC_CAP_MASK_NONE = 0, - - /** bit 1: Hardware decoder support flag. */ - CODEC_CAP_MASK_HW_DEC = 1 << 0, - - /** bit 2: Hardware encoder support flag. */ - CODEC_CAP_MASK_HW_ENC = 1 << 1, - - /** bit 3: Software decoder support flag. */ - CODEC_CAP_MASK_SW_DEC = 1 << 2, - - /** bit 4: Software encoder support flag. */ - CODEC_CAP_MASK_SW_ENC = 1 << 3, -}; - -struct CodecCapLevels { - VIDEO_CODEC_CAPABILITY_LEVEL hwDecodingLevel; - VIDEO_CODEC_CAPABILITY_LEVEL swDecodingLevel; - - CodecCapLevels(): hwDecodingLevel(CODEC_CAPABILITY_LEVEL_UNSPECIFIED), swDecodingLevel(CODEC_CAPABILITY_LEVEL_UNSPECIFIED) {} -}; - -/** The codec support information. */ -struct CodecCapInfo { - /** The codec type: #VIDEO_CODEC_TYPE. */ - VIDEO_CODEC_TYPE codecType; - /** The codec support flag. */ - int codecCapMask; - /** The codec capability level, estimated based on the device hardware.*/ - CodecCapLevels codecLevels; - - CodecCapInfo(): codecType(VIDEO_CODEC_NONE), codecCapMask(0) {} -}; - -/** FocalLengthInfo contains the IDs of the front and rear cameras, along with the wide-angle types. */ -struct FocalLengthInfo { - /** The camera direction. */ - int cameraDirection; - /** Camera focal segment type. */ - CAMERA_FOCAL_LENGTH_TYPE focalLengthType; -}; - -/** - * The definition of the VideoEncoderConfiguration struct. - */ -struct VideoEncoderConfiguration { - /** - * The video encoder code type: #VIDEO_CODEC_TYPE. - */ - VIDEO_CODEC_TYPE codecType; - /** - * The video dimension: VideoDimensions. - */ - VideoDimensions dimensions; - /** - * The frame rate of the video. You can set it manually, or choose one from #FRAME_RATE. - */ - int frameRate; - /** - * The bitrate (Kbps) of the video. - * - * Refer to the **Video Bitrate Table** below and set your bitrate. If you set a bitrate beyond the - * proper range, the SDK automatically adjusts it to a value within the range. You can also choose - * from the following options: - * - * - #STANDARD_BITRATE: (Recommended) Standard bitrate mode. In this mode, the bitrates differ between - * the Live Broadcast and Communication profiles: - * - In the Communication profile, the video bitrate is the same as the base bitrate. - * - In the Live Broadcast profile, the video bitrate is twice the base bitrate. - * - #COMPATIBLE_BITRATE: Compatible bitrate mode. The compatible bitrate mode. In this mode, the bitrate - * stays the same regardless of the profile. If you choose this mode for the Live Broadcast profile, - * the video frame rate may be lower than the set value. - * - * Agora uses different video codecs for different profiles to optimize the user experience. For example, - * the communication profile prioritizes the smoothness while the live-broadcast profile prioritizes the - * video quality (a higher bitrate). Therefore, We recommend setting this parameter as #STANDARD_BITRATE. - * - * | Resolution | Frame Rate (fps) | Base Bitrate (Kbps) | Live Bitrate (Kbps)| - * |------------------------|------------------|---------------------|--------------------| - * | 160 * 120 | 15 | 65 | 110 | - * | 120 * 120 | 15 | 50 | 90 | - * | 320 * 180 | 15 | 140 | 240 | - * | 180 * 180 | 15 | 100 | 160 | - * | 240 * 180 | 15 | 120 | 200 | - * | 320 * 240 | 15 | 200 | 300 | - * | 240 * 240 | 15 | 140 | 240 | - * | 424 * 240 | 15 | 220 | 370 | - * | 640 * 360 | 15 | 400 | 680 | - * | 360 * 360 | 15 | 260 | 440 | - * | 640 * 360 | 30 | 600 | 1030 | - * | 360 * 360 | 30 | 400 | 670 | - * | 480 * 360 | 15 | 320 | 550 | - * | 480 * 360 | 30 | 490 | 830 | - * | 640 * 480 | 15 | 500 | 750 | - * | 480 * 480 | 15 | 400 | 680 | - * | 640 * 480 | 30 | 750 | 1130 | - * | 480 * 480 | 30 | 600 | 1030 | - * | 848 * 480 | 15 | 610 | 920 | - * | 848 * 480 | 30 | 930 | 1400 | - * | 640 * 480 | 10 | 400 | 600 | - * | 960 * 540 | 15 | 750 | 1100 | - * | 960 * 540 | 30 | 1110 | 1670 | - * | 1280 * 720 | 15 | 1130 | 1600 | - * | 1280 * 720 | 30 | 1710 | 2400 | - * | 960 * 720 | 15 | 910 | 1280 | - * | 960 * 720 | 30 | 1380 | 2000 | - * | 1920 * 1080 | 15 | 2080 | 2500 | - * | 1920 * 1080 | 30 | 3150 | 3780 | - * | 1920 * 1080 | 60 | 4780 | 5730 | - * | 2560 * 1440 | 30 | 4850 | 4850 | - * | 2560 * 1440 | 60 | 7350 | 7350 | - * | 3840 * 2160 | 30 | 8910 | 8910 | - * | 3840 * 2160 | 60 | 13500 | 13500 | - */ - int bitrate; - - /** - * The minimum encoding bitrate (Kbps). - * - * The Agora SDK automatically adjusts the encoding bitrate to adapt to the - * network conditions. - * - * Using a value greater than the default value forces the video encoder to - * output high-quality images but may cause more packet loss and hence - * sacrifice the smoothness of the video transmission. That said, unless you - * have special requirements for image quality, Agora does not recommend - * changing this value. - * - * @note - * This parameter applies to the live-broadcast profile only. - */ - int minBitrate; - /** - * The video orientation mode: #ORIENTATION_MODE. - */ - ORIENTATION_MODE orientationMode; - /** - * The video degradation preference under limited bandwidth: #DEGRADATION_PREFERENCE. - */ - DEGRADATION_PREFERENCE degradationPreference; - - /** - * The mirror mode is disabled by default - * If mirror_type is set to VIDEO_MIRROR_MODE_ENABLED, then the video frame would be mirrored before encoding. - */ - VIDEO_MIRROR_MODE_TYPE mirrorMode; - - /** - * The advanced options for the video encoder configuration. See AdvanceOptions. - */ - AdvanceOptions advanceOptions; - - VideoEncoderConfiguration(const VideoDimensions& d, int f, int b, ORIENTATION_MODE m, VIDEO_MIRROR_MODE_TYPE mirror = VIDEO_MIRROR_MODE_DISABLED) - : codecType(VIDEO_CODEC_NONE), - dimensions(d), - frameRate(f), - bitrate(b), - minBitrate(DEFAULT_MIN_BITRATE), - orientationMode(m), - degradationPreference(MAINTAIN_QUALITY), - mirrorMode(mirror), - advanceOptions(PREFER_AUTO, PREFER_LOW_LATENCY, false) {} - VideoEncoderConfiguration(int width, int height, int f, int b, ORIENTATION_MODE m, VIDEO_MIRROR_MODE_TYPE mirror = VIDEO_MIRROR_MODE_DISABLED) - : codecType(VIDEO_CODEC_NONE), - dimensions(width, height), - frameRate(f), - bitrate(b), - minBitrate(DEFAULT_MIN_BITRATE), - orientationMode(m), - degradationPreference(MAINTAIN_QUALITY), - mirrorMode(mirror), - advanceOptions(PREFER_AUTO, PREFER_LOW_LATENCY, false) {} - VideoEncoderConfiguration(const VideoEncoderConfiguration& config) - : codecType(config.codecType), - dimensions(config.dimensions), - frameRate(config.frameRate), - bitrate(config.bitrate), - minBitrate(config.minBitrate), - orientationMode(config.orientationMode), - degradationPreference(config.degradationPreference), - mirrorMode(config.mirrorMode), - advanceOptions(config.advanceOptions) {} - VideoEncoderConfiguration() - : codecType(VIDEO_CODEC_NONE), - dimensions(FRAME_WIDTH_960, FRAME_HEIGHT_540), - frameRate(FRAME_RATE_FPS_15), - bitrate(STANDARD_BITRATE), - minBitrate(DEFAULT_MIN_BITRATE), - orientationMode(ORIENTATION_MODE_ADAPTIVE), - degradationPreference(MAINTAIN_QUALITY), - mirrorMode(VIDEO_MIRROR_MODE_DISABLED), - advanceOptions(PREFER_AUTO, PREFER_LOW_LATENCY, false) {} - - VideoEncoderConfiguration& operator=(const VideoEncoderConfiguration& rhs) { - if (this == &rhs) return *this; - codecType = rhs.codecType; - dimensions = rhs.dimensions; - frameRate = rhs.frameRate; - bitrate = rhs.bitrate; - minBitrate = rhs.minBitrate; - orientationMode = rhs.orientationMode; - degradationPreference = rhs.degradationPreference; - mirrorMode = rhs.mirrorMode; - advanceOptions = rhs.advanceOptions; - return *this; - } -}; - -/** - * The configurations for the data stream. - */ -struct DataStreamConfig { - /** - * Whether to synchronize the data packet with the published audio packet. - * - `true`: Synchronize the data packet with the audio packet. - * - `false`: Do not synchronize the data packet with the audio packet. - * - * When you set the data packet to synchronize with the audio, then if the data packet delay is - * within the audio delay, the SDK triggers the `onStreamMessage` callback when the synchronized - * audio packet is played out. Do not set this parameter as true if you need the receiver to receive - * the data packet immediately. Agora recommends that you set this parameter to `true` only when you - * need to implement specific functions, for example lyric synchronization. - */ - bool syncWithAudio; - /** - * Whether the SDK guarantees that the receiver receives the data in the sent order. - * - `true`: Guarantee that the receiver receives the data in the sent order. - * - `false`: Do not guarantee that the receiver receives the data in the sent order. - * - * Do not set this parameter as `true` if you need the receiver to receive the data packet immediately. - */ - bool ordered; -}; - -/** - * The definition of SIMULCAST_STREAM_MODE - */ -enum SIMULCAST_STREAM_MODE { - /* - * disable simulcast stream until receive request for enable simulcast stream by other broadcaster - */ - AUTO_SIMULCAST_STREAM = -1, - /* - * disable simulcast stream - */ - DISABLE_SIMULCAST_STREAM = 0, - /* - * always enable simulcast stream - */ - ENABLE_SIMULCAST_STREAM = 1, -}; - -/** - * The configuration of the low-quality video stream. - */ -struct SimulcastStreamConfig { - /** - * The video frame dimension: VideoDimensions. The default value is 160 × 120. - */ - VideoDimensions dimensions; - /** - * The video bitrate (Kbps), represented by an instantaneous value. The default value of the log level is 5. - */ - int kBitrate; - /** - * The capture frame rate (fps) of the local video. The default value is 5. - */ - int framerate; - SimulcastStreamConfig() : dimensions(160, 120), kBitrate(65), framerate(5) {} - SimulcastStreamConfig(const SimulcastStreamConfig& other) : dimensions(other.dimensions), kBitrate(other.kBitrate), framerate(other.framerate) {} - bool operator==(const SimulcastStreamConfig& rhs) const { - return dimensions == rhs.dimensions && kBitrate == rhs.kBitrate && framerate == rhs.framerate; - } -}; - -/** - * The configuration of the multi-layer video stream. - */ -struct SimulcastConfig { - /** - * The index of multi-layer video stream - */ - enum StreamLayerIndex { - /** - * 0: video stream index of layer_1 - */ - STREAM_LAYER_1 = 0, - /** - * 1: video stream index of layer_2 - */ - STREAM_LAYER_2 = 1, - /** - * 2: video stream index of layer_3 - */ - STREAM_LAYER_3 = 2, - /** - * 3: video stream index of layer_4 - */ - STREAM_LAYER_4 = 3, - /** - * 4: video stream index of layer_5 - */ - STREAM_LAYER_5 = 4, - /** - * 5: video stream index of layer_6 - */ - STREAM_LAYER_6 = 5, - /** - * 6: video stream index of low - */ - STREAM_LOW = 6, - /** - * 7: max count of video stream layers - */ - STREAM_LAYER_COUNT_MAX = 7 - }; - struct StreamLayerConfig { - /** - * The video frame dimension. The default value is 0. - */ - VideoDimensions dimensions; - /** - * The capture frame rate (fps) of the local video. The default value is 0. - */ - int framerate; - /** - * Whether to enable the corresponding layer of video stream. The default value is false. - */ - bool enable; - StreamLayerConfig() : dimensions(0, 0), framerate(0), enable(false) {} - }; - - /** - * The array of StreamLayerConfig, which contains STREAM_LAYER_COUNT_MAX layers of video stream at most. - */ - StreamLayerConfig configs[STREAM_LAYER_COUNT_MAX]; -}; -/** - * The location of the target area relative to the screen or window. If you do not set this parameter, - * the SDK selects the whole screen or window. - */ -struct Rectangle { - /** - * The horizontal offset from the top-left corner. - */ - int x; - /** - * The vertical offset from the top-left corner. - */ - int y; - /** - * The width of the region. - */ - int width; - /** - * The height of the region. - */ - int height; - - Rectangle() : x(0), y(0), width(0), height(0) {} - Rectangle(int xx, int yy, int ww, int hh) : x(xx), y(yy), width(ww), height(hh) {} -}; - -/** - * The position and size of the watermark on the screen. - * - * The position and size of the watermark on the screen are determined by `xRatio`, `yRatio`, and `widthRatio`: - * - (`xRatio`, `yRatio`) refers to the coordinates of the upper left corner of the watermark, which determines - * the distance from the upper left corner of the watermark to the upper left corner of the screen. - * The `widthRatio` determines the width of the watermark. - */ -struct WatermarkRatio { - /** - * The x-coordinate of the upper left corner of the watermark. The horizontal position relative to - * the origin, where the upper left corner of the screen is the origin, and the x-coordinate is the - * upper left corner of the watermark. The value range is [0.0,1.0], and the default value is 0. - */ - float xRatio; - /** - * The y-coordinate of the upper left corner of the watermark. The vertical position relative to the - * origin, where the upper left corner of the screen is the origin, and the y-coordinate is the upper - * left corner of the screen. The value range is [0.0,1.0], and the default value is 0. - */ - float yRatio; - /** - * The width of the watermark. The SDK calculates the height of the watermark proportionally according - * to this parameter value to ensure that the enlarged or reduced watermark image is not distorted. - * The value range is [0,1], and the default value is 0, which means no watermark is displayed. - */ - float widthRatio; - - WatermarkRatio() : xRatio(0.0), yRatio(0.0), widthRatio(0.0) {} - WatermarkRatio(float x, float y, float width) : xRatio(x), yRatio(y), widthRatio(width) {} -}; - -/** - * Configurations of the watermark image. - */ -struct WatermarkOptions { - /** - * Whether or not the watermark image is visible in the local video preview: - * - true: (Default) The watermark image is visible in preview. - * - false: The watermark image is not visible in preview. - */ - bool visibleInPreview; - /** - * When the adaptation mode of the watermark is `FIT_MODE_COVER_POSITION`, it is used to set the - * area of the watermark image in landscape mode. See #FIT_MODE_COVER_POSITION for details. - */ - Rectangle positionInLandscapeMode; - /** - * When the adaptation mode of the watermark is `FIT_MODE_COVER_POSITION`, it is used to set the - * area of the watermark image in portrait mode. See #FIT_MODE_COVER_POSITION for details. - */ - Rectangle positionInPortraitMode; - /** - * When the watermark adaptation mode is `FIT_MODE_USE_IMAGE_RATIO`, this parameter is used to set - * the watermark coordinates. See WatermarkRatio for details. - */ - WatermarkRatio watermarkRatio; - /** - * The adaptation mode of the watermark. See #WATERMARK_FIT_MODE for details. - */ - WATERMARK_FIT_MODE mode; - - WatermarkOptions() - : visibleInPreview(true), - positionInLandscapeMode(0, 0, 0, 0), - positionInPortraitMode(0, 0, 0, 0), - mode(FIT_MODE_COVER_POSITION) {} -}; - -/** - * The definition of the RtcStats struct. - */ -struct RtcStats { - /** - * The call duration (s), represented by an aggregate value. - */ - unsigned int duration; - /** - * The total number of bytes transmitted, represented by an aggregate value. - */ - unsigned int txBytes; - /** - * The total number of bytes received, represented by an aggregate value. - */ - unsigned int rxBytes; - /** - * The total number of audio bytes sent (bytes), represented by an aggregate value. - */ - unsigned int txAudioBytes; - /** - * The total number of video bytes sent (bytes), represented by an aggregate value. - */ - unsigned int txVideoBytes; - /** - * The total number of audio bytes received (bytes), represented by an aggregate value. - */ - unsigned int rxAudioBytes; - /** - * The total number of video bytes received (bytes), represented by an aggregate value. - */ - unsigned int rxVideoBytes; - /** - * The transmission bitrate (Kbps), represented by an instantaneous value. - */ - unsigned short txKBitRate; - /** - * The receiving bitrate (Kbps), represented by an instantaneous value. - */ - unsigned short rxKBitRate; - /** - * Audio receiving bitrate (Kbps), represented by an instantaneous value. - */ - unsigned short rxAudioKBitRate; - /** - * The audio transmission bitrate (Kbps), represented by an instantaneous value. - */ - unsigned short txAudioKBitRate; - /** - * The video receive bitrate (Kbps), represented by an instantaneous value. - */ - unsigned short rxVideoKBitRate; - /** - * The video transmission bitrate (Kbps), represented by an instantaneous value. - */ - unsigned short txVideoKBitRate; - /** - * The VOS client-server latency (ms). - */ - unsigned short lastmileDelay; - /** - * The number of users in the channel. - */ - unsigned int userCount; - /** - * The app CPU usage (%). - * @note - * - The value of `cpuAppUsage` is always reported as 0 in the `onLeaveChannel` callback. - * - As of Android 8.1, you cannot get the CPU usage from this attribute due to system limitations. - */ - double cpuAppUsage; - /** - * The system CPU usage (%). - * - * For Windows, in the multi-kernel environment, this member represents the average CPU usage. The - * value = (100 - System Idle Progress in Task Manager)/100. - * @note - * - The value of `cpuTotalUsage` is always reported as 0 in the `onLeaveChannel` callback. - * - As of Android 8.1, you cannot get the CPU usage from this attribute due to system limitations. - */ - double cpuTotalUsage; - /** - * The round-trip time delay from the client to the local router. - * @note On Android, to get `gatewayRtt`, ensure that you add the `android.permission.ACCESS_WIFI_STATE` - * permission after `` in the `AndroidManifest.xml` file in your project. - */ - int gatewayRtt; - /** - * The memory usage ratio of the app (%). - * @note This value is for reference only. Due to system limitations, you may not get this value. - */ - double memoryAppUsageRatio; - /** - * The memory usage ratio of the system (%). - * @note This value is for reference only. Due to system limitations, you may not get this value. - */ - double memoryTotalUsageRatio; - /** - * The memory usage of the app (KB). - * @note This value is for reference only. Due to system limitations, you may not get this value. - */ - int memoryAppUsageInKbytes; - /** - * The time elapsed from the when the app starts connecting to an Agora channel - * to when the connection is established. 0 indicates that this member does not apply. - */ - int connectTimeMs; - /** - * The duration (ms) between the app starting connecting to an Agora channel - * and the first audio packet is received. 0 indicates that this member does not apply. - */ - int firstAudioPacketDuration; - /** - * The duration (ms) between the app starting connecting to an Agora channel - * and the first video packet is received. 0 indicates that this member does not apply. - */ - int firstVideoPacketDuration; - /** - * The duration (ms) between the app starting connecting to an Agora channel - * and the first video key frame is received. 0 indicates that this member does not apply. - */ - int firstVideoKeyFramePacketDuration; - /** - * The number of video packets before the first video key frame is received. - * 0 indicates that this member does not apply. - */ - int packetsBeforeFirstKeyFramePacket; - /** - * The duration (ms) between the last time unmute audio and the first audio packet is received. - * 0 indicates that this member does not apply. - */ - int firstAudioPacketDurationAfterUnmute; - /** - * The duration (ms) between the last time unmute video and the first video packet is received. - * 0 indicates that this member does not apply. - */ - int firstVideoPacketDurationAfterUnmute; - /** - * The duration (ms) between the last time unmute video and the first video key frame is received. - * 0 indicates that this member does not apply. - */ - int firstVideoKeyFramePacketDurationAfterUnmute; - /** - * The duration (ms) between the last time unmute video and the first video key frame is decoded. - * 0 indicates that this member does not apply. - */ - int firstVideoKeyFrameDecodedDurationAfterUnmute; - /** - * The duration (ms) between the last time unmute video and the first video key frame is rendered. - * 0 indicates that this member does not apply. - */ - int firstVideoKeyFrameRenderedDurationAfterUnmute; - /** - * The packet loss rate of sender(broadcaster). - */ - int txPacketLossRate; - /** - * The packet loss rate of receiver(audience). - */ - int rxPacketLossRate; - RtcStats() - : duration(0), - txBytes(0), - rxBytes(0), - txAudioBytes(0), - txVideoBytes(0), - rxAudioBytes(0), - rxVideoBytes(0), - txKBitRate(0), - rxKBitRate(0), - rxAudioKBitRate(0), - txAudioKBitRate(0), - rxVideoKBitRate(0), - txVideoKBitRate(0), - lastmileDelay(0), - userCount(0), - cpuAppUsage(0.0), - cpuTotalUsage(0.0), - gatewayRtt(0), - memoryAppUsageRatio(0.0), - memoryTotalUsageRatio(0.0), - memoryAppUsageInKbytes(0), - connectTimeMs(0), - firstAudioPacketDuration(0), - firstVideoPacketDuration(0), - firstVideoKeyFramePacketDuration(0), - packetsBeforeFirstKeyFramePacket(0), - firstAudioPacketDurationAfterUnmute(0), - firstVideoPacketDurationAfterUnmute(0), - firstVideoKeyFramePacketDurationAfterUnmute(0), - firstVideoKeyFrameDecodedDurationAfterUnmute(0), - firstVideoKeyFrameRenderedDurationAfterUnmute(0), - txPacketLossRate(0), - rxPacketLossRate(0) {} -}; - -/** - * User role types. - */ -enum CLIENT_ROLE_TYPE { - /** - * 1: Broadcaster. A broadcaster can both send and receive streams. - */ - CLIENT_ROLE_BROADCASTER = 1, - /** - * 2: Audience. An audience member can only receive streams. - */ - CLIENT_ROLE_AUDIENCE = 2, -}; - -/** - * Quality change of the local video in terms of target frame rate and target bit rate since last count. - */ -enum QUALITY_ADAPT_INDICATION { - /** - * 0: The quality of the local video stays the same. - */ - ADAPT_NONE = 0, - /** - * 1: The quality improves because the network bandwidth increases. - */ - ADAPT_UP_BANDWIDTH = 1, - /** - * 2: The quality worsens because the network bandwidth decreases. - */ - ADAPT_DOWN_BANDWIDTH = 2, -}; - -/** - * The latency level of an audience member in interactive live streaming. This enum takes effect only - * when the user role is set to `CLIENT_ROLE_AUDIENCE`. - */ -enum AUDIENCE_LATENCY_LEVEL_TYPE -{ - /** - * 1: Low latency. - */ - AUDIENCE_LATENCY_LEVEL_LOW_LATENCY = 1, - /** - * 2: Ultra low latency. - */ - AUDIENCE_LATENCY_LEVEL_ULTRA_LOW_LATENCY = 2, -}; - -/** - * The detailed options of a user. - */ -struct ClientRoleOptions -{ - /** - * The latency level of an audience member in interactive live streaming. See `AUDIENCE_LATENCY_LEVEL_TYPE`. - */ - AUDIENCE_LATENCY_LEVEL_TYPE audienceLatencyLevel; - - ClientRoleOptions() - : audienceLatencyLevel(AUDIENCE_LATENCY_LEVEL_ULTRA_LOW_LATENCY) {} -}; - -/** - * Quality of experience (QoE) of the local user when receiving a remote audio stream. - */ -enum EXPERIENCE_QUALITY_TYPE { - /** 0: QoE of the local user is good. */ - EXPERIENCE_QUALITY_GOOD = 0, - /** 1: QoE of the local user is poor. */ - EXPERIENCE_QUALITY_BAD = 1, -}; - -/** - * Reasons why the QoE of the local user when receiving a remote audio stream is poor. - */ -enum EXPERIENCE_POOR_REASON { - /** - * 0: No reason, indicating good QoE of the local user. - */ - EXPERIENCE_REASON_NONE = 0, - /** - * 1: The remote user's network quality is poor. - */ - REMOTE_NETWORK_QUALITY_POOR = 1, - /** - * 2: The local user's network quality is poor. - */ - LOCAL_NETWORK_QUALITY_POOR = 2, - /** - * 4: The local user's Wi-Fi or mobile network signal is weak. - */ - WIRELESS_SIGNAL_POOR = 4, - /** - * 8: The local user enables both Wi-Fi and bluetooth, and their signals interfere with each other. - * As a result, audio transmission quality is undermined. - */ - WIFI_BLUETOOTH_COEXIST = 8, -}; - -/** - * Audio AINS mode - */ -enum AUDIO_AINS_MODE { - /** - * AINS mode with soft suppression level. - */ - AINS_MODE_BALANCED = 0, - /** - * AINS mode with high suppression level. - */ - AINS_MODE_AGGRESSIVE = 1, - /** - * AINS mode with high suppression level and ultra-low-latency - */ - AINS_MODE_ULTRALOWLATENCY = 2 -}; - -/** - * Audio profile types. - */ -enum AUDIO_PROFILE_TYPE { - /** - * 0: The default audio profile. - * - For the Communication profile: - * - Windows: A sample rate of 16 kHz, audio encoding, mono, and a bitrate of up to 16 Kbps. - * - Android/macOS/iOS: A sample rate of 32 kHz, audio encoding, mono, and a bitrate of up to 18 Kbps. - * of up to 16 Kbps. - * - For the Live-broadcast profile: A sample rate of 48 kHz, music encoding, mono, and a bitrate of up to 64 Kbps. - */ - AUDIO_PROFILE_DEFAULT = 0, - /** - * 1: A sample rate of 32 kHz, audio encoding, mono, and a bitrate of up to 18 Kbps. - */ - AUDIO_PROFILE_SPEECH_STANDARD = 1, - /** - * 2: A sample rate of 48 kHz, music encoding, mono, and a bitrate of up to 64 Kbps. - */ - AUDIO_PROFILE_MUSIC_STANDARD = 2, - /** - * 3: A sample rate of 48 kHz, music encoding, stereo, and a bitrate of up to 80 Kbps. - * - * To implement stereo audio, you also need to call `setAdvancedAudioOptions` and set `audioProcessingChannels` - * to `AUDIO_PROCESSING_STEREO` in `AdvancedAudioOptions`. - */ - AUDIO_PROFILE_MUSIC_STANDARD_STEREO = 3, - /** - * 4: A sample rate of 48 kHz, music encoding, mono, and a bitrate of up to 96 Kbps. - */ - AUDIO_PROFILE_MUSIC_HIGH_QUALITY = 4, - /** - * 5: A sample rate of 48 kHz, music encoding, stereo, and a bitrate of up to 128 Kbps. - * - * To implement stereo audio, you also need to call `setAdvancedAudioOptions` and set `audioProcessingChannels` - * to `AUDIO_PROCESSING_STEREO` in `AdvancedAudioOptions`. - */ - AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO = 5, - /** - * 6: A sample rate of 16 kHz, audio encoding, mono, and Acoustic Echo Cancellation (AES) enabled. - */ - AUDIO_PROFILE_IOT = 6, - AUDIO_PROFILE_NUM = 7 -}; - -/** - * The audio scenario. - */ -enum AUDIO_SCENARIO_TYPE { - /** - * 0: Automatic scenario, where the SDK chooses the appropriate audio quality according to the - * user role and audio route. - */ - AUDIO_SCENARIO_DEFAULT = 0, - /** - * 3: (Recommended) The live gaming scenario, which needs to enable gaming - * audio effects in the speaker. Choose this scenario to achieve high-fidelity - * music playback. - */ - AUDIO_SCENARIO_GAME_STREAMING = 3, - /** - * 5: The chatroom scenario, which needs to keep recording when setClientRole to audience. - * Normally, app developer can also use mute api to achieve the same result, - * and we implement this 'non-orthogonal' behavior only to make API backward compatible. - */ - AUDIO_SCENARIO_CHATROOM = 5, - /** - * 7: Real-time chorus scenario, where users have good network conditions and require ultra-low latency. - */ - AUDIO_SCENARIO_CHORUS = 7, - /** - * 8: Meeting - */ - AUDIO_SCENARIO_MEETING = 8, - /** - * 9: The number of enumerations. - */ - AUDIO_SCENARIO_NUM = 9, -}; - -/** - * The format of the video frame. - */ -struct VideoFormat { - OPTIONAL_ENUM_SIZE_T { - /** The maximum value (px) of the width. */ - kMaxWidthInPixels = 3840, - /** The maximum value (px) of the height. */ - kMaxHeightInPixels = 2160, - /** The maximum value (fps) of the frame rate. */ - kMaxFps = 60, - }; - - /** - * The width (px) of the video. - */ - int width; // Number of pixels. - /** - * The height (px) of the video. - */ - int height; // Number of pixels. - /** - * The video frame rate (fps). - */ - int fps; - VideoFormat() : width(FRAME_WIDTH_960), height(FRAME_HEIGHT_540), fps(FRAME_RATE_FPS_15) {} - VideoFormat(int w, int h, int f) : width(w), height(h), fps(f) {} - - bool operator<(const VideoFormat& fmt) const { - if (height != fmt.height) { - return height < fmt.height; - } else if (width != fmt.width) { - return width < fmt.width; - } else { - return fps < fmt.fps; - } - } - bool operator==(const VideoFormat& fmt) const { - return width == fmt.width && height == fmt.height && fps == fmt.fps; - } - bool operator!=(const VideoFormat& fmt) const { - return !operator==(fmt); - } -}; - -/** - * Video content hints. - */ -enum VIDEO_CONTENT_HINT { - /** - * (Default) No content hint. In this case, the SDK balances smoothness with sharpness. - */ - CONTENT_HINT_NONE, - /** - * Choose this option if you prefer smoothness or when - * you are sharing motion-intensive content such as a video clip, movie, or video game. - * - * - */ - CONTENT_HINT_MOTION, - /** - * Choose this option if you prefer sharpness or when you are - * sharing montionless content such as a picture, PowerPoint slide, ot text. - * - */ - CONTENT_HINT_DETAILS -}; -/** - * The screen sharing scenario. - */ -enum SCREEN_SCENARIO_TYPE { - /** - * 1: Document. This scenario prioritizes the video quality of screen sharing and reduces the - * latency of the shared video for the receiver. If you share documents, slides, and tables, - * you can set this scenario. - */ - SCREEN_SCENARIO_DOCUMENT = 1, - /** - * 2: Game. This scenario prioritizes the smoothness of screen sharing. If you share games, you - * can set this scenario. - */ - SCREEN_SCENARIO_GAMING = 2, - /** - * 3: Video. This scenario prioritizes the smoothness of screen sharing. If you share movies or - * live videos, you can set this scenario. - */ - SCREEN_SCENARIO_VIDEO = 3, - /** - * 4: Remote control. This scenario prioritizes the video quality of screen sharing and reduces - * the latency of the shared video for the receiver. If you share the device desktop being - * remotely controlled, you can set this scenario. - */ - SCREEN_SCENARIO_RDC = 4, -}; - - -/** - * The video application scenario type. - */ -enum VIDEO_APPLICATION_SCENARIO_TYPE { - /** - * 0: Default Scenario. - */ - APPLICATION_SCENARIO_GENERAL = 0, - /** - * 1: Meeting Scenario. This scenario is the best QoE practice of meeting application. - */ - APPLICATION_SCENARIO_MEETING = 1, - /** - * 2: Video Call Scenario. This scenario is used to optimize the video experience in video application, like 1v1 video call. - */ - APPLICATION_SCENARIO_1V1 = 2, -}; - -/** - * The video QoE preference type. - */ -enum VIDEO_QOE_PREFERENCE_TYPE { - /** - * 1: Default QoE type, balance the delay, picture quality and fluency. - */ - VIDEO_QOE_PREFERENCE_BALANCE = 1, - /** - * 2: lower the e2e delay. - */ - VIDEO_QOE_PREFERENCE_DELAY_FIRST = 2, - /** - * 3: picture quality. - */ - VIDEO_QOE_PREFERENCE_PICTURE_QUALITY_FIRST = 3, - /** - * 4: more fluency. - */ - VIDEO_QOE_PREFERENCE_FLUENCY_FIRST = 4, - -}; - -/** - * The brightness level of the video image captured by the local camera. - */ -enum CAPTURE_BRIGHTNESS_LEVEL_TYPE { - /** -1: The SDK does not detect the brightness level of the video image. - * Wait a few seconds to get the brightness level from `CAPTURE_BRIGHTNESS_LEVEL_TYPE` in the next callback. - */ - CAPTURE_BRIGHTNESS_LEVEL_INVALID = -1, - /** 0: The brightness level of the video image is normal. - */ - CAPTURE_BRIGHTNESS_LEVEL_NORMAL = 0, - /** 1: The brightness level of the video image is too bright. - */ - CAPTURE_BRIGHTNESS_LEVEL_BRIGHT = 1, - /** 2: The brightness level of the video image is too dark. - */ - CAPTURE_BRIGHTNESS_LEVEL_DARK = 2, -}; - -enum CAMERA_STABILIZATION_MODE { - /** The camera stabilization mode is disabled. - */ - CAMERA_STABILIZATION_MODE_OFF = -1, - /** device choose stabilization mode automatically. - */ - CAMERA_STABILIZATION_MODE_AUTO = 0, - /** stabilization mode level 1. - */ - CAMERA_STABILIZATION_MODE_LEVEL_1 = 1, - /** stabilization mode level 2. - */ - CAMERA_STABILIZATION_MODE_LEVEL_2 = 2, - /** stabilization mode level 3. - */ - CAMERA_STABILIZATION_MODE_LEVEL_3 = 3, - /** The maximum level of the camera stabilization mode. - */ - CAMERA_STABILIZATION_MODE_MAX_LEVEL = CAMERA_STABILIZATION_MODE_LEVEL_3, -}; - -/** - * Local audio states. - */ -enum LOCAL_AUDIO_STREAM_STATE { - /** - * 0: The local audio is in the initial state. - */ - LOCAL_AUDIO_STREAM_STATE_STOPPED = 0, - /** - * 1: The capturing device starts successfully. - */ - LOCAL_AUDIO_STREAM_STATE_RECORDING = 1, - /** - * 2: The first audio frame encodes successfully. - */ - LOCAL_AUDIO_STREAM_STATE_ENCODING = 2, - /** - * 3: The local audio fails to start. - */ - LOCAL_AUDIO_STREAM_STATE_FAILED = 3 -}; - -/** - * Local audio state error codes. - */ -enum LOCAL_AUDIO_STREAM_REASON { - /** - * 0: The local audio is normal. - */ - LOCAL_AUDIO_STREAM_REASON_OK = 0, - /** - * 1: No specified reason for the local audio failure. Remind your users to try to rejoin the channel. - */ - LOCAL_AUDIO_STREAM_REASON_FAILURE = 1, - /** - * 2: No permission to use the local audio device. Remind your users to grant permission. - */ - LOCAL_AUDIO_STREAM_REASON_DEVICE_NO_PERMISSION = 2, - /** - * 3: (Android and iOS only) The local audio capture device is used. Remind your users to check - * whether another application occupies the microphone. Local audio capture automatically resume - * after the microphone is idle for about five seconds. You can also try to rejoin the channel - * after the microphone is idle. - */ - LOCAL_AUDIO_STREAM_REASON_DEVICE_BUSY = 3, - /** - * 4: The local audio capture failed. - */ - LOCAL_AUDIO_STREAM_REASON_RECORD_FAILURE = 4, - /** - * 5: The local audio encoding failed. - */ - LOCAL_AUDIO_STREAM_REASON_ENCODE_FAILURE = 5, - /** 6: The SDK cannot find the local audio recording device. - */ - LOCAL_AUDIO_STREAM_REASON_NO_RECORDING_DEVICE = 6, - /** 7: The SDK cannot find the local audio playback device. - */ - LOCAL_AUDIO_STREAM_REASON_NO_PLAYOUT_DEVICE = 7, - /** - * 8: The local audio capturing is interrupted by the system call. - */ - LOCAL_AUDIO_STREAM_REASON_INTERRUPTED = 8, - /** 9: An invalid audio capture device ID. - */ - LOCAL_AUDIO_STREAM_REASON_RECORD_INVALID_ID = 9, - /** 10: An invalid audio playback device ID. - */ - LOCAL_AUDIO_STREAM_REASON_PLAYOUT_INVALID_ID = 10, -}; - -/** Local video state types. - */ -enum LOCAL_VIDEO_STREAM_STATE { - /** - * 0: The local video is in the initial state. - */ - LOCAL_VIDEO_STREAM_STATE_STOPPED = 0, - /** - * 1: The local video capturing device starts successfully. The SDK also reports this state when - * you call `startScreenCaptureByWindowId` to share a maximized window. - */ - LOCAL_VIDEO_STREAM_STATE_CAPTURING = 1, - /** - * 2: The first video frame is successfully encoded. - */ - LOCAL_VIDEO_STREAM_STATE_ENCODING = 2, - /** - * 3: Fails to start the local video. - */ - LOCAL_VIDEO_STREAM_STATE_FAILED = 3 -}; - -/** - * Local video state error codes. - */ -enum LOCAL_VIDEO_STREAM_REASON { - /** - * 0: The local video is normal. - */ - LOCAL_VIDEO_STREAM_REASON_OK = 0, - /** - * 1: No specified reason for the local video failure. - */ - LOCAL_VIDEO_STREAM_REASON_FAILURE = 1, - /** - * 2: No permission to use the local video capturing device. Remind the user to grant permission - * and rejoin the channel. - */ - LOCAL_VIDEO_STREAM_REASON_DEVICE_NO_PERMISSION = 2, - /** - * 3: The local video capturing device is in use. Remind the user to check whether another - * application occupies the camera. - */ - LOCAL_VIDEO_STREAM_REASON_DEVICE_BUSY = 3, - /** - * 4: The local video capture fails. Remind the user to check whether the video capture device - * is working properly or the camera is occupied by another application, and then to rejoin the - * channel. - */ - LOCAL_VIDEO_STREAM_REASON_CAPTURE_FAILURE = 4, - /** - * 5: The local video encoder is not supported. - */ - LOCAL_VIDEO_STREAM_REASON_CODEC_NOT_SUPPORT = 5, - /** - * 6: (iOS only) The app is in the background. Remind the user that video capture cannot be - * performed normally when the app is in the background. - */ - LOCAL_VIDEO_STREAM_REASON_CAPTURE_INBACKGROUND = 6, - /** - * 7: (iOS only) The current application window is running in Slide Over, Split View, or Picture - * in Picture mode, and another app is occupying the camera. Remind the user that the application - * cannot capture video properly when the app is running in Slide Over, Split View, or Picture in - * Picture mode and another app is occupying the camera. - */ - LOCAL_VIDEO_STREAM_REASON_CAPTURE_MULTIPLE_FOREGROUND_APPS = 7, - /** - * 8: Fails to find a local video capture device. Remind the user to check whether the camera is - * connected to the device properly or the camera is working properly, and then to rejoin the - * channel. - */ - LOCAL_VIDEO_STREAM_REASON_DEVICE_NOT_FOUND = 8, - /** - * 9: (macOS only) The video capture device currently in use is disconnected (such as being - * unplugged). - */ - LOCAL_VIDEO_STREAM_REASON_DEVICE_DISCONNECTED = 9, - /** - * 10: (macOS and Windows only) The SDK cannot find the video device in the video device list. - * Check whether the ID of the video device is valid. - */ - LOCAL_VIDEO_STREAM_REASON_DEVICE_INVALID_ID = 10, - /** - * 14: (Android only) Video capture was interrupted, possibly due to the camera being occupied - * or some policy reasons such as background termination. - */ - LOCAL_VIDEO_STREAM_REASON_DEVICE_INTERRUPT = 14, - /** - * 15: (Android only) The device may need to be shut down and restarted to restore camera function, - * or there may be a persistent hardware problem. - */ - LOCAL_VIDEO_STREAM_REASON_DEVICE_FATAL_ERROR = 15, - /** - * 101: The current video capture device is unavailable due to excessive system pressure. - */ - LOCAL_VIDEO_STREAM_REASON_DEVICE_SYSTEM_PRESSURE = 101, - /** - * 11: (macOS only) The shared window is minimized when you call `startScreenCaptureByWindowId` - * to share a window. The SDK cannot share a minimized window. You can cancel the minimization - * of this window at the application layer, for example by maximizing this window. - */ - LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_WINDOW_MINIMIZED = 11, - /** - * 12: (macOS and Windows only) The error code indicates that a window shared by the window ID - * has been closed or a full-screen window shared by the window ID has exited full-screen mode. - * After exiting full-screen mode, remote users cannot see the shared window. To prevent remote - * users from seeing a black screen, Agora recommends that you immediately stop screen sharing. - * - * Common scenarios for reporting this error code: - * - When the local user closes the shared window, the SDK reports this error code. - * - The local user shows some slides in full-screen mode first, and then shares the windows of - * the slides. After the user exits full-screen mode, the SDK reports this error code. - * - The local user watches a web video or reads a web document in full-screen mode first, and - * then shares the window of the web video or document. After the user exits full-screen mode, - * the SDK reports this error code. - */ - LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_WINDOW_CLOSED = 12, - /** 13: The local screen capture window is occluded. */ - LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_WINDOW_OCCLUDED = 13, - /** 20: The local screen capture window is not supported. */ - LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_WINDOW_NOT_SUPPORTED = 20, - /** 21: The screen capture fails. */ - LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_FAILURE = 21, - /** 22: No permision to capture screen. */ - LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_NO_PERMISSION = 22, - /** - * 24: (Windows Only) An unexpected error (possibly due to window block failure) occurs during the screen - * sharing process, resulting in performance degradation. However, the screen sharing process itself is - * functioning normally. - */ - LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_AUTO_FALLBACK = 24, - /** 25: (Windows only) The local screen capture window is currently hidden and not visible on the desktop. */ - LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_WINDOW_HIDDEN = 25, - /** 26: (Windows only) The local screen capture window is recovered from its hidden state. */ - LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_WINDOW_RECOVER_FROM_HIDDEN = 26, - /** 27: (Windows and macOS only) The window is recovered from miniminzed */ - LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_WINDOW_RECOVER_FROM_MINIMIZED = 27, - /** - * 28: The screen capture paused. - * - * Common scenarios for reporting this error code: - * - When the desktop switch to the secure desktop such as UAC dialog or the Winlogon desktop on - * Windows platform, the SDK reports this error code. - */ - LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_PAUSED = 28, - /** 29: The screen capture is resumed. */ - LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_RESUMED = 29, - /** 30: The shared display has been disconnected */ - LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_DISPLAY_DISCONNECTED = 30, - /* 30: (HMOS only) ScreenCapture stopped by user */ - LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_STOPPED_BY_USER = 31, - /* 31: (HMOS only) ScreenCapture interrupted by other screen capture */ - LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_INTERRUPTED_BY_OTHER = 32, - /* 32: (HMOS only) ScreenCapture stopped by SIM call */ - LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_STOPPED_BY_CALL = 33, -}; - -/** - * Remote audio states. - */ -enum REMOTE_AUDIO_STATE -{ - /** - * 0: The remote audio is in the default state. The SDK reports this state in the case of - * `REMOTE_AUDIO_REASON_LOCAL_MUTED(3)`, `REMOTE_AUDIO_REASON_REMOTE_MUTED(5)`, or - * `REMOTE_AUDIO_REASON_REMOTE_OFFLINE(7)`. - */ - REMOTE_AUDIO_STATE_STOPPED = 0, // Default state, audio is started or remote user disabled/muted audio stream - /** - * 1: The first remote audio packet is received. - */ - REMOTE_AUDIO_STATE_STARTING = 1, // The first audio frame packet has been received - /** - * 2: The remote audio stream is decoded and plays normally. The SDK reports this state in the case of - * `REMOTE_AUDIO_REASON_NETWORK_RECOVERY(2)`, `REMOTE_AUDIO_REASON_LOCAL_UNMUTED(4)`, or - * `REMOTE_AUDIO_REASON_REMOTE_UNMUTED(6)`. - */ - REMOTE_AUDIO_STATE_DECODING = 2, // The first remote audio frame has been decoded or fronzen state ends - /** - * 3: The remote audio is frozen. The SDK reports this state in the case of - * `REMOTE_AUDIO_REASON_NETWORK_CONGESTION(1)`. - */ - REMOTE_AUDIO_STATE_FROZEN = 3, // Remote audio is frozen, probably due to network issue - /** - * 4: The remote audio fails to start. The SDK reports this state in the case of - * `REMOTE_AUDIO_REASON_INTERNAL(0)`. - */ - REMOTE_AUDIO_STATE_FAILED = 4, // Remote audio play failed -}; - -/** - * Reasons for the remote audio state change. - */ -enum REMOTE_AUDIO_STATE_REASON -{ - /** - * 0: The SDK reports this reason when the video state changes. - */ - REMOTE_AUDIO_REASON_INTERNAL = 0, - /** - * 1: Network congestion. - */ - REMOTE_AUDIO_REASON_NETWORK_CONGESTION = 1, - /** - * 2: Network recovery. - */ - REMOTE_AUDIO_REASON_NETWORK_RECOVERY = 2, - /** - * 3: The local user stops receiving the remote audio stream or - * disables the audio module. - */ - REMOTE_AUDIO_REASON_LOCAL_MUTED = 3, - /** - * 4: The local user resumes receiving the remote audio stream or - * enables the audio module. - */ - REMOTE_AUDIO_REASON_LOCAL_UNMUTED = 4, - /** - * 5: The remote user stops sending the audio stream or disables the - * audio module. - */ - REMOTE_AUDIO_REASON_REMOTE_MUTED = 5, - /** - * 6: The remote user resumes sending the audio stream or enables the - * audio module. - */ - REMOTE_AUDIO_REASON_REMOTE_UNMUTED = 6, - /** - * 7: The remote user leaves the channel. - */ - REMOTE_AUDIO_REASON_REMOTE_OFFLINE = 7, - /** - * 8: The local user does not receive any audio packet from remote user. - */ - REMOTE_AUDIO_REASON_NO_PACKET_RECEIVE = 8, - /** - * 9: The local user receives remote audio packet but fails to play. - */ - REMOTE_AUDIO_REASON_LOCAL_PLAY_FAILED = 9, -}; - -/** - * The state of the remote video. - */ -enum REMOTE_VIDEO_STATE { - /** - * 0: The remote video is in the default state. The SDK reports this state in the case of - * `REMOTE_VIDEO_STATE_REASON_LOCAL_MUTED (3)`, `REMOTE_VIDEO_STATE_REASON_REMOTE_MUTED (5)`, - * `REMOTE_VIDEO_STATE_REASON_REMOTE_OFFLINE (7)`, or `REMOTE_VIDEO_STATE_REASON_AUDIO_FALLBACK (8)`. - */ - REMOTE_VIDEO_STATE_STOPPED = 0, - /** - * 1: The first remote video packet is received. - */ - REMOTE_VIDEO_STATE_STARTING = 1, - /** - * 2: The remote video stream is decoded and plays normally. The SDK reports this state in the case of - * `REMOTE_VIDEO_STATE_REASON_NETWORK_RECOVERY (2)`, `REMOTE_VIDEO_STATE_REASON_LOCAL_UNMUTED (4)`, - * `REMOTE_VIDEO_STATE_REASON_REMOTE_UNMUTED (6)`, or `REMOTE_VIDEO_STATE_REASON_AUDIO_FALLBACK_RECOVERY (9)`. - */ - REMOTE_VIDEO_STATE_DECODING = 2, - /** 3: The remote video is frozen, probably due to - * #REMOTE_VIDEO_STATE_REASON_NETWORK_CONGESTION (1). - */ - REMOTE_VIDEO_STATE_FROZEN = 3, - /** 4: The remote video fails to start. The SDK reports this state in the case of - * `REMOTE_VIDEO_STATE_REASON_INTERNAL (0)`. - */ - REMOTE_VIDEO_STATE_FAILED = 4, -}; -/** - * The reason for the remote video state change. - */ -enum REMOTE_VIDEO_STATE_REASON { - /** - * 0: The SDK reports this reason when the video state changes. - */ - REMOTE_VIDEO_STATE_REASON_INTERNAL = 0, - /** - * 1: Network congestion. - */ - REMOTE_VIDEO_STATE_REASON_NETWORK_CONGESTION = 1, - /** - * 2: Network recovery. - */ - REMOTE_VIDEO_STATE_REASON_NETWORK_RECOVERY = 2, - /** - * 3: The local user stops receiving the remote video stream or disables the video module. - */ - REMOTE_VIDEO_STATE_REASON_LOCAL_MUTED = 3, - /** - * 4: The local user resumes receiving the remote video stream or enables the video module. - */ - REMOTE_VIDEO_STATE_REASON_LOCAL_UNMUTED = 4, - /** - * 5: The remote user stops sending the video stream or disables the video module. - */ - REMOTE_VIDEO_STATE_REASON_REMOTE_MUTED = 5, - /** - * 6: The remote user resumes sending the video stream or enables the video module. - */ - REMOTE_VIDEO_STATE_REASON_REMOTE_UNMUTED = 6, - /** - * 7: The remote user leaves the channel. - */ - REMOTE_VIDEO_STATE_REASON_REMOTE_OFFLINE = 7, - /** 8: The remote audio-and-video stream falls back to the audio-only stream - * due to poor network conditions. - */ - REMOTE_VIDEO_STATE_REASON_AUDIO_FALLBACK = 8, - /** 9: The remote audio-only stream switches back to the audio-and-video - * stream after the network conditions improve. - */ - REMOTE_VIDEO_STATE_REASON_AUDIO_FALLBACK_RECOVERY = 9, - /** (Internal use only) 10: The remote video stream type change to low stream type - */ - REMOTE_VIDEO_STATE_REASON_VIDEO_STREAM_TYPE_CHANGE_TO_LOW = 10, - /** (Internal use only) 11: The remote video stream type change to high stream type - */ - REMOTE_VIDEO_STATE_REASON_VIDEO_STREAM_TYPE_CHANGE_TO_HIGH = 11, - /** (iOS only) 12: The app of the remote user is in background. - */ - REMOTE_VIDEO_STATE_REASON_SDK_IN_BACKGROUND = 12, - - /** 13: The remote video stream is not supported by the decoder - */ - REMOTE_VIDEO_STATE_REASON_CODEC_NOT_SUPPORT = 13, - -}; - -/** - * The remote user state information. - */ -enum REMOTE_USER_STATE { - /** - * The remote user has muted the audio. - */ - USER_STATE_MUTE_AUDIO = (1 << 0), - /** - * The remote user has muted the video. - */ - USER_STATE_MUTE_VIDEO = (1 << 1), - /** - * The remote user has enabled the video, which includes video capturing and encoding. - */ - USER_STATE_ENABLE_VIDEO = (1 << 4), - /** - * The remote user has enabled the local video capturing. - */ - USER_STATE_ENABLE_LOCAL_VIDEO = (1 << 8), -}; - -/** - * The definition of the VideoTrackInfo struct, which contains information of - * the video track. - */ -struct VideoTrackInfo { - VideoTrackInfo() - : isLocal(false), ownerUid(0), trackId(0), channelId(OPTIONAL_NULLPTR) - , codecType(VIDEO_CODEC_H265) - , encodedFrameOnly(false), sourceType(VIDEO_SOURCE_CAMERA_PRIMARY) - , observationPosition(agora::media::base::POSITION_POST_CAPTURER) {} - /** - * Whether the video track is local or remote. - * - true: The video track is local. - * - false: The video track is remote. - */ - bool isLocal; - /** - * ID of the user who publishes the video track. - */ - uid_t ownerUid; - /** - * ID of the video track. - */ - track_id_t trackId; - /** - * The channel ID of the video track. - */ - const char* channelId; - /** - * The video codec type: #VIDEO_CODEC_TYPE. - */ - VIDEO_CODEC_TYPE codecType; - /** - * Whether the video track contains encoded video frame only. - * - true: The video track contains encoded video frame only. - * - false: The video track does not contain encoded video frame only. - */ - bool encodedFrameOnly; - /** - * The video source type: #VIDEO_SOURCE_TYPE - */ - VIDEO_SOURCE_TYPE sourceType; - /** - * the frame position for the video observer: #VIDEO_MODULE_POSITION - */ - uint32_t observationPosition; -}; - -/** - * The downscale level of the remote video stream . The higher the downscale level, the more the video downscales. - */ -enum REMOTE_VIDEO_DOWNSCALE_LEVEL { - /** - * No downscale. - */ - REMOTE_VIDEO_DOWNSCALE_LEVEL_NONE, - /** - * Downscale level 1. - */ - REMOTE_VIDEO_DOWNSCALE_LEVEL_1, - /** - * Downscale level 2. - */ - REMOTE_VIDEO_DOWNSCALE_LEVEL_2, - /** - * Downscale level 3. - */ - REMOTE_VIDEO_DOWNSCALE_LEVEL_3, - /** - * Downscale level 4. - */ - REMOTE_VIDEO_DOWNSCALE_LEVEL_4, -}; - -/** - * The volume information of users. - */ -struct AudioVolumeInfo { - /** - * User ID of the speaker. - * - In the local user's callback, `uid` = 0. - * - In the remote users' callback, `uid` is the user ID of a remote user whose instantaneous - * volume is one of the three highest. - */ - uid_t uid; - /** - * The volume of the user. The value ranges between 0 (the lowest volume) and 255 (the highest - * volume). If the user calls `startAudioMixing`, the value of volume is the volume after audio - * mixing. - */ - unsigned int volume; // [0,255] - /** - * Voice activity status of the local user. - * - 0: The local user is not speaking. - * - 1: The local user is speaking. - * @note - * - The `vad` parameter does not report the voice activity status of remote users. In a remote - * user's callback, the value of `vad` is always 1. - * - To use this parameter, you must set `reportVad` to true when calling `enableAudioVolumeIndication`. - */ - unsigned int vad; - /** - * The voice pitch (Hz) of the local user. The value ranges between 0.0 and 4000.0. - * @note The `voicePitch` parameter does not report the voice pitch of remote users. In the - * remote users' callback, the value of `voicePitch` is always 0.0. - */ - double voicePitch; - - AudioVolumeInfo() : uid(0), volume(0), vad(0), voicePitch(0.0) {} -}; - -/** - * The audio device information. - */ -struct DeviceInfo { - /* - * Whether the audio device supports ultra-low-latency capture and playback: - * - `true`: The device supports ultra-low-latency capture and playback. - * - `false`: The device does not support ultra-low-latency capture and playback. - */ - bool isLowLatencyAudioSupported; - - DeviceInfo() : isLowLatencyAudioSupported(false) {} -}; - -/** - * The definition of the IPacketObserver struct. - */ -class IPacketObserver { - public: - virtual ~IPacketObserver() {} - /** - * The definition of the Packet struct. - */ - struct Packet { - /** - * The buffer address of the sent or received data. - * @note Agora recommends setting `buffer` to a value larger than 2048 bytes. Otherwise, you - * may encounter undefined behaviors (such as crashes). - */ - const unsigned char* buffer; - /** - * The buffer size of the sent or received data. - */ - unsigned int size; - - Packet() : buffer(OPTIONAL_NULLPTR), size(0) {} - }; - /** - * Occurs when the SDK is ready to send the audio packet. - * @param packet The audio packet to be sent: Packet. - * @return Whether to send the audio packet: - * - true: Send the packet. - * - false: Do not send the packet, in which case the audio packet will be discarded. - */ - virtual bool onSendAudioPacket(Packet& packet) = 0; - /** - * Occurs when the SDK is ready to send the video packet. - * @param packet The video packet to be sent: Packet. - * @return Whether to send the video packet: - * - true: Send the packet. - * - false: Do not send the packet, in which case the audio packet will be discarded. - */ - virtual bool onSendVideoPacket(Packet& packet) = 0; - /** - * Occurs when the audio packet is received. - * @param packet The received audio packet: Packet. - * @return Whether to process the audio packet: - * - true: Process the packet. - * - false: Do not process the packet, in which case the audio packet will be discarded. - */ - virtual bool onReceiveAudioPacket(Packet& packet) = 0; - /** - * Occurs when the video packet is received. - * @param packet The received video packet: Packet. - * @return Whether to process the audio packet: - * - true: Process the packet. - * - false: Do not process the packet, in which case the video packet will be discarded. - */ - virtual bool onReceiveVideoPacket(Packet& packet) = 0; -}; - -/** - * Audio sample rate types. - */ -enum AUDIO_SAMPLE_RATE_TYPE { - /** - * 32000: 32 KHz. - */ - AUDIO_SAMPLE_RATE_32000 = 32000, - /** - * 44100: 44.1 KHz. - */ - AUDIO_SAMPLE_RATE_44100 = 44100, - /** - * 48000: 48 KHz. - */ - AUDIO_SAMPLE_RATE_48000 = 48000, -}; -/** - * The codec type of the output video. - */ -enum VIDEO_CODEC_TYPE_FOR_STREAM { - /** - * 1: H.264. - */ - VIDEO_CODEC_H264_FOR_STREAM = 1, - /** - * 2: H.265. - */ - VIDEO_CODEC_H265_FOR_STREAM = 2, -}; - -/** - * Video codec profile types. - */ -enum VIDEO_CODEC_PROFILE_TYPE { - /** - * 66: Baseline video codec profile. Generally used in video calls on mobile phones. - */ - VIDEO_CODEC_PROFILE_BASELINE = 66, - /** - * 77: Main video codec profile. Generally used in mainstream electronics, such as MP4 players, portable video players, PSP, and iPads. - */ - VIDEO_CODEC_PROFILE_MAIN = 77, - /** - * 100: High video codec profile. Generally used in high-resolution broadcasts or television. - */ - VIDEO_CODEC_PROFILE_HIGH = 100, -}; - - -/** - * Self-defined audio codec profile. - */ -enum AUDIO_CODEC_PROFILE_TYPE { - /** - * 0: LC-AAC. - */ - AUDIO_CODEC_PROFILE_LC_AAC = 0, - /** - * 1: HE-AAC. - */ - AUDIO_CODEC_PROFILE_HE_AAC = 1, - /** - * 2: HE-AAC v2. - */ - AUDIO_CODEC_PROFILE_HE_AAC_V2 = 2, -}; - -/** - * Local audio statistics. - */ -struct LocalAudioStats -{ - /** - * The number of audio channels. - */ - int numChannels; - /** - * The sampling rate (Hz) of sending the local user's audio stream. - */ - int sentSampleRate; - /** - * The average bitrate (Kbps) of sending the local user's audio stream. - */ - int sentBitrate; - /** - * The internal payload codec. - */ - int internalCodec; - /** - * The packet loss rate (%) from the local client to the Agora server before applying the anti-packet loss strategies. - */ - unsigned short txPacketLossRate; - /** - * The audio delay of the device, contains record and playout delay - */ - int audioDeviceDelay; - /** - * The playout delay of the device - */ - int audioPlayoutDelay; - /** - * The signal delay estimated from audio in-ear monitoring (ms). - */ - int earMonitorDelay; - /** - * The signal delay estimated during the AEC process from nearin and farin (ms). - */ - int aecEstimatedDelay; -}; - - -/** - * States of the Media Push. - */ -enum RTMP_STREAM_PUBLISH_STATE { - /** - * 0: The Media Push has not started or has ended. This state is also triggered after you remove a RTMP or RTMPS stream from the CDN by calling `removePublishStreamUrl`. - */ - RTMP_STREAM_PUBLISH_STATE_IDLE = 0, - /** - * 1: The SDK is connecting to Agora's streaming server and the CDN server. This state is triggered after you call the `addPublishStreamUrl` method. - */ - RTMP_STREAM_PUBLISH_STATE_CONNECTING = 1, - /** - * 2: The RTMP or RTMPS streaming publishes. The SDK successfully publishes the RTMP or RTMPS streaming and returns this state. - */ - RTMP_STREAM_PUBLISH_STATE_RUNNING = 2, - /** - * 3: The RTMP or RTMPS streaming is recovering. When exceptions occur to the CDN, or the streaming is interrupted, the SDK tries to resume RTMP or RTMPS streaming and returns this state. - * - If the SDK successfully resumes the streaming, #RTMP_STREAM_PUBLISH_STATE_RUNNING (2) returns. - * - If the streaming does not resume within 60 seconds or server errors occur, #RTMP_STREAM_PUBLISH_STATE_FAILURE (4) returns. You can also reconnect to the server by calling the `removePublishStreamUrl` and `addPublishStreamUrl` methods. - */ - RTMP_STREAM_PUBLISH_STATE_RECOVERING = 3, - /** - * 4: The RTMP or RTMPS streaming fails. See the `errCode` parameter for the detailed error information. You can also call the `addPublishStreamUrl` method to publish the RTMP or RTMPS streaming again. - */ - RTMP_STREAM_PUBLISH_STATE_FAILURE = 4, - /** - * 5: The SDK is disconnecting to Agora's streaming server and the CDN server. This state is triggered after you call the `removePublishStreamUrl` method. - */ - RTMP_STREAM_PUBLISH_STATE_DISCONNECTING = 5, -}; - -/** - * Error codes of the RTMP or RTMPS streaming. - */ -enum RTMP_STREAM_PUBLISH_REASON { - /** - * 0: The RTMP or RTMPS streaming publishes successfully. - */ - RTMP_STREAM_PUBLISH_REASON_OK = 0, - /** - * 1: Invalid argument used. If, for example, you do not call the `setLiveTranscoding` method to configure the LiveTranscoding parameters before calling the addPublishStreamUrl method, - * the SDK returns this error. Check whether you set the parameters in the `setLiveTranscoding` method properly. - */ - RTMP_STREAM_PUBLISH_REASON_INVALID_ARGUMENT = 1, - /** - * 2: The RTMP or RTMPS streaming is encrypted and cannot be published. - */ - RTMP_STREAM_PUBLISH_REASON_ENCRYPTED_STREAM_NOT_ALLOWED = 2, - /** - * 3: Timeout for the RTMP or RTMPS streaming. Call the `addPublishStreamUrl` method to publish the streaming again. - */ - RTMP_STREAM_PUBLISH_REASON_CONNECTION_TIMEOUT = 3, - /** - * 4: An error occurs in Agora's streaming server. Call the `addPublishStreamUrl` method to publish the streaming again. - */ - RTMP_STREAM_PUBLISH_REASON_INTERNAL_SERVER_ERROR = 4, - /** - * 5: An error occurs in the CDN server. - */ - RTMP_STREAM_PUBLISH_REASON_RTMP_SERVER_ERROR = 5, - /** - * 6: The RTMP or RTMPS streaming publishes too frequently. - */ - RTMP_STREAM_PUBLISH_REASON_TOO_OFTEN = 6, - /** - * 7: The host publishes more than 10 URLs. Delete the unnecessary URLs before adding new ones. - */ - RTMP_STREAM_PUBLISH_REASON_REACH_LIMIT = 7, - /** - * 8: The host manipulates other hosts' URLs. Check your app logic. - */ - RTMP_STREAM_PUBLISH_REASON_NOT_AUTHORIZED = 8, - /** - * 9: Agora's server fails to find the RTMP or RTMPS streaming. - */ - RTMP_STREAM_PUBLISH_REASON_STREAM_NOT_FOUND = 9, - /** - * 10: The format of the RTMP or RTMPS streaming URL is not supported. Check whether the URL format is correct. - */ - RTMP_STREAM_PUBLISH_REASON_FORMAT_NOT_SUPPORTED = 10, - /** - * 11: The user role is not host, so the user cannot use the CDN live streaming function. Check your application code logic. - */ - RTMP_STREAM_PUBLISH_REASON_NOT_BROADCASTER = 11, // Note: match to ERR_PUBLISH_STREAM_NOT_BROADCASTER in AgoraBase.h - /** - * 13: The `updateRtmpTranscoding` or `setLiveTranscoding` method is called to update the transcoding configuration in a scenario where there is streaming without transcoding. Check your application code logic. - */ - RTMP_STREAM_PUBLISH_REASON_TRANSCODING_NO_MIX_STREAM = 13, // Note: match to ERR_PUBLISH_STREAM_TRANSCODING_NO_MIX_STREAM in AgoraBase.h - /** - * 14: Errors occurred in the host's network. - */ - RTMP_STREAM_PUBLISH_REASON_NET_DOWN = 14, // Note: match to ERR_NET_DOWN in AgoraBase.h - /** - * 15: Your App ID does not have permission to use the CDN live streaming function. - */ - RTMP_STREAM_PUBLISH_REASON_INVALID_APPID = 15, // Note: match to ERR_PUBLISH_STREAM_APPID_INVALID in AgoraBase.h - /** invalid privilege. */ - RTMP_STREAM_PUBLISH_REASON_INVALID_PRIVILEGE = 16, - /** - * 100: The streaming has been stopped normally. After you call `removePublishStreamUrl` to stop streaming, the SDK returns this value. - */ - RTMP_STREAM_UNPUBLISH_REASON_OK = 100, -}; - -/** Events during the RTMP or RTMPS streaming. */ -enum RTMP_STREAMING_EVENT { - /** - * 1: An error occurs when you add a background image or a watermark image to the RTMP or RTMPS stream. - */ - RTMP_STREAMING_EVENT_FAILED_LOAD_IMAGE = 1, - /** - * 2: The streaming URL is already being used for CDN live streaming. If you want to start new streaming, use a new streaming URL. - */ - RTMP_STREAMING_EVENT_URL_ALREADY_IN_USE = 2, - /** - * 3: The feature is not supported. - */ - RTMP_STREAMING_EVENT_ADVANCED_FEATURE_NOT_SUPPORT = 3, - /** - * 4: Client request too frequently. - */ - RTMP_STREAMING_EVENT_REQUEST_TOO_OFTEN = 4, -}; - -/** - * Image properties. - */ -typedef struct RtcImage { - /** - *The HTTP/HTTPS URL address of the image in the live video. The maximum length of this parameter is 1024 bytes. - */ - const char* url; - /** - * The x coordinate (pixel) of the image on the video frame (taking the upper left corner of the video frame as the origin). - */ - int x; - /** - * The y coordinate (pixel) of the image on the video frame (taking the upper left corner of the video frame as the origin). - */ - int y; - /** - * The width (pixel) of the image on the video frame. - */ - int width; - /** - * The height (pixel) of the image on the video frame. - */ - int height; - /** - * The layer index of the watermark or background image. When you use the watermark array to add - * a watermark or multiple watermarks, you must pass a value to `zOrder` in the range [1,255]; - * otherwise, the SDK reports an error. In other cases, zOrder can optionally be passed in the - * range [0,255], with 0 being the default value. 0 means the bottom layer and 255 means the top - * layer. - */ - int zOrder; - /** The transparency level of the image. The value ranges between 0.0 and 1.0: - * - * - 0.0: Completely transparent. - * - 1.0: (Default) Opaque. - */ - double alpha; - - RtcImage() : url(OPTIONAL_NULLPTR), x(0), y(0), width(0), height(0), zOrder(0), alpha(1.0) {} -} RtcImage; -/** - * The configuration for advanced features of the RTMP or RTMPS streaming with transcoding. - * - * If you want to enable the advanced features of streaming with transcoding, contact support@agora.io. - */ -struct LiveStreamAdvancedFeature { - LiveStreamAdvancedFeature() : featureName(OPTIONAL_NULLPTR), opened(false) {} - LiveStreamAdvancedFeature(const char* feat_name, bool open) : featureName(feat_name), opened(open) {} - /** The advanced feature for high-quality video with a lower bitrate. */ - // static const char* LBHQ = "lbhq"; - /** The advanced feature for the optimized video encoder. */ - // static const char* VEO = "veo"; - - /** - * The feature names, including LBHQ (high-quality video with a lower bitrate) and VEO (optimized video encoder). - */ - const char* featureName; - - /** - * Whether to enable the advanced features of streaming with transcoding: - * - `true`: Enable the advanced feature. - * - `false`: (Default) Disable the advanced feature. - */ - bool opened; -} ; - -/** - * Connection state types. - */ -enum CONNECTION_STATE_TYPE -{ - /** - * 1: The SDK is disconnected from the Agora edge server. The state indicates the SDK is in one of the following phases: - * - The initial state before calling the `joinChannel` method. - * - The app calls the `leaveChannel` method. - */ - CONNECTION_STATE_DISCONNECTED = 1, - /** - * 2: The SDK is connecting to the Agora edge server. This state indicates that the SDK is - * establishing a connection with the specified channel after the app calls `joinChannel`. - * - If the SDK successfully joins the channel, it triggers the `onConnectionStateChanged` - * callback and the connection state switches to `CONNECTION_STATE_CONNECTED`. - * - After the connection is established, the SDK also initializes the media and triggers - * `onJoinChannelSuccess` when everything is ready. - */ - CONNECTION_STATE_CONNECTING = 2, - /** - * 3: The SDK is connected to the Agora edge server. This state also indicates that the user - * has joined a channel and can now publish or subscribe to a media stream in the channel. - * If the connection to the Agora edge server is lost because, for example, the network is down - * or switched, the SDK automatically tries to reconnect and triggers `onConnectionStateChanged` - * that indicates the connection state switches to `CONNECTION_STATE_RECONNECTING`. - */ - CONNECTION_STATE_CONNECTED = 3, - /** - * 4: The SDK keeps reconnecting to the Agora edge server. The SDK keeps rejoining the channel - * after being disconnected from a joined channel because of network issues. - * - If the SDK cannot rejoin the channel within 10 seconds, it triggers `onConnectionLost`, - * stays in the `CONNECTION_STATE_RECONNECTING` state, and keeps rejoining the channel. - * - If the SDK fails to rejoin the channel 20 minutes after being disconnected from the Agora - * edge server, the SDK triggers the `onConnectionStateChanged` callback, switches to the - * `CONNECTION_STATE_FAILED` state, and stops rejoining the channel. - */ - CONNECTION_STATE_RECONNECTING = 4, - /** - * 5: The SDK fails to connect to the Agora edge server or join the channel. This state indicates - * that the SDK stops trying to rejoin the channel. You must call `leaveChannel` to leave the - * channel. - * - You can call `joinChannel` to rejoin the channel. - * - If the SDK is banned from joining the channel by the Agora edge server through the RESTful - * API, the SDK triggers the `onConnectionStateChanged` callback. - */ - CONNECTION_STATE_FAILED = 5, -}; - -/** - * Transcoding configurations of each host. - */ -struct TranscodingUser { - /** - * The user ID of the host. - */ - uid_t uid; - /** - * The x coordinate (pixel) of the host's video on the output video frame (taking the upper left corner of the video frame as the origin). The value range is [0, width], where width is the `width` set in `LiveTranscoding`. - */ - int x; - /** - * The y coordinate (pixel) of the host's video on the output video frame (taking the upper left corner of the video frame as the origin). The value range is [0, height], where height is the `height` set in `LiveTranscoding`. - */ - int y; - /** - * The width (pixel) of the host's video. - */ - int width; - /** - * The height (pixel) of the host's video. - */ - int height; - /** - * The layer index number of the host's video. The value range is [0, 100]. - * - 0: (Default) The host's video is the bottom layer. - * - 100: The host's video is the top layer. - * - * If the value is beyond this range, the SDK reports the error code `ERR_INVALID_ARGUMENT`. - */ - int zOrder; - /** - * The transparency of the host's video. The value range is [0.0, 1.0]. - * - 0.0: Completely transparent. - * - 1.0: (Default) Opaque. - */ - double alpha; - /** - * The audio channel used by the host's audio in the output audio. The default value is 0, and the value range is [0, 5]. - * - `0`: (Recommended) The defaut setting, which supports dual channels at most and depends on the upstream of the host. - * - `1`: The host's audio uses the FL audio channel. If the host's upstream uses multiple audio channels, the Agora server mixes them into mono first. - * - `2`: The host's audio uses the FC audio channel. If the host's upstream uses multiple audio channels, the Agora server mixes them into mono first. - * - `3`: The host's audio uses the FR audio channel. If the host's upstream uses multiple audio channels, the Agora server mixes them into mono first. - * - `4`: The host's audio uses the BL audio channel. If the host's upstream uses multiple audio channels, the Agora server mixes them into mono first. - * - `5`: The host's audio uses the BR audio channel. If the host's upstream uses multiple audio channels, the Agora server mixes them into mono first. - * - `0xFF` or a value greater than 5: The host's audio is muted, and the Agora server removes the host's audio. - * - * @note If the value is not `0`, a special player is required. - */ - int audioChannel; - - TranscodingUser() - : uid(0), - x(0), - y(0), - width(0), - height(0), - zOrder(0), - alpha(1.0), - audioChannel(0) {} -}; - -/** - * Transcoding configurations for Media Push. - */ -struct LiveTranscoding { - /** The width of the video in pixels. The default value is 360. - * - When pushing video streams to the CDN, the value range of `width` is [64,1920]. - * If the value is less than 64, Agora server automatically adjusts it to 64; if the - * value is greater than 1920, Agora server automatically adjusts it to 1920. - * - When pushing audio streams to the CDN, set `width` and `height` as 0. - */ - int width; - /** The height of the video in pixels. The default value is 640. - * - When pushing video streams to the CDN, the value range of `height` is [64,1080]. - * If the value is less than 64, Agora server automatically adjusts it to 64; if the - * value is greater than 1080, Agora server automatically adjusts it to 1080. - * - When pushing audio streams to the CDN, set `width` and `height` as 0. - */ - int height; - /** Bitrate of the CDN live output video stream. The default value is 400 Kbps. - - Set this parameter according to the Video Bitrate Table. If you set a bitrate beyond the proper range, the SDK automatically adapts it to a value within the range. - */ - int videoBitrate; - /** Frame rate of the output video stream set for the CDN live streaming. The default value is 15 fps, and the value range is (0,30]. - - @note The Agora server adjusts any value over 30 to 30. - */ - int videoFramerate; - - /** **DEPRECATED** Latency mode: - - - true: Low latency with unassured quality. - - false: (Default) High latency with assured quality. - */ - bool lowLatency; - - /** Video GOP in frames. The default value is 30 fps. - */ - int videoGop; - /** Self-defined video codec profile: #VIDEO_CODEC_PROFILE_TYPE. - - @note If you set this parameter to other values, Agora adjusts it to the default value of 100. - */ - VIDEO_CODEC_PROFILE_TYPE videoCodecProfile; - /** The background color in RGB hex value. Value only. Do not include a preceeding #. For example, 0xFFB6C1 (light pink). The default value is 0x000000 (black). - */ - unsigned int backgroundColor; - /** Video codec profile types for Media Push. See VIDEO_CODEC_TYPE_FOR_STREAM. */ - VIDEO_CODEC_TYPE_FOR_STREAM videoCodecType; - /** The number of users in the live interactive streaming. - * The value range is [0, 17]. - */ - unsigned int userCount; - /** Manages the user layout configuration in the Media Push. Agora supports a maximum of 17 transcoding users in a Media Push channel. See `TranscodingUser`. - */ - TranscodingUser* transcodingUsers; - /** Reserved property. Extra user-defined information to send SEI for the H.264/H.265 video stream to the CDN live client. Maximum length: 4096 Bytes. - - For more information on SEI frame, see [SEI-related questions](https://docs.agora.io/en/faq/sei). - */ - const char* transcodingExtraInfo; - - /** **DEPRECATED** The metadata sent to the CDN live client. - */ - const char* metadata; - /** The watermark on the live video. The image format needs to be PNG. See `RtcImage`. - - You can add one watermark, or add multiple watermarks using an array. This parameter is used with `watermarkCount`. - */ - RtcImage* watermark; - /** - * The number of watermarks on the live video. The total number of watermarks and background images can range from 0 to 10. This parameter is used with `watermark`. - */ - unsigned int watermarkCount; - - /** The number of background images on the live video. The image format needs to be PNG. See `RtcImage`. - * - * You can add a background image or use an array to add multiple background images. This parameter is used with `backgroundImageCount`. - */ - RtcImage* backgroundImage; - /** - * The number of background images on the live video. The total number of watermarks and background images can range from 0 to 10. This parameter is used with `backgroundImage`. - */ - unsigned int backgroundImageCount; - - /** The audio sampling rate (Hz) of the output media stream. See #AUDIO_SAMPLE_RATE_TYPE. - */ - AUDIO_SAMPLE_RATE_TYPE audioSampleRate; - /** Bitrate (Kbps) of the audio output stream for Media Push. The default value is 48, and the highest value is 128. - */ - int audioBitrate; - /** The number of audio channels for Media Push. Agora recommends choosing 1 (mono), or 2 (stereo) audio channels. Special players are required if you choose 3, 4, or 5. - * - 1: (Default) Mono. - * - 2: Stereo. - * - 3: Three audio channels. - * - 4: Four audio channels. - * - 5: Five audio channels. - */ - int audioChannels; - /** Audio codec profile type for Media Push. See #AUDIO_CODEC_PROFILE_TYPE. - */ - AUDIO_CODEC_PROFILE_TYPE audioCodecProfile; - /** Advanced features of the RTMP or RTMPS streaming with transcoding. See LiveStreamAdvancedFeature. - */ - LiveStreamAdvancedFeature* advancedFeatures; - - /** The number of enabled advanced features. The default value is 0. */ - unsigned int advancedFeatureCount; - - LiveTranscoding() - : width(360), - height(640), - videoBitrate(400), - videoFramerate(15), - lowLatency(false), - videoGop(30), - videoCodecProfile(VIDEO_CODEC_PROFILE_HIGH), - backgroundColor(0x000000), - videoCodecType(VIDEO_CODEC_H264_FOR_STREAM), - userCount(0), - transcodingUsers(OPTIONAL_NULLPTR), - transcodingExtraInfo(OPTIONAL_NULLPTR), - metadata(OPTIONAL_NULLPTR), - watermark(OPTIONAL_NULLPTR), - watermarkCount(0), - backgroundImage(OPTIONAL_NULLPTR), - backgroundImageCount(0), - audioSampleRate(AUDIO_SAMPLE_RATE_48000), - audioBitrate(48), - audioChannels(1), - audioCodecProfile(AUDIO_CODEC_PROFILE_LC_AAC), - advancedFeatures(OPTIONAL_NULLPTR), - advancedFeatureCount(0) {} -}; - -/** - * The video streams for the video mixing on the local client. - */ -struct TranscodingVideoStream { - /** - * The source type of video for the video mixing on the local client. See #VIDEO_SOURCE_TYPE. - */ - VIDEO_SOURCE_TYPE sourceType; - /** - * The ID of the remote user. - * @note Use this parameter only when the source type of the video for the video mixing on the local client is `VIDEO_SOURCE_REMOTE`. - */ - uid_t remoteUserUid; - /** - * The URL of the image. - * @note Use this parameter only when the source type of the video for the video mixing on the local client is `RTC_IMAGE`. - */ - const char* imageUrl; - /** - * MediaPlayer id if sourceType is MEDIA_PLAYER_SOURCE. - */ - int mediaPlayerId; - /** - * The horizontal displacement of the top-left corner of the video for the video mixing on the client relative to the top-left corner (origin) of the canvas for this video mixing. - */ - int x; - /** - * The vertical displacement of the top-left corner of the video for the video mixing on the client relative to the top-left corner (origin) of the canvas for this video mixing. - */ - int y; - /** - * The width (px) of the video for the video mixing on the local client. - */ - int width; - /** - * The height (px) of the video for the video mixing on the local client. - */ - int height; - /** - * The number of the layer to which the video for the video mixing on the local client belongs. The value range is [0,100]. - * - 0: (Default) The layer is at the bottom. - * - 100: The layer is at the top. - */ - int zOrder; - /** - * The transparency of the video for the video mixing on the local client. The value range is [0.0,1.0]. 0.0 means the transparency is completely transparent. 1.0 means the transparency is opaque. - */ - double alpha; - /** - * Whether to mirror the video for the video mixing on the local client. - * - true: Mirroring. - * - false: (Default) Do not mirror. - * @note The paramter only works for videos with the source type `CAMERA`. - */ - bool mirror; - - TranscodingVideoStream() - : sourceType(VIDEO_SOURCE_CAMERA_PRIMARY), - remoteUserUid(0), - imageUrl(OPTIONAL_NULLPTR), - x(0), - y(0), - width(0), - height(0), - zOrder(0), - alpha(1.0), - mirror(false) {} -}; - -/** - * The configuration of the video mixing on the local client. - */ -struct LocalTranscoderConfiguration { - /** - * The number of the video streams for the video mixing on the local client. - */ - unsigned int streamCount; - /** - * The video streams for the video mixing on the local client. See TranscodingVideoStream. - */ - TranscodingVideoStream* videoInputStreams; - /** - * The encoding configuration of the mixed video stream after the video mixing on the local client. See VideoEncoderConfiguration. - */ - VideoEncoderConfiguration videoOutputConfiguration; - /** - * Whether to use the timestamp when the primary camera captures the video frame as the timestamp of the mixed video frame. - * - true: (Default) Use the timestamp of the captured video frame as the timestamp of the mixed video frame. - * - false: Do not use the timestamp of the captured video frame as the timestamp of the mixed video frame. Instead, use the timestamp when the mixed video frame is constructed. - */ - bool syncWithPrimaryCamera; - - LocalTranscoderConfiguration() : streamCount(0), videoInputStreams(OPTIONAL_NULLPTR), videoOutputConfiguration(), syncWithPrimaryCamera(true) {} -}; - -enum VIDEO_TRANSCODER_ERROR { - /** - * The video track of the video source is not started. - */ - VT_ERR_VIDEO_SOURCE_NOT_READY = 1, - /** - * The video source type is not supported. - */ - VT_ERR_INVALID_VIDEO_SOURCE_TYPE = 2, - /** - * The image url is not correctly of image source. - */ - VT_ERR_INVALID_IMAGE_PATH = 3, - /** - * The image format not the type png/jpeg/gif of image source. - */ - VT_ERR_UNSUPPORT_IMAGE_FORMAT = 4, - /** - * The layout is invalid such as width is zero. - */ - VT_ERR_INVALID_LAYOUT = 5, - /** - * Internal error. - */ - VT_ERR_INTERNAL = 20 -}; - -/** - * Configurations of the last-mile network test. - */ -struct LastmileProbeConfig { - /** - * Determines whether to test the uplink network. Some users, for example, - * the audience in a live broadcast channel, do not need such a test: - * - true: Test. - * - false: Do not test. - */ - bool probeUplink; - /** - * Determines whether to test the downlink network: - * - true: Test. - * - false: Do not test. - */ - bool probeDownlink; - /** - * The expected maximum sending bitrate (bps) of the local user. The value range is [100000, 5000000]. We recommend setting this parameter - * according to the bitrate value set by `setVideoEncoderConfiguration`. - */ - unsigned int expectedUplinkBitrate; - /** - * The expected maximum receiving bitrate (bps) of the local user. The value range is [100000,5000000]. - */ - unsigned int expectedDownlinkBitrate; -}; - -/** - * The status of the last-mile network tests. - */ -enum LASTMILE_PROBE_RESULT_STATE { - /** - * 1: The last-mile network probe test is complete. - */ - LASTMILE_PROBE_RESULT_COMPLETE = 1, - /** - * 2: The last-mile network probe test is incomplete because the bandwidth estimation is not available due to limited test resources. - */ - LASTMILE_PROBE_RESULT_INCOMPLETE_NO_BWE = 2, - /** - * 3: The last-mile network probe test is not carried out, probably due to poor network conditions. - */ - LASTMILE_PROBE_RESULT_UNAVAILABLE = 3 -}; - -/** - * Results of the uplink or downlink last-mile network test. - */ -struct LastmileProbeOneWayResult { - /** - * The packet loss rate (%). - */ - unsigned int packetLossRate; - /** - * The network jitter (ms). - */ - unsigned int jitter; - /** - * The estimated available bandwidth (bps). - */ - unsigned int availableBandwidth; - - LastmileProbeOneWayResult() : packetLossRate(0), - jitter(0), - availableBandwidth(0) {} -}; - -/** - * Results of the uplink and downlink last-mile network tests. - */ -struct LastmileProbeResult { - /** - * The status of the last-mile network tests. See #LASTMILE_PROBE_RESULT_STATE. - */ - LASTMILE_PROBE_RESULT_STATE state; - /** - * Results of the uplink last-mile network test. For details, see LastmileProbeOneWayResult. - */ - LastmileProbeOneWayResult uplinkReport; - /** - * Results of the downlink last-mile network test. For details, see LastmileProbeOneWayResult. - */ - LastmileProbeOneWayResult downlinkReport; - /** - * The round-trip time (ms). - */ - unsigned int rtt; - - LastmileProbeResult() - : state(LASTMILE_PROBE_RESULT_UNAVAILABLE), - rtt(0) {} -}; - -/** - * Reasons causing the change of the connection state. - */ -enum CONNECTION_CHANGED_REASON_TYPE -{ - /** - * 0: The SDK is connecting to the server. - */ - CONNECTION_CHANGED_CONNECTING = 0, - /** - * 1: The SDK has joined the channel successfully. - */ - CONNECTION_CHANGED_JOIN_SUCCESS = 1, - /** - * 2: The connection between the SDK and the server is interrupted. - */ - CONNECTION_CHANGED_INTERRUPTED = 2, - /** - * 3: The connection between the SDK and the server is banned by the server. This error occurs when the user is kicked out of the channel by the server. - */ - CONNECTION_CHANGED_BANNED_BY_SERVER = 3, - /** - * 4: The SDK fails to join the channel. When the SDK fails to join the channel for more than 20 minutes, this error occurs and the SDK stops reconnecting to the channel. - */ - CONNECTION_CHANGED_JOIN_FAILED = 4, - /** - * 5: The SDK has left the channel. - */ - CONNECTION_CHANGED_LEAVE_CHANNEL = 5, - /** - * 6: The connection fails because the App ID is not valid. - */ - CONNECTION_CHANGED_INVALID_APP_ID = 6, - /** - * 7: The connection fails because the channel name is not valid. Please rejoin the channel with a valid channel name. - */ - CONNECTION_CHANGED_INVALID_CHANNEL_NAME = 7, - /** - * 8: The connection fails because the token is not valid. Typical reasons include: - * - The App Certificate for the project is enabled in Agora Console, but you do not use a token when joining the channel. If you enable the App Certificate, you must use a token to join the channel. - * - The `uid` specified when calling `joinChannel` to join the channel is inconsistent with the `uid` passed in when generating the token. - */ - CONNECTION_CHANGED_INVALID_TOKEN = 8, - /** - * 9: The connection fails because the token has expired. - */ - CONNECTION_CHANGED_TOKEN_EXPIRED = 9, - /** - * 10: The connection is rejected by the server. Typical reasons include: - * - The user is already in the channel and still calls a method, for example, `joinChannel`, to join the channel. Stop calling this method to clear this error. - * - The user tries to join the channel when conducting a pre-call test. The user needs to call the channel after the call test ends. - */ - CONNECTION_CHANGED_REJECTED_BY_SERVER = 10, - /** - * 11: The connection changes to reconnecting because the SDK has set a proxy server. - */ - CONNECTION_CHANGED_SETTING_PROXY_SERVER = 11, - /** - * 12: The connection state changed because the token is renewed. - */ - CONNECTION_CHANGED_RENEW_TOKEN = 12, - /** - * 13: The IP address of the client has changed, possibly because the network type, IP address, or port has been changed. - */ - CONNECTION_CHANGED_CLIENT_IP_ADDRESS_CHANGED = 13, - /** - * 14: Timeout for the keep-alive of the connection between the SDK and the Agora edge server. The connection state changes to CONNECTION_STATE_RECONNECTING. - */ - CONNECTION_CHANGED_KEEP_ALIVE_TIMEOUT = 14, - /** - * 15: The SDK has rejoined the channel successfully. - */ - CONNECTION_CHANGED_REJOIN_SUCCESS = 15, - /** - * 16: The connection between the SDK and the server is lost. - */ - CONNECTION_CHANGED_LOST = 16, - /** - * 17: The change of connection state is caused by echo test. - */ - CONNECTION_CHANGED_ECHO_TEST = 17, - /** - * 18: The local IP Address is changed by user. - */ - CONNECTION_CHANGED_CLIENT_IP_ADDRESS_CHANGED_BY_USER = 18, - /** - * 19: The connection is failed due to join the same channel on another device with the same uid. - */ - CONNECTION_CHANGED_SAME_UID_LOGIN = 19, - /** - * 20: The connection is failed due to too many broadcasters in the channel. - */ - CONNECTION_CHANGED_TOO_MANY_BROADCASTERS = 20, - - /** - * 21: The connection is failed due to license validation failure. - */ - CONNECTION_CHANGED_LICENSE_VALIDATION_FAILURE = 21, - /* - * 22: The connection is failed due to certification verify failure. - */ - CONNECTION_CHANGED_CERTIFICATION_VERYFY_FAILURE = 22, - /** - * 23: The connection is failed due to the lack of granting permission to the stream channel. - */ - CONNECTION_CHANGED_STREAM_CHANNEL_NOT_AVAILABLE = 23, - /** - * 24: The connection is failed due to join channel with an inconsistent appid. - */ - CONNECTION_CHANGED_INCONSISTENT_APPID = 24, -}; - -/** - * The reason of changing role's failure. - */ -enum CLIENT_ROLE_CHANGE_FAILED_REASON { - /** - * 1: Too many broadcasters in the channel. - */ - CLIENT_ROLE_CHANGE_FAILED_TOO_MANY_BROADCASTERS = 1, - /** - * 2: The operation of changing role is not authorized. - */ - CLIENT_ROLE_CHANGE_FAILED_NOT_AUTHORIZED = 2, - /** - * 3: The operation of changing role is timeout. - * @deprecated This reason is deprecated. - */ - CLIENT_ROLE_CHANGE_FAILED_REQUEST_TIME_OUT __deprecated = 3, - /** - * 4: The operation of changing role is interrupted since we lost connection with agora service. - * @deprecated This reason is deprecated. - */ - CLIENT_ROLE_CHANGE_FAILED_CONNECTION_FAILED __deprecated = 4, -}; - -/** - * The reason of notifying the user of a message. - */ -enum WLACC_MESSAGE_REASON { - /** - * WIFI signal is weak. - */ - WLACC_MESSAGE_REASON_WEAK_SIGNAL = 0, - /** - * Channel congestion. - */ - WLACC_MESSAGE_REASON_CHANNEL_CONGESTION = 1, -}; - -/** - * Suggest an action for the user. - */ -enum WLACC_SUGGEST_ACTION { - /** - * Please get close to AP. - */ - WLACC_SUGGEST_ACTION_CLOSE_TO_WIFI = 0, - /** - * The user is advised to connect to the prompted SSID. - */ - WLACC_SUGGEST_ACTION_CONNECT_SSID = 1, - /** - * The user is advised to check whether the AP supports 5G band and enable 5G band (the aciton link is attached), or purchases an AP that supports 5G. AP does not support 5G band. - */ - WLACC_SUGGEST_ACTION_CHECK_5G = 2, - /** - * The user is advised to change the SSID of the 2.4G or 5G band (the aciton link is attached). The SSID of the 2.4G band AP is the same as that of the 5G band. - */ - WLACC_SUGGEST_ACTION_MODIFY_SSID = 3, -}; - -/** - * Indicator optimization degree. - */ -struct WlAccStats { - /** - * End-to-end delay optimization percentage. - */ - unsigned short e2eDelayPercent; - /** - * Frozen Ratio optimization percentage. - */ - unsigned short frozenRatioPercent; - /** - * Loss Rate optimization percentage. - */ - unsigned short lossRatePercent; -}; - -/** - * The network type. - */ -enum NETWORK_TYPE { - /** - * -1: The network type is unknown. - */ - NETWORK_TYPE_UNKNOWN = -1, - /** - * 0: The SDK disconnects from the network. - */ - NETWORK_TYPE_DISCONNECTED = 0, - /** - * 1: The network type is LAN. - */ - NETWORK_TYPE_LAN = 1, - /** - * 2: The network type is Wi-Fi (including hotspots). - */ - NETWORK_TYPE_WIFI = 2, - /** - * 3: The network type is mobile 2G. - */ - NETWORK_TYPE_MOBILE_2G = 3, - /** - * 4: The network type is mobile 3G. - */ - NETWORK_TYPE_MOBILE_3G = 4, - /** - * 5: The network type is mobile 4G. - */ - NETWORK_TYPE_MOBILE_4G = 5, - /** - * 6: The network type is mobile 5G. - */ - NETWORK_TYPE_MOBILE_5G = 6, -}; - -/** - * The mode of setting up video views. - */ -enum VIDEO_VIEW_SETUP_MODE { - /** - * 0: replace one view - */ - VIDEO_VIEW_SETUP_REPLACE = 0, - /** - * 1: add one view - */ - VIDEO_VIEW_SETUP_ADD = 1, - /** - * 2: remove one view - */ - VIDEO_VIEW_SETUP_REMOVE = 2, -}; - -/** - * Attributes of video canvas object. - */ -struct VideoCanvas { - /** - * The user id of local video. - */ - uid_t uid; - - /** - * The uid of video stream composing the video stream from transcoder which will be drawn on this video canvas. - */ - uid_t subviewUid; - /** - * Video display window. - */ - view_t view; - /** - * A RGBA value indicates background color of the render view. Defaults to 0x00000000. - */ - uint32_t backgroundColor; - /** - * The video render mode. See \ref agora::media::base::RENDER_MODE_TYPE "RENDER_MODE_TYPE". - * The default value is RENDER_MODE_HIDDEN. - */ - media::base::RENDER_MODE_TYPE renderMode; - /** - * The video mirror mode. See \ref VIDEO_MIRROR_MODE_TYPE "VIDEO_MIRROR_MODE_TYPE". - * The default value is VIDEO_MIRROR_MODE_AUTO. - * @note - * - For the mirror mode of the local video view: - * If you use a front camera, the SDK enables the mirror mode by default; - * if you use a rear camera, the SDK disables the mirror mode by default. - * - For the remote user: The mirror mode is disabled by default. - */ - VIDEO_MIRROR_MODE_TYPE mirrorMode; - /** - * The mode of setting up video view. See \ref VIDEO_VIEW_SETUP_MODE "VIDEO_VIEW_SETUP_MODE" - * The default value is VIDEO_VIEW_SETUP_REPLACE. - */ - VIDEO_VIEW_SETUP_MODE setupMode; - /** - * The video source type. See \ref VIDEO_SOURCE_TYPE "VIDEO_SOURCE_TYPE". - * The default value is VIDEO_SOURCE_CAMERA_PRIMARY. - */ - VIDEO_SOURCE_TYPE sourceType; - /** - * The media player id of AgoraMediaPlayer. It should set this parameter when the - * sourceType is VIDEO_SOURCE_MEDIA_PLAYER to show the video that AgoraMediaPlayer is playing. - * You can get this value by calling the method \ref getMediaPlayerId(). - */ - int mediaPlayerId; - /** - * If you want to display a certain part of a video frame, you can set - * this value to crop the video frame to show. - * The default value is empty(that is, if it has zero width or height), which means no cropping. - */ - Rectangle cropArea; - /** - * Whether to apply alpha mask to the video frame if exsit: - * true: Apply alpha mask to video frame. - * false: (Default) Do not apply alpha mask to video frame. - */ - bool enableAlphaMask; - /** - * The video frame position in pipeline. See \ref VIDEO_MODULE_POSITION "VIDEO_MODULE_POSITION". - * The default value is POSITION_POST_CAPTURER. - */ - media::base::VIDEO_MODULE_POSITION position; - - VideoCanvas() - : uid(0), subviewUid(0), view(NULL), backgroundColor(0x00000000), renderMode(media::base::RENDER_MODE_HIDDEN), mirrorMode(VIDEO_MIRROR_MODE_AUTO), - setupMode(VIDEO_VIEW_SETUP_REPLACE), sourceType(VIDEO_SOURCE_CAMERA_PRIMARY), mediaPlayerId(-ERR_NOT_READY), - cropArea(0, 0, 0, 0), enableAlphaMask(false), position(media::base::POSITION_POST_CAPTURER) {} - - VideoCanvas(view_t v, media::base::RENDER_MODE_TYPE m, VIDEO_MIRROR_MODE_TYPE mt) - : uid(0), subviewUid(0), view(v), backgroundColor(0x00000000), renderMode(m), mirrorMode(mt), setupMode(VIDEO_VIEW_SETUP_REPLACE), - sourceType(VIDEO_SOURCE_CAMERA_PRIMARY), mediaPlayerId(-ERR_NOT_READY), - cropArea(0, 0, 0, 0), enableAlphaMask(false), position(media::base::POSITION_POST_CAPTURER) {} - - VideoCanvas(view_t v, media::base::RENDER_MODE_TYPE m, VIDEO_MIRROR_MODE_TYPE mt, uid_t u) - : uid(u), subviewUid(0), view(v), backgroundColor(0x00000000), renderMode(m), mirrorMode(mt), setupMode(VIDEO_VIEW_SETUP_REPLACE), - sourceType(VIDEO_SOURCE_CAMERA_PRIMARY), mediaPlayerId(-ERR_NOT_READY), - cropArea(0, 0, 0, 0), enableAlphaMask(false), position(media::base::POSITION_POST_CAPTURER) {} - - VideoCanvas(view_t v, media::base::RENDER_MODE_TYPE m, VIDEO_MIRROR_MODE_TYPE mt, uid_t u, uid_t subu) - : uid(u), subviewUid(subu), view(v), backgroundColor(0x00000000), renderMode(m), mirrorMode(mt), setupMode(VIDEO_VIEW_SETUP_REPLACE), - sourceType(VIDEO_SOURCE_CAMERA_PRIMARY), mediaPlayerId(-ERR_NOT_READY), - cropArea(0, 0, 0, 0), enableAlphaMask(false), position(media::base::POSITION_POST_CAPTURER) {} -}; - -/** Image enhancement options. - */ -struct BeautyOptions { - /** The contrast level. - */ - enum LIGHTENING_CONTRAST_LEVEL { - /** Low contrast level. */ - LIGHTENING_CONTRAST_LOW = 0, - /** (Default) Normal contrast level. */ - LIGHTENING_CONTRAST_NORMAL = 1, - /** High contrast level. */ - LIGHTENING_CONTRAST_HIGH = 2, - }; - - /** The contrast level, used with the `lighteningLevel` parameter. The larger the value, the greater the contrast between light and dark. See #LIGHTENING_CONTRAST_LEVEL. - */ - LIGHTENING_CONTRAST_LEVEL lighteningContrastLevel; - - /** The brightness level. The value ranges from 0.0 (original) to 1.0. The default value is 0.0. The greater the value, the greater the degree of whitening. */ - float lighteningLevel; - - /** The value ranges from 0.0 (original) to 1.0. The default value is 0.0. The greater the value, the greater the degree of skin grinding. - */ - float smoothnessLevel; - - /** The redness level. The value ranges from 0.0 (original) to 1.0. The default value is 0.0. The larger the value, the greater the rosy degree. - */ - float rednessLevel; - - /** The sharpness level. The value ranges from 0.0 (original) to 1.0. The default value is 0.0. The larger the value, the greater the sharpening degree. - */ - float sharpnessLevel; - - BeautyOptions(LIGHTENING_CONTRAST_LEVEL contrastLevel, float lightening, float smoothness, float redness, float sharpness) : lighteningContrastLevel(contrastLevel), lighteningLevel(lightening), smoothnessLevel(smoothness), rednessLevel(redness), sharpnessLevel(sharpness) {} - - BeautyOptions() : lighteningContrastLevel(LIGHTENING_CONTRAST_NORMAL), lighteningLevel(0), smoothnessLevel(0), rednessLevel(0), sharpnessLevel(0) {} -}; - -/** Face shape area options. This structure defines options for facial adjustments on different facial areas. - * - * @technical preview - */ -struct FaceShapeAreaOptions { - /** The specific facial area to be adjusted. - */ - enum FACE_SHAPE_AREA { - /** (Default) Invalid area. */ - FACE_SHAPE_AREA_NONE = -1, - /** Head Scale, reduces the size of head. */ - FACE_SHAPE_AREA_HEADSCALE = 0, - /** Forehead, adjusts the size of forehead. */ - FACE_SHAPE_AREA_FOREHEAD = 1, - /** Face Contour, slims the facial contour. */ - FACE_SHAPE_AREA_FACECONTOUR = 2, - /** Face Length, adjusts the length of face. */ - FACE_SHAPE_AREA_FACELENGTH = 3, - /** Face Width, narrows the width of face. */ - FACE_SHAPE_AREA_FACEWIDTH = 4, - /** Cheekbone, adjusts the size of cheekbone. */ - FACE_SHAPE_AREA_CHEEKBONE = 5, - /** Cheek, adjusts the size of cheek. */ - FACE_SHAPE_AREA_CHEEK = 6, - /** Chin, adjusts the length of chin. */ - FACE_SHAPE_AREA_CHIN = 7, - /** Eye Scale, adjusts the size of eyes. */ - FACE_SHAPE_AREA_EYESCALE = 8, - /** Nose Length, adjusts the length of nose. */ - FACE_SHAPE_AREA_NOSELENGTH = 9, - /** Nose Width, adjusts the width of nose. */ - FACE_SHAPE_AREA_NOSEWIDTH = 10, - /** Mouth Scale, adjusts the size of mouth. */ - FACE_SHAPE_AREA_MOUTHSCALE = 11, - }; - - /** The specific facial area to be adjusted, See #FACE_SHAPE_AREA. - */ - FACE_SHAPE_AREA shapeArea; - - /** The intensity of the pinching effect applied to the specified facial area. - * For the following area values: #FACE_SHAPE_AREA_FOREHEAD, #FACE_SHAPE_AREA_FACELENGTH, #FACE_SHAPE_AREA_CHIN, #FACE_SHAPE_AREA_NOSELENGTH, #FACE_SHAPE_AREA_NOSEWIDTH, #FACE_SHAPE_AREA_MOUTHSCALE, the value ranges from -100 to 100. - * The default value is 0. The greater the absolute value, the stronger the intensity applied to the specified facial area, and negative values indicate the opposite direction. - * For enumeration values other than the above, the value ranges from 0 to 100. The default value is 0. The greater the value, the stronger the intensity applied to the specified facial area. - */ - int shapeIntensity; - - FaceShapeAreaOptions(FACE_SHAPE_AREA shapeArea, int areaIntensity) : shapeArea(shapeArea), shapeIntensity(areaIntensity) {} - - FaceShapeAreaOptions() : shapeArea(FACE_SHAPE_AREA_NONE), shapeIntensity(0) {} -}; - -/** Face shape beauty options. This structure defines options for facial adjustments of different facial styles. - * - * @technical preview - */ -struct FaceShapeBeautyOptions { - /** The face shape style. - */ - enum FACE_SHAPE_BEAUTY_STYLE { - /** (Default) Female face shape style. */ - FACE_SHAPE_BEAUTY_STYLE_FEMALE = 0, - /** Male face shape style. */ - FACE_SHAPE_BEAUTY_STYLE_MALE = 1, - }; - - /** The face shape style, See #FACE_SHAPE_BEAUTY_STYLE. - */ - FACE_SHAPE_BEAUTY_STYLE shapeStyle; - - /** The intensity of the pinching effect applied to the specified facial style. The value ranges from 0 (original) to 100. The default value is 0. The greater the value, the stronger the intensity applied to face pinching. - */ - int styleIntensity; - - FaceShapeBeautyOptions(FACE_SHAPE_BEAUTY_STYLE shapeStyle, int styleIntensity) : shapeStyle(shapeStyle), styleIntensity(styleIntensity) {} - - FaceShapeBeautyOptions() : shapeStyle(FACE_SHAPE_BEAUTY_STYLE_FEMALE), styleIntensity(50) {} -}; - -struct LowlightEnhanceOptions { - /** - * The low-light enhancement mode. - */ - enum LOW_LIGHT_ENHANCE_MODE { - /** 0: (Default) Automatic mode. The SDK automatically enables or disables the low-light enhancement feature according to the ambient light to compensate for the lighting level or prevent overexposure, as necessary. */ - LOW_LIGHT_ENHANCE_AUTO = 0, - /** Manual mode. Users need to enable or disable the low-light enhancement feature manually. */ - LOW_LIGHT_ENHANCE_MANUAL = 1, - }; - /** - * The low-light enhancement level. - */ - enum LOW_LIGHT_ENHANCE_LEVEL { - /** - * 0: (Default) Promotes video quality during low-light enhancement. It processes the brightness, details, and noise of the video image. The performance consumption is moderate, the processing speed is moderate, and the overall video quality is optimal. - */ - LOW_LIGHT_ENHANCE_LEVEL_HIGH_QUALITY = 0, - /** - * Promotes performance during low-light enhancement. It processes the brightness and details of the video image. The processing speed is faster. - */ - LOW_LIGHT_ENHANCE_LEVEL_FAST = 1, - }; - - /** The low-light enhancement mode. See #LOW_LIGHT_ENHANCE_MODE. - */ - LOW_LIGHT_ENHANCE_MODE mode; - - /** The low-light enhancement level. See #LOW_LIGHT_ENHANCE_LEVEL. - */ - LOW_LIGHT_ENHANCE_LEVEL level; - - LowlightEnhanceOptions(LOW_LIGHT_ENHANCE_MODE lowlightMode, LOW_LIGHT_ENHANCE_LEVEL lowlightLevel) : mode(lowlightMode), level(lowlightLevel) {} - - LowlightEnhanceOptions() : mode(LOW_LIGHT_ENHANCE_AUTO), level(LOW_LIGHT_ENHANCE_LEVEL_HIGH_QUALITY) {} -}; -/** - * The video noise reduction options. - * - * @since v4.0.0 - */ -struct VideoDenoiserOptions { - /** The video noise reduction mode. - */ - enum VIDEO_DENOISER_MODE { - /** 0: (Default) Automatic mode. The SDK automatically enables or disables the video noise reduction feature according to the ambient light. */ - VIDEO_DENOISER_AUTO = 0, - /** Manual mode. Users need to enable or disable the video noise reduction feature manually. */ - VIDEO_DENOISER_MANUAL = 1, - }; - /** - * The video noise reduction level. - */ - enum VIDEO_DENOISER_LEVEL { - /** - * 0: (Default) Promotes video quality during video noise reduction. `HIGH_QUALITY` balances performance consumption and video noise reduction quality. - * The performance consumption is moderate, the video noise reduction speed is moderate, and the overall video quality is optimal. - */ - VIDEO_DENOISER_LEVEL_HIGH_QUALITY = 0, - /** - * Promotes reducing performance consumption during video noise reduction. `FAST` prioritizes reducing performance consumption over video noise reduction quality. - * The performance consumption is lower, and the video noise reduction speed is faster. To avoid a noticeable shadowing effect (shadows trailing behind moving objects) in the processed video, Agora recommends that you use `FAST` when the camera is fixed. - */ - VIDEO_DENOISER_LEVEL_FAST = 1, - /** - * Enhanced video noise reduction. `STRENGTH` prioritizes video noise reduction quality over reducing performance consumption. - * The performance consumption is higher, the video noise reduction speed is slower, and the video noise reduction quality is better. - * If `HIGH_QUALITY` is not enough for your video noise reduction needs, you can use `STRENGTH`. - */ - VIDEO_DENOISER_LEVEL_STRENGTH = 2, - }; - /** The video noise reduction mode. See #VIDEO_DENOISER_MODE. - */ - VIDEO_DENOISER_MODE mode; - - /** The video noise reduction level. See #VIDEO_DENOISER_LEVEL. - */ - VIDEO_DENOISER_LEVEL level; - - VideoDenoiserOptions(VIDEO_DENOISER_MODE denoiserMode, VIDEO_DENOISER_LEVEL denoiserLevel) : mode(denoiserMode), level(denoiserLevel) {} - - VideoDenoiserOptions() : mode(VIDEO_DENOISER_AUTO), level(VIDEO_DENOISER_LEVEL_HIGH_QUALITY) {} -}; - -/** The color enhancement options. - * - * @since v4.0.0 - */ -struct ColorEnhanceOptions { - /** The level of color enhancement. The value range is [0.0,1.0]. `0.0` is the default value, which means no color enhancement is applied to the video. The higher the value, the higher the level of color enhancement. - */ - float strengthLevel; - - /** The level of skin tone protection. The value range is [0.0,1.0]. `0.0` means no skin tone protection. The higher the value, the higher the level of skin tone protection. - * The default value is `1.0`. When the level of color enhancement is higher, the portrait skin tone can be significantly distorted, so you need to set the level of skin tone protection; when the level of skin tone protection is higher, the color enhancement effect can be slightly reduced. - * Therefore, to get the best color enhancement effect, Agora recommends that you adjust `strengthLevel` and `skinProtectLevel` to get the most appropriate values. - */ - float skinProtectLevel; - - ColorEnhanceOptions(float stength, float skinProtect) : strengthLevel(stength), skinProtectLevel(skinProtect) {} - - ColorEnhanceOptions() : strengthLevel(0), skinProtectLevel(1) {} -}; - -/** - * The custom background image. - */ -struct VirtualBackgroundSource { - /** The type of the custom background source. - */ - enum BACKGROUND_SOURCE_TYPE { - /** - * 0: Enable segementation with the captured video frame without replacing the background. - */ - BACKGROUND_NONE = 0, - /** - * 1: (Default) The background source is a solid color. - */ - BACKGROUND_COLOR = 1, - /** - * The background source is a file in PNG or JPG format. - */ - BACKGROUND_IMG = 2, - /** - * The background source is the blurred original video frame. - * */ - BACKGROUND_BLUR = 3, - /** - * The background source is a file in MP4, AVI, MKV, FLV format. - * */ - BACKGROUND_VIDEO = 4, - }; - - /** The degree of blurring applied to the background source. - */ - enum BACKGROUND_BLUR_DEGREE { - /** 1: The degree of blurring applied to the custom background image is low. The user can almost see the background clearly. */ - BLUR_DEGREE_LOW = 1, - /** 2: The degree of blurring applied to the custom background image is medium. It is difficult for the user to recognize details in the background. */ - BLUR_DEGREE_MEDIUM = 2, - /** 3: (Default) The degree of blurring applied to the custom background image is high. The user can barely see any distinguishing features in the background. */ - BLUR_DEGREE_HIGH = 3, - }; - - /** The type of the custom background image. See #BACKGROUND_SOURCE_TYPE. - */ - BACKGROUND_SOURCE_TYPE background_source_type; - - /** - * The color of the custom background image. The format is a hexadecimal integer defined by RGB, without the # sign, - * such as 0xFFB6C1 for light pink. The default value is 0xFFFFFF, which signifies white. The value range - * is [0x000000,0xFFFFFF]. If the value is invalid, the SDK replaces the original background image with a white - * background image. - * - * @note This parameter takes effect only when the type of the custom background image is `BACKGROUND_COLOR`. - */ - unsigned int color; - - /** - * The local absolute path of the custom background image. PNG and JPG formats are supported. If the path is invalid, - * the SDK replaces the original background image with a white background image. - * - * @note This parameter takes effect only when the type of the custom background image is `BACKGROUND_IMG`. - */ - const char* source; - - /** The degree of blurring applied to the custom background image. See BACKGROUND_BLUR_DEGREE. - * @note This parameter takes effect only when the type of the custom background image is `BACKGROUND_BLUR`. - */ - BACKGROUND_BLUR_DEGREE blur_degree; - - VirtualBackgroundSource() : background_source_type(BACKGROUND_COLOR), color(0xffffff), source(OPTIONAL_NULLPTR), blur_degree(BLUR_DEGREE_HIGH) {} -}; - -struct SegmentationProperty { - - enum SEG_MODEL_TYPE { - - SEG_MODEL_AI = 1, - SEG_MODEL_GREEN = 2 - }; - - SEG_MODEL_TYPE modelType; - - float greenCapacity; - - - SegmentationProperty() : modelType(SEG_MODEL_AI), greenCapacity(0.5){} -}; - -/** The type of custom audio track -*/ -enum AUDIO_TRACK_TYPE { - /** - * -1: Invalid audio track - */ - AUDIO_TRACK_INVALID = -1, - /** - * 0: Mixable audio track - * You can push more than one mixable Audio tracks into one RTC connection(channel id + uid), - * and SDK will mix these tracks into one audio track automatically. - * However, compare to direct audio track, mixable track might cause extra 30ms+ delay. - */ - AUDIO_TRACK_MIXABLE = 0, - /** - * 1: Direct audio track - * You can only push one direct (non-mixable) audio track into one RTC connection(channel id + uid). - * Compare to mixable stream, you can have lower lantency using direct audio track. - */ - AUDIO_TRACK_DIRECT = 1, -}; - -/** The configuration of custom audio track -*/ -struct AudioTrackConfig { - /** - * Enable local playback, enabled by default - * true: (Default) Enable local playback - * false: Do not enable local playback - */ - bool enableLocalPlayback; - - AudioTrackConfig() - : enableLocalPlayback(true) {} -}; - -/** - * Preset local voice reverberation options. - * bitmap allocation: - * | bit31 | bit30 - bit24 | bit23 - bit16 | bit15 - bit8 | bit7 - bit0 | - * |---------|--------------------|-----------------------------|--------------|----------------| - * |reserved | 0x1: voice beauty | 0x1: chat beautification | effect types | effect settings| - * | | | 0x2: singing beautification | | | - * | | | 0x3: timbre transform | | | - * | | | 0x4: ultra high_quality | | | - * | |--------------------|-----------------------------| | | - * | | 0x2: audio effect | 0x1: space construction | | | - * | | | 0x2: voice changer effect | | | - * | | | 0x3: style transform | | | - * | | | 0x4: electronic sound | | | - * | | | 0x5: magic tone | | | - * | |--------------------|-----------------------------| | | - * | | 0x3: voice changer | 0x1: voice transform | | | - */ -/** The options for SDK preset voice beautifier effects. - */ -enum VOICE_BEAUTIFIER_PRESET { - /** Turn off voice beautifier effects and use the original voice. - */ - VOICE_BEAUTIFIER_OFF = 0x00000000, - /** A more magnetic voice. - * - * @note Agora recommends using this enumerator to process a male-sounding voice; otherwise, you - * may experience vocal distortion. - */ - CHAT_BEAUTIFIER_MAGNETIC = 0x01010100, - /** A fresher voice. - * - * @note Agora recommends using this enumerator to process a female-sounding voice; otherwise, you - * may experience vocal distortion. - */ - CHAT_BEAUTIFIER_FRESH = 0x01010200, - /** A more vital voice. - * - * @note Agora recommends using this enumerator to process a female-sounding voice; otherwise, you - * may experience vocal distortion. - */ - CHAT_BEAUTIFIER_VITALITY = 0x01010300, - /** - * Singing beautifier effect. - * - If you call `setVoiceBeautifierPreset`(SINGING_BEAUTIFIER), you can beautify a male-sounding voice and add a reverberation effect - * that sounds like singing in a small room. Agora recommends not using `setVoiceBeautifierPreset`(SINGING_BEAUTIFIER) to process - * a female-sounding voice; otherwise, you may experience vocal distortion. - * - If you call `setVoiceBeautifierParameters`(SINGING_BEAUTIFIER, param1, param2), you can beautify a male- or - * female-sounding voice and add a reverberation effect. - */ - SINGING_BEAUTIFIER = 0x01020100, - /** A more vigorous voice. - */ - TIMBRE_TRANSFORMATION_VIGOROUS = 0x01030100, - /** A deeper voice. - */ - TIMBRE_TRANSFORMATION_DEEP = 0x01030200, - /** A mellower voice. - */ - TIMBRE_TRANSFORMATION_MELLOW = 0x01030300, - /** A falsetto voice. - */ - TIMBRE_TRANSFORMATION_FALSETTO = 0x01030400, - /** A fuller voice. - */ - TIMBRE_TRANSFORMATION_FULL = 0x01030500, - /** A clearer voice. - */ - TIMBRE_TRANSFORMATION_CLEAR = 0x01030600, - /** A more resounding voice. - */ - TIMBRE_TRANSFORMATION_RESOUNDING = 0x01030700, - /** A more ringing voice. - */ - TIMBRE_TRANSFORMATION_RINGING = 0x01030800, - /** - * A ultra-high quality voice, which makes the audio clearer and restores more details. - * - To achieve better audio effect quality, Agora recommends that you call `setAudioProfile` - * and set the `profile` to `AUDIO_PROFILE_MUSIC_HIGH_QUALITY(4)` or `AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO(5)` - * and `scenario` to `AUDIO_SCENARIO_HIGH_DEFINITION(6)` before calling `setVoiceBeautifierPreset`. - * - If you have an audio capturing device that can already restore audio details to a high - * degree, Agora recommends that you do not enable ultra-high quality; otherwise, the SDK may - * over-restore audio details, and you may not hear the anticipated voice effect. - */ - ULTRA_HIGH_QUALITY_VOICE = 0x01040100 -}; - -/** Preset voice effects. - * - * For better voice effects, Agora recommends setting the `profile` parameter of `setAudioProfile` to `AUDIO_PROFILE_MUSIC_HIGH_QUALITY` or `AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO` before using the following presets: - * - * - `ROOM_ACOUSTICS_KTV` - * - `ROOM_ACOUSTICS_VOCAL_CONCERT` - * - `ROOM_ACOUSTICS_STUDIO` - * - `ROOM_ACOUSTICS_PHONOGRAPH` - * - `ROOM_ACOUSTICS_SPACIAL` - * - `ROOM_ACOUSTICS_ETHEREAL` - * - `ROOM_ACOUSTICS_CHORUS` - * - `VOICE_CHANGER_EFFECT_UNCLE` - * - `VOICE_CHANGER_EFFECT_OLDMAN` - * - `VOICE_CHANGER_EFFECT_BOY` - * - `VOICE_CHANGER_EFFECT_SISTER` - * - `VOICE_CHANGER_EFFECT_GIRL` - * - `VOICE_CHANGER_EFFECT_PIGKING` - * - `VOICE_CHANGER_EFFECT_HULK` - * - `PITCH_CORRECTION` - */ -enum AUDIO_EFFECT_PRESET { - /** Turn off voice effects, that is, use the original voice. - */ - AUDIO_EFFECT_OFF = 0x00000000, - /** The voice effect typical of a KTV venue. - */ - ROOM_ACOUSTICS_KTV = 0x02010100, - /** The voice effect typical of a concert hall. - */ - ROOM_ACOUSTICS_VOCAL_CONCERT = 0x02010200, - /** The voice effect typical of a recording studio. - */ - ROOM_ACOUSTICS_STUDIO = 0x02010300, - /** The voice effect typical of a vintage phonograph. - */ - ROOM_ACOUSTICS_PHONOGRAPH = 0x02010400, - /** The virtual stereo effect, which renders monophonic audio as stereo audio. - * - * @note Before using this preset, set the `profile` parameter of `setAudioProfile` - * to `AUDIO_PROFILE_MUSIC_STANDARD_STEREO(3)` or `AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO(5)`; - * otherwise, the preset setting is invalid. - */ - ROOM_ACOUSTICS_VIRTUAL_STEREO = 0x02010500, - /** A more spatial voice effect. - */ - ROOM_ACOUSTICS_SPACIAL = 0x02010600, - /** A more ethereal voice effect. - */ - ROOM_ACOUSTICS_ETHEREAL = 0x02010700, - /** A 3D voice effect that makes the voice appear to be moving around the user. The default cycle - * period of the 3D voice effect is 10 seconds. To change the cycle period, call `setAudioEffectParameters` - * after this method. - * - * @note - * - Before using this preset, set the `profile` parameter of `setAudioProfile` to - * `AUDIO_PROFILE_MUSIC_STANDARD_STEREO` or `AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO`; otherwise, - * the preset setting is invalid. - * - If the 3D voice effect is enabled, users need to use stereo audio playback devices to hear - * the anticipated voice effect. - */ - ROOM_ACOUSTICS_3D_VOICE = 0x02010800, - /** virtual suround sound. - * - * @note - * - Agora recommends using this enumerator to process virtual suround sound; otherwise, you may - * not hear the anticipated voice effect. - * - To achieve better audio effect quality, Agora recommends calling \ref - * IRtcEngine::setAudioProfile "setAudioProfile" and setting the `profile` parameter to - * `AUDIO_PROFILE_MUSIC_HIGH_QUALITY(4)` or `AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO(5)` before - * setting this enumerator. - */ - ROOM_ACOUSTICS_VIRTUAL_SURROUND_SOUND = 0x02010900, - /** The voice effect for chorus. - * - * @note: To achieve better audio effect quality, Agora recommends calling \ref - * IRtcEngine::setAudioProfile "setAudioProfile" and setting the `profile` parameter to - * `AUDIO_PROFILE_MUSIC_HIGH_QUALITY(4)` or `AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO(5)` before - * setting this enumerator. - */ - ROOM_ACOUSTICS_CHORUS = 0x02010D00, - /** A middle-aged man's voice. - * - * @note - * Agora recommends using this enumerator to process a male-sounding voice; otherwise, you may - * not hear the anticipated voice effect. - */ - VOICE_CHANGER_EFFECT_UNCLE = 0x02020100, - /** A senior man's voice. - * - * @note Agora recommends using this enumerator to process a male-sounding voice; otherwise, you may - * not hear the anticipated voice effect. - */ - VOICE_CHANGER_EFFECT_OLDMAN = 0x02020200, - /** A boy's voice. - * - * @note Agora recommends using this enumerator to process a male-sounding voice; otherwise, you may - * not hear the anticipated voice effect. - */ - VOICE_CHANGER_EFFECT_BOY = 0x02020300, - /** A young woman's voice. - * - * @note - * - Agora recommends using this enumerator to process a female-sounding voice; otherwise, you may - * not hear the anticipated voice effect. - */ - VOICE_CHANGER_EFFECT_SISTER = 0x02020400, - /** A girl's voice. - * - * @note Agora recommends using this enumerator to process a female-sounding voice; otherwise, you may - * not hear the anticipated voice effect. - */ - VOICE_CHANGER_EFFECT_GIRL = 0x02020500, - /** The voice of Pig King, a character in Journey to the West who has a voice like a growling - * bear. - */ - VOICE_CHANGER_EFFECT_PIGKING = 0x02020600, - /** The Hulk's voice. - */ - VOICE_CHANGER_EFFECT_HULK = 0x02020700, - /** An audio effect typical of R&B music. - * - * @note Before using this preset, set the `profile` parameter of `setAudioProfile` to - - `AUDIO_PROFILE_MUSIC_HIGH_QUALITY` or `AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO`; otherwise, - * the preset setting is invalid. - */ - STYLE_TRANSFORMATION_RNB = 0x02030100, - /** The voice effect typical of popular music. - * - * @note Before using this preset, set the `profile` parameter of `setAudioProfile` to - - `AUDIO_PROFILE_MUSIC_HIGH_QUALITY` or `AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO`; otherwise, - * the preset setting is invalid. - */ - STYLE_TRANSFORMATION_POPULAR = 0x02030200, - /** A pitch correction effect that corrects the user's pitch based on the pitch of the natural C - * major scale. After setting this voice effect, you can call `setAudioEffectParameters` to adjust - * the basic mode of tuning and the pitch of the main tone. - */ - PITCH_CORRECTION = 0x02040100, - - /** Todo: Electronic sound, Magic tone haven't been implemented. - * - */ -}; - -/** The options for SDK preset voice conversion. - */ -enum VOICE_CONVERSION_PRESET { - /** Turn off voice conversion and use the original voice. - */ - VOICE_CONVERSION_OFF = 0x00000000, - /** A gender-neutral voice. To avoid audio distortion, ensure that you use this enumerator to process a female-sounding voice. - */ - VOICE_CHANGER_NEUTRAL = 0x03010100, - /** A sweet voice. To avoid audio distortion, ensure that you use this enumerator to process a female-sounding voice. - */ - VOICE_CHANGER_SWEET = 0x03010200, - /** A steady voice. To avoid audio distortion, ensure that you use this enumerator to process a male-sounding voice. - */ - VOICE_CHANGER_SOLID = 0x03010300, - /** A deep voice. To avoid audio distortion, ensure that you use this enumerator to process a male-sounding voice. - */ - VOICE_CHANGER_BASS = 0x03010400, - /** A voice like a cartoon character. - */ - VOICE_CHANGER_CARTOON = 0x03010500, - /** A voice like a child. - */ - VOICE_CHANGER_CHILDLIKE = 0x03010600, - /** A voice like a phone operator. - */ - VOICE_CHANGER_PHONE_OPERATOR = 0x03010700, - /** A monster voice. - */ - VOICE_CHANGER_MONSTER = 0x03010800, - /** A voice like Transformers. - */ - VOICE_CHANGER_TRANSFORMERS = 0x03010900, - /** A voice like Groot. - */ - VOICE_CHANGER_GROOT = 0x03010A00, - /** A voice like Darth Vader. - */ - VOICE_CHANGER_DARTH_VADER = 0x03010B00, - /** A rough female voice. - */ - VOICE_CHANGER_IRON_LADY = 0x03010C00, - /** A voice like Crayon Shin-chan. - */ - VOICE_CHANGER_SHIN_CHAN = 0x03010D00, - /** A voice like a castrato. - */ - VOICE_CHANGER_GIRLISH_MAN = 0x03010E00, - /** A voice like chipmunk. - */ - VOICE_CHANGER_CHIPMUNK = 0x03010F00, - -}; - -/** The options for SDK preset headphone equalizer. - */ -enum HEADPHONE_EQUALIZER_PRESET { - /** Turn off headphone EQ and use the original voice. - */ - HEADPHONE_EQUALIZER_OFF = 0x00000000, - /** For over-ear headphones. - */ - HEADPHONE_EQUALIZER_OVEREAR = 0x04000001, - /** For in-ear headphones. - */ - HEADPHONE_EQUALIZER_INEAR = 0x04000002 -}; - -/** The options for SDK voice AI tuner. - */ -enum VOICE_AI_TUNER_TYPE { - /** Uncle, deep and magnetic male voice. - */ - VOICE_AI_TUNER_MATURE_MALE, - /** Fresh male, refreshing and sweet male voice. - */ - VOICE_AI_TUNER_FRESH_MALE, - /** Big sister, deep and charming female voice. - */ - VOICE_AI_TUNER_ELEGANT_FEMALE, - /** Lolita, high-pitched and cute female voice. - */ - VOICE_AI_TUNER_SWEET_FEMALE, - /** Warm man singing, warm and melodic male voice that is suitable for male lyrical songs. - */ - VOICE_AI_TUNER_WARM_MALE_SINGING, - /** Gentle female singing, soft and delicate female voice that is suitable for female lyrical songs. - */ - VOICE_AI_TUNER_GENTLE_FEMALE_SINGING, - /** Smoky uncle singing, unique husky male voice that is suitable for rock or blues songs. - */ - VOICE_AI_TUNER_HUSKY_MALE_SINGING, - /** Warm big sister singing, warm and mature female voice that is suitable for emotionally powerful songs. - */ - VOICE_AI_TUNER_WARM_ELEGANT_FEMALE_SINGING, - /** Forceful male singing, strong and powerful male voice that is suitable for passionate songs. - */ - VOICE_AI_TUNER_POWERFUL_MALE_SINGING, - /** Dreamy female singing, dreamlike and soft female voice that is suitable for airy and dream-like songs. - */ - VOICE_AI_TUNER_DREAMY_FEMALE_SINGING, -}; - -/** - * Screen sharing configurations. - */ -struct ScreenCaptureParameters { - /** - * On Windows and macOS, it represents the video encoding resolution of the shared screen stream. - * See `VideoDimensions`. The default value is 1920 x 1080, that is, 2,073,600 pixels. Agora uses - * the value of this parameter to calculate the charges. - * - * If the aspect ratio is different between the encoding dimensions and screen dimensions, Agora - * applies the following algorithms for encoding. Suppose dimensions are 1920 x 1080: - * - If the value of the screen dimensions is lower than that of dimensions, for example, - * 1000 x 1000 pixels, the SDK uses 1000 x 1000 pixels for encoding. - * - If the value of the screen dimensions is higher than that of dimensions, for example, - * 2000 x 1500, the SDK uses the maximum value under dimensions with the aspect ratio of - * the screen dimension (4:3) for encoding, that is, 1440 x 1080. - */ - VideoDimensions dimensions; - /** - * On Windows and macOS, it represents the video encoding frame rate (fps) of the shared screen stream. - * The frame rate (fps) of the shared region. The default value is 5. We do not recommend setting - * this to a value greater than 15. - */ - int frameRate; - /** - * On Windows and macOS, it represents the video encoding bitrate of the shared screen stream. - * The bitrate (Kbps) of the shared region. The default value is 0 (the SDK works out a bitrate - * according to the dimensions of the current screen). - */ - int bitrate; - /** Whether to capture the mouse in screen sharing: - * - `true`: (Default) Capture the mouse. - * - `false`: Do not capture the mouse. - */ - bool captureMouseCursor; - /** - * Whether to bring the window to the front when calling the `startScreenCaptureByWindowId` method to share it: - * - `true`: Bring the window to the front. - * - `false`: (Default) Do not bring the window to the front. - */ - bool windowFocus; - /** - * A list of IDs of windows to be blocked. When calling `startScreenCaptureByDisplayId` to start screen sharing, - * you can use this parameter to block a specified window. When calling `updateScreenCaptureParameters` to update - * screen sharing configurations, you can use this parameter to dynamically block the specified windows during - * screen sharing. - */ - view_t *excludeWindowList; - /** - * The number of windows to be blocked. - */ - int excludeWindowCount; - - /** The width (px) of the border. Defaults to 0, and the value range is [0,50]. - * - */ - int highLightWidth; - /** The color of the border in RGBA format. The default value is 0xFF8CBF26. - * - */ - unsigned int highLightColor; - /** Whether to place a border around the shared window or screen: - * - true: Place a border. - * - false: (Default) Do not place a border. - * - * @note When you share a part of a window or screen, the SDK places a border around the entire window or screen if you set `enableHighLight` as true. - * - */ - bool enableHighLight; - - ScreenCaptureParameters() - : dimensions(1920, 1080), frameRate(5), bitrate(STANDARD_BITRATE), captureMouseCursor(true), windowFocus(false), excludeWindowList(OPTIONAL_NULLPTR), excludeWindowCount(0), highLightWidth(0), highLightColor(0), enableHighLight(false) {} - ScreenCaptureParameters(const VideoDimensions& d, int f, int b) - : dimensions(d), frameRate(f), bitrate(b), captureMouseCursor(true), windowFocus(false), excludeWindowList(OPTIONAL_NULLPTR), excludeWindowCount(0), highLightWidth(0), highLightColor(0), enableHighLight(false) {} - ScreenCaptureParameters(int width, int height, int f, int b) - : dimensions(width, height), frameRate(f), bitrate(b), captureMouseCursor(true), windowFocus(false), excludeWindowList(OPTIONAL_NULLPTR), excludeWindowCount(0), highLightWidth(0), highLightColor(0), enableHighLight(false){} - ScreenCaptureParameters(int width, int height, int f, int b, bool cur, bool fcs) - : dimensions(width, height), frameRate(f), bitrate(b), captureMouseCursor(cur), windowFocus(fcs), excludeWindowList(OPTIONAL_NULLPTR), excludeWindowCount(0), highLightWidth(0), highLightColor(0), enableHighLight(false) {} - ScreenCaptureParameters(int width, int height, int f, int b, view_t *ex, int cnt) - : dimensions(width, height), frameRate(f), bitrate(b), captureMouseCursor(true), windowFocus(false), excludeWindowList(ex), excludeWindowCount(cnt), highLightWidth(0), highLightColor(0), enableHighLight(false) {} - ScreenCaptureParameters(int width, int height, int f, int b, bool cur, bool fcs, view_t *ex, int cnt) - : dimensions(width, height), frameRate(f), bitrate(b), captureMouseCursor(cur), windowFocus(fcs), excludeWindowList(ex), excludeWindowCount(cnt), highLightWidth(0), highLightColor(0), enableHighLight(false) {} -}; - -/** - * Audio recording quality. - */ -enum AUDIO_RECORDING_QUALITY_TYPE { - /** - * 0: Low quality. The sample rate is 32 kHz, and the file size is around 1.2 MB after 10 minutes of recording. - */ - AUDIO_RECORDING_QUALITY_LOW = 0, - /** - * 1: Medium quality. The sample rate is 32 kHz, and the file size is around 2 MB after 10 minutes of recording. - */ - AUDIO_RECORDING_QUALITY_MEDIUM = 1, - /** - * 2: High quality. The sample rate is 32 kHz, and the file size is around 3.75 MB after 10 minutes of recording. - */ - AUDIO_RECORDING_QUALITY_HIGH = 2, - /** - * 3: Ultra high audio recording quality. - */ - AUDIO_RECORDING_QUALITY_ULTRA_HIGH = 3, -}; - -/** - * Recording content. Set in `startAudioRecording`. - */ -enum AUDIO_FILE_RECORDING_TYPE { - /** - * 1: Only records the audio of the local user. - */ - AUDIO_FILE_RECORDING_MIC = 1, - /** - * 2: Only records the audio of all remote users. - */ - AUDIO_FILE_RECORDING_PLAYBACK = 2, - /** - * 3: Records the mixed audio of the local and all remote users. - */ - AUDIO_FILE_RECORDING_MIXED = 3, -}; - -/** - * Audio encoded frame observer position. - */ -enum AUDIO_ENCODED_FRAME_OBSERVER_POSITION { - /** - * 1: Only records the audio of the local user. - */ - AUDIO_ENCODED_FRAME_OBSERVER_POSITION_RECORD = 1, - /** - * 2: Only records the audio of all remote users. - */ - AUDIO_ENCODED_FRAME_OBSERVER_POSITION_PLAYBACK = 2, - /** - * 3: Records the mixed audio of the local and all remote users. - */ - AUDIO_ENCODED_FRAME_OBSERVER_POSITION_MIXED = 3, -}; - -/** - * Recording configuration. - */ -struct AudioRecordingConfiguration { - /** - * The absolute path (including the filename extensions) of the recording file. For example: `C:\music\audio.mp4`. - * @note Ensure that the directory for the log files exists and is writable. - */ - const char* filePath; - /** - * Whether to encode the audio data: - * - `true`: Encode audio data in AAC. - * - `false`: (Default) Do not encode audio data, but save the recorded audio data directly. - */ - bool encode; - /** - * Recording sample rate (Hz). - * - 16000 - * - (Default) 32000 - * - 44100 - * - 48000 - * @note If you set this parameter to 44100 or 48000, Agora recommends recording WAV files, or AAC files with quality - * to be `AUDIO_RECORDING_QUALITY_MEDIUM` or `AUDIO_RECORDING_QUALITY_HIGH` for better recording quality. - */ - int sampleRate; - /** - * The recording content. See `AUDIO_FILE_RECORDING_TYPE`. - */ - AUDIO_FILE_RECORDING_TYPE fileRecordingType; - /** - * Recording quality. See `AUDIO_RECORDING_QUALITY_TYPE`. - * @note This parameter applies to AAC files only. - */ - AUDIO_RECORDING_QUALITY_TYPE quality; - - /** - * Recording channel. The following values are supported: - * - (Default) 1 - * - 2 - */ - int recordingChannel; - - AudioRecordingConfiguration() - : filePath(OPTIONAL_NULLPTR), - encode(false), - sampleRate(32000), - fileRecordingType(AUDIO_FILE_RECORDING_MIXED), - quality(AUDIO_RECORDING_QUALITY_LOW), - recordingChannel(1) {} - - AudioRecordingConfiguration(const char* file_path, int sample_rate, AUDIO_RECORDING_QUALITY_TYPE quality_type, int channel) - : filePath(file_path), - encode(false), - sampleRate(sample_rate), - fileRecordingType(AUDIO_FILE_RECORDING_MIXED), - quality(quality_type), - recordingChannel(channel) {} - - AudioRecordingConfiguration(const char* file_path, bool enc, int sample_rate, AUDIO_FILE_RECORDING_TYPE type, AUDIO_RECORDING_QUALITY_TYPE quality_type, int channel) - : filePath(file_path), - encode(enc), - sampleRate(sample_rate), - fileRecordingType(type), - quality(quality_type), - recordingChannel(channel) {} - - AudioRecordingConfiguration(const AudioRecordingConfiguration &rhs) - : filePath(rhs.filePath), - encode(rhs.encode), - sampleRate(rhs.sampleRate), - fileRecordingType(rhs.fileRecordingType), - quality(rhs.quality), - recordingChannel(rhs.recordingChannel) {} -}; - -/** - * Observer settings for the encoded audio. - */ -struct AudioEncodedFrameObserverConfig { - /** - * Audio profile. For details, see `AUDIO_ENCODED_FRAME_OBSERVER_POSITION`. - */ - AUDIO_ENCODED_FRAME_OBSERVER_POSITION postionType; - /** - * Audio encoding type. For details, see `AUDIO_ENCODING_TYPE`. - */ - AUDIO_ENCODING_TYPE encodingType; - - AudioEncodedFrameObserverConfig() - : postionType(AUDIO_ENCODED_FRAME_OBSERVER_POSITION_PLAYBACK), - encodingType(AUDIO_ENCODING_TYPE_OPUS_48000_MEDIUM){} - -}; -/** - * The encoded audio observer. - */ -class IAudioEncodedFrameObserver { -public: -/** -* Gets the encoded audio data of the local user. -* -* After calling `registerAudioEncodedFrameObserver` and setting the encoded audio as `AUDIO_ENCODED_FRAME_OBSERVER_POSITION_RECORD`, -* you can get the encoded audio data of the local user from this callback. -* -* @param frameBuffer The pointer to the audio frame buffer. -* @param length The data length (byte) of the audio frame. -* @param audioEncodedFrameInfo Audio information after encoding. For details, see `EncodedAudioFrameInfo`. -*/ -virtual void onRecordAudioEncodedFrame(const uint8_t* frameBuffer, int length, const EncodedAudioFrameInfo& audioEncodedFrameInfo) = 0; - -/** -* Gets the encoded audio data of all remote users. -* -* After calling `registerAudioEncodedFrameObserver` and setting the encoded audio as `AUDIO_ENCODED_FRAME_OBSERVER_POSITION_PLAYBACK`, -* you can get encoded audio data of all remote users through this callback. -* -* @param frameBuffer The pointer to the audio frame buffer. -* @param length The data length (byte) of the audio frame. -* @param audioEncodedFrameInfo Audio information after encoding. For details, see `EncodedAudioFrameInfo`. -*/ -virtual void onPlaybackAudioEncodedFrame(const uint8_t* frameBuffer, int length, const EncodedAudioFrameInfo& audioEncodedFrameInfo) = 0; - -/** -* Gets the mixed and encoded audio data of the local and all remote users. -* -* After calling `registerAudioEncodedFrameObserver` and setting the audio profile as `AUDIO_ENCODED_FRAME_OBSERVER_POSITION_MIXED`, -* you can get the mixed and encoded audio data of the local and all remote users through this callback. -* -* @param frameBuffer The pointer to the audio frame buffer. -* @param length The data length (byte) of the audio frame. -* @param audioEncodedFrameInfo Audio information after encoding. For details, see `EncodedAudioFrameInfo`. -*/ -virtual void onMixedAudioEncodedFrame(const uint8_t* frameBuffer, int length, const EncodedAudioFrameInfo& audioEncodedFrameInfo) = 0; - -virtual ~IAudioEncodedFrameObserver () {} -}; - -/** The region for connection, which is the region where the server the SDK connects to is located. - */ -enum AREA_CODE { - /** - * Mainland China. - */ - AREA_CODE_CN = 0x00000001, - /** - * North America. - */ - AREA_CODE_NA = 0x00000002, - /** - * Europe. - */ - AREA_CODE_EU = 0x00000004, - /** - * Asia, excluding Mainland China. - */ - AREA_CODE_AS = 0x00000008, - /** - * Japan. - */ - AREA_CODE_JP = 0x00000010, - /** - * India. - */ - AREA_CODE_IN = 0x00000020, - /** - * (Default) Global. - */ - AREA_CODE_GLOB = (0xFFFFFFFF) -}; - -/** - Extra region code - @technical preview -*/ -enum AREA_CODE_EX { - /** - * Oceania - */ - AREA_CODE_OC = 0x00000040, - /** - * South-American - */ - AREA_CODE_SA = 0x00000080, - /** - * Africa - */ - AREA_CODE_AF = 0x00000100, - /** - * South Korea - */ - AREA_CODE_KR = 0x00000200, - /** - * Hong Kong and Macou - */ - AREA_CODE_HKMC = 0x00000400, - /** - * United States - */ - AREA_CODE_US = 0x00000800, - /** - * Russia - */ - AREA_CODE_RU = 0x00001000, - /** - * The global area (except China) - */ - AREA_CODE_OVS = 0xFFFFFFFE -}; - -/** - * The error code of the channel media replay. - */ -enum CHANNEL_MEDIA_RELAY_ERROR { - /** 0: No error. - */ - RELAY_OK = 0, - /** 1: An error occurs in the server response. - */ - RELAY_ERROR_SERVER_ERROR_RESPONSE = 1, - /** 2: No server response. You can call the `leaveChannel` method to leave the channel. - * - * This error can also occur if your project has not enabled co-host token authentication. You can contact technical - * support to enable the service for cohosting across channels before starting a channel media relay. - */ - RELAY_ERROR_SERVER_NO_RESPONSE = 2, - /** 3: The SDK fails to access the service, probably due to limited resources of the server. - */ - RELAY_ERROR_NO_RESOURCE_AVAILABLE = 3, - /** 4: Fails to send the relay request. - */ - RELAY_ERROR_FAILED_JOIN_SRC = 4, - /** 5: Fails to accept the relay request. - */ - RELAY_ERROR_FAILED_JOIN_DEST = 5, - /** 6: The server fails to receive the media stream. - */ - RELAY_ERROR_FAILED_PACKET_RECEIVED_FROM_SRC = 6, - /** 7: The server fails to send the media stream. - */ - RELAY_ERROR_FAILED_PACKET_SENT_TO_DEST = 7, - /** 8: The SDK disconnects from the server due to poor network connections. You can call the `leaveChannel` method to - * leave the channel. - */ - RELAY_ERROR_SERVER_CONNECTION_LOST = 8, - /** 9: An internal error occurs in the server. - */ - RELAY_ERROR_INTERNAL_ERROR = 9, - /** 10: The token of the source channel has expired. - */ - RELAY_ERROR_SRC_TOKEN_EXPIRED = 10, - /** 11: The token of the destination channel has expired. - */ - RELAY_ERROR_DEST_TOKEN_EXPIRED = 11, -}; - -/** - * The state code of the channel media relay. - */ -enum CHANNEL_MEDIA_RELAY_STATE { - /** 0: The initial state. After you successfully stop the channel media relay by calling `stopChannelMediaRelay`, - * the `onChannelMediaRelayStateChanged` callback returns this state. - */ - RELAY_STATE_IDLE = 0, - /** 1: The SDK tries to relay the media stream to the destination channel. - */ - RELAY_STATE_CONNECTING = 1, - /** 2: The SDK successfully relays the media stream to the destination channel. - */ - RELAY_STATE_RUNNING = 2, - /** 3: An error occurs. See `code` in `onChannelMediaRelayStateChanged` for the error code. - */ - RELAY_STATE_FAILURE = 3, -}; - -/** The definition of ChannelMediaInfo. - */ -struct ChannelMediaInfo { - /** The user ID. - */ - uid_t uid; - /** The channel name. The default value is NULL, which means that the SDK - * applies the current channel name. - */ - const char* channelName; - /** The token that enables the user to join the channel. The default value - * is NULL, which means that the SDK applies the current token. - */ - const char* token; - - ChannelMediaInfo() : uid(0), channelName(NULL), token(NULL) {} - ChannelMediaInfo(const char* c, const char* t, uid_t u) : uid(u), channelName(c), token(t) {} -}; - -/** The definition of ChannelMediaRelayConfiguration. - */ -struct ChannelMediaRelayConfiguration { - /** The information of the source channel `ChannelMediaInfo`. It contains the following members: - * - `channelName`: The name of the source channel. The default value is `NULL`, which means the SDK applies the name - * of the current channel. - * - `uid`: The unique ID to identify the relay stream in the source channel. The default value is 0, which means the - * SDK generates a random UID. You must set it as 0. - * - `token`: The token for joining the source channel. It is generated with the `channelName` and `uid` you set in - * `srcInfo`. - * - If you have not enabled the App Certificate, set this parameter as the default value `NULL`, which means the - * SDK applies the App ID. - * - If you have enabled the App Certificate, you must use the token generated with the `channelName` and `uid`, and - * the `uid` must be set as 0. - */ - ChannelMediaInfo* srcInfo; - /** The information of the destination channel `ChannelMediaInfo`. It contains the following members: - * - `channelName`: The name of the destination channel. - * - `uid`: The unique ID to identify the relay stream in the destination channel. The value - * ranges from 0 to (2^32-1). To avoid UID conflicts, this `UID` must be different from any - * other `UID` in the destination channel. The default value is 0, which means the SDK generates - * a random `UID`. Do not set this parameter as the `UID` of the host in the destination channel, - * and ensure that this `UID` is different from any other `UID` in the channel. - * - `token`: The token for joining the destination channel. It is generated with the `channelName` - * and `uid` you set in `destInfos`. - * - If you have not enabled the App Certificate, set this parameter as the default value NULL, - * which means the SDK applies the App ID. - * If you have enabled the App Certificate, you must use the token generated with the `channelName` - * and `uid`. - */ - ChannelMediaInfo* destInfos; - /** The number of destination channels. The default value is 0, and the value range is from 0 to - * 6. Ensure that the value of this parameter corresponds to the number of `ChannelMediaInfo` - * structs you define in `destInfo`. - */ - int destCount; - - ChannelMediaRelayConfiguration() : srcInfo(OPTIONAL_NULLPTR), destInfos(OPTIONAL_NULLPTR), destCount(0) {} -}; - -/** - * The uplink network information. - */ -struct UplinkNetworkInfo { - /** - * The target video encoder bitrate (bps). - */ - int video_encoder_target_bitrate_bps; - - UplinkNetworkInfo() : video_encoder_target_bitrate_bps(0) {} - - bool operator==(const UplinkNetworkInfo& rhs) const { - return (video_encoder_target_bitrate_bps == rhs.video_encoder_target_bitrate_bps); - } -}; - -struct DownlinkNetworkInfo { - struct PeerDownlinkInfo { - /** - * The ID of the user who owns the remote video stream. - */ - const char* userId; - /** - * The remote video stream type: #VIDEO_STREAM_TYPE. - */ - VIDEO_STREAM_TYPE stream_type; - /** - * The remote video downscale type: #REMOTE_VIDEO_DOWNSCALE_LEVEL. - */ - REMOTE_VIDEO_DOWNSCALE_LEVEL current_downscale_level; - /** - * The expected bitrate in bps. - */ - int expected_bitrate_bps; - - PeerDownlinkInfo() - : userId(OPTIONAL_NULLPTR), - stream_type(VIDEO_STREAM_HIGH), - current_downscale_level(REMOTE_VIDEO_DOWNSCALE_LEVEL_NONE), - expected_bitrate_bps(-1) {} - - PeerDownlinkInfo(const PeerDownlinkInfo& rhs) - : stream_type(rhs.stream_type), - current_downscale_level(rhs.current_downscale_level), - expected_bitrate_bps(rhs.expected_bitrate_bps) { - if (rhs.userId != OPTIONAL_NULLPTR) { - const int len = std::strlen(rhs.userId); - char* buf = new char[len + 1]; - std::memcpy(buf, rhs.userId, len); - buf[len] = '\0'; - userId = buf; - } - } - - PeerDownlinkInfo& operator=(const PeerDownlinkInfo& rhs) { - if (this == &rhs) return *this; - userId = OPTIONAL_NULLPTR; - stream_type = rhs.stream_type; - current_downscale_level = rhs.current_downscale_level; - expected_bitrate_bps = rhs.expected_bitrate_bps; - if (rhs.userId != OPTIONAL_NULLPTR) { - const int len = std::strlen(rhs.userId); - char* buf = new char[len + 1]; - std::memcpy(buf, rhs.userId, len); - buf[len] = '\0'; - userId = buf; - } - return *this; - } - - ~PeerDownlinkInfo() { delete[] userId; } - }; - - /** - * The lastmile buffer delay queue time in ms. - */ - int lastmile_buffer_delay_time_ms; - /** - * The current downlink bandwidth estimation(bps) after downscale. - */ - int bandwidth_estimation_bps; - /** - * The total video downscale level count. - */ - int total_downscale_level_count; - /** - * The peer video downlink info array. - */ - PeerDownlinkInfo* peer_downlink_info; - /** - * The total video received count. - */ - int total_received_video_count; - - DownlinkNetworkInfo() - : lastmile_buffer_delay_time_ms(-1), - bandwidth_estimation_bps(-1), - total_downscale_level_count(-1), - peer_downlink_info(OPTIONAL_NULLPTR), - total_received_video_count(-1) {} - - DownlinkNetworkInfo(const DownlinkNetworkInfo& info) - : lastmile_buffer_delay_time_ms(info.lastmile_buffer_delay_time_ms), - bandwidth_estimation_bps(info.bandwidth_estimation_bps), - total_downscale_level_count(info.total_downscale_level_count), - peer_downlink_info(OPTIONAL_NULLPTR), - total_received_video_count(info.total_received_video_count) { - if (total_received_video_count <= 0) return; - peer_downlink_info = new PeerDownlinkInfo[total_received_video_count]; - for (int i = 0; i < total_received_video_count; ++i) - peer_downlink_info[i] = info.peer_downlink_info[i]; - } - - DownlinkNetworkInfo& operator=(const DownlinkNetworkInfo& rhs) { - if (this == &rhs) return *this; - lastmile_buffer_delay_time_ms = rhs.lastmile_buffer_delay_time_ms; - bandwidth_estimation_bps = rhs.bandwidth_estimation_bps; - total_downscale_level_count = rhs.total_downscale_level_count; - peer_downlink_info = OPTIONAL_NULLPTR; - total_received_video_count = rhs.total_received_video_count; - if (total_received_video_count > 0) { - peer_downlink_info = new PeerDownlinkInfo[total_received_video_count]; - for (int i = 0; i < total_received_video_count; ++i) - peer_downlink_info[i] = rhs.peer_downlink_info[i]; - } - return *this; - } - - ~DownlinkNetworkInfo() { delete[] peer_downlink_info; } -}; - -/** - * The built-in encryption mode. - * - * Agora recommends using AES_128_GCM2 or AES_256_GCM2 encrypted mode. These two modes support the - * use of salt for higher security. - */ -enum ENCRYPTION_MODE { - /** 1: 128-bit AES encryption, XTS mode. - */ - AES_128_XTS = 1, - /** 2: 128-bit AES encryption, ECB mode. - */ - AES_128_ECB = 2, - /** 3: 256-bit AES encryption, XTS mode. - */ - AES_256_XTS = 3, - /** 4: 128-bit SM4 encryption, ECB mode. - */ - SM4_128_ECB = 4, - /** 5: 128-bit AES encryption, GCM mode. - */ - AES_128_GCM = 5, - /** 6: 256-bit AES encryption, GCM mode. - */ - AES_256_GCM = 6, - /** 7: (Default) 128-bit AES encryption, GCM mode. This encryption mode requires the setting of - * salt (`encryptionKdfSalt`). - */ - AES_128_GCM2 = 7, - /** 8: 256-bit AES encryption, GCM mode. This encryption mode requires the setting of salt (`encryptionKdfSalt`). - */ - AES_256_GCM2 = 8, - /** Enumerator boundary. - */ - MODE_END, -}; - -/** Built-in encryption configurations. */ -struct EncryptionConfig { - /** - * The built-in encryption mode. See #ENCRYPTION_MODE. Agora recommends using `AES_128_GCM2` - * or `AES_256_GCM2` encrypted mode. These two modes support the use of salt for higher security. - */ - ENCRYPTION_MODE encryptionMode; - /** - * Encryption key in string type with unlimited length. Agora recommends using a 32-byte key. - * - * @note If you do not set an encryption key or set it as NULL, you cannot use the built-in encryption, and the SDK returns #ERR_INVALID_ARGUMENT (-2). - */ - const char* encryptionKey; - /** - * Salt, 32 bytes in length. Agora recommends that you use OpenSSL to generate salt on the server side. - * - * @note This parameter takes effect only in `AES_128_GCM2` or `AES_256_GCM2` encrypted mode. - * In this case, ensure that this parameter is not 0. - */ - uint8_t encryptionKdfSalt[32]; - - bool datastreamEncryptionEnabled; - - EncryptionConfig() - : encryptionMode(AES_128_GCM2), - encryptionKey(OPTIONAL_NULLPTR), - datastreamEncryptionEnabled(false) - { - memset(encryptionKdfSalt, 0, sizeof(encryptionKdfSalt)); - } - - /// @cond - const char* getEncryptionString() const { - switch(encryptionMode) { - case AES_128_XTS: - return "aes-128-xts"; - case AES_128_ECB: - return "aes-128-ecb"; - case AES_256_XTS: - return "aes-256-xts"; - case SM4_128_ECB: - return "sm4-128-ecb"; - case AES_128_GCM: - return "aes-128-gcm"; - case AES_256_GCM: - return "aes-256-gcm"; - case AES_128_GCM2: - return "aes-128-gcm-2"; - case AES_256_GCM2: - return "aes-256-gcm-2"; - default: - return "aes-128-gcm-2"; - } - return "aes-128-gcm-2"; - } - /// @endcond -}; - -/** Encryption error type. - */ -enum ENCRYPTION_ERROR_TYPE { - /** - * 0: Internal reason. - */ - ENCRYPTION_ERROR_INTERNAL_FAILURE = 0, - /** - * 1: MediaStream decryption errors. Ensure that the receiver and the sender use the same encryption mode and key. - */ - ENCRYPTION_ERROR_DECRYPTION_FAILURE = 1, - /** - * 2: MediaStream encryption errors. - */ - ENCRYPTION_ERROR_ENCRYPTION_FAILURE = 2, - /** - * 3: DataStream decryption errors. Ensure that the receiver and the sender use the same encryption mode and key. - */ - ENCRYPTION_ERROR_DATASTREAM_DECRYPTION_FAILURE = 3, - /** - * 4: DataStream encryption errors. - */ - ENCRYPTION_ERROR_DATASTREAM_ENCRYPTION_FAILURE = 4, -}; - -enum UPLOAD_ERROR_REASON -{ - UPLOAD_SUCCESS = 0, - UPLOAD_NET_ERROR = 1, - UPLOAD_SERVER_ERROR = 2, -}; - -/** The type of the device permission. - */ -enum PERMISSION_TYPE { - /** - * 0: Permission for the audio capture device. - */ - RECORD_AUDIO = 0, - /** - * 1: Permission for the camera. - */ - CAMERA = 1, - - SCREEN_CAPTURE = 2, -}; - -/** - * The subscribing state. - */ -enum STREAM_SUBSCRIBE_STATE { - /** - * 0: The initial subscribing state after joining the channel. - */ - SUB_STATE_IDLE = 0, - /** - * 1: Fails to subscribe to the remote stream. Possible reasons: - * - The remote user: - * - Calls `muteLocalAudioStream(true)` or `muteLocalVideoStream(true)` to stop sending local - * media stream. - * - Calls `disableAudio` or `disableVideo `to disable the local audio or video module. - * - Calls `enableLocalAudio(false)` or `enableLocalVideo(false)` to disable the local audio or video capture. - * - The role of the remote user is audience. - * - The local user calls the following methods to stop receiving remote streams: - * - Calls `muteRemoteAudioStream(true)`, `muteAllRemoteAudioStreams(true)` to stop receiving the remote audio streams. - * - Calls `muteRemoteVideoStream(true)`, `muteAllRemoteVideoStreams(true)` to stop receiving the remote video streams. - */ - SUB_STATE_NO_SUBSCRIBED = 1, - /** - * 2: Subscribing. - */ - SUB_STATE_SUBSCRIBING = 2, - /** - * 3: Subscribes to and receives the remote stream successfully. - */ - SUB_STATE_SUBSCRIBED = 3 -}; - -/** - * The publishing state. - */ -enum STREAM_PUBLISH_STATE { - /** - * 0: The initial publishing state after joining the channel. - */ - PUB_STATE_IDLE = 0, - /** - * 1: Fails to publish the local stream. Possible reasons: - * - The local user calls `muteLocalAudioStream(true)` or `muteLocalVideoStream(true)` to stop sending the local media stream. - * - The local user calls `disableAudio` or `disableVideo` to disable the local audio or video module. - * - The local user calls `enableLocalAudio(false)` or `enableLocalVideo(false)` to disable the local audio or video capture. - * - The role of the local user is audience. - */ - PUB_STATE_NO_PUBLISHED = 1, - /** - * 2: Publishing. - */ - PUB_STATE_PUBLISHING = 2, - /** - * 3: Publishes successfully. - */ - PUB_STATE_PUBLISHED = 3 -}; - -/** - * The EchoTestConfiguration struct. - */ -struct EchoTestConfiguration { - view_t view; - bool enableAudio; - bool enableVideo; - const char* token; - const char* channelId; - int intervalInSeconds; - - EchoTestConfiguration(view_t v, bool ea, bool ev, const char* t, const char* c, const int is) - : view(v), enableAudio(ea), enableVideo(ev), token(t), channelId(c), intervalInSeconds(is) {} - - EchoTestConfiguration() - : view(OPTIONAL_NULLPTR), enableAudio(true), enableVideo(true), token(OPTIONAL_NULLPTR), channelId(OPTIONAL_NULLPTR), intervalInSeconds(2) {} -}; - -/** - * The information of the user. - */ -struct UserInfo { - /** - * The user ID. - */ - uid_t uid; - /** - * The user account. The maximum data length is `MAX_USER_ACCOUNT_LENGTH_TYPE`. - */ - char userAccount[MAX_USER_ACCOUNT_LENGTH]; - - UserInfo() : uid(0) { - userAccount[0] = '\0'; - } -}; - -/** - * The audio filter of in-ear monitoring. - */ -enum EAR_MONITORING_FILTER_TYPE { - /** - * 1: Do not add an audio filter to the in-ear monitor. - */ - EAR_MONITORING_FILTER_NONE = (1<<0), - /** - * 2: Enable audio filters to the in-ear monitor. If you implement functions such as voice - * beautifier and audio effect, users can hear the voice after adding these effects. - */ - EAR_MONITORING_FILTER_BUILT_IN_AUDIO_FILTERS = (1<<1), - /** - * 4: Enable noise suppression to the in-ear monitor. - */ - EAR_MONITORING_FILTER_NOISE_SUPPRESSION = (1<<2), - /** - * 32768: Enable audio filters by reuse post-processing filter to the in-ear monitor. - * This bit is intended to be used in exclusive mode, which means, if this bit is set, all other bits will be disregarded. - */ - EAR_MONITORING_FILTER_REUSE_POST_PROCESSING_FILTER = (1<<15), -}; - -/** - * Thread priority type. - */ -enum THREAD_PRIORITY_TYPE { - /** - * 0: Lowest priority. - */ - LOWEST = 0, - /** - * 1: Low priority. - */ - LOW = 1, - /** - * 2: Normal priority. - */ - NORMAL = 2, - /** - * 3: High priority. - */ - HIGH = 3, - /** - * 4. Highest priority. - */ - HIGHEST = 4, - /** - * 5. Critical priority. - */ - CRITICAL = 5, -}; - -#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) || defined(__OHOS__) - -/** - * The video configuration for the shared screen stream. - */ -struct ScreenVideoParameters { - /** - * The dimensions of the video encoding resolution. The default value is `1280` x `720`. - * For recommended values, see [Recommended video - * profiles](https://docs.agora.io/en/Interactive%20Broadcast/game_streaming_video_profile?platform=Android#recommended-video-profiles). - * If the aspect ratio is different between width and height and the screen, the SDK adjusts the - * video encoding resolution according to the following rules (using an example where `width` × - * `height` is 1280 × 720): - * - When the width and height of the screen are both lower than `width` and `height`, the SDK - * uses the resolution of the screen for video encoding. For example, if the screen is 640 × - * 360, The SDK uses 640 × 360 for video encoding. - * - When either the width or height of the screen is higher than `width` or `height`, the SDK - * uses the maximum values that do not exceed those of `width` and `height` while maintaining - * the aspect ratio of the screen for video encoding. For example, if the screen is 2000 × 1500, - * the SDK uses 960 × 720 for video encoding. - * - * @note - * - The billing of the screen sharing stream is based on the values of width and height. - * When you do not pass in these values, Agora bills you at 1280 × 720; - * when you pass in these values, Agora bills you at those values. - * For details, see [Pricing for Real-time - * Communication](https://docs.agora.io/en/Interactive%20Broadcast/billing_rtc). - * - This value does not indicate the orientation mode of the output ratio. - * For how to set the video orientation, see `ORIENTATION_MODE`. - * - Whether the SDK can support a resolution at 720P depends on the performance of the device. - * If you set 720P but the device cannot support it, the video frame rate can be lower. - */ - VideoDimensions dimensions; - /** - * The video encoding frame rate (fps). The default value is `15`. - * For recommended values, see [Recommended video - * profiles](https://docs.agora.io/en/Interactive%20Broadcast/game_streaming_video_profile?platform=Android#recommended-video-profiles). - */ - int frameRate = 15; - /** - * The video encoding bitrate (Kbps). For recommended values, see [Recommended video - * profiles](https://docs.agora.io/en/Interactive%20Broadcast/game_streaming_video_profile?platform=Android#recommended-video-profiles). - */ - int bitrate; - /* - * The content hint of the screen sharing: - */ - VIDEO_CONTENT_HINT contentHint = VIDEO_CONTENT_HINT::CONTENT_HINT_MOTION; - - ScreenVideoParameters() : dimensions(1280, 720) {} -}; - -/** - * The audio configuration for the shared screen stream. - */ -struct ScreenAudioParameters { - /** - * The audio sample rate (Hz). The default value is `16000`. - */ - int sampleRate = 16000; - /** - * The number of audio channels. The default value is `2`, indicating dual channels. - */ - int channels = 2; - /** - * The volume of the captured system audio. The value range is [0,100]. The default value is - * `100`. - */ - int captureSignalVolume = 100; -}; - -/** - * The configuration of the screen sharing - */ -struct ScreenCaptureParameters2 { - /** - * Determines whether to capture system audio during screen sharing: - * - `true`: Capture. - * - `false`: (Default) Do not capture. - * - * **Note** - * Due to system limitations, capturing system audio is only available for Android API level 29 - * and later (that is, Android 10 and later). - */ - bool captureAudio = false; - /** - * The audio configuration for the shared screen stream. - */ - ScreenAudioParameters audioParams; - /** - * Determines whether to capture the screen during screen sharing: - * - `true`: (Default) Capture. - * - `false`: Do not capture. - * - * **Note** - * Due to system limitations, screen capture is only available for Android API level 21 and later - * (that is, Android 5 and later). - */ - bool captureVideo = true; - /** - * The video configuration for the shared screen stream. - */ - ScreenVideoParameters videoParams; -}; -#endif - -/** - * The tracing event of media rendering. - */ -enum MEDIA_TRACE_EVENT { - /** - * 0: The media frame has been rendered. - */ - MEDIA_TRACE_EVENT_VIDEO_RENDERED = 0, - /** - * 1: The media frame has been decoded. - */ - MEDIA_TRACE_EVENT_VIDEO_DECODED, -}; - -/** - * The video rendering tracing result - */ -struct VideoRenderingTracingInfo { - /** - * Elapsed time from the start tracing time to the time when the tracing event occurred. - */ - int elapsedTime; - /** - * Elapsed time from the start tracing time to the time when join channel. - * - * **Note** - * If the start tracing time is behind the time when join channel, this value will be negative. - */ - int start2JoinChannel; - /** - * Elapsed time from joining channel to finishing joining channel. - */ - int join2JoinSuccess; - /** - * Elapsed time from finishing joining channel to remote user joined. - * - * **Note** - * If the start tracing time is after the time finishing join channel, this value will be - * the elapsed time from the start tracing time to remote user joined. The minimum value is 0. - */ - int joinSuccess2RemoteJoined; - /** - * Elapsed time from remote user joined to set the view. - * - * **Note** - * If the start tracing time is after the time when remote user joined, this value will be - * the elapsed time from the start tracing time to set the view. The minimum value is 0. - */ - int remoteJoined2SetView; - /** - * Elapsed time from remote user joined to the time subscribing remote video stream. - * - * **Note** - * If the start tracing time is after the time when remote user joined, this value will be - * the elapsed time from the start tracing time to the time subscribing remote video stream. - * The minimum value is 0. - */ - int remoteJoined2UnmuteVideo; - /** - * Elapsed time from remote user joined to the remote video packet received. - * - * **Note** - * If the start tracing time is after the time when remote user joined, this value will be - * the elapsed time from the start tracing time to the time subscribing remote video stream. - * The minimum value is 0. - */ - int remoteJoined2PacketReceived; -}; - -enum CONFIG_FETCH_TYPE { - /** - * 1: Fetch config when initializing RtcEngine, without channel info. - */ - CONFIG_FETCH_TYPE_INITIALIZE = 1, - /** - * 2: Fetch config when joining channel with channel info, such as channel name and uid. - */ - CONFIG_FETCH_TYPE_JOIN_CHANNEL = 2, -}; - - -/** The local proxy mode type. */ -enum LOCAL_PROXY_MODE { - /** 0: Connect local proxy with high priority, if not connected to local proxy, fallback to sdrtn. - */ - ConnectivityFirst = 0, - /** 1: Only connect local proxy - */ - LocalOnly = 1, -}; - -struct LogUploadServerInfo { - /** Log upload server domain - */ - const char* serverDomain; - /** Log upload server path - */ - const char* serverPath; - /** Log upload server port - */ - int serverPort; - /** Whether to use HTTPS request: - - true: Use HTTPS request - - fasle: Use HTTP request - */ - bool serverHttps; - - LogUploadServerInfo() : serverDomain(NULL), serverPath(NULL), serverPort(0), serverHttps(true) {} - - LogUploadServerInfo(const char* domain, const char* path, int port, bool https) : serverDomain(domain), serverPath(path), serverPort(port), serverHttps(https) {} -}; - -struct AdvancedConfigInfo { - /** Log upload server - */ - LogUploadServerInfo logUploadServer; -}; - -struct LocalAccessPointConfiguration { - /** Local access point IP address list. - */ - const char** ipList; - /** The number of local access point IP address. - */ - int ipListSize; - /** Local access point domain list. - */ - const char** domainList; - /** The number of local access point domain. - */ - int domainListSize; - /** Certificate domain name installed on specific local access point. pass "" means using sni domain on specific local access point - * SNI(Server Name Indication) is an extension to the TLS protocol. - */ - const char* verifyDomainName; - /** Local proxy connection mode, connectivity first or local only. - */ - LOCAL_PROXY_MODE mode; - /** Local proxy connection, advanced Config info. - */ - AdvancedConfigInfo advancedConfig; - /** - * Whether to disable vos-aut: - - true: (Default)disable vos-aut. - - false: not disable vos-aut - */ - bool disableAut; - LocalAccessPointConfiguration() : ipList(NULL), ipListSize(0), domainList(NULL), domainListSize(0), verifyDomainName(NULL), mode(ConnectivityFirst), disableAut(true) {} -}; - -/** - * The information about recorded media streams. - */ -struct RecorderStreamInfo { - const char* channelId; - /** - * The user ID. - */ - uid_t uid; - /** - * The channel ID of the audio/video stream needs to be recorded. - */ - RecorderStreamInfo() : channelId(NULL), uid(0) {} - RecorderStreamInfo(const char* channelId, uid_t uid) : channelId(channelId), uid(uid) {} -}; -} // namespace rtc - -namespace base { - -class IEngineBase { - public: - virtual int queryInterface(rtc::INTERFACE_ID_TYPE iid, void** inter) = 0; - virtual ~IEngineBase() {} -}; - -class AParameter : public agora::util::AutoPtr { - public: - AParameter(IEngineBase& engine) { initialize(&engine); } - AParameter(IEngineBase* engine) { initialize(engine); } - AParameter(IAgoraParameter* p) : agora::util::AutoPtr(p) {} - - private: - bool initialize(IEngineBase* engine) { - IAgoraParameter* p = OPTIONAL_NULLPTR; - if (engine && !engine->queryInterface(rtc::AGORA_IID_PARAMETER_ENGINE, (void**)&p)) reset(p); - return p != OPTIONAL_NULLPTR; - } -}; - -class LicenseCallback { - public: - virtual ~LicenseCallback() {} - virtual void onCertificateRequired() = 0; - virtual void onLicenseRequest() = 0; - virtual void onLicenseValidated() = 0; - virtual void onLicenseError(int result) = 0; -}; - -} // namespace base - -/** - * Spatial audio parameters - */ -struct SpatialAudioParams { - /** - * Speaker azimuth in a spherical coordinate system centered on the listener. - */ - Optional speaker_azimuth; - /** - * Speaker elevation in a spherical coordinate system centered on the listener. - */ - Optional speaker_elevation; - /** - * Distance between speaker and listener. - */ - Optional speaker_distance; - /** - * Speaker orientation [0-180], 0 degree is the same with listener orientation. - */ - Optional speaker_orientation; - /** - * Enable blur or not for the speaker. - */ - Optional enable_blur; - /** - * Enable air absorb or not for the speaker. - */ - Optional enable_air_absorb; - /** - * Speaker attenuation factor. - */ - Optional speaker_attenuation; - /** - * Enable doppler factor. - */ - Optional enable_doppler; -}; -/** - * Layout info of video stream which compose a transcoder video stream. -*/ -struct VideoLayout -{ - /** - * Channel Id from which this video stream come from. - */ - const char* channelId; - /** - * User id of video stream. - */ - rtc::uid_t uid; - /** - * User account of video stream. - */ - user_id_t strUid; - /** - * x coordinate of video stream on a transcoded video stream canvas. - */ - uint32_t x; - /** - * y coordinate of video stream on a transcoded video stream canvas. - */ - uint32_t y; - /** - * width of video stream on a transcoded video stream canvas. - */ - uint32_t width; - /** - * height of video stream on a transcoded video stream canvas. - */ - uint32_t height; - /** - * video state of video stream on a transcoded video stream canvas. - * 0 for normal video , 1 for placeholder image showed , 2 for black image. - */ - uint32_t videoState; - - VideoLayout() : channelId(OPTIONAL_NULLPTR), uid(0), strUid(OPTIONAL_NULLPTR), x(0), y(0), width(0), height(0), videoState(0) {} -}; -} // namespace agora - -/** - * Gets the version of the SDK. - * @param [out] build The build number of Agora SDK. - * @return The string of the version of the SDK. - */ -AGORA_API const char* AGORA_CALL getAgoraSdkVersion(int* build); - -/** - * Gets error description of an error code. - * @param [in] err The error code. - * @return The description of the error code. - */ -AGORA_API const char* AGORA_CALL getAgoraSdkErrorDescription(int err); - -AGORA_API int AGORA_CALL setAgoraSdkExternalSymbolLoader(void* (*func)(const char* symname)); - -/** - * Generate credential - * @param [in, out] credential The content of the credential. - * @return The description of the error code. - * @note For license only, everytime will generate a different credential. - * So, just need to call once for a device, and then save the credential - */ -AGORA_API int AGORA_CALL createAgoraCredential(agora::util::AString &credential); - -/** - * Verify given certificate and return the result - * When you receive onCertificateRequired event, you must validate the certificate by calling - * this function. This is sync call, and if validation is success, it will return ERR_OK. And - * if failed to pass validation, you won't be able to joinChannel and ERR_CERT_FAIL will be - * returned. - * @param [in] credential_buf pointer to the credential's content. - * @param [in] credential_len the length of the credential's content. - * @param [in] certificate_buf pointer to the certificate's content. - * @param [in] certificate_len the length of the certificate's content. - * @return The description of the error code. - * @note For license only. - */ -AGORA_API int AGORA_CALL getAgoraCertificateVerifyResult(const char *credential_buf, int credential_len, - const char *certificate_buf, int certificate_len); - -/** - * @brief Implement the agora::base::LicenseCallback, - * create a LicenseCallback object to receive callbacks of license. - * - * @param [in] callback The object of agora::LiceseCallback, - * set the callback to null before delete it. - */ -AGORA_API void setAgoraLicenseCallback(agora::base::LicenseCallback *callback); - -/** - * @brief Get the LicenseCallback pointer if already setup, - * otherwise, return null. - * - * @return a pointer of agora::base::LicenseCallback - */ - -AGORA_API agora::base::LicenseCallback* getAgoraLicenseCallback(); - -/* - * Get monotonic time in ms which can be used by capture time, - * typical scenario is as follows: - * - * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * | // custom audio/video base capture time, e.g. the first audio/video capture time. | - * | int64_t custom_capture_time_base; | - * | | - * | int64_t agora_monotonic_time = getAgoraCurrentMonotonicTimeInMs(); | - * | | - * | // offset is fixed once calculated in the begining. | - * | const int64_t offset = agora_monotonic_time - custom_capture_time_base; | - * | | - * | // realtime_custom_audio/video_capture_time is the origin capture time that customer provided.| - * | // actual_audio/video_capture_time is the actual capture time transfered to sdk. | - * | int64_t actual_audio_capture_time = realtime_custom_audio_capture_time + offset; | - * | int64_t actual_video_capture_time = realtime_custom_video_capture_time + offset; | - * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * - * @return - * - >= 0: Success. - * - < 0: Failure. - */ -AGORA_API int64_t AGORA_CALL getAgoraCurrentMonotonicTimeInMs(); diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraExtensionProviderEntry.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraExtensionProviderEntry.h deleted file mode 100644 index acae66ea4..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraExtensionProviderEntry.h +++ /dev/null @@ -1,77 +0,0 @@ -// -// Copyright (c) 2020 Agora.io. All rights reserved - -// This program is confidential and proprietary to Agora.io. -// And may not be copied, reproduced, modified, disclosed to others, published -// or used, in whole or in part, without the express prior written permission -// of Agora.io. - -#pragma once // NOLINT(build/header_guard) - -#include "NGIAgoraExtensionControl.h" -AGORA_API agora::rtc::IExtensionControl* AGORA_CALL getAgoraExtensionControl(); -AGORA_API void AGORA_CALL declareProviderVersion( - const char*, const agora::rtc::ExtensionVersion&); -typedef void(*agora_ext_entry_func_t)(void); -AGORA_API void AGORA_CALL registerProviderEntry(const char*, agora_ext_entry_func_t); - -#define DECLARE_CREATE_AND_REGISTER_PROVIDER(PROVIDER_NAME, PROVIDER_CLASS, PROVIDER_INTERFACE_USED, ...) \ -static void register_##PROVIDER_NAME##_to_agora() { \ - auto control = getAgoraExtensionControl(); \ - agora::rtc::ExtensionVersion version = \ - agora::rtc::ExtensionInterfaceVersion::Version(); \ - declareProviderVersion(#PROVIDER_NAME, version); \ - if (#PROVIDER_NAME && control) { \ - control->registerProvider(#PROVIDER_NAME, \ - new agora::RefCountedObject(__VA_ARGS__)); \ - } \ -} \ - -#define DECLARE_CREATE_AND_REGISTER_PROVIDER_PTR(PROVIDER_NAME, PROVIDER_INTERFACE_USED, PROVIDER_REF_PTR) \ -static void register_##PROVIDER_NAME##_to_agora() { \ - auto control = getAgoraExtensionControl(); \ - agora::rtc::ExtensionVersion version = \ - agora::rtc::ExtensionInterfaceVersion::Version(); \ - declareProviderVersion(#PROVIDER_NAME, version); \ - if (#PROVIDER_NAME && control) { \ - control->registerProvider(#PROVIDER_NAME, PROVIDER_REF_PTR); \ - } \ -} \ - - -#if defined (__GNUC__) -#define REGISTER_AGORA_EXTENSION_PROVIDER(PROVIDER_NAME, PROVIDER_CLASS, PROVIDER_INTERFACE_USED, ...) \ -DECLARE_CREATE_AND_REGISTER_PROVIDER(PROVIDER_NAME, PROVIDER_CLASS, PROVIDER_INTERFACE_USED, __VA_ARGS__); \ -__attribute__((constructor, used)) \ -static void _##PROVIDER_NAME##_provider_entry() { \ - registerProviderEntry(#PROVIDER_NAME, register_##PROVIDER_NAME##_to_agora); \ -} \ - -#define REGISTER_AGORA_EXTENSION_PROVIDER_PTR(PROVIDER_NAME, PROVIDER_INTERFACE_USED, PROVIDER_REF_PTR) \ -DECLARE_CREATE_AND_REGISTER_PROVIDER_PTR(PROVIDER_NAME, PROVIDER_INTERFACE_USED, PROVIDER_REF_PTR); \ -__attribute__((constructor, used)) \ -static void _##PROVIDER_NAME##_provider_entry() { \ - registerProviderEntry(#PROVIDER_NAME, register_##PROVIDER_NAME##_to_agora); \ -} \ - - -#elif defined (_MSC_VER) -#define REGISTER_AGORA_EXTENSION_PROVIDER(PROVIDER_NAME, PROVIDER_CLASS, PROVIDER_INTERFACE_USED, ...) \ -DECLARE_CREATE_AND_REGISTER_PROVIDER(PROVIDER_NAME, PROVIDER_CLASS, PROVIDER_INTERFACE_USED, __VA_ARGS__); \ -static int _##PROVIDER_NAME##_provider_entry() { \ - registerProviderEntry(#PROVIDER_NAME, register_##PROVIDER_NAME##_to_agora); \ - return 0; \ -} \ -const int DUMMY_AGORA_REGEXT_##PROVIDE_NAME##_VAR = _##PROVIDER_NAME##_provider_entry(); \ - -#define REGISTER_AGORA_EXTENSION_PROVIDER_PTR(PROVIDER_NAME, PROVIDER_INTERFACE_USED, PROVIDER_REF_PTR) \ -DECLARE_CREATE_AND_REGISTER_PROVIDER_PTR(PROVIDER_NAME, PROVIDER_INTERFACE_USED, PROVIDER_REF_PTR); \ -static int _##PROVIDER_NAME##_provider_entry() { \ - registerProviderEntry(#PROVIDER_NAME, register_##PROVIDER_NAME##_to_agora); \ - return 0; \ -} \ -const int DUMMY_AGORA_REGEXT_##PROVIDE_NAME##_VAR = _##PROVIDER_NAME##_provider_entry(); \ - -#else -#error Unsupported Compilation Toolchain! -#endif diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraExtensionVersion.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraExtensionVersion.h deleted file mode 100644 index da4d563a3..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraExtensionVersion.h +++ /dev/null @@ -1,111 +0,0 @@ -// -// Copyright (c) 2021 Agora.io. All rights reserved - -// This program is confidential and proprietary to Agora.io. -// And may not be copied, reproduced, modified, disclosed to others, published -// or used, in whole or in part, without the express prior written permission -// of Agora.io. - -#pragma once - -namespace agora { -namespace rtc { - -struct ExtensionVersion { - // Extension Framework Version : major.minor.micro - int major_v; - int minor_v; - int micro_v; - - ExtensionVersion() - : major_v(0), minor_v(0), micro_v(0) {} - ExtensionVersion(int majorV, int minorV = 0, int microV = 0) - : major_v(majorV), minor_v(minorV), micro_v(microV) {} - - bool operator==(const ExtensionVersion& other) const { - return major_v == other.major_v && minor_v == other.minor_v && micro_v == other.micro_v; - } - - bool operator>(const ExtensionVersion& other) const { - return major_v > other.major_v || (major_v == other.major_v && minor_v > other.minor_v) - || (major_v == other.major_v && minor_v == other.minor_v && micro_v > other.micro_v); - } - - bool operator<(const ExtensionVersion& other) const { - return major_v < other.major_v || (major_v == other.major_v && minor_v < other.minor_v) - || (major_v == other.major_v && minor_v == other.minor_v && micro_v < other.micro_v); - } - - bool operator<=(const ExtensionVersion& other) const { - return !operator>(other); - } - - bool operator>=(const ExtensionVersion& other) const { - return !operator<(other); - } -}; - -#define BUMP_MAJOR_VERSION(VERSION) \ - ExtensionVersion(VERSION.major_v + 1, 0, 0); \ - -#define BUMP_MINOR_VERSION(VERSION) \ - ExtensionVersion(VERSION.major_v, VERSION.minor_v + 1, 0); \ - -#define BUMP_MICRO_VERSION(VERSION) \ - ExtensionVersion(VERSION.major_v, VERSION.minor_v, VERSION.micro_v + 1); \ - -class IExtensionProvider; -class IExtensionProviderV2; -class IExtensionProviderV3; -class IAudioFilter; -class IAudioFilterV2; -class IExtensionVideoFilter; -class IScreenCaptureSource; - -template -struct ExtensionInterfaceVersion; - -template <> -struct ExtensionInterfaceVersion { - static ExtensionVersion Version() { - return ExtensionVersion(1, 0, 0); - } -}; - -template <> -struct ExtensionInterfaceVersion { - static ExtensionVersion Version() { - return BUMP_MAJOR_VERSION(ExtensionInterfaceVersion::Version()); - } -}; - -template <> -struct ExtensionInterfaceVersion { - static ExtensionVersion Version() { - return ExtensionVersion(1, 0, 0); - } -}; - -template <> -struct ExtensionInterfaceVersion { - static ExtensionVersion Version() { - return BUMP_MAJOR_VERSION(ExtensionInterfaceVersion::Version()); - } -}; - -template <> -struct ExtensionInterfaceVersion { - static ExtensionVersion Version() { - return ExtensionVersion(1, 0, 0); - } -}; - -template <> -struct ExtensionInterfaceVersion { - static ExtensionVersion Version() { - return ExtensionVersion(1, 0, 0); - } -}; - -} // namespace rtc -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraMediaBase.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraMediaBase.h deleted file mode 100644 index 8120acb3f..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraMediaBase.h +++ /dev/null @@ -1,1981 +0,0 @@ -// Agora Engine SDK -// -// Created by Sting Feng in 2017-11. -// Copyright (c) 2017 Agora.io. All rights reserved. - -#pragma once // NOLINT(build/header_guard) - -#include -#include -#include -#include - -#ifndef OPTIONAL_ENUM_SIZE_T -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) -#define OPTIONAL_ENUM_SIZE_T enum : size_t -#else -#define OPTIONAL_ENUM_SIZE_T enum -#endif -#endif - -#if !defined(__APPLE__) -#define __deprecated -#endif - -namespace agora { -namespace rtc { - -typedef unsigned int uid_t; -typedef unsigned int track_id_t; -typedef unsigned int conn_id_t; -typedef unsigned int video_track_id_t; - -static const unsigned int INVALID_TRACK_ID = 0xffffffff; -static const unsigned int DEFAULT_CONNECTION_ID = 0; -static const unsigned int DUMMY_CONNECTION_ID = (std::numeric_limits::max)(); - -struct EncodedVideoFrameInfo; -/** -* The definition of extension context types. -**/ -struct ExtensionContext { - /** - * Whether the uid is valid. - * - true: The uid is valid. - * - false: The uid is invalid. - */ - bool isValid; - /** - * The ID of the user. - * A uid of 0 indicates the local user, and a uid greater than 0 represents a remote user. - */ - uid_t uid; - /** - * The provider name of the current extension. - */ - const char *providerName; - /** - * The extension name of the current extension. - */ - const char *extensionName; - ExtensionContext():isValid(false), uid(0), providerName(NULL), extensionName(NULL) {} -}; - - -/** -* Video source types definition. -**/ -enum VIDEO_SOURCE_TYPE { - /** Video captured by the camera. - */ - VIDEO_SOURCE_CAMERA_PRIMARY = 0, - VIDEO_SOURCE_CAMERA = VIDEO_SOURCE_CAMERA_PRIMARY, - /** Video captured by the secondary camera. - */ - VIDEO_SOURCE_CAMERA_SECONDARY = 1, - /** Video for screen sharing. - */ - VIDEO_SOURCE_SCREEN_PRIMARY = 2, - VIDEO_SOURCE_SCREEN = VIDEO_SOURCE_SCREEN_PRIMARY, - /** Video for secondary screen sharing. - */ - VIDEO_SOURCE_SCREEN_SECONDARY = 3, - /** Not define. - */ - VIDEO_SOURCE_CUSTOM = 4, - /** Video for media player sharing. - */ - VIDEO_SOURCE_MEDIA_PLAYER = 5, - /** Video for png image. - */ - VIDEO_SOURCE_RTC_IMAGE_PNG = 6, - /** Video for png image. - */ - VIDEO_SOURCE_RTC_IMAGE_JPEG = 7, - /** Video for png image. - */ - VIDEO_SOURCE_RTC_IMAGE_GIF = 8, - /** Remote video received from network. - */ - VIDEO_SOURCE_REMOTE = 9, - /** Video for transcoded. - */ - VIDEO_SOURCE_TRANSCODED = 10, - - /** Video captured by the third camera. - */ - VIDEO_SOURCE_CAMERA_THIRD = 11, - /** Video captured by the fourth camera. - */ - VIDEO_SOURCE_CAMERA_FOURTH = 12, - /** Video for third screen sharing. - */ - VIDEO_SOURCE_SCREEN_THIRD = 13, - /** Video for fourth screen sharing. - */ - VIDEO_SOURCE_SCREEN_FOURTH = 14, - /** Video for voice drive. - */ - VIDEO_SOURCE_SPEECH_DRIVEN = 15, - - VIDEO_SOURCE_UNKNOWN = 100 -}; - -/** - * Audio routes. - */ -enum AudioRoute -{ - /** - * -1: The default audio route. - */ - ROUTE_DEFAULT = -1, - /** - * The Headset. - */ - ROUTE_HEADSET = 0, - /** - * The Earpiece. - */ - ROUTE_EARPIECE = 1, - /** - * The Headset with no microphone. - */ - ROUTE_HEADSETNOMIC = 2, - /** - * The Speakerphone. - */ - ROUTE_SPEAKERPHONE = 3, - /** - * The Loudspeaker. - */ - ROUTE_LOUDSPEAKER = 4, - /** - * The Bluetooth Device via HFP. - */ - ROUTE_BLUETOOTH_DEVICE_HFP = 5, - /** - * The USB. - */ - ROUTE_USB = 6, - /** - * The HDMI. - */ - ROUTE_HDMI = 7, - /** - * The DisplayPort. - */ - ROUTE_DISPLAYPORT = 8, - /** - * The AirPlay. - */ - ROUTE_AIRPLAY = 9, - /** - * The Bluetooth Device via A2DP. - */ - ROUTE_BLUETOOTH_DEVICE_A2DP = 10, -}; - -/** - * Bytes per sample - */ -enum BYTES_PER_SAMPLE { - /** - * two bytes per sample - */ - TWO_BYTES_PER_SAMPLE = 2, -}; - -struct AudioParameters { - int sample_rate; - size_t channels; - size_t frames_per_buffer; - - AudioParameters() - : sample_rate(0), - channels(0), - frames_per_buffer(0) {} -}; - -/** - * The use mode of the audio data. - */ -enum RAW_AUDIO_FRAME_OP_MODE_TYPE { - /** 0: Read-only mode: Users only read the data from `AudioFrame` without modifying anything. - * For example, when users acquire the data with the Agora SDK, then start the media push. - */ - RAW_AUDIO_FRAME_OP_MODE_READ_ONLY = 0, - - /** 2: Read and write mode: Users read the data from `AudioFrame`, modify it, and then play it. - * For example, when users have their own audio-effect processing module and perform some voice pre-processing, such as a voice change. - */ - RAW_AUDIO_FRAME_OP_MODE_READ_WRITE = 2, -}; - -} // namespace rtc - -namespace media { - /** - * The type of media device. - */ -enum MEDIA_SOURCE_TYPE { - /** - * 0: The audio playback device. - */ - AUDIO_PLAYOUT_SOURCE = 0, - /** - * 1: Microphone. - */ - AUDIO_RECORDING_SOURCE = 1, - /** - * 2: Video captured by primary camera. - */ - PRIMARY_CAMERA_SOURCE = 2, - /** - * 3: Video captured by secondary camera. - */ - SECONDARY_CAMERA_SOURCE = 3, - /** - * 4: Video captured by primary screen capturer. - */ - PRIMARY_SCREEN_SOURCE = 4, - /** - * 5: Video captured by secondary screen capturer. - */ - SECONDARY_SCREEN_SOURCE = 5, - /** - * 6: Video captured by custom video source. - */ - CUSTOM_VIDEO_SOURCE = 6, - /** - * 7: Video for media player sharing. - */ - MEDIA_PLAYER_SOURCE = 7, - /** - * 8: Video for png image. - */ - RTC_IMAGE_PNG_SOURCE = 8, - /** - * 9: Video for jpeg image. - */ - RTC_IMAGE_JPEG_SOURCE = 9, - /** - * 10: Video for gif image. - */ - RTC_IMAGE_GIF_SOURCE = 10, - /** - * 11: Remote video received from network. - */ - REMOTE_VIDEO_SOURCE = 11, - /** - * 12: Video for transcoded. - */ - TRANSCODED_VIDEO_SOURCE = 12, - /** - * 13: Video for voice drive. - */ - SPEECH_DRIVEN_VIDEO_SOURCE = 13, - /** - * 100: Internal Usage only. - */ - UNKNOWN_MEDIA_SOURCE = 100 -}; -/** Definition of contentinspect - */ -#define MAX_CONTENT_INSPECT_MODULE_COUNT 32 -enum CONTENT_INSPECT_RESULT { - CONTENT_INSPECT_NEUTRAL = 1, - CONTENT_INSPECT_SEXY = 2, - CONTENT_INSPECT_PORN = 3, -}; - -enum CONTENT_INSPECT_TYPE { -/** - * (Default) content inspect type invalid - */ -CONTENT_INSPECT_INVALID = 0, -/** - * @deprecated - * Content inspect type moderation - */ -CONTENT_INSPECT_MODERATION __deprecated = 1, -/** - * Content inspect type supervise - */ -CONTENT_INSPECT_SUPERVISION = 2, -/** - * Content inspect type image moderation - */ -CONTENT_INSPECT_IMAGE_MODERATION = 3 -}; - -struct ContentInspectModule { - /** - * The content inspect module type. - */ - CONTENT_INSPECT_TYPE type; - /**The content inspect frequency, default is 0 second. - * the frequency <= 0 is invalid. - */ - unsigned int interval; - ContentInspectModule() { - type = CONTENT_INSPECT_INVALID; - interval = 0; - } -}; -/** Definition of ContentInspectConfig. - */ -struct ContentInspectConfig { - const char* extraInfo; - /** - * The specific server configuration for image moderation. Please contact technical support. - */ - const char* serverConfig; - /**The content inspect modules, max length of modules is 32. - * the content(snapshot of send video stream, image) can be used to max of 32 types functions. - */ - ContentInspectModule modules[MAX_CONTENT_INSPECT_MODULE_COUNT]; - /**The content inspect module count. - */ - int moduleCount; - ContentInspectConfig& operator=(const ContentInspectConfig& rth) - { - extraInfo = rth.extraInfo; - serverConfig = rth.serverConfig; - moduleCount = rth.moduleCount; - memcpy(&modules, &rth.modules, MAX_CONTENT_INSPECT_MODULE_COUNT * sizeof(ContentInspectModule)); - return *this; - } - ContentInspectConfig() :extraInfo(NULL), serverConfig(NULL), moduleCount(0){} -}; - -namespace base { - -typedef void* view_t; - -typedef const char* user_id_t; - -static const uint8_t kMaxCodecNameLength = 50; - -/** - * The definition of the PacketOptions struct, which contains infomation of the packet - * in the RTP (Real-time Transport Protocal) header. - */ -struct PacketOptions { - /** - * The timestamp of the packet. - */ - uint32_t timestamp; - // Audio level indication. - uint8_t audioLevelIndication; - PacketOptions() - : timestamp(0), - audioLevelIndication(127) {} -}; - -/** - * The detailed information of the incoming audio encoded frame. - */ - -struct AudioEncodedFrameInfo { - /** - * The send time of the packet. - */ - uint64_t sendTs; - /** - * The codec of the packet. - */ - uint8_t codec; - AudioEncodedFrameInfo() - : sendTs(0), - codec(0) {} -}; - -/** - * The detailed information of the incoming audio frame in the PCM format. - */ -struct AudioPcmFrame { - /** - * The buffer size of the PCM audio frame. - */ - OPTIONAL_ENUM_SIZE_T { - // Stereo, 32 kHz, 60 ms (2 * 32 * 60) - /** - * The max number of the samples of the data. - * - * When the number of audio channel is two, the sample rate is 32 kHZ, - * the buffer length of the data is 60 ms, the number of the samples of the data is 3840 (2 x 32 x 60). - */ - kMaxDataSizeSamples = 3840, - /** The max number of the bytes of the data. */ - kMaxDataSizeBytes = kMaxDataSizeSamples * sizeof(int16_t), - }; - - /** The timestamp (ms) of the audio frame. - */ - int64_t capture_timestamp; - /** The number of samples per channel. - */ - size_t samples_per_channel_; - /** The sample rate (Hz) of the audio data. - */ - int sample_rate_hz_; - /** The channel number. - */ - size_t num_channels_; - /** The number of bytes per sample. - */ - rtc::BYTES_PER_SAMPLE bytes_per_sample; - /** The audio frame data. */ - int16_t data_[kMaxDataSizeSamples]; - - /** - * @technical preview - * data_[kMaxDataSizeSamples] is real stereo data - */ - bool is_stereo_; - - AudioPcmFrame& operator=(const AudioPcmFrame& src) { - if (this == &src) { - return *this; - } - - capture_timestamp = src.capture_timestamp; - samples_per_channel_ = src.samples_per_channel_; - sample_rate_hz_ = src.sample_rate_hz_; - bytes_per_sample = src.bytes_per_sample; - num_channels_ = src.num_channels_; - is_stereo_ = src.is_stereo_; - - size_t length = src.samples_per_channel_ * src.num_channels_; - if (length > kMaxDataSizeSamples) { - length = kMaxDataSizeSamples; - } - - memcpy(data_, src.data_, length * sizeof(int16_t)); - - return *this; - } - - AudioPcmFrame() - : capture_timestamp(0), - samples_per_channel_(0), - sample_rate_hz_(0), - num_channels_(0), - bytes_per_sample(rtc::TWO_BYTES_PER_SAMPLE), - is_stereo_(false) { - memset(data_, 0, sizeof(data_)); - } - - AudioPcmFrame(const AudioPcmFrame& src) - : capture_timestamp(src.capture_timestamp), - samples_per_channel_(src.samples_per_channel_), - sample_rate_hz_(src.sample_rate_hz_), - num_channels_(src.num_channels_), - bytes_per_sample(src.bytes_per_sample), - is_stereo_(src.is_stereo_) { - size_t length = src.samples_per_channel_ * src.num_channels_; - if (length > kMaxDataSizeSamples) { - length = kMaxDataSizeSamples; - } - - memcpy(this->data_, src.data_, length * sizeof(int16_t)); - } -}; - -/** Audio dual-mono output mode - */ -enum AUDIO_DUAL_MONO_MODE { - /**< ChanLOut=ChanLin, ChanRout=ChanRin */ - AUDIO_DUAL_MONO_STEREO = 0, - /**< ChanLOut=ChanRout=ChanLin */ - AUDIO_DUAL_MONO_L = 1, - /**< ChanLOut=ChanRout=ChanRin */ - AUDIO_DUAL_MONO_R = 2, - /**< ChanLout=ChanRout=(ChanLin+ChanRin)/2 */ - AUDIO_DUAL_MONO_MIX = 3 -}; - -/** - * Video pixel formats. - */ -enum VIDEO_PIXEL_FORMAT { - /** - * 0: Default format. - */ - VIDEO_PIXEL_DEFAULT = 0, - /** - * 1: I420. - */ - VIDEO_PIXEL_I420 = 1, - /** - * 2: BGRA. - */ - VIDEO_PIXEL_BGRA = 2, - /** - * 3: NV21. - */ - VIDEO_PIXEL_NV21 = 3, - /** - * 4: RGBA. - */ - VIDEO_PIXEL_RGBA = 4, - /** - * 8: NV12. - */ - VIDEO_PIXEL_NV12 = 8, - /** - * 10: GL_TEXTURE_2D - */ - VIDEO_TEXTURE_2D = 10, - /** - * 11: GL_TEXTURE_OES - */ - VIDEO_TEXTURE_OES = 11, - /* - 12: pixel format for iOS CVPixelBuffer NV12 - */ - VIDEO_CVPIXEL_NV12 = 12, - /* - 13: pixel format for iOS CVPixelBuffer I420 - */ - VIDEO_CVPIXEL_I420 = 13, - /* - 14: pixel format for iOS CVPixelBuffer BGRA - */ - VIDEO_CVPIXEL_BGRA = 14, - /** - 15: pixel format for iOS CVPixelBuffer P010(10bit NV12) - */ - VIDEO_CVPIXEL_P010 = 15, - /** - * 16: I422. - */ - VIDEO_PIXEL_I422 = 16, - /** - * 17: ID3D11Texture2D, only support DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_TYPELESS, DXGI_FORMAT_NV12 texture format - */ - VIDEO_TEXTURE_ID3D11TEXTURE2D = 17, - /** - * 18: I010. 10bit I420 data. - * @technical preview - */ - VIDEO_PIXEL_I010 = 18, -}; - -/** - * The video display mode. - */ -enum RENDER_MODE_TYPE { - /** - * 1: Uniformly scale the video until it fills the visible boundaries - * (cropped). One dimension of the video may have clipped contents. - */ - RENDER_MODE_HIDDEN = 1, - /** - * 2: Uniformly scale the video until one of its dimension fits the boundary - * (zoomed to fit). Areas that are not filled due to the disparity in the - * aspect ratio will be filled with black. - */ - RENDER_MODE_FIT = 2, - /** - * @deprecated - * 3: This mode is deprecated. - */ - RENDER_MODE_ADAPTIVE __deprecated = 3, -}; - -/** - * The camera video source type - */ -enum CAMERA_VIDEO_SOURCE_TYPE { - /** - * 0: the video frame comes from the front camera - */ - CAMERA_SOURCE_FRONT = 0, - /** - * 1: the video frame comes from the back camera - */ - CAMERA_SOURCE_BACK = 1, - /** - * 1: the video frame source is unsepcified - */ - VIDEO_SOURCE_UNSPECIFIED = 2, -}; - -/** - * The IVideoFrameMetaInfo class. - * This interface provides access to metadata information. - */ -class IVideoFrameMetaInfo { - public: - enum META_INFO_KEY { - KEY_FACE_CAPTURE = 0, - }; - virtual ~IVideoFrameMetaInfo() {}; - virtual const char* getMetaInfoStr(META_INFO_KEY key) const = 0; -}; - -struct ColorSpace { - enum PrimaryID { - // The indices are equal to the values specified in T-REC H.273 Table 2. - PRIMARYID_BT709 = 1, - PRIMARYID_UNSPECIFIED = 2, - PRIMARYID_BT470M = 4, - PRIMARYID_BT470BG = 5, - PRIMARYID_SMPTE170M = 6, // Identical to BT601 - PRIMARYID_SMPTE240M = 7, - PRIMARYID_FILM = 8, - PRIMARYID_BT2020 = 9, - PRIMARYID_SMPTEST428 = 10, - PRIMARYID_SMPTEST431 = 11, - PRIMARYID_SMPTEST432 = 12, - PRIMARYID_JEDECP22 = 22, // Identical to EBU3213-E - }; - - enum RangeID { - // The indices are equal to the values specified at - // https://www.webmproject.org/docs/container/#colour for the element Range. - RANGEID_INVALID = 0, - // Limited Rec. 709 color range with RGB values ranging from 16 to 235. - RANGEID_LIMITED = 1, - // Full RGB color range with RGB valees from 0 to 255. - RANGEID_FULL = 2, - // Range is defined by MatrixCoefficients/TransferCharacteristics. - RANGEID_DERIVED = 3, - }; - - enum MatrixID { - // The indices are equal to the values specified in T-REC H.273 Table 4. - MATRIXID_RGB = 0, - MATRIXID_BT709 = 1, - MATRIXID_UNSPECIFIED = 2, - MATRIXID_FCC = 4, - MATRIXID_BT470BG = 5, - MATRIXID_SMPTE170M = 6, - MATRIXID_SMPTE240M = 7, - MATRIXID_YCOCG = 8, - MATRIXID_BT2020_NCL = 9, - MATRIXID_BT2020_CL = 10, - MATRIXID_SMPTE2085 = 11, - MATRIXID_CDNCLS = 12, - MATRIXID_CDCLS = 13, - MATRIXID_BT2100_ICTCP = 14, - }; - - enum TransferID { - // The indices are equal to the values specified in T-REC H.273 Table 3. - TRANSFERID_BT709 = 1, - TRANSFERID_UNSPECIFIED = 2, - TRANSFERID_GAMMA22 = 4, - TRANSFERID_GAMMA28 = 5, - TRANSFERID_SMPTE170M = 6, - TRANSFERID_SMPTE240M = 7, - TRANSFERID_LINEAR = 8, - TRANSFERID_LOG = 9, - TRANSFERID_LOG_SQRT = 10, - TRANSFERID_IEC61966_2_4 = 11, - TRANSFERID_BT1361_ECG = 12, - TRANSFERID_IEC61966_2_1 = 13, - TRANSFERID_BT2020_10 = 14, - TRANSFERID_BT2020_12 = 15, - TRANSFERID_SMPTEST2084 = 16, - TRANSFERID_SMPTEST428 = 17, - TRANSFERID_ARIB_STD_B67 = 18, - }; - - PrimaryID primaries; - TransferID transfer; - MatrixID matrix; - RangeID range; - - ColorSpace() - : primaries(PRIMARYID_UNSPECIFIED), transfer(TRANSFERID_UNSPECIFIED), - matrix(MATRIXID_UNSPECIFIED), range(RANGEID_INVALID) {} - - bool validate() const { - return primaries != PRIMARYID_UNSPECIFIED || transfer != TRANSFERID_UNSPECIFIED || - matrix != MATRIXID_UNSPECIFIED || - range != RANGEID_INVALID; - } -}; - -/** - * The definition of the Hdr10MetadataInfo struct. - */ -struct Hdr10MetadataInfo { - /** - * The x coordinates of the red value in the CIE1931 color space. The values need to normalized to 50,000. - */ - uint16_t redPrimaryX; - /** - * The y coordinates of the red value in the CIE1931 color space. The values need to normalized to 50,000. - */ - uint16_t redPrimaryY; - /** - * The x coordinates of the green value in the CIE1931 color space. The values need to normalized to 50,000. - */ - uint16_t greenPrimaryX; - /** - * The y coordinates of the green value in the CIE1931 color space. The values need to normalized to 50,000. - */ - uint16_t greenPrimaryY; - /** - * The x coordinates of the blue value in the CIE1931 color space. The values need to normalized to 50,000. - */ - uint16_t bluePrimaryX; - /** - * The y coordinates of the blue value in the CIE1931 color space. The values need to normalized to 50,000. - */ - uint16_t bluePrimaryY; - /** - * The x coordinates of the white point in the CIE1931 color space.The values need to normalized to 50,000. - */ - uint16_t whitePointX; - /** - * The y coordinates of the white point in the CIE1931 color space.The values need to normalized to 50,000. - */ - uint16_t whitePointY; - /** - * The maximum number of nits of the display used to master the content. The values need to normalized to 10,000. - */ - unsigned int maxMasteringLuminance; - /** - * The minimum number of nits of the display used to master the content. The values need to normalized to 10,000. - */ - unsigned int minMasteringLuminance; - /** - * The maximum content light level (MaxCLL). This is the nit value corresponding to the brightest pixel used anywhere in the content. - */ - uint16_t maxContentLightLevel; - /** - * The maximum frame average light level (MaxFALL). This is the nit value corresponding to the average luminance of the frame which has the brightest average luminance anywhere in the content. - */ - uint16_t maxFrameAverageLightLevel; - - Hdr10MetadataInfo() - : redPrimaryX(0), - redPrimaryY(0), - greenPrimaryX(0), - greenPrimaryY(0), - bluePrimaryX(0), - bluePrimaryY(0), - whitePointX(0), - whitePointY(0), - maxMasteringLuminance(0), - minMasteringLuminance(0), - maxContentLightLevel(0), - maxFrameAverageLightLevel(0){} - - bool validate() const { - return maxContentLightLevel >= 0 && maxContentLightLevel <= 20000 && - maxFrameAverageLightLevel >= 0 && - maxFrameAverageLightLevel <= 20000; - } -}; - -/** - * The relative position between alphabuffer and the frame. - */ -enum ALPHA_STITCH_MODE { - /** - * 0: Normal frame without alphabuffer stitched - */ - NO_ALPHA_STITCH = 0, - /** - * 1: Alphabuffer is above the frame - */ - ALPHA_STITCH_UP = 1, - /** - * 2: Alphabuffer is below the frame - */ - ALPHA_STITCH_BELOW = 2, - /** - * 3: Alphabuffer is on the left of frame - */ - ALPHA_STITCH_LEFT = 3, - /** - * 4: Alphabuffer is on the right of frame - */ - ALPHA_STITCH_RIGHT = 4, -}; - - -/** - * The definition of the ExternalVideoFrame struct. - */ -struct ExternalVideoFrame { - ExternalVideoFrame() - : type(VIDEO_BUFFER_RAW_DATA), - format(VIDEO_PIXEL_DEFAULT), - buffer(NULL), - stride(0), - height(0), - cropLeft(0), - cropTop(0), - cropRight(0), - cropBottom(0), - rotation(0), - timestamp(0), - eglContext(NULL), - eglType(EGL_CONTEXT10), - textureId(0), - fenceObject(0), - metadataBuffer(NULL), - metadataSize(0), - alphaBuffer(NULL), - fillAlphaBuffer(false), - alphaStitchMode(NO_ALPHA_STITCH), - d3d11Texture2d(NULL), - textureSliceIndex(0){} - - /** - * The EGL context type. - */ - enum EGL_CONTEXT_TYPE { - /** - * 0: When using the OpenGL interface (javax.microedition.khronos.egl.*) defined by Khronos - */ - EGL_CONTEXT10 = 0, - /** - * 0: When using the OpenGL interface (android.opengl.*) defined by Android - */ - EGL_CONTEXT14 = 1, - }; - - /** - * Video buffer types. - */ - enum VIDEO_BUFFER_TYPE { - /** - * 1: Raw data. - */ - VIDEO_BUFFER_RAW_DATA = 1, - /** - * 2: The same as VIDEO_BUFFER_RAW_DATA. - */ - VIDEO_BUFFER_ARRAY = 2, - /** - * 3: The video buffer in the format of texture. - */ - VIDEO_BUFFER_TEXTURE = 3, - }; - - /** - * The buffer type: #VIDEO_BUFFER_TYPE. - */ - VIDEO_BUFFER_TYPE type; - /** - * The pixel format: #VIDEO_PIXEL_FORMAT - */ - VIDEO_PIXEL_FORMAT format; - /** - * The video buffer. - */ - void* buffer; - /** - * The line spacing of the incoming video frame (px). For - * texture, it is the width of the texture. - */ - int stride; - /** - * The height of the incoming video frame. - */ - int height; - /** - * [Raw data related parameter] The number of pixels trimmed from the left. The default value is - * 0. - */ - int cropLeft; - /** - * [Raw data related parameter] The number of pixels trimmed from the top. The default value is - * 0. - */ - int cropTop; - /** - * [Raw data related parameter] The number of pixels trimmed from the right. The default value is - * 0. - */ - int cropRight; - /** - * [Raw data related parameter] The number of pixels trimmed from the bottom. The default value - * is 0. - */ - int cropBottom; - /** - * [Raw data related parameter] The clockwise rotation information of the video frame. You can set the - * rotation angle as 0, 90, 180, or 270. The default value is 0. - */ - int rotation; - /** - * The timestamp (ms) of the incoming video frame. An incorrect timestamp results in a frame loss or - * unsynchronized audio and video. - * - * Please refer to getAgoraCurrentMonotonicTimeInMs or getCurrentMonotonicTimeInMs - * to determine how to fill this filed. - */ - long long timestamp; - /** - * [Texture-related parameter] - * When using the OpenGL interface (javax.microedition.khronos.egl.*) defined by Khronos, set EGLContext to this field. - * When using the OpenGL interface (android.opengl.*) defined by Android, set EGLContext to this field. - */ - void *eglContext; - /** - * [Texture related parameter] Texture ID used by the video frame. - */ - EGL_CONTEXT_TYPE eglType; - /** - * [Texture related parameter] Incoming 4 × 4 transformational matrix. The typical value is a unit matrix. - */ - int textureId; - /** - * [Texture related parameter] The fence object related to the textureId parameter, indicating the synchronization status of the video data in Texture format. - * The default value is 0 - */ - long long fenceObject; - /** - * [Texture related parameter] Incoming 4 × 4 transformational matrix. The typical value is a unit matrix. - */ - float matrix[16]; - /** - * [Texture related parameter] The MetaData buffer. - * The default value is NULL - */ - uint8_t* metadataBuffer; - /** - * [Texture related parameter] The MetaData size. - * The default value is 0 - */ - int metadataSize; - /** - * Indicates the alpha channel of current frame, which is consistent with the dimension of the video frame. - * The value range of each pixel is [0,255], where 0 represents the background; 255 represents the foreground. - * The default value is NULL. - */ - uint8_t* alphaBuffer; - /** - * [For bgra or rgba only] Extract alphaBuffer from bgra or rgba data. Set it true if you do not explicitly specify the alphabuffer. - * The default value is false - */ - bool fillAlphaBuffer; - /** - * The relative position between alphabuffer and the frame. - * 0: Normal frame; - * 1: Alphabuffer is above the frame; - * 2: Alphabuffer is below the frame; - * 3: Alphabuffer is on the left of frame; - * 4: Alphabuffer is on the right of frame; - * The default value is 0. - */ - ALPHA_STITCH_MODE alphaStitchMode; - - /** - * [For Windows only] The pointer of ID3D11Texture2D used by the video frame. - */ - void *d3d11Texture2d; - - /** - * [For Windows only] The index of ID3D11Texture2D array used by the video frame. - */ - int textureSliceIndex; - - /** - * metadata info used for hdr video data - */ - Hdr10MetadataInfo hdr10MetadataInfo; - - /** - * The ColorSpace of the video frame. - */ - ColorSpace colorSpace; -}; - -/** - * The definition of the VideoFrame struct. - */ -struct VideoFrame { - VideoFrame(): - type(VIDEO_PIXEL_DEFAULT), - width(0), - height(0), - yStride(0), - uStride(0), - vStride(0), - yBuffer(NULL), - uBuffer(NULL), - vBuffer(NULL), - rotation(0), - renderTimeMs(0), - avsync_type(0), - metadata_buffer(NULL), - metadata_size(0), - sharedContext(0), - textureId(0), - d3d11Texture2d(NULL), - alphaBuffer(NULL), - alphaStitchMode(NO_ALPHA_STITCH), - pixelBuffer(NULL), - metaInfo(NULL){ - memset(matrix, 0, sizeof(matrix)); - } - /** - * The video pixel format: #VIDEO_PIXEL_FORMAT. - */ - VIDEO_PIXEL_FORMAT type; - /** - * The width of the video frame. - */ - int width; - /** - * The height of the video frame. - */ - int height; - /** - * The line span of Y buffer in the YUV data. - */ - int yStride; - /** - * The line span of U buffer in the YUV data. - */ - int uStride; - /** - * The line span of V buffer in the YUV data. - */ - int vStride; - /** - * The pointer to the Y buffer in the YUV data. - */ - uint8_t* yBuffer; - /** - * The pointer to the U buffer in the YUV data. - */ - uint8_t* uBuffer; - /** - * The pointer to the V buffer in the YUV data. - */ - uint8_t* vBuffer; - /** - * The clockwise rotation information of this frame. You can set it as 0, 90, 180 or 270. - */ - int rotation; - /** - * The timestamp to render the video stream. Use this parameter for audio-video synchronization when - * rendering the video. - * - * @note This parameter is for rendering the video, not capturing the video. - */ - int64_t renderTimeMs; - /** - * The type of audio-video synchronization. - */ - int avsync_type; - /** - * [Texture related parameter] The MetaData buffer. - * The default value is NULL - */ - uint8_t* metadata_buffer; - /** - * [Texture related parameter] The MetaData size. - * The default value is 0 - */ - int metadata_size; - /** - * [Texture related parameter], egl context. - */ - void* sharedContext; - /** - * [Texture related parameter], Texture ID used by the video frame. - */ - int textureId; - /** - * [Texture related parameter] The pointer of ID3D11Texture2D used by the video frame,for Windows only. - */ - void* d3d11Texture2d; - /** - * [Texture related parameter], Incoming 4 × 4 transformational matrix. - */ - float matrix[16]; - /** - * Indicates the alpha channel of current frame, which is consistent with the dimension of the video frame. - * The value range of each pixel is [0,255], where 0 represents the background; 255 represents the foreground. - * The default value is NULL. - */ - uint8_t* alphaBuffer; - /** - * The relative position between alphabuffer and the frame. - * 0: Normal frame; - * 1: Alphabuffer is above the frame; - * 2: Alphabuffer is below the frame; - * 3: Alphabuffer is on the left of frame; - * 4: Alphabuffer is on the right of frame; - * The default value is 0. - */ - ALPHA_STITCH_MODE alphaStitchMode; - /** - *The type of CVPixelBufferRef, for iOS and macOS only. - */ - void* pixelBuffer; - /** - * The pointer to IVideoFrameMetaInfo, which is the interface to get metainfo contents from VideoFrame. - */ - IVideoFrameMetaInfo* metaInfo; - - /** - * metadata info used for hdr video data - */ - Hdr10MetadataInfo hdr10MetadataInfo; - - /** - * The ColorSpace of the video frame - */ - ColorSpace colorSpace; -}; - -/** - * The IVideoFrameObserver class. - */ -class IVideoFrameObserver { - public: - /** - * Occurs each time the player receives a video frame. - * - * After registering the video frame observer, - * the callback occurs each time the player receives a video frame to report the detailed information of the video frame. - * @param frame The detailed information of the video frame. See {@link VideoFrame}. - */ - virtual void onFrame(const VideoFrame* frame) = 0; - virtual ~IVideoFrameObserver() {} - virtual bool isExternal() { return true; } - virtual VIDEO_PIXEL_FORMAT getVideoFormatPreference() { return VIDEO_PIXEL_DEFAULT; } -}; - -enum MEDIA_PLAYER_SOURCE_TYPE { - /** - * The real type of media player when use MEDIA_PLAYER_SOURCE_DEFAULT is decided by the - * type of SDK package. It is full feature media player in full-featured SDK, or simple - * media player in others. - */ - MEDIA_PLAYER_SOURCE_DEFAULT, - /** - * Full featured media player is designed to support more codecs and media format, which - * requires more package size than simple player. If you need this player enabled, you - * might need to download a full-featured SDK. - */ - MEDIA_PLAYER_SOURCE_FULL_FEATURED, - /** - * Simple media player with limit codec supported, which requires minimal package size - * requirement and is enabled by default - */ - MEDIA_PLAYER_SOURCE_SIMPLE, -}; - -enum VIDEO_MODULE_POSITION { - POSITION_POST_CAPTURER = 1 << 0, - POSITION_PRE_RENDERER = 1 << 1, - POSITION_PRE_ENCODER = 1 << 2, - POSITION_POST_CAPTURER_ORIGIN = 1 << 3, -}; - -} // namespace base - -/** - * The audio frame observer. - */ -class IAudioPcmFrameSink { - public: - /** - * Occurs when each time the player receives an audio frame. - * - * After registering the audio frame observer, - * the callback occurs when each time the player receives an audio frame, - * reporting the detailed information of the audio frame. - * @param frame The detailed information of the audio frame. See {@link AudioPcmFrame}. - */ - virtual void onFrame(agora::media::base::AudioPcmFrame* frame) = 0; - virtual ~IAudioPcmFrameSink() {} -}; - -/** - * The IAudioFrameObserverBase class. - */ -class IAudioFrameObserverBase { - public: - /** - * Audio frame types. - */ - enum AUDIO_FRAME_TYPE { - /** - * 0: 16-bit PCM. - */ - FRAME_TYPE_PCM16 = 0, - }; - enum { MAX_HANDLE_TIME_CNT = 10 }; - /** - * The definition of the AudioFrame struct. - */ - struct AudioFrame { - /** - * The audio frame type: #AUDIO_FRAME_TYPE. - */ - AUDIO_FRAME_TYPE type; - /** - * The number of samples per channel in this frame. - */ - int samplesPerChannel; - /** - * The number of bytes per sample: #BYTES_PER_SAMPLE - */ - agora::rtc::BYTES_PER_SAMPLE bytesPerSample; - /** - * The number of audio channels (data is interleaved, if stereo). - * - 1: Mono. - * - 2: Stereo. - */ - int channels; - /** - * The sample rate - */ - int samplesPerSec; - /** - * The data buffer of the audio frame. When the audio frame uses a stereo channel, the data - * buffer is interleaved. - * - * Buffer data size: buffer = samplesPerChannel × channels × bytesPerSample. - */ - void* buffer; - /** - * The timestamp to render the audio data. - * - * You can use this timestamp to restore the order of the captured audio frame, and synchronize - * audio and video frames in video scenarios, including scenarios where external video sources - * are used. - */ - int64_t renderTimeMs; - /** - * A reserved parameter. - * - * You can use this presentationMs parameter to indicate the presenation milisecond timestamp, - * this will then filled into audio4 extension part, the remote side could use this pts in av - * sync process with video frame. - */ - int avsync_type; - /** - * The pts timestamp of this audio frame. - * - * This timestamp is used to indicate the origin pts time of the frame, and sync with video frame by - * the pts time stamp - */ - int64_t presentationMs; - /** - * The number of the audio track. - */ - int audioTrackNumber; - /** - * RTP timestamp of the first sample in the audio frame - */ - uint32_t rtpTimestamp; - - AudioFrame() : type(FRAME_TYPE_PCM16), - samplesPerChannel(0), - bytesPerSample(rtc::TWO_BYTES_PER_SAMPLE), - channels(0), - samplesPerSec(0), - buffer(NULL), - renderTimeMs(0), - avsync_type(0), - presentationMs(0), - audioTrackNumber(0), - rtpTimestamp(0) {} - }; - - enum AUDIO_FRAME_POSITION { - AUDIO_FRAME_POSITION_NONE = 0x0000, - /** The position for observing the playback audio of all remote users after mixing - */ - AUDIO_FRAME_POSITION_PLAYBACK = 0x0001, - /** The position for observing the recorded audio of the local user - */ - AUDIO_FRAME_POSITION_RECORD = 0x0002, - /** The position for observing the mixed audio of the local user and all remote users - */ - AUDIO_FRAME_POSITION_MIXED = 0x0004, - /** The position for observing the audio of a single remote user before mixing - */ - AUDIO_FRAME_POSITION_BEFORE_MIXING = 0x0008, - /** The position for observing the ear monitoring audio of the local user - */ - AUDIO_FRAME_POSITION_EAR_MONITORING = 0x0010, - }; - - struct AudioParams { - /** The audio sample rate (Hz), which can be set as one of the following values: - - - `8000` - - `16000` (Default) - - `32000` - - `44100 ` - - `48000` - */ - int sample_rate; - - /* The number of audio channels, which can be set as either of the following values: - - - `1`: Mono (Default) - - `2`: Stereo - */ - int channels; - - /* The use mode of the audio data. See AgoraAudioRawFrameOperationMode. - */ - rtc::RAW_AUDIO_FRAME_OP_MODE_TYPE mode; - - /** The number of samples. For example, set it as 1024 for RTMP or RTMPS - streaming. - */ - int samples_per_call; - - AudioParams() : sample_rate(0), channels(0), mode(rtc::RAW_AUDIO_FRAME_OP_MODE_READ_ONLY), samples_per_call(0) {} - AudioParams(int samplerate, int channel, rtc::RAW_AUDIO_FRAME_OP_MODE_TYPE type, int samplesPerCall) : sample_rate(samplerate), channels(channel), mode(type), samples_per_call(samplesPerCall) {} - }; - - public: - virtual ~IAudioFrameObserverBase() {} - - /** - * Occurs when the recorded audio frame is received. - * @param channelId The channel name - * @param audioFrame The reference to the audio frame: AudioFrame. - * @return - * - true: The recorded audio frame is valid and is encoded and sent. - * - false: The recorded audio frame is invalid and is not encoded or sent. - */ - virtual bool onRecordAudioFrame(const char* channelId, AudioFrame& audioFrame) = 0; - /** - * Occurs when the playback audio frame is received. - * @param channelId The channel name - * @param audioFrame The reference to the audio frame: AudioFrame. - * @return - * - true: The playback audio frame is valid and is encoded and sent. - * - false: The playback audio frame is invalid and is not encoded or sent. - */ - virtual bool onPlaybackAudioFrame(const char* channelId, AudioFrame& audioFrame) = 0; - /** - * Occurs when the mixed audio data is received. - * @param channelId The channel name - * @param audioFrame The reference to the audio frame: AudioFrame. - * @return - * - true: The mixed audio data is valid and is encoded and sent. - * - false: The mixed audio data is invalid and is not encoded or sent. - */ - virtual bool onMixedAudioFrame(const char* channelId, AudioFrame& audioFrame) = 0; - /** - * Occurs when the ear monitoring audio frame is received. - * @param audioFrame The reference to the audio frame: AudioFrame. - * @return - * - true: The ear monitoring audio data is valid and is encoded and sent. - * - false: The ear monitoring audio data is invalid and is not encoded or sent. - */ - virtual bool onEarMonitoringAudioFrame(AudioFrame& audioFrame) = 0; - /** - * Occurs when the before-mixing playback audio frame is received. - * @param channelId The channel name - * @param userId ID of the remote user. - * @param audioFrame The reference to the audio frame: AudioFrame. - * @return - * - true: The before-mixing playback audio frame is valid and is encoded and sent. - * - false: The before-mixing playback audio frame is invalid and is not encoded or sent. - */ - virtual bool onPlaybackAudioFrameBeforeMixing(const char* channelId, base::user_id_t userId, AudioFrame& audioFrame) { - (void) channelId; - (void) userId; - (void) audioFrame; - return true; - } - - /** - * Sets the frame position for the audio observer. - * @return A bit mask that controls the frame position of the audio observer. - * @note - Use '|' (the OR operator) to observe multiple frame positions. - *

- * After you successfully register the audio observer, the SDK triggers this callback each time it receives a audio frame. You can determine which position to observe by setting the return value. - * The SDK provides 4 positions for observer. Each position corresponds to a callback function: - * - `AUDIO_FRAME_POSITION_PLAYBACK (1 << 0)`: The position for playback audio frame is received, which corresponds to the \ref onPlaybackFrame "onPlaybackFrame" callback. - * - `AUDIO_FRAME_POSITION_RECORD (1 << 1)`: The position for record audio frame is received, which corresponds to the \ref onRecordFrame "onRecordFrame" callback. - * - `AUDIO_FRAME_POSITION_MIXED (1 << 2)`: The position for mixed audio frame is received, which corresponds to the \ref onMixedFrame "onMixedFrame" callback. - * - `AUDIO_FRAME_POSITION_BEFORE_MIXING (1 << 3)`: The position for playback audio frame before mixing is received, which corresponds to the \ref onPlaybackFrameBeforeMixing "onPlaybackFrameBeforeMixing" callback. - * @return The bit mask that controls the audio observation positions. - * See AUDIO_FRAME_POSITION. - */ - - virtual int getObservedAudioFramePosition() = 0; - - /** Sets the audio playback format - **Note**: - - - The SDK calculates the sample interval according to the `AudioParams` - you set in the return value of this callback and triggers the - `onPlaybackAudioFrame` callback at the calculated sample interval. - Sample interval (seconds) = `samplesPerCall`/(`sampleRate` × `channel`). - Ensure that the value of sample interval is equal to or greater than 0.01. - - @return Sets the audio format. See AgoraAudioParams. - */ - virtual AudioParams getPlaybackAudioParams() = 0; - - /** Sets the audio recording format - **Note**: - - The SDK calculates the sample interval according to the `AudioParams` - you set in the return value of this callback and triggers the - `onRecordAudioFrame` callback at the calculated sample interval. - Sample interval (seconds) = `samplesPerCall`/(`sampleRate` × `channel`). - Ensure that the value of sample interval is equal to or greater than 0.01. - - @return Sets the audio format. See AgoraAudioParams. - */ - virtual AudioParams getRecordAudioParams() = 0; - - /** Sets the audio mixing format - **Note**: - - The SDK calculates the sample interval according to the `AudioParams` - you set in the return value of this callback and triggers the - `onMixedAudioFrame` callback at the calculated sample interval. - Sample interval (seconds) = `samplesPerCall`/(`sampleRate` × `channel`). - Ensure that the value of sample interval is equal to or greater than 0.01. - - @return Sets the audio format. See AgoraAudioParams. - */ - virtual AudioParams getMixedAudioParams() = 0; - - /** Sets the ear monitoring audio format - **Note**: - - The SDK calculates the sample interval according to the `AudioParams` - you set in the return value of this callback and triggers the - `onEarMonitoringAudioFrame` callback at the calculated sample interval. - Sample interval (seconds) = `samplesPerCall`/(`sampleRate` × `channel`). - Ensure that the value of sample interval is equal to or greater than 0.01. - - @return Sets the audio format. See AgoraAudioParams. - */ - virtual AudioParams getEarMonitoringAudioParams() = 0; -}; - -/** - * The IAudioFrameObserver class. - */ -class IAudioFrameObserver : public IAudioFrameObserverBase { - public: - using IAudioFrameObserverBase::onPlaybackAudioFrameBeforeMixing; - /** - * Occurs when the before-mixing playback audio frame is received. - * @param channelId The channel name - * @param uid ID of the remote user. - * @param audioFrame The reference to the audio frame: AudioFrame. - * @return - * - true: The before-mixing playback audio frame is valid and is encoded and sent. - * - false: The before-mixing playback audio frame is invalid and is not encoded or sent. - */ - virtual bool onPlaybackAudioFrameBeforeMixing(const char* channelId, rtc::uid_t uid, AudioFrame& audioFrame) = 0; -}; - -struct AudioSpectrumData { - /** - * The audio spectrum data of audio. - */ - const float *audioSpectrumData; - /** - * The data length of audio spectrum data. - */ - int dataLength; - - AudioSpectrumData() : audioSpectrumData(NULL), dataLength(0) {} - AudioSpectrumData(const float *data, int length) : - audioSpectrumData(data), dataLength(length) {} -}; - -struct UserAudioSpectrumInfo { - /** - * User ID of the speaker. - */ - agora::rtc::uid_t uid; - /** - * The audio spectrum data of audio. - */ - struct AudioSpectrumData spectrumData; - - UserAudioSpectrumInfo() : uid(0) {} - - UserAudioSpectrumInfo(agora::rtc::uid_t uid, const float* data, int length) : uid(uid), spectrumData(data, length) {} -}; - -/** - * The IAudioSpectrumObserver class. - */ -class IAudioSpectrumObserver { -public: - virtual ~IAudioSpectrumObserver() {} - - /** - * Reports the audio spectrum of local audio. - * - * This callback reports the audio spectrum data of the local audio at the moment - * in the channel. - * - * You can set the time interval of this callback using \ref ILocalUser::enableAudioSpectrumMonitor "enableAudioSpectrumMonitor". - * - * @param data The audio spectrum data of local audio. - * - true: Processed. - * - false: Not processed. - */ - virtual bool onLocalAudioSpectrum(const AudioSpectrumData& data) = 0; - /** - * Reports the audio spectrum of remote user. - * - * This callback reports the IDs and audio spectrum data of the loudest speakers at the moment - * in the channel. - * - * You can set the time interval of this callback using \ref ILocalUser::enableAudioSpectrumMonitor "enableAudioSpectrumMonitor". - * - * @param spectrums The pointer to \ref agora::media::UserAudioSpectrumInfo "UserAudioSpectrumInfo", which is an array containing - * the user ID and audio spectrum data for each speaker. - * - This array contains the following members: - * - `uid`, which is the UID of each remote speaker - * - `spectrumData`, which reports the audio spectrum of each remote speaker. - * @param spectrumNumber The array length of the spectrums. - * - true: Processed. - * - false: Not processed. - */ - virtual bool onRemoteAudioSpectrum(const UserAudioSpectrumInfo* spectrums, unsigned int spectrumNumber) = 0; -}; - -/** - * The IVideoEncodedFrameObserver class. - */ -class IVideoEncodedFrameObserver { - public: - /** - * Occurs each time the SDK receives an encoded video image. - * @param uid The user id of remote user. - * @param imageBuffer The pointer to the video image buffer. - * @param length The data length of the video image. - * @param videoEncodedFrameInfo The information of the encoded video frame: EncodedVideoFrameInfo. - * @return Determines whether to accept encoded video image. - * - true: Accept. - * - false: Do not accept. - */ - virtual bool onEncodedVideoFrameReceived(rtc::uid_t uid, const uint8_t* imageBuffer, size_t length, - const rtc::EncodedVideoFrameInfo& videoEncodedFrameInfo) = 0; - - virtual ~IVideoEncodedFrameObserver() {} -}; - -/** - * The IVideoFrameObserver class. - */ -class IVideoFrameObserver { - public: - typedef media::base::VideoFrame VideoFrame; - /** - * The process mode of the video frame: - */ - enum VIDEO_FRAME_PROCESS_MODE { - /** - * Read-only mode. - * - * In this mode, you do not modify the video frame. The video frame observer is a renderer. - */ - PROCESS_MODE_READ_ONLY, // Observer works as a pure renderer and will not modify the original frame. - /** - * Read and write mode. - * - * In this mode, you modify the video frame. The video frame observer is a video filter. - */ - PROCESS_MODE_READ_WRITE, // Observer works as a filter that will process the video frame and affect the following frame processing in SDK. - }; - - public: - virtual ~IVideoFrameObserver() {} - - /** - * Occurs each time the SDK receives a video frame captured by the local camera. - * - * After you successfully register the video frame observer, the SDK triggers this callback each time - * a video frame is received. In this callback, you can get the video data captured by the local - * camera. You can then pre-process the data according to your scenarios. - * - * After pre-processing, you can send the processed video data back to the SDK by setting the - * `videoFrame` parameter in this callback. - * - * @note - * - If you get the video data in RGBA color encoding format, Agora does not support using this callback to send the processed data in RGBA color encoding format back to the SDK. - * - The video data that this callback gets has not been pre-processed, such as watermarking, cropping content, rotating, or image enhancement. - * - * @param videoFrame A pointer to the video frame: VideoFrame - * @param sourceType source type of video frame. See #VIDEO_SOURCE_TYPE. - * @return Determines whether to ignore the current video frame if the pre-processing fails: - * - true: Do not ignore. - * - false: Ignore, in which case this method does not sent the current video frame to the SDK. - */ - virtual bool onCaptureVideoFrame(agora::rtc::VIDEO_SOURCE_TYPE sourceType, VideoFrame& videoFrame) = 0; - - /** - * Occurs each time the SDK receives a video frame before encoding. - * - * After you successfully register the video frame observer, the SDK triggers this callback each time - * when it receives a video frame. In this callback, you can get the video data before encoding. You can then - * process the data according to your particular scenarios. - * - * After processing, you can send the processed video data back to the SDK by setting the - * `videoFrame` parameter in this callback. - * - * @note - * - To get the video data captured from the second screen before encoding, you need to set (1 << 2) as a frame position through `getObservedFramePosition`. - * - The video data that this callback gets has been pre-processed, such as watermarking, cropping content, rotating, or image enhancement. - * - This callback does not support sending processed RGBA video data back to the SDK. - * - * @param videoFrame A pointer to the video frame: VideoFrame - * @param sourceType source type of video frame. See #VIDEO_SOURCE_TYPE. - * @return Determines whether to ignore the current video frame if the pre-processing fails: - * - true: Do not ignore. - * - false: Ignore, in which case this method does not sent the current video frame to the SDK. - */ - virtual bool onPreEncodeVideoFrame(agora::rtc::VIDEO_SOURCE_TYPE sourceType, VideoFrame& videoFrame) = 0; - - /** - * Occurs each time the SDK receives a video frame decoded by the MediaPlayer. - * - * After you successfully register the video frame observer, the SDK triggers this callback each - * time a video frame is decoded. In this callback, you can get the video data decoded by the - * MediaPlayer. You can then pre-process the data according to your scenarios. - * - * After pre-processing, you can send the processed video data back to the SDK by setting the - * `videoFrame` parameter in this callback. - * - * @note - * - This callback will not be affected by the return values of \ref getVideoFrameProcessMode "getVideoFrameProcessMode", \ref getRotationApplied "getRotationApplied", \ref getMirrorApplied "getMirrorApplied", \ref getObservedFramePosition "getObservedFramePosition". - * - On Android, this callback is not affected by the return value of \ref getVideoFormatPreference "getVideoFormatPreference" - * - * @param videoFrame A pointer to the video frame: VideoFrame - * @param mediaPlayerId ID of the mediaPlayer. - * @return Determines whether to ignore the current video frame if the pre-processing fails: - * - true: Do not ignore. - * - false: Ignore, in which case this method does not sent the current video frame to the SDK. - */ - virtual bool onMediaPlayerVideoFrame(VideoFrame& videoFrame, int mediaPlayerId) = 0; - - /** - * Occurs each time the SDK receives a video frame sent by the remote user. - * - * After you successfully register the video frame observer, the SDK triggers this callback each time a - * video frame is received. In this callback, you can get the video data sent by the remote user. You - * can then post-process the data according to your scenarios. - * - * After post-processing, you can send the processed data back to the SDK by setting the `videoFrame` - * parameter in this callback. - * - * @note This callback does not support sending processed RGBA video data back to the SDK. - * - * @param channelId The channel name - * @param remoteUid ID of the remote user who sends the current video frame. - * @param videoFrame A pointer to the video frame: VideoFrame - * @return Determines whether to ignore the current video frame if the post-processing fails: - * - true: Do not ignore. - * - false: Ignore, in which case this method does not sent the current video frame to the SDK. - */ - virtual bool onRenderVideoFrame(const char* channelId, rtc::uid_t remoteUid, VideoFrame& videoFrame) = 0; - - virtual bool onTranscodedVideoFrame(VideoFrame& videoFrame) = 0; - - /** - * Occurs each time the SDK receives a video frame and prompts you to set the process mode of the video frame. - * - * After you successfully register the video frame observer, the SDK triggers this callback each time it receives - * a video frame. You need to set your preferred process mode in the return value of this callback. - * @return VIDEO_FRAME_PROCESS_MODE. - */ - virtual VIDEO_FRAME_PROCESS_MODE getVideoFrameProcessMode() { - return PROCESS_MODE_READ_ONLY; - } - - /** - * Sets the format of the raw video data output by the SDK. - * - * If you want to get raw video data in a color encoding format other than YUV 420, register this callback when - * calling `registerVideoFrameObserver`. After you successfully register the video frame observer, the SDK triggers - * this callback each time it receives a video frame. You need to set your preferred video data in the return value - * of this callback. - * - * @note If you want the video captured by the sender to be the original format, set the original video data format - * to VIDEO_PIXEL_DEFAULT in the return value. On different platforms, the original video pixel format is also - * different, for the actual video pixel format, see `VideoFrame`. - * - * @return Sets the video format. See VIDEO_PIXEL_FORMAT. - */ - virtual base::VIDEO_PIXEL_FORMAT getVideoFormatPreference() { return base::VIDEO_PIXEL_DEFAULT; } - - /** - * Occurs each time the SDK receives a video frame, and prompts you whether to rotate the captured video. - * - * If you want to rotate the captured video according to the rotation member in the `VideoFrame` class, register this - * callback by calling `registerVideoFrameObserver`. After you successfully register the video frame observer, the - * SDK triggers this callback each time it receives a video frame. You need to set whether to rotate the video frame - * in the return value of this callback. - * - * @note This function only supports video data in RGBA or YUV420. - * - * @return Determines whether to rotate. - * - `true`: Rotate the captured video. - * - `false`: (Default) Do not rotate the captured video. - */ - virtual bool getRotationApplied() { return false; } - - /** - * Occurs each time the SDK receives a video frame and prompts you whether or not to mirror the captured video. - * - * If the video data you want to obtain is a mirror image of the original video, you need to register this callback - * when calling `registerVideoFrameObserver`. After you successfully register the video frame observer, the SDK - * triggers this callback each time it receives a video frame. You need to set whether or not to mirror the video - * frame in the return value of this callback. - * - * @note This function only supports video data in RGBA and YUV420 formats. - * - * @return Determines whether to mirror. - * - `true`: Mirror the captured video. - * - `false`: (Default) Do not mirror the captured video. - */ - virtual bool getMirrorApplied() { return false; } - - /** - * Sets the frame position for the video observer. - * - * After you successfully register the video observer, the SDK triggers this callback each time it receives - * a video frame. You can determine which position to observe by setting the return value. The SDK provides - * 3 positions for observer. Each position corresponds to a callback function: - * - * POSITION_POST_CAPTURER(1 << 0): The position after capturing the video data, which corresponds to the onCaptureVideoFrame callback. - * POSITION_PRE_RENDERER(1 << 1): The position before receiving the remote video data, which corresponds to the onRenderVideoFrame callback. - * POSITION_PRE_ENCODER(1 << 2): The position before encoding the video data, which corresponds to the onPreEncodeVideoFrame callback. - * - * To observe multiple frame positions, use '|' (the OR operator). - * This callback observes POSITION_POST_CAPTURER(1 << 0) and POSITION_PRE_RENDERER(1 << 1) by default. - * To conserve the system consumption, you can reduce the number of frame positions that you want to observe. - * - * @return A bit mask that controls the frame position of the video observer: VIDEO_OBSERVER_POSITION. - */ - virtual uint32_t getObservedFramePosition() { - return base::POSITION_POST_CAPTURER | base::POSITION_PRE_RENDERER; - } - - /** - * Indicate if the observer is for internal use. - * Note: Never override this function - * @return - * - true: the observer is for external use - * - false: the observer is for internal use - */ - virtual bool isExternal() { return true; } -}; - -/** - * The external video source type. - */ -enum EXTERNAL_VIDEO_SOURCE_TYPE { - /** - * 0: non-encoded video frame. - */ - VIDEO_FRAME = 0, - /** - * 1: encoded video frame. - */ - ENCODED_VIDEO_FRAME, -}; - -/** - * The format of the recording file. - * - * @since v3.5.2 - */ -enum MediaRecorderContainerFormat { - /** - * 1: (Default) MP4. - */ - FORMAT_MP4 = 1, -}; -/** - * The recording content. - * - * @since v3.5.2 - */ -enum MediaRecorderStreamType { - /** - * Only audio. - */ - STREAM_TYPE_AUDIO = 0x01, - /** - * Only video. - */ - STREAM_TYPE_VIDEO = 0x02, - /** - * (Default) Audio and video. - */ - STREAM_TYPE_BOTH = STREAM_TYPE_AUDIO | STREAM_TYPE_VIDEO, -}; -/** - * The current recording state. - * - * @since v3.5.2 - */ -enum RecorderState { - /** - * -1: An error occurs during the recording. See RecorderReasonCode for the reason. - */ - RECORDER_STATE_ERROR = -1, - /** - * 2: The audio and video recording is started. - */ - RECORDER_STATE_START = 2, - /** - * 3: The audio and video recording is stopped. - */ - RECORDER_STATE_STOP = 3, -}; -/** - * The reason for the state change - * - * @since v3.5.2 - */ -enum RecorderReasonCode { - /** - * 0: No error occurs. - */ - RECORDER_REASON_NONE = 0, - /** - * 1: The SDK fails to write the recorded data to a file. - */ - RECORDER_REASON_WRITE_FAILED = 1, - /** - * 2: The SDK does not detect audio and video streams to be recorded, or audio and video streams are interrupted for more than five seconds during recording. - */ - RECORDER_REASON_NO_STREAM = 2, - /** - * 3: The recording duration exceeds the upper limit. - */ - RECORDER_REASON_OVER_MAX_DURATION = 3, - /** - * 4: The recording configuration changes. - */ - RECORDER_REASON_CONFIG_CHANGED = 4, -}; -/** - * Configurations for the local audio and video recording. - * - * @since v3.5.2 - */ -struct MediaRecorderConfiguration { - /** - * The absolute path (including the filename extensions) of the recording file. - * For example, `C:\Users\\AppData\Local\Agora\\example.mp4` on Windows, - * `/App Sandbox/Library/Caches/example.mp4` on iOS, `/Library/Logs/example.mp4` on macOS, and - * `/storage/emulated/0/Android/data//files/example.mp4` on Android. - * - * @note Ensure that the specified path exists and is writable. - */ - const char* storagePath; - /** - * The format of the recording file. See \ref agora::rtc::MediaRecorderContainerFormat "MediaRecorderContainerFormat". - */ - MediaRecorderContainerFormat containerFormat; - /** - * The recording content. See \ref agora::rtc::MediaRecorderStreamType "MediaRecorderStreamType". - */ - MediaRecorderStreamType streamType; - /** - * The maximum recording duration, in milliseconds. The default value is 120000. - */ - int maxDurationMs; - /** - * The interval (ms) of updating the recording information. The value range is - * [1000,10000]. Based on the set value of `recorderInfoUpdateInterval`, the - * SDK triggers the \ref IMediaRecorderObserver::onRecorderInfoUpdated "onRecorderInfoUpdated" - * callback to report the updated recording information. - */ - int recorderInfoUpdateInterval; - - MediaRecorderConfiguration() : storagePath(NULL), containerFormat(FORMAT_MP4), streamType(STREAM_TYPE_BOTH), maxDurationMs(120000), recorderInfoUpdateInterval(0) {} - MediaRecorderConfiguration(const char* path, MediaRecorderContainerFormat format, MediaRecorderStreamType type, int duration, int interval) : storagePath(path), containerFormat(format), streamType(type), maxDurationMs(duration), recorderInfoUpdateInterval(interval) {} -}; - -class IFaceInfoObserver { -public: - /** - * Occurs when the face info is received. - * @param outFaceInfo The output face info. - * @return - * - true: The face info is valid. - * - false: The face info is invalid. - */ - virtual bool onFaceInfo(const char* outFaceInfo) = 0; - - virtual ~IFaceInfoObserver() {} -}; - -/** - * Information for the recording file. - * - * @since v3.5.2 - */ -struct RecorderInfo { - /** - * The absolute path of the recording file. - */ - const char* fileName; - /** - * The recording duration, in milliseconds. - */ - unsigned int durationMs; - /** - * The size in bytes of the recording file. - */ - unsigned int fileSize; - - RecorderInfo() : fileName(NULL), durationMs(0), fileSize(0) {} - RecorderInfo(const char* name, unsigned int dur, unsigned int size) : fileName(name), durationMs(dur), fileSize(size) {} -}; - -class IMediaRecorderObserver { - public: - /** - * Occurs when the recording state changes. - * - * @since v4.0.0 - * - * When the local audio and video recording state changes, the SDK triggers this callback to report the current - * recording state and the reason for the change. - * - * @param channelId The channel name. - * @param uid ID of the user. - * @param state The current recording state. See \ref agora::media::RecorderState "RecorderState". - * @param reason The reason for the state change. See \ref agora::media::RecorderReasonCode "RecorderReasonCode". - */ - virtual void onRecorderStateChanged(const char* channelId, rtc::uid_t uid, RecorderState state, RecorderReasonCode reason) = 0; - /** - * Occurs when the recording information is updated. - * - * @since v4.0.0 - * - * After you successfully register this callback and enable the local audio and video recording, the SDK periodically triggers - * the `onRecorderInfoUpdated` callback based on the set value of `recorderInfoUpdateInterval`. This callback reports the - * filename, duration, and size of the current recording file. - * - * @param channelId The channel name. - * @param uid ID of the user. - * @param info Information about the recording file. See \ref agora::media::RecorderInfo "RecorderInfo". - * - */ - virtual void onRecorderInfoUpdated(const char* channelId, rtc::uid_t uid, const RecorderInfo& info) = 0; - - virtual ~IMediaRecorderObserver() {} -}; - -} // namespace media -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraMediaPlayerTypes.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraMediaPlayerTypes.h deleted file mode 100644 index 3beaba788..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraMediaPlayerTypes.h +++ /dev/null @@ -1,516 +0,0 @@ -// -// Agora Engine SDK -// -// Created by Sting Feng in 2020-05. -// Copyright (c) 2017 Agora.io. All rights reserved. - -#pragma once // NOLINT(build/header_guard) - -#include -#include - -#include "AgoraOptional.h" - -/** - * set analyze duration for real time stream - * @example "setPlayerOption(KEY_PLAYER_REAL_TIME_STREAM_ANALYZE_DURATION,1000000)" - */ -#define KEY_PLAYER_REAL_TIME_STREAM_ANALYZE_DURATION "analyze_duration" - -/** - * make the player to enable audio or not - * @example "setPlayerOption(KEY_PLAYER_ENABLE_AUDIO,0)" - */ -#define KEY_PLAYER_ENABLE_AUDIO "enable_audio" - -/** - * make the player to enable video or not - * @example "setPlayerOption(KEY_PLAYER_ENABLE_VIDEO,0)" - */ -#define KEY_PLAYER_ENABLE_VIDEO "enable_video" - -/** - * set the player enable to search metadata - * @example "setPlayerOption(KEY_PLAYER_DISABLE_SEARCH_METADATA,0)" - */ -#define KEY_PLAYER_ENABLE_SEARCH_METADATA "enable_search_metadata" - -/** - * set the player sei filter type - * @example "setPlayerOption(KEY_PLAYER_SEI_FILTER_TYPE,"5")" - */ -#define KEY_PLAYER_SEI_FILTER_TYPE "set_sei_filter_type" - -namespace agora { - -namespace media { - -namespace base { -static const uint8_t kMaxCharBufferLength = 50; -/** - * @brief The playback state. - * - */ -enum MEDIA_PLAYER_STATE { - /** Default state. - */ - PLAYER_STATE_IDLE = 0, - /** Opening the media file. - */ - PLAYER_STATE_OPENING, - /** The media file is opened successfully. - */ - PLAYER_STATE_OPEN_COMPLETED, - /** Playing the media file. - */ - PLAYER_STATE_PLAYING, - /** The playback is paused. - */ - PLAYER_STATE_PAUSED, - /** The playback is completed. - */ - PLAYER_STATE_PLAYBACK_COMPLETED, - /** All loops are completed. - */ - PLAYER_STATE_PLAYBACK_ALL_LOOPS_COMPLETED, - /** The playback is stopped. - */ - PLAYER_STATE_STOPPED, - /** Player pausing (internal) - */ - PLAYER_STATE_PAUSING_INTERNAL = 50, - /** Player stopping (internal) - */ - PLAYER_STATE_STOPPING_INTERNAL, - /** Player seeking state (internal) - */ - PLAYER_STATE_SEEKING_INTERNAL, - /** Player getting state (internal) - */ - PLAYER_STATE_GETTING_INTERNAL, - /** None state for state machine (internal) - */ - PLAYER_STATE_NONE_INTERNAL, - /** Do nothing state for state machine (internal) - */ - PLAYER_STATE_DO_NOTHING_INTERNAL, - /** Player set track state (internal) - */ - PLAYER_STATE_SET_TRACK_INTERNAL, - /** The playback fails. - */ - PLAYER_STATE_FAILED = 100, -}; -/** - * @brief Player error code - * - */ -enum MEDIA_PLAYER_REASON { - /** No error. - */ - PLAYER_REASON_NONE = 0, - /** The parameter is invalid. - */ - PLAYER_REASON_INVALID_ARGUMENTS = -1, - /** Internel error. - */ - PLAYER_REASON_INTERNAL = -2, - /** No resource. - */ - PLAYER_REASON_NO_RESOURCE = -3, - /** Invalid media source. - */ - PLAYER_REASON_INVALID_MEDIA_SOURCE = -4, - /** The type of the media stream is unknown. - */ - PLAYER_REASON_UNKNOWN_STREAM_TYPE = -5, - /** The object is not initialized. - */ - PLAYER_REASON_OBJ_NOT_INITIALIZED = -6, - /** The codec is not supported. - */ - PLAYER_REASON_CODEC_NOT_SUPPORTED = -7, - /** Invalid renderer. - */ - PLAYER_REASON_VIDEO_RENDER_FAILED = -8, - /** An error occurs in the internal state of the player. - */ - PLAYER_REASON_INVALID_STATE = -9, - /** The URL of the media file cannot be found. - */ - PLAYER_REASON_URL_NOT_FOUND = -10, - /** Invalid connection between the player and the Agora server. - */ - PLAYER_REASON_INVALID_CONNECTION_STATE = -11, - /** The playback buffer is insufficient. - */ - PLAYER_REASON_SRC_BUFFER_UNDERFLOW = -12, - /** The audio mixing file playback is interrupted. - */ - PLAYER_REASON_INTERRUPTED = -13, - /** The SDK does not support this function. - */ - PLAYER_REASON_NOT_SUPPORTED = -14, - /** The token has expired. - */ - PLAYER_REASON_TOKEN_EXPIRED = -15, - /** The ip has expired. - */ - PLAYER_REASON_IP_EXPIRED = -16, - /** An unknown error occurs. - */ - PLAYER_REASON_UNKNOWN = -17, -}; - -/** - * @brief The type of the media stream. - * - */ -enum MEDIA_STREAM_TYPE { - /** The type is unknown. - */ - STREAM_TYPE_UNKNOWN = 0, - /** The video stream. - */ - STREAM_TYPE_VIDEO = 1, - /** The audio stream. - */ - STREAM_TYPE_AUDIO = 2, - /** The subtitle stream. - */ - STREAM_TYPE_SUBTITLE = 3, -}; - -/** - * @brief The playback event. - * - */ -enum MEDIA_PLAYER_EVENT { - /** The player begins to seek to the new playback position. - */ - PLAYER_EVENT_SEEK_BEGIN = 0, - /** The seek operation completes. - */ - PLAYER_EVENT_SEEK_COMPLETE = 1, - /** An error occurs during the seek operation. - */ - PLAYER_EVENT_SEEK_ERROR = 2, - /** The player changes the audio track for playback. - */ - PLAYER_EVENT_AUDIO_TRACK_CHANGED = 5, - /** player buffer low - */ - PLAYER_EVENT_BUFFER_LOW = 6, - /** player buffer recover - */ - PLAYER_EVENT_BUFFER_RECOVER = 7, - /** The video or audio is interrupted - */ - PLAYER_EVENT_FREEZE_START = 8, - /** Interrupt at the end of the video or audio - */ - PLAYER_EVENT_FREEZE_STOP = 9, - /** switch source begin - */ - PLAYER_EVENT_SWITCH_BEGIN = 10, - /** switch source complete - */ - PLAYER_EVENT_SWITCH_COMPLETE = 11, - /** switch source error - */ - PLAYER_EVENT_SWITCH_ERROR = 12, - /** An application can render the video to less than a second - */ - PLAYER_EVENT_FIRST_DISPLAYED = 13, - /** cache resources exceed the maximum file count - */ - PLAYER_EVENT_REACH_CACHE_FILE_MAX_COUNT = 14, - /** cache resources exceed the maximum file size - */ - PLAYER_EVENT_REACH_CACHE_FILE_MAX_SIZE = 15, - /** Triggered when a retry is required to open the media - */ - PLAYER_EVENT_TRY_OPEN_START = 16, - /** Triggered when the retry to open the media is successful - */ - PLAYER_EVENT_TRY_OPEN_SUCCEED = 17, - /** Triggered when retrying to open media fails - */ - PLAYER_EVENT_TRY_OPEN_FAILED = 18, -}; - -/** - * @brief The play preload another source event. - * - */ -enum PLAYER_PRELOAD_EVENT { - /** preload source begin - */ - PLAYER_PRELOAD_EVENT_BEGIN = 0, - /** preload source complete - */ - PLAYER_PRELOAD_EVENT_COMPLETE = 1, - /** preload source error - */ - PLAYER_PRELOAD_EVENT_ERROR = 2, -}; - -/** - * @brief The information of the media stream object. - * - */ -struct PlayerStreamInfo { - /** The index of the media stream. */ - int streamIndex; - - /** The type of the media stream. See {@link MEDIA_STREAM_TYPE}. */ - MEDIA_STREAM_TYPE streamType; - - /** The codec of the media stream. */ - char codecName[kMaxCharBufferLength]; - - /** The language of the media stream. */ - char language[kMaxCharBufferLength]; - - /** The frame rate (fps) if the stream is video. */ - int videoFrameRate; - - /** The video bitrate (bps) if the stream is video. */ - int videoBitRate; - - /** The video width (pixel) if the stream is video. */ - int videoWidth; - - /** The video height (pixel) if the stream is video. */ - int videoHeight; - - /** The rotation angle if the steam is video. */ - int videoRotation; - - /** The sample rate if the stream is audio. */ - int audioSampleRate; - - /** The number of audio channels if the stream is audio. */ - int audioChannels; - - /** The number of bits per sample if the stream is audio. */ - int audioBitsPerSample; - - /** The total duration (millisecond) of the media stream. */ - int64_t duration; - - PlayerStreamInfo() : streamIndex(0), - streamType(STREAM_TYPE_UNKNOWN), - videoFrameRate(0), - videoBitRate(0), - videoWidth(0), - videoHeight(0), - videoRotation(0), - audioSampleRate(0), - audioChannels(0), - audioBitsPerSample(0), - duration(0) { - memset(codecName, 0, sizeof(codecName)); - memset(language, 0, sizeof(language)); - } -}; - -/** - * @brief The information of the media stream object. - * - */ -struct SrcInfo { - /** The bitrate of the media stream. The unit of the number is kbps. - * - */ - int bitrateInKbps; - - /** The name of the media stream. - * - */ - const char* name; - -}; - -/** - * @brief The type of the media metadata. - * - */ -enum MEDIA_PLAYER_METADATA_TYPE { - /** The type is unknown. - */ - PLAYER_METADATA_TYPE_UNKNOWN = 0, - /** The type is SEI. - */ - PLAYER_METADATA_TYPE_SEI = 1, -}; - -struct CacheStatistics { - /** total data size of uri - */ - int64_t fileSize; - /** data of uri has cached - */ - int64_t cacheSize; - /** data of uri has downloaded - */ - int64_t downloadSize; -}; - -/** - * @brief The real time statistics of the media stream being played. - * - */ -struct PlayerPlaybackStats { - /** Video fps. - */ - int videoFps; - /** Video bitrate (Kbps). - */ - int videoBitrateInKbps; - /** Audio bitrate (Kbps). - */ - int audioBitrateInKbps; - /** Total bitrate (Kbps). - */ - int totalBitrateInKbps; -}; - -/** - * @brief The updated information of media player. - * - */ -struct PlayerUpdatedInfo { - /** @technical preview - */ - const char* internalPlayerUuid; - /** The device ID of the playback device. - */ - const char* deviceId; - /** Video height. - */ - int videoHeight; - /** Video width. - */ - int videoWidth; - /** Audio sample rate. - */ - int audioSampleRate; - /** The audio channel number. - */ - int audioChannels; - /** The bit number of each audio sample. - */ - int audioBitsPerSample; - - PlayerUpdatedInfo() - : internalPlayerUuid(NULL), - deviceId(NULL), - videoHeight(0), - videoWidth(0), - audioSampleRate(0), - audioChannels(0), - audioBitsPerSample(0) {} -}; - -/** - * The custom data source provides a data stream input callback, and the player will continue to call back this interface, requesting the user to fill in the data that needs to be played. - */ -class IMediaPlayerCustomDataProvider { -public: - - /** - * @brief The player requests to read the data callback, you need to fill the specified length of data into the buffer - * @param buffer the buffer pointer that you need to fill data. - * @param bufferSize the bufferSize need to fill of the buffer pointer. - * @return you need return offset value if succeed. return 0 if failed. - */ - virtual int onReadData(unsigned char *buffer, int bufferSize) = 0; - - /** - * @brief The Player seek event callback, you need to operate the corresponding stream seek operation, You can refer to the definition of lseek() at https://man7.org/linux/man-pages/man2/lseek.2.html - * @param offset the value of seek offset. - * @param whence the postion of start seeking, the directive whence as follows: - * 0 - SEEK_SET : The file offset is set to offset bytes. - * 1 - SEEK_CUR : The file offset is set to its current location plus offset bytes. - * 2 - SEEK_END : The file offset is set to the size of the file plus offset bytes. - * 65536 - AVSEEK_SIZE : Optional. Passing this as the "whence" parameter to a seek function causes it to return the filesize without seeking anywhere. - * @return - * whence == 65536, return filesize if you need. - * whence >= 0 && whence < 3 , return offset value if succeed. return -1 if failed. - */ - virtual int64_t onSeek(int64_t offset, int whence) = 0; - - virtual ~IMediaPlayerCustomDataProvider() {} -}; - -struct MediaSource { - /** - * The URL of the media file that you want to play. - */ - const char* url; - /** - * The URI of the media file - * - * When caching is enabled, if the url cannot distinguish the cache file name, - * the uri must be able to ensure that the cache file name corresponding to the url is unique. - */ - const char* uri; - /** - * Set the starting position for playback, in ms. - */ - int64_t startPos; - /** - * Determines whether to autoplay after opening a media resource. - * - true: (Default) Autoplay after opening a media resource. - * - false: Do not autoplay after opening a media resource. - */ - bool autoPlay; - /** - * Determines whether to enable cache streaming to local files. If enable cached, the media player will - * use the url or uri as the cache index. - * - * @note - * The local cache function only supports on-demand video/audio streams and does not support live streams. - * Caching video and audio files based on the HLS protocol (m3u8) to your local device is not supported. - * - * - true: Enable cache. - * - false: (Default) Disable cache. - */ - bool enableCache; - /** - * Determines whether to enable multi-track audio stream decoding. - * Then you can select multi audio track of the media file for playback or publish to channel - * - * @note - * If you use the selectMultiAudioTrack API, you must set enableMultiAudioTrack to true. - * - * - true: Enable MultiAudioTrack;. - * - false: (Default) Disable MultiAudioTrack;. - */ - bool enableMultiAudioTrack; - /** - * Determines whether the opened media resource is a stream through the Agora Broadcast Streaming Network(CDN). - * - true: It is a stream through the Agora Broadcast Streaming Network. - * - false: (Default) It is not a stream through the Agora Broadcast Streaming Network. - */ - Optional isAgoraSource; - /** - * Determines whether the opened media resource is a live stream. If is a live stream, it can speed up the opening of media resources. - * - true: It is a live stream. - * - false: (Default) It is not is a live stream. - */ - Optional isLiveSource; - /** - * External custom data source object - */ - IMediaPlayerCustomDataProvider* provider; - - MediaSource() : url(NULL), uri(NULL), startPos(0), autoPlay(true), enableCache(false), - enableMultiAudioTrack(false), provider(NULL){ - } -}; - -} // namespace base -} // namespace media -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraOptional.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraOptional.h deleted file mode 100644 index 97595be45..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraOptional.h +++ /dev/null @@ -1,891 +0,0 @@ -// Copyright (c) 2019 Agora.io. All rights reserved - -// This program is confidential and proprietary to Agora.io. -// And may not be copied, reproduced, modified, disclosed to others, published -// or used, in whole or in part, without the express prior written permission -// of Agora.io. -#pragma once - -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) -#include -#endif -#include - -#ifndef CONSTEXPR -#if __cplusplus >= 201103L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103L) -#define CONSTEXPR constexpr -#else -#define CONSTEXPR -#endif -#endif // !CONSTEXPR - -#ifndef NOEXCEPT -#if __cplusplus >= 201103L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103L) -#define NOEXCEPT(Expr) noexcept(Expr) -#else -#define NOEXCEPT(Expr) -#endif -#endif // !NOEXCEPT - -namespace agora { - -// Specification: -// http://en.cppreference.com/w/cpp/utility/optional/in_place_t -struct in_place_t {}; - -// Specification: -// http://en.cppreference.com/w/cpp/utility/optional/nullopt_t -struct nullopt_t { - CONSTEXPR explicit nullopt_t(int) {} -}; - -// Specification: -// http://en.cppreference.com/w/cpp/utility/optional/in_place -/*CONSTEXPR*/ const in_place_t in_place = {}; - -// Specification: -// http://en.cppreference.com/w/cpp/utility/optional/nullopt -/*CONSTEXPR*/ const nullopt_t nullopt(0); - -// Forward declaration, which is refered by following helpers. -template -class Optional; - -namespace internal { - -template -struct OptionalStorageBase { - // Initializing |empty_| here instead of using default member initializing - // to avoid errors in g++ 4.8. - CONSTEXPR OptionalStorageBase() : is_populated_(false), empty_('\0') {} - -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) - template - CONSTEXPR explicit OptionalStorageBase(in_place_t, Args&&... args) - : is_populated_(true), value_(std::forward(args)...) {} -#else - CONSTEXPR explicit OptionalStorageBase(in_place_t, const T& _value) - : is_populated_(true), value_(_value) {} -#endif - // When T is not trivially destructible we must call its - // destructor before deallocating its memory. - // Note that this hides the (implicitly declared) move constructor, which - // would be used for constexpr move constructor in OptionalStorage. - // It is needed iff T is trivially move constructible. However, the current - // is_trivially_{copy,move}_constructible implementation requires - // is_trivially_destructible (which looks a bug, cf: - // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51452 and - // http://cplusplus.github.io/LWG/lwg-active.html#2116), so it is not - // necessary for this case at the moment. Please see also the destructor - // comment in "is_trivially_destructible = true" specialization below. - ~OptionalStorageBase() { - if (is_populated_) - value_.~T(); - } - -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) - template - void Init(Args&&... args) { - ::new (&value_) T(std::forward(args)...); - is_populated_ = true; - } -#else - void Init(const T& _value) { - ::new (&value_) T(_value); - is_populated_ = true; - } -#endif - - bool is_populated_; - - union { - // |empty_| exists so that the union will always be initialized, even when - // it doesn't contain a value. Union members must be initialized for the - // constructor to be 'constexpr'. - char empty_; - T value_; - }; -}; - -// Implement conditional constexpr copy and move constructors. These are -// constexpr if is_trivially_{copy,move}_constructible::value is true -// respectively. If each is true, the corresponding constructor is defined as -// "= default;", which generates a constexpr constructor (In this case, -// the condition of constexpr-ness is satisfied because the base class also has -// compiler generated constexpr {copy,move} constructors). Note that -// placement-new is prohibited in constexpr. -template -struct OptionalStorage : OptionalStorageBase { - // This is no trivially {copy,move} constructible case. Other cases are - // defined below as specializations. - - // Accessing the members of template base class requires explicit - // declaration. - using OptionalStorageBase::is_populated_; - using OptionalStorageBase::value_; - using OptionalStorageBase::Init; - - // Inherit constructors (specifically, the in_place constructor). - //using OptionalStorageBase::OptionalStorageBase; - -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) - template - CONSTEXPR explicit OptionalStorage(in_place_t in_place, Args&&... args) - : OptionalStorageBase(in_place, std::forward(args)...) {} -#else - CONSTEXPR explicit OptionalStorage(in_place_t in_place, const T& _value) - : OptionalStorageBase(in_place, _value) {} -#endif - - // User defined constructor deletes the default constructor. - // Define it explicitly. - OptionalStorage() {} - - OptionalStorage(const OptionalStorage& other) { - if (other.is_populated_) - Init(other.value_); - } - -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) - OptionalStorage(OptionalStorage&& other) NOEXCEPT(std::is_nothrow_move_constructible::value) { - if (other.is_populated_) - Init(std::move(other.value_)); - } -#endif -}; - -// Base class to support conditionally usable copy-/move- constructors -// and assign operators. -template -class OptionalBase { - // This class provides implementation rather than public API, so everything - // should be hidden. Often we use composition, but we cannot in this case - // because of C++ language restriction. - protected: - CONSTEXPR OptionalBase() {} - CONSTEXPR OptionalBase(const OptionalBase& other) : storage_(other.storage_) {} -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) - CONSTEXPR OptionalBase(OptionalBase&& other) : storage_(std::move(other.storage_)) {} - - template - CONSTEXPR explicit OptionalBase(in_place_t, Args&&... args) - : storage_(in_place, std::forward(args)...) {} -#else - CONSTEXPR explicit OptionalBase(in_place_t, const T& _value) - : storage_(in_place, _value) {} -#endif - - // Implementation of converting constructors. - template - explicit OptionalBase(const OptionalBase& other) { - if (other.storage_.is_populated_) - storage_.Init(other.storage_.value_); - } - -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) - template - explicit OptionalBase(OptionalBase&& other) { - if (other.storage_.is_populated_) - storage_.Init(std::move(other.storage_.value_)); - } -#endif - - ~OptionalBase() {} - - OptionalBase& operator=(const OptionalBase& other) { - CopyAssign(other); - return *this; - } - -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) - OptionalBase& operator=(OptionalBase&& other) NOEXCEPT( - std::is_nothrow_move_assignable::value && - std::is_nothrow_move_constructible::value) { - MoveAssign(std::move(other)); - return *this; - } -#endif - - template - void CopyAssign(const OptionalBase& other) { - if (other.storage_.is_populated_) - InitOrAssign(other.storage_.value_); - else - FreeIfNeeded(); - } - -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) - template - void MoveAssign(OptionalBase&& other) { - if (other.storage_.is_populated_) - InitOrAssign(std::move(other.storage_.value_)); - else - FreeIfNeeded(); - } -#endif - - template -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) - void InitOrAssign(U&& value) { - if (storage_.is_populated_) - storage_.value_ = std::forward(value); - else - storage_.Init(std::forward(value)); - } -#else - void InitOrAssign(const U& value) { - if (storage_.is_populated_) - storage_.value_ = value; - else - storage_.Init(value); - } -#endif - - - void FreeIfNeeded() { - if (!storage_.is_populated_) - return; - storage_.value_.~T(); - storage_.is_populated_ = false; - } - - // For implementing conversion, allow access to other typed OptionalBase - // class. - template - friend class OptionalBase; - - OptionalStorage storage_; -}; - -// The following {Copy,Move}{Constructible,Assignable} structs are helpers to -// implement constructor/assign-operator overloading. Specifically, if T is -// is not movable but copyable, Optional's move constructor should not -// participate in overload resolution. This inheritance trick implements that. -template -struct CopyConstructible {}; - -template <> -struct CopyConstructible { - CONSTEXPR CopyConstructible() {} - CopyConstructible& operator=(const CopyConstructible&) { return *this; } -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) - CONSTEXPR CopyConstructible(CopyConstructible&&) {} - CopyConstructible& operator=(CopyConstructible&&) { return *this; } -#endif - private: - CONSTEXPR CopyConstructible(const CopyConstructible&); -}; - -template -struct MoveConstructible {}; - -template <> -struct MoveConstructible { - CONSTEXPR MoveConstructible() {} - CONSTEXPR MoveConstructible(const MoveConstructible&) {} - MoveConstructible& operator=(const MoveConstructible&) { return *this; } -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) - MoveConstructible& operator=(MoveConstructible&&) { return *this; } - private: - CONSTEXPR MoveConstructible(MoveConstructible&&); -#endif -}; - -template -struct CopyAssignable {}; - -template <> -struct CopyAssignable { - CONSTEXPR CopyAssignable() {} - CONSTEXPR CopyAssignable(const CopyAssignable&) {} -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) - CONSTEXPR CopyAssignable(CopyAssignable&&) {} - CopyAssignable& operator=(CopyAssignable&&) { return *this; } -#endif - private: - CopyAssignable& operator=(const CopyAssignable&); -}; - -template -struct MoveAssignable {}; - -template <> -struct MoveAssignable { - CONSTEXPR MoveAssignable() {} - CONSTEXPR MoveAssignable(const MoveAssignable&) {} - MoveAssignable& operator=(const MoveAssignable&) { return *this; } -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) - CONSTEXPR MoveAssignable(MoveAssignable&&) {} - - private: - MoveAssignable& operator=(MoveAssignable&&); -#endif -}; - -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) -// Helper to conditionally enable converting constructors and assign operators. -template -struct IsConvertibleFromOptional - : std::integral_constant< - bool, - std::is_constructible&>::value || - std::is_constructible&>::value || - std::is_constructible&&>::value || - std::is_constructible&&>::value || - std::is_convertible&, T>::value || - std::is_convertible&, T>::value || - std::is_convertible&&, T>::value || - std::is_convertible&&, T>::value> {}; - -template -struct IsAssignableFromOptional - : std::integral_constant< - bool, - IsConvertibleFromOptional::value || - std::is_assignable&>::value || - std::is_assignable&>::value || - std::is_assignable&&>::value || - std::is_assignable&&>::value> {}; - -// Forward compatibility for C++17. -// Introduce one more deeper nested namespace to avoid leaking using std::swap. -namespace swappable_impl { -using std::swap; - -struct IsSwappableImpl { - // Tests if swap can be called. Check(0) returns true_type iff swap - // is available for T. Otherwise, Check's overload resolution falls back - // to Check(...) declared below thanks to SFINAE, so returns false_type. - template - static auto Check(int) - -> decltype(swap(std::declval(), std::declval()), std::true_type()); - - template - static std::false_type Check(...); -}; -} // namespace swappable_impl -template -struct IsSwappable : decltype(swappable_impl::IsSwappableImpl::Check(0)) {}; -#endif -} // namespace internal - -// On Windows, by default, empty-base class optimization does not work, -// which means even if the base class is empty struct, it still consumes one -// byte for its body. __declspec(empty_bases) enables the optimization. -// cf) -// https://blogs.msdn.microsoft.com/vcblog/2016/03/30/optimizing-the-layout-of-empty-base-classes-in-vs2015-update-2-3/ -#if defined(_WIN32) -#define OPTIONAL_DECLSPEC_EMPTY_BASES __declspec(empty_bases) -#else -#define OPTIONAL_DECLSPEC_EMPTY_BASES -#endif - -// Optional is a Chromium version of the C++17 optional class: -// std::optional documentation: -// http://en.cppreference.com/w/cpp/utility/optional -// Chromium documentation: -// https://chromium.googlesource.com/chromium/src/+/master/docs/optional.md -// -// These are the differences between the specification and the implementation: -// - Constructors do not use 'constexpr' as it is a C++14 extension. -// - 'constexpr' might be missing in some places for reasons specified locally. -// - No exceptions are thrown, because they are banned from Chromium. -// Marked noexcept for only move constructor and move assign operators. -// - All the non-members are in the 'base' namespace instead of 'std'. -// -// Note that T cannot have a constructor T(Optional) etc. Optional checks -// T's constructor (specifically via IsConvertibleFromOptional), and in the -// check whether T can be constructible from Optional, which is recursive -// so it does not work. As of Feb 2018, std::optional C++17 implementation in -// both clang and gcc has same limitation. MSVC SFINAE looks to have different -// behavior, but anyway it reports an error, too. -template -class OPTIONAL_DECLSPEC_EMPTY_BASES Optional - : public internal::OptionalBase -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) - , public internal::CopyConstructible::value>, - public internal::MoveConstructible::value>, - public internal::CopyAssignable::value && - std::is_copy_assignable::value>, - public internal::MoveAssignable::value && - std::is_move_assignable::value> -#endif -{ - public: -#undef OPTIONAL_DECLSPEC_EMPTY_BASES - - typedef T value_type; - - // Defer default/copy/move constructor implementation to OptionalBase. - CONSTEXPR Optional() {} - CONSTEXPR Optional(const Optional& other) : internal::OptionalBase(other) {} - - CONSTEXPR Optional(nullopt_t) {} // NOLINT(runtime/explicit) - - // Converting copy constructor. "explicit" only if - // std::is_convertible::value is false. It is implemented by - // declaring two almost same constructors, but that condition in enable_if_t - // is different, so that either one is chosen, thanks to SFINAE. - template - Optional(const Optional& other) : internal::OptionalBase(other) {} - -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) - // Converting move constructor. Similar to converting copy constructor, - // declaring two (explicit and non-explicit) constructors. - template - Optional(Optional&& other) : internal::OptionalBase(std::move(other)) {} - - template - CONSTEXPR explicit Optional(in_place_t, Args&&... args) - : internal::OptionalBase(in_place, std::forward(args)...) {} - - template - CONSTEXPR explicit Optional(in_place_t, - std::initializer_list il, - Args&&... args) - : internal::OptionalBase(in_place, il, std::forward(args)...) {} -#else - CONSTEXPR explicit Optional(in_place_t, const T& _value) - : internal::OptionalBase(in_place, _value) {} - template - CONSTEXPR explicit Optional(in_place_t, - const U il[], - const T& _value) - : internal::OptionalBase(in_place, il, _value) {} -#endif - - // Forward value constructor. Similar to converting constructors, - // conditionally explicit. -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) - template - CONSTEXPR Optional(U&& value) - : internal::OptionalBase(in_place, std::forward(value)) {} -#else - template - CONSTEXPR Optional(const U& value) - : internal::OptionalBase(in_place, value) {} -#endif - - ~Optional() {} - - // Defer copy-/move- assign operator implementation to OptionalBase. - Optional& operator=(const Optional& other) { - if (&other == this) { - return *this; - } - - internal::OptionalBase::operator=(other); - return *this; - } - - Optional& operator=(nullopt_t) { - FreeIfNeeded(); - return *this; - } - - // Perfect-forwarded assignment. - template -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) - Optional& operator=(U&& value) { - InitOrAssign(std::forward(value)); - return *this; - } -#else - Optional& operator=(const U& value) { - InitOrAssign(value); - return *this; - } -#endif - - // Copy assign the state of other. - template - Optional& operator=(const Optional& other) { - CopyAssign(other); - return *this; - } - -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) - // Move assign the state of other. - template - Optional& operator=(Optional&& other) { - MoveAssign(std::move(other)); - return *this; - } -#endif - - const T* operator->() const { - return &storage_.value_; - } - - T* operator->() { - return &storage_.value_; - } - - const T& operator*() const { - return storage_.value_; - } - - T& operator*() { - return storage_.value_; - } - - -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) - CONSTEXPR explicit operator bool() const { return storage_.is_populated_; } -#else - CONSTEXPR operator bool() const { return storage_.is_populated_; } -#endif - - CONSTEXPR bool has_value() const { return storage_.is_populated_; } - -#if 1 - const T& value() const { - return storage_.value_; - } - - template -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) - CONSTEXPR T value_or(U&& default_value) const { - // TODO(mlamouri): add the following assert when possible: - // static_assert(std::is_copy_constructible::value, - // "T must be copy constructible"); - static_assert(std::is_convertible::value, - "U must be convertible to T"); - return storage_.is_populated_ - ? value() - : static_cast(std::forward(default_value)); - } -#else - CONSTEXPR T value_or(const U& default_value) const { - return storage_.is_populated_ - ? value() - : static_cast(default_value); - } -#endif -#else - const T& value() const & { - return storage_.value_; - } - -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) - const T&& value() const && { - return std::move(storage_.value_); - } -#endif - - template -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) - CONSTEXPR T value_or(U&& default_value) const & { - // TODO(mlamouri): add the following assert when possible: - // static_assert(std::is_copy_constructible::value, - // "T must be copy constructible"); - static_assert(std::is_convertible::value, - "U must be convertible to T"); - return storage_.is_populated_ - ? value() - : static_cast(std::forward(default_value)); - } -#else - CONSTEXPR T value_or(const U& default_value) const & { - // TODO(mlamouri): add the following assert when possible: - // static_assert(std::is_copy_constructible::value, - // "T must be copy constructible"); - static_assert(std::is_convertible::value, - "U must be convertible to T"); - return storage_.is_populated_ - ? value() - : static_cast(default_value); - } -#endif - - template -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) - CONSTEXPR T value_or(U&& default_value) const && { - // TODO(mlamouri): add the following assert when possible: - // static_assert(std::is_move_constructible::value, - // "T must be move constructible"); - static_assert(std::is_convertible::value, - "U must be convertible to T"); - return storage_.is_populated_ - ? std::move(value()) - : static_cast(std::forward(default_value)); - } -#endif -#endif // 1 - - void swap(Optional& other) { - if (!storage_.is_populated_ && !other.storage_.is_populated_) - return; - -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) - if (storage_.is_populated_ != other.storage_.is_populated_) { - if (storage_.is_populated_) { - other.storage_.Init(std::move(storage_.value_)); - FreeIfNeeded(); - } else { - storage_.Init(std::move(other.storage_.value_)); - other.FreeIfNeeded(); - } - return; - } -#endif - using std::swap; - swap(**this, *other); - } - - void reset() { FreeIfNeeded(); } - -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) - template - T& emplace(Args&&... args) { - FreeIfNeeded(); - storage_.Init(std::forward(args)...); - return storage_.value_; - } - - template - T& emplace(std::initializer_list il, Args&&... args) { - FreeIfNeeded(); - storage_.Init(il, std::forward(args)...); - return storage_.value_; - } -#else - T& emplace(const T& _value) { - FreeIfNeeded(); - storage_.Init(_value); - return storage_.value_; - } - template - T& emplace(const U il[], const T& _value) { - FreeIfNeeded(); - storage_.Init(il, _value); - return storage_.value_; - } -#endif - - private: - // Accessing template base class's protected member needs explicit - // declaration to do so. - using internal::OptionalBase::CopyAssign; - using internal::OptionalBase::FreeIfNeeded; - using internal::OptionalBase::InitOrAssign; -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) - using internal::OptionalBase::MoveAssign; -#endif - using internal::OptionalBase::storage_; -}; - -// Here after defines comparation operators. The definition follows -// http://en.cppreference.com/w/cpp/utility/optional/operator_cmp -// while bool() casting is replaced by has_value() to meet the chromium -// style guide. -template -bool operator==(const Optional& lhs, const Optional& rhs) { - if (lhs.has_value() != rhs.has_value()) - return false; - if (!lhs.has_value()) - return true; - return *lhs == *rhs; -} - -template -bool operator!=(const Optional& lhs, const Optional& rhs) { - if (lhs.has_value() != rhs.has_value()) - return true; - if (!lhs.has_value()) - return false; - return *lhs != *rhs; -} - -template -bool operator<(const Optional& lhs, const Optional& rhs) { - if (!rhs.has_value()) - return false; - if (!lhs.has_value()) - return true; - return *lhs < *rhs; -} - -template -bool operator<=(const Optional& lhs, const Optional& rhs) { - if (!lhs.has_value()) - return true; - if (!rhs.has_value()) - return false; - return *lhs <= *rhs; -} - -template -bool operator>(const Optional& lhs, const Optional& rhs) { - if (!lhs.has_value()) - return false; - if (!rhs.has_value()) - return true; - return *lhs > *rhs; -} - -template -bool operator>=(const Optional& lhs, const Optional& rhs) { - if (!rhs.has_value()) - return true; - if (!lhs.has_value()) - return false; - return *lhs >= *rhs; -} - -template -CONSTEXPR bool operator==(const Optional& opt, nullopt_t) { - return !opt; -} - -template -CONSTEXPR bool operator==(nullopt_t, const Optional& opt) { - return !opt; -} - -template -CONSTEXPR bool operator!=(const Optional& opt, nullopt_t) { - return opt.has_value(); -} - -template -CONSTEXPR bool operator!=(nullopt_t, const Optional& opt) { - return opt.has_value(); -} - -template -CONSTEXPR bool operator<(const Optional& , nullopt_t) { - return false; -} - -template -CONSTEXPR bool operator<(nullopt_t, const Optional& opt) { - return opt.has_value(); -} - -template -CONSTEXPR bool operator<=(const Optional& opt, nullopt_t) { - return !opt; -} - -template -CONSTEXPR bool operator<=(nullopt_t, const Optional& ) { - return true; -} - -template -CONSTEXPR bool operator>(const Optional& opt, nullopt_t) { - return opt.has_value(); -} - -template -CONSTEXPR bool operator>(nullopt_t, const Optional& ) { - return false; -} - -template -CONSTEXPR bool operator>=(const Optional& , nullopt_t) { - return true; -} - -template -CONSTEXPR bool operator>=(nullopt_t, const Optional& opt) { - return !opt; -} - -template -CONSTEXPR bool operator==(const Optional& opt, const U& value) { - return opt.has_value() ? *opt == value : false; -} - -template -CONSTEXPR bool operator==(const U& value, const Optional& opt) { - return opt.has_value() ? value == *opt : false; -} - -template -CONSTEXPR bool operator!=(const Optional& opt, const U& value) { - return opt.has_value() ? *opt != value : true; -} - -template -CONSTEXPR bool operator!=(const U& value, const Optional& opt) { - return opt.has_value() ? value != *opt : true; -} - -template -CONSTEXPR bool operator<(const Optional& opt, const U& value) { - return opt.has_value() ? *opt < value : true; -} - -template -CONSTEXPR bool operator<(const U& value, const Optional& opt) { - return opt.has_value() ? value < *opt : false; -} - -template -CONSTEXPR bool operator<=(const Optional& opt, const U& value) { - return opt.has_value() ? *opt <= value : true; -} - -template -CONSTEXPR bool operator<=(const U& value, const Optional& opt) { - return opt.has_value() ? value <= *opt : false; -} - -template -CONSTEXPR bool operator>(const Optional& opt, const U& value) { - return opt.has_value() ? *opt > value : false; -} - -template -CONSTEXPR bool operator>(const U& value, const Optional& opt) { - return opt.has_value() ? value > *opt : true; -} - -template -CONSTEXPR bool operator>=(const Optional& opt, const U& value) { - return opt.has_value() ? *opt >= value : false; -} - -template -CONSTEXPR bool operator>=(const U& value, const Optional& opt) { - return opt.has_value() ? value >= *opt : true; -} - -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) -template -CONSTEXPR Optional make_optional(Args&&... args) { - return Optional(in_place, std::forward(args)...); -} - -template -CONSTEXPR Optional make_optional(std::initializer_list il, - Args&&... args) { - return Optional(in_place, il, std::forward(args)...); -} -#endif - -// Partial specialization for a function template is not allowed. Also, it is -// not allowed to add overload function to std namespace, while it is allowed -// to specialize the template in std. Thus, swap() (kind of) overloading is -// defined in base namespace, instead. -template -void swap(Optional& lhs, Optional& rhs) { - lhs.swap(rhs); -} - -} // namespace agora - -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) -namespace std { -template -struct hash > { - size_t operator()(const agora::Optional& opt) const { - return opt == agora::nullopt ? 0 : std::hash()(*opt); - } -}; -} // namespace std -#endif -#undef CONSTEXPR -#undef NOEXCEPT diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraRefCountedObject.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraRefCountedObject.h deleted file mode 100644 index 93c970ed3..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraRefCountedObject.h +++ /dev/null @@ -1,137 +0,0 @@ - -// Copyright (c) 2020 Agora.io. All rights reserved - -// This program is confidential and proprietary to Agora.io. -// And may not be copied, reproduced, modified, disclosed to others, published -// or used, in whole or in part, without the express prior written permission -// of Agora.io. -#pragma once - -#ifndef __AGORA_REF_COUNTED_OBJECT_H__ -#define __AGORA_REF_COUNTED_OBJECT_H__ -#endif - -#if defined(__AGORA_REF_COUNTED_OBJECT_INTERNAL_H__) -#error AgoraRefCountedObject is deprected now, its only purpose is for API compatiable. -#endif - -#include "AgoraRefPtr.h" -#include "AgoraAtomicOps.h" - -#ifndef OPTIONAL_REFCOUNTRELEASESTATUS_SPECIFIER -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) -#define OPTIONAL_REFCOUNTRELEASESTATUS_SPECIFIER agora::RefCountReleaseStatus:: -#else -#define OPTIONAL_REFCOUNTRELEASESTATUS_SPECIFIER -#endif -#endif -namespace agora { - -class RefCounter { - public: - explicit RefCounter(int ref_count) : ref_count_(ref_count) {} - - void IncRef() { AtomicOps::Increment(&ref_count_); } - - /** - * Returns true if this was the last reference, and the resource protected by - * the reference counter can be deleted. - */ - agora::RefCountReleaseStatus DecRef() { - return (AtomicOps::Decrement(&ref_count_) == 0 - ? OPTIONAL_REFCOUNTRELEASESTATUS_SPECIFIER kDroppedLastRef - : OPTIONAL_REFCOUNTRELEASESTATUS_SPECIFIER kOtherRefsRemained); - } - - /** - * Return whether the reference count is one. If the reference count is used - * in the conventional way, a reference count of 1 implies that the current - * thread owns the reference and no other thread shares it. This call performs - * the test for a reference count of one, and performs the memory barrier - * needed for the owning thread to act on the resource protected by the - * reference counter, knowing that it has exclusive access. - */ - bool HasOneRef() const { return (AtomicOps::AcquireLoad(&ref_count_) == 1); } - - private: - RefCounter(); - - private: - volatile int ref_count_; -}; - -/** - * Agora sample code for wrapping a class that needs to inherit from RefCountInterface in order - * to be held by agora::agora_refptr - * Usage: - * agora::agora_refptr ptr = new RefCountedObject(Arg1, Arg2, ...); - */ - -template -class RefCountedObject : public T { - public: - RefCountedObject(): ref_count_(0) {} - - template -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) - explicit RefCountedObject(P0&& p0) : T(std::forward(p0)), ref_count_(0) {} -#else - explicit RefCountedObject(const P0& p0) : T(p0), ref_count_(0) {} -#endif - -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) - template - RefCountedObject(P0&& p0, P1&& p1, Args&&... args) - : T(std::forward(p0), - std::forward(p1), - std::forward(args)...), - ref_count_(0) {} -#endif - - virtual void AddRef() const { ref_count_.IncRef(); } - - virtual agora::RefCountReleaseStatus Release() const { - const agora::RefCountReleaseStatus status = ref_count_.DecRef(); - if (status == OPTIONAL_REFCOUNTRELEASESTATUS_SPECIFIER kDroppedLastRef) { - delete this; - } - return status; - } - - /** - * Return whether the reference count is one. If the reference count is used - * in the conventional way, a reference count of 1 implies that the current - * thread owns the reference and no other thread shares it. This call - * performs the test for a reference count of one, and performs the memory - * barrier needed for the owning thread to act on the object, knowing that it - * has exclusive access to the object. - */ - virtual bool HasOneRef() const { return ref_count_.HasOneRef(); } - - protected: - virtual ~RefCountedObject() {} - - private: - RefCountedObject(const RefCountedObject&); - RefCountedObject& operator=(const RefCountedObject&); - - protected: - mutable agora::RefCounter ref_count_; -}; - -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) -template -inline agora_refptr make_refptr(types&&... args) { - return agora_refptr(new RefCountedObject(std::forward(args)...)); -} -#else -template -inline agora_refptr make_refptr() { - return agora_refptr(new RefCountedObject()); -} -template -inline agora_refptr make_refptr(const P0& p0) { - return agora_refptr(new RefCountedObject(p0)); -} -#endif -} // namespace agora \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraRefPtr.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraRefPtr.h deleted file mode 100644 index 97594cb87..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/AgoraRefPtr.h +++ /dev/null @@ -1,156 +0,0 @@ - -// Copyright (c) 2019 Agora.io. All rights reserved - -// This program is confidential and proprietary to Agora.io. -// And may not be copied, reproduced, modified, disclosed to others, published -// or used, in whole or in part, without the express prior written permission -// of Agora.io. - -#pragma once - -#include -#if !(__cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)) -#include -#endif -#ifndef OPTIONAL_ENUM_CLASS -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) -#define OPTIONAL_ENUM_CLASS enum class -#else -#define OPTIONAL_ENUM_CLASS enum -#endif -#endif - -namespace agora { - -OPTIONAL_ENUM_CLASS RefCountReleaseStatus { kDroppedLastRef, kOtherRefsRemained }; - -// Interfaces where refcounting is part of the public api should -// inherit this abstract interface. The implementation of these -// methods is usually provided by the RefCountedObject template class, -// applied as a leaf in the inheritance tree. -class RefCountInterface { - public: - virtual void AddRef() const = 0; - virtual RefCountReleaseStatus Release() const = 0; - virtual bool HasOneRef() const = 0; - - // Non-public destructor, because Release() has exclusive responsibility for - // destroying the object. - protected: - virtual ~RefCountInterface() {} -}; - -template -class agora_refptr { - public: - agora_refptr() : ptr_(NULL) {} - - agora_refptr(T* p) : ptr_(p) { - if (ptr_) ptr_->AddRef(); - } - - template - agora_refptr(U* p) : ptr_(p) { - if (ptr_) ptr_->AddRef(); - } - - agora_refptr(const agora_refptr& r) : ptr_(r.get()) { - if (ptr_) ptr_->AddRef(); - } - - template - agora_refptr(const agora_refptr& r) : ptr_(r.get()) { - if (ptr_) ptr_->AddRef(); - } - -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) - agora_refptr(agora_refptr&& r) : ptr_(r.move()) {} - - template - agora_refptr(agora_refptr&& r) : ptr_(r.move()) {} -#endif - - ~agora_refptr() { - reset(); - } - - T* get() const { return ptr_; } - operator bool() const { return (ptr_ != NULL); } - - T* operator->() const { return ptr_; } - T& operator*() const { return *ptr_; } - - // Returns the (possibly null) raw pointer, and makes the agora_refptr hold a - // null pointer, all without touching the reference count of the underlying - // pointed-to object. The object is still reference counted, and the caller of - // move() is now the proud owner of one reference, so it is responsible for - // calling Release() once on the object when no longer using it. - T* move() { - T* retVal = ptr_; - ptr_ = NULL; - return retVal; - } - - agora_refptr& operator=(T* p) { - if (ptr_ == p) return *this; - - if (p) p->AddRef(); - if (ptr_) ptr_->Release(); - ptr_ = p; - return *this; - } - - agora_refptr& operator=(const agora_refptr& r) { - return *this = r.get(); - } - -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) - agora_refptr& operator=(agora_refptr&& r) { - agora_refptr(std::move(r)).swap(*this); - return *this; - } - - template - agora_refptr& operator=(agora_refptr&& r) { - agora_refptr(std::move(r)).swap(*this); - return *this; - } -#endif - - // For working with std::find() - bool operator==(const agora_refptr& r) const { return ptr_ == r.ptr_; } - - // For working with std::set - bool operator<(const agora_refptr& r) const { return ptr_ < r.ptr_; } - - void swap(T** pp) { - T* p = ptr_; - ptr_ = *pp; - *pp = p; - } - - void swap(agora_refptr& r) { swap(&r.ptr_); } - - void reset() { - if (ptr_) { - ptr_->Release(); - ptr_ = NULL; - } - } - - protected: - T* ptr_; -}; - -} // namespace agora - -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) -namespace std { -template -struct hash> { - std::size_t operator()(const agora::agora_refptr& k) const { - return reinterpret_cast(k.get()); - } -}; -} // namespace std -#endif \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraFileUploader.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraFileUploader.h deleted file mode 100644 index f531e4853..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraFileUploader.h +++ /dev/null @@ -1,45 +0,0 @@ - -// Copyright (c) 2019 Agora.io. All rights reserved - -// This program is confidential and proprietary to Agora.io. -// And may not be copied, reproduced, modified, disclosed to others, published -// or used, in whole or in part, without the express prior written permission -// of Agora.io. - -#pragma once // NOLINT(build/header_guard) - -#include "AgoraRefPtr.h" -#include - -namespace agora { -namespace rtc { - -struct ImagePayloadData { - ImagePayloadData(int seq, uint8_t* pixel, int fileSize, int w, int h, int64_t ts) - : seqid(seq), - size(fileSize), - width(w), - height(h), - timestamp(ts){ - } - - int seqid; - int size; - int width; - int height; - int64_t timestamp; - uint8_t* buffer; - void* privdata; - int privsize; -}; -/** - * The IFileUploadService class, which enables upload file service. - */ -class IFileUploaderService : public RefCountInterface { - public: - virtual ~IFileUploaderService() {} - virtual int startImageUpload(const ImagePayloadData* imgData, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - virtual int stopImageUpload(aosl_ref_t ares = AOSL_REF_INVALID) = 0; -}; -} // namespace rtc -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraH265Transcoder.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraH265Transcoder.h deleted file mode 100644 index b2f5c5b31..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraH265Transcoder.h +++ /dev/null @@ -1,178 +0,0 @@ -// -// Agora Media SDK -// -// Copyright (c) 2022 Agora IO. All rights reserved. -// - -#pragma once - -#include "AgoraBase.h" -#include "AgoraMediaBase.h" - -namespace agora{ -namespace rtc{ - -/** - * The result of IH265Transcoder interface invoking. -*/ -enum H265_TRANSCODE_RESULT { - /** - * -1: Unknown error. - */ - H265_TRANSCODE_RESULT_UNKNOWN = -1, - /** - * 0: The request of operation is successfully. - */ - H265_TRANSCODE_RESULT_SUCCESS = 0, - /** - * 1: This request is invalid. Possible reasons include incorrect parameters. - */ - H265_TRANSCODE_RESULT_REQUEST_INVALID = 1, - /** - * 2: Authentication failed, please check for correctness of token. - */ - H265_TRANSCODE_RESULT_UNAUTHORIZED = 2, - /** - * 3: The token is expired, please update token. - */ - H265_TRANSCODE_RESULT_TOKEN_EXPIRED = 3, - /** - * 4: No permission to access the interface. - */ - H265_TRANSCODE_RESULT_FORBIDDEN = 4, - /** - * 5: The url of request is not found. - */ - H265_TRANSCODE_RESULT_NOT_FOUND = 5, - /** - * 6: The request encountered a conflict, please try again. - */ - H265_TRANSCODE_RESULT_CONFLICTED = 6, - /** - * 7: Content type not supported. - */ - H265_TRANSCODE_RESULT_NOT_SUPPORTED = 7, - /** - * 8: The requests are too frequent. - */ - H265_TRANSCODE_RESULT_TOO_OFTEN = 8, - /** - * 9: Internal Server Error, you can try sending the request again. - */ - H265_TRANSCODE_RESULT_SERVER_INTERNAL_ERROR = 9, - /** - * 10: Service is unavailable. - */ - H265_TRANSCODE_RESULT_SERVICE_UNAVAILABLE = 10 -}; - -/** - * The IH265TranscoderObserver class -*/ -class IH265TranscoderObserver { - public: - virtual ~IH265TranscoderObserver() {}; - - /** - * Use to notify the result of invoking enableTranscode interface. - * @param result Result of invoking enableTranscode interface. There are some processing advice below of result. - * - H265_TRANSCODE_RESULT_REQUEST_INVALID: Channel or uid param have a mistake, you need to check them for correctness. - * - H265_TRANSCODE_RESULT_UNAUTHORIZED: Authentication failed, please check for correctness of token. - * - H265_TRANSCODE_RESULT_TOKEN_EXPIRED: The token has expired, you need to generate a new token. - * - H265_TRANSCODE_RESULT_FORBIDDEN: You need to contact agora staff to add the vid whitelist. - * - H265_TRANSCODE_RESULT_NOT_FOUND: Indicates that the network may be faulty. - * - H265_TRANSCODE_RESULT_TOO_OFTEN: Request is too often, please request again later. - * - H265_TRANSCODE_RESULT_SERVER_INTERNAL_ERROR: The service has an internal error. A request can be made again. - */ - virtual void onEnableTranscode(H265_TRANSCODE_RESULT result) = 0; - - /** - * Use to notify the result of invoking queryChannel interface. - * @param result Result of invoking queryChannel interface. There are some processing advice below of result. - * - H265_TRANSCODE_RESULT_UNAUTHORIZED: Authentication failed, please check for correctness of token. - * - H265_TRANSCODE_RESULT_TOKEN_EXPIRED: The token has expired, you need to generate a new token. - * - H265_TRANSCODE_RESULT_NOT_FOUND: Indicates that the network may be faulty or the channel param may be is empty. - * - H265_TRANSCODE_RESULT_TOO_OFTEN: Request is too often, please request again later. - * - H265_TRANSCODE_RESULT_SERVER_INTERNAL_ERROR: The service has an internal error. A request can be made again. - * - * @param originChannel Origin channel id - * @param transcodeChannel Transcode channel id - */ - virtual void onQueryChannel(H265_TRANSCODE_RESULT result, const char* originChannel, const char* transcodeChannel) = 0; - - /** Use to notify the result of invoking triggerTranscode interface. - * @param result Result of invoking triggerTranscode interface. There are some processing advice below of result. - * - H265_TRANSCODE_RESULT_UNAUTHORIZED: Authentication failed, please check for correctness of token. - * - H265_TRANSCODE_RESULT_TOKEN_EXPIRED: The token has expired, you need to generate a new token. - * - H265_TRANSCODE_RESULT_NOT_FOUND: Indicates that the network may be faulty or the channel param may be is empty. - * - H265_TRANSCODE_RESULT_CONFLICTED: The request of trigger transcode is conflicted, please try again. - * - H265_TRANSCODE_RESULT_TOO_OFTEN: Request is too often, please request again later - * - H265_TRANSCODE_RESULT_SERVER_INTERNAL_ERROR: The service has an internal error. A request can be made again. - * - H265_TRANSCODE_RESULT_SERVICE_UNAVAILABLE: May be the number of transcode service is over the limit. - */ - virtual void onTriggerTranscode(H265_TRANSCODE_RESULT result) = 0; - -}; - -/** - * The IH265Transcoder class -*/ -class IH265Transcoder : public RefCountInterface { - public: - /** - * Enable transcoding for a channel. - * @param token The token for authentication. - * @param channel The unique channel name for the AgoraRTC session in the string format. - * @param uid User ID. - * @return - * - 0: Success. - * - <0: Failure. - */ - virtual int enableTranscode(const char *token, const char *channel, uid_t uid) = 0; - - /** - * Query the transcoded channel of a channel. - * @param token The token for authentication. - * @param channel The unique channel name for the AgoraRTC session in the string format. - * @param uid User ID. - * @return - * - 0: Success. - * - <0: Failure. - */ - virtual int queryChannel(const char *token, const char *channel, uid_t uid) = 0; - - /** - * Trigger channel transcoding. - * @param token The token for authentication. - * @param channel The unique channel name for the AgoraRTC session in the string format. - * @param uid User ID. - * @return - * - 0: Success. - * - <0: Failure. - */ - virtual int triggerTranscode(const char* token, const char* channel, uid_t uid) = 0; - /** - * Register a IH265TranscoderObserver object. - * @param observer IH265TranscoderObserver. - * @return - * - 0: Success. - * - <0: Failure. - */ - virtual int registerTranscoderObserver(IH265TranscoderObserver *observer) = 0; - /** - * Unregister a IH265TranscoderObserver object. - * @param observer IH265TranscoderObserver. - * @return - * - 0: Success. - * - <0: Failure. - */ - virtual int unregisterTranscoderObserver(IH265TranscoderObserver *observer) = 0; - - - protected: - virtual ~IH265Transcoder() {}; - -}; - -} // namespace rtc -} // namespace agora \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraLog.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraLog.h deleted file mode 100644 index 20b6416ef..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraLog.h +++ /dev/null @@ -1,99 +0,0 @@ -// -// Agora Media SDK -// -// Copyright (c) 2015 Agora IO. All rights reserved. -// -#pragma once - -#include -#include - -#ifndef OPTIONAL_ENUM_CLASS -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) -#define OPTIONAL_ENUM_CLASS enum class -#else -#define OPTIONAL_ENUM_CLASS enum -#endif -#endif - -#ifndef OPTIONAL_LOG_LEVEL_SPECIFIER -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) -#define OPTIONAL_LOG_LEVEL_SPECIFIER LOG_LEVEL:: -#else -#define OPTIONAL_LOG_LEVEL_SPECIFIER -#endif -#endif - -namespace agora { -namespace commons { - -/** - * Supported logging severities of SDK - */ -OPTIONAL_ENUM_CLASS LOG_LEVEL { - LOG_LEVEL_NONE = 0x0000, - LOG_LEVEL_INFO = 0x0001, - LOG_LEVEL_WARN = 0x0002, - LOG_LEVEL_ERROR = 0x0004, - LOG_LEVEL_FATAL = 0x0008, - LOG_LEVEL_API_CALL = 0x0010, - LOG_LEVEL_DEBUG = 0x0020, -}; - -/* -The SDK uses ILogWriter class Write interface to write logs as application -The application inherits the methods Write() to implentation their own log writ - -Write has default implementation, it writes logs to files. -Application can use setLogFile() to change file location, see description of set -*/ -class ILogWriter { - public: - /** user defined log Write function - @param level log level - @param message log message content - @param length log message length - @return - - 0: success - - <0: failure - */ - virtual int32_t writeLog(LOG_LEVEL level, const char* message, uint16_t length) = 0; - - virtual ~ILogWriter() {} -}; - -enum LOG_FILTER_TYPE { - LOG_FILTER_OFF = 0, - LOG_FILTER_DEBUG = 0x080f, - LOG_FILTER_INFO = 0x000f, - LOG_FILTER_WARN = 0x000e, - LOG_FILTER_ERROR = 0x000c, - LOG_FILTER_CRITICAL = 0x0008, - LOG_FILTER_MASK = 0x80f, -}; - -const uint32_t MAX_LOG_SIZE = 20 * 1024 * 1024; // 20MB -const uint32_t MIN_LOG_SIZE = 128 * 1024; // 128KB -/** The default log size in kb - */ -const uint32_t DEFAULT_LOG_SIZE_IN_KB = 2048; - -/** Definition of LogConfiguration - */ -struct LogConfig { - /**The log file path, default is NULL for default log path - */ - const char* filePath; - /** The log file size, KB , set 2048KB to use default log size - */ - uint32_t fileSizeInKB; - /** The log level, set LOG_LEVEL_INFO to use default log level - */ - LOG_LEVEL level; - - LogConfig() : filePath(NULL), fileSizeInKB(DEFAULT_LOG_SIZE_IN_KB), level(OPTIONAL_LOG_LEVEL_SPECIFIER LOG_LEVEL_INFO) {} -}; -} // namespace commons -} // namespace agora - -#undef OPTIONAL_LOG_LEVEL_SPECIFIER diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaComponentFactory.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaComponentFactory.h deleted file mode 100644 index 28de53fbd..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaComponentFactory.h +++ /dev/null @@ -1,41 +0,0 @@ -// -// Agora SDK -// -// Copyright (c) 2021 Agora.io. All rights reserved. -// -#pragma once // NOLINT(build/header_guard) - -#include "AgoraBase.h" -#include "AgoraRefPtr.h" - -namespace agora { -namespace rtc { - -class IMediaPlayer; - -class IMediaComponentFactory { -public: - /** This method creates media player. - */ - virtual agora_refptr createMediaPlayer( - agora::media::base::MEDIA_PLAYER_SOURCE_TYPE type = agora::media::base::MEDIA_PLAYER_SOURCE_DEFAULT) = 0; - -protected: - virtual ~IMediaComponentFactory() {} -}; - -} //namespace rtc -} // namespace agora - -/** \addtogroup createMediaComponentFactory - @{ - */ -/** - * Creates an \ref agora::rtc::IMediaComponentFactory "IMediaComponentFactory" object and returns the pointer. - * - * @return - * - The pointer to \ref agora::rtc::IMediaComponentFactory "IMediaComponentFactory": Success. - * - A null pointer: Failure. - */ -AGORA_API agora::rtc::IMediaComponentFactory* AGORA_CALL createAgoraMediaComponentFactory(); -/** @} */ diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaEngine.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaEngine.h deleted file mode 100644 index b3b92e9e4..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaEngine.h +++ /dev/null @@ -1,285 +0,0 @@ -// -// Agora Media SDK -// -// Copyright (c) 2015 Agora IO. All rights reserved. -// -#pragma once - -#include "AgoraBase.h" -#include "AgoraMediaBase.h" -#include "AgoraRefPtr.h" - -namespace agora { -namespace media { - -/** dual-mono music output mode - */ -enum AUDIO_MIXING_DUAL_MONO_MODE { - /* 0: Original mode */ - AUDIO_MIXING_DUAL_MONO_AUTO = 0, - /* 1: Left channel mode */ - AUDIO_MIXING_DUAL_MONO_L = 1, - /* 2: Right channel mode */ - AUDIO_MIXING_DUAL_MONO_R = 2, - /* 3: Mixed channel mode */ - AUDIO_MIXING_DUAL_MONO_MIX = 3 -}; - - -/** - * The IMediaEngine class. - */ -class IMediaEngine { - public: - /** - * Registers an audio frame observer object. - * - * @note - * Ensure that you call this method before \ref IRtcEngine::joinChannel "joinChannel". - * - * @param observer A pointer to the audio frame observer object: IAudioFrameObserver, - * nullptr means unregistering observer instead. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerAudioFrameObserver(IAudioFrameObserver* observer) = 0; - /** - * Registers a video frame observer object. - * - * @note - * - Ensure that you call this method before joining the channel. - * - If you register an observer for video raw video data, you cannot register an IVideoEncodedFrameObserver - * object. - * - * @param observer A pointer to the video frame observer: IVideoFrameObserver. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerVideoFrameObserver(IVideoFrameObserver* observer) = 0; - /** - * Registers a receiver object for the encoded video image. - * - * @note - * - Ensure that you call this method before joining the channel. - * - * @param observer A pointer to the observer of the encoded video image: \ref IVideoEncodedFrameObserver - * "IVideoEncodedFrameObserver". - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerVideoEncodedFrameObserver(IVideoEncodedFrameObserver* observer) = 0; - - /** - * Registers a face info observer object. - * - * @note - * Ensure that you call this method before \ref IRtcEngine::joinChannel "joinChannel". - * - * @param observer A pointer to the face info observer object: IFaceInfoObserver. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerFaceInfoObserver(IFaceInfoObserver* observer) = 0; - - /** - * Pushes the external audio data to the app. - * - * @param frame The audio buffer data. - * @param trackId The audio track ID. - * @return - * - 0: Success. - * - < 0: Failure. - */ - - virtual int pushAudioFrame(IAudioFrameObserverBase::AudioFrame* frame, rtc::track_id_t trackId = 0) = 0; - - /** - * Pulls the remote audio data. - * - * After a successful method call, the app pulls the decoded and mixed audio data for playback. - * - * The difference between this method and the \ref onPlaybackAudioFrame "onPlaybackAudioFrame" is as follows: - * - `onPlaybackAudioFrame`: The SDK sends the audio data to the app once every 10 ms. Any delay in processing - * the audio frames may result in audio jitter. - * - `pullAudioFrame`: The app pulls the remote audio data. After setting the audio data parameters, the - * SDK adjusts the frame buffer and avoids problems caused by jitter in the external audio playback. - * - * @param frame The pointer to the audio frame: AudioFrame. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int pullAudioFrame(IAudioFrameObserverBase::AudioFrame* frame) = 0; - - /** - * Sets the external video source. - * - * Once the external video source is enabled, the SDK prepares to accept the external video frame. - * - * @param enabled Determines whether to enable the external video source. - * - true: Enable the external video source. Once set, the SDK creates the external source and prepares - * video data from `pushVideoFrame` or `pushEncodedVideoImage`. - * - false: Disable the external video source. - * @param useTexture Determines whether to use textured video data. - * - true: Use texture, which is not supported now. - * - False: Do not use texture. - * @param sourceType Determines the type of external video source frame. - * - ENCODED_VIDEO_FRAME: The external video source is encoded. - * - VIDEO_FRAME: The external video source is not encoded. - * @param encodedVideoOption Video encoded track option, which is only used for ENCODED_VIDEO_FRAME. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setExternalVideoSource( - bool enabled, bool useTexture, EXTERNAL_VIDEO_SOURCE_TYPE sourceType = VIDEO_FRAME, - rtc::SenderOptions encodedVideoOption = rtc::SenderOptions()) = 0; - - /** - * Sets the external audio source. - * - * @note - * Ensure that you call this method before joining the channel. - * - * @deprecated This method is deprecated. Use createCustomAudioTrack(rtc::AUDIO_TRACK_TYPE trackType, const rtc::AudioTrackConfig& config) instead. - * - * @param enabled Determines whether to enable the external audio source: - * - true: Enable the external audio source. - * - false: (default) Disable the external audio source. - * @param sampleRate The Sample rate (Hz) of the external audio source, which can set be as - * 8000, 16000, 32000, 44100, or 48000. - * @param channels The number of channels of the external audio source, which can be set as 1 or 2: - * - 1: Mono. - * - 2: Stereo. - * @param localPlayback Enable/Disables the local playback of external audio track: - * - true: Enable local playback - * - false: (Default) Do not enable local playback - * @param publish Determines whether to publish the external audio track: - * - true: (Default) Publish the external audio track. - * - false: Don`t publish the external audio track. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setExternalAudioSource(bool enabled, int sampleRate, int channels, bool localPlayback = false, bool publish = true) __deprecated = 0; - - /** - * Create a custom audio track and get the audio track id. - * - * @note Ensure that you call this method before calling `joinChannel`. - * - * @param trackType The type of custom audio track - * See AUDIO_TRACK_TYPE. - * - * @param config The config of custom audio track - * See AudioTrackConfig. - * - * @return - * - If the call is successful, SDK returns audio track id. - * - If the call fails, SDK returns 0xffffffff. - */ - virtual rtc::track_id_t createCustomAudioTrack(rtc::AUDIO_TRACK_TYPE trackType, const rtc::AudioTrackConfig& config) = 0; - - /** - * Destroy custom audio track by trackId - * - * @param trackId The custom audio track id. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int destroyCustomAudioTrack(rtc::track_id_t trackId) = 0; - - /** - * Sets the external audio sink. - * - * This method applies to scenarios where you want to use external audio - * data for playback. After calling the \ref IRtcEngine::initialize "initialize" - * method and pass value of false in the `enableAudioDevice` member in the RtcEngineContext struct, you can call - * the \ref agora::media::IMediaEngine::pullAudioFrame "pullAudioFrame" method to pull the remote audio data, process - * it, and play it with the audio effects that you want. - * - * @note - * Once you call the \ref IRtcEngine::initialize "initialize" method and pass value of false in the `enableAudioDevice` - * member in the RtcEngineContext struct, the app will not retrieve any audio data from the - * \ref agora::media::IAudioFrameObserver::onPlaybackAudioFrame "onPlaybackAudioFrame" callback. - * - * @param enabled Sets whether or not to the external audio sink - * - true: Enables the external audio sink. - * - false: Disables the external audio sink. - * @param sampleRate Sets the sample rate (Hz) of the external audio sink, which can be set as 16000, 32000, 44100 or 48000. - * @param channels Sets the number of audio channels of the external - * audio sink: - * - 1: Mono. - * - 2: Stereo. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setExternalAudioSink(bool enabled, int sampleRate, int channels) = 0; - - /** - * Sets the external audio track. - * - * @note - * Ensure that you call this method before joining the channel. - * - * @param trackId The custom audio track id. - * @param enabled Enable/Disables the local playback of external audio track: - * - true: Enable local playback - * - false: Do not enable local playback - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableCustomAudioLocalPlayback(rtc::track_id_t trackId, bool enabled) = 0; - - /** - * Pushes the external video frame to the app. - * - * @param frame The external video frame: ExternalVideoFrame. - * @param videoTrackId The id of the video track. - * - 0: Success. - * - < 0: Failure. - */ - virtual int pushVideoFrame(base::ExternalVideoFrame* frame, unsigned int videoTrackId = 0) = 0; - /** - * Pushes the encoded video image to the app. - * @param imageBuffer A pointer to the video image. - * @param length The data length. - * @param videoEncodedFrameInfo The reference to the information of the encoded video frame: - * \ref agora::rtc::EncodedVideoFrameInfo "EncodedVideoFrameInfo". - * @param videoTrackId The id of the video track. - * - 0: Success. - * - < 0: Failure. - */ - virtual int pushEncodedVideoImage(const unsigned char* imageBuffer, size_t length, - const agora::rtc::EncodedVideoFrameInfo& videoEncodedFrameInfo, - unsigned int videoTrackId = 0) = 0; - /** - * @hide For internal usage only - */ - virtual int addVideoFrameRenderer(IVideoFrameObserver *renderer) = 0; - - /** - * @hide For internal usage only - */ - virtual int removeVideoFrameRenderer(IVideoFrameObserver *renderer) = 0; - - virtual void release() = 0; - - protected: - virtual ~IMediaEngine() {} -}; - -} // namespace media - -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaPlayer.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaPlayer.h deleted file mode 100644 index 25f48a4a2..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaPlayer.h +++ /dev/null @@ -1,633 +0,0 @@ -// -// Agora SDK -// -// Copyright (c) 2020 Agora.io. All rights reserved. -// -#pragma once // NOLINT(build/header_guard) - -#include "AgoraBase.h" -#include "AgoraMediaBase.h" -#include "AgoraMediaPlayerTypes.h" -#include "AgoraRefPtr.h" - -namespace agora { -namespace base { -class IAgoraService; -} -namespace rtc { - -class ILocalAudioTrack; -class ILocalVideoTrack; -class IMediaPlayerSourceObserver; -class IMediaPlayerCustomDataProvider; - -/** - * The IMediaPlayerEntity class provides access to a media player entity. If yout want to playout - * multiple media sources simultaneously, create multiple media player source objects. - */ -class IMediaPlayer : public RefCountInterface { -protected: - virtual ~IMediaPlayer() {} - -public: - virtual int initialize(base::IAgoraService* agora_service) = 0; - - /** - * Get unique media player id of the media player entity. - * @return - * - >= 0: The source id of this media player entity. - * - < 0: Failure. - */ - virtual int getMediaPlayerId() const = 0; - - /** - * Opens a media file with a specified URL. - * @param url The URL of the media file that you want to play. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int open(const char* url, int64_t startPos) = 0; - - /** - * @brief Open a media file with a media file source. - * @param source Media file source that you want to play, see `MediaSource` - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int openWithMediaSource(const media::base::MediaSource &source) = 0; - - /** - * Plays the media file. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int play() = 0; - - /** - * Pauses playing the media file. - */ - virtual int pause() = 0; - - /** - * Stops playing the current media file. - */ - virtual int stop() = 0; - - /** - * Resumes playing the media file. - */ - virtual int resume() = 0; - - /** - * Sets the current playback position of the media file. - * @param newPos The new playback position (ms). - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int seek(int64_t newPos) = 0; - - /** Sets the pitch of the current media file. - * @param pitch Sets the pitch of the local music file by chromatic scale. The default value is 0, - * which means keeping the original pitch. The value ranges from -12 to 12, and the pitch value between - * consecutive values is a chromatic value. The greater the absolute value of this parameter, the - * higher or lower the pitch of the local music file. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setAudioPitch(int pitch) = 0; - - /** - * Gets the duration of the media file. - * @param duration A reference to the duration of the media file. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getDuration(int64_t& duration) = 0; - - /** - * Gets the current playback position of the media file. - * @param currentPosition A reference to the current playback position (ms). - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getPlayPosition(int64_t& pos) = 0; - - virtual int getStreamCount(int64_t& count) = 0; - - virtual int getStreamInfo(int64_t index, media::base::PlayerStreamInfo* info) = 0; - - /** - * Sets whether to loop the media file for playback. - * @param loopCount the number of times looping the media file. - * - 0: Play the audio effect once. - * - 1: Play the audio effect twice. - * - -1: Play the audio effect in a loop indefinitely, until stopEffect() or stop() is called. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setLoopCount(int loopCount) = 0; - - /** - * Change playback speed - * @param speed the value of playback speed ref [50-400] - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setPlaybackSpeed(int speed) = 0; - - /** - * Slect playback audio track of the media file - * @param index the index of the audio track in media file - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int selectAudioTrack(int index) = 0; - - /** - * Selects multi audio track of the media file for playback or publish to channel. - * @param playoutTrackIndex The index of the audio track in media file for local playback. - * @param publishTrackIndex The index of the audio track in the media file published to the remote. - * - * @note - * You can obtain the streamIndex of the audio track by calling getStreamInfo.. - * If you want to use selectMultiAudioTrack, you need to open the media file with openWithMediaSource and set enableMultiAudioTrack to true. - * - * @return - * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. - * - -2: Invalid argument. Argument must be greater than or equal to zero. - * - -8: Invalid State.You must open the media file with openWithMediaSource and set enableMultiAudioTrack to true - */ - virtual int selectMultiAudioTrack(int playoutTrackIndex, int publishTrackIndex) = 0; - - /** - * change player option before play a file - * @param key the key of the option param - * @param value the value of option param - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setPlayerOption(const char* key, int value) = 0; - - /** - * change player option before play a file - * @param key the key of the option param - * @param value the value of option param - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setPlayerOption(const char* key, const char* value) = 0; - /** - * take screenshot while playing video - * @param filename the filename of screenshot file - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int takeScreenshot(const char* filename) = 0; - - /** - * select internal subtitles in video - * @param index the index of the internal subtitles - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int selectInternalSubtitle(int index) = 0; - - /** - * set an external subtitle for video - * @param url The URL of the subtitle file that you want to load. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setExternalSubtitle(const char* url) = 0; - - virtual media::base::MEDIA_PLAYER_STATE getState() = 0; - - /** - * @brief Turn mute on or off - * - * @param muted Whether to mute on - * @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_REASON - */ - virtual int mute(bool muted) = 0; - - /** - * @brief Get mute state - * - * @param[out] muted Whether is mute on - * @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_REASON - */ - virtual int getMute(bool& muted) = 0; - - /** - * @brief Adjust playback volume - * - * @param volume The volume value to be adjusted - * The volume can be adjusted from 0 to 400: - * 0: mute; - * 100: original volume; - * 400: Up to 4 times the original volume (with built-in overflow protection). - * @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_REASON - */ - virtual int adjustPlayoutVolume(int volume) = 0; - - /** - * @brief Get the current playback volume - * - * @param[out] volume - * @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_REASON - */ - virtual int getPlayoutVolume(int& volume) = 0; - - /** - * @brief adjust publish signal volume - * - * @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_REASON - */ - virtual int adjustPublishSignalVolume(int volume) = 0; - - /** - * @brief get publish signal volume - * - * @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_REASON - */ - virtual int getPublishSignalVolume(int& volume) = 0; - - /** - * @brief Set video rendering view - * - * @param view view object, windows platform is HWND - * @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_REASON - */ - virtual int setView(media::base::view_t view) = 0; - - /** - * @brief Set video display mode - * - * @param renderMode Video display mode - * @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_REASON - */ - virtual int setRenderMode(media::base::RENDER_MODE_TYPE renderMode) = 0; - - /** - * Registers a media player source observer. - * - * Once the media player source observer is registered, you can use the observer to monitor the state change of the media player. - * @param observer The pointer to the IMediaPlayerSourceObserver object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerPlayerSourceObserver(IMediaPlayerSourceObserver* observer) = 0; - - /** - * Releases the media player source observer. - * @param observer The pointer to the IMediaPlayerSourceObserver object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unregisterPlayerSourceObserver(IMediaPlayerSourceObserver* observer) = 0; - - /** - * Register the audio frame observer. - * - * @param observer The pointer to the IAudioFrameObserver object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerAudioFrameObserver(media::IAudioPcmFrameSink* observer) = 0; - - /** - * Registers an audio observer. - * - * @param observer The audio observer, reporting the reception of each audio - * frame. See - * \ref media::IAudioPcmFrameSink "IAudioFrameObserver" for - * details. - * @param mode Use mode of the audio frame. See #RAW_AUDIO_FRAME_OP_MODE_TYPE. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerAudioFrameObserver(media::IAudioPcmFrameSink* observer, - RAW_AUDIO_FRAME_OP_MODE_TYPE mode) = 0; - - /** - * Releases the audio frame observer. - * @param observer The pointer to the IAudioFrameObserver object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unregisterAudioFrameObserver(media::IAudioPcmFrameSink* observer) = 0; - - /** - * @brief Register the player video observer - * - * @param observer observer object - * @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_REASON - */ - virtual int registerVideoFrameObserver(media::base::IVideoFrameObserver* observer) = 0; - - /** - * @brief UnRegister the player video observer - * - * @param observer observer object - * @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_REASON - */ - virtual int unregisterVideoFrameObserver(agora::media::base::IVideoFrameObserver* observer) = 0; - - /** - * Registers the audio frame spectrum observer. - * - * @param observer The pointer to the {@link media::base::IAudioSpectrumObserver IAudioSpectrumObserver} object. - * @param intervalInMS Sets the time interval(ms) between two consecutive audio spectrum callback. - * The default value is 100. This param should be larger than 10. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerMediaPlayerAudioSpectrumObserver(media::IAudioSpectrumObserver* observer, int intervalInMS) = 0; - - /** - * Releases the audio frame spectrum observer. - * @param observer The pointer to the {@link media::base::IAudioSpectrumObserver IAudioSpectrumObserver} object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unregisterMediaPlayerAudioSpectrumObserver(media::IAudioSpectrumObserver* observer) = 0; - - /** - * @brief Set dual-mono output mode of the music file. - * - * @param mode dual mono mode. See #agora::media::AUDIO_DUAL_MONO_MODE - */ - virtual int setAudioDualMonoMode(agora::media::base::AUDIO_DUAL_MONO_MODE mode) = 0; - - /** - * get sdk version and build number of player SDK. - * @return String of the SDK version. - * - * @deprecated This method is deprecated. - */ - virtual const char* getPlayerSdkVersion() = 0; - - /** - * Get the current play src. - * @return - * - current play src of raw bytes. - */ - virtual const char* getPlaySrc() = 0; - - - /** - * Open the Agora CDN media source. - * @param src The src of the media file that you want to play. - * @param startPos The playback position (ms). - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int openWithAgoraCDNSrc(const char* src, int64_t startPos) = 0; - - /** - * Gets the number of Agora CDN lines. - * @return - * - > 0: number of CDN. - * - <= 0: Failure. - */ - virtual int getAgoraCDNLineCount() = 0; - - /** - * Switch Agora CDN lines. - * @param index Specific CDN line index. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int switchAgoraCDNLineByIndex(int index) = 0; - - /** - * Gets the line of the current CDN. - * @return - * - >= 0: Specific line. - * - < 0: Failure. - */ - virtual int getCurrentAgoraCDNIndex() = 0; - - /** - * Enable automatic CDN line switching. - * @param enable Whether enable. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableAutoSwitchAgoraCDN(bool enable) = 0; - - /** - * Update the CDN source token and timestamp. - * @param token token. - * @param ts ts. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int renewAgoraCDNSrcToken(const char* token, int64_t ts) = 0; - - /** - * Switch the CDN source when open a media through "openWithAgoraCDNSrc" API - * @param src Specific src. - * @param syncPts Live streaming must be set to false. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int switchAgoraCDNSrc(const char* src, bool syncPts = false) = 0; - - /** - * Switch the media source when open a media through "open" API - * @param src Specific src. - * @param syncPts Live streaming must be set to false. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int switchSrc(const char* src, bool syncPts = true) = 0; - - /** - * Preload a media source - * @param src Specific src. - * @param startPos The starting position (ms) for playback. Default value is 0. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int preloadSrc(const char* src, int64_t startPos) = 0; - - /** - * Play a pre-loaded media source - * @param src Specific src. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int playPreloadedSrc(const char* src) = 0; - - /** - * Unload a preloaded media source - * @param src Specific src. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unloadSrc(const char* src) = 0; - - /** - * Set spatial audio params for the music file. It can be called after the media player - * was created. - * - * @param params See #agora::SpatialAudioParams. If it's - * not set, then the spatial audio will be disabled; or it will be enabled. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setSpatialAudioParams(const SpatialAudioParams& params) = 0; - - /** - * Set sound position params for the music file. It can be called after the media player - * was created. - * - *@param pan The sound position of the music file. The value ranges from -1.0 to 1.0: - *- 0.0: the music sound comes from the front. - *- -1.0: the music sound comes from the left. - *- 1.0: the music sound comes from the right. - *@param gain Gain of the music. The value ranges from 0.0 to 100.0. The default value is 100.0 (the original gain of the music). The smaller the value, the less the gain. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setSoundPositionParams(float pan, float gain) = 0; - -}; - -/** - * This class is used to set and manage the player cache, implemented in the - * form of a singleton, independent of the player. - */ -class IMediaPlayerCacheManager { -public: - /** - * Delete the longest used cache file in order to release some of the cache file disk usage. - * (usually used when the cache quota notification is received) - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int removeAllCaches() = 0; - /** - * Remove the latest media resource cache file. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int removeOldCache() = 0; - /** - * Remove the cache file by uri, setting by MediaSource. - * @param uri URI,identify the uniqueness of the property, Set from `MeidaSource` - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int removeCacheByUri(const char *uri) = 0; - /** - * Set cache file path that files will be saved to. - * @param path file path. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setCacheDir(const char *path) = 0; - /** - * Set the maximum number of cached files. - * @param count maximum number of cached files. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setMaxCacheFileCount(int count) = 0; - /** - * Set the maximum size of cache file disk usage. - * @param cacheSize total size of the largest cache file. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setMaxCacheFileSize(int64_t cacheSize) = 0; - /** - * Whether to automatically delete old cache files when the cache file usage reaches the limit. - * @param enable enable the player to automatically clear the cache. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableAutoRemoveCache(bool enable) = 0; - /** - * Get the cache directory. - * @param path cache path, recieve a pointer to be copied to. - * @param length the length to be copied. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getCacheDir(char* path, int length) = 0; - /** - * Get the maximum number of cached files. - * @return - * > 0: file count. - * - < 0: Failure. - */ - virtual int getMaxCacheFileCount() = 0; - /** - * Get the total size of the largest cache file - * @return - * > 0: file size. - * - < 0: Failure. - */ - virtual int64_t getMaxCacheFileSize() = 0; - /** - * Get the number of all cache files. - * @return - * > 0: file count. - * - < 0: Failure. - */ - virtual int getCacheFileCount() = 0; - - virtual ~IMediaPlayerCacheManager(){}; -}; - -} //namespace rtc -} // namespace agora - -AGORA_API agora::rtc::IMediaPlayerCacheManager* AGORA_CALL getMediaPlayerCacheManager(); diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaPlayerSource.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaPlayerSource.h deleted file mode 100644 index 99da405bc..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaPlayerSource.h +++ /dev/null @@ -1,493 +0,0 @@ -// -// Agora SDK -// -// Copyright (c) 2018 Agora.io. All rights reserved. -// -#pragma once // NOLINT(build/header_guard) - -#include "AgoraBase.h" -#include "AgoraMediaBase.h" -#include "AgoraMediaPlayerTypes.h" -#include "AgoraRefPtr.h" - -namespace agora { -namespace rtc { - -class IMediaPlayerSourceObserver; - -/** - * The IMediaPlayerSource class provides access to a media player source. To playout multiple media sources simultaneously, - * create multiple media player source objects. - */ -class IMediaPlayerSource : public RefCountInterface { -protected: - virtual ~IMediaPlayerSource() {} - -public: - - /** - * Gets the unique source ID of the media player source. - * @return - * - >=0: The source ID of this media player source. - * - < 0: Failure. - */ - virtual int getSourceId() const = 0; - - /** - * Opens a media file with a specified URL. - * @param url The path of the media file. Both the local path and online path are supported. - * @param startPos The starting position (ms) for playback. Default value is 0. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int open(const char* url, int64_t startPos) = 0; - - /** - * Opens a media file with a media file source. - * @param source Media file source that you want to play, see `MediaSource` - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int openWithMediaSource(const media::base::MediaSource &source) = 0; - - /** - * Plays the media file. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int play() = 0; - - /** - * Pauses the playback. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int pause() = 0; - - /** - * Stops the playback. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int stop() = 0; - - /** - * Resumes the playback. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int resume() = 0; - - /** - * Sets the playback position of the media file. - * @param newPos The new playback position (ms). - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int seek(int64_t newPos) = 0; - - /** - * Gets the duration of the media file. - * @param [out] duration A reference to the duration of the media file. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getDuration(int64_t& duration) = 0; - - /** - * Gets the current playback position of the media file. - * @param [out] pos A reference to the current playback position (ms). - * @return - * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. - */ - virtual int getPlayPosition(int64_t& pos) = 0; - - /** - * Gets the number of the media streams in the media source. - * @param [out] count The number of the media streams in the media source. - * @return - * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. - */ - virtual int getStreamCount(int64_t& count) = 0; - - /** - * Gets the detailed information of a media stream. - * @param index The index of the media stream. - * @param [out] info The detailed information of the media stream. See \ref media::base::PlayerStreamInfo "PlayerStreamInfo" for details. - * @return - * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. - */ - virtual int getStreamInfo(int64_t index, media::base::PlayerStreamInfo* info) = 0; - - /** - * Sets whether to loop the media file for playback. - * @param loopCount The number of times of looping the media file. - * - 0: Play the media file once. - * - 1: Play the media file twice. - * - -1: Play the media file in a loop indefinitely, until {@link stop} is called. - * @return - * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. - */ - virtual int setLoopCount(int64_t loopCount) = 0; - - /** - * Changes the playback speed. - * @param speed The playback speed ref [50-400]. - * @return - * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. - */ - virtual int setPlaybackSpeed(int speed) = 0; - - /** - * Selects an audio track of the media file for playback. - * @param index The index of the audio track in media file. - * @return - * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. - */ - virtual int selectAudioTrack(int64_t index) = 0; - - /** - * Selects multi audio track of the media file for playback or publish to channel. - * @param playoutTrackIndex The index of the audio track in media file for local playback. - * @param publishTrackIndex The index of the audio track in the media file published to the remote. - * - * @note - * You can obtain the streamIndex of the audio track by calling getStreamInfo.. - * If you want to use selectMultiAudioTrack, you need to open the media file with openWithMediaSource and set enableMultiAudioTrack to true. - * - * @return - * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. - * - -2: Invalid argument. Argument must be greater than or equal to zero. - * - -8: Invalid State.You must open the media file with openWithMediaSource and set enableMultiAudioTrack to true - */ - virtual int selectMultiAudioTrack(int playoutTrackIndex, int publishTrackIndex) = 0; - - /** - * Changes the player option before playing a file. - * @param key The key of the option paramemter. - * @param value The value of option parameter. - * @return - * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. - */ - virtual int setPlayerOption(const char* key, int64_t value) = 0; - - /** - * Changes the player option before playing a file. - * @param key The key of the option paramemter. - * @param value The value of option parameter. - * @return - * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. - */ - virtual int setPlayerOption(const char* key, const char* value) = 0; - - /** - * Takes a screenshot when playing a video file. - * @param filename The filename of the screenshot file. - * @return - * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. - */ - virtual int takeScreenshot(const char* filename) = 0; - - /** - * Selects internal subtitles for a video file. - * @param index The index of the internal subtitles. - * @return - * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. - */ - virtual int selectInternalSubtitle(int64_t index) = 0; - - /** - * Sets an external subtitle file for a video file. - * @param url The URL of the subtitle file. - * @return - * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. - */ - virtual int setExternalSubtitle(const char* url) = 0; - - /** - * Gets the playback state. - * @return The current playback state. See {@link media::base::MEDIA_PLAYER_STATE MEDIA_PLAYER_STATE} for details. - */ - virtual media::base::MEDIA_PLAYER_STATE getState() = 0; - - /** - * Registers a media player source observer. - * - * Once the media player source observer is registered, you can use the observer to monitor the state change of the media player. - * @param observer The pointer to the IMediaPlayerSourceObserver object. - * @return - * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. - */ - virtual int registerPlayerSourceObserver(IMediaPlayerSourceObserver* observer) = 0; - - /** - * Releases the media player source observer. - * @param observer The pointer to the IMediaPlayerSourceObserver object. - * @return - * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. - */ - virtual int unregisterPlayerSourceObserver(IMediaPlayerSourceObserver* observer) = 0; - - /** - * Registers the audio frame observer. - * - * @param observer The pointer to the {@link media::IAudioPcmFrameSink observer} object. - * @return - * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. - */ - virtual int registerAudioFrameObserver(media::IAudioPcmFrameSink* observer) = 0; - - /** - * Releases the audio frame observer. - * @param observer The pointer to the {@link media::IAudioPcmFrameSink observer} object. - * @return - * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. - */ - virtual int unregisterAudioFrameObserver(media::IAudioPcmFrameSink* observer) = 0; - - /** - * Open the Agora CDN media source. - * @param src The src of the media file that you want to play. - * @param startPos The playback position (ms). - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int openWithAgoraCDNSrc(const char* src, int64_t startPos) = 0; - - /** - * Gets the number of Agora CDN lines. - * @return - * - > 0: number of CDN. - * - <= 0: Failure. - */ - virtual int getAgoraCDNLineCount() = 0; - - - /** - * Switch Agora CDN lines. - * @param index Specific CDN line index. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int switchAgoraCDNLineByIndex(int index) = 0; - - /** - * Gets the line of the current CDN. - * @return - * - >= 0: Specific line. - * - < 0: Failure. - */ - virtual int getCurrentAgoraCDNIndex() = 0; - - /** - * Enable automatic CDN line switching. - * @param enable Whether enable. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableAutoSwitchAgoraCDN(bool enable) = 0; - - /** - * Update the CDN source token and timestamp. - * @param token token. - * @param ts ts. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int renewAgoraCDNSrcToken(const char* token, int64_t ts) = 0; - - /** - * Switch the CDN source when open a media through "openWithAgoraCDNSrc" API - * @param src Specific src. - * @param syncPts Live streaming must be set to false. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int switchAgoraCDNSrc(const char* src, bool syncPts = false) = 0; - - /** - * Switch the media source when open a media through "open" API - * @param src Specific src. - * @param syncPts Live streaming must be set to false. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int switchSrc(const char* src, bool syncPts) = 0; - - /** - * Preload a media source - * @param src Specific src. - * @param startPos The starting position (ms) for playback. Default value is 0. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int preloadSrc(const char* src, int64_t startPos) = 0; - - /** - * Unload a preloaded media source - * @param src Specific src. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unloadSrc(const char* src) = 0; - - /** - * Play a pre-loaded media source - * @param src Specific src. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int playPreloadedSrc(const char* src) = 0; - -}; - -/** - * This class class reports runtime events to the applications. - */ -class IMediaPlayerSourceObserver { - public: - virtual ~IMediaPlayerSourceObserver() {} - - /** - * @brief Reports the playback state change. - * - * When the state of the playback changes, the SDK triggers this callback to report the new playback state and the reason or error for the change. - * @param state The new playback state after change. See {@link media::base::MEDIA_PLAYER_STATE MEDIA_PLAYER_STATE}. - * @param reason The player's error code. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. - */ - virtual void onPlayerSourceStateChanged(media::base::MEDIA_PLAYER_STATE state, - media::base::MEDIA_PLAYER_REASON reason) = 0; - - /** - * @brief Reports current playback progress. - * - * The callback occurs once every one second during the playback and reports the current playback progress. - * @param positionMs Current playback progress (milisecond). - * @param timestampMs Current NTP(Network Time Protocol) time (milisecond). - */ - virtual void onPositionChanged(int64_t positionMs, int64_t timestampMs) = 0; - - /** - * @brief Reports the playback event. - * - * - After calling the `seek` method, the SDK triggers the callback to report the results of the seek operation. - * - After calling the `selectAudioTrack` method, the SDK triggers the callback to report that the audio track changes. - * - * @param eventCode The playback event. See {@link media::base::MEDIA_PLAYER_EVENT MEDIA_PLAYER_EVENT}. - * @param elapsedTime The playback elapsed time. - * @param message The playback message. - */ - virtual void onPlayerEvent(media::base::MEDIA_PLAYER_EVENT eventCode, int64_t elapsedTime, const char* message) = 0; - - /** - * @brief Occurs when the metadata is received. - * - * The callback occurs when the player receives the media metadata and reports the detailed information of the media metadata. - * @param data The detailed data of the media metadata. - * @param length The data length (bytes). - */ - virtual void onMetaData(const void* data, int length) = 0; - - - /** - * @brief Triggered when play buffer updated, once every 1 second - * - * @param int cached buffer during playing, in milliseconds - */ - virtual void onPlayBufferUpdated(int64_t playCachedBuffer) = 0; - - - /** - * @brief Triggered when the player preloadSrc - * - * @param event - */ - virtual void onPreloadEvent(const char* src, media::base::PLAYER_PRELOAD_EVENT event) = 0; - - /** - * @brief Occurs when one playback of the media file is completed. - */ - virtual void onCompleted() = 0; - - /** - * @brief AgoraCDN Token has expired and needs to be set up with renewAgoraCDNSrcToken(const char* src). - */ - virtual void onAgoraCDNTokenWillExpire() = 0; - - /** - * @brief Reports current playback source bitrate changed. - * @brief Reports current playback source info changed. - * - * @param from Streaming media information before the change. - * @param to Streaming media information after the change. - */ - virtual void onPlayerSrcInfoChanged(const media::base::SrcInfo& from, const media::base::SrcInfo& to) = 0; - - /** - * @brief Triggered when media player information updated. - * - * @param info Include information of media player. - */ - virtual void onPlayerInfoUpdated(const media::base::PlayerUpdatedInfo& info) = 0; - - /** - * @brief Triggered every 1 second, reports the statistics of the files being cached. - * - * @param stats Cached file statistics. - */ - virtual void onPlayerCacheStats(const media::base::CacheStatistics& stats) { - (void)stats; - } - - /** - * @brief Triggered every 1 second, reports the statistics of the media stream being played. - * - * @param stats The statistics of the media stream. - */ - virtual void onPlayerPlaybackStats(const media::base::PlayerPlaybackStats& stats) { - (void)stats; - } - - /** - * @brief Triggered every 200 millisecond ,update player current volume range [0,255] - * - * @param volume volume of current player. - */ - virtual void onAudioVolumeIndication(int volume) = 0; -}; - -} //namespace rtc -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaRecorder.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaRecorder.h deleted file mode 100644 index 17375607c..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaRecorder.h +++ /dev/null @@ -1,90 +0,0 @@ -// -// Agora SDK -// -// Copyright (c) 2022 Agora.io. All rights reserved. -// -#pragma once // NOLINT(build/header_guard) - -#include "AgoraBase.h" -#include "AgoraMediaBase.h" -#include "IAgoraRtcEngineEx.h" - -namespace agora { -namespace rtc { - -class IMediaRecorder : public RefCountInterface { - protected: - virtual ~IMediaRecorder() {} - - public: - /** - * Registers the IMediaRecorderObserver object. - * - * @since v4.0.0 - * - * @note Call this method before the startRecording method. - * - * @param callback The callbacks for recording audio and video streams. See \ref IMediaRecorderObserver. - * - * @return - * - 0(ERR_OK): Success. - * - < 0: Failure: - */ - virtual int setMediaRecorderObserver(media::IMediaRecorderObserver* callback) = 0; - /** - * Starts recording the local or remote audio and video. - * - * @since v4.0.0 - * - * After successfully calling \ref IRtcEngine::createMediaRecorder "createMediaRecorder" to get the media recorder object - * , you can call this method to enable the recording of the local audio and video. - * - * This method can record the following content: - * - The audio captured by the local microphone and encoded in AAC format. - * - The video captured by the local camera and encoded by the SDK. - * - The audio received from remote users and encoded in AAC format. - * - The video received from remote users. - * - * The SDK can generate a recording file only when it detects the recordable audio and video streams; when there are - * no audio and video streams to be recorded or the audio and video streams are interrupted for more than five - * seconds, the SDK stops recording and triggers the - * \ref IMediaRecorderObserver::onRecorderStateChanged "onRecorderStateChanged" (RECORDER_STATE_ERROR, RECORDER_ERROR_NO_STREAM) - * callback. - * - * @note Call this method after joining the channel. - * - * @param config The recording configurations. See MediaRecorderConfiguration. - * - * @return - * - 0(ERR_OK): Success. - * - < 0: Failure: - * - `-1(ERR_FAILED)`: IRtcEngine does not support the request because the remote user did not subscribe to the target channel or the media streams published by the local user during remote recording. - * - `-2(ERR_INVALID_ARGUMENT)`: The parameter is invalid. Ensure the following: - * - The specified path of the recording file exists and is writable. - * - The specified format of the recording file is supported. - * - The maximum recording duration is correctly set. - * - During remote recording, ensure the user whose media streams you want record did join the channel. - * - `-4(ERR_NOT_SUPPORTED)`: IRtcEngine does not support the request due to one of the following reasons: - * - The recording is ongoing. - * - The recording stops because an error occurs. - * - No \ref IMediaRecorderObserver object is registered. - */ - virtual int startRecording(const media::MediaRecorderConfiguration& config) = 0; - /** - * Stops recording the audio and video. - * - * @since v4.0.0 - * - * @note After calling \ref IMediaRecorder::startRecording "startRecording", if you want to stop the recording, - * you must call `stopRecording`; otherwise, the generated recording files might not be playable. - * - * - * @return - * - 0(ERR_OK): Success. - * - < 0: Failure: - */ - virtual int stopRecording() = 0; -}; - -} //namespace rtc -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaRelayService.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaRelayService.h deleted file mode 100644 index 7e5a18495..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaRelayService.h +++ /dev/null @@ -1,87 +0,0 @@ -// -// Agora Media SDK -// -// Created by Xiaosen Wang in 2020. -// Copyright (c) 2020 Agora IO. All rights reserved. -// -#pragma once -#include "AgoraBase.h" -#include "AgoraRefPtr.h" -#include "IAgoraService.h" - -namespace agora { -namespace rtc { -class IMediaRelayObserver; -class IMediaRelayService : public RefCountInterface { - public: - /** Starts or update to relay media streams across channels. - * - * @since v4.2.0 - * @param configuration The configuration of the media stream relay: - * ChannelMediaRelayConfiguration. - * - * @return - * - 0: Success. - * - < 0: Failure. - * - -1(ERR_FAILED): A general error occurs (no specified reason). - * - -2(ERR_INVALID_ARGUMENT): The argument is invalid. - * - -5(ERR_REFUSED): The request is rejected. - */ - virtual int startOrUpdateChannelMediaRelay(const ChannelMediaRelayConfiguration& configuration) = 0; - - /** Stops the media stream relay. - * - * Once the relay stops, the host quits all the destination - * channels. - * - * @return - * - 0: Success. - * - < 0: Failure. - * - -1(ERR_FAILED): A general error occurs (no specified reason). - * - -2(ERR_INVALID_ARGUMENT): The argument is invalid. - * - -5(ERR_REFUSED): The request is rejected. - */ - virtual int stopChannelMediaRelay(aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** pause the channels for media stream relay. - * @return - * - 0: Success. - * - < 0: Failure. - * - -1(ERR_FAILED): A general error occurs (no specified reason). - * - -2(ERR_INVALID_ARGUMENT): The argument is invalid. - * - -5(ERR_REFUSED): The request is rejected. - */ - virtual int pauseAllChannelMediaRelay(aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** resume the channels for media stream relay. - * @return - * - 0: Success. - * - < 0: Failure. - * - -1(ERR_FAILED): A general error occurs (no specified reason). - * - -2(ERR_INVALID_ARGUMENT): The argument is invalid. - * - -5(ERR_REFUSED): The request is rejected. - */ - virtual int resumeAllChannelMediaRelay(aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - virtual void registerEventHandler(IMediaRelayObserver* eventObserver, void(*safeDeleter)(IMediaRelayObserver*) = NULL) = 0; - virtual void unregisterEventHandler(IMediaRelayObserver* eventObserver) = 0; -}; - -class IMediaRelayObserver { - public: - virtual ~IMediaRelayObserver() {} - - /** Occurs when the state of the media stream relay changes. - * - * The SDK returns the state of the current media relay with any error - * message. - * - * @param state The state code in #CHANNEL_MEDIA_RELAY_STATE. - * @param code The error code in #CHANNEL_MEDIA_RELAY_ERROR. - */ - virtual void onChannelMediaRelayStateChanged(CHANNEL_MEDIA_RELAY_STATE state, - CHANNEL_MEDIA_RELAY_ERROR code) {} -}; - -} // namespace rtc -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaStreamingSource.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaStreamingSource.h deleted file mode 100644 index e1267b683..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraMediaStreamingSource.h +++ /dev/null @@ -1,332 +0,0 @@ -// -// Agora SDK -// Copyright (c) 2019 Agora.io. All rights reserved. -// -// Created by xiaohua.lu in 2020-03. -// CodeStyle: Google C++ -// - -#pragma once // NOLINT(build/header_guard) - - -#include "AgoraBase.h" -#include "AgoraMediaBase.h" -#include "AgoraMediaPlayerTypes.h" -#include "AgoraRefPtr.h" - -namespace agora { -namespace rtc { - - -class IMediaStreamingSourceObserver; - - -/** - * @brief The error code of streaming source - * - */ -enum STREAMING_SRC_ERR { - STREAMING_SRC_ERR_NONE = 0, ///< no error - STREAMING_SRC_ERR_UNKNOWN = 1, ///< unknown error - STREAMING_SRC_ERR_INVALID_PARAM = 2, ///< invalid parameter - STREAMING_SRC_ERR_BAD_STATE = 3, ///< bad status - STREAMING_SRC_ERR_NO_MEM = 4, ///< not enough memory - STREAMING_SRC_ERR_BUFFER_OVERFLOW = 5, ///< buffer overflow - STREAMING_SRC_ERR_BUFFER_UNDERFLOW = 6, ///< buffer underflow - STREAMING_SRC_ERR_NOT_FOUND = 7, ///< buffer underflow - STREAMING_SRC_ERR_TIMEOUT = 8, ///< buffer underflow - STREAMING_SRC_ERR_EXPIRED = 9, ///< expired - STREAMING_SRC_ERR_UNSUPPORTED = 10, ///< unsupported - STREAMING_SRC_ERR_NOT_EXIST = 11, ///< component not exist - STREAMING_SRC_ERR_EXIST = 12, ///< component already exist - STREAMING_SRC_ERR_OPEN = 13, ///< fail to IO open - STREAMING_SRC_ERR_CLOSE = 14, ///< fail to IO close - STREAMING_SRC_ERR_READ = 15, ///< fail to IO read - STREAMING_SRC_ERR_WRITE = 16, ///< fail to IO write - STREAMING_SRC_ERR_SEEK = 17, ///< fail to IO seek - STREAMING_SRC_ERR_EOF = 18, ///< reach to IO EOF, can do nothing - STREAMING_SRC_ERR_CODECOPEN = 19, ///< fail to codec open - STREAMING_SRC_ERR_CODECCLOSE = 20, ///< fail to codec close - STREAMING_SRC_ERR_CODECPROC = 21, ///< fail to codec process -}; - - - -/** - * @brief The state machine of Streaming Source - * - */ -enum STREAMING_SRC_STATE { - STREAMING_SRC_STATE_CLOSED = 0, ///< streaming source still closed, can do nothing - STREAMING_SRC_STATE_OPENING = 1, ///< after call open() method and start parsing streaming source - STREAMING_SRC_STATE_IDLE = 2, ///< streaming source is ready waiting for play - STREAMING_SRC_STATE_PLAYING = 3, ///< after call play() method, playing & pushing the AV data - STREAMING_SRC_STATE_SEEKING = 4, ///< after call seek() method, start seeking poisition - STREAMING_SRC_STATE_EOF = 5, ///< The position is located at end, can NOT playing - STREAMING_SRC_STATE_ERROR = 6, ///< The error status and can do nothing except close -}; - - -/** - * @brief The input SEI data - * - */ -struct InputSeiData { - int32_t type; ///< SEI type - int64_t timestamp; ///< the frame timestamp which be attached - int64_t frame_index; ///< the frame index which be attached - uint8_t* private_data; ///< SEI really data - int32_t data_size; ///< size of really data -}; - - - -/** - * @brief The IMediaStreamingSource class provides access to a media streaming source demuxer. - * To playout multiple stream sources simultaneously, - * create multiple media stream source objects. - */ -class IMediaStreamingSource : public RefCountInterface { -public: - virtual ~IMediaStreamingSource() {}; - - - /** - * @brief Opens a media streaming source with a specified URL. - * @param url The path of the media file. Both the local path and online path are supported. - * @param startPos The starting position (ms) for pushing. Default value is 0. - * @param auto_play whether start playing after opened - * @return - * - 0: Success. - * - < 0: Failure - */ - virtual int open(const char* url, int64_t start_pos, bool auto_play = true) = 0; - - /** - * @brief Close current media streaming source - * @return - * - 0: Success. - * - < 0: Failure - */ - virtual int close() = 0; - - /** - * @brief Gets the unique source ID of the streaming source. - * @return - * - ≧ 0: The source ID of this media player source. - * - < 0: Failure. - */ - virtual int getSourceId() const = 0; - - /** - * @brief Retrieve whether video stream is valid - * @return: valid or invalid - */ - virtual bool isVideoValid() = 0; - - /** - * @brief Retrieve whether audio stream is valid - * @return: valid or invalid - */ - virtual bool isAudioValid() = 0; - - /** - * @brief Gets the duration of the streaming source. - * @param [out] duration A reference to the duration of the media file. - * @return - * - 0: Success. - * - < 0: Failure. See {@link STREAMINGSRC_ERR}. - */ - virtual int getDuration(int64_t& duration) = 0; - - /** - * @brief Gets the number of the streming source - * @param [out] count The number of the media streams in the media source. - * @return - * - 0: Success. - * - < 0: Failure. See {@link STREAMINGSRC_ERR}. - */ - virtual int getStreamCount(int64_t& count) = 0; - - /** - * @brief Gets the detailed information of a media stream. - * @param index The index of the media stream. - * @param [out] out_info The detailed information of the media stream. See \ref media::base::PlayerStreamInfo "PlayerStreamInfo" for details. - * @return - * - 0: Success. - * - < 0: Failure. See {@link STREAMINGSRC_ERR}. - */ - virtual int getStreamInfo(int64_t index, media::base::PlayerStreamInfo* out_info) = 0; - - /** - * @brief Sets whether to loop the streaming source for playback. - * @param loop_count The number of times of looping the media file. - * - 1: Play the media file once. - * - 2: Play the media file twice. - * - <= 0: Play the media file in a loop indefinitely, until {@link stop} is called. - * @return - * - 0: Success. - * - < 0: Failure. See {@link STREAMINGSRC_ERR}. - */ - virtual int setLoopCount(int64_t loop_count) = 0; - - /** - * @brief Play & push the streaming source. - * @return - * - 0: Success. - * - < 0: Failure. See {@link STREAMINGSRC_ERR}. - */ - virtual int play() = 0; - - /** - * @brief Pauses the playing & pushing of the streaming source, Keep current position. - * @return - * - 0: Success. - * - < 0: Failure. See {@link STREAMINGSRC_ERR}. - */ - virtual int pause() = 0; - - /** - * @brief Stop the playing & pushing of the streaming source, set the position to 0. - * @return - * - 0: Success. - * - < 0: Failure.See {@link STREAMINGSRC_ERR}. - */ - virtual int stop() = 0; - - /** - * @brief Sets the playback position of the streaming source. - * After seek done, it will return to previous status - * @param newPos The new playback position (ms). - * @return - * - 0: Success. - * - < 0: Failure. See {@link STREAMINGSRC_ERR}. - */ - virtual int seek(int64_t new_pos) = 0; - - /** - * @brief Gets the current playback position of the media file. - * @param [out] pos A reference to the current playback position (ms). - * @return - * - 0: Success. - * - < 0: Failure. See {@link STREAMINGSRC_ERR}. - */ - virtual int getCurrPosition(int64_t& pos) = 0; - - /** - * @breif Gets the status of current streaming source. - * @return The current state machine - */ - virtual STREAMING_SRC_STATE getCurrState() = 0; - - /** - * @brief append the SEI data which can be sent attached to video packet - * @param type SEI type - * @param timestamp the video frame timestamp which attached to - * @param frame_index the video frame timestamp which attached to - * - * @return - * - 0: Success. - * - < 0: Failure. See {@link STREAMINGSRC_ERR}. - */ - virtual int appendSeiData(const InputSeiData& inSeiData) = 0; - - /** - * Registers a media player source observer. - * - * Once the media player source observer is registered, you can use the observer to monitor the state change of the media player. - * @param observer The pointer to the IMediaStreamingSource object. - * @return - * - 0: Success. - * - < 0: Failure. See {@link STREAMINGSRC_ERR}. - */ - virtual int registerObserver(IMediaStreamingSourceObserver* observer) = 0; - - /** - * Releases the media player source observer. - * @param observer The pointer to the IMediaStreamingSource object. - * @return - * - 0: Success. - * - < 0: Failure. See {@link STREAMINGSRC_ERR}. - */ - virtual int unregisterObserver(IMediaStreamingSourceObserver* observer) = 0; - - /** - * @brief Parse a media information with a specified URL. - * @param url : The path of the media file. Both the local path and online path are supported. - * @param video_info : The output video information, It means no video track while video_info.streamIndex less than 0 - * @param audio_info : The output audio information, It means no audio track while audio_info.streamIndex less than 0 - * @return - * - 0: Success. - * - < 0: Failure - */ - virtual int parseMediaInfo(const char* url, - media::base::PlayerStreamInfo& video_info, - media::base::PlayerStreamInfo& audio_info) = 0; - -}; - - - -/** - * @brief This observer interface of media streaming source - */ -class IMediaStreamingSourceObserver { - public: - virtual ~IMediaStreamingSourceObserver() {}; - - - /** - * @brief Reports the playback state change. - * When the state of the playback changes, - * the SDK triggers this callback to report the new playback state - * and the reason or error for the change. - * @param state The new playback state after change. See {@link STREAMING_SRC_STATE}. - * @param ec The player's error code. See {@link STREAMINGSRC_ERR}. - */ - virtual void onStateChanged(STREAMING_SRC_STATE state, STREAMING_SRC_ERR err_code) = 0; - - /** - * @brief Triggered when file is opened - * @param err_code The error code - * @return None - */ - virtual void onOpenDone(STREAMING_SRC_ERR err_code) = 0; - - /** - * @brief Triggered when seeking is done - * @param err_code The error code - * @return None - */ - virtual void onSeekDone(STREAMING_SRC_ERR err_code) = 0; - - /** - * @brief Triggered when playing is EOF - * @param progress_ms the progress position - * @param repeat_count means repeated count of playing - */ - virtual void onEofOnce(int64_t progress_ms, int64_t repeat_count) = 0; - - /** - * @brief Reports current playback progress. - * The callback triggered once every one second during the playing status - * @param position_ms Current playback progress (millisecond). - */ - virtual void onProgress(int64_t position_ms) = 0; - - /** - * @brief Occurs when the metadata is received. - * The callback occurs when the player receives the media metadata - * and reports the detailed information of the media metadata. - * @param data The detailed data of the media metadata. - * @param length The data length (bytes). - */ - virtual void onMetaData(const void* data, int length) = 0; - -}; - - - -} //namespace rtc -} // namespace agora - diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraParameter.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraParameter.h deleted file mode 100644 index f50afe9b5..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraParameter.h +++ /dev/null @@ -1,308 +0,0 @@ -// -// Agora Engine SDK -// -// Created by minbo in 2019-10. -// Copyright (c) 2019 Agora.io. All rights reserved. - -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#pragma once // NOLINT(build/header_guard) -#include "AgoraRefPtr.h" - -// external key -/** - * set the range of ports available for connection - * @example "{\"rtc.udp_port_range\":[4500, 5000]}" - */ -#define KEY_RTC_UDP_PORT_RANGE "rtc.udp_port_range" -/** - * set the list of ports available for connection - * @example "{\"rtc.udp_port_list\":[4501, 4502, 4503, 4504, 4505, 4506]}" - */ -#define KEY_RTC_UDP_PORT_LIST "rtc.udp_port_list" - -/** - * get the fd of sending socket available for connection - * note: set method is not supported. - */ -#define KEY_RTC_UDP_SEND_FD "rtc.udp_send_fd" - - /** - * set the video encoder mode (hardware or software) - */ -#define KEY_RTC_VIDEO_ENABLED_HW_ENCODER "engine.video.enable_hw_encoder" -#define KEY_RTC_VIDEO_HARDWARE_ENCODEING "che.hardware_encoding" // deprecated, please use engine.video.enable_hw_encoder - /** - * set the hardware video encoder provider (nv for nvidia or qsv for intel) - */ -#define KEY_RTC_VIDEO_HW_ENCODER_PROVIDER "engine.video.hw_encoder_provider" - - /** - * set the video decoder mode (hardware or software) - */ -#define KEY_RTC_VIDEO_ENABLED_HW_DECODER "engine.video.enable_hw_decoder" -#define KEY_RTC_VIDEO_HARDWARE_DECODING "che.hardware_decoding" // deprecated, please use engine.video.enable_hw_decoder - - /** - * set the hardware video decoder provider (h264_cuvid(default) or h264_qsv) - */ -#define KEY_RTC_VIDEO_HW_DECODER_PROVIDER "engine.video.hw_decoder_provider" - - /** - * override the lua policy - */ -#define KEY_RTC_VIDEO_OVERRIDE_SMALLVIDEO_NOT_USE_HWENC_POLICY "engine.video.override_smallvideo_not_use_hwenc_policy" - -/** - * enable/disable video packet retransmission, enabled by default - */ -#define KEY_RTC_VIDEO_RESEND "rtc.video_resend" - -/** - * enable/disable audio packet retransmission, enabled by default -*/ -#define KEY_RTC_AUDIO_RESEND "rtc.audio_resend" - -/** - * set the bitrate ratio for video -*/ -#define KEY_RTC_VIDEO_BITRATE_ADJUST_RATIO "rtc.video.bitrate_adjust_ratio" - -/** - * set the minbitrate / bitrate ratio for video -*/ -#define KEY_RTC_VIDEO_MINBITRATE_RATIO "rtc.video.minbitrate_ratio" - -/** - * set the degradation preference -*/ -#define KEY_RTC_VIDEO_DEGRADATION_PREFERENCE "rtc.video.degradation_preference" - -/** - * set the degradation fps down step -*/ - -#define KEY_RTC_VIDEO_DEGRADATION_FPS_DOWN_STEP "rtc.video.degradation_fps_down_step" -/** - * set the degradation fps up step -*/ -#define KEY_RTC_VIDEO_DEGRADATION_FPS_UP_STEP "rtc.video.degradation_fps_up_step" - -/** - * set the duration ms for connection lost callback -*/ -#define KEY_RTC_CONNECTION_LOST_PERIOD "rtc.connection_lost_period" - -/** - * set the local ip -*/ -#define KEY_RTC_LOCAL_IP "rtc.local.ip" - -/** - * set the network interface -*/ -#define KEY_RTC_NETWORK_INTERFACE "rtc.network.interface" - -/** - * set the video codec type, such as "H264", "JPEG" - */ -#define KEY_RTC_VIDEO_MINOR_STREAM_CODEC_INDEX "engine.video.minor_stream_codec_index" -#define KEY_RTC_VIDEO_CODEC_INDEX "che.video.videoCodecIndex" -/** - * only use average QP for quality scaling -*/ -#define KEY_RTC_VIDEO_QUALITY_SCALE_ONLY_ON_AVERAGE_QP "engine.video.quality_scale_only_on_average_qp" - -/** - * low bound for quality scaling -*/ -#define KEY_RTC_VIDEO_H264_QP_THRESHOLD_LOW "engine.video.h264_qp_thresholds_low" - -/** - * high bound for quality scaling -*/ -#define KEY_RTC_VIDEO_H264_QP_THRESHOLD_HIGH "engine.video.h264_qp_thresholds_high" - - -namespace agora { - -namespace util { -template -class CopyableAutoPtr; - -class IString; -typedef CopyableAutoPtr AString; -} // namespace util - -namespace base { - -class IAgoraParameter : public RefCountInterface { - public: - /** - * release the resource - */ - virtual void release() = 0; - - /** - * set bool value of the json - * @param [in] key - * the key name - * @param [in] value - * the value - * @return return 0 if success or an error code - */ - virtual int setBool(const char* key, bool value) = 0; - - /** - * set int value of the json - * @param [in] key - * the key name - * @param [in] value - * the value - * @return return 0 if success or an error code - */ - virtual int setInt(const char* key, int value) = 0; - - /** - * set unsigned int value of the json - * @param [in] key - * the key name - * @param [in] value - * the value - * @return return 0 if success or an error code - */ - virtual int setUInt(const char* key, unsigned int value) = 0; - - /** - * set double value of the json - * @param [in] key - * the key name - * @param [in] value - * the value - * @return return 0 if success or an error code - */ - virtual int setNumber(const char* key, double value) = 0; - - /** - * set string value of the json - * @param [in] key - * the key name - * @param [in] value - * the value - * @return return 0 if success or an error code - */ - virtual int setString(const char* key, const char* value) = 0; - - /** - * set object value of the json - * @param [in] key - * the key name - * @param [in] value - * the value - * @return return 0 if success or an error code - */ - virtual int setObject(const char* key, const char* value) = 0; - - /** - * set array value of the json - * @param [in] key - * the key name - * @param [in] value - * the value - * @return return 0 if success or an error code - */ - virtual int setArray(const char* key, const char* value) = 0; - /** - * get bool value of the json - * @param [in] key - * the key name - * @param [in, out] value - * the value - * @return return 0 if success or an error code - */ - virtual int getBool(const char* key, bool& value) = 0; - - /** - * get int value of the json - * @param [in] key - * the key name - * @param [in, out] value - * the value - * @return return 0 if success or an error code - */ - virtual int getInt(const char* key, int& value) = 0; - - /** - * get unsigned int value of the json - * @param [in] key - * the key name - * @param [in, out] value - * the value - * @return return 0 if success or an error code - */ - virtual int getUInt(const char* key, unsigned int& value) = 0; - - /** - * get double value of the json - * @param [in] key - * the key name - * @param [in, out] value - * the value - * @return return 0 if success or an error code - */ - virtual int getNumber(const char* key, double& value) = 0; - - /** - * get string value of the json - * @param [in] key - * the key name - * @param [in, out] value - * the value - * @return return 0 if success or an error code - */ - virtual int getString(const char* key, agora::util::AString& value) = 0; - - /** - * get a child object value of the json - * @param [in] key - * the key name - * @param [in, out] value - * the value - * @return return 0 if success or an error code - */ - virtual int getObject(const char* key, agora::util::AString& value) = 0; - - /** - * get array value of the json - * @param [in] key - * the key name - * @param [in, out] value - * the value - * @return return 0 if success or an error code - */ - virtual int getArray(const char* key, const char* args, agora::util::AString& value) = 0; - - /** - * set parameters of the sdk or engine - * @param [in] parameters - * the parameters - * @return return 0 if success or an error code - */ - virtual int setParameters(const char* parameters) = 0; - - virtual int convertPath(const char* filePath, agora::util::AString& value) = 0; - - protected: - virtual ~IAgoraParameter() {} -}; - -} // namespace base -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRhythmPlayer.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRhythmPlayer.h deleted file mode 100644 index e2e00ac70..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRhythmPlayer.h +++ /dev/null @@ -1,92 +0,0 @@ -// -// Agora SDK -// -// Copyright (c) 2021 Agora.io. All rights reserved. -// - -#pragma once // NOLINT(build/header_guard) - -#include "AgoraBase.h" -#include "AgoraRefPtr.h" - -namespace agora { -namespace base { -class IAgoraService; -} - -namespace rtc { -class ILocalAudioTrack; -class IRtcEngineEventHandler; - -/** - The states of the rhythm player. - */ -enum RHYTHM_PLAYER_STATE_TYPE { - /** 810: The rhythm player is idle. */ - RHYTHM_PLAYER_STATE_IDLE = 810, - /** 811: The rhythm player is opening files. */ - RHYTHM_PLAYER_STATE_OPENING, - /** 812: Files opened successfully, the rhythm player starts decoding files. */ - RHYTHM_PLAYER_STATE_DECODING, - /** 813: Files decoded successfully, the rhythm player starts mixing the two files and playing back them locally. */ - RHYTHM_PLAYER_STATE_PLAYING, - /** 814: The rhythm player is starting to fail, and you need to check the error code for detailed failure reasons. */ - RHYTHM_PLAYER_STATE_FAILED, -}; - -/** - The reason codes of the rhythm player. - */ -enum RHYTHM_PLAYER_REASON { - /** 0: The rhythm player works well. */ - RHYTHM_PLAYER_REASON_OK = 0, - /** 1: The rhythm player occurs a internal error. */ - RHYTHM_PLAYER_REASON_FAILED = 1, - /** 801: The rhythm player can not open the file. */ - RHYTHM_PLAYER_REASON_CAN_NOT_OPEN = 801, - /** 802: The rhythm player can not play the file. */ - RHYTHM_PLAYER_REASON_CAN_NOT_PLAY, - /** 803: The file duration over the limit. The file duration limit is 1.2 seconds */ - RHYTHM_PLAYER_REASON_FILE_OVER_DURATION_LIMIT, -}; - -/** - * The configuration of rhythm player, - * which is set in startRhythmPlayer or configRhythmPlayer. - */ -struct AgoraRhythmPlayerConfig { - /** - * The number of beats per measure. The range is 1 to 9. - * The default value is 4, - * which means that each measure contains one downbeat and three upbeats. - */ - int beatsPerMeasure; - /* - * The range is 60 to 360. - * The default value is 60, - * which means that the rhythm player plays 60 beats in one minute. - */ - int beatsPerMinute; - - AgoraRhythmPlayerConfig() : beatsPerMeasure(4), beatsPerMinute(60) {} -}; - -/** - * The IRhythmPlayer class provides access to a rhythm player entity. - * A rhythm player synthesizes beats, plays them locally, and pushes them remotely. - */ -class IRhythmPlayer : public RefCountInterface { -protected: - virtual ~IRhythmPlayer() {} - -public: - static agora_refptr Create(); - virtual int initialize(base::IAgoraService* agora_service, IRtcEngineEventHandler* event_handler, bool is_pass_thru_mode) = 0; - virtual int playRhythm(const char* sound1, const char* sound2, const AgoraRhythmPlayerConfig& config) = 0; - virtual int stopRhythm() = 0; - virtual int configRhythmPlayer(const AgoraRhythmPlayerConfig& config) = 0; - virtual agora_refptr getRhythmPlayerTrack() = 0; -}; - -} //namespace rtc -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtcEngine.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtcEngine.h deleted file mode 100644 index b4746d898..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtcEngine.h +++ /dev/null @@ -1,8558 +0,0 @@ -// -// Agora Rtc Engine SDK -// -// Copyright (c) 2018 Agora.io. All rights reserved. -// -#pragma once - -#include "AgoraBase.h" -#include "AgoraMediaBase.h" -#include "IAgoraLog.h" -#include "AgoraOptional.h" -#include "IAudioDeviceManager.h" -#include "IAgoraRhythmPlayer.h" -#include "IAgoraMediaEngine.h" -#include "IAgoraH265Transcoder.h" - -namespace agora { -namespace rtm { -class IStreamChannel; -} -namespace rtc { - -template -static void SetFrom(Optional* s, const Optional& o) { - if (o) { - *s = o; - } -} - -template -static void ReplaceBy(Optional* s, const Optional& o) { - *s = o; -} - -//class IAudioDeviceManager; - -/** - * The media device types. - */ -enum MEDIA_DEVICE_TYPE { - /** - * -1: Unknown device type. - */ - UNKNOWN_AUDIO_DEVICE = -1, - /** - * 0: The audio playback device. - */ - AUDIO_PLAYOUT_DEVICE = 0, - /** - * 1: The audio recording device. - */ - AUDIO_RECORDING_DEVICE = 1, - /** - * 2: The video renderer. - */ - VIDEO_RENDER_DEVICE = 2, - /** - * 3: The video capturer. - */ - VIDEO_CAPTURE_DEVICE = 3, - /** - * 4: The audio playback device of the app. - */ - AUDIO_APPLICATION_PLAYOUT_DEVICE = 4, - /** - * 5: The virtual audio playback device. - */ - AUDIO_VIRTUAL_PLAYOUT_DEVICE = 5, - /** - * 6: The virtual audio recording device. - */ - AUDIO_VIRTUAL_RECORDING_DEVICE = 6, -}; - -/** - The playback state of the music file. - */ -enum AUDIO_MIXING_STATE_TYPE { - /** 710: The music file is playing. */ - AUDIO_MIXING_STATE_PLAYING = 710, - /** 711: The music file pauses playing. */ - AUDIO_MIXING_STATE_PAUSED = 711, - /** 713: The music file stops playing. */ - AUDIO_MIXING_STATE_STOPPED = 713, - /** 714: An error occurs during the playback of the audio mixing file. - */ - AUDIO_MIXING_STATE_FAILED = 714, -}; - -/** - The reson codes of the local user's audio mixing file. - */ -enum AUDIO_MIXING_REASON_TYPE { - /** 701: The SDK cannot open the audio mixing file. */ - AUDIO_MIXING_REASON_CAN_NOT_OPEN = 701, - /** 702: The SDK opens the audio mixing file too frequently. */ - AUDIO_MIXING_REASON_TOO_FREQUENT_CALL = 702, - /** 703: The audio mixing file playback is interrupted. */ - AUDIO_MIXING_REASON_INTERRUPTED_EOF = 703, - /** 715: The audio mixing file is played once. */ - AUDIO_MIXING_REASON_ONE_LOOP_COMPLETED = 721, - /** 716: The audio mixing file is all played out. */ - AUDIO_MIXING_REASON_ALL_LOOPS_COMPLETED = 723, - /** 716: The audio mixing file stopped by user */ - AUDIO_MIXING_REASON_STOPPED_BY_USER = 724, - /** 0: The SDK can open the audio mixing file. */ - AUDIO_MIXING_REASON_OK = 0, -}; - -/** - * The status of importing an external video stream in a live broadcast. - */ -enum INJECT_STREAM_STATUS { - /** - * 0: The media stream is injected successfully. - */ - INJECT_STREAM_STATUS_START_SUCCESS = 0, - /** - * 1: The media stream already exists. - */ - INJECT_STREAM_STATUS_START_ALREADY_EXISTS = 1, - /** - * 2: The media stream injection is unauthorized. - */ - INJECT_STREAM_STATUS_START_UNAUTHORIZED = 2, - /** - * 3: Timeout occurs when injecting a media stream. - */ - INJECT_STREAM_STATUS_START_TIMEDOUT = 3, - /** - * 4: The media stream injection fails. - */ - INJECT_STREAM_STATUS_START_FAILED = 4, - /** - * 5: The media stream stops being injected successfully. - */ - INJECT_STREAM_STATUS_STOP_SUCCESS = 5, - /** - * 6: The media stream injection that you want to stop is found. - */ - INJECT_STREAM_STATUS_STOP_NOT_FOUND = 6, - /** - * 7: You are not authorized to stop the media stream injection. - */ - INJECT_STREAM_STATUS_STOP_UNAUTHORIZED = 7, - /** - * 8: Timeout occurs when you stop injecting the media stream. - */ - INJECT_STREAM_STATUS_STOP_TIMEDOUT = 8, - /** - * 9: Stopping injecting the media stream fails. - */ - INJECT_STREAM_STATUS_STOP_FAILED = 9, - /** - * 10: The media stream is broken. - */ - INJECT_STREAM_STATUS_BROKEN = 10, -}; - -/** - * The audio equalization band frequency. - */ -enum AUDIO_EQUALIZATION_BAND_FREQUENCY { - /** - * 0: 31 Hz. - */ - AUDIO_EQUALIZATION_BAND_31 = 0, - /** - * 1: 62 Hz. - */ - AUDIO_EQUALIZATION_BAND_62 = 1, - /** - * 2: 125 Hz. - */ - AUDIO_EQUALIZATION_BAND_125 = 2, - /** - * 3: 250 Hz. - */ - AUDIO_EQUALIZATION_BAND_250 = 3, - /** - * 4: 500 Hz. - */ - AUDIO_EQUALIZATION_BAND_500 = 4, - /** - * 5: 1 KHz. - */ - AUDIO_EQUALIZATION_BAND_1K = 5, - /** - * 6: 2 KHz. - */ - AUDIO_EQUALIZATION_BAND_2K = 6, - /** - * 7: 4 KHz. - */ - AUDIO_EQUALIZATION_BAND_4K = 7, - /** - * 8: 8 KHz. - */ - AUDIO_EQUALIZATION_BAND_8K = 8, - /** - * 9: 16 KHz. - */ - AUDIO_EQUALIZATION_BAND_16K = 9, -}; - -/** - * The audio reverberation type. - */ -enum AUDIO_REVERB_TYPE { - /** - * 0: (-20 to 10 dB), the level of the dry signal. - */ - AUDIO_REVERB_DRY_LEVEL = 0, - /** - * 1: (-20 to 10 dB), the level of the early reflection signal (wet signal). - */ - AUDIO_REVERB_WET_LEVEL = 1, - /** - * 2: (0 to 100 dB), the room size of the reflection. - */ - AUDIO_REVERB_ROOM_SIZE = 2, - /** - * 3: (0 to 200 ms), the length of the initial delay of the wet signal in ms. - */ - AUDIO_REVERB_WET_DELAY = 3, - /** - * 4: (0 to 100), the strength of the late reverberation. - */ - AUDIO_REVERB_STRENGTH = 4, -}; - -enum STREAM_FALLBACK_OPTIONS { - /** 0: No fallback operation to a lower resolution stream when the network - condition is poor. Fallback to Scalable Video Coding (e.g. SVC) - is still possible, but the resolution remains in high stream. - The stream quality cannot be guaranteed. */ - STREAM_FALLBACK_OPTION_DISABLED = 0, - /** 1: (Default) Under poor network conditions, the receiver SDK will receive - agora::rtc::VIDEO_STREAM_LOW. You can only set this option in - RtcEngineParameters::setRemoteSubscribeFallbackOption. Nothing happens when - you set this in RtcEngineParameters::setLocalPublishFallbackOption. */ - STREAM_FALLBACK_OPTION_VIDEO_STREAM_LOW = 1, - /** 2: Under poor network conditions, the SDK may receive agora::rtc::VIDEO_STREAM_LOW first, - then agora::rtc::VIDEO_STREAM_LAYER_1 to agora::rtc::VIDEO_STREAM_LAYER_6 if the related layer exists. - If the network still does not allow displaying the video, the SDK will receive audio only. */ - STREAM_FALLBACK_OPTION_AUDIO_ONLY = 2, - /** 3~8: If the receiver SDK uses RtcEngineParameters::setRemoteSubscribeFallbackOption,it will receive - one of the streams from agora::rtc::VIDEO_STREAM_LAYER_1 to agora::rtc::VIDEO_STREAM_LAYER_6 - if the related layer exists when the network condition is poor. The lower bound of fallback depends on - the STREAM_FALLBACK_OPTION_VIDEO_STREAM_LAYER_X. */ - STREAM_FALLBACK_OPTION_VIDEO_STREAM_LAYER_1 = 3, - STREAM_FALLBACK_OPTION_VIDEO_STREAM_LAYER_2 = 4, - STREAM_FALLBACK_OPTION_VIDEO_STREAM_LAYER_3 = 5, - STREAM_FALLBACK_OPTION_VIDEO_STREAM_LAYER_4 = 6, - STREAM_FALLBACK_OPTION_VIDEO_STREAM_LAYER_5 = 7, - STREAM_FALLBACK_OPTION_VIDEO_STREAM_LAYER_6 = 8, -}; - -enum PRIORITY_TYPE { - /** 50: High priority. - */ - PRIORITY_HIGH = 50, - /** 100: (Default) normal priority. - */ - PRIORITY_NORMAL = 100, -}; - -struct RtcConnection; - -/** Statistics of the local video stream. - */ -struct LocalVideoStats -{ - /** - * ID of the local user. - */ - uid_t uid; - /** The actual bitrate (Kbps) while sending the local video stream. - * @note This value does not include the bitrate for resending the video after packet loss. - */ - int sentBitrate; - /** The actual frame rate (fps) while sending the local video stream. - * @note This value does not include the frame rate for resending the video after packet loss. - */ - int sentFrameRate; - /** The capture frame rate (fps) of the local video. - */ - int captureFrameRate; - /** The width of the capture frame (px). - */ - int captureFrameWidth; - /** The height of the capture frame (px). - */ - int captureFrameHeight; - /** - * The regulated frame rate of capture frame rate according to video encoder configuration. - */ - int regulatedCaptureFrameRate; - /** - * The regulated frame width (pixel) of capture frame width according to video encoder configuration. - */ - int regulatedCaptureFrameWidth; - /** - * The regulated frame height (pixel) of capture frame height according to video encoder configuration. - */ - int regulatedCaptureFrameHeight; - /** The output frame rate (fps) of the local video encoder. - */ - int encoderOutputFrameRate; - /** The width of the encoding frame (px). - */ - int encodedFrameWidth; - /** The height of the encoding frame (px). - */ - int encodedFrameHeight; - /** The output frame rate (fps) of the local video renderer. - */ - int rendererOutputFrameRate; - /** The target bitrate (Kbps) of the current encoder. This is an estimate made by the SDK based on the current network conditions. - */ - int targetBitrate; - /** The target frame rate (fps) of the current encoder. - */ - int targetFrameRate; - /** Quality adaption of the local video stream in the reported interval (based on the target frame - * rate and target bitrate). See #QUALITY_ADAPT_INDICATION. - */ - QUALITY_ADAPT_INDICATION qualityAdaptIndication; - /** The bitrate (Kbps) while encoding the local video stream. - * @note This value does not include the bitrate for resending the video after packet loss. - */ - int encodedBitrate; - /** The number of the sent video frames, represented by an aggregate value. - */ - int encodedFrameCount; - /** The codec type of the local video. See #VIDEO_CODEC_TYPE. - */ - VIDEO_CODEC_TYPE codecType; - /** - * The video packet loss rate (%) from the local client to the Agora server before applying the anti-packet loss strategies. - */ - unsigned short txPacketLossRate; - /** The brightness level of the video image captured by the local camera. See #CAPTURE_BRIGHTNESS_LEVEL_TYPE. - */ - CAPTURE_BRIGHTNESS_LEVEL_TYPE captureBrightnessLevel; - /** - * Whether we send dual stream now. - */ - bool dualStreamEnabled; - /** The hwEncoderAccelerating of the local video: - * - software = 0. - * - hardware = 1. - */ - int hwEncoderAccelerating; - /** The dimensions of the simulcast streams's encoding frame. - */ - VideoDimensions simulcastDimensions[SimulcastConfig::STREAM_LAYER_COUNT_MAX]; -}; - -/** - * Audio statistics of the remote user. - */ -struct RemoteAudioStats -{ - /** - * User ID of the remote user sending the audio stream. - */ - uid_t uid; - /** - * The quality of the remote audio: #QUALITY_TYPE. - */ - int quality; - /** - * The network delay (ms) from the sender to the receiver. - */ - int networkTransportDelay; - /** - * The network delay (ms) from the receiver to the jitter buffer. - * @note When the receiving end is an audience member and `audienceLatencyLevel` of `ClientRoleOptions` - * is 1, this parameter does not take effect. - */ - int jitterBufferDelay; - /** - * The audio frame loss rate in the reported interval. - */ - int audioLossRate; - /** - * The number of channels. - */ - int numChannels; - /** - * The sample rate (Hz) of the remote audio stream in the reported interval. - */ - int receivedSampleRate; - /** - * The average bitrate (Kbps) of the remote audio stream in the reported - * interval. - */ - int receivedBitrate; - /** - * The total freeze time (ms) of the remote audio stream after the remote - * user joins the channel. - * - * In a session, audio freeze occurs when the audio frame loss rate reaches 4%. - */ - int totalFrozenTime; - /** - * The total audio freeze time as a percentage (%) of the total time when the - * audio is available. - */ - int frozenRate; - /** - * The quality of the remote audio stream as determined by the Agora - * real-time audio MOS (Mean Opinion Score) measurement method in the - * reported interval. The return value ranges from 0 to 500. Dividing the - * return value by 100 gets the MOS score, which ranges from 0 to 5. The - * higher the score, the better the audio quality. - * - * | MOS score | Perception of audio quality | - * |-----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------| - * | Greater than 4 | Excellent. The audio sounds clear and smooth. | - * | From 3.5 to 4 | Good. The audio has some perceptible impairment, but still sounds clear. | - * | From 3 to 3.5 | Fair. The audio freezes occasionally and requires attentive listening. | - * | From 2.5 to 3 | Poor. The audio sounds choppy and requires considerable effort to understand. | - * | From 2 to 2.5 | Bad. The audio has occasional noise. Consecutive audio dropouts occur, resulting in some information loss. The users can communicate only with difficulty. | - * | Less than 2 | Very bad. The audio has persistent noise. Consecutive audio dropouts are frequent, resulting in severe information loss. Communication is nearly impossible. | - */ - int mosValue; - /** - * If the packet loss concealment (PLC) occurs for N consecutive times, freeze is considered as PLC occurring for M consecutive times. - * freeze cnt = (n_plc - n) / m - */ - uint32_t frozenRateByCustomPlcCount; - /** - * The number of audio packet loss concealment - */ - uint32_t plcCount; - - /** - * The total time (ms) when the remote user neither stops sending the audio - * stream nor disables the audio module after joining the channel. - */ - int totalActiveTime; - /** - * The total publish duration (ms) of the remote audio stream. - */ - int publishDuration; - /** - * Quality of experience (QoE) of the local user when receiving a remote audio stream. See #EXPERIENCE_QUALITY_TYPE. - */ - int qoeQuality; - /** - * The reason for poor QoE of the local user when receiving a remote audio stream. See #EXPERIENCE_POOR_REASON. - */ - int qualityChangedReason; - /** - * The total number of audio bytes received (bytes), inluding the FEC bytes, represented by an aggregate value. - */ - unsigned int rxAudioBytes; - /** - * The end-to-end delay (ms) from the sender to the receiver. - */ - int e2eDelay; - - RemoteAudioStats() - : uid(0), - quality(0), - networkTransportDelay(0), - jitterBufferDelay(0), - audioLossRate(0), - numChannels(0), - receivedSampleRate(0), - receivedBitrate(0), - totalFrozenTime(0), - frozenRate(0), - mosValue(0), - frozenRateByCustomPlcCount(0), - plcCount(0), - totalActiveTime(0), - publishDuration(0), - qoeQuality(0), - qualityChangedReason(0), - rxAudioBytes(0), - e2eDelay(0) {} -}; - -/** - * The statistics of the remote video stream. - */ -struct RemoteVideoStats { - /** - * ID of the remote user sending the video stream. - */ - uid_t uid; - /** - * @deprecated Time delay (ms). - * - * In scenarios where audio and video is synchronized, you can use the - * value of `networkTransportDelay` and `jitterBufferDelay` in `RemoteAudioStats` - * to know the delay statistics of the remote video. - */ - int delay __deprecated; - /** - * End-to-end delay from video capturer to video renderer. Hardware capture or render delay is excluded. - */ - int e2eDelay; - /** - * The width (pixels) of the video stream. - */ - int width; - /** - * The height (pixels) of the video stream. - */ - int height; - /** - * Bitrate (Kbps) received since the last count. - */ - int receivedBitrate; - /** The decoder input frame rate (fps) of the remote video. - */ - int decoderInputFrameRate; - /** The decoder output frame rate (fps) of the remote video. - */ - int decoderOutputFrameRate; - /** The render output frame rate (fps) of the remote video. - */ - int rendererOutputFrameRate; - /** The video frame loss rate (%) of the remote video stream in the reported interval. - */ - int frameLossRate; - /** Packet loss rate (%) of the remote video stream after using the anti-packet-loss method. - */ - int packetLossRate; - /** - * The type of the remote video stream: #VIDEO_STREAM_TYPE. - */ - VIDEO_STREAM_TYPE rxStreamType; - /** - The total freeze time (ms) of the remote video stream after the remote user joins the channel. - In a video session where the frame rate is set to no less than 5 fps, video freeze occurs when - the time interval between two adjacent renderable video frames is more than 500 ms. - */ - int totalFrozenTime; - /** - The total video freeze time as a percentage (%) of the total time when the video is available. - */ - int frozenRate; - /** - The offset (ms) between audio and video stream. A positive value indicates the audio leads the - video, and a negative value indicates the audio lags the video. - */ - int avSyncTimeMs; - /** - * The total time (ms) when the remote user neither stops sending the audio - * stream nor disables the audio module after joining the channel. - */ - int totalActiveTime; - /** - * The total publish duration (ms) of the remote audio stream. - */ - int publishDuration; - /** - * The quality of the remote video stream in the reported interval. - * The quality is determined by the Agora real-time video MOS (Mean Opinion Score) measurement method. - * The return value range is [0, 500]. - * Dividing the return value by 100 gets the MOS score, which ranges from 0 to 5. The higher the score, the better the video quality. - * @note For textured video data, this parameter always returns 0. - */ - int mosValue; - /** - * The total number of video bytes received (bytes), inluding the FEC bytes, represented by an aggregate value. - */ - unsigned int rxVideoBytes; -}; - -struct VideoCompositingLayout { - struct Region { - /** User ID of the user whose video is to be displayed in the region. - */ - uid_t uid; - /** Horizontal position of the region on the screen. - */ - double x; // [0,1] - /** Vertical position of the region on the screen. - */ - double y; // [0,1] - /** - Actual width of the region. - */ - double width; // [0,1] - /** Actual height of the region. */ - double height; // [0,1] - /** 0 means the region is at the bottom, and 100 means the region is at the - * top. - */ - int zOrder; // optional, [0, 100] //0 (default): bottom most, 100: top most - - /** 0 means the region is transparent, and 1 means the region is opaque. The - * default value is 1.0. - */ - double alpha; - - media::base::RENDER_MODE_TYPE renderMode; // RENDER_MODE_HIDDEN: Crop, RENDER_MODE_FIT: Zoom to fit - - Region() - : uid(0), - x(0), - y(0), - width(0), - height(0), - zOrder(0), - alpha(1.0), - renderMode(media::base::RENDER_MODE_HIDDEN) {} - }; - - /** Ignore this parameter. The width of the canvas is set by - agora::rtc::IRtcEngine::configPublisher, and not by - agora::rtc::VideoCompositingLayout::canvasWidth. - */ - int canvasWidth; - /** Ignore this parameter. The height of the canvas is set by - agora::rtc::IRtcEngine::configPublisher, and not by - agora::rtc::VideoCompositingLayout::canvasHeight. - */ - int canvasHeight; - /** Enter any of the 6-digit symbols defined in RGB. - */ - const char* backgroundColor; // e.g. "#C0C0C0" in RGB - /** Region array. Each host in the channel can have a region to display the - * video on the screen. - */ - const Region* regions; - /** Number of users in the channel. - */ - int regionCount; - /** User-defined data. - */ - const char* appData; - /** Length of the user-defined data. - */ - int appDataLength; - - VideoCompositingLayout() - : canvasWidth(0), - canvasHeight(0), - backgroundColor(OPTIONAL_NULLPTR), - regions(NULL), - regionCount(0), - appData(OPTIONAL_NULLPTR), - appDataLength(0) {} -}; - -/** The definition of InjectStreamConfig. - */ -struct InjectStreamConfig { - /** Width of the stream to be added into the broadcast. The default value is - 0; same width as the original stream. - */ - int width; - /** Height of the stream to be added into the broadcast. The default value is - 0; same height as the original stream. - */ - int height; - /** Video GOP of the stream to be added into the broadcast. The default value - is 30. - */ - int videoGop; - /** Video frame rate of the stream to be added into the broadcast. The - default value is 15 fps. - */ - int videoFramerate; - /** Video bitrate of the stream to be added into the broadcast. The default - value is 400 Kbps. - */ - int videoBitrate; - /** Audio-sampling rate of the stream to be added into the broadcast: - #AUDIO_SAMPLE_RATE_TYPE. The default value is 48000. - */ - AUDIO_SAMPLE_RATE_TYPE audioSampleRate; - /** Audio bitrate of the stream to be added into the broadcast. The default - value is 48. - */ - int audioBitrate; - /** Audio channels to be added into the broadcast. The default value is 1. - */ - int audioChannels; - - // width / height default set to 0 means pull the stream with its original - // resolution - InjectStreamConfig() - : width(0), - height(0), - videoGop(30), - videoFramerate(15), - videoBitrate(400), - audioSampleRate(AUDIO_SAMPLE_RATE_48000), - audioBitrate(48), - audioChannels(1) {} -}; - -/** The video stream lifecycle of CDN Live. - */ -enum RTMP_STREAM_LIFE_CYCLE_TYPE { - /** Bound to the channel lifecycle. - */ - RTMP_STREAM_LIFE_CYCLE_BIND2CHANNEL = 1, - /** Bound to the owner identity of the RTMP stream. - */ - RTMP_STREAM_LIFE_CYCLE_BIND2OWNER = 2, -}; - -/** The definition of PublisherConfiguration. -*/ -struct PublisherConfiguration { - /** Width of the output data stream set for CDN Live. The default value is - 360. - */ - int width; - /** Height of the output data stream set for CDN Live. The default value is - 640. - */ - int height; - /** Frame rate of the output data stream set for CDN Live. The default value - is 15 fps. - */ - int framerate; - /** Bitrate of the output data stream set for CDN Live. The default value is - 500 Kbps. - */ - int bitrate; - /** The default layout: - - 0: Tile horizontally - - 1: Layered windows - - 2: Tile vertically - */ - int defaultLayout; - /** The video stream lifecycle of CDN Live: RTMP_STREAM_LIFE_CYCLE_TYPE - */ - int lifecycle; - /** Whether the current user is the owner of the RTMP stream: - - True: Yes (default). The push-stream configuration takes effect. - - False: No. The push-stream configuration will not work. - */ - bool owner; - /** Width of the stream to be injected. Set it as 0. - */ - int injectStreamWidth; - /** Height of the stream to be injected. Set it as 0. - */ - int injectStreamHeight; - /** URL address of the stream to be injected to the channel. - */ - const char* injectStreamUrl; - /** Push-stream URL address for the picture-in-picture layouts. The default - value is NULL. - */ - const char* publishUrl; - /** Push-stream URL address of the original stream which does not require - picture-blending. The default value is NULL. - */ - const char* rawStreamUrl; - /** Reserved field. The default value is NULL. - */ - const char* extraInfo; - - PublisherConfiguration() - : width(640), - height(360), - framerate(15), - bitrate(500), - defaultLayout(1), - lifecycle(RTMP_STREAM_LIFE_CYCLE_BIND2CHANNEL), - owner(true), - injectStreamWidth(0), - injectStreamHeight(0), - injectStreamUrl(NULL), - publishUrl(NULL), - rawStreamUrl(NULL), - extraInfo(NULL) {} -}; - -/** - * The camera direction. - */ -enum CAMERA_DIRECTION { - /** The rear camera. */ - CAMERA_REAR = 0, - /** The front camera. */ - CAMERA_FRONT = 1, -}; - -/** The cloud proxy type. - * - * @since v3.3.0 - */ -enum CLOUD_PROXY_TYPE { - /** 0: Do not use the cloud proxy. - */ - NONE_PROXY = 0, - /** 1: The cloud proxy for the UDP protocol. - */ - UDP_PROXY = 1, - /// @cond - /** 2: The cloud proxy for the TCP (encrypted) protocol. - */ - TCP_PROXY = 2, - /// @endcond -}; - -/** Camera capturer configuration.*/ -struct CameraCapturerConfiguration { - /** Camera direction settings (for Android/iOS only). See: #CAMERA_DIRECTION. */ -#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) || defined(__OHOS__) - /** - * The camera direction. - */ - Optional cameraDirection; - - /*- CAMERA_FOCAL_LENGTH_TYPE.CAMERA_FOCAL_LENGTH_DEFAULT: - For iOS, if iPhone/iPad has 3 or 2 back camera, it means combination of triple (wide + ultra wide + telephoto) camera - or dual wide(wide + ultra wide) camera.In this situation, you can apply for ultra wide len by set smaller zoom fator - and bigger zoom fator for telephoto len.Otherwise, it always means wide back/front camera. - - - CAMERA_FOCAL_LENGTH_TYPE.CAMERA_FOCAL_LENGTH_WIDE_ANGLE:wide camera - - CAMERA_FOCAL_LENGTH_TYPE.CAMERA_FOCAL_LENGTH_ULTRA_WIDE:ultra wide camera - - CAMERA_FOCAL_LENGTH_TYPE.CAMERA_FOCAL_LENGTH_TELEPHOTO:telephoto camera*/ - Optional cameraFocalLengthType; -#else - /** For windows. The device ID of the playback device. */ - Optional deviceId; -#endif - -#if defined(__ANDROID__) - /** - * The camera id. - */ - Optional cameraId; -#endif - Optional followEncodeDimensionRatio; - /** The video format. See VideoFormat. */ - VideoFormat format; - CameraCapturerConfiguration() : format(VideoFormat(0, 0, 0)) {} -}; -/** - * The configuration of the captured screen. - */ -struct ScreenCaptureConfiguration { - /** - * Whether to capture the window on the screen: - * - `true`: Capture the window. - * - `false`: (Default) Capture the screen, not the window. - */ - bool isCaptureWindow; // true - capture window, false - capture display - /** - * (macOS only) The display ID of the screen. - */ - uint32_t displayId; - /** - * (Windows only) The relative position of the shared screen to the virtual screen. - * @note This parameter takes effect only when you want to capture the screen on Windows. - */ - Rectangle screenRect; //Windows only - /** - * (For Windows and macOS only) The window ID. - * @note This parameter takes effect only when you want to capture the window. - */ - view_t windowId; - /** - * (For Windows and macOS only) The screen capture configuration. For details, see ScreenCaptureParameters. - */ - ScreenCaptureParameters params; - /** - * (For Windows and macOS only) The relative position of the shared region to the whole screen. For details, see Rectangle. - * - * If you do not set this parameter, the SDK shares the whole screen. If the region you set exceeds the boundary of the - * screen, only the region within in the screen is shared. If you set width or height in Rectangle as 0, the whole - * screen is shared. - */ - Rectangle regionRect; - - ScreenCaptureConfiguration() : isCaptureWindow(false), displayId(0), windowId(0) {} -}; - -#if (defined(__APPLE__) && TARGET_OS_MAC && !TARGET_OS_IPHONE) -/** The size of the screen shot to the screen or window. - */ -struct SIZE { - /** The width of the screen shot. - */ - int width; - /** The width of the screen shot. - */ - int height; - - SIZE() : width(0), height(0) {} - SIZE(int ww, int hh) : width(ww), height(hh) {} -}; -#endif - -#if defined(_WIN32) || (defined(__APPLE__) && TARGET_OS_MAC && !TARGET_OS_IPHONE) -/** - * The image content of the thumbnail or icon. - * @note The default image is in the RGBA format. If you need to use another format, you need to convert the image on - * your own. - */ -struct ThumbImageBuffer { - /** - * The buffer of the thumbnail ot icon. - */ - const char* buffer; - /** - * The buffer length of the thumbnail or icon, in bytes. - */ - unsigned int length; - /** - * The actual width (px) of the thumbnail or icon. - */ - unsigned int width; - /** - * The actual height (px) of the thumbnail or icon. - */ - unsigned int height; - ThumbImageBuffer() : buffer(nullptr), length(0), width(0), height(0) {} -}; -/** - * The type of the shared target. Set in ScreenCaptureSourceInfo. - */ -enum ScreenCaptureSourceType { - /** -1: Unknown type. */ - ScreenCaptureSourceType_Unknown = -1, - /** 0: The shared target is a window.*/ - ScreenCaptureSourceType_Window = 0, - /** 1: The shared target is a screen of a particular monitor.*/ - ScreenCaptureSourceType_Screen = 1, - /** 2: Reserved parameter.*/ - ScreenCaptureSourceType_Custom = 2, -}; -/** The information about the specified shareable window or screen. It is returned in IScreenCaptureSourceList. */ -struct ScreenCaptureSourceInfo { - /** - * The type of the shared target. See \ref agora::rtc::ScreenCaptureSourceType "ScreenCaptureSourceType". - */ - ScreenCaptureSourceType type; - /** - * The window ID for a window or the display ID for a screen. - */ - view_t sourceId; - /** - * The name of the window or screen. UTF-8 encoding. - */ - const char* sourceName; - /** - * The image content of the thumbnail. See ThumbImageBuffer. - */ - ThumbImageBuffer thumbImage; - /** - * The image content of the icon. See ThumbImageBuffer. - */ - ThumbImageBuffer iconImage; - /** - * The process to which the window belongs. UTF-8 encoding. - */ - const char* processPath; - /** - * The title of the window. UTF-8 encoding. - */ - const char* sourceTitle; - /** - * Determines whether the screen is the primary display: - * - true: The screen is the primary display. - * - false: The screen is not the primary display. - */ - bool primaryMonitor; - bool isOccluded; - /** - * The relative position of the shared region to the screen space (A virtual space include all the screens). See Rectangle. - */ - Rectangle position; -#if defined(_WIN32) - /** - * Determines whether the window is minimized. - */ - bool minimizeWindow; - /** - * The display ID to the window of interest. - * If the window intersects one or more display monitor rectangles, the return value is an valid - * ID to the display monitor that has the largest area of intersection with the window, Otherwise - * the return value is -2. - */ - view_t sourceDisplayId; - ScreenCaptureSourceInfo() : type(ScreenCaptureSourceType_Unknown), sourceId(nullptr), sourceName(nullptr), - processPath(nullptr), sourceTitle(nullptr), primaryMonitor(false), isOccluded(false), minimizeWindow(false), sourceDisplayId((view_t)-2) {} -#else - ScreenCaptureSourceInfo() : type(ScreenCaptureSourceType_Unknown), sourceId(nullptr), sourceName(nullptr), processPath(nullptr), sourceTitle(nullptr), primaryMonitor(false), isOccluded(false) {} -#endif -}; -/** - * The IScreenCaptureSourceList class. This class is returned in the getScreenCaptureSources method. - */ -class IScreenCaptureSourceList { - protected: - virtual ~IScreenCaptureSourceList(){}; - - public: - /** - * Gets the number of shareable cpp and screens. - * - * @return The number of shareable cpp and screens. - */ - virtual unsigned int getCount() = 0; - /** - * Gets information about the specified shareable window or screen. - * - * After you get IScreenCaptureSourceList, you can pass in the index value of the specified shareable window or - * screen to get information about that window or screen from ScreenCaptureSourceInfo. - * - * @param index The index of the specified shareable window or screen. The value range is [0, getCount()). - * @return ScreenCaptureSourceInfo The information of the specified window or screen. - */ - virtual ScreenCaptureSourceInfo getSourceInfo(unsigned int index) = 0; - /** - * Releases IScreenCaptureSourceList. - * - * After you get the list of shareable cpp and screens, to avoid memory leaks, call this method to release - * IScreenCaptureSourceList instead of deleting IScreenCaptureSourceList directly. - */ - virtual void release() = 0; -}; -#endif // _WIN32 || (__APPLE__ && !TARGET_OS_IPHONE && TARGET_OS_MAC) -/** - * The advanced options for audio. - */ -struct AdvancedAudioOptions { - /** - * Audio processing channels, only support 1 or 2. - */ - Optional audioProcessingChannels; - - AdvancedAudioOptions() {} - ~AdvancedAudioOptions() {} -}; - -struct ImageTrackOptions { - const char* imageUrl; - int fps; - VIDEO_MIRROR_MODE_TYPE mirrorMode; - ImageTrackOptions() : imageUrl(NULL), fps(1), mirrorMode(VIDEO_MIRROR_MODE_DISABLED) {} -}; - -/** - * The channel media options. - * - * Agora supports publishing multiple audio streams and one video stream at the same time and in the same RtcConnection. - * For example, `publishAudioTrack`, `publishCustomAudioTrack` and `publishMediaPlayerAudioTrack` can be true at the same time; - * but only one of `publishCameraTrack`, `publishScreenTrack`, `publishCustomVideoTrack`, and `publishEncodedVideoTrack` can be - * true at the same time. - */ -struct ChannelMediaOptions { - /** - * Whether to publish the video of the camera track. - * - `true`: (Default) Publish the video track of the camera capturer. - * - `false`: Do not publish the video track of the camera capturer. - */ - Optional publishCameraTrack; - /** - * Whether to publish the video of the secondary camera track. - * - `true`: Publish the video track of the secondary camera capturer. - * - `false`: (Default) Do not publish the video track of the secondary camera capturer. - */ - Optional publishSecondaryCameraTrack; - /** - * Whether to publish the video of the third camera track. - * - `true`: Publish the video track of the third camera capturer. - * - `false`: (Default) Do not publish the video track of the third camera capturer. - */ - Optional publishThirdCameraTrack; - /** - * Whether to publish the video of the fourth camera track. - * - `true`: Publish the video track of the fourth camera capturer. - * - `false`: (Default) Do not publish the video track of the fourth camera capturer. - */ - Optional publishFourthCameraTrack; - /** - * Whether to publish the recorded audio. - * - `true`: (Default) Publish the recorded audio. - * - `false`: Do not publish the recorded audio. - */ - Optional publishMicrophoneTrack; - - #if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || defined(__OHOS__) - /** - * Whether to publish the video track of the screen capturer: - * - `true`: Publish the video track of the screen capture. - * - `false`: (Default) Do not publish the video track of the screen capture. - */ - Optional publishScreenCaptureVideo; - /** - * Whether to publish the audio track of the screen capturer: - * - `true`: Publish the video audio of the screen capturer. - * - `false`: (Default) Do not publish the audio track of the screen capturer. - */ - Optional publishScreenCaptureAudio; - #else - /** - * Whether to publish the captured video from the screen: - * - `true`: PPublish the captured video from the screen. - * - `false`: (Default) Do not publish the captured video from the screen. - */ - Optional publishScreenTrack; - /** - * Whether to publish the captured video from the secondary screen: - * - true: Publish the captured video from the secondary screen. - * - false: (Default) Do not publish the captured video from the secondary screen. - */ - Optional publishSecondaryScreenTrack; - /** - * Whether to publish the captured video from the third screen: - * - true: Publish the captured video from the third screen. - * - false: (Default) Do not publish the captured video from the third screen. - */ - Optional publishThirdScreenTrack; - /** - * Whether to publish the captured video from the fourth screen: - * - true: Publish the captured video from the fourth screen. - * - false: (Default) Do not publish the captured video from the fourth screen. - */ - Optional publishFourthScreenTrack; - #endif - - /** - * Whether to publish the captured audio from a custom source: - * - true: Publish the captured audio from a custom source. - * - false: (Default) Do not publish the captured audio from the custom source. - */ - Optional publishCustomAudioTrack; - /** - * The custom audio track id. The default value is 0. - */ - Optional publishCustomAudioTrackId; - /** - * Whether to publish the captured video from a custom source: - * - `true`: Publish the captured video from a custom source. - * - `false`: (Default) Do not publish the captured video from the custom source. - */ - Optional publishCustomVideoTrack; - /** - * Whether to publish the encoded video: - * - `true`: Publish the encoded video. - * - `false`: (Default) Do not publish the encoded video. - */ - Optional publishEncodedVideoTrack; - /** - * Whether to publish the audio from the media player: - * - `true`: Publish the audio from the media player. - * - `false`: (Default) Do not publish the audio from the media player. - */ - Optional publishMediaPlayerAudioTrack; - /** - * Whether to publish the video from the media player: - * - `true`: Publish the video from the media player. - * - `false`: (Default) Do not publish the video from the media player. - */ - Optional publishMediaPlayerVideoTrack; - /** - * Whether to publish the local transcoded video track. - * - `true`: Publish the video track of local transcoded video track. - * - `false`: (Default) Do not publish the local transcoded video track. - */ - Optional publishTranscodedVideoTrack; - /** - * Whether to publish the local mixed track. - * - `true`: Publish the audio track of local mixed track. - * - `false`: (Default) Do not publish the local mixed track. - */ - Optional publishMixedAudioTrack; - /** - * Whether to publish the local lip sync video track. - * - `true`: Publish the video track of local lip sync video track. - * - `false`: (Default) Do not publish the local lip sync video track. - */ - Optional publishLipSyncTrack; - /** - * Whether to automatically subscribe to all remote audio streams when the user joins a channel: - * - `true`: (Default) Subscribe to all remote audio streams. - * - `false`: Do not subscribe to any remote audio stream. - */ - Optional autoSubscribeAudio; - /** - * Whether to subscribe to all remote video streams when the user joins the channel: - * - `true`: (Default) Subscribe to all remote video streams. - * - `false`: Do not subscribe to any remote video stream. - */ - Optional autoSubscribeVideo; - /** - * Whether to enable audio capturing or playback. - * - `true`: (Default) Enable audio capturing and playback. - * - `false`: Do not enable audio capturing or playback. - */ - Optional enableAudioRecordingOrPlayout; - /** - * The ID of the media player to be published. The default value is 0. - */ - Optional publishMediaPlayerId; - /** - * The client role type. See \ref CLIENT_ROLE_TYPE. - * Default is CLIENT_ROLE_AUDIENCE. - */ - Optional clientRoleType; - /** - * The audience latency level type. See #AUDIENCE_LATENCY_LEVEL_TYPE. - */ - Optional audienceLatencyLevel; - /** - * The default video stream type. See \ref VIDEO_STREAM_TYPE. - * Default is VIDEO_STREAM_HIGH. - */ - Optional defaultVideoStreamType; - /** - * The channel profile. See \ref CHANNEL_PROFILE_TYPE. - * Default is CHANNEL_PROFILE_LIVE_BROADCASTING. - */ - Optional channelProfile; - /** - * The delay in ms for sending audio frames. This is used for explicit control of A/V sync. - * To switch off the delay, set the value to zero. - */ - Optional audioDelayMs; - /** - * The delay in ms for sending media player audio frames. This is used for explicit control of A/V sync. - * To switch off the delay, set the value to zero. - */ - Optional mediaPlayerAudioDelayMs; - /** - * (Optional) The token generated on your server for authentication. - * @note - * - This parameter takes effect only when calling `updateChannelMediaOptions` or `updateChannelMediaOptionsEx`. - * - Ensure that the App ID, channel name, and user name used for creating the token are the same ones as those - * used by the initialize method for initializing the RTC engine, and those used by the `joinChannel [2/2]` - * and `joinChannelEx` methods for joining the channel. - */ - Optional token; - /** - * Whether to enable media packet encryption: - * - `true`: Yes. - * - `false`: (Default) No. - * - * @note This parameter is ignored when calling `updateChannelMediaOptions`. - */ - Optional enableBuiltInMediaEncryption; - /** - * Whether to publish the sound of the rhythm player to remote users: - * - `true`: (Default) Publish the sound of the rhythm player. - * - `false`: Do not publish the sound of the rhythm player. - */ - Optional publishRhythmPlayerTrack; - /** - * Whether the user is an interactive audience member in the channel. - * - `true`: Enable low lentancy and smooth video when joining as an audience. - * - `false`: (Default) Use default settings for audience role. - * @note This mode is only used for audience. In PK mode, client might join one channel as broadcaster, and join - * another channel as interactive audience to achieve low lentancy and smooth video from remote user. - */ - Optional isInteractiveAudience; - /** - * The custom video track id which will used to publish or preview. - * You can get the VideoTrackId after calling createCustomVideoTrack() of IRtcEngine. - */ - Optional customVideoTrackId; - /** - * Whether local audio stream can be filtered. - * - `true`: (Default) Can be filtered when audio level is low. - * - `false`: Do not Filter this audio stream. - */ - Optional isAudioFilterable; - - /** Provides the technical preview functionalities or special customizations by configuring the SDK with JSON options. - Pointer to the set parameters in a JSON string. - * @technical preview - */ - Optional parameters; - - ChannelMediaOptions() {} - ~ChannelMediaOptions() {} - - void SetAll(const ChannelMediaOptions& change) { -#define SET_FROM(X) SetFrom(&X, change.X) - - SET_FROM(publishCameraTrack); - SET_FROM(publishSecondaryCameraTrack); - SET_FROM(publishThirdCameraTrack); - SET_FROM(publishFourthCameraTrack); - SET_FROM(publishMicrophoneTrack); -#if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || defined(__OHOS__) - SET_FROM(publishScreenCaptureVideo); - SET_FROM(publishScreenCaptureAudio); -#else - SET_FROM(publishScreenTrack); - SET_FROM(publishSecondaryScreenTrack); - SET_FROM(publishThirdScreenTrack); - SET_FROM(publishFourthScreenTrack); -#endif - SET_FROM(publishTranscodedVideoTrack); - SET_FROM(publishMixedAudioTrack); - SET_FROM(publishLipSyncTrack); - SET_FROM(publishCustomAudioTrack); - SET_FROM(publishCustomAudioTrackId); - SET_FROM(publishCustomVideoTrack); - SET_FROM(publishEncodedVideoTrack); - SET_FROM(publishMediaPlayerAudioTrack); - SET_FROM(publishMediaPlayerVideoTrack); - SET_FROM(autoSubscribeAudio); - SET_FROM(autoSubscribeVideo); - SET_FROM(publishMediaPlayerId); - SET_FROM(enableAudioRecordingOrPlayout); - SET_FROM(clientRoleType); - SET_FROM(audienceLatencyLevel); - SET_FROM(defaultVideoStreamType); - SET_FROM(channelProfile); - SET_FROM(audioDelayMs); - SET_FROM(mediaPlayerAudioDelayMs); - SET_FROM(token); - SET_FROM(enableBuiltInMediaEncryption); - SET_FROM(publishRhythmPlayerTrack); - SET_FROM(customVideoTrackId); - SET_FROM(isAudioFilterable); - SET_FROM(isInteractiveAudience); - SET_FROM(parameters); -#undef SET_FROM - } - - bool operator==(const ChannelMediaOptions& o) const { -#define BEGIN_COMPARE() bool b = true -#define ADD_COMPARE(X) b = (b && (X == o.X)) -#define END_COMPARE() - - BEGIN_COMPARE(); - ADD_COMPARE(publishCameraTrack); - ADD_COMPARE(publishSecondaryCameraTrack); - ADD_COMPARE(publishThirdCameraTrack); - ADD_COMPARE(publishFourthCameraTrack); - ADD_COMPARE(publishMicrophoneTrack); -#if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || defined(__OHOS__) - ADD_COMPARE(publishScreenCaptureVideo); - ADD_COMPARE(publishScreenCaptureAudio); -#else - ADD_COMPARE(publishScreenTrack); - ADD_COMPARE(publishSecondaryScreenTrack); - ADD_COMPARE(publishThirdScreenTrack); - ADD_COMPARE(publishFourthScreenTrack); -#endif - ADD_COMPARE(publishTranscodedVideoTrack); - ADD_COMPARE(publishMixedAudioTrack); - ADD_COMPARE(publishLipSyncTrack); - ADD_COMPARE(publishCustomAudioTrack); - ADD_COMPARE(publishCustomAudioTrackId); - ADD_COMPARE(publishCustomVideoTrack); - ADD_COMPARE(publishEncodedVideoTrack); - ADD_COMPARE(publishMediaPlayerAudioTrack); - ADD_COMPARE(publishMediaPlayerVideoTrack); - ADD_COMPARE(autoSubscribeAudio); - ADD_COMPARE(autoSubscribeVideo); - ADD_COMPARE(publishMediaPlayerId); - ADD_COMPARE(enableAudioRecordingOrPlayout); - ADD_COMPARE(clientRoleType); - ADD_COMPARE(audienceLatencyLevel); - ADD_COMPARE(defaultVideoStreamType); - ADD_COMPARE(channelProfile); - ADD_COMPARE(audioDelayMs); - ADD_COMPARE(mediaPlayerAudioDelayMs); - ADD_COMPARE(token); - ADD_COMPARE(enableBuiltInMediaEncryption); - ADD_COMPARE(publishRhythmPlayerTrack); - ADD_COMPARE(customVideoTrackId); - ADD_COMPARE(isAudioFilterable); - ADD_COMPARE(isInteractiveAudience); - ADD_COMPARE(parameters); - END_COMPARE(); - -#undef BEGIN_COMPARE -#undef ADD_COMPARE -#undef END_COMPARE - return b; - } - - ChannelMediaOptions& operator=(const ChannelMediaOptions& replace) { - if (this != &replace) { -#define REPLACE_BY(X) ReplaceBy(&X, replace.X) - - REPLACE_BY(publishCameraTrack); - REPLACE_BY(publishSecondaryCameraTrack); - REPLACE_BY(publishThirdCameraTrack); - REPLACE_BY(publishFourthCameraTrack); - REPLACE_BY(publishMicrophoneTrack); -#if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || defined(__OHOS__) - REPLACE_BY(publishScreenCaptureVideo); - REPLACE_BY(publishScreenCaptureAudio); -#else - REPLACE_BY(publishScreenTrack); - REPLACE_BY(publishSecondaryScreenTrack); - REPLACE_BY(publishThirdScreenTrack); - REPLACE_BY(publishFourthScreenTrack); -#endif - REPLACE_BY(publishTranscodedVideoTrack); - REPLACE_BY(publishMixedAudioTrack); - REPLACE_BY(publishLipSyncTrack); - REPLACE_BY(publishCustomAudioTrack); - REPLACE_BY(publishCustomAudioTrackId); - REPLACE_BY(publishCustomVideoTrack); - REPLACE_BY(publishEncodedVideoTrack); - REPLACE_BY(publishMediaPlayerAudioTrack); - REPLACE_BY(publishMediaPlayerVideoTrack); - REPLACE_BY(autoSubscribeAudio); - REPLACE_BY(autoSubscribeVideo); - REPLACE_BY(publishMediaPlayerId); - REPLACE_BY(enableAudioRecordingOrPlayout); - REPLACE_BY(clientRoleType); - REPLACE_BY(audienceLatencyLevel); - REPLACE_BY(defaultVideoStreamType); - REPLACE_BY(channelProfile); - REPLACE_BY(audioDelayMs); - REPLACE_BY(mediaPlayerAudioDelayMs); - REPLACE_BY(token); - REPLACE_BY(enableBuiltInMediaEncryption); - REPLACE_BY(publishRhythmPlayerTrack); - REPLACE_BY(customVideoTrackId); - REPLACE_BY(isAudioFilterable); - REPLACE_BY(isInteractiveAudience); - REPLACE_BY(parameters); -#undef REPLACE_BY - } - return *this; - } -}; - -enum PROXY_TYPE { - /** 0: Do not use the cloud proxy. - */ - NONE_PROXY_TYPE = 0, - /** 1: The cloud proxy for the UDP protocol. - */ - UDP_PROXY_TYPE = 1, - /** 2: The cloud proxy for the TCP (encrypted) protocol. - */ - TCP_PROXY_TYPE = 2, - /** 3: The local proxy. - */ - LOCAL_PROXY_TYPE = 3, - /** 4: auto fallback to tcp cloud proxy - */ - TCP_PROXY_AUTO_FALLBACK_TYPE = 4, - /** 5: The http proxy. - */ - HTTP_PROXY_TYPE = 5, - /** 6: The https proxy. - */ - HTTPS_PROXY_TYPE = 6, -}; - -enum FeatureType { - VIDEO_VIRTUAL_BACKGROUND = 1, - VIDEO_BEAUTY_EFFECT = 2, -}; - -/** - * The options for leaving a channel. - */ -struct LeaveChannelOptions { - /** - * Whether to stop playing and mixing the music file when a user leaves the channel. - * - `true`: (Default) Stop playing and mixing the music file. - * - `false`: Do not stop playing and mixing the music file. - */ - bool stopAudioMixing; - /** - * Whether to stop playing all audio effects when a user leaves the channel. - * - `true`: (Default) Stop playing all audio effects. - * - `false`: Do not stop playing any audio effect. - */ - bool stopAllEffect; - /** - * Whether to stop microphone recording when a user leaves the channel. - * - `true`: (Default) Stop microphone recording. - * - `false`: Do not stop microphone recording. - */ - bool stopMicrophoneRecording; - - LeaveChannelOptions() : stopAudioMixing(true), stopAllEffect(true), stopMicrophoneRecording(true) {} -}; - -/** - * The IRtcEngineEventHandler class. - * - * The SDK uses this class to send callback event notifications to the app, and the app inherits - * the methods in this class to retrieve these event notifications. - * - * All methods in this class have their default (empty) implementations, and the app can inherit - * only some of the required events instead of all. In the callback methods, the app should avoid - * time-consuming tasks or calling blocking APIs, otherwise the SDK may not work properly. - */ -class IRtcEngineEventHandler { - public: - virtual ~IRtcEngineEventHandler() {} - - virtual const char* eventHandlerType() const { return "event_handler"; } - - /** - * Occurs when a user joins a channel. - * - * This callback notifies the application that a user joins a specified channel. - * - * @param channel The channel name. - * @param uid The ID of the user who joins the channel. - * @param elapsed The time elapsed (ms) from the local user calling joinChannel until the SDK triggers this callback. - */ - virtual void onJoinChannelSuccess(const char* channel, uid_t uid, int elapsed) { - (void)channel; - (void)uid; - (void)elapsed; - } - - /** - * Occurs when a user rejoins the channel. - * - * When a user loses connection with the server because of network problems, the SDK automatically tries to reconnect - * and triggers this callback upon reconnection. - * - * @param channel The channel name. - * @param uid The ID of the user who rejoins the channel. - * @param elapsed Time elapsed (ms) from the local user calling the joinChannel method until this callback is triggered. - */ - virtual void onRejoinChannelSuccess(const char* channel, uid_t uid, int elapsed) { - (void)channel; - (void)uid; - (void)elapsed; - } - - /** Occurs when join success after calling \ref IRtcEngine::setLocalAccessPoint "setLocalAccessPoint" or \ref IRtcEngine::setCloudProxy "setCloudProxy" - @param channel Channel name. - @param uid User ID of the user joining the channel. - @param proxyType type of proxy agora sdk connected, proxyType will be NONE_PROXY_TYPE if not connected to proxy(fallback). - @param localProxyIp local proxy ip. if not join local proxy, it will be "". - @param elapsed Time elapsed (ms) from the user calling the \ref IRtcEngine::joinChannel "joinChannel" method until the SDK triggers this callback. - */ - virtual void onProxyConnected(const char* channel, uid_t uid, PROXY_TYPE proxyType, const char* localProxyIp, int elapsed) { - (void)channel; - (void)uid; - (void)proxyType; - (void)localProxyIp; - (void)elapsed; - } - - /** An error occurs during the SDK runtime. - - @param err The error code: #ERROR_CODE_TYPE. - @param msg The detailed error message. - */ - virtual void onError(int err, const char* msg) { - (void)err; - (void)msg; - } - - /** Reports the statistics of the audio stream from each remote - user/broadcaster. - - @deprecated This callback is deprecated. Use onRemoteAudioStats instead. - - The SDK triggers this callback once every two seconds to report the audio - quality of each remote user/host sending an audio stream. If a channel has - multiple remote users/hosts sending audio streams, the SDK triggers this - callback as many times. - - @param uid The user ID of the remote user sending the audio stream. - @param quality The audio quality of the user: #QUALITY_TYPE - @param delay The network delay (ms) from the sender to the receiver, including the delay caused by audio sampling pre-processing, network transmission, and network jitter buffering. - @param lost The audio packet loss rate (%) from the sender to the receiver. - */ - virtual void onAudioQuality(uid_t uid, int quality, unsigned short delay, unsigned short lost) __deprecated { - (void)uid; - (void)quality; - (void)delay; - (void)lost; - } - - /** Reports the result of the last-mile network probe result. - * - * The SDK triggers this callback within 30 seconds after the app calls the `startLastmileProbeTest` method. - * @param result The uplink and downlink last-mile network probe test result: LastmileProbeResult. - */ - virtual void onLastmileProbeResult(const LastmileProbeResult& result) { - (void)result; - } - - /** - * Reports the volume information of users. - * - * By default, this callback is disabled. You can enable it by calling `enableAudioVolumeIndication`. Once this - * callback is enabled and users send streams in the channel, the SDK triggers the `onAudioVolumeIndication` - * callback at the time interval set in `enableAudioVolumeIndication`. The SDK triggers two independent - * `onAudioVolumeIndication` callbacks simultaneously, which separately report the volume information of the - * local user who sends a stream and the remote users (up to three) whose instantaneous volume is the highest. - * - * @note After you enable this callback, calling muteLocalAudioStream affects the SDK's behavior as follows: - * - If the local user stops publishing the audio stream, the SDK stops triggering the local user's callback. - * - 20 seconds after a remote user whose volume is one of the three highest stops publishing the audio stream, - * the callback excludes this user's information; 20 seconds after all remote users stop publishing audio streams, - * the SDK stops triggering the callback for remote users. - * - * @param speakers The volume information of the users, see AudioVolumeInfo. An empty `speakers` array in the - * callback indicates that no remote user is in the channel or sending a stream at the moment. - * @param speakerNumber The total number of speakers. - * - In the local user's callback, when the local user sends a stream, `speakerNumber` is 1. - * - In the callback for remote users, the value range of speakerNumber is [0,3]. If the number of remote users who - * send streams is greater than or equal to three, the value of `speakerNumber` is 3. - * @param totalVolume The volume of the speaker. The value ranges between 0 (lowest volume) and 255 (highest volume). - * - In the local user's callback, `totalVolume` is the volume of the local user who sends a stream. - * - In the remote users' callback, `totalVolume` is the sum of all remote users (up to three) whose instantaneous - * volume is the highest. If the user calls `startAudioMixing`, `totalVolume` is the volume after audio mixing. - */ - virtual void onAudioVolumeIndication(const AudioVolumeInfo* speakers, unsigned int speakerNumber, - int totalVolume) { - (void)speakers; - (void)speakerNumber; - (void)totalVolume; - } - - /** - * Occurs when a user leaves a channel. - * - * This callback notifies the app that the user leaves the channel by calling `leaveChannel`. From this callback, - * the app can get information such as the call duration and quality statistics. - * - * @param stats The statistics on the call: RtcStats. - */ - virtual void onLeaveChannel(const RtcStats& stats) { (void)stats; } - - /** - * Reports the statistics of the current call. - * - * The SDK triggers this callback once every two seconds after the user joins the channel. - * - * @param stats The statistics of the current call: RtcStats. - */ - virtual void onRtcStats(const RtcStats& stats) { (void)stats; } - - /** Occurs when the audio device state changes. - - This callback notifies the application that the system's audio device state - is changed. For example, a headset is unplugged from the device. - - @param deviceId The device ID. - @param deviceType The device type: #MEDIA_DEVICE_TYPE. - @param deviceState The device state: - - On macOS: - - 0: The device is ready for use. - - 8: The device is not connected. - - On Windows: #MEDIA_DEVICE_STATE_TYPE. - */ - virtual void onAudioDeviceStateChanged(const char* deviceId, int deviceType, int deviceState) { - (void)deviceId; - (void)deviceType; - (void)deviceState; - } - - /** - * @brief Reports current AudioMixing progress. - * - * The callback occurs once every one second during the playback and reports the current playback progress. - * @param position Current AudioMixing progress (millisecond). - */ - virtual void onAudioMixingPositionChanged(int64_t position) {} - - /** Occurs when the audio mixing file playback finishes. - @deprecated This method is deprecated, use onAudioMixingStateChanged instead. - - After you call startAudioMixing to play a local music file, this callback occurs when the playback finishes. - If the startAudioMixing method call fails, the SDK returns the error code 701. - */ - virtual void onAudioMixingFinished() __deprecated {} - - /** - * Occurs when the playback of the local audio effect file finishes. - * - * This callback occurs when the local audio effect file finishes playing. - * - * @param soundId The audio effect ID. The ID of each audio effect file is unique. - */ - virtual void onAudioEffectFinished(int soundId) {} - - /** Occurs when the video device state changes. - - This callback notifies the application that the system's video device state - is changed. - - @param deviceId Pointer to the device ID. - @param deviceType Device type: #MEDIA_DEVICE_TYPE. - @param deviceState Device state: #MEDIA_DEVICE_STATE_TYPE. - */ - virtual void onVideoDeviceStateChanged(const char* deviceId, int deviceType, int deviceState) { - (void)deviceId; - (void)deviceType; - (void)deviceState; - } - - /** - * Reports the last mile network quality of each user in the channel. - * - * This callback reports the last mile network conditions of each user in the channel. Last mile refers to the - * connection between the local device and Agora's edge server. - * - * The SDK triggers this callback once every two seconds. If a channel includes multiple users, the SDK triggers - * this callback as many times. - * - * @note `txQuality` is UNKNOWN when the user is not sending a stream; `rxQuality` is UNKNOWN when the user is not - * receiving a stream. - * - * @param uid The user ID. The network quality of the user with this user ID is reported. - * @param txQuality Uplink network quality rating of the user in terms of the transmission bit rate, packet loss rate, - * average RTT (Round-Trip Time) and jitter of the uplink network. This parameter is a quality rating helping you - * understand how well the current uplink network conditions can support the selected video encoder configuration. - * For example, a 1000 Kbps uplink network may be adequate for video frames with a resolution of 640 × 480 and a frame - * rate of 15 fps in the LIVE_BROADCASTING profile, but may be inadequate for resolutions higher than 1280 × 720. - * See #QUALITY_TYPE. - * @param rxQuality Downlink network quality rating of the user in terms of packet loss rate, average RTT, and jitter - * of the downlink network. See #QUALITY_TYPE. - */ - virtual void onNetworkQuality(uid_t uid, int txQuality, int rxQuality) { - (void)uid; - (void)txQuality; - (void)rxQuality; - } - - /** - * Occurs when intra request from remote user is received. - * - * This callback is triggered once remote user needs one Key frame. - * - */ - virtual void onIntraRequestReceived() {} - - /** - * Occurs when uplink network info is updated. - * - * The SDK triggers this callback when the uplink network information changes. - * - * @note This callback only applies to scenarios where you push externally encoded - * video data in H.264 format to the SDK. - * - * @param info The uplink network information. See UplinkNetworkInfo. - */ - virtual void onUplinkNetworkInfoUpdated(const UplinkNetworkInfo& info) { - (void)info; - } - - /** - * Occurs when downlink network info is updated. - * - * This callback is used for notifying user to switch major/minor stream if needed. - * - * @param info The downlink network info collections. - */ - virtual void onDownlinkNetworkInfoUpdated(const DownlinkNetworkInfo& info) { - (void)info; - } - - /** - * Reports the last-mile network quality of the local user. - * - * This callback reports the last-mile network conditions of the local user before the user joins - * the channel. Last mile refers to the connection between the local device and Agora's edge server. - * - * When the user is not in a channel and the last-mile network test is enabled - * (by calling `startLastmileProbeTest`), this callback function is triggered - * to update the app on the network connection quality of the local user. - * - * @param quality The last mile network quality. See #QUALITY_TYPE. - */ - virtual void onLastmileQuality(int quality) { (void)quality; } - - /** Occurs when the first local video frame is rendered on the local video view. - * - * @param source The video source: #VIDEO_SOURCE_TYPE. - * @param width The width (px) of the first local video frame. - * @param height The height (px) of the first local video frame. - * @param elapsed Time elapsed (ms) from the local user calling the `joinChannel` - * method until the SDK triggers this callback. If you call the `startPreview` method before calling - * the `joinChannel` method, then `elapsed` is the time elapsed from calling the - * `startPreview` method until the SDK triggers this callback. - */ - virtual void onFirstLocalVideoFrame(VIDEO_SOURCE_TYPE source, int width, int height, int elapsed) { - (void)source; - (void)width; - (void)height; - (void)elapsed; - } - - /** Occurs when the first local video frame is published. - * The SDK triggers this callback under one of the following circumstances: - * - The local client enables the video module and calls `joinChannel` successfully. - * - The local client calls `muteLocalVideoStream(true)` and muteLocalVideoStream(false) in sequence. - * - The local client calls `disableVideo` and `enableVideo` in sequence. - * - The local client calls `pushVideoFrame` to successfully push the video frame to the SDK. - * @param source The video source type. - * @param elapsed The time elapsed (ms) from the local user calling joinChannel` to the SDK triggers - * this callback. - */ - virtual void onFirstLocalVideoFramePublished(VIDEO_SOURCE_TYPE source, int elapsed) { - (void)source; - (void)elapsed; - } - - /** Occurs when the first remote video frame is received and decoded. - - The SDK triggers this callback under one of the following circumstances: - - The remote user joins the channel and sends the video stream. - - The remote user stops sending the video stream and re-sends it after 15 seconds. Reasons for such an interruption include: - - The remote user leaves the channel. - - The remote user drops offline. - - The remote user calls `muteLocalVideoStream` to stop sending the video stream. - - The remote user calls `disableVideo` to disable video. - - @param uid The user ID of the remote user sending the video stream. - @param width The width (pixels) of the video stream. - @param height The height (pixels) of the video stream. - @param elapsed The time elapsed (ms) from the local user calling `joinChannel` - until the SDK triggers this callback. - */ - virtual void onFirstRemoteVideoDecoded(uid_t uid, int width, int height, int elapsed) __deprecated { - (void)uid; - (void)width; - (void)height; - (void)elapsed; - } - - /** - * Occurs when the local or remote video size or rotation has changed. - * @param sourceType The video source type: #VIDEO_SOURCE_TYPE. - * @param uid The user ID. 0 indicates the local user. - * @param width The new width (pixels) of the video. - * @param height The new height (pixels) of the video. - * @param rotation The rotation information of the video. - */ - virtual void onVideoSizeChanged(VIDEO_SOURCE_TYPE sourceType, uid_t uid, int width, int height, int rotation) { - (void)uid; - (void)width; - (void)height; - (void)rotation; - } - - /** Occurs when the local video stream state changes. - * - * When the state of the local video stream changes (including the state of the video capture and - * encoding), the SDK triggers this callback to report the current state. This callback indicates - * the state of the local video stream, including camera capturing and video encoding, and allows - * you to troubleshoot issues when exceptions occur. - * - * The SDK triggers the onLocalVideoStateChanged callback with the state code of `LOCAL_VIDEO_STREAM_STATE_FAILED` - * and error code of `LOCAL_VIDEO_STREAM_REASON_CAPTURE_FAILURE` in the following situations: - * - The app switches to the background, and the system gets the camera resource. - * - The camera starts normally, but does not output video for four consecutive seconds. - * - * When the camera outputs the captured video frames, if the video frames are the same for 15 - * consecutive frames, the SDK triggers the `onLocalVideoStateChanged` callback with the state code - * of `LOCAL_VIDEO_STREAM_STATE_CAPTURING` and error code of `LOCAL_VIDEO_STREAM_REASON_CAPTURE_FAILURE`. - * Note that the video frame duplication detection is only available for video frames with a resolution - * greater than 200 × 200, a frame rate greater than or equal to 10 fps, and a bitrate less than 20 Kbps. - * - * @note For some device models, the SDK does not trigger this callback when the state of the local - * video changes while the local video capturing device is in use, so you have to make your own - * timeout judgment. - * - * @param source The video source type: #VIDEO_SOURCE_TYPE. - * @param state The state of the local video. See #LOCAL_VIDEO_STREAM_STATE. - * @param reason The detailed error information. See #LOCAL_VIDEO_STREAM_REASON. - */ - virtual void onLocalVideoStateChanged(VIDEO_SOURCE_TYPE source, LOCAL_VIDEO_STREAM_STATE state, LOCAL_VIDEO_STREAM_REASON reason) { - (void)source; - (void)state; - (void)reason; - } - - /** - * Occurs when the remote video state changes. - * - * @note This callback does not work properly when the number of users (in the voice/video call - * channel) or hosts (in the live streaming channel) in the channel exceeds 17. - * - * @param uid The ID of the user whose video state has changed. - * @param state The remote video state: #REMOTE_VIDEO_STATE. - * @param reason The reason of the remote video state change: #REMOTE_VIDEO_STATE_REASON. - * @param elapsed The time elapsed (ms) from the local client calling `joinChannel` until this callback is triggered. - */ - virtual void onRemoteVideoStateChanged(uid_t uid, REMOTE_VIDEO_STATE state, REMOTE_VIDEO_STATE_REASON reason, int elapsed) { - (void)uid; - (void)state; - (void)reason; - (void)elapsed; - } - - /** Occurs when the renderer receives the first frame of the remote video. - * - * @param uid The user ID of the remote user sending the video stream. - * @param width The width (px) of the video frame. - * @param height The height (px) of the video stream. - * @param elapsed The time elapsed (ms) from the local user calling `joinChannel` until the SDK triggers this callback. - */ - virtual void onFirstRemoteVideoFrame(uid_t uid, int width, int height, int elapsed) { - (void)uid; - (void)width; - (void)height; - (void)elapsed; - } - - /** - * Occurs when a remote user or broadcaster joins the channel. - * - * - In the COMMUNICATION channel profile, this callback indicates that a remote user joins the channel. - * The SDK also triggers this callback to report the existing users in the channel when a user joins the - * channel. - * In the LIVE_BROADCASTING channel profile, this callback indicates that a host joins the channel. The - * SDK also triggers this callback to report the existing hosts in the channel when a host joins the - * channel. Agora recommends limiting the number of hosts to 17. - * - * The SDK triggers this callback under one of the following circumstances: - * - A remote user/host joins the channel by calling the `joinChannel` method. - * - A remote user switches the user role to the host after joining the channel. - * - A remote user/host rejoins the channel after a network interruption. - * - * @param uid The ID of the remote user or broadcaster joining the channel. - * @param elapsed The time elapsed (ms) from the local user calling `joinChannel` or `setClientRole` - * until this callback is triggered. - */ - virtual void onUserJoined(uid_t uid, int elapsed) { - (void)uid; - (void)elapsed; - } - - /** - * Occurs when a remote user or broadcaster goes offline. - * - * There are two reasons for a user to go offline: - * - Leave the channel: When the user leaves the channel, the user sends a goodbye message. When this - * message is received, the SDK determines that the user leaves the channel. - * - Drop offline: When no data packet of the user is received for a certain period of time, the SDK assumes - * that the user drops offline. A poor network connection may lead to false detection, so we recommend using - * the RTM SDK for reliable offline detection. - * - The user switches the user role from a broadcaster to an audience. - * - * @param uid The ID of the remote user or broadcaster who leaves the channel or drops offline. - * @param reason The reason why the remote user goes offline: #USER_OFFLINE_REASON_TYPE. - */ - virtual void onUserOffline(uid_t uid, USER_OFFLINE_REASON_TYPE reason) { - (void)uid; - (void)reason; - } - - /** Occurs when a remote user's audio stream playback pauses/resumes. - - The SDK triggers this callback when the remote user stops or resumes sending the audio stream by - calling the `muteLocalAudioStream` method. - - @note This callback can be inaccurate when the number of users (in the `COMMUNICATION` profile) or hosts (in the `LIVE_BROADCASTING` profile) in the channel exceeds 17. - - @param uid The user ID. - @param muted Whether the remote user's audio stream is muted/unmuted: - - true: Muted. - - false: Unmuted. - */ - virtual void onUserMuteAudio(uid_t uid, bool muted) { - (void)uid; - (void)muted; - } - - /** Occurs when a remote user pauses or resumes sending the video stream. - * - * When a remote user calls `muteLocalVideoStream` to stop or resume publishing the video stream, the - * SDK triggers this callback to report the state of the remote user's publishing stream to the local - * user. - - @note This callback is invalid when the number of users or broadacasters in a - channel exceeds 20. - - @param userId ID of the remote user. - @param muted Whether the remote user stops publishing the video stream: - - true: The remote user has paused sending the video stream. - - false: The remote user has resumed sending the video stream. - */ - virtual void onUserMuteVideo(uid_t uid, bool muted) { - (void)uid; - (void)muted; - } - - /** Occurs when a remote user enables or disables the video module. - - Once the video function is disabled, the users cannot see any video. - - The SDK triggers this callback when a remote user enables or disables the video module by calling the - `enableVideo` or `disableVideo` method. - - @param uid The ID of the remote user. - @param enabled Whether the video of the remote user is enabled: - - true: The remote user has enabled video. - - false: The remote user has disabled video. - */ - virtual void onUserEnableVideo(uid_t uid, bool enabled) { - (void)uid; - (void)enabled; - } - - /** - * Occurs when the remote user audio or video state is updated. - * @param uid The uid of the remote user. - * @param state The remote user's audio or video state: #REMOTE_USER_STATE. - */ - virtual void onUserStateChanged(uid_t uid, REMOTE_USER_STATE state) { - (void)uid; - (void)state; - } - - /** Occurs when a remote user enables or disables local video capturing. - - The SDK triggers this callback when the remote user resumes or stops capturing the video stream by - calling the `enableLocalVideo` method. - - @param uid The ID of the remote user. - @param enabled Whether the specified remote user enables/disables local video: - - `true`: The remote user has enabled local video capturing. - - `false`: The remote user has disabled local video capturing. - */ - virtual void onUserEnableLocalVideo(uid_t uid, bool enabled) __deprecated { - (void)uid; - (void)enabled; - } - - /** Reports the statistics of the audio stream from each remote user/host. - - The SDK triggers this callback once every two seconds for each remote user who is sending audio - streams. If a channel includes multiple remote users, the SDK triggers this callback as many times. - - @param stats Statistics of the received remote audio streams. See RemoteAudioStats. - */ - virtual void onRemoteAudioStats(const RemoteAudioStats& stats) { - (void)stats; - } - - /** Reports the statistics of the local audio stream. - * - * The SDK triggers this callback once every two seconds. - * - * @param stats The statistics of the local audio stream. - * See LocalAudioStats. - */ - virtual void onLocalAudioStats(const LocalAudioStats& stats) { - (void)stats; - } - - /** Reports the statistics of the local video stream. - * - * The SDK triggers this callback once every two seconds for each - * user/host. If there are multiple users/hosts in the channel, the SDK - * triggers this callback as many times. - * - * @note If you have called the `enableDualStreamMode` - * method, this callback reports the statistics of the high-video - * stream (high bitrate, and high-resolution video stream). - * - * @param source The video source type. See #VIDEO_SOURCE_TYPE. - * @param stats Statistics of the local video stream. See LocalVideoStats. - */ - virtual void onLocalVideoStats(VIDEO_SOURCE_TYPE source, const LocalVideoStats& stats) { - (void)source; - (void)stats; - } - - /** Reports the statistics of the video stream from each remote user/host. - * - * The SDK triggers this callback once every two seconds for each remote user. If a channel has - * multiple users/hosts sending video streams, the SDK triggers this callback as many times. - * - * @param stats Statistics of the remote video stream. See - * RemoteVideoStats. - */ - virtual void onRemoteVideoStats(const RemoteVideoStats& stats) { - (void)stats; - } - - /** - * Occurs when the camera turns on and is ready to capture the video. - * @deprecated Use `LOCAL_VIDEO_STREAM_STATE_CAPTURING(1)` in onLocalVideoStateChanged instead. - * This callback indicates that the camera has been successfully turned on and you can start to capture video. - */ - virtual void onCameraReady() __deprecated {} - - /** - * Occurs when the camera focus area changes. - * - * @note This method is for Andriod and iOS only. - * - * @param x The x coordinate of the changed camera focus area. - * @param y The y coordinate of the changed camera focus area. - * @param width The width of the changed camera focus area. - * @param height The height of the changed camera focus area. - */ - virtual void onCameraFocusAreaChanged(int x, int y, int width, int height) { - (void)x; - (void)y; - (void)width; - (void)height; - } - /** - * Occurs when the camera exposure area changes. - * - * @param x The x coordinate of the changed camera exposure area. - * @param y The y coordinate of the changed camera exposure area. - * @param width The width of the changed camera exposure area. - * @param height The height of the changed exposure area. - */ - virtual void onCameraExposureAreaChanged(int x, int y, int width, int height) { - (void)x; - (void)y; - (void)width; - (void)height; - } -#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) || defined(__OHOS__) - /** - * Reports the face detection result of the local user. - * - * Once you enable face detection by calling enableFaceDetection(true), you can get the following - * information on the local user in real-time: - * - The width and height of the local video. - * - The position of the human face in the local view. - * - The distance between the human face and the screen. - * - * This value is based on the fitting calculation of the local video size and the position of the human face. - * - * @note - * - This callback is for Android and iOS only. - * - When it is detected that the face in front of the camera disappears, the callback will be - * triggered immediately. In the state of no face, the trigger frequency of the callback will be - * reduced to save power consumption on the local device. - * - The SDK stops triggering this callback when a human face is in close proximity to the screen. - * On Android, the value of `distance` reported in this callback may be slightly different from the - * actual distance. Therefore, Agora does not recommend using it for accurate calculation. - * - * @param imageWidth The width (px) of the video image captured by the local camera. - * @param imageHeight The height (px) of the video image captured by the local camera. - * @param vecRectangle A Rectangle array of length 'numFaces', which represents the position and size of the human face on the local video: - * - x: The x-coordinate (px) of the human face in the local view. Taking the top left corner of the view as the origin, the x-coordinate represents the horizontal position of the human face relative to the origin. - * - y: The y-coordinate (px) of the human face in the local view. Taking the top left corner of the view as the origin, the y-coordinate represents the vertical position of the human face relative to the origin. - * - width: The width (px) of the human face in the captured view. - * - height: The height (px) of the human face in the captured view. - * @param vecDistance An int array of length 'numFaces', which represents distance (cm) between the human face and the screen. - * @param numFaces The number of faces detected. If the value is 0, it means that no human face is detected. - */ - virtual void onFacePositionChanged(int imageWidth, int imageHeight, - const Rectangle* vecRectangle, const int* vecDistance, - int numFaces) { - (void) imageWidth; - (void) imageHeight; - (void) vecRectangle; - (void) vecDistance; - (void) numFaces; - } -#endif - /** - * Occurs when the video stops playing. - * @deprecated Use `LOCAL_VIDEO_STREAM_STATE_STOPPED(0)` in the onLocalVideoStateChanged callback instead. - * - * The app can use this callback to change the configuration of the view (for example, displaying - * other pictures in the view) after the video stops playing. - */ - virtual void onVideoStopped() __deprecated {} - - /** Occurs when the playback state of the music file changes. - * - * This callback occurs when the playback state of the music file changes, and reports the current state and error code. - - @param state The playback state of the music file. See #AUDIO_MIXING_STATE_TYPE. - @param reason The reason for the change of the music file playback state. See #AUDIO_MIXING_REASON_TYPE. - */ - virtual void onAudioMixingStateChanged(AUDIO_MIXING_STATE_TYPE state, AUDIO_MIXING_REASON_TYPE reason) { - (void)state; - (void)reason; - } - - /** Occurs when the state of the rhythm player changes. - When you call the \ref IRtcEngine::startRhythmPlayer "startRhythmPlayer" - method and the state of rhythm player changes, the SDK triggers this - callback. - - @param state The state code. See #RHYTHM_PLAYER_STATE_TYPE. - @param reason The error code. See #RHYTHM_PLAYER_REASON. - */ - virtual void onRhythmPlayerStateChanged(RHYTHM_PLAYER_STATE_TYPE state, RHYTHM_PLAYER_REASON reason) { - (void)state; - (void)reason; - } - - /** - * Occurs when the SDK cannot reconnect to the server 10 seconds after its connection to the server is - * interrupted. - * - * The SDK triggers this callback when it cannot connect to the server 10 seconds after calling - * `joinChannel`, regardless of whether it is in the channel or not. If the SDK fails to rejoin - * the channel 20 minutes after being disconnected from Agora's edge server, the SDK stops rejoining the channel. - */ - virtual void onConnectionLost() {} - - /** Occurs when the connection between the SDK and the server is interrupted. - * @deprecated Use `onConnectionStateChanged` instead. - - The SDK triggers this callback when it loses connection with the serer for more - than 4 seconds after the connection is established. After triggering this - callback, the SDK tries to reconnect to the server. If the reconnection fails - within a certain period (10 seconds by default), the onConnectionLost() - callback is triggered. If the SDK fails to rejoin the channel 20 minutes after - being disconnected from Agora's edge server, the SDK stops rejoining the channel. - - */ - virtual void onConnectionInterrupted() __deprecated {} - - /** Occurs when your connection is banned by the Agora Server. - * @deprecated Use `onConnectionStateChanged` instead. - */ - virtual void onConnectionBanned() __deprecated {} - - /** Occurs when the local user receives the data stream from the remote user. - * - * The SDK triggers this callback when the user receives the data stream that another user sends - * by calling the \ref agora::rtc::IRtcEngine::sendStreamMessage "sendStreamMessage" method. - * - * @param uid ID of the user who sends the data stream. - * @param streamId The ID of the stream data. - * @param data The data stream. - * @param length The length (byte) of the data stream. - * @param sentTs The time when the data stream sent. - */ - virtual void onStreamMessage(uid_t uid, int streamId, const char* data, size_t length, uint64_t sentTs) { - (void)uid; - (void)streamId; - (void)data; - (void)length; - (void)sentTs; - } - - /** Occurs when the local user does not receive the data stream from the remote user. - * - * The SDK triggers this callback when the user fails to receive the data stream that another user sends - * by calling the \ref agora::rtc::IRtcEngine::sendStreamMessage "sendStreamMessage" method. - * - * @param uid ID of the user who sends the data stream. - * @param streamId The ID of the stream data. - * @param code The error code. - * @param missed The number of lost messages. - * @param cached The number of incoming cached messages when the data stream is - * interrupted. - */ - virtual void onStreamMessageError(uid_t uid, int streamId, int code, int missed, int cached) { - (void)uid; - (void)streamId; - (void)code; - (void)missed; - (void)cached; - } - - /** - * Occurs when the token expires. - * - * When the token expires during a call, the SDK triggers this callback to remind the app to renew the token. - * - * Upon receiving this callback, generate a new token at your app server and call - * `joinChannel` to pass the new token to the SDK. - * - */ - virtual void onRequestToken() {} - - /** - * Occurs when the token will expire in 30 seconds. - * - * When the token is about to expire in 30 seconds, the SDK triggers this callback to remind the app to renew the token. - - * Upon receiving this callback, generate a new token at your app server and call - * \ref IRtcEngine::renewToken "renewToken" to pass the new Token to the SDK. - * - * - * @param token The token that will expire in 30 seconds. - */ - virtual void onTokenPrivilegeWillExpire(const char* token) { - (void)token; - } - - /** - * Occurs when connection license verification fails. - * - * You can know the reason accordding to error code - */ - virtual void onLicenseValidationFailure(LICENSE_ERROR_TYPE error) { - (void)error; - } - - /** Occurs when the first local audio frame is published. - * - * The SDK triggers this callback under one of the following circumstances: - * - The local client enables the audio module and calls `joinChannel` successfully. - * - The local client calls `muteLocalAudioStream(true)` and `muteLocalAudioStream(false)` in sequence. - * - The local client calls `disableAudio` and `enableAudio` in sequence. - * - The local client calls `pushAudioFrame` to successfully push the audio frame to the SDK. - * - * @param elapsed The time elapsed (ms) from the local user calling `joinChannel` to the SDK triggers this callback. - */ - virtual void onFirstLocalAudioFramePublished(int elapsed) { - (void)elapsed; - } - - /** - * Occurs when the SDK decodes the first remote audio frame for playback. - * - * @deprecated Use `onRemoteAudioStateChanged` instead. - * The SDK triggers this callback under one of the following circumstances: - * - The remote user joins the channel and sends the audio stream for the first time. - * - The remote user's audio is offline and then goes online to re-send audio. It means the local user cannot - * receive audio in 15 seconds. Reasons for such an interruption include: - * - The remote user leaves channel. - * - The remote user drops offline. - * - The remote user calls muteLocalAudioStream to stop sending the audio stream. - * - The remote user calls disableAudio to disable audio. - * @param uid User ID of the remote user sending the audio stream. - * @param elapsed The time elapsed (ms) from the loca user calling `joinChannel` - * until this callback is triggered. - */ - virtual void onFirstRemoteAudioDecoded(uid_t uid, int elapsed) __deprecated { - (void)uid; - (void)elapsed; - } - - /** Occurs when the SDK receives the first audio frame from a specific remote user. - * @deprecated Use `onRemoteAudioStateChanged` instead. - * - * @param uid ID of the remote user. - * @param elapsed The time elapsed (ms) from the loca user calling `joinChannel` - * until this callback is triggered. - */ - virtual void onFirstRemoteAudioFrame(uid_t uid, int elapsed) __deprecated { - (void)uid; - (void)elapsed; - } - - /** Occurs when the local audio state changes. - * - * When the state of the local audio stream changes (including the state of the audio capture and encoding), the SDK - * triggers this callback to report the current state. This callback indicates the state of the local audio stream, - * and allows you to troubleshoot issues when audio exceptions occur. - * - * @note - * When the state is `LOCAL_AUDIO_STREAM_STATE_FAILED(3)`, see the `error` - * parameter for details. - * - * @param state State of the local audio. See #LOCAL_AUDIO_STREAM_STATE. - * @param reason The reason information of the local audio. - * See #LOCAL_AUDIO_STREAM_REASON. - */ - virtual void onLocalAudioStateChanged(LOCAL_AUDIO_STREAM_STATE state, LOCAL_AUDIO_STREAM_REASON reason) { - (void)state; - (void)reason; - } - - /** Occurs when the remote audio state changes. - * - * When the audio state of a remote user (in the voice/video call channel) or host (in the live streaming channel) - * changes, the SDK triggers this callback to report the current state of the remote audio stream. - * - * @note This callback does not work properly when the number of users (in the voice/video call channel) or hosts - * (in the live streaming channel) in the channel exceeds 17. - * - * @param uid ID of the remote user whose audio state changes. - * @param state State of the remote audio. See #REMOTE_AUDIO_STATE. - * @param reason The reason of the remote audio state change. - * See #REMOTE_AUDIO_STATE_REASON. - * @param elapsed Time elapsed (ms) from the local user calling the - * `joinChannel` method until the SDK - * triggers this callback. - */ - virtual void onRemoteAudioStateChanged(uid_t uid, REMOTE_AUDIO_STATE state, REMOTE_AUDIO_STATE_REASON reason, int elapsed) { - (void)uid; - (void)state; - (void)reason; - (void)elapsed; - } - - /** - * Occurs when an active speaker is detected. - * - * After a successful call of `enableAudioVolumeIndication`, the SDK continuously detects which remote user has the - * loudest volume. During the current period, the remote user, who is detected as the loudest for the most times, - * is the most active user. - * - * When the number of users is no less than two and an active remote speaker exists, the SDK triggers this callback and reports the uid of the most active remote speaker. - * - If the most active remote speaker is always the same user, the SDK triggers the `onActiveSpeaker` callback only once. - * - If the most active remote speaker changes to another user, the SDK triggers this callback again and reports the uid of the new active remote speaker. - * - * @param userId The ID of the active speaker. A `uid` of 0 means the local user. - */ - virtual void onActiveSpeaker(uid_t uid) { - (void)uid; - } - - /** Reports result of content inspection. - * - * @param result The result of content inspection: #CONTENT_INSPECT_RESULT. - */ - virtual void onContentInspectResult(media::CONTENT_INSPECT_RESULT result) { (void)result; } - - /** Reports the result of taking a video snapshot. - * - * After a successful `takeSnapshot` method call, the SDK triggers this callback to report whether the snapshot is - * successfully taken, as well as the details for that snapshot. - * - * @param uid The user ID. A `uid` of 0 indicates the local user. - * @param filePath The local path of the snapshot. - * @param width The width (px) of the snapshot. - * @param height The height (px) of the snapshot. - * @param errCode The message that confirms success or gives the reason why the snapshot is not successfully taken: - * - 0: Success. - * - < 0: Failure. - * - -1: The SDK fails to write data to a file or encode a JPEG image. - * - -2: The SDK does not find the video stream of the specified user within one second after the `takeSnapshot` method call succeeds. - * - -3: Calling the `takeSnapshot` method too frequently. Call the `takeSnapshot` method after receiving the `onSnapshotTaken` - * callback from the previous call. - */ - virtual void onSnapshotTaken(uid_t uid, const char* filePath, int width, int height, int errCode) { - (void)uid; - (void)filePath; - (void)width; - (void)height; - (void)errCode; - } - - /** - * Occurs when the user role switches in the interactive live streaming. - * - * @param oldRole The old role of the user: #CLIENT_ROLE_TYPE. - * @param newRole The new role of the user: #CLIENT_ROLE_TYPE. - * @param newRoleOptions The client role options of the new role: #ClientRoleOptions. - */ - virtual void onClientRoleChanged(CLIENT_ROLE_TYPE oldRole, CLIENT_ROLE_TYPE newRole, const ClientRoleOptions& newRoleOptions) { - (void)oldRole; - (void)newRole; - (void)newRoleOptions; - } - - /** - * Occurs when the user role in a Live-Broadcast channel fails to switch, for example, from a broadcaster - * to an audience or vice versa. - * - * @param reason The reason for failing to change the client role: #CLIENT_ROLE_CHANGE_FAILED_REASON. - * @param currentRole The current role of the user: #CLIENT_ROLE_TYPE. - */ - virtual void onClientRoleChangeFailed(CLIENT_ROLE_CHANGE_FAILED_REASON reason, CLIENT_ROLE_TYPE currentRole) { - (void)reason; - (void)currentRole; - } - - /** Occurs when the audio device volume changes. - @param deviceType The device type, see #MEDIA_DEVICE_TYPE - @param volume The volume of the audio device. - @param muted Whether the audio device is muted: - - true: The audio device is muted. - - false: The audio device is not muted. - */ - virtual void onAudioDeviceVolumeChanged(MEDIA_DEVICE_TYPE deviceType, int volume, bool muted) { - (void)deviceType; - (void)volume; - (void)muted; - } - - /** - * Occurs when the state of the RTMP streaming changes. - * - * When the media push state changes, the SDK triggers this callback and reports the URL address and the current state - * of the media push. This callback indicates the state of the media push. When exceptions occur, you can troubleshoot - * issues by referring to the detailed error descriptions in the error code. - * - * @param url The URL address where the state of the media push changes. - * @param state The current state of the media push: #RTMP_STREAM_PUBLISH_STATE. - * @param reason The detailed error information for the media push: #RTMP_STREAM_PUBLISH_REASON. - */ - virtual void onRtmpStreamingStateChanged(const char* url, RTMP_STREAM_PUBLISH_STATE state, - RTMP_STREAM_PUBLISH_REASON reason) { - (void)url; - (void)state; - (void)reason; - } - - /** Reports events during the media push. - * - * @param url The URL for media push. - * @param eventCode The event code of media push. See RTMP_STREAMING_EVENT for details. - */ - virtual void onRtmpStreamingEvent(const char* url, RTMP_STREAMING_EVENT eventCode) { - (void)url; - (void)eventCode; - } - - /** - * Occurs when the publisher's transcoding settings are updated. - * - * When the `LiveTranscoding` class in \ref IRtcEngine::setLiveTranscoding "setLiveTranscoding" - * updates, the SDK triggers this callback to report the update information. - * - * @note - * If you call the `setLiveTranscoding` method to set the `LiveTranscoding` class for the first time, the SDK - * does not trigger this callback. - */ - virtual void onTranscodingUpdated() {} - - /** Occurs when the local audio route changes (for Android, iOS, and macOS only). - - The SDK triggers this callback when the local audio route switches to an - earpiece, speakerphone, headset, or Bluetooth device. - @param routing The current audio output routing: - - -1: Default. - - 0: Headset. - - 1: Earpiece. - - 2: Headset with no microphone. - - 3: Speakerphone. - - 4: Loudspeaker. - - 5: Bluetooth headset. - */ - virtual void onAudioRoutingChanged(int routing) { (void)routing; } - - /** - * Occurs when the state of the media stream relay changes. - * - * The SDK reports the state of the current media relay and possible error messages in this - * callback. - * - * @param state The state code: - * - `RELAY_STATE_IDLE(0)`: The SDK is initializing. - * - `RELAY_STATE_CONNECTING(1)`: The SDK tries to relay the media stream to the destination - * channel. - * - `RELAY_STATE_RUNNING(2)`: The SDK successfully relays the media stream to the destination - * channel. - * - `RELAY_STATE_FAILURE(3)`: A failure occurs. See the details in `code`. - * @param code The error code: - * - `RELAY_OK(0)`: The state is normal. - * - `RELAY_ERROR_SERVER_ERROR_RESPONSE(1)`: An error occurs in the server response. - * - `RELAY_ERROR_SERVER_NO_RESPONSE(2)`: No server response. You can call the leaveChannel method - * to leave the channel. - * - `RELAY_ERROR_NO_RESOURCE_AVAILABLE(3)`: The SDK fails to access the service, probably due to - * limited resources of the server. - * - `RELAY_ERROR_FAILED_JOIN_SRC(4)`: Fails to send the relay request. - * - `RELAY_ERROR_FAILED_JOIN_DEST(5)`: Fails to accept the relay request. - * - `RELAY_ERROR_FAILED_PACKET_RECEIVED_FROM_SRC(6)`: The server fails to receive the media - * stream. - * - `RELAY_ERROR_FAILED_PACKET_SENT_TO_DEST(7)`: The server fails to send the media stream. - * - `RELAY_ERROR_SERVER_CONNECTION_LOST(8)`: The SDK disconnects from the server due to poor - * network connections. You can call the leaveChannel method to leave the channel. - * - `RELAY_ERROR_INTERNAL_ERROR(9)`: An internal error occurs in the server. - * - `RELAY_ERROR_SRC_TOKEN_EXPIRED(10)`: The token of the source channel has expired. - * - `RELAY_ERROR_DEST_TOKEN_EXPIRED(11)`: The token of the destination channel has expired. - */ - virtual void onChannelMediaRelayStateChanged(int state, int code) { - (void)state; - (void)code; - } - - /** - * Occurs when the published media stream falls back to an audio-only stream due to poor network conditions or - * switches back to video stream after the network conditions improve. - * - * If you call `setLocalPublishFallbackOption` and set `option` as `STREAM_FALLBACK_OPTION_AUDIO_ONLY(2)`, this - * callback is triggered when the locally published stream falls back to audio-only mode due to poor uplink - * conditions, or when the audio stream switches back to the video after the uplink network condition improves. - * Once the published stream falls back to audio only, the remote app receives the `onRemoteVideoStateChanged` callback. - * - * @param isFallbackOrRecover Whether the published stream fell back to audio-only or switched back to the video: - * - `true`: The published stream fell back to audio-only due to poor network conditions. - * - `false`: The published stream switched back to the video after the network conditions improved. - */ - virtual void onLocalPublishFallbackToAudioOnly(bool isFallbackOrRecover) { - (void)isFallbackOrRecover; - } - - /** - * Occurs when the remote media stream falls back to audio-only stream due to poor network conditions or - * switches back to video stream after the network conditions improve. - * - * If you call `setRemoteSubscribeFallbackOption` and set `option` as `STREAM_FALLBACK_OPTION_AUDIO_ONLY(2)`, this - * callback is triggered when the remotely subscribed media stream falls back to audio-only mode due to poor downlink - * conditions, or when the remotely subscribed media stream switches back to the video after the downlink network - * condition improves. - * - * @note Once the remote media stream is switched to the low stream due to poor network conditions, you can monitor - * the stream switch between a high and low stream in the `onRemoteVideoStats` callback. - * - * @param uid ID of the remote user sending the stream. - * @param isFallbackOrRecover Whether the remote media stream fell back to audio-only or switched back to the video: - * - `true`: The remote media stream fell back to audio-only due to poor network conditions. - * - `false`: The remote media stream switched back to the video stream after the network conditions improved. - */ - virtual void onRemoteSubscribeFallbackToAudioOnly(uid_t uid, bool isFallbackOrRecover) { - (void)uid; - (void)isFallbackOrRecover; - } - - /** Reports the transport-layer statistics of each remote audio stream. - * @deprecated Use `onRemoteAudioStats` instead. - - This callback reports the transport-layer statistics, such as the packet loss rate and network time delay, once every - two seconds after the local user receives an audio packet from a remote user. During a call, when the user receives - the audio packet sent by the remote user/host, the callback is triggered every 2 seconds. - - @param uid ID of the remote user whose audio data packet is received. - @param delay The network time delay (ms) from the sender to the receiver. - @param lost The Packet loss rate (%) of the audio packet sent from the remote - user. - @param rxKBitRate Received bitrate (Kbps) of the audio packet sent from the - remote user. - */ - virtual void onRemoteAudioTransportStats(uid_t uid, unsigned short delay, unsigned short lost, unsigned short rxKBitRate) __deprecated { - (void)uid; - (void)delay; - (void)lost; - (void)rxKBitRate; - } - - /** Reports the transport-layer statistics of each remote video stream. - * @deprecated Use `onRemoteVideoStats` instead. - - This callback reports the transport-layer statistics, such as the packet loss rate and network time - delay, once every two seconds after the local user receives a video packet from a remote user. - - During a call, when the user receives the video packet sent by the remote user/host, the callback is - triggered every 2 seconds. - - @param uid ID of the remote user whose video packet is received. - @param delay The network time delay (ms) from the remote user sending the - video packet to the local user. - @param lost The packet loss rate (%) of the video packet sent from the remote - user. - @param rxKBitRate The bitrate (Kbps) of the video packet sent from - the remote user. - */ - virtual void onRemoteVideoTransportStats(uid_t uid, unsigned short delay, unsigned short lost, unsigned short rxKBitRate) __deprecated { - (void)uid; - (void)delay; - (void)lost; - (void)rxKBitRate; - } - - /** Occurs when the network connection state changes. - * - * When the network connection state changes, the SDK triggers this callback and reports the current - * connection state and the reason for the change. - - @param state The current connection state. See #CONNECTION_STATE_TYPE. - @param reason The reason for a connection state change. See #CONNECTION_CHANGED_REASON_TYPE. - */ - virtual void onConnectionStateChanged( - CONNECTION_STATE_TYPE state, CONNECTION_CHANGED_REASON_TYPE reason) { - (void)state; - (void)reason; - } - - /** Occurs when the WIFI message need be sent to the user. - * - * @param reason The reason of notifying the user of a message. - * @param action Suggest an action for the user. - * @param wlAccMsg The message content of notifying the user. - */ - virtual void onWlAccMessage(WLACC_MESSAGE_REASON reason, WLACC_SUGGEST_ACTION action, const char* wlAccMsg) { - (void)reason; - (void)action; - (void)wlAccMsg; - } - - /** Occurs when SDK statistics wifi acceleration optimization effect. - * - * @param currentStats Instantaneous value of optimization effect. - * @param averageStats Average value of cumulative optimization effect. - */ - virtual void onWlAccStats(const WlAccStats& currentStats, const WlAccStats& averageStats) { - (void)currentStats; - (void)averageStats; - } - - /** Occurs when the local network type changes. - * - * This callback occurs when the connection state of the local user changes. You can get the - * connection state and reason for the state change in this callback. When the network connection - * is interrupted, this callback indicates whether the interruption is caused by a network type - * change or poor network conditions. - - @param type The type of the local network connection. See #NETWORK_TYPE. - */ - virtual void onNetworkTypeChanged(NETWORK_TYPE type) { - (void)type; - } - - /** Reports the built-in encryption errors. - * - * When encryption is enabled by calling `enableEncryption`, the SDK triggers this callback if an - * error occurs in encryption or decryption on the sender or the receiver side. - - @param errorType The error type. See #ENCRYPTION_ERROR_TYPE. - */ - virtual void onEncryptionError(ENCRYPTION_ERROR_TYPE errorType) { - (void)errorType; - } - - /** Occurs when the SDK cannot get the device permission. - * - * When the SDK fails to get the device permission, the SDK triggers this callback to report which - * device permission cannot be got. - * - * @note This method is for Android and iOS only. - - @param permissionType The type of the device permission. See #PERMISSION_TYPE. - */ - virtual void onPermissionError(PERMISSION_TYPE permissionType) { - (void)permissionType; - } - - /** Occurs when the local user registers a user account. - * - * After the local user successfully calls `registerLocalUserAccount` to register the user account - * or calls `joinChannelWithUserAccount` to join a channel, the SDK triggers the callback and - * informs the local user's UID and User Account. - - @param uid The ID of the local user. - @param userAccount The user account of the local user. - */ - virtual void onLocalUserRegistered(uid_t uid, const char* userAccount) { - (void)uid; - (void)userAccount; - } - - /** Occurs when the SDK gets the user ID and user account of the remote user. - - After a remote user joins the channel, the SDK gets the UID and user account of the remote user, - caches them in a mapping table object (`userInfo`), and triggers this callback on the local client. - - @param uid The ID of the remote user. - @param info The `UserInfo` object that contains the user ID and user account of the remote user. - */ - virtual void onUserInfoUpdated(uid_t uid, const UserInfo& info) { - (void)uid; - (void)info; - } - - /** - * Occurs when the user account is updated. - * - * @param uid The user ID. - * @param userAccount The user account. - */ - virtual void onUserAccountUpdated(uid_t uid, const char* userAccount){ - (void)uid; - (void)userAccount; - } - - /** - * Reports the tracing result of video rendering event of the user. - * - * @param uid The user ID. - * @param currentEvent The current event of the tracing result: #MEDIA_TRACE_EVENT. - * @param tracingInfo The tracing result: #VideoRenderingTracingInfo. - */ - virtual void onVideoRenderingTracingResult(uid_t uid, MEDIA_TRACE_EVENT currentEvent, VideoRenderingTracingInfo tracingInfo) { - (void)uid; - (void)currentEvent; - (void)tracingInfo; - } - - /** - * Occurs when local video transcoder stream has an error. - * - * @param stream Stream type of TranscodingVideoStream. - * @param error Error code of VIDEO_TRANSCODER_ERROR. - */ - virtual void onLocalVideoTranscoderError(const TranscodingVideoStream& stream, VIDEO_TRANSCODER_ERROR error){ - (void)stream; - (void)error; - } - - /** - * Reports the user log upload result - * @param requestId RequestId of the upload - * @param success Is upload success - * @param reason Reason of the upload, 0: OK, 1 Network Error, 2 Server Error. - */ - virtual void onUploadLogResult(const char* requestId, bool success, UPLOAD_ERROR_REASON reason) { - (void)requestId; - (void)success; - (void)reason; - } - - /** - * Occurs when the audio subscribing state changes. - * - * @param channel The name of the channel. - * @param uid The ID of the remote user. - * @param oldState The previous subscribing status: #STREAM_SUBSCRIBE_STATE. - * @param newState The current subscribing status: #STREAM_SUBSCRIBE_STATE. - * @param elapseSinceLastState The time elapsed (ms) from the previous state to the current state. - */ - virtual void onAudioSubscribeStateChanged(const char* channel, uid_t uid, STREAM_SUBSCRIBE_STATE oldState, STREAM_SUBSCRIBE_STATE newState, int elapseSinceLastState) { - (void)channel; - (void)uid; - (void)oldState; - (void)newState; - (void)elapseSinceLastState; - } - - /** - * Occurs when the video subscribing state changes. - * - * @param channel The name of the channel. - * @param uid The ID of the remote user. - * @param oldState The previous subscribing status: #STREAM_SUBSCRIBE_STATE. - * @param newState The current subscribing status: #STREAM_SUBSCRIBE_STATE. - * @param elapseSinceLastState The time elapsed (ms) from the previous state to the current state. - */ - virtual void onVideoSubscribeStateChanged(const char* channel, uid_t uid, STREAM_SUBSCRIBE_STATE oldState, STREAM_SUBSCRIBE_STATE newState, int elapseSinceLastState) { - (void)channel; - (void)uid; - (void)oldState; - (void)newState; - (void)elapseSinceLastState; - } - - /** - * Occurs when the audio publishing state changes. - * - * @param channel The name of the channel. - * @param oldState The previous publishing state: #STREAM_PUBLISH_STATE. - * @param newState The current publishing state: #STREAM_PUBLISH_STATE. - * @param elapseSinceLastState The time elapsed (ms) from the previous state to the current state. - */ - virtual void onAudioPublishStateChanged(const char* channel, STREAM_PUBLISH_STATE oldState, STREAM_PUBLISH_STATE newState, int elapseSinceLastState) { - (void)channel; - (void)oldState; - (void)newState; - (void)elapseSinceLastState; - } - - /** - * Occurs when the video publishing state changes. - * - * @param source The video source type. - * @param channel The name of the channel. - * @param oldState The previous publishing state: #STREAM_PUBLISH_STATE. - * @param newState The current publishing state: #STREAM_PUBLISH_STATE. - * @param elapseSinceLastState The time elapsed (ms) from the previous state to the current state. - */ - virtual void onVideoPublishStateChanged(VIDEO_SOURCE_TYPE source, const char* channel, STREAM_PUBLISH_STATE oldState, STREAM_PUBLISH_STATE newState, int elapseSinceLastState) { - (void)source; - (void)channel; - (void)oldState; - (void)newState; - (void)elapseSinceLastState; - } - - /** - * Occurs when receive a video transcoder stream which has video layout info. - * - * @param uid user id of the transcoded stream. - * @param width width of the transcoded stream. - * @param height height of the transcoded stream. - * @param layoutCount count of layout info in the transcoded stream. - * @param layoutlist video layout info list of the transcoded stream. - */ - virtual void onTranscodedStreamLayoutInfo(uid_t uid, int width, int height, int layoutCount,const VideoLayout* layoutlist) { - (void)uid; - (void)width; - (void)height; - (void)layoutCount; - (void)layoutlist; - } - - /** - * Occurs when the SDK receives audio metadata. - * @since v4.3.1 - * @param uid ID of the remote user. - * @param metadata The pointer of metadata - * @param length Size of metadata - * @technical preview - */ - virtual void onAudioMetadataReceived(uid_t uid, const char* metadata, size_t length) { - (void)uid; - (void)metadata; - (void)length; - } - - /** - * The event callback of the extension. - * - * To listen for events while the extension is running, you need to register this callback. - * - * @param context The context of the extension. - * @param key The key of the extension. - * @param value The value of the extension key. - */ - virtual void onExtensionEventWithContext(const ExtensionContext &context, const char* key, const char* value) { - (void)context; - (void)key; - (void)value; - } - - /** - * Occurs when the extension is enabled. - * - * After a successful creation of filter , the extension triggers this callback. - * - * @param context The context of the extension. - */ - virtual void onExtensionStartedWithContext(const ExtensionContext &context) { - (void)context; - } - - /** - * Occurs when the extension is disabled. - * - * After a successful destroy filter, the extension triggers this callback. - * - * @param context The context of the extension. - */ - virtual void onExtensionStoppedWithContext(const ExtensionContext &context) { - (void)context; - } - - /** - * Occurs when the extension runs incorrectly. - * - * When the extension runs in error, the extension triggers - * this callback and reports the error code and reason. - * - * @param context The context of the extension. - * @param error The error code. For details, see the extension documentation provided by the extension provider. - * @param message The error message. For details, see the extension documentation provided by the extension provider. - */ - virtual void onExtensionErrorWithContext(const ExtensionContext &context, int error, const char* message) { - (void)context; - (void)error; - (void)message; - } - - /** - * Occurs when the SDK receives RTM setting change response. - * - * @technical preview - * @param code The error code. - */ - virtual void onSetRtmFlagResult(int code) { - (void)code; - } -}; - -/** - * The IVideoDeviceCollection class. You can get information related to video devices through this interface. - */ -class IVideoDeviceCollection { - public: - virtual ~IVideoDeviceCollection() {} - - /** - * Gets the total number of the indexed video capture devices in the system. - * - * @return The total number of the indexed video capture devices. - */ - virtual int getCount() = 0; - - /** - * Specifies a device with the device ID. - * - * @param deviceIdUTF8 The device ID. The maximum length is #MAX_DEVICE_ID_LENGTH_TYPE. Plugging or - * unplugging the audio device does not change the value of deviceId. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setDevice(const char deviceIdUTF8[MAX_DEVICE_ID_LENGTH]) = 0; - - /** - * Gets a specified piece of information about an indexed video device. - * - * @param index The index value of the video device. The value of this parameter must be less than the value returned in `getCount`. - * @param deviceNameUTF8 The name of the device. The maximum length is #MAX_DEVICE_ID_LENGTH. - * @param deviceIdUTF8 The device ID of the video device. The maximum length is #MAX_DEVICE_ID_LENGTH. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getDevice(int index, char deviceNameUTF8[MAX_DEVICE_ID_LENGTH], - char deviceIdUTF8[MAX_DEVICE_ID_LENGTH]) = 0; - - /** - * Releases all the resources occupied by the IVideoDeviceCollection object. - */ - virtual void release() = 0; -}; - -/** - * The IVideoDeviceManager class. - */ -class IVideoDeviceManager { - public: - virtual ~IVideoDeviceManager() {} - /** - * Enumerates the video devices. - * - * This method returns an `IVideoDeviceCollection` object including all video devices in the system. - * With the `IVideoDeviceCollection` object, the application can enumerate video devices. The - * application must call the release method to release the returned object after using it. - * - * @return - * - Success: An `IVideoDeviceCollection` object including all video devices in the system. - * - Failure: NULL. - */ - virtual IVideoDeviceCollection* enumerateVideoDevices() = 0; - - /** - * Specifies the video capture device with the device ID. - * - * @param deviceIdUTF8 he device ID. You can get the device ID by calling `enumerateVideoDevices`. - * The maximum length is #MAX_DEVICE_ID_LENGTH. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setDevice(const char deviceIdUTF8[MAX_DEVICE_ID_LENGTH]) = 0; - - /** - * Retrieves the current video capture device. - * @param deviceIdUTF8 Output parameter. The device ID. The maximum length is #MAX_DEVICE_ID_LENGTH_TYPE. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getDevice(char deviceIdUTF8[MAX_DEVICE_ID_LENGTH]) = 0; - -#if defined(_WIN32) || (defined(__linux__) && !defined(__ANDROID__) && !defined(__OHOS__)) || \ - (defined(__APPLE__) && TARGET_OS_MAC && !TARGET_OS_IPHONE) - /** - * Gets the number of video formats supported by the specified video capture device. - * - * Video capture devices may support multiple video formats, and each format supports different - * combinations of video frame width, video frame height, and frame rate. - * - * You can call this method to get how many video formats the specified video capture device can - * support, and then call `getCapability` to get the specific video frame information in the - * specified video format. - * - * @param deviceIdUTF8 The ID of the video capture device. - * - * @return - * - 0: Success. Returns the number of video formats supported by this device. For example: If the - * specified camera supports 10 different video formats, the return value is 10. - * - < 0: Failure. - */ - virtual int numberOfCapabilities(const char* deviceIdUTF8) = 0; - - /** - * Gets the detailed video frame information of the video capture device in the specified video format. - * - * After calling `numberOfCapabilities` to get the number of video formats supported by the video capture - * device, you can call this method to get the specific video frame information supported by the - * specified index number. - * - * @param deviceIdUTF8 ID of the video capture device. - * @param deviceCapabilityNumber The index number of the video format. If the return value of `numberOfCapabilities` - * is i, the value range of this parameter is [0,i). - * @param capability Output parameter. Indicates the specific information of the specified video format, - * including width (px), height (px), and frame rate (fps). See VideoFormat. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getCapability(const char* deviceIdUTF8, const uint32_t deviceCapabilityNumber, VideoFormat& capability) = 0; -#endif - /** - * Starts the video capture device test. - * - * This method tests whether the video capture device works properly. - * Before calling this method, ensure that you have already called - * \ref IRtcEngine::enableVideo "enableVideo", and the HWND window handle of - * the incoming parameter is valid. - * - * @param hwnd An Output parameter that specifies the window handle to display the video. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int startDeviceTest(view_t hwnd) = 0; - - /** - * Stops the video capture device test. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int stopDeviceTest() = 0; - - /** - * Releases all the resources occupied by the `IVideoDeviceManager` object. - */ - virtual void release() = 0; -}; - -/** - * The context of IRtcEngine. - */ -struct RtcEngineContext { - /** - * The event handler for IRtcEngine. - */ - IRtcEngineEventHandler* eventHandler; - /** - * The App ID issued by Agora for your project. Only users in apps with the same App ID can join the - * same channel and communicate with each other. An App ID can only be used to create one `IRtcEngine` - * instance. To change your App ID, call release to destroy the current IRtcEngine instance, and then - * create a new one. - */ - const char* appId; - /** - * - For Android, it is the context of Activity or Application. - * - For Windows, it is the window handle of app. Once set, this parameter enables you to plug - * or unplug the video devices while they are powered. - */ - void* context; - /** - * The channel profile. See #CHANNEL_PROFILE_TYPE. - */ - CHANNEL_PROFILE_TYPE channelProfile; - - /** - * The license used for verification when connectting channel. Charge according to the license - */ - const char* license; - - /** - * The audio application scenario. See #AUDIO_SCENARIO_TYPE. - * - * @note Agora recommends the following scenarios: - * - `AUDIO_SCENARIO_DEFAULT(0)` - * - `AUDIO_SCENARIO_GAME_STREAMING(3)` - */ - AUDIO_SCENARIO_TYPE audioScenario; - /** - * The region for connection. This is an advanced feature and applies to scenarios that have regional restrictions. - * - * For the regions that Agora supports, see #AREA_CODE. The area codes support bitwise operation. - * - * After specifying the region, the app integrated with the Agora SDK connects to the Agora servers - * within that region. - */ - unsigned int areaCode; - - /** - * The log files that the SDK outputs. See LogConfig. - * - * By default, the SDK generates five SDK log files and five API call log files with the following rules: - * - The SDK log files are: `agorasdk.log`, `agorasdk.1.log`, `agorasdk.2.log`, `agorasdk.3.log`, and `agorasdk.4.log`. - * - The API call log files are: `agoraapi.log`, `agoraapi.1.log`, `agoraapi.2.log`, `agoraapi.3.log`, and `agoraapi.4.log`. - * - The default size for each SDK log file is 1,024 KB; the default size for each API call log file is 2,048 KB. These log files are encoded in UTF-8. - * - The SDK writes the latest logs in `agorasdk.log` or `agoraapi.log`. - * - When `agorasdk.log` is full, the SDK processes the log files in the following order: - * - Delete the `agorasdk.4.log` file (if any). - * - Rename `agorasdk.3.log` to `agorasdk.4.log`. - * - Rename `agorasdk.2.log` to `agorasdk.3.log`. - * - Rename `agorasdk.1.log` to `agorasdk.2.log`. - * - Create a new `agorasdk.log` file. - */ - commons::LogConfig logConfig; - - /** - * Thread priority for SDK common threads - */ - Optional threadPriority; - - /** - * Whether to use egl context in the current thread as sdk‘s root egl context, - * which is shared by all egl related modules. eg. camera capture, video renderer. - * - * @note - * This property applies to Android only. - */ - bool useExternalEglContext; - - /** - * Determines whether to enable domain limit - * -true: only connect to servers which already parsed by DNS - * -false: (Default) connect to servers with no limit - */ - bool domainLimit; - - /** - * Whether to automatically register Agora extensions when initializing RtcEngine. - * -true: (Default) Automatically register Agora extensions. - * -false: Do not automatically register Agora extensions. The user calls EnableExtension to manually register an Agora extension. - */ - bool autoRegisterAgoraExtensions; - - RtcEngineContext() - : eventHandler(NULL), appId(NULL), context(NULL), channelProfile(CHANNEL_PROFILE_LIVE_BROADCASTING), - license(NULL), audioScenario(AUDIO_SCENARIO_DEFAULT), areaCode(AREA_CODE_GLOB), - logConfig(), useExternalEglContext(false), domainLimit(false), autoRegisterAgoraExtensions(true) {} -}; - -/** Definition of IMetadataObserver -*/ -class IMetadataObserver { -public: - virtual ~IMetadataObserver() {} - - /** The metadata type. - * - * @note We only support video metadata for now. - */ - enum METADATA_TYPE - { - /** -1: (Not supported) Unknown. - */ - UNKNOWN_METADATA = -1, - /** 0: (Supported) Video metadata. - */ - VIDEO_METADATA = 0, - }; - /** - * The maximum metadata size. - */ - enum MAX_METADATA_SIZE_TYPE - { - INVALID_METADATA_SIZE_IN_BYTE = -1, - DEFAULT_METADATA_SIZE_IN_BYTE = 512, - MAX_METADATA_SIZE_IN_BYTE = 1024 - }; - - /** Metadata. - */ - struct Metadata - { - /** The channel ID of the `metadata`. - */ - const char* channelId; - /** The User ID that sent the metadata. - * - For the receiver: The user ID of the user who sent the `metadata`. - * - For the sender: Ignore this value. - */ - unsigned int uid; - /** The buffer size of the sent or received `metadata`. - */ - unsigned int size; - /** The buffer address of the sent or received `metadata`. - */ - unsigned char *buffer; - /** The NTP timestamp (ms) when the metadata is sent. - * @note If the receiver is audience, the receiver cannot get the NTP timestamp (ms). - */ - long long timeStampMs; - - Metadata() : channelId(NULL), uid(0), size(0), buffer(NULL), timeStampMs(0) {} - }; - - /** Occurs when the SDK requests the maximum size of the metadata. - * - * - * After successfully complete the registration by calling `registerMediaMetadataObserver`, the SDK - * triggers this callback once every video frame is sent. You need to specify the maximum size of - * the metadata in the return value of this callback. - * - * @return The maximum size of the buffer of the metadata that you want to use. The highest value is - * 1024 bytes. Ensure that you set the return value. - */ - virtual int getMaxMetadataSize() { return DEFAULT_METADATA_SIZE_IN_BYTE; } - - /** Occurs when the local user receives the metadata. - - @note Ensure that the size of the metadata does not exceed the value set in the `getMaxMetadataSize` callback. - - @param metadata The metadata that the user wants to send. For details, see Metadata. - @param source_type The video data type: #VIDEO_SOURCE_TYPE. - @return - - true: Send. - - false: Do not send. - */ - virtual bool onReadyToSendMetadata(Metadata &metadata, VIDEO_SOURCE_TYPE source_type) = 0; - - /** Occurs when the local user receives the metadata. - * - * @param metadata The metadata received. See Metadata. - * - * @note If the receiver is audience, the receiver cannot get the NTP timestamp (ms) - * that the metadata sends. - */ - virtual void onMetadataReceived(const Metadata& metadata) = 0; -}; - -// The reason codes for media streaming -// GENERATED_JAVA_ENUM_PACKAGE: io.agora.streaming -enum DIRECT_CDN_STREAMING_REASON { - // No error occurs. - DIRECT_CDN_STREAMING_REASON_OK = 0, - // A general error occurs (no specified reason). - DIRECT_CDN_STREAMING_REASON_FAILED = 1, - // Audio publication error. - DIRECT_CDN_STREAMING_REASON_AUDIO_PUBLICATION = 2, - // Video publication error. - DIRECT_CDN_STREAMING_REASON_VIDEO_PUBLICATION = 3, - - DIRECT_CDN_STREAMING_REASON_NET_CONNECT = 4, - // Already exist stream name. - DIRECT_CDN_STREAMING_REASON_BAD_NAME = 5, -}; - -// The connection state of media streaming -// GENERATED_JAVA_ENUM_PACKAGE: io.agora.streaming -enum DIRECT_CDN_STREAMING_STATE { - - DIRECT_CDN_STREAMING_STATE_IDLE = 0, - - DIRECT_CDN_STREAMING_STATE_RUNNING = 1, - - DIRECT_CDN_STREAMING_STATE_STOPPED = 2, - - DIRECT_CDN_STREAMING_STATE_FAILED = 3, - - DIRECT_CDN_STREAMING_STATE_RECOVERING = 4, -}; - -/** - * The statistics of the Direct Cdn Streams. - */ -struct DirectCdnStreamingStats { - /** - * Width of the video pushed by rtmp. - */ - int videoWidth; - - /** - * Height of the video pushed by rtmp. - */ - int videoHeight; - - /** - * The frame rate of the video pushed by rtmp. - */ - int fps; - - /** - * Real-time bit rate of the video streamed by rtmp. - */ - int videoBitrate; - - /** - * Real-time bit rate of the audio pushed by rtmp. - */ - int audioBitrate; -}; - -/** - * The event handler for direct cdn streaming - * - */ -class IDirectCdnStreamingEventHandler { - public: - virtual ~IDirectCdnStreamingEventHandler() {} - - /** - * Event callback of direct cdn streaming - * @param state Current status - * @param reason Reason Code - * @param message Message - */ - virtual void onDirectCdnStreamingStateChanged(DIRECT_CDN_STREAMING_STATE state, DIRECT_CDN_STREAMING_REASON reason, const char* message) { - (void)state; - (void)reason; - (void)message; - }; - - virtual void onDirectCdnStreamingStats(const DirectCdnStreamingStats& stats) { - (void)stats; - }; -}; - -/** - * The channel media options. - */ -struct DirectCdnStreamingMediaOptions { - /** - * Determines whether to publish the video of the camera track. - * - true: Publish the video track of the camera capturer. - * - false: (Default) Do not publish the video track of the camera capturer. - */ - Optional publishCameraTrack; - /** - * Determines whether to publish the recorded audio. - * - true: Publish the recorded audio. - * - false: (Default) Do not publish the recorded audio. - */ - Optional publishMicrophoneTrack; - /** - * Determines whether to publish the audio of the custom audio track. - * - true: Publish the audio of the custom audio track. - * - false: (Default) Do not publish the audio of the custom audio track. - */ - Optional publishCustomAudioTrack; - /** - * Determines whether to publish the video of the custom video track. - * - true: Publish the video of the custom video track. - * - false: (Default) Do not publish the video of the custom video track. - */ - Optional publishCustomVideoTrack; - /** - * Determines whether to publish the audio track of media player source. - * - true: Publish the audio track of media player source. - * - false: (Default) Do not publish the audio track of media player source. - */ - Optional publishMediaPlayerAudioTrack; - /** - * Determines which media player source should be published. - * You can get the MediaPlayerId after calling getMediaPlayerId() of AgoraMediaPlayer. - */ - Optional publishMediaPlayerId; - /** - * The custom video track id which will used to publish. - * You can get the VideoTrackId after calling createCustomVideoTrack() of IRtcEngine. - */ - Optional customVideoTrackId; - - DirectCdnStreamingMediaOptions() {} - ~DirectCdnStreamingMediaOptions() {} - - void SetAll(const DirectCdnStreamingMediaOptions& change) { -#define SET_FROM(X) SetFrom(&X, change.X) - SET_FROM(publishCameraTrack); - SET_FROM(publishMicrophoneTrack); - SET_FROM(publishCustomAudioTrack); - SET_FROM(publishCustomVideoTrack); - SET_FROM(publishMediaPlayerAudioTrack); - SET_FROM(publishMediaPlayerId); - SET_FROM(customVideoTrackId); -#undef SET_FROM - } - - bool operator==(const DirectCdnStreamingMediaOptions& o) const { -#define BEGIN_COMPARE() bool b = true -#define ADD_COMPARE(X) b = (b && (X == o.X)) -#define END_COMPARE() - - BEGIN_COMPARE(); - ADD_COMPARE(publishCameraTrack); - ADD_COMPARE(publishMicrophoneTrack); - ADD_COMPARE(publishCustomAudioTrack); - ADD_COMPARE(publishCustomVideoTrack); - ADD_COMPARE(publishMediaPlayerAudioTrack); - ADD_COMPARE(customVideoTrackId); - ADD_COMPARE(publishMediaPlayerId); - END_COMPARE(); - -#undef BEGIN_COMPARE -#undef ADD_COMPARE -#undef END_COMPARE - return b; - } - - DirectCdnStreamingMediaOptions& operator=(const DirectCdnStreamingMediaOptions& replace) { - if (this != &replace) { -#define REPLACE_BY(X) ReplaceBy(&X, replace.X) - - REPLACE_BY(publishCameraTrack); - REPLACE_BY(publishMicrophoneTrack); - REPLACE_BY(publishCustomAudioTrack); - REPLACE_BY(publishCustomVideoTrack); - REPLACE_BY(publishMediaPlayerAudioTrack); - REPLACE_BY(customVideoTrackId); - REPLACE_BY(publishMediaPlayerId); -#undef REPLACE_BY - } - return *this; - } -}; - -/** - * The information for extension. - */ -struct ExtensionInfo { - /** - * The type of media device. - */ - agora::media::MEDIA_SOURCE_TYPE mediaSourceType; - - /** - * The id of the remote user on which the extension works. - * - * @note remoteUid = 0 means that the extension works on all remote streams. - */ - uid_t remoteUid; - - /** - * The unique channel name for the AgoraRTC session in the string format. The string - * length must be less than 64 bytes. Supported character scopes are: - * - All lowercase English letters: a to z. - * - All uppercase English letters: A to Z. - * - All numeric characters: 0 to 9. - * - The space character. - * - Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", - * "-", - * ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",". - */ - const char* channelId; - - /** - * User ID: A 32-bit unsigned integer ranging from 1 to (2^32-1). It must be unique. - */ - uid_t localUid; - - ExtensionInfo() : mediaSourceType(agora::media::UNKNOWN_MEDIA_SOURCE), remoteUid(0), channelId(NULL), localUid(0) {} -}; - -class IMediaPlayer; -class IMediaRecorder; - -/** - * The IRtcEngine class, which is the basic interface of the Agora SDK that implements the core functions of real-time communication. - * - * `IRtcEngine` provides the main methods that your app can call. - * - */ -class IRtcEngine : public agora::base::IEngineBase { - public: - /** - * Releases the IRtcEngine object. - * - * This method releases all resources used by the Agora SDK. Use this method for apps in which users - * occasionally make voice or video calls. When users do not make calls, you can free up resources for - * other operations. - * - * After a successful method call, you can no longer use any method or callback in the SDK anymore. - * If you want to use the real-time communication functions again, you must call `createAgoraRtcEngine` - * and `initialize` to create a new `IRtcEngine` instance. - * - * @note If you want to create a new `IRtcEngine` instance after destroying the current one, ensure - * that you wait till the `release` method execution to complete. - * - * @param sync Determines whether this method is a synchronous call. - * - `true`: This method is a synchronous call, which means that the result of this method call - * returns after the IRtcEngine object resources are released. Do not call this method - * in any callback generated by the SDK, or it may result in a deadlock. - * - `false`: This method is an asynchronous call. The result returns immediately even when the - * IRtcEngine object resources are not released. - * - */ - AGORA_CPP_API static void release(bool sync = false); - - /** - * Initializes `IRtcEngine`. - * - * All called methods provided by the `IRtcEngine` class are executed asynchronously. Agora - * recommends calling these methods in the same thread. - * - * @note - * - Before calling other APIs, you must call `createAgoraRtcEngine` and `initialize `to create and - * initialize the `IRtcEngine` object. - * - The SDK supports creating only one `IRtcEngine` instance for an app. - * - * @param context The RtcEngineContext object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int initialize(const RtcEngineContext& context) = 0; - - /** - * Gets the pointer to the specified interface. - * - * @param iid The ID of the interface. See #INTERFACE_ID_TYPE for details. - * @param inter Output parameter. The pointer to the specified interface. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int queryInterface(INTERFACE_ID_TYPE iid, void** inter) = 0; - - - /** - * Gets the SDK version. - * @param build The build number. - * @return The version of the current SDK in the string format. - */ - virtual const char* getVersion(int* build) = 0; - - /** - * Gets the warning or error description. - * @param code The error code or warning code reported by the SDK. - * @return The specific error or warning description. - */ - virtual const char* getErrorDescription(int code) = 0; - - /** - * Queries the capacity of the current device codec. - * - * @param codec_info An array of the codec cap information: CodecCapInfo. - * @param size The array size. - * @return - * 0: Success. - * < 0: Failure. - */ - virtual int queryCodecCapability(CodecCapInfo* codecInfo, int& size) = 0; - - /** - * Queries the score of the current device. - * - * @return - * > 0: If the value is greater than 0, it means that the device score has been retrieved and represents the score value. - * Most devices score between 60-100, with higher scores indicating better performance. - * - * < 0: Failure. - */ - virtual int queryDeviceScore() = 0; - - /** - * Preload a channel. - * - * This method enables users to preload a channel. - * - * A successful call of this method will reduce the time of joining the same channel. - * - * Note: - * 1. The SDK supports preloading up to 20 channels. Once the preloaded channels exceed the limit, the SDK will keep the latest 20 available. - * 2. Renew the token of the preloaded channel by calling this method with the same 'channelId' and 'uid'. - * - * @param token The token generated on your server for authentication. - * @param channelId The channel name. This parameter signifies the channel in which users engage in - * real-time audio and video interaction. Under the premise of the same App ID, users who fill in - * the same channel ID enter the same channel for audio and video interaction. The string length - * must be less than 64 bytes. Supported character scopes are: - * - All lowercase English letters: a to z. - * - All uppercase English letters: A to Z. - * - All numeric characters: 0 to 9. - * - The space character. - * - Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", - * ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",". - * @param uid The user ID. This parameter is used to identify the user in the channel for real-time - * audio and video interaction. You need to set and manage user IDs yourself, and ensure that each - * user ID in the same channel is unique. This parameter is a 32-bit unsigned integer. The value - * range is 1 to 232-1. If the user ID is not assigned (or set to 0), the SDK assigns a random user - * ID and returns it in the onJoinChannelSuccess callback. Your application must record and maintain - * the returned user ID, because the SDK does not do so. - * - * @return - * - 0: Success. - * - < 0: Failure. - * - -7: The IRtcEngine object has not been initialized. You need to initialize the IRtcEngine - * object before calling this method. - * - -102: The channel name is invalid. You need to pass in a valid channel name in channelId to - * preload the channel again. - */ - virtual int preloadChannel(const char* token, const char* channelId, uid_t uid) = 0; - - /** - * Preload a channel. - * - * This method enables users to preload a channel. - * - * A successful call of this method will reduce the time of joining the same channel. - * - * Note: - * 1. The SDK supports preloading up to 20 channels. Once the preloaded channels exceed the limit, the SDK will keep the latest 20 available. - * 2. Renew the token of the preloaded channel by calling this method with the same 'channelId' and 'userAccount'. - * - * @param token The token generated on your server for authentication. - * @param channelId The channel name. This parameter signifies the channel in which users engage in - * real-time audio and video interaction. Under the premise of the same App ID, users who fill in - * the same channel ID enter the same channel for audio and video interaction. The string length - * must be less than 64 bytes. Supported character scopes are: - * - All lowercase English letters: a to z. - * - All uppercase English letters: A to Z. - * - All numeric characters: 0 to 9. - * - The space character. - * - Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", - * ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",". - * @param userAccount The user account. The maximum length of this parameter is 255 bytes. Ensure that you set this parameter and do not set it as null. Supported character scopes are: - * - All lowercase English letters: a to z. - * - All uppercase English letters: A to Z. - * - All numeric characters: 0 to 9. - * - The space character. - * - Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",". - * - * @return - * - 0: Success. - * - < 0: Failure. - * - -2: The parameter is invalid. For example, the userAccount parameter is empty. - * You need to pass in a valid parameter and preload the channel again. - * - -7: The IRtcEngine object has not been initialized. You need to initialize the IRtcEngine - * object before calling this method. - * - -102: The channel name is invalid. You need to pass in a valid channel name in channelId to - * preload the channel again. - */ - virtual int preloadChannelWithUserAccount(const char* token, const char* channelId, const char* userAccount) = 0; - - /** - * Update token of the preloaded channels. - * - * An easy way to update all preloaded channels' tokens, if all preloaded channels use the same token. - * - * If preloaded channels use different tokens, we need to call the 'preloadChannel' method with the same 'channelId' - * and 'uid' or 'userAccount' to update the corresponding token. - * - * @param token The token generated on your server for authentication. - * - * @return - * - 0: Success. - * - < 0: Failure. - * - -2: The token is invalid. You need to pass in a valid token and update the token again. - * - -7: The IRtcEngine object has not been initialized. You need to initialize the IRtcEngine - * object before calling this method. - */ - virtual int updatePreloadChannelToken(const char* token) = 0; - - /** - * Joins a channel. - * - * This method enables users to join a channel. Users in the same channel can talk to each other, - * and multiple users in the same channel can start a group chat. Users with different App IDs - * cannot call each other. - * - * A successful call of this method triggers the following callbacks: - * - The local client: The `onJoinChannelSuccess` and `onConnectionStateChanged` callbacks. - * - The remote client: `onUserJoined`, if the user joining the channel is in the Communication - * profile or is a host in the Live-broadcasting profile. - * - * When the connection between the client and Agora's server is interrupted due to poor network - * conditions, the SDK tries reconnecting to the server. When the local client successfully rejoins - * the channel, the SDK triggers the `onRejoinChannelSuccess` callback on the local client. - * - * @note Once a user joins the channel, the user subscribes to the audio and video streams of all - * the other users in the channel by default, giving rise to usage and billing calculation. To - * stop subscribing to a specified stream or all remote streams, call the corresponding `mute` methods. - * - * @param token The token generated on your server for authentication. - * @param channelId The channel name. This parameter signifies the channel in which users engage in - * real-time audio and video interaction. Under the premise of the same App ID, users who fill in - * the same channel ID enter the same channel for audio and video interaction. The string length - * must be less than 64 bytes. Supported character scopes are: - * - All lowercase English letters: a to z. - * - All uppercase English letters: A to Z. - * - All numeric characters: 0 to 9. - * - The space character. - * - Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", - * ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",". - * @param info (Optional) Reserved for future use. - * @param uid The user ID. This parameter is used to identify the user in the channel for real-time - * audio and video interaction. You need to set and manage user IDs yourself, and ensure that each - * user ID in the same channel is unique. This parameter is a 32-bit unsigned integer. The value - * range is 1 to 232-1. If the user ID is not assigned (or set to 0), the SDK assigns a random user - * ID and returns it in the onJoinChannelSuccess callback. Your application must record and maintain - * the returned user ID, because the SDK does not do so. - * - * @return - * - 0: Success. - * - < 0: Failure. - * - -2: The parameter is invalid. For example, the token is invalid, the uid parameter is not set - * to an integer, or the value of a member in the `ChannelMediaOptions` structure is invalid. You need - * to pass in a valid parameter and join the channel again. - * - -3: Failes to initialize the `IRtcEngine` object. You need to reinitialize the IRtcEngine object. - * - -7: The IRtcEngine object has not been initialized. You need to initialize the IRtcEngine - * object before calling this method. - * - -8: The internal state of the IRtcEngine object is wrong. The typical cause is that you call - * this method to join the channel without calling `stopEchoTest` to stop the test after calling - * `startEchoTest` to start a call loop test. You need to call `stopEchoTest` before calling this method. - * - -17: The request to join the channel is rejected. The typical cause is that the user is in the - * channel. Agora recommends using the `onConnectionStateChanged` callback to get whether the user is - * in the channel. Do not call this method to join the channel unless you receive the - * `CONNECTION_STATE_DISCONNECTED(1)` state. - * - -102: The channel name is invalid. You need to pass in a valid channel name in channelId to - * rejoin the channel. - * - -121: The user ID is invalid. You need to pass in a valid user ID in uid to rejoin the channel. - */ - virtual int joinChannel(const char* token, const char* channelId, const char* info, uid_t uid) = 0; - - /** - * Joins a channel with media options. - * - * This method enables users to join a channel. Users in the same channel can talk to each other, - * and multiple users in the same channel can start a group chat. Users with different App IDs - * cannot call each other. - * - * A successful call of this method triggers the following callbacks: - * - The local client: The `onJoinChannelSuccess` and `onConnectionStateChanged` callbacks. - * - The remote client: `onUserJoined`, if the user joining the channel is in the Communication - * profile or is a host in the Live-broadcasting profile. - * - * When the connection between the client and Agora's server is interrupted due to poor network - * conditions, the SDK tries reconnecting to the server. When the local client successfully rejoins - * the channel, the SDK triggers the `onRejoinChannelSuccess` callback on the local client. - * - * Compared to `joinChannel`, this method adds the options parameter to configure whether to - * automatically subscribe to all remote audio and video streams in the channel when the user - * joins the channel. By default, the user subscribes to the audio and video streams of all - * the other users in the channel, giving rise to usage and billings. To unsubscribe, set the - * `options` parameter or call the `mute` methods accordingly. - * - * @note - * - This method allows users to join only one channel at a time. - * - Ensure that the app ID you use to generate the token is the same app ID that you pass in the - * `initialize` method; otherwise, you may fail to join the channel by token. - * - * @param token The token generated on your server for authentication. - * - * @param channelId The channel name. This parameter signifies the channel in which users engage in - * real-time audio and video interaction. Under the premise of the same App ID, users who fill in - * the same channel ID enter the same channel for audio and video interaction. The string length - * must be less than 64 bytes. Supported character scopes are: - * - All lowercase English letters: a to z. - * - All uppercase English letters: A to Z. - * - All numeric characters: 0 to 9. - * - The space character. - * - Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", - * ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",". - * @param uid The user ID. This parameter is used to identify the user in the channel for real-time - * audio and video interaction. You need to set and manage user IDs yourself, and ensure that each - * user ID in the same channel is unique. This parameter is a 32-bit unsigned integer. The value - * range is 1 to 232-1. If the user ID is not assigned (or set to 0), the SDK assigns a random user - * ID and returns it in the `onJoinChannelSuccess` callback. Your application must record and maintain - * the returned user ID, because the SDK does not do so. - * @param options The channel media options: ChannelMediaOptions. - * - * @return - * - 0: Success. - * - < 0: Failure. - * - -2: The parameter is invalid. For example, the token is invalid, the uid parameter is not set - * to an integer, or the value of a member in the `ChannelMediaOptions` structure is invalid. You need - * to pass in a valid parameter and join the channel again. - * - -3: Failes to initialize the `IRtcEngine` object. You need to reinitialize the IRtcEngine object. - * - -7: The IRtcEngine object has not been initialized. You need to initialize the IRtcEngine - * object before calling this method. - * - -8: The internal state of the IRtcEngine object is wrong. The typical cause is that you call - * this method to join the channel without calling `stopEchoTest` to stop the test after calling - * `startEchoTest` to start a call loop test. You need to call `stopEchoTest` before calling this method. - * - -17: The request to join the channel is rejected. The typical cause is that the user is in the - * channel. Agora recommends using the `onConnectionStateChanged` callback to get whether the user is - * in the channel. Do not call this method to join the channel unless you receive the - * `CONNECTION_STATE_DISCONNECTED(1)` state. - * - -102: The channel name is invalid. You need to pass in a valid channel name in channelId to - * rejoin the channel. - * - -121: The user ID is invalid. You need to pass in a valid user ID in uid to rejoin the channel. - */ - virtual int joinChannel(const char* token, const char* channelId, uid_t uid, const ChannelMediaOptions& options) = 0; - - /** - * Updates the channel media options after joining the channel. - * - * @param options The channel media options: ChannelMediaOptions. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int updateChannelMediaOptions(const ChannelMediaOptions& options) = 0; - - /** - * Leaves the channel. - * - * This method allows a user to leave the channel, for example, by hanging up or exiting a call. - * - * This method is an asynchronous call, which means that the result of this method returns even before - * the user has not actually left the channel. Once the user successfully leaves the channel, the - * SDK triggers the \ref IRtcEngineEventHandler::onLeaveChannel "onLeaveChannel" callback. - * - * @note - * If you call \ref release "release" immediately after this method, the leaveChannel process will be - * interrupted, and the SDK will not trigger the `onLeaveChannel` callback. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int leaveChannel() = 0; - - /** - * Leaves the channel. - * - * @param options The leave channel options. - * - * This method allows a user to leave the channel, for example, by hanging up or exiting a call. - * - * This method is an asynchronous call, which means that the result of this method returns even before - * the user has not actually left the channel. Once the user successfully leaves the channel, the - * SDK triggers the \ref IRtcEngineEventHandler::onLeaveChannel "onLeaveChannel" callback. - * - * @note - * If you call \ref release "release" immediately after this method, the leaveChannel process will be - * interrupted, and the SDK will not trigger the `onLeaveChannel` callback. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int leaveChannel(const LeaveChannelOptions& options) = 0; - - /** - * Renews the token. - * - * Once a token is enabled and used, it expires after a certain period of time. - * - * Under the following circumstances, generate a new token on your server, and then call this method to - * renew it. Failure to do so results in the SDK disconnecting from the server. - * - The \ref IRtcEngineEventHandler onTokenPrivilegeWillExpire "onTokenPrivilegeWillExpire" callback is triggered; - * - The \ref IRtcEngineEventHandler::onRequestToken "onRequestToken" callback is triggered; - * - The `ERR_TOKEN_EXPIRED(-109)` error is reported. - * - * @param token The new token. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int renewToken(const char* token) = 0; - - /** - * Sets the channel profile. - * - * The IRtcEngine differentiates channel profiles and applies different optimization algorithms accordingly. - * For example, it prioritizes smoothness and low latency for a video call, and prioritizes video quality - * for a video broadcast. - * - * @note - * - To ensure the quality of real-time communication, we recommend that all users in a channel use the - * same channel profile. - * - Call this method before calling `joinChannel`. You cannot set the channel profile - * once you have joined the channel. - * - * @param profile The channel profile: #CHANNEL_PROFILE_TYPE. - * @return - * - 0: Success. - * - < 0: Failure. - * - -8(ERR_INVALID_STATE): The current status is invalid, only allowed to be called when the connection is disconnected. - */ - virtual int setChannelProfile(CHANNEL_PROFILE_TYPE profile) = 0; - - /** - * Sets the role of a user. - * - * This method sets the user role as either BROADCASTER or AUDIENCE (default). - * - The broadcaster sends and receives streams. - * - The audience receives streams only. - * - * By default, all users are audience regardless of the channel profile. - * Call this method to change the user role to BROADCASTER so that the user can - * send a stream. - * - * @note - * After calling the setClientRole() method to CLIENT_ROLE_AUDIENCE, the SDK stops audio recording. - * However, CLIENT_ROLE_AUDIENCE will keep audio recording with AUDIO_SCENARIO_CHATROOM(5). - * Normally, app developer can also use mute api to achieve the same result, and we implement - * this 'non-orthogonal' behavior only to make API backward compatible. - * - * @param role The role of the client: #CLIENT_ROLE_TYPE. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setClientRole(CLIENT_ROLE_TYPE role) = 0; - - /** Sets the role of the user, such as a host or an audience (default), before joining a channel in the live interactive streaming. - * - * This method can be used to switch the user role in the live interactive streaming after the user joins a channel. - * - * In the `LIVE_BROADCASTING` profile, when a user switches user roles after joining a channel, a successful \ref agora::rtc::IRtcEngine::setClientRole "setClientRole" method call triggers the following callbacks: - * - The local client: \ref agora::rtc::IRtcEngineEventHandler::onClientRoleChanged "onClientRoleChanged" - * - The remote client: \ref agora::rtc::IRtcEngineEventHandler::onUserJoined "onUserJoined" or \ref agora::rtc::IRtcEngineEventHandler::onUserOffline "onUserOffline" (BECOME_AUDIENCE) - * - * @note - * This method applies only to the `LIVE_BROADCASTING` profile. - * - * @param role Sets the role of the user. See #CLIENT_ROLE_TYPE. - * @param options Sets the audience latency level of the user. See #ClientRoleOptions. - * - * @return - * - 0(ERR_OK): Success. - * - < 0: Failure. - * - -1(ERR_FAILED): A general error occurs (no specified reason). - * - -2(ERR_INALID_ARGUMENT): The parameter is invalid. - * - -7(ERR_NOT_INITIALIZED): The SDK is not initialized. - * - -8(ERR_INVALID_STATE): The channel profile is not `LIVE_BROADCASTING`. - */ - virtual int setClientRole(CLIENT_ROLE_TYPE role, const ClientRoleOptions& options) = 0; - - /** Starts a video call test. - * - * @param config: configuration for video call test. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int startEchoTest(const EchoTestConfiguration& config) = 0; - - /** Stops the audio call test. - @return int - - - 0: Success. - - < 0: Failure. - */ - virtual int stopEchoTest() = 0; - -#if defined(__APPLE__) && TARGET_OS_IOS - /** Enables the SDK use AVCaptureMultiCamSession or AVCaptureSession. Applies to iOS 13.0+ only. - * @param enabled Whether to enable multi-camera when capturing video: - * - true: Enable multi-camera, and the SDK uses AVCaptureMultiCamSession. - * - false: Disable multi-camera, and the SDK uses AVCaptureSession. - * @param config The config for secondary camera capture session. See #CameraCapturerConfiguration. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableMultiCamera(bool enabled, const CameraCapturerConfiguration& config) = 0; -#endif - /** - * Enables the video. - * - * You can call this method either before joining a channel or during a call. - * If you call this method before entering a channel, the service starts the video; if you call it - * during a call, the audio call switches to a video call. - * - * @note - * This method controls the underlying states of the Engine. It is still - * valid after one leaves the channel. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableVideo() = 0; - - /** - * Disables the video. - * - * This method stops capturing the local video and receiving any remote video. - * To enable the local preview function, call \ref enableLocalVideo "enableLocalVideo" (true). - * @return int - * - 0: Success. - * - < 0: Failure. - */ - virtual int disableVideo() = 0; - - /** - * Starts the local video preview before joining a channel. - * - * Once you call this method to start the local video preview, if you leave - * the channel by calling \ref leaveChannel "leaveChannel", the local video preview remains until - * you call \ref stopPreview "stopPreview" to disable it. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int startPreview() = 0; - - /** - * Starts the local video preview for specific source type. - * @param sourceType - The video source type. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int startPreview(VIDEO_SOURCE_TYPE sourceType) = 0; - - /** - * Stops the local video preview and the video. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int stopPreview() = 0; - - /** - * Stops the local video preview for specific source type. - * @param sourceType - The video source type. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int stopPreview(VIDEO_SOURCE_TYPE sourceType) = 0; - - /** Starts the last-mile network probe test. - - This method starts the last-mile network probe test before joining a channel - to get the uplink and downlink last-mile network statistics, including the - bandwidth, packet loss, jitter, and round-trip time (RTT). - - Call this method to check the uplink network quality before users join a - channel or before an audience switches to a host. Once this method is - enabled, the SDK returns the following callbacks: - - \ref IRtcEngineEventHandler::onLastmileQuality "onLastmileQuality": the - SDK triggers this callback depending on the network - conditions. This callback rates the network conditions and is more closely - linked to the user experience. - - \ref IRtcEngineEventHandler::onLastmileProbeResult "onLastmileProbeResult": - the SDK triggers this callback within 30 seconds depending on the network - conditions. This callback returns the real-time statistics of the network - conditions and is more objective. - - @note - - Do not call other methods before receiving the - \ref IRtcEngineEventHandler::onLastmileQuality "onLastmileQuality" and - \ref IRtcEngineEventHandler::onLastmileProbeResult "onLastmileProbeResult" - callbacks. Otherwise, the callbacks may be interrupted. - - In the Live-broadcast profile, a host should not call this method after - joining a channel. - - @param config Sets the configurations of the last-mile network probe test. See - LastmileProbeConfig. - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int startLastmileProbeTest(const LastmileProbeConfig& config) = 0; - - /** Stops the last-mile network probe test. */ - virtual int stopLastmileProbeTest() = 0; - - /** - * Sets the video encoder configuration. - * - * Each configuration profile corresponds to a set of video parameters, including - * the resolution, frame rate, and bitrate. - * - * The parameters specified in this method are the maximum values under ideal network conditions. - * If the video engine cannot render the video using the specified parameters due - * to poor network conditions, the parameters further down the list are considered - * until a successful configuration is found. - * - * @param config The local video encoder configuration: VideoEncoderConfiguration. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setVideoEncoderConfiguration(const VideoEncoderConfiguration& config) = 0; - - /** Enables/Disables image enhancement and sets the options. - * - * @note Call this method after calling the \ref IRtcEngine::enableVideo "enableVideo" method. - * - * @param enabled Sets whether or not to enable image enhancement: - * - true: enables image enhancement. - * - false: disables image enhancement. - * @param options Sets the image enhancement option. See BeautyOptions. - */ - virtual int setBeautyEffectOptions(bool enabled, const BeautyOptions& options, agora::media::MEDIA_SOURCE_TYPE type = agora::media::PRIMARY_CAMERA_SOURCE) = 0; - /** Enables/Disables face shape and sets the beauty options. - * - * @note Call this method after calling the \ref IRtcEngine::enableVideo "enableVideo" method. - * - * @param enabled Sets whether or not to enable face shape: - * - true: enables face shape. - * - false: disables face shape. - * @param options Sets the face shape beauty option. See FaceShapeBeautyOptions. - */ - virtual int setFaceShapeBeautyOptions(bool enabled, const FaceShapeBeautyOptions& options, agora::media::MEDIA_SOURCE_TYPE type = agora::media::PRIMARY_CAMERA_SOURCE) = 0; - /** Enables/Disables face shape and sets the area options. - * - * @note Call this method after calling the \ref IRtcEngine::setFaceShapeBeautyOptions "setFaceShapeBeautyOptions" method. - * - * @param options Sets the face shape area option. See FaceShapeAreaOptions. - */ - virtual int setFaceShapeAreaOptions(const FaceShapeAreaOptions& options, agora::media::MEDIA_SOURCE_TYPE type = agora::media::PRIMARY_CAMERA_SOURCE) = 0; - - /** Gets the face shape beauty options. - * - * @note Call this method after calling the \ref IRtcEngine::enableVideo "enableVideo" method. - * - * @param options Gets the face shape beauty option. See FaceShapeBeautyOptions. - */ - virtual int getFaceShapeBeautyOptions(FaceShapeBeautyOptions& options, agora::media::MEDIA_SOURCE_TYPE type = agora::media::PRIMARY_CAMERA_SOURCE) = 0; - - /** Gets the face shape area options. - * - * @note Call this method after calling the \ref IRtcEngine::enableVideo "enableVideo" method. - * - * @param shapeArea The face area. See FaceShapeAreaOptions::FACE_SHAPE_AREA. - * @param options Gets the face area beauty option. See FaceShapeAreaOptions. - */ - virtual int getFaceShapeAreaOptions(agora::rtc::FaceShapeAreaOptions::FACE_SHAPE_AREA shapeArea, FaceShapeAreaOptions& options, agora::media::MEDIA_SOURCE_TYPE type = agora::media::PRIMARY_CAMERA_SOURCE) = 0; - - /** - * Sets low-light enhancement. - * - * @since v4.0.0 - * - * The low-light enhancement feature can adaptively adjust the brightness value of the video captured in situations with low or uneven lighting, such as backlit, cloudy, or dark scenes. It restores or highlights the image details and improves the overall visual effect of the video. - * - * You can call this method to enable the low-light enhancement feature and set the options of the low-light enhancement effect. - * - * @note - * - Before calling this method, ensure that you have integrated the following dynamic library into your project: - * - Android: `libagora_segmentation_extension.so` - * - iOS/macOS: `AgoraVideoSegmentationExtension.xcframework` - * - Windows: `libagora_segmentation_extension.dll` - * - Call this method after \ref IRtcEngine::enableVideo "enableVideo". - * - The low-light enhancement feature has certain performance requirements on devices. If your device overheats after you enable low-light enhancement, Agora recommends modifying the low-light enhancement options to a less performance-consuming level or disabling low-light enhancement entirely. - * - * @param enabled Sets whether to enable low-light enhancement: - * - `true`: Enable. - * - `false`: (Default) Disable. - * @param options The low-light enhancement options. See LowlightEnhanceOptions. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setLowlightEnhanceOptions(bool enabled, const LowlightEnhanceOptions& options, agora::media::MEDIA_SOURCE_TYPE type = agora::media::PRIMARY_CAMERA_SOURCE) = 0; - /** - * Sets video noise reduction. - * - * @since v4.0.0 - * - * Underlit environments and low-end video capture devices can cause video images to contain significant noise, which affects video quality. In real-time interactive scenarios, video noise also consumes bitstream resources and reduces encoding efficiency during encoding. - * - * You can call this method to enable the video noise reduction feature and set the options of the video noise reduction effect. - * - * @note - * - Before calling this method, ensure that you have integrated the following dynamic library into your project: - * - Android: `libagora_segmentation_extension.so` - * - iOS/macOS: `AgoraVideoSegmentationExtension.xcframework` - * - Windows: `libagora_segmentation_extension.dll` - * - Call this method after \ref IRtcEngine::enableVideo "enableVideo". - * - The video noise reduction feature has certain performance requirements on devices. If your device overheats after you enable video noise reduction, Agora recommends modifying the video noise reduction options to a less performance-consuming level or disabling video noise reduction entirely. - * - * @param enabled Sets whether to enable video noise reduction: - * - `true`: Enable. - * - `false`: (Default) Disable. - * @param options The video noise reduction options. See VideoDenoiserOptions. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setVideoDenoiserOptions(bool enabled, const VideoDenoiserOptions& options, agora::media::MEDIA_SOURCE_TYPE type = agora::media::PRIMARY_CAMERA_SOURCE) = 0; - /** - * Sets color enhancement. - * - * @since v4.0.0 - * - * The video images captured by the camera can have color distortion. The color enhancement feature intelligently adjusts video characteristics such as saturation and contrast to enhance the video color richness and color reproduction, making the video more vivid. - * - * You can call this method to enable the color enhancement feature and set the options of the color enhancement effect. - * - * @note - * - Before calling this method, ensure that you have integrated the following dynamic library into your project: - * - Android: `libagora_segmentation_extension.so` - * - iOS/macOS: `AgoraVideoSegmentationExtension.xcframework` - * - Windows: `libagora_segmentation_extension.dll` - * - Call this method after \ref IRtcEngine::enableVideo "enableVideo". - * - The color enhancement feature has certain performance requirements on devices. If your device overheats after you enable color enhancement, Agora recommends modifying the color enhancement options to a less performance-consuming level or disabling color enhancement entirely. - * - * @param enabled Sets whether to enable color enhancement: - * - `true`: Enable. - * - `false`: (Default) Disable. - * @param options The color enhancement options. See ColorEnhanceOptions. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setColorEnhanceOptions(bool enabled, const ColorEnhanceOptions& options, agora::media::MEDIA_SOURCE_TYPE type = agora::media::PRIMARY_CAMERA_SOURCE) = 0; - - /** - * Enables/Disables the virtual background. (beta function) - * - * @since v3.7.200 - * - * After enabling the virtual background function, you can replace the original background image of the local user - * with a custom background image. After the replacement, all users in the channel can see the custom background - * image. - * - * @note - * - Before calling this method, ensure that you have integrated the - * `libagora_segmentation_extension.dll` (Windows)/`AgoraVideoSegmentationExtension.framework` (macOS) dynamic - * library into the project folder. - * - Call this method after \ref IRtcEngine::enableVideo "enableVideo". - * - This function requires a high-performance device. Agora recommends that you use this function on devices with - * an i5 CPU and better. - * - Agora recommends that you use this function in scenarios that meet the following conditions: - * - A high-definition camera device is used, and the environment is uniformly lit. - * - The captured video image is uncluttered, the user's portrait is half-length and largely unobstructed, and the - * background is a single color that differs from the color of the user's clothing. - * - * @param enabled Sets whether to enable the virtual background: - * - true: Enable. - * - false: Disable. - * @param backgroundSource The custom background image. See VirtualBackgroundSource. **Note**: To adapt the - * resolution of the custom background image to the resolution of the SDK capturing video, the SDK scales and crops - * the custom background image while ensuring that the content of the custom background image is not distorted. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableVirtualBackground(bool enabled, VirtualBackgroundSource backgroundSource, SegmentationProperty segproperty, agora::media::MEDIA_SOURCE_TYPE type = agora::media::PRIMARY_CAMERA_SOURCE) = 0; - - /** - * Initializes the video view of a remote user. - * - * This method initializes the video view of a remote stream on the local device. It affects only the - * video view that the local user sees. - * - * Usually the app should specify the `uid` of the remote video in the method call before the - * remote user joins the channel. If the remote `uid` is unknown to the app, set it later when the - * app receives the \ref IRtcEngineEventHandler::onUserJoined "onUserJoined" callback. - * - * To unbind the remote user from the view, set `view` in VideoCanvas as `null`. - * - * @note - * Ensure that you call this method in the UI thread. - * - * @param canvas The remote video view settings: VideoCanvas. - * @return int - * VIRTUAL_BACKGROUND_SOURCE_STATE_REASON_SUCCESS = 0, - * VIRTUAL_BACKGROUND_SOURCE_STATE_REASON_IMAGE_NOT_EXIST = -1, - * VIRTUAL_BACKGROUND_SOURCE_STATE_REASON_COLOR_FORMAT_NOT_SUPPORTED = -2, - * VIRTUAL_BACKGROUND_SOURCE_STATE_REASON_DEVICE_NOT_SUPPORTED = -3, - */ - virtual int setupRemoteVideo(const VideoCanvas& canvas) = 0; - - /** - * Initializes the local video view. - * - * This method initializes the video view of the local stream on the local device. It affects only - * the video view that the local user sees, not the published local video stream. - * - * To unbind the local video from the view, set `view` in VideoCanvas as `null`. - * - * @note - * Call this method before joining a channel. - * - * @param canvas The local video view setting: VideoCanvas. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setupLocalVideo(const VideoCanvas& canvas) = 0; - - /** - * Sets the Video application scenario. - * - * @since v4.2.0 - * - * You can call this method to set the expected video scenario. - * The SDK will optimize the video experience for each scenario you set. - * - * - * @param scenarioType The video application scenario. See #ApplicationScenarioType. - * - * @return - * - 0: Success. - * - < 0: Failure. - * - ERR_FAILED (1): A general error occurs (no specified reason). - * - ERR_NOT_SUPPORTED (4): Unable to set video application scenario. - * - ERR_NOT_INITIALIZED (7): The SDK is not initialized. - */ - virtual int setVideoScenario(VIDEO_APPLICATION_SCENARIO_TYPE scenarioType) = 0; - - /** - * Sets the video qoe preference. - * - * @since v4.2.1 - * - * You can call this method to set the expected QoE Preference. - * The SDK will optimize the video experience for each preference you set. - * - * - * @param qoePreference The qoe preference type. See #VIDEO_QOE_PREFERENCE_TYPE. - * - * @return - * - 0: Success. - * - < 0: Failure. - * - ERR_FAILED (1): A general error occurs (no specified reason). - * - ERR_NOT_SUPPORTED (4): Unable to set video application scenario. - * - ERR_NOT_INITIALIZED (7): The SDK is not initialized. - */ - virtual int setVideoQoEPreference(VIDEO_QOE_PREFERENCE_TYPE qoePreference) = 0; - - /** - * Enables the audio. - * - * The audio is enabled by default. - * - * @note - * This method controls the underlying states of the Engine. It is still - * valid after one leaves channel. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableAudio() = 0; - - /** - * Disables the audio. - * - * @note - * This method controls the underlying states of the Engine. It is still - * valid after one leaves channel. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int disableAudio() = 0; - - /** - * Sets the audio parameters and application scenarios. - * - * @deprecated This method is deprecated. You can use the - * \ref IRtcEngine::setAudioProfile(AUDIO_PROFILE_TYPE) "setAudioProfile" - * method instead. To set the audio scenario, call the \ref IRtcEngine::initialize "initialize" - * method and pass value in the `audioScenario` member in the RtcEngineContext struct. - * - * @note - * - Call this method before calling the `joinChannel` method. - * - In scenarios requiring high-quality audio, we recommend setting `profile` as `MUSIC_HIGH_QUALITY`(4) - * and `scenario` as `AUDIO_SCENARIO_GAME_STREAMING`(3). - * - * @param profile Sets the sample rate, bitrate, encoding mode, and the number of channels: - * #AUDIO_PROFILE_TYPE. - * @param scenario Sets the audio application scenarios: #AUDIO_SCENARIO_TYPE. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setAudioProfile(AUDIO_PROFILE_TYPE profile, AUDIO_SCENARIO_TYPE scenario) __deprecated = 0; - - /** - * Sets the audio profile. - * - * @note - * - Call this method before calling the `joinChannel` method. - * - In scenarios requiring high-quality audio, Agora recommends setting `profile` as `MUSIC_HIGH_QUALITY`(4). - * - To set the audio scenario, call the \ref IRtcEngine::initialize "initialize" - * method and pass value in the `audioScenario` member in the RtcEngineContext struct. - * - * @param profile The audio profile, such as the sample rate, bitrate and codec type: #AUDIO_PROFILE_TYPE. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setAudioProfile(AUDIO_PROFILE_TYPE profile) = 0; - /** - * Set the audio scenario. - * - * @param scenario The audio scenario: #AUDIO_SCENARIO_TYPE. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setAudioScenario(AUDIO_SCENARIO_TYPE scenario) = 0; - /** - * Enables or disables the local audio capture. - * - * The audio function is enabled by default. This method disables or re-enables the - * local audio function, that is, to stop or restart local audio capture and - * processing. - * - * This method does not affect receiving or playing the remote audio streams, - * and `enableLocalAudio` (false) is applicable to scenarios where the user wants - * to receive remote audio streams without sending any audio stream to other users - * in the channel. - * - * @param enabled Determines whether to disable or re-enable the local audio function: - * - true: (Default) Re-enable the local audio function, that is, to start local - * audio capture and processing. - * - false: Disable the local audio function, that is, to stop local audio - * capture and processing. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableLocalAudio(bool enabled) = 0; - - /** - Stops or resumes sending the local audio stream. - - After calling this method successfully, the SDK triggers the - \ref IRtcEngineEventHandler::onRemoteAudioStateChanged "onRemoteAudioStateChanged" - callback with the following parameters: - - REMOTE_AUDIO_STATE_STOPPED(0) and REMOTE_AUDIO_REASON_REMOTE_MUTED(5). - - REMOTE_AUDIO_STATE_DECODING(2) and REMOTE_AUDIO_REASON_REMOTE_UNMUTED(6). - - @note - - When `mute` is set as `true`, this method does not disable the - microphone, which does not affect any ongoing recording. - - If you call \ref IRtcEngine::setChannelProfile "setChannelProfile" after - this method, the SDK resets whether or not to mute the local audio - according to the channel profile and user role. Therefore, we recommend - calling this method after the `setChannelProfile` method. - - @param mute Determines whether to send or stop sending the local audio stream: - - true: Stop sending the local audio stream. - - false: (Default) Send the local audio stream. - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int muteLocalAudioStream(bool mute) = 0; - - /** - Stops or resumes receiving all remote audio stream. - - This method works for all remote users that join or will join a channel - using the `joinChannel` method. It is - equivalent to the `autoSubscribeAudio` member in the ChannelMediaOptions - class. - - Ensure that you call this method after joining a channel. - - If you call muteAllRemoteAudioStreams(true) after joining a channel, the - local use stops receiving any audio stream from any user in the channel, - including any user who joins the channel after you call this method. - - If you call muteAllRemoteAudioStreams(true) after leaving a channel, the - local user does not receive any audio stream the next time the user joins a - channel. - - After you successfully call muteAllRemoteAudioStreams(true), you can take - the following actions: - - To resume receiving all remote audio streams, call - muteAllRemoteAudioStreams(false). - - To resume receiving the audio stream of a specified user, call - muteRemoteAudioStream(uid, false), where uid is the ID of the user whose - audio stream you want to resume receiving. - - @note - - The result of calling this method is affected by calling - \ref IRtcEngine::enableAudio "enableAudio" and - \ref IRtcEngine::disableAudio "disableAudio". Settings in - muteAllRemoteAudioStreams stop taking effect if either of the following occurs: - - Calling `enableAudio` after muteAllRemoteAudioStreams(true). - - Calling `disableAudio` after muteAllRemoteAudioStreams(false). - - This method only works for the channel created by calling - `joinChannel`. To set whether to receive remote - audio streams for a specific channel, Agora recommends using - `autoSubscribeAudio` in the ChannelMediaOptions class. - @param mute Whether to stop receiving remote audio streams: - - true: Stop receiving any remote audio stream. - - false: (Default) Resume receiving all remote audio streams. - @return - - 0: Success. - - < 0: Failure. - */ - virtual int muteAllRemoteAudioStreams(bool mute) = 0; - - /** - * Stops or resumes receiving the audio stream of a specified user. - * - * @note - * You can call this method before or after joining a channel. If a user - * leaves a channel, the settings in this method become invalid. - * - * @param uid The ID of the specified user. - * @param mute Whether to stop receiving the audio stream of the specified user: - * - true: Stop receiving the audio stream of the specified user. - * - false: (Default) Resume receiving the audio stream of the specified user. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int muteRemoteAudioStream(uid_t uid, bool mute) = 0; - - /** - * Stops or resumes sending the local video stream. - * - * @param mute Determines whether to send or stop sending the local video stream: - * - true: Stop sending the local video stream. - * - false: (Default) Send the local video stream. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int muteLocalVideoStream(bool mute) = 0; - - /** - * Disables or re-enables the local video capture. - * - * Once you enable the video using \ref enableVideo "enableVideo", the local video is enabled - * by default. This method disables or re-enables the local video capture. - * - * `enableLocalVideo(false)` applies to scenarios when the user wants to watch the remote video - * without sending any video stream to the other user. - * - * @note - * Call this method after `enableVideo`. Otherwise, this method may not work properly. - * - * @param enabled Determines whether to disable or re-enable the local video, including - * the capturer, renderer, and sender: - * - true: (Default) Re-enable the local video. - * - false: Disable the local video. Once the local video is disabled, the remote - * users can no longer receive the video stream of this user, while this user - * can still receive the video streams of other remote users. When you set - * `enabled` as `false`, this method does not require a local camera. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableLocalVideo(bool enabled) = 0; - - /** Stops or resumes receiving all remote video streams. - - This method works for all remote users that join or will join a channel - using the `joinChannel` method. It is - equivalent to the `autoSubscribeVideo` member in the ChannelMediaOptions - class. - - Ensure that you call this method after joining a channel. - - If you call muteAllRemoteVideoStreams(true) after joining a channel, the - local use stops receiving any video stream from any user in the channel, - including any user who joins the channel after you call this method. - - If you call muteAllRemoteVideoStreams(true) after leaving a channel, - the local user does not receive any video stream the next time the user - joins a channel. - - After you successfully call muteAllRemoteVideoStreams(true), you can take - the following actions: - - To resume receiving all remote video streams, call - muteAllRemoteVideoStreams(false). - - To resume receiving the video stream of a specified user, call - muteRemoteVideoStream(uid, false), where uid is the ID of the user whose - video stream you want to resume receiving. - - @note - - The result of calling this method is affected by calling - \ref IRtcEngine::enableVideo "enableVideo" and - \ref IRtcEngine::disableVideo "disableVideo". Settings in - muteAllRemoteVideoStreams stop taking effect if either of the following occurs: - - Calling `enableVideo` after muteAllRemoteVideoStreams(true). - - Calling `disableVideo` after muteAllRemoteVideoStreams(false). - - This method only works for the channel created by calling `joinChannel`. - To set whether to receive remote audio streams for a specific channel, Agora - recommends using `autoSubscribeVideo` in the ChannelMediaOptions class. - @param mute Whether to stop receiving remote video streams: - - true: Stop receiving any remote video stream. - - false: (Default) Resume receiving all remote video streams. - @return - - 0: Success. - - < 0: Failure. - */ - virtual int muteAllRemoteVideoStreams(bool mute) = 0; - - /** - * Sets the default stream type of the remote video if the remote user has enabled dual-stream. - * - * @param streamType Sets the default video stream type: #VIDEO_STREAM_TYPE. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setRemoteDefaultVideoStreamType(VIDEO_STREAM_TYPE streamType) = 0; - - /** - * Stops or resumes receiving the video stream of a specified user. - * - * @note - * You can call this method before or after joining a channel. If a user - * leaves a channel, the settings in this method become invalid. - * - * @param uid The ID of the specified user. - * @param mute Whether to stop receiving the video stream of the specified user: - * - true: Stop receiving the video stream of the specified user. - * - false: (Default) Resume receiving the video stream of the specified user. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int muteRemoteVideoStream(uid_t uid, bool mute) = 0; - - /** - * Sets the remote video stream type. - * - * If the remote user has enabled the dual-stream mode, by default the SDK receives the high-stream video by - * Call this method to switch to the low-stream video. - * - * @note - * This method applies to scenarios where the remote user has enabled the dual-stream mode using - * \ref enableDualStreamMode "enableDualStreamMode"(true) before joining the channel. - * - * @param uid ID of the remote user sending the video stream. - * @param streamType Sets the video stream type: #VIDEO_STREAM_TYPE. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setRemoteVideoStreamType(uid_t uid, VIDEO_STREAM_TYPE streamType) = 0; - - /** - * Sets the remote video subscription options - * - * - * @param uid ID of the remote user sending the video stream. - * @param options Sets the video subscription options. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setRemoteVideoSubscriptionOptions(uid_t uid, const VideoSubscriptionOptions &options) = 0; - - /** - * Sets the blocklist of subscribe remote stream audio. - * - * @param uidList The id list of users whose audio you do not want to subscribe to. - * @param uidNumber The number of uid in uidList. - * - * @note - * If uid is in uidList, the remote user's audio will not be subscribed, - * even if muteRemoteAudioStream(uid, false) and muteAllRemoteAudioStreams(false) are operated. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setSubscribeAudioBlocklist(uid_t* uidList, int uidNumber) = 0; - - /** - * Sets the allowlist of subscribe remote stream audio. - * - * @param uidList The id list of users whose audio you want to subscribe to. - * @param uidNumber The number of uid in uidList. - * - * @note - * If uid is in uidList, the remote user's audio will be subscribed, - * even if muteRemoteAudioStream(uid, true) and muteAllRemoteAudioStreams(true) are operated. - * - * If a user is in the blocklist and allowlist at the same time, only the blocklist takes effect. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setSubscribeAudioAllowlist(uid_t* uidList, int uidNumber) = 0; - - /** - * Sets the blocklist of subscribe remote stream video. - * - * @param uidList The id list of users whose video you do not want to subscribe to. - * @param uidNumber The number of uid in uidList. - * - * @note - * If uid is in uidList, the remote user's video will not be subscribed, - * even if muteRemoteVideoStream(uid, false) and muteAllRemoteVideoStreams(false) are operated. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setSubscribeVideoBlocklist(uid_t* uidList, int uidNumber) = 0; - - /** - * Sets the allowlist of subscribe remote stream video. - * - * @param uidList The id list of users whose video you want to subscribe to. - * @param uidNumber The number of uid in uidList. - * - * @note - * If uid is in uidList, the remote user's video will be subscribed, - * even if muteRemoteVideoStream(uid, true) and muteAllRemoteVideoStreams(true) are operated. - * - * If a user is in the blocklist and allowlist at the same time, only the blocklist takes effect. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setSubscribeVideoAllowlist(uid_t* uidList, int uidNumber) = 0; - - /** - * Enables the `onAudioVolumeIndication` callback to report on which users are speaking - * and the speakers' volume. - * - * Once the \ref IRtcEngineEventHandler::onAudioVolumeIndication "onAudioVolumeIndication" - * callback is enabled, the SDK returns the volume indication in the at the time interval set - * in `enableAudioVolumeIndication`, regardless of whether any user is speaking in the channel. - * - * @param interval Sets the time interval between two consecutive volume indications: - * - <= 0: Disables the volume indication. - * - > 0: Time interval (ms) between two consecutive volume indications, - * and should be integral multiple of 200 (less than 200 will be set to 200). - * @param smooth The smoothing factor that sets the sensitivity of the audio volume - * indicator. The value range is [0, 10]. The greater the value, the more sensitive the - * indicator. The recommended value is 3. - * @param reportVad - * - `true`: Enable the voice activity detection of the local user. Once it is enabled, the `vad` parameter of the - * `onAudioVolumeIndication` callback reports the voice activity status of the local user. - * - `false`: (Default) Disable the voice activity detection of the local user. Once it is disabled, the `vad` parameter - * of the `onAudioVolumeIndication` callback does not report the voice activity status of the local user, except for - * the scenario where the engine automatically detects the voice activity of the local user. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableAudioVolumeIndication(int interval, int smooth, bool reportVad) = 0; - - /** Starts an audio recording. - - The SDK allows recording during a call, which supports either one of the - following two formats: - - - .wav: Large file size with high sound fidelity - - .aac: Small file size with low sound fidelity - - Ensure that the directory to save the recording file exists and is writable. - This method is usually called after the joinChannel() method. - The recording automatically stops when the leaveChannel() method is - called. - - @param filePath Full file path of the recording file. The string of the file - name is in UTF-8 code. - @param quality Sets the audio recording quality: #AUDIO_RECORDING_QUALITY_TYPE. - @return - - 0: Success. - - < 0: Failure. - */ - virtual int startAudioRecording(const char* filePath, - AUDIO_RECORDING_QUALITY_TYPE quality) = 0; - /** Starts an audio recording. - - The SDK allows recording during a call, which supports either one of the - following two formats: - - - .wav: Large file size with high sound fidelity - - .aac: Small file size with low sound fidelity - - Ensure that the directory to save the recording file exists and is writable. - This method is usually called after the joinChannel() method. - The recording automatically stops when the leaveChannel() method is - called. - - @param filePath Full file path of the recording file. The string of the file - name is in UTF-8 code. - @param sampleRate Sample rate, value should be 16000, 32000, 44100, or 48000. - @param quality Sets the audio recording quality: #AUDIO_RECORDING_QUALITY_TYPE. - @return - - 0: Success. - - < 0: Failure. - */ - virtual int startAudioRecording(const char* filePath, - int sampleRate, - AUDIO_RECORDING_QUALITY_TYPE quality) = 0; - - /** Starts an audio recording. - - The SDK allows recording during a call, which supports either one of the - following two formats: - - - .wav: Large file size with high sound fidelity - - .aac: Small file size with low sound fidelity - - Ensure that the directory to save the recording file exists and is writable. - This method is usually called after the joinChannel() method. - The recording automatically stops when the leaveChannel() method is - called. - - @param config Audio recording config. - @return - - 0: Success. - - < 0: Failure. - */ - virtual int startAudioRecording(const AudioRecordingConfiguration& config) = 0; - - /** register encoded audio frame observer - @return - - 0: Success. - - < 0: Failure. - */ - virtual int registerAudioEncodedFrameObserver(const AudioEncodedFrameObserverConfig& config, IAudioEncodedFrameObserver *observer) = 0; - - /** Stops the audio recording on the client. - - The recording automatically stops when the leaveChannel() method is called. - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int stopAudioRecording() = 0; - - /** - * Creates a media player source object and return its pointer. If full featured - * media player source is supported, it will create it, or it will create a simple - * media player. - * - * @return - * - The pointer to \ref rtc::IMediaPlayerSource "IMediaPlayerSource", - * if the method call succeeds. - * - The empty pointer NULL, if the method call fails. - */ - virtual agora_refptr createMediaPlayer() = 0; - - /** - * Destroy a media player source instance. - * If a media player source instance is destroyed, the video and audio of it cannot - * be published. - * - * @param media_player The pointer to \ref rtc::IMediaPlayerSource. - * - * @return - * - >0: The id of media player source instance. - * - < 0: Failure. - */ - virtual int destroyMediaPlayer(agora_refptr media_player) = 0; - - /** - * Creates a media recorder object and return its pointer. - * - * @param info The RecorderStreamInfo object. It contains the user ID and the channel name. - * - * @return - * - The pointer to \ref rtc::IMediaRecorder "IMediaRecorder", - * if the method call succeeds. - * - The empty pointer NULL, if the method call fails. - */ - virtual agora_refptr createMediaRecorder(const RecorderStreamInfo& info) = 0; - - /** - * Destroy a media recorder object. - * - * @param mediaRecorder The pointer to \ref rtc::IMediaRecorder. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int destroyMediaRecorder(agora_refptr mediaRecorder) = 0; - - /** Starts playing and mixing the music file. - - This method mixes the specified local audio file with the audio stream from - the microphone. You can choose whether the other user can hear the local - audio playback and specify the number of playback loops. This method also - supports online music playback. - - After calling this method successfully, the SDK triggers the - - \ref IRtcEngineEventHandler::onAudioMixingStateChanged "onAudioMixingStateChanged" (PLAY) - callback on the local client. - When the audio mixing file playback finishes after calling this method, the - SDK triggers the - \ref IRtcEngineEventHandler::onAudioMixingStateChanged "onAudioMixingStateChanged" (STOPPED) - callback on the local client. - - @note - - Call this method after joining a channel, otherwise issues may occur. - - If the local audio mixing file does not exist, or if the SDK does not - support the file format or cannot access the music file URL, the SDK returns - #WARN_AUDIO_MIXING_OPEN_ERROR (701). - - If you want to play an online music file, ensure that the time interval - between calling this method is more than 100 ms, or the - `AUDIO_MIXING_ERROR_TOO_FREQUENT_CALL(702)` error code occurs. - - @param filePath Pointer to the absolute path (including the suffixes of the - filename) of the local or online audio file to mix, for example, c:/music/au - dio.mp4. Supported audio formats: 3GP, ASF, ADTS, AVI, MP3, MP4, MPEG-4, - SAMI, and WAVE. - @param loopback Sets which user can hear the audio mixing: - - true: Only the local user can hear the audio mixing. - - false: Both users can hear the audio mixing. - - @param cycle Sets the number of playback loops: - - Positive integer: Number of playback loops. - - `-1`: Infinite playback loops. - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int startAudioMixing(const char* filePath, bool loopback, int cycle) = 0; - - /** Starts playing and mixing the music file. - - This method mixes the specified local audio file with the audio stream from - the microphone. You can choose whether the other user can hear the local - audio playback and specify the number of playback loops. This method also - supports online music playback. - - After calling this method successfully, the SDK triggers the - - \ref IRtcEngineEventHandler::onAudioMixingStateChanged "onAudioMixingStateChanged" (PLAY) - callback on the local client. - When the audio mixing file playback finishes after calling this method, the - SDK triggers the - \ref IRtcEngineEventHandler::onAudioMixingStateChanged "onAudioMixingStateChanged" (STOPPED) - callback on the local client. - - @note - - Call this method after joining a channel, otherwise issues may occur. - - If the local audio mixing file does not exist, or if the SDK does not - support the file format or cannot access the music file URL, the SDK returns - #WARN_AUDIO_MIXING_OPEN_ERROR (701). - - If you want to play an online music file, ensure that the time interval - between calling this method is more than 100 ms, or the - `AUDIO_MIXING_ERROR_TOO_FREQUENT_CALL(702)` error code occurs. - - @param filePath Pointer to the absolute path (including the suffixes of the - filename) of the local or online audio file to mix, for example, c:/music/au - dio.mp4. Supported audio formats: 3GP, ASF, ADTS, AVI, MP3, MP4, MPEG-4, - SAMI, and WAVE. - @param loopback Sets which user can hear the audio mixing: - - true: Only the local user can hear the audio mixing. - - false: Both users can hear the audio mixing. - - @param cycle Sets the number of playback loops: - - Positive integer: Number of playback loops. - - `-1`: Infinite playback loops. - - @param startPos The playback position (ms) of the music file. - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int startAudioMixing(const char* filePath, bool loopback, int cycle, int startPos) = 0; - - /** Stops playing and mixing the music file. - - Call this method when you are in a channel. - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int stopAudioMixing() = 0; - - /** Pauses playing and mixing the music file. - - Call this method when you are in a channel. - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int pauseAudioMixing() = 0; - - /** Resumes playing and mixing the music file. - - Call this method when you are in a channel. - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int resumeAudioMixing() = 0; - - /** Select audio track for the music file. - - Call this method when you are in a channel. - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int selectAudioTrack(int index) = 0; - /** Get audio track count of the music file. - - Call this method when you are in a channel. - - @return - - ≥ 0: Audio track count of the music file, if the method call is successful. - - < 0: Failure. - */ - virtual int getAudioTrackCount() = 0; - - /** Adjusts the volume during audio mixing. - - Call this method when you are in a channel. - - @note This method does not affect the volume of audio effect file playback - invoked by the \ref IRtcEngine::playEffect "playEffect" method. - - @param volume The audio mixing volume. The value ranges between 0 and 100 - (default). - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int adjustAudioMixingVolume(int volume) = 0; - - /** Adjusts the audio mixing volume for publishing (for remote users). - @note Call this method when you are in a channel. - @param volume Audio mixing volume for publishing. The value ranges between 0 and 100 (default). - @return - - 0: Success. - - < 0: Failure. - */ - virtual int adjustAudioMixingPublishVolume(int volume) = 0; - - /** Retrieves the audio mixing volume for publishing. - This method helps troubleshoot audio volume related issues. - @note Call this method when you are in a channel. - @return - - ≥ 0: The audio mixing volume for publishing, if this method call succeeds. The value range is [0,100]. - - < 0: Failure. - */ - virtual int getAudioMixingPublishVolume() = 0; - - /** Adjusts the audio mixing volume for local playback. - @note Call this method when you are in a channel. - @param volume Audio mixing volume for local playback. The value ranges between 0 and 100 (default). - @return - - 0: Success. - - < 0: Failure. - */ - virtual int adjustAudioMixingPlayoutVolume(int volume) = 0; - - /** Retrieves the audio mixing volume for local playback. - This method helps troubleshoot audio volume related issues. - @note Call this method when you are in a channel. - @return - - ≥ 0: The audio mixing volume, if this method call succeeds. The value range is [0,100]. - - < 0: Failure. - */ - virtual int getAudioMixingPlayoutVolume() = 0; - - /** Gets the duration (ms) of the music file. - - Call this API when you are in a channel. - - @return - - Returns the audio mixing duration, if the method call is successful. - - < 0: Failure. - */ - virtual int getAudioMixingDuration() = 0; - - /** Gets the playback position (ms) of the music file. - - Call this method when you are in a channel. - - @return - - ≥ 0: The current playback position of the audio mixing, if this method - call succeeds. - - < 0: Failure. - */ - virtual int getAudioMixingCurrentPosition() = 0; - - /** Sets the playback position of the music file to a different starting - position (the default plays from the beginning). - - @param pos The playback starting position (ms) of the audio mixing file. - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int setAudioMixingPosition(int pos /*in ms*/) = 0; - - /** In dual-channel music files, different audio data can be stored on the left and right channels. - * According to actual needs, you can set the channel mode as the original mode, - * the left channel mode, the right channel mode or the mixed mode - - @param mode The mode of channel mode - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int setAudioMixingDualMonoMode(media::AUDIO_MIXING_DUAL_MONO_MODE mode) = 0; - - /** Sets the pitch of the local music file. - * - * When a local music file is mixed with a local human voice, call this method to set the pitch of the local music file only. - * - * @note Call this method after calling \ref IRtcEngine::startAudioMixing "startAudioMixing" and - * receiving the \ref IRtcEngineEventHandler::onAudioMixingStateChanged "onAudioMixingStateChanged" (AUDIO_MIXING_STATE_PLAYING) callback. - * - * @param pitch Sets the pitch of the local music file by chromatic scale. The default value is 0, - * which means keeping the original pitch. The value ranges from -12 to 12, and the pitch value between - * consecutive values is a chromatic value. The greater the absolute value of this parameter, the - * higher or lower the pitch of the local music file. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setAudioMixingPitch(int pitch) = 0; - - /** - * Sets the playback speed of the current music file. - * - * @note Call this method after calling \ref IRtcEngine::startAudioMixing(const char*,bool,bool,int,int) "startAudioMixing" [2/2] - * and receiving the \ref IRtcEngineEventHandler::onAudioMixingStateChanged "onAudioMixingStateChanged" (AUDIO_MIXING_STATE_PLAYING) callback. - * - * @param speed The playback speed. Agora recommends that you limit this value to between 50 and 400, defined as follows: - * - 50: Half the original speed. - * - 100: The original speed. - * - 400: 4 times the original speed. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setAudioMixingPlaybackSpeed(int speed) = 0; - - /** - * Gets the volume of audio effects. - * - * @return - * - ≥ 0: The volume of audio effects. The value ranges between 0 and 100 (original volume). - * - < 0: Failure. - */ - virtual int getEffectsVolume() = 0; - /** Sets the volume of audio effects. - * - * @param volume The volume of audio effects. The value ranges between 0 - * and 100 (original volume). - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setEffectsVolume(int volume) = 0; - /** Preloads a specified audio effect. - * - * This method preloads only one specified audio effect into the memory each time - * it is called. To preload multiple audio effects, call this method multiple times. - * - * After preloading, you can call \ref IRtcEngine::playEffect "playEffect" - * to play the preloaded audio effect or call - * \ref IRtcEngine::playAllEffects "playAllEffects" to play all the preloaded - * audio effects. - * - * @note - * - To ensure smooth communication, limit the size of the audio effect file. - * - Agora recommends calling this method before joining the channel. - * - * @param soundId The ID of the audio effect. - * @param filePath The absolute path of the local audio effect file or the URL - * of the online audio effect file. Supported audio formats: mp3, mp4, m4a, aac, - * 3gp, mkv, and wav. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int preloadEffect(int soundId, const char* filePath, int startPos = 0) = 0; - /** Plays a specified audio effect. - * - * After calling \ref IRtcEngine::preloadEffect "preloadEffect", you can call - * this method to play the specified audio effect for all users in - * the channel. - * - * This method plays only one specified audio effect each time it is called. - * To play multiple audio effects, call this method multiple times. - * - * @note - * - Agora recommends playing no more than three audio effects at the same time. - * - The ID and file path of the audio effect in this method must be the same - * as that in the \ref IRtcEngine::preloadEffect "preloadEffect" method. - * - * @param soundId The ID of the audio effect. - * @param filePath The absolute path of the local audio effect file or the URL - * of the online audio effect file. Supported audio formats: mp3, mp4, m4a, aac, - * 3gp, mkv, and wav. - * @param loopCount The number of times the audio effect loops: - * - `-1`: Play the audio effect in an indefinite loop until - * \ref IRtcEngine::stopEffect "stopEffect" or - * \ref IRtcEngine::stopAllEffects "stopAllEffects" - * - `0`: Play the audio effect once. - * - `1`: Play the audio effect twice. - * @param pitch The pitch of the audio effect. The value ranges between 0.5 and 2.0. - * The default value is `1.0` (original pitch). The lower the value, the lower the pitch. - * @param pan The spatial position of the audio effect. The value ranges between -1.0 and 1.0: - * - `-1.0`: The audio effect displays to the left. - * - `0.0`: The audio effect displays ahead. - * - `1.0`: The audio effect displays to the right. - * @param gain The volume of the audio effect. The value ranges between 0 and 100. - * The default value is `100` (original volume). The lower the value, the lower - * the volume of the audio effect. - * @param publish Sets whether to publish the audio effect to the remote: - * - true: Publish the audio effect to the remote. - * - false: (Default) Do not publish the audio effect to the remote. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int playEffect(int soundId, const char* filePath, int loopCount, double pitch, double pan, int gain, bool publish = false, int startPos = 0) = 0; - /** Plays all audio effects. - * - * After calling \ref IRtcEngine::preloadEffect "preloadEffect" multiple times - * to preload multiple audio effects into the memory, you can call this - * method to play all the specified audio effects for all users in - * the channel. - * - * @param loopCount The number of times the audio effect loops: - * - `-1`: Play the audio effect in an indefinite loop until - * \ref IRtcEngine::stopEffect "stopEffect" or - * \ref IRtcEngine::stopAllEffects "stopAllEffects" - * - `0`: Play the audio effect once. - * - `1`: Play the audio effect twice. - * @param pitch The pitch of the audio effect. The value ranges between 0.5 and 2.0. - * The default value is `1.0` (original pitch). The lower the value, the lower the pitch. - * @param pan The spatial position of the audio effect. The value ranges between -1.0 and 1.0: - * - `-1.0`: The audio effect displays to the left. - * - `0.0`: The audio effect displays ahead. - * - `1.0`: The audio effect displays to the right. - * @param gain The volume of the audio effect. The value ranges between 0 and 100. - * The default value is `100` (original volume). The lower the value, the lower - * the volume of the audio effect. - * @param publish Sets whether to publish the audio effect to the remote: - * - true: Publish the audio effect to the remote. - * - false: (Default) Do not publish the audio effect to the remote. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int playAllEffects(int loopCount, double pitch, double pan, int gain, bool publish = false) = 0; - - /** Gets the volume of the specified audio effect. - * - * @param soundId The ID of the audio effect. - * - * @return - * - ≥ 0: The volume of the specified audio effect. The value ranges - * between 0 and 100 (original volume). - * - < 0: Failure. - */ - virtual int getVolumeOfEffect(int soundId) = 0; - - /** Sets the volume of the specified audio effect. - * - * @param soundId The ID of the audio effect. - * @param volume The volume of the specified audio effect. The value ranges - * between 0 and 100 (original volume). - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setVolumeOfEffect(int soundId, int volume) = 0; - /** Pauses playing the specified audio effect. - * - * @param soundId The ID of the audio effect. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int pauseEffect(int soundId) = 0; - /** Pauses playing audio effects. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int pauseAllEffects() = 0; - /** Resumes playing the specified audio effect. - * - * @param soundId The ID of the audio effect. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int resumeEffect(int soundId) = 0; - /** Resumes playing audio effects. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int resumeAllEffects() = 0; - /** Stops playing the specified audio effect. - * - * @param soundId The ID of the audio effect. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int stopEffect(int soundId) = 0; - /** Stops playing audio effects. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int stopAllEffects() = 0; - /** Releases the specified preloaded audio effect from the memory. - * - * @param soundId The ID of the audio effect. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unloadEffect(int soundId) = 0; - /** Releases preloaded audio effects from the memory. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unloadAllEffects() = 0; - /** - * Gets the duration of the audio effect file. - * @note - * - Call this method after joining a channel. - * - For the audio file formats supported by this method, see [What formats of audio files does the Agora RTC SDK support](https://docs.agora.io/en/faq/audio_format). - * - * @param filePath The absolute path or URL address (including the filename extensions) - * of the music file. For example: `C:\music\audio.mp4`. - * When you access a local file on Android, Agora recommends passing a URI address or the path starts - * with `/assets/` in this parameter. - * - * @return - * - ≥ 0: A successful method call. Returns the total duration (ms) of - * the specified audio effect file. - * - < 0: Failure. - * - `-22(ERR_RESOURCE_LIMITED)`: Cannot find the audio effect file. Please - * set a correct `filePath`. - */ - virtual int getEffectDuration(const char* filePath) = 0; - /** - * Sets the playback position of an audio effect file. - * After a successful setting, the local audio effect file starts playing at the specified position. - * - * @note Call this method after \ref IRtcEngine::playEffect(int,const char*,int,double,double,int,bool,int) "playEffect" . - * - * @param soundId Audio effect ID. Ensure that this parameter is set to the - * same value as in \ref IRtcEngine::playEffect(int,const char*,int,double,double,int,bool,int) "playEffect" . - * @param pos The playback position (ms) of the audio effect file. - * - * @return - * - 0: Success. - * - < 0: Failure. - * - `-22(ERR_RESOURCE_LIMITED)`: Cannot find the audio effect file. Please - * set a correct `soundId`. - */ - virtual int setEffectPosition(int soundId, int pos) = 0; - /** - * Gets the playback position of the audio effect file. - * @note Call this method after \ref IRtcEngine::playEffect(int,const char*,int,double,double,int,bool,int) "playEffect" . - * - * @param soundId Audio effect ID. Ensure that this parameter is set to the - * same value as in \ref IRtcEngine::playEffect(int,const char*,int,double,double,int,bool,int) "playEffect" . - * - * @return - * - ≥ 0: A successful method call. Returns the playback position (ms) of - * the specified audio effect file. - * - < 0: Failure. - * - `-22(ERR_RESOURCE_LIMITED)`: Cannot find the audio effect file. Please - * set a correct `soundId`. - */ - virtual int getEffectCurrentPosition(int soundId) = 0; - /** Enables/Disables stereo panning for remote users. - - Ensure that you call this method before joinChannel to enable stereo panning for remote users so that the local user can track the position of a remote user by calling \ref agora::rtc::IRtcEngine::setRemoteVoicePosition "setRemoteVoicePosition". - - @param enabled Sets whether or not to enable stereo panning for remote users: - - true: enables stereo panning. - - false: disables stereo panning. - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int enableSoundPositionIndication(bool enabled) = 0; - - /** Sets the sound position and gain of a remote user. - - When the local user calls this method to set the sound position of a remote user, the sound difference between the left and right channels allows the local user to track the real-time position of the remote user, creating a real sense of space. This method applies to massively multiplayer online games, such as Battle Royale games. - - @note - - For this method to work, enable stereo panning for remote users by calling the \ref agora::rtc::IRtcEngine::enableSoundPositionIndication "enableSoundPositionIndication" method before joining a channel. - - This method requires hardware support. For the best sound positioning, we recommend using a wired headset. - - Ensure that you call this method after joining a channel. - - @param uid The ID of the remote user. - @param pan The sound position of the remote user. The value ranges from -1.0 to 1.0: - - 0.0: the remote sound comes from the front. - - -1.0: the remote sound comes from the left. - - 1.0: the remote sound comes from the right. - @param gain Gain of the remote user. The value ranges from 0.0 to 100.0. The default value is 100.0 (the original gain of the remote user). The smaller the value, the less the gain. - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int setRemoteVoicePosition(uid_t uid, double pan, double gain) = 0; - - /** enable spatial audio - - @param enabled enable/disable spatial audio: - - true: enable spatial audio. - - false: disable spatial audio. - @return - - 0: Success. - - < 0: Failure. - */ - virtual int enableSpatialAudio(bool enabled) = 0; - - /** Sets remote user parameters for spatial audio - - @param uid The ID of the remote user. - @param param spatial audio parameters: SpatialAudioParams. - - @return int - - 0: Success. - - < 0: Failure. - */ - virtual int setRemoteUserSpatialAudioParams(uid_t uid, const agora::SpatialAudioParams& params) = 0; - - /** Sets an SDK preset voice beautifier effect. - * - * Call this method to set an SDK preset voice beautifier effect for the local user who sends an - * audio stream. After setting a voice beautifier effect, all users in the channel can hear the - * effect. - * - * You can set different voice beautifier effects for different scenarios. See *Set the Voice - * Beautifier and Audio Effects*. - * - * To achieve better audio effect quality, Agora recommends calling \ref - * IRtcEngine::setAudioProfile "setAudioProfile" and setting the `scenario` parameter to - * `AUDIO_SCENARIO_GAME_STREAMING(3)` and the `profile` parameter to - * `AUDIO_PROFILE_MUSIC_HIGH_QUALITY(4)` or `AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO(5)` before - * calling this method. - * - * @note - * - You can call this method either before or after joining a channel. - * - Do not set the `profile` parameter of \ref IRtcEngine::setAudioProfile "setAudioProfile" to - * `AUDIO_PROFILE_SPEECH_STANDARD(1)` or `AUDIO_PROFILE_IOT(6)`; otherwise, this method call - * fails. - * - This method works best with the human voice. Agora does not recommend using this method for - * audio containing music. - * - After calling this method, Agora recommends not calling the following methods, because they - * can override \ref IRtcEngine::setAudioEffectParameters "setAudioEffectParameters": - * - \ref IRtcEngine::setAudioEffectPreset "setAudioEffectPreset" - * - \ref IRtcEngine::setVoiceBeautifierPreset "setVoiceBeautifierPreset" - * - \ref IRtcEngine::setLocalVoicePitch "setLocalVoicePitch" - * - \ref IRtcEngine::setLocalVoiceEqualization "setLocalVoiceEqualization" - * - \ref IRtcEngine::setLocalVoiceReverb "setLocalVoiceReverb" - * - \ref IRtcEngine::setVoiceBeautifierParameters "setVoiceBeautifierParameters" - * - * @param preset The options for SDK preset voice beautifier effects: #VOICE_BEAUTIFIER_PRESET. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setVoiceBeautifierPreset(VOICE_BEAUTIFIER_PRESET preset) = 0; - - /** Sets an SDK preset audio effect. - * - * Call this method to set an SDK preset audio effect for the local user who sends an audio - * stream. This audio effect does not change the gender characteristics of the original voice. - * After setting an audio effect, all users in the channel can hear the effect. - * - * You can set different audio effects for different scenarios. See *Set the Voice Beautifier and - * Audio Effects*. - * - * To achieve better audio effect quality, Agora recommends calling \ref - * IRtcEngine::setAudioProfile "setAudioProfile" and setting the `scenario` parameter to - * `AUDIO_SCENARIO_GAME_STREAMING(3)` before calling this method. - * - * @note - * - You can call this method either before or after joining a channel. - * - Do not set the profile `parameter` of `setAudioProfile` to `AUDIO_PROFILE_SPEECH_STANDARD(1)` - * or `AUDIO_PROFILE_IOT(6)`; otherwise, this method call fails. - * - This method works best with the human voice. Agora does not recommend using this method for - * audio containing music. - * - If you call this method and set the `preset` parameter to enumerators except - * `ROOM_ACOUSTICS_3D_VOICE` or `PITCH_CORRECTION`, do not call \ref - * IRtcEngine::setAudioEffectParameters "setAudioEffectParameters"; otherwise, - * `setAudioEffectParameters` overrides this method. - * - After calling this method, Agora recommends not calling the following methods, because they - * can override `setAudioEffectPreset`: - * - \ref IRtcEngine::setVoiceBeautifierPreset "setVoiceBeautifierPreset" - * - \ref IRtcEngine::setLocalVoicePitch "setLocalVoicePitch" - * - \ref IRtcEngine::setLocalVoiceEqualization "setLocalVoiceEqualization" - * - \ref IRtcEngine::setLocalVoiceReverb "setLocalVoiceReverb" - * - \ref IRtcEngine::setVoiceBeautifierParameters "setVoiceBeautifierParameters" - * - * @param preset The options for SDK preset audio effects. See #AUDIO_EFFECT_PRESET. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setAudioEffectPreset(AUDIO_EFFECT_PRESET preset) = 0; - - /** Sets an SDK preset voice conversion. - * - * Call this method to set an SDK preset voice conversion for the local user who sends an audio - * stream. After setting an voice conversion, all users in the channel can hear the effect. - * - * You can set different voice conversion for different scenarios. See *Set the Voice Beautifier and - * Audio Effects*. - * - * To achieve better voice conversion quality, Agora recommends calling \ref - * IRtcEngine::setAudioProfile "setAudioProfile" and setting the `scenario` parameter to - * `AUDIO_SCENARIO_GAME_STREAMING(3)` before calling this method. - * - * @note - * - You can call this method either before or after joining a channel. - * - Do not set the profile `parameter` of `setAudioProfile` to `AUDIO_PROFILE_SPEECH_STANDARD(1)` - * or `AUDIO_PROFILE_IOT(6)`; otherwise, this method call fails. - * - This method works best with the human voice. Agora does not recommend using this method for - * audio containing music. - * - If you call this method and set the `preset` parameter to enumerators, - * - After calling this method, Agora recommends not calling the following methods, because they - * can override `setVoiceConversionPreset`: - * - \ref IRtcEngine::setVoiceBeautifierPreset "setVoiceBeautifierPreset" - * - \ref IRtcEngine::setAudioEffectPreset "setAudioEffectPreset" - * - \ref IRtcEngine::setLocalVoicePitch "setLocalVoicePitch" - * - \ref IRtcEngine::setLocalVoiceFormant "setLocalVoiceFormant" - * - \ref IRtcEngine::setLocalVoiceEqualization "setLocalVoiceEqualization" - * - \ref IRtcEngine::setLocalVoiceReverb "setLocalVoiceReverb" - * - \ref IRtcEngine::setVoiceBeautifierParameters "setVoiceBeautifierParameters" - * - \ref IRtcEngine::setAudioEffectParameters "setAudioEffectParameters" - * - * @param preset The options for SDK preset voice conversion. See #VOICE_CONVERSION_PRESET. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setVoiceConversionPreset(VOICE_CONVERSION_PRESET preset) = 0; - - /** Sets parameters for SDK preset audio effects. - * - * Call this method to set the following parameters for the local user who send an audio stream: - * - 3D voice effect: Sets the cycle period of the 3D voice effect. - * - Pitch correction effect: Sets the basic mode and tonic pitch of the pitch correction effect. - * Different songs have different modes and tonic pitches. Agora recommends bounding this method - * with interface elements to enable users to adjust the pitch correction interactively. - * - * After setting parameters, all users in the channel can hear the relevant effect. - * - * You can call this method directly or after \ref IRtcEngine::setAudioEffectPreset - * "setAudioEffectPreset". If you call this method after \ref IRtcEngine::setAudioEffectPreset - * "setAudioEffectPreset", ensure that you set the preset parameter of `setAudioEffectPreset` to - * `ROOM_ACOUSTICS_3D_VOICE` or `PITCH_CORRECTION` and then call this method to set the same - * enumerator; otherwise, this method overrides `setAudioEffectPreset`. - * - * @note - * - You can call this method either before or after joining a channel. - * - To achieve better audio effect quality, Agora recommends calling \ref - * IRtcEngine::setAudioProfile "setAudioProfile" and setting the `scenario` parameter to - * `AUDIO_SCENARIO_GAME_STREAMING(3)` before calling this method. - * - Do not set the `profile` parameter of \ref IRtcEngine::setAudioProfile "setAudioProfile" to - * `AUDIO_PROFILE_SPEECH_STANDARD(1)` or `AUDIO_PROFILE_IOT(6)`; otherwise, this method call - * fails. - * - This method works best with the human voice. Agora does not recommend using this method for - * audio containing music. - * - After calling this method, Agora recommends not calling the following methods, because they - * can override `setAudioEffectParameters`: - * - \ref IRtcEngine::setAudioEffectPreset "setAudioEffectPreset" - * - \ref IRtcEngine::setVoiceBeautifierPreset "setVoiceBeautifierPreset" - * - \ref IRtcEngine::setLocalVoicePitch "setLocalVoicePitch" - * - \ref IRtcEngine::setLocalVoiceEqualization "setLocalVoiceEqualization" - * - \ref IRtcEngine::setLocalVoiceReverb "setLocalVoiceReverb" - * - \ref IRtcEngine::setVoiceBeautifierParameters "setVoiceBeautifierParameters" - * @param preset The options for SDK preset audio effects: - * - 3D voice effect: `ROOM_ACOUSTICS_3D_VOICE`. - * - Call \ref IRtcEngine::setAudioProfile "setAudioProfile" and set the `profile` parameter to - * `AUDIO_PROFILE_MUSIC_STANDARD_STEREO(3)` or `AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO(5)` before - * setting this enumerator; otherwise, the enumerator setting does not take effect. - * - If the 3D voice effect is enabled, users need to use stereo audio playback devices to hear - * the anticipated voice effect. - * - Pitch correction effect: `PITCH_CORRECTION`. To achieve better audio effect quality, Agora - * recommends calling \ref IRtcEngine::setAudioProfile "setAudioProfile" and setting the `profile` - * parameter to `AUDIO_PROFILE_MUSIC_HIGH_QUALITY(4)` or - * `AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO(5)` before setting this enumerator. - * @param param1 - * - If you set `preset` to `ROOM_ACOUSTICS_3D_VOICE`, the `param1` sets the cycle period of the - * 3D voice effect. The value range is [1,60] and the unit is a second. The default value is 10 - * seconds, indicating that the voice moves around you every 10 seconds. - * - If you set `preset` to `PITCH_CORRECTION`, `param1` sets the basic mode of the pitch - * correction effect: - * - `1`: (Default) Natural major scale. - * - `2`: Natural minor scale. - * - `3`: Japanese pentatonic scale. - * @param param2 - * - If you set `preset` to `ROOM_ACOUSTICS_3D_VOICE`, you need to set `param2` to `0`. - * - If you set `preset` to `PITCH_CORRECTION`, `param2` sets the tonic pitch of the pitch - * correction effect: - * - `1`: A - * - `2`: A# - * - `3`: B - * - `4`: (Default) C - * - `5`: C# - * - `6`: D - * - `7`: D# - * - `8`: E - * - `9`: F - * - `10`: F# - * - `11`: G - * - `12`: G# - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setAudioEffectParameters(AUDIO_EFFECT_PRESET preset, int param1, int param2) = 0; - - /** Sets parameters for SDK preset voice beautifier effects. - * - * Call this method to set a gender characteristic and a reverberation effect for the singing - * beautifier effect. This method sets parameters for the local user who sends an audio stream. - * - * After you call this method successfully, all users in the channel can hear the relevant effect. - * - * To achieve better audio effect quality, before you call this method, Agora recommends calling - * \ref IRtcEngine::setAudioProfile "setAudioProfile", and setting the `scenario` parameter as - * `AUDIO_SCENARIO_GAME_STREAMING(3)` and the `profile` parameter as - * `AUDIO_PROFILE_MUSIC_HIGH_QUALITY(4)` or `AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO(5)`. - * - * @note - * - You can call this method either before or after joining a channel. - * - Do not set the `profile` parameter of \ref IRtcEngine::setAudioProfile "setAudioProfile" as - * `AUDIO_PROFILE_SPEECH_STANDARD(1)` or `AUDIO_PROFILE_IOT(6)`; otherwise, this method call does - * not take effect. - * - This method works best with the human voice. Agora does not recommend using this method for - * audio containing music. - * - After you call this method, Agora recommends not calling the following methods, because they - * can override `setVoiceBeautifierParameters`: - * - \ref IRtcEngine::setAudioEffectPreset "setAudioEffectPreset" - * - \ref IRtcEngine::setAudioEffectParameters "setAudioEffectParameters" - * - \ref IRtcEngine::setVoiceBeautifierPreset "setVoiceBeautifierPreset" - * - \ref IRtcEngine::setLocalVoicePitch "setLocalVoicePitch" - * - \ref IRtcEngine::setLocalVoiceEqualization "setLocalVoiceEqualization" - * - \ref IRtcEngine::setLocalVoiceReverb "setLocalVoiceReverb" - * - * @param preset The options for SDK preset voice beautifier effects: - * - `SINGING_BEAUTIFIER`: Singing beautifier effect. - * @param param1 The gender characteristics options for the singing voice: - * - `1`: A male-sounding voice. - * - `2`: A female-sounding voice. - * @param param2 The reverberation effects options: - * - `1`: The reverberation effect sounds like singing in a small room. - * - `2`: The reverberation effect sounds like singing in a large room. - * - `3`: The reverberation effect sounds like singing in a hall. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setVoiceBeautifierParameters(VOICE_BEAUTIFIER_PRESET preset, - int param1, int param2) = 0; - - /** Set parameters for SDK preset voice conversion. - * - * @note - * - reserved interface - * - * @param preset The options for SDK preset audio effects. See #VOICE_CONVERSION_PRESET. - * @param param1 reserved. - * @param param2 reserved. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setVoiceConversionParameters(VOICE_CONVERSION_PRESET preset, - int param1, int param2) = 0; - - /** Changes the voice pitch of the local speaker. - - @param pitch The voice pitch. The value ranges between 0.5 and 2.0. The lower - the value, the lower the voice pitch. The default value is 1.0 (no change to - the local voice pitch). - - @return - - 0: Success. - - -1: Failure. - */ - virtual int setLocalVoicePitch(double pitch) = 0; - - /** Changes the voice formant ratio for local speaker. - - @param formantRatio The voice formant ratio. The value ranges between -1.0 and 1.0. - The lower the value, the deeper the sound, and the higher the value, the more it - sounds like a child. The default value is 0.0 (the local user's voice will not be changed). - - @return - - 0: Success. - - -1: Failure. - */ - virtual int setLocalVoiceFormant(double formantRatio) = 0; - - /** Sets the local voice equalization effect. - - @param bandFrequency The band frequency ranging from 0 to 9, representing the - respective 10-band center frequencies of the voice effects, including 31, 62, - 125, 500, 1k, 2k, 4k, 8k, and 16k Hz. - @param bandGain Gain of each band in dB. The value ranges from -15 to 15. The - default value is 0. - @return - - 0: Success. - - -1: Failure. - */ - virtual int setLocalVoiceEqualization(AUDIO_EQUALIZATION_BAND_FREQUENCY bandFrequency, int bandGain) = 0; - - /** Sets the local voice reverberation. - - @param reverbKey The reverberation key: #AUDIO_REVERB_TYPE. - @param value The value of the reverberation key: #AUDIO_REVERB_TYPE. - @return - - 0: Success. - - -1: Failure. - */ - virtual int setLocalVoiceReverb(AUDIO_REVERB_TYPE reverbKey, int value) = 0; - /** Sets preset audio playback effect for remote headphones after remote audio is mixed. - - @param preset The preset key: #HEADPHONE_EQUALIZER_PRESET. - - HEADPHONE_EQUALIZER_OFF = 0x00000000 : Turn off the eualizer effect for headphones. - - HEADPHONE_EQUALIZER_OVEREAR = 0x04000001 : For over-ear headphones only. - - HEADPHONE_EQUALIZER_INEAR = 0x04000002 : For in-ear headphones only. - @return - - 0: Success. - - < 0: Failure. - - -1(ERR_FAILED): A general error occurs (no specified reason). - */ - virtual int setHeadphoneEQPreset(HEADPHONE_EQUALIZER_PRESET preset) = 0; - - /** Sets the parameters of audio playback effect for remote headphones after remote audio is mixed. - - @param lowGain The higher the parameter value, the deeper the sound. The value range is [-10,10]. - @param highGain The higher the parameter value, the sharper the sound. The value range is [-10,10]. - @return - - 0: Success. - - < 0: Failure. - - -1(ERR_FAILED): A general error occurs (no specified reason). - */ - virtual int setHeadphoneEQParameters(int lowGain, int highGain) = 0; - - /** Enables or disables the voice AI tuner. - * - * @param enabled Determines whether to enable the voice AI tuner: - * - true: Enable the voice AI tuner - * - false: (default) Disable the voice AI tuner. - * - * @param type. The options for SDK voice AI tuner types. See #VOICE_AI_TUNER_TYPE. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableVoiceAITuner(bool enabled, VOICE_AI_TUNER_TYPE type) = 0; - - /** **DEPRECATED** Specifies an SDK output log file. - * - * The log file records all log data for the SDK’s operation. Ensure that the - * directory for the log file exists and is writable. - * - * @note - * Ensure that you call this method immediately after \ref initialize "initialize", - * or the output log may not be complete. - * - * @param filePath File path of the log file. The string of the log file is in UTF-8. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setLogFile(const char* filePath) = 0; - - /** - * Sets the output log filter level of the SDK. - * - * You can use one or a combination of the filters. The log filter level follows the - * sequence of `OFF`, `CRITICAL`, `ERROR`, `WARNING`, `INFO`, and `DEBUG`. Choose a filter level - * and you will see logs preceding that filter level. For example, if you set the log filter level to - * `WARNING`, you see the logs within levels `CRITICAL`, `ERROR`, and `WARNING`. - * - * @param filter The log filter level: - * - `LOG_FILTER_DEBUG(0x80f)`: Output all API logs. Set your log filter as DEBUG - * if you want to get the most complete log file. - * - `LOG_FILTER_INFO(0x0f)`: Output logs of the CRITICAL, ERROR, WARNING, and INFO - * level. We recommend setting your log filter as this level. - * - `LOG_FILTER_WARNING(0x0e)`: Output logs of the CRITICAL, ERROR, and WARNING level. - * - `LOG_FILTER_ERROR(0x0c)`: Output logs of the CRITICAL and ERROR level. - * - `LOG_FILTER_CRITICAL(0x08)`: Output logs of the CRITICAL level. - * - `LOG_FILTER_OFF(0)`: Do not output any log. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setLogFilter(unsigned int filter) = 0; - - /** - * Sets the output log level of the SDK. - * - * You can set the SDK to ouput the log files of the specified level. - * - * @param level The log level: - * - `LOG_LEVEL_NONE (0x0000)`: Do not output any log file. - * - `LOG_LEVEL_INFO (0x0001)`: (Recommended) Output log files of the INFO level. - * - `LOG_LEVEL_WARN (0x0002)`: Output log files of the WARN level. - * - `LOG_LEVEL_ERROR (0x0004)`: Output log files of the ERROR level. - * - `LOG_LEVEL_FATAL (0x0008)`: Output log files of the FATAL level. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setLogLevel(commons::LOG_LEVEL level) = 0; - - /** - * Sets the log file size (KB). - * - * The SDK has two log files, each with a default size of 512 KB. If you set - * `fileSizeInBytes` as 1024 KB, the SDK outputs log files with a total - * maximum size of 2 MB. - * If the total size of the log files exceed the set value, - * the new output log files overwrite the old output log files. - * - * @param fileSizeInKBytes The SDK log file size (KB). - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setLogFileSize(unsigned int fileSizeInKBytes) = 0; - - /** Upload current log file immediately to server. - * only use this when an error occurs - * block before log file upload success or timeout. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int uploadLogFile(agora::util::AString& requestId) = 0; - - /** * Write the log to SDK . @technical preview - * - * You can Write the log to SDK log files of the specified level. - * - * @param level The log level: - * - `LOG_LEVEL_NONE (0x0000)`: Do not output any log file. - * - `LOG_LEVEL_INFO (0x0001)`: (Recommended) Output log files of the INFO level. - * - `LOG_LEVEL_WARN (0x0002)`: Output log files of the WARN level. - * - `LOG_LEVEL_ERROR (0x0004)`: Output log files of the ERROR level. - * - `LOG_LEVEL_FATAL (0x0008)`: Output log files of the FATAL level. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int writeLog(commons::LOG_LEVEL level, const char* fmt, ...) = 0; - - /** - * Updates the display mode of the local video view. - * - * After initializing the local video view, you can call this method to update its rendering mode. - * It affects only the video view that the local user sees, not the published local video stream. - * - * @note - * - Ensure that you have called \ref setupLocalVideo "setupLocalVideo" to initialize the local video - * view before this method. - * - During a call, you can call this method as many times as necessary to update the local video view. - * - * @param renderMode Sets the local display mode. See #RENDER_MODE_TYPE. - * @param mirrorMode Sets the local mirror mode. See #VIDEO_MIRROR_MODE_TYPE. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setLocalRenderMode(media::base::RENDER_MODE_TYPE renderMode, VIDEO_MIRROR_MODE_TYPE mirrorMode) = 0; - - /** - * Updates the display mode of the video view of a remote user. - * - * After initializing the video view of a remote user, you can call this method to update its - * rendering and mirror modes. This method affects only the video view that the local user sees. - * - * @note - * - Ensure that you have called \ref setupRemoteVideo "setupRemoteVideo" to initialize the remote video - * view before calling this method. - * - During a call, you can call this method as many times as necessary to update the display mode - * of the video view of a remote user. - * - * @param uid ID of the remote user. - * @param renderMode Sets the remote display mode. See #RENDER_MODE_TYPE. - * @param mirrorMode Sets the mirror type. See #VIDEO_MIRROR_MODE_TYPE. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setRemoteRenderMode(uid_t uid, media::base::RENDER_MODE_TYPE renderMode, - VIDEO_MIRROR_MODE_TYPE mirrorMode) = 0; - - // The following APIs are either deprecated and going to deleted. - - /** - * Updates the display mode of the local video view. - * - * After initializing the local video view, you can call this method to update its rendering mode. - * It affects only the video view that the local user sees, not the published local video stream. - * - * @note - * - Ensure that you have called \ref setupLocalVideo "setupLocalVideo" to initialize the local video - * view before this method. - * - During a call, you can call this method as many times as necessary to update the local video view. - * - * @param renderMode Sets the local display mode. See #RENDER_MODE_TYPE. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setLocalRenderMode(media::base::RENDER_MODE_TYPE renderMode) __deprecated = 0; - - /** - * Sets the local video mirror mode. - * - * Use this method before calling the \ref startPreview "startPreview" method, or the mirror mode - * does not take effect until you call the `startPreview` method again. - * @param mirrorMode Sets the local video mirror mode. See #VIDEO_MIRROR_MODE_TYPE. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setLocalVideoMirrorMode(VIDEO_MIRROR_MODE_TYPE mirrorMode) __deprecated = 0; - - /** - * Enables or disables the dual video stream mode. - * - * If dual-stream mode is enabled, the subscriber can choose to receive the high-stream - * (high-resolution high-bitrate video stream) or low-stream (low-resolution low-bitrate video stream) - * video using \ref setRemoteVideoStreamType "setRemoteVideoStreamType". - * - * @param enabled - * - true: Enable the dual-stream mode. - * - false: (default) Disable the dual-stream mode. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableDualStreamMode(bool enabled) __deprecated = 0; - - /** - * Enables or disables the dual video stream mode. - * - * If dual-stream mode is enabled, the subscriber can choose to receive the high-stream - * (high-resolution high-bitrate video stream) or low-stream (low-resolution low-bitrate video stream) - * video using \ref setRemoteVideoStreamType "setRemoteVideoStreamType". - * - * @param enabled - * - true: Enable the dual-stream mode. - * - false: (default) Disable the dual-stream mode. - * @param streamConfig - * - The minor stream config - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableDualStreamMode(bool enabled, const SimulcastStreamConfig& streamConfig) __deprecated = 0; - - - /** - * Enables, disables or auto enable the dual video stream mode. - * - * If dual-stream mode is enabled, the subscriber can choose to receive the high-stream - * (high-resolution high-bitrate video stream) or low-stream (low-resolution low-bitrate video stream) - * video using \ref setRemoteVideoStreamType "setRemoteVideoStreamType". - * - * @param mode - * - The dual stream mode - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setDualStreamMode(SIMULCAST_STREAM_MODE mode) = 0; - - /** - * Sets the multi-layer video stream configuration. - * - * If multi-layer is configured, the subscriber can choose to receive the coresponding layer - * of video stream using {@link setRemoteVideoStreamType setRemoteVideoStreamType}. - * - * @param simulcastConfig - * - The configuration for multi-layer video stream. It includes seven layers, ranging from - * STREAM_LAYER_1 to STREAM_LOW. A maximum of 3 layers can be enabled simultaneously. - * - * @return - * - 0: Success. - * - < 0: Failure. - * @technical preview - */ - virtual int setSimulcastConfig(const SimulcastConfig& simulcastConfig) = 0; - - /** - * Enables, disables or auto enable the dual video stream mode. - * - * If dual-stream mode is enabled, the subscriber can choose to receive the high-stream - * (high-resolution high-bitrate video stream) or low-stream (low-resolution low-bitrate video stream) - * video using \ref setRemoteVideoStreamType "setRemoteVideoStreamType". - * - * @param mode Dual stream mode: #SIMULCAST_STREAM_MODE. - * @param streamConfig Configurations of the low stream: SimulcastStreamConfig. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setDualStreamMode(SIMULCAST_STREAM_MODE mode, const SimulcastStreamConfig& streamConfig) = 0; - - /** - * Sets the external audio track. - * - * @note - * Ensure that you call this method before joining the channel. - * - * @param trackId custom audio track id. - * @param enabled Determines whether to local playback the external audio track: - * - true: Local playback the external audio track. - * - false: Local don`t playback the external audio track. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableCustomAudioLocalPlayback(track_id_t trackId, bool enabled) = 0; - - /** - * Sets the audio recording format for the - * \ref agora::media::IAudioFrameObserver::onRecordAudioFrame "onRecordAudioFrame" callback. - * - * @param sampleRate The sample rate (Hz) of the audio data returned in the `onRecordAudioFrame` callback, which can set be - * as 8000, 16000, 32000, 44100, or 48000. - * @param channel The number of audio channels of the audio data returned in the `onRecordAudioFrame` callback, which can - * be set as 1 or 2: - * - 1: Mono. - * - 2: Stereo. - * @param mode This mode is deprecated. - * @param samplesPerCall not support. Sampling points in the called data returned in - * onRecordAudioFrame(). For example, it is usually set as 1024 for stream - * pushing. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setRecordingAudioFrameParameters(int sampleRate, int channel, - RAW_AUDIO_FRAME_OP_MODE_TYPE mode, - int samplesPerCall) = 0; - - /** - * Sets the audio playback format for the - * \ref agora::media::IAudioFrameObserver::onPlaybackAudioFrame "onPlaybackAudioFrame" callback. - * - * @param sampleRate Sets the sample rate (Hz) of the audio data returned in the `onPlaybackAudioFrame` callback, - * which can set be as 8000, 16000, 32000, 44100, or 48000. - * @param channel The number of channels of the audio data returned in the `onPlaybackAudioFrame` callback, which - * can be set as 1 or 2: - * - 1: Mono - * - 2: Stereo - * @param mode Deprecated. The use mode of the onPlaybackAudioFrame() callback: - * agora::rtc::RAW_AUDIO_FRAME_OP_MODE_TYPE. - * @param samplesPerCall not support. Sampling points in the called data returned in - * onPlaybackAudioFrame(). For example, it is usually set as 1024 for stream - * pushing. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setPlaybackAudioFrameParameters(int sampleRate, int channel, - RAW_AUDIO_FRAME_OP_MODE_TYPE mode, - int samplesPerCall) = 0; - - /** - * Sets the mixed audio format for the - * \ref agora::media::IAudioFrameObserver::onMixedAudioFrame "onMixedAudioFrame" callback. - * - * @param sampleRate The sample rate (Hz) of the audio data returned in the `onMixedAudioFrame` callback, which can set - * be as 8000, 16000, 32000, 44100, or 48000. - * @param channel The number of channels of the audio data in `onMixedAudioFrame` callback, which can be set as 1 or 2: - * - 1: Mono - * - 2: Stereo - * @param samplesPerCall not support. Sampling points in the called data returned in - * `onMixedAudioFrame`. For example, it is usually set as 1024 for stream pushing. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setMixedAudioFrameParameters(int sampleRate, int channel, int samplesPerCall) = 0; - - /** - * Sets the audio ear monitoring format for the - * \ref agora::media::IAudioFrameObserver::onEarMonitoringAudioFrame "onEarMonitoringAudioFrame" callback. - * - * @param sampleRate Sets the sample rate (Hz) of the audio data returned in the `onEarMonitoringAudioFrame` callback, - * which can set be as 8000, 16000, 32000, 44100, or 48000. - * @param channel The number of channels of the audio data returned in the `onEarMonitoringAudioFrame` callback, which - * can be set as 1 or 2: - * - 1: Mono - * - 2: Stereo - * @param mode Deprecated. The use mode of the onEarMonitoringAudioFrame() callback: - * agora::rtc::RAW_AUDIO_FRAME_OP_MODE_TYPE. - * @param samplesPerCall not support. Sampling points in the called data returned in - * onEarMonitoringAudioFrame(). For example, it is usually set as 1024 for stream - * pushing. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setEarMonitoringAudioFrameParameters(int sampleRate, int channel, - RAW_AUDIO_FRAME_OP_MODE_TYPE mode, - int samplesPerCall) = 0; - - /** - * Sets the audio playback format before mixing in the - * \ref agora::media::IAudioFrameObserver::onPlaybackAudioFrameBeforeMixing "onPlaybackAudioFrameBeforeMixing" - * callback. - * - * @param sampleRate The sample rate (Hz) of the audio data returned in - * `onPlaybackAudioFrameBeforeMixing`, which can set be as 8000, 16000, 32000, 44100, or 48000. - * @param channel Number of channels of the audio data returned in `onPlaybackAudioFrameBeforeMixing`, - * which can be set as 1 or 2: - * - 1: Mono - * - 2: Stereo - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setPlaybackAudioFrameBeforeMixingParameters(int sampleRate, int channel) = 0; - - /** - * Enable the audio spectrum monitor. - * - * @param intervalInMS Sets the time interval(ms) between two consecutive audio spectrum callback. - * The default value is 100. This param should be larger than 10. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableAudioSpectrumMonitor(int intervalInMS = 100) = 0; - /** - * Disalbe the audio spectrum monitor. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int disableAudioSpectrumMonitor() = 0; - - /** - * Registers an audio spectrum observer. - * - * You need to implement the `IAudioSpectrumObserver` class in this method, and register the following callbacks - * according to your scenario: - * - \ref agora::media::IAudioSpectrumObserver::onAudioSpectrumComputed "onAudioSpectrumComputed": Occurs when - * the SDK receives the audio data and at set intervals. - * - * @param observer A pointer to the audio spectrum observer: \ref agora::media::IAudioSpectrumObserver - * "IAudioSpectrumObserver". - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerAudioSpectrumObserver(agora::media::IAudioSpectrumObserver * observer) = 0; - /** - * Releases the audio spectrum observer. - * - * @param observer The pointer to the audio spectrum observer: \ref agora::media::IAudioSpectrumObserver - * "IAudioSpectrumObserver". - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unregisterAudioSpectrumObserver(agora::media::IAudioSpectrumObserver * observer) = 0; - - /** Adjusts the recording volume. - - @param volume The recording volume, which ranges from 0 to 400: - - - 0: Mute the recording volume. - - 100: The Original volume. - - 400: (Maximum) Four times the original volume with signal clipping - protection. - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int adjustRecordingSignalVolume(int volume) = 0; - - /** - * Mute or resume recording signal volume. - * - * @param mute Determines whether to mute or resume the recording signal volume. - * - true: Mute the recording signal volume. - * - false: (Default) Resume the recording signal volume. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int muteRecordingSignal(bool mute) = 0; - - /** Adjusts the playback volume. - - @param volume The playback volume, which ranges from 0 to 400: - - - 0: Mute the recoridng volume. - - 100: The Original volume. - - 400: (Maximum) Four times the original volume with signal clipping - protection. - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int adjustPlaybackSignalVolume(int volume) = 0; - - /* - * Adjust the playback volume of the user specified by uid. - * - * You can call this method to adjust the playback volume of the user specified by uid - * in call. If you want to adjust playback volume of the multi user, you can call this - * this method multi times. - * - * @note - * Please call this method after join channel. - * This method adjust the playback volume of specified user. - * - * @param uid Remote user ID. - * @param volume The playback volume of the specified remote user. The value ranges between 0 and 400, including the following: - * 0: Mute. - * 100: (Default) Original volume. - * 400: Four times the original volume with signal-clipping protection. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int adjustUserPlaybackSignalVolume(uid_t uid, int volume) = 0; - - /** Sets the fallback option for the published video stream based on the network conditions. - - If `option` is set as #STREAM_FALLBACK_OPTION_AUDIO_ONLY (2), the SDK will: - - - Disable the upstream video but enable audio only when the network conditions deteriorate and cannot support both video and audio. - - Re-enable the video when the network conditions improve. - - When the published video stream falls back to audio only or when the audio-only stream switches back to the video, the SDK triggers the \ref agora::rtc::IRtcEngineEventHandler::onLocalPublishFallbackToAudioOnly "onLocalPublishFallbackToAudioOnly" callback. - - @note - - Agora does not recommend using this method for CDN live streaming, because the remote CDN live user will have a noticeable lag when the published video stream falls back to audio only. - - Ensure that you call this method before joining a channel. - - @param option Sets the fallback option for the published video stream: - - #STREAM_FALLBACK_OPTION_DISABLED (0): (Default) No fallback behavior for the published video stream when the uplink network condition is poor. The stream quality is not guaranteed. - - #STREAM_FALLBACK_OPTION_AUDIO_ONLY (2): The published video stream falls back to audio only when the uplink network condition is poor. - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int setLocalPublishFallbackOption(STREAM_FALLBACK_OPTIONS option) = 0; - - /** Sets the fallback option for the remotely subscribed video stream based on the network conditions. - - The default setting for `option` is #STREAM_FALLBACK_OPTION_VIDEO_STREAM_LOW (1), where the remotely subscribed video stream falls back to the low-stream video (low resolution and low bitrate) under poor downlink network conditions. - - If `option` is set as #STREAM_FALLBACK_OPTION_AUDIO_ONLY (2), the SDK automatically switches the video from a high-stream to a low-stream, or disables the video when the downlink network conditions cannot support both audio and video to guarantee the quality of the audio. The SDK monitors the network quality and restores the video stream when the network conditions improve. - - When the remotely subscribed video stream falls back to audio only or when the audio-only stream switches back to the video stream, the SDK triggers the \ref agora::rtc::IRtcEngineEventHandler::onRemoteSubscribeFallbackToAudioOnly "onRemoteSubscribeFallbackToAudioOnly" callback. - - @note Ensure that you call this method before joining a channel. - - @param option Sets the fallback option for the remotely subscribed video stream. See #STREAM_FALLBACK_OPTIONS. - @return - - 0: Success. - - < 0: Failure. - */ - virtual int setRemoteSubscribeFallbackOption(STREAM_FALLBACK_OPTIONS option) = 0; - - /** Sets the high priority user list and their fallback level in weak network condition. - * @note - * - This method can be called before and after joining a channel. - * - If a subscriber is set to high priority, this stream only fallback to lower stream after all normal priority users fallback to their fallback level on weak network condition if needed. - * - * @param uidList The high priority user list. - * @param uidNum The size of uidList. - * @param option The fallback level of high priority users. - * - * @return int - * - 0 : Success. - * - <0 : Failure. - */ - virtual int setHighPriorityUserList(uid_t* uidList, int uidNum, STREAM_FALLBACK_OPTIONS option) = 0; - - /** - * Enable/Disable an extension. - * By calling this function, you can dynamically enable/disable the extension without changing the pipeline. - * For example, enabling/disabling Extension_A means the data will be adapted/bypassed by Extension_A. - * - * NOTE: For compatibility reasons, if you haven't call registerExtension, - * enableExtension will automatically register the specified extension. - * We suggest you call registerExtension explicitly. - * - * @param provider The name of the extension provider, e.g. agora.io. - * @param extension The name of the extension, e.g. agora.beauty. - * @param extensionInfo The information for extension. - * @param enable Whether to enable the extension: - * - true: (Default) Enable the extension. - * - false: Disable the extension. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableExtension(const char* provider, const char* extension, const ExtensionInfo& extensionInfo, bool enable = true) = 0; - - /** - * Sets the properties of an extension. - * - * @param provider The name of the extension provider, e.g. agora.io. - * @param extension The name of the extension, e.g. agora.beauty. - * @param extensionInfo The information for extension. - * @param key The key of the extension. - * @param value The JSON formatted value of the extension key. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setExtensionProperty(const char* provider, const char* extension, const ExtensionInfo& extensionInfo, const char* key, const char* value) = 0; - - /** - * Gets the properties of an extension. - * - * @param provider The name of the extension provider, e.g. agora.io. - * @param extension The name of the extension, e.g. agora.beauty. - * @param extensionInfo The information for extension. - * @param key The key of the extension. - * @param value The value of the extension key. - * @param buf_len Maximum length of the JSON string indicating the extension property. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getExtensionProperty(const char* provider, const char* extension, const ExtensionInfo& extensionInfo, const char* key, char* value, int buf_len) = 0; - - /** Enables loopback recording. - * - * If you enable loopback recording, the output of the default sound card is mixed into - * the audio stream sent to the other end. - * - * @note This method is for Windows only. - * - * @param enabled Sets whether to enable/disable loopback recording. - * - true: Enable loopback recording. - * - false: (Default) Disable loopback recording. - * @param deviceName Pointer to the device name of the sound card. The default value is NULL (the default sound card). - * - This method is for macOS and Windows only. - * - macOS does not support loopback capturing of the default sound card. If you need to use this method, - * please use a virtual sound card and pass its name to the deviceName parameter. Agora has tested and recommends using soundflower. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableLoopbackRecording(bool enabled, const char* deviceName = NULL) = 0; - - - /** Adjusts the loopback recording volume. - - @param volume The loopback volume, which ranges from 0 to 100: - - - 0: Mute the recoridng volume. - - 100: The Original volume. - protection. - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int adjustLoopbackSignalVolume(int volume) = 0; - - /** Retrieves the audio volume for recording loopback. - @note Call this method when you are in a channel. - @return - - ≥ 0: The audio volume for loopback, if this method call succeeds. The value range is [0,100]. - - < 0: Failure. - */ - virtual int getLoopbackRecordingVolume() = 0; - - /** - * Enables in-ear monitoring. - * - * @param enabled Determines whether to enable in-ear monitoring. - * - true: Enable. - * - false: (Default) Disable. - * @param includeAudioFilters The type of the ear monitoring: #EAR_MONITORING_FILTER_TYPE - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableInEarMonitoring(bool enabled, int includeAudioFilters) = 0; - - /** - * Sets the volume of the in-ear monitor. - * - * @param volume Sets the volume of the in-ear monitor. The value ranges - * between 0 and 100 (default). - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setInEarMonitoringVolume(int volume) = 0; - -#if defined(_WIN32) || defined(__linux__) || defined(__ANDROID__) - virtual int loadExtensionProvider(const char* path, bool unload_after_use = false) = 0; -#endif - - /** - * Sets the provider property of an extension. - * - * @param provider The name of the extension provider, e.g. agora.io. - * @param key The key of the extension. - * @param value The JSON formatted value of the extension key. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setExtensionProviderProperty(const char* provider, const char* key, const char* value) = 0; - - /** - * Registers an extension. Normally you should call this function immediately after engine initialization. - * Once an extension is registered, the SDK will automatically create and add it to the pipeline. - * - * @param provider The name of the extension provider, e.g. agora.io. - * @param extension The name of the extension, e.g. agora.beauty. - * @param type The source type of the extension, e.g. PRIMARY_CAMERA_SOURCE. The default is UNKNOWN_MEDIA_SOURCE. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerExtension(const char* provider, const char* extension, agora::media::MEDIA_SOURCE_TYPE type = agora::media::UNKNOWN_MEDIA_SOURCE) = 0; - - /** - * Enable/Disable an extension. - * By calling this function, you can dynamically enable/disable the extension without changing the pipeline. - * For example, enabling/disabling Extension_A means the data will be adapted/bypassed by Extension_A. - * - * NOTE: For compatibility reasons, if you haven't call registerExtension, - * enableExtension will automatically register the specified extension. - * We suggest you call registerExtension explicitly. - * - * @param provider The name of the extension provider, e.g. agora.io. - * @param extension The name of the extension, e.g. agora.beauty. - * @param enable Whether to enable the extension: - * - true: (Default) Enable the extension. - * - false: Disable the extension. - * @param type The source type of the extension, e.g. PRIMARY_CAMERA_SOURCE. The default is UNKNOWN_MEDIA_SOURCE. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableExtension(const char* provider, const char* extension, bool enable=true, agora::media::MEDIA_SOURCE_TYPE type = agora::media::UNKNOWN_MEDIA_SOURCE) = 0; - - /** - * Sets the properties of an extension. - * - * @param provider The name of the extension provider, e.g. agora.io. - * @param extension The name of the extension, e.g. agora.beauty. - * @param key The key of the extension. - * @param value The JSON formatted value of the extension key. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setExtensionProperty( - const char* provider, const char* extension, - const char* key, const char* value, agora::media::MEDIA_SOURCE_TYPE type = agora::media::UNKNOWN_MEDIA_SOURCE) = 0; - - /** - * Gets the properties of an extension. - * - * @param provider The name of the extension provider, e.g. agora.io. - * @param extension The name of the extension, e.g. agora.beauty. - * @param key The key of the extension. - * @param value The value of the extension key. - * @param buf_len Maximum length of the JSON string indicating the extension property. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getExtensionProperty( - const char* provider, const char* extension, - const char* key, char* value, int buf_len, agora::media::MEDIA_SOURCE_TYPE type = agora::media::UNKNOWN_MEDIA_SOURCE) = 0; - - /** Sets the camera capture configuration. - * @note Call this method before enabling the local camera. - * That said, you can call this method before calling \ref IRtcEngine::joinChannel "joinChannel", - * \ref IRtcEngine::enableVideo "enableVideo", or \ref IRtcEngine::enableLocalVideo "enableLocalVideo", - * depending on which method you use to turn on your local camera. - * - * @param config Sets the camera capturer configuration. See CameraCapturerConfiguration. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setCameraCapturerConfiguration(const CameraCapturerConfiguration& config) = 0; - - /** - * Get an custom video track id created by internal,which could used to publish or preview - * - * @return - * - > 0: the useable video track id. - * - < 0: Failure. - */ - virtual video_track_id_t createCustomVideoTrack() = 0; - - /** - * Get an custom encoded video track id created by internal,which could used to publish or preview - * - * @return - * - > 0: the useable video track id. - * - < 0: Failure. - */ - virtual video_track_id_t createCustomEncodedVideoTrack(const SenderOptions& sender_option) = 0; - - /** - * destroy a created custom video track id - * - * @param video_track_id The video track id which was created by createCustomVideoTrack - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int destroyCustomVideoTrack(video_track_id_t video_track_id) = 0; - - /** - * destroy a created custom encoded video track id - * - * @param video_track_id The video track id which was created by createCustomEncodedVideoTrack - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int destroyCustomEncodedVideoTrack(video_track_id_t video_track_id) = 0; - -#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) || defined(__OHOS__) - /** - * Switches between front and rear cameras. - * - * @note This method applies to Android and iOS only. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int switchCamera() = 0; - - /** - * Checks whether the camera zoom function is supported. - * - * @return - * - true: The camera zoom function is supported. - * - false: The camera zoom function is not supported. - */ - virtual bool isCameraZoomSupported() = 0; - - /** - * Checks whether the camera face detect is supported. - * - * @return - * - true: The camera face detect is supported. - * - false: The camera face detect is not supported. - */ - virtual bool isCameraFaceDetectSupported() = 0; - - /** - * Checks whether the camera flash function is supported. - * - * @return - * - true: The camera flash function is supported. - * - false: The camera flash function is not supported. - */ - virtual bool isCameraTorchSupported() = 0; - - /** - * Checks whether the camera manual focus function is supported. - * - * @return - * - true: The camera manual focus function is supported. - * - false: The camera manual focus function is not supported. - */ - virtual bool isCameraFocusSupported() = 0; - - /** - * Checks whether the camera auto focus function is supported. - * - * @return - * - true: The camera auto focus function is supported. - * - false: The camera auto focus function is not supported. - */ - virtual bool isCameraAutoFocusFaceModeSupported() = 0; - - /** - * Sets the camera zoom ratio. - * - * @param factor The camera zoom factor. It ranges from 1.0 to the maximum zoom - * supported by the camera. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setCameraZoomFactor(float factor) = 0; - - /** - * Sets the camera face detection. - * - * @param enabled The camera face detection enabled. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableFaceDetection(bool enabled) = 0; - - /** - * Gets the maximum zoom ratio supported by the camera. - * @return The maximum zoom ratio supported by the camera. - */ - virtual float getCameraMaxZoomFactor() = 0; - - /** - * Sets the manual focus position. - * - * @param positionX The horizontal coordinate of the touch point in the view. - * @param positionY The vertical coordinate of the touch point in the view. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setCameraFocusPositionInPreview(float positionX, float positionY) = 0; - - /** - * Enables the camera flash. - * - * @param isOn Determines whether to enable the camera flash. - * - true: Enable the flash. - * - false: Do not enable the flash. - */ - virtual int setCameraTorchOn(bool isOn) = 0; - - /** - * Enables the camera auto focus face function. - * - * @param enabled Determines whether to enable the camera auto focus face mode. - * - true: Enable the auto focus face function. - * - false: Do not enable the auto focus face function. - */ - virtual int setCameraAutoFocusFaceModeEnabled(bool enabled) = 0; - - /** Checks whether the camera exposure function is supported. - * - * Ensure that you call this method after the camera starts, for example, by calling `startPreview` or `joinChannel`. - * - * @since v2.3.2. - * @return - *

    - *
  • true: The device supports the camera exposure function.
  • - *
  • false: The device does not support the camera exposure function.
  • - *
- */ - virtual bool isCameraExposurePositionSupported() = 0; - - /** Sets the camera exposure position. - * - * Ensure that you call this method after the camera starts, for example, by calling `startPreview` or `joinChannel`. - * - * A successful setCameraExposurePosition method call triggers the {@link IRtcEngineEventHandler#onCameraExposureAreaChanged onCameraExposureAreaChanged} callback on the local client. - * @since v2.3.2. - * @param positionXinView The horizontal coordinate of the touch point in the view. - * @param positionYinView The vertical coordinate of the touch point in the view. - * - * @return - *
    - *
  • 0: Success.
  • - *
  • < 0: Failure.
  • - *
- */ - virtual int setCameraExposurePosition(float positionXinView, float positionYinView) = 0; - - /** - * Returns whether exposure value adjusting is supported by the current device. - * Exposure compensation is in auto exposure mode. - * @since v4.2.2 - * @note - * This method only supports Android and iOS. - * This interface returns valid values only after the device is initialized. - * - * @return - * - true: exposure value adjusting is supported. - * - false: exposure value adjusting is not supported or device is not initialized. - */ - virtual bool isCameraExposureSupported() = 0; - - /** - * Sets the camera exposure ratio. - * @since v4.2.2 - * @param factor The camera zoom factor. The recommended camera exposure factor ranging from -8.0 to 8.0 for iOS, - * and -20.0 to 20.0 for Android. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setCameraExposureFactor(float factor) = 0; - -#if defined(__APPLE__) - /** - * Checks whether the camera auto exposure function is supported. - * - * @return - * - true: The camera auto exposure function is supported. - * - false: The camera auto exposure function is not supported. - */ - virtual bool isCameraAutoExposureFaceModeSupported() = 0; - - - /** - * Enables the camera auto exposure face function. - * - * @param enabled Determines whether to enable the camera auto exposure face mode. - * - true: Enable the auto exposure face function. - * - false: Do not enable the auto exposure face function. - */ - virtual int setCameraAutoExposureFaceModeEnabled(bool enabled) = 0; - - /** - * set camera stabilization mode.If open stabilization mode, fov will be smaller and capture latency will be longer. - * - * @param mode specifies the camera stabilization mode. - */ - virtual int setCameraStabilizationMode(CAMERA_STABILIZATION_MODE mode) = 0; -#endif - - /** Sets the default audio route (for Android and iOS only). - - Most mobile phones have two audio routes: an earpiece at the top, and a - speakerphone at the bottom. The earpiece plays at a lower volume, and the - speakerphone at a higher volume. - - When setting the default audio route, you determine whether audio playback - comes through the earpiece or speakerphone when no external audio device is - connected. - - Depending on the scenario, Agora uses different default audio routes: - - Voice call: Earpiece - - Audio broadcast: Speakerphone - - Video call: Speakerphone - - Video broadcast: Speakerphone - - Call this method before, during, or after a call, to change the default - audio route. When the audio route changes, the SDK triggers the - \ref IRtcEngineEventHandler::onAudioRoutingChanged "onAudioRoutingChanged" - callback. - - @note The system audio route changes when an external audio device, such as - a headphone or a Bluetooth audio device, is connected. See *Principles for changing the audio route*. - - @param defaultToSpeaker Whether to set the speakerphone as the default audio - route: - - true: Set the speakerphone as the default audio route. - - false: Do not set the speakerphone as the default audio route. - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int setDefaultAudioRouteToSpeakerphone(bool defaultToSpeaker) = 0; - - /** Enables/Disables the speakerphone temporarily (for Android and iOS only). - - When the audio route changes, the SDK triggers the - \ref IRtcEngineEventHandler::onAudioRoutingChanged "onAudioRoutingChanged" - callback. - - You can call this method before, during, or after a call. However, Agora - recommends calling this method only when you are in a channel to change - the audio route temporarily. - - @note This method sets the audio route temporarily. Plugging in or - unplugging a headphone, or the SDK re-enabling the audio device module - (ADM) to adjust the media volume in some scenarios relating to audio, leads - to a change in the audio route. See *Principles for changing the audio - route*. - - @param speakerOn Whether to set the speakerphone as the temporary audio - route: - - true: Set the speakerphone as the audio route temporarily. (For iOS only: - calling setEnableSpeakerphone(true) does not change the audio route to the - speakerphone if a headphone or a Bluetooth audio device is connected.) - - false: Do not set the speakerphone as the audio route. - @return - - 0: Success. - - < 0: Failure. - */ - virtual int setEnableSpeakerphone(bool speakerOn) = 0; - - /** Checks whether the speakerphone is enabled (for Android and iOS only). - - @return - - true: The speakerphone is enabled, and the audio plays from the speakerphone. - - false: The speakerphone is not enabled, and the audio plays from devices - other than the speakerphone. For example, the headset or earpiece. - */ - virtual bool isSpeakerphoneEnabled() = 0; - - /** Select preferred route for android communication mode - - @param route The preferred route. For example, when a Bluetooth headset is connected, - you can use this API to switch the route to a wired headset. - @return meanless, route switch result is pass through CallbackOnRoutingChanged - */ - virtual int setRouteInCommunicationMode(int route) = 0; -#endif // __ANDROID__ || (__APPLE__ && TARGET_OS_IOS) || __OHOS__ - -#if defined(__APPLE__) - /** - * Checks whether the center stage is supported. Use this method after starting the camera. - * - * @return - * - true: The center stage is supported. - * - false: The center stage is not supported. - */ - virtual bool isCameraCenterStageSupported() = 0; - - /** Enables the camera Center Stage. - * @param enabled enable Center Stage: - * - true: Enable Center Stage. - * - false: Disable Center Stage. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableCameraCenterStage(bool enabled) = 0; -#endif - -#if defined(_WIN32) || (defined(__APPLE__) && TARGET_OS_MAC && !TARGET_OS_IPHONE) - /** Get \ref ScreenCaptureSourceInfo list including available windows and screens. - * - * @param thumbSize Set expected size for thumb, image will be scaled accordingly. For windows, SIZE is defined in windef.h. - * @param iconSize Set expected size for icon, image will be scaled accordingly. For windows, SIZE is defined in windef.h. - * @param includeScreen Determines whether to include screens info. - * - true: sources will have screens info - * - false: source will only have windows info - * @return - * - IScreenCaptureSourceList* a pointer to an instance of IScreenCaptureSourceList - */ - virtual IScreenCaptureSourceList* getScreenCaptureSources(const SIZE& thumbSize, const SIZE& iconSize, const bool includeScreen) = 0; -#endif // _WIN32 || (__APPLE__ && !TARGET_OS_IPHONE && TARGET_OS_MAC) -#if (defined(__APPLE__) && TARGET_OS_IOS) - /** Sets the operational permission of the SDK on the audio session. - * - * The SDK and the app can both configure the audio session by default. If - * you need to only use the app to configure the audio session, this method - * restricts the operational permission of the SDK on the audio session. - * - * You can call this method either before or after joining a channel. Once - * you call this method to restrict the operational permission of the SDK - * on the audio session, the restriction takes effect when the SDK needs to - * change the audio session. - * - * @note - * - This method is for iOS only. - * - This method does not restrict the operational permission of the app on - * the audio session. - * - * @param restriction The operational permission of the SDK on the audio session. - * See #AUDIO_SESSION_OPERATION_RESTRICTION. This parameter is in bit mask - * format, and each bit corresponds to a permission. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setAudioSessionOperationRestriction(AUDIO_SESSION_OPERATION_RESTRICTION restriction) = 0; -#endif // __APPLE__ && TARGET_OS_IOS - -#if defined(_WIN32) || (defined(__APPLE__) && !TARGET_OS_IPHONE && TARGET_OS_MAC) - - /** Shares the whole or part of a screen by specifying the display ID. - - @note This method applies to macOS only. - - @param displayId The display ID of the screen to be shared. This parameter - specifies which screen you want to share. For information on how to get the - displayId, see the advanced guide: Share the Screen. - @param regionRect (Optional) Sets the relative location of the region to the - screen. NIL means sharing the whole screen. See Rectangle. - If the specified region overruns the screen, the SDK shares only the region - within it; if you set width or height as 0, the SDK shares the whole screen. - @param captureParams Sets the screen sharing encoding parameters. See - ScreenCaptureParameters. - - @return - - 0: Success. - - < 0: Failure: - - ERR_INVALID_ARGUMENT (2): The argument is invalid. - - ERR_NOT_INITIALIZED (7): You have not initialized IRtcEngine when try to start screen capture. - */ - virtual int startScreenCaptureByDisplayId(uint32_t displayId, const Rectangle& regionRect, - const ScreenCaptureParameters& captureParams) = 0; - -#endif // __APPLE__ && TARGET_OS_MAC && !TARGET_OS_IPHONE - -#if defined(_WIN32) - /** - * Shares the whole or part of a screen by specifying the screen rect. - * - * @deprecated This method is deprecated, use \ref IRtcEngine::startScreenCaptureByDisplayId "startScreenCaptureByDisplayId" instead. Agora strongly recommends using `startScreenCaptureByDisplayId` if you need to start screen sharing on a device connected to another display. - * - * @note This method applies to Windows only. - * - * @param screenRect Sets the relative location of the screen to the virtual - * screen. For information on how to get screenRect, see the advanced guide: - * Share the Screen. - * @param regionRect (Optional) Sets the relative location of the region to the - * screen. NULL means sharing the whole screen. See Rectangle. - * If the specified region overruns the screen, the SDK shares only the region - * within it; if you set width or height as 0, the SDK shares the whole screen. - * @param captureParams Sets the screen sharing encoding parameters. See - * ScreenCaptureParameters. - * - * @return - * - 0: Success. - * - < 0: Failure: - * - ERR_INVALID_ARGUMENT (2): The argument is invalid. - * - ERR_NOT_INITIALIZED (7): You have not initialized IRtcEngine when try to start screen capture. - */ - virtual int startScreenCaptureByScreenRect(const Rectangle& screenRect, - const Rectangle& regionRect, - const ScreenCaptureParameters& captureParams) __deprecated = 0; -#endif - -#if defined(__ANDROID__) - /** - * Gets the the Audio device Info - * @return - * - 0: Success. - * - < 0: Failure.. - */ - virtual int getAudioDeviceInfo(DeviceInfo& deviceInfo) = 0; -#endif // __ANDROID__ - -#if defined(_WIN32) || (defined(__APPLE__) && TARGET_OS_MAC && !TARGET_OS_IPHONE) - - /** Shares the whole or part of a window by specifying the window ID. - * - * @param windowId The ID of the window to be shared. For information on how to - * get the windowId, see the advanced guide *Share Screen*. - * @param regionRect (Optional) The relative location of the region to the - * window. NULL means sharing the whole window. See Rectangle. If the - * specified region overruns the window, the SDK shares only the region within - * it; if you set width or height as 0, the SDK shares the whole window. - * @param captureParams The window sharing encoding parameters. See - * ScreenCaptureParameters. - * - * @return - * - 0: Success. - * - < 0: Failure: - * - ERR_INVALID_ARGUMENT (2): The argument is invalid. - * - ERR_NOT_INITIALIZED (7): You have not initialized IRtcEngine when try to start screen capture. - */ - virtual int startScreenCaptureByWindowId(view_t windowId, const Rectangle& regionRect, - const ScreenCaptureParameters& captureParams) = 0; - - /** - * Sets the content hint for screen sharing. - * - * A content hint suggests the type of the content being shared, so that the SDK applies different - * optimization algorithm to different types of content. - * - * @param contentHint Sets the content hint for screen sharing: #VIDEO_CONTENT_HINT. - * - * @return - * - 0: Success. - * - < 0: Failure: - * - ERR_NOT_SUPPORTED (4): unable to set screencapture content hint - * - ERR_FAILED (1): A general error occurs (no specified reason). - * - ERR_NOT_INITIALIZED (7): You have not initialized IRtcEngine when set screen capture content hint. - */ - virtual int setScreenCaptureContentHint(VIDEO_CONTENT_HINT contentHint) = 0; - - /** - * Updates the screen sharing region. - * - * @param regionRect Sets the relative location of the region to the screen or - * window. NULL means sharing the whole screen or window. See Rectangle. - * If the specified region overruns the screen or window, the SDK shares only - * the region within it; if you set width or height as 0, the SDK shares the - * whole screen or window. - * - * @return - * - 0: Success. - * - < 0: Failure: - * - ERR_NOT_SUPPORTED (4): unable to update screen capture region - * - ERR_FAILED (1): A general error occurs (no specified reason). - * - ERR_NOT_INITIALIZED (7): You have not initialized IRtcEngine when update screen capture regoin. - */ - virtual int updateScreenCaptureRegion(const Rectangle& regionRect) = 0; - - /** - * Updates the screen sharing parameters. - * - * @param captureParams Sets the screen sharing encoding parameters: ScreenCaptureParameters. - * - * @return - * - 0: Success. - * - < 0: Failure. - * - ERR_NOT_SUPPORTED (4): unable to update screen capture parameters - * - ERR_INVALID_ARGUMENT (2): The argument is invalid. - * - ERR_FAILED (1): A general error occurs (no specified reason). - * - ERR_NOT_INITIALIZED (7): You have not initialized IRtcEngine when update screen capture parameters. - */ - virtual int updateScreenCaptureParameters(const ScreenCaptureParameters& captureParams) = 0; -#endif // _WIN32 || (__APPLE__ && !TARGET_OS_IPHONE && TARGET_OS_MAC) - -#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) || defined(__OHOS__) - /** - * Starts screen sharing. - * - * @param captureParams The configuration of the screen sharing. See {@link - * ScreenCaptureParameters ScreenCaptureParameters}. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int startScreenCapture(const ScreenCaptureParameters2& captureParams) = 0; - - /** - * Updates the screen sharing configuration. - * - * @param captureParams The configuration of the screen sharing. See {@link - * ScreenCaptureParameters ScreenCaptureParameters}. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int updateScreenCapture(const ScreenCaptureParameters2& captureParams) = 0; - - /** - * Queries the ability of screen sharing to support the maximum frame rate. - * - * @since v4.2.0 - * - * @return - * - 0: support 15 fps, Low devices. - * - 1: support 30 fps, Usually low - to mid-range devices. - * - 2: support 60 fps, Advanced devices. - * - < 0: Failure. - */ - virtual int queryScreenCaptureCapability() = 0; - -#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) - /** - * Query all focal attributes supported by the camera. - * - * @param focalLengthInfos The camera supports the collection of focal segments.Ensure the size of array is not less than 8. - * - * @param size The camera supports the size of the focal segment set. Ensure the size is not less than 8. - * - * @return - * - 0: Success. - * - < 0: Failure.. - */ - virtual int queryCameraFocalLengthCapability(agora::rtc::FocalLengthInfo* focalLengthInfos, int& size) = 0; -#endif // defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) -#endif // defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) || defined(__OHOS__) - -#if defined(_WIN32) || defined(__APPLE__) || defined(__ANDROID__) - /** - * Sets the screen sharing scenario. - * - * - * When you start screen sharing or window sharing, you can call this method to set the screen sharing scenario. The SDK adjusts the video quality and experience of the sharing according to the scenario. - * - * - * @param screenScenario The screen sharing scenario. See #SCREEN_SCENARIO_TYPE. - * - * @return - * - 0: Success. - * - < 0: Failure. - * - ERR_NOT_SUPPORTED (4): unable to set screencapture scenario - * - ERR_FAILED (1): A general error occurs (no specified reason). - * - ERR_NOT_INITIALIZED (7): You have not initialized IRtcEngine when set screencapture scenario. - */ - virtual int setScreenCaptureScenario(SCREEN_SCENARIO_TYPE screenScenario) = 0; - - /** - * Stops the screen sharing. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int stopScreenCapture() = 0; -#endif // _WIN32 || (__APPLE__ && !TARGET_OS_IPHONE && TARGET_OS_MAC) || __ANDROID__ - - /** - * Gets the current call ID. - * - * When a user joins a channel on a client, a `callId` is generated to identify - * the call. - * - * After a call ends, you can call `rate` or `complain` to gather feedback from the customer. - * These methods require a `callId` parameter. To use these feedback methods, call the this - * method first to retrieve the `callId` during the call, and then pass the value as an - * argument in the `rate` or `complain` method after the call ends. - * - * @param callId The reference to the call ID. - * @return - * - The call ID if the method call is successful. - * - < 0: Failure. - */ - virtual int getCallId(agora::util::AString& callId) = 0; - - /** - * Allows a user to rate the call. - * - * It is usually called after the call ends. - * - * @param callId The call ID retrieved from the \ref getCallId "getCallId" method. - * @param rating The rating of the call between 1 (the lowest score) to 5 (the highest score). - * @param description (Optional) The description of the rating. The string length must be less than - * 800 bytes. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int rate(const char* callId, int rating, const char* description) = 0; // 0~10 - - /** - * Allows a user to complain about the call quality. - * - * This method is usually called after the call ends. - * - * @param callId The call ID retrieved from the `getCallId` method. - * @param description (Optional) The description of the complaint. The string length must be less than - * 800 bytes. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int complain(const char* callId, const char* description) = 0; - - /** Publishes the local stream without transcoding to a specified CDN live RTMP address. (CDN live only.) - - * The SDK returns the result of this method call in the \ref IRtcEngineEventHandler::onStreamPublished "onStreamPublished" callback. - - * The \ref agora::rtc::IRtcEngine::startRtmpStreamWithoutTranscoding "startRtmpStreamWithoutTranscoding" method call triggers the \ref agora::rtc::IRtcEngineEventHandler::onRtmpStreamingStateChanged "onRtmpStreamingStateChanged" callback on the local client to report the state of adding a local stream to the CDN. - * @note - * - Ensure that the user joins the channel before calling this method. - * - This method adds only one stream RTMP URL address each time it is called. - * - The RTMP URL address must not contain special characters, such as Chinese language characters. - * - This method applies to Live Broadcast only. - - * @param url The CDN streaming URL in the RTMP format. The maximum length of this parameter is 1024 bytes. - - * @return - * - 0: Success. - * - < 0: Failure. - * - #ERR_INVALID_ARGUMENT (2): The RTMP URL address is NULL or has a string length of 0. - * - #ERR_NOT_INITIALIZED (7): You have not initialized the RTC engine when publishing the stream. - * - #ERR_ALREADY_IN_USE (19): This streaming URL is already in use. Use a new streaming URL for CDN streaming. - */ - virtual int startRtmpStreamWithoutTranscoding(const char* url) = 0; - - /** Publishes the local stream with transcoding to a specified CDN live RTMP address. (CDN live only.) - - * The SDK returns the result of this method call in the \ref IRtcEngineEventHandler::onStreamPublished "onStreamPublished" callback. - - * The \ref agora::rtc::IRtcEngine::startRtmpStreamWithTranscoding "startRtmpStreamWithTranscoding" method call triggers the \ref agora::rtc::IRtcEngineEventHandler::onRtmpStreamingStateChanged "onRtmpStreamingStateChanged" callback on the local client to report the state of adding a local stream to the CDN. - * @note - * - Ensure that the user joins the channel before calling this method. - * - This method adds only one stream RTMP URL address each time it is called. - * - The RTMP URL address must not contain special characters, such as Chinese language characters. - * - This method applies to Live Broadcast only. - - * @param url The CDN streaming URL in the RTMP format. The maximum length of this parameter is 1024 bytes. - * @param transcoding Sets the CDN live audio/video transcoding settings. See LiveTranscoding. - - * @return - * - 0: Success. - * - < 0: Failure. - * - #ERR_INVALID_ARGUMENT (2): The RTMP URL address is NULL or has a string length of 0. - * - #ERR_NOT_INITIALIZED (7): You have not initialized the RTC engine when publishing the stream. - * - #ERR_ALREADY_IN_USE (19): This streaming URL is already in use. Use a new streaming URL for CDN streaming. - */ - virtual int startRtmpStreamWithTranscoding(const char* url, const LiveTranscoding& transcoding) = 0; - - /** Update the video layout and audio settings for CDN live. (CDN live only.) - * @note This method applies to Live Broadcast only. - - * @param transcoding Sets the CDN live audio/video transcoding settings. See LiveTranscoding. - - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int updateRtmpTranscoding(const LiveTranscoding& transcoding) = 0; - - virtual int startLocalVideoTranscoder(const LocalTranscoderConfiguration& config) = 0; - virtual int updateLocalTranscoderConfiguration(const LocalTranscoderConfiguration& config) = 0; - - /** Stop an RTMP stream with transcoding or without transcoding from the CDN. (CDN live only.) - - * This method removes the RTMP URL address (added by the \ref IRtcEngine::startRtmpStreamWithoutTranscoding "startRtmpStreamWithoutTranscoding" method - * or IRtcEngine::startRtmpStreamWithTranscoding "startRtmpStreamWithTranscoding" method) from a CDN live stream. - * The SDK returns the result of this method call in the \ref IRtcEngineEventHandler::onStreamUnpublished "onStreamUnpublished" callback. - - * The \ref agora::rtc::IRtcEngine::stopRtmpStream "stopRtmpStream" method call triggers the \ref agora::rtc::IRtcEngineEventHandler::onRtmpStreamingStateChanged "onRtmpStreamingStateChanged" callback on the local client to report the state of removing an RTMP stream from the CDN. - * @note - * - This method removes only one RTMP URL address each time it is called. - * - The RTMP URL address must not contain special characters, such as Chinese language characters. - * - This method applies to Live Broadcast only. - - * @param url The RTMP URL address to be removed. The maximum length of this parameter is 1024 bytes. - - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int stopRtmpStream(const char* url) = 0; - - virtual int stopLocalVideoTranscoder() = 0; - /** - * Starts video capture with a camera. - * - * @param config The configuration of the video capture with a primary camera. For details, see CameraCaptureConfiguration. - * @param sourceType Source type of camera. See #VIDEO_SOURCE_TYPE. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int startCameraCapture(VIDEO_SOURCE_TYPE sourceType, const CameraCapturerConfiguration& config) = 0; - - /** - * Stops capturing video through camera. - * - * You can call this method to stop capturing video through the first camera after calling `startCameraCapture`. - * - * @param sourceType Source type of camera. See #VIDEO_SOURCE_TYPE. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int stopCameraCapture(VIDEO_SOURCE_TYPE sourceType) = 0; - /** - * Sets the rotation angle of the video captured by the camera. - * - * When the video capture device does not have the gravity sensing function, you can call this method to manually adjust the rotation angle of the captured video. - * - * @param type The video source type. See #VIDEO_SOURCE_TYPE. - * @param orientation The clockwise rotation angle. See #VIDEO_ORIENTATION. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setCameraDeviceOrientation(VIDEO_SOURCE_TYPE type, VIDEO_ORIENTATION orientation) = 0; - /** - * Sets the rotation angle of the video captured by the screen. - * - * When the screen capture device does not have the gravity sensing function, you can call this method to manually adjust the rotation angle of the captured video. - * - * @param type The video source type. See #VIDEO_SOURCE_TYPE. - * @param orientation The clockwise rotation angle. See #VIDEO_ORIENTATION. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setScreenCaptureOrientation(VIDEO_SOURCE_TYPE type, VIDEO_ORIENTATION orientation) = 0; - - /** - * Starts sharing a screen. - * - * @param config The configuration of the captured screen. For details, see ScreenCaptureConfiguration. - * @param sourceType source type of screen. See #VIDEO_SOURCE_TYPE. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int startScreenCapture(VIDEO_SOURCE_TYPE sourceType, const ScreenCaptureConfiguration& config) = 0; - - /** - * Stop sharing the screen. - * - * After calling `startScreenCapture`, you can call this method to stop sharing the first screen. - * - * @param sourceType source type of screen. See #VIDEO_SOURCE_TYPE. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int stopScreenCapture(VIDEO_SOURCE_TYPE sourceType) = 0; - - /** Gets the current connection state of the SDK. - - @return #CONNECTION_STATE_TYPE. - */ - virtual CONNECTION_STATE_TYPE getConnectionState() = 0; - - // The following APIs are not implemented yet. - virtual bool registerEventHandler(IRtcEngineEventHandler* eventHandler) = 0; - virtual bool unregisterEventHandler(IRtcEngineEventHandler* eventHandler) = 0; - virtual int setRemoteUserPriority(uid_t uid, PRIORITY_TYPE userPriority) = 0; - - /** - * Registers a packet observer. - * - * The Agora Native SDK allows your app to register a packet observer to - * receive events whenever a voice or video packet is transmitting. - * - * @param observer The IPacketObserver object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerPacketObserver(IPacketObserver* observer) = 0; - - - /** Enables/Disables the built-in encryption. - * - * In scenarios requiring high security, Agora recommends calling this method to enable the built-in encryption before joining a channel. - * - * All users in the same channel must use the same encryption mode and encryption key. Once all users leave the channel, the encryption key of this channel is automatically cleared. - * - * @note - * - If you enable the built-in encryption, you cannot use the RTMP streaming function. - * - * @param enabled Whether to enable the built-in encryption: - * - true: Enable the built-in encryption. - * - false: Disable the built-in encryption. - * @param config Configurations of built-in encryption schemas. See EncryptionConfig. - * - * @return - * - 0: Success. - * - < 0: Failure. - * - -2(ERR_INVALID_ARGUMENT): An invalid parameter is used. Set the parameter with a valid value. - * - -4(ERR_NOT_SUPPORTED): The encryption mode is incorrect or the SDK fails to load the external encryption library. Check the enumeration or reload the external encryption library. - * - -7(ERR_NOT_INITIALIZED): The SDK is not initialized. Initialize the `IRtcEngine` instance before calling this method. - */ - virtual int enableEncryption(bool enabled, const EncryptionConfig& config) = 0; - - /** Creates a data stream. - * - * You can call this method to create a data stream and improve the - * reliability and ordering of data tranmission. - * - * @note - * - Ensure that you set the same value for `reliable` and `ordered`. - * - Each user can only create a maximum of 5 data streams during a RtcEngine - * lifecycle. - * - The data channel allows a data delay of up to 5 seconds. If the receiver - * does not receive the data stream within 5 seconds, the data channel reports - * an error. - * - * @param[out] streamId The ID of the stream data. - * @param reliable Sets whether the recipients are guaranteed to receive - * the data stream from the sender within five seconds: - * - true: The recipients receive the data stream from the sender within - * five seconds. If the recipient does not receive the data stream within - * five seconds, an error is reported to the application. - * - false: There is no guarantee that the recipients receive the data stream - * within five seconds and no error message is reported for any delay or - * missing data stream. - * @param ordered Sets whether the recipients receive the data stream - * in the sent order: - * - true: The recipients receive the data stream in the sent order. - * - false: The recipients do not receive the data stream in the sent order. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int createDataStream(int* streamId, bool reliable, bool ordered) = 0; - - /** Creates a data stream. - * - * Each user can create up to five data streams during the lifecycle of the IChannel. - * @param streamId The ID of the created data stream. - * @param config The config of data stream. - * @return int - * - Returns 0: Success. - * - < 0: Failure. - */ - virtual int createDataStream(int* streamId, const DataStreamConfig& config) = 0; - - /** Sends a data stream. - * - * After calling \ref IRtcEngine::createDataStream "createDataStream", you can call - * this method to send a data stream to all users in the channel. - * - * The SDK has the following restrictions on this method: - * - Up to 60 packets can be sent per second in a channel with each packet having a maximum size of 1 KB. - * - Each client can send up to 30 KB of data per second. - * - Each user can have up to five data streams simultaneously. - * - * After the remote user receives the data stream within 5 seconds, the SDK triggers the - * \ref IRtcEngineEventHandler::onStreamMessage "onStreamMessage" callback on - * the remote client. After the remote user does not receive the data stream within 5 seconds, - * the SDK triggers the \ref IRtcEngineEventHandler::onStreamMessageError "onStreamMessageError" - * callback on the remote client. - * - * @note - * - Call this method after calling \ref IRtcEngine::createDataStream "createDataStream". - * - This method applies only to the `COMMUNICATION` profile or to - * the hosts in the `LIVE_BROADCASTING` profile. If an audience in the - * `LIVE_BROADCASTING` profile calls this method, the audience may be switched to a host. - * - * @param streamId The ID of the stream data. - * @param data The data stream. - * @param length The length (byte) of the data stream. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int sendStreamMessage(int streamId, const char* data, size_t length) = 0; - - /** **DEPRECATED** Adds a watermark image to the local video or CDN live stream. - - This method is not recommend, Use \ref agora::rtc::IRtcEngine::addVideoWatermark(const char* watermarkUrl, const WatermarkOptions& options) "addVideoWatermark"2 instead. - - This method adds a PNG watermark image to the local video stream for the recording device, channel audience, and CDN live audience to view and capture. - - To add the PNG file to the CDN live publishing stream, see the \ref IRtcEngine::setLiveTranscoding "setLiveTranscoding" method. - - @param watermark Pointer to the watermark image to be added to the local video stream. See RtcImage. - - @note - - The URL descriptions are different for the local video and CDN live streams: - - In a local video stream, `url` in RtcImage refers to the absolute path of the added watermark image file in the local video stream. - - In a CDN live stream, `url` in RtcImage refers to the URL address of the added watermark image in the CDN live broadcast. - - The source file of the watermark image must be in the PNG file format. If the width and height of the PNG file differ from your settings in this method, the PNG file will be cropped to conform to your settings. - - The Agora SDK supports adding only one watermark image onto a local video or CDN live stream. The newly added watermark image replaces the previous one. - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int addVideoWatermark(const RtcImage& watermark) __deprecated = 0; - - /** Adds a watermark image to the local video. - - This method adds a PNG watermark image to the local video in a live broadcast. Once the watermark image is added, all the audience in the channel (CDN audience included), - and the recording device can see and capture it. Agora supports adding only one watermark image onto the local video, and the newly watermark image replaces the previous one. - - The watermark position depends on the settings in the \ref IRtcEngine::setVideoEncoderConfiguration "setVideoEncoderConfiguration" method: - - If the orientation mode of the encoding video is #ORIENTATION_MODE_FIXED_LANDSCAPE, or the landscape mode in #ORIENTATION_MODE_ADAPTIVE, the watermark uses the landscape orientation. - - If the orientation mode of the encoding video is #ORIENTATION_MODE_FIXED_PORTRAIT, or the portrait mode in #ORIENTATION_MODE_ADAPTIVE, the watermark uses the portrait orientation. - - When setting the watermark position, the region must be less than the dimensions set in the `setVideoEncoderConfiguration` method. Otherwise, the watermark image will be cropped. - - @note - - Ensure that you have called the \ref agora::rtc::IRtcEngine::enableVideo "enableVideo" method to enable the video module before calling this method. - - If you only want to add a watermark image to the local video for the audience in the CDN live broadcast channel to see and capture, you can call this method or the \ref agora::rtc::IRtcEngine::setLiveTranscoding "setLiveTranscoding" method. - - This method supports adding a watermark image in the PNG file format only. Supported pixel formats of the PNG image are RGBA, RGB, Palette, Gray, and Alpha_gray. - - If the dimensions of the PNG image differ from your settings in this method, the image will be cropped or zoomed to conform to your settings. - - If you have enabled the local video preview by calling the \ref agora::rtc::IRtcEngine::startPreview "startPreview" method, you can use the `visibleInPreview` member in the WatermarkOptions class to set whether or not the watermark is visible in preview. - - If you have enabled the mirror mode for the local video, the watermark on the local video is also mirrored. To avoid mirroring the watermark, Agora recommends that you do not use the mirror and watermark functions for the local video at the same time. You can implement the watermark function in your application layer. - - @param watermarkUrl The local file path of the watermark image to be added. This method supports adding a watermark image from the local absolute or relative file path. - @param options Pointer to the watermark's options to be added. See WatermarkOptions for more infomation. - - @return int - - 0: Success. - - < 0: Failure. - */ - virtual int addVideoWatermark(const char* watermarkUrl, const WatermarkOptions& options) = 0; - - /** Removes the watermark image on the video stream added by - addVideoWatermark(). - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int clearVideoWatermarks() = 0; - - // The following APIs are either deprecated and going to deleted. - - /** @deprecated Use disableAudio() instead. - - Disables the audio function in the channel. - - @return int - - 0: Success. - - < 0: Failure. - */ - virtual int pauseAudio() __deprecated = 0; - /** @deprecated Use enableAudio() instead. - - Resumes the audio function in the channel. - - @return int - - 0: Success. - - < 0: Failure. - */ - virtual int resumeAudio() __deprecated = 0; - - /** - * Enables interoperability with the Agora Web SDK (Live Broadcast only). - * - * @deprecated The Agora NG SDK enables the interoperablity with the Web SDK. - * - * Use this method when the channel profile is Live Broadcast. Interoperability - * with the Agora Web SDK is enabled by default when the channel profile is - * Communication. - * - * @param enabled Determines whether to enable interoperability with the Agora Web SDK. - * - true: (Default) Enable interoperability with the Agora Native SDK. - * - false: Disable interoperability with the Agora Native SDK. - * - * @return int - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableWebSdkInteroperability(bool enabled) __deprecated = 0; - - /** Agora supports reporting and analyzing customized messages. - * - * This function is in the beta stage with a free trial. The ability provided - * in its beta test version is reporting a maximum of 10 message pieces within - * 6 seconds, with each message piece not exceeding 256 bytes. - * - * To try out this function, contact [support@agora.io](mailto:support@agora.io) - * and discuss the format of customized messages with us. - */ - virtual int sendCustomReportMessage(const char* id, const char* category, const char* event, const char* label, int value) = 0; - - /** Registers the metadata observer. - - You need to implement the IMetadataObserver class and specify the metadata type - in this method. This method enables you to add synchronized metadata in the video - stream for more diversified live interactive streaming, such as sending - shopping links, digital coupons, and online quizzes. - - A successful call of this method triggers - the \ref agora::rtc::IMetadataObserver::getMaxMetadataSize "getMaxMetadataSize" callback. - - @note - - Call this method before the `joinChannel` method. - - This method applies to the `LIVE_BROADCASTING` channel profile. - - @param observer IMetadataObserver. - @param type The metadata type. See \ref IMetadataObserver::METADATA_TYPE "METADATA_TYPE". The SDK supports VIDEO_METADATA (0) only for now. - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int registerMediaMetadataObserver(IMetadataObserver *observer, IMetadataObserver::METADATA_TYPE type) = 0; - - /** Unregisters the metadata observer. - @param observer IMetadataObserver. - @param type The metadata type. See \ref IMetadataObserver::METADATA_TYPE "METADATA_TYPE". The SDK supports VIDEO_METADATA (0) only for now. - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int unregisterMediaMetadataObserver(IMetadataObserver* observer, IMetadataObserver::METADATA_TYPE type) = 0; - - /** Start audio frame dump. - - Optional `location` is: "pre_apm_proc", "apm", "pre_send_proc", "filter", "enc", "tx_mixer", - "at_record", "atw_record" for audio sending. - "dec", "mixed", "play", "rx_mixer", "playback_mixer", "pcm_source_playback_mixer", - "pre_play_proc", "at_playout", "atw_playout" for audio receiving. - - */ - virtual int startAudioFrameDump(const char* channel_id, uid_t uid, const char* location, const char* uuid, const char* passwd, long duration_ms, bool auto_upload) = 0; - - /** - * Stops the audio frame dump. - */ - virtual int stopAudioFrameDump(const char* channel_id, uid_t uid, const char* location) = 0; - - /** - * Enables/Disables Agora AI Noise Suppression(AINS) with preset mode. - * - * @param enabled Sets whether or not to enable AINS. - * - true: Enables the AINS. - * - false: Disables the AINS. - * @param mode The preset AINS mode, range is [0,1,2]: - * 0: AINS mode with soft suppression level. - * 1: AINS mode with aggressive suppression level. - * 2: AINS mode with aggressive suppression level and low algorithm latency. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setAINSMode(bool enabled, AUDIO_AINS_MODE mode) = 0; - - /** Registers a user account. - * - * Once registered, the user account can be used to identify the local user when the user joins the channel. - * After the user successfully registers a user account, the SDK triggers the \ref agora::rtc::IRtcEngineEventHandler::onLocalUserRegistered "onLocalUserRegistered" callback on the local client, - * reporting the user ID and user account of the local user. - * - * To join a channel with a user account, you can choose either of the following: - * - * - Call the \ref agora::rtc::IRtcEngine::registerLocalUserAccount "registerLocalUserAccount" method to create a user account, and then the \ref agora::rtc::IRtcEngine::joinChannelWithUserAccount "joinChannelWithUserAccount" method to join the channel. - * - Call the \ref agora::rtc::IRtcEngine::joinChannelWithUserAccount "joinChannelWithUserAccount" method to join the channel. - * - * The difference between the two is that for the former, the time elapsed between calling the \ref agora::rtc::IRtcEngine::joinChannelWithUserAccount "joinChannelWithUserAccount" method - * and joining the channel is shorter than the latter. - * - * @note - * - Ensure that you set the `userAccount` parameter. Otherwise, this method does not take effect. - * - Ensure that the value of the `userAccount` parameter is unique in the channel. - * - To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a user ID, then ensure all the other users use the user ID too. The same applies to the user account. If a user joins the channel with the Agora Web SDK, ensure that the uid of the user is set to the same parameter type. - * - * @param appId The App ID of your project. - * @param userAccount The user account. The maximum length of this parameter is 255 bytes. Ensure that you set this parameter and do not set it as null. Supported character scopes are: - * - All lowercase English letters: a to z. - * - All uppercase English letters: A to Z. - * - All numeric characters: 0 to 9. - * - The space character. - * - Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",". - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerLocalUserAccount(const char* appId, const char* userAccount) = 0; - - /** Joins the channel with a user account. - * - * After the user successfully joins the channel, the SDK triggers the following callbacks: - * - * - The local client: \ref agora::rtc::IRtcEngineEventHandler::onLocalUserRegistered "onLocalUserRegistered" and \ref agora::rtc::IRtcEngineEventHandler::onJoinChannelSuccess "onJoinChannelSuccess" . - * - The remote client: \ref agora::rtc::IRtcEngineEventHandler::onUserJoined "onUserJoined" and \ref agora::rtc::IRtcEngineEventHandler::onUserInfoUpdated "onUserInfoUpdated" , if the user joining the channel is in the `COMMUNICATION` profile, or is a host in the `LIVE_BROADCASTING` profile. - * - * @note To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a user ID, then ensure all the other users use the user ID too. The same applies to the user account. - * If a user joins the channel with the Agora Web SDK, ensure that the uid of the user is set to the same parameter type. - * - * @param token The token generated at your server: - * - For low-security requirements: You can use the temporary token generated at Console. For details, see [Get a temporary toke](https://docs.agora.io/en/Voice/token?platform=All%20Platforms#get-a-temporary-token). - * - For high-security requirements: Set it as the token generated at your server. For details, see [Get a token](https://docs.agora.io/en/Voice/token?platform=All%20Platforms#get-a-token). - * @param channelId The channel name. The maximum length of this parameter is 64 bytes. Supported character scopes are: - * - All lowercase English letters: a to z. - * - All uppercase English letters: A to Z. - * - All numeric characters: 0 to 9. - * - The space character. - * - Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",". - * @param userAccount The user account. The maximum length of this parameter is 255 bytes. Ensure that you set this parameter and do not set it as null. Supported character scopes are: - * - All lowercase English letters: a to z. - * - All uppercase English letters: A to Z. - * - All numeric characters: 0 to 9. - * - The space character. - * - Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",". - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int joinChannelWithUserAccount(const char* token, const char* channelId, const char* userAccount) = 0; - - /** Joins the channel with a user account. - * - * After the user successfully joins the channel, the SDK triggers the following callbacks: - * - * - The local client: \ref agora::rtc::IRtcEngineEventHandler::onLocalUserRegistered "onLocalUserRegistered" and \ref agora::rtc::IRtcEngineEventHandler::onJoinChannelSuccess "onJoinChannelSuccess" . - * - The remote client: \ref agora::rtc::IRtcEngineEventHandler::onUserJoined "onUserJoined" and \ref agora::rtc::IRtcEngineEventHandler::onUserInfoUpdated "onUserInfoUpdated" , if the user joining the channel is in the `COMMUNICATION` profile, or is a host in the `LIVE_BROADCASTING` profile. - * - * @note To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a user ID, then ensure all the other users use the user ID too. The same applies to the user account. - * If a user joins the channel with the Agora Web SDK, ensure that the uid of the user is set to the same parameter type. - * - * @param token The token generated at your server: - * - For low-security requirements: You can use the temporary token generated at Console. For details, see [Get a temporary toke](https://docs.agora.io/en/Voice/token?platform=All%20Platforms#get-a-temporary-token). - * - For high-security requirements: Set it as the token generated at your server. For details, see [Get a token](https://docs.agora.io/en/Voice/token?platform=All%20Platforms#get-a-token). - * @param channelId The channel name. The maximum length of this parameter is 64 bytes. Supported character scopes are: - * - All lowercase English letters: a to z. - * - All uppercase English letters: A to Z. - * - All numeric characters: 0 to 9. - * - The space character. - * - Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",". - * @param userAccount The user account. The maximum length of this parameter is 255 bytes. Ensure that you set this parameter and do not set it as null. Supported character scopes are: - * - All lowercase English letters: a to z. - * - All uppercase English letters: A to Z. - * - All numeric characters: 0 to 9. - * - The space character. - * - Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",". - * @param options The channel media options: \ref agora::rtc::ChannelMediaOptions::ChannelMediaOptions "ChannelMediaOptions" - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int joinChannelWithUserAccount(const char* token, const char* channelId, const char* userAccount, const ChannelMediaOptions& options) = 0; - - /** Joins the channel with a user account. - * - * After the user successfully joins the channel, the SDK triggers the following callbacks: - * - * - The local client: \ref agora::rtc::IRtcEngineEventHandler::onLocalUserRegistered "onLocalUserRegistered" and \ref agora::rtc::IRtcEngineEventHandler::onJoinChannelSuccess "onJoinChannelSuccess" . - * - The remote client: \ref agora::rtc::IRtcEngineEventHandler::onUserJoined "onUserJoined" and \ref agora::rtc::IRtcEngineEventHandler::onUserInfoUpdated "onUserInfoUpdated" , if the user joining the channel is in the `COMMUNICATION` profile, or is a host in the `LIVE_BROADCASTING` profile. - * - * @note To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a user ID, then ensure all the other users use the user ID too. The same applies to the user account. - * If a user joins the channel with the Agora Web SDK, ensure that the uid of the user is set to the same parameter type. - * - * @param token The token generated at your server: - * - For low-security requirements: You can use the temporary token generated at Console. For details, see [Get a temporary toke](https://docs.agora.io/en/Voice/token?platform=All%20Platforms#get-a-temporary-token). - * - For high-security requirements: Set it as the token generated at your server. For details, see [Get a token](https://docs.agora.io/en/Voice/token?platform=All%20Platforms#get-a-token). - * @param channelId The channel name. The maximum length of this parameter is 64 bytes. Supported character scopes are: - * - All lowercase English letters: a to z. - * - All uppercase English letters: A to Z. - * - All numeric characters: 0 to 9. - * - The space character. - * - Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",". - * @param userAccount The user account. The maximum length of this parameter is 255 bytes. Ensure that you set this parameter and do not set it as null. Supported character scopes are: - * - All lowercase English letters: a to z. - * - All uppercase English letters: A to Z. - * - All numeric characters: 0 to 9. - * - The space character. - * - Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",". - * @param options The channel media options: \ref agora::rtc::ChannelMediaOptions::ChannelMediaOptions "ChannelMediaOptions" - * @param eventHandler The pointer to the IRtcEngine event handler: IRtcEngineEventHandler. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int joinChannelWithUserAccountEx(const char* token, const char* channelId, - const char* userAccount, const ChannelMediaOptions& options, - IRtcEngineEventHandler* eventHandler) = 0; - - /** Gets the user information by passing in the user account. - * - * After a remote user joins the channel, the SDK gets the user ID and user account of the remote user, caches them - * in a mapping table object (`userInfo`), and triggers the \ref agora::rtc::IRtcEngineEventHandler::onUserInfoUpdated "onUserInfoUpdated" callback on the local client. - * - * After receiving the o\ref agora::rtc::IRtcEngineEventHandler::onUserInfoUpdated "onUserInfoUpdated" callback, you can call this method to get the user ID of the - * remote user from the `userInfo` object by passing in the user account. - * - * @param userAccount The user account of the user. Ensure that you set this parameter. - * @param [in,out] userInfo A userInfo object that identifies the user: - * - Input: A userInfo object. - * - Output: A userInfo object that contains the user account and user ID of the user. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getUserInfoByUserAccount(const char* userAccount, rtc::UserInfo* userInfo) = 0; - - /** Gets the user information by passing in the user ID. - * - * After a remote user joins the channel, the SDK gets the user ID and user account of the remote user, - * caches them in a mapping table object (`userInfo`), and triggers the \ref agora::rtc::IRtcEngineEventHandler::onUserInfoUpdated "onUserInfoUpdated" callback on the local client. - * - * After receiving the \ref agora::rtc::IRtcEngineEventHandler::onUserInfoUpdated "onUserInfoUpdated" callback, you can call this method to get the user account of the remote user - * from the `userInfo` object by passing in the user ID. - * - * @param uid The user ID of the remote user. Ensure that you set this parameter. - * @param[in,out] userInfo A userInfo object that identifies the user: - * - Input: A userInfo object. - * - Output: A userInfo object that contains the user account and user ID of the user. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getUserInfoByUid(uid_t uid, rtc::UserInfo* userInfo) = 0; - - /** Starts relaying media streams across channels or updates the channels for media relay. - * - * After a successful method call, the SDK triggers the - * \ref agora::rtc::IRtcEngineEventHandler::onChannelMediaRelayStateChanged - * "onChannelMediaRelayStateChanged" callback, and this callback return the state of the media stream relay. - * - If the - * \ref agora::rtc::IRtcEngineEventHandler::onChannelMediaRelayStateChanged - * "onChannelMediaRelayStateChanged" callback returns - * #RELAY_STATE_RUNNING (2) and #RELAY_OK (0), the host starts sending data to the destination channel. - * - If the - * \ref agora::rtc::IRtcEngineEventHandler::onChannelMediaRelayStateChanged - * "onChannelMediaRelayStateChanged" callback returns - * #RELAY_STATE_FAILURE (3), an exception occurs during the media stream - * relay. - * - * @note - * - Call this method after the \ref joinChannel() "joinChannel" method. - * - This method takes effect only when you are a host in a - * `LIVE_BROADCASTING` channel. - * - Contact sales-us@agora.io before implementing this function. - * - We do not support string user accounts in this API. - * - * @since v4.2.0 - * @param configuration The configuration of the media stream relay: - * ChannelMediaRelayConfiguration. - * - * @return - * - 0: Success. - * - < 0: Failure. - * - -1(ERR_FAILED): A general error occurs (no specified reason). - * - -2(ERR_INVALID_ARGUMENT): The argument is invalid. - * - -5(ERR_REFUSED): The request is rejected. - * - -8(ERR_INVALID_STATE): The current status is invalid, only allowed to be called when the role is the broadcaster. - **/ - virtual int startOrUpdateChannelMediaRelay(const ChannelMediaRelayConfiguration &configuration) = 0; - - /** Stops the media stream relay. - * - * Once the relay stops, the host quits all the destination - * channels. - * - * After a successful method call, the SDK triggers the - * \ref agora::rtc::IRtcEngineEventHandler::onChannelMediaRelayStateChanged - * "onChannelMediaRelayStateChanged" callback. If the callback returns - * #RELAY_STATE_IDLE (0) and #RELAY_OK (0), the host successfully - * stops the relay. - * - * @note - * If the method call fails, the SDK triggers the - * \ref agora::rtc::IRtcEngineEventHandler::onChannelMediaRelayStateChanged - * "onChannelMediaRelayStateChanged" callback with the - * #RELAY_ERROR_SERVER_NO_RESPONSE (2) or - * #RELAY_ERROR_SERVER_CONNECTION_LOST (8) state code. You can leave the - * channel by calling the \ref leaveChannel() "leaveChannel" method, and - * the media stream relay automatically stops. - * - * @return - * - 0: Success. - * - < 0: Failure. - * - -1(ERR_FAILED): A general error occurs (no specified reason). - * - -2(ERR_INVALID_ARGUMENT): The argument is invalid. - * - -5(ERR_REFUSED): The request is rejected. - * - -7(ERR_NOT_INITIALIZED): cross channel media streams are not relayed. - */ - virtual int stopChannelMediaRelay() = 0; - - /** pause the channels for media stream relay. - * @return - * - 0: Success. - * - < 0: Failure. - * - -1(ERR_FAILED): A general error occurs (no specified reason). - * - -2(ERR_INVALID_ARGUMENT): The argument is invalid. - * - -5(ERR_REFUSED): The request is rejected. - * - -7(ERR_NOT_INITIALIZED): cross channel media streams are not relayed. - */ - virtual int pauseAllChannelMediaRelay() = 0; - - /** resume the channels for media stream relay. - * @return - * - 0: Success. - * - < 0: Failure. - * - -1(ERR_FAILED): A general error occurs (no specified reason). - * - -2(ERR_INVALID_ARGUMENT): The argument is invalid. - * - -5(ERR_REFUSED): The request is rejected. - * - -7(ERR_NOT_INITIALIZED): cross channel media streams are not relayed. - */ - virtual int resumeAllChannelMediaRelay() = 0; - - /** Set audio parameters for direct streaming to CDN - * - * @note - * Must call this api before "startDirectCdnStreaming" - * - * @param profile Sets the sample rate, bitrate, encoding mode, and the number of channels: - * #AUDIO_PROFILE_TYPE. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setDirectCdnStreamingAudioConfiguration(AUDIO_PROFILE_TYPE profile) = 0; - - /** Set video parameters for direct streaming to CDN - * - * Each configuration profile corresponds to a set of video parameters, including - * the resolution, frame rate, and bitrate. - * - * @note - * Must call this api before "startDirectCdnStreaming" - * - * @param config The local video encoder configuration: VideoEncoderConfiguration. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setDirectCdnStreamingVideoConfiguration(const VideoEncoderConfiguration& config) = 0; - - /** Start direct cdn streaming - * - * @param eventHandler A pointer to the direct cdn streaming event handler: \ref agora::rtc::IDirectCdnStreamingEventHandler - * "IDirectCdnStreamingEventHandler". - * @param publishUrl The url of the cdn used to publish the stream. - * @param options The direct cdn streaming media options: DirectCdnStreamingMediaOptions. - * This API must pass an audio-related option, and temporarily cannot pass more than one. - * For video-related options, you can either choose to not pass any, or only one. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int startDirectCdnStreaming(IDirectCdnStreamingEventHandler* eventHandler, - const char* publishUrl, const DirectCdnStreamingMediaOptions& options) = 0; - - /** Stop direct cdn streaming - * - * @note - * This method is synchronous. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int stopDirectCdnStreaming() = 0; - - /** Change the media source during the pushing - * - * @note - * This method is temporarily not supported. - * - * @param options The direct cdn streaming media options: DirectCdnStreamingMediaOptions. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int updateDirectCdnStreamingMediaOptions(const DirectCdnStreamingMediaOptions& options) = 0; - - /** Enables the rhythm player. - * - * @param sound1 The absolute path or URL address (including the filename extensions) of the file for the downbeat. - * @param sound2 The absolute path or URL address (including the filename extensions) of the file for the upbeats. - * @param config The configuration of rhythm player. - * - * @return int - * - 0: Success. - * - < 0: Failure. - */ - virtual int startRhythmPlayer(const char* sound1, const char* sound2, const AgoraRhythmPlayerConfig& config) = 0; - - /** Disables the rhythm player. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int stopRhythmPlayer() = 0; - - /** Configures the rhythm player. - * - * @param config The configuration of rhythm player. - * - * @return int - * - 0: Success. - * - < 0: Failure. - */ - virtual int configRhythmPlayer(const AgoraRhythmPlayerConfig& config) = 0; - - /** - * Takes a snapshot of a video stream. - * - * This method takes a snapshot of a video stream from the specified user, generates a JPG - * image, and saves it to the specified path. - * - * The method is asynchronous, and the SDK has not taken the snapshot when the method call - * returns. After a successful method call, the SDK triggers the `onSnapshotTaken` callback - * to report whether the snapshot is successfully taken, as well as the details for that - * snapshot. - * - * @note - * - Call this method after joining a channel. - * - This method takes a snapshot of the published video stream specified in `ChannelMediaOptions`. - * - If the user's video has been preprocessed, for example, watermarked or beautified, the resulting - * snapshot includes the pre-processing effect. - * - * @param uid The user ID. Set uid as 0 if you want to take a snapshot of the local user's video. - * @param filePath The local path (including filename extensions) of the snapshot. For example: - * - Windows: `C:\Users\\AppData\Local\Agora\\example.jpg` - * - iOS: `/App Sandbox/Library/Caches/example.jpg` - * - macOS: `~/Library/Logs/example.jpg` - * - Android: `/storage/emulated/0/Android/data//files/example.jpg` - * - * Ensure that the path you specify exists and is writable. - * @return - * - 0 : Success. - * - < 0 : Failure. - */ - virtual int takeSnapshot(uid_t uid, const char* filePath) = 0; - - /** Enables the content inspect. - @param enabled Whether to enable content inspect: - - `true`: Yes. - - `false`: No. - @param config The configuration for the content inspection. - @return - - 0: Success. - - < 0: Failure. - */ - virtual int enableContentInspect(bool enabled, const media::ContentInspectConfig &config) = 0; - /* - * Adjust the custom audio publish volume by track id. - * @param trackId custom audio track id. - * @param volume The volume, range is [0,100]: - * 0: mute, 100: The original volume - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int adjustCustomAudioPublishVolume(track_id_t trackId, int volume) = 0; - - /* - * Adjust the custom audio playout volume by track id. - * @param trackId custom audio track id. - * @param volume The volume, range is [0,100]: - * 0: mute, 100: The original volume - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int adjustCustomAudioPlayoutVolume(track_id_t trackId, int volume) = 0; - - /** Sets the Agora cloud proxy service. - * - * @since v3.3.0 - * - * When the user's firewall restricts the IP address and port, refer to *Use Cloud Proxy* to add the specific - * IP addresses and ports to the firewall allowlist; then, call this method to enable the cloud proxy and set - * the `proxyType` parameter as `UDP_PROXY(1)`, which is the cloud proxy for the UDP protocol. - * - * After a successfully cloud proxy connection, the SDK triggers - * the \ref IRtcEngineEventHandler::onConnectionStateChanged "onConnectionStateChanged" (CONNECTION_STATE_CONNECTING, CONNECTION_CHANGED_SETTING_PROXY_SERVER) callback. - * - * To disable the cloud proxy that has been set, call `setCloudProxy(NONE_PROXY)`. To change the cloud proxy type that has been set, - * call `setCloudProxy(NONE_PROXY)` first, and then call `setCloudProxy`, and pass the value that you expect in `proxyType`. - * - * @note - * - Agora recommends that you call this method before joining the channel or after leaving the channel. - * - For the SDK v3.3.x, the services for pushing streams to CDN and co-hosting across channels are not available - * when you use the cloud proxy for the UDP protocol. For the SDK v3.4.0 and later, the services for pushing streams - * to CDN and co-hosting across channels are not available when the user is in a network environment with a firewall - * and uses the cloud proxy for the UDP protocol. - * - * @param proxyType The cloud proxy type, see #CLOUD_PROXY_TYPE. This parameter is required, and the SDK reports an error if you do not pass in a value. - * - * @return - * - 0: Success. - * - < 0: Failure. - * - `-2(ERR_INVALID_ARGUMENT)`: The parameter is invalid. - * - `-7(ERR_NOT_INITIALIZED)`: The SDK is not initialized. - */ - virtual int setCloudProxy(CLOUD_PROXY_TYPE proxyType) = 0; - /** set local access point addresses in local proxy mode. use this method before join channel. - - @param config The LocalAccessPointConfiguration class, See the definition of LocalAccessPointConfiguration for details. - - @return - - 0: Success - - < 0: Failure - */ - virtual int setLocalAccessPoint(const LocalAccessPointConfiguration& config) = 0; - - /** set advanced audio options. - @param options The AdvancedAudioOptions class, See the definition of AdvancedAudioOptions for details. - - @return - - 0: Success - - < 0: Failure - */ - virtual int setAdvancedAudioOptions(AdvancedAudioOptions& options, int sourceType = 0) = 0; - - /** Bind local user and a remote user as an audio&video sync group. The remote user is defined by cid and uid. - * There’s a usage limit that local user must be a video stream sender. On the receiver side, media streams from same sync group will be time-synced - * - * @param channelId The channel id - * @param uid The user ID of the remote user to be bound with (local user) - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setAVSyncSource(const char* channelId, uid_t uid) = 0; - - /** - * @brief enable or disable video image source to replace the current video source published or resume it - * - * @param enable true for enable, false for disable - * @param options options for image track - */ - virtual int enableVideoImageSource(bool enable, const ImageTrackOptions& options) = 0; - - /* - * Get monotonic time in ms which can be used by capture time, - * typical scenario is as follows: - * - * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * | // custom audio/video base capture time, e.g. the first audio/video capture time. | - * | int64_t custom_capture_time_base; | - * | | - * | int64_t agora_monotonic_time = getCurrentMonotonicTimeInMs(); | - * | | - * | // offset is fixed once calculated in the begining. | - * | const int64_t offset = agora_monotonic_time - custom_capture_time_base; | - * | | - * | // realtime_custom_audio/video_capture_time is the origin capture time that customer provided.| - * | // actual_audio/video_capture_time is the actual capture time transfered to sdk. | - * | int64_t actual_audio_capture_time = realtime_custom_audio_capture_time + offset; | - * | int64_t actual_video_capture_time = realtime_custom_video_capture_time + offset; | - * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * - * @return - * - >= 0: Success. - * - < 0: Failure. - */ - virtual int64_t getCurrentMonotonicTimeInMs() = 0; - - /** - * Turns WIFI acceleration on or off. - * - * @note - * - This method is called before and after joining a channel. - * - Users check the WIFI router app for information about acceleration. Therefore, if this interface is invoked, the caller accepts that the caller's name will be displayed to the user in the WIFI router application on behalf of the caller. - * - * @param enabled - * - true:Turn WIFI acceleration on. - * - false:Turn WIFI acceleration off. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableWirelessAccelerate(bool enabled) = 0; - - /** - * get network type value - * - * @return - * - 0: DISCONNECTED. - * - 1: LAN. - * - 2: WIFI. - * - 3: MOBILE_2G. - * - 4: MOBILE_3G. - * - 5: MOBILE_4G. - * - 6: MOBILE_5G. - * - -1: UNKNOWN. - */ - - virtual int getNetworkType() = 0; - - /** Provides the technical preview functionalities or special customizations by configuring the SDK with JSON options. - - @param parameters Pointer to the set parameters in a JSON string. - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int setParameters(const char* parameters) = 0; - - /** - @brief Start tracing media rendering events. - @since v4.1.1 - @discussion - - SDK will trace media rendering events when this API is called. - - The tracing result can be obtained through callback `IRtcEngineEventHandler::onVideoRenderingTracingResult` - @note - - By default, SDK will trace media rendering events when `IRtcEngine::joinChannel` is called. - - The start point of event tracing will be reset after leaving channel. - @return - - 0: Success. - - < 0: Failure. - - -7(ERR_NOT_INITIALIZED): The SDK is not initialized. Initialize the `IRtcEngine` instance before calling this method. - */ - virtual int startMediaRenderingTracing() = 0; - - /** - @brief Enable instant media rendering. - @since v4.1.1 - @discussion - - This method enable SDK to render video or playout audio faster. - @note - - Once enable this mode, we should destroy rtc engine to disable it. - - Enable this mode, will sacrifice some part of experience. - @return - - 0: Success. - - < 0: Failure. - - -7(ERR_NOT_INITIALIZED): The SDK is not initialized. Initialize the `IRtcEngine` instance before calling this method. - */ - virtual int enableInstantMediaRendering() = 0; - - /** - * Return current NTP(unix timestamp) time in milliseconds. - */ - virtual uint64_t getNtpWallTimeInMs() = 0; - - /** - * @brief Whether the target feature is available for the device. - * @since v4.3.0 - * @param type The feature type. See FeatureType. - * @return - * - true: available. - * - false: not available. - */ - virtual bool isFeatureAvailableOnDevice(FeatureType type) = 0; - - /** - * @brief send audio metadata - * @since v4.3.1 - * @param metadata The pointer of metadata - * @param length Size of metadata - * @return - * - 0: success - * - <0: failure - * @technical preview - */ - virtual int sendAudioMetadata(const char* metadata, size_t length) = 0; -}; - -// The following types are either deprecated or not implmented yet. -enum QUALITY_REPORT_FORMAT_TYPE { - /** 0: The quality report in JSON format, - */ - QUALITY_REPORT_JSON = 0, - /** 1: The quality report in HTML format. - */ - QUALITY_REPORT_HTML = 1, -}; - -/** Media device states. */ -enum MEDIA_DEVICE_STATE_TYPE { - /** 0: The device is ready for use. - */ - MEDIA_DEVICE_STATE_IDLE = 0, - /** 1: The device is active. - */ - MEDIA_DEVICE_STATE_ACTIVE = 1, - /** 2: The device is disabled. - */ - MEDIA_DEVICE_STATE_DISABLED = 2, - /** 4: The device is not present. - */ - MEDIA_DEVICE_STATE_NOT_PRESENT = 4, - /** 8: The device is unplugged. - */ - MEDIA_DEVICE_STATE_UNPLUGGED = 8 -}; - -enum VIDEO_PROFILE_TYPE { - /** 0: 160 x 120 @ 15 fps */ // res fps - VIDEO_PROFILE_LANDSCAPE_120P = 0, // 160x120 15 - /** 2: 120 x 120 @ 15 fps */ - VIDEO_PROFILE_LANDSCAPE_120P_3 = 2, // 120x120 15 - /** 10: 320 x 180 @ 15 fps */ - VIDEO_PROFILE_LANDSCAPE_180P = 10, // 320x180 15 - /** 12: 180 x 180 @ 15 fps */ - VIDEO_PROFILE_LANDSCAPE_180P_3 = 12, // 180x180 15 - /** 13: 240 x 180 @ 15 fps */ - VIDEO_PROFILE_LANDSCAPE_180P_4 = 13, // 240x180 15 - /** 20: 320 x 240 @ 15 fps */ - VIDEO_PROFILE_LANDSCAPE_240P = 20, // 320x240 15 - /** 22: 240 x 240 @ 15 fps */ - VIDEO_PROFILE_LANDSCAPE_240P_3 = 22, // 240x240 15 - /** 23: 424 x 240 @ 15 fps */ - VIDEO_PROFILE_LANDSCAPE_240P_4 = 23, // 424x240 15 - /** 30: 640 x 360 @ 15 fps */ - VIDEO_PROFILE_LANDSCAPE_360P = 30, // 640x360 15 - /** 32: 360 x 360 @ 15 fps */ - VIDEO_PROFILE_LANDSCAPE_360P_3 = 32, // 360x360 15 - /** 33: 640 x 360 @ 30 fps */ - VIDEO_PROFILE_LANDSCAPE_360P_4 = 33, // 640x360 30 - /** 35: 360 x 360 @ 30 fps */ - VIDEO_PROFILE_LANDSCAPE_360P_6 = 35, // 360x360 30 - /** 36: 480 x 360 @ 15 fps */ - VIDEO_PROFILE_LANDSCAPE_360P_7 = 36, // 480x360 15 - /** 37: 480 x 360 @ 30 fps */ - VIDEO_PROFILE_LANDSCAPE_360P_8 = 37, // 480x360 30 - /** 38: 640 x 360 @ 15 fps */ - VIDEO_PROFILE_LANDSCAPE_360P_9 = 38, // 640x360 15 - /** 39: 640 x 360 @ 24 fps */ - VIDEO_PROFILE_LANDSCAPE_360P_10 = 39, // 640x360 24 - /** 100: 640 x 360 @ 24 fps */ - VIDEO_PROFILE_LANDSCAPE_360P_11 = 100, // 640x360 24 - /** 40: 640 x 480 @ 15 fps */ - VIDEO_PROFILE_LANDSCAPE_480P = 40, // 640x480 15 - /** 42: 480 x 480 @ 15 fps */ - VIDEO_PROFILE_LANDSCAPE_480P_3 = 42, // 480x480 15 - /** 43: 640 x 480 @ 30 fps */ - VIDEO_PROFILE_LANDSCAPE_480P_4 = 43, // 640x480 30 - /** 45: 480 x 480 @ 30 fps */ - VIDEO_PROFILE_LANDSCAPE_480P_6 = 45, // 480x480 30 - /** 47: 848 x 480 @ 15 fps */ - VIDEO_PROFILE_LANDSCAPE_480P_8 = 47, // 848x480 15 - /** 48: 848 x 480 @ 30 fps */ - VIDEO_PROFILE_LANDSCAPE_480P_9 = 48, // 848x480 30 - /** 49: 640 x 480 @ 10 fps */ - VIDEO_PROFILE_LANDSCAPE_480P_10 = 49, // 640x480 10 - /** 50: 1280 x 720 @ 15 fps */ - VIDEO_PROFILE_LANDSCAPE_720P = 50, // 1280x720 15 - /** 52: 1280 x 720 @ 30 fps */ - VIDEO_PROFILE_LANDSCAPE_720P_3 = 52, // 1280x720 30 - /** 54: 960 x 720 @ 15 fps */ - VIDEO_PROFILE_LANDSCAPE_720P_5 = 54, // 960x720 15 - /** 55: 960 x 720 @ 30 fps */ - VIDEO_PROFILE_LANDSCAPE_720P_6 = 55, // 960x720 30 - /** 60: 1920 x 1080 @ 15 fps */ - VIDEO_PROFILE_LANDSCAPE_1080P = 60, // 1920x1080 15 - /** 62: 1920 x 1080 @ 30 fps */ - VIDEO_PROFILE_LANDSCAPE_1080P_3 = 62, // 1920x1080 30 - /** 64: 1920 x 1080 @ 60 fps */ - VIDEO_PROFILE_LANDSCAPE_1080P_5 = 64, // 1920x1080 60 - /** 66: 2560 x 1440 @ 30 fps */ - VIDEO_PROFILE_LANDSCAPE_1440P = 66, // 2560x1440 30 - /** 67: 2560 x 1440 @ 60 fps */ - VIDEO_PROFILE_LANDSCAPE_1440P_2 = 67, // 2560x1440 60 - /** 70: 3840 x 2160 @ 30 fps */ - VIDEO_PROFILE_LANDSCAPE_4K = 70, // 3840x2160 30 - /** 72: 3840 x 2160 @ 60 fps */ - VIDEO_PROFILE_LANDSCAPE_4K_3 = 72, // 3840x2160 60 - /** 1000: 120 x 160 @ 15 fps */ - VIDEO_PROFILE_PORTRAIT_120P = 1000, // 120x160 15 - /** 1002: 120 x 120 @ 15 fps */ - VIDEO_PROFILE_PORTRAIT_120P_3 = 1002, // 120x120 15 - /** 1010: 180 x 320 @ 15 fps */ - VIDEO_PROFILE_PORTRAIT_180P = 1010, // 180x320 15 - /** 1012: 180 x 180 @ 15 fps */ - VIDEO_PROFILE_PORTRAIT_180P_3 = 1012, // 180x180 15 - /** 1013: 180 x 240 @ 15 fps */ - VIDEO_PROFILE_PORTRAIT_180P_4 = 1013, // 180x240 15 - /** 1020: 240 x 320 @ 15 fps */ - VIDEO_PROFILE_PORTRAIT_240P = 1020, // 240x320 15 - /** 1022: 240 x 240 @ 15 fps */ - VIDEO_PROFILE_PORTRAIT_240P_3 = 1022, // 240x240 15 - /** 1023: 240 x 424 @ 15 fps */ - VIDEO_PROFILE_PORTRAIT_240P_4 = 1023, // 240x424 15 - /** 1030: 360 x 640 @ 15 fps */ - VIDEO_PROFILE_PORTRAIT_360P = 1030, // 360x640 15 - /** 1032: 360 x 360 @ 15 fps */ - VIDEO_PROFILE_PORTRAIT_360P_3 = 1032, // 360x360 15 - /** 1033: 360 x 640 @ 30 fps */ - VIDEO_PROFILE_PORTRAIT_360P_4 = 1033, // 360x640 30 - /** 1035: 360 x 360 @ 30 fps */ - VIDEO_PROFILE_PORTRAIT_360P_6 = 1035, // 360x360 30 - /** 1036: 360 x 480 @ 15 fps */ - VIDEO_PROFILE_PORTRAIT_360P_7 = 1036, // 360x480 15 - /** 1037: 360 x 480 @ 30 fps */ - VIDEO_PROFILE_PORTRAIT_360P_8 = 1037, // 360x480 30 - /** 1038: 360 x 640 @ 15 fps */ - VIDEO_PROFILE_PORTRAIT_360P_9 = 1038, // 360x640 15 - /** 1039: 360 x 640 @ 24 fps */ - VIDEO_PROFILE_PORTRAIT_360P_10 = 1039, // 360x640 24 - /** 1100: 360 x 640 @ 24 fps */ - VIDEO_PROFILE_PORTRAIT_360P_11 = 1100, // 360x640 24 - /** 1040: 480 x 640 @ 15 fps */ - VIDEO_PROFILE_PORTRAIT_480P = 1040, // 480x640 15 - /** 1042: 480 x 480 @ 15 fps */ - VIDEO_PROFILE_PORTRAIT_480P_3 = 1042, // 480x480 15 - /** 1043: 480 x 640 @ 30 fps */ - VIDEO_PROFILE_PORTRAIT_480P_4 = 1043, // 480x640 30 - /** 1045: 480 x 480 @ 30 fps */ - VIDEO_PROFILE_PORTRAIT_480P_6 = 1045, // 480x480 30 - /** 1047: 480 x 848 @ 15 fps */ - VIDEO_PROFILE_PORTRAIT_480P_8 = 1047, // 480x848 15 - /** 1048: 480 x 848 @ 30 fps */ - VIDEO_PROFILE_PORTRAIT_480P_9 = 1048, // 480x848 30 - /** 1049: 480 x 640 @ 10 fps */ - VIDEO_PROFILE_PORTRAIT_480P_10 = 1049, // 480x640 10 - /** 1050: 720 x 1280 @ 15 fps */ - VIDEO_PROFILE_PORTRAIT_720P = 1050, // 720x1280 15 - /** 1052: 720 x 1280 @ 30 fps */ - VIDEO_PROFILE_PORTRAIT_720P_3 = 1052, // 720x1280 30 - /** 1054: 720 x 960 @ 15 fps */ - VIDEO_PROFILE_PORTRAIT_720P_5 = 1054, // 720x960 15 - /** 1055: 720 x 960 @ 30 fps */ - VIDEO_PROFILE_PORTRAIT_720P_6 = 1055, // 720x960 30 - /** 1060: 1080 x 1920 @ 15 fps */ - VIDEO_PROFILE_PORTRAIT_1080P = 1060, // 1080x1920 15 - /** 1062: 1080 x 1920 @ 30 fps */ - VIDEO_PROFILE_PORTRAIT_1080P_3 = 1062, // 1080x1920 30 - /** 1064: 1080 x 1920 @ 60 fps */ - VIDEO_PROFILE_PORTRAIT_1080P_5 = 1064, // 1080x1920 60 - /** 1066: 1440 x 2560 @ 30 fps */ - VIDEO_PROFILE_PORTRAIT_1440P = 1066, // 1440x2560 30 - /** 1067: 1440 x 2560 @ 60 fps */ - VIDEO_PROFILE_PORTRAIT_1440P_2 = 1067, // 1440x2560 60 - /** 1070: 2160 x 3840 @ 30 fps */ - VIDEO_PROFILE_PORTRAIT_4K = 1070, // 2160x3840 30 - /** 1072: 2160 x 3840 @ 60 fps */ - VIDEO_PROFILE_PORTRAIT_4K_3 = 1072, // 2160x3840 60 - /** Default 640 x 360 @ 15 fps */ - VIDEO_PROFILE_DEFAULT = VIDEO_PROFILE_LANDSCAPE_360P, -}; - -class AAudioDeviceManager : public agora::util::AutoPtr { - public: - AAudioDeviceManager(IRtcEngine* engine) { - queryInterface(engine, AGORA_IID_AUDIO_DEVICE_MANAGER); - } -}; - -class AVideoDeviceManager : public agora::util::AutoPtr { - public: - AVideoDeviceManager(IRtcEngine* engine) { - queryInterface(engine, AGORA_IID_VIDEO_DEVICE_MANAGER); - } -}; - -} // namespace rtc -} // namespace agora - -/** Gets the SDK version number. - -@param build Build number of Agora the SDK. -* @return String of the SDK version. -*/ -#define getAgoraRtcEngineVersion getAgoraSdkVersion - -//////////////////////////////////////////////////////// -/** \addtogroup createAgoraRtcEngine - @{ - */ -//////////////////////////////////////////////////////// - -/** Creates the RTC engine object and returns the pointer. - -* @return Pointer of the RTC engine object. -*/ -AGORA_API agora::rtc::IRtcEngine* AGORA_CALL createAgoraRtcEngine(); - -//////////////////////////////////////////////////////// -/** @} */ -//////////////////////////////////////////////////////// - -/** Creates the RTC engine object and returns the pointer. - - @param err Error Code. -* @return Description of the Error Code: agora::ERROR_CODE_TYPE -*/ -#define getAgoraRtcEngineErrorDescription getAgoraSdkErrorDescription -#define setAgoraRtcEngineExternalSymbolLoader setAgoraSdkExternalSymbolLoader diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtcEngineEx.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtcEngineEx.h deleted file mode 100644 index 423d1964a..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtcEngineEx.h +++ /dev/null @@ -1,1992 +0,0 @@ -// -// Agora Media SDK -// -// Created by Sting Feng in 2015-05. -// Updated by Tommy Miao in 2020-11. -// Copyright (c) 2015 Agora IO. All rights reserved. -// -#pragma once - -#include "IAgoraRtcEngine.h" - -namespace agora { -namespace rtc { - -// OPTIONAL_ENUM_CLASS RTC_EVENT; - -/** - * Rtc Connection. - */ -struct RtcConnection { - /** - * The unique channel name for the AgoraRTC session in the string format. The string - * length must be less than 64 bytes. Supported character scopes are: - * - All lowercase English letters: a to z. - * - All uppercase English letters: A to Z. - * - All numeric characters: 0 to 9. - * - The space character. - * - Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", - * ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",". - */ - const char* channelId; - /** - * User ID: A 32-bit unsigned integer ranging from 1 to (2^32-1). It must be unique. - */ - uid_t localUid; - - RtcConnection() : channelId(NULL), localUid(0) {} - RtcConnection(const char* channel_id, uid_t local_uid) - : channelId(channel_id), localUid(local_uid) {} -}; - -class IRtcEngineEventHandlerEx : public IRtcEngineEventHandler { - public: - using IRtcEngineEventHandler::eventHandlerType; - using IRtcEngineEventHandler::onJoinChannelSuccess; - using IRtcEngineEventHandler::onRejoinChannelSuccess; - using IRtcEngineEventHandler::onAudioQuality; - using IRtcEngineEventHandler::onAudioVolumeIndication; - using IRtcEngineEventHandler::onLeaveChannel; - using IRtcEngineEventHandler::onRtcStats; - using IRtcEngineEventHandler::onNetworkQuality; - using IRtcEngineEventHandler::onIntraRequestReceived; - using IRtcEngineEventHandler::onFirstLocalVideoFramePublished; - using IRtcEngineEventHandler::onFirstRemoteVideoDecoded; - using IRtcEngineEventHandler::onVideoSizeChanged; - using IRtcEngineEventHandler::onLocalVideoStateChanged; - using IRtcEngineEventHandler::onRemoteVideoStateChanged; - using IRtcEngineEventHandler::onFirstRemoteVideoFrame; - using IRtcEngineEventHandler::onUserJoined; - using IRtcEngineEventHandler::onUserOffline; - using IRtcEngineEventHandler::onUserMuteAudio; - using IRtcEngineEventHandler::onUserMuteVideo; - using IRtcEngineEventHandler::onUserEnableVideo; - using IRtcEngineEventHandler::onUserEnableLocalVideo; - using IRtcEngineEventHandler::onUserStateChanged; - using IRtcEngineEventHandler::onLocalAudioStats; - using IRtcEngineEventHandler::onRemoteAudioStats; - using IRtcEngineEventHandler::onLocalVideoStats; - using IRtcEngineEventHandler::onRemoteVideoStats; - using IRtcEngineEventHandler::onConnectionLost; - using IRtcEngineEventHandler::onConnectionInterrupted; - using IRtcEngineEventHandler::onConnectionBanned; - using IRtcEngineEventHandler::onStreamMessage; - using IRtcEngineEventHandler::onStreamMessageError; - using IRtcEngineEventHandler::onRequestToken; - using IRtcEngineEventHandler::onTokenPrivilegeWillExpire; - using IRtcEngineEventHandler::onLicenseValidationFailure; - using IRtcEngineEventHandler::onFirstLocalAudioFramePublished; - using IRtcEngineEventHandler::onFirstRemoteAudioFrame; - using IRtcEngineEventHandler::onFirstRemoteAudioDecoded; - using IRtcEngineEventHandler::onLocalAudioStateChanged; - using IRtcEngineEventHandler::onRemoteAudioStateChanged; - using IRtcEngineEventHandler::onActiveSpeaker; - using IRtcEngineEventHandler::onClientRoleChanged; - using IRtcEngineEventHandler::onClientRoleChangeFailed; - using IRtcEngineEventHandler::onRemoteAudioTransportStats; - using IRtcEngineEventHandler::onRemoteVideoTransportStats; - using IRtcEngineEventHandler::onConnectionStateChanged; - using IRtcEngineEventHandler::onWlAccMessage; - using IRtcEngineEventHandler::onWlAccStats; - using IRtcEngineEventHandler::onNetworkTypeChanged; - using IRtcEngineEventHandler::onEncryptionError; - using IRtcEngineEventHandler::onUploadLogResult; - using IRtcEngineEventHandler::onUserInfoUpdated; - using IRtcEngineEventHandler::onUserAccountUpdated; - using IRtcEngineEventHandler::onAudioSubscribeStateChanged; - using IRtcEngineEventHandler::onVideoSubscribeStateChanged; - using IRtcEngineEventHandler::onAudioPublishStateChanged; - using IRtcEngineEventHandler::onVideoPublishStateChanged; - using IRtcEngineEventHandler::onSnapshotTaken; - using IRtcEngineEventHandler::onVideoRenderingTracingResult; - using IRtcEngineEventHandler::onSetRtmFlagResult; - using IRtcEngineEventHandler::onTranscodedStreamLayoutInfo; - using IRtcEngineEventHandler::onAudioMetadataReceived; - - virtual const char* eventHandlerType() const { return "event_handler_ex"; } - - /** - * Occurs when a user joins a channel. - * - * This callback notifies the application that a user joins a specified channel. - * - * @param connection The RtcConnection object. - * @param elapsed The time elapsed (ms) from the local user calling joinChannel until the SDK triggers this callback. - */ - virtual void onJoinChannelSuccess(const RtcConnection& connection, int elapsed) { - (void)connection; - (void)elapsed; - } - - /** - * Occurs when a user rejoins the channel. - * - * When a user loses connection with the server because of network problems, the SDK automatically tries to reconnect - * and triggers this callback upon reconnection. - * - * @param connection The RtcConnection object. - * @param elapsed Time elapsed (ms) from the local user calling the joinChannel method until this callback is triggered. - */ - virtual void onRejoinChannelSuccess(const RtcConnection& connection, int elapsed) { - (void)connection; - (void)elapsed; - } - - /** Reports the statistics of the audio stream from each remote - user/broadcaster. - - @deprecated This callback is deprecated. Use onRemoteAudioStats instead. - - The SDK triggers this callback once every two seconds to report the audio - quality of each remote user/host sending an audio stream. If a channel has - multiple remote users/hosts sending audio streams, the SDK triggers this - callback as many times. - - @param connection The RtcConnection object. - @param remoteUid The user ID of the remote user sending the audio stream. - @param quality The audio quality of the user: #QUALITY_TYPE - @param delay The network delay (ms) from the sender to the receiver, including the delay caused by audio sampling pre-processing, network transmission, and network jitter buffering. - @param lost The audio packet loss rate (%) from the sender to the receiver. - */ - virtual void onAudioQuality(const RtcConnection& connection, uid_t remoteUid, int quality, unsigned short delay, unsigned short lost) __deprecated { - (void)connection; - (void)remoteUid; - (void)quality; - (void)delay; - (void)lost; - } - /** - * Reports the volume information of users. - * - * By default, this callback is disabled. You can enable it by calling `enableAudioVolumeIndication`. Once this - * callback is enabled and users send streams in the channel, the SDK triggers the `onAudioVolumeIndication` - * callback at the time interval set in `enableAudioVolumeIndication`. The SDK triggers two independent - * `onAudioVolumeIndication` callbacks simultaneously, which separately report the volume information of the - * local user who sends a stream and the remote users (up to three) whose instantaneous volume is the highest. - * - * @note After you enable this callback, calling muteLocalAudioStream affects the SDK's behavior as follows: - * - If the local user stops publishing the audio stream, the SDK stops triggering the local user's callback. - * - 20 seconds after a remote user whose volume is one of the three highest stops publishing the audio stream, - * the callback excludes this user's information; 20 seconds after all remote users stop publishing audio streams, - * the SDK stops triggering the callback for remote users. - * - * @param connection The RtcConnection object. - * @param speakers The volume information of the users, see AudioVolumeInfo. An empty `speakers` array in the - * callback indicates that no remote user is in the channel or sending a stream at the moment. - * @param speakerNumber The total number of speakers. - * - In the local user's callback, when the local user sends a stream, `speakerNumber` is 1. - * - In the callback for remote users, the value range of speakerNumber is [0,3]. If the number of remote users who - * send streams is greater than or equal to three, the value of `speakerNumber` is 3. - * @param totalVolume The volume of the speaker. The value ranges between 0 (lowest volume) and 255 (highest volume). - * - In the local user's callback, `totalVolume` is the volume of the local user who sends a stream. - * - In the remote users' callback, `totalVolume` is the sum of all remote users (up to three) whose instantaneous - * volume is the highest. If the user calls `startAudioMixing`, `totalVolume` is the volume after audio mixing. - */ - virtual void onAudioVolumeIndication(const RtcConnection& connection, const AudioVolumeInfo* speakers, - unsigned int speakerNumber, int totalVolume) { - (void)connection; - (void)speakers; - (void)speakerNumber; - (void)totalVolume; - } - - /** - * Occurs when a user leaves a channel. - * - * This callback notifies the app that the user leaves the channel by calling `leaveChannel`. From this callback, - * the app can get information such as the call duration and quality statistics. - * - * @param connection The RtcConnection object. - * @param stats The statistics on the call: RtcStats. - */ - virtual void onLeaveChannel(const RtcConnection& connection, const RtcStats& stats) { - (void)connection; - (void)stats; - } - - /** - * Reports the statistics of the current call. - * - * The SDK triggers this callback once every two seconds after the user joins the channel. - * - * @param connection The RtcConnection object. - * @param stats The statistics of the current call: RtcStats. - */ - virtual void onRtcStats(const RtcConnection& connection, const RtcStats& stats) { - (void)connection; - (void)stats; - } - - /** - * Reports the last mile network quality of each user in the channel. - * - * This callback reports the last mile network conditions of each user in the channel. Last mile refers to the - * connection between the local device and Agora's edge server. - * - * The SDK triggers this callback once every two seconds. If a channel includes multiple users, the SDK triggers - * this callback as many times. - * - * @note `txQuality` is UNKNOWN when the user is not sending a stream; `rxQuality` is UNKNOWN when the user is not - * receiving a stream. - * - * @param connection The RtcConnection object. - * @param remoteUid The user ID. The network quality of the user with this user ID is reported. - * @param txQuality Uplink network quality rating of the user in terms of the transmission bit rate, packet loss rate, - * average RTT (Round-Trip Time) and jitter of the uplink network. This parameter is a quality rating helping you - * understand how well the current uplink network conditions can support the selected video encoder configuration. - * For example, a 1000 Kbps uplink network may be adequate for video frames with a resolution of 640 × 480 and a frame - * rate of 15 fps in the LIVE_BROADCASTING profile, but may be inadequate for resolutions higher than 1280 × 720. - * See #QUALITY_TYPE. - * @param rxQuality Downlink network quality rating of the user in terms of packet loss rate, average RTT, and jitter - * of the downlink network. See #QUALITY_TYPE. - */ - virtual void onNetworkQuality(const RtcConnection& connection, uid_t remoteUid, int txQuality, int rxQuality) { - (void)connection; - (void)remoteUid; - (void)txQuality; - (void)rxQuality; - } - - /** - * Occurs when intra request from remote user is received. - * - * This callback is triggered once remote user needs one Key frame. - * - * @param connection The RtcConnection object. - */ - virtual void onIntraRequestReceived(const RtcConnection& connection) { - (void)connection; - } - - /** Occurs when the first local video frame is published. - * The SDK triggers this callback under one of the following circumstances: - * - The local client enables the video module and calls `joinChannel` successfully. - * - The local client calls `muteLocalVideoStream(true)` and muteLocalVideoStream(false) in sequence. - * - The local client calls `disableVideo` and `enableVideo` in sequence. - * - The local client calls `pushVideoFrame` to successfully push the video frame to the SDK. - * - * @param connection The RtcConnection object. - * @param elapsed The time elapsed (ms) from the local user calling joinChannel` to the SDK triggers - * this callback. - */ - virtual void onFirstLocalVideoFramePublished(const RtcConnection& connection, int elapsed) { - (void)connection; - (void)elapsed; - } - - /** Occurs when the first remote video frame is received and decoded. - - The SDK triggers this callback under one of the following circumstances: - - The remote user joins the channel and sends the video stream. - - The remote user stops sending the video stream and re-sends it after 15 seconds. Reasons for such an interruption include: - - The remote user leaves the channel. - - The remote user drops offline. - - The remote user calls `muteLocalVideoStream` to stop sending the video stream. - - The remote user calls `disableVideo` to disable video. - - @param connection The RtcConnection object. - @param remoteUid The user ID of the remote user sending the video stream. - @param width The width (pixels) of the video stream. - @param height The height (pixels) of the video stream. - @param elapsed The time elapsed (ms) from the local user calling `joinChannel` - until the SDK triggers this callback. - */ - virtual void onFirstRemoteVideoDecoded(const RtcConnection& connection, uid_t remoteUid, int width, int height, int elapsed) { - (void)connection; - (void)remoteUid; - (void)width; - (void)height; - (void)elapsed; - } - - /** - * Occurs when the local or remote video size or rotation has changed. - * - * @param connection The RtcConnection object. - * @param sourceType The video source type: #VIDEO_SOURCE_TYPE. - * @param uid The user ID. 0 indicates the local user. - * @param width The new width (pixels) of the video. - * @param height The new height (pixels) of the video. - * @param rotation The rotation information of the video. - */ - virtual void onVideoSizeChanged(const RtcConnection& connection, VIDEO_SOURCE_TYPE sourceType, uid_t uid, int width, int height, int rotation) { - (void)connection; - (void)sourceType; - (void)uid; - (void)width; - (void)height; - (void)rotation; - } - - /** - * Occurs when the remote video state changes. - * - * @note This callback does not work properly when the number of users (in the voice/video call - * channel) or hosts (in the live streaming channel) in the channel exceeds 17. - * - * @param connection The RtcConnection object. - * @param remoteUid The ID of the user whose video state has changed. - * @param state The remote video state: #REMOTE_VIDEO_STATE. - * @param reason The reason of the remote video state change: #REMOTE_VIDEO_STATE_REASON. - * @param elapsed The time elapsed (ms) from the local client calling `joinChannel` until this callback is triggered. - */ - virtual void onRemoteVideoStateChanged(const RtcConnection& connection, uid_t remoteUid, REMOTE_VIDEO_STATE state, REMOTE_VIDEO_STATE_REASON reason, int elapsed) { - (void)connection; - (void)remoteUid; - (void)state; - (void)reason; - (void)elapsed; - } - - /** Occurs when the renderer receives the first frame of the remote video. - * - * @param connection The RtcConnection object. - * @param remoteUid The user ID of the remote user sending the video stream. - * @param width The width (px) of the video frame. - * @param height The height (px) of the video stream. - * @param elapsed The time elapsed (ms) from the local user calling `joinChannel` until the SDK triggers this callback. - */ - virtual void onFirstRemoteVideoFrame(const RtcConnection& connection, uid_t remoteUid, int width, int height, int elapsed) { - (void)connection; - (void)remoteUid; - (void)width; - (void)height; - (void)elapsed; - } - - /** - * Occurs when a remote user or broadcaster joins the channel. - * - * - In the COMMUNICATION channel profile, this callback indicates that a remote user joins the channel. - * The SDK also triggers this callback to report the existing users in the channel when a user joins the - * channel. - * In the LIVE_BROADCASTING channel profile, this callback indicates that a host joins the channel. The - * SDK also triggers this callback to report the existing hosts in the channel when a host joins the - * channel. Agora recommends limiting the number of hosts to 17. - * - * The SDK triggers this callback under one of the following circumstances: - * - A remote user/host joins the channel by calling the `joinChannel` method. - * - A remote user switches the user role to the host after joining the channel. - * - A remote user/host rejoins the channel after a network interruption. - * - * @param connection The RtcConnection object. - * @param remoteUid The ID of the remote user or broadcaster joining the channel. - * @param elapsed The time elapsed (ms) from the local user calling `joinChannel` or `setClientRole` - * until this callback is triggered. - */ - virtual void onUserJoined(const RtcConnection& connection, uid_t remoteUid, int elapsed) { - (void)connection; - (void)remoteUid; - (void)elapsed; - } - - /** - * Occurs when a remote user or broadcaster goes offline. - * - * There are two reasons for a user to go offline: - * - Leave the channel: When the user leaves the channel, the user sends a goodbye message. When this - * message is received, the SDK determines that the user leaves the channel. - * - Drop offline: When no data packet of the user is received for a certain period of time, the SDK assumes - * that the user drops offline. A poor network connection may lead to false detection, so we recommend using - * the RTM SDK for reliable offline detection. - * - The user switches the user role from a broadcaster to an audience. - * - * @param connection The RtcConnection object. - * @param remoteUid The ID of the remote user or broadcaster who leaves the channel or drops offline. - * @param reason The reason why the remote user goes offline: #USER_OFFLINE_REASON_TYPE. - */ - virtual void onUserOffline(const RtcConnection& connection, uid_t remoteUid, USER_OFFLINE_REASON_TYPE reason) { - (void)connection; - (void)remoteUid; - (void)reason; - } - - /** Occurs when a remote user's audio stream playback pauses/resumes. - * The SDK triggers this callback when the remote user stops or resumes sending the audio stream by - * calling the `muteLocalAudioStream` method. - * @note This callback can be inaccurate when the number of users (in the `COMMUNICATION` profile) or hosts (in the `LIVE_BROADCASTING` profile) in the channel exceeds 17. - * - * @param connection The RtcConnection object. - * @param remoteUid The user ID. - * @param muted Whether the remote user's audio stream is muted/unmuted: - * - true: Muted. - * - false: Unmuted. - */ - virtual void onUserMuteAudio(const RtcConnection& connection, uid_t remoteUid, bool muted) __deprecated { - (void)connection; - (void)remoteUid; - (void)muted; - } - - /** Occurs when a remote user pauses or resumes sending the video stream. - * - * When a remote user calls `muteLocalVideoStream` to stop or resume publishing the video stream, the - * SDK triggers this callback to report the state of the remote user's publishing stream to the local - * user. - * - * @note This callback can be inaccurate when the number of users or broadacasters in a - * channel exceeds 20. - * - * @param connection The RtcConnection object. - * @param remoteUid ID of the remote user. - * @param muted Whether the remote user stops publishing the video stream: - * - true: The remote user has paused sending the video stream. - * - false: The remote user has resumed sending the video stream. - */ - virtual void onUserMuteVideo(const RtcConnection& connection, uid_t remoteUid, bool muted) { - (void)connection; - (void)remoteUid; - (void)muted; - } - - /** Occurs when a remote user enables or disables the video module. - - Once the video function is disabled, the users cannot see any video. - - The SDK triggers this callback when a remote user enables or disables the video module by calling the - `enableVideo` or `disableVideo` method. - - @param connection The RtcConnection object. - @param remoteUid The ID of the remote user. - @param enabled Whether the video of the remote user is enabled: - - true: The remote user has enabled video. - - false: The remote user has disabled video. - */ - virtual void onUserEnableVideo(const RtcConnection& connection, uid_t remoteUid, bool enabled) { - (void)connection; - (void)remoteUid; - (void)enabled; - } - - /** Occurs when a remote user enables or disables local video capturing. - - The SDK triggers this callback when the remote user resumes or stops capturing the video stream by - calling the `enableLocalVideo` method. - - @param connection The RtcConnection object. - @param remoteUid The ID of the remote user. - @param enabled Whether the specified remote user enables/disables local video: - - `true`: The remote user has enabled local video capturing. - - `false`: The remote user has disabled local video capturing. - */ - virtual void onUserEnableLocalVideo(const RtcConnection& connection, uid_t remoteUid, bool enabled) __deprecated { - (void)connection; - (void)remoteUid; - (void)enabled; - } - - /** - * Occurs when the remote user state is updated. - * - * @param connection The RtcConnection object. - * @param remoteUid The uid of the remote user. - * @param state The remote user state: #REMOTE_USER_STATE. - */ - virtual void onUserStateChanged(const RtcConnection& connection, uid_t remoteUid, uint32_t state) { - (void)connection; - (void)remoteUid; - (void)state; - } - - /** Reports the statistics of the local audio stream. - * - * The SDK triggers this callback once every two seconds. - * - * @param connection The RtcConnection object. - * @param stats The statistics of the local audio stream. - * See LocalAudioStats. - */ - virtual void onLocalAudioStats(const RtcConnection& connection, const LocalAudioStats& stats) { - (void)connection; - (void)stats; - } - - /** Reports the statistics of the audio stream from each remote user/host. - - The SDK triggers this callback once every two seconds for each remote user who is sending audio - streams. If a channel includes multiple remote users, the SDK triggers this callback as many times. - @param connection The RtcConnection object. - @param stats Statistics of the received remote audio streams. See RemoteAudioStats. - */ - virtual void onRemoteAudioStats(const RtcConnection& connection, const RemoteAudioStats& stats) { - (void)connection; - (void)stats; - } - - /** Reports the statistics of the local video stream. - * - * The SDK triggers this callback once every two seconds for each - * user/host. If there are multiple users/hosts in the channel, the SDK - * triggers this callback as many times. - * - * @note If you have called the `enableDualStreamMode` - * method, this callback reports the statistics of the high-video - * stream (high bitrate, and high-resolution video stream). - * - * @param connection The RtcConnection object. - * @param stats Statistics of the local video stream. See LocalVideoStats. - */ - virtual void onLocalVideoStats(const RtcConnection& connection, const LocalVideoStats& stats) { - (void)connection; - (void)stats; - } - - /** Reports the statistics of the video stream from each remote user/host. - * - * The SDK triggers this callback once every two seconds for each remote user. If a channel has - * multiple users/hosts sending video streams, the SDK triggers this callback as many times. - * - * @param connection The RtcConnection object. - * @param stats Statistics of the remote video stream. See - * RemoteVideoStats. - */ - virtual void onRemoteVideoStats(const RtcConnection& connection, const RemoteVideoStats& stats) { - (void)connection; - (void)stats; - } - - /** - * Occurs when the SDK cannot reconnect to the server 10 seconds after its connection to the server is - * interrupted. - * - * The SDK triggers this callback when it cannot connect to the server 10 seconds after calling - * `joinChannel`, regardless of whether it is in the channel or not. If the SDK fails to rejoin - * the channel 20 minutes after being disconnected from Agora's edge server, the SDK stops rejoining the channel. - * - * @param connection The RtcConnection object. - */ - virtual void onConnectionLost(const RtcConnection& connection) { - (void)connection; - } - - /** Occurs when the connection between the SDK and the server is interrupted. - * @deprecated Use `onConnectionStateChanged` instead. - - The SDK triggers this callback when it loses connection with the serer for more - than 4 seconds after the connection is established. After triggering this - callback, the SDK tries to reconnect to the server. If the reconnection fails - within a certain period (10 seconds by default), the onConnectionLost() - callback is triggered. If the SDK fails to rejoin the channel 20 minutes after - being disconnected from Agora's edge server, the SDK stops rejoining the channel. - - @param connection The RtcConnection object. - - */ - virtual void onConnectionInterrupted(const RtcConnection& connection) __deprecated { - (void)connection; - } - - /** Occurs when your connection is banned by the Agora Server. - * - * @param connection The RtcConnection object. - */ - virtual void onConnectionBanned(const RtcConnection& connection) { - (void)connection; - } - - /** Occurs when the local user receives the data stream from the remote user. - * - * The SDK triggers this callback when the user receives the data stream that another user sends - * by calling the \ref agora::rtc::IRtcEngine::sendStreamMessage "sendStreamMessage" method. - * - * @param connection The RtcConnection object. - * @param remoteUid ID of the user who sends the data stream. - * @param streamId The ID of the stream data. - * @param data The data stream. - * @param length The length (byte) of the data stream. - * @param sentTs The time when the data stream sent. - */ - virtual void onStreamMessage(const RtcConnection& connection, uid_t remoteUid, int streamId, const char* data, size_t length, uint64_t sentTs) { - (void)connection; - (void)remoteUid; - (void)streamId; - (void)data; - (void)length; - (void)sentTs; - } - - /** Occurs when the local user does not receive the data stream from the remote user. - * - * The SDK triggers this callback when the user fails to receive the data stream that another user sends - * by calling the \ref agora::rtc::IRtcEngine::sendStreamMessage "sendStreamMessage" method. - * - * @param connection The RtcConnection object. - * @param remoteUid ID of the user who sends the data stream. - * @param streamId The ID of the stream data. - * @param code The error code. - * @param missed The number of lost messages. - * @param cached The number of incoming cached messages when the data stream is - * interrupted. - */ - virtual void onStreamMessageError(const RtcConnection& connection, uid_t remoteUid, int streamId, int code, int missed, int cached) { - (void)connection; - (void)remoteUid; - (void)streamId; - (void)code; - (void)missed; - (void)cached; - } - - /** - * Occurs when the token expires. - * - * When the token expires during a call, the SDK triggers this callback to remind the app to renew the token. - * - * Upon receiving this callback, generate a new token at your app server and call - * `joinChannel` to pass the new token to the SDK. - * - * @param connection The RtcConnection object. - */ - virtual void onRequestToken(const RtcConnection& connection) { - (void)connection; - } - - /** - * Occurs when connection license verification fails. - * - * You can know the reason accordding to error code - */ - virtual void onLicenseValidationFailure(const RtcConnection& connection, LICENSE_ERROR_TYPE reason) { - (void)connection; - (void)reason; - } - - /** - * Occurs when the token will expire in 30 seconds. - * - * When the token is about to expire in 30 seconds, the SDK triggers this callback to remind the app to renew the token. - - * Upon receiving this callback, generate a new token at your app server and call - * \ref IRtcEngine::renewToken "renewToken" to pass the new Token to the SDK. - * - * @param connection The RtcConnection object. - * @param token The token that will expire in 30 seconds. - */ - virtual void onTokenPrivilegeWillExpire(const RtcConnection& connection, const char* token) { - (void)connection; - (void)token; - } - - /** Occurs when the first local audio frame is published. - * - * The SDK triggers this callback under one of the following circumstances: - * - The local client enables the audio module and calls `joinChannel` successfully. - * - The local client calls `muteLocalAudioStream(true)` and `muteLocalAudioStream(false)` in sequence. - * - The local client calls `disableAudio` and `enableAudio` in sequence. - * - The local client calls `pushAudioFrame` to successfully push the audio frame to the SDK. - * - * @param connection The RtcConnection object. - * @param elapsed The time elapsed (ms) from the local user calling `joinChannel` to the SDK triggers this callback. - */ - virtual void onFirstLocalAudioFramePublished(const RtcConnection& connection, int elapsed) { - (void)connection; - (void)elapsed; - } - - /** Occurs when the SDK receives the first audio frame from a specific remote user. - * @deprecated Use `onRemoteAudioStateChanged` instead. - * - * @param connection The RtcConnection object. - * @param userId ID of the remote user. - * @param elapsed The time elapsed (ms) from the loca user calling `joinChannel` - * until this callback is triggered. - */ - virtual void onFirstRemoteAudioFrame(const RtcConnection& connection, uid_t userId, int elapsed) __deprecated { - (void)connection; - (void)userId; - (void)elapsed; - } - - /** - * Occurs when the SDK decodes the first remote audio frame for playback. - * - * @deprecated Use `onRemoteAudioStateChanged` instead. - * The SDK triggers this callback under one of the following circumstances: - * - The remote user joins the channel and sends the audio stream for the first time. - * - The remote user's audio is offline and then goes online to re-send audio. It means the local user cannot - * receive audio in 15 seconds. Reasons for such an interruption include: - * - The remote user leaves channel. - * - The remote user drops offline. - * - The remote user calls muteLocalAudioStream to stop sending the audio stream. - * - The remote user calls disableAudio to disable audio. - * @param connection The RtcConnection object. - * @param uid User ID of the remote user sending the audio stream. - * @param elapsed The time elapsed (ms) from the loca user calling `joinChannel` - * until this callback is triggered. - */ - virtual void onFirstRemoteAudioDecoded(const RtcConnection& connection, uid_t uid, int elapsed) __deprecated { - (void)connection; - (void)uid; - (void)elapsed; - } - - /** Occurs when the local audio state changes. - * - * When the state of the local audio stream changes (including the state of the audio capture and encoding), the SDK - * triggers this callback to report the current state. This callback indicates the state of the local audio stream, - * and allows you to troubleshoot issues when audio exceptions occur. - * - * @note - * When the state is `LOCAL_AUDIO_STREAM_STATE_FAILED(3)`, see the `error` - * parameter for details. - * - * @param connection The RtcConnection object. - * @param state State of the local audio. See #LOCAL_AUDIO_STREAM_STATE. - * @param reason The reason information of the local audio. - * See #LOCAL_AUDIO_STREAM_REASON. - */ - virtual void onLocalAudioStateChanged(const RtcConnection& connection, LOCAL_AUDIO_STREAM_STATE state, LOCAL_AUDIO_STREAM_REASON reason) { - (void)connection; - (void)state; - (void)reason; - } - - /** Occurs when the remote audio state changes. - * - * When the audio state of a remote user (in the voice/video call channel) or host (in the live streaming channel) - * changes, the SDK triggers this callback to report the current state of the remote audio stream. - * - * @note This callback does not work properly when the number of users (in the voice/video call channel) or hosts - * (in the live streaming channel) in the channel exceeds 17. - * - * @param connection The RtcConnection object. - * @param remoteUid ID of the remote user whose audio state changes. - * @param state State of the remote audio. See #REMOTE_AUDIO_STATE. - * @param reason The reason of the remote audio state change. - * See #REMOTE_AUDIO_STATE_REASON. - * @param elapsed Time elapsed (ms) from the local user calling the - * `joinChannel` method until the SDK - * triggers this callback. - */ - virtual void onRemoteAudioStateChanged(const RtcConnection& connection, uid_t remoteUid, REMOTE_AUDIO_STATE state, REMOTE_AUDIO_STATE_REASON reason, int elapsed) { - (void)connection; - (void)remoteUid; - (void)state; - (void)reason; - (void)elapsed; - } - - /** - * Occurs when an active speaker is detected. - * - * After a successful call of `enableAudioVolumeIndication`, the SDK continuously detects which remote user has the - * loudest volume. During the current period, the remote user, who is detected as the loudest for the most times, - * is the most active user. - * - * When the number of users is no less than two and an active remote speaker exists, the SDK triggers this callback and reports the uid of the most active remote speaker. - * - If the most active remote speaker is always the same user, the SDK triggers the `onActiveSpeaker` callback only once. - * - If the most active remote speaker changes to another user, the SDK triggers this callback again and reports the uid of the new active remote speaker. - * - * @param connection The RtcConnection object. - * @param uid The ID of the active speaker. A `uid` of 0 means the local user. - */ - virtual void onActiveSpeaker(const RtcConnection& connection, uid_t uid) { - (void)connection; - (void)uid; - } - - /** - * Occurs when the user role switches in the interactive live streaming. - * - * @param connection The RtcConnection of the local user: #RtcConnection - * @param oldRole The old role of the user: #CLIENT_ROLE_TYPE - * @param newRole The new role of the user: #CLIENT_ROLE_TYPE - * @param newRoleOptions The client role options of the new role: #ClientRoleOptions. - */ - virtual void onClientRoleChanged(const RtcConnection& connection, CLIENT_ROLE_TYPE oldRole, CLIENT_ROLE_TYPE newRole, const ClientRoleOptions& newRoleOptions) { - (void)connection; - (void)oldRole; - (void)newRole; - (void)newRoleOptions; - } - - /** - * Occurs when the user role in a Live-Broadcast channel fails to switch, for example, from a broadcaster - * to an audience or vice versa. - * - * @param connection The RtcConnection object. - * @param reason The reason for failing to change the client role: #CLIENT_ROLE_CHANGE_FAILED_REASON. - * @param currentRole The current role of the user: #CLIENT_ROLE_TYPE. - */ - virtual void onClientRoleChangeFailed(const RtcConnection& connection, CLIENT_ROLE_CHANGE_FAILED_REASON reason, CLIENT_ROLE_TYPE currentRole) { - (void)connection; - (void)reason; - (void)currentRole; - } - - /** Reports the transport-layer statistics of each remote audio stream. - * @deprecated Use `onRemoteAudioStats` instead. - - This callback reports the transport-layer statistics, such as the packet loss rate and network time delay, once every - two seconds after the local user receives an audio packet from a remote user. During a call, when the user receives - the audio packet sent by the remote user/host, the callback is triggered every 2 seconds. - - @param connection The RtcConnection object. - @param remoteUid ID of the remote user whose audio data packet is received. - @param delay The network time delay (ms) from the sender to the receiver. - @param lost The Packet loss rate (%) of the audio packet sent from the remote - user. - @param rxKBitRate Received bitrate (Kbps) of the audio packet sent from the - remote user. - */ - virtual void onRemoteAudioTransportStats(const RtcConnection& connection, uid_t remoteUid, unsigned short delay, unsigned short lost, - unsigned short rxKBitRate) __deprecated { - (void)connection; - (void)remoteUid; - (void)delay; - (void)lost; - (void)rxKBitRate; - } - - /** Reports the transport-layer statistics of each remote video stream. - * @deprecated Use `onRemoteVideoStats` instead. - - This callback reports the transport-layer statistics, such as the packet loss rate and network time - delay, once every two seconds after the local user receives a video packet from a remote user. - - During a call, when the user receives the video packet sent by the remote user/host, the callback is - triggered every 2 seconds. - - @param connection The RtcConnection object. - @param remoteUid ID of the remote user whose video packet is received. - @param delay The network time delay (ms) from the remote user sending the - video packet to the local user. - @param lost The packet loss rate (%) of the video packet sent from the remote - user. - @param rxKBitRate The bitrate (Kbps) of the video packet sent from - the remote user. - */ - virtual void onRemoteVideoTransportStats(const RtcConnection& connection, uid_t remoteUid, unsigned short delay, unsigned short lost, - unsigned short rxKBitRate) __deprecated { - (void)connection; - (void)remoteUid; - (void)delay; - (void)lost; - (void)rxKBitRate; - } - - /** Occurs when the network connection state changes. - * - * When the network connection state changes, the SDK triggers this callback and reports the current - * connection state and the reason for the change. - * - * @param connection The RtcConnection object. - * @param state The current connection state. See #CONNECTION_STATE_TYPE. - * @param reason The reason for a connection state change. See #CONNECTION_CHANGED_REASON_TYPE. - */ - virtual void onConnectionStateChanged(const RtcConnection& connection, - CONNECTION_STATE_TYPE state, - CONNECTION_CHANGED_REASON_TYPE reason) { - (void)connection; - (void)state; - (void)reason; - } - - /** Occurs when the WIFI message need be sent to the user. - * - * @param connection The RtcConnection object. - * @param reason The reason of notifying the user of a message. - * @param action Suggest an action for the user. - * @param wlAccMsg The message content of notifying the user. - */ - virtual void onWlAccMessage(const RtcConnection& connection, WLACC_MESSAGE_REASON reason, WLACC_SUGGEST_ACTION action, const char* wlAccMsg) { - (void)connection; - (void)reason; - (void)action; - (void)wlAccMsg; - } - - /** Occurs when SDK statistics wifi acceleration optimization effect. - * - * @param connection The RtcConnection object. - * @param currentStats Instantaneous value of optimization effect. - * @param averageStats Average value of cumulative optimization effect. - */ - virtual void onWlAccStats(const RtcConnection& connection, WlAccStats currentStats, WlAccStats averageStats) { - (void)connection; - (void)currentStats; - (void)averageStats; - } - - /** Occurs when the local network type changes. - * - * This callback occurs when the connection state of the local user changes. You can get the - * connection state and reason for the state change in this callback. When the network connection - * is interrupted, this callback indicates whether the interruption is caused by a network type - * change or poor network conditions. - * @param connection The RtcConnection object. - * @param type The type of the local network connection. See #NETWORK_TYPE. - */ - virtual void onNetworkTypeChanged(const RtcConnection& connection, NETWORK_TYPE type) { - (void)connection; - (void)type; - } - - /** Reports the built-in encryption errors. - * - * When encryption is enabled by calling `enableEncryption`, the SDK triggers this callback if an - * error occurs in encryption or decryption on the sender or the receiver side. - * @param connection The RtcConnection object. - * @param errorType The error type. See #ENCRYPTION_ERROR_TYPE. - */ - virtual void onEncryptionError(const RtcConnection& connection, ENCRYPTION_ERROR_TYPE errorType) { - (void)connection; - (void)errorType; - } - /** - * Reports the user log upload result - * @param connection The RtcConnection object. - * @param requestId RequestId of the upload - * @param success Is upload success - * @param reason Reason of the upload, 0: OK, 1 Network Error, 2 Server Error. - */ - virtual void onUploadLogResult(const RtcConnection& connection, const char* requestId, bool success, UPLOAD_ERROR_REASON reason) { - (void)connection; - (void)requestId; - (void)success; - (void)reason; - } - - /** - * Occurs when the user account is updated. - * - * @param connection The RtcConnection object. - * @param remoteUid The user ID. - * @param userAccount The user account. - */ - virtual void onUserAccountUpdated(const RtcConnection& connection, uid_t remoteUid, const char* remoteUserAccount){ - (void)connection; - (void)remoteUid; - (void)remoteUserAccount; - } - - /** Reports the result of taking a video snapshot. - * - * After a successful `takeSnapshot` method call, the SDK triggers this callback to report whether the snapshot is - * successfully taken, as well as the details for that snapshot. - * @param connection The RtcConnection object. - * @param uid The user ID. A `uid` of 0 indicates the local user. - * @param filePath The local path of the snapshot. - * @param width The width (px) of the snapshot. - * @param height The height (px) of the snapshot. - * @param errCode The message that confirms success or gives the reason why the snapshot is not successfully taken: - * - 0: Success. - * - < 0: Failure. - * - -1: The SDK fails to write data to a file or encode a JPEG image. - * - -2: The SDK does not find the video stream of the specified user within one second after the `takeSnapshot` method call succeeds. - * - -3: Calling the `takeSnapshot` method too frequently. Call the `takeSnapshot` method after receiving the `onSnapshotTaken` - * callback from the previous call. - */ - virtual void onSnapshotTaken(const RtcConnection& connection, uid_t uid, const char* filePath, int width, int height, int errCode) { - (void)uid; - (void)filePath; - (void)width; - (void)height; - (void)errCode; - } - - /** - * Reports the tracing result of video rendering event of the user. - * - * @param connection The RtcConnection object. - * @param uid The user ID. - * @param currentEvent The current event of the tracing result: #MEDIA_TRACE_EVENT. - * @param tracingInfo The tracing result: #VideoRenderingTracingInfo. - */ - virtual void onVideoRenderingTracingResult(const RtcConnection& connection, uid_t uid, MEDIA_TRACE_EVENT currentEvent, VideoRenderingTracingInfo tracingInfo) { - (void)uid; - (void)currentEvent; - (void)tracingInfo; - } - - /** - * Occurs when receive use rtm response. - * - * @param connection The RtcConnection object. - * @param code The error code: - */ - virtual void onSetRtmFlagResult(const RtcConnection& connection, int code) { - (void)connection; - (void)code; - } - /** - * Occurs when receive a video transcoder stream which has video layout info. - * - * @param connection The RtcConnection object. - * @param uid user id of the transcoded stream. - * @param width width of the transcoded stream. - * @param height height of the transcoded stream. - * @param layoutCount count of layout info in the transcoded stream. - * @param layoutlist video layout info list of the transcoded stream. - */ - virtual void onTranscodedStreamLayoutInfo(const RtcConnection& connection, uid_t uid, int width, int height, int layoutCount,const VideoLayout* layoutlist) { - (void)uid; - (void)width; - (void)height; - (void)layoutCount; - (void)layoutlist; - } - - /** - * The audio metadata received. - * - * @param connection The RtcConnection object. - * @param uid ID of the remote user. - * @param metadata The pointer of metadata - * @param length Size of metadata - * @technical preview - */ - virtual void onAudioMetadataReceived(const RtcConnection& connection, uid_t uid, const char* metadata, size_t length) { - (void)metadata; - (void)length; - } -}; - -class IRtcEngineEx : public IRtcEngine { -public: - /** - * Joins a channel with media options. - * - * This method enables users to join a channel. Users in the same channel can talk to each other, - * and multiple users in the same channel can start a group chat. Users with different App IDs - * cannot call each other. - * - * A successful call of this method triggers the following callbacks: - * - The local client: The `onJoinChannelSuccess` and `onConnectionStateChanged` callbacks. - * - The remote client: `onUserJoined`, if the user joining the channel is in the Communication - * profile or is a host in the Live-broadcasting profile. - * - * When the connection between the client and Agora's server is interrupted due to poor network - * conditions, the SDK tries reconnecting to the server. When the local client successfully rejoins - * the channel, the SDK triggers the `onRejoinChannelSuccess` callback on the local client. - * - * Compared to `joinChannel`, this method adds the options parameter to configure whether to - * automatically subscribe to all remote audio and video streams in the channel when the user - * joins the channel. By default, the user subscribes to the audio and video streams of all - * the other users in the channel, giving rise to usage and billings. To unsubscribe, set the - * `options` parameter or call the `mute` methods accordingly. - * - * @note - * - This method allows users to join only one channel at a time. - * - Ensure that the app ID you use to generate the token is the same app ID that you pass in the - * `initialize` method; otherwise, you may fail to join the channel by token. - * - * @param connection The RtcConnection object. - * @param token The token generated on your server for authentication. - * @param options The channel media options: ChannelMediaOptions. - * @param eventHandler The event handler: IRtcEngineEventHandler. - * - * @return - * - 0: Success. - * - < 0: Failure. - * - -2: The parameter is invalid. For example, the token is invalid, the uid parameter is not set - * to an integer, or the value of a member in the `ChannelMediaOptions` structure is invalid. You need - * to pass in a valid parameter and join the channel again. - * - -3: Failes to initialize the `IRtcEngine` object. You need to reinitialize the IRtcEngine object. - * - -7: The IRtcEngine object has not been initialized. You need to initialize the IRtcEngine - * object before calling this method. - * - -8: The internal state of the IRtcEngine object is wrong. The typical cause is that you call - * this method to join the channel without calling `stopEchoTest` to stop the test after calling - * `startEchoTest` to start a call loop test. You need to call `stopEchoTest` before calling this method. - * - -17: The request to join the channel is rejected. The typical cause is that the user is in the - * channel. Agora recommends using the `onConnectionStateChanged` callback to get whether the user is - * in the channel. Do not call this method to join the channel unless you receive the - * `CONNECTION_STATE_DISCONNECTED(1)` state. - * - -102: The channel name is invalid. You need to pass in a valid channel name in channelId to - * rejoin the channel. - * - -121: The user ID is invalid. You need to pass in a valid user ID in uid to rejoin the channel. - */ - virtual int joinChannelEx(const char* token, const RtcConnection& connection, - const ChannelMediaOptions& options, - IRtcEngineEventHandler* eventHandler) = 0; - - /** - * Leaves the channel. - * - * This method allows a user to leave the channel, for example, by hanging up or exiting a call. - * - * This method is an asynchronous call, which means that the result of this method returns even before - * the user has not actually left the channel. Once the user successfully leaves the channel, the - * SDK triggers the \ref IRtcEngineEventHandler::onLeaveChannel "onLeaveChannel" callback. - * - * @param connection The RtcConnection object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int leaveChannelEx(const RtcConnection& connection) = 0; - - /** - * Leaves the channel with the connection ID. - * - * @param connection connection. - * @param options The options for leaving the channel. See #LeaveChannelOptions. - * @return int - * - 0: Success. - * - < 0: Failure. - */ - virtual int leaveChannelEx(const RtcConnection& connection, const LeaveChannelOptions& options) = 0; - - /** - * Updates the channel media options after joining the channel. - * - * @param options The channel media options: ChannelMediaOptions. - * @param connection The RtcConnection object. - * @return int - * - 0: Success. - * - < 0: Failure. - */ - virtual int updateChannelMediaOptionsEx(const ChannelMediaOptions& options, const RtcConnection& connection) = 0; - /** - * Sets the video encoder configuration. - * - * Each configuration profile corresponds to a set of video parameters, including - * the resolution, frame rate, and bitrate. - * - * The parameters specified in this method are the maximum values under ideal network conditions. - * If the video engine cannot render the video using the specified parameters due - * to poor network conditions, the parameters further down the list are considered - * until a successful configuration is found. - * - * @param config The local video encoder configuration: VideoEncoderConfiguration. - * @param connection The RtcConnection object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setVideoEncoderConfigurationEx(const VideoEncoderConfiguration& config, const RtcConnection& connection) = 0; - /** - * Initializes the video view of a remote user. - * - * This method initializes the video view of a remote stream on the local device. It affects only the - * video view that the local user sees. - * - * Usually the app should specify the `uid` of the remote video in the method call before the - * remote user joins the channel. If the remote `uid` is unknown to the app, set it later when the - * app receives the \ref IRtcEngineEventHandler::onUserJoined "onUserJoined" callback. - * - * To unbind the remote user from the view, set `view` in VideoCanvas as `null`. - * - * @note - * Ensure that you call this method in the UI thread. - * - * @param canvas The remote video view settings: VideoCanvas. - * @param connection The RtcConnection object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setupRemoteVideoEx(const VideoCanvas& canvas, const RtcConnection& connection) = 0; - /** - * Stops or resumes receiving the audio stream of a specified user. - * - * @note - * You can call this method before or after joining a channel. If a user - * leaves a channel, the settings in this method become invalid. - * - * @param uid The ID of the specified user. - * @param mute Whether to stop receiving the audio stream of the specified user: - * - true: Stop receiving the audio stream of the specified user. - * - false: (Default) Resume receiving the audio stream of the specified user. - * @param connection The RtcConnection object. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int muteRemoteAudioStreamEx(uid_t uid, bool mute, const RtcConnection& connection) = 0; - /** - * Stops or resumes receiving the video stream of a specified user. - * - * @note - * You can call this method before or after joining a channel. If a user - * leaves a channel, the settings in this method become invalid. - * - * @param uid The ID of the specified user. - * @param mute Whether to stop receiving the video stream of the specified user: - * - true: Stop receiving the video stream of the specified user. - * - false: (Default) Resume receiving the video stream of the specified user. - * @param connection The RtcConnetion object. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int muteRemoteVideoStreamEx(uid_t uid, bool mute, const RtcConnection& connection) = 0; - /** - * Sets the remote video stream type. - * - * If the remote user has enabled the dual-stream mode, by default the SDK receives the high-stream video by - * Call this method to switch to the low-stream video. - * - * @note - * This method applies to scenarios where the remote user has enabled the dual-stream mode using - * \ref enableDualStreamMode "enableDualStreamMode"(true) before joining the channel. - * - * @param uid ID of the remote user sending the video stream. - * @param streamType Sets the video stream type: #VIDEO_STREAM_TYPE. - * @param connection The RtcConnection object. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setRemoteVideoStreamTypeEx(uid_t uid, VIDEO_STREAM_TYPE streamType, const RtcConnection& connection) = 0; - /** - *Stops or resumes sending the local audio stream with connection. - * - *@param mute Determines whether to send or stop sending the local audio stream: - *- true: Stop sending the local audio stream. - *- false: Send the local audio stream. - * - *@param connection The connection of the user ID. - * - *@return - *- 0: Success. - *- < 0: Failure. - */ - virtual int muteLocalAudioStreamEx(bool mute, const RtcConnection& connection) = 0; - - /** - *Stops or resumes sending the local video stream with connection. - * - *@param mute Determines whether to send or stop sending the local video stream: - *- true: Stop sending the local video stream. - *- false: Send the local video stream. - * - *@param connection The connection of the user ID. - * - *@return - *- 0: Success. - *- < 0: Failure. - */ - virtual int muteLocalVideoStreamEx(bool mute, const RtcConnection& connection) = 0; - - /** - *Stops or resumes receiving all remote audio stream with connection. - * - *@param mute Whether to stop receiving remote audio streams: - *- true: Stop receiving any remote audio stream. - *- false: Resume receiving all remote audio streams. - * - *@param connection The connection of the user ID. - * - *@return - *- 0: Success. - *- < 0: Failure. - */ - virtual int muteAllRemoteAudioStreamsEx(bool mute, const RtcConnection& connection) = 0; - - /** - *Stops or resumes receiving all remote video stream with connection. - * - *@param mute Whether to stop receiving remote audio streams: - *- true: Stop receiving any remote audio stream. - *- false: Resume receiving all remote audio streams. - * - *@param connection The connection of the user ID. - * - *@return - *- 0: Success. - *- < 0: Failure. - */ - virtual int muteAllRemoteVideoStreamsEx(bool mute, const RtcConnection& connection) = 0; - - - /** - * Sets the blocklist of subscribe remote stream audio. - * - * @note - * If uid is in uidList, the remote user's audio will not be subscribed, - * even if muteRemoteAudioStream(uid, false) and muteAllRemoteAudioStreams(false) are operated. - * - * @param uidList The id list of users who do not subscribe to audio. - * @param uidNumber The number of uid in uidList. - * @param connection The RtcConnection object. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setSubscribeAudioBlocklistEx(uid_t* uidList, int uidNumber, const RtcConnection& connection) = 0; - - /** - * Sets the allowlist of subscribe remote stream audio. - * - * @note - * - If uid is in uidList, the remote user's audio will be subscribed, - * even if muteRemoteAudioStream(uid, true) and muteAllRemoteAudioStreams(true) are operated. - * - If a user is in the blacklist and whitelist at the same time, the user will not subscribe to audio. - * - * @param uidList The id list of users who do subscribe to audio. - * @param uidNumber The number of uid in uidList. - * @param connection The RtcConnection object. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setSubscribeAudioAllowlistEx(uid_t* uidList, int uidNumber, const RtcConnection& connection) = 0; - - /** - * Sets the blocklist of subscribe remote stream video. - * - * @note - * If uid is in uidList, the remote user's video will not be subscribed, - * even if muteRemoteVideoStream(uid, false) and muteAllRemoteVideoStreams(false) are operated. - * - * @param uidList The id list of users who do not subscribe to video. - * @param uidNumber The number of uid in uidList. - * @param connection The RtcConnection object. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setSubscribeVideoBlocklistEx(uid_t* uidList, int uidNumber, const RtcConnection& connection) = 0; - - /** - * Sets the allowlist of subscribe remote stream video. - * - * @note - * - If uid is in uidList, the remote user's video will be subscribed, - * even if muteRemoteVideoStream(uid, true) and muteAllRemoteVideoStreams(true) are operated. - * - If a user is in the blacklist and whitelist at the same time, the user will not subscribe to video. - * - * @param uidList The id list of users who do subscribe to video. - * @param uidNumber The number of uid in uidList. - * @param connection The RtcConnection object. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setSubscribeVideoAllowlistEx(uid_t* uidList, int uidNumber, const RtcConnection& connection) = 0; - /** - * Sets the remote video subscription options - * - * - * @param uid ID of the remote user sending the video stream. - * @param options Sets the video subscription options: VideoSubscriptionOptions. - * @param connection The RtcConnection object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setRemoteVideoSubscriptionOptionsEx(uid_t uid, const VideoSubscriptionOptions& options, const RtcConnection& connection) = 0; - /** Sets the sound position and gain of a remote user. - - When the local user calls this method to set the sound position of a remote user, the sound difference between the left and right channels allows the local user to track the real-time position of the remote user, creating a real sense of space. This method applies to massively multiplayer online games, such as Battle Royale games. - - @note - - For this method to work, enable stereo panning for remote users by calling the \ref agora::rtc::IRtcEngine::enableSoundPositionIndication "enableSoundPositionIndication" method before joining a channel. - - This method requires hardware support. For the best sound positioning, we recommend using a wired headset. - - Ensure that you call this method after joining a channel. - - @param uid The ID of the remote user. - @param pan The sound position of the remote user. The value ranges from -1.0 to 1.0: - - 0.0: the remote sound comes from the front. - - -1.0: the remote sound comes from the left. - - 1.0: the remote sound comes from the right. - @param gain Gain of the remote user. The value ranges from 0.0 to 100.0. The default value is 100.0 (the original gain of the remote user). The smaller the value, the less the gain. - @param connection The RtcConnection object. - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int setRemoteVoicePositionEx(uid_t uid, double pan, double gain, const RtcConnection& connection) = 0; - /** Sets remote user parameters for spatial audio - - @param uid The ID of the remote user. - @param param Spatial audio parameters. See SpatialAudioParams. - @param connection The RtcConnection object. - - @return int - - 0: Success. - - < 0: Failure. - */ - virtual int setRemoteUserSpatialAudioParamsEx(uid_t uid, const agora::SpatialAudioParams& params, const RtcConnection& connection) = 0; - /** - * Updates the display mode of the video view of a remote user. - * - * After initializing the video view of a remote user, you can call this method to update its - * rendering and mirror modes. This method affects only the video view that the local user sees. - * - * @note - * - Ensure that you have called \ref setupRemoteVideo "setupRemoteVideo" to initialize the remote video - * view before calling this method. - * - During a call, you can call this method as many times as necessary to update the display mode - * of the video view of a remote user. - * - * @param uid ID of the remote user. - * @param renderMode Sets the remote display mode. See #RENDER_MODE_TYPE. - * @param mirrorMode Sets the mirror type. See #VIDEO_MIRROR_MODE_TYPE. - * @param connection The RtcConnection object. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setRemoteRenderModeEx(uid_t uid, media::base::RENDER_MODE_TYPE renderMode, - VIDEO_MIRROR_MODE_TYPE mirrorMode, const RtcConnection& connection) = 0; - /** Enables loopback recording. - * - * If you enable loopback recording, the output of the default sound card is mixed into - * the audio stream sent to the other end. - * - * @note This method is for Windows only. - * - * @param connection The RtcConnection object. - * @param enabled Sets whether to enable/disable loopback recording. - * - true: Enable loopback recording. - * - false: (Default) Disable loopback recording. - * @param deviceName Pointer to the device name of the sound card. The default value is NULL (the default sound card). - * - This method is for macOS and Windows only. - * - macOS does not support loopback capturing of the default sound card. If you need to use this method, - * please use a virtual sound card and pass its name to the deviceName parameter. Agora has tested and recommends using soundflower. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableLoopbackRecordingEx(const RtcConnection& connection, bool enabled, const char* deviceName = NULL) = 0; - - /** - * Adjusts the recording volume. - * - * @param volume The recording volume, which ranges from 0 to 400: - * - 0 : Mute the recording volume. - * - 100: The original volume. - * - 400: (Maximum) Four times the original volume with signal clipping protection. - * - * @param connection The RtcConnection object. - * - * @return - * - 0 : Success. - * - < 0: Failure. - */ - virtual int adjustRecordingSignalVolumeEx(int volume, const RtcConnection& connection) = 0; - - /** - * Mute or resume recording signal volume. - * - * @param mute Determines whether to mute or resume the recording signal volume. - * - true: Mute the recording signal volume. - * - false: (Default) Resume the recording signal volume. - * - * @param connection The RtcConnection object. - * - * @return - * - 0 : Success. - * - < 0: Failure. - */ - virtual int muteRecordingSignalEx(bool mute, const RtcConnection& connection) = 0; - - /** - * Adjust the playback signal volume of a specified remote user. - * You can call this method as many times as necessary to adjust the playback volume of different remote users, or to repeatedly adjust the playback volume of the same remote user. - * - * @note - * The playback volume here refers to the mixed volume of a specified remote user. - * This method can only adjust the playback volume of one specified remote user at a time. To adjust the playback volume of different remote users, call the method as many times, once for each remote user. - * - * @param uid The ID of the remote user. - * @param volume The playback volume of the specified remote user. The value ranges between 0 and 400, including the following: - * - * - 0: Mute. - * - 100: (Default) Original volume. - * @param connection RtcConnection - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int adjustUserPlaybackSignalVolumeEx(uid_t uid, int volume, const RtcConnection& connection) = 0; - - /** Gets the current connection state of the SDK. - @param connection The RtcConnection object. - @return #CONNECTION_STATE_TYPE. - */ - virtual CONNECTION_STATE_TYPE getConnectionStateEx(const RtcConnection& connection) = 0; - /** Enables/Disables the built-in encryption. - * - * In scenarios requiring high security, Agora recommends calling this method to enable the built-in encryption before joining a channel. - * - * All users in the same channel must use the same encryption mode and encryption key. Once all users leave the channel, the encryption key of this channel is automatically cleared. - * - * @note - * - If you enable the built-in encryption, you cannot use the RTMP streaming function. - * - * @param connection The RtcConnection object. - * @param enabled Whether to enable the built-in encryption: - * - true: Enable the built-in encryption. - * - false: Disable the built-in encryption. - * @param config Configurations of built-in encryption schemas. See EncryptionConfig. - * - * @return - * - 0: Success. - * - < 0: Failure. - * - -2(ERR_INVALID_ARGUMENT): An invalid parameter is used. Set the parameter with a valid value. - * - -4(ERR_NOT_SUPPORTED): The encryption mode is incorrect or the SDK fails to load the external encryption library. Check the enumeration or reload the external encryption library. - * - -7(ERR_NOT_INITIALIZED): The SDK is not initialized. Initialize the `IRtcEngine` instance before calling this method. - */ - virtual int enableEncryptionEx(const RtcConnection& connection, bool enabled, const EncryptionConfig& config) = 0; - /** Creates a data stream. - * - * You can call this method to create a data stream and improve the - * reliability and ordering of data tranmission. - * - * @note - * - Ensure that you set the same value for `reliable` and `ordered`. - * - Each user can only create a maximum of 5 data streams during a RtcEngine - * lifecycle. - * - The data channel allows a data delay of up to 5 seconds. If the receiver - * does not receive the data stream within 5 seconds, the data channel reports - * an error. - * - * @param[out] streamId The ID of the stream data. - * @param reliable Sets whether the recipients are guaranteed to receive - * the data stream from the sender within five seconds: - * - true: The recipients receive the data stream from the sender within - * five seconds. If the recipient does not receive the data stream within - * five seconds, an error is reported to the application. - * - false: There is no guarantee that the recipients receive the data stream - * within five seconds and no error message is reported for any delay or - * missing data stream. - * @param ordered Sets whether the recipients receive the data stream - * in the sent order: - * - true: The recipients receive the data stream in the sent order. - * - false: The recipients do not receive the data stream in the sent order. - * @param connection The RtcConnection object. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int createDataStreamEx(int* streamId, bool reliable, bool ordered, const RtcConnection& connection) = 0; - /** Creates a data stream. - * - * Each user can create up to five data streams during the lifecycle of the IChannel. - * @param streamId The ID of the created data stream. - * @param config The config of data stream. - * @param connection The RtcConnection object. - * @return int - * - Returns 0: Success. - * - < 0: Failure. - */ - virtual int createDataStreamEx(int* streamId, const DataStreamConfig& config, const RtcConnection& connection) = 0; - /** Sends a data stream. - * - * After calling \ref IRtcEngine::createDataStream "createDataStream", you can call - * this method to send a data stream to all users in the channel. - * - * The SDK has the following restrictions on this method: - * - Up to 60 packets can be sent per second in a channel with each packet having a maximum size of 1 KB. - * - Each client can send up to 30 KB of data per second. - * - Each user can have up to five data streams simultaneously. - * - * After the remote user receives the data stream within 5 seconds, the SDK triggers the - * \ref IRtcEngineEventHandler::onStreamMessage "onStreamMessage" callback on - * the remote client. After the remote user does not receive the data stream within 5 seconds, - * the SDK triggers the \ref IRtcEngineEventHandler::onStreamMessageError "onStreamMessageError" - * callback on the remote client. - * - * @note - * - Call this method after calling \ref IRtcEngine::createDataStream "createDataStream". - * - This method applies only to the `COMMUNICATION` profile or to - * the hosts in the `LIVE_BROADCASTING` profile. If an audience in the - * `LIVE_BROADCASTING` profile calls this method, the audience may be switched to a host. - * - * @param streamId The ID of the stream data. - * @param data The data stream. - * @param length The length (byte) of the data stream. - * @param connection The RtcConnection object. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int sendStreamMessageEx(int streamId, const char* data, size_t length, const RtcConnection& connection) = 0; - /** Adds a watermark image to the local video. - - This method adds a PNG watermark image to the local video in a live broadcast. Once the watermark image is added, all the audience in the channel (CDN audience included), - and the recording device can see and capture it. Agora supports adding only one watermark image onto the local video, and the newly watermark image replaces the previous one. - - The watermark position depends on the settings in the \ref IRtcEngine::setVideoEncoderConfiguration "setVideoEncoderConfiguration" method: - - If the orientation mode of the encoding video is #ORIENTATION_MODE_FIXED_LANDSCAPE, or the landscape mode in #ORIENTATION_MODE_ADAPTIVE, the watermark uses the landscape orientation. - - If the orientation mode of the encoding video is #ORIENTATION_MODE_FIXED_PORTRAIT, or the portrait mode in #ORIENTATION_MODE_ADAPTIVE, the watermark uses the portrait orientation. - - When setting the watermark position, the region must be less than the dimensions set in the `setVideoEncoderConfiguration` method. Otherwise, the watermark image will be cropped. - - @note - - Ensure that you have called the \ref agora::rtc::IRtcEngine::enableVideo "enableVideo" method to enable the video module before calling this method. - - If you only want to add a watermark image to the local video for the audience in the CDN live broadcast channel to see and capture, you can call this method or the \ref agora::rtc::IRtcEngine::setLiveTranscoding "setLiveTranscoding" method. - - This method supports adding a watermark image in the PNG file format only. Supported pixel formats of the PNG image are RGBA, RGB, Palette, Gray, and Alpha_gray. - - If the dimensions of the PNG image differ from your settings in this method, the image will be cropped or zoomed to conform to your settings. - - If you have enabled the local video preview by calling the \ref agora::rtc::IRtcEngine::startPreview "startPreview" method, you can use the `visibleInPreview` member in the WatermarkOptions class to set whether or not the watermark is visible in preview. - - If you have enabled the mirror mode for the local video, the watermark on the local video is also mirrored. To avoid mirroring the watermark, Agora recommends that you do not use the mirror and watermark functions for the local video at the same time. You can implement the watermark function in your application layer. - - @param watermarkUrl The local file path of the watermark image to be added. This method supports adding a watermark image from the local absolute or relative file path. - @param options Pointer to the watermark's options to be added. See WatermarkOptions for more infomation. - @param connection The RtcConnection object. - - @return int - - 0: Success. - - < 0: Failure. - */ - virtual int addVideoWatermarkEx(const char* watermarkUrl, const WatermarkOptions& options, const RtcConnection& connection) = 0; - /** Removes the watermark image on the video stream added by - addVideoWatermark(). - - @param connection The RtcConnection object. - @return - - 0: Success. - - < 0: Failure. - */ - virtual int clearVideoWatermarkEx(const RtcConnection& connection) = 0; - /** Agora supports reporting and analyzing customized messages. - * - * This function is in the beta stage with a free trial. The ability provided - * in its beta test version is reporting a maximum of 10 message pieces within - * 6 seconds, with each message piece not exceeding 256 bytes. - * - * To try out this function, contact [support@agora.io](mailto:support@agora.io) - * and discuss the format of customized messages with us. - */ - virtual int sendCustomReportMessageEx(const char* id, const char* category, const char* event, const char* label, - int value, const RtcConnection& connection) = 0; - - /** - * Enables the `onAudioVolumeIndication` callback to report on which users are speaking - * and the speakers' volume. - * - * Once the \ref IRtcEngineEventHandler::onAudioVolumeIndication "onAudioVolumeIndication" - * callback is enabled, the SDK returns the volume indication in the at the time interval set - * in `enableAudioVolumeIndication`, regardless of whether any user is speaking in the channel. - * - * @param interval Sets the time interval between two consecutive volume indications: - * - <= 0: Disables the volume indication. - * - > 0: Time interval (ms) between two consecutive volume indications, - * and should be integral multiple of 200 (less than 200 will be set to 200). - * @param smooth The smoothing factor that sets the sensitivity of the audio volume - * indicator. The value range is [0, 10]. The greater the value, the more sensitive the - * indicator. The recommended value is 3. - * @param reportVad - * - `true`: Enable the voice activity detection of the local user. Once it is enabled, the `vad` parameter of the - * `onAudioVolumeIndication` callback reports the voice activity status of the local user. - * - `false`: (Default) Disable the voice activity detection of the local user. Once it is disabled, the `vad` parameter - * of the `onAudioVolumeIndication` callback does not report the voice activity status of the local user, except for - * the scenario where the engine automatically detects the voice activity of the local user. - * @param connection The RtcConnection object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableAudioVolumeIndicationEx(int interval, int smooth, bool reportVad, const RtcConnection& connection) = 0; - - /** Publishes the local stream without transcoding to a specified CDN live RTMP address. (CDN live only.) - * - * @param url The CDN streaming URL in the RTMP format. The maximum length of this parameter is 1024 bytes. - * @param connection RtcConnection. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int startRtmpStreamWithoutTranscodingEx(const char* url, const RtcConnection& connection) = 0; - - /** Publishes the local stream with transcoding to a specified CDN live RTMP address. (CDN live only.) - * - * @param url The CDN streaming URL in the RTMP format. The maximum length of this parameter is 1024 bytes. - * @param transcoding Sets the CDN live audio/video transcoding settings. See LiveTranscoding. - * @param connection RtcConnection. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int startRtmpStreamWithTranscodingEx(const char* url, const LiveTranscoding& transcoding, const RtcConnection& connection) = 0; - - /** Update the video layout and audio settings for CDN live. (CDN live only.) - * @note This method applies to Live Broadcast only. - * - * @param transcoding Sets the CDN live audio/video transcoding settings. See LiveTranscoding. - * @param connection RtcConnection. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int updateRtmpTranscodingEx(const LiveTranscoding& transcoding, const RtcConnection& connection) = 0; - - /** Stop an RTMP stream with transcoding or without transcoding from the CDN. (CDN live only.) - * @param url The RTMP URL address to be removed. The maximum length of this parameter is 1024 bytes. - * @param connection RtcConnection. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int stopRtmpStreamEx(const char* url, const RtcConnection& connection) = 0; - - /** Starts relaying media streams across channels or updates the channels for media relay. - * - * @since v4.2.0 - * @param configuration The configuration of the media stream relay:ChannelMediaRelayConfiguration. - * @param connection RtcConnection. - * @return - * - 0: Success. - * - < 0: Failure. - * - -1(ERR_FAILED): A general error occurs (no specified reason). - * - -2(ERR_INVALID_ARGUMENT): The argument is invalid. - * - -5(ERR_REFUSED): The request is rejected. - * - -8(ERR_INVALID_STATE): The current status is invalid, only allowed to be called when the role is the broadcaster. - */ - virtual int startOrUpdateChannelMediaRelayEx(const ChannelMediaRelayConfiguration& configuration, const RtcConnection& connection) = 0; - - /** Stops the media stream relay. - * - * Once the relay stops, the host quits all the destination - * channels. - * - * @param connection RtcConnection. - * @return - * - 0: Success. - * - < 0: Failure. - * - -1(ERR_FAILED): A general error occurs (no specified reason). - * - -2(ERR_INVALID_ARGUMENT): The argument is invalid. - * - -5(ERR_REFUSED): The request is rejected. - * - -7(ERR_NOT_INITIALIZED): cross channel media streams are not relayed. - */ - virtual int stopChannelMediaRelayEx(const RtcConnection& connection) = 0; - - /** pause the channels for media stream relay. - * - * @param connection RtcConnection. - * @return - * - 0: Success. - * - < 0: Failure. - * - -1(ERR_FAILED): A general error occurs (no specified reason). - * - -2(ERR_INVALID_ARGUMENT): The argument is invalid. - * - -5(ERR_REFUSED): The request is rejected. - * - -7(ERR_NOT_INITIALIZED): cross channel media streams are not relayed. - */ - virtual int pauseAllChannelMediaRelayEx(const RtcConnection& connection) = 0; - - /** resume the channels for media stream relay. - * - * @param connection RtcConnection. - * @return - * - 0: Success. - * - < 0: Failure. - * - -1(ERR_FAILED): A general error occurs (no specified reason). - * - -2(ERR_INVALID_ARGUMENT): The argument is invalid. - * - -5(ERR_REFUSED): The request is rejected. - * - -7(ERR_NOT_INITIALIZED): cross channel media streams are not relayed. - */ - virtual int resumeAllChannelMediaRelayEx(const RtcConnection& connection) = 0; - - /** Gets the user information by passing in the user account. - * It is same as agora::rtc::IRtcEngine::getUserInfoByUserAccount. - * - * @param userAccount The user account of the user. Ensure that you set this parameter. - * @param [in,out] userInfo A userInfo object that identifies the user: - * - Input: A userInfo object. - * - Output: A userInfo object that contains the user account and user ID of the user. - * @param connection The RtcConnection object. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getUserInfoByUserAccountEx(const char* userAccount, rtc::UserInfo* userInfo, const RtcConnection& connection) = 0; - - /** Gets the user information by passing in the user ID. - * It is same as agora::rtc::IRtcEngine::getUserInfoByUid. - * - * @param uid The user ID of the remote user. Ensure that you set this parameter. - * @param[in,out] userInfo A userInfo object that identifies the user: - * - Input: A userInfo object. - * - Output: A userInfo object that contains the user account and user ID of the user. - * @param connection The RtcConnection object. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getUserInfoByUidEx(uid_t uid, rtc::UserInfo* userInfo, const RtcConnection& connection) = 0; - - /** - * Enables or disables the dual video stream mode. - * - * @deprecated v4.2.0. This method is deprecated. Use setDualStreamModeEx instead - * - * If dual-stream mode is enabled, the subscriber can choose to receive the high-stream - * (high-resolution high-bitrate video stream) or low-stream (low-resolution low-bitrate video - * stream) video using {@link setRemoteVideoStreamType setRemoteVideoStreamType}. - * - * @param enabled - * - true: Enable the dual-stream mode. - * - false: (default) Disable the dual-stream mode. - * @param streamConfig The minor stream config - * @param connection The RtcConnection object. - */ - virtual int enableDualStreamModeEx(bool enabled, const SimulcastStreamConfig& streamConfig, - const RtcConnection& connection) = 0; - /** - * Enables, disables or auto enable the dual video stream mode. - * - * If dual-stream mode is enabled, the subscriber can choose to receive the high-stream - * (high-resolution high-bitrate video stream) or low-stream (low-resolution low-bitrate video - * stream) video using {@link setRemoteVideoStreamType setRemoteVideoStreamType}. - * - * @param mode The dual stream mode: #SIMULCAST_STREAM_MODE. - * @param streamConfig The configuration of the low stream: SimulcastStreamConfig. - * @param connection The RtcConnection object. - */ - virtual int setDualStreamModeEx(SIMULCAST_STREAM_MODE mode, - const SimulcastStreamConfig& streamConfig, - const RtcConnection& connection) = 0; - - /** - * Set the multi-layer video stream configuration. - * - * If multi-layer is configed, the subscriber can choose to receive the coresponding layer - * of video stream using {@link setRemoteVideoStreamType setRemoteVideoStreamType}. - * - * @param simulcastConfig - * - The configuration for multi-layer video stream. It includes seven layers, ranging from - * STREAM_LAYER_1 to STREAM_LOW. A maximum of 3 layers can be enabled simultaneously. - * @param connection The RtcConnection object. - * @return - * - 0: Success. - * - < 0: Failure. - * @technical preview - */ - virtual int setSimulcastConfigEx(const SimulcastConfig& simulcastConfig, - const RtcConnection& connection) = 0; - - /** - * Set the high priority user list and their fallback level in weak network condition. - * - * @note - * - This method can be called before and after joining a channel. - * - If a subscriber is set to high priority, this stream only fallback to lower stream after all normal priority users fallback to their fallback level on weak network condition if needed. - * - * @param uidList The high priority user list. - * @param uidNum The size of uidList. - * @param option The fallback level of high priority users. - * @param connection An output parameter which is used to control different connection instances. - * - * @return int - * - 0 : Success. - * - <0 : Failure. - */ - virtual int setHighPriorityUserListEx(uid_t* uidList, int uidNum, - STREAM_FALLBACK_OPTIONS option, - const RtcConnection& connection) = 0; - - /** - * Takes a snapshot of a video stream. - * - * This method takes a snapshot of a video stream from the specified user, generates a JPG - * image, and saves it to the specified path. - * - * The method is asynchronous, and the SDK has not taken the snapshot when the method call - * returns. After a successful method call, the SDK triggers the `onSnapshotTaken` callback - * to report whether the snapshot is successfully taken, as well as the details for that - * snapshot. - * - * @note - * - Call this method after joining a channel. - * - This method takes a snapshot of the published video stream specified in `ChannelMediaOptions`. - * - If the user's video has been preprocessed, for example, watermarked or beautified, the resulting - * snapshot includes the pre-processing effect. - * @param connection The RtcConnection object. - * @param uid The user ID. Set uid as 0 if you want to take a snapshot of the local user's video. - * @param filePath The local path (including filename extensions) of the snapshot. For example: - * - Windows: `C:\Users\\AppData\Local\Agora\\example.jpg` - * - iOS: `/App Sandbox/Library/Caches/example.jpg` - * - macOS: `~/Library/Logs/example.jpg` - * - Android: `/storage/emulated/0/Android/data//files/example.jpg` - * - * Ensure that the path you specify exists and is writable. - * @return - * - 0 : Success. - * - < 0 : Failure. - */ - virtual int takeSnapshotEx(const RtcConnection& connection, uid_t uid, const char* filePath) = 0; - - /** Enables video screenshot and upload with the connection ID. - @param enabled Whether to enable video screenshot and upload: - - `true`: Yes. - - `false`: No. - @param config The configuration for video screenshot and upload. - @param connection The connection information. See RtcConnection. - @return - - 0: Success. - - < 0: Failure. - */ - virtual int enableContentInspectEx(bool enabled, const media::ContentInspectConfig &config, const RtcConnection& connection) = 0; - - /** - @brief Start tracing media rendering events. - @since v4.1.1 - @discussion - - SDK will trace media rendering events when this API is called. - - The tracing result can be obtained through callback `IRtcEngineEventHandler(Ex)::onVideoRenderingTracingResult` - @param connection The RtcConnection object. - @note - - By default, SDK will trace media rendering events when `IRtcEngineEx::joinChannelEx` is called. - - The start point of event tracing will be reset after leaving channel. - @return - - 0: Success. - - < 0: Failure. - - -2(ERR_INVALID_ARGUMENT): The parameter is invalid. Check the channel ID and local uid set by parameter `connection`. - - -7(ERR_NOT_INITIALIZED): The SDK is not initialized. Initialize the `IRtcEngine` instance before calling this method. - */ - virtual int startMediaRenderingTracingEx(const RtcConnection& connection) = 0; - - /** Provides the technical preview functionalities or special customizations by configuring the SDK with JSON options. - @since v4.3.0 - @param connection The connection information. See RtcConnection. - @param parameters Pointer to the set parameters in a JSON string. - @return - - 0: Success. - - < 0: Failure. - */ - virtual int setParametersEx(const RtcConnection& connection, const char* parameters) = 0; - - /** - * Gets the current call ID. - * - * When a user joins a channel on a client, a `callId` is generated to identify - * the call. - * - * After a call ends, you can call `rate` or `complain` to gather feedback from the customer. - * These methods require a `callId` parameter. To use these feedback methods, call the this - * method first to retrieve the `callId` during the call, and then pass the value as an - * argument in the `rate` or `complain` method after the call ends. - * - * @param callId The reference to the call ID. - * @param connection The RtcConnection object. - * @return - * - The call ID if the method call is successful. - * - < 0: Failure. - */ - virtual int getCallIdEx(agora::util::AString& callId, const RtcConnection& connection) = 0; - - /** - * send audio metadata - * @since v4.3.1 - * @param connection The RtcConnection object. - * @param metadata The pointer of metadata - * @param length Size of metadata - * @return - * - 0: success - * - <0: failure - * @technical preview - */ - virtual int sendAudioMetadataEx(const RtcConnection& connection, const char* metadata, size_t length) = 0; -}; - -} // namespace rtc -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtmService.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtmService.h deleted file mode 100644 index 580790c30..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtmService.h +++ /dev/null @@ -1,716 +0,0 @@ -// -// Agora Rtm SDK -// -// Created by junhao Wang in 2018-05. -// Copyright (c) 2018 Agora IO. All rights reserved. -// -#pragma once - -#include -#include - -namespace agora { - -namespace rtm { - -enum PEER_MESSAGE_STATE { - PEER_MESSAGE_INIT = 0, - PEER_MESSAGE_FAILURE = 1, - PEER_MESSAGE_PEER_UNREACHABLE = 2, - PEER_MESSAGE_RECEIVED_BY_PEER = 3, - PEER_MESSAGE_SENT_TIMEOUT = 4, -}; -/** - * The login error code. - */ -enum LOGIN_ERR_CODE { - /** - * 0: Login succeeds. No error occurs. - */ - LOGIN_ERR_OK = 0, - /** - * 1: Login fails for reasons unknown. - */ - LOGIN_ERR_UNKNOWN = 1, - /** - * 2: The server rejects the login, either because the user has already logged in, or because - * the RTM service is not initialized. - */ - LOGIN_ERR_REJECTED = 2, // ALREADY LOGIN OR NOT INITIALIZED, SERVER REJECT - /** - * 3: Invalid login arguments. - */ - LOGIN_ERR_INVALID_ARGUMENT = 3, - /** - * 4: The App ID is invalid. - */ - LOGIN_ERR_INVALID_APP_ID = 4, - /** - * 5: The token is invalid. - */ - LOGIN_ERR_INVALID_TOKEN = 5, - /** - * 6: The login is rejected because the token has expired. - */ - LOGIN_ERR_TOKEN_EXPIRED = 6, - /** - * 7: Authentication of the RTMP token fails. - */ - LOGIN_ERR_NOT_AUTHORIZED = 7, - /** - * 8: The login times out. The current timeout is set as six seconds. - */ - LOGIN_ERR_TIMEOUT = 8, -}; -/** - * The logout error code. - */ -enum LOGOUT_ERR_CODE { - /** - * 0: Logout succeeds. No error occurs. - */ - LOGOUT_ERR_OK = 0, - /** - * 1: Logout fails. - */ - LOGOUT_ERR_REJECTED = 1, -}; -/** - * The connection state. - */ -enum CONNECTION_STATE { - /** - * 1: The SDK has logged in the RTM service. - */ - CONNECTION_STATE_CONNECTED = 1, - /** - * 2: The initial state. The SDK is disconnected from the RTM service. - */ - CONNECTION_STATE_DISCONNECTED = 2, - /** - * 3: The SDK gives up logging in the RTM service, mainly because another instance has logged in the RTM - * service with the same user ID. - * - * Call the logout() method before calling login to log in the RTM service again. - */ - CONNECTION_STATE_ABORTED = 3, -}; - -/** - * The state of the channel message. - */ -enum CHANNEL_MESSAGE_STATE { - /** - * 1: The channel message is received by the server. - */ - CHANNEL_MESSAGE_RECEIVED_BY_SERVER = 1, - /** - * 3: The SDK has not received a response from the server in five seconds. The current timeout is set as - * five seconds. - */ - CHANNEL_MESSAGE_SENT_TIMEOUT = 3, -}; -/** - * The join channel error. - */ -enum JOIN_CHANNEL_ERR { - /** - 0: The method call succeeds, or the user joins the channel successfully. - */ - JOIN_CHANNEL_ERR_OK = 0, - - /** - 1: Common failure. The user fails to join the channel. - */ - JOIN_CHANNEL_ERR_FAILURE = 1, - - /** - 2: **RESERVED FOR FUTURE USE** - */ - JOIN_CHANNEL_ERR_REJECTED = 2, // Usually occurs when the user is already in the channel - - /** - 3: The user fails to join the channel because the argument is invalid. - */ - JOIN_CHANNEL_ERR_INVALID_ARGUMENT = 3, - - /** - 4: A timeout occurs when joining the channel. The current timeout is set as five seconds. Possible reasons: The user is in the \ref agora::rtm::CONNECTION_STATE_ABORTED "CONNECTION_STATE_ABORTED" state. - */ - JOIN_CHANNEL_TIMEOUT = 4, - - /** - 5: The number of the RTM channels you are in exceeds the limit of 20. - */ - JOIN_CHANNEL_ERR_EXCEED_LIMIT = 5, - - /** - 6: The user is joining or has joined the channel. - */ - JOIN_CHANNEL_ERR_ALREADY_JOINED = 6, - - /** - 7: The method call frequency exceeds 50 queries every three seconds. - */ - JOIN_CHANNEL_ERR_TOO_OFTEN = 7, - - /** - 8: The frequency of joining the same channel exceeds two times every five seconds. - */ - JOIN_CHANNEL_ERR_JOIN_SAME_CHANNEL_TOO_OFTEN = 8, - - /** - 101: \ref agora::rtm::IRtmService "IRtmService" is not initialized. - */ - JOIN_CHANNEL_ERR_NOT_INITIALIZED = 101, - - /** - 102: The user does not call the \ref agora::rtm::IRtmService::login "login" method, or the method call of \ref agora::rtm::IRtmService::login "login" does not succeed before joining the channel. - */ - JOIN_CHANNEL_ERR_USER_NOT_LOGGED_IN = 102, -}; -/** - @brief Error codes related to leaving a channel. - */ -enum LEAVE_CHANNEL_ERR { - - /** - 0: The method call succeeds, or the user leaves the channel successfully. - */ - LEAVE_CHANNEL_ERR_OK = 0, - - /** - 1: Common failure. The user fails to leave the channel. - */ - LEAVE_CHANNEL_ERR_FAILURE = 1, - - /** - 2: **RESERVED FOR FUTURE USE** - */ - LEAVE_CHANNEL_ERR_REJECTED = 2, - - /** - 3: The user is not in the channel. - */ - LEAVE_CHANNEL_ERR_NOT_IN_CHANNEL = 3, - - /** - 101: \ref agora::rtm::IRtmService "IRtmService" is not initialized. - */ - LEAVE_CHANNEL_ERR_NOT_INITIALIZED = 101, - - /** - 102: The user does not call the \ref agora::rtm::IRtmService::login "login" method, or the method call of \ref agora::rtm::IRtmService::login "login" does not succeed before calling the \ref agora::rtm::IChannel::leave "leave" method. - */ - LEAVE_CHANNEL_ERR_USER_NOT_LOGGED_IN = 102, -}; - -/** - * The reason for a user to leave the channel. - */ -enum LEAVE_CHANNEL_REASON { - /** - * 1: The user quits the channel. - */ - LEAVE_CHANNEL_REASON_QUIT = 1, - /** - * 2: The user is kicked off the channel. - */ - LEAVE_CHANNEL_REASON_KICKED = 2, -}; -/** - @brief Error codes related to sending a channel message. - */ -enum CHANNEL_MESSAGE_ERR_CODE { - - /** - 0: The method call succeeds, or the server receives the channel message. - */ - CHANNEL_MESSAGE_ERR_OK = 0, - - /** - 1: Common failure. The user fails to send the channel message. - */ - CHANNEL_MESSAGE_ERR_FAILURE = 1, - - /** - 2: The SDK does not receive a response from the server in 10 seconds. The current timeout is set as 10 seconds. Possible reasons: The user is in the \ref agora::rtm::CONNECTION_STATE_ABORTED "CONNECTION_STATE_ABORTED" state. - */ - CHANNEL_MESSAGE_ERR_SENT_TIMEOUT = 2, - - /** - 3: The method call frequency exceeds the limit of (RTM SDK for Windows C++) 180 calls every three seconds or (RTM SDK for Linux C++) 1500 calls every three seconds, with channel and peer messages taken together.. - */ - CHANNEL_MESSAGE_ERR_TOO_OFTEN = 3, - - /** - 4: The message is null or exceeds 32 KB in length. - */ - CHANNEL_MESSAGE_ERR_INVALID_MESSAGE = 4, - - /** - 101: \ref agora::rtm::IRtmService "IRtmService" is not initialized. - */ - CHANNEL_MESSAGE_ERR_NOT_INITIALIZED = 101, - - /** - 102: The user does not call the \ref agora::rtm::IRtmService::login "login" method, or the method call of \ref agora::rtm::IRtmService::login "login" does not succeed before sending out a channel message. - */ - CHANNEL_MESSAGE_ERR_USER_NOT_LOGGED_IN = 102, -}; - -/** - * The response code. - */ -enum RESPONSE_CODE { - /** - * 1: The response - */ - RESPONSE_CODE_SUCCESS = 1, - RESPONSE_CODE_FAILURE = 2, -}; -/** - * The message type. - */ -enum MESSAGE_TYPE { - /** - * 0: The message type is undefined. - */ - MESSAGE_TYPE_UNDEFINED = 0, - /** - * 1: A text message. - */ - MESSAGE_TYPE_TEXT = 1, - /** - * 2: A raw message in binary, for example, audio data, or video data. - */ - MESSAGE_TYPE_BINARY = 2, - /** - * 4: A converge message. - */ - MESSAGE_TYPE_CONVERGE = 4, -}; -/** - * The IMessage class. - */ -class IMessage { - public: - /** - * Creates an IMessage instance. - * - * The created IMessage instance can be either for a channel message or for a peer-to-peer message. - * - * You can set the content of the text message later using the setText() method. - * @return - * - An empty text IMessage instance, if the method call succeeds. - */ - static IMessage *createMessage(); - virtual ~IMessage() {} - /** - * Gets the ID of the message. - * @return The ID of the current IMessage instance. - */ - virtual int64_t getMessageId() const = 0; - /** - * Gets the message type. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getMessageType() const = 0; - /** - * Sets the content of the text message, or the text description of the raw message. - * @param str The content of the text message, or the text description of the raw message. The maximum length - * is 32 KB. - */ - virtual void setText(const char *str) = 0; - /** - * Gets the content of the text messsage, or the text description of the raw message. - * @return - * - The content of the text message or the text description of the raw message. - */ - virtual const char *getText() const = 0; - /** - * Get pointer of custom raw message - * @return - * - The content of binary raw message - */ - virtual const unsigned char *getRawMessageData() const = 0; - /** - * Get length of custom raw message - * @return - * - The length of binary raw message in bytes - */ - virtual int getRawMessageLength() const = 0; - /** - * Set message type - */ - virtual void setMessageType(int32_t type) = 0; - /** - * Set raw binary message - */ - virtual void setRawMessage(const uint8_t* data, int length) = 0; - /** - * Releases the IMessage instance. - */ - virtual void release() = 0; -}; - -/** - * The IChannelMember class. - */ -class IChannelMember { - public: - virtual ~IChannelMember() {} - /** - * Gets the ID of the channel member. - * @return The ID of the channel member. - */ - virtual const char *getMemberId() const = 0; - /** - * Gets the ID of the channel. - * @return The ID of the channel. - */ - virtual const char *getChannelId() const = 0; - /** - * Releases the IChannelMember class. - */ - virtual void release() = 0; -}; -/** - * The IChannelAttributes class. - */ -class IChannelAttributes { - public: - /** - * Creates an IChannelAttributes instance. - * @return - * - An IChannelAttributes instance, if the method call succeeds. - */ - static IChannelAttributes *createChannelAttributes(); - /** - * Adds an attribute to a specified channel. - * - * @param key The pointer to the attribute key. - * @param value The pointer to the attribute value. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int addAttribute(const char *key, const char *value) = 0; - /** - * Removes an attribute from the channel. - * @param key The pointer to the attribute key. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int removeAttribute(const char *key) = 0; - /** - * Gets the size of the attributes. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getAttributesSize() const = 0; - /** - * Gets the channel attributes. - * @param size The size of the channel attributes. - * @param key The pointer to the key of each channel attribute. - * @param value The pointer to the value of each channel attribute. - */ - virtual void getAttributes(int size, char **key, - char **value) const = 0; // todo: discussion, how to traveral - /** - * Gets the value of a channel attribute using the attribute key. - * @param key The pointer to the key of the channel attribute that you want to get. - */ - virtual const char *getAttributeValue(const char *key) const = 0; - /** - * Releases the IChannelAttributes instance. - * @param - * - 0: Success. - * - < 0: Failure. - */ - virtual int release() = 0; -}; -/** - * The IChannelEventHandler class. - */ -class IChannelEventHandler { - public: - virtual ~IChannelEventHandler() {} - /** - * Occurs when the local user successfully joins a channel. - */ - virtual void onJoinSuccess() {} - /** - * Occurs when the local user fails to join a channel. - * @param errorCode The error code: #JOIN_CHANNEL_ERR. - */ - virtual void onJoinFailure(JOIN_CHANNEL_ERR errorCode) {} - /** - * Occurs when the local user leaves a channel. - * @param errorCode The error code. See #LEAVE_CHANNEL_ERR. - */ - virtual void onLeave(LEAVE_CHANNEL_ERR errorCode) {} - /** - * Occurs when the local user receives a channel message. - * @param message The pointer to the messsage: IMessage. - */ - virtual void onMessageReceived(const char *userId, const IMessage *message) {} - /** - * Reports the state of the message sent by the local user. - * @param messageId ID of the message. - * @param state The state of the message: #CHANNEL_MESSAGE_STATE. - */ - virtual void onSendMessageState(int64_t messageId, CHANNEL_MESSAGE_STATE state) {} - /** - Returns the result of the \ref agora::rtm::IChannel::sendMessage "sendMessage" method call. - - @param messageId The ID of the sent channel message. - @param state The error codes. See #CHANNEL_MESSAGE_ERR_CODE. - */ - virtual void onSendMessageResult(long long messageId, CHANNEL_MESSAGE_ERR_CODE state) {} - /** - * Occurs when another member joins the channel. - * @param member The pointer to the member who joins the channel: IChannelMember. - */ - virtual void onMemberJoined(IChannelMember *member) {} - /** - * Occurs when the other member leaves the channel. - * @param member The pointer to the member who leaves the channel: IChannelMember. - */ - virtual void onMemberLeft(IChannelMember *member) {} - /** - * Reports all the members in the channel. - * @param members The pointer to each member in the channel: IChannelMember. - * @param userCount The number of users in the channel. - */ - virtual void onMembersGotten(IChannelMember **members, int userCount) {} - /** - * Occurs when the channel attributes are updated. - * @param attributes The pointer to the current channel attributes: IChannelAttributes. - */ - virtual void onAttributesUpdated(const IChannelAttributes *attributes) {} - /** - * Occurs when the local user calls updateAttributes(). - * @param requestId ID of the current attribute update request. - * @param resCode The response code: #RESPONSE_CODE. - */ - virtual void onUpdateAttributesResponse(int64_t requestId, RESPONSE_CODE resCode) {} - /** - * Occurs when the channel attributes are deleted. - * @param attributes The pointer to the channel attributes that you want to remove: IChannelAttributes. - */ - virtual void onAttributesDeleted(const IChannelAttributes *attributes) {} - /** - * Occurs when the local user calls deleteAttributes(). - * @param requestId ID of the current attribute delete request. - * @param resCode The response code: #RESPONSE_CODE. - */ - virtual void onDeleteAttributesResponse(int64_t requestId, RESPONSE_CODE resCode) {} -}; -/** - * The IChannel class. - */ -class IChannel { - public: - /** - * Sets an event handler for IChannel. - * @param eventHandler The pointer to the event handler of IChannel: IChannelEventHandler. - */ - virtual int setEventHandler(IChannelEventHandler *eventHandler, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Joins the current channel. - * - * A successful method call triggers either onJoinSuccess() or onJoinFailure() on the local client, to report - * the state of joining the channel. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int join(aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Leaves the current channel. - * - * After the local user successfully leaves the channel, the SDK triggers the onLeave() on the local client. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int leave(aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Sends a channel message. - * - * After you successfully send a channel message, all members in the channel receive the message in the - * onMessageReceived() callback. - * @param message The pointer to the channel message that you want to send: IMessage. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int sendMessage(const IMessage *message, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Updates the channel attributes. - * - * A successful method call triggers the onUpdateAttributesResponse() callback on the local client. - * @param attributes The pointer to the channel attributes that you want to update: IChannelAttributes. - * @param requestId ID of the current update request. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int updateAttributes(IChannelAttributes *attributes, int64_t &requestId, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Removes the channel attributes. - * - * A successful method call triggers the onDeleteAttributesResponse() callback on the local client. - * @param attributes The pointer to the channel attributes that you want to remove: IChannelAttributes. - * @param requestId ID of the current delete request. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int deleteAttributes(IChannelAttributes *attributes, int64_t &requestId, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Gets the current request ID. - * @return - * - The pointer to the request ID, if the method call succeeds. - * - An empty pointer NULL, if the method call fails. - */ - virtual const char *getId() const = 0; - - // sync_call - /** - * Releases the IChannel instance. - * - * This is a synchronous method call, which means that the SDK reports the result of this method call - * after the IChannel instance is successfully released. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int release() = 0; -}; -/** - * The IRtmServiceEventHandler class. - */ -class IRtmServiceEventHandler { - public: - virtual ~IRtmServiceEventHandler() {} - - /** - * Occurs when the user successfully logs in the RTM service. - */ - virtual void onLoginSuccess() {} - /** - * Occurs when the user fails to log in the RTM service. - * @param errorCode The reason for the login failure: #LOGIN_ERR_CODE. - */ - virtual void onLoginFailure(LOGIN_ERR_CODE errorCode) {} - /** - * Occurs when the user successfully logs out of the RTM service. - */ - virtual void onLogout() {} - /** - * Occurs when the connection state of the local user has changed. - * @param state The current connection state: #CONNECTION_STATE. - */ - virtual void onConnectionStateChanged(CONNECTION_STATE state) {} - /** - * Reports the state of sending a message. - * @param messageId ID of the message. - * @param state The current state of the message: #PEER_MESSAGE_STATE. - */ - virtual void onSendMessageState(int64_t messageId, PEER_MESSAGE_STATE state) {} - /** - * Occurs when the local user receives a message from a remote user. - * @param peerId ID of the remote user that sends the message. - * @param message The pointer to the message: IMessage. - */ - virtual void onMessageReceivedFromPeer(const char *peerId, const IMessage *message) {} -}; -/** - * The IRtmService class. - */ -class IRtmService { - public: - virtual ~IRtmService() {} - /** - * Creates and gets an IRtmService instance. - * @param appId The pointer to the app ID. - * @param eventHandler The pointer to the IRtmServiceEventHandler object. - * @param eventSpace The connection specific ID, used during report to argus. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int initialize(const char *appId, IRtmServiceEventHandler *eventHandler) = 0; - /** - * Releases the IRtmServiceEventHandler object. - * @param eventHandler The pointer to the IRtmServiceEventHandler object. - */ - virtual void unregisterObserver(IRtmServiceEventHandler *eventHandler) = 0; - /** - * Releases the IRtmService instance. - * @param sync Determines whether to report the result of this method call synchronously. - * - true: Report the result of this method call after the IRtmService instance is released. - * - false: (Default) Report the result of this method call immediately, even when the IRtmService is not - * released. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int release(bool sync = false) = 0; - /** - * Logs in the RTM service. - * - * @note - * - If you login with the same user ID from a different instance, your previous login will be kicked. - * - The call frequency limit of this method is 2 queries per second. - * @param token The token used to log in the RTM service. - * @param userId ID of the user logging in the RTM service. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int login(const char *token, const char *userId, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Logs out of the RTM service. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int logout(aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Sends a peer message to a specified remote user. - * - * @param peerId The pointer to the ID of the remote user. - * @param message The pointer to message: IMessage. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int sendMessageToPeer(const char *peerId, const IMessage *message, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Creates an RTM channel. - * - * @param channelId The unique channel name for an RTM session. Supported character scopes are: - * - All lowercase English letters: a to z. - * - All uppercase English letters: A to Z. - * - All numeric characters: 0 to 9. - * - The space character. - * - Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", - * ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", "," - * - * @param eventHandler The pointer to IChannelEventHandler. - * @return - * - The pointer to an IChannel instance, if the method call succeeds. - * - An empty pointer NULL, if the method call fails. - */ - virtual IChannel *createChannel(const char *channelId, IChannelEventHandler *eventHandler) = 0; -}; - -} // namespace rtm -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtmpStreamingService.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtmpStreamingService.h deleted file mode 100644 index e9c3568c2..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraRtmpStreamingService.h +++ /dev/null @@ -1,193 +0,0 @@ - -// Copyright (c) 2019 Agora.io. All rights reserved - -// This program is confidential and proprietary to Agora.io. -// And may not be copied, reproduced, modified, disclosed to others, published -// or used, in whole or in part, without the express prior written permission -// of Agora.io. - -#pragma once // NOLINT(build/header_guard) - -#include "AgoraBase.h" -#include "AgoraRefPtr.h" -#include "IAgoraService.h" -#include "NGIAgoraRtcConnection.h" -#include - -namespace agora { -namespace rtc { - -/** - * The events in the RTMP channel. -*/ -enum RTMP_CHANNEL_EVENT -{ - /** - * 0: The live stream service is disconnected. - */ - RTMP_CHANNEL_EVENT_DISCONNECT = 0, - /** - * 1: The live stream service has left the channel. - */ - RTMP_CHANNEL_EVENT_LEAVE_CHANNEL = 1, - /** - * 2: The live stream service is banned by the server. - */ - RTMP_CHANNEL_EVENT_BANNED_BY_SERVER = 2 -}; -/** - * The IRtmpStreamingObserver class, which monitors events in of the live streaming service. - */ -class IRtmpStreamingObserver { -public: - /** - * Occurs when the state of the RTMP streaming changes. - * - * The SDK triggers this callback to report the result of the local user calling - * `addPublishStreamUrl` or `removePublishStreamUrl`. - * - * This callback also reports the streaming URL and its current streaming state. When exceptions - * occur, you can troubleshoot issues by referring to the detailed error description in the `errCode` - * parameter. - * - * @param url The RTMP URL address. - * @param state The RTMP streaming state: #RTMP_STREAM_PUBLISH_STATE. - * @param reason The detailed error information for streaming: #RTMP_STREAM_PUBLISH_REASON. - */ - virtual void onRtmpStreamingStateChanged(const char* url, RTMP_STREAM_PUBLISH_STATE state, - RTMP_STREAM_PUBLISH_REASON reason) { - (void)url; - (void)state; - (void)reason; - } - - /** Reports events during the RTMP or RTMPS streaming. - * - * @since v3.1.0 - * - * @param url The RTMP or RTMPS streaming URL. - * @param eventCode The event code. See #RTMP_STREAMING_EVENT - */ - virtual void onRtmpStreamingEvent(const char* url, RTMP_STREAMING_EVENT eventCode) { - (void)url; - (void)eventCode; - } - /** - * Occurs when the publisher's transcoding settings are updated. - * - * When the `LiveTranscoding` class in the `setLiveTransocding` method updates, the SDK triggers this callback - * to report the update information. - * - * @note - * If you call the `setLiveTranscoding` method to set the `LiveTranscoding` class for the first time, the SDK - * does not trigger this callback. - */ - virtual void onTranscodingUpdated() {} -}; -/** - * The IRtmpStreamingService class, which enables the live stream service. - */ -class IRtmpStreamingService : public RefCountInterface { - public: - - /** Publishes the local stream without transcoding to a specified CDN live RTMP address. (CDN live only.) - - * The SDK returns the result of this method call in the \ref IRtcEngineEventHandler::onStreamPublished "onStreamPublished" callback. - - * The \ref agora::rtc::IRtcEngine::startRtmpStreamWithoutTranscoding "startRtmpStreamWithoutTranscoding" method call triggers the \ref agora::rtc::IRtcEngineEventHandler::onRtmpStreamingStateChanged "onRtmpStreamingStateChanged" callback on the local client to report the state of adding a local stream to the CDN. - * @note - * - Ensure that the user joins the channel before calling this method. - * - This method adds only one stream RTMP URL address each time it is called. - * - The RTMP URL address must not contain special characters, such as Chinese language characters. - * - This method applies to Live Broadcast only. - - * @param url The CDN streaming URL in the RTMP format. The maximum length of this parameter is 1024 bytes. - - * @return - * - 0: Success. - * - < 0: Failure. - * - #ERR_INVALID_ARGUMENT (2): The RTMP URL address is NULL or has a string length of 0. - * - #ERR_NOT_INITIALIZED (7): You have not initialized the RTC engine when publishing the stream. - * - #ERR_ALREADY_IN_USE (19): This streaming URL is already in use. Use a new streaming URL for CDN streaming. - */ - virtual int startRtmpStreamWithoutTranscoding(const char* url, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** Publishes the local stream with transcoding to a specified CDN live RTMP address. (CDN live only.) - - * The SDK returns the result of this method call in the \ref IRtcEngineEventHandler::onStreamPublished "onStreamPublished" callback. - - * The \ref agora::rtc::IRtcEngine::startRtmpStreamWithTranscoding "startRtmpStreamWithTranscoding" method call triggers the \ref agora::rtc::IRtcEngineEventHandler::onRtmpStreamingStateChanged "onRtmpStreamingStateChanged" callback on the local client to report the state of adding a local stream to the CDN. - * @note - * - Ensure that the user joins the channel before calling this method. - * - This method adds only one stream RTMP URL address each time it is called. - * - The RTMP URL address must not contain special characters, such as Chinese language characters. - * - This method applies to Live Broadcast only. - - * @param url The CDN streaming URL in the RTMP format. The maximum length of this parameter is 1024 bytes. - * @param transcoding Sets the CDN live audio/video transcoding settings. See LiveTranscoding. - - * @return - * - 0: Success. - * - < 0: Failure. - * - #ERR_INVALID_ARGUMENT (2): The RTMP URL address is NULL or has a string length of 0. - * - #ERR_NOT_INITIALIZED (7): You have not initialized the RTC engine when publishing the stream. - * - #ERR_ALREADY_IN_USE (19): This streaming URL is already in use. Use a new streaming URL for CDN streaming. - */ - virtual int startRtmpStreamWithTranscoding(const char* url, const LiveTranscoding& transcoding, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** Update the video layout and audio settings for CDN live. (CDN live only.) - * @note This method applies to Live Broadcast only. - - * @param transcoding Sets the CDN live audio/video transcoding settings. See LiveTranscoding. - - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int updateRtmpTranscoding(const LiveTranscoding& transcoding, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** Stop an RTMP stream with transcoding or without transcoding from the CDN. (CDN live only.) - - * This method removes the RTMP URL address (added by the \ref IRtcEngine::startRtmpStreamWithoutTranscoding "startRtmpStreamWithoutTranscoding" method - * or IRtcEngine::startRtmpStreamWithTranscoding "startRtmpStreamWithTranscoding" method) from a CDN live stream. - * The SDK returns the result of this method call in the \ref IRtcEngineEventHandler::onStreamUnpublished "onStreamUnpublished" callback. - - * The \ref agora::rtc::IRtcEngine::stopRtmpStream "stopRtmpStream" method call triggers the \ref agora::rtc::IRtcEngineEventHandler::onRtmpStreamingStateChanged "onRtmpStreamingStateChanged" callback on the local client to report the state of removing an RTMP stream from the CDN. - * @note - * - This method removes only one RTMP URL address each time it is called. - * - The RTMP URL address must not contain special characters, such as Chinese language characters. - * - This method applies to Live Broadcast only. - - * @param url The RTMP URL address to be removed. The maximum length of this parameter is 1024 bytes. - - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int stopRtmpStream(const char* url, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Registers an RTMP streaming observer. - * @param observer The pointer to an RTMP streaming observer. See \ref agora::rtc::IRtmpStreamingObserver "IRtmpStreamingObserver". - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerObserver(IRtmpStreamingObserver* observer, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Releases the RTMP streaming observer created by registerObserver(). - * @param observer The pointer to the RTMP streaming observer that you want to release. See \ref agora::rtc::IRtmpStreamingObserver "IRtmpStreamingObserver". - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unregisterObserver(IRtmpStreamingObserver* observer) = 0; - - protected: - ~IRtmpStreamingService() {} -}; - - - - -} // namespace rtc -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraService.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraService.h deleted file mode 100644 index b5c036340..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAgoraService.h +++ /dev/null @@ -1,1024 +0,0 @@ -// Agora SDK -// -// Copyright (c) 2018 Agora.io. All rights reserved. -// - -#pragma once // NOLINT(build/header_guard) - -#include "IAgoraLog.h" -#include "AgoraBase.h" -#include "AgoraOptional.h" -#include - -namespace agora { -class ILocalDataChannel; -class IRemoteDataChannel; -struct DataChannelConfig; - -namespace rtc { -class IRtcConnection; -class IRtmpConnection; -class ILocalUser; -class IMediaDeviceManager; -class INGAudioDeviceManager; -struct TConnectionInfo; -struct RtcConnectionConfiguration; -struct RtmpConnectionConfiguration; -class ILocalAudioTrack; -class IMediaPlayerSource; -class IMediaStreamingSource; -class ICameraCapturer; -class IScreenCapturer; -class IScreenCapturer2; -class IAudioPcmDataSender; -class IAudioEncodedFrameSender; -class IVideoFrameSender; -class IVideoEncodedImageSender; -class IVideoSourceNode; -class IVideoMixerSource; -class IVideoFrameTransceiver; -class ILocalVideoTrack; -class IMediaNodeFactory; -class IRecordingDeviceSource; -class IRemoteAudioMixerSource; -class IRtmpStreamingService; -class IMediaPacketSender; -class IMediaRelayService; -class IAudioDeviceManager; -class IAudioDeviceManagerObserver; - -class IMediaExtensionObserver; -class IExtensionProvider; -class IFileUploaderService; -class IConfigCenter; -/** - * The audio encoder configuration. - */ -struct AudioEncoderConfiguration { - /** - * The audio profile: #AUDIO_PROFILE_TYPE - */ - AUDIO_PROFILE_TYPE audioProfile; - - AudioEncoderConfiguration() : audioProfile(AUDIO_PROFILE_DEFAULT) {} -}; - -} // namespace rtc - -namespace rtm { -class IRtmService; -} - -namespace base { -class IServiceObserver; -class ISyncClient; -struct SyncConfig; - -/** - * The global configurations for \ref agora::base::IAgoraService "AgoraService". - * - * Set these configurations when calling \ref agora::base::IAgoraService::initialize "initialize". - */ -struct AgoraServiceConfiguration { - /** - * Whether to enable the audio processing module. - * - `true`: (Default) Enable the audio processing module. - * - `false`: Disable the audio processing module. If you disable the audio processing module, you cannot create audio tracks. - */ - bool enableAudioProcessor; - /** - * Whether to enable the audio device module. The function of the audio device module is to manage audio devices, - * such as recording and playing audio. - * - `true`: (Default) Enable the audio device module. Audio recording and playback is available. - * - `false`: Disable the audio device module. Audio recording and playback is unavailable. - * - * @note - * If you set `enableAudioDevice` as `false` and set `enableAudioProcessor` as `true`, you cannot use audio devices, - * but you can push PCM audio data. - */ - bool enableAudioDevice; - /** - * Whether to enable video. - * - `true`: Enable video. - * - `false`: (Default) Disable video. - */ - bool enableVideo; - /** - * The user context. - * - For Windows, it is the handle of the window that loads the video. Specify this value to support plugging or unplugging the video devices while the host is powered on. - * - For Android, it is the context of activity. - */ - void* context; - /** - * The App ID of your project. - */ - const char* appId; - - /** - * The supported area code, default is AREA_CODE_GLOB - */ - unsigned int areaCode; - - /** The channel profile. For details, see \ref agora::CHANNEL_PROFILE_TYPE "CHANNEL_PROFILE_TYPE". The default channel profile is `CHANNEL_PROFILE_LIVE_BROADCASTING`. - */ - agora::CHANNEL_PROFILE_TYPE channelProfile; - - /** - * The license used for verification when connectting channel. Charge according to the license - */ - const char* license; - - /** - * The audio scenario. See \ref agora::rtc::AUDIO_SCENARIO_TYPE "AUDIO_SCENARIO_TYPE". The default value is `AUDIO_SCENARIO_DEFAULT`. - */ - rtc::AUDIO_SCENARIO_TYPE audioScenario; - /** - * The config for custumer set log path, log size and log level. - */ - commons::LogConfig logConfig; - /** - * Whether to enable string uid. - */ - bool useStringUid; - /** - * The service observer. - */ - IServiceObserver* serviceObserver; - - /** - * @deprecated Thread priority for SDK common threads - */ - Optional threadPriority __deprecated; - /** - * Whether use egl context in current thread as sdk‘s root egl context - * which shared by all egl related modules. eg. camera capture, video renderer. - * @note - * This property applies to Android only. - */ - bool useExternalEglContext; - - /** - * Determines whether to enable domain limit. - * - `true`: only connect to servers that already parsed by DNS - * - `false`: (Default) connect to servers with no limit - */ - bool domainLimit; - - AgoraServiceConfiguration() : enableAudioProcessor(true), - enableAudioDevice(true), - enableVideo(false), - context(NULL), - appId(NULL), - areaCode(rtc::AREA_CODE_GLOB), - channelProfile(agora::CHANNEL_PROFILE_LIVE_BROADCASTING), - license(NULL), - audioScenario(rtc::AUDIO_SCENARIO_DEFAULT), - useStringUid(false), - serviceObserver(NULL), - useExternalEglContext(false), - domainLimit(false){} -}; -/** - * The audio session configurations. - * - * Set these configurations when calling \ref agora::base::IAgoraService::setAudioSessionConfiguration "setAudioSessionConfiguration". - */ -struct AudioSessionConfiguration { - /** - * Whether to enable audio input (recording) and audio output (playback): - * - `true`: Enable audio recording and playback. - * - `false`: Disable audio recording and playback, which prevents audio input - * and output. - * - * @note - * - For the recording function to work, the user must grant permission for audio recording. - * - By default, the audio of your app is nonmixable, which means - * activating audio sessions in your app interrupts other nonmixable audio sessions. - * Set `allowMixWithOthers` as `true` to allow audio mixing. - */ - Optional playbackAndRecord; - /** - * Whether to enable chat mode: - * - `true`: Enable chat mode. This mode is for apps that are engaged in two-way - * real-time communication, such as a voice or video chat. - * - `false`: Disable chat mode. - * - * For a video chat, set this member as `true` and set the audio route to the speaker. - */ - Optional chatMode; - /** - * Whether the audio defaults to the built-in speaker: - * - `true`: The audio defaults to the built-in speaker. - * - `false`: The audio does not default to the built-in speaker. - * - * @note - * This member is available only when `playbackAndRecord` is set as `true`. - */ - Optional defaultToSpeaker; - /** - * Whether to temporarily change the current audio route to the built-in speaker: - * - `true`: Set the current audio route to the built-in speaker. - * - `false`: Do not set the current audio route to the built-in speaker. - * - * @note - * This member is available only when the `playbackAndRecord` member is set as `true`. - */ - Optional overrideSpeaker; - /** - * Whether to mix the audio from this session with the audio from active audio sessions in other apps. - * - `true`: Mix the audio sessions. - * - `false`: Do not mix the audio session. - * - * @note - * This member is available only when the `playbackAndRecord` member is set as `true`. - */ - Optional allowMixWithOthers; - /** - * Whether to duck the audio from this session with the audio from active audio sessions in other apps. - * - `true`: Duck the audio sessions. - * - `false`: Do not duck the audio session. - * - * @note - * This member is available only when the `playbackAndRecord` member is set as `true`. - */ - Optional allowDuckOthers; - /** - * Whether to allow Bluetooth handsfree devices to appear as available audio input - * devices: - * - `true`: Allow Bluetooth handsfree devices to appear as available audio input routes. - * - `false`: Do not allow Bluetooth handsfree devices to appear as available audio input - * routes. - * - * @note - * This member is available only when the `playbackAndRecord` member is set as `true`. - */ - Optional allowBluetooth; - /** - * Whether to allow the audio from this session to be routed to Bluetooth - * devices that support the Advanced Audio Distribution Profile (A2DP). - * - `true`: Allow the audio from this session to be routed to Bluetooth devices that - * support the Advanced Audio Distribution Profile (A2DP). - * - `false`: Do not allow the audio from this session to be routed to Bluetooth devices that - * support the Advanced Audio Distribution Profile (A2DP). - * - * @note - * This member is available only when the `playbackAndRecord` member is set as `true`. - */ - Optional allowBluetoothA2DP; - /** - * The expected audio sample rate (kHz) of this session. - * - * The value range is [8,48]. The actual sample rate may differ based on the audio sampling - * device in use. - */ - Optional sampleRate; - /** - * The expected input and output buffer duration (ms) of this session. - * - * The value range is [0,93]. The actual I/O buffer duration might be lower - * than the set value based on the hardware in use. - */ - Optional ioBufferDuration; - /** - * The expected number of input audio channels of this session. - */ - Optional inputNumberOfChannels; - /** - * The expected number of output audio channels of this session. - */ - Optional outputNumberOfChannels; - -#if defined(WEBRTC_IOS) - /** - * Initialize the AudioSession with the value for category. (iOS only) - */ - Optional category; -#endif - - void SetAll(const AudioSessionConfiguration& change) { - SetFrom(&playbackAndRecord, change.playbackAndRecord); - SetFrom(&chatMode, change.chatMode); - SetFrom(&defaultToSpeaker, change.defaultToSpeaker); - SetFrom(&overrideSpeaker, change.overrideSpeaker); - SetFrom(&allowMixWithOthers, change.allowMixWithOthers); - SetFrom(&allowDuckOthers, change.allowDuckOthers); - SetFrom(&allowBluetooth, change.allowBluetooth); - SetFrom(&allowBluetoothA2DP, change.allowBluetoothA2DP); - SetFrom(&sampleRate, change.sampleRate); - SetFrom(&ioBufferDuration, change.ioBufferDuration); - SetFrom(&inputNumberOfChannels, change.inputNumberOfChannels); - SetFrom(&outputNumberOfChannels, change.outputNumberOfChannels); -#if defined(WEBRTC_IOS) - SetFrom(&category, change.category); -#endif - } - - bool operator==(const AudioSessionConfiguration& o) const { - return playbackAndRecord == o.playbackAndRecord && chatMode == o.chatMode && - defaultToSpeaker == o.defaultToSpeaker && overrideSpeaker == o.overrideSpeaker && - allowMixWithOthers == o.allowMixWithOthers && allowDuckOthers == o.allowDuckOthers && - allowBluetooth == o.allowBluetooth && allowBluetoothA2DP == o.allowBluetoothA2DP && sampleRate == o.sampleRate && - ioBufferDuration == o.ioBufferDuration && - inputNumberOfChannels == o.inputNumberOfChannels && -#if defined(WEBRTC_IOS) - outputNumberOfChannels == o.outputNumberOfChannels && - category == o.category; -#else - outputNumberOfChannels == o.outputNumberOfChannels; -#endif - } - bool operator!=(const AudioSessionConfiguration& o) const { return !(*this == o); } - - private: - template - static void SetFrom(Optional* s, const Optional& o) { - if (o) { - *s = o; - } - } -}; -/** - * The audio mixing mode. - */ -enum TMixMode { - /** - * Mix all the local audio tracks in the channel. - */ - MIX_ENABLED, - /** - * Do not mix the local audio tracks in the channel. - */ - MIX_DISABLED, -}; - -/** - * The IServiceObserver class. - */ -class IServiceObserver { -public: - virtual ~IServiceObserver() {} - - /** - * Reports the permission error. - * @param permission {@link PERMISSION} - */ - virtual void onPermissionError(agora::rtc::PERMISSION_TYPE permissionType) {} - /** - * Reports the audio device error. - * @param error {@link ERROR_CODE_TYPE} - */ - virtual void onAudioDeviceError(ERROR_CODE_TYPE error, const char* description) {} - /** - * Reports the config fetch result. - * - * @param code The error code of fetching config. - * - 0(ERR_OK): Success. - * - 10(ERR_TIMEDOUT): Fetching config is timed out. - * @param configType The type of fetching config. - * - 1(CONFIG_FETCH_TYPE_INITIALIZE): Fetch config when initializing RtcEngine without channel info. - * - 2(CONFIG_FETCH_TYPE_JOIN_CHANNEL): Fetch config when joining channel with channel info, such as channel name and uid. - * @param configContent The config fetched from server. - */ - virtual void onFetchConfigResult(int code, rtc::CONFIG_FETCH_TYPE configType, const char* configContent) {} -}; - -/** - * The IAgoraService class. - * - * `IAgoraService` is the entry point of Agora low-level APIs. Use this interface to - * create access points to Agora interfaces, including RTC connections and media tracks. - * - * You can create an `IAgoraService` object by calling \ref agora::base::IAgoraService::createAgoraService "createAgoraService". - * - * You can configure the `IAgoraService` object for different user scenarios on the global level by using `AgoraServiceConfiguration`. - */ -class IAgoraService { - public: - /** - * Initializes the \ref agora::base::IAgoraService "AgoraService" object. - * - * @param config The configuration of the initialization. For details, see \ref agora::base::AgoraServiceConfiguration "AgoraServiceConfiguration". - * @return - * - 0: Success. - * - < 0: Failure. - * - `ERR_INVALID_ARGUMENT`, if `context` in `AgoraServiceConfiguration` is not provided for - * Android. - * - `ERR_INIT_NET_ENGINE`, if the network engine cannot be initialized. On Windows, the error occurs mostly because the connection to the local port is disabled by the firewall. In this case, turn off the firewall and then turn it on again. - */ - virtual int initialize(const AgoraServiceConfiguration& config) = 0; - - /** - * Flush log & cache before exit - */ - virtual int atExit(aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Releases the \ref agora::base::IAgoraService "AgoraService" object. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int release() = 0; - - /** - * Configures the preset audio scenario. - * - * @param scenario The preset audio scenario: \ref agora::rtc::AUDIO_SCENARIO_TYPE - * "AUDIO_SCENARIO_TYPE". - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setAudioSessionPreset(agora::rtc::AUDIO_SCENARIO_TYPE scenario, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Customizes the audio session configuration. - * - * @param config The reference to the audio session configuration: \ref agora::base::AudioSessionConfiguration "AudioSessionConfiguration". - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setAudioSessionConfiguration(const AudioSessionConfiguration& config, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Gets the audio session configuration. - * - * @param [out] config The pointer to the audio session configuration: \ref agora::base::AudioSessionConfiguration "AudioSessionConfiguration". - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getAudioSessionConfiguration(AudioSessionConfiguration* config) = 0; - - /** - * Sets the path and size of the SDK log files. - * - * The SDK records all the log data during the SDK runtime in two log files, - * each with a default size of 512 KB. If you set `fileSize` as 1024 KB, - * the SDK outputs log files with a maximum size of 2 MB. If the total size - * of the log files exceeds the set value, the new output log - * overwrites the old output log. - * - * @note - * To ensure that the output log is complete, call this method immediately after calling - * \ref agora::base::IAgoraService::initialize "initialize". - * - * @param filePath The pointer to the log file. Ensure that the directory of the log file exists and is writable. - * @param fileSize The size of the SDK log file size (Byte), which means fileSize bytes per log file. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setLogFile(const char* filePath, unsigned int fileSize, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Sets the SDK log output filter. - * - * The log level follows the sequence of OFF, CRITICAL, ERROR, WARNING, INFO, and DEBUG. - * - * Select a level to output the logs in and above the selected level. - * For example, if you set the log level to WARNING, you can see the logs in the levels of CRITICAL, ERROR, and WARNING. - * - * @param filters The log output filter. - * - `LOG_LEVEL_NONE (0x0000)`: Do not output any log file. - * - `LOG_LEVEL_INFO (0x0001)`: (Recommended) Output log files of the INFO level. - * - `LOG_LEVEL_WARN (0x0002)`: Output log files of the WARN level. - * - `LOG_LEVEL_ERROR (0x0004)`: Output log files of the ERROR level. - * - `LOG_LEVEL_FATAL (0x0008)`: Output log files of the FATAL level. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setLogFilter(unsigned int filters, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Creates an \ref agora::rtc::IRtcConnection "RtcConnection" object and returns the pointer. - * - * @param cfg The reference to the RTC connection configuration: \ref agora::rtc::RtcConnectionConfiguration "RtcConnectionConfiguration". - * @return - * - The pointer to \ref rtc::IRtcConnection "IRtcConnection": Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createRtcConnection( - const rtc::RtcConnectionConfiguration& cfg) = 0; - - virtual agora_refptr createRtmpConnection( - const rtc::RtmpConnectionConfiguration& cfg) = 0; - - /** - * Creates a local audio track object and returns the pointer. - * - * By default, the audio track is created from the selected audio input device, such as - * the built-in microphone on a mobile device. - * - * @return - * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success. - * - A null pointer: Failure. - * - `INVALID_STATE`, if `enableAudioProcessor` in \ref agora::base::AgoraServiceConfiguration "AgoraServiceConfiguration" is set as `false`. - */ - virtual agora_refptr createLocalAudioTrack() = 0; - - /** - * Creates a local mixed audio track object and returns the pointer. - * - * By default, the audio track is created from mix source, which could mixed target track. - * - * @return - * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createLocalMixedAudioTrack() = 0; - - /** - * Creates a local audio track object with a PCM data sender and returns the pointer. - * - * Once created, this track can be used to send PCM audio data. - * - * @param audioSource The pointer to the PCM audio data sender: \ref agora::rtc::IAudioPcmDataSender "IAudioPcmDataSender". - * @return - * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success. - * - A null pointer: Failure. - * - `INVALID_STATE`, if `enableAudioProcessor` in \ref agora::base::AgoraServiceConfiguration "AgoraServiceConfiguration" is set as `false`. - */ - virtual agora_refptr createCustomAudioTrack( - agora_refptr audioSource) = 0; - - /** - * Creates a local audio track object with a PCM data sender and returns the pointer. - * The source is not intended to be mixed with other source. - * - * Once created, this track can be used to send PCM audio data. - * - * @param audioSource The pointer to the PCM audio data sender: \ref agora::rtc::IAudioPcmDataSender "IAudioPcmDataSender". - * @return - * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success. - * - A null pointer: Failure. - * - `INVALID_STATE`, if `enableAudioProcessor` in \ref agora::base::AgoraServiceConfiguration "AgoraServiceConfiguration" is set as `false`. - */ - virtual agora_refptr createDirectCustomAudioTrack( - agora_refptr audioSource) = 0; - - /** - * Creates a local audio track object with a PCM data sender and returns the pointer. - * - * Once created, this track can be used to send PCM audio data. - * - * @param audioSource The pointer to the PCM audio data sender: \ref agora::rtc::IAudioPcmDataSender "IAudioPcmDataSender". - * @param enableAec Whether enable audio echo cancellation for PCM audio data. - * @return - * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success. - * - A null pointer: Failure. - * - `INVALID_STATE`, if `enableAudioProcessor` in \ref agora::base::AgoraServiceConfiguration "AgoraServiceConfiguration" is set as `false`. - */ - virtual agora_refptr createCustomAudioTrack( - agora_refptr audioSource, bool enableAec) = 0; - - /** - * Creates a local audio track object with a audio mixer source and returns the pointer. - * - * Once created, this track can be used to send PCM audio data. - * - * @param audioSource The pointer to the audio mixer source : \ref agora::rtc::IRemoteAudioMixerSource "IRemoteAudioMixerSource". - * @return - * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack", if the method call succeeds. - * - A null pointer, if the method call fails. - * - `INVALID_STATE`, if `enableAudioProcessor` in `AgoraServiceConfiguration` is set as `false`. - */ - virtual agora_refptr createCustomAudioTrack( - agora_refptr audioSource) = 0; - - /** - * Creates a local audio track object with an encoded audio frame sender and returns the pointer. - * - * Once created, this track can be used to send encoded audio frames, such as Opus frames. - * - * @param audioSource The pointer to the encoded audio frame sender: \ref agora::rtc::IAudioEncodedFrameSender "IAudioEncoderFrameSender". - * @param mixMode The mixing mode of the encoded audio in the channel: #TMixMode. - * @return - * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success. - * - A null pointer: Failure. - * - `INVALID_STATE`, if `enableAudioProcessor` is set as `false` in \ref agora::base::AgoraServiceConfiguration "AgoraServiceConfiguration". - */ - virtual agora_refptr createCustomAudioTrack( - agora_refptr audioSource, TMixMode mixMode) = 0; -/// @cond (!Linux) - /** - * Creates a local audio track object with a media packet sender and returns the pointer. - * - * Once created, this track can be used to send audio packets, such as customized UDP/RTP packets. - * - * @param source The pointer to the media packet sender: \ref agora::rtc::IMediaPacketSender "IMediaPacketSender". - * @return - * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success. - * - A null pointer: Failure. - * - `INVALID_STATE`, if `enableAudioProcessor` is set as `false` in \ref agora::base::AgoraServiceConfiguration "AgoraServiceConfiguration". - */ - virtual agora_refptr createCustomAudioTrack( - agora_refptr source) = 0; - /// @endcond - /** - * Creates a local audio track object with an IMediaPlayerSource object and returns the pointer. - * - * Once created, this track can be used to send PCM audio data decoded from a media player. - * - * @param audioSource The pointer to the player source. See \ref agora::rtc::IMediaPlayerSource "IMediaPlayerSource". - * @return - * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success. - * - A null pointer: Failure. - * - `INVALID_STATE`, if `enableAudioProcessor` is set as `false` in \ref agora::base::AgoraServiceConfiguration "AgoraServiceConfiguration". - */ - virtual agora_refptr createMediaPlayerAudioTrack( - agora_refptr audioSource) = 0; - - /** - * Creates a local audio track object with an IMediaStreamingSource object and returns the pointer. - * - * Once created, this track can be used to send encoded audio data which demuxed from a media streaming. - * - * @param streamingSource The pointer to the streaming source. See \ref agora::rtc::IMediaStreamingSource "IMediaStreamingSource". - * @return - * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success. - * - A null pointer: Failure. - * - `INVALID_STATE`, if `enableAudioProcessor` is set as `false` in \ref agora::base::AgoraServiceConfiguration "AgoraServiceConfiguration". - */ - virtual agora_refptr createMediaStreamingAudioTrack( - agora_refptr streamingSource) = 0; - - /** - * Creates a local audio track object with the recording device source and returns the pointer. - * - * Once created, this track can be used to send audio data got from a recording device. - * @param audioSource The pointer to the recording device source. See \ref agora::rtc::IRecordingDeviceSource "IRecordingDeviceSource". - * @param enableAec Whether enable audio echo cancellation for loopback recording. If loopback - * recording device is a virtual sound card, it should be false, or it should be true. - * @param overlap Whether overlap playout signal. - * @return - * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createRecordingDeviceAudioTrack( - agora_refptr audioSource, bool enableAec, bool overlap) = 0; - - /** - * Creates an audio device manager object and returns the pointer. - * - * @return - * - The pointer to \ref rtc::INGAudioDeviceManager "INGAudioDeviceManager": Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createAudioDeviceManager() = 0; - - /** - * Creates a media node factory object and returns the pointer. - * - * @return - * - The pointer to \ref rtc::IMediaNodeFactory "IMediaNodeFactory": Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createMediaNodeFactory() = 0; - - /** - * Creates a local video track object with a camera capturer and returns the pointer. - * - * Once created, this track can be used to send video data captured by the camera. - * - * @param videoSource The pointer to the camera capturer: \ref agora::rtc::ICameraCapturer "ICameraCapturer". - * - * @return - * - The pointer to \ref rtc::ILocalVideoTrack "ILocalVideoTrack": Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createCameraVideoTrack( - agora_refptr videoSource, const char* id = OPTIONAL_NULLPTR) = 0; - - /** - * Creates a local video track object with a video mixer and returns the pointer. - * - * Once created, this track can be used to send video data processed by the video mixer. - * - * @param videoSource The pointer to the video mixer. See \ref agora::rtc::IVideoMixerSource "IVideoMixerSource". - * - * @return - * - The pointer to \ref rtc::ILocalVideoTrack "ILocalVideoTrack": Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createMixedVideoTrack(agora_refptr videoSource, - const char* id = OPTIONAL_NULLPTR) = 0; - - /** - * Creates a local video track object with a video frame transceiver and returns the pointer. - * - * Once created, this track can be used to send video data processed by the transceiver. - * - * @param transceiver The pointer to the video transceiver. See \ref agora::rtc::IVideoFrameTransceiver "IVideoFrameTransceiver". - * - * @return - * - The pointer to \ref rtc::ILocalVideoTrack "ILocalVideoTrack": Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createTranscodedVideoTrack(agora_refptr transceiver, - const char* id = OPTIONAL_NULLPTR) = 0; - -/// @cond (!RTSA) - /** - * Creates a local video track object with a customized video source and returns the pointer. - * - * Once created, this track can be used to send video data from a customized source. - * - * @param videoSource The pointer to the customized video frame sender: \ref agora::rtc::IVideoFrameSender "IVideoFrameSender". - * @return - * - The pointer to \ref rtc::ILocalVideoTrack "ILocalVideoTrack": Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createCustomVideoTrack( - agora_refptr videoSource, const char* id = OPTIONAL_NULLPTR) = 0; -/// @endcond - - /** - * Creates a local video track object with an encoded video image sender and returns the pointer. - * - * Once created, this track can be used to send encoded video images, such as H.264 or VP8 frames. - * - * @param videoSource The pointer to the encoded video frame sender. See \ref agora::rtc::IVideoEncodedImageSender "IVideoEncodedImageSender". - * @param options The configuration for creating video encoded image track. - * - * @return - * - The pointer to \ref rtc::ILocalVideoTrack "ILocalVideoTrack": Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createCustomVideoTrack( - agora_refptr videoSource, - const rtc::SenderOptions& options, - const char* id = OPTIONAL_NULLPTR) = 0; - -#if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || defined(__OHOS__) - /** - * Creates a local video track object with a screen capture source extension and returns the pointer. - * - * Once created, this track can be used to work with the screen capture extension. - * - * @param screen The pointer to the screen capture source. - * - * @return - * - The pointer to \ref rtc::ILocalVideoTrack "ILocalVideoTrack": Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createScreenCaptureVideoTrack( - agora_refptr screen) = 0; - -/** - * Creates a local audio track object with a screen capture source extension and returns the pointer. - * - * Once created, this track can be used to work with the screen capture extension. - * - * @param screen The pointer to the screen capture source. - * - * @return - * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createScreenCaptureAudioTrack( - agora_refptr screen) = 0; -#else - /** - * Creates a local video track object with a screen capture source extension and returns the pointer. - * - * Once created, this track can be used to work with the screen capture extension. - * - * @param screen The pointer to the screen capture source. - * - * @return - * - The pointer to \ref rtc::ILocalVideoTrack "ILocalVideoTrack": Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createScreenCaptureVideoTrack( - agora_refptr screen, const char* id = OPTIONAL_NULLPTR) = 0; -#endif - -/// @cond (!Linux) - /** - * Creates a local video track object with a media packet sender and returns the pointer. - * - * Once created, this track can be used to send video packets, such as customized UDP/RTP packets. - * - * @param source The pointer to the media packet sender: \ref agora::rtc::IMediaPacketSender "IMediaPacketSender". - * @return - * - The pointer to \ref rtc::ILocalVideoTrack "ILocalVideoTrack": Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createCustomVideoTrack( - agora_refptr source, const char* id = OPTIONAL_NULLPTR) = 0; -/// @endcond - /** - * Creates a local video track object with an IMediaPlayerSource object and returns the pointer. - * - * Once created, this track can be used to send YUV frames decoded from a player. - * - * @param videoSource The pointer to the player source. See \ref agora::rtc::IMediaPlayerSource "IMediaPlayerSource". - * @return - * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createMediaPlayerVideoTrack( - agora_refptr videoSource, const char* id = OPTIONAL_NULLPTR) = 0; - - /** - * Creates a local video track object with an IMediaStreamingSource object and returns the pointer. - * - * Once created, this track can be used to send H264 frames which demuxed from a streaming. - * - * @param streamingSource The pointer to the player source. See \ref agora::rtc::IMediaStreamingSource "IMediaStreamingSource". - * @return - * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createMediaStreamingVideoTrack( - agora_refptr streamingSource, const char* id = OPTIONAL_NULLPTR) = 0; - - - /** - * Creates an RTMP streaming service object and returns the pointer. - * - * @param rtcConnection The pointer to \ref rtc::IRtcConnection "IRtcConnection". - * @param appId The App ID of the live streaming service. - * @return - * - The pointer to \ref rtc::IRtmpStreamingService "IRtmpStreamingService": Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createRtmpStreamingService( - agora_refptr rtcConnection, const char* appId) = 0; - - /** - * Creates an Media Relay service object and returns the pointer. - * - * @param rtcConnection The pointer to \ref rtc::IRtcConnection "IRtcConnection". - * @param appId The App ID of the media relay service. - * @return - * - The pointer to \ref rtc::IMediaRelayService "IMediaRelayService", if the method call - * succeeds. - * - A null pointer, if the method call fails. - */ - virtual agora_refptr createMediaRelayService( - agora_refptr rtcConnection, const char* appId) = 0; - - /** - * Creates an file upload object and returns the pointer. - * - * @param rtcConnection The pointer to \ref rtc::IRtcConnection "IRtcConnection". - * @param appId The App ID of the media relay service. - * @return - * - The pointer to \ref rtc::IFileUploaderService "IFileUploaderService", if the method call - * succeeds. - * - A null pointer, if the method call fails. - */ - virtual agora_refptr createFileUploadService( - agora_refptr rtcConnection, const char* appId) = 0; - - /** - * Creates an RTM servive object and returns the pointer. - * - * @return - * - The pointer to \ref rtm::IRtmService "IRtmService": Success. - * - A null pointer: Failure. - */ - virtual rtm::IRtmService* createRtmService() = 0; - - virtual int addExtensionObserver(agora::agora_refptr observer, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - virtual int removeExtensionObserver(agora::agora_refptr observer, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Creates an audio device manager and returns the pointer. - * - * @return - * - The pointer to \ref rtc::IAudioDeviceManager "IAudioDeviceManager": Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createAudioDeviceManagerComponent( - rtc::IAudioDeviceManagerObserver *observer) = 0; - - /** - * Creates an data channel and returns the pointer. - * - * @return - * - The pointer to \ref rtc::ILocalDataChannel "ILocalDataChannel": Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createLocalDataChannel(const DataChannelConfig& config) = 0; - - /** - * @brief Get the ID of the registered extension - * - * @param provider_name The pointer to provider name string (null-terminated) - * @param extension_name The pointer to extension name string (null-terminated) - * @return - * - Pointer to the extension id string (null-terminated). The pointer will be valid during service's lifetime - */ - virtual const char* getExtensionId(const char* provider_name, const char* extension_name) = 0; - -#if defined (_WIN32) || defined(__linux__) || defined(__ANDROID__) - /** - * @brief load the dynamic library of the extension - * - * @param path path of the extension library - * @param unload_after_use unload the library when engine release - * @return int - */ - virtual int loadExtensionProvider(const char* path, bool unload_after_use = false) = 0; -#endif - /** - * Enable extension. - * If the extension is enabled, the track loads the extension automatically. - * - * @param provider_name name for provider, e.g. agora.io. - * @param extension_name name for extension, e.g. agora.beauty. - * @param track_id id for the track, OPTIONAL_NULLPTR means effective on all tracks - * @param auto_enable_on_track if the extension is automatically open on track. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableExtension( - const char* provider_name, const char* extension_name, const char* track_id = NULL, - bool auto_enable_on_track = false, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Disable extension. - * - * @param provider_name name for provider, e.g. agora.io. - * @param extension_name name for extension, e.g. agora.beauty. - * @param track_id id for the track, OPTIONAL_NULLPTR means effective on all tracks - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int disableExtension( - const char* provider_name, const char* extension_name, const char* track_id = NULL, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Gets the IAgoraParameter object. - * @since 4.3.0 - * @return - * - The pointer to the \ref agora::base::IAgoraParameter "IAgoraParameter" object. - * - A null pointer: Failure. - */ - virtual agora_refptr getAgoraParameter() = 0; - - /** - * Get the \ref agora::rtc::IConfigCenter "IConfigCenter" object and return the pointer. - * - * @return - * - The pointer to \ref rtc::IConfigCenter "IConfigCenter": Success. - * - A null pointer: Failure. - */ - virtual agora_refptr getConfigCenter() = 0; - - /** - * Get the \ref agora::rtc::ISyncClient "ISyncClient" object and return the pointer. - * - * @return - * - The pointer to \ref rtc::ISyncClient "ISyncClient": Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createSyncClient(const base::SyncConfig& config) = 0; - - /** - * Set the logWriter for the sdk log. - * @param logWriter the log writer - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int32_t setLogWriter(agora::commons::ILogWriter* logWriter) = 0; - - /** - * Release logWriter for the sdk log. - * @return - * -The pointer to \ref agora::commons::ILogWriter - * - A null pointer: Failure. - */ - virtual agora::commons::ILogWriter* releaseLogWriter() = 0; - - protected: - virtual ~IAgoraService() {} -}; - -} // namespace base -} // namespace agora - -/** \addtogroup createAgoraService - @{ - */ -/** - * Creates an \ref agora::base::IAgoraService "IAgoraService" object and returns the pointer. - * - * @return - * - The pointer to \ref agora::base::IAgoraService "IAgoraService": Success. - * - A null pointer: Failure. - */ -AGORA_API agora::base::IAgoraService* AGORA_CALL createAgoraService(); -/** @} */ - -AGORA_API void AGORA_CALL TestHmOs(); \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAudioDeviceManager.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAudioDeviceManager.h deleted file mode 100644 index 6537f0990..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/IAudioDeviceManager.h +++ /dev/null @@ -1,532 +0,0 @@ -// -// Agora SDK -// -// Copyright (c) 2021 Agora.io. All rights reserved. -// -#pragma once // NOLINT(build/header_guard) - -namespace agora { -namespace rtc { - -/** - * The maximum device ID length. - */ -enum MAX_DEVICE_ID_LENGTH_TYPE { - /** - * The maximum device ID length is 512. - */ - MAX_DEVICE_ID_LENGTH = 512 -}; - -/** - * The IAudioDeviceCollection class. - */ -class IAudioDeviceCollection { -public: - virtual ~IAudioDeviceCollection() {} - - /** - * Gets the total number of the playback or recording devices. - * - * Call \ref IAudioDeviceManager::enumeratePlaybackDevices - * "enumeratePlaybackDevices" first, and then call this method to return the - * number of the audio playback devices. - * - * @return - * - The number of the audio devices, if the method call succeeds. - * - < 0, if the method call fails. - */ - virtual int getCount() = 0; - - /** - * Gets the information of a specified audio device. - * @param index An input parameter that specifies the audio device. - * @param deviceName An output parameter that indicates the device name. - * @param deviceId An output parameter that indicates the device ID. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getDevice(int index, char deviceName[MAX_DEVICE_ID_LENGTH], - char deviceId[MAX_DEVICE_ID_LENGTH]) = 0; - - /** - * Gets the information of a specified audio device. - * @note - * @param index An input parameter that specifies the audio device. - * @param deviceName An output parameter that indicates the device name. - * @param deviceTypeName An output parameter that indicates the device type name. such as Built-in, USB, HDMI, etc. (MacOS only) - * @param deviceId An output parameter that indicates the device ID. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getDevice(int index, char deviceName[MAX_DEVICE_ID_LENGTH], char deviceTypeName[MAX_DEVICE_ID_LENGTH], - char deviceId[MAX_DEVICE_ID_LENGTH]) = 0; - - /** - * Specifies a device with the device ID. - * @param deviceId The device ID. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setDevice(const char deviceId[MAX_DEVICE_ID_LENGTH]) = 0; - - /** - * Gets the default audio device of the system (for macOS and Windows only). - * - * @param deviceName The name of the system default audio device. - * @param deviceId The device ID of the the system default audio device. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getDefaultDevice(char deviceName[MAX_DEVICE_ID_LENGTH], char deviceId[MAX_DEVICE_ID_LENGTH]) = 0; - - /** - * Gets the default audio device of the system (for macOS and Windows only). - * - * @param deviceName The name of the system default audio device. - * @param deviceTypeName The device type name of the the system default audio device, such as Built-in, USB, HDMI, etc. (MacOS only) - * @param deviceId The device ID of the the system default audio device. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getDefaultDevice(char deviceName[MAX_DEVICE_ID_LENGTH], char deviceTypeName[MAX_DEVICE_ID_LENGTH], char deviceId[MAX_DEVICE_ID_LENGTH]) = 0; - - /** - * Sets the volume of the app. - * - * @param volume The volume of the app. The value range is [0, 255]. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setApplicationVolume(int volume) = 0; - - /** - * Gets the volume of the app. - * - * @param volume The volume of the app. The value range is [0, 255] - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getApplicationVolume(int &volume) = 0; - - /** Mutes or unmutes the app. - * - * @param mute Determines whether to mute the app: - * - true: Mute the app. - * - false: Unmute the app. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setApplicationMute(bool mute) = 0; - - /** - * Gets the mute state of the app. - * - * @param mute A reference to the mute state of the app: - * - true: The app is muted. - * - false: The app is not muted. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int isApplicationMute(bool &mute) = 0; - - /** - * Releases all IAudioDeviceCollection resources. - */ - virtual void release() = 0; -}; - -/** - * The IAudioDeviceManager class. - */ -class IAudioDeviceManager : public RefCountInterface { -public: - virtual ~IAudioDeviceManager() {} - - /** - * Enumerates the audio playback devices. - * - * This method returns an IAudioDeviceCollection object that includes all the - * audio playback devices in the system. With the IAudioDeviceCollection - * object, the app can enumerate the audio playback devices. The app must call - * the \ref IAudioDeviceCollection::release "IAudioDeviceCollection::release" - * method to release the returned object after using it. - * - * @return - * - A pointer to the IAudioDeviceCollection object that includes all the - * audio playback devices in the system, if the method call succeeds. - * - The empty pointer NULL, if the method call fails. - */ - virtual IAudioDeviceCollection *enumeratePlaybackDevices() = 0; - - /** - * Enumerates the audio recording devices. - * - * This method returns an IAudioDeviceCollection object that includes all the - * audio recording devices in the system. With the IAudioDeviceCollection - * object, the app can enumerate the audio recording devices. The app needs to - * call the \ref IAudioDeviceCollection::release - * "IAudioDeviceCollection::release" method to release the returned object - * after using it. - * - * @return - * - A pointer to the IAudioDeviceCollection object that includes all the - * audio recording devices in the system, if the method call succeeds. - * - The empty pointer NULL, if the method call fails. - */ - virtual IAudioDeviceCollection *enumerateRecordingDevices() = 0; - - /** - * Specifies an audio playback device with the device ID. - * - * @param deviceId ID of the audio playback device. It can be retrieved by the - * \ref enumeratePlaybackDevices "enumeratePlaybackDevices" method. Plugging - * or unplugging the audio device does not change the device ID. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setPlaybackDevice(const char deviceId[MAX_DEVICE_ID_LENGTH]) = 0; - - /** - * Gets the ID of the audio playback device. - * @param deviceId An output parameter that specifies the ID of the audio - * playback device. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getPlaybackDevice(char deviceId[MAX_DEVICE_ID_LENGTH]) = 0; - - /** - * Gets the device ID and device name of the audio playback device. - * @param deviceId An output parameter that specifies the ID of the audio - * playback device. - * @param deviceName An output parameter that specifies the name of the audio - * playback device. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getPlaybackDeviceInfo(char deviceId[MAX_DEVICE_ID_LENGTH], - char deviceName[MAX_DEVICE_ID_LENGTH]) = 0; - - /** - * Gets the device ID and device name and device type name of the audio playback device. - * @param deviceId An output parameter that specifies the ID of the audio playback device. - * @param deviceName An output parameter that specifies the name of the audio playback device. - * @param deviceTypeName An output parameter that specifies the device type name. such as Built-in, USB, HDMI, etc. (MacOS only) - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getPlaybackDeviceInfo(char deviceId[MAX_DEVICE_ID_LENGTH], char deviceName[MAX_DEVICE_ID_LENGTH], char deviceTypeName[MAX_DEVICE_ID_LENGTH]) = 0; - - /** - * Sets the volume of the audio playback device. - * @param volume The volume of the audio playing device. The value range is - * [0, 255]. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setPlaybackDeviceVolume(int volume) = 0; - - /** - * Gets the volume of the audio playback device. - * @param volume The volume of the audio playback device. The value range is - * [0, 255]. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getPlaybackDeviceVolume(int *volume) = 0; - - /** - * Specifies an audio recording device with the device ID. - * - * @param deviceId ID of the audio recording device. It can be retrieved by - * the \ref enumerateRecordingDevices "enumerateRecordingDevices" method. - * Plugging or unplugging the audio device does not change the device ID. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setRecordingDevice(const char deviceId[MAX_DEVICE_ID_LENGTH]) = 0; - - /** - * Gets the audio recording device by the device ID. - * - * @param deviceId ID of the audio recording device. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getRecordingDevice(char deviceId[MAX_DEVICE_ID_LENGTH]) = 0; - - /** - * Gets the information of the audio recording device by the device ID and - * device name. - * - * @param deviceId ID of the audio recording device. - * @param deviceName The name of the audio recording device. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getRecordingDeviceInfo(char deviceId[MAX_DEVICE_ID_LENGTH], - char deviceName[MAX_DEVICE_ID_LENGTH]) = 0; - - /** - * Gets the device ID and device name and device type name of the audio recording device. - * - * @param deviceId An output parameter that indicates the device id. - * @param deviceName An output parameter that indicates the device name. - * @param deviceTypeName An output parameter that indicates the device type name. such as Built-in, USB, HDMI, etc. (MacOS only) - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getRecordingDeviceInfo(char deviceId[MAX_DEVICE_ID_LENGTH], char deviceName[MAX_DEVICE_ID_LENGTH], char deviceTypeName[MAX_DEVICE_ID_LENGTH]) = 0; - - /** - * Sets the volume of the recording device. - * @param volume The volume of the recording device. The value range is [0, - * 255]. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setRecordingDeviceVolume(int volume) = 0; - - /** - * Gets the volume of the recording device. - * @param volume The volume of the microphone, ranging from 0 to 255. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getRecordingDeviceVolume(int *volume) = 0; - - /** - * Specifies an audio loopback recording device with the device ID. - * - * @param deviceId ID of the audio loopback recording device. It can be retrieved by - * the \ref enumeratePlaybackDevices "enumeratePlaybackDevices" method. - * Plugging or unplugging the audio device does not change the device ID. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setLoopbackDevice(const char deviceId[MAX_DEVICE_ID_LENGTH]) = 0; - - /** - * Gets the audio loopback recording device by the device ID. - * - * @param deviceId ID of the audio loopback recording device. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getLoopbackDevice(char deviceId[MAX_DEVICE_ID_LENGTH]) = 0; - - /** - * Mutes or unmutes the audio playback device. - * - * @param mute Determines whether to mute the audio playback device. - * - true: Mute the device. - * - false: Unmute the device. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setPlaybackDeviceMute(bool mute) = 0; - - /** - * Gets the mute state of the playback device. - * - * @param mute A pointer to the mute state of the playback device. - * - true: The playback device is muted. - * - false: The playback device is unmuted. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getPlaybackDeviceMute(bool *mute) = 0; - - /** - * Mutes or unmutes the audio recording device. - * - * @param mute Determines whether to mute the recording device. - * - true: Mute the microphone. - * - false: Unmute the microphone. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setRecordingDeviceMute(bool mute) = 0; - - /** - * Gets the mute state of the audio recording device. - * - * @param mute A pointer to the mute state of the recording device. - * - true: The microphone is muted. - * - false: The microphone is unmuted. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getRecordingDeviceMute(bool *mute) = 0; - - /** - * Starts the audio playback device test. - * - * This method tests if the playback device works properly. In the test, the - * SDK plays an audio file specified by the user. If the user hears the audio, - * the playback device works properly. - * - * @param testAudioFilePath The file path of the audio file for the test, - * which is an absolute path in UTF8: - * - Supported file format: wav, mp3, m4a, and aac. - * - Supported file sampling rate: 8000, 16000, 32000, 44100, and 48000. - * - * @return - * - 0, if the method call succeeds and you can hear the sound of the - * specified audio file. - * - An error code, if the method call fails. - */ - virtual int startPlaybackDeviceTest(const char *testAudioFilePath) = 0; - - /** - * Stops the audio playback device test. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int stopPlaybackDeviceTest() = 0; - - /** - * Starts the recording device test. - * - * This method tests whether the recording device works properly. Once the - * test starts, the SDK uses the \ref - * IRtcEngineEventHandler::onAudioVolumeIndication "onAudioVolumeIndication" - * callback to notify the app on the volume information. - * - * @param indicationInterval The time interval (ms) between which the SDK - * triggers the `onAudioVolumeIndication` callback. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int startRecordingDeviceTest(int indicationInterval) = 0; - - /** - * Stops the recording device test. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int stopRecordingDeviceTest() = 0; - - /** - * Starts the audio device loopback test. - * - * This method tests whether the local audio devices are working properly. - * After calling this method, the microphone captures the local audio and - * plays it through the speaker, and the \ref - * IRtcEngineEventHandler::onAudioVolumeIndication "onAudioVolumeIndication" - * callback returns the local audio volume information at the set interval. - * - * @note This method tests the local audio devices and does not report the - * network conditions. - * @param indicationInterval The time interval (ms) at which the \ref - * IRtcEngineEventHandler::onAudioVolumeIndication "onAudioVolumeIndication" - * callback returns. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int startAudioDeviceLoopbackTest(int indicationInterval) = 0; - - /** - * Stops the audio device loopback test. - * - * @note Ensure that you call this method to stop the loopback test after - * calling the \ref IAudioDeviceManager::startAudioDeviceLoopbackTest - * "startAudioDeviceLoopbackTest" method. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int stopAudioDeviceLoopbackTest() = 0; - - /** The status of following system default playback device. - - @note The status of following system default playback device. - - @param enable Variable to whether the current device follow system default playback device or not. - - true: The current device will change when the system default playback device changed. - - false: The current device will change only current device is removed. - @return - - 0: Success. - - < 0: Failure. - */ - virtual int followSystemPlaybackDevice(bool enable) = 0; - - /** The status of following system default recording device. - - @note The status of following system default recording device. - - @param enable Variable to whether the current device follow system default recording device or not. - - true: The current device will change when the system default recording device changed. - - false: The current device will change only current device is removed. - @return - - 0: Success. - - < 0: Failure. - */ - virtual int followSystemRecordingDevice(bool enable) = 0; - - /** The status of following system default loopback device. - - @note The status of following system default loopback device. - - @param enable Variable to whether the current device follow system default loopback device or not. - - true: The current device will change when the system default loopback device changed. - - false: The current device will change only current device is removed. - @return - - 0: Success. - - < 0: Failure. - */ - virtual int followSystemLoopbackDevice(bool enable) = 0; - - /** - * Releases all IAudioDeviceManager resources. - */ - virtual void release() = 0; -}; - -} // namespace rtc -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioDeviceManager.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioDeviceManager.h deleted file mode 100644 index 0c41470ef..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioDeviceManager.h +++ /dev/null @@ -1,570 +0,0 @@ -// -// Agora SDK -// -// Copyright (c) 2018 Agora.io. All rights reserved. -// - -#pragma once // NOLINT(build/header_guard) - -#include - -#include "AgoraBase.h" -#include "AgoraRefPtr.h" -#include -namespace agora { -namespace media { -namespace base { -class IAudioFrameObserver; -} // namespace base -} // namespace media - -namespace rtc { - -static const int kAdmMaxDeviceNameSize = 128; -static const int kAdmMaxGuidSize = 128; -static const int kIntervalInMillseconds = 200; - - -#if defined(_WIN32) || (defined(__APPLE__) && TARGET_OS_MAC && !TARGET_OS_IPHONE) -/** - * The struct of AudioDeviceInfo. - * - * @note - * This struct applies to Windows and macOS only. - */ -struct AudioDeviceInfo { - /** - * The name of the device. The maximum name size is 128 bytes. The default value is 0. - */ - char deviceName[kAdmMaxDeviceNameSize]; - /** - * The type name of the device. such as Built-in, USB, HDMI, etc. The maximum size is 128 bytes. The default value is 0. - * @note This member applies to macOS only. - */ - char deviceTypeName[kAdmMaxDeviceNameSize]; - /** - * The ID of the device. The maximum size is 128 bytes. The default value is 0. - */ - char deviceId[kAdmMaxGuidSize]; - /** - * Determines whether the current device is selected for audio capturing or playback. - * - true: Select the current device for audio capturing or playback. - * - false: (Default) Do not select the current device for audio capturing or playback. - */ - bool isCurrentSelected; - /** - * Determines whether the current device is the audio playout device. - * - true: (Default) The current device is the playout device. - * - false: The current device is not the playout device. - */ - bool isPlayoutDevice; - - AudioDeviceInfo() : isCurrentSelected(false), - isPlayoutDevice(true) { - memset(deviceName, 0, sizeof(deviceName)); - memset(deviceTypeName, 0, sizeof(deviceTypeName)); - memset(deviceId, 0, sizeof(deviceId)); - } -}; -#endif // _WIN32 || (TARGET_OS_MAC && !TARGET_OS_IPHONE) - -/** - * The struct of LoopbackRecordingOption - * - * @note - */ -struct LoopbackRecordingOption { - /** - * the name of the device. the maximum name size is 128 bytes. the default value is 0. - */ - Optional deviceName; - /** - * allow output device change when enable loopback recording. - */ - Optional allowDeviceChange; -}; - -/** - * The IAudioDeviceManagerObserver class. - */ -class IAudioDeviceManagerObserver -{ -public: - virtual ~IAudioDeviceManagerObserver() {} - - /** - * Occurs when the device state changes, for example, when a device is added or removed. - * - * To get the current information of the connected audio devices, call \ref agora::rtc::INGAudioDeviceManager::getNumberOfPlayoutDevices "getNumberOfPlayoutDevices". - */ - virtual void onDeviceStateChanged() = 0; - - /** - * Occurs when the device state changes, for example, when a device is added or removed or default device change. - * - * @note - * This method applies to Windows only now. - * - * @param deviceId Pointer to the device ID. - * @param deviceType Device type: #MEDIA_DEVICE_TYPE. - * @param deviceState Device state: #MEDIA_DEVICE_STATE_TYPE.. - */ - virtual void onAudioDeviceStateChanged(const char *deviceId, int deviceType, int deviceState) = 0; - - /** Indicates incoming volume. This can be used to test microphone or speaker. - * - * @param deviceType Device type: #MEDIA_DEVICE_TYPE. - * @param volume volume between 0 (lowest volume) to 255 (highest volume). - */ - virtual void onVolumeIndication(int deviceType, int volume) = 0; - - /** - * Occurs when the audio route changes. - * - * @param route The current audio route. See #AudioRoute. - */ - virtual void onRoutingChanged(AudioRoute route) = 0; - - /** - * Occurs when the audio device volume changes. - * - * @param deviceType The device type, see #MEDIA_DEVICE_TYPE. - * @param volume The volume of the audio device. - * @param muted Whether the audio device is muted: - * - true: The audio device is muted. - * - false: The audio device is not muted. - */ - virtual void onAudioDeviceVolumeChanged(int deviceType, int volume, bool muted) = 0; -}; - -class IRecordingDeviceSource : public RefCountInterface { - public: - /** - * Initialize the recording device source. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int initRecording(const char* deviceName = NULL) = 0; - - /** - * Start the recording device. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int startRecording(aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Stop the recording device. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int stopRecording(aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Registers an audio frame observer. - * - * @param observer The pointer to the IAudioFrameObserver object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerAudioFrameObserver(media::IAudioPcmFrameSink* observer, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Releases the registered IAudioFrameObserver object. - * - * @param observer The pointer to the IAudioFrameObserver object created by the `registerAudioPcmDataCallback` method. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unregisterAudioFrameObserver(media::IAudioPcmFrameSink* observer) = 0; - - /** - * Set parameter to object loopback device; - * @param option - * - 0: Success. - * - < 0: Failure. - */ - virtual int setLoopbackDeviceParameter(const LoopbackRecordingOption &option, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - virtual ~IRecordingDeviceSource() {} -}; - -/** - * The INGAudioDeciceManager class. - * - * This class provides access to audio volume and audio route control, as well as device enumeration and - * selection on the PC. - */ -class INGAudioDeviceManager : public RefCountInterface { -public: - /** - * Creates a audio device source object and returns the pointer. - * - * @return - * - The pointer to \ref rtc::IRecordingDeviceSource "IRecordingDeviceSource", if the method call - * succeeds. - * - An empty pointer NULL: Failure. - */ - virtual agora_refptr createRecordingDeviceSource(char deviceId[kAdmMaxDeviceNameSize]) = 0; - - /** - * Sets the volume of the microphone. - * @param volume The volume of the microphone. The value range is [0, 255]. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setMicrophoneVolume(unsigned int volume, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Gets the volume of the microphone. - * @param volume The volume of the microphone. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getMicrophoneVolume(unsigned int& volume) = 0; - /** - * Sets the volume of the speaker. - * @param volume The volume of the speaker. The value range is [2, 255]. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setSpeakerVolume(unsigned int volume, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Gets the volume of the speaker. - * @param volume The volume of the speaker. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getSpeakerVolume(unsigned int& volume) = 0; - /** - * Captures or stops capturing the local audio with the microphone. - * @param mute Determines whether to capture or stop capturing the local audio with the microphone. - * - true: Stop capturing the local audio. - * - false: (Default) Capture the local audio. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setMicrophoneMute(bool mute, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Gets the mute state of the microphone. - * @param mute The mute state of the microphone. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getMicrophoneMute(bool& mute) = 0; - /** - * Plays or stops playing the remote audio with the speaker. - * @param mute Determines whether to play or stop playing the remote audio. - * - true: Stop playing the remote audio. - * - false: (Default) Play the remote audio. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setSpeakerMute(bool mute, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Gets the mute state of the speaker. - * @param mute A reference to the mute state of the speaker. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getSpeakerMute(bool& mute) = 0; - - /** - * Get the playout parameters of audio device. - * @param params A point to the struct AudioParameters. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getPlayoutAudioParameters(AudioParameters* params) const = 0; - - /** - * Get the record parameters of audio device. - * @param params A point to the struct AudioParameters. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getRecordAudioParameters(AudioParameters* params) const = 0; - -#if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || defined (__OHOS__) - /** - * Sets the default audio routing. - * - * This method allows apps to change the current audio route for the received audio. - * Noted: In Low Level API, we don't support default audio routing, i.e., - * setDefaultAudioRouteToSpeakerphone. This can be done in RTC engine. - * - * @note - * This method applies to Android and iOS only. - * - * @param route The default audio route. See #AudioRoute. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setDefaultAudioRouting(AudioRoute route, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Changes the current audio routing. - * - * @note - * This method applies to Android and iOS only. - * - * @param route The audio route that you want to change to. See #AudioRoute. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int changeAudioRouting(AudioRoute route, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Changes the speaker status on/off. - * - * @note - * This method applies to Android and iOS only. - * - * @param enable on/off - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setAudioRoutingSpeakerOn(bool enable, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Gets the current audio routing. - * - * @note - * This method applies to Android and iOS only. - * - * @param route A reference to the audio route: AudioRoute. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getCurrentRouting(AudioRoute& route) = 0; -#endif // __ANDROID__ || TARGET_OS_IPHONE || __OHOS__ - -#if defined(_WIN32) || (defined(__APPLE__) && TARGET_OS_MAC && !TARGET_OS_IPHONE) - /** - * Gets the index numbers of all audio playout devices. - * - * @note - * This method applies to Windows or macOS only. - * - * @return - * - The index numbers of the audio playout devices: Success. - * - < 0: Failure. - */ - virtual int getNumberOfPlayoutDevices() = 0; - - /** - * Gets the index numbers of all audio recording devices. - * - * @note - * This method applies to Windows or macOS only. - * - * @return - * - The index numbers of the audio recording devices: Success. - * - < 0: Failure. - */ - virtual int getNumberOfRecordingDevices() = 0; - /** - * Gets the information of the current audio playout device. - * - * @note - * This method applies to Windows or macOS only. - * - * @param index The index number of the current audio playout device. - * @return - * The information of the audio playout device. See \ref agora::rtc::AudioDeviceInfo "AudioDeviceInfo". - */ - virtual AudioDeviceInfo getPlayoutDeviceInfo(int index) = 0; - /** - * Gets the information of the current recording device. - * - * @note - * This method applies to Windows or macOS only. - * - * @param index The index number of the current recording device. - * @return - * The information of the recording device. See \ref agora::rtc::AudioDeviceInfo "AudioDeviceInfo". - */ - virtual AudioDeviceInfo getRecordingDeviceInfo(int index) = 0; - /** - * Sets the audio playback device. - * - * @note - * This method applies to Windows or macOS only. - * - * @param index The index number of the audio playout device. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setPlayoutDevice(int index, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Sets the recording device. - * - * @note - * This method applies to Windows or macOS only. - * - * @param index The index number of the recording device. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setRecordingDevice(int index, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** The status of following system default playback device. - - @note The status of following system default playback device. - - @param enable Variable to whether the current device follow system default playback device or not. - - true: The current device will change when the system default playback device changed. - - false: The current device will change only current device is removed. - @return - - 0: Success. - - < 0: Failure. - */ - virtual int followSystemPlaybackDevice(bool enable, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** The status of following system default recording device. - - @note The status of following system default recording device. - - @param enable Variable to whether the current device follow system default recording device or not. - - true: The current device will change when the system default recording device changed. - - false: The current device will change only current device is removed. - @return - - 0: Success. - - < 0: Failure. - */ - virtual int followSystemRecordingDevice(bool enable, aosl_ref_t ares = AOSL_REF_INVALID) = 0; -#endif // _WIN32 || (TARGET_OS_MAC && !TARGET_OS_IPHONE) - -#if defined(_WIN32) - /** - * Sets the volume of the app. - * - * @note - * This method applies to Windows only. - * - * @param volume The volume of the app. The value range is [0, 255]. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setApplicationVolume(unsigned int volume, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Gets the volume of the app. - * - * @note - * This method applies to Windows only. - * - * @param volume The volume of the app. The value range is [0, 255]. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getApplicationVolume(unsigned int& volume) = 0; - /** - * Sets the mute state of the app. - * - * @note - * This method applies to Windows only. - * - * @param mute Determines whether to set the app to the mute state. - * - true: Set the app to the mute state. - * - false: (Default) Do not set the app to the mute state. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setApplicationMuteState(bool mute, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Gets the mute state of the app. - * - * @note - * This method applies to Windows only. - * - * @param mute A reference to the mute state of the app. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getApplicationMuteState(bool& mute) = 0; - /** - * Gets the information of the current audio loopback device. - * - * @note - * This method applies to Windows or macOS only. - * - * @param index The index number of the current audio playout device. - * @return - * The information of the audio playout device. See \ref agora::rtc::AudioDeviceInfo "AudioDeviceInfo". - */ - virtual AudioDeviceInfo getLoopbackDeviceInfo(int index) = 0; - /** - * Sets the audio loopback device. - * - * @note - * This method applies to Windows only. - * - * @param index The index number of the audio playout device. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setLoopbackDevice(int index, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** The status of following system default loopback device. - - @note The status of following system default loopback device. - - @param enable Variable to whether the current device follow system default loopback device or not. - - true: The current device will change when the system default loopback device changed. - - false: The current device will change only current device is removed. - @return - - 0: Success. - - < 0: Failure. - */ - virtual int followSystemLoopbackDevice(bool enable, aosl_ref_t ares = AOSL_REF_INVALID) = 0; -#endif // _WIN32 - - /** - * Registers an IAudioDeviceManagerObserver object. - * - * You need to implement the IAudioDeviceManageObserver class in this method, and register callbacks - * according to your scenario. - * - * @param observer A pointer to the IAudioDeviceManagerObserver class. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerObserver(IAudioDeviceManagerObserver* observer, void(*safeDeleter)(IAudioDeviceManagerObserver*) = NULL, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Releases the IAudioDeviceManagerObserver object. - * @param observer The pointer to the IAudioDeviceManagerObserver class registered using #registerObserver. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unregisterObserver(IAudioDeviceManagerObserver* observer) = 0; - - virtual int setupAudioAttributeContext(void* audioAttr, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - -protected: - ~INGAudioDeviceManager() {} -}; - -} //namespace rtc -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioMixerSource.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioMixerSource.h deleted file mode 100644 index c6be20e7f..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioMixerSource.h +++ /dev/null @@ -1,46 +0,0 @@ -// -// Agora SDK -// Created by wangqin in 2023-05. -// Copyright (c) 2018 Agora.io. All rights reserved. -// - -#pragma once // NOLINT(build/header_guard) - -#include "AgoraBase.h" -#include "AgoraRefPtr.h" -#include "IAgoraService.h" -#include - -namespace agora { -namespace rtc { - -class IAudioTrack; -/** - * The IAudioMixerSource class abstracts a multi-in-multi-out audio source which receives audio - * streams from multiple local or remote audio tracks and generate mixed audio stream in user defined output - * format. When only one audio track is added to the mixer, it simply forwards the incoming audio frames - * to its sinks. - */ -class IAudioMixerSource : public RefCountInterface { -public: - /** - * Add audio track for mixing. - * @param id The unique id of the stream. - * @param track The instance of the audio track that you want mixer to receive its audio stream. - * @return - * 0 - Success - * <0 - Failure - */ - virtual int addAudioTrack(agora_refptr track, bool is_remote, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Remove the audio track. - * @param track The instance of the audio track that you want to remove from the mixer. - * @return - * 0 - Success - * <0 - Failure - */ - virtual int removeAudioTrack(agora_refptr track, bool is_remote, aosl_ref_t ares = AOSL_REF_INVALID) = 0; -}; - -} -} \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioTrack.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioTrack.h deleted file mode 100644 index e877e370e..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraAudioTrack.h +++ /dev/null @@ -1,830 +0,0 @@ - -// Copyright (c) 2018 Agora.io. All rights reserved - -// This program is confidential and proprietary to Agora.io. -// And may not be copied, reproduced, modified, disclosed to others, published -// or used, in whole or in part, without the express prior written permission -// of Agora.io. - -#pragma once // NOLINT(build/header_guard) - -#include "AgoraBase.h" -#include - -// FIXME(Ender): use this class instead of AudioSendStream as local track -namespace agora { -namespace rtc { -class IAudioTrackStateObserver; -class IAudioFilter; -class IAudioSinkBase; -class IMediaPacketReceiver; -class IAudioEncodedFrameReceiver; -/** - * Properties of audio frames expected by a sink. - * - * @note The source determines the audio frame to be sent to the sink based on a variety of factors, - * such as other sinks or the capability of the source. - * - */ -struct AudioSinkWants { - /** The sample rate of the audio frame to be sent to the sink. */ - int samplesPerSec; - - /** The number of audio channels of the audio frame to be sent to the sink. */ - size_t channels; - - AudioSinkWants() : samplesPerSec(0), - channels(0) {} - AudioSinkWants(int sampleRate, size_t chs) : samplesPerSec(sampleRate), - channels(chs) {} - AudioSinkWants(int sampleRate, size_t chs, int trackNum) : samplesPerSec(sampleRate), channels(chs) {} -}; - -/** - * The IAudioTrack class. - */ -class IAudioTrack : public RefCountInterface { - public: - /** - * The position of the audio filter in audio frame. - */ - enum AudioFilterPosition { - /** - * Work on the local playback - */ - RecordingLocalPlayback, - /** - * Work on the post audio processing. - */ - PostAudioProcessing, - /** - * Work on the remote audio before mixing. - */ - RemoteUserPlayback, - /** - * Work on the pcm source. - */ - PcmSource, - /** - * Work on the sending branch of the pcm source. - */ - PcmSourceSending, - /** - * Work on the local playback branch of the pcm source. - */ - PcmSourceLocalPlayback, - /** - * Work on the playback after remote-audio mix. - */ - RemoteMixedPlayback, - }; - - public: - /** - * Adjusts the playback volume. - * @param volume The playback volume. The value ranges between 0 and 100 (default). - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int adjustPlayoutVolume(int volume, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Gets the current playback volume. - * @param volume A pointer to the playback volume. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getPlayoutVolume(int* volume) = 0; - - /** - * Adds an audio filter. - * - * By adding an audio filter, you can apply various audio effects to the audio, for example, voice change. - * @param filter A pointer to the audio filter. See \ref agora::rtc::IAudioFilter "IAudioFilter". - * @param position The position of the audio filter. See \ref agora::rtc::IAudioTrack::AudioFilterPosition "AudioFilterPosition". - * @param extContext The context of current filter. See \ref agora::rtc::ExtensionContext "ExtensionContext". - * @return - * - `true`: Success. - * - `false`: Failure. - */ - virtual bool addAudioFilter(agora_refptr filter, AudioFilterPosition position, ExtensionContext *extContext = NULL, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Removes the audio filter added by callling `addAudioFilter`. - * - * @param filter The pointer to the audio filter that you want to remove. See \ref agora::rtc::IAudioFilter "IAudioFilter". - * @param position The position of the audio filter. See #AudioFilterPosition. - * @return - * - `true`: Success. - * - `false`: Failure. - */ - virtual bool removeAudioFilter(agora_refptr filter, AudioFilterPosition position, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Enable / Disable specified audio filter - * @param id id of the filter - * @param enable enable / disable the filter with given id - * @param position The position of the audio filter. See #AudioFilterPosition. - * @return - * - 0: success - * - <0: failure - */ - virtual int enableAudioFilter(const char* id, bool enable, AudioFilterPosition position, aosl_ref_t ares = AOSL_REF_INVALID) { - (void)id; - (void)enable; - (void)position; - return -1; - } - - /** - * set the properties of the specified audio filter - * @param id id of the filter - * @param key key of the property - * @param jsonValue json str value of the property - * @param position The position of the audio filter. See #AudioFilterPosition. - * @return - * - 0: success - * - <0: failure - */ - virtual int setFilterProperty(const char* id, const char* key, const char* jsonValue, AudioFilterPosition position, aosl_ref_t ares = AOSL_REF_INVALID) { - (void)id; - (void)key; - (void)jsonValue; - (void)position; - return -1; - } - - /** - * get the properties of the specified video filter - * @param id id of the filter - * @param key key of the property - * @param jsonValue json str value of the property - * @param bufSize max length of the json value buffer - * @param position The position of the audio filter. See #AudioFilterPosition. - * @return - * - 0: success - * - <0: failure - */ - virtual int getFilterProperty(const char* id, const char* key, char* jsonValue, size_t bufSize, AudioFilterPosition position) { - (void)id; - (void)key; - (void)jsonValue; - (void)bufSize; - (void)position; - return -1; - } - - /** - * Gets the audio filter by its name. - * - * @param name The name of the audio filter. - * @param position The position of the audio filter. See #AudioFilterPosition. - * @return - * - The pointer to the audio filter: Success. - * - A null pointer: Failure. - */ - virtual agora_refptr getAudioFilter(const char *name, AudioFilterPosition position) const = 0; - - /** - * Adds an audio sink to get PCM data from the audio track. - * - * @param sink The pointer to the audio sink. See \ref agora::rtc::IAudioSinkBase "IAudioSinkBase". - * @param wants The properties an audio frame should have when it is delivered to the sink. See \ref agora::rtc::AudioSinkWants "AudioSinkWants". - * @return - * - `true`: Success. - * - `false`: Failure. - */ - virtual bool addAudioSink(agora_refptr sink, const AudioSinkWants& wants, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Removes an audio sink. - * - * @param sink The pointer to the audio sink to be removed. See \ref agora::rtc::IAudioSinkBase "IAudioSinkBase". - * @return - * - `true`: Success. - * - `false`: Failure. - */ - virtual bool removeAudioSink(agora_refptr sink, aosl_ref_t ares = AOSL_REF_INVALID) = 0; -}; - -/** - * The observer of the local audio track. - */ -class ILocalAudioTrackObserver { - public: - virtual ~ILocalAudioTrackObserver() {} - - /** - * Occurs when the state of a local audio track changes. - * - * @param state The state of the local audio track. - * @param reasonCode The error information for a state failure: \ref agora::rtc::LOCAL_AUDIO_STREAM_REASON "LOCAL_AUDIO_STREAM_REASON". - */ - virtual void onLocalAudioTrackStateChanged(LOCAL_AUDIO_STREAM_STATE state, - LOCAL_AUDIO_STREAM_REASON reasonCode) = 0; -}; - -/** - * `ILocalAudioTrack` is the basic class for local audio tracks, providing main methods of local audio tracks. - * - * You can create a local audio track by calling one of the following methods: - * - `createLocalAudioTrack` - * - `createCustomAudioTrack` - * - `createMediaPlayerAudioTrack` - * @if (!Linux) - * You can also use the APIs in the \ref agora::rtc::INGAudioDeviceManager "IAudioDeviceManager" class if multiple recording devices are available in the system. - * @endif - * - * After creating local audio tracks, you can publish one or more local audio - * tracks by calling \ref agora::rtc::ILocalUser::publishAudio "publishAudio". - */ -class ILocalAudioTrack : public IAudioTrack { - public: - /** - * Statistics of a local audio track. - */ - struct LocalAudioTrackStats { - /** - * The source ID of the local audio track. - */ - uint32_t source_id; - /** - * The number of audio frames in the buffer. - * - * When sending PCM data, the PCM data is first stored in a buffer area. - * Then a thread gets audio frames from the buffer and sends PCM data. - */ - uint32_t buffered_pcm_data_list_size; - /** - * The number of audio frames missed by the thread that gets PCM data from the buffer. - */ - uint32_t missed_audio_frames; - /** - * The number of audio frames sent by the thread that gets PCM data from the buffer. - */ - uint32_t sent_audio_frames; - /** - * The number of audio frames sent by the user. - */ - uint32_t pushed_audio_frames; - /** - * The number of dropped audio frames caused by insufficient buffer size. - */ - uint32_t dropped_audio_frames; - /** - * The number of playout audio frames. - */ - uint32_t playout_audio_frames; - /** - * The type of audio effect. - */ - uint32_t effect_type; - /** - * Whether the hardware ear monitor is enabled. - */ - uint32_t hw_ear_monitor; - /** - * Whether the local audio track is enabled. - */ - bool enabled; - /** - * The volume that ranges from 0 to 255. - */ - uint32_t audio_volume; // [0,255] - - LocalAudioTrackStats() : source_id(0), - buffered_pcm_data_list_size(0), - missed_audio_frames(0), - sent_audio_frames(0), - pushed_audio_frames(0), - dropped_audio_frames(0), - playout_audio_frames(0), - effect_type(0), - hw_ear_monitor(0), - enabled(false), - audio_volume(0) {} - }; - - public: - /** - * Enables or disables the local audio track. - * - * Once the local audio is enabled, the SDK allows for local audio capturing, processing, and encoding. - * - * @param enable Whether to enable the audio track: - * - `true`: Enable the local audio track. - * - `false`: Disable the local audio track. - */ - virtual int setEnabled(bool enable, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Gets whether the local audio track is enabled. - * @return Whether the local audio track is enabled: - * - `true`: The local track is enabled. - * - `false`: The local track is disabled. - */ - virtual bool isEnabled() const = 0; - - /** - * Gets the state of the local audio. - * @return The state of the local audio: #LOCAL_AUDIO_STREAM_STATE: Success. - */ - virtual LOCAL_AUDIO_STREAM_STATE getState() = 0; - - /** - * Gets the statistics of the local audio track: LocalAudioTrackStats. - * @return The statistics of the local audio: LocalAudioTrackStats: Success. - */ - virtual LocalAudioTrackStats GetStats() = 0; - - /** - * Adjusts the audio volume for publishing. - * - * @param volume The volume for publishing. The value ranges between 0 and 100 (default). - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int adjustPublishVolume(int volume, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Gets the current volume for publishing. - * @param volume A pointer to the publishing volume. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getPublishVolume(int* volume) = 0; - - /** - * Enables or disables local playback. - * @param enable Whether to enable local playback: - * - `true`: Enable local playback. - * - `false`: Disable local playback. - * @param sync Whether to destroy local playback synchronously: - * - `true`: Destroy local playback synchronously. - * - `false`: Destroy local playback asynchronously. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableLocalPlayback(bool enable, bool sync = true, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Enables in-ear monitoring (for Android and iOS only). - * - * @param enabled Determines whether to enable in-ear monitoring. - * - true: Enable. - * - false: (Default) Disable. - * @param includeAudioFilters The type of the ear monitoring: #EAR_MONITORING_FILTER_TYPE - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableEarMonitor(bool enable, int includeAudioFilters, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** Register an local audio track observer - * - * @param observer A pointer to the local audio track observer: \ref agora::rtc::ILocalAudioTrackObserver - * "ILocalAudioTrackObserver". - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerTrackObserver(ILocalAudioTrackObserver* observer, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** Releases the local audio track observer - * - * @param observer A pointer to the local audio track observer: \ref agora::rtc::ILocalAudioTrackObserver - * "ILocalAudioTrackObserver". - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unregisterTrackObserver(ILocalAudioTrackObserver* observer) = 0; - - /** set Max buffered audio frame number - * - * @param number : the buffer number set,unit is 10ms - * - */ - virtual void setMaxBufferedAudioFrameNumber(int number) = 0; - - /** clear sender buffer - * - * @return - * - >= 0: Frame number in sender buffer. - * - < 0: Failure. - */ - virtual int ClearSenderBuffer() = 0; - - protected: - ~ILocalAudioTrack() {} -}; - -/** - * The statistics of a remote audio track. - */ -struct RemoteAudioTrackStats { - /** - * The user ID of the remote user who sends the audio track. - */ - uid_t uid; - /** - * The audio quality of the remote audio track: #QUALITY_TYPE. - */ - int quality; - /** - * The network delay (ms) from the sender to the receiver. - */ - int network_transport_delay; - /** - * The delay (ms) from the receiver to the jitter buffer. - */ - uint32_t jitter_buffer_delay; - /** - * The audio frame loss rate in the reported interval. - */ - int audio_loss_rate; - /** - * The number of audio channels. - */ - int num_channels; - /** - * The sample rate (Hz) of the received audio track in the reported interval. - */ - int received_sample_rate; - /** - * The average bitrate (Kbps) of the received audio track in the reported interval. - * */ - int received_bitrate; - /** - * The total freeze time (ms) of the remote audio track after the remote user joins the channel. - * In a session, audio freeze occurs when the audio frame loss rate reaches 4%. - * The total audio freeze time = The audio freeze number × 2 seconds. - */ - int total_frozen_time; - /** - * The total audio freeze time as a percentage (%) of the total time when the audio is available. - * */ - int frozen_rate; - /** - * The number of audio bytes received. - */ - int64_t received_bytes; - /** - * The average packet waiting time (ms) in the jitter buffer. - */ - int mean_waiting_time; - /** - * The samples of expanded speech. - */ - size_t expanded_speech_samples; - /** - * The samples of expanded noise. - */ - size_t expanded_noise_samples; - /** - * The timestamps since last report. - */ - uint32_t timestamps_since_last_report; - /** - * The minimum sequence number. - */ - uint16_t min_sequence_number; - /** - * The maximum sequence number. - */ - uint16_t max_sequence_number; - /** - * The audio energy. - */ - int32_t audio_level; - /** - * audio downlink average process time - */ - uint32_t downlink_process_time_ms; - /** - * audio neteq loss because of expired - */ - uint32_t packet_expired_loss; - /** - * audio neteq packet arrival expired time ms - */ - uint32_t packet_max_expired_ms; - /** - * audio neteq jitter peak num in two second - */ - uint32_t burst_peak_num; - /** - * audio neteq jitter calc by burst opti feature - */ - uint32_t burst_jitter; - /** - * audio base target level - */ - uint32_t target_level_base_ms; - /** - * audio average target level - */ - uint32_t target_level_prefered_ms; - /** - * audio average accelerate ratio in 2s - */ - uint16_t accelerate_rate; - /** - * audio average preemptive expand ratio in 2s - */ - uint16_t preemptive_expand_rate; - /** - * The count of 80 ms frozen in 2 seconds - */ - uint16_t frozen_count_80_ms; - /** - * The time of 80 ms frozen in 2 seconds - */ - uint16_t frozen_time_80_ms; - /** - * The count of 200 ms frozen in 2 seconds - */ - uint16_t frozen_count_200_ms; - /** - * The time of 200 ms frozen in 2 seconds - */ - uint16_t frozen_time_200_ms; - /** - * The full time of 80 ms frozen in 2 seconds - */ - uint16_t full_frozen_time_80_ms; - /** - * The full time of 200 ms frozen in 2 seconds - */ - uint16_t full_frozen_time_200_ms; - /** - * The estimate delay - */ - uint32_t delay_estimate_ms; - /** - * The MOS value - */ - uint32_t mos_value; - /** - * If the packet loss concealment (PLC) occurs for N consecutive times, freeze is considered as PLC occurring for M consecutive times. - * freeze cnt = (n_plc - n) / m - */ - uint32_t frozen_rate_by_custom_plc_count; - /** - * The number of audio packet loss concealment - */ - uint32_t plc_count; - /** - * Duration of inbandfec - */ - int32_t fec_decode_ms; - /** - * The count of 10 ms frozen in 2 seconds - */ - uint16_t frozen_count_10_ms; - /** - * The total time (ms) when the remote user neither stops sending the audio - * stream nor disables the audio module after joining the channel. - */ - uint64_t total_active_time; - /** - * The total publish duration (ms) of the remote audio stream. - */ - uint64_t publish_duration; - - int32_t e2e_delay_ms; - /** - * Quality of experience (QoE) of the local user when receiving a remote audio stream. See #EXPERIENCE_QUALITY_TYPE. - */ - int qoe_quality; - /** - * The reason for poor QoE of the local user when receiving a remote audio stream. See #EXPERIENCE_POOR_REASON. - */ - int32_t quality_changed_reason; - - /** - * The type of downlink audio effect. - */ - int32_t downlink_effect_type; - - RemoteAudioTrackStats() : - uid(0), - quality(0), - network_transport_delay(0), - jitter_buffer_delay(0), - audio_loss_rate(0), - num_channels(0), - received_sample_rate(0), - received_bitrate(0), - total_frozen_time(0), - frozen_rate(0), - received_bytes(0), - mean_waiting_time(0), - expanded_speech_samples(0), - expanded_noise_samples(0), - timestamps_since_last_report(0), - min_sequence_number(0xFFFF), - max_sequence_number(0), - audio_level(0), - downlink_process_time_ms(0), - packet_expired_loss(0), - packet_max_expired_ms(0), - burst_peak_num(0), - burst_jitter(0), - target_level_base_ms(0), - target_level_prefered_ms(0), - accelerate_rate(0), - preemptive_expand_rate(0), - frozen_count_80_ms(0), - frozen_time_80_ms(0), - frozen_count_200_ms(0), - frozen_time_200_ms(0), - full_frozen_time_80_ms(0), - full_frozen_time_200_ms(0), - delay_estimate_ms(0), - mos_value(0), - frozen_rate_by_custom_plc_count(0), - plc_count(0), - fec_decode_ms(-1), - frozen_count_10_ms(0), - total_active_time(0), - publish_duration(0), - e2e_delay_ms(0), - qoe_quality(0), - quality_changed_reason(0), - downlink_effect_type(0) {} -}; - -/** - * The IRemoteAudioTrack class. - */ -class IRemoteAudioTrack : public IAudioTrack { - public: - /** - * Gets the statistics of the remote audio track. - * @param stats A reference to the statistics of the remote audio track: RemoteAudioTrackStats. - * @return - * - `true`: Success. - * - `false`: Failure. - */ - virtual bool getStatistics(RemoteAudioTrackStats& stats) = 0; - - /** - * Gets the state of the remote audio. - * @return The state of the remote audio: #REMOTE_AUDIO_STATE. - */ - virtual REMOTE_AUDIO_STATE getState() = 0; - - /** - * Registers an `IMediaPacketReceiver` object. - * - * You need to implement the `IMediaPacketReceiver` class in this method. Once you successfully register - * the media packet receiver, the SDK triggers the `onMediaPacketReceived` callback when it receives an - * audio packet. - * - * @param packetReceiver The pointer to the `IMediaPacketReceiver` object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerMediaPacketReceiver(IMediaPacketReceiver* packetReceiver, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Releases the `IMediaPacketReceiver` object. - * @param packetReceiver The pointer to the `IMediaPacketReceiver` object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unregisterMediaPacketReceiver(IMediaPacketReceiver* packetReceiver) = 0; - - /** - * Registers an `IAudioEncodedFrameReceiver` object. - * - * You need to implement the `IAudioEncodedFrameReceiver` class in this method. Once you successfully register - * the media packet receiver, the SDK triggers the `onEncodedAudioFrameReceived` callback when it receives an - * audio packet. - * - * @param packetReceiver The pointer to the `IAudioEncodedFrameReceiver` object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerAudioEncodedFrameReceiver(IAudioEncodedFrameReceiver* packetReceiver, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Releases the `IAudioEncodedFrameReceiver` object. - * @param packetReceiver The pointer to the `IAudioEncodedFrameReceiver` object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unregisterAudioEncodedFrameReceiver(IAudioEncodedFrameReceiver* packetReceiver) = 0; - - /** Sets the sound position and gain - - @param pan The sound position of the remote user. The value ranges from -1.0 to 1.0: - - 0.0: the remote sound comes from the front. - - -1.0: the remote sound comes from the left. - - 1.0: the remote sound comes from the right. - @param gain Gain of the remote user. The value ranges from 0.0 to 100.0. The default value is 100.0 (the original gain of the remote user). The smaller the value, the less the gain. - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int setRemoteVoicePosition(float pan, float gain, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** Sets the volume of each audio decoded channel - - @param decoded_index The channel index of the remote user. The value ranges from 0 to 100: - @param volume The channel index of the remote user. The value ranges from 0 to 100. - - 0: mute the channel. - - 100: keep the origin volume of the channel. - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int adjustDecodedAudioVolume(int decoded_index, int volume, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** mute remote stream from timestamp - - @note - - unmuteRemoteFromTimestamp should be called after muteRemoteFromTimestamp, othewise this stream will be muted all time - - @param timestamp The rtp timestamp of start mute - @return - - 0: Success. - - < 0: Failure. - */ - virtual int muteRemoteFromTimestamp(uint32_t timestamp) = 0; - - /** unmute remote stream from timestamp - - @note - - unmuteRemoteFromTimestamp should be called after muteRemoteFromTimestamp, othewise this stream will be muted all time - - @param timestamp The rtp timestamp of start unmute - @return - - 0: Success. - - < 0: Failure. - */ - virtual int unmuteRemoteFromTimestamp(uint32_t timestamp) = 0; - - /** set percentage of audio acceleration during poor network - - @note - - The relationship between this percentage and the degree of audio acceleration is non-linear and varies with different audio material. - - @param percentage The percentage of audio acceleration. The value ranges from 0 to 100. The higher the - * percentage, the faster the acceleration. The default value is 100 (no change to the acceleration): - - 0: disable audio acceleration. - - > 0: enable audio acceleration. - @return - - 0: Success. - - < 0: Failure. - */ - virtual int adjustAudioAcceleration(int percentage, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** set percentage of audio deceleration during poor network - - @note - - The relationship between this percentage and the degree of audio deceleration is non-linear and varies with different audio material. - - @param percentage The percentage of audio deceleration. The value ranges from 0 to 100. The higher the - * percentage, the faster the deceleration. The default value is 100 (no change to the deceleration): - - 0: disable audio deceleration. - - > 0: enable audio deceleration. - @return - - 0: Success. - - < 0: Failure. - */ - virtual int adjustAudioDeceleration(int percentage, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** enable spatial audio - - @param enabled enable/disable spatial audio: - - true: enable spatial audio. - - false: disable spatial audio. - @return - - 0: Success. - - < 0: Failure. - */ - virtual int enableSpatialAudio(bool enabled, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** Sets remote user parameters for spatial audio - - @param params spatial audio parameters - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int setRemoteUserSpatialAudioParams(const agora::SpatialAudioParams& params, aosl_ref_t ares = AOSL_REF_INVALID) = 0; -}; - -} // namespace rtc -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraCameraCapturer.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraCameraCapturer.h deleted file mode 100644 index 022a6c181..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraCameraCapturer.h +++ /dev/null @@ -1,569 +0,0 @@ -// -// Agora SDK -// -// Copyright (c) 2019 Agora.io. All rights reserved. -// - -#pragma once // NOLINT(build/header_guard) - -#include "AgoraBase.h" -#include "AgoraRefPtr.h" -#include - -namespace agora { -namespace rtc { -class IVideoSinkBase; -class ICameraCaptureObserver; -/** - * The ICameraCapturer class, which provides access to a camera capturer. - */ -class ICameraCapturer : public RefCountInterface { - - public: - /** - * The camera source. - */ - enum CAMERA_SOURCE { - /** - * The camera source is the rear camera. - */ - CAMERA_BACK, - /** - * The camera source is the front camera. - */ - CAMERA_FRONT, - /** - * The camera source is the extra camera. - */ - CAMERA_EXTRA, - }; - - /** - * The camera state. - */ - enum CAMERA_STATE { - /** - * The camera source is started. - */ - CAMERA_STARTED, - /** - * The camera source is stopped. - */ - CAMERA_STOPPED, - }; - - // Interface for receiving information about available camera devices. - /** - * The IDeviceInfo class, which manages the information of available cameras. - */ - class IDeviceInfo { - public: - virtual ~IDeviceInfo() {} - - /** - * Releases the device. - */ - virtual void release() = 0; - - /** - * Gets the number of all available cameras. - * @return The number of all available cameras. - */ - virtual uint32_t NumberOfDevices() = 0; - - /** - * Gets the name of a specified camera. - * @param deviceNumber The index number of the device. - * @param deviceNameUTF8 The name of the device. - * @param deviceNameLength The length of the device name. - * @param deviceUniqueIdUTF8 The unique ID of the device. - * @param deviceUniqueIdLength The length of the device ID. - * @param productUniqueIdUTF8 The unique ID of the product. - * @param productUniqueIdLength The length of the product ID. - * @param deviceTypeUTF8 The camera type of the device. - * @param deviceTypeLength The length of the camera type. - * @return - * The name of the device in the UTF8 format: Success. - */ - virtual int32_t GetDeviceName(uint32_t deviceNumber, char* deviceNameUTF8, - uint32_t deviceNameLength, char* deviceUniqueIdUTF8, - uint32_t deviceUniqueIdLength, char* productUniqueIdUTF8 = 0, - uint32_t productUniqueIdLength = 0, - char* deviceTypeUTF8 = 0, uint32_t deviceTypeLength = 0) = 0; - - /** - * Sets the capability number for a specified device. - * @param deviceUniqueIdUTF8 The pointer to the ID of the device in the UTF8 format. - * @return - * The capability number of the device. - */ - virtual int32_t NumberOfCapabilities(const char* deviceUniqueIdUTF8) = 0; - - /** - * Gets the capability of a specified device. - * @param deviceUniqueIdUTF8 The pointer to the ID of the device in the UTF8 format. - * @param deviceCapabilityNumber The capability number of the device. - * @param capability The reference to the video capability. See {@link VideoFormat}. - * @return - * The capability number of the device. - */ - virtual int32_t GetCapability(const char* deviceUniqueIdUTF8, - const uint32_t deviceCapabilityNumber, - VideoFormat& capability) = 0; - }; - - public: -#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IPHONE) || defined (__OHOS__) - /** - * Sets the camera source. - * - * @note - * This method applies to Android and iOS only. - * - * @param source The camera source that you want to capture. See #CAMERA_SOURCE. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setCameraSource(CAMERA_SOURCE source, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Gets the camera source. - * - * @note - * This method applies to Android and iOS only. - * - * @return The camera source. See #CAMERA_SOURCE. - */ - virtual CAMERA_SOURCE getCameraSource() = 0; - /** - * Switch the camera source - * - * @note - * This method applies to Android and iOS only. - */ - virtual int switchCamera(aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Returns whether zooming is supported by the current device. - * @note - * This method applies to Android and iOS only. - * This interface returns valid values only after the device is initialized. - * - * @return - * - true: zooming is supported. - * - false: zooming is not supported or device is not initialized. - */ - virtual bool isZoomSupported() = 0; - /** - * Sets the zooming factor of the device. - * - * @note - * This method applies to Android and iOS only. - * - * @param zoomValue The zooming factor of the device. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int32_t setCameraZoom(float zoomValue, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Gets the max zooming factor of the device. - * - * @note - * This method applies to Android and iOS only. - * - * @return - * - The max zooming factor of the device - */ - virtual float getCameraMaxZoom() = 0; - /** - * Returns whether auto-focus is supported by the current device. - * @note - * This method applies to Android and iOS only. - * This interface returns valid values only after device is initialized. - * - * @return - * - true: auto-focus is supported. - * - false: auto-focus is not supported or device is not initialized. - */ - virtual bool isFocusSupported() = 0; - /** - * Sets the focus area of the current device. - * @note - * This method applies to Android and iOS only. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int32_t setCameraFocus(float x, float y, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Returns whether auto face focus is supported by the current device. - * @note - * This method applies to Android and iOS only. - * This interface returns valid values only after device is initialized. - * - * @return - * - true: auto-face-focus is supported. - * - false: auto-face-focus is not supported or device is not initialized. - */ - virtual bool isAutoFaceFocusSupported() = 0; - /** - * Enables or disables auto face focus. - * @note - * This method applies to Android and iOS only. - * This interface returns valid values only after device is initialized. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int32_t setCameraAutoFaceFocus(bool enable, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Enables or disables auto face detection. - * @note - * This method applies to Android and iOS only. - * This interface returns valid values only after device is initialized. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int32_t enableFaceDetection(bool enable, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Checks whether the camera face detect is supported. - * - * @return - * - true: The camera face detect is supported. - * - false: The camera face detect is not supported. - */ - virtual bool isCameraFaceDetectSupported() = 0; - - /** - * Checks whether the camera flash function is supported. - * - * The SDK uses the front camera by default, so if you call `isCameraTorchSupported` directly, - * you can find out from the return value whether the device supports enabling the flash - * when using the front camera. If you want to check whether the device supports enabling the - * flash when using the rear camera, call \ref IRtcEngine::switchCamera "switchCamera" - * to switch the camera used by the SDK to the rear camera, and then call `isCameraTorchSupported`. - * - * @note - * - Call this method after the camera is started. - * - This method is for Android and iOS only. - * - On iPads with system version 15, even if `isCameraTorchSupported` returns true, you might - * fail to successfully enable the flash by calling \ref IRtcEngine::setCameraTorchOn "setCameraTorchOn" - * due to system issues. - * - * @return - * - true: The device supports enabling the flash. - * - false: The device does not support enabling the flash. - */ - virtual bool isCameraTorchSupported() = 0; - - /** - * @note - * - Call this method after the camera is started. - * - This method is for Android and iOS only. - * - On iPads with system version 15, even if \ref IRtcEngine::isCameraTorchSupported "isCameraTorchSupported" - * returns true, you might fail to successfully enable the flash by calling `setCameraTorchOn` due to - * system issues. - * - * @param isOn Determines whether to enable the flash: - * - true: Enable the flash. - * - false: Disable the flash. - * - * @return - * - 0: Success - * - < 0: Failure - */ - virtual int setCameraTorchOn(bool on, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** Checks whether the camera exposure function is supported. - * - * Ensure that you call this method after the camera starts, for example, by calling `startPreview` or `joinChannel`. - * - * @since v2.3.2. - * @return - *
    - *
  • true: The device supports the camera exposure function.
  • - *
  • false: The device does not support the camera exposure function.
  • - *
- */ - virtual bool isCameraExposurePositionSupported() = 0; - - /** Sets the camera exposure position. - * - * Ensure that you call this method after the camera starts, for example, by calling `startPreview` or `joinChannel`. - * - * A successful setCameraExposurePosition method call triggers the {@link IRtcEngineEventHandler#onCameraExposureAreaChanged onCameraExposureAreaChanged} callback on the local client. - * @since v2.3.2. - * @param positionXinView The horizontal coordinate of the touch point in the view. - * @param positionYinView The vertical coordinate of the touch point in the view. - * - * @return - *
    - *
  • 0: Success.
  • - *
  • < 0: Failure.
  • - *
- */ - virtual int setCameraExposurePosition(float positionXinView, float positionYinView, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Returns whether exposure value adjusting is supported by the current device. - * Exposure compensation is in auto exposure mode. - * @since v4.2.2. - * @note - * This method only supports Android and iOS. - * This interface returns valid values only after the device is initialized. - * - * @return - * - true: exposure value adjusting is supported. - * - false: exposure value adjusting is not supported or device is not initialized. - */ - virtual bool isCameraExposureSupported() = 0; - - /** - * Sets the camera exposure ratio. - * - * @since v4.2.2. - * @param value Absolute EV bias will set to camera. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setCameraExposureFactor(float value, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - -#if (defined(__APPLE__) && TARGET_OS_IOS) - /** - * Enables or disables the AVCaptureMultiCamSession. - * - * @param enable Determines whether to use the AVCaptureMultiCamSession: - * - true: Enable the AVCaptureMultiCamSession. - * - false: Disable the AVCaptureMultiCamSession. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual bool enableMultiCamera(bool enable, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Checks whether the camera auto exposure function is supported. - * - * @return - * - true: The camera auto exposure function is supported. - * - false: The camera auto exposure function is not supported. - */ - virtual bool isCameraAutoExposureFaceModeSupported() = 0; - - - /** - * Enables the camera auto exposure face function. - * - * @param enabled Determines whether to enable the camera auto exposure face mode. - * - true: Enable the auto exposure face function. - * - false: Do not enable the auto exposure face function. - * - * @return - *
    - *
  • 0: Success.
  • - *
  • < 0: Failure.
  • - *
- */ - virtual int setCameraAutoExposureFaceModeEnabled(bool enabled, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * set camera stabilization mode.If open stabilization mode, fov will be smaller and capture latency will be longer. - * - * @param mode specifies the camera stabilization mode. - */ - virtual int setCameraStabilizationMode(CAMERA_STABILIZATION_MODE mode) = 0; -#endif - -#elif defined(_WIN32) || (defined(__linux__) && !defined(__ANDROID__) && !defined (__OHOS__)) || \ - (defined(__APPLE__) && TARGET_OS_MAC && !TARGET_OS_IPHONE) - - /** - * Creates a DeviceInfo object. - * - * @note - * This method applies to Windows, macOS, and Linux only. - * @return - * - The pointer to \ref agora::rtc::ICameraCapturer::IDeviceInfo "IDeviceInfo": Success. - * - An empty pointer NULL: Failure. - */ - virtual IDeviceInfo* createDeviceInfo() = 0; - /** - * Initializes the device with the device ID. - * - * @note - * This method applies to Windows, macOS, and Linux only. - * - * @param deviceId The pointer to the device ID. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int initWithDeviceId(const char* deviceId) = 0; - /** - * Initializes the device with the device name. - * - * @note - * This method applies to Windows, macOS, and Linux only. - * - * @param deviceName The pointer to the device name. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int initWithDeviceName(const char* deviceName) = 0; -#endif - -#if defined(__APPLE__) - /** - * Checks whether the center stage is supported. Use this method after starting the camera. - * - * @return - * - true: The center stage is supported. - * - false: The center stage is not supported. - */ - virtual bool isCenterStageSupported() = 0; - - /** Enables the camera Center Stage. - * @param enabled enable Center Stage: - * - true: Enable Center Stage. - * - false: Disable Center Stage. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableCenterStage(bool enabled) = 0; -#endif - - /** - * Set the device orientation of the capture device - * @param VIDEO_ORIENTATION orientaion of the device 0(by default), 90, 180, 270 - */ - virtual int setDeviceOrientation(VIDEO_ORIENTATION orientation, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Sets the format of the video captured by the camera. - * - * If you do not set the video capturing format, the SDK automatically chooses a proper format according to the video encoder configuration of the video track. - * - * @param capture_format The reference to the video format: VideoFormat. - */ - virtual int setCaptureFormat(const VideoFormat& capture_format, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Gets the format of the video captured by the camera. - * @return - * VideoFormat. - */ - virtual VideoFormat getCaptureFormat() = 0; - /** - * Register a camera observer. - * - * @param observer Instance of the capture observer. - */ - virtual int registerCameraObserver(ICameraCaptureObserver* observer, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Unregisters the camera observer. - * - * @param observer Instance of the capture observer. - */ - virtual int unregisterCameraObserver(ICameraCaptureObserver* observer) = 0; - - protected: - ~ICameraCapturer() {} -}; -/** - * The ICameraCaptureObserver class, which handles camera capture events. - */ -class ICameraCaptureObserver { - public: - /** - * Occurs when the camera focus area changes. - * - * @note The SDK triggers this callback when the local user changes the camera focus position by - * calling the \ref agora::rtc::ICameraCapturer::setCameraFocus "setCameraFocus" method. - * - * @param imageWidth Width of the changed camera focus area. - * @param imageHeight Height of the changed camera focus area. - * @param x x coordinate of the changed camera focus area. - * @param y y coordinate of the changed camera focus area. - */ - virtual void onCameraFocusAreaChanged(int imageWidth, int imageHeight, int x, int y) { - (void) imageWidth; - (void) imageHeight; - (void) x; - (void) y; - - } - /** - * Reports the face detection result of the local user. Applies to Android and iOS only. - * - * Once you enable face detection by calling \ref agora::rtc::ICameraCapturer::setCameraFaceDetection "setCameraFaceDetection" (true), - * you can get the following information on the local user in real-time: - * - The width and height of the local video. - * - The position of the human face in the local video. - * - The distance between the human face and the device screen. - * This value is based on the fitting calculation of the local video size and the position of the human face. - * - * @note - * - If the SDK does not detect a face, it reduces the frequency of this callback to reduce power consumption on the local device. - * - The SDK stops triggering this callback when a human face is in close proximity to the screen. - * - On Android, the distance value reported in this callback may be slightly different from the actual distance. - * Therefore, Agora does not recommend using it for accurate calculation. - * - * @param imageWidth The width (px) of the local video. - * @param imageHeight The height (px) of the local video. - * @param vecRectangle A Rectangle array of length 'numFaces', which represents the position and size of the human face on the local video: - * - `x`: The x coordinate (px) of the human face in the local video. Taking the top left corner of the captured video as the origin, - * the x coordinate represents the relative lateral displacement of the top left corner of the human face to the origin. - * - `y`: The y coordinate (px) of the human face in the local video. Taking the top left corner of the captured video as the origin, - * the y coordinate represents the relative longitudinal displacement of the top left corner of the human face to the origin. - * - `width`: The width (px) of the human face in the captured video. - * - `height`: The height (px) of the human face in the captured video. - * @param vecDistance An int array of length 'numFaces', which represents distance (cm) between the human face and the screen. - * @param numFaces The number of faces detected. If the value is 0, it means that no human face is detected. - */ - virtual void onFacePositionChanged( - int imageWidth, int imageHeight, const Rectangle* vecRectangle, const int* vecDistance, int numFaces) { - (void) imageWidth; - (void) imageHeight; - (void) vecRectangle; - (void) vecDistance; - (void) numFaces; - } - - /** Occurs when the camera exposure area changes. - * - * The SDK triggers this callback when the local user changes the camera exposure position by calling the setCameraExposurePosition method. - * - * @note This callback is for Android and iOS only. - * - * @param x x coordinate of the changed camera exposure area. - * @param y y coordinate of the changed camera exposure area. - * @param width Width of the changed camera exposure area. - * @param height Height of the changed camera exposure area. - */ - virtual void onCameraExposureAreaChanged(int x, int y, int width, int height) { - (void)x; - (void)y; - (void)width; - (void)height; - } - - virtual void onCameraStateChanged(ICameraCapturer::CAMERA_STATE state, ICameraCapturer::CAMERA_SOURCE source) { - (void) state; - (void) source; - } - - protected: - virtual ~ICameraCaptureObserver() {} -}; - -} // namespace rtc -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraConfigCenter.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraConfigCenter.h deleted file mode 100644 index e8c4c7585..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraConfigCenter.h +++ /dev/null @@ -1,32 +0,0 @@ -// -// Agora SDK -// -// Copyright (c) 2023 Agora.io. All rights reserved -// - -#pragma once - -#include "AgoraBase.h" -#include "AgoraRefPtr.h" - -namespace agora { -namespace rtc { - -class IConfigCenter : public RefCountInterface { // NOLINT - public: - /** Set local access point addresses in local Ap mode(which also calls local proxy). - Use this method before join channel. - @param config The LocalAccessPointConfiguration class, See the definition of - LocalAccessPointConfiguration for details. - @return - - 0: Success - - < 0: Failure - */ - virtual int SetLocalAccessPoint(const LocalAccessPointConfiguration& config) = 0; - - protected: - virtual ~IConfigCenter() {} // NOLINT -}; - -} // namespace rtc -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraDataChannel.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraDataChannel.h deleted file mode 100644 index d62a64ee1..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraDataChannel.h +++ /dev/null @@ -1,166 +0,0 @@ - -// Copyright (c) 2022 Agora.io. All rights reserved - -// This program is confidential and proprietary to Agora.io. -// And may not be copied, reproduced, modified, disclosed to others, published -// or used, in whole or in part, without the express prior written permission -// of Agora.io. -#pragma once // NOLINT(build/header_guard) - -#include "AgoraRefPtr.h" -#include "AgoraBase.h" -#include -namespace agora { - -/** - * The definition of the DataChannelConfig struct. - */ -struct DataChannelConfig { - /** - * Whether this channel should sync with media stream: - * - true: sync . - * - false: not sync. - */ - bool syncWithMedia; - /** - * Whether this channel should ensure oredered message: - * - true: orderd . - * - false: not orderd. - */ - bool ordered; - - /** - * Whether this channel should compress the data packet: - * - <= 0: We dont compress the data packet - * - > 0: Once the packet length exceeds the compressionLength, we compress it. - */ - int compressionLength; - // optional - Optional channelId; // 0~7 - - /** - * The priority - */ - int32_t priority; - DataChannelConfig() : - syncWithMedia(false), - ordered(false), - compressionLength(0), - priority(-1) {} -}; - -/** - * The definition of the DataChannelInfo struct. - */ -struct DataChannelInfo { - /** - * The Id of the data channel - */ - int dataChannelId; - /** - * The metaData of the data channel - */ - util::AString metadata; -}; - -/** - * The definition of the DataChannelInfo struct. - */ -struct UserDataChannelInfo { - /** - * The user Id of the data channel - */ - util::AString userId; - /** - * The data channel infos - */ - const DataChannelInfo* infos; - /** - * The info size - */ - size_t info_size; -}; - -class ILocalDataChannel : public RefCountInterface { - public: - /** - * Send data packet to this data channel after publishing. - * - * @param [in] packet packet buffer pointer. - * @param [in] length packet buffer length. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int sendDataPacket(const char* packet, size_t length, uint64_t capture_time_ms, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Send meta data to this data channel before publishing. - * - * @param [in] metaData meta data pointer. - * @param [in] length meta data length. - * @return···· - * - 0: Success. - * - < 0: Failure. - */ - virtual int setMetaData(const char* metaData, size_t length, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * return configured channel id - * - * @return - */ - virtual Optional configuredChannelId() const = 0; - - protected: - virtual ~ILocalDataChannel() {} -}; - -class IRemoteDataChannel: public RefCountInterface { - public: - virtual util::AString UserId() const = 0; - virtual int ChannelId() const = 0; - virtual util::AString Meta() = 0; - - protected: - virtual ~IRemoteDataChannel() {} -}; - -class IDataChannelObserver { - public: - /** - * Occurs when the channe is ready to send the data packet. - * @param channel the published channel. - */ - virtual void onLocalDataChannelPublished(agora_refptr channel) {} - - /** - * Occurs when the the channe is added and ready to receive data packet. - * @param channel the remote channel pointer. - */ - virtual void onRemoteDataChannelSubscribed(agora_refptr channel) {} - - /** - * Occurs when the the channe is removed. - * @param channel the remote channel pointer. - */ - virtual void onRemoteDataChannelUnsubscribed(agora_refptr channel) {} - /** - * Occurs when the packet is received. - * @param info the channel Info. - * @param packet the received packet. - */ - virtual void onRemoteDataPacketReceived(const UserDataChannelInfo& info, util::AString packet) {} - - /** - * Occurs when the remote data channel info updated. - * @param modified_infos the modifed channel Infos, add or update. - * @param modified_infos_size the size of modifed channel Infos . - * @param deleted_infos the deleted channel Infos. - * @param deleted_infos_size the size of deleted channel Infos . - */ - virtual void onRemoteDataChannelInfoUpdated(const UserDataChannelInfo* modified_infos, size_t modified_infos_size, - const UserDataChannelInfo* deleted_infos, size_t deleted_infos_size) {} - virtual ~IDataChannelObserver() {} -}; - -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionAINoiseSuppressor.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionAINoiseSuppressor.h deleted file mode 100644 index 5826a6ca3..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionAINoiseSuppressor.h +++ /dev/null @@ -1,24 +0,0 @@ - - //Agora SDK - - //Copyright (c) 2021 Agora.io. All rights reserved. - -#pragma once // NOLINT(build/header_guard) - -#include "AgoraRefPtr.h" - -namespace agora { -namespace rtc { - -class AINoiseSuppressorExtension : public RefCountInterface { -public: - virtual ~AINoiseSuppressorExtension() {}; - virtual int Init(const char* weight_raw_buffer, size_t raw_buffer_bytes) = 0; - virtual int ProcessDenoiseFrame(float* input, float* output, int stage) = 0; - virtual int ClearHiddenState(bool clear_hidden, int clear_lpsbuffer_nframe) = 0; - virtual const char* GetLibVersion(int mode = 0) = 0; -}; - - -} // namespace rtc -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionAiAec.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionAiAec.h deleted file mode 100644 index fec96b6a1..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionAiAec.h +++ /dev/null @@ -1,27 +0,0 @@ - -// Agora SDK -// -// Created by LLF on 2022-8-15. -// Copyright (c) 2022 Agora. All rights reserved. -// - -#pragma once // NOLINT(build/header_guard) - -#include "AgoraRefPtr.h" - -#define MAX_VERSION_LEN 64 - -namespace agora { -namespace rtc { - -class AiEchoCancellationExtension : public RefCountInterface { - public: - virtual ~AiEchoCancellationExtension() {}; - virtual int Init(const char* weight_raw_buffer, size_t raw_buffer_bytes) = 0; - virtual int ProcessAiNlpFrame(const float* linear, const float* nearin, const float* far_ref, float* out_mask) = 0; - virtual int ClearHiddenState(float scale_factor = 0.0,int clear_lpsbuffer_nframe = 0) = 0; - virtual const char* GetLibVersion(int mode = 0) = 0; -}; - -} // namespace rtc -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionControl.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionControl.h deleted file mode 100644 index da0c708df..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionControl.h +++ /dev/null @@ -1,99 +0,0 @@ -// -// Copyright (c) 2020 Agora.io. All rights reserved - -// This program is confidential and proprietary to Agora.io. -// And may not be copied, reproduced, modified, disclosed to others, published -// or used, in whole or in part, without the express prior written permission -// of Agora.io. - -#pragma once // NOLINT(build/header_guard) -#include "AgoraBase.h" -#include "AgoraRefPtr.h" -#include "IAgoraLog.h" -#include "NGIAgoraVideoFrame.h" -#include "NGIAgoraExtensionProvider.h" - -namespace agora { -namespace rtc { -class IExtensionProvider; -/** - * Interface for handling agora extensions. - */ -class IExtensionControl { - public: - /** - * Agora Extension Capabilities. - */ - struct Capabilities { - /** - * Whether to support audio extensions. - */ - bool audio; - /** - * Whether to support video extensions. - */ - bool video; - }; - - /** - * Gets the capabilities of agora extensions. - * - * @param capabilities Supported extension capabilities. - */ - virtual void getCapabilities(Capabilities& capabilities) = 0; - - /** - * Recycles internal frame memory with a specified Video frame type. - * - * The SDK automatically recycles deprecated video frames. However, - * you can still call this method to perform an immediate memory recycle. - * @param type Frame type to be recycled. - */ - virtual int recycleVideoCache() = 0; - - /** - * This method dumps the content of the video frame to the specified file. - * - * @return - * - 0: The method call succeeds. - * - <0: The method call fails. - */ - virtual int dumpVideoFrame(agora_refptr frame, const char* file) = 0; - - /** - * Sets log file. - * - * @param level Logging level. See #commons::LOG_LEVEL. - * @param message Message to add to the log file. - * @return - * - 0: The method call succeeds. - * - <0: The method call fails. - */ - virtual int log(commons::LOG_LEVEL level, const char* message) = 0; - - /** - * Post extension events to SDK. - * - * @param provider name of the provider - * @param extension name of the extension - * @param event_key key of the extension event - * @param event_json_str string of the extension event - * @return - * - 0: The method call succeeds. - * - <0: The method call fails. - */ - virtual int fireEvent(const char* provider, const char* extension, const char* event_key, const char* value) = 0; - - /** - * Register provider to the SDK - * @param provider name of the provider - * @param instance instance of the provider - */ - virtual int registerProvider(const char* provider, agora_refptr instance) = 0; - - protected: - virtual ~IExtensionControl() {} -}; - -} // namespace rtc -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionProvider.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionProvider.h deleted file mode 100644 index 4dff21248..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionProvider.h +++ /dev/null @@ -1,122 +0,0 @@ -// -// Agora SDK -// -// Copyright (c) 2021 Agora.io. All rights reserved. -// - -#pragma once - -#include "AgoraRefPtr.h" -#include "NGIAgoraMediaNode.h" -#include "AgoraExtensionVersion.h" - -namespace agora { -namespace rtc { -class IExtensionControl; - -/** - * Interfaces for Extension Provider - * User can implement these interfaces for providing their own media node implementations to SDK. - * Please refer to \ref agora::RefCountedObject to wrap your implementation so that it can be - * held by agora::agora_refptr. - * For example: - * class YourExtensionProvide: public IExtensionProvider { - * // Your Concrete implementaion - * }; - * - * // Use agroa::RefCountedObject to provide RefCountInterface implementation for you implementation, - * // intantiate and wrap it with agora_refptr. - * - * agora_refptr provider = new RefCountedObject(Arg1, Arg2, ...); - * - * You can instantiate your AudioFilter/VideoFilter/VideoSink in the same way. - */ - -class IExtensionProvider : public RefCountInterface { - public: - enum EXTENSION_TYPE { - /** - * note: discarded, Don't use it anymore. - */ - AUDIO_FILTER, - VIDEO_PRE_PROCESSING_FILTER, - VIDEO_POST_PROCESSING_FILTER, - AUDIO_SINK, - VIDEO_SINK, - /* - * Used to modify locally captured audio data to play, such as ear monitoring. - */ - AUDIO_RECORDING_LOCAL_PLAYBACK_FILTER = 10000, - /* - * Used to modify audio data after the local APM (3A). - */ - AUDIO_POST_PROCESSING_FILTER = 10001, - /* - * Used to modify received and decoded remote user audio data. - */ - AUDIO_REMOTE_USER_PLAYBACK_FILTER = 10002, - /* - * note: It is used internally by agora and does not support users other than agora. - * - * Used to modify the audio data of the sender's PCM source to take effect for sending and local playback. - */ - AUDIO_PCM_SOURCE_FILTER = 10003, - /* - * note: It is used internally by agora and does not support users other than agora. - * - * Used to Modifying the audio data of the sender's PCM source is only effect for the sending. - */ - AUDIO_PCM_SOURCE_SENDING_FILTER = 10004, - /* - * note: It is used internally by agora and does not support users other than agora. - * - * Used to Modifying the audio data of the sender's PCM source is only effect for the local playback. - */ - AUDIO_PCM_SOURCE_LOCAL_PLAYBACK_FILTER = 10005, - /* - * note: It is used internally by agora and does not support users other than agora. - * - * Used to modify local playback audio data after the remote audio mixed. - */ - AUDIO_REMOTE_MIXED_PLAYBACK_FILTER = 10006, - UNKNOWN = 0xFFFF, - }; - - struct ExtensionMetaInfo { - EXTENSION_TYPE type; - const char* extension_name; - }; - - virtual void setExtensionControl(IExtensionControl* control) {} - - virtual void enumerateExtensions(ExtensionMetaInfo* extension_list, - int& extension_count) { - (void) extension_list; - extension_count = 0; - } - - virtual agora_refptr createAudioFilter(const char* name) { - return NULL; - } - - virtual agora_refptr createVideoFilter(const char* name) { - return NULL; - } - - virtual agora_refptr createVideoSink(const char* name) { - return NULL; - } - - virtual void setProperty(const char* key, const char* value) {} - - protected: - virtual ~IExtensionProvider() {} -}; - -class IExtensionProviderV2 : public IExtensionProvider { - public: - virtual void getExtensionVersion(const char* extension_name, ExtensionVersion& version) = 0; -}; - -} // namespace rtc -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionScreenSource.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionScreenSource.h deleted file mode 100644 index 0b12be254..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionScreenSource.h +++ /dev/null @@ -1,186 +0,0 @@ -// -// Agora SDK -// -// Copyright (c) 2021 Agora.io. All rights reserved. -// - -#pragma once // NOLINT(build/header_guard) - -#include "AgoraBase.h" -#include "IAgoraLog.h" -#include "AgoraRefPtr.h" -#include "NGIAgoraVideoFrame.h" -#include "AgoraMediaBase.h" -#if defined(WEBRTC_IOS) -#include -#endif -namespace agora { -namespace rtc { - -struct ScreenCaptureProfilingStatistics { - int capture_type; - uint32_t captured_frame_width; - uint32_t captured_frame_height; - uint32_t total_captured_frames; - uint64_t per_frame_cap_time_ms; - uint64_t per_capture_cpu_cycles; - bool capture_mouse_cursor; - uint32_t target_fps; - uint32_t real_capture_fps; - uint32_t capture_out_fps; - uint32_t drop_fps; - - ScreenCaptureProfilingStatistics() - : capture_type(-1), captured_frame_width(0), captured_frame_height(0), - total_captured_frames(0), per_frame_cap_time_ms(0), - per_capture_cpu_cycles(0), capture_mouse_cursor(true), - target_fps(0), real_capture_fps(0), - capture_out_fps(0), drop_fps(0) {} -}; - -class IScreenCaptureSource : public RefCountInterface { - public: - class Control : public RefCountInterface { - public: - virtual int postEvent(const char* key, const char* value) = 0; - virtual void printLog(commons::LOG_LEVEL level, const char* format, ...) = 0; - virtual void printLog(commons::LOG_LEVEL level, const char* fromat, va_list) = 0; - virtual int pushAudioFrame(const media::IAudioFrameObserver::AudioFrame& captured_frame) = 0; - virtual bool timeToPushVideo() = 0; - virtual int pushVideoFrame(const agora::agora_refptr& captured_frame) = 0; - virtual agora::agora_refptr getMemoryPool() = 0; -#if defined(WEBRTC_IOS) - virtual int pushVideoFrame(CVPixelBufferRef pixelBuffer, int64_t timestamp_ms, uint32_t rotation) = 0; -#endif -#if defined(WEBRTC_WIN) - virtual void recycleVideoCache() = 0; -#endif - }; - - struct AudioCaptureConfig { - uint32_t volume; - int sample_rate_hz; - int num_channels; - AudioCaptureConfig() : volume(0), sample_rate_hz(0), num_channels(0) {} - }; - -#if defined (__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || defined(__OHOS__) - struct VideoCaptureConfig { - agora::rtc::VideoDimensions dimensions; - int frameRate; - VideoCaptureConfig() - : dimensions(640, 360), frameRate(15) {} - }; -#else - struct VideoCaptureConfig { - enum CaptureType { - CaptureWindow, - CaptureScreen, - }; - CaptureType type; - Rectangle screen_rect; - Rectangle region_offset; - uint32_t display_id; - view_t window_id; - - // Mac only - bool disable_avf; - - VideoCaptureConfig() - : type(CaptureScreen), screen_rect(), region_offset(), display_id(0), window_id(NULL), disable_avf(false) { } - }; -#endif - - struct ScreenSourceListOption { - int thumb_width; - int thumb_height; - int icon_width; - int icon_height; - bool include_screen; - bool unfiltered; - bool unskip_system_window; - }; - - enum CaptureMode { - kPull, // SDK needs to poll the captured frame actively - kPush // Capture source pushes the captured frame to sdk - }; - - - virtual ~IScreenCaptureSource() {} - - virtual int initializeCapture(const agora_refptr& control) = 0; - - virtual int initVideo(const VideoCaptureConfig& config) = 0; - // Start video capture interface for desktop capturing - virtual int startVideoCapture(const VideoCaptureConfig& config) = 0; - virtual int stopVideoCapture() = 0; - virtual int stopVideoCaptureAsync() = 0; - - virtual CaptureMode getVideoCaptureMode() = 0; - - // Implementation of the following interfaces are not mandatory - virtual int startAudioCapture(const AudioCaptureConfig& config) { - return -ERR_NOT_SUPPORTED; - } - virtual int stopAudioCapture() { - return -ERR_NOT_SUPPORTED; - } - virtual int setAudioVolume(uint32_t volume) { - return -ERR_NOT_SUPPORTED; - } - virtual int setFrameRate(int fps) { - return -ERR_NOT_SUPPORTED; - } - - virtual int setScreenCaptureDimensions(const agora::rtc::VideoDimensions& dimensions) { - return -ERR_NOT_SUPPORTED; - } - virtual int updateCaptureRegion(const agora::rtc::Rectangle& captureRegion) { - return -ERR_NOT_SUPPORTED; - } - virtual int setExcludeWindowList(void* const * handles, int count) { - return -ERR_NOT_SUPPORTED; - } - virtual int captureMouseCursor(bool capture) { - return -ERR_NOT_SUPPORTED; - } - virtual int capture(agora::agora_refptr& frame) { - return -ERR_NOT_SUPPORTED; - } - virtual int getProfilingStats(ScreenCaptureProfilingStatistics& stats) { - return -ERR_NOT_SUPPORTED; - } - virtual int getScreenDimensions(int& width, int& height) { - return ERR_NOT_SUPPORTED; - } - virtual int setProperty(const char* key, const char* json_value) { - return -ERR_NOT_SUPPORTED; - } - virtual int setCustomContext(const char* key, const void* context) { - return -ERR_NOT_SUPPORTED; - } - virtual int getProperty(const char* key, char* json_value, int& length) { - return -ERR_NOT_SUPPORTED; - } - virtual int setHighLight(bool isHighLight, unsigned int color, int width) { - return -ERR_NOT_SUPPORTED; - } - virtual int setContentType(int contentType) { - return -ERR_NOT_SUPPORTED; - } - virtual void* getCustomContext(const char* key) { - return NULL; - } - virtual void* getScreenCaptureSources(const ScreenSourceListOption& option) { - return NULL; - } - virtual void setFrameCopy(bool frameCopy) {}; -#if defined(WEBRTC_ANDROID) && !defined(RTC_EXCLUDE_JAVA) - virtual void setSmoothCapture(bool smoothCapture) {}; - virtual void setResetVitualDisplay(bool reset) {}; -#endif -}; - -} // namespace rtc -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionVQA.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionVQA.h deleted file mode 100644 index ea7d8d692..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraExtensionVQA.h +++ /dev/null @@ -1,41 +0,0 @@ -// -// Agora SDK -// -// Copyright (c) 2021 Agora.io. All rights reserved. -// - -#pragma once // NOLINT(build/header_guard) - -#include "AgoraBase.h" -#include "IAgoraLog.h" -#include "AgoraRefPtr.h" -#include "NGIAgoraVideoFrame.h" -#include "AgoraMediaBase.h" - -namespace agora { -namespace rtc { - -// class ExtensionControlImpl; -class IAgoraVideoQualityAnalyzer : public RefCountInterface { - public: - class Control : public RefCountInterface { - public: - // virtual int postEvent(const char* key, const char* value) = 0; - virtual void printLog(commons::LOG_LEVEL level, const char* format, ...) = 0; - }; - - - virtual ~IAgoraVideoQualityAnalyzer() {} - virtual int initializeVQA(const agora_refptr& control) = 0; - - virtual int pushYuvData(agora::agora_refptr frame) { - return -ERR_NOT_SUPPORTED; - } - - virtual int getVqaMos(int& mos) { - return -ERR_NOT_SUPPORTED; - } -}; - -} // namespace rtc -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraLocalUser.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraLocalUser.h deleted file mode 100644 index 2db3c9dcf..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraLocalUser.h +++ /dev/null @@ -1,1601 +0,0 @@ -// -// Agora SDK -// -// Created by Zheng Ender in 2018-01. -// Copyright (c) 2018 Agora.io. All rights reserved. -// - -#pragma once // NOLINT(build/header_guard) - -#include -#include -#include "AgoraBase.h" -#include "AgoraOptional.h" -#include - -namespace agora { -namespace media { -class IAudioFrameObserver; -} - -class ILocalDataChannel; -class IDataChannelObserver; - -namespace rtc { -class IAudioEngineWrapper; - -class ILocalUserObserver; -class ILocalVideoTrack; -class IRemoteVideoTrack; -class IVideoFrameObserver2; - -class IMediaControlPacketSender; -class IMediaControlPacketReceiver; -struct AudioEncoderConfiguration; -struct VideoEncoderConfiguration; - -class ILocalAudioTrack; -struct RemoteAudioTrackStats; -class IRemoteAudioTrack; -struct LocalVideoTrackStats; -struct RemoteVideoTrackStats; -class IMediaPacketReceiver; -class IVideoSinkBase; - -/** - * The ILocalUser class defines the behavior and state of a local user. - * - * Each RTC connection has its own local user. Apps can get the local - * user object by calling \ref agora::rtc::IRtcConnection::getLocalUser - * "IRtcConnection::getLocalUser". - * - * Each local user has two user roles: broadcaster (publisher and subscriber) and - * audience (subscriber only). A publisher publishes audio and video tracks, while - * audience receive them. - */ -class ILocalUser { - public: - /** - * The statistics related to audio network adaptation (ANA). - */ - struct ANAStats { - /** - * The number of actions taken by the ANA bitrate controller since the start of the call. - * - * If you do not set this parameter, the ANA bitrate controller is disabled. - */ - agora::Optional bitrate_action_counter; - /** - * The number of actions taken by the ANA channel controller since the start of the call. - * - * If you do not set this parameter, the ANA channel controller is disabled. - */ - agora::Optional channel_action_counter; - /** - * The number of actions taken by the ANA DTX controller since the start of the call. - * - * If you do not set this parameter, the ANA DTX controller is disabled. - */ - agora::Optional dtx_action_counter; - /** - * The number of actions taken by the ANA FEC (Forward Error Correction) controller since the start of the call. - * - * If you do not set this parameter, the ANA FEC controller is disabled. - */ - agora::Optional fec_action_counter; - /** - * The number of times that the ANA frame length controller increases the frame length - * since the start of the call. - * - * If you do not set this parameter, the ANA frame length controller is disabled. - */ - agora::Optional frame_length_increase_counter; - /** - * The number of times that the ANA frame length controller decreases the frame length - * since the start of the call. - * - * If you so not set this parameter, the ANA frame length controller is disabled. - */ - agora::Optional frame_length_decrease_counter; - /** - * The uplink packet loss fractions set by the ANA FEC controller. - * - * If you do not set this parameter, the ANA FEC controller is not active. - */ - agora::Optional uplink_packet_loss_fraction; - }; - - /** - * The statistics related to audio processing. - */ - struct AudioProcessingStats { - /** - * The echo return loss (ERL). - * - * ERL = 10log_10(P_far / P_echo). - * - * ERL measures the signal loss that comes back as an echo. A higher ratio corresponds to a smaller - * amount of echo. The higher the ERL the better. - */ - agora::Optional echo_return_loss; - // - /** - * The echo return loss enhancement (ERLE). - * - * ERLE = 10log_10(P_echo / P_out). - * - * The performance of an echo canceller is measured in echo return loss enhancement, which is the amount - * of additional signal loss applied by the echo canceller. - * - * The total signal loss of the echo is the sum of ERL and ERLE. - */ - agora::Optional echo_return_loss_enhancement; - /** - * The fraction of time that the AEC (Acoustic Echo Cancelling) linear filter is divergent, in a - * 1-second non-overlapped aggregation window. - */ - agora::Optional divergent_filter_fraction; - - /** - * The delay metrics (ms). - * - * It consists of the delay median and standard deviation. It also consists of the - * fraction of delay estimates that can make the echo cancellation perform poorly. The values are - * aggregated until the first call of \ref agora::rtc::IRemoteAudioTrack::getStatistics "getStatistics" and afterwards aggregated and updated every - * second. - * @note - * If there are several clients pulling metrics from - * `getStatistics` during a session, the first call from any of them will change to one second - * aggregation window for all. - */ - agora::Optional delay_median_ms; - /** - * The delay standard deviation(ms). - */ - agora::Optional delay_standard_deviation_ms; - - /** - * The residual echo detector likelihood. - */ - agora::Optional residual_echo_likelihood; - /** - * The maximum residual echo likelihood from the last time period. - */ - agora::Optional residual_echo_likelihood_recent_max; - - /** - * The instantaneous delay estimate produced in the AEC (ms). - * The value is the instantaneous value at the time of calling \ref agora::rtc::IRemoteAudioTrack::getStatistics "getStatistics". - */ - agora::Optional delay_ms; - }; - - /** - * The detailed statistics of the local audio. - */ - struct LocalAudioDetailedStats { - /** - * The synchronization source (SSRC) to identify the stream of RTP packets from the local audio. - */ - uint32_t local_ssrc; - /** - * The number of sent audio bytes. - */ - int64_t bytes_sent; - /** - * The number of sent audio packets. - */ - int32_t packets_sent; - /** - * The number of lost audio packets. - */ - int32_t packets_lost; - /** - * The fraction packet loss reported for this SSRC. - */ - float fraction_lost; - /** - * The codec name. - */ - char codec_name[media::base::kMaxCodecNameLength]; - /** - * The payload type as used in RTP encoding or decoding. - */ - agora::Optional codec_payload_type; - /** - * The ext sequence number. - */ - int32_t ext_seqnum; - /** - * The jitter duration (ms). - */ - int32_t jitter_ms; - /** - * The RTT (Round-Trip Time) duration (ms). - */ - int64_t rtt_ms; - /** - * The audio level (dBov) of the media source. - */ - int32_t audio_level; - /** - * The audio energy of the media source. - */ - double total_input_energy; - /** - * The audio duration of the media source. - */ - double total_input_duration; - /** - * Whether the typing noise is detected. - * - `true`: The typing noise is detected. - * - `false`: The typing noise is not detected. - */ - bool typing_noise_detected; - - /** - * The audio process time from record done to encode done - */ - - ANAStats ana_statistics; - AudioProcessingStats apm_statistics; - - LocalAudioDetailedStats() : local_ssrc(0), bytes_sent(0), packets_sent(0), packets_lost(-1), fraction_lost(-1.0f), - ext_seqnum(-1), jitter_ms(-1), rtt_ms(-1), audio_level(-1), - total_input_energy(0.0), total_input_duration(0.0), typing_noise_detected(false) { - memset(codec_name, 0, sizeof(codec_name)); - } - }; - - enum NS_MODE { - ElderNsStatistical = 0, /* Elder Statistical Noise Suppression.*/ - NsNGStatistical = 1, /* Next Generation Statistical Noise Suppression.*/ - NsNG = 2 /* Next Generation Noise Suppression.*/ - }; - enum NS_LEVEL { - Soft = 0,/* Soft Noise Suppression.*/ - Aggressive = 1 /* Aggressiveness Noise Suppression.*/ - }; - enum NS_DELAY { - HighQuality = 0,/* High Audio Quality with High Delay.*/ - Balance = 1,/* Balanced Audio Quality and Delay.*/ - LowDelay = 2/* Slight Low Audio Quality with Low Delay.*/ - }; - - public: - virtual ~ILocalUser() {} - - /** - * Sets the role of the user. - * - * You can call this method either before or after connecting to an Agora channel: - * - Before connecting: This method sets the user role as publisher or subscriber (default). - * - After connecting: This method allows you to switch the user role between publisher and - * subscriber. - * The \ref IRtcConnectionObserver::onChangeRoleSuccess "onChangeRoleSuccess" and - * \ref IRtcConnectionObserver::onChangeRoleFailure "onChangeRoleFailure" - * callbacks indicate the result of this method call. - * - * @note - * If the token in the \ref IRtcConnection::connect "connect" method does not have the same role - * as `role`, the connection fails with the \ref IRtcConnectionObserver::onConnectionFailure "onConnectionFailure" callback. - * @param role The role of the user. See \ref rtc::CLIENT_ROLE_TYPE "CLIENT_ROLE_TYPE". - */ - virtual int setUserRole(rtc::CLIENT_ROLE_TYPE role, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Gets the role of the user. - * - * @return The role of the user: Success. - */ - virtual CLIENT_ROLE_TYPE getUserRole() = 0; - - /** - * Sets the latency level of an audience member. - * - * @note - * @param level The latency level of an audience member in interactive live streaming. See AUDIENCE_LATENCY_LEVEL_TYPE. - * @param role The user role determined by the config. If it's -1, it means there is no configured role. - */ - virtual int setAudienceLatencyLevel(AUDIENCE_LATENCY_LEVEL_TYPE level, int role, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - virtual AUDIENCE_LATENCY_LEVEL_TYPE getAudienceLatencyLevel() = 0; - - /** - * Configures the audio encoder. - * - * The SDK applies the configurations to all the sending audio tracks. - * - * @param config The reference to the audio encoder configurations. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setAudioEncoderConfiguration(const rtc::AudioEncoderConfiguration& config, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Sets the audio parameters and application scenarios. - * - * @param scenario Sets the audio application scenarios: #AUDIO_SCENARIO_TYPE. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setAudioScenario(AUDIO_SCENARIO_TYPE scenario, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * You can call this method to set the expected video scenario. - * The SDK will optimize the video experience for each scenario you set. - * - * @param scenarioType The video application scenario. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setVideoScenario(VIDEO_APPLICATION_SCENARIO_TYPE scenarioType, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Sets the Video qoe preference. - * - * You can call this method to set the expected QoE Preference. - * The SDK will optimize the video experience for each preference you set. - * - * - * @param qoePreference The qoe preference type. See #VIDEO_QOE_PREFERENCE_TYPE. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setVideoQoEPreference(VIDEO_QOE_PREFERENCE_TYPE qoePreference, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Gets the detailed statistics of the local audio. - * - * @param[out] stats The reference to the detailed statistics of the local audio. - * @return - * - `true`: Success. - * - `false`: Failure. - */ - virtual bool getLocalAudioStatistics(LocalAudioDetailedStats& stats) = 0; - - /** - * Publishes a local audio track to the channel. - * - * By default, all published audio tracks are mixed. - * - * @param audioTrack The local audio track to be published. - * @return - * - 0: Success. - * - < 0: Failure. - * - -5(ERR_REFUSED), if the role of the local user is not broadcaster. - */ - virtual int publishAudio(agora_refptr audioTrack, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Stops publishing the local audio track to the channel. - * - * @param audioTrack The local audio track that you want to stop publishing. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unpublishAudio(agora_refptr audioTrack, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Publishes a local video track to the channel. - * - * @param videoTrack The local video track to be published. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int publishVideo(agora_refptr videoTrack, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Stops publishing the local video track to the channel. - * - * @param videoTrack The local video track that you want to stop publishing. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unpublishVideo(agora_refptr videoTrack, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Subscribes to the audio of a specified remote user in channel. - * - * @param userId The ID of the remote user whose audio you want to subscribe to. - * @return - * - 0: Success. - * - < 0: Failure. - * - -2(ERR_INVALID_ARGUMENT), if no such user exists or `userId` is invalid. - */ - virtual int subscribeAudio(user_id_t userId, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Subscribes to the audio of all remote users in the channel. - * - * This method also automatically subscribes to the audio of any subsequent user. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int subscribeAllAudio(aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Stops subscribing to the audio of a specified remote user in the channel. - * - * @param userId The ID of the user whose audio you want to stop subscribing to. - * @return - * - 0: Success. - * - < 0: Failure. - * - -2(ERR_INVALID_ARGUMENT), if no such user exists or `userId` is invalid. - */ - virtual int unsubscribeAudio(user_id_t userId, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Stops subscribing to the audio of all remote users in the channel. - * - * This method automatically stops subscribing to the audio of any subsequent user, unless you explicitly - * call \ref subscribeAudio "subscribeAudio" or \ref subscribeAllAudio "subscribeAllAudio". - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unsubscribeAllAudio(aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Adjusts the playback signal volume. - * @param volume The playback volume. The value ranges between 0 and 400, including the following: - * 0: Mute. - * 100: (Default) Original volume. - * 400: Four times the original volume with signal-clipping protection. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int adjustPlaybackSignalVolume(int volume, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Gets the current playback signal volume. - * @param volume A pointer to the playback signal volume. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getPlaybackSignalVolume(int* volume) = 0; - - /* - * Adjust the playback volume of the user specified by uid. - * - * You can call this method to adjust the playback volume of the user specified by uid - * in call. If you want to adjust playback volume of the multi user, you can call this - * this method multi times. - * - * @note - * Please call this method after join channel. - * This method adjust the playback volume of specified user. - * - * @param userId The ID of the Remote user. - * @param volume The playback volume of the specified remote user. The value ranges between 0 and 400, including the following: - * 0: Mute. - * 100: (Default) Original volume. - * 400: Four times the original volume with signal-clipping protection. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int adjustUserPlaybackSignalVolume(user_id_t userId, int volume, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Gets the current playback signal volume of specified user. - * @param userId The ID of the Remote user. - * @param volume A pointer to the playback signal volume. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getUserPlaybackSignalVolume(user_id_t userId, int* volume) = 0; - - /** Enables/Disables stereo panning for remote users. - - Ensure that you call this method before joinChannel to enable stereo panning for remote users so that the local user can track the position of a remote user by calling \ref agora::rtc::IRtcEngine::setRemoteVoicePosition "setRemoteVoicePosition". - - @param enabled Sets whether or not to enable stereo panning for remote users: - - true: enables stereo panning. - - false: disables stereo panning. - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int enableSoundPositionIndication(bool enabled, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** Sets the sound position and gain of a remote user. - - When the local user calls this method to set the sound position of a remote user, the sound difference between the left and right channels allows the local user to track the real-time position of the remote user, creating a real sense of space. This method applies to massively multiplayer online games, such as Battle Royale games. - - @note - - For this method to work, enable stereo panning for remote users by calling the \ref agora::rtc::IRtcEngine::enableSoundPositionIndication "enableSoundPositionIndication" method before joining a channel. - - This method requires hardware support. For the best sound positioning, we recommend using a wired headset. - - Ensure that you call this method after joining a channel. - - @param userId The ID of the remote user. - @param pan The sound position of the remote user. The value ranges from -1.0 to 1.0: - - 0.0: the remote sound comes from the front. - - -1.0: the remote sound comes from the left. - - 1.0: the remote sound comes from the right. - @param gain Gain of the remote user. The value ranges from 0.0 to 100.0. The default value is 100.0 (the original gain of the remote user). The smaller the value, the less the gain. - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int setRemoteVoicePosition(user_id_t userId, double pan, double gain, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** enable spatial audio - - @param enabled enable/disable spatial audio: - - true: enable spatial audio. - - false: disable spatial audio. - @return - - 0: Success. - - < 0: Failure. - */ - virtual int enableSpatialAudio(bool enabled, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** Sets remote user parameters for spatial audio - - @param userId The ID of the remote user. - @param param spatial audio parameters - - @return - - 0: Success. - - < 0: Failure. - */ - virtual int setRemoteUserSpatialAudioParams(user_id_t userId, const agora::SpatialAudioParams& param, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Sets the audio frame parameters for the \ref agora::media::IAudioFrameObserver::onPlaybackAudioFrame - * "onPlaybackAudioFrame" callback. - * - * @param numberOfChannels The number of audio channels of the audio frame in the `onPlaybackAudioFrame` callback. - * - 1: Mono. - * - 2: Stereo. - * @param sampleRateHz The sample rate (Hz) of the audio frame in the `onPlaybackAudioFrame` callback. You can - * set it as 8000, 16000, 32000, 44100, or 48000. - * @param mode Use mode of the audio frame. See #RAW_AUDIO_FRAME_OP_MODE_TYPE. - * @param samplesPerCall The number of samples of the audio frame. * - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setPlaybackAudioFrameParameters(size_t numberOfChannels, - uint32_t sampleRateHz, - RAW_AUDIO_FRAME_OP_MODE_TYPE mode = RAW_AUDIO_FRAME_OP_MODE_READ_ONLY, - int samplesPerCall = 0, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Sets the audio frame parameters for the \ref agora::media::IAudioFrameObserver::onRecordAudioFrame - * "onRecordAudioFrame" callback. - * - * @param numberOfChannels The number of channels of the audio frame in the `onRecordAudioFrame` callback. - * - 1: Mono. - * - 2: Stereo. - * @param sampleRateHz The sample rate (Hz) of the audio frame in the `onRecordAudioFrame` callback. You can - * set it as 8000, 16000, 32000, 44100, or 48000. - * @param mode Use mode of the audio frame. See #RAW_AUDIO_FRAME_OP_MODE_TYPE. - * @param samplesPerCall The number of samples of the audio frame. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setRecordingAudioFrameParameters(size_t numberOfChannels, - uint32_t sampleRateHz, - RAW_AUDIO_FRAME_OP_MODE_TYPE mode = RAW_AUDIO_FRAME_OP_MODE_READ_ONLY, - int samplesPerCall = 0, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Sets the audio frame parameters for the \ref agora::media::IAudioFrameObserver::onMixedAudioFrame - * "onMixedAudioFrame" callback. - * - * @param numberOfChannels The number of channels of the audio frame in the `onMixedAudioFrame` callback. - * - 1: Mono. - * - 2: Stereo. - * @param sampleRateHz The sample rate (Hz) of the audio frame in the `onMixedAudioFrame` callback. You can - * set it as 8000, 16000, 32000, 44100, or 48000. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setMixedAudioFrameParameters(size_t numberOfChannels, - uint32_t sampleRateHz, - int samplesPerCall = 0, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Sets the audio frame parameters for the \ref agora::media::IAudioFrameObserver::onEarMonitoringAudioFrame - * "onEarMonitoringAudioFrame" callback. - * @param enabled Determines whether to enable ear monitoring audio frame observer. - * - true: Enable ear monitoring audio frame observer. - * - false: Disable ear monitoring audio frame observer. - * @param numberOfChannels The number of audio channels of the audio frame in the `onEarMonitoringAudioFrame` callback. - * - 1: Mono. - * - 2: Stereo. - * @param sampleRateHz The sample rate (Hz) of the audio frame in the `onEarMonitoringAudioFrame` callback. You can - * set it as 8000, 16000, 32000, 44100, or 48000. - * @param mode Use mode of the audio frame. See #RAW_AUDIO_FRAME_OP_MODE_TYPE. - * @param samplesPerCall The number of samples of the audio frame. * - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setEarMonitoringAudioFrameParameters(bool enabled, - size_t numberOfChannels, - uint32_t sampleRateHz, - RAW_AUDIO_FRAME_OP_MODE_TYPE mode = RAW_AUDIO_FRAME_OP_MODE_READ_ONLY, - int samplesPerCall = 0, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Sets the audio frame parameters for the \ref agora::media::IAudioFrameObserver::onPlaybackAudioFrameBeforeMixing - * "onPlaybackAudioFrameBeforeMixing" callback. - * - * @param numberOfChannels The number of channels of the audio frame in the `onPlaybackAudioFrameBeforeMixing` callback. - * - 1: Mono. - * - 2: Stereo. - * @param sampleRateHz The sample rate (Hz) of the audio frame in the `onPlaybackAudioFrameBeforeMixing` callback. You can - * set it as 8000, 16000, 32000, 44100, or 48000. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setPlaybackAudioFrameBeforeMixingParameters(size_t numberOfChannels, - uint32_t sampleRateHz, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Registers an audio frame observer. - * - * You need to implement the `IAudioFrameObserverBase` class in this method, and register the following callbacks - * according to your scenario: - * - \ref agora::media::IAudioFrameObserverBase::onRecordAudioFrame "onRecordAudioFrame": Occurs when the SDK receives the audio data captured by the local recording device. - * - \ref agora::media::IAudioFrameObserverBase::onPlaybackAudioFrame "onPlaybackAudioFrame": Occurs when the SDK receives the remote audio data for playback. - * - \ref agora::media::IAudioFrameObserverBase::onPlaybackAudioFrameBeforeMixing "onPlaybackAudioFrameBeforeMixing": Occurs when the SDK receives the remote audio data of a specified - * remote user before mixing. - * - \ref agora::media::IAudioFrameObserverBase::onMixedAudioFrame "onMixedAudioFrame": Occurs when the SDK receives the mixed data of recorded and playback audio. - * - * @param observer A pointer to the audio frame observer: \ref agora::media::IAudioFrameObserverBase "IAudioFrameObserverBase". - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerAudioFrameObserver(agora::media::IAudioFrameObserverBase* observer, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Releases the audio frame observer. - * - * @param observer The pointer to the audio frame observer: \ref agora::media::IAudioFrameObserverBase "IAudioFrameObserverBase". - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unregisterAudioFrameObserver(agora::media::IAudioFrameObserverBase* observer) = 0; - - /** - * Enable the audio spectrum monitor. - * - * @param intervalInMS Sets the time interval(ms) between two consecutive audio spectrum callback. - * The default value is 100. This param should be larger than 10. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableAudioSpectrumMonitor(int intervalInMS = 100, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Disalbe the audio spectrum monitor. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int disableAudioSpectrumMonitor(aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Registers an audio spectrum observer. - * - * You need to implement the `IAudioSpectrumObserver` class in this method, and register the following callbacks - * according to your scenario: - * - \ref agora::media::IAudioSpectrumObserver::onAudioSpectrumComputed "onAudioSpectrumComputed": Occurs when - * the SDK receives the audio data and at set intervals. - * - * @param observer A pointer to the audio spectrum observer: \ref agora::media::IAudioSpectrumObserver - * "IAudioSpectrumObserver". - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerAudioSpectrumObserver(agora::media::IAudioSpectrumObserver * observer, void (*safeDeleter)(agora::media::IAudioSpectrumObserver*), aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Releases the audio spectrum observer. - * - * @param observer The pointer to the audio spectrum observer: \ref agora::media::IAudioSpectrumObserver - * "IAudioSpectrumObserver". - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unregisterAudioSpectrumObserver(agora::media::IAudioSpectrumObserver * observer) = 0; - - /** - * Registers an \ref agora::media::IVideoEncodedFrameObserver "IVideoEncodedFrameObserver" object. - * - * You need to implement the `IVideoEncodedFrameObserver` class in this method. Once you successfully register - * the local encoded frame observer, the SDK triggers the \ref agora::media::IVideoEncodedFrameObserver::onEncodedVideoFrameReceived - * "onEncodedVideoFrameReceived" callback when it receives the encoded video image. - * - * @param observer The pointer to the `IVideoEncodedFrameObserver` object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerLocalVideoEncodedFrameObserver(agora::media::IVideoEncodedFrameObserver* observer, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Releases the \ref agora::media::IVideoEncodedFrameObserver "IVideoEncodedFrameObserver" object. - * @param observer The pointer to the `IVideoEncodedFrameObserver` object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unregisterLocalVideoEncodedFrameObserver(agora::media::IVideoEncodedFrameObserver* observer) = 0; - /** - * Force trigger to intra-frame the next frame. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int forceNextIntraFrame(aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Registers an \ref agora::media::IVideoEncodedFrameObserver "IVideoEncodedFrameObserver" object. - * - * You need to implement the `IVideoEncodedFrameObserver` class in this method. Once you successfully register - * the encoded frame observer, the SDK triggers the \ref agora::media::IVideoEncodedFrameObserver::onEncodedVideoFrameReceived - * "onEncodedVideoFrameReceived" callback when it receives the encoded video image. - * - * @param observer The pointer to the `IVideoEncodedFrameObserver` object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerVideoEncodedFrameObserver(agora::media::IVideoEncodedFrameObserver* observer, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Releases the \ref agora::media::IVideoEncodedFrameObserver "IVideoEncodedFrameObserver" object. - * @param observer The pointer to the `IVideoEncodedFrameObserver` object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unregisterVideoEncodedFrameObserver(agora::media::IVideoEncodedFrameObserver* observer) = 0; - - /** - * Registers an \ref agora::rtc::IVideoFrameObserver2 "IVideoFrameObserver2" object. - * - * You need to implement the `IVideoFrameObserver2` class in this method. Once you successfully register - * the video frame observer, the SDK triggers the \ref agora::media::IVideoFrameObserver2::onFrame - * "onFrame" callback when it receives the video image. - * - * @param observer The pointer to the `IVideoFrameObserver2` object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerVideoFrameObserver(IVideoFrameObserver2* observer, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Releases the \ref agora::rtc::IVideoFrameObserver2 "IVideoFrameObserver2" object. - * @param observer The pointer to the `IVideoFrameObserver2` object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unregisterVideoFrameObserver(IVideoFrameObserver2* observer) = 0; - - virtual int setVideoSubscriptionOptions(user_id_t userId, - const VideoSubscriptionOptions& options, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - virtual int setHighPriorityUserList(uid_t* vipList, int uidNum, int option, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - virtual int getHighPriorityUserList(std::vector& vipList, int& option) = 0; - - virtual int setRemoteSubscribeFallbackOption(int option, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Sets the blocklist of subscribe remote stream audio. - * - * @param userList The id list of users who do not subscribe to audio. - * @param userNumber The number of uid in uidList. - * - * @note - * If uid is in uidList, the remote user's audio will not be subscribed, - * even if subscribeAudio(uid) and subscribeAllAudio(true) are operated. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setSubscribeAudioBlocklist(user_id_t* userList, int userNumber, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Sets the allowlist of subscribe remote stream audio. - * - * @param userList The id list of users who do subscribe to audio. - * @param userNumber The number of uid in uidList. - * - * @note - * If uid is in uidList, the remote user's audio will be subscribed, - * even if unsubscribeAudio(uid) and unsubscribeAllAudio(true) are operated. - * - * If a user is in the blocklist and allowlist at the same time, the user will not subscribe to audio. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setSubscribeAudioAllowlist(user_id_t* userList, int userNumber, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Sets the blocklist of subscribe remote stream video. - * - * @param userList The id list of users who do not subscribe to video. - * @param userNumber The number of uid in uidList. - * - * @note - * If uid is in uidList, the remote user's video will not be subscribed, - * even if subscribeVideo(uid) and subscribeAllVideo(true) are operated. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setSubscribeVideoBlocklist(user_id_t* userList, int userNumber, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Sets the allowlist of subscribe remote stream video. - * - * @param userList The id list of users who do subscribe to video. - * @param userNumber The number of uid in uidList. - * - * @note - * If uid is in uidList, the remote user's video will be subscribed, - * even if unsubscribeVideo(uid) and unsubscribeAllVideo(true) are operated. - * - * If a user is in the blocklist and allowlist at the same time, the user will not subscribe to video. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setSubscribeVideoAllowlist(user_id_t* userList, int userNumber, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Subscribes to the video of a specified remote user in the channel. - * - * @param userId The ID of the user whose video you want to subscribe to. - * @param subscriptionOptions The reference to the video subscription options: \ref agora::rtc::VideoSubscriptionOptions "VideoSubscriptionOptions". - * For example, subscribing to encoded video data only or subscribing to low-stream video. - * - * @return - * - 0: Success. - * - < 0: Failure. - * - -2(ERR_INVALID_ARGUMENT), if `userId` is invalid. - */ - virtual int subscribeVideo(user_id_t userId, - const VideoSubscriptionOptions &subscriptionOptions, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Subscribes to the video of all remote users in the channel. - * - * This method also automatically subscribes to the video of any subsequent remote user. - * - * @param subscriptionOptions The reference to the video subscription options: \ref agora::rtc::VideoSubscriptionOptions "VideoSubscriptionOptions". - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int subscribeAllVideo(const VideoSubscriptionOptions &subscriptionOptions, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Stops subscribing to the video of a specified remote user in the channel. - * - * @param userId The ID of the user whose video you want to stop subscribing to. - * @return - * - 0: Success. - * - < 0: Failure. - * - -2(ERR_INVALID_ARGUMENT), if `userId` is invalid. - */ - virtual int unsubscribeVideo(user_id_t userId, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Stops subscribing to the video of all remote users in the channel. - * - * This method automatically stops subscribing to the video of any subsequent user, unless you explicitly - * call \ref subscribeVideo "subscribeVideo" or \ref subscribeAllVideo "subscribeAllVideo". - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unsubscribeAllVideo(aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Sets the time interval and the volume smoothing factor of the \ref agora::rtc::ILocalUserObserver::onAudioVolumeIndication "onAudioVolumeIndication" callback. - * - * By default, the SDK triggers the `onAudioVolumeIndication` - * callback once every 500 ms, with a smoothing factor of 3. - * - * @param intervalInMS Sets the time interval(ms) between two consecutive volume indications. The default - * value is 500. - * - ≤ 10: Disables the volume indication. - * - > 10: The time interval (ms) between two consecutive callbacks. - * - * @param smooth The smoothing factor that sets the sensitivity of the audio volume indicator. - * The value range is [0,10]. The greater the value, the more sensitive the indicator.The default value is 3. - * - * @return - * - 0: Success. - * - < 0: Failure. - * - -2(ERR_INVALID_ARGUMENT), if `intervalInMS` or `smooth` is out of range. - */ - virtual int setAudioVolumeIndicationParameters(int intervalInMS, int smooth, bool reportVad, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Registers a local user observer object. - * - * You need to implement the \ref agora::rtc::ILocalUserObserver "ILocalUserObserver" class in this method. Once registered, the - * ILocalUserObserver receives events of the \ref agora::rtc::ILocalUser "ILocalUser" object. - * - * @param observer The pointer to the `ILocalUserObserver` object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerLocalUserObserver( - ILocalUserObserver* observer, - void(*safeDeleter)(ILocalUserObserver*) = NULL, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Releases the \ref agora::rtc::ILocalUserObserver "ILocalUserObserver" object. - * - * @param observer The pointer to the `ILocalUserObserver` object that you want to release. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unregisterLocalUserObserver(ILocalUserObserver* observer) = 0; - - /** - * Gets the media control packet sender. - * - * @return - * - The pointer to the media control packet sender IMediaControlPacketSender: Success. - * - A null pointer: Failure. - */ - virtual IMediaControlPacketSender* getMediaControlPacketSender() = 0; - - /** - * Registers a media control packet receiver. - * - * You need to implement the `IMediaControlPacketReceiver` class in this method. Once you successfully - * register the media control packet receiver, the SDK triggers the \ref agora::rtc::IMediaControlPacketReceiver::onMediaControlPacketReceived "onMediaControlPacketReceived" - * callback when it receives the media control packet. - * - * @param ctrlPacketReceiver The pointer to the IMediaControlPacketReceiver object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerMediaControlPacketReceiver(IMediaControlPacketReceiver* ctrlPacketReceiver, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Releases the media control packet receiver. - * @param ctrlPacketReceiver The pointer to the `IMediaControlPacketReceiver` object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unregisterMediaControlPacketReceiver(IMediaControlPacketReceiver* ctrlPacketReceiver) = 0; - - /** - * Sends intra-frame request to the broadcaster with a specified uid. - * - * The local user receives the `onIntraRequestReceived` callback when the broadcaster receives the request. - * - * @param userId The user ID of the target broadcaster . - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int sendIntraRequest(user_id_t userId, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Set local audio filterable by topn - * - * The local user receives the `onIntraRequestReceived` callback when the broadcaster receives the request. - * - * @param userId The user ID of the target broadcaster . - * @return - * - 0: Success. - * - < 0: Failure. - */ - - virtual int setAudioFilterable(bool filterable, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - -/** - * Enable / Disable specified audio filter - * @param userId The ID of the remote user - * @param id id of the filter - * @param enable enable / disable the filter with given id - * @return - * - 0: success - * - <0: failure - */ - virtual int enableRemoteAudioTrackFilter(user_id_t userId, const char* id, bool enable, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * set the properties of the specified audio filter - * @param userId The ID of the remote user - * @param id id of the filter - * @param key key of the property - * @param jsonValue json str value of the property - * @return - * - 0: success - * - <0: failure - */ - virtual int setRemoteAudioTrackFilterProperty(user_id_t userId, const char* id, const char* key, const char* jsonValue, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * get the properties of the specified audio filter - * @param userId The ID of the remote user - * @param id id of the filter - * @param key key of the property - * @param jsonValue json str value of the property - * @param bufSize max length of the json value buffer - * @return - * - 0: success - * - <0: failure - */ - virtual int getRemoteAudioTrackFilterProperty(user_id_t userId, const char* id, const char* key, char* jsonValue, size_t bufSize) = 0; - /** - * Publishes a local data channel to the channel. - * - * @param channel The data stream to be published. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int publishDataChannel(agora_refptr channel, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Stops publishing the data channel to the channel. - * - * @param channel The data channel that you want to stop publishing. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unpublishDataChannel(agora_refptr channel, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Subscribes to a specified data channel of a specified remote user in channel. - * - * @param userId The ID of the remote user whose data channel you want to subscribe to. - * @param channelId The ID of the data channel that you want to subscribe to. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int subscribeDataChannel(user_id_t userId, int channelId, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Stops subscribing to the data channel of a specified remote user in the channel. - * - * @param userId The ID of the remote user whose data channel you want to stop subscribing to. - * @param channelId The ID of the data channel that you want to stop subscribing to. - * @return - * - 0: Success. - * - < 0: Failure. - * - -2(ERR_INVALID_ARGUMENT), if no such user exists or `userId` is invalid. - */ - virtual int unsubscribeDataChannel(user_id_t userId, int channelId, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Registers an data channel observer. - * - * You need to implement the `IDataChannelObserver` class in this method - * - * @param observer A pointer to the data channel observer: - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerDataChannelObserver(IDataChannelObserver * observer, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Releases the data channel observer. - * - * @param observer The pointer to the data channel observer - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unregisterDataChannelObserver(IDataChannelObserver * observer) = 0; - /** - * set the profile of audio noise suppression module - * - * @param NsEnable enable ns or not - * @param NsMode type of ns - * @param NsLevel level of the suppression - * @param NsDelay algorithm delay - * @return - * - 0: success - * - <0: failure - */ - virtual int SetAudioNsMode(bool NsEnable, NS_MODE NsMode, NS_LEVEL NsLevel, NS_DELAY NsDelay, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * enable the mix track that mix special track - * - * @param track The special mixed audio track. - * @param enalble Action of start mixing this user's audio. - * @param MixLocal Mix publish stream. - * @param MixRemote Mix remote stream. - * @return - * - 0: success - * - <0: failure - */ - virtual int EnableLocalMixedAudioTrack(agora_refptr& track, bool enable, bool MixLocal, bool MixRemote, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Trigger data channel update callback with all data channel infos. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int takeDataChannelSnapshot(aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * send audio metadata - * - * @param metadata The pointer of metadata - * @param length Size of metadata - * @return - * - 0: success - * - <0: failure - * @technical preview - */ - virtual int sendAudioMetadata(const char* metadata, size_t length, aosl_ref_t ares = AOSL_REF_INVALID) = 0; -}; - -/** - * The definition of the AudioVolumeInformation struct. - */ -struct AudioVolumeInformation { - /** - * User ID of the speaker. - */ - user_id_t userId; - - /** - * The volume of the speaker that ranges from 0 to 255. - */ - unsigned int volume; - - /* - * The activity status of remote users - */ - unsigned int vad; - - /** - * Voice pitch frequency in Hz - */ - double voicePitch; - - AudioVolumeInformation() : userId(NULL), volume(0), vad(0), voicePitch(0.0) {} -}; - -/** - * The `ILocalUserObserver` class. - */ -class ILocalUserObserver { - public: - virtual ~ILocalUserObserver() {} - - virtual void onAudioTrackPublishStart(agora_refptr audioTrack) = 0; - /** - * Occurs when the first packet of the local audio track is sent, indicating that the local audio track - * is successfully published. - * - * @param audioTrack The pointer to \ref agora::rtc::ILocalAudioTrack "ILocalAudioTrack". - */ - virtual void onAudioTrackPublishSuccess(agora_refptr audioTrack) = 0; - - virtual void onAudioTrackUnpublished(agora_refptr audioTrack) = 0; - - /** - * Occurs when a local audio track fails to be published. - * - * @param audioTrack The pointer to `ILocalAudioTrack`. - * @param error The error information: #ERROR_CODE_TYPE. - */ - virtual void onAudioTrackPublicationFailure(agora_refptr audioTrack, - ERROR_CODE_TYPE error) = 0; - - /** - * Reports the statistics of a local audio track. - * - * @param stats The reference to the statistics of the local audio track. - */ - virtual void onLocalAudioTrackStatistics(const LocalAudioStats& stats) = 0; - /** - * Reports the statistics of a remote audio track. - * - * @param audioTrack The pointer to `IRemoteAudioTrack`. - * @param stats The statistics of the remote audio track. - */ - virtual void onRemoteAudioTrackStatistics(agora_refptr audioTrack, const RemoteAudioTrackStats& stats) = 0; - /** - * Occurs when the first remote audio frame is received. - * - * This callback indicates that the local user has subscribed to a specified remote audio track, and the first - * frame of this audio track has been received. - * - * @param userId The ID of the remote user whose audio frame is received. - * @param audioTrack The pointer to `IRemoteAudioTrack`. - */ - virtual void onUserAudioTrackSubscribed(user_id_t userId, - agora_refptr audioTrack) = 0; - - /** - * Occurs when the state of a remote audio track changes. - * - * @param userId The ID of the remote user whose audio track state has changed. - * @param audioTrack The pointer to `IRemoteAudioTrack`. - * @param state The current state of the audio track. - * @param reason The reason for the state change. - * @param elapsed The time (ms) since the user connects to an Agora channel. - */ - virtual void onUserAudioTrackStateChanged(user_id_t userId, - agora_refptr audioTrack, - REMOTE_AUDIO_STATE state, - REMOTE_AUDIO_STATE_REASON reason, - int elapsed) = 0; - - virtual void onVideoTrackPublishStart(agora_refptr videoTrack) = 0; - /** - * Occurs when the first packet of a local video track is sent, indicating that the local video track - * is successfully published. - * @param videoTrack The pointer to `ILocalVideoTrack`. - */ - virtual void onVideoTrackPublishSuccess(agora_refptr videoTrack) = 0; - - /** - * Occurs when a local video track fails to be published. - * - * @param videoTrack The pointer to `ILocalVideoTrack`. - * @param error The error information: #ERROR_CODE_TYPE. - */ - virtual void onVideoTrackPublicationFailure(agora_refptr videoTrack, - ERROR_CODE_TYPE error) = 0; - - virtual void onVideoTrackUnpublished(agora_refptr videoTrack) = 0; - /** - * Occurs when the state of a local video track changes. - * @note - * When you receive error from this callback, the corresponding track is in error state. - * To make the track recover from error state, we highly recommend that you disable the track and - * try re-enabling it again. - * - * @param videoTrack The pointer to `ILocalVideoTrack`. - * @param state The state of the local video track. - * @param reason The error information. - */ - virtual void onLocalVideoTrackStateChanged(agora_refptr videoTrack, - LOCAL_VIDEO_STREAM_STATE state, - LOCAL_VIDEO_STREAM_REASON reason) = 0; - - /** - * Reports the statistics of a local video track. - * - * @param videoTrack The pointer to `ILocalVideoTrack`. - * @param stats The statistics of the local video track. - */ - virtual void onLocalVideoTrackStatistics(agora_refptr videoTrack, - const LocalVideoTrackStats& stats) = 0; - - /** - * Occurs when the first remote video frame is received. - * - * This callback indicates that the local user has subscribed to a specified remote video track, and - * the first frame of this video track has been received. - * - * @param userId The ID of the remote user whose video frame is received. - * @param trackInfo The information of the remote video track. - * @param videoTrack The pointer to `IRemoteVideoTrack`. - */ - virtual void onUserVideoTrackSubscribed(user_id_t userId, const VideoTrackInfo& trackInfo, - agora_refptr videoTrack) = 0; - - /** - * Occurs when the state of a remote video track changes. - * - * @param userId the ID of the remote user whose video track state has changed. - * @param videoTrack The pointer to `IRemoteVideoTrack`. - * @param state The current state of the video track. - * @param reason The reason for the state change. - * @param elapsed The time (ms) since the user connects to an Agora channel. - */ - virtual void onUserVideoTrackStateChanged(user_id_t userId, - agora_refptr videoTrack, - REMOTE_VIDEO_STATE state, - REMOTE_VIDEO_STATE_REASON reason, - int elapsed) = 0; - - /** - * Occurs when the first remote video frame is rendered. - * - * @param userId the ID of the remote user. - * @param width Width (px) of the video frame. - * @param height Height (px) of the video stream. - * @param elapsed The time (ms) since the user connects to an Agora channel. - */ - virtual void onFirstRemoteVideoFrameRendered(user_id_t userId, int width, - int height, int elapsed) = 0; - - - /** - * Reports the statistics of a remote video track. - * - * @param videoTrack The pointer to `IRemoteVideoTrack`. - * @param stats The statistics of the remote video track. - */ - virtual void onRemoteVideoTrackStatistics(agora_refptr videoTrack, - const RemoteVideoTrackStats& stats) = 0; - - /** - * Reports which users are speaking, the speakers' volumes, and whether the local user is speaking. - * - * This callback reports the IDs and volumes of the loudest speakers at the moment in the channel, - * and whether the local user is speaking. - * - * You can set the time interval of this callback using \ref ILocalUser::setAudioVolumeIndicationParameters "setAudioVolumeIndicationParameters". - * - * The SDK triggers two `onAudioVolumeIndication` callbacks at one time, one reporting the - * volume information of the local user and the other reporting the volume information of all remote users. - * - * @note - * - To detect whether the local user is speaking, set `report_vad` in `enableAudioVolumeIndication` to `true`. - * - * @param speakers The pointer to \ref agora::rtc::AudioVolumeInformation "AudioVolumeInformation", which is an array containing the user ID and volume information for each speaker. - * - In the local user's callback, this array contains the following members: - * - `uid`, which is always `0` - * - `volume`, which reports the sum of the voice volume and the audio-mixing volume of the local user - * - `vad`, which reports whether the local user is speaking - * - In the remote users' callback, this array contains the following members: - * - `uid`, which is the UID of each remote speaker - * - `volume`, which reports the sum of the voice volume and the audio-mixing volume of each remote speaker. - * - `vad`, which is always `0` - * An empty `speakers` array in the callback indicates that no remote user is speaking at the moment. - * @param speakerNumber The total number of the speakers. - * @param totalVolume The total volume after audio mixing. The value ranges between 0 (lowest volume) and 255 (highest volume). - * - In the local user's callback, `totalVolume` is the sum of the voice volume and the audio-mixing volume of the local user. - * - In the remote speakers' callback, `totalVolume` is the sum of the voice volume and the audio-mixing volume of all remote speakers. - */ - virtual void onAudioVolumeIndication(const AudioVolumeInformation* speakers, unsigned int speakerNumber, - int totalVolume) = 0; - - /** - * Occurs when an active speaker is detected. - * - * You can add relative functions on your app, for example, the active speaker, once detected, - * will have the portrait zoomed in. - * - * @note - * - The active speaker means the user ID of the speaker who speaks at the highest volume during a - * certain period of time. - * - * @param userId The ID of the active speaker. A `userId` of `0` means the local user. - */ - virtual void onActiveSpeaker(user_id_t userId) = 0; - - /** - * Occurs when the audio subscribe state changed. - * - * @param channel The channel name of user joined. - * @param userId The remote string user ID that is subscribed to. - * @param oldState The old state of the audio stream subscribe : #STREAM_SUBSCRIBE_STATE. - * @param newState The new state of the audio stream subscribe : #STREAM_SUBSCRIBE_STATE. - * @param elapseSinceLastState The time elapsed (ms) from the old state to the new state. - */ - virtual void onAudioSubscribeStateChanged(const char* channel, user_id_t userId, STREAM_SUBSCRIBE_STATE oldState, STREAM_SUBSCRIBE_STATE newState, int elapseSinceLastState) = 0; - - /** - * Occurs when the video subscribe state changed. - * - * @param channel The channel name of user joined. - * @param userId The remote string user ID that is subscribed to. - * @param oldState The old state of the video stream subscribe : #STREAM_SUBSCRIBE_STATE. - * @param newState The new state of the video stream subscribe : #STREAM_SUBSCRIBE_STATE. - * @param elapseSinceLastState The time elapsed (ms) from the old state to the new state. - */ - virtual void onVideoSubscribeStateChanged(const char* channel, user_id_t userId, STREAM_SUBSCRIBE_STATE oldState, STREAM_SUBSCRIBE_STATE newState, int elapseSinceLastState) = 0; - - /** - * Occurs when the audio publish state changed. - * - * @param channel The channel name of user joined. - * @param oldState The old state of the audio stream publish : #STREAM_PUBLISH_STATE. - * @param newState The new state of the audio stream publish : #STREAM_PUBLISH_STATE. - * @param elapseSinceLastState The time elapsed (ms) from the old state to the new state. - */ - virtual void onAudioPublishStateChanged(const char* channel, STREAM_PUBLISH_STATE oldState, STREAM_PUBLISH_STATE newState, int elapseSinceLastState) = 0; - - /** - * Occurs when the video publish state changed. - * - * @param channel The channel name of user joined. - * @param oldState The old state of the video stream publish : #STREAM_PUBLISH_STATE. - * @param newState The new state of the video stream publish : #STREAM_PUBLISH_STATE. - * @param elapseSinceLastState The time elapsed (ms) from the old state to the new state. - */ - virtual void onVideoPublishStateChanged(const char* channel, STREAM_PUBLISH_STATE oldState, STREAM_PUBLISH_STATE newState, int elapseSinceLastState) = 0; - - /** Occurs when the first remote audio frame is received. - * - * @param userId ID of the remote user. - * @param isFallbackOrRecover Whether the remotely subscribed media stream - * falls back to audio-only or switches back to the video: - * - true: The remotely subscribed media stream falls back to audio-only - * due to poor network conditions. - * - false: The remotely subscribed media stream switches back to the - * video stream after the network conditions improved. - **/ - virtual void onRemoteSubscribeFallbackToAudioOnly(user_id_t userId, bool isFallbackOrRecover) { - (void)userId; - (void)isFallbackOrRecover; - } - - /** Occurs when the first remote audio frame is received. - * - * @param userId ID of the remote user. - * @param elapsed The time (ms) since the user connects to an Agora channel. - **/ - virtual void onFirstRemoteAudioFrame(user_id_t userId, int elapsed) = 0; - - /** - * Occurs when the SDK decodes the first remote audio frame for playback. - * - * @param uid User ID of the remote user sending the audio stream. - * @param elapsed The time (ms) since the user connects to an Agora channel. - */ - virtual void onFirstRemoteAudioDecoded(user_id_t userId, int elapsed) = 0; - - /** - * Occurs when the first remote video frame is rendered. - * The SDK triggers this callback when the first frame of the remote video is displayed in the user's video window. The application can get the time elapsed from a user joining the channel until the first video frame is displayed. - * - * @param userId ID of the remote user. - * @param width Width (px) of the video frame. - * @param height Height (px) of the video stream. - * @param elapsed Time elapsed (ms) from the local user calling the \ref IRtcEngine::joinChannel "joinChannel" method until the SDK triggers this callback. - */ - virtual void onFirstRemoteVideoFrame(user_id_t userId, int width, int height, int elapsed) = 0; - - /** - * Occurs when the SDK decodes the first remote video frame for playback. - * - * @param userId ID of the remote user. - * @param width Width (px) of the video stream. - * @param height Height (px) of the video stream. - * @param elapsed The time (ms) since the user connects to an Agora channel. - */ - virtual void onFirstRemoteVideoDecoded(user_id_t userId, int width, int height, int elapsed) = 0; - - /** - * The local or remote video size or rotation changed. - * - * @param uid User ID of the user whose video size or rotation has changed. - * @param width Width (pixels) of the video stream. - * @param height Height (pixels) of the video stream. - * @param rotation Rotation [0 to 360). - */ - virtual void onVideoSizeChanged(user_id_t userId, int width, int height, int rotation) = 0; - - /** - * The audio metadata received. - * - * @param userId ID of the remote user. - * @param metadata The pointer of metadata - * @param length Size of metadata - * @technical preview - */ - virtual void onAudioMetadataReceived(user_id_t userId, const char* metadata, size_t length) { - (void)userId; - (void)metadata; - (void)length; - } - - /** - * The media information of a specified user. - */ - enum USER_MEDIA_INFO { - /** - * 0: The user has muted the audio. - */ - USER_MEDIA_INFO_MUTE_AUDIO = 0, - /** - * 1: The user has muted the video. - */ - USER_MEDIA_INFO_MUTE_VIDEO = 1, - /** - * 4: The user has enabled the video, which includes video capturing and encoding. - */ - USER_MEDIA_INFO_ENABLE_VIDEO = 4, - /** - * 8: The user has enabled the local video capturing. - */ - USER_MEDIA_INFO_ENABLE_LOCAL_VIDEO = 8, - }; - - /** - * Occurs when the user media information is updated. - * - * - * @param userId The ID of the user. - * @param msg The media information of the user. See #USER_MEDIA_INFO. - * @param val Whether the user is muted. - */ - virtual void onUserInfoUpdated(user_id_t userId, USER_MEDIA_INFO msg, bool val) { - (void)userId; - (void)msg; - (void)val; - } - - /** - * Occurs when the intra request is received from a remote user. - * - * The method notifies the local user to encode a key frame. - * - */ - virtual void onIntraRequestReceived() {} - - /** - * datastream from this connection. - */ - virtual void onStreamMessage(user_id_t userId, int streamId, const char* data, size_t length) {} - - /** - * Occurs when the remote user state is updated. - * @param uid The uid of the remote user. - * @param state The remote user state.Just & #REMOTE_USER_STATE - */ - virtual void onUserStateChanged(user_id_t userId, uint32_t state){} - - virtual void onVideoRenderingTracingResult(user_id_t user_id, MEDIA_TRACE_EVENT currentState, VideoRenderingTracingInfo tracingInfo) {} -}; - -class IVideoFrameObserver2 { - public: - /** - * Occurs each time the player receives a video frame. - * - * After registering the video frame observer, - * the callback occurs each time receives a video frame to report the detailed information of the video frame. - * @param channelId The channel name - * @param remoteUid ID of the remote user. - * @param frame The detailed information of the video frame. See {@link VideoFrame}. - */ - virtual void onFrame(const char* channelId, user_id_t remoteUid, const media::base::VideoFrame* frame) = 0; - - virtual ~IVideoFrameObserver2() {} -}; - -} // namespace rtc -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraMediaNode.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraMediaNode.h deleted file mode 100644 index 0b2bc0152..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraMediaNode.h +++ /dev/null @@ -1,944 +0,0 @@ -#pragma once -#include "AgoraRefPtr.h" -#include "AgoraBase.h" -#include "IAgoraLog.h" -#include "NGIAgoraVideoFrame.h" -#include "AgoraExtensionVersion.h" -#include - -#ifndef OPTIONAL_PROCESSRESULT_SPECIFIER -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) -#define OPTIONAL_PROCESSRESULT_SPECIFIER ProcessResult:: -#else -#define OPTIONAL_PROCESSRESULT_SPECIFIER -#endif -#endif - -namespace webrtc { -struct AudioFrameHandleInfo; -} // namespace webrtc - -namespace agora { -namespace rtc { -/** - * The `IAudioFilterBase` class is the base class for audio filters. You can use this class to implement your own filter - * and add it to an audio track. - */ -class IAudioFilterBase : public RefCountInterface { - public: - // Return false if filter decide to drop the frame. - // Implementation should not change samples_per_channel_/sample_rate_hz_/num_channels_ - // Implementation should just adapt data of audio frame. - /** - * Adapts the audio frame. - * @param inAudioFrame The reference to the audio frame that you want to adapt. - * @param adaptedFrame The reference to the adapted audio frame. - * @return - * - `true`: Success. - * - `false`: Failure. For example, the IAudiofilter object drops the audio frame. - */ - virtual bool adaptAudioFrame(const media::base::AudioPcmFrame& inAudioFrame, - media::base::AudioPcmFrame& adaptedFrame) = 0; - - /** - * Get the sample rate supported by the audio filter, the framework will resample - * the audio data and then pass it to the audio filter. - * @return - * - 0: Audio data will not be resampled. - * - > 0: Audio data will be resampled to this sample rate. - */ - virtual int getPreferredSampleRate() = 0; - - /** - * Get the channel number supported by the audio filter, the framework will resample - * the audio data and then pass it to the audio filter. If the user does not - * overwrite, resampling will not be done by default. - * @return - * - 0: Audio data will not be resampled. - * - > 0: Audio data will be resampled to this sample rate. - */ - virtual int getPreferredChannelNumbers() = 0; - - protected: - ~IAudioFilterBase() {} -}; - -/** - * The `IAudioFilter` class. - * - * This class is the intermediate node for audio, which reads audio frames from the underlying - * pipeline and writes audio frames back after adaptation. - */ -class IAudioFilter : public IAudioFilterBase { - public: - /** - * Enables or disables the audio filter. - * @param enable Whether to enable the audio filter: - * - `true`: Enable the audio filter. - * - `false`: Do not enable the audio filter. - */ - virtual void setEnabled(bool enable) = 0; - /** - * Checks whether the audio filter is enabled. - * @return - * - `true`: The audio filter is enabled. - * - `false`: The audio filter is not enabled. - */ - virtual bool isEnabled() const = 0; - /** - * Sets a private property in the `IAudioFilter` class. - * - * @param key The pointer to the property name. - * @param buf The pointer to the buffer of this private property. - * @param buf_size The buffer size of this private property. - * @return - * - The actual size of the private property, if the method call succeeds. - * - -1, if the method call fails. - */ - virtual int setProperty(const char* key, const void* buf, int buf_size) = 0; - /** - * Gets a private property in the `IAudioFilter` class. - * - * @param name The pointer to the property name. - * @param buf The pointer to the buffer of this private property. - * @param buf_size The buffer size of this private property. - * @return - * - The actual size of the private property, if the method call succeeds. - * - -1, if the method call fails. - */ - virtual int getProperty(const char* key, void* buf, int buf_size) const = 0; - /** - * Gets the name of the `IAudioFilter` class. - * - * @return - * - The name of the audio filter, if the method call succeeds. - * - An empty string, if the method call fails. - */ - virtual const char * getName() const = 0; - - /** - * Get the sample rate supported by the audio filter, the framework will resample - * the audio data and then pass it to the audio filter. If the user does not - * overwrite, resampling will not be done by default. - * @return - * - 0: Audio data will not be resampled. - * - > 0: Audio data will be resampled to this sample rate. - */ - virtual int getPreferredSampleRate() { return 0; }; - - /** - * Get the channel number supported by the audio filter, the framework will resample - * the audio data and then pass it to the audio filter. If the user does not - * overwrite, resampling will not be done by default. - * @return - * - 0: Audio data will not be resampled. - * - > 0: Audio data will be resampled to this sample rate. - */ - virtual int getPreferredChannelNumbers() { return 0; }; - - protected: - ~IAudioFilter() {} -}; - -class IAudioFilterV2 : public IAudioFilter { -public: - class Control : public RefCountInterface { - public: - /** - * @brief Post an event and notify the end users. - * @param key '\0' ended string that describes the key of the event - * @param value '\0' ended string that describes the value of the event - */ - virtual int postEvent(const char* key, const char* value) = 0; - /** - * @brief print log to the SDK. - * @param level Log level @ref agora::commons::LOG_LEVEL - * @param format log formatter string - * @param ... variadic arguments - */ - virtual void printLog(commons::LOG_LEVEL level, const char* format, ...) = 0; - }; -public: - /** - * @brief AgoraSDK set IAudioFilterV2::Control to filter - * @param control IAudioFilterV2::Control - */ - virtual void setExtensionControl(agora::agora_refptr control) = 0; -}; - -/** - * The `IVideoFilterBase` class is the base class for video filters. You can use this class to implement your own filter - * and add the filter to a video track. - */ -class IVideoFilterBase : public RefCountInterface { - public: - /** - * Adapts the video frame. - * - * @param capturedFrame The reference to the captured video frame that you want to adapt. - * @param adaptedFrame The reference to the adapted video frame. - * - * @return - * - `true`: Success. - * - `false`: Failure, if, for example, the `IVideofilter` object drops the video frame. - */ - virtual bool adaptVideoFrame(const media::base::VideoFrame& capturedFrame, - media::base::VideoFrame& adaptedFrame) = 0; -}; - -// TODO(Bob): private inherit? -/** - * The IVideoFilter class. - * - * This class is the intermediate node for video, which contains both the video source and the video - * sink. It reads video frames from the underlying video pipeline and writes video frames back after - * adaptation. - */ -class IVideoFilter : public IVideoFilterBase { - public: - /** - * Enables or disables the video filter. - * @param enable Whether to enable the video filter: - * - `true`: (Default) Enable the video filter. - * - `false`: Do not enable the video filter. If the filter is disabled, frames will be passed without - * adaption. - */ - virtual void setEnabled(bool enable) {} - /** - * Checks whether the video filter is enabled. - * @return - * - `true`: The video filter is enabled. - * - `false`: The video filter is not enabled. - */ - virtual bool isEnabled() { return true; } - /** - * Sets a private property in the `IVideoFilter` class. - * - * @param key The pointer to the property name. - * @param buf The pointer to the buffer of this private property. - * @param buf_size The buffer size of this private property. - * @return - * - The actual size of the private property, if the method call succeeds. - * - -1, if the method call fails. - */ - virtual int setProperty(const char* key, const void* buf, size_t buf_size) { return -1; } - /** - * Gets a private property in the IVideoFilter class. - * - * @param key The pointer to the property name. - * @param buf The pointer to the buffer of this private property. - * @param buf_size The buffer size of this private property. - * @return - * - The actual size of the private property, if the method call succeeds. - * - -1, if the method call fails. - */ - virtual int getProperty(const char* key, void* buf, size_t buf_size) { return -1; } - /** - * This function is invoked right before data stream starts. - * Custom filter can override this function for initialization. - * @return - * - `true`: The initialization succeeds. - * - `false`: The initialization fails. - */ - virtual bool onDataStreamWillStart() { return true; } - /** - * This function is invoked right before data stream stops. - * Custom filter can override this function for deinitialization. - */ - virtual void onDataStreamWillStop() { } - /** - * This function indicates if the filter is for internal use. - * @note Do not override this function. - * @return - * - `true`: The filter is implemented by external users. - * - `false`: The filter is implemented by internal users. - */ - virtual bool isExternal() { return true; } - /** - * This function indicates if the filter is implemented by third-party providers. - * @note Do not override this function. - * @return - * - `true`: The filter is implemented by third-party providers. - * - `false`: otherwise. - */ - virtual bool isExtensionFilter() { return false; } -}; - -/** - * The IExtensionVideoFilter class. - * - * This class defines the interfaces that a external video extension provider can implement - * so as to be loaded by SDK as an "3rd party extension" for video pre- or post- processing. - */ -class IExtensionVideoFilter : public IVideoFilter { - public: - enum ProcessMode { - kSync, // Indicates that video frame data will be exchanged via "adaptVideoFrame" - kAsync, // Indicates that video frame data will be exchanged via "pendVideoFrame" & "deliverVideoFrame" - }; - - enum ProcessResult { - kSuccess, // Video frame data is successfully processed - kBypass, // Video frame data should bypass the current filter and flow to its successsors - kDrop, // Video Frame data should be discarded - }; - - /** - * The IExtensionVideoFilter::Control class. - * - * This class defines the interfaces that the extension filter can leverage to interact with the SDK. - * The "IExtensionVideoFilter::Control" object will be passed to the filter when SDK invoke the filter's - * "start" interface. - */ - class Control : public RefCountInterface { - public: - /** - * @brief Filter can invoke this function to deliver the processed frame to SDK if the Process Mode is - * designated as "kAsync" by the filter via "getProcessMode". - * @param frame the processed video frame - * @return see @ref ProcessResult - */ - virtual ProcessResult deliverVideoFrame(agora::agora_refptr frame) = 0; - /** - * @brief Filter can invoke this function to get the IVideoFrameMemoryPool object if a new IVideoFrame - * data object is needed. - */ - virtual agora::agora_refptr getMemoryPool() = 0; - /** - * @brief Post an event and notify the end users. - * @param key '\0' ended string that describes the key of the event - * @param value '\0' ended string that describes the value of the event - */ - virtual int postEvent(const char* key, const char* value) = 0; - /** - * @brief print log to the SDK. - * @param level Log level @ref agora::commons::LOG_LEVEL - * @param format log formatter string - * @param ... variadic arguments - */ - virtual void printLog(commons::LOG_LEVEL level, const char* format, ...) = 0; - /** - * @brief Ask SDK to disable the current filter if a fatal error is detected - * @param error error code - * @param msg error message - */ - virtual void disableMe(int error, const char* msg) = 0; - }; - - /** - * @brief SDK will invoke this API first to get the filter's requested process mode @ref ProcessMode - * @param mode [out] filter assign its desired the process mode @ref ProcessMode - * @param independent_thread deprecated. SDK will ignore this parameter. - * @note If the filter implementation is not thread sensitive, we recommend to set the boolean to "false" to reduce thread context - * switching. - */ - virtual void getProcessMode(ProcessMode& mode, bool& independent_thread) = 0; - - /** - * @brief SDK will invoke this API before feeding video frame data to the filter. Filter can perform its initialization/preparation job - * in this step. - * - * @param control object to @ref IExtensionFilter::Control that pass to the filter which can be used for future interaction with the SDK - * @return error code - */ - virtual int start(agora::agora_refptr control) = 0; - /** - * @brief SDK will invoke this API when the data stream is about to stop. Filter can perform cleanup jobs in this step - * - * @return error code - */ - virtual int stop() = 0; - /** - * @brief SDK will invoke this API every time before sending data to the filter. Filter can desigante the type @ref VideoFrameInfo::Type - * and format @ref MemPixelBuffer::Format of the next frame. SDK will then try to perform type / format conversion before sending data to - * the filter. - * - * @param type requested type of the next frame - * @param format requested formant of the next frame - */ - virtual void getVideoFormatWanted(VideoFrameData::Type& type, RawPixelBuffer::Format& format) = 0; - /** - * @brief SDK will invoke this API to send video frame to the filter if process mode is "Async". Filter invokes control's "deliverFrame" - * to send back the frame after processing. - * - * @param frame frame pending for processing - */ - virtual ProcessResult pendVideoFrame(agora::agora_refptr frame) { - return OPTIONAL_PROCESSRESULT_SPECIFIER kBypass; - } - /** - * @brief SDK will invoke this API to send video frame to the filter if process mode is "Sync". - * - * @param frame frame pending for processing - */ - virtual ProcessResult adaptVideoFrame(agora::agora_refptr in, agora::agora_refptr& out) { - return OPTIONAL_PROCESSRESULT_SPECIFIER kBypass; - } - /* Occurs each time needs to get rotation apply. - * - * @return Determines whether to rotate. - * - true: need to rotate. - * - false: no rotate. - */ - virtual bool getRotationApplied() { return false; } - - // NOTE: The following two interfaces should never be overriden! - virtual bool isExtensionFilter() { return true; } - virtual bool adaptVideoFrame( - const media::base::VideoFrame& capturedFrame, - media::base::VideoFrame& adaptedFrame) { - return -ERR_NOT_SUPPORTED; - } -}; - -class ILipSyncFilter : public RefCountInterface { - public: - enum ProcessResult { - kSuccess, // Video frame data is successfully processed - kBypass, // Video frame data should bypass the current filter and flow to its successsors - kDrop, // Video Frame data should be discarded - }; - - class Control : public RefCountInterface { - public: - /** - * @brief Post an event and notify the end users. - * @param key '\0' ended string that describes the key of the event - * @param value '\0' ended string that describes the value of the event - */ - virtual int postEvent(const char* key, const char* value) = 0; - /** - * @brief print log to the SDK. - * @param level Log level @ref agora::commons::LOG_LEVEL - * @param format log formatter string - * @param ... variadic arguments - */ - virtual void printLog(commons::LOG_LEVEL level, const char* format, ...) = 0; - /** - * @brief Ask SDK to disable the current filter if a fatal error is detected - * @param error error code - * @param msg error message - */ - virtual void disableMe(int error, const char* msg) = 0; - /** - * @brief report counter to the SDK. - * @param counter_id counter id - * @param value counter value - */ - virtual void ReportCounter(int32_t counter_id, int32_t value) = 0; - /** - * @brief get stats to the SDK. - * @param counter_id counter id - */ - virtual int GetStats(int32_t counter_id) = 0; - }; - - virtual int start(agora::agora_refptr control) = 0; - - virtual int stop() = 0; - - virtual int setProperty(const char* key, const void* buf, size_t buf_size) { return -1; } - /** - * Convert the audio frame to face info. - * @param inAudioFrame The reference to the audio frame that you want to convert. - * @param outFaceInfo The reference to the face info. - * @return see @ref ProcessResult - */ - virtual ProcessResult convertAudioFrameToFaceInfo(const agora::media::base::AudioPcmFrame& inAudioFrame, char* outFaceInfo) { - return kBypass; - } -}; - -/** - * The `IVideoSinkBase` class is the base class for the custom video sink. - */ -class IVideoSinkBase : public RefCountInterface { - public: - /** - * Sets a private property in the `IVideoFilter` class. - * - * @param key The pointer to the property name. - * @param buf The pointer to the buffer of this private property. - * @param buf_size The buffer size of this private property. - * @return - * - The actual size of the private property, if the method call succeeds. - * - -1, if the method call fails. - */ - virtual int setProperty(const char* key, const void* buf, int buf_size) { return -1; } - /** - * Gets a private property in the `IVideoFilter` class. - * - * @param key The pointer to the property name. - * @param buf The pointer to the buffer of this private property. - * @param buf_size The buffer size of this private property. - * @return - * - The actual size of the private property, if the method call succeeds. - * - -1, if the method call fails. - */ - virtual int getProperty(const char* key, void* buf, int buf_size) { return -1; } - /** - * Occurs when the `IVideoSinkBase` object receives the video frame. - * @param videoFrame The reference to the video frame. - */ - virtual int onFrame(const media::base::VideoFrame& videoFrame) = 0; - /** - * Used internally to distinguish between external and internal sinks. - * External application should not override this interface. - */ - virtual bool isExternalSink() { return true; } - /** - * This function is invoked right before data stream starts. - * Custom sink can override this function for initialization. - * @return - * - `true`, if initialization succeeds. - * - `false`, if initialization fails. - */ - virtual bool onDataStreamWillStart() { return true; } - /** - * This function is invoked right before data stream stops. - * Custom sink can override this function for deinitialization. - */ - virtual void onDataStreamWillStop() { } - /** - * Whether to mirror the video frame. - * @return - * - true: mirror the video frame. - * - false: do not mirror the video frame. - */ - virtual bool applyMirror() { return false; } - /** - * Whether to rotate the video frame. - * @return - * - true: rotate the video frame. - * - false: do not rotate the video frame. - */ - virtual bool applyRotation() { return false; } -}; - -class IMediaExtensionObserver : public RefCountInterface { -public: - virtual ~IMediaExtensionObserver() {} - virtual void onEventWithContext(const ExtensionContext& context, const char* key, const char* json_value) {} - virtual void onExtensionStoppedWithContext(const ExtensionContext& context) {} - virtual void onExtensionStartedWithContext(const ExtensionContext& context) {} - virtual void onExtensionErrorWithContext(const ExtensionContext& context, int error, const char* message) {} -}; - -/** - * The IAudioPcmDataSender class. - * - * In scenarios involving custom audio source, you can use the `IAudioPcmDataSender` class to send PCM audio data directly to the audio track. If the audio track is disabled, the sent audio data is automatically discarded. - */ -class IAudioPcmDataSender : public RefCountInterface { - public: - /** - * Sends the PCM audio data to the local audio track. - * - * @param audio_data The PCM audio data to be sent. - * @param samples_per_channel The number of audio samples in 10 ms for each audio channel. - * @param bytes_per_sample The number of bytes in each sample. - * @param number_of_channels The number of audio channels. - * @param sample_rate The sample rate (Hz). The minimum value is 8000. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int sendAudioPcmData( - const void* audio_data, uint32_t capture_timestamp, int64_t presentation_ms, - const size_t samples_per_channel, // for 10ms Data, number_of_samples * 100 = sample_rate - const agora::rtc::BYTES_PER_SAMPLE bytes_per_sample, // 2 - const size_t number_of_channels, - const uint32_t sample_rate, aosl_ref_t ares = AOSL_REF_INVALID) = 0; // sample_rate > 8000) - - protected: - ~IAudioPcmDataSender() {} -}; - -/** - * The `IAudioEncodedFrameSender` class. - * - * In scenarios involving custom audio source, you can use the `IAudioEncodedFrameSender` class to - * send encoded audio data directly to the audio track. If the track is disabled, the sent audio - * data will be automatically discarded. - */ -class IAudioEncodedFrameSender : public RefCountInterface { - public: - /** - * Sends the encoded audio frame to the local audio track. - * - * @param payload_data The pointer to the payload data. - * @param payload_size The payload size. - * @param audioFrameInfo The reference to the information of the audio frame: - * \ref agora::rtc::EncodedAudioFrameInfo "EncodedAudioFrameInfo". - * - * @return - * - `true`: Success. - * - `false`: Failure. - */ - virtual bool sendEncodedAudioFrame(const uint8_t* payload_data, size_t payload_size, - const EncodedAudioFrameInfo& audioFrameInfo, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - protected: - ~IAudioEncodedFrameSender() {} -}; - -class IAudioEncodedFrameReceiver { - public: - /** - * Occurs when the track receives an audio encodeed frame packet. - * - * @param packet The pointer to the audio packet. - * @param length The length of the packet. - * @param info The packet info. - * - */ - virtual bool onEncodedAudioFrameReceived ( - const uint8_t *packet, size_t length, const media::base::AudioEncodedFrameInfo& info) = 0; - - virtual ~IAudioEncodedFrameReceiver() {} -}; - -/** - * The IMediaPacketReceiver class. You can register a receiver in remote audio or video tracks to trigger - * callbacks when RTP/UDP packets are received. - */ -class IMediaPacketReceiver { - public: - /** - * Occurs when the track receives a media packet. - * - * @param packet The pointer to the media packet. - * @param length The length of the packet. - * @param options The packet info. - * - */ - virtual bool onMediaPacketReceived( - const uint8_t *packet, size_t length, const agora::media::base::PacketOptions& options) = 0; - - virtual ~IMediaPacketReceiver() {} -}; - -/** - * The IMediaControlPacketReceiver class. - * - * You can register a receiver in audio or video tracks to trigger callbacks - * when RTCP/UDP packets are received. - */ -class IMediaControlPacketReceiver { - public: - /** - * Occurs when the track receives media control packet. - * - * @param packet The pointer to the media packet. - * @param length The length of the packet. - * - */ - virtual bool onMediaControlPacketReceived(uid_t uid, const uint8_t *packet, size_t length) = 0; - - virtual ~IMediaControlPacketReceiver() {} -}; - -/** - * The `IMediaPacketSender` class. - * - * You can use the `IMediaPacketSender` class to create a LocalVideoTrack or LocalAudioTrack, - * and then send media packets directly to the track. The media packets are RTP/UDP packets that contain - * media payload. If the track is disabled, the packets will be automatically discarded. - */ -class IMediaPacketSender : public RefCountInterface { - public: - /** - * Sends the frame packet to the local track. - * - * @param packet The pointer to the packet. - * @param length The packet size. - * @param options The packet information: {@link media::base::PacketOptions PacketOptions}. - * - * @return - * - `true`: Success. - * - `false`: Failure. - */ - virtual int sendMediaPacket(const uint8_t *packet, size_t length, - const media::base::PacketOptions &options, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - protected: - ~IMediaPacketSender() {} -}; - -/** - * The `IMediaControlPacketSender` class. - * - * You can get the `IMediaControlPacketSender` class object from a video track or audio track, - * and then send media control packets directly. The media control packets are RTCP/UDP packets that contain - * media control payload. If the track is disabled, the packets will be automatically discarded. - */ -class IMediaControlPacketSender { - public: - /** - * Sends the media control packet to a specified user. - * Currently, we only support sending packets through video tracks. - * - * @param userId ID of the user to send the packet to. - * @param packet The pointer to the packet. - * @param length The packet size. - * - * @return - * - `true`: Success. - * - `false`: Failure. - */ - virtual int sendPeerMediaControlPacket(media::base::user_id_t userId, - const uint8_t *packet, - size_t length, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Sends the media transport control packet to all users. - * Currently, we only support sending packets through video tracks. - * @param packet The pointer to the packet. - * @param length The packet size. - * - * @return - * - `true`: Success. - * - `false`: Failure. - */ - virtual int sendBroadcastMediaControlPacket(const uint8_t *packet, size_t length, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - virtual ~IMediaControlPacketSender() {} -}; - -/** - * The `IAudioSinkBase` class is the base class for the audio sink. You can use this class to implement your own sink - * and add the sink to an audio track. - */ -class IAudioSinkBase : public RefCountInterface { - public: - /** Gets the audio frame. - * - * @param audioframe {@link media::base::AudioPcmFrame AudioPcmFrame} - * @return - * - `true`: Success. - * - `false`: Failure. - */ - virtual bool onAudioFrame(const media::base::AudioPcmFrame& audioFrame) = 0; - - protected: - ~IAudioSinkBase() {} -}; - -/** - * The `IVideoFrameSender` class. - * - * In scenarios involving custom video sources, you can use this class to send the video - * data directly to a video track. If the video track is disabled, the sent data will - * be automatically discarded. - */ -class IVideoFrameSender : public RefCountInterface { - public: - /** - * Sends the video frame to the video track. - * - * @param videoFrame The reference to the video frame to send. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int sendVideoFrame(const media::base::ExternalVideoFrame& videoFrame, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - protected: - ~IVideoFrameSender() {} -}; - -/** - * The `IVideoEncodedImageSender` class. - * - * In scenarios involving custom video sources, you can use this class to send the encoded video data - * directly to the video track. If the video track is disabled, the sent video image will be - * automatically discarded. - */ -class IVideoEncodedImageSender : public RefCountInterface { - public: - /** - * Sends the encoded video image to the video track. - * @param imageBuffer The video buffer. - * @param length The data length of the video data. - * @param videoEncodedFrameInfo The reference to the information of the encoded video frame: - * {@link EncodedVideoFrameInfo}. - * - * @return - * - `true`: Success. - * - `false`: Failure. - */ - virtual bool sendEncodedVideoImage(const uint8_t* imageBuffer, size_t length, - const EncodedVideoFrameInfo& videoEncodedFrameInfo, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - protected: - ~IVideoEncodedImageSender() {} -}; - -/** - * The IVideoBeautyFilter class. - */ -class IVideoBeautyFilter : public IVideoFilter { - public: - /** - * The video image enhancement options. - */ - struct BeautyOptions { - /** - * The lightening contrast level. - */ - enum LIGHTENING_CONTRAST_LEVEL { - /** - * 0: Low contrast level. - */ - LIGHTENING_CONTRAST_LOW = 0, - /** - * (Default) Normal contrast level. - */ - LIGHTENING_CONTRAST_NORMAL, - /** - * High contrast level. - */ - LIGHTENING_CONTRAST_HIGH - }; - - /** - * The contrast level, usually used with {@link lighteningLevel} to brighten the video: - * #LIGHTENING_CONTRAST_LEVEL. - */ - LIGHTENING_CONTRAST_LEVEL lighteningContrastLevel; - - /** - * The brightness level. The value ranges from 0.0 (original) to 1.0. - */ - float lighteningLevel; - - /** - * The sharpness level. The value ranges from 0.0 (original) to 1.0. This parameter is usually - * used to remove blemishes. - */ - float smoothnessLevel; - - /** - * The redness level. The value ranges from 0.0 (original) to 1.0. This parameter adjusts the - * red saturation level. - */ - float rednessLevel; - - BeautyOptions(LIGHTENING_CONTRAST_LEVEL contrastLevel, float lightening, float smoothness, - float redness) - : lighteningContrastLevel(contrastLevel), - lighteningLevel(lightening), - smoothnessLevel(smoothness), - rednessLevel(redness) {} - - BeautyOptions() - : lighteningContrastLevel(LIGHTENING_CONTRAST_NORMAL), - lighteningLevel(0), - smoothnessLevel(0), - rednessLevel(0) {} - }; - /** - * Sets the image enhancement options. - * @param enabled Whether to enable image enhancement. - * - `true`: Enable image enhancement. - * - `false`: Do not enable image enhancement. - * @param options The image enhancement options: BeautyOptions. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setBeautyEffectOptions(bool enabled, BeautyOptions options) = 0; -}; - -/** - * The `IVideoRenderer` class. - */ -class IVideoRenderer : public IVideoSinkBase { - public: - /** - * Sets the render mode. - * @param renderMode The video render mode. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setRenderMode(media::base::RENDER_MODE_TYPE renderMode, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Sets the render mode of the view. - * @param view the view to set render mode. - * @param renderMode The video render mode. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setRenderMode(void* view, media::base::RENDER_MODE_TYPE renderMode, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Sets whether to mirror the video. - * @param mirror Whether to mirror the video: - * - `true`: Mirror the video. - * - `false`: Do not mirror the video. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setMirror(bool mirror, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Sets whether to mirror the video. - * @param view the view to set mirror mode. - * @param mirror Whether to mirror the video: - * - `true`: Mirror the video. - * - `false`: Do not mirror the video. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setMirror(void* view, bool mirror, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Sets the video display window. - * @param view The pointer to the video display window. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setView(void* view, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Sets the video display window. - * @param view The pointer to the video display window. - * @param cropArea (Optional) Sets the relative location of the region to show. See Rectangle. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int addView(void* view, const Rectangle& cropArea, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Stops rendering the video view on the window. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unsetView(aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * remove rendering the video view on the window. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int removeView(void* view) = 0; -}; - -static const int kDeviceIdSize = 128; - -class IVideoTrack; -/** - * The `IVideoFrameTransceiver` class. - */ -class IVideoFrameTransceiver : public RefCountInterface { - public: - virtual int getTranscodingDelayMs() = 0; - virtual int addVideoTrack(agora_refptr track, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - virtual int removeVideoTrack(agora_refptr track, aosl_ref_t ares = AOSL_REF_INVALID) = 0; -}; - -} -} diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraMediaNodeFactory.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraMediaNodeFactory.h deleted file mode 100644 index 90806b543..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraMediaNodeFactory.h +++ /dev/null @@ -1,248 +0,0 @@ -// -// Agora SDK -// -// Copyright (c) 2019 Agora.io. All rights reserved. -// - -#pragma once // NOLINT(build/header_guard) - -#include "AgoraBase.h" -#include - -namespace agora { -namespace rtc { - -class IAudioPcmDataSender; -class IAudioEncodedFrameSender; -class IRemoteAudioMixerSource; -class ICameraCapturer; -class IScreenCapturer; -class IVideoMixerSource; -class IVideoFrameTransceiver; -class IVideoFrameSender; -class IVideoRenderer; -class IVideoFilter; -class IAudioFilter; -class IVideoSinkBase; -class IVideoEncodedImageSender; -class IMediaPlayerSource; -class IMediaPacketSender; -class IMediaStreamingSource; -class IScreenCapturer2; - - -/** - * The `IMediaNodeFactory` class. - */ -class IMediaNodeFactory : public RefCountInterface { - public: - /** - * Creates a PCM audio data sender. - * - * This method creates an `IAudioPcmDataSender` object, which can be used by \ref agora::base::IAgoraService::createCustomAudioTrack(agora_refptr< rtc::IAudioPcmDataSender > audioSource) "createCustomAudioTrack" to send PCM audio data. - * - * @return - * - The pointer to \ref agora::rtc::IAudioPcmDataSender "IAudioPcmDataSender": Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createAudioPcmDataSender() = 0; - - /** - * Creates an encoded audio data sender. - * - * This method creates an IAudioEncodedFrameSender object, which can be used by \ref agora::base::IAgoraService::createCustomAudioTrack(agora_refptr< rtc::IAudioEncodedFrameSender > audioSource, TMixMode mixMode) "createCustomAudioTrack" to send encoded audio data. - * - * @return - * - The pointer to IAudioEncodedFrameSender: Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createAudioEncodedFrameSender() = 0; - - /** - * Creates a camera capturer. - * - * Once a camera capturer object is created, you can use the video data captured by the camera as - * the custom video source. - * - * @return - * - The pointer to ICameraCapturer: Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createCameraCapturer() = 0; - -#if !defined(__ANDROID__) && !(defined(__APPLE__) && TARGET_OS_IPHONE) && !defined(__OHOS__) - /** - * Creates a screen capturer. - * - * Once a screen capturer object is created, you can use the screen video data as the custom video - * source. - * - * @return - * - The pointer to IScreenCapturer: Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createScreenCapturer() = 0; -#endif - - /** - * Creates a video mixer. - * - * Once a video mixer object is created, you can use the video mixer data as the custom video - * source. - * - * @return - * - The pointer to IVideoMixerSource: Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createVideoMixer() = 0; - - /** - * Creates a video transceiver. - * - * Once a video transceiver object is created, you can use the video transceiver data as the custom video - * source. - * - * @return - * - The pointer to IVideoFrameTransceiver: Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createVideoFrameTransceiver() = 0; - - /** - * Creates a video frame sender. - * - * This method creates an `IVideoFrameSender` object, which can be used by \ref agora::base::IAgoraService::createCustomVideoTrack(agora_refptr videoSource) "createCustomVideoTrack" to - * send the custom video data. - * - * @return - * - The pointer to \ref agora::rtc::IVideoFrameSender "IVideoFrameSender": Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createVideoFrameSender() = 0; - - /** - * Creates an encoded video image sender. - * - * This method creates an `IVideoEncodedImageSender` object, which can be used by \ref agora::base::IAgoraService::createCustomVideoTrack(agora_refptr videoSource, SenderOptions& options) "createCustomVideoTrack" to send the encoded video data. - * - * @return - * - The pointer to `IVideoEncodedImageSender`: Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createVideoEncodedImageSender() = 0; - - /** - * Creates a built-in video renderer. - * - * @param view The video window view. - * @return - * - The pointer to `IVideoRenderer`: Success. - * - A null pointer: Failure. - * - */ - virtual agora_refptr createVideoRenderer() = 0; - - /** - * Creates an audio filter for the extension. - * - * This method creates an `IAudioFilter` object, which can be used to filter the audio data from the - * inside extension. - * - * @param provider_name provider name string. - * @param extension_name extension name string. - * @return - * - The pointer to IAudioFilter: Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createAudioFilter(const char* provider_name, const char* extension_name) = 0; - - /** - * Creates a video filter for the extension. - * - * This method creates an `IVideoFilter` object, which can be used to filter the video from inside - * extension. - * - * @param provider_name provider name string. - * @param extension_name extension name string. - * @return - * - The pointer to IVideoFilter: Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createVideoFilter(const char* provider_name, const char* extension_name) = 0; - - /** - * Creates a video sink for the extension. - * - * This method creates an IVideoSinkBase object, which can be used to receive the video from the - * inside extension. - * - * @param provider_name provider name string. - * @param extension_name extension name string. - * @return - * - The pointer to IVideoSinkBase: Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createVideoSink(const char* provider_name, const char* extension_name) = 0; - - /** - * Creates a media player source object and returns the pointer. - * - * @param type The type of media player source you want to create. - * - * @return - * - The pointer to \ref rtc::IMediaPlayerSource "IMediaPlayerSource", if the method call - * succeeds. - * - A null pointer: Failure. - */ - virtual agora_refptr createMediaPlayerSource(media::base::MEDIA_PLAYER_SOURCE_TYPE type = agora::media::base::MEDIA_PLAYER_SOURCE_DEFAULT) = 0; - - /** - * @brief Creates a media streaming source object and returns the pointer. - * - * @param type The type of media streaming source you want to create. - * - * @return - * - The pointer to \ref rtc::IMediaStreamingSource "IMediaStreamingSource", if the method call - * succeeds. - * - A null pointer: Failure. - */ - virtual agora_refptr createMediaStreamingSource() = 0; - - /** - * Creates a media packet sender object and returns the pointer. - * - * @return - * - The pointer to \ref rtc::IMediaPacketSender "IMediaPacketSender", if the method call - * succeeds. - * - A null pointer: Failure. - */ - virtual agora_refptr createMediaPacketSender() = 0; - -#if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || defined(__OHOS__) - /** - * Creates screen capture source extension with given provider&extension names - * @param provider_name provider name string. - * @param extension_name extension name string. - * @return - * - The pointer to IScreenCapturer: Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createScreenCapturer2(const char* provider_name, const char* extension_name) = 0; -#else - /** - * Creates screen capture source extension with given provider&extension names - * @param provider_name provider name string. - * @param extension_name extension name string. - * @return - * - The pointer to IScreenCapturer: Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createScreenCapturer(const char* provider_name, const char* extension_name) = 0; -#endif - - protected: - ~IMediaNodeFactory() {} -}; - -} // namespace rtc -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRemoteAudioMixerSource.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRemoteAudioMixerSource.h deleted file mode 100644 index 98bdf2bd2..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRemoteAudioMixerSource.h +++ /dev/null @@ -1,45 +0,0 @@ -// -// Agora SDK -// -// Copyright (c) 2020 Agora.io. All rights reserved. -// - -#pragma once - -#include "AgoraRefPtr.h" -#include - -namespace agora { -namespace rtc { - -class IRemoteAudioTrack; - -/** - * The IRemoteAudioMixerSource class abstracts a multi-in-single-out audio source which receives audio - * streams from multiple remote audio tracks and generate mixed audio stream in user defined output - * format. - */ -class IRemoteAudioMixerSource : public RefCountInterface { - public: - virtual ~IRemoteAudioMixerSource() {} - - /** - * Add a audio track for mixing. Automatically starts mixing if add audio track - * @param track The instance of the audio track that you want mixer to receive its audio stream. - */ - virtual int addAudioTrack(agora_refptr track, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Remove a audio track for mixing. Automatically stops the mixed stream if all audio tracks are removed - * @param track The instance of the audio track that you want to remove from the mixer. - */ - virtual int removeAudioTrack(agora_refptr track, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Gets the delay time for mix. - */ - virtual int getMixDelay() const = 0; -}; - -} // namespace rtc -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRtcConnection.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRtcConnection.h deleted file mode 100644 index 2959d06da..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRtcConnection.h +++ /dev/null @@ -1,858 +0,0 @@ -// -// Agora SDK -// -// Created by Sting Feng in 2018-01. -// Copyright (c) 2018 Agora.io. All rights reserved. -// - -#pragma once // NOLINT(build/header_guard) - -#include "AgoraBase.h" -#include "time_utils.h" -#include - -namespace agora { -namespace rtc { -class IAudioEncodedFrameSender; -class IRtcConnectionObserver; -class INetworkObserver; -class IRtcConnection; -class IVideoEncodedImageSender; -class ILocalUser; - -/** - * The information of an RTC Connection. - */ -struct TConnectionInfo { - /** - * The ID of the RTC Connection. - */ - conn_id_t id; - /** - * The ID of the channel. If you have not called \ref agora::rtc::IRtcConnection::connect "connect", this member is `NULL`. - */ - util::AString channelId; - /** - * The connection state: #CONNECTION_STATE_TYPE. - */ - CONNECTION_STATE_TYPE state; - /** - * The ID of the local user. - */ - util::AString localUserId; - /** - * Internal use only. - */ - uid_t internalUid; - - int proxyType; - - util::AString connectionIp; - - TConnectionInfo() : id(-1), state(CONNECTION_STATE_DISCONNECTED), internalUid(0), proxyType(0) {} -}; - -struct TConnectSettings { - /** - * The app ID. - */ - const char* token; - /** - The channel name. It must be in the string format and not exceed 64 bytes in length. Supported character scopes are: - * - All lowercase English letters: a to z. - * - All uppercase English letters: A to Z. - * - All numeric characters: 0 to 9. - * - The space character. - * - Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", - * "-", ":", ";", "<", "=", - * ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", "," - */ - const char* channelId; - /** - The ID of the local user. If you do not specify a user ID or set `userId` as `null`, - * the SDK returns a user ID in the \ref IRtcConnectionObserver::onConnected "onConnected" - * callback. Your app must record and maintain the `userId` since the SDK does not do so. - */ - user_id_t userId; - - /* - App can provide a app defined start time to trace some events like connect cost , first video, etc. - */ - agora::Optional appDefinedStartTimeMs; -}; - -/** - * Configurations for an RTC connection. - * - * Set these configurations when calling \ref agora::base::IAgoraService::createRtcConnection "createRtcConnection". - */ -struct RtcConnectionConfiguration { - /** - * Whether to subscribe to all audio tracks automatically. - * - `true`: (Default) Subscribe to all audio tracks automatically. - * - `false`: Do not subscribe to any audio track automatically. - */ - bool autoSubscribeAudio; - /** - * Whether to subscribe to all video tracks automatically. - * - `true`: (Default) Subscribe to all video tracks automatically. - * - `false`: Do not subscribe to any video track automatically. - */ - bool autoSubscribeVideo; - /** - * Whether to enable audio recording or playout. - * - `true`: Enables audio recording or playout. Use this option when you publish and mix audio tracks, or subscribe to one or multiple audio tracks and play audio. - * - `false`: Disables audio recording or playout. Use this option when you publish external audio frames without audio mixing, or you do not need audio devices to play audio. - */ - bool enableAudioRecordingOrPlayout; - /** - * The maximum sending bitrate. - */ - int maxSendBitrate; - /** - * The minimum port. - */ - int minPort; - /** - * The maximum port. - */ - int maxPort; - /** - * The user role. For details, see #CLIENT_ROLE_TYPE. The default user role is `CLIENT_ROLE_AUDIENCE`. - */ - CLIENT_ROLE_TYPE clientRoleType; - /** The channel profile. For details, see #CHANNEL_PROFILE_TYPE. The default channel profile is `CHANNEL_PROFILE_LIVE_BROADCASTING`. - */ - CHANNEL_PROFILE_TYPE channelProfile; - - /** - * Determines whether to receive audio encoded frame or not. - */ - bool audioRecvEncodedFrame; - - /** - * Determines whether to receive audio media packet or not. - */ - bool audioRecvMediaPacket; - - /** - * Determines whether to receive video media packet or not. - */ - bool videoRecvMediaPacket; - - /** - * This mode is only used for audience. In PK mode, client might join one - * channel as broadcaster, and join another channel as interactive audience to - * achieve low lentancy and smooth video from remote user. - * - true: Enable low lentancy and smooth video when joining as an audience. - * - false: (Default) Use default settings for audience role. - */ - bool isInteractiveAudience; - - /** - * Indicates data channel only. - */ - bool isDataChannelOnly; - - RtcConnectionConfiguration() - : autoSubscribeAudio(true), - autoSubscribeVideo(true), - enableAudioRecordingOrPlayout(true), - maxSendBitrate(-1), - minPort(0), - maxPort(0), - clientRoleType(CLIENT_ROLE_AUDIENCE), - channelProfile(CHANNEL_PROFILE_LIVE_BROADCASTING), - audioRecvEncodedFrame(false), - audioRecvMediaPacket(false), - videoRecvMediaPacket(false), - isInteractiveAudience(false), - isDataChannelOnly(false) {} -}; - -/** - * The `IRtcConnection` class. - * - * You can use this class for managing the connection between your app and an Agora Channel. - * - * Once connected, your app gets an `AgoraLocalUser` object for publishing and subscribing to media streams in the Agora Channel. - * - * Connecting to a channel is done asynchronously, and your app can listen for the connection states or events through `IRtcConnectionObserver`. - * `IRtcConnection` also monitors remote users in the channel. The SDK notifies your app when a remote user joins or leaves the channel. - */ -class IRtcConnection : public RefCountInterface { - protected: - ~IRtcConnection() {} - - public: - /** - * Connects to an Agora channel. - * - * When the method call succeeds, the connection state changes from `CONNECTION_STATE_DISCONNECTED(1)` to - * `CONNECTION_STATE_CONNECTING(2)`. - * - * Depending on the whether the connection succeeds or not, the - * connection state changes to either `CONNECTION_STATE_CONNECTED(3)` or `CONNECTION_STATE_FAILED(5)`. The SDK also triggers `onConnected` or `onDisconnected` to notify you of the state change. - * - * @param token The app ID. - * @param channelId The channel name. It must be in the string format and not exceed 64 bytes in length. Supported character scopes are: - * - All lowercase English letters: a to z. - * - All uppercase English letters: A to Z. - * - All numeric characters: 0 to 9. - * - The space character. - * - Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", - * "-", ":", ";", "<", "=", - * ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", "," - * @param userId The ID of the local user. If you do not specify a user ID or set `userId` as `null`, - * the SDK returns a user ID in the \ref IRtcConnectionObserver::onConnected "onConnected" - * callback. Your app must record and maintain the `userId` since the SDK does not do so. - * @return - * - 0: Success. - * - < 0: Failure. - * - -2(ERR_INVALID_ARGUMENT): The argument that you pass is invalid. - * - -8(ERR_INVALID_STATE): The current connection state is not CONNECTION_STATE_DISCONNECTED(1). - */ - virtual int connect(const char* token, const char* channelId, user_id_t userId, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Connects to an Agora channel. - * - * When the method call succeeds, the connection state changes from `CONNECTION_STATE_DISCONNECTED(1)` to - * `CONNECTION_STATE_CONNECTING(2)`. - * - * Depending on the whether the connection succeeds or not, the - * connection state changes to either `CONNECTION_STATE_CONNECTED(3)` or `CONNECTION_STATE_FAILED(5)`. - * The SDK also triggers `onConnected` or `onDisconnected` to notify you of the state change. - * @param settings The settings of connecting. - */ - virtual int connect(const TConnectSettings& settings, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Disconnects from the Agora channel. - * - * Once your app successful disconnects from the channel, the connection state changes to - * `CONNECTION_STATE_DISCONNECTED(1)`. You are also notified with the callback - * \ref IRtcConnectionObserver::onDisconnected "onDisconnected". - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int disconnect(aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Starts the last-mile network probe test. - * - * Call this method before connecting to the channel to get the uplink and - * downlink last-mile network statistics, including the bandwidth, packet loss, jitter, and - * round-trip time (RTT). - * - * After you enable the last-mile network probe test, the SDK triggers the following callbacks: - * - \ref IRtcConnectionObserver::onLastmileQuality "onLastmileQuality": The SDK triggers this - * callback within two seconds depending on the network conditions. This callback rates the network - * conditions and is more closely linked to the user experience. - * - \ref IRtcConnectionObserver::onLastmileProbeResult "onLastmileProbeResult": The SDK triggers - * this callback within 30 seconds depending on the network conditions. This callback reports the - * real-time statistics of the network conditions and is more objective. - * - * @note - * - Do not call any other method before receiving the \ref IRtcConnectionObserver::onLastmileQuality - * "onLastmileQuality" and \ref IRtcConnectionObserver::onLastmileProbeResult "onLastmileProbeResult" - * callbacks. Otherwise, the callbacks may be interrupted. - * - In the live-broadcast profile, a host should not call this method after connecting to a channel. - * - * @param config The configurations of the last-mile network probe test. See \ref agora::rtc::LastmileProbeConfig "LastmileProbeConfig". - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int startLastmileProbeTest(const LastmileProbeConfig& config, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Stops the last-mile network probe test. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int stopLastmileProbeTest(aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Renews the token. - * - * The token expires after a certain period of time. - * When the \ref IRtcConnectionObserver::onError "onError" callback reports `ERR_TOKEN_EXPIRED(109)`, you must generate a new token from the server - * and then call this method to renew it. Otherwise, the SDK disconnects from the Agora channel. - * - * @param token The pointer to the new token. - */ - virtual int renewToken(const char* token, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Gets the connection information. - * - * @return - * - The pointer to the \ref agora::rtc::TConnectionInfo "TConnectionInfo" object: Success. - * - A null pointer: Failure. - */ - virtual TConnectionInfo getConnectionInfo() = 0; - - /** - * Gets the \ref agora::rtc::ILocalUser "ILocalUser" object. - * - * @return - * - The pointer to the \ref agora::rtc::ILocalUser "ILocalUser" object: Success. - * - A null pointer: Failure. - */ - virtual ILocalUser* getLocalUser() = 0; - - /** - * Gets the information of all the remote users in the channel. - * - * After a user successfully connects to the channel, you can also get the information of this remote user - * with the \ref IRtcConnectionObserver::onUserJoined "onUserJoined" callback. - * - * @param [out] users The reference to the \ref agora::UserList "UserList" object, which contains the information of all users - * in the channel. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getRemoteUsers(UserList& users) = 0; - - /** - * Gets the information of a specified remote user in the channel. - * - * @param [in] userId ID of the user whose information you want to get. - * @param [out] userInfo The reference to the \ref agora::UserInfo "UserInfo" object, which contains the information of the - * specified user. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getUserInfo(user_id_t userId, agora::UserInfo& userInfo) = 0; - - /** - * Registers an RTC connection observer. You can call this method only after creating an `IRtcConnection` object. - * - * @param observer The pointer to the IRtcConnectionObserver object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerObserver(IRtcConnectionObserver* observer, void(*safeDeleter)(IRtcConnectionObserver*) = NULL, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Releases the registered IRtcConnectionObserver object. - * - * @param observer The pointer to the IRtcConnectionObserver object created by the \ref registerObserver - * "registerObserver" method. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unregisterObserver(IRtcConnectionObserver* observer) = 0; - - /** - * Registers an network observer object. - * - * @param observer The pointer to the INetworkObserver object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerNetworkObserver(INetworkObserver* observer, void(*safeDeleter)(INetworkObserver*) = NULL, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Releases the registered INetworkObserver object. - * - * @param observer The pointer to the INetworkObserver object created by the \ref registerNetworkObserver - * "registerNetworkObserver" method. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unregisterNetworkObserver(INetworkObserver* observer) = 0; - - /** - * Gets the ID of the connection. - * - * @return - * - The connection ID: Success. - * - A null pointer: Failure. - */ - virtual conn_id_t getConnId() = 0; - - /** - * Gets the transportation statistics of the RTC connection. - * - * @return - * - The pointer to \ref agora::rtc::RtcStats "RtcStats": Success. - * - A null pointer: Failure. - */ - virtual RtcStats getTransportStats() = 0; - - /** - * Gets the IAgoraParameter object. - * - * @return - * - The pointer to the \ref agora::base::IAgoraParameter "IAgoraParameter" object. - * - A null pointer: Failure. - */ - virtual agora::base::IAgoraParameter* getAgoraParameter() = 0; - - /** - * Creates a data stream. - * - * Each user can create up to five data streams during the lifecycle of an RTC connection. - * - * @note Set both the `reliable` and `ordered` parameters as `true` or `false`. Do not set one as `true` and the other as `false`. - * - * @param streamId The pointer to the ID of the data stream. - * @param reliable Whether to guarantee the receivers receive the data stream within five seconds: - * - `true`: Guarantee that the receivers receive the data stream within five seconds. If the receivers do not receive the data stream within five seconds, the SDK reports an error to the application. - * - `false`: Do not guarantee that the receivers receive the data stream within five seconds and the SDK does not report any error message for data stream delay or missing. - * @param ordered Whether the receivers receive the data stream in the order of sending: - * - `true`: The receivers receive the data stream in the order of sending. - * - `false`: The receivers do not receive the data stream in the order of sending. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int createDataStream(int* streamId, bool reliable, bool ordered, bool sync) = 0; - - /** Sends data stream messages to all users in a channel. - * - * @note This method has the following restrictions: - * - Up to 30 packets can be sent per second in a channel with a maximum size of 1 kB for each packet. - * - Each client can send up to 6 kB of data per second. - * - Each user can have up to five data streams simultaneously. - * - * @param streamId The ID of the sent data stream, returned in the \ref agora::rtc::IRtcConnection::createDataStream "createDataStream" method. - * @param data The pointer to the sent data. - * @param length The length of the sent data. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int sendStreamMessage(int streamId, const char* data, size_t length, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** Enables/Disables the built-in encryption. - * - * In scenarios requiring high security, Agora recommends calling this method to enable the built-in encryption before joining a channel. - * - * All users in the same channel must use the same encryption mode and encryption key. Once all users leave the channel, the encryption key of this channel is automatically cleared. - * - * @note - * - If you enable the built-in encryption, you cannot use the RTMP streaming function. - * - * @param enabled Whether to enable the built-in encryption: - * - true: Enable the built-in encryption. - * - false: Disable the built-in encryption. - * @param config Configurations of built-in encryption schemas. See \ref agora::rtc::EncryptionConfig "EncryptionConfig". - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableEncryption(bool enabled, const EncryptionConfig& config, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Reports a custom event to Agora. - * - * @param id The custom event ID. - * @param category The category of the custom event. - * @param event The custom event to report. - * @param label The label of the custom event. - * @param value The value of the custom event. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int sendCustomReportMessage(const char* id, const char* category, const char* event, const char* label, int value, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** Gets the user information by user account, which is in string format. - * - * @param userAccount The user account of the user. - * @param [in,out] userInfo A \ref rtc::UserInfo "UserInfo" object that identifies the user: - * - Input: A userInfo object. - * - Output: A userInfo object that contains the user account and user ID of the user. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getUserInfoByUserAccount(const char* userAccount, rtc::UserInfo* userInfo) = 0; - /** Gets the user information by user ID, which is in integer format. - * - * @param uid The ID of the remote user. - * @param [in,out] userInfo A \ref rtc::UserInfo "UserInfo" object that identifies the user: - * - Input: A userInfo object. - * - Output: A userInfo object that contains the user account and user ID of the user. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getUserInfoByUid(uid_t uid, rtc::UserInfo* userInfo) = 0; -}; - -/** - * The IRtcConnectionObserver class, which observes the connection state of the SDK. - */ -class IRtcConnectionObserver { - public: - virtual ~IRtcConnectionObserver() {} - - /** - * Occurs when the connection state between the SDK and the Agora channel changes to `CONNECTION_STATE_CONNECTED(3)`. - * - * @param connectionInfo The information of the connection. See \ref agora::rtc::TConnectionInfo "TConnectionInfo". - * @param reason The reason of the connection state change. See #CONNECTION_CHANGED_REASON_TYPE. - */ - virtual void onConnected(const TConnectionInfo& connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason) = 0; - - /** - * Occurs when the connection state between the SDK and the Agora channel changes to `CONNECTION_STATE_DISCONNECTED(1)`. - * - * @param connectionInfo The information of the connection. See \ref agora::rtc::TConnectionInfo "TConnectionInfo". - * @param reason The reason of the connection state change. See #CONNECTION_CHANGED_REASON_TYPE. - */ - virtual void onDisconnected(const TConnectionInfo& connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason) = 0; - - /** - * Occurs when the connection state between the SDK and the Agora channel changes to `CONNECTION_STATE_CONNECTING(2)`. - * - * @param connectionInfo The information of the connection. See \ref agora::rtc::TConnectionInfo "TConnectionInfo". - * @param reason The reason of the connection state change. See #CONNECTION_CHANGED_REASON_TYPE. - */ - virtual void onConnecting(const TConnectionInfo& connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason) = 0; - - /** - * Occurs when the connection state between the SDK and the Agora channel changes to `CONNECTION_STATE_RECONNECTING(4)`. - * - * @param connectionInfo The information of the connection. See \ref agora::rtc::TConnectionInfo "TConnectionInfo". - * @param reason The reason of the connection state change. See #CONNECTION_CHANGED_REASON_TYPE. - */ - virtual void onReconnecting(const TConnectionInfo& connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason) = 0; - - // This should be deleted. onConnected is enough. - virtual void onReconnected(const TConnectionInfo& connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason) = 0; - - /** - * Occurs when the SDK loses connection with the Agora channel. - * - * @param connectionInfo The information of the connection. See \ref agora::rtc::TConnectionInfo "TConnectionInfo". - */ - virtual void onConnectionLost(const TConnectionInfo& connectionInfo) = 0; - - /** - * Reports the quality of the last-mile network. - * - * The SDK triggers this callback within two seconds after the app calls \ref IRtcConnection::startLastmileProbeTest "startLastmileProbeTest". - * - * @param quality Quality of the last-mile network: #QUALITY_TYPE. - */ - virtual void onLastmileQuality(const QUALITY_TYPE quality) = 0; - - /** - * Reports the result of the last-mile network probe test. - * - * The SDK triggers this callback within 30 seconds after the app calls \ref IRtcConnection::startLastmileProbeTest "startLastmileProbeTest". - * - * @param result The result of the last-mile network probe test: \ref agora::rtc::LastmileProbeResult "LastmileProbeResult". - */ - virtual void onLastmileProbeResult(const LastmileProbeResult& result) = 0; - - /** - * Occurs when the token expires in 30 seconds. - * - * The SDK triggers this callback to remind the app to get a new token before the token privilege expires. - * - * Upon receiving this callback, you must generate a new token on your server and call \ref IRtcConnection::renewToken - * "renewToken" to pass the new token to the SDK. - * - * @param token The pointer to the token that expires in 30 seconds. - */ - virtual void onTokenPrivilegeWillExpire(const char* token) = 0; - - /** - * Occurs when the token has expired. - * - * Upon receiving this callback, you must generate a new token on your server and call \ref IRtcConnection::renewToken - * "renewToken" to pass the new token to the SDK. - */ - virtual void onTokenPrivilegeDidExpire() = 0; - - /** - * Occurs when the connection state between the SDK and the Agora channel changes to `CONNECTION_STATE_FAILED(5)`. - * - * @param connectionInfo The connection information: TConnectionInfo. - * @param reason The reason of the connection state change: #CONNECTION_CHANGED_REASON_TYPE. - */ - virtual void onConnectionFailure(const TConnectionInfo& connectionInfo, - CONNECTION_CHANGED_REASON_TYPE reason) = 0; - - /** - * Occurs when a remote user joins the channel. - * - * You can get the ID of the remote user in this callback. - * - * @param userId The ID of the remote user who joins the channel. - */ - virtual void onUserJoined(user_id_t userId) = 0; - - /** - * Occurs when a remote user leaves the channel. - * - * You can know why the user leaves the channel through the `reason` parameter. - * - * @param userId The ID of the user who leaves the channel. - * @param reason The reason why the remote user leaves the channel: #USER_OFFLINE_REASON_TYPE. - */ - virtual void onUserLeft(user_id_t userId, USER_OFFLINE_REASON_TYPE reason) = 0; - - /** - * Reports the transport statistics of the connection. - * - * The SDK triggers this callback once every two seconds when the connection state is `CONNECTION_STATE_CONNECTED`. - * - * @param stats The pointer to \ref rtc::RtcStats "RtcStats". - */ - virtual void onTransportStats(const RtcStats& stats) = 0; - - /** - * Occurs when the role of the local user changes. - * - * @param oldRole The previous role of the local user: \ref rtc::CLIENT_ROLE_TYPE "CLIENT_ROLE_TYPE". - * @param newRole The current role of the local user: \ref rtc::CLIENT_ROLE_TYPE "CLIENT_ROLE_TYPE". - * @param newRoleOptions The client role options of the current role of the local user: \ref rtc::ClientRoleOptions "ClientRoleOptions". - */ - virtual void onChangeRoleSuccess(CLIENT_ROLE_TYPE oldRole, CLIENT_ROLE_TYPE newRole, const ClientRoleOptions& newRoleOptions) { - (void)oldRole; - (void)newRole; - (void)newRoleOptions; - } - - /** - * Occurs when the local user fails to change the user role. - */ - virtual void onChangeRoleFailure(CLIENT_ROLE_CHANGE_FAILED_REASON reason, CLIENT_ROLE_TYPE currentRole) { - (void)reason; - (void)currentRole; - } - - /** - * Occurs when connection license verification fails - * - * You can know the reason accordding to error code - * @param error verify fail reason - */ - virtual void onLicenseValidationFailure(LICENSE_ERROR_TYPE error) { - (void)error; - } - - /** - * Reports the network quality of each user. - * - * The SDK triggers this callback once every two seconds to report the uplink and downlink network conditions - * of each user in the channel, including the local user. - * - * @param userId The ID of the user. If `userId` is empty, this callback reports the network quality of the local user. - * @param txQuality The uplink network quality: #QUALITY_TYPE. - * @param rxQuality The downlink network quality: #QUALITY_TYPE. - */ - virtual void onUserNetworkQuality(user_id_t userId, QUALITY_TYPE txQuality, - QUALITY_TYPE rxQuality) { - (void)userId; - (void)txQuality; - (void)rxQuality; - } - - /** Occurs when the network type is changed. - * @param type The current network type. See #NETWORK_TYPE. - */ - virtual void onNetworkTypeChanged(NETWORK_TYPE type) { - (void)type; - } - - /** Reports result of Content Inspect*/ - virtual void onContentInspectResult(media::CONTENT_INSPECT_RESULT result) { (void)result; } - /** Occurs when takeSnapshot API result is obtained - * - * - * @brief snapshot taken callback - * - * @param channel channel name - * @param uid user id - * @param filePath image is saveed file path - * @param width image width - * @param height image height - * @param errCode 0 is ok negative is error - */ - virtual void onSnapshotTaken(user_id_t userId, const char* filePath, int width, int height, int errCode) { - (void)userId; - (void)filePath; - (void)width; - (void)height; - (void)errCode; - } - /** - * Reports the error code and error message. - * @param error The error code: #ERROR_CODE_TYPE. - * @param msg The error message. - */ - virtual void onError(ERROR_CODE_TYPE error, const char* msg) { - (void)error; - (void)msg; - } - - /** - * Occurs when the state of the channel media relay changes. - * - * - * @param state The state code: - * - `RELAY_STATE_IDLE(0)`: The SDK is initializing. - * - `RELAY_STATE_CONNECTING(1)`: The SDK tries to relay the media stream to the destination - * channel. - * - `RELAY_STATE_RUNNING(2)`: The SDK successfully relays the media stream to the destination - * channel. - * - `RELAY_STATE_FAILURE(3)`: A failure occurs. See the details in `code`. - * @param code The error code: - * - `RELAY_OK(0)`: The state is normal. - * - `RELAY_ERROR_SERVER_ERROR_RESPONSE(1)`: An error occurs in the server response. - * - `RELAY_ERROR_SERVER_NO_RESPONSE(2)`: No server response. You can call the leaveChannel method - * to leave the channel. - * - `RELAY_ERROR_NO_RESOURCE_AVAILABLE(3)`: The SDK fails to access the service, probably due to - * limited resources of the server. - * - `RELAY_ERROR_FAILED_JOIN_SRC(4)`: Fails to send the relay request. - * - `RELAY_ERROR_FAILED_JOIN_DEST(5)`: Fails to accept the relay request. - * - `RELAY_ERROR_FAILED_PACKET_RECEIVED_FROM_SRC(6)`: The server fails to receive the media - * stream. - * - `RELAY_ERROR_FAILED_PACKET_SENT_TO_DEST(7)`: The server fails to send the media stream. - * - `RELAY_ERROR_SERVER_CONNECTION_LOST(8)`: The SDK disconnects from the server due to poor - * network connections. You can call the leaveChannel method to leave the channel. - * - `RELAY_ERROR_INTERNAL_ERROR(9)`: An internal error occurs in the server. - * - `RELAY_ERROR_SRC_TOKEN_EXPIRED(10)`: The token of the source channel has expired. - * - `RELAY_ERROR_DEST_TOKEN_EXPIRED(11)`: The token of the destination channel has expired. - */ - virtual void onChannelMediaRelayStateChanged(int state, int code) = 0; - - /** Occurs when the local user successfully registers a user account by calling the \ref IRtcEngine::joinChannelWithUserAccount "joinChannelWithUserAccount" method.This callback reports the user ID and user account of the local user. - * - * @param uid The ID of the local user. - * @param userAccount The user account of the local user. - */ - virtual void onLocalUserRegistered(uid_t uid, const char* userAccount) { - (void)uid; - (void)userAccount; - } - - /** Technical Preview, please do not depend on this event. */ - virtual void onUserAccountUpdated(uid_t uid, const char* userAccount) { - (void)uid; - (void)userAccount; - } - - /** - * Reports the error that occurs when receiving data stream messages. - * - * @param userId The ID of the user sending the data stream. - * @param streamId the ID of the sent data stream, returned in the \ref agora::rtc::IRtcConnection::createDataStream "createDataStream" method. - * @param code The error code. - * @param missed The number of lost messages. - * @param cached The number of incoming cached messages when the data stream is interrupted. - */ - virtual void onStreamMessageError(user_id_t userId, int streamId, int code, int missed, - int cached) { - (void)userId; - (void)streamId; - (void)code; - (void)missed; - (void)cached; - } - - /** - * Reports the error type of encryption. - * @param type See #ENCRYPTION_ERROR_TYPE. - */ - virtual void onEncryptionError(ENCRYPTION_ERROR_TYPE errorType) { - (void)errorType; - } - /** - * Reports the user log upload result - * @param requestId RequestId of the upload - * @param success Is upload success - * @param reason Reason of the upload, 0: OK, 1 Network Error, 2 Server Error. - */ - virtual void onUploadLogResult(const char* requestId, bool success, UPLOAD_ERROR_REASON reason) { - (void)requestId; - (void)success; - (void)reason; - } - - /** - * Occurs when receive use rtm response. - * - * @param code The error code: - */ - virtual void onSetRtmFlagResult(int code) { - (void)code; - } - - /** Occurs when the WIFI message need be sent to the user. - * - * @param reason The reason of notifying the user of a message. - * @param action Suggest an action for the user. - * @param wlAccMsg The message content of notifying the user. - */ - virtual void onWlAccMessage(WLACC_MESSAGE_REASON reason, WLACC_SUGGEST_ACTION action, const char* wlAccMsg) { - (void)reason; - (void)action; - (void)wlAccMsg; - } - - /** Occurs when SDK statistics wifi acceleration optimization effect. - * - * @param currentStats Instantaneous value of optimization effect. - * @param averageStats Average value of cumulative optimization effect. - */ - virtual void onWlAccStats(const WlAccStats& currentStats, const WlAccStats& averageStats) { - (void)currentStats; - (void)averageStats; - } -}; - -class INetworkObserver { - public: - virtual ~INetworkObserver() {} - - public: - /** - * Occurs when downlink network info is updated. - * - * This callback is used for notifying user to adjust the send pace based - * on the target bitrate. - * - * @param info The uplink network info collections. - */ - virtual void onUplinkNetworkInfoUpdated(const UplinkNetworkInfo& info) { - (void)info; - } - - /** - * Occurs when downlink network info is updated. - * - * This callback is used for notifying user to switch major/minor stream if needed. - * - * @param info The downlink network info collections. - */ - virtual void onDownlinkNetworkInfoUpdated(const DownlinkNetworkInfo& info) { - (void)info; - } -}; - -} // namespace rtc -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRtmpConnection.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRtmpConnection.h deleted file mode 100644 index 1fabd7339..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRtmpConnection.h +++ /dev/null @@ -1,392 +0,0 @@ -// -// Agora RTMP connection -// -// Created by Haonong Yu in 2020-02. -// Copyright (c) 2020 Agora.io. All rights reserved. -// - -#pragma once // NOLINT(build/header_guard) - -#include "AgoraBase.h" -#include "AgoraRefPtr.h" -#include - -namespace agora { -namespace rtc { - -class IRtmpLocalUser; - -/** - * Configurations for the RTMP audio stream. - */ -struct RtmpStreamingAudioConfiguration { - /** - * Sampling rate (Hz). The default value is 44100 (i.e. 44.1kHz). - */ - int sampleRateHz; - - /** - * Number of bytes per sample. The default value is 2 (i.e. 16-bit PCM). - */ - int bytesPerSample; - - /** - * Number of channels. The default value is 1 (i.e. mono). - */ - int numberOfChannels; - - /** - * The target bitrate (Kbps) of the output audio stream to be published. - * The default value is 48 Kbps. - */ - int bitrate; - - RtmpStreamingAudioConfiguration(): sampleRateHz(44100), bytesPerSample(2), - numberOfChannels(1), bitrate(48000) {} -}; - -/** - * Configurations for the RTMP video stream. - */ -struct RtmpStreamingVideoConfiguration { - /** - * The width (in pixels) of the video. The default value is 640. - * - * @note - * - The value of the dimension (with the |height| below) does not indicate the orientation mode - * of the output ratio. For how to set the video orientation, - * see {@link OrientationMode OrientationMode}. - */ - int width; - - /** - * The height (in pixels) of the video. The default value is 360. - * - * @note - * - The value of the dimension (with the |width| above) does not indicate the orientation mode - * of the output ratio. For how to set the video orientation, - * see {@link OrientationMode OrientationMode}. - */ - int height; - - /** - * Frame rate (fps) of the output video stream to be published. The default - * value is 15 fps. - */ - int framerate; - - /** - * The target bitrate (Kbps) of the output video stream to be published. - * The default value is 800 Kbps. - */ - int bitrate; - - /** - * (For future use) The maximum bitrate (Kbps) for video. - * The default value is 960 Kbps. - */ - int maxBitrate; - - /** - * (For future use) The minimum bitrate (Kbps) for video. - * The default value is 600 Kbps. - */ - int minBitrate; - - /** - * The interval between two keyframes. - * The default value is 2000ms. - */ - unsigned int gopInMs; - - /** - * Whether the encoder enables hard coding or soft coding. - * The default value is 0. - * 0: default - * 1: hardware encoder - * 2: software encoder - */ - int encoderHwSwMode; - - /** - * Whether the encoder enables CBR coding or VBR coding. - * The default value is 0. - * 0: CBR - * 1: VBR - */ - int encoderBitrateControlMode; - - /** - * The orientation mode. - * See {@link ORIENTATION_MODE ORIENTATION_MODE}. - */ - ORIENTATION_MODE orientationMode; - - RtmpStreamingVideoConfiguration(): width(640), height(360), framerate(15), - bitrate(800), maxBitrate(960), minBitrate(600), gopInMs(2000), encoderHwSwMode(0),encoderBitrateControlMode(0), - orientationMode(ORIENTATION_MODE_ADAPTIVE) {} -}; - - -/** - * The RTMP Connection error codes. - */ -enum RTMP_CONNECTION_ERROR { - /** - * 0: No error occurs. - */ - RTMP_CONNECTION_ERR_OK = 0, - - /** - * 1: A general error occurs (no specified reason). - */ - RTMP_CONNECTION_ERR_FAILED = 1, - - /** - * 2: The rtmp url is invalid. - */ - RTMP_CONNECTION_ERR_INVALID_URL = 2, - - /** - * 3: Already exist stream name. - */ - RTMP_CONNECTION_ERR_BAD_NAME = 3, -}; - -/** - * The connection state between the SDK and the RTMP server. - */ -enum RTMP_CONNECTION_STATE { - /** - * 1: The SDK is disconnected from the RTMP server. - * - * This is the initial state when an RTMP Connetion is created by - * the \ref IAgoraService::createRtmoConnection "createRtmpConnection" method. - * - * The RTMP Connection also enters this state if you call the - * \ref disconnect "disconnect" method when the SDK is in the - * STATE_CONNECTING(2), STATE_CONNECTED(3), STATE_RECONNECTING(4) or - * STATE_FAILED(5) state. - */ - STATE_DISCONNECTED = 1, - - /** - * 2: The SDK is connecting to the RTMP server. - * - * The SDK goes to this state after you call the \ref connect "connect" method, - * indicating that the SDK is in the process of establishing a connection - * to the RTMP server. - * - * Once successfully connected, it enters the STATE_CONNECTED(3) state. - * - * If the SDK fails to connect to RTMP server, the SDK goes to STATE_FAILED(5). - */ - STATE_CONNECTING = 2, - - /** - * 3: The SDK is connected to the RTMP server. - * - * This state indicates that the SDK has established a connection to the - * RTMP server, and you can publish media streams through this connection. - * - * Once the connection is interrupted, for example, due to network deterioration or - * network type change, the SDK tries to reconnect to the RTMP server - * and enters the STATE_RECONNECTING(4) state. - */ - STATE_CONNECTED = 3, - - /** - * 4: The SDK is reconnecting to the RTMP server. - * - * This state indicates that the connection is interrupted by - * some network issue. The SDK keeps trying connecting to the - * server. If the SDK fails to reconnect, the SDK goes to - * STATE_FAILED(5). - */ - STATE_RECONNECTING = 4, - - /** - * 5: The SDK fails to connect to the RTMP server. - * - * In this state, SDK stops connecting to the server. Call the - * - \ref IRtmpConnection::disconnect "disconnect" method to leave this state and the - * - \ref IRtmpConnection::connect "connect" method to reconnect. - */ - STATE_FAILED = 5, - - /** - * 6: The SDK is reconnected to the RTMP server. - * - * This state indicates that the connection is interrupted by - * some network issue. The SDK keeps trying connecting to the - * server. If the SDK reconnected to server, the SDK goes to - * STATE_RECONNECTED(6). - */ - STATE_RECONNECTED = 6 -}; - -/** - * Configurations for the RTMP connection. - */ -struct RtmpConnectionConfiguration { - RtmpStreamingAudioConfiguration audioConfig; - RtmpStreamingVideoConfiguration videoConfig; - bool audioOnly; - RtmpConnectionConfiguration() : audioOnly(false) {} -}; - -/** - * The information on the RTMP Connection. - */ -struct RtmpConnectionInfo { - /** - * The state of the current connection: #RTMP_CONNECTION_STATE. - */ - RTMP_CONNECTION_STATE state; - - RtmpConnectionInfo() : state(STATE_DISCONNECTED) {} -}; - - -/** - * The IRtmpConnectionObserver class, which observes the RTMP connection state of the SDK. - */ -class IRtmpConnectionObserver { - public: - /** - * Occurs when the connection state between the SDK and the RTMP server changes to STATE_CONNECTED(3). - * - * @param connectionInfo The information of the current connection: RtmpConnectionInfo. - */ - virtual void onConnected(const RtmpConnectionInfo& connectionInfo) = 0; - - /** - * Occurs when the connection state between the SDK and the RTMP server changes to STATE_DISCONNECTED(1). - * - * @param connectionInfo The information of the current connection: RtmpConnectionInfo. - */ - virtual void onDisconnected(const RtmpConnectionInfo& connectionInfo) = 0; - - /** - * Occurs when the connection state between the SDK and RTMP server changes to STATE_RECONNECTING(4). - * - * @param connectionInfo The information of the current connection: RtmpConnectionInfo. - */ - virtual void onReconnecting(const RtmpConnectionInfo& connectionInfo) = 0; - - /** - * Occurs when the connection state between the SDK and RTMP server changes to STATE_RECONNECTED(6). - * - * @param connectionInfo The information of the current connection: RtmpConnectionInfo. - */ - virtual void onReconnected(const RtmpConnectionInfo& connectionInfo) = 0; - - /** - * Occurs when the connection state between the SDK and the RTMP server changes to STATE_FAILED(5). - * - * @param connectionInfo The connection information: RtmpConnectionInfo. - * @param errCode The error code for the connection failure. - */ - virtual void onConnectionFailure(const RtmpConnectionInfo& connectionInfo, - RTMP_CONNECTION_ERROR errCode) = 0; - - /** - * Occurs every 1s when the connection transmits data, report the current video bitrate, audio bitrate and video framerate. - * - * @param video_width The width of the video frame actually pushed out - * @param video_height The height of the video frame actually pushed out - * @param video_bitrate The actual bitrate of the video stream being pushed out - * @param audio_bitrate The actual bitrate of the audio stream being pushed out - * @param video_frame_rate The frame rate of the video stream actually pushed out - */ - virtual void onTransferStatistics(uint64_t video_width, uint64_t video_height, uint64_t video_bitrate, uint64_t audio_bitrate, uint64_t video_frame_rate, uint64_t push_video_frame_cnt, uint64_t pop_video_frame_cnt) = 0; - - virtual ~IRtmpConnectionObserver() {} -}; - -/** - * The IRtmpConnection class. - * - * With this class, an app can establish a connection to a RTMP server. - * Once connected, the app gets an RtmpUser object, which - * can publish media streams to the RTMP server. - * - * Connecting to the server is done asynchronous, and apps can listen for the - * connection states or events with IRtmpConnectionObserver. - */ -class IRtmpConnection : public RefCountInterface { - public: - ~IRtmpConnection() {} - - /** - * Connects to a RTMP server. - * - * When the method call succeeds, the RTMP connection state changes to - * STATE_CONNECTING(2). - * - * Depending on the success or failure of the connection establishment, the RTMP - * connection will make a second state transition to either - * STATE_CONNECTED(3) or STATE_FAILED(5). You will also be notified with the either - * onConnected() or onDisconnected(). - * - * @param url The CDN streaming URL in the RTMP format. The maximum length of this parameter is 1024 - * bytes. The URL address must not contain special characters, such as Chinese language characters. - * @return - * - 0: Success. - * - < 0: Failure. - * - ERR_INVALID_ARGUMENT: The passed in argument is invalid. - * - ERR_INVALID_STATE: The current connection state is not STATE_DISCONNECTED(3). - */ - virtual int connect(const char* url, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Disconnects from the RTMP server. - * - * A successful call of this method changes the connection state to - * STATE_DISCONNECTED(4). You will be notified with the callback - * \ref onDisconnected "onDisconnected". - */ - virtual int disconnect(aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Gets the current connection information. - * - * @return - * - A pointer to the RtmpConnectionInfo object, if the method call succeeds. - * - An empty pointer NULL, if the method call fails. - */ - virtual RtmpConnectionInfo getConnectionInfo() = 0; - - /** - * Gets the IRtmpUser object. - * - * @return - * - A pointer to the IRtmpUser object, if the method call succeeds. - * - An empty pointer NULL, if the method call fails. - */ - virtual IRtmpLocalUser* getRtmpLocalUser() = 0; - - /** - * Registers an IRtmpConnectionObserver object. - * - * @param observer A pointer to the IRtmpConnectionObserver object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerObserver(IRtmpConnectionObserver* observer, void(*safeDeleter)(IRtmpConnectionObserver*) = NULL, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Releases the registered IRtmpConnectionObserver object. - * - * @param observer The pointer to the IRtmpConnectionObserver object created by the \ref registerObserver - * "registerObserver" method. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unregisterObserver(IRtmpConnectionObserver* observer) = 0; -}; - -} // namespace rtc -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRtmpLocalUser.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRtmpLocalUser.h deleted file mode 100644 index e5ee27f0c..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraRtmpLocalUser.h +++ /dev/null @@ -1,299 +0,0 @@ -// -// Agora RTMP connection -// -// Created by Haonong Yu in 2020-02. -// Copyright (c) 2020 Agora.io. All rights reserved. -// - -#pragma once // NOLINT(build/header_guard) - -#include "NGIAgoraAudioTrack.h" -#include "NGIAgoraVideoTrack.h" - -namespace agora { -namespace rtc { - -struct RtmpStreamingAudioConfiguration; -struct RtmpStreamingVideoConfiguration; - -/** - * The error occurs while publising audio stream. - */ -enum PublishAudioError { - /** - * 0: No error occurs. - */ - PUBLISH_AUDIO_ERR_OK = 0, - - /** - * 1: A general error occurs (no specified reason). - */ - PUBLISH_AUDIO_ERR_FAILED = 1, -}; - -/** - * The error occurs while publising video stream. - */ -enum PublishVideoError { - /** - * 0: No error occurs. - */ - PUBLISH_VIDEO_ERR_OK = 0, - - /** - * 1: A general error occurs (no specified reason). - */ - PUBLISH_VIDEO_ERR_FAILED = 1, -}; - -/** - * The IRtmpLocalUserObserver class. - */ -class IRtmpLocalUserObserver { - public: - virtual ~IRtmpLocalUserObserver() {} - - /** - * Occurs when the first packet of the local audio track is sent, indicating that the local audio track - * is successfully published. - * - * @param audioTrack The pointer to ILocalAudioTrack. - */ - virtual void onAudioTrackPublishSuccess(agora_refptr audioTrack) = 0; - - /** - * @deprecated This method will not be called back - */ - virtual void onAudioTrackPublishStart(agora_refptr audioTrack) = 0; - - /** - * @deprecated This method will not be called back - */ - virtual void onAudioTrackUnpublished(agora_refptr audioTrack) = 0; - - /** - * Occurs when the local audio track fails to be published. - * - * @param audioTrack The pointer to ILocalAudioTrack. - * @param error The error information: #RtmpAudioStreamError. - */ - virtual void onAudioTrackPublicationFailure(agora_refptr audioTrack, - PublishAudioError error) = 0; - - /** - * Occurs when the first packet of the local video track is sent, indicating that the local video track - * is successfully published. - * @param videoTrack The pointer to ILocalVideoTrack. - */ - virtual void onVideoTrackPublishSuccess(agora_refptr videoTrack) = 0; - - /** - * @deprecated This method will not be called back - */ - virtual void onVideoTrackPublishStart(agora_refptr videoTrack) = 0; - - /** - * @deprecated This method will not be called back - */ - virtual void onVideoTrackUnpublished(agora_refptr videoTrack) = 0; - - /** - * Occurs when the local video track fails to be published. - * - * @param videoTrack The pointer to ILocalVideoTrack. - * @param error The error information: #RtmpVideoStreamError. - */ - virtual void onVideoTrackPublicationFailure(agora_refptr videoTrack, - PublishVideoError error) = 0; -}; - -/** - * The IRtmpLocalUser class defines the behavior and state of the RTMP user. - * - * Once connected, a RTMP connection has its own user. Apps can get the - * user object using \ref agora::rtmp::IRtmpConnection::getUser - * "IRtmpConnection::getUser". - */ -class IRtmpLocalUser { - public: - - enum VideoBitrateAdjustType { - None = 0, - Increasing = 1, // The buffer is in good declining state to increase bitrate - Decreasing = 2, // The buffer is in bad increasing state to decrease bitrate - }; - - virtual ~IRtmpLocalUser() {} - - /** - * Set the parameters of the audio encoder when pushing the stream - * - * @param config Audio encoder parameters - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setAudioStreamConfiguration(const RtmpStreamingAudioConfiguration& config, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Set the parameters of the video encoder when pushing the stream - * - * @param config Video encoder parameters - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setVideoStreamConfiguration(const RtmpStreamingVideoConfiguration& config, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Adjusts the audio volume for publishing. - * - * @param volume The volume for publishing. The value ranges between 0 and 100 (default). - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int adjustRecordingSignalVolume(int volume, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Gets the current volume for publishing. - * @param volume A pointer to the publishing volume. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getRecordingSignalVolume(int32_t* volume) = 0; - - /** - * Dynamically adjust the bit rate parameters of the video encoder in the push stream - * - * @note: When increasing the bit rate, each call increases by 50kbps; - * When you lower the bit rate, you reduce it by 100kbps per call - * - * @param type The type of adjustment mode for the bit-rate parameter of the video encoder in the push stream: - * - `Increasing`: Increase the video encoding bitrate. - * - `Decreasing`: Reduce video encoding bitrate - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int adjustVideoBitrate(VideoBitrateAdjustType type, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Set whether to enable local video - * - * @param enabled Whether to enable local video: - * - `true`: Enable local video. - * - `false`: Disable local video. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setVideoEnabled(bool enabled, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Publishes a local audio track to the RTMP connection. - * - * @param audioTrack The local audio track to be published: ILocalAudioTrack. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int publishAudio(agora_refptr audioTrack, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Stops publishing the local audio track to the RTMP connection. - * - * @param audioTrack The local audio track that you want to stop publishing: ILocalAudioTrack. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unpublishAudio(agora_refptr audioTrack, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Publishes a local video track to the RTMP connection. - * - * @param videoTrack The local video track to be published: ILocalVideoTrack. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int publishVideo(agora_refptr videoTrack, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Stops publishing the local video track to the RTMP connection. - * - * @param videoTrack The local video track that you want to stop publishing: ILocalVideoTrack. - * - 0: Success. - * - < 0: Failure. - */ - virtual int unpublishVideo(agora_refptr videoTrack, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Registers a RTMP user observer object. - * - * You need to implement the IRtmpLocalUserObserver class in this method. Once registered, the - * IRtmpLocalUserObserver receives events sent by the IRtmpLocalUser object. - * - * @param observer The pointer to the IRtmpLocalUserObserver object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerRtmpUserObserver(IRtmpLocalUserObserver* observer, void(*safeDeleter)(IRtmpLocalUserObserver*) = NULL, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Releases the IRtmpLocalUserObserver object previously registered using registerRtmpUserObserver(). - * - * @param observer The pointer to the IRtmpLocalUserObserver object that you want to release. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unregisterRtmpUserObserver(IRtmpLocalUserObserver* observer) = 0; - /** - * Registers an audio frame observer object. - * - * @param observer A pointer to the audio frame observer object: IAudioFrameObserver. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerAudioFrameObserver(media::IAudioPcmFrameSink* observer, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Unregisters an audio frame observer object. - * - * @param observer A pointer to the audio frame observer object: IAudioFrameObserver. - */ - virtual void unregisterAudioFrameObserver(media::IAudioPcmFrameSink* observer) = 0; - - /** - * Registers a video frame observer object. - * - * @param observer A pointer to the video frame observer: IVideoFrameObserver. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerVideoFrameObserver(media::base::IVideoFrameObserver* observer, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Unregisters a video frame observer object. - * - * @param observer A pointer to the video frame observer: IVideoFrameObserver. - */ - virtual void unregisterVideoFrameObserver(media::base::IVideoFrameObserver* observer) = 0; -}; - -} // namespace rtc -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraScreenCapturer.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraScreenCapturer.h deleted file mode 100644 index c06ef80e3..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraScreenCapturer.h +++ /dev/null @@ -1,203 +0,0 @@ -// -// Agora SDK -// -// Copyright (c) 2019 Agora.io. All rights reserved. -// - -#pragma once // NOLINT(build/header_guard) - -#include "AgoraBase.h" -#include "AgoraRefPtr.h" -#include - -namespace agora { -namespace rtc { - -/** - * The IScreenCapturer class, which provides access to the screen capturer. - */ -class IScreenCapturer : public RefCountInterface { - public: -#if defined (_WIN32) || (defined(__APPLE__) && TARGET_OS_MAC && !TARGET_OS_IPHONE) - /** - * Initializes the screen capturer by specifying a display ID. - * - * @note - * This method applies to macOS only. - * - * This method shares a whole or part of a screen specified by the display ID. - * @param displayId The display ID of the screen to be shared. This parameter specifies which screen you want - * to share. - * @param regionRect The reference to the relative location of the region to the screen: Rectangle. - * - If the specified region overruns the screen, only the region within the screen will be captured. - * - If you set `width` or `height` as 0, the whole screen will be captured. - * Note that the coordinates of rectangle are relative to the window and follows system specifications. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int initWithDisplayId(uint32_t displayId, const Rectangle& regionRect) = 0; -#endif - -#if defined(_WIN32) || (defined(__linux__) && !defined(__ANDROID__) && !defined(__OHOS__)) - /** - * Initializes the screen capturer by specifying a screen Rect. - * - * @note - * This method applies to Windows only. - * - * This method shares a whole or part of a screen specified by the screen Rect. - * @param screenRect The reference to the Rect of the screen to be shared. This parameter specifies which screen you want - * to share. - * @param regionRect The reference to the relative location of the region to the screen. See \ref agora::rtc::Rectangle ®ionRect "regionRect". - * - If the specified region overruns the screen, only the region within the screen will be captured. - * - If you set `width` or `height` as 0, the whole screen will be captured. - * Note that the coordinates of rectangle are relative to the window and follows system specifications. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int initWithScreenRect(const Rectangle& screenRect, - const Rectangle& regionRect) = 0; -#endif // TARGET_OS_MAC && !TARGET_OS_IPHONE - - /** - * Initializes the screen capturer by specifying a window ID. - * - * This method shares a whole or part of a window specified by the window ID. - * - * @note - * This method applies to Windows and macOS only. - * @param windowId The ID of the window to be shared. This parameter specifies which window you want - * to share. - * @param regionRect The reference to the relative location of the region to the window. See \ref agora::rtc::Rectangle ®ionRect "regionRect". - * - If the specified region overruns the window, only the region within the screen will be captured. - * - If you set `width` or `height` as 0, the whole window will be captured. - * Note that the coordinates of rectangle are relative to the window and follows system specifications. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int initWithWindowId(view_t windowId, const Rectangle& regionRect) = 0; - - /** - * Sets the content hint for screen sharing. - * - * A content hint suggests the type of the content being shared, so that the SDK applies different - * optimization algorithms to different types of content. - * @param contentHint The content hint for screen capture: \ref rtc::VIDEO_CONTENT_HINT "VIDEO_CONTENT_HINT". - * @return - * - 0: Success. - * - < 0: Failure. - * - ERR_NOT_READY: No screen or window is being shared. - */ - virtual int setContentHint(VIDEO_CONTENT_HINT contentHint, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Updates the screen capture region. - * @param regionRect The reference to the relative location of the region to the screen or window. See \ref agora::rtc::Rectangle "Rectangle". - * - If the specified region overruns the screen or window, the screen capturer captures only the region within it. - * - If you set `width` or `height` as 0, the SDK shares the whole screen or window. - * @return - * - 0: Success. - * - < 0: Failure. - * - No screen or window is being shared. - */ - virtual int updateScreenCaptureRegion(const Rectangle& regionRect, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Set orientation of the captured screen image - * @param VIDEO_ORIENTATION orientaion of the device 0(by default), 90, 180, 270 - */ - virtual int setScreenOrientation(VIDEO_ORIENTATION orientation, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Set frame rate of the screen capture source - * @param rate frame rate (in fps) - */ - virtual int setFrameRate(int rate, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - -#if defined(__ANDROID__) - /** - * Initializes the screen capturer by specifying the Intent data obtained from MediaProjection. - * - * This method shares the whole screen. - * - * @note - * This method applies to Android only. - * @param data The Intent data from `onActivityResult (int requestCode, int resultCode, Intent data)` after you create - * an Intent from `MediaProjection` and sends the Intent to `startActivityForResult`. - * @param dimensions The reference to the captured screen's resolution in terms of width × height. - * - If you set `width` or `height` as 0, the dimensions will be the screen's width × height. - * @return - * - 0: Success. - * - < 0: Failure. - * - ERR_INVALID_ARGUMENT if data is null. - */ - virtual int initWithMediaProjectionPermissionResultData(void* data, - const VideoDimensions& dimensions) = 0; -#endif // __ANDROID__ - - protected: - ~IScreenCapturer() {} -}; - -#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IPHONE) || defined (__OHOS__) -class IScreenCapturer2 : public RefCountInterface { - public: - /** - * Screen capture's resolution. - * - * @param dimensions The reference to the captured screen's resolution in terms of width × height. - * - If you set `width` or `height` as 0, the dimensions will be the screen's width × height. - * @return - * - 0: Success. - * - < 0: Failure. - * - ERR_INVALID_ARGUMENT if data is null. - */ - virtual int setScreenCaptureDimensions(const VideoDimensions& dimensions, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Updates the screen capture region. - * @param regionRect The reference to the relative location of the region to the screen or window. See \ref agora::rtc::Rectangle "Rectangle". - * - If the specified region overruns the screen or window, the screen capturer captures only the region within it. - * - If you set `width` or `height` as 0, the SDK shares the whole screen or window. - * @return - * - 0: Success. - * - < 0: Failure. - * - No screen or window is being shared. - */ - virtual int updateScreenCaptureRegion(const Rectangle& regionRect, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Set frame rate of the screen capture source - * @param rate frame rate (in fps) - */ - virtual int setFrameRate(int rate, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Set channels and sample rate of screen audio capturing - * @param channels: channels of system audio capture - * @param sampleRate: sample rate of system audio capture - * @return - * - 0: Sucess. - * - < 0: Failure - */ - virtual int setAudioRecordConfig(int channels, int sampleRate, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Set volume of screen audio capturing - * @param volume: volume of system audio capture - * @return - * - 0: Sucess. - * - < 0: Failure - */ - virtual int setAudioVolume(uint32_t volume, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - protected: - virtual ~IScreenCapturer2() {} -}; -#endif - -} // namespace rtc -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraSyncClient.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraSyncClient.h deleted file mode 100644 index 7c8880de2..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraSyncClient.h +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) 2020 Agora.io. All rights reserved - -// This program is confidential and proprietary to Agora.io. -// And may not be copied, reproduced, modified, disclosed to others, published -// or used, in whole or in part, without the express prior written permission -// of Agora.io. - -#pragma once // NOLINT(build/header_guard) -#include "AgoraRefPtr.h" -#include "AgoraBase.h" -#include -#include - -namespace agora { -namespace base { - -enum SyncClientError { - kOk = 0, - kFail = -1, - kConnectSyncFailed = -2, - kConnectDatabaseFailed = -3, - kDisconnectDatabaseFailed = -4, - kDatabaseNotConnected = -5, - kCreateCollectionFailed = -6, - kCollectionNotCreated = -7, - kCollectionExisted = -8, - kInvalidParams = -9, - kNotLoggedIn = -10, - kQueryDocFailed = -11, - kDocNotCreated = -12, -}; - -typedef void(*syncClientCallback)(SyncClientError, void*); -typedef void(*dataBaseOpCallback)(SyncClientError, const char*, void*); -typedef void(*collectionOpCallback)(SyncClientError, const char*, const char*, void*); -typedef void(*queryDocCallback)(SyncClientError error, const char* resultJson, size_t count, bool more, void* userData); - -enum SyncEventType { - kInserted = 0, - kPut = 1, - kDeleted = 2, - - kToBeInserted = 3, - kToBePut = 4, - kToBeDeleted = 5, - - kTransactionBegin = 6, - kTransactionEnd = 7, - kDocSyncEnd = 8, -}; - -/** - * sync client observer - */ -class ISyncClientObserver { - public: - struct CollectionEvent { - SyncEventType type; - const char* path; - const char* value; - }; - virtual void onCollectionEvent(const char* previousJson, const char* curJson, const char* collection, const char* docName, - const CollectionEvent* events, int eventSize) = 0; - virtual void onDatabaseEvent(const char* databaseName, SyncClientError error) = 0; - virtual void onDataException(const char* databaseName, const char* collectionName) = 0; - virtual ~ISyncClientObserver() {}; -}; - -/** - * sync configuration - */ -struct SyncConfig { - const char* appId; - /* shakehand interval in seconds, 0 means enable manual shake hand */ - uint32_t shakehand_interval; - /* connection timeout in seconds */ - uint32_t connection_timeout; - /* compact interval in seconds */ - uint32_t compact_interval; - SyncConfig() : shakehand_interval(1), connection_timeout(10), compact_interval(3600 * 1000) {} -}; - -class ISyncClient : public RefCountInterface { -protected: - virtual ~ISyncClient() {} -public: - - virtual int32_t registerSyncClientObserver(ISyncClientObserver* observer, void(*safeDeleter)(ISyncClientObserver*) = OPTIONAL_NULLPTR, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - virtual int32_t unregisterSyncClientObserver(ISyncClientObserver* observer) = 0; - // client operations - virtual int32_t login(const char* token, const char* channelName, user_id_t userId, syncClientCallback callback, void* userData, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - virtual int32_t queryDoc(const char* database, const char* coll, const char* range_start, const char* range_end, int64_t limits, bool doc_only, bool count_only, queryDocCallback callback, void* userData, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - virtual int32_t logout(aosl_ref_t ares = AOSL_REF_INVALID) = 0; - virtual int32_t renewToken(const char* token, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - // database operations - virtual int32_t connectDatabase(const char* database, dataBaseOpCallback callback, void* userData, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - virtual int32_t disconnectDatabase(const char* database, - dataBaseOpCallback callback, void* userData, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - virtual int32_t createCollection(const char* database, const char* collection, - const char** readable, int readSize, - collectionOpCallback callback, void* userData, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - virtual int32_t deleteCollection(const char* database, const char* collection, - collectionOpCallback callback, void* userData, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - // collection operations - virtual int32_t subscribe(const char* database, const char* collection, - util::AString& snapshotJson) = 0; - virtual int32_t unsubscribe(const char* database, const char* collection, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - virtual int32_t putDoc(const char* database, const char* collection, - const char* docName, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - virtual int32_t deleteDoc(const char* database, const char* collection, - const char* docName, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - virtual int32_t getDocs(const char* database, const char* collection, - util::AString* docNames, uint32_t docSize) = 0; - - // document operations - virtual int32_t putDocValue(const char* database, const char* collection, - const char* docName, const char* jsonValue, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - virtual int32_t updateDocValue(const char* database, const char* collection, - const char* docName, const char* path, - const char* jsonValue, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - virtual int32_t deleteDocValue(const char* database, const char* collection, - const char* docName, const char* path, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - virtual int32_t deleteDocValues(const char* database, const char* collection, const char* docName, - const char** path, uint32_t pathSize, - aosl_ref_t ares = AOSL_REF_INVALID) = 0; - virtual int32_t getDocValue(const char* database, const char* collection, - const char* docName, util::AString& jsonValue) = 0; - virtual int32_t hasPath(const char* database, const char* collection, - const char* docName, const char* path, bool& result) = 0; - virtual int32_t keepAliveDoc(const char* database, const char* collection, - const char* docName, uint32_t ttl, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - // sync operations - virtual int32_t shakehand(aosl_ref_t ares = AOSL_REF_INVALID) = 0; -}; -}// namespace base -}// namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoFrame.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoFrame.h deleted file mode 100644 index 9be3e9cbe..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoFrame.h +++ /dev/null @@ -1,192 +0,0 @@ - -// Copyright (c) 2020 Agora.io. All rights reserved - -// This program is confidential and proprietary to Agora.io. -// And may not be copied, reproduced, modified, disclosed to others, published -// or used, in whole or in part, without the express prior written permission -// of Agora.io. - -#pragma once // NOLINT(build/header_guard) - -#include "AgoraBase.h" - -#ifndef OPTIONAL_ENUM_CLASS -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) -#define OPTIONAL_ENUM_CLASS enum class -#else -#define OPTIONAL_ENUM_CLASS enum -#endif -#endif - -namespace agora { -namespace rtc { - -/** - * This structure defines the video frame of texture type on Android - * @note For technical preview, not supported for the moment. Use RawPixelBuffer instead. - * - */ -struct TextureInfo { - OPTIONAL_ENUM_CLASS TextureType { - kGlTextureOes, - kGlTexture2D, - }; - OPTIONAL_ENUM_CLASS EglContextType { - kEglContext10, - kEglContext14, - }; - - TextureType texture_type; - EglContextType context_type; - void* shared_context; - int texture_id; - int64_t fence_object; - int frame_buffer_id; - float transform_matrix[16]; -}; - -/** - * This structure defines the raw video frame data in memory - * - */ -struct RawPixelBuffer { - OPTIONAL_ENUM_CLASS Format { - kUnknown, - kI420, - kI422, - kNV21, - kNV12, - kI010, - kRGBA, - kARGB, - kBGRA, - kABGR - }; - Format format; - uint8_t* data; - int size; -}; - -struct PaddedRawPixelBuffer { - RawPixelBuffer::Format format; - uint8_t* data; - int size; - int stride; - PaddedRawPixelBuffer() - : data(NULL), size(0), stride(0) {} -}; - -/** - * This structure defines underlying detailed video frame data of @ref agora::rtc::IVideoFrame - * - */ -struct VideoFrameData { - OPTIONAL_ENUM_CLASS Type { - kRawPixels, // Raw pixels in memory - kTexture, // Deprecated Android: GL_TEXTURE_2D/GL_TEXTURE_OES - kCVPixelBuffer, // iOS: CVPixelBufferRef - kPaddedRawPixels, // Raw pixels with paddings - kTextureOES,// Android: GL_TEXTURE_OES - kTexture2D, // Android: GL_TEXTURE_2D - }; - Type type; - union { - TextureInfo texture; // Android (To be supported) - RawPixelBuffer pixels; // All platform - void* cvpixelbuffer; // iOS (To be supported) - }; - int width; - int height; - int rotation; - agora::media::base::ColorSpace color_space; - int64_t timestamp_ms; // Capture time in milli-seconds -}; - -struct VideoFrameDataV2 : public VideoFrameData { - PaddedRawPixelBuffer padded_pixels; // All platform -}; - -OPTIONAL_ENUM_CLASS VideoFrameMetaDataType { - kAlphaChannel, - kScreenMetaInfo, - kVideoSourceType, - kFaceInfo, - kFaceCaptureInfo, - // Add other types afterwards -}; - -struct AlphaChannel { - uint8_t* data; - int size; -}; - -typedef int32_t VideoSourceType; - -/** - * The IVideoFrame class defines the interface to - * send video frame data to the SDK or get video frame data from the SDK. - */ -class IVideoFrame : public RefCountInterface { - public: - /** - * Get the concrete video frame data of the underlying buffer. - * @param data [out] The video frame data. - * @return - * - int: error code. 0 for success. - */ - virtual int getVideoFrameData(VideoFrameData& data) const = 0; - - /** - * Fill the underlying buffer with source buffer info contained in VideoFrameData - * For frames of type "Type::kMemPixels", This function first tries to fill in-place with no copy and reallocation. - * When it fails, a copy or copy-plus-reallocation may happen - * @param data [in] Data to be filled in. - * @return - * - 0: if succeeds - * - <0: failure - */ - virtual int fillVideoFrameData(const VideoFrameData& data) = 0; - - /** - * Get the underlying meta data of the given type. - * e.g. If type is VideoFrameMetaDataType::kAlphaChannel, then data value can be casted to AlphaChannel; - * @param type @ref VideoFrameMetaDataType type of the meta data wanted - * @param data [out] pointer to the the meta data object of the given type - * @return - * - 0: if succeeds - * - <0: failure - */ - virtual int getVideoFrameMetaData(VideoFrameMetaDataType type, void* data) = 0; - - /** - * Fill the underlying meta data of the given type. - * e.g. If type is VideoFrameMetaDataType::kAlphaChannel, then data should point to AlphaChannel object; - * @param type @ref VideoFrameMetaDataType type of the meta data to fill - * @param data [in] pointer to the the meta data object of the given type - * @return - * - 0: if succeeds - * - <0: failure - */ - virtual int fillVideoFrameMetaData(VideoFrameMetaDataType type, const void* data) = 0; - - protected: - ~IVideoFrame() {} -}; - -class IVideoFrameMemoryPool : public RefCountInterface { - public: - /** - * Create IVideoFrame - * @param data video frame data of the new video frame - * @param metatypes pointer to the array of meta types - * @param count number of the meta types in the array - */ - virtual agora::agora_refptr createVideoFrame( - const VideoFrameData& data, const VideoFrameMetaDataType* metatypes = NULL, int count = 0) = 0; - - protected: - virtual ~IVideoFrameMemoryPool() {} -}; - -} // namespace rtc -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoMixerSource.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoMixerSource.h deleted file mode 100644 index 58d085b6b..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoMixerSource.h +++ /dev/null @@ -1,159 +0,0 @@ -// -// Agora SDK -// -// Copyright (c) 2018 Agora.io. All rights reserved. -// - -#pragma once // NOLINT(build/header_guard) - -#include "AgoraBase.h" -#include "AgoraRefPtr.h" -#include "IAgoraService.h" - -namespace agora { -namespace rtc { - -class IVideoTrack; - -struct MixerLayoutConfig { - int32_t x; - int32_t y; - int32_t width; - int32_t height; - int32_t zOrder; // larger zOrder prioritizes smaller ones - float alpha; - bool mirror; - const char* image_path; // url of the place holder picture - - MixerLayoutConfig() : x(0), y(0), width(0), height(0), zOrder(0), alpha(1.0), mirror(false), image_path(NULL) {} - MixerLayoutConfig(int ox, int oy, int w, int h, int order) : x(ox), y(oy), width(w), height(h), zOrder(order), alpha(1.0), mirror(false), image_path(NULL) {} -}; - -enum ImageType { - kPng, - kJpeg, - kGif -}; - -/** - * The IVideoMixerSource class abstracts a multi-in-multi-out video source which receives video - * streams from multiple local or remote video tracks and generate mixed video stream in user defined output - * format. When only one video track is added to the mixer, it simply forwards the incoming video frames - * to its sinks. - */ -class IVideoMixerSource : public RefCountInterface { -public: - /** - * Add a video track for mixing. - * @param id The unique id of the stream. - * @param track The instance of the video track that you want mixer to receive its video stream. - * @return - * 0 - Success - * <0 - Failure - */ - virtual int addVideoTrack(const char* id, agora_refptr track, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Remove the video track. - * @param id The unique id of the stream. - * @param track The instance of the video track that you want to remove from the mixer. - * @return - * 0 - Success - * <0 - Failure - */ - virtual int removeVideoTrack(const char* id, agora_refptr track, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Configures the layout of video frames comming from a specific track (indicated by uid) - * on the mixer canvas. - * @param id The unique id of the stream. - * @param config The layout configuration - * @return - * 0 - Success - * <0 - Failure - */ - virtual int setStreamLayout(const char* id, const MixerLayoutConfig& config, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Remove the user layout on the mixer canvas - * @param id The unique id of the stream. - * @param uid The uid of the stream. - * @return - * 0 - Success - * <0 - Failure - */ - virtual int delStreamLayout(const char* id, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Add a image source to the mixer with its layout configuration on the mixer canvas. - * @param id The unique id of the image. - * @param config The layout configuration - * @return - * 0 - Success - * <0 - Failure - */ - virtual int addImageSource(const char* id, const MixerLayoutConfig& config, ImageType type = kPng, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Delete a image source to the mixer. - * @param id The unique id of the image. - * @return - * 0 - Success - * <0 - Failure - */ - virtual int delImageSource(const char* id, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Clear all the layout settings set previously - */ - virtual int clearLayout(aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Refresh the user layout on the mixer canvas - * @return - * 0 - Success - * <0 - Failure - */ - virtual int refresh(aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Set the mixer canvas background to override the default configuration - * @param width width of the canvas - * @param height height of the canvas - * @param fps fps of the mixed video stream - * @param color_argb mixer canvas background color in argb - * @return - * 0 - Success - * <0 - Failure - */ - virtual int setBackground(uint32_t width, uint32_t height, int fps, uint32_t color_argb = 0, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Set the mixer canvas background to override the default configuration - * @param width width of the canvas - * @param height height of the canvas - * @param fps fps of the mixed video stream - * @param url URL of the canvas background image - * @return - * 0 - Success - * <0 - Failure - */ - virtual int setBackground(uint32_t width, uint32_t height, int fps, const char* url, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Set the rotation of the mixed video stream - * @param rotation:0:none, 1:90°, 2:180°, 3:270° - * @return - * 0 - Success - * <0 - Failure - */ - virtual int setRotation(uint8_t rotation, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Get the average delay in ms introduced by the mixer module, which includes the average - * mixing delay plus the encoder delay. - * @return - * delay in ms - */ - virtual int getAvgMixerDelay() = 0; - /** - * Set the master clock source for mixed video frame. The master clock source serves as the - * reference clock for audio/video synchronization after mixing. - * @return - * 0 - Success - * <0 - Failure - */ - virtual int setMasterClockSource(const char* id = NULL, aosl_ref_t ares = AOSL_REF_INVALID) = 0; -}; - -} //namespace rtc -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoTrack.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoTrack.h deleted file mode 100644 index ea36ee93e..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/NGIAgoraVideoTrack.h +++ /dev/null @@ -1,620 +0,0 @@ - -// Copyright (c) 2019 Agora.io. All rights reserved - -// This program is confidential and proprietary to Agora.io. -// And may not be copied, reproduced, modified, disclosed to others, published -// or used, in whole or in part, without the express prior written permission -// of Agora.io. - -#pragma once // NOLINT(build/header_guard) - -#include "AgoraBase.h" -#include - -#ifndef OPTIONAL_OVERRIDE -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) -#define OPTIONAL_OVERRIDE override -#else -#define OPTIONAL_OVERRIDE -#endif -#endif - -namespace agora { -namespace rtc { -class IVideoFilter; -class IVideoEncodedFrameObserver; -class IMediaPacketReceiver; -class IVideoSinkBase; - -enum StreamLayerIndexInternal { - STREAM_LAYER_1 = 1, - STREAM_LAYER_2 = 2, - STREAM_LAYER_3 = 3, - STREAM_LAYER_4 = 4, - STREAM_LAYER_5 = 5, - STREAM_LAYER_6 = 6, - STREAM_LOW = 7, - STREAM_LAYER_COUNT_MAX = 8 - }; - -struct StreamLayerConfigInternal { - VideoDimensions dimensions; - int framerate; - int bitrate_kbps; - bool enable; - StreamLayerConfigInternal() : dimensions(0, 0), framerate(0), bitrate_kbps(STANDARD_BITRATE), enable(false) {} - StreamLayerConfigInternal(const StreamLayerConfigInternal& other) : dimensions(other.dimensions), framerate(other.framerate), bitrate_kbps(other.bitrate_kbps), enable(other.enable) {} - bool operator==(const StreamLayerConfigInternal& rhs) const { - return dimensions == rhs.dimensions && bitrate_kbps == rhs.bitrate_kbps && framerate == rhs.framerate && enable == rhs.enable; - } - - StreamLayerConfigInternal& operator=(const SimulcastConfig::StreamLayerConfig& slc) { - dimensions = slc.dimensions; - framerate = slc.framerate; - enable = slc.enable; - return *this; - } - - void reset() { - dimensions.width = 0; - dimensions.height = 0; - framerate = 0; - bitrate_kbps = STANDARD_BITRATE; - enable = false; - } -}; - -struct SimulcastConfigInternal { - StreamLayerConfigInternal simulcastlayerConfigs[STREAM_LAYER_COUNT_MAX]; - - void reset() { - for (int i = STREAM_LAYER_1; i < STREAM_LAYER_COUNT_MAX; i++) { - simulcastlayerConfigs[i].reset(); - } - } - - bool operator==(const SimulcastConfigInternal& rhs) const { - for (int i = 0; i < STREAM_LAYER_COUNT_MAX; i++) { - if (simulcastlayerConfigs[i] == rhs.simulcastlayerConfigs[i]) { - continue; - } else { - return false; - } - } - return true; - } -}; - -enum VideoTrackType { - LOCAL_VIDEO_TRACK, - REMOTE_VIDEO_TRACK, - REMOTE_VIDEO_IMAGE_TRACK, -}; - -/** - * The `IVideoTrack` class defines the behavior and status of a video track. - */ -class IVideoTrack : public RefCountInterface { - public: - /** - * Adds a video filter to the video track. - * - * Add a video filter in either of the following ways: - * - Use the \ref agora::rtc::IMediaNodeFactory "IMediaNodeFactory" object to create a built-in video filter. - * - Use a custom video filter by implementing the \ref agora::rtc::IVideoFilter "IVideoFilter" class. - * - * To add multiple filters, call this method multiple times. The order of the added filters depends on when - * the app successfully adds the filter. - * - * @param filter The video filter that you want to add to the video track. - * @param position The position where the filter is added. - * @param id id of the filter - * @return - * - `true`: The video filter is added successfully. - * - `false`: The video filter fails to be added. - */ - virtual bool addVideoFilter( - agora_refptr filter, media::base::VIDEO_MODULE_POSITION position = media::base::POSITION_POST_CAPTURER, - const char* id = NULL, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Removes the video filter added by `addVideoFilter` from the video track. - * - * @param filter The video filter that you want to remove: `IVideoFilter`. - * @param position The position of the filter. - * @id id of the filter - * @return - * - `true`: The video filter is removed successfully. - * - `false`: The video filter fails to be removed. - */ - virtual bool removeVideoFilter( - agora_refptr filter, media::base::VIDEO_MODULE_POSITION position = media::base::POSITION_POST_CAPTURER, - const char* id = NULL, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Whether a video filter exists - * @param id id of the filter - * @return - * - true: exist - * - false: not exist - */ - virtual bool hasVideoFilter(const char* id, media::base::VIDEO_MODULE_POSITION position = media::base::POSITION_POST_CAPTURER) = 0; - - /** - * Adds a video renderer to the video track. - * - * Add a video renderer in either of the following ways: - * - Use the built-in video renderer by implementing the `IVideoRenderer` in the `IMediaNodeFactory` class. - * - Use a custom video renderer by implementing the `IVideoSinkBase` class. - * - * @param videoRenderer The video renderer that you want to add: IVideoSinkBase. - * @param position The position where the renderer is added. - * - * @return - * - `true`: The video renderer is added successfully. - * - `false`: The video renderer fails to be added. - */ - virtual bool addRenderer(agora_refptr videoRenderer, media::base::VIDEO_MODULE_POSITION position, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Removes the video renderer added by `addRenderer` from the video track. - * - * @param videoRenderer The video renderer that you want to remove: IVideoSinkBase. - * @param position The position where the renderer is removed: \ref media::base::VIDEO_MODULE_POSITION "VIDEO_MODULE_POSITION". - * @return - * - `true`: The video renderer is removed successfully. - * - `false`: The video renderer fails to be removed. - */ - virtual bool removeRenderer(agora_refptr videoRenderer, media::base::VIDEO_MODULE_POSITION position, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Get the track type of the video track - * @return - * - VideoTrackType - */ - virtual VideoTrackType getType() = 0; - - /** - * Enable / Disable specified video filter - * @param id id of the filter - * @param enable enable / disable the filter with given id - * @return - * - 0: success - * - <0: failure - */ - virtual int enableVideoFilter(const char* id, bool enable, aosl_ref_t ares = AOSL_REF_INVALID) { return -1; } - - /** - * set the properties of the specified video filter - * @param id id of the filter - * @param key key of the property - * @param json_value json str value of the property - * @return - * - 0: success - * - <0: failure - */ - virtual int setFilterProperty(const char* id, const char* key, const char* json_value, aosl_ref_t ares = AOSL_REF_INVALID) { return -1; } - - /** - * get the properties of the specified video filter - * @param id id of the filter - * @param key key of the property - * @param json_value json str value of the property - * @return - * - 0: success - * - <0: failure - */ - virtual int getFilterProperty(const char* id, const char* key, char* json_value, size_t buf_size, aosl_ref_t ares = AOSL_REF_INVALID) { return -1; } - - protected: - ~IVideoTrack() {} -}; - -struct SimulcastStreamProfile { - int width; - int height; - int framerate; - int bitrate; -}; -/** - * The statistics of the local video track. - */ -struct LocalVideoTrackStats { - /** - * The number of streams. - */ - uint64_t number_of_streams; - /** - * The number of bytes of the major stream. - */ - uint64_t bytes_major_stream; - /** - * The number of bytes of the minor stream. - */ - uint64_t bytes_minor_stream; - /** - * The number of encoded frames. - */ - uint32_t frames_encoded; - /** - * The SSRC (synchronization source) of the major stream. - */ - uint32_t ssrc_major_stream; - /** - * The SSRC (synchronization source) of the minor stream. - */ - uint32_t ssrc_minor_stream; - /** - * The capture frame rate of the video. - */ - int capture_frame_rate; - /** - * The regulated frame rate of capture frame rate according to video encoder configuration. - */ - int regulated_capture_frame_rate; - /** - * The input frame rate of the encoder. - */ - int input_frame_rate; - /** - * The output frame rate of the encoder. - */ - int encode_frame_rate; - /** - * The rendering frame rate. - */ - int render_frame_rate; - /** - * The target bitrate (bps). - */ - int target_media_bitrate_bps; - /** - * The frame rate excluding FEC. - */ - int media_bitrate_bps; - /** - * The total frame rate including FEC. - */ - int total_bitrate_bps; // Include FEC - /** - * The capture frame width (pixel). - */ - int capture_width; - /** - * The capture frame height (pixel). - */ - int capture_height; - /** - * The regulated frame width (pixel) of capture frame width according to video encoder configuration. - */ - int regulated_capture_width; - /** - * The regulated frame height (pixel) of capture frame height according to video encoder configuration. - */ - int regulated_capture_height; - /** - * The frame width (pixel). - */ - int width; - /** - * The frame height (pixel). - */ - int height; - uint32_t encoder_type; - uint32_t hw_encoder_accelerating; - /* - * encoder vender id, VideoCodecVenderId - */ - uint32_t encoder_vender_id; - /** - * The average time diff between frame captured and framed encoded. - */ - uint32_t uplink_cost_time_ms; - /** Quality change of the local video in terms of target frame rate and - * target bit rate in this reported interval. See #QUALITY_ADAPT_INDICATION. - */ - QUALITY_ADAPT_INDICATION quality_adapt_indication; - /** - * The video packet loss rate (%) from the local client to the Agora edge server before applying the anti-packet loss strategies. - */ - unsigned short txPacketLossRate; - - /** The brightness level of the video image captured by the local camera. See #CAPTURE_BRIGHTNESS_LEVEL_TYPE. - */ - CAPTURE_BRIGHTNESS_LEVEL_TYPE capture_brightness_level; - - SimulcastStreamProfile simulcast_stream_profile[STREAM_LAYER_COUNT_MAX]; - - LocalVideoTrackStats() : number_of_streams(0), - bytes_major_stream(0), - bytes_minor_stream(0), - frames_encoded(0), - ssrc_major_stream(0), - ssrc_minor_stream(0), - capture_frame_rate(0), - regulated_capture_frame_rate(0), - input_frame_rate(0), - encode_frame_rate(0), - render_frame_rate(0), - target_media_bitrate_bps(0), - media_bitrate_bps(0), - total_bitrate_bps(0), - capture_width(0), - capture_height(0), - regulated_capture_width(0), - regulated_capture_height(0), - width(0), - height(0), - encoder_type(0), - hw_encoder_accelerating(0), - encoder_vender_id(0), - uplink_cost_time_ms(0), - quality_adapt_indication(ADAPT_NONE), - txPacketLossRate(0), - capture_brightness_level(CAPTURE_BRIGHTNESS_LEVEL_INVALID) {} -}; - -/** - * `ILocalVideoTrack` is the basic class for local video tracks, providing the main methods of local video tracks. - * You can create a local video track by calling one of the following methods: - * - `createCameraVideoTrack` - * - `createScreenVideoTrack` - * - `createMixedVideoTrack` - * - `createCustomVideoTrack` - * - `createMediaPlayerVideoTrack` - * - * After creating local video tracks, you can publish one or more local video tracks by calling \ref agora::rtc::ILocalUser::publishVideo "publishVideo". - */ -class ILocalVideoTrack : public IVideoTrack { - public: - /** - * Enables or disables the local video track. - * - * Once the local video track is enabled, the SDK allows for local video capturing, processing, and encoding. - * - * @param enable Determines whether to enable the local video track. - * - `true`: Enable the local video track. - * - `false`: Disable the local video track. - */ - virtual int setEnabled(bool enable, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Sets the video encoder configuration. - * - * Each video encoder configuration corresponds to a set of video parameters, including the - * resolution, frame rate, bitrate, and video orientation. - * - * The configurations specified in this method are the maximum values under ideal network conditions. If - * the video engine cannot render the video using the specified parameters due to poor network - * conditions, the configurations further down the list are considered until a successful configuration - * is found. - * - * @param config The reference to the video encoder configuration. See \ref agora::rtc::VideoEncoderConfiguration "VideoEncoderConfiguration". - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setVideoEncoderConfiguration(const VideoEncoderConfiguration& config, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Set simulcast stream mode, enable, disable or auto enable - * - * @param mode Determines simulcast stream mode. See \ref agora::rtc::SIMULCAST_STREAM_MODE "SIMULCAST_STREAM_MODE". - * @param config The reference to the configurations for the simulcast stream mode. See \ref agora::rtc::SimulcastStreamConfig "SimulcastStreamConfig". - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setSimulcastStreamMode(SIMULCAST_STREAM_MODE mode, const SimulcastConfigInternal& config, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - - /** - * Gets the state of the local video stream. - * - * @return The current state of the local video stream. - */ - virtual LOCAL_VIDEO_STREAM_STATE getState() = 0; - - /** - * Gets the statistics of the local video track. - * - * @param[out] stats The reference to the statistics of the local video track. - * @return - * - `true`: Success. - * - `false`: Failure. - */ - virtual bool getStatistics(LocalVideoTrackStats& stats) = 0; - - virtual VideoTrackType getType() OPTIONAL_OVERRIDE { return LOCAL_VIDEO_TRACK; } - - protected: - ~ILocalVideoTrack() {} -}; -/** - * The struct of RemoteVideoTrackStats. - */ -struct RemoteVideoTrackStats { - /** - The ID of the remote user. - */ - uid_t uid; - /** - * The overall delay (ms) of the video frames. - */ - int delay; - /** - * End-to-end delay from video capturer to video renderer. Hardware capture or render delay is excluded. - */ - int e2eDelay; - /** - * The width (pixel) of the remote video track. - */ - int width; - /** - * The height (pixel) of the remote video track. - */ - int height; - /** - * The bitrate (Kbps) received in the reported interval. - */ - int receivedBitrate; - /** The decoder input frame rate (fps) of the remote video track. - */ - int decoderInputFrameRate; - /** The decoder output frame rate (fps) of the remote video track. - */ - int decoderOutputFrameRate; - /** The render output frame rate (fps) of the remote video track. - */ - int rendererOutputFrameRate; - /** The video frame loss rate (%) of the remote video stream in the reported interval. - */ - int frameLossRate; - /** The packet loss rate (%) of the remote video track after using the anti-packet-loss method. - */ - int packetLossRate; - /** - * The remote video stream type: #VIDEO_STREAM_TYPE. - */ - VIDEO_STREAM_TYPE rxStreamType; - /** - The total freeze time (ms) of the remote video track after the remote user joins the channel. - In a video session where the frame rate is set to no less than 5 fps, video freeze occurs when - the time interval between two adjacent renderable video frames is more than 500 ms. - */ - int totalFrozenTime; - /** - The total video freeze time as a percentage (%) of the total time when the video is available. - */ - int frozenRate; - /** - * The number of video bytes received. - */ - uint32_t received_bytes; - /** - The total number of decoded video frames. - */ - uint32_t totalDecodedFrames; - /** - The offset (ms) between audio and video stream. A positive value indicates the audio leads the - video, and a negative value indicates the audio lags the video. - */ - int avSyncTimeMs; - /** - The average offset(ms) between receive first packet which composite the frame and the frame - ready to render. - */ - uint32_t downlink_process_time_ms; - /** - The average time cost in renderer. - */ - uint32_t frame_render_delay_ms; - /** - The total time (ms) when the remote user neither stops sending the video - stream nor disables the video module after joining the channel. - */ - uint64_t totalActiveTime; - /** - The total publish duration (ms) of the remote video stream. - */ - uint64_t publishDuration; - /** - decoded frame vqa mos value after all filter. - */ - int vqa_mos; - /** - vqa avg cost ms - */ - int vqa_avg_cost_ms; - /** - decoder vender id, VideoCodecVenderId - */ - uint32_t decoder_vender_id; - /** - The decoder codec type of the remote video track - */ - uint32_t decoder_type; - - RemoteVideoTrackStats() : uid(0), delay(0), width(0), height(0), - receivedBitrate(0), decoderInputFrameRate(0), decoderOutputFrameRate(0), rendererOutputFrameRate(0), - frameLossRate(0), packetLossRate(0), rxStreamType(VIDEO_STREAM_HIGH), - totalFrozenTime(0), frozenRate(0), received_bytes(0), totalDecodedFrames(0), avSyncTimeMs(0), - downlink_process_time_ms(0), frame_render_delay_ms(0), totalActiveTime(0), - publishDuration(0), vqa_mos(0), vqa_avg_cost_ms(0), decoder_vender_id(0), decoder_type(0) {} -}; - -/** - * The IRemoteVideoTrack class. - */ -class IRemoteVideoTrack : public IVideoTrack { - public: - /** - * Gets the statistics of the remote video track. - * @param[out] stats The reference to the statistics of the remote video track. - * @return - * - `true`: Success. - * - `false`: Failure. - */ - virtual bool getStatistics(RemoteVideoTrackStats& stats) = 0; - /** - * Gets the state of the remote video track. - * @return The state of the remote video track. - */ - virtual REMOTE_VIDEO_STATE getState() = 0; - /** - * Gets the information of the remote video track. - * @param[out] info The reference to the information of the remote video track. - * @return - * - `true`: Success. - * - `false`: Failure. - */ - virtual bool getTrackInfo(VideoTrackInfo& info) = 0; - /** - * Registers an \ref agora::media::IVideoEncodedFrameObserver "IVideoEncodedFrameObserver" object. - * - * You need to implement the `IVideoEncodedFrameObserver` class in this method. Once you successfully register - * the encoded image receiver, the SDK triggers the \ref agora::rtc::IVideoEncodedFrameObserver::onEncodedVideoFrameReceived "onEncodedVideoFrameReceived" callback when it receives the - * encoded video image. - * - * @param encodedObserver The pointer to the `IVideoEncodedFrameObserver` object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerVideoEncodedFrameObserver(agora::media::IVideoEncodedFrameObserver* encodedObserver, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Releases the \ref agora::media::IVideoEncodedFrameObserver "IVideoEncodedFrameObserver" object. - * @param encodedObserver The pointer to the `IVideoEncodedFrameObserver` object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unregisterVideoEncodedFrameObserver(agora::media::IVideoEncodedFrameObserver* encodedObserver) = 0; - - /** - * Registers an \ref agora::rtc::IMediaPacketReceiver "IMediaPacketReceiver" object. - * - * You need to implement the `IMediaPacketReceiver` class in this method. Once you successfully register - * the media packet receiver, the SDK triggers the \ref agora::rtc::IMediaPacketReceiver::onMediaPacketReceived "onMediaPacketReceived" callback when it receives the - * video packet. - * - * @param videoReceiver The pointer to the `IMediaPacketReceiver` object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int registerMediaPacketReceiver(IMediaPacketReceiver* videoReceiver, aosl_ref_t ares = AOSL_REF_INVALID) = 0; - /** - * Releases the \ref agora::rtc::IMediaPacketReceiver "IMediaPacketReceiver" object. - * @param videoReceiver The pointer to the `IMediaPacketReceiver` object. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unregisterMediaPacketReceiver(IMediaPacketReceiver* videoReceiver) = 0; - - virtual VideoTrackType getType() OPTIONAL_OVERRIDE { return REMOTE_VIDEO_TRACK; } - - protected: - ~IRemoteVideoTrack() {} -}; - -} // namespace rtc -} // namespace agora diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/Makefile b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/Makefile deleted file mode 100644 index c2cc00933..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/Makefile +++ /dev/null @@ -1,48 +0,0 @@ -header-y += aosl_alloca.h -header-y += aosl_mm.h -header-y += aosl_atomic.h -header-y += aosl_angel.h -header-y += aosl_defs.h -header-y += aosl_errno.h -header-y += aosl_async.h -header-y += aosl_socket.h -header-y += aosl_fcntl.h -header-y += aosl_file.h -header-$(CONFIG_ENABLE_HTTP) += aosl_http.h -header-y += aosl_input.h -header-y += aosl_integer_wrappings.h -header-$(call |,$(CONFIG_ANDROID),$(CONFIG_ENABLE_JAVA)) += aosl_jni.h -header-y += aosl_list.h -header-y += aosl_log.h -header-$(CONFIG_MARSHALLING) += aosl_marshalling.h -header-y += aosl_mpq.h -header-y += aosl_mpq_fd.h -header-y += aosl_mpq_net.h -header-y += aosl_mpq_timer.h -header-y += aosl_mpqp.h -header-$(CONFIG_PSB) += aosl_psb.h -header-y += aosl_rbtree.h -header-y += aosl_ref.h -header-y += aosl_route.h -header-y += aosl_task.h -header-y += aosl_thread.h -header-y += aosl_time.h -header-y += aosl_types.h -header-y += aosl_utils.h -header-y += aosl_version.h -header-y += aosl_so.h -header-y += aosl_module.h -header-y += aosl_os.h -header-y += aosl_pmdf.h -header-y += aosl_profile.h -header-y += aosl_kobj.h -header-y += aosl_value.h -header-y += aosl_display.h -header-y += aosl_poll.h -header-y += aosl_ares.h -header-y += aosl_dq.h -header-y += cpp/ -header-$(CONFIG_XNU) += objc/ -header-$(CONFIG_AUDIO) += aosl_audio.h -header-$(CONFIG_VIDEO) += aosl_video.h -header-$(CONFIG_XDUMP) += aosl_xdump.h diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_alloca.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_alloca.h deleted file mode 100644 index 1bf745423..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_alloca.h +++ /dev/null @@ -1,22 +0,0 @@ -/************************************************************* - * Author : Lionfore Hao (haolianfu@agora.io) - * Date : Jul 31st, 2020 - * Module : AOSL alloca definition header file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2020 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_ALLOCA_H__ -#define __AOSL_ALLOCA_H__ - -#if defined (__GNUC__) -#include -#elif defined (_MSC_VER) -#include -#endif - -#endif /* __AOSL_ALLOCA_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_angel.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_angel.h deleted file mode 100644 index e57a5028e..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_angel.h +++ /dev/null @@ -1,54 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : May 4th, 2022 - * Module: AOSL angel functionalities definition header file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2020 ~ 2022 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_ANGEL_H__ -#define __AOSL_ANGEL_H__ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -#define AOSL_MPQ_STALLED_THRESHOLD_MS 9000 - -typedef struct { - aosl_thrdid_t thrd_id; - char thrd_name [32]; -} aosl_stalled_info_t; - -typedef void (*aosl_stall_cb_t) (uint32_t stalled_secs, size_t stalled_count, aosl_stalled_info_t *stalled_thrds); - -extern __aosl_api__ int aosl_angel_stall_register (aosl_stall_cb_t f); -extern __aosl_api__ int aosl_angel_stall_unregister (aosl_stall_cb_t f); - - -typedef struct overload_thrd { - aosl_thrdid_t thrd_id; - char thrd_name [32]; - float cpu_usage; -} aosl_ovl_thrd_info_t; - -typedef void (*aosl_ovl_cb_t) (size_t count, aosl_ovl_thrd_info_t *thrds); -extern __aosl_api__ int aosl_angel_ovl_register (aosl_ovl_cb_t f); -extern __aosl_api__ int aosl_angel_ovl_unregister (aosl_ovl_cb_t f); - - -#ifdef __cplusplus -} -#endif - - -#endif /* __AOSL_ANGEL_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_ares.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_ares.h deleted file mode 100644 index 9b5ba7b1f..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_ares.h +++ /dev/null @@ -1,77 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : May 30th, 2023 - * Module: AOSL async result object header file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 ~ 2023 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_ARES_H__ -#define __AOSL_ARES_H__ - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -/** - * Create an async result object. - * Parameter: - * arg: the parameter attached with the async result object; - * Return value: - * the async result object ref id just created, AOSL_REF_INVALID when failed. - **/ -extern __aosl_api__ aosl_ref_t aosl_ares_create (void *arg); - -/** - * Complete the specified async result object. - * Parameters: - * ref: the async result object ref id; - * result: a result value which can be retrieved by wait function; - * Return value: - * <0: error occured, and aosl_errno indicates which error; - * >=0: successful; - **/ -extern __aosl_api__ int aosl_ares_complete (aosl_ref_t ref, intptr_t result); - -/** - * Wait the specified async result object to complete. - * Parameters: - * ref: the async result object ref id; - * timeo: maximum waiting time in milliseconds; - * result: variable address for the value which was set by complete function, - * NOTE: the *result only will be set when the return value of wait - * function is AOSL_POLL_ST_SIGNALED and result != NULL, if you - * do not care the complete result, just passing NULL to it; - * Return value: - * <0: error occured, and aosl_errno indicates which error; - * >=0: AOSL_POLL_ST_* macros value; - **/ -extern __aosl_api__ int aosl_ares_wait (aosl_ref_t ref, intptr_t timeo, intptr_t *result); - -/** - * Reset the specified async result object to non signaled state. - * Parameters: - * ref: the async result object ref id - * Return value: - * <0: error occured, and aosl_errno indicates which error; - * >=0: successful; - **/ -extern __aosl_api__ int aosl_ares_reset (aosl_ref_t ref); - - - -#ifdef __cplusplus -} -#endif - -#endif /* __AOSL_ARES_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_async.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_async.h deleted file mode 100644 index 4e139db5a..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_async.h +++ /dev/null @@ -1,86 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Aug 9th, 2023 - * Module: AOSL async and resume definition file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 ~ 2023 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_ASYNC_H__ -#define __AOSL_ASYNC_H__ - - -#include -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - - -typedef const struct _aosl_stack_ *aosl_stack_id_t; -#define AOSL_STACK_INVALID NULL -#define aosl_stack_invalid(id) ((id) == AOSL_STACK_INVALID) -#define aosl_define_stack(id) aosl_stack_id_t id = (aosl_stack_id_t)&id - -/** - * The async prepare mechanism function prototype. - * Parameter: - * free_only: only do free action, no other action allowed - * argc: specify the argv array elements count - * argv: array for passing variable args - * - * Return value: - * <0: failed, not continue the prepare functions, - * just do free only for the left functions in - * the stack chain; - * other values: success, continue executing left functions; - **/ -typedef int (*aosl_prepare_func_t) (int free_only, uintptr_t argc, uintptr_t argv []); - -extern __aosl_api__ int aosl_async_prepare (aosl_stack_id_t stack_id, aosl_ref_t ref, const char *f_name, aosl_prepare_func_t f, uintptr_t argc, ...); -extern __aosl_api__ int aosl_async_prepare_args (aosl_stack_id_t stack_id, aosl_ref_t ref, const char *f_name, aosl_prepare_func_t f, uintptr_t argc, va_list args); -extern __aosl_api__ int aosl_async_prepare_argv (aosl_stack_id_t stack_id, aosl_ref_t ref, const char *f_name, aosl_prepare_func_t f, uintptr_t argc, uintptr_t argv []); - -/** - * The async resume mechanism function prototype. - * Parameter: - * free_only: only do free action, no other action allowed - * argc: specify the argv array elements count - * argv: array for passing variable args - * - * Return value: - * none. - **/ -typedef void (*aosl_resume_func_t) (int free_only, uintptr_t argc, uintptr_t argv []); - -extern __aosl_api__ int aosl_async_resume (aosl_stack_id_t stack_id, aosl_ref_t ref, const char *f_name, aosl_resume_func_t f, uintptr_t argc, ...); -extern __aosl_api__ int aosl_async_resume_args (aosl_stack_id_t stack_id, aosl_ref_t ref, const char *f_name, aosl_resume_func_t f, uintptr_t argc, va_list args); -extern __aosl_api__ int aosl_async_resume_argv (aosl_stack_id_t stack_id, aosl_ref_t ref, const char *f_name, aosl_resume_func_t f, uintptr_t argc, uintptr_t argv []); - - -/** - * Start a new coroutine block, which acts just like a C/C++ block - * scope, and the coroutine will act as a whole logic unit in the - * block. - **/ -extern __aosl_api__ int aosl_async_block (aosl_argv_f f, uintptr_t argc, ...); -extern __aosl_api__ int aosl_async_block_args (aosl_argv_f f, uintptr_t argc, va_list args); -extern __aosl_api__ int aosl_async_block_argv (aosl_argv_f f, uintptr_t argc, uintptr_t argv []); - - - -#ifdef __cplusplus -} -#endif - - - -#endif /* __AOSL_ASYNC_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_atomic.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_atomic.h deleted file mode 100644 index 5174535f2..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_atomic.h +++ /dev/null @@ -1,70 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jul 23rd, 2018 - * Module: AOSL atomic operation API definitions. - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_ATOMIC_H__ -#define __AOSL_ATOMIC_H__ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -typedef int aosl_atomic_t; -typedef intptr_t aosl_atomic_intptr_t; - - -extern __aosl_api__ int aosl_atomic_read (const aosl_atomic_t *v); -extern __aosl_api__ void aosl_atomic_set (aosl_atomic_t *v, int i); - -extern __aosl_api__ void aosl_atomic_inc (aosl_atomic_t *v); -extern __aosl_api__ void aosl_atomic_dec (aosl_atomic_t *v); - -extern __aosl_api__ int aosl_atomic_add_return (int i, aosl_atomic_t *v); -extern __aosl_api__ int aosl_atomic_sub_return (int i, aosl_atomic_t *v); - -extern __aosl_api__ int aosl_atomic_inc_and_test (aosl_atomic_t *v); -extern __aosl_api__ int aosl_atomic_dec_and_test (aosl_atomic_t *v); - -extern __aosl_api__ int aosl_atomic_cmpxchg (aosl_atomic_t *v, int oldval, int newval); -extern __aosl_api__ int aosl_atomic_xchg (aosl_atomic_t *v, int newval); - - -extern __aosl_api__ intptr_t aosl_atomic_intptr_read (const aosl_atomic_intptr_t *v); -extern __aosl_api__ void aosl_atomic_intptr_set (aosl_atomic_intptr_t *v, intptr_t i); - -extern __aosl_api__ void aosl_atomic_intptr_inc (aosl_atomic_intptr_t *v); -extern __aosl_api__ void aosl_atomic_intptr_dec (aosl_atomic_intptr_t *v); - -extern __aosl_api__ int aosl_atomic_intptr_add_return (intptr_t i, aosl_atomic_t *v); -extern __aosl_api__ int aosl_atomic_intptr_sub_return (intptr_t i, aosl_atomic_t *v); - -extern __aosl_api__ int aosl_atomic_intptr_inc_and_test (aosl_atomic_t *v); -extern __aosl_api__ int aosl_atomic_intptr_dec_and_test (aosl_atomic_t *v); - -extern __aosl_api__ intptr_t aosl_atomic_intptr_cmpxchg (aosl_atomic_intptr_t *v, intptr_t oldval, intptr_t newval); -extern __aosl_api__ intptr_t aosl_atomic_intptr_xchg (aosl_atomic_intptr_t *v, intptr_t newval); - - -extern __aosl_api__ void aosl_mb (void); -extern __aosl_api__ void aosl_rmb (void); -extern __aosl_api__ void aosl_wmb (void); - - -#ifdef __cplusplus -} -#endif - - -#endif /* __AOSL_ATOMIC_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_audio.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_audio.h deleted file mode 100644 index a9b71fcd7..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_audio.h +++ /dev/null @@ -1,182 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jan 26th, 2023 - * Module: AOSL audio relative API definition file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 ~ 2023 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_AUDIO_H__ -#define __AOSL_AUDIO_H__ - - -#include -#include -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - -#define AOSL_PCM_FMT_UNSIGNED 0x80 /* Set if unsigned data for integer format */ -#define AOSL_PCM_FMT_BE 0x40 /* Set if bigendian */ -#define AOSL_PCM_FMT_NONINTERLEAVED 0x20 /* Set if non interleaved data for channels */ - -/* Integer formats */ -#define AOSL_PCM_FMT_I8 0x0 -#define AOSL_PCM_FMT_I16 0x1 -#define AOSL_PCM_FMT_I24 0x2 -#define AOSL_PCM_FMT_I32 0x3 -/* Float formats */ -#define AOSL_PCM_FMT_F32 0x4 -#define AOSL_PCM_FMT_F64 0x5 - -/* format type mask */ -#define AOSL_PCM_FMT_TYPE_MASK 0xf - - -/* Integer, Signed, Interleaved */ -#define AOSL_PCM_FMT_S8 AOSL_PCM_FMT_I8 - -/* Integer, Signed, Little Endian, Interleaved */ -#define AOSL_PCM_FMT_S16_LE AOSL_PCM_FMT_I16 -#define AOSL_PCM_FMT_S24_LE AOSL_PCM_FMT_I24 -#define AOSL_PCM_FMT_S32_LE AOSL_PCM_FMT_I32 - -/* Float: Little Endian, Interleaved */ -#define AOSL_PCM_FMT_FLOAT_LE AOSL_PCM_FMT_F32 -#define AOSL_PCM_FMT_FLOAT64_LE AOSL_PCM_FMT_F64 - -/* Integer: Signed, Big Endian, Interleaved */ -#define AOSL_PCM_FMT_S16_BE (AOSL_PCM_FMT_I16 | AOSL_PCM_FMT_BE) -#define AOSL_PCM_FMT_S24_BE (AOSL_PCM_FMT_I24 | AOSL_PCM_FMT_BE) -#define AOSL_PCM_FMT_S32_BE (AOSL_PCM_FMT_I32 | AOSL_PCM_FMT_BE) - -/* Float: Big Endian, Interleaved */ -#define AOSL_PCM_FMT_FLOAT_BE (AOSL_PCM_FMT_F32 | AOSL_PCM_FMT_BE) -#define AOSL_PCM_FMT_FLOAT64_BE (AOSL_PCM_FMT_F64 | AOSL_PCM_FMT_BE) - -/* Integer, Unsigned, Interleaved */ -#define AOSL_PCM_FMT_U8 (AOSL_PCM_FMT_I8 | AOSL_PCM_FMT_UNSIGNED) - -/* Integer, Unsigned, Little Endian, Interleaved */ -#define AOSL_PCM_FMT_U16_LE (AOSL_PCM_FMT_I16 | AOSL_PCM_FMT_UNSIGNED) -#define AOSL_PCM_FMT_U24_LE (AOSL_PCM_FMT_I24 | AOSL_PCM_FMT_UNSIGNED) -#define AOSL_PCM_FMT_U32_LE (AOSL_PCM_FMT_I32 | AOSL_PCM_FMT_UNSIGNED) - -/* Integer, Unigned, Big Endian, Interleaved */ -#define AOSL_PCM_FMT_U16_BE (AOSL_PCM_FMT_I16 | AOSL_PCM_FMT_UNSIGNED | AOSL_PCM_FMT_BE) -#define AOSL_PCM_FMT_U24_BE (AOSL_PCM_FMT_I24 | AOSL_PCM_FMT_UNSIGNED | AOSL_PCM_FMT_BE) -#define AOSL_PCM_FMT_U32_BE (AOSL_PCM_FMT_I32 | AOSL_PCM_FMT_UNSIGNED | AOSL_PCM_FMT_BE) - -/* Integer, Signed, Noninterleaved */ -#define AOSL_PCM_FMT_S8_N (AOSL_PCM_FMT_I8 | AOSL_PCM_FMT_NONINTERLEAVED) - -/* Integer, Signed, Little Endian, Noninterleaved */ -#define AOSL_PCM_FMT_S16_LE_N (AOSL_PCM_FMT_I16 | AOSL_PCM_FMT_NONINTERLEAVED) -#define AOSL_PCM_FMT_S24_LE_N (AOSL_PCM_FMT_I24 | AOSL_PCM_FMT_NONINTERLEAVED) -#define AOSL_PCM_FMT_S32_LE_N (AOSL_PCM_FMT_I32 | AOSL_PCM_FMT_NONINTERLEAVED) - -/* Float: Little Endian, Noninterleaved */ -#define AOSL_PCM_FMT_FLOAT_LE_N (AOSL_PCM_FMT_F32 | AOSL_PCM_FMT_NONINTERLEAVED) -#define AOSL_PCM_FMT_FLOAT64_LE_N (AOSL_PCM_FMT_F64 | AOSL_PCM_FMT_NONINTERLEAVED) - -/* Integer, Signed, Big Endian, Noninterleaved */ -#define AOSL_PCM_FMT_S16_BE_N (AOSL_PCM_FMT_I16 | AOSL_PCM_FMT_BE | AOSL_PCM_FMT_NONINTERLEAVED) -#define AOSL_PCM_FMT_S24_BE_N (AOSL_PCM_FMT_I24 | AOSL_PCM_FMT_BE | AOSL_PCM_FMT_NONINTERLEAVED) -#define AOSL_PCM_FMT_S32_BE_N (AOSL_PCM_FMT_I32 | AOSL_PCM_FMT_BE | AOSL_PCM_FMT_NONINTERLEAVED) - -/* Float: Big Endian, Noninterleaved */ -#define AOSL_PCM_FMT_FLOAT_BE_N (AOSL_PCM_FMT_F32 | AOSL_PCM_FMT_BE | AOSL_PCM_FMT_NONINTERLEAVED) -#define AOSL_PCM_FMT_FLOAT64_BE_N (AOSL_PCM_FMT_F64 | AOSL_PCM_FMT_BE | AOSL_PCM_FMT_NONINTERLEAVED) - -/* Integer, Unsigned, Noninterleaved */ -#define AOSL_PCM_FMT_U8_N (AOSL_PCM_FMT_I8 | AOSL_PCM_FMT_UNSIGNED | AOSL_PCM_FMT_NONINTERLEAVED) - -/* Integer, Unsigned, Little Endian, Noninterleaved */ -#define AOSL_PCM_FMT_U16_LE_N (AOSL_PCM_FMT_I16 | AOSL_PCM_FMT_UNSIGNED | AOSL_PCM_FMT_NONINTERLEAVED) -#define AOSL_PCM_FMT_U24_LE_N (AOSL_PCM_FMT_I24 | AOSL_PCM_FMT_UNSIGNED | AOSL_PCM_FMT_NONINTERLEAVED) -#define AOSL_PCM_FMT_U32_LE_N (AOSL_PCM_FMT_I32 | AOSL_PCM_FMT_UNSIGNED | AOSL_PCM_FMT_NONINTERLEAVED) - -/* Integer, Unsigned, Big Endian, Noninterleaved */ -#define AOSL_PCM_FMT_U16_BE_N (AOSL_PCM_FMT_I16 | AOSL_PCM_FMT_UNSIGNED | AOSL_PCM_FMT_BE | AOSL_PCM_FMT_NONINTERLEAVED) -#define AOSL_PCM_FMT_U24_BE_N (AOSL_PCM_FMT_I24 | AOSL_PCM_FMT_UNSIGNED | AOSL_PCM_FMT_BE | AOSL_PCM_FMT_NONINTERLEAVED) -#define AOSL_PCM_FMT_U32_BE_N (AOSL_PCM_FMT_I32 | AOSL_PCM_FMT_UNSIGNED | AOSL_PCM_FMT_BE | AOSL_PCM_FMT_NONINTERLEAVED) - -typedef struct { - uint32_t sample_rate; - uint8_t format; - uint8_t channels; -} aosl_pcm_fmt_t; - - -#define AOSL_IOCS_AUDIO_PARAMS 1 -#define AOSL_IOCG_AUDIO_PARAMS 2 - -/* aosl_kobj_ioctl (vfd, AOSL_IOCS_AUDIO_CAP_START, 4, , , , ); */ -#define AOSL_IOCS_AUDIO_CAP_START 3 - -/* aosl_kobj_ioctl (vfd, AOSL_IOCS_AUDIO_CAP_STOP, 0); */ -#define AOSL_IOCS_AUDIO_CAP_STOP 4 - - -typedef aosl_data_t aosl_abuf_t; - -/** - * Get the sample size for the specified PCM format. - * Parameters: - * fmt: the PCM format; - * Return value: - * >0: the sample size (in bytes) for the format; - * <0: failed with aosl_errno set; - **/ -extern __aosl_api__ int aosl_pcm_sample_size (uint8_t fmt); - -/** - * Create an audio buffer with the specified parameters. - * Parameters: - * sample_rate: the PCM sample rate; - * fmt: the PCM format; - * channels: the PCM channels, 1 for mono 2 for stereo etc; - * nms: how many milliseconds audio data the buffer holding; - * Return value: - * non-NULL: the audio buffer created; - * NULL: failed with aosl_errno set; - **/ -extern __aosl_api__ aosl_abuf_t aosl_abuf_create (uint32_t sample_rate, uint8_t fmt, uint8_t channels, uint32_t nms); - -/** - * Get the audio data timestamp in microseconds of a audio buffer object. - * Parameters: - * abuf: the audio buffer object; - * Return value: - * the audio data timestamp in microseconds; - **/ -extern __aosl_api__ aosl_ts_t aosl_abuf_us (aosl_abuf_t abuf); - -/** - * Get the audio data PCM format of a audio buffer object. - * Parameters: - * abuf: the audio buffer object; - * fmt: the buffer for holding the format; - * Return value: - * 0: successful with fmt filled; - * <0: failed with aosl_errno set; - **/ -extern __aosl_api__ int aosl_abuf_fmt (aosl_abuf_t abuf, aosl_pcm_fmt_t *fmt); - - -#ifdef __cplusplus -} -#endif - - - -#endif /* __AOSL_AUDIO_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_byteswap.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_byteswap.h deleted file mode 100644 index 3d54adcfc..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_byteswap.h +++ /dev/null @@ -1,38 +0,0 @@ -/************************************************************* - * Author : Lionfore Hao (haolianfu@agora.io) - * Date : Jul 31st, 2020 - * Module : AOSL byteswap header file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2020 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_BYTESWAP_H__ -#define __AOSL_BYTESWAP_H__ - -#if defined (__linux__) -#include -#elif defined (__MACH__) -#include -#define bswap_32(x) OSSwapInt32(x) -#define bswap_64(x) OSSwapInt64(x) -#elif defined (_WIN32) -#include -#define bswap_32(x) _byteswap_ulong(x) -#define bswap_64(x) _byteswap_uint64(x) -#else -#include -#include - -extern __aosl_api__ uint32_t aosl_bswap_32 (uint32_t v); -extern __aosl_api__ uint64_t aosl_bswap_64 (uint64_t v); - -#define bswap_32(x) aosl_bswap_32(x) -#define bswap_64(x) aosl_bswap_64(x) -#endif - - -#endif /* __AOSL_BYTESWAP_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_data.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_data.h deleted file mode 100644 index 3eca075eb..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_data.h +++ /dev/null @@ -1,155 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jun 6th, 2023 - * Module: AOSL common data memory definition header file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 ~ 2023 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_DATA_H__ -#define __AOSL_DATA_H__ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - - - -typedef struct _aosl_data_buf_ *aosl_data_t; - -typedef enum { - aosl_dt_data, - aosl_dt_abuf, - aosl_dt_vbuf, -} aosl_dt_t; - -/* data destructor */ -typedef void (*aosl_data_dtor_t) (void *ptr, size_t len); - -/** - * Create an data object with the specified parameters. - * Parameters: - * len: the data length; - * dtor: the data buffer destructor function: - * you may want to free some members or call - * the C++ destructor function here; - * Return value: - * non-NULL: the data object pointer; - * NULL: failed with aosl_errno set; - **/ -extern __aosl_api__ aosl_data_t aosl_data_create (size_t len, aosl_data_dtor_t dtor); - -/* user defined data free function */ -typedef void (*aosl_data_user_free_t) (void *ptr, size_t len); - -/** - * Create an data object from the user data buffer pointer. - * Parameters: - * ptr: the data pointer; - * len: the data length; - * dtor: the data buffer free function: - * 1. A libc 'free' like function - * We will take the ownership of the memory pointed by - * ptr, and will invoke the specified destructor when - * finished using. - * 2. An empty function like void myfree (void *ptr, size_t len) {} - * If the memory pointed by ptr is a long life cycle - * memory but does not need to be freed at all, like - * a global data segment based memory, then you can - * pass an empty function pointer as the dtor arg. - * - * Return value: - * non-NULL: the data object pointer; - * NULL: failed with aosl_errno set; - **/ -extern __aosl_api__ aosl_data_t aosl_data_user_create (void *ptr, size_t len, aosl_data_user_free_t dtor); - -/** - * Get the data object type. - * Parameters: - * data: the data object; - * Return value: - * >=0: one of aosl_dt_t value; - * <0: error with aosl_errno set; - **/ -extern __aosl_api__ int aosl_data_type (aosl_data_t d); - -/** - * Increase the data object usage count. - * Parameters: - * data: the data object; - * Return value: - * the current usage count after get; - **/ -extern __aosl_api__ int aosl_data_get (aosl_data_t d); - -/** - * Decrease the data object usage count. - * Parameters: - * data: the data object; - * Return value: - * the current usage count after put. - * The data object would be released - * if the usage count is zero. - **/ -extern __aosl_api__ int aosl_data_put (aosl_data_t d); - -/** - * Get the data object usage count. - * Parameters: - * data: the data object; - * Return value: - * the current usage count; - **/ -extern __aosl_api__ int aosl_data_usage (aosl_data_t d); - -/** - * Get the data pointer of a data object. - * Parameters: - * data: the data object; - * Return value: - * the data memory pointer, need to be put after used; - **/ -extern __aosl_api__ void *aosl_data_ptr_get (aosl_data_t d); - -/** - * Put the data pointer of a data object. - * Parameters: - * data: the data object; - * Return value: - * None. - **/ -extern __aosl_api__ void aosl_data_ptr_put (aosl_data_t d); - -/** - * Get the data length of a data object. - * Parameters: - * data: the data object; - * Return value: - * the data length; - **/ -extern __aosl_api__ size_t aosl_data_len (aosl_data_t d); - -/** - * Retrieve the OS data object pointer of the data object. - * Parameters: - * data: the data object; - * Return value: - * The OS data object pointer, NULL for none. - **/ -extern __aosl_api__ void *aosl_data_os_data (aosl_data_t d); - - - -#ifdef __cplusplus -} -#endif - -#endif /* __AOSL_DATA_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_defs.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_defs.h deleted file mode 100644 index ce2386549..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_defs.h +++ /dev/null @@ -1,171 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jul 21st, 2018 - * Module: AOSL common definitions header file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_DEFS_H__ -#define __AOSL_DEFS_H__ - - -#define aosl_stringify_1(x) #x -#define aosl_stringify(x) aosl_stringify_1(x) - - -#ifndef __MAKERCORE_ASSEMBLY__ - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifdef _MSC_VER -#ifndef __inline__ -#define __inline__ __inline -#endif -#endif - - -#ifndef container_of -#if defined (__GNUC__) -#define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (void *)(ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) -#else -#define container_of(ptr, type, member) ((type *)((char *)(ptr) - offsetof(type,member))) -#endif -#endif - -#define aosl_rela_addr(type, field) (&((type *)0)->field) -#define aosl_base_addr(ptr, type, field) \ - ((type *)((uintptr_t)(ptr) - (uintptr_t)(&((type *)0)->field))) - - -#define aosl_min(x, y) ((x) < (y) ? (x) : (y)) -#define aosl_max(x, y) ((x) > (y) ? (x) : (y)) - - -/* I think 64 args is big enough */ -#define AOSL_VAR_ARGS_MAX 64 - - -#ifdef BUILD_TARGET_SHARED -#if defined (__GNUC__) -#define __export_in_so__ __attribute__ ((visibility ("default"))) -#elif defined (_MSC_VER) -#define __export_in_so__ __declspec (dllexport) -#endif -#else -#define __export_in_so__ -#endif - - -#ifndef __aosl_api__ -#if defined (_MSC_VER) && defined (BUILDING_API_IMPL_SOURCE) && defined (BUILD_TARGET_SHARED) -#define __aosl_api__ __declspec (dllexport) -#elif defined (_MSC_VER) && !defined (BUILDING_API_IMPL_SOURCE) -#define __aosl_api__ __declspec (dllimport) -#else -#define __aosl_api__ -#endif -#endif - -#if defined (BUILDING_API_IMPL_SOURCE) || defined (STATIC_LINKING_AOSL) - -#if defined (__GNUC__) -#define __so_api__ __attribute__ ((visibility ("default"))) -#elif defined (_MSC_VER) -#define __so_api__ __declspec (dllexport) -#else -#define __so_api__ -#endif - -#else - -#if defined (_MSC_VER) -#define __so_api__ __declspec (dllimport) -#else -#define __so_api__ -#endif - -#endif - - -#ifdef __GNUC__ -#ifndef __MACH__ -#define AOSL_DEFINE_BIN(v, f) \ -__asm__ (".section .rodata\n\t" \ - ".globl "#v"_bin_begin\n\t" \ - ".hidden "#v"_bin_begin\n\t" \ - ".align 4\n\t" \ - #v"_bin_begin:\n\t" \ - ".incbin \"" aosl_stringify(MAKERCORE_THIS_FILE_DIR/f)"\"\n\t" \ - ".globl "#v"_bin_end\n\t" \ - ".hidden "#v"_bin_end\n\t" \ - #v"_bin_end:\n\t" \ - ".previous\n\t") -#else -#define AOSL_DEFINE_BIN(v, f) \ -__asm__ (".section __TEXT,__const\n\t" \ - ".globl _"#v"_bin_begin\n\t" \ - ".private_extern _"#v"_bin_begin\n\t" \ - ".align 4\n\t" \ - "_"#v"_bin_begin:\n\t" \ - ".incbin \"" aosl_stringify (MAKERCORE_THIS_FILE_DIR/f) "\"\n\t" \ - ".globl _"#v"_bin_end\n\t" \ - ".private_extern _"#v"_bin_end\n\t" \ - "_"#v"_bin_end:\n\t" \ - ".previous\n\t") -#endif - -#define AOSL_DECLARE_BIN(v) extern unsigned char v##_bin_begin, v##_bin_end -#define AOSL_BIN_ADDR(v) ((void *)&v##_bin_begin) -#define AOSL_BIN_SIZE(v) ((size_t)((unsigned char *)&v##_bin_end - (unsigned char *)&v##_bin_begin)) -#endif - - -#ifdef __cplusplus -} -#endif - -#else /* __MAKERCORE_ASSEMBLY__ */ - -#ifdef __GNUC__ -#ifndef __MACH__ -.macro AOSL_DEFINE_BIN_S v, f - .section .rodata - .globl \v\()_bin_begin - .hidden \v\()_bin_begin - .align 4 - \v\()_bin_begin: - .incbin aosl_stringify (MAKERCORE_THIS_FILE_DIR/\f) - .globl \v\()_bin_end - .hidden \v\()_bin_end - \v\()_bin_end: - .previous -.endm -#else -.macro AOSL_DEFINE_BIN_S v, f - .section __TEXT,__const - .globl _\()\v\()_bin_begin - .private_extern _\()\v\()_bin_begin - .align 4 - _\()\v\()_bin_begin: - .incbin aosl_stringify (MAKERCORE_THIS_FILE_DIR/\f) - .globl _\()\v\()_bin_end - .private_extern _\()\v\()_bin_end - _\()\v\()_bin_end: - .previous -.endm -#endif -#endif - -#endif /* __MAKERCORE_ASSEMBLY__ */ - -#endif /* __AOSL_DEFS_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_display.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_display.h deleted file mode 100644 index 55c3226a3..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_display.h +++ /dev/null @@ -1,54 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Feb 19th, 2023 - * Module: AOSL display relative API definition file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 ~ 2023 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_DISPLAY_H__ -#define __AOSL_DISPLAY_H__ - - -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - - -/** - * Set the global display. - * Parameters: - * display: the display; - * Return value: - * <0: failed with aosl_errno set - * 0: successful - **/ -extern __aosl_api__ int aosl_display_set (void *display); - -/** - * Get the global display. - * Parameters: - * None. - * Return value: - * the display. - **/ -extern __aosl_api__ void *aosl_display_get (void); - - - -#ifdef __cplusplus -} -#endif - - - -#endif /* __AOSL_DISPLAY_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_dq.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_dq.h deleted file mode 100644 index 7021f3b2a..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_dq.h +++ /dev/null @@ -1,77 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jun 6th, 2023 - * Module: AOSL data queue object header file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 ~ 2023 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_DQ_H__ -#define __AOSL_DQ_H__ - -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - - - -/** - * Create a data queue object. - * Parameter: - * max: the maximum queue length; - * Return value: - * !aosl_ref_invalid(ret): the data queue object ref id just created; - * aosl_ref_invalid(ret): create failed with aosl_errno set; - * AOSL_REF_INVALID when failed. - **/ -extern __aosl_api__ aosl_ref_t aosl_dq_create (size_t max); - -/** - * Complete the specified async result object. - * Parameters: - * dque: the data queue object ref id; - * data: the data to be queued to the data queue; - * Return value: - * <0: error occured, and aosl_errno indicates which error; - * >=0: queued the data to dq successfully; - **/ -extern __aosl_api__ int aosl_dq_queue (aosl_ref_t dque, aosl_data_t data); - -/** - * Complete the specified async result object. - * Parameters: - * dque: the data queue object ref id; - * timeo: the max waiting time before dequeuing a data object in ms; - * Return value: - * non-NULL: the dequeued data pointer; - * NULL: failed with aosl_errno set; - **/ -extern __aosl_api__ aosl_data_t aosl_dq_dequeue (aosl_ref_t dque, intptr_t timeo); - -/** - * Complete the specified async result object. - * Parameters: - * dque: the data queue object ref id; - * Return value: - * <0: error occured, and aosl_errno indicates which error; - * >=0: queued the data object count in the dq; - **/ -extern __aosl_api__ int aosl_dq_count (aosl_ref_t dque); - - - -#ifdef __cplusplus -} -#endif - -#endif /* __AOSL_DQ_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_errno.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_errno.h deleted file mode 100644 index 7843ad4a5..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_errno.h +++ /dev/null @@ -1,91 +0,0 @@ -/************************************************************* - * Author : Lionfore Hao (haolianfu@agora.io) - * Date : Jul 30th, 2020 - * Module : AOSL errno definition header file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2020 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_ERRNO_H__ -#define __AOSL_ERRNO_H__ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -#if defined (__linux__) || defined (__MACH__) || defined (_WIN32) || defined (__kliteos__) || defined (__kliteos2__) -#define _AOSL_HAVING_OS_ERRNO -#endif - -#if defined (__linux__) || defined (__MACH__) || defined (__kliteos__) || defined (__kliteos2__) -#define _AOSL_USING_OS_ERRNO -#endif - -#ifdef _AOSL_USING_OS_ERRNO -#define aosl_errno_ptr() (&errno) -#else -extern __aosl_api__ int *aosl_errno_ptr (void); -#endif - -#ifdef _AOSL_HAVING_OS_ERRNO -#include -#define aosl_strerror(err) strerror (err) -#else -/** - * PLEASE BE CAREFUL ENOUGH HERE: - * The macro __kspreadtrum__ is not a compiler toolchain - * predefined macro, and makercore building system will - * define this macro when building Spreadtrum system, so - * you must GUARANTEE define it when not using makercore - * building system. - * Use this style name rather than Kbuild CONFIG_* just - * want to keep consistent with __linux__/__MACH__ etc. - * -- Lionfore Hao Aug 1st, 2020 - **/ -#if defined (__kspreadtrum__) -#include -#endif - -#define errno (*aosl_errno_ptr ()) - -extern __aosl_api__ char *aosl_strerror (int errnum); -#endif - - -#define aosl_errno (*aosl_errno_ptr ()) - - -/** - * Check whether a value returned by aosl api is an error code. - * Parameters: - * err: the value returned by one of aosl api; - * Return Value: - * 1: this value is an error code; - * 0: this value is normal, not an error; -*/ -extern __aosl_api__ int aosl_is_err (intptr_t err); - -/** - * Convert an error code to aosl_errno value. - * Parameters: - * err: the error code value returned by one of aosl api; - * Return Value: - * the corresponding aosl_errno value; -*/ -extern __aosl_api__ int aosl_err_to_errno (intptr_t err); - - -#ifdef __cplusplus -} -#endif - - -#endif /* __AOSL_ERRNO_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_fcntl.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_fcntl.h deleted file mode 100644 index 064d26349..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_fcntl.h +++ /dev/null @@ -1,87 +0,0 @@ -/************************************************************* - * Author : Lionfore Hao (haolianfu@agora.io) - * Date : Jul 31st, 2020 - * Module : AOSL fcntl.h definition header file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2020 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_FCNTL_H__ -#define __AOSL_FCNTL_H__ - -#if defined (__linux__) || defined (__MACH__) || defined (__kliteos2__) || defined (_WIN32) -#include -#include - -#if defined (__linux__) || defined (__MACH__) || defined (__kliteos2__) -#include -#elif defined (_WIN32) -#include /* for open */ -#include /* for mkdir */ - -typedef unsigned short mode_t; -#endif -#elif defined (__kliteos__) -#include -#include - -typedef unsigned int mode_t; -#elif defined (__kaliosthings__) -#include -#include - -typedef unsigned int mode_t; -#elif defined (__kspreadtrum__) -#include - -/* open/fcntl. */ -#define O_ACCMODE 0003 -#define O_RDONLY 00 -#define O_WRONLY 01 -#define O_RDWR 02 - -#ifndef O_CREAT -#define O_CREAT 0100 /* Not fcntl. */ -#endif - -#ifndef O_TRUNC -#define O_TRUNC 01000 /* Not fcntl. */ -#endif - -#ifndef O_APPEND -#define O_APPEND 02000 -#endif - -#ifndef FIONBIO -#define FIONBIO 0 -#endif - -typedef unsigned short mode_t; - -struct stat { -// unsigned long st_dev; -// unsigned long st_ino; -// unsigned short st_mode; -// unsigned short st_nlink; -// unsigned short st_uid; -// unsigned short st_gid; -// unsigned long st_rdev; - size_t st_size; -// unsigned long st_blksize; -// unsigned long st_blocks; -// unsigned long st_atime; -// unsigned long st_atime_nsec; -// unsigned long st_mtime; -// unsigned long st_mtime_nsec; -// unsigned long st_ctime; -// unsigned long st_ctime_nsec; -// unsigned long __unused4; -// unsigned long __unused5; -}; -#endif - -#endif /* __AOSL_FCNTL_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_file.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_file.h deleted file mode 100644 index dcf163ebd..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_file.h +++ /dev/null @@ -1,289 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Aug 16th, 2020 - * Module: AOSL regular file async read/write operations - * definition header file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2020 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_FILE_H__ -#define __AOSL_FILE_H__ - -#include -#include -#include -#include - -/** - * PLEASE BE CAREFUL ENOUGH HERE: - * The macro __kspreadtrum__ is not a compiler toolchain - * predefined macro, and makercore building system will - * define this macro when building Spreadtrum system, so - * you must GUARANTEE define it when not using makercore - * building system. - * Use this style name rather than Kbuild CONFIG_* just - * want to keep consistent with __linux__/__MACH__ etc. - * -- Lionfore Hao Aug 1st, 2020 - **/ -#if defined (__kspreadtrum__) -#include -#elif defined (__kliteos__) -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined (__kspreadtrum__) -#undef SEEK_SET -#undef SEEK_CUR -#undef SEEK_END - -#define SEEK_SET SFS_SEEK_BEGIN -#define SEEK_CUR SFS_SEEK_CUR -#define SEEK_END SFS_SEEK_END - -typedef int64_t off_t; -#endif - -/** - * Cross platform file open function just like the posix open function. - * Parameters: - * file: the file path; - * oflag: the open flag like posix open; - * ...: the mode when specified O_CREAT in the oflag, or ignored; - * Return Value: - * the opened file 'fd', AOSL_INVALID_FD for failed with aosl_errno - * set. - * Remarks: - * For posix platforms, this function acts just like open, but for - * Windows platform, this function is implemented via Win32 API. - **/ -extern __aosl_api__ aosl_fd_t aosl_file_open (const char *file, int oflag, ...); - -/** - * Cross platform get file size function. - * Parameters: - * fd: the file fd; - * Return Value: - * the file size, -1 for failed with aosl_errno set. - **/ -extern __aosl_api__ ssize_t aosl_file_size (aosl_fd_t fd); - -/** - * Cross platform file read function just like the posix read function. - * Parameters: - * fd: the file fd; - * buf: the buffer for holding the read data; - * count: the max bytes to read; - * Return Value: - * the actual read bytes, -1 for failed with aosl_errno set. - **/ -extern __aosl_api__ ssize_t aosl_file_read (aosl_fd_t fd, void *buf, size_t count); - -/** - * Cross platform file write function just like the posix write function. - * Parameters: - * fd: the file fd; - * buf: the buffer holding the writing data; - * count: the number of bytes to write; - * Return Value: - * the actual written bytes, -1 for failed with aosl_errno set. - **/ -extern __aosl_api__ ssize_t aosl_file_write (aosl_fd_t fd, const void *buf, size_t count); - -/** - * Cross platform file seek function just like the posix lseek function. - * Parameters: - * fd: the file fd; - * offset: the argument offset according to the directive whence as follows: - * SEEK_SET - * The file offset is set to offset bytes. - * SEEK_CUR - * The file offset is set to its current location plus offset bytes. - * SEEK_END - * The file offset is set to the size of the file plus offset bytes. - * whence: SEEK_SET/SEEK_CUR/SEEK_END - * Return Value: - * Upon successful completion, returns the resulting offset location as measured in bytes - * from the beginning of the file; - * On error, the value (off_t)-1 is returned with aosl_errno set. - **/ -extern __aosl_api__ off_t aosl_file_lseek (aosl_fd_t fd, off_t offset, int whence); - -/** - * The async file read callback function prototype. - * Parameters: - * free_only: indicates whether this is a 'free only' case, do nothing except freeing - * possible resource for 'free only' cases; - * fd: the file fd; - * ret: the async read return value; - * buf: the buffer holding the read data; - * argc: arguments count passed by async read function; - * argv: the various arguments passed by async read function; - * Return Value: - * None. - **/ -typedef void (*aosl_file_aread_t) (int free_only, aosl_fd_t fd, ssize_t ret, void *buf, uintptr_t argc, uintptr_t argv []); - -/** - * The async file write callback function prototype. - * Parameters: - * free_only: indicates whether this is a 'free only' case, do nothing except freeing - * possible resource for 'free only' cases; - * fd: the file fd; - * ret: the async write return value; - * argc: arguments count passed by async write function; - * argv: the various arguments passed by async write function; - * Return Value: - * None. - **/ -typedef void (*aosl_file_awrite_t) (int free_only, aosl_fd_t fd, ssize_t ret, uintptr_t argc, uintptr_t argv []); - -/** - * The async file seek callback function prototype. - * Parameters: - * free_only: indicates whether this is a 'free only' case, do nothing except freeing - * possible resource for 'free only' cases; - * fd: the file fd; - * ret: the async seek return value; - * argc: arguments count passed by async write function; - * argv: the various arguments passed by async write function; - * Return Value: - * None. - **/ -typedef void (*aosl_file_alseek_t) (int free_only, aosl_fd_t fd, off_t ret, uintptr_t argc, uintptr_t argv []); - -/** - * The async file read function for reading from the specified file asynchronously. - * Parameters: - * fd: the file fd; - * count: the max read bytes; - * f: the async read callback function; - * argc: arguments count would be passed to async callback function; - * ...: the various arguments would be passed to async callback function; - * Return Value: - * 0: successful, and the async callback will be invoked; - * <0: failed with aosl_errno set; - **/ -extern __aosl_api__ int aosl_file_aread (aosl_fd_t fd, size_t count, aosl_file_aread_t f, uintptr_t argc, ...); - -/** - * The async file write function for writing to the specified file asynchronously. - * Parameters: - * fd: the file fd; - * buf: the buffer holding the writing data; - * count: the writing data size in bytes; - * done: the async write done callback function; - * argc: arguments count would be passed to async callback function; - * ...: the various arguments would be passed to async callback function; - * Return Value: - * 0: successful, and the async callback will be invoked; - * <0: failed with aosl_errno set; - **/ -extern __aosl_api__ int aosl_file_awrite (aosl_fd_t fd, const void *buf, size_t count, aosl_file_awrite_t done, uintptr_t argc, ...); - -/** - * The async file seek function for seeking the specified file asynchronously. - * Parameters: - * fd: the file fd; - * offset: the argument offset according to the directive whence as follows: - * SEEK_SET - * The file offset is set to offset bytes. - * SEEK_CUR - * The file offset is set to its current location plus offset bytes. - * SEEK_END - * The file offset is set to the size of the file plus offset bytes. - * whence: SEEK_SET/SEEK_CUR/SEEK_END - * done: the async seek done callback function; - * argc: arguments count would be passed to async callback function; - * ...: the various arguments would be passed to async callback function; - * Return Value: - * 0: successful, and the async callback will be invoked; - * <0: failed with aosl_errno set; - **/ -extern __aosl_api__ int aosl_file_alseek (aosl_fd_t fd, off_t offset, int whence, aosl_file_alseek_t done, uintptr_t argc, ...); - -/* va_list versions */ -extern __aosl_api__ int aosl_file_aread_args (aosl_fd_t fd, size_t count, aosl_file_aread_t f, uintptr_t argc, va_list args); -extern __aosl_api__ int aosl_file_awrite_args (aosl_fd_t fd, const void *buf, size_t count, aosl_file_awrite_t done, uintptr_t argc, va_list args); -extern __aosl_api__ int aosl_file_alseek_args (aosl_fd_t fd, off_t offset, int whence, aosl_file_alseek_t done, uintptr_t argc, va_list args); - -/* args vector versions */ -extern __aosl_api__ int aosl_file_aread_argv (aosl_fd_t fd, size_t count, aosl_file_aread_t f, uintptr_t argc, uintptr_t argv []); -extern __aosl_api__ int aosl_file_awrite_argv (aosl_fd_t fd, const void *buf, size_t count, aosl_file_awrite_t done, uintptr_t argc, uintptr_t argv []); -extern __aosl_api__ int aosl_file_alseek_argv (aosl_fd_t fd, off_t offset, int whence, aosl_file_alseek_t done, uintptr_t argc, uintptr_t argv []); - -/** - * The regular file read function which supports coroutine. - * Parameters: - * fd: the opened file fd; - * d_ret: the data object for holding return value, the - * length must >= sizeof (ssize_t); - * d_buf: the buffer for holding the read data; - * buf_off: the buffer offset for holding the read data; - * Return value: - * <0: failed with aosl_errno set; - * 0: async read issued successfully; - **/ -extern __aosl_api__ int aosl_co_file_read (aosl_fd_t fd, aosl_data_t d_ret, aosl_data_t d_buf, uintptr_t buf_off); - -/** - * The regular file write function which supports coroutine. - * Parameters: - * fd: the opened file fd; - * d_ret: the data object for holding the async write - * done return value, it can be NULL, but if - * set the length must >= sizeof (ssize_t); - * d_buf: the buffer for holding the data for writing; - * count: the writing data bytes; - * Return value: - * <0: failed with aosl_errno set; - * 0: successfully; - **/ -extern __aosl_api__ int aosl_co_file_write (aosl_fd_t fd, aosl_data_t d_ret, aosl_data_t d_buf); - -/** - * Cross platform file seek function just like the posix lseek function. - * Parameters: - * fd: the file fd; - * d_ret: the data object for holding return value, the length must >= sizeof (off_t), - * upon successful completion, returns the resulting offset location as measured - * in bytes from the beginning of the file, on error, the value (off_t)-aosl_errno - * is returned; - * offset: the argument offset according to the directive whence as follows: - * SEEK_SET - * The file offset is set to offset bytes. - * SEEK_CUR - * The file offset is set to its current location plus offset bytes. - * SEEK_END - * The file offset is set to the size of the file plus offset bytes. - * whence: SEEK_SET/SEEK_CUR/SEEK_END - * Return Value: - **/ -extern __aosl_api__ int aosl_co_file_lseek (aosl_fd_t fd, aosl_data_t d_ret, off_t offset, int whence); - -/** - * Cross platform close file function. - * Parameters: - * fd: the file fd; - * Return Value: - * 0: successful; - * <0: failed with aosl_errno set; - **/ -extern __aosl_api__ int aosl_file_close (aosl_fd_t fd); - - - -#ifdef __cplusplus -} -#endif - - -#endif /* __AOSL_FILE_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_http.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_http.h deleted file mode 100644 index 01bfb10cb..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_http.h +++ /dev/null @@ -1,289 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Dec 23rd, 2018 - * Module: AOSL HTTP API definition file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_HTTP_API_H__ -#define __AOSL_HTTP_API_H__ - - -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - -#if 0 /* Will be implemented soon */ -typedef struct http_server *aosl_http_server_t; -typedef struct http_client *aosl_http_client_t; - -typedef enum { - aosl_http_req_type_get, - aosl_http_req_type_options, - aosl_http_req_type_head, - aosl_http_req_type_post, - aosl_http_req_type_put, - aosl_http_req_type_delete, - aosl_http_req_type_trace, - aosl_http_req_type_connect, - aosl_http_req_type_propfind, - aosl_http_req_type_proppatch, - aosl_http_req_type_mkcol, - aosl_http_req_type_copy, - aosl_http_req_type_move, - aosl_http_req_type_lock, - aosl_http_req_type_unlock -} aosl_http_req_type_t; - - -/** - * The http object creating function prototype, which is used to create an http object. - * Parameters: - * arg: the parameter attached with the http object; - * dtor: the http object destructor function, which will be invoked when - * the http object is deleted; - **/ -extern __aosl_api__ aosl_http_conn_t aosl_http_conn_create (const char *host, uint16_t port); - -/** - * The http object creating function prototype, which is used to create an http object. - * Parameters: - * arg: the parameter attached with the http object; - * dtor: the http object destructor function, which will be invoked when - * the http object is deleted; - **/ -extern __aosl_api__ aosl_http_t aosl_http_create (); - -/** - * Add header to http object function prototype, which is used to add a header to an http object. - * Parameters: - * http: the http object; - * key: the header key; - * val: the header value; - * Return value: - * 0: success - * <0: failed, and errno indicates what error occurs - **/ -extern __aosl_api__ int aosl_http_add_header (aosl_http_t http, const char *key, const char *val); - -/** - * Del header from http object function prototype, which is used to add a header to an http object. - * Parameters: - * http: the http object; - * key: the header key; - * Return value: - * 0: success - * <0: failed, and errno indicates what error occurs - **/ -extern __aosl_api__ int aosl_http_del_header (aosl_http_t http, const char *key); - -/** - * Destroy the http object specified by http. - * Parameter: - * http: the http object - * Return value: - * 0: success - * <0: failed, and errno indicates what error occurs - **/ -extern __aosl_api__ int aosl_http_destroy (aosl_http_t http); -#endif - -/** - * Encode a URI string, escape all characters which are not - * allowed to appear in a URI string. - * Parameters: - * buf: the destination buffer pointer to hold the escaped URI - * src: the source URI string - * buf_len: the destination buffer size - * Return value: - * <0: the specified destination buffer too small - * >=0: the escaped URI string length, not including the termination '\0' - **/ -extern __aosl_api__ int aosl_uri_encode (char *buf, const char *src, size_t buf_len); - -typedef void *aosl_http_parser_t; - -#define AOSL_HTTP_PARSER_INVALID ((aosl_http_parser_t)NULL) - -#define aosl_http_parser_invalid(p) ((aosl_http_parser_t)(p) == NULL) - -typedef enum { - aosl_http_ev_tcp_connected = 0x1000, - aosl_http_ev_message_begin, - aosl_http_ev_request_url, - aosl_http_ev_response_status, - aosl_http_ev_header_field, - aosl_http_ev_header_value, - aosl_http_ev_headers_complete, - aosl_http_ev_body, - aosl_http_ev_message_complete, - aosl_http_ev_chunk_header, - aosl_http_ev_chunk_complete, -} aosl_http_event_t; - -/** - * HTTP parser event callback function. - * Parameters: - * parser: the parser object - * event: indicate what happened, values are as following: - * <0: negative value for OS level error, equal to -errno - * 0: OK, no error - * >0&<0x1000: HTTP parser errno - * >=0x1000: events defined in aosl_http_event_t - * ...: - * aosl_http_ev_message_begin: - * N/A - * aosl_http_ev_request_url: - * 1. va_arg (args, const char *): url, terminated with '\0' - * aosl_http_ev_response_status: - * 1. va_arg (args, const char *): status string, terminated with '\0' - * aosl_http_ev_header_field: - * 1. va_arg (args, const char *): header field name, terminated with '\0' - * aosl_http_ev_header_field: - * 1. va_arg (args, const char *): header field value, terminated with '\0' - * aosl_http_ev_headers_complete: - * N/A - * aosl_http_ev_body: - * 1. va_arg (args, const char *): body content(NOTE: it is not terminated with '\0') - * 2. va_arg (args, size_t): body content length - * aosl_http_ev_message_complete: - * N/A - * aosl_http_ev_chunk_header: - * N/A - * aosl_http_ev_chunk_complete: - * N/A - * Return value: - * none. - **/ -typedef void (*aosl_http_event_cb_t) (aosl_http_parser_t parser, int event, ...); - -/** - * Create an HTTP parser. - * Parameters: - * event_f: HTTP parser event callback function - * arg: application passed arg which will be passed in event_f - * Return value: - * NULL: failed to create the HTTP parser. - * Other: the created HTTP parser object. - **/ -extern __aosl_api__ aosl_http_parser_t aosl_http_parser_create (aosl_http_event_cb_t event_f, void *arg); - -/** - * Retrieve the argument passed in when creating this parser. - * Parameters: - * parser_obj: the parser object - * Return value: - * the arg. - **/ -extern __aosl_api__ void *aosl_http_parser_arg (aosl_http_parser_t parser_obj); - -/** - * Reset the HTTP parser object. - * Parameters: - * parser_obj: the parser object - * Return value: - * none. - **/ -extern __aosl_api__ void aosl_http_parser_reset (aosl_http_parser_t parser_obj); - -/** - * HTTP parser execute the parsing. - * Parameters: - * parser_obj: the parser object - * data: the buffer contains the HTTP data - * len: the buffer length - * Return value: - * Returns number of parsed bytes, negative value for error. - **/ -extern __aosl_api__ ssize_t aosl_http_parser_execute (aosl_http_parser_t parser_obj, const char *data, size_t len); - -/** - * Get the HTTP major from parser. - * Parameters: - * parser_obj: the parser object - * Return value: - * the HTTP major number, negative value for error. - **/ -extern __aosl_api__ int aosl_http_parser_major (aosl_http_parser_t parser_obj); - -/** - * Get the HTTP minor from parser. - * Parameters: - * parser_obj: the parser object - * Return value: - * the HTTP minor number, negative value for error. - **/ -extern __aosl_api__ int aosl_http_parser_minor (aosl_http_parser_t parser_obj); - -/** - * Get the HTTP status code from parser. - * Parameters: - * parser_obj: the parser object - * Return value: - * the HTTP status code, negative value for error. - **/ -extern __aosl_api__ int aosl_http_parser_status (aosl_http_parser_t parser_obj); - -/** - * Get the HTTP status code string from parser. - * Parameters: - * parser_obj: the parser object - * Return value: - * the HTTP status code string. - **/ -extern __aosl_api__ const char *aosl_http_parser_status_str (int status); - -/** - * Get the HTTP errno from parser. - * Parameters: - * parser_obj: the parser object - * Return value: - * the HTTP errno. - **/ -extern __aosl_api__ int aosl_http_parser_errno (aosl_http_parser_t parser_obj); - -/** - * Get the HTTP errno name string from parser. - * Parameters: - * parser_obj: the parser object - * Return value: - * the HTTP errno name string. - **/ -extern __aosl_api__ const char *aosl_http_parser_errno_name (int http_err); - -/** - * Get the HTTP errno description string from parser. - * Parameters: - * parser_obj: the parser object - * Return value: - * the HTTP errno description string. - **/ -extern __aosl_api__ const char *aosl_http_parser_errno_descr (int http_err); - -/** - * Destroy the specified parser object. - * Parameters: - * parser_obj: the parser object - * Return value: - * none. - **/ -extern __aosl_api__ void aosl_http_parser_destroy (aosl_http_parser_t parser); - - -#ifdef __cplusplus -} -#endif - - - -#endif /* __AOSL_HTTP_API_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_input.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_input.h deleted file mode 100644 index f76513b26..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_input.h +++ /dev/null @@ -1,115 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : May 21st, 2019 - * Module: AOSL input object definition file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 ~ 2019 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_INPUT_H__ -#define __AOSL_INPUT_H__ - - -#include -#include -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - - -/** - * The input object function prototype. - * Parameter: - * iobj: the input object itself; - * free_only: only do free action, no other action allowed - * argc: specify the argv array elements count - * argv: array for passing variable args - * - * Return value: - * none. - **/ -typedef void (*aosl_input_func_t) (aosl_refobj_t iobj, int free_only, uintptr_t argc, uintptr_t argv []); - -/** - * The input object creating function prototype, which is used to create an input object. - * Parameters: - * arg: the parameter attached with the input object; - * dtor: the input object destructor function, which will be invoked when - * the input object is deleted; - * waitings_max: input works max waitings: - * 0: for sync mode - * >0: async mode, specified the max waitings - * input_q: input only to the specified MPQ, if specify AOSL_MPQ_INVALID, then the - * input would be sent to one of valid mpq of the general mpq pool; - **/ -extern __aosl_api__ aosl_ref_t aosl_input_create (void *arg, aosl_ref_dtor_t dtor, uintptr_t waitings_max, aosl_mpq_t input_q); - -/** - * Execute the input action, and the callback function will be invoked. - * Parameters: - * input: the input object; - * f_name: the functionality name for the callback function; - * f: the input action callback function; - * argc: arguments count would be passed to the callback function; - * ...: the various arguments would be passed to the callback function; - * Return Value: - * 0: successful, and the async callback will be invoked; - * <0: failed with aosl_errno set; - * Remarks: - * The input action callback function will be invoked according to the - * input object creating parameters: - * 1. if specified a valid mpq when creating, then the input action f - * will be invoked in the mpq thread context; - * 2. if specified AOSL_MPQ_INVALID when creating, then the input action - * f will be invoked in any one of mpq thread of general mpq pool; - * 3. the callback function will be invoked orderly; - **/ -extern __aosl_api__ int aosl_input_exec (aosl_ref_t input, const char *f_name, aosl_input_func_t f, uintptr_t argc, ...); - -/* va_list version */ -extern __aosl_api__ int aosl_input_exec_args (aosl_ref_t input, const char *f_name, aosl_input_func_t f, uintptr_t argc, va_list args); - -/* args vector versions */ -extern __aosl_api__ int aosl_input_exec_argv (aosl_ref_t input, const char *f_name, aosl_input_func_t f, uintptr_t argc, uintptr_t argv []); - -/** - * Get the input waitings count. - * Parameters: - * input: the input object; - * Return Value: - * >=0: successful, and the input waitings count; - * <0: failed with aosl_errno set; - **/ -extern __aosl_api__ int aosl_input_waitings_count (aosl_ref_t input); - -/** - * Remove one waiting input from the input waitings head, i.e. the eldest input data. - * Parameters: - * input: the input object; - * Return Value: - * >=0: successful, and the input waitings count; - * <0: failed with aosl_errno set; - * Remarks: - * The removed data will be passed to the async callback function with free_only - * set to true to do the possible resource releasing. - **/ -extern __aosl_api__ int aosl_input_remove_waitings_head (aosl_ref_t input); - - - -#ifdef __cplusplus -} -#endif - - - -#endif /* __AOSL_INPUT_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_integer_wrappings.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_integer_wrappings.h deleted file mode 100644 index 39ef7b82b..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_integer_wrappings.h +++ /dev/null @@ -1,163 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jul 21st, 2018 - * Module: AOSL integer wrapping processing definitions. - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_INTEGER_WRAPPINGS_H__ -#define __AOSL_INTEGER_WRAPPINGS_H__ - -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - -#define aosl_uint8_add(a, b) ((uint8_t)((a) + (b))) -#define aosl_uint16_add(a, b) ((uint16_t)((a) + (b))) -#define aosl_uint32_add(a, b) ((uint32_t)((a) + (b))) -#define aosl_uint64_add(a, b) ((uint64_t)((a) + (b))) - -#define aosl_uint8_sub(a, b) ((uint8_t)((a) - (b))) -#define aosl_uint16_sub(a, b) ((uint16_t)((a) - (b))) -#define aosl_uint32_sub(a, b) ((uint32_t)((a) - (b))) -#define aosl_uint64_sub(a, b) ((uint64_t)((a) - (b))) - - -static __inline__ int aosl_uint16_after (uint16_t a, uint16_t b) -{ - return (int)((int16_t)(a - b) > 0); -} -#define aosl_uint16_before(a, b) aosl_uint16_after (b, a) - -static __inline__ int aosl_uint16_after_eq (uint16_t a, uint16_t b) -{ - return (int)((int16_t)(a - b) >= 0); -} -#define aosl_uint16_before_eq(a, b) aosl_uint16_after_eq (b, a) - -#define aosl_uint16_in_range(x, a, b) (aosl_uint16_after_eq (x, a) && aosl_uint16_before_eq (x, b)) - -static __inline__ uint16_t aosl_uint16_prev (uint16_t val) -{ - return (uint16_t)(val - 1); -} - -static __inline__ uint16_t aosl_uint16_next (uint16_t val) -{ - return (uint16_t)(val + 1); -} - -static __inline__ uint16_t aosl_uint16_dist (uint16_t a, uint16_t b) -{ - if (aosl_uint16_after (a, b)) - return (uint16_t)(a - b); - - return (uint16_t)(b - a); -} - -static __inline__ int aosl_uint32_after (uint32_t a, uint32_t b) -{ - return (int)((int32_t)(a - b) > 0); -} -#define aosl_uint32_before(a, b) aosl_uint32_after (b, a) - -static __inline__ int aosl_uint32_after_eq (uint32_t a, uint32_t b) -{ - return (int)((int32_t)(a - b) >= 0); -} -#define aosl_uint32_before_eq(a, b) aosl_uint32_after_eq (b, a) - -#define aosl_uint32_in_range(x, a, b) (aosl_uint32_after_eq (x, a) && aosl_uint32_before_eq (x, b)) - -static __inline__ uint32_t aosl_uint32_prev (uint32_t val) -{ - return (uint32_t)(val - 1); -} - -static __inline__ uint32_t aosl_uint32_next (uint32_t val) -{ - return (uint32_t)(val + 1); -} - -static __inline__ uint32_t aosl_uint32_dist (uint32_t a, uint32_t b) -{ - if (aosl_uint32_after (a, b)) - return (uint32_t)(a - b); - - return (uint32_t)(b - a); -} - -static __inline__ int aosl_uint64_after (uint64_t a, uint64_t b) -{ - return (int)((int64_t)(a - b) > 0); -} -#define aosl_uint64_before(a, b) aosl_uint64_after (b, a) - -static __inline__ int aosl_uint64_after_eq (uint64_t a, uint64_t b) -{ - return (int)((int64_t)(a - b) >= 0); -} -#define aosl_uint64_before_eq(a, b) aosl_uint64_after_eq (b, a) - -#define aosl_uint64_in_range(x, a, b) (aosl_uint64_after_eq (x, a) && aosl_uint64_before_eq (x, b)) - -static __inline__ uint64_t aosl_uint64_prev (uint64_t val) -{ - return (uint64_t)(val - 1); -} - -static __inline__ uint64_t aosl_uint64_next (uint64_t val) -{ - return (uint64_t)(val + 1); -} - -static __inline__ uint64_t aosl_uint64_dist (uint64_t a, uint64_t b) -{ - if (aosl_uint64_after (a, b)) - return (uint64_t)(a - b); - - return (uint64_t)(b - a); -} - - -#if defined (__LP64__) || defined (_WIN64) -#define aosl_uintptr_add(a, b) aosl_uint64_add (a, b) -#define aosl_uintptr_sub(a, b) aosl_uint64_sub (a, b) -#define aosl_uintptr_after(a, b) aosl_uint64_after (a, b) -#define aosl_uintptr_after_eq(a, b) aosl_uint64_after_eq (a, b) -#define aosl_uintptr_before(a, b) aosl_uint64_before (a, b) -#define aosl_uintptr_before_eq(a, b) aosl_uint64_before_eq (a, b) -#define aosl_uintptr_in_range(x, a, b) aosl_uint64_in_range (x, a, b) -#define aosl_uintptr_prev(val) aosl_uint64_prev (val) -#define aosl_uintptr_next(val) aosl_uint64_next (val) -#define aosl_uintptr_dist(a, b) aosl_uint64_dist (a, b) -#else -#define aosl_uintptr_add(a, b) aosl_uint32_add (a, b) -#define aosl_uintptr_sub(a, b) aosl_uint32_sub (a, b) -#define aosl_uintptr_after(a, b) aosl_uint32_after (a, b) -#define aosl_uintptr_after_eq(a, b) aosl_uint32_after_eq (a, b) -#define aosl_uintptr_before(a, b) aosl_uint32_before (a, b) -#define aosl_uintptr_before_eq(a, b) aosl_uint32_before_eq (a, b) -#define aosl_uintptr_in_range(x, a, b) aosl_uint32_in_range (x, a, b) -#define aosl_uintptr_prev(val) aosl_uint32_prev (val) -#define aosl_uintptr_next(val) aosl_uint32_next (val) -#define aosl_uintptr_dist(a, b) aosl_uint32_dist (a, b) -#endif - - -#ifdef __cplusplus -} -#endif - - -#endif /* __AOSL_INTEGER_WRAPPINGS_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_jni.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_jni.h deleted file mode 100644 index 43a7d2946..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_jni.h +++ /dev/null @@ -1,56 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jul 21st, 2018 - * Module: AOSL JNI relatives header file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_JNI_H__ -#define __AOSL_JNI_H__ - -#include - -#ifdef __ANDROID__ -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - - -extern __aosl_api__ JavaVM *aosl_java_vm (); -extern __aosl_api__ int aosl_set_java_vm (JavaVM *jvm); - -extern __aosl_api__ JNIEnv *aosl_this_jni_env (int *attached_p); - -/** - * Set Java Application Context. - * Parameter: - * ctxt: Main Activity Context, i.e. the main activity; - * Return value: - * <0: indicates error, check aosl_errno for detail; - * 0: successful; - * Remarks: - * For Android, the ctxt MUST BE the Main Activity object, - * but for other Java environment, ctxt can be any object - * which is loaded by the main Java thread. - **/ -extern __aosl_api__ int aosl_java_set_context (jobject ctxt); - -extern __aosl_api__ void aosl_thread_java_detach (); - - -#ifdef __cplusplus -} -#endif -#endif /* __ANDROID__ */ - - -#endif /* __AOSL_JNI_H__ */ diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_kobj.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_kobj.h deleted file mode 100644 index ccb86f8c1..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_kobj.h +++ /dev/null @@ -1,494 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Nov 26th, 2022 - * Module: AOSL kernel object API definition file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 ~ 2022 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_KOBJ_H__ -#define __AOSL_KOBJ_H__ - - -#include -#include -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - -/* The kobject file descriptor type */ -typedef struct _internal_kobj_od_ *aosl_kfd_t; - -/* The common invalid file descriptor value for initializing an aosl_kfd_t var */ -#define AOSL_KFD_INVALID ((aosl_kfd_t)(intptr_t)NULL) - -/* Check whether an aosl_kfd_t val is invalid */ -#define aosl_kfd_invalid(id) ((int)(intptr_t)(id) <= 0) - - -typedef enum { - aosl_kobj_obj, /* object */ - aosl_kobj_dir, /* directory */ - aosl_kobj_lnk, /* symbolic link */ - aosl_kobj_drv, /* driver */ - aosl_kobj_val, /* value */ -} aosl_kobj_type_t; - -#define AOSL_KOBJ_PATHMAX 256 - -#define AOSL_KOBJ_R 0x10 /* Read */ -#define AOSL_KOBJ_W 0x20 /* Write */ -#define AOSL_KOBJ_RW (AOSL_KOBJ_R | AOSL_KOBJ_W) -#define AOSL_KOBJ_S 0x40 /* Start */ -#define AOSL_KOBJ_NONBLOCK 0x80 /* Non block */ -#define AOSL_KOBJ_OPEN_METHOD_MASK 0xf - -/** - * The kobject open function prototype, which is used to open a kobject. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the opening kobject name; - * flags: the opening flags bitmask AOSL_KOBJ_R, AOSL_KOBJ_W - * Return value: - * the opened kobject id, some like an fd. - * aosl_kfd_invalid(result): open failed with aosl_errno set; - * !aosl_kfd_invalid(result): successfully; - **/ -extern __aosl_api__ aosl_kfd_t aosl_kobj_open (aosl_kfd_t dfd, const char *name, int flags); - -/** - * Close an aosl_kfd_t. - * Parameters: - * fd: the fd to be closed - * Return value: - * 0: successfully - * <0: failed with aosl_errno set - **/ -extern __aosl_api__ int aosl_kobj_close (aosl_kfd_t fd); - -/** - * Get the full path of the kobject specified by fd. - * Parameters: - * fd: the opened fd; - * pathbuf: the buffer for holding the path. - * NOTE: the path was filled from the end, so do NOT - * use the pathbuf directly when accessing the - * path result, using the return value instead. - * len: the pathbuf size in bytes. - * needed_p: the path length needed when non-NULL, it could be - * NULL if guarantee the pathbuf is big enough. - * Return value: - * the returned path pointer, it is >= &pathbuf [0] and < &pathbuf [len], - * NULL for failed, with aosl_errno set correspondingly. - **/ -extern __aosl_api__ char *aosl_kobj_path (aosl_kfd_t fd, char *pathbuf, size_t len, size_t *needed_p); - -/** - * Get the current working directory path. - * Parameters: - * pathbuf: the buffer for holding the path. - * NOTE: the path was filled from the end, so do NOT - * use the pathbuf directly when accessing the - * path result, using the return value instead. - * len: the pathbuf size in bytes. - * needed_p: the path length needed when non-NULL, it could be - * NULL if guarantee the pathbuf is big enough. - * Return value: - * the returned path pointer, it is >= &pathbuf [0] and < &pathbuf [len], - * NULL for failed, with aosl_errno set correspondingly. - **/ -extern __aosl_api__ char *aosl_kobj_pwd (char *pathbuf, size_t len, size_t *needed_p); - -/** - * Read data from the kobject specified by fd. - * Parameters: - * fd: the opened fd; - * buf: the buffer for holding the data; - * len: the buffer size in bytes; - * Return value: - * >=0: the read data length; - * <0: failed with aosl_errno set accordingly. - **/ -extern __aosl_api__ ssize_t aosl_kobj_read (aosl_kfd_t fd, void *buf, size_t len); - -/** - * Write data to the kobject specified by fd. - * Parameters: - * fd: the opened fd; - * buf: the buffer for holding the data; - * len: the buffer size in bytes; - * Return value: - * >=0: the written data length; - * <0: failed with aosl_errno set accordingly. - **/ -extern __aosl_api__ ssize_t aosl_kobj_write (aosl_kfd_t fd, const void *buf, size_t len); - -/** - * IO control the kobject specified by fd. - * Parameters: - * fd: the opened fd; - * req: the request code; - * argc: various arg count; - * argv: the various args vector; - * Return value: - * >=0: the IO control result according to the request; - * <0: failed with aosl_errno set accordingly. - **/ -extern __aosl_api__ intptr_t aosl_kobj_ioctl_argv (aosl_kfd_t fd, uintptr_t req, uintptr_t argc, uintptr_t *argv); - -/** - * IO control the kobject specified by fd. - * Parameters: - * fd: the opened fd; - * req: the request code; - * argc: various arg count; - * args: the various args; - * Return value: - * >=0: the IO control result according to the request; - * <0: failed with aosl_errno set accordingly. - **/ -extern __aosl_api__ intptr_t aosl_kobj_ioctl_args (aosl_kfd_t fd, uintptr_t req, uintptr_t argc, va_list args); - -/** - * IO control the kobject specified by fd. - * Parameters: - * fd: the opened fd; - * req: the request code; - * argc: various arg count; - * ...: the various args; - * Return value: - * >=0: the IO control result according to the request; - * <0: failed with aosl_errno set accordingly. - **/ -extern __aosl_api__ intptr_t aosl_kobj_ioctl (aosl_kfd_t fd, uintptr_t req, uintptr_t argc, ...); - - -typedef enum { - aosl_kobj_seek_set, - aosl_kobj_seek_cur, - aosl_kobj_seek_end -} aosl_kobj_seek_t; - -/** - * Seek the kobject specified by fd. - * Parameters: - * fd: the opened fd; - * offset: the seek offset; - * whence: where the seeking from, aosl_kobj_seek_t type; - * Return value: - * >=0: the seek result; - * <0: failed with aosl_errno set accordingly. - **/ -extern __aosl_api__ int32_t aosl_kobj_seek (aosl_kfd_t fd, int32_t offset, int whence); - -/** - * Make a directory in the directory specified by dfd. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * Return value: - * 0: successfully; - * <0: failed with aosl_errno set accordingly. - **/ -extern __aosl_api__ int aosl_kobj_mkdir (aosl_kfd_t dfd, const char *name); - -/** - * Remove a directory from the directory specified by dfd. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the kobject name; - * Return value: - * 0: successfully; - * <0: failed with aosl_errno set accordingly. - **/ -extern __aosl_api__ int aosl_kobj_rm (aosl_kfd_t dfd, const char *name); - -/** - * Change the current working directory to the directory specified by dfd + name. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * Return value: - * 0: successfully; - * <0: failed with aosl_errno set accordingly. - **/ -extern __aosl_api__ int aosl_kobj_chdir (aosl_kfd_t dfd, const char *name); - -/** - * Create a symbolic link to the target. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * tdfd: the target opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * target: the target name; - * Return value: - * 0: successfully; - * <0: failed with aosl_errno set accordingly. - **/ -extern __aosl_api__ int aosl_kobj_ln (aosl_kfd_t dfd, const char *name, aosl_kfd_t tdfd, const char *target); - -/** - * Read the full path of a symbolic link specified by dfd + name. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * buf: the buffer for holding the path. - * NOTE: the path was filled from the end, so do NOT - * use the pathbuf directly when accessing the - * path result, using the return value instead. - * bufsz: the buf size in bytes. - * Return value: - * the returned path pointer, it is >= &buf [0] and < &buf [bufsz], - * NULL for failed, with aosl_errno set correspondingly. - **/ -extern __aosl_api__ char *aosl_kobj_readlink (aosl_kfd_t dfd, const char *name, char *buf, size_t bufsz); - -/** - * Move the object specified by sdfd + sname to the destination specified by ddfd + dname. - * Parameters: - * sdfd: the source opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * sname: the source object name; - * ddfd: the destination opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * dname: the destination name; - * Return value: - * 0: successfully; - * <0: failed with aosl_errno set accordingly. - **/ -extern __aosl_api__ int aosl_kobj_mv (aosl_kfd_t sdfd, const char *sname, aosl_kfd_t ddfd, const char *dname); - -/** - * Get the kobject type specified by fd. - * Parameters: - * fd: the opened kobject fd; - * Return value: - * >=0: the kobject type, value is one of aosl_kobj_type_t; - * <0: failed with aosl_errno set accordingly. - **/ -extern __aosl_api__ int aosl_kobj_fdtype (aosl_kfd_t fd); - -/** - * Get the kobject type specified by dfd + name. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * Return value: - * >=0: the kobject type, value is one of aosl_kobj_type_t; - * <0: failed with aosl_errno set accordingly. - **/ -extern __aosl_api__ int aosl_kobj_type (aosl_kfd_t dfd, const char *name); - - -typedef struct { - uint16_t e_len; /* the total dir entry length in bytes. */ - uint16_t e_type; /* the dir entry type, one of aosl_kobj_type_t */ - char e_name [0]; /* the dir entry name */ -} aosl_kobj_dent_t; - -typedef struct kobj_dir *aosl_kobj_dir_t; - -/** - * Open the dir specified by dfd + name for reading its' content. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * Return value: - * non-NULL: the opened dir; - * NULL: failed with aosl_errno set accordingly. - **/ -extern __aosl_api__ aosl_kobj_dir_t aosl_kobj_dir_open (aosl_kfd_t dfd, const char *name); - -/** - * Get the opened dir fd. - * Parameters: - * d: the opened dir. - * Return value: the fd of the opened dir. - **/ -extern __aosl_api__ aosl_kfd_t aosl_kobj_dir_kfd (aosl_kobj_dir_t d); - -/** - * Read the opened dir specified by d. - * Parameters: - * d: the opened dir. - * Return value: - * non-NULL: one dir entry of the opened dir; - * NULL: failed with aosl_errno set accordingly. - **/ -extern __aosl_api__ aosl_kobj_dent_t *aosl_kobj_dir_read (aosl_kobj_dir_t d); - -/** - * Seek the opened dir specified by d to the specified position. - * Parameters: - * d: the opened dir; - * pos: the target position. - * Return value: - * <0: failed with aosl_errno set accordingly; - * non-0: equal to value of pos. - **/ -extern __aosl_api__ int32_t aosl_kobj_dir_seek (aosl_kobj_dir_t d, uint32_t pos); - -/** - * Tell the current position of the opened dir specified by d. - * Parameters: - * d: the opened dir; - * Return value: - * <0: failed with aosl_errno set accordingly; - * non-0: the current position of d. - **/ -extern __aosl_api__ int32_t aosl_kobj_dir_pos (aosl_kobj_dir_t d); - -/** - * Close the the opened dir specified by d. - * Parameters: - * d: the opened dir; - * Return value: - * <0: failed with aosl_errno set accordingly; - * 0: successfully. - **/ -extern __aosl_api__ int aosl_kobj_dir_close (aosl_kobj_dir_t d); - -typedef enum { - aosl_kobj_dent_add, /* add a dir entry */ - aosl_kobj_dent_del, /* del a dir entry */ -} aosl_kobj_dir_op_t; - -typedef struct { - const char *name; - aosl_kobj_type_t type; - aosl_kobj_dir_op_t dir_op; -} aosl_kobj_dir_notify_t; - -/** - * A registered callback function for an object, which will be invoked when the object changed. - * Parameters: - * robj: the ref object specified when registering; - * dirpath: the fullpath for the object; - * name: the object name; - * notif_data: the notification data, which may be 'aosl_kobj_dir_notify_t *' or 'aosl_kobj_value_notify_t *'; - * argc: the various args count, passed when registering; - * argv: the various args vector, passed as various args when registering; - * Return value: - * None. - **/ -typedef void (*aosl_kobj_notify_t) (aosl_refobj_t robj, const char *dirpath, const char *name, void *notif_data, uintptr_t argc, uintptr_t argv []); - -/** - * Register a notification of the kobject specified by dfd + name for monitoring changes. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the object name; - * touch: 0: notify only when changed; !0: notify anyway; - * qid: the mpq you want the target function to be invoked in, must be valid; - * ref: specify a ref object just like the queue operation of an mpq; - * f_name: specify the target function name; - * f: the target function; - * dtor: destructor which be invoked when unregister the notification; - * argc: the various args count; - * ...: the various args; - * Return value: - * non-NULL: successfully; - * NULL: failed with aosl_errno set accordingly. - * The return value only used for unregister, no other usage. - **/ -extern __aosl_api__ void *aosl_kobj_notify_register (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_t f, aosl_obj_dtor_t dtor, uintptr_t argc, ...); - -/** - * Register a notification of the kobject specified by dfd + name for monitoring changes. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the object name; - * touch: 0: notify only when changed; !0: notify anyway; - * qid: the mpq you want the target function to be invoked in, must be valid; - * ref: specify a ref object just like the queue operation of an mpq; - * f_name: specify the target function name; - * f: the target function; - * dtor: destructor which be invoked when unregister the notification; - * argc: the various args count; - * args: the various args; - * Return value: - * Return value: - * non-NULL: successfully; - * NULL: failed with aosl_errno set accordingly. - * The return value only used for unregister, no other usage. - **/ -extern __aosl_api__ void *aosl_kobj_notify_register_args (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_t f, aosl_obj_dtor_t dtor, uintptr_t argc, va_list args); - -/** - * Register a notification of the kobject specified by dfd + name for monitoring changes. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the object name; - * touch: 0: notify only when changed; !0: notify anyway; - * qid: the mpq you want the target function to be invoked in, must be valid; - * ref: specify a ref object just like the queue operation of an mpq; - * f_name: specify the target function name; - * f: the target function; - * dtor: destructor which be invoked when unregister the notification; - * argc: the various args count; - * argv: the various args vector; - * Return value: - * Return value: - * non-NULL: successfully; - * NULL: failed with aosl_errno set accordingly. - * The return value only used for unregister, no other usage. - **/ -extern __aosl_api__ void *aosl_kobj_notify_register_argv (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_t f, aosl_obj_dtor_t dtor, uintptr_t argc, uintptr_t argv []); - -/** - * Unregister a notification of the kobject specified by dfd + name. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the object name; - * handle: the handle returned by above register functions; - * Return value: - * 0: successfully; - * <0: failed with aosl_errno set accordingly. - **/ -extern __aosl_api__ int aosl_kobj_notify_unregister (aosl_kfd_t dfd, const char *name, void *handle); - - -#ifdef __cplusplus -} -#endif - - - -#endif /* __AOSL_KOBJ_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_list.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_list.h deleted file mode 100644 index 1e0ff9f39..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_list.h +++ /dev/null @@ -1,912 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jul 16th, 2018 - * Module: AOSL list implementation header file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_LIST_H__ -#define __AOSL_LIST_H__ - - -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - -#define AOSL_LIST_POISON1 ((void *)((uintptr_t)0x00100100 + 1)) -#define AOSL_LIST_POISON2 ((void *)((uintptr_t)0x00200200 + 3)) - - -struct aosl_list_head { - struct aosl_list_head *next; - struct aosl_list_head *prev; -}; - - -#define AOSL_LIST_HEAD_INIT(name) { &(name), &(name) } - -#define AOSL_DEFINE_LIST_HEAD(name) \ - struct aosl_list_head name = AOSL_LIST_HEAD_INIT(name) - -static __inline__ void aosl_list_head_init(struct aosl_list_head *list) -{ - list->next = list; - list->prev = list; -} - -static __inline__ void aosl_list_head_poison (struct aosl_list_head *list) -{ - list->next = (struct aosl_list_head *)AOSL_LIST_POISON1; - list->prev = (struct aosl_list_head *)AOSL_LIST_POISON2; -} - -/* - * Insert a new entry between two known consecutive entries. - * - * This is only for internal list manipulation where we know - * the prev/next entries already! - */ -static inline void __aosl_list_add(struct aosl_list_head *new_node, - struct aosl_list_head *prev, - struct aosl_list_head *next) -{ - next->prev = new_node; - new_node->next = next; - new_node->prev = prev; - prev->next = new_node; -} - -/** - * aosl_list_add - add a new entry - * @new: new entry to be added - * @head: list head to add it after - * - * Insert a new entry after the specified head. - * This is good for implementing stacks. - */ -static inline void aosl_list_add(struct aosl_list_head *new_node, struct aosl_list_head *head) -{ - __aosl_list_add(new_node, head, head->next); -} - - -/** - * aosl_list_add_tail - add a new entry - * @new: new entry to be added - * @head: list head to add it before - * - * Insert a new entry before the specified head. - * This is useful for implementing queues. - */ -static inline void aosl_list_add_tail(struct aosl_list_head *new_node, struct aosl_list_head *head) -{ - __aosl_list_add(new_node, head->prev, head); -} - -/* - * Delete a list entry by making the prev/next entries - * point to each other. - * - * This is only for internal list manipulation where we know - * the prev/next entries already! - */ -static inline void __aosl_list_del(struct aosl_list_head * prev, struct aosl_list_head * next) -{ - next->prev = prev; - prev->next = next; -} - - -/** - * aosl_list_del - deletes entry from list. - * @entry: the element to delete from the list. - * Note: aosl_list_empty() on entry does not return true after this, the entry is - * in an undefined state. - */ -static inline void __aosl_list_del_entry(struct aosl_list_head *entry) -{ - __aosl_list_del(entry->prev, entry->next); -} - -static inline void aosl_list_del(struct aosl_list_head *entry) -{ - __aosl_list_del(entry->prev, entry->next); - aosl_list_head_poison (entry); -} - -/** - * aosl_list_replace - replace old entry by new one - * @old : the element to be replaced - * @new : the new element to insert - * - * If @old was empty, it will be overwritten. - */ -static inline void aosl_list_replace(struct aosl_list_head *old, - struct aosl_list_head *new_node) -{ - new_node->next = old->next; - new_node->next->prev = new_node; - new_node->prev = old->prev; - new_node->prev->next = new_node; -} - -static inline void aosl_list_replace_init(struct aosl_list_head *old, - struct aosl_list_head *new_node) -{ - aosl_list_replace(old, new_node); - aosl_list_head_init(old); -} - -/** - * aosl_list_del_init - deletes entry from list and reinitialize it. - * @entry: the element to delete from the list. - */ -static inline void aosl_list_del_init(struct aosl_list_head *entry) -{ - __aosl_list_del_entry(entry); - aosl_list_head_init(entry); -} - -/** - * aosl_list_move - delete from one list and add as another's head - * @list: the entry to move - * @head: the head that will precede our entry - */ -static inline void aosl_list_move(struct aosl_list_head *list, struct aosl_list_head *head) -{ - __aosl_list_del_entry(list); - aosl_list_add(list, head); -} - -/** - * aosl_list_move_tail - delete from one list and add as another's tail - * @list: the entry to move - * @head: the head that will follow our entry - */ -static inline void aosl_list_move_tail(struct aosl_list_head *list, - struct aosl_list_head *head) -{ - __aosl_list_del_entry(list); - aosl_list_add_tail(list, head); -} - -/** - * aosl_list_is_last - tests whether @list is the last entry in list @head - * @list: the entry to test - * @head: the head of the list - */ -static inline int aosl_list_is_last(const struct aosl_list_head *list, - const struct aosl_list_head *head) -{ - return list->next == head; -} - -/** - * aosl_list_empty - tests whether a list is empty - * @head: the list to test. - */ -static inline int aosl_list_empty(const struct aosl_list_head *head) -{ - return head->next == head; -} - -/** - * aosl_list_empty_careful - tests whether a list is empty and not being modified - * @head: the list to test - * - * Description: - * tests whether a list is empty _and_ checks that no other CPU might be - * in the process of modifying either member (next or prev) - * - * NOTE: using aosl_list_empty_careful() without synchronization - * can only be safe if the only activity that can happen - * to the list entry is aosl_list_del_init(). Eg. it cannot be used - * if another CPU could re-aosl_list_add() it. - */ -static inline int aosl_list_empty_careful(const struct aosl_list_head *head) -{ - struct aosl_list_head *next = head->next; - return (next == head) && (next == head->prev); -} - -/** - * aosl_list_rotate_left - rotate the list to the left - * @head: the head of the list - */ -static inline void aosl_list_rotate_left(struct aosl_list_head *head) -{ - struct aosl_list_head *first; - - if (!aosl_list_empty(head)) { - first = head->next; - aosl_list_move_tail(first, head); - } -} - -/** - * aosl_list_is_singular - tests whether a list has just one entry. - * @head: the list to test. - */ -static inline int aosl_list_is_singular(const struct aosl_list_head *head) -{ - return !aosl_list_empty(head) && (head->next == head->prev); -} - -static inline void __aosl_list_cut_position(struct aosl_list_head *list, - struct aosl_list_head *head, struct aosl_list_head *entry) -{ - struct aosl_list_head *new_first = entry->next; - list->next = head->next; - list->next->prev = list; - list->prev = entry; - entry->next = list; - head->next = new_first; - new_first->prev = head; -} - -/** - * aosl_list_cut_position - cut a list into two - * @list: a new list to add all removed entries - * @head: a list with entries - * @entry: an entry within head, could be the head itself - * and if so we won't cut the list - * - * This helper moves the initial part of @head, up to and - * including @entry, from @head to @list. You should - * pass on @entry an element you know is on @head. @list - * should be an empty list or a list you do not care about - * losing its data. - * - */ -static inline void aosl_list_cut_position(struct aosl_list_head *list, - struct aosl_list_head *head, struct aosl_list_head *entry) -{ - if (aosl_list_empty(head)) - return; - if (aosl_list_is_singular(head) && - (head->next != entry && head != entry)) - return; - if (entry == head) - aosl_list_head_init(list); - else - __aosl_list_cut_position(list, head, entry); -} - -static inline void __aosl_list_splice(const struct aosl_list_head *list, - struct aosl_list_head *prev, - struct aosl_list_head *next) -{ - struct aosl_list_head *first = list->next; - struct aosl_list_head *last = list->prev; - - first->prev = prev; - prev->next = first; - - last->next = next; - next->prev = last; -} - -/** - * aosl_list_splice - join two lists, this is designed for stacks - * @list: the new list to add. - * @head: the place to add it in the first list. - */ -static inline void aosl_list_splice(const struct aosl_list_head *list, - struct aosl_list_head *head) -{ - if (!aosl_list_empty(list)) - __aosl_list_splice(list, head, head->next); -} - -/** - * aosl_list_splice_tail - join two lists, each list being a queue - * @list: the new list to add. - * @head: the place to add it in the first list. - */ -static inline void aosl_list_splice_tail(struct aosl_list_head *list, - struct aosl_list_head *head) -{ - if (!aosl_list_empty(list)) - __aosl_list_splice(list, head->prev, head); -} - -/** - * aosl_list_splice_init - join two lists and reinitialise the emptied list. - * @list: the new list to add. - * @head: the place to add it in the first list. - * - * The list at @list is reinitialised - */ -static inline void aosl_list_splice_init(struct aosl_list_head *list, - struct aosl_list_head *head) -{ - if (!aosl_list_empty(list)) { - __aosl_list_splice(list, head, head->next); - aosl_list_head_init(list); - } -} - -/** - * aosl_list_splice_tail_init - join two lists and reinitialise the emptied list - * @list: the new list to add. - * @head: the place to add it in the first list. - * - * Each of the lists is a queue. - * The list at @list is reinitialised - */ -static inline void aosl_list_splice_tail_init(struct aosl_list_head *list, - struct aosl_list_head *head) -{ - if (!aosl_list_empty(list)) { - __aosl_list_splice(list, head->prev, head); - aosl_list_head_init(list); - } -} - -/** - * aosl_list_entry - get the struct for this entry - * @ptr: the &struct aosl_list_head pointer. - * @type: the type of the struct this is embedded in. - * @member: the name of the list_struct within the struct. - */ -#define aosl_list_entry(ptr, type, member) \ - container_of(ptr, type, member) - -/** - * aosl_list_first_entry - get the first element from a list - * @ptr: the list head to take the element from. - * @type: the type of the struct this is embedded in. - * @member: the name of the list_struct within the struct. - * - * Note, that list is expected to be not empty. - */ -#define aosl_list_first_entry(ptr, type, member) \ - aosl_list_entry((ptr)->next, type, member) - -/** - * aosl_list_for_each - iterate over a list - * @pos: the &struct aosl_list_head to use as a loop cursor. - * @head: the head for your list. - */ -#define aosl_list_for_each(pos, head) \ - for (pos = (head)->next; pos != (head); pos = pos->next) - -/** - * aosl_list_for_each_prev - iterate over a list backwards - * @pos: the &struct aosl_list_head to use as a loop cursor. - * @head: the head for your list. - */ -#define aosl_list_for_each_prev(pos, head) \ - for (pos = (head)->prev; pos != (head); pos = pos->prev) - -/** - * aosl_list_for_each_safe - iterate over a list safe against removal of list entry - * @pos: the &struct aosl_list_head to use as a loop cursor. - * @n: another &struct aosl_list_head to use as temporary storage - * @head: the head for your list. - */ -#define aosl_list_for_each_safe(pos, n, head) \ - for (pos = (head)->next, n = pos->next; pos != (head); \ - pos = n, n = pos->next) - -/** - * aosl_list_for_each_prev_safe - iterate over a list backwards safe against removal of list entry - * @pos: the &struct aosl_list_head to use as a loop cursor. - * @n: another &struct aosl_list_head to use as temporary storage - * @head: the head for your list. - */ -#define aosl_list_for_each_prev_safe(pos, n, head) \ - for (pos = (head)->prev, n = pos->prev; \ - pos != (head); \ - pos = n, n = pos->prev) - -/** - * aosl_list_for_each_entry_t - iterate over list of given type - * @type: the type name. - * @pos: the type * to use as a loop cursor. - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - */ -#define aosl_list_for_each_entry_t(type, pos, head, member) \ - for (pos = aosl_list_entry((head)->next, type, member); \ - &pos->member != (head); \ - pos = aosl_list_entry(pos->member.next, type, member)) - -#ifdef __GNUC__ -/** - * aosl_list_for_each_entry - iterate over list of given type - * @pos: the type * to use as a loop cursor. - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - */ -#define aosl_list_for_each_entry(pos, head, member) \ - for (pos = aosl_list_entry((head)->next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = aosl_list_entry(pos->member.next, typeof(*pos), member)) -#endif - -/** - * aosl_list_for_each_entry_reverse_t - iterate backwards over list of given type. - * @type: the type name. - * @pos: the type * to use as a loop cursor. - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - */ -#define aosl_list_for_each_entry_reverse_t(type, pos, head, member) \ - for (pos = aosl_list_entry((head)->prev, type, member); \ - &pos->member != (head); \ - pos = aosl_list_entry(pos->member.prev, type, member)) - -#ifdef __GNUC__ -/** - * aosl_list_for_each_entry_reverse - iterate backwards over list of given type. - * @pos: the type * to use as a loop cursor. - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - */ -#define aosl_list_for_each_entry_reverse(pos, head, member) \ - for (pos = aosl_list_entry((head)->prev, typeof(*pos), member); \ - &pos->member != (head); \ - pos = aosl_list_entry(pos->member.prev, typeof(*pos), member)) -#endif - -/** - * aosl_list_prepare_entry_t - prepare a pos entry for use in aosl_list_for_each_entry_continue() - * @type: the type name. - * @pos: the type * to use as a start point - * @head: the head of the list - * @member: the name of the list_struct within the struct. - * - * Prepares a pos entry for use as a start point in aosl_list_for_each_entry_continue(). - */ -#define aosl_list_prepare_entry_t(type, pos, head, member) \ - ((pos) ? : aosl_list_entry(head, type, member)) - -#ifdef __GNUC__ -/** - * aosl_list_prepare_entry - prepare a pos entry for use in aosl_list_for_each_entry_continue() - * @pos: the type * to use as a start point - * @head: the head of the list - * @member: the name of the list_struct within the struct. - * - * Prepares a pos entry for use as a start point in aosl_list_for_each_entry_continue(). - */ -#define aosl_list_prepare_entry(pos, head, member) \ - ((pos) ? : aosl_list_entry(head, typeof(*pos), member)) -#endif - -/** - * aosl_list_for_each_entry_continue_t - continue iteration over list of given type - * @type: the type name. - * @pos: the type * to use as a loop cursor. - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - * - * Continue to iterate over list of given type, continuing after - * the current position. - */ -#define aosl_list_for_each_entry_continue_t(type, pos, head, member) \ - for (pos = aosl_list_entry(pos->member.next, type, member); \ - &pos->member != (head); \ - pos = aosl_list_entry(pos->member.next, type, member)) - -#ifdef __GNUC__ -/** - * aosl_list_for_each_entry_continue - continue iteration over list of given type - * @pos: the type * to use as a loop cursor. - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - * - * Continue to iterate over list of given type, continuing after - * the current position. - */ -#define aosl_list_for_each_entry_continue(pos, head, member) \ - for (pos = aosl_list_entry(pos->member.next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = aosl_list_entry(pos->member.next, typeof(*pos), member)) -#endif - -/** - * aosl_list_for_each_entry_continue_reverse_t - iterate backwards from the given point - * @type: the type name. - * @pos: the type * to use as a loop cursor. - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - * - * Start to iterate over list of given type backwards, continuing after - * the current position. - */ -#define aosl_list_for_each_entry_continue_reverse_t(type, pos, head, member) \ - for (pos = aosl_list_entry(pos->member.prev, type, member); \ - &pos->member != (head); \ - pos = aosl_list_entry(pos->member.prev, type, member)) - -#ifdef __GNUC__ -/** - * aosl_list_for_each_entry_continue_reverse - iterate backwards from the given point - * @pos: the type * to use as a loop cursor. - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - * - * Start to iterate over list of given type backwards, continuing after - * the current position. - */ -#define aosl_list_for_each_entry_continue_reverse(pos, head, member) \ - for (pos = aosl_list_entry(pos->member.prev, typeof(*pos), member); \ - &pos->member != (head); \ - pos = aosl_list_entry(pos->member.prev, typeof(*pos), member)) -#endif - -/** - * aosl_list_for_each_entry_from_t - iterate over list of given type from the current point - * @type: the type name. - * @pos: the type * to use as a loop cursor. - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - * - * Iterate over list of given type, continuing from current position. - */ -#define aosl_list_for_each_entry_from_t(type, pos, head, member) \ - for (; &pos->member != (head); \ - pos = aosl_list_entry(pos->member.next, type, member)) - -#ifdef __GNUC__ -/** - * aosl_list_for_each_entry_from - iterate over list of given type from the current point - * @pos: the type * to use as a loop cursor. - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - * - * Iterate over list of given type, continuing from current position. - */ -#define aosl_list_for_each_entry_from(pos, head, member) \ - for (; &pos->member != (head); \ - pos = aosl_list_entry(pos->member.next, typeof(*pos), member)) -#endif - -/** - * aosl_list_for_each_entry_safe_t - iterate over list of given type safe against removal of list entry - * @type: the type name. - * @pos: the type * to use as a loop cursor. - * @n: another type * to use as temporary storage - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - */ -#define aosl_list_for_each_entry_safe_t(type, pos, n, head, member) \ - for (pos = aosl_list_entry((head)->next, type, member), \ - n = aosl_list_entry(pos->member.next, type, member); \ - &pos->member != (head); \ - pos = n, n = aosl_list_entry(n->member.next, type, member)) - -#ifdef __GNUC__ -/** - * aosl_list_for_each_entry_safe - iterate over list of given type safe against removal of list entry - * @pos: the type * to use as a loop cursor. - * @n: another type * to use as temporary storage - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - */ -#define aosl_list_for_each_entry_safe(pos, n, head, member) \ - for (pos = aosl_list_entry((head)->next, typeof(*pos), member), \ - n = aosl_list_entry(pos->member.next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = n, n = aosl_list_entry(n->member.next, typeof(*n), member)) -#endif - -/** - * aosl_list_for_each_entry_safe_continue_t - continue list iteration safe against removal - * @type: the type name. - * @pos: the type * to use as a loop cursor. - * @n: another type * to use as temporary storage - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - * - * Iterate over list of given type, continuing after current point, - * safe against removal of list entry. - */ -#define aosl_list_for_each_entry_safe_continue_t(type, pos, n, head, member) \ - for (pos = aosl_list_entry(pos->member.next, type, member), \ - n = aosl_list_entry(pos->member.next, type, member); \ - &pos->member != (head); \ - pos = n, n = aosl_list_entry(n->member.next, type, member)) - -#ifdef __GNUC__ -/** - * aosl_list_for_each_entry_safe_continue - continue list iteration safe against removal - * @pos: the type * to use as a loop cursor. - * @n: another type * to use as temporary storage - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - * - * Iterate over list of given type, continuing after current point, - * safe against removal of list entry. - */ -#define aosl_list_for_each_entry_safe_continue(pos, n, head, member) \ - for (pos = aosl_list_entry(pos->member.next, typeof(*pos), member), \ - n = aosl_list_entry(pos->member.next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = n, n = aosl_list_entry(n->member.next, typeof(*n), member)) -#endif - -/** - * aosl_list_for_each_entry_safe_from_t - iterate over list from current point safe against removal - * @type: the type name. - * @pos: the type * to use as a loop cursor. - * @n: another type * to use as temporary storage - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - * - * Iterate over list of given type from current point, safe against - * removal of list entry. - */ -#define aosl_list_for_each_entry_safe_from_t(type, pos, n, head, member) \ - for (n = aosl_list_entry(pos->member.next, type, member); \ - &pos->member != (head); \ - pos = n, n = aosl_list_entry(n->member.next, type, member)) - -#ifdef __GNUC__ -/** - * aosl_list_for_each_entry_safe_from - iterate over list from current point safe against removal - * @pos: the type * to use as a loop cursor. - * @n: another type * to use as temporary storage - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - * - * Iterate over list of given type from current point, safe against - * removal of list entry. - */ -#define aosl_list_for_each_entry_safe_from(pos, n, head, member) \ - for (n = aosl_list_entry(pos->member.next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = n, n = aosl_list_entry(n->member.next, typeof(*n), member)) -#endif - -/** - * aosl_list_for_each_entry_safe_reverse_t - iterate backwards over list safe against removal - * @type: the type name. - * @pos: the type * to use as a loop cursor. - * @n: another type * to use as temporary storage - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - * - * Iterate backwards over list of given type, safe against removal - * of list entry. - */ -#define aosl_list_for_each_entry_safe_reverse_t(type, pos, n, head, member) \ - for (pos = aosl_list_entry((head)->prev, type, member), \ - n = aosl_list_entry(pos->member.prev, type, member); \ - &pos->member != (head); \ - pos = n, n = aosl_list_entry(n->member.prev, type, member)) - -#ifdef __GNUC__ -/** - * aosl_list_for_each_entry_safe_reverse - iterate backwards over list safe against removal - * @pos: the type * to use as a loop cursor. - * @n: another type * to use as temporary storage - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - * - * Iterate backwards over list of given type, safe against removal - * of list entry. - */ -#define aosl_list_for_each_entry_safe_reverse(pos, n, head, member) \ - for (pos = aosl_list_entry((head)->prev, typeof(*pos), member), \ - n = aosl_list_entry(pos->member.prev, typeof(*pos), member); \ - &pos->member != (head); \ - pos = n, n = aosl_list_entry(n->member.prev, typeof(*n), member)) -#endif - -/** - * aosl_list_safe_reset_next_t - reset a stale aosl_list_for_each_entry_safe loop - * @type: the type name. - * @pos: the loop cursor used in the aosl_list_for_each_entry_safe loop - * @n: temporary storage used in aosl_list_for_each_entry_safe - * @member: the name of the list_struct within the struct. - * - * aosl_list_safe_reset_next is not safe to use in general if the list may be - * modified concurrently (eg. the lock is dropped in the loop body). An - * exception to this is if the cursor element (pos) is pinned in the list, - * and aosl_list_safe_reset_next is called after re-taking the lock and before - * completing the current iteration of the loop body. - */ -#define aosl_list_safe_reset_next_t(type, pos, n, member) \ - n = aosl_list_entry(pos->member.next, type, member) - -#ifdef __GNUC__ -/** - * aosl_list_safe_reset_next - reset a stale aosl_list_for_each_entry_safe loop - * @pos: the loop cursor used in the aosl_list_for_each_entry_safe loop - * @n: temporary storage used in aosl_list_for_each_entry_safe - * @member: the name of the list_struct within the struct. - * - * aosl_list_safe_reset_next is not safe to use in general if the list may be - * modified concurrently (eg. the lock is dropped in the loop body). An - * exception to this is if the cursor element (pos) is pinned in the list, - * and aosl_list_safe_reset_next is called after re-taking the lock and before - * completing the current iteration of the loop body. - */ -#define aosl_list_safe_reset_next(pos, n, member) \ - n = aosl_list_entry(pos->member.next, typeof(*pos), member) -#endif - -static __inline__ struct aosl_list_head *aosl_list_head (struct aosl_list_head *head) -{ - if (!aosl_list_empty (head)) - return head->next; - - return NULL; -} - -static __inline__ struct aosl_list_head *aosl_list_next (struct aosl_list_head *head, struct aosl_list_head *node) -{ - node = node->next; - if (node != head) - return node; - - return NULL; -} - -static __inline__ struct aosl_list_head *aosl_list_prev (struct aosl_list_head *head, struct aosl_list_head *node) -{ - node = node->prev; - if (node != head) - return node; - - return NULL; -} - -static inline struct aosl_list_head *aosl_list_tail (struct aosl_list_head *head) -{ - if (!aosl_list_empty (head)) - return head->prev; - - return NULL; -} - -#ifdef __GNUC__ -#define aosl_list_head_entry(list, type, member) \ -({ \ - struct aosl_list_head *__$p$ = aosl_list_head (list); \ - type *entry = (__$p$ != NULL) ? aosl_list_entry (__$p$, type, member) : NULL; \ - entry; \ -}) - -#define aosl_list_next_entry(list, pos, type, member) \ -({ \ - struct aosl_list_head *__$p$ = aosl_list_next (list, &(pos)->member); \ - type *entry = (__$p$ != NULL) ? aosl_list_entry (__$p$, type, member) : NULL; \ - entry; \ -}) - -#define aosl_list_prev_entry(list, pos, type, member) \ -({ \ - struct aosl_list_head *__$p$ = aosl_list_prev (list, &(pos)->member); \ - type *entry = (__$p$ != NULL) ? aosl_list_entry (__$p$, type, member) : NULL; \ - entry; \ -}) - -#define aosl_list_tail_entry(list, type, member) \ -({ \ - struct aosl_list_head *__$p$ = aosl_list_tail (list); \ - type *entry = (__$p$ != NULL) ? aosl_list_entry (__$p$, type, member) : NULL; \ - entry; \ -}) -#else -#define aosl_list_head_entry(list, type, member) \ - ((aosl_list_head (list) != NULL) ? aosl_list_entry (aosl_list_head (list), type, member) : NULL) - -#define aosl_list_next_entry(list, pos, type, member) \ - ((aosl_list_next (list, &(pos)->member) != NULL) ? aosl_list_entry (aosl_list_next (list, &(pos)->member), type, member) : NULL) - -#define aosl_list_prev_entry(list, pos, type, member) \ - ((aosl_list_prev (list, &(pos)->member) != NULL) ? aosl_list_entry (aosl_list_prev (list, &(pos)->member), type, member) : NULL) - -#define aosl_list_tail_entry(list, type, member) \ - ((aosl_list_tail (list) != NULL) ? aosl_list_entry (aosl_list_tail (list), type, member) : NULL) -#endif - -static inline struct aosl_list_head *aosl_list_remove_head (struct aosl_list_head *head) -{ - if (!aosl_list_empty (head)) { - struct aosl_list_head *__$p$ = head->next; - aosl_list_del (__$p$); - return __$p$; - } - - return NULL; -} - -static inline struct aosl_list_head *aosl_list_remove_head_init (struct aosl_list_head *head) -{ - if (!aosl_list_empty (head)) { - struct aosl_list_head *__$p$ = head->next; - aosl_list_del_init (__$p$); - return __$p$; - } - - return NULL; -} - -#ifdef __GNUC__ -#define aosl_list_remove_head_entry(list, type, member) \ -({ \ - struct aosl_list_head *__$p$ = aosl_list_remove_head (list); \ - type *entry = (__$p$ != NULL) ? aosl_list_entry (__$p$, type, member) : NULL; \ - entry; \ -}) - -#define aosl_list_remove_head_entry_init(list, type, member) \ -({ \ - struct aosl_list_head *__$p$ = aosl_list_remove_head_init (list); \ - type *entry = (__$p$ != NULL) ? aosl_list_entry (__$p$, type, member) : NULL; \ - entry; \ -}) -#else -#define aosl_list_remove_head_entry(list, type, member) \ - ((aosl_list_head (list) != NULL) ? aosl_list_entry (aosl_list_remove_head (list), type, member) : NULL) - -#define aosl_list_remove_head_entry_init(list, type, member) \ - ((aosl_list_head (list) != NULL) ? aosl_list_entry (aosl_list_remove_head_init (list), type, member) : NULL) -#endif - -static inline struct aosl_list_head *aosl_list_remove_tail (struct aosl_list_head *head) -{ - if (!aosl_list_empty (head)) { - struct aosl_list_head *__$p$ = head->prev; - aosl_list_del (__$p$); - return __$p$; - } - - return NULL; -} - -static inline struct aosl_list_head *aosl_list_remove_tail_init (struct aosl_list_head *head) -{ - if (!aosl_list_empty (head)) { - struct aosl_list_head *__$p$ = head->prev; - aosl_list_del_init (__$p$); - return __$p$; - } - - return NULL; -} - -#ifdef __GNUC__ -#define aosl_list_remove_tail_entry(list, type, member) \ -({ \ - struct aosl_list_head *__$p$ = aosl_list_remove_tail (list); \ - type *entry = (__$p$ != NULL) ? aosl_list_entry (__$p$, type, member) : NULL; \ - entry; \ -}) - -#define aosl_list_remove_tail_entry_init(list, type, member) \ -({ \ - struct aosl_list_head *__$p$ = aosl_list_remove_tail_init (list); \ - type *entry = (__$p$ != NULL) ? aosl_list_entry (__$p$, type, member) : NULL; \ - entry; \ -}) -#else -#define aosl_list_remove_tail_entry(list, type, member) \ - ((aosl_list_tail (list) != NULL) ? aosl_list_entry (aosl_list_remove_tail (list), type, member) : NULL) - -#define aosl_list_remove_tail_entry_init(list, type, member) \ - ((aosl_list_tail (list) != NULL) ? aosl_list_entry (aosl_list_remove_tail_init (list), type, member) : NULL) -#endif - - -#ifdef __cplusplus -} -#endif - - -#endif /* __AOSL_LIST_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_log.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_log.h deleted file mode 100644 index 9d502fd18..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_log.h +++ /dev/null @@ -1,135 +0,0 @@ -#ifndef __AOSL_LOG_H__ -#define __AOSL_LOG_H__ - -#include -#include - -#if defined (__linux__) || defined (__MACH__) || defined (__kliteos2__) -#include - -#define AOSL_LOG_EMERG LOG_EMERG /* system is unusable */ -#define AOSL_LOG_ALERT LOG_ALERT /* action must be taken immediately */ -#define AOSL_LOG_CRIT LOG_CRIT /* critical conditions */ -#define AOSL_LOG_ERR LOG_ERR /* error conditions */ -#define AOSL_LOG_WARNING LOG_WARNING /* warning conditions */ -#define AOSL_LOG_NOTICE LOG_NOTICE /* normal but significant condition */ -#define AOSL_LOG_INFO LOG_INFO /* informational */ -#define AOSL_LOG_DEBUG LOG_DEBUG /* debug-level messages */ - -#define AOSL_LOG_PRIMASK LOG_PRIMASK /* mask to extract priority part (internal) */ -/* extract priority */ -#define AOSL_LOG_PRI(p) LOG_PRI(p) -#define AOSL_LOG_MAKEPRI(fac, pri) LOG_MAKEPRI (fac, pri) -#else -/** - * PLEASE BE CAREFUL ENOUGH HERE: - * The macro __kspreadtrum__ is not a compiler toolchain - * predefined macro, and makercore building system will - * define this macro when building Spreadtrum system, so - * you must GUARANTEE define it when not using makercore - * building system. - * Use this style name rather than Kbuild CONFIG_* just - * want to keep consistent with __linux__/__MACH__ etc. - * -- Lionfore Hao Aug 1st, 2020 - **/ -#if defined (__kspreadtrum__) -/* For SCI_Trace/SCI_TraceHigh/SCI_TraceLow declarations. */ -#include -#endif - -/* - * priorities/facilities are encoded into a single 32-bit quantity, where the - * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility - * (0-big number). Both the priorities and the facilities map roughly - * one-to-one to strings in the syslogd(8) source code. This mapping is - * included in this file. - * - * priorities (these are ordered) - */ -#define AOSL_LOG_EMERG 0 /* system is unusable */ -#define AOSL_LOG_ALERT 1 /* action must be taken immediately */ -#define AOSL_LOG_CRIT 2 /* critical conditions */ -#define AOSL_LOG_ERR 3 /* error conditions */ -#define AOSL_LOG_WARNING 4 /* warning conditions */ -#define AOSL_LOG_NOTICE 5 /* normal but significant condition */ -#define AOSL_LOG_INFO 6 /* informational */ -#define AOSL_LOG_DEBUG 7 /* debug-level messages */ - -#define AOSL_LOG_PRIMASK 0x07 /* mask to extract priority part (internal) */ -/* extract priority */ -#define AOSL_LOG_PRI(p) ((p) & AOSL_LOG_PRIMASK) -#define AOSL_LOG_MAKEPRI(fac, pri) ((fac) | (pri)) -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifndef _MSC_VER -#define aosl_printf_fmt(a, b) __attribute__ ((format (printf, a, b))) -#define aosl_scanf_fmt(a, b) __attribute__ ((format (scanf, a, b))) -#else -#define aosl_printf_fmt(a, b) -#define aosl_scanf_fmt(a, b) -#endif - -#define aosl_printf_fmt12 aosl_printf_fmt (1, 2) -#define aosl_printf_fmt23 aosl_printf_fmt (2, 3) - - - -/** - * The log callback function. - * The log level uses the same values as syslog, these values are used by AOSL library and - * its' descendents, so please translate the log levels to your own log levels respectively. - **/ -typedef void (*aosl_vlog_t) (int level, const char *fmt, va_list args); - -/** - * The default AOSL log function is syslog, but you can provide your own log function. - * Pay enough attention please, your own log function MUST conform the same semantics - * with syslog, and all log levels must have the same meaning with the ones of syslog. - **/ -extern __aosl_api__ void aosl_set_vlog_func (aosl_vlog_t vlog); - -/** - * Get the aosl log level, AOSL_LOG_ERR is the default value. - * Parameters: - * none. - * Return value: - * the current aosl log level. - **/ -extern __aosl_api__ int aosl_get_log_level (void); - -/** - * Set the aosl log level, AOSL_LOG_ERR is the default value. - * Parameters: - * level: the log level you want to set - * Return value: - * none. - **/ -extern __aosl_api__ void aosl_set_log_level (int level); - -extern __aosl_api__ void aosl_printf_fmt23 aosl_log (int level, const char *fmt, ...); -extern __aosl_api__ void aosl_vlog (int level, const char *fmt, va_list args); - -#if !defined (__linux__) && !defined (__MACH__) && !defined (__kliteos2__) -extern __aosl_api__ void aosl_printf_fmt23 syslog (int level, const char *fmt, ...); -extern __aosl_api__ void vsyslog (int level, const char *fmt, va_list args); -#endif - -extern __aosl_api__ void aosl_printf_fmt12 aosl_printf (const char *fmt, ...); -extern __aosl_api__ void aosl_vprintf (const char *fmt, va_list args); - - -extern __aosl_api__ void aosl_printf_fmt12 aosl_panic (const char *fmt, ...); - - -#ifdef __cplusplus -} -#endif - - - -#endif /* __AOSL_LOG_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_marshalling.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_marshalling.h deleted file mode 100644 index ee2d4968f..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_marshalling.h +++ /dev/null @@ -1,170 +0,0 @@ -/************************************************************* - * Author : Lionfore Hao (haolianfu@agora.io) - * Date : Jul 21st, 2018 - * Module : Data Marshalling - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_MARSHALLING_H__ -#define __AOSL_MARSHALLING_H__ - -#include -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - -typedef enum { - AOSL_TYPE_VOID, - AOSL_TYPE_INT8, - AOSL_TYPE_INT16, - AOSL_TYPE_INT32, - AOSL_TYPE_INT64, -#if !defined (_MSC_VER) && defined (__LP64__) - AOSL_TYPE_INT128, -#endif - AOSL_TYPE_FLOAT, - AOSL_TYPE_DOUBLE, - AOSL_TYPE_V4_IPADDR, - AOSL_TYPE_V6_IPADDR, - AOSL_TYPE_POINTER, - AOSL_TYPE_REFERENCE, - AOSL_TYPE_STRING, - AOSL_TYPE_STRUCT, - AOSL_TYPE_FIXED_BYTES, - AOSL_TYPE_VAR_BYTES, - AOSL_TYPE_BYTES_WITH_NIL, - AOSL_TYPE_DYNAMIC_BYTES, - AOSL_TYPE_DYNAMIC_STRING, - AOSL_TYPE_FIXED_ARRAY, - AOSL_TYPE_VAR_ARRAY, - AOSL_TYPE_DYNAMIC_ARRAY, -} aosl_type_id; - -typedef struct { - /** - * For almost all cases, the count of an array will not - * exceed a 16 bit unsigned integer, so we just employ - * a 16 bit unsigned in the marshalling packet is OK. - * For those cases that the size of array exceed a 16 - * bit integer, I think the system designer should split - * the packet into severals to resolve the problem. - * -- Lionfore Hao Jul 19th, 2018 - **/ - uint16_t count; - uint16_t allocated; - void *values; -} aosl_dynamic_array_t; - -extern __aosl_api__ void aosl_dynamic_array_init (aosl_dynamic_array_t *arr); -extern __aosl_api__ void aosl_dynamic_array_init_with (aosl_dynamic_array_t *arr, void *data, size_t len); -extern __aosl_api__ int aosl_dynamic_array_add_elems (aosl_dynamic_array_t *arr, const void *elems, size_t elem_size, size_t nelems); -extern __aosl_api__ void aosl_dynamic_array_take (aosl_dynamic_array_t *dst, aosl_dynamic_array_t *src); -extern __aosl_api__ int aosl_dynamic_array_is_empty (const aosl_dynamic_array_t *arr); - -typedef aosl_dynamic_array_t aosl_dynamic_bytes_t; -typedef aosl_dynamic_bytes_t aosl_dynamic_string_t; - -#define aosl_dynamic_bytes_init(v) aosl_dynamic_array_init (v) -#define aosl_dynamic_bytes_init_with(v, buf, len) aosl_dynamic_array_init_with (v, buf, len) -#define aosl_dynamic_string_init(s) aosl_dynamic_array_init (s) -#define aosl_dynamic_string_init_with(v, buf, len) aosl_dynamic_array_init_with (v, buf, len) - -#define aosl_dynamic_array_data(arr, T) ((T *)(arr).values) -#define aosl_dynamic_bytes_data(arr) aosl_dynamic_array_data (arr, uint8_t) -#define aosl_dynamic_string_c_str(dyn_str) aosl_dynamic_array_data (dyn_str, char) - -extern __aosl_api__ int aosl_dynamic_bytes_add_data (aosl_dynamic_bytes_t *dyn_bytes, const void *data, size_t len); -extern __aosl_api__ int aosl_dynamic_bytes_copy_data (aosl_dynamic_bytes_t *dyn_bytes, const void *data, size_t len); -extern __aosl_api__ int aosl_dynamic_string_strcat (aosl_dynamic_string_t *dyn_str, const char *str); -extern __aosl_api__ int aosl_dynamic_string_strcpy (aosl_dynamic_string_t *dyn_str, const char *str); -extern __aosl_api__ const char *aosl_dynamic_string_strcpy_out (char *buf, size_t buf_sz, const aosl_dynamic_string_t *dyn_str); - -#define aosl_dynamic_bytes_take(dst, src) aosl_dynamic_array_take (dst, src) -#define aosl_dynamic_string_take(dst, src) aosl_dynamic_array_take (dst, src) - -#define aosl_bytes_is_empty(v) aosl_dynamic_array_is_empty (v) -#define aosl_dynamic_string_is_empty(v) aosl_dynamic_array_is_empty (v) - -extern __aosl_api__ int aosl_dynamic_bytes_copy (aosl_dynamic_bytes_t *dst, const aosl_dynamic_bytes_t *src); -#define aosl_dynamic_string_copy(dst, src) aosl_dynamic_bytes_copy (dst, src) - -extern __aosl_api__ int aosl_dynamic_bytes_compare (const aosl_dynamic_bytes_t *b1, const aosl_dynamic_bytes_t *b2); -#define aosl_dynamic_string_compare(s1, s2) aosl_dynamic_bytes_compare (s1, s2) - - -typedef struct _____type_info { - aosl_type_id type_id; - uint32_t obj_size; - uint32_t array_size; - uint16_t *count_var_addr; - void *obj_addr; - const struct _____type_info *child; -} aosl_type_info_t; - -#define AOSL_TYPE_STRUCT_END { .type_id = AOSL_TYPE_VOID } - - - -extern __aosl_api__ void aosl_init_typed_obj (const aosl_type_info_t *type, void *typed_obj_p); -extern __aosl_api__ ssize_t aosl_marshal (const aosl_type_info_t *type, const void *typed_obj_p, aosl_psb_t *psb); -extern __aosl_api__ ssize_t aosl_unmarshal (const aosl_type_info_t *type, void *typed_obj_p, const aosl_psb_t *psb); -extern __aosl_api__ ssize_t aosl_marshal_c_str (const char *str, uint32_t nmax, aosl_psb_t *psb); -extern __aosl_api__ ssize_t aosl_unmarshal_c_str (char *str, uint32_t nmax, const aosl_psb_t *psb); -extern __aosl_api__ void aosl_fini_typed_obj (const aosl_type_info_t *type, const void *typed_obj_p); -extern __aosl_api__ ssize_t aosl_marshal_size (const aosl_type_info_t *type, const void *typed_obj_p); - - -extern __aosl_api__ uint16_t aosl_encode_int16 (uint16_t v); -extern __aosl_api__ uint32_t aosl_encode_int32 (uint32_t v); -extern __aosl_api__ uint64_t aosl_encode_int64 (uint64_t v); - -extern __aosl_api__ uint16_t aosl_decode_int16 (uint16_t v); -extern __aosl_api__ uint32_t aosl_decode_int32 (uint32_t v); -extern __aosl_api__ uint64_t aosl_decode_int64 (uint64_t v); - - -extern const aosl_type_info_t aosl_void_type; -extern const aosl_type_info_t aosl_int16_type; -extern const aosl_type_info_t aosl_int32_type; -extern const aosl_type_info_t aosl_int64_type; -#if !defined (_MSC_VER) && defined (__LP64__) -extern const aosl_type_info_t aosl_int128_type; -#endif -extern const aosl_type_info_t aosl_float_type; -extern const aosl_type_info_t aosl_double_type; -extern const aosl_type_info_t aosl_v4_ipaddr_type; -extern const aosl_type_info_t aosl_v6_ipaddr_type; -extern const aosl_type_info_t aosl_dynamic_bytes_type; -extern const aosl_type_info_t aosl_dynamic_string_type; -extern const aosl_type_info_t aosl_dynamic_int16_array_type; -extern const aosl_type_info_t aosl_dynamic_int32_array_type; -extern const aosl_type_info_t aosl_dynamic_int64_array_type; -#if !defined (_MSC_VER) && defined (__LP64__) -extern const aosl_type_info_t aosl_dynamic_int128_array_type; -#endif -extern const aosl_type_info_t aosl_dynamic_float_array_type; -extern const aosl_type_info_t aosl_dynamic_double_array_type; -extern const aosl_type_info_t aosl_dynamic_v4_ipaddr_array_type; -extern const aosl_type_info_t aosl_dynamic_v6_ipaddr_array_type; - -#define aosl_dynamic_bytes_fini(bytes) aosl_fini_typed_obj (&aosl_dynamic_bytes_type, bytes) -#define aosl_dynamic_string_fini(dyn_str) aosl_fini_typed_obj (&aosl_dynamic_string_type, dyn_str) - - - -#ifdef __cplusplus -} -#endif - - -#endif /* __AOSL_MARSHALLING_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mm.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mm.h deleted file mode 100644 index 97b7b0fe4..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mm.h +++ /dev/null @@ -1,295 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jul 23rd, 2018 - * Module: Memory Management relative utilities header file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_MM_H__ -#define __AOSL_MM_H__ - -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - -/** - * aosl memory management malloc like function - * Note: this is memory pool based implementation, so it - * can decrease the fragmentation. - * Parameters: - * size: the allocation size in bytes; - * Return Value: - * non-NULL: success - * NULL: failure with aosl_errno set - * Remarks: - * The memory allocated by this function must be freed - * via aosl_mm_free when finished using. - **/ -extern __aosl_api__ void *aosl_mm_malloc (size_t size); - -/** - * aosl memory management realloc like function - * Note: this is memory pool based implementation, so it - * can decrease the fragmentation. - * Parameters: - * ptr: the old pointer wanting to realloc; - * size: the new allocation size in bytes; - * Return Value: - * non-NULL: success - * NULL: failure with aosl_errno set - * Remarks: - * The contents will be unchanged in the range from the - * start of the region up to the minimum of the old and - * new sizes; - * If the new size is larger than the old size, the added - * memory will not be initialized; - * If ptr is NULL, then the call is equivalent to - * aosl_mm_malloc(size), for all values of size; - * If size is equal to zero, and ptr is not NULL, then the - * call is equivalent to aosl_mm_free(ptr); - * Unless ptr is NULL, it must have been returned by an - * earlier call to aosl_mm_malloc, aosl_mm_calloc, or - * aosl_mm_realloc; - * If this function fails, the original block is left - * untouched, it is not freed or moved; - * The memory allocated by this function must be freed - * via aosl_mm_free when finished using. - **/ -extern __aosl_api__ void *aosl_mm_realloc (void *ptr, size_t size); - -/** - * aosl memory management calloc like function - * Note: this is memory pool based implementation, so it - * can decrease the fragmentation. - * Parameters: - * nmemb: number of array elements count; - * size: the element size in bytes; - * Return Value: - * non-NULL: success - * NULL: failure with aosl_errno set - * Remarks: - * This function allocates memory for an array of nmemb - * elements of size bytes each and returns a pointer to - * the allocated memory, and the memory is set to zero; - * If nmemb or size is 0, then returns NULL; - * The memory allocated by this function must be freed - * via aosl_mm_free when finished using. - **/ -extern __aosl_api__ void *aosl_mm_calloc (size_t nmemb, size_t size); - -/** - * aosl memory management free like function - * Note: this is memory pool based implementation, so it - * can decrease the fragmentation. - * Parameters: - * ptr: the allocated pointer by aosl_mm_malloc; - * Return Value: - * None. - * Remarks: - * Do NOT try to free a pointer which is not allocated - * by aosl_mm_malloc via this function. - **/ -extern __aosl_api__ void aosl_mm_free (void *ptr); - -/** - * Preallocate the objects count to threshold for the memory pool specified by size. - * Note: this is memory pool based implementation, so it - * can decrease the fragmentation. - * Parameters: - * size: specify which the memory pool will be set threshold; - * threshold: specify the memory objects count will be preallocated; - * Return Value: - * 0: success - * <0: failure with aosl_errno set - * Remarks: - * If set the threshold first, then the following first time - * allocation operation will be faster than normal. - **/ -extern __aosl_api__ int aosl_mm_set_threshold (size_t size, size_t threshold); - -/** - * Set the max objects count to max_val for the memory pool specified by size. - * Note: this is memory pool based implementation, so it - * can decrease the fragmentation. - * Parameters: - * size: specify which the memory pool will be set threshold; - * max_val: specify the max memory objects count; - * Return Value: - * 0: success - * <0: failure with aosl_errno set - * Remarks: - * If the max objects were allocated, and the following allocation - * will return NULL if no objects was freed. - **/ -extern __aosl_api__ int aosl_mm_set_max (size_t size, size_t max_val); - -/** - * Shrink the memory pool specified by the size parameter. - * Parameters: - * size: specify which the memory pool will be shrinked; - * Return Value: - * None. - **/ -extern __aosl_api__ void aosl_mm_shrink (size_t size); - -/** - * Shrink all the created memory pools. - * Parameters: - * None. - * Return Value: - * None. - **/ -extern __aosl_api__ void aosl_mm_shrink_all (void); - -/* the aosl freelist object type */ -typedef struct _aosl_freelist_ *aosl_freelist_t; - -/** - * Create a freelist object for efficient memory management. - * Note: this is memory pool based implementation, so it - * can decrease the fragmentation. - * Parameters: - * obj_size: the memory object size in bytes for this freelist; - * namefmt: printf like format for the freelist object name; - * ...: printf like ... args; - * Return Value: - * non-NULL: success - * NULL: failure with aosl_errno set - * Remarks: - * The max name length of freelist object is 32 including - * the final '\0'. - **/ -extern __aosl_api__ aosl_freelist_t aosl_freelist_create (size_t obj_size, const char *namefmt, ...); - -/** - * Create a freelist object for efficient memory management. - * Note: this is memory pool based implementation, so it - * can decrease the fragmentation. - * Parameters: - * obj_size: the memory object size in bytes for this freelist; - * namefmt: vprintf like format for the freelist object name; - * args: vprintf like args; - * Return Value: - * non-NULL: success - * NULL: failure with aosl_errno set - * Remarks: - * The max name length of freelist object is 32 including - * the final '\0'. - **/ -extern __aosl_api__ aosl_freelist_t aosl_freelist_create_args (size_t obj_size, const char *namefmt, va_list args); - -/** - * Allocate memory from the specified freelist object. - * Note: this is memory pool based implementation, so it - * can decrease the fragmentation. - * Parameters: - * fl: the freelist object; - * Return Value: - * non-NULL: success - * NULL: failure with aosl_errno set - * Remarks: - * The allocated memory must be freed by aosl_freelist_free - * after finished using. - **/ -extern __aosl_api__ void *aosl_freelist_alloc (aosl_freelist_t fl); - -/** - * Free memory to the specified freelist object. - * Note: this is memory pool based implementation, so it - * can decrease the fragmentation. - * Parameters: - * fl: the freelist object; - * ptr: the memory pointer will be freed; - * Return Value: - * None. - * Remarks: - * The ptr must be allocated from fl. - **/ -extern __aosl_api__ void aosl_freelist_free (aosl_freelist_t fl, void *ptr); - -/** - * Preallocate the objects count to threshold for the specified freelist object. - * Note: this is memory pool based implementation, so it - * can decrease the fragmentation. - * Parameters: - * fl: the freelist object which will be set threshold; - * threshold: specify the memory objects count will be preallocated; - * Return Value: - * 0: success - * <0: failure with aosl_errno set - * Remarks: - * If set the threshold first, then the following first time - * allocation operation will be faster than normal. - **/ -extern __aosl_api__ int aosl_freelist_set_threshold (aosl_freelist_t fl, size_t threshold); - -/** - * Set the max objects count to max_val for the specified freelist object. - * Note: this is memory pool based implementation, so it - * can decrease the fragmentation. - * Parameters: - * fl: the freelist object which will be set max memory objects count; - * max_val: specify the max memory objects count; - * Return Value: - * 0: success - * <0: failure with aosl_errno set - * Remarks: - * If the max objects were allocated, and the following allocation - * will return NULL if no objects was freed. - **/ -extern __aosl_api__ int aosl_freelist_set_max (aosl_freelist_t fl, size_t max_val); - -/** - * Shrink the freelist specified by the fl. - * Parameters: - * fl: the freelist object which will be shrinked; - * Return Value: - * None. - **/ -extern __aosl_api__ void aosl_freelist_shrink (aosl_freelist_t fl); - -/** - * Destroy the freelist specified by the fl. - * Parameters: - * fl: the freelist object which will be destroyed; - * Return Value: - * 0: success - * <0: failure with aosl_errno set - * Remarks: - * If there are allocated objects from this freelist, then it - * could not be destroyed, so the destroy call would fail. - **/ -extern __aosl_api__ int aosl_freelist_destroy (aosl_freelist_t fl); - - -extern __aosl_api__ void *aosl_malloc (size_t size); -extern __aosl_api__ void aosl_free (void *ptr); -extern __aosl_api__ void *aosl_calloc (size_t nmemb, size_t size); -extern __aosl_api__ void *aosl_realloc (void *ptr, size_t size); - -extern __aosl_api__ char *aosl_strdup (const char *s); - -extern __aosl_api__ int aosl_page_size (void); - -#define AOSL_PAGE_SIZE (aosl_page_size ()) -#define PAGE_ALIGNED_ADDR(a) ((void *)((uintptr_t)(a) & (uintptr_t)(intptr_t)~(AOSL_PAGE_SIZE - 1))) -#define PAGE_ALIGNED_SIZE(s) ((size_t)((size_t)(s) + (AOSL_PAGE_SIZE - 1)) & (uintptr_t)(intptr_t)~(AOSL_PAGE_SIZE - 1)) - - -#ifdef __cplusplus -} -#endif - - - -#endif /* __AOSL_MM_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_module.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_module.h deleted file mode 100644 index e148c9c81..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_module.h +++ /dev/null @@ -1,81 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jul 18th, 2020 - * Module: AOSL module interface definition header file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2020 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_MODULE_H__ -#define __AOSL_MODULE_H__ - -#include - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -typedef void *aosl_module_t; - -typedef int (*aosl_module_call_t) (uintptr_t argc, uintptr_t argv []); - -extern __so_api__ int aosl_module_register (const char *name, aosl_module_call_t entry); -extern __so_api__ aosl_module_t aosl_module_get (const char *name); -extern __so_api__ int aosl_module_call (aosl_module_t module, uintptr_t argc, ...); -extern __so_api__ int aosl_module_call_args (aosl_module_t module, uintptr_t argc, va_list args); -extern __so_api__ int aosl_module_call_argv (aosl_module_t module, uintptr_t argc, uintptr_t argv []); -extern __so_api__ void aosl_module_put (aosl_module_t module); -extern __so_api__ int aosl_module_unregister (const char *name); - -#if defined (__GNUC__) -#define AOSL_DEFINE_MODULE_REGFN(regfn, name, entry) \ - static void __attribute__ ((constructor, used)) _##name##_module_ctor (void) \ - { \ - if (regfn##_register (#name, entry) < 0) \ - abort (); \ - } \ -\ - static void __attribute__ ((destructor, used)) _##name##_module_dtor (void) \ - { \ - if (regfn##_unregister (#name) < 0) \ - abort (); \ - } -#elif defined (_MSC_VER) -#pragma section (".CRT$XIG", long, read) - -#define AOSL_DEFINE_MODULE_REGFN(regfn, name, entry) \ - static void _##name##_module_dtor (void) \ - { \ - if (regfn##_unregister (#name) < 0) \ - abort (); \ - } \ -\ - static int _##name##_module_ctor (void) \ - { \ - if (regfn##_register (#name, entry) < 0) \ - abort (); \ - atexit (_##name##_module_dtor); \ - return 0; \ - } \ - __declspec(allocate(".CRT$XIG")) int (*_##name##_module_ctor_f) (void) = _##name##_module_ctor; -#else -#error Unsupported Toolchain! -#endif - -#define AOSL_DEFINE_MODULE(name, entry) AOSL_DEFINE_MODULE_REGFN(aosl_module, name, entry) - - -#ifdef __cplusplus -} -#endif - - -#endif /* __AOSL_MODULE_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq.h deleted file mode 100644 index 3dc8c1b95..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq.h +++ /dev/null @@ -1,549 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jul 18th, 2018 - * Module: Multiplex queue header file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_MPQ_H__ -#define __AOSL_MPQ_H__ - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - - - -/** - * AOSL performance callback function proto type. - * Parameters: - * f_name: the functionality name, which was specified when - * queue/call something, it might be NULL if not - * specified a name - * free_only: 0 for normal exec, and other values for free only - * wait_us: the wait time in queue before executing(microseconds) - * exec_us: the executing time(microseconds) - * Return Value: - * none. - **/ -typedef void (*aosl_perf_f_t) (const char *f_name, int free_only, uint32_t wait_us, uint32_t exec_us); - -/** - * Set/Unset the AOSL performance callback function. - * Note: this callback function MUST BE set/unset before - * creating any mpq or after all mpq have exited. - * Parameters: - * perf_f: the performance callback function, NULL for unset - * Return Value: - * 0: success - * <0: failure with aosl_errno set - * Remarks: - * If invoking this function when any mpq is active, - * then it will return -1 with aosl_errno set to EPERM. - **/ -extern __aosl_api__ int aosl_perf_set_callback (aosl_perf_f_t perf_f); - -typedef struct _internal_mpq_od_ *aosl_mpq_t; - -#define AOSL_MPQ_INVALID ((aosl_mpq_t)(intptr_t)NULL) - -#define aosl_mpq_invalid(mpq) ((int)(intptr_t)(mpq) <= 0) - -/** - * The initialize callback function of the mp queue create function. - * Parameters: - * arg: the input parameter - * Return Value: - * <0: error occurs - * 0: ok, no error - **/ -typedef int (*aosl_mpq_init_t) (void *arg); - -/** - * The finalize callback function of the mp queue destroy function. - * Parameters: - * arg: the input parameter - **/ -typedef void (*aosl_mpq_fini_t) (void *arg); - - -/* I think this is big enough */ -#define MPQ_MAX_SIZE 1000000 - -/** - * Create an multiplex queue. - * Parameter: - * pri: the priority of the mpq, 0 for system default - * #define AOSL_THRD_PRI_DEFAULT 0 - * #define AOSL_THRD_PRI_LOW 1 - * #define AOSL_THRD_PRI_NORMAL 2 - * #define AOSL_THRD_PRI_HIGH 3 - * #define AOSL_THRD_PRI_HIGHEST 4 - * #define AOSL_THRD_PRI_RT 5 - * max: specify the max queue size, must > 0 and <= MPQ_MAX_SIZE - * name: the queue name - * init: the initialize callback function - * fini: the finalize callback function - * arg: the parameter passed to init callback - * Return value: - * the queue object just created, <0 when failed. - **/ -extern __aosl_api__ aosl_mpq_t aosl_mpq_create (int pri, int max, const char *name, aosl_mpq_init_t init, aosl_mpq_fini_t fini, void *arg); - -#define AOSL_MPQ_NONBLOCK 1 -#define AOSL_MPQ_MAYSTALL 2 -#define AOSL_MPQ_IOMP 4 -#define AOSL_MPQ_USER 8 - -/** - * Create an multiplex queue with specified flags. - * Parameter: - * flags: specify the queue flags - * pri: the priority of the mpq, 0 for system default - * #define AOSL_THRD_PRI_DEFAULT 0 - * #define AOSL_THRD_PRI_LOW 1 - * #define AOSL_THRD_PRI_NORMAL 2 - * #define AOSL_THRD_PRI_HIGH 3 - * #define AOSL_THRD_PRI_HIGHEST 4 - * #define AOSL_THRD_PRI_RT 5 - * max: specify the max queue size, must > 0 and <= MPQ_MAX_SIZE - * name: the queue name - * init: the initialize callback function - * fini: the finalize callback function - * arg: the parameter passed to init callback - * Return value: - * the queue object just created, <0 when failed. - **/ -extern __aosl_api__ aosl_mpq_t aosl_mpq_create_flags (int flags, int pri, int max, const char *name, aosl_mpq_init_t init, aosl_mpq_fini_t fini, void *arg); - -#define BITOP_OR 0 -#define BITOP_AND 1 -#define BITOP_XOR 2 - -extern __aosl_api__ int aosl_mpq_change_flags (aosl_mpq_t qid, int bit_op, int bits); - -extern __aosl_api__ int aosl_mpq_get_flags (aosl_mpq_t qid); - -/* Get this multiplex queue id, if not exists, then just return -1 */ -extern __aosl_api__ aosl_mpq_t aosl_mpq_this (void); - -/** - * Create an mpq with default queue size on the current calling thread if not exists yet. - * Generally, this function is only used in the non-mpq thread, such as the main - * thread. - **/ -extern __aosl_api__ aosl_mpq_t aosl_mpq_create_current (void); - -/** - * Get the N-th argument of the current running queued function (argv version). - * Parameters: - * n: which argument you want to get, the first arg is 0; - * arg: the argument variable address to save the argument value; - * Return value: - * <0: error occured, and aosl_errno indicates which error; - * 0: call successful, and '*arg' is value of the N-th argument; - **/ -extern __aosl_api__ int aosl_mpq_run_func_arg (uintptr_t n, uintptr_t *arg); - -/** - * Get the data and length of the current running queued function (data version). - * Parameters: - * len_p: return the queued *_data function data length if not NULL; - * data_p: return the queued *_data function data pointer if not NULL; - * Return value: - * <0: error occured, and aosl_errno indicates which error; - * 0: call successful; - **/ -extern __aosl_api__ int aosl_mpq_run_func_data (size_t *len_p, void **data_p); - -/** - * Get the done mpq id of the current running queued function. - * Parameters: - * None. - * Return value: - * <0: error occured or the current running function has no done mpq id; - * >=0: running function's done mpq id; - **/ -extern __aosl_api__ aosl_mpq_t aosl_mpq_run_func_done_qid (void); - -/** - * Checking whether the refobj specified by robj is just running on the - * running mpq. - * Parameters: - * robj: the ref object - * Return value: - * 0: Not running on this mpq now - * None-0: Just running on this mpq now - **/ -extern __aosl_api__ int aosl_mpq_running_refobj (aosl_refobj_t robj); - -/** - * Get the arg of the running mpq object which was specified when creating. - * Parameters: - * None. - * Return value: - * The arg. - **/ -extern __aosl_api__ void *aosl_mpq_get_q_arg (void); - -/** - * Set the arg of the running mpq object. - * Parameters: - * arg: the arg - * Return value: - * <0: error occured, and aosl_errno indicates which error; - * 0: call successful; - **/ -extern __aosl_api__ int aosl_mpq_set_q_arg (void *arg); - - -/** - * The queue function prototype, something like the standard 'main' function. - * Parameter: - * queued_ts_p: pointer of milliseconds timestamp of the func being queued - * We employ a 'pointer' instead of the timestamp value here - * just for only passing one value on the 32bit system - * robj: when this parameter is AOSL_FREE_ONLY_OBJ, you can only - * free the relative resources, MUST NOT DO ANYTHING ELSE; - * argc: specify the argv array elements count - * argv: array for passing variable args - * Return value: - * none. - **/ -typedef void (*aosl_mpq_func_argv_t) (const aosl_ts_t *queued_ts_p, aosl_refobj_t robj, uintptr_t argc, uintptr_t argv []); - -/** - * Another queue function prototype for passing a chunk of data. - * Parameter: - * queued_ts_p: pointer of milliseconds timestamp of the func being queued - * We employ a 'pointer' instead of the timestamp value here - * just for only passing one value on the 32bit system. - * robj: when this parameter is AOSL_FREE_ONLY_OBJ, you can only - * free the relative resources, MUST NOT DO ANYTHING ELSE; - * len: the passed data length - * data: the data itself - * Return value: - * none. - **/ -typedef void (*aosl_mpq_func_data_t) (const aosl_ts_t *queued_ts_p, aosl_refobj_t robj, size_t len, void *data); - -/** - * Queue a function with args for invoking by the target thread which monitoring - * the queue. - * Parameter: - * tq: the target queue id - * dq: the done queue id, -1 for no done notification - * If dq is a valid mpq id, then the queued function f will be - * queued to the mpq specified by dq, and then got executed again. - * It is the responsibility of the function itself to differentiate the - * reentrance, such as, identify the reentrance according to one of arg. - * ref: the mpq object id for indicating whether the relative operation - * should be aborted and only free the relative resources, if the - * mpq object specified by ref has been destroyed, then target - * function specified by 'f' MUST NOT DO ANYTING ELSE except free - * the relative resources. - * f: the function - * argc: the args count - * ...: variable args - * Return value: - * <0: indicates error, check aosl_errno for detail - * 0: successful. - **/ -extern __aosl_api__ int aosl_mpq_queue (aosl_mpq_t tq, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...); - -/* The synchronous version, the target f must have been invoked when this function returns */ -extern __aosl_api__ int aosl_mpq_call (aosl_mpq_t q, aosl_ref_t ref, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...); - -/** - * Run the specified function on the specified mpq in async or sync mode: - * 1. identical to aosl_mpq_queue if the target q is not the same as the running q; - * 2. identical to aosl_mpq_call if the target q is just the running q; - **/ -extern __aosl_api__ int aosl_mpq_run (aosl_mpq_t tq, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...); - - -/** - * The same as 'aosl_mpq_queue' except this function takes a 'va_list' arg for the - * variable args rather than '...'. - **/ -extern __aosl_api__ int aosl_mpq_queue_args (aosl_mpq_t tq, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args); - -/* The synchronous version, the target f must have been invoked when this function returns */ -extern __aosl_api__ int aosl_mpq_call_args (aosl_mpq_t q, aosl_ref_t ref, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args); - -/** - * Run the specified function on the specified mpq in async or sync mode: - * 1. identical to aosl_mpq_queue_args if the target q is not the same as the running q; - * 2. identical to aosl_mpq_call_args if the target q is just the running q; - **/ -extern __aosl_api__ int aosl_mpq_run_args (aosl_mpq_t tq, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args); - -/** - * The same as 'aosl_mpq_queue_args' except this function takes a 'uintptr_t *' arg for the argv - * rather than 'va_list args'. - **/ -extern __aosl_api__ int aosl_mpq_queue_argv (aosl_mpq_t tq, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv); - -/* The synchronous version, the target f must have been invoked when this function returns */ -extern __aosl_api__ int aosl_mpq_call_argv (aosl_mpq_t q, aosl_ref_t ref, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv); - -/** - * Run the specified function on the specified mpq in async or sync mode: - * 1. identical to aosl_mpq_queue_argv if the target q is not the same as the running q; - * 2. identical to aosl_mpq_call_argv if the target q is just the running q; - **/ -extern __aosl_api__ int aosl_mpq_run_argv (aosl_mpq_t tq, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv); - - -/** - * Queue a function with a chunk of data for invoking by the target thread which monitoring - * the queue. - * Parameter: - * tq: the target queue id - * dq: the done queue id, -1 for no done notification - * If dq is a valid mpq id, then the queued function f will be - * queued to the mpq specified by dq, and then got executed again. - * It is the responsibility of the function itself to differentiate the - * reentrance, such as, identify the reentrance according to one of arg. - * ref: the mpq object id for indicating whether the relative operation - * should be aborted and only free the relative resources, if the - * mpq object specified by ref has been destroyed, then target - * function specified by 'f' MUST NOT DO ANYTING ELSE except free - * the relative resources. - * f: the function - * len: the data length in bytes - * data: the data pointer which contains the data(would be copied in) - * Return value: - * <0: indicates error, check aosl_errno for detail - * 0: successful. - **/ -extern __aosl_api__ int aosl_mpq_queue_data (aosl_mpq_t tq, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_mpq_func_data_t f, size_t len, void *data); - -/* The synchronous version, the target f must have been invoked when this function returns */ -extern __aosl_api__ int aosl_mpq_call_data (aosl_mpq_t q, aosl_ref_t ref, const char *f_name, aosl_mpq_func_data_t f, size_t len, void *data); - -/** - * Run the specified function on the specified mpq in async or sync mode: - * 1. identical to aosl_mpq_queue_data if the target q is not the same as the running q; - * 2. identical to aosl_mpq_call_data if the target q is just the running q; - **/ -extern __aosl_api__ int aosl_mpq_run_data (aosl_mpq_t tq, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_mpq_func_data_t f, size_t len, void *data); - -/** - * Start aosl main mpq, only a single main mpq allowed. - **/ -extern __aosl_api__ int aosl_main_start (int pri, aosl_mpq_init_t init, aosl_mpq_fini_t fini, void *arg); - -/** - * Increase and return the main mpq usage count, start the main mpq if not start yet. - * Parameter: - * None. - * Return value: - * <0: indicates error, check aosl_errno for detail; - * >0: the main mpq current usage count after get; - **/ -extern __aosl_api__ int aosl_main_get (void); - -/** - * Decrease and return the main mpq usage count, destroy the main mpq if the usage is 0. - * Parameter: - * None. - * Return value: - * <0: indicates error, check aosl_errno for detail; - * >=0: the main mpq current usage count after put; - **/ -extern __aosl_api__ int aosl_main_put (void); - - -/** - * Get the aosl main mpq id, and return -1 for not exist. - **/ -extern __aosl_api__ aosl_mpq_t aosl_mpq_main (void); - -/** - * Check whether the aosl main mpq started. - **/ -#define aosl_main_started() (!aosl_mpq_invalid (aosl_mpq_main ())) - - -/** - * Get the queued function invocations count. - * Parameters: - * q: the queue object id - * Return value: - * <0: indicates error, check aosl_errno for detail - * >=0: the queued function invocations count - */ -extern __aosl_api__ int aosl_mpq_queued_count (aosl_mpq_t q); - -/** - * Get the last load/idle costs in micro seconds of this mpq - * Parameters: - * load_p: the variable for saving the last load costs(us), NULL for not care - * idle_p: the variable for saving the last idle costs(us), NULL for not care - * Return value: - * <0: indicates error, check aosl_errno for detail - * 0: the last load/idle costs was/were saved to *load_p, *idle_p - */ -extern __aosl_api__ int aosl_mpq_last_costs (aosl_ts_t *load_p, aosl_ts_t *idle_p); - -/** - * Get the current running counters of this mpq - * Parameters: - * funcs_count_p: the variable for saving the current running funcs count, NULL for not care - * timers_count_p: the variable for saving the current running timers count, NULL for not care - * fds_count_p: the variable for saving the current running fds count, NULL for not care - * Return value: - * <0: indicates error, check aosl_errno for detail - * 0: the running counters was/were saved to *funcs_count_p, *timers_count_p, *fds_count_p - */ -extern __aosl_api__ int aosl_mpq_exec_counters (uint64_t *funcs_count_p, uint64_t *timers_count_p, uint64_t *fds_count_p); - - -typedef struct { - uint32_t fw_avg; /* function average wait time */ - uint32_t fw_worst; /* function worst wait time */ - uint32_t fe_avg; /* function average exec time */ - uint32_t fe_worst; /* function worst exec time */ - uint32_t f_count; /* executed functions count */ -} aosl_ftimes_t; - -/** - * Get the average & worst function wait & execution times of this mpq - * Parameters: - * qid: the mpq id - * ftimes: the variable address for saving the function times - * reset: whether reset the counters, 0 for not clear, other values clear - * Return value: - * <0: indicates error, check aosl_errno for detail - * 0: the average function execution time was saved to *fe_*_p - */ -extern __aosl_api__ int aosl_mpq_ftimes (aosl_mpq_t qid, aosl_ftimes_t *ftimes, int reset); - -/** - * Get the average & worst function wait time of this mpq - * Parameters: - * qid: the mpq id - * fw_avg_p: the variable address for saving the average function wait time - * fw_worst_p: the variable address for saving the worst function wait time - * reset: whether reset the counters, 0 for not clear, other values clear - * Return value: - * <0: indicates error, check aosl_errno for detail - * 0: the average function wait time was saved to *fw_*_p - */ -extern __aosl_api__ int aosl_mpq_fwtime (aosl_mpq_t qid, uint32_t *fw_avg_p, uint32_t *fw_worst_p, int reset); - -/** - * Get the name of the current running mpq - * Parameters: - * None. - * Return value: - * non-NULL: the running mpq name; - * NULL: the running thread is not an mpq thread; - */ -extern __aosl_api__ const char *aosl_mpq_this_name (void); - -/** - * Invoking this function will enter the infinite run loop of current thread's multiplex queue. - * Generally, this function is only used in the non-mpq thread, such as the main thread. - **/ -extern __aosl_api__ void aosl_mpq_loop (void); - -/** - * Invoking this function when you need to ack the aosl ITC logic. - * There's no need to use this function for most cases due to the default aosl mpq behaviors, - * and only need to invoke this function explicitly when the aosl mpq thread does not run the - * default mpq loop. - * Return value: - * <0: indicates error, check aosl_errno for detail: - * ESRCH: this mpq has been destroyed; - * EPERM: the running thread is not an aosl mpq thread; - * other values: processed ITC calls count - **/ -extern __aosl_api__ int aosl_mpq_itc_ack (void); - -/** - * Check whether the running mpq is the aosl main mpq. - * Return value: - * non-zero: the running mpq is the main mpq; - * 0: the running mpq is not the main mpq; - **/ -extern __aosl_api__ int aosl_mpq_is_main (void); - -/** - * Destroy an multiplex queue object. - * Parameter: - * mpq_id: the queue id to be destroyed - **/ -extern __aosl_api__ int aosl_mpq_destroy (aosl_mpq_t q); - - -/** - * Destroy an multiplex queue object and wait until done. - * Parameter: - * mpq_id: the queue id to be destroyed - **/ -extern __aosl_api__ int aosl_mpq_destroy_wait (aosl_mpq_t mpq_id); - -/** - * Wait an multiplex queue object to be destroyed. Note - * that this function will not do the destroy action, and - * just wait for the queue to be destroyed. - * Parameter: - * mpq_id: the queue id to wait - **/ -extern __aosl_api__ int aosl_mpq_wait (aosl_mpq_t mpq_id); - -/** - * Check whether the thread of specified mpq still exists. - * Parameter: - * qid: the mpq id - * Return value: - * none zero: the thread still exists - * 0: the thread exited - **/ -extern __aosl_api__ int aosl_mpq_thrd_exist (aosl_mpq_t qid); - -/** - * Let the aosl main multiplex queue thread exit, but not wait. - **/ -extern __aosl_api__ int aosl_main_exit (void); - -/** - * Let the aosl main multiplex queue thread exit, and wait done. - **/ -extern __aosl_api__ int aosl_main_exit_wait (void); - -/** - * Wait the aosl main multiplex queue thread to exit. - * Note that this function will not let the aosl main thread exit, - * just wait for the queue thread to exit. - * Parameter: - * mpq_id: the queue id to wait - **/ -extern __aosl_api__ int aosl_main_wait (void); - - -/** - * Shrink the resources allocated dynamically by AOSL. - * Only need to do this when you do not use AOSL again but - * the program does not exit now. - **/ -extern __aosl_api__ void aosl_shrink_resources (); - - -#ifdef __cplusplus -} -#endif - -#endif /* __AOSL_MPQ_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_fd.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_fd.h deleted file mode 100644 index 2ac67539d..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_fd.h +++ /dev/null @@ -1,220 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jul 17th, 2018 - * Module: Multiplex queue iofd header file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_MPQ_FD_H__ -#define __AOSL_MPQ_FD_H__ - - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -/** - * The user provided read/write callback function, just use - * AOSL_DEFAULT_READ_FN/AOSL_DEFAULT_WRITE_FN respectively - * for read/write for most cases, except the read/write ops - * are special, such as an 'ioctl' supplied read/write. - * Please make sure that you can only do the actual I/O ops - * in these callback functions, and return '-error' when - * encounter errors, MUST NOT close the io fd in these - * callback functions. - * -- Lionfore Hao Nov 9th, 2018 - **/ -#ifndef _WIN32 -typedef ssize_t (*aosl_fd_read_t) (aosl_fd_t fd, void *buf, size_t len, size_t extra_size, uintptr_t argc, uintptr_t argv []); -typedef ssize_t (*aosl_fd_write_t) (aosl_fd_t fd, const void *buf, size_t len, size_t extra_size, uintptr_t argc, uintptr_t argv []); -#else -typedef ssize_t (*aosl_fd_read_t) (aosl_fd_t fd, void *buf, size_t len, size_t extra_size, OVERLAPPED *ovlp, uintptr_t argc, uintptr_t argv []); -typedef ssize_t (*aosl_fd_write_t) (aosl_fd_t fd, const void *buf, size_t len, size_t extra_size, OVERLAPPED *ovlp, uintptr_t argc, uintptr_t argv []); -#endif - -#define AOSL_DEFAULT_READ_FN ((aosl_fd_read_t)1) -#define AOSL_DEFAULT_WRITE_FN ((aosl_fd_write_t)1) - -/** - * The data packet check callback function is provided by the user for determining - * whether the data has contained a complet user level packet, as following: - * Parameters: - * data: the data buffer holding the packet - * len: the data length in bytes in the buffer - * argc: the args count when adding the fd - * argv: the args vector when adding the fd - * Return value: - * <0: indicate some error occurs; - * 0: no error, but the whole packet is not ready so far; - * >0: the whole packet length - **/ -typedef ssize_t (*aosl_check_packet_t) (const void *data, size_t len, uintptr_t argc, uintptr_t argv []); - -/** - * The iofd received data callback function type - * Parameters: - * data: the data buffer holding the packet - * len: the data length in bytes in the buffer - * argc: the args count when adding the fd - * argv: the args vector when adding the fd - * Return value: - * None. - **/ -typedef void (*aosl_fd_data_t) (void *data, size_t len, uintptr_t argc, uintptr_t argv []); - -/** - * The iofd event callback function type - * Parameters: - * fd: the fd - * event: if <0, then indicates an error occurs, and the error number is '-event'; - * if >=0, then indicates an event needs to be reported to application; - * argc: the args count when adding the fd - * argv: the args vector when adding the fd - * Return value: - * None. - **/ -/* event values when no error */ -#define AOSL_IOFD_READY_FOR_WRITING 1 -#define AOSL_IOFD_HUP -19999 -#define AOSL_IOFD_ERR -20000 - -/** - * The fd event callback function. - * Parameters: - * fd: the fd itself - * event: the reporting event, values are as following: - * <0: an error occurs: - * [-19999 ~ -1]: OS error and '-event' indicates the OS error number; - * <= -20000: SDK defined errors such as HUP etc; - * argc: the args count passed in when adding the fd - * argv: the args vector passed in when adding the fd - * Return value: - * None. - **/ -typedef void (*aosl_fd_event_t) (aosl_fd_t fd, int event, uintptr_t argc, uintptr_t argv []); - -extern __aosl_api__ int aosl_mpq_add_fd (aosl_mpq_t qid, aosl_fd_t fd, int enable, size_t max_pkt_size, - aosl_fd_read_t read_f, aosl_fd_write_t write_f, aosl_check_packet_t chk_pkt_f, - aosl_fd_data_t data_f, aosl_fd_event_t event_f, uintptr_t argc, ...); - -extern __aosl_api__ int aosl_mpq_enable_fd (aosl_fd_t fd); - -extern __aosl_api__ ssize_t aosl_write (aosl_fd_t fd, const void *buf, size_t len); - -#define AOSL_FD_EVM_SET 0 /* fd event mask set */ -#define AOSL_FD_EVM_ADD 1 /* fd event mask add */ -#define AOSL_FD_EVM_DEL 2 /* fd event mask del */ - -#define AOSL_FD_EV_I 0x1 /* fd event input */ -#define AOSL_FD_EV_O 0x2 /* fd event output */ - -/** - * Modify the fd listening event mask. - * Parameters: - * fd: the fd you want to modify event mask - * ctrl: one of AOSL_FD_EVM_SET, AOSL_FD_EVM_ADD or AOSL_FD_EVM_DEL - * for setting, adding or deleting event mask respectively - * eventmask: bitmask of AOSL_FD_EV_I and AOSL_FD_EV_O - * Return value: - * <0: error occured, and aosl_errno indicates which error; - * 0: call successful, and '*arg' is value of the N-th argument; - * Remarks: - * This function is used for flow control normally, if we do not - * want to receive data from fd now, then we can remove the bit - * AOSL_FD_EV_I from the event mask, and add it again later - * when needed. - **/ -extern __aosl_api__ int aosl_fd_evm_ctrl (aosl_fd_t fd, int ctrl, int eventmask); - -/** - * Clear the fd error. - * Parameters: - * fd: the fd you want to clear error - * Return value: - * <0: error occured, and aosl_errno indicates which error; - * 0: call successful, and '*arg' is value of the N-th argument; - * Remarks: - * The fd errors are also edge triggered, so if some error is not real - * error in fact, you must clear the error manually, otherwise the fd - * would be in an incorrect state and could not work normally. - **/ -extern __aosl_api__ int aosl_fd_clear_err (aosl_fd_t fd); - -/** - * Get the N-th argument of the mpq attached fd. - * Parameters: - * fd: the fd you want to retrieve the arg - * n: which argument you want to get, the first arg is 0; - * arg: the argument variable address to save the argument value; - * Return value: - * <0: error occured, and aosl_errno indicates which error; - * 0: call successful, and '*arg' is value of the N-th argument; - **/ -extern __aosl_api__ int aosl_mpq_fd_arg (aosl_fd_t fd, uintptr_t n, uintptr_t *arg); - -extern __aosl_api__ int aosl_mpq_disable_fd (aosl_fd_t fd); -extern __aosl_api__ int aosl_mpq_del_fd (aosl_fd_t fd); -extern __aosl_api__ int aosl_close (aosl_fd_t fd); - - -/** - * The I/O device read function which supports coroutine. - * Parameters: - * fd: the opened device fd; - * d_ret: the data object for holding return value, the - * length must >= sizeof (ssize_t); - * d_buf: the buffer for holding the read data; - * buf_off: the buffer offset for holding the read data; - * Return value: - * <0: failed with aosl_errno set; - * 0: async read issued successfully; - **/ -extern __aosl_api__ int aosl_co_read (aosl_fd_t fd, aosl_data_t d_ret, aosl_data_t d_buf, uintptr_t buf_off); - -/** - * The I/O device write function which supports coroutine. - * Parameters: - * fd: the opened device fd; - * d_ret: the data object for holding the async write - * done return value, it can be NULL, but if - * set the length must >= sizeof (ssize_t); - * d_buf: the buffer for holding the data for writing; - * Return value: - * <0: failed with aosl_errno set; - * >=0: successfully; - **/ -extern __aosl_api__ ssize_t aosl_co_write (aosl_fd_t fd, aosl_data_t d_ret, aosl_data_t d_buf); - -/** - * The I/O device write function which supports coroutine. - * Parameters: - * fd: the opened device fd; - * d_ret: the data object for holding the async write - * done return value, it can be NULL, but if - * set the length must >= sizeof (ssize_t); - * buf: the buffer for holding the data for writing; - * count: the writing data bytes; - * Return value: - * <0: failed with aosl_errno set; - * >=0: successfully; - **/ -extern __aosl_api__ ssize_t aosl_co_buf_write (aosl_fd_t fd, aosl_data_t d_ret, const void *buf, size_t count); - - -#ifdef __cplusplus -} -#endif - - -#endif /* __AOSL_MPQ_FD_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_net.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_net.h deleted file mode 100644 index 82763e049..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_net.h +++ /dev/null @@ -1,408 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jul 22nd, 2018 - * Module: Socket helper utils header file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_MPQ_NET_H__ -#define __AOSL_MPQ_NET_H__ - -#include -#include -#include -#include -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * The fucking Windows has different definitions for a - * 'fd' and a 'sk', so we define a aosl_sk_t type to - * handle this issue uniformly. - * Fucking Windows, Fucking Microsoft! - **/ -#ifndef _WIN32 -typedef aosl_fd_t aosl_sk_t; -#define AOSL_INVALID_SK AOSL_INVALID_FD -#else -typedef SOCKET aosl_sk_t; -#define AOSL_INVALID_SK ((aosl_sk_t)AOSL_INVALID_FD) -#endif - -#if !defined (__linux__) && !defined (__MACH__) && !defined (__kliteos__) -typedef uint16_t sa_family_t; -#endif - -#define AOSL_IPHDR_LEN 20 - -#define AOSL_UDPHDR_LEN 8 -#define AOSL_TCPHDR_LEN 20 - -#define AOSL_IP_UDP_HDR_LEN (AOSL_IPHDR_LEN + AOSL_UDPHDR_LEN) -#define AOSL_IP_TCP_HDR_LEN (AOSL_IPHDR_LEN + AOSL_TCPHDR_LEN) - - -typedef union { - struct sockaddr sa; - struct sockaddr_in in; - aosl_sockaddr_in6_t in6; -#if defined (__linux__) || defined (__MACH__) || defined (__kliteos2__) - struct sockaddr_un un; -#endif - aosl_sockaddr_storage_t __storage; -} aosl_sk_addr_t; - -typedef struct { - aosl_fd_t newsk; - aosl_sk_addr_t addr; - socklen_t addrlen; -} aosl_accept_data_t; - -typedef struct { - aosl_sk_addr_t addr; - socklen_t addrlen; -} aosl_sk_addr_and_len_t; - -/** - * The listen state socket readable callback function type - * Parameters: - * data: the data buffer holding the packet - * len: the data length in bytes in the buffer - * argc: the args count when adding the fd - * argv: the args vector when adding the fd - * addr: the socket address data received from - * Return value: - * None. - **/ -typedef void (*aosl_sk_accepted_t) (aosl_accept_data_t *accept_data, size_t len, uintptr_t argc, uintptr_t argv []); - -/** - * The dgram socket received data callback function type - * Parameters: - * data: the data buffer holding the packet - * len: the data length in bytes in the buffer - * argc: the args count when adding the fd - * argv: the args vector when adding the fd - * addr: the socket address data received from - * Return value: - * None. - **/ -typedef void (*aosl_dgram_sk_data_t) (void *data, size_t len, uintptr_t argc, uintptr_t argv [], const aosl_sk_addr_t *addr); - -extern __aosl_api__ aosl_fd_t aosl_socket (int domain, int type, int protocol); -extern __aosl_api__ int aosl_bind (aosl_fd_t sockfd, const struct sockaddr *addr, socklen_t addrlen); -extern __aosl_api__ int aosl_getsockname (aosl_fd_t sockfd, struct sockaddr *addr, socklen_t *addrlen); -extern __aosl_api__ int aosl_getpeername (aosl_fd_t sockfd, struct sockaddr *addr, socklen_t *addrlen); -extern __aosl_api__ int aosl_getsockopt (aosl_fd_t sockfd, int level, int optname, void *optval, socklen_t *optlen); -extern __aosl_api__ int aosl_setsockopt (aosl_fd_t sockfd, int level, int optname, const void *optval, socklen_t optlen); - - -extern __aosl_api__ int aosl_mpq_add_dgram_socket (aosl_mpq_t qid, aosl_fd_t fd, size_t max_pkt_size, - aosl_dgram_sk_data_t data_f, aosl_fd_event_t event_f, uintptr_t argc, ...); - -extern __aosl_api__ int aosl_mpq_add_stream_socket (aosl_mpq_t qid, aosl_fd_t fd, int enable, size_t max_pkt_size, - aosl_check_packet_t chk_pkt_f, aosl_fd_data_t data_f, aosl_fd_event_t event_f, uintptr_t argc, ...); - -extern __aosl_api__ int aosl_mpq_add_listen_socket (aosl_mpq_t qid, aosl_fd_t fd, int backlog, - aosl_sk_accepted_t accepted_f, aosl_fd_event_t event_f, uintptr_t argc, ...); - -extern __aosl_api__ int aosl_mpq_connect (aosl_fd_t fd, const struct sockaddr *dest_addr, socklen_t addrlen, int timeo); -extern __aosl_api__ int aosl_mpq_listen (aosl_fd_t fd, int backlog); - -extern __aosl_api__ ssize_t aosl_send (aosl_fd_t sockfd, const void *buf, size_t len, int flags); -extern __aosl_api__ ssize_t aosl_sendto (aosl_fd_t sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen); - -extern __aosl_api__ int aosl_ip_sk_bind_port_only (aosl_fd_t sk, sa_family_t af, unsigned short port); - - -typedef struct { - aosl_fd_t v4; - aosl_fd_t v6; -} aosl_ip_sk_t; - -static __inline__ void aosl_ip_sk_init (aosl_ip_sk_t *sk) -{ - sk->v4 = AOSL_INVALID_FD; - sk->v6 = AOSL_INVALID_FD; -} - -extern __aosl_api__ int aosl_ip_sk_create (aosl_ip_sk_t *sk, int type, int protocol); - -typedef struct { - struct sockaddr_in v4; - aosl_sockaddr_in6_t v6; -} aosl_ip_addr_t; - -extern __aosl_api__ void aosl_ip_addr_init (aosl_ip_addr_t *addr); -extern __aosl_api__ int aosl_ip_sk_bind (const aosl_ip_sk_t *sk, const aosl_ip_addr_t *addr); - -extern __aosl_api__ int aosl_mpq_ip_sk_connect (const aosl_ip_sk_t *sk, const struct sockaddr *dest_addr, int timeo); - -extern __aosl_api__ ssize_t aosl_ip_sk_sendto (const aosl_ip_sk_t *sk, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr); -extern __aosl_api__ void aosl_ip_sk_close (aosl_ip_sk_t *sk); - -extern __aosl_api__ int aosl_ipv6_addr_v4_mapped (const aosl_in6_addr_t *a6); -extern __aosl_api__ int aosl_ipv6_addr_nat64 (const aosl_in6_addr_t *a6); -extern __aosl_api__ int aosl_ipv6_addr_v4_compatible (const aosl_in6_addr_t *a6); - -extern __aosl_api__ int aosl_ipv6_sk_addr_from_ipv4 (struct sockaddr *sk_addr_v6, const struct sockaddr *sk_addr_v4); -extern __aosl_api__ int aosl_ipv6_sk_addr_to_ipv4 (struct sockaddr *sk_addr_v6, const struct sockaddr *sk_addr_v4); - - -extern __aosl_api__ int aosl_ip_sk_addr_init_with_port (aosl_sk_addr_t *sk_addr, sa_family_t af, unsigned short port); - -/* Structure for describing a resolved sock address information */ -typedef struct { - sa_family_t sk_af; - int sk_type; - int sk_prot; - aosl_sk_addr_t sk_addr; - socklen_t sk_addr_len; -} aosl_sk_addrinfo_t; - - -extern __aosl_api__ int aosl_sk_addr_ip_equal (const struct sockaddr *addr1, const struct sockaddr *addr2); -extern __aosl_api__ socklen_t aosl_sk_addr_len (const struct sockaddr *addr); - -extern __aosl_api__ const char *aosl_inet_addr_str (int af, const void *addr, char *addr_buf, size_t buf_len); -extern __aosl_api__ const char *aosl_ip_sk_addr_str (const aosl_sk_addr_t *addr, char *addr_buf, size_t buf_len); -extern __aosl_api__ unsigned short aosl_ip_sk_addr_port (const aosl_sk_addr_t *addr); - -extern __aosl_api__ socklen_t aosl_inet_addr_from_string (void *addr, const char *str_addr); -extern __aosl_api__ socklen_t aosl_ip_sk_addr_from_string (aosl_sk_addr_t *sk_addr, const char *str_addr, uint16_t port); - -extern __aosl_api__ int aosl_net_get_ipv6_prefix (aosl_in6_addr_t *prefix); -extern __aosl_api__ void aosl_net_set_ipv6_prefix (const aosl_in6_addr_t *a6); - - -/** - * Resolve host name asynchronously relative functions, these functions would queue back a function call - * specified by f to the mpq object specified by q with the specified args. - **/ -extern __aosl_api__ int aosl_resolve_host_async (aosl_ref_t ref, const char *hostname, unsigned short port, aosl_sk_addrinfo_t *addrs, size_t addr_count, aosl_mpq_t q, aosl_mpq_func_argv_t f, uintptr_t argc, ...); -extern __aosl_api__ int aosl_resolve_host_asyncv (aosl_ref_t ref, const char *hostname, unsigned short port, aosl_sk_addrinfo_t *addrs, size_t addr_count, aosl_mpq_t q, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args); -extern __aosl_api__ int aosl_tcp_resolve_host_async (aosl_ref_t ref, const char *hostname, unsigned short port, aosl_sk_addrinfo_t *addrs, size_t addr_count, aosl_mpq_t q, aosl_mpq_func_argv_t f, uintptr_t argc, ...); -extern __aosl_api__ int aosl_tcp_resolve_host_asyncv (aosl_ref_t ref, const char *hostname, unsigned short port, aosl_sk_addrinfo_t *addrs, size_t addr_count, aosl_mpq_t q, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args); -extern __aosl_api__ int aosl_udp_resolve_host_async (aosl_ref_t ref, const char *hostname, unsigned short port, aosl_sk_addrinfo_t *addrs, size_t addr_count, aosl_mpq_t q, aosl_mpq_func_argv_t f, uintptr_t argc, ...); -extern __aosl_api__ int aosl_udp_resolve_host_asyncv (aosl_ref_t ref, const char *hostname, unsigned short port, aosl_sk_addrinfo_t *addrs, size_t addr_count, aosl_mpq_t q, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args); - -/** - * The DNS resolving function which supports coroutine. - * Parameters: - * d_count: the data object for holding the resolved addresses - * count, the length must >= sizeof (size_t); - * d_hostname: the data object for holding the resolving hostname; - * d_addrs: the data object for holding the resolved addresses, - * this is an array of aosl_sk_addrinfo_t in fact; - * Return value: - * 0: async DNS resolve issued successfully; - * <0: failed with aosl_errno set; - **/ -extern __aosl_api__ int aosl_co_resolve_host (aosl_data_t d_count, aosl_data_t d_hostname, aosl_data_t d_addrs); -extern __aosl_api__ int aosl_co_resolve_tcp_host (aosl_data_t d_count, aosl_data_t d_hostname, aosl_data_t d_addrs); -extern __aosl_api__ int aosl_co_resolve_udp_host (aosl_data_t d_count, aosl_data_t d_hostname, aosl_data_t d_addrs); - -/** - * This is just a wrapper implementation of listen syscall for - * cross platforms supporting. - **/ -extern __aosl_api__ int aosl_listen (aosl_fd_t sk, int backlog); - -/** - * The socket accept function which supports coroutine. - * Parameters: - * fd: the socket fd; - * d_ret: the data object for holding return value, it is - * the accepted new socket fd, so the length must - * >= sizeof (aosl_fd_t); - * d_addr: the data object for holding the remote address, - * the len must >= sizeof (aosl_sk_addr_and_len_t); - * Return value: - * <0: failed with aosl_errno set; - * 0: async accept issued successfully; - **/ -extern __aosl_api__ int aosl_co_accept (aosl_fd_t fd, aosl_data_t d_ret, aosl_data_t d_addr); - -/** - * The socket recv function which supports coroutine. - * Parameters: - * fd: the socket fd; - * d_ret: the data object for holding return value, the - * length must >= sizeof (ssize_t); - * d_buf: the buffer for holding the read data; - * buf_off: the buffer offset for holding the read data; - * flags: the flags same as recv syscall; - * Return value: - * <0: failed with aosl_errno set; - * 0: async read issued successfully; - **/ -extern __aosl_api__ int aosl_co_recv (aosl_fd_t fd, aosl_data_t d_ret, aosl_data_t d_buf, uintptr_t buf_off, int flags); - -/** - * The socket recv function which supports coroutine. - * Parameters: - * fd: the socket fd; - * d_ret: the data object for holding return value, the - * length must >= sizeof (ssize_t); - * d_buf: the buffer for holding the read data; - * buf_off: the buffer offset for holding the read data; - * flags: the flags same as recvfrom syscall; - * d_addr: the data object for holding the remote address, - * the len must >= sizeof (aosl_sk_addr_and_len_t); - * Return value: - * <0: failed with aosl_errno set; - * 0: async read issued successfully; - **/ -extern __aosl_api__ int aosl_co_recvfrom (aosl_fd_t fd, aosl_data_t d_ret, aosl_data_t d_buf, uintptr_t buf_off, int flags, aosl_data_t d_addr); - -/** - * The socket connect function which supports coroutine. - * Parameters: - * fd: the socket fd; - * d_ret: the data object for holding the async connect - * done return value, it can be NULL, but if set - * the length must >= sizeof (int); - * dest_addr: the target address; - * addrlen: the target address size; - * timeo: the flags same as send syscall; - * Return value: - * <0: failed with aosl_errno set; - * 0: async connect issued successfully; - **/ -extern __aosl_api__ int aosl_co_connect (aosl_fd_t fd, aosl_data_t d_ret, const struct sockaddr *dest_addr, socklen_t addrlen, int timeo); - -/** - * The IPv4/IPv6 socket connect function which supports coroutine. - * Parameters: - * sk: the IPv4/IPv6 sockets; - * d_ret: the data object for holding the async connect - * done return value, it can be NULL, but if set - * the length must >= sizeof (int); - * dest_addr: the target address; - * timeo: the flags same as send syscall; - * Return value: - * <0: failed with aosl_errno set; - * 0: async connect issued successfully; - **/ -extern __aosl_api__ int aosl_co_ip_sk_connect (const aosl_ip_sk_t *sk, aosl_data_t d_ret, const struct sockaddr *dest_addr, int timeo); - -/** - * The socket send function which supports coroutine. - * Parameters: - * fd: the socket fd; - * d_ret: the data object for holding the async write - * done return value, it can be NULL, but if - * set the length must >= sizeof (ssize_t); - * d_buf: the buffer for holding the data for writing; - * flags: the flags same as send syscall; - * Return value: - * <0: failed with aosl_errno set; - * >=0: successfully; - **/ -extern __aosl_api__ ssize_t aosl_co_send (aosl_fd_t fd, aosl_data_t d_ret, aosl_data_t d_buf, int flags); - -/** - * The socket sendto function which supports coroutine. - * Parameters: - * fd: the socket fd; - * d_ret: the data object for holding the async write - * done return value, it can be NULL, but if - * set the length must >= sizeof (ssize_t); - * d_buf: the buffer for holding the data for writing; - * flags: the flags same as sendto syscall; - * dest_addr: the target address; - * addrlen: the target address size; - * Return value: - * <0: failed with aosl_errno set; - * >=0: successfully; - **/ -extern __aosl_api__ ssize_t aosl_co_sendto (aosl_fd_t fd, aosl_data_t d_ret, aosl_data_t d_buf, int flags, - const struct sockaddr *dest_addr, socklen_t addrlen); - -/** - * The socket send function which supports coroutine. - * Parameters: - * fd: the socket fd; - * d_ret: the data object for holding the async write - * done return value, it can be NULL, but if - * set the length must >= sizeof (ssize_t); - * buf: the buffer for holding the data for writing; - * len: the writing data bytes; - * flags: the flags same as send syscall; - * Return value: - * <0: failed with aosl_errno set; - * >=0: successfully; - **/ -extern __aosl_api__ ssize_t aosl_co_buf_send (aosl_fd_t fd, aosl_data_t d_ret, const void *buf, size_t len, int flags); - -/** - * The socket sendto function which supports coroutine. - * Parameters: - * fd: the socket fd; - * d_ret: the data object for holding the async write - * done return value, it can be NULL, but if - * set the length must >= sizeof (ssize_t); - * buf: the buffer for holding the data for writing; - * len: the writing data bytes; - * flags: the flags same as sendto syscall; - * dest_addr: the target address; - * addrlen: the target address size; - * Return value: - * <0: failed with aosl_errno set; - * >=0: successfully; - **/ -extern __aosl_api__ ssize_t aosl_co_buf_sendto (aosl_fd_t fd, aosl_data_t d_ret, const void *buf, size_t len, - int flags, const struct sockaddr *dest_addr, socklen_t addrlen); - -/** - * The IPv4/IPv6 socket sendto function which supports coroutine. - * Parameters: - * sk: the IPv4/IPv6 sockets; - * d_ret: the data object for holding the async write - * done return value, it can be NULL, but if - * set the length must >= sizeof (ssize_t); - * d_buf: the buffer for holding the data for writing; - * flags: the flags same as sendto syscall; - * dest_addr: the target address; - * Return value: - * <0: failed with aosl_errno set; - * >=0: successfully; - **/ -__export_in_so__ ssize_t aosl_co_ip_sk_sendto (const aosl_ip_sk_t *sk, aosl_data_t d_ret, aosl_data_t d_buf, - int flags, const struct sockaddr *dest_addr); - -/** - * The IPv4/IPv6 socket sendto function which supports coroutine. - * Parameters: - * sk: the IPv4/IPv6 sockets; - * d_ret: the data object for holding the async write - * done return value, it can be NULL, but if - * set the length must >= sizeof (ssize_t); - * buf: the buffer for holding the data for writing; - * len: the writing data bytes; - * flags: the flags same as sendto syscall; - * dest_addr: the target address; - * Return value: - * <0: failed with aosl_errno set; - * >=0: successfully; - **/ -extern __aosl_api__ ssize_t aosl_co_ip_sk_buf_sendto (const aosl_ip_sk_t *sk, aosl_data_t d_ret, const void *buf, - size_t len, int flags, const struct sockaddr *dest_addr); - - -#ifdef __cplusplus -} -#endif - - -#endif /* __AOSL_MPQ_NET_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_timer.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_timer.h deleted file mode 100644 index df00a3467..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpq_timer.h +++ /dev/null @@ -1,230 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jul 19th, 2018 - * Module: Multiplex queue timer header file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_MPQ_TIMER_H__ -#define __AOSL_MPQ_TIMER_H__ - -#include -#include -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - -/* The timer object type */ -typedef struct _internal_timer_od_ *aosl_timer_t; - -#define AOSL_MPQ_TIMER_INVALID ((aosl_timer_t)(intptr_t)NULL) - -#define aosl_mpq_timer_invalid(timer_id) ((int)(intptr_t)(timer_id) <= 0) - -/** - * The timer callback function prototype. - * Parameters: - * timer_id: the timer id; - * now_p: *now_p is the triggering time tick in ms; - * argc: arguments count would be passed to async callback function; - * argv: the various arguments would be passed to async callback function; - * Return Value: - * None. - **/ -typedef void (*aosl_timer_func_t) (aosl_timer_t timer_id, const aosl_ts_t *now_p, uintptr_t argc, uintptr_t argv []); - - -#define AOSL_INVALID_TIMER_INTERVAL ((uintptr_t)(-1)) - -/** - * Create but not start a periodic timer. - * Parameters: - * qid: the mpq id in which the created timer will run; - * interval: the timer interval in ms; - * func: the timer callback function; - * dtor: the timer destructor function; - * argc: arguments count would be passed to async callback function; - * ...: the various arguments would be passed to async callback function; - * Return Value: - * aosl_mpq_timer_invalid($ret): failed with aosl_errno set; - * other value: the created timer id; - **/ -extern __aosl_api__ aosl_timer_t aosl_mpq_create_timer (aosl_mpq_t qid, uintptr_t interval, aosl_timer_func_t func, aosl_obj_dtor_t dtor, uintptr_t argc, ...); - -/** - * Create but not start a oneshot timer. - * Parameters: - * qid: the mpq id in which the created timer will run; - * func: the timer callback function; - * dtor: the timer destructor function; - * argc: arguments count would be passed to async callback function; - * ...: the various arguments would be passed to async callback function; - * Return Value: - * aosl_mpq_timer_invalid($ret): failed with aosl_errno set; - * other value: the created timer id; - **/ -extern __aosl_api__ aosl_timer_t aosl_mpq_create_oneshot_timer (aosl_mpq_t qid, aosl_timer_func_t func, aosl_obj_dtor_t dtor, uintptr_t argc, ...); - -/** - * Create and start a periodic timer. - * Parameters: - * qid: the mpq id in which the created timer will run; - * interval: the timer interval in ms; - * func: the timer callback function; - * dtor: the timer destructor function; - * argc: arguments count would be passed to async callback function; - * ...: the various arguments would be passed to async callback function; - * Return Value: - * aosl_mpq_timer_invalid($ret): failed with aosl_errno set; - * other value: the created timer id; - **/ -extern __aosl_api__ aosl_timer_t aosl_mpq_set_timer (aosl_mpq_t qid, uintptr_t interval, aosl_timer_func_t func, aosl_obj_dtor_t dtor, uintptr_t argc, ...); - -/** - * Create and start a oneshot timer. - * Parameters: - * qid: the mpq id in which the created timer will run; - * func: the timer callback function; - * dtor: the timer destructor function; - * argc: arguments count would be passed to async callback function; - * ...: the various arguments would be passed to async callback function; - * Return Value: - * aosl_mpq_timer_invalid($ret): failed with aosl_errno set; - * other value: the created timer id; - **/ -extern __aosl_api__ aosl_timer_t aosl_mpq_set_oneshot_timer (aosl_mpq_t qid, aosl_ts_t expire_time, aosl_timer_func_t func, aosl_obj_dtor_t dtor, uintptr_t argc, ...); - -/** - * Get the timer interval. - * Parameters: - * timer_id: the timer id; - * interval_p: the variable address to store the interval value; - * Return Value: - * 0: successful, and the interval will be stored to *interval_p; - * <0: failed with aosl_errno set; - **/ -extern __aosl_api__ int aosl_mpq_timer_interval (aosl_timer_t timer_id, uintptr_t *interval_p); - -/** - * Check whether the timer is active. - * Parameters: - * timer_id: the timer id; - * active_p: the variable address to store the active value: - * 1: for active; - * 0: for inactive; - * Return Value: - * 0: successful, and the active status will be stored to *active_p; - * <0: failed with aosl_errno set; - **/ -extern __aosl_api__ int aosl_mpq_timer_active (aosl_timer_t timer_id, int *active_p); - -/** - * Reschedule the specified timer. - * Parameters: - * timer_id: the timer id; - * interval: AOSL_INVALID_TIMER_INTERVAL for not change interval; - * other values will be set as the new interval; - * Return Value: - * 0: successful; - * <0: failed with aosl_errno set; - * Remarks: - * We can use this function to reschedule a new created but not start timer. - **/ -extern __aosl_api__ int aosl_mpq_resched_timer (aosl_timer_t timer_id, uintptr_t interval); - -/** - * Reschedule the specified onshot timer. - * Parameters: - * timer_id: the timer id; - * expire_time: 0 is the only invalid value for expire time; - * other values will be set as the new expire time; - * Return Value: - * 0: successful; - * <0: failed with aosl_errno set; - * Remarks: - * We can use this function to reschedule a new created but not start timer. - **/ -extern __aosl_api__ int aosl_mpq_resched_oneshot_timer (aosl_timer_t timer_id, aosl_ts_t expire_time); - -/** - * Cancel the specified timer. - * Parameters: - * timer_id: the timer id; - * Return Value: - * 0: successful; - * <0: failed with aosl_errno set; - **/ -extern __aosl_api__ int aosl_mpq_cancel_timer (aosl_timer_t timer_id); - -/** - * Get the N-th argument of the timer object specified by timer_id. - * Parameters: - * timer_id: the timer id you want to retrieve the arg - * n: which argument you want to get, the first arg is 0; - * arg_p: the argument variable address to save the argument value; - * Return value: - * <0: error occured, and aosl_errno indicates which error; - * 0: call successful, and '*arg' is value of the N-th argument; - **/ -extern __aosl_api__ int aosl_mpq_timer_arg (aosl_timer_t timer_id, uintptr_t n, uintptr_t *arg_p); - -/** - * Cancel and destroy the specified timer. - * Parameters: - * timer_id: the timer id; - * Return Value: - * 0: successful; - * <0: failed with aosl_errno set; - **/ -extern __aosl_api__ int aosl_mpq_kill_timer (aosl_timer_t timer_id); - - -/** - * Coroutine sleep the specified milliseconds. - * Parameters: - * msecs: sleep time in milliseconds; - * Return Value: - * >=0: successful, returns the sleep id, and coroutine resume - * chain will be invoked after the specified milliseconds - * elapsed or the sleep was canceled by the following API; - * <0: failed with aosl_errno set; - * Remarks: - * this function is very different with common sleep, msleep etc - * functions, this is stackless coroutine sleep functionality, - * so it will suspend the coroutine rather than the running thread, - * and the coroutine resume chain will be invoked after the time - * specified by msecs passed. - **/ -extern __aosl_api__ intptr_t aosl_co_sleep_ms (uint32_t msecs); - -/** - * Cancel the async sleep specified by the sleep id. - * Parameters: - * sleep_id: sleep id returned by above async sleep API; - * Return Value: - * 0: the sleep was canceled successfully; - * <0: failed with aosl_errno set; - * Remarks: - * this function is very useful when we want to cancel an async - * sleep due to some purpose, just passing the sleep id returned - * by async sleep API as the parameter. - **/ -extern __aosl_api__ int aosl_co_sleep_cancel (intptr_t sleep_id); - - -#ifdef __cplusplus -} -#endif - - -#endif /* __AOSL_MPQ_TIMER_H__ */ diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpqp.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpqp.h deleted file mode 100644 index 99ed9facd..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_mpqp.h +++ /dev/null @@ -1,303 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jul 26th, 2018 - * Module: Multiplex queue pool header file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_MPQP_H__ -#define __AOSL_MPQP_H__ - -#include -#include -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - - -typedef struct __mpqp_obj_type *aosl_mpqp_t; - - -/* This value should be big enough for the pool size */ -#define MPQP_MAX_SIZE 65536 - -/** - * Create a multiplex queue pool. - * Parameter: - * pool_size: the pool size - * flags: the mpq flags in this pool - * pri: the priority of the mpq in this mpq pool, 0 for system default - * #define AOSL_THRD_PRI_DEFAULT 0 - * #define AOSL_THRD_PRI_LOW 1 - * #define AOSL_THRD_PRI_NORMAL 2 - * #define AOSL_THRD_PRI_HIGH 3 - * #define AOSL_THRD_PRI_HIGHEST 4 - * #define AOSL_THRD_PRI_RT 5 - * max: specify the max queue size, must not greater than MPQP_MAX_SIZE - * max_idles: specify the max idle count before shrinking the pool: - * <0: no max idle count - * ==0 || > 0x7fffffff: invalid - * other values: the max idle count - * name: the queue poll name - * init: the initialize callback function - * fini: the finalize callback function - * arg: the parameter passed to init callback - * Return value: - * the queue object just created, NULL when failed. - **/ -extern __aosl_api__ aosl_mpqp_t aosl_mpqp_create (int pool_size, int flags, int pri, int max, int max_idles, const char *name, aosl_mpq_init_t init, aosl_mpq_fini_t fini, void *arg); - -/** - * Queue a function to the pool with args for invoking by the target thread which monitoring - * the corresponding queue object. - * Parameter: - * qp: the queue pool object - * dq: the done queue id, -1 for no done notification - * If dq is a valid mpq id, then the queued function f will be - * queued to the mpq specified by dq, and then got executed again. - * It is the responsibility of the function itself to differentiate the - * reentrance, such as, identify the reentrance according to one of arg. - * ref: the mpq object id for indicating whether the relative operation - * should be aborted and only free the relative resources, if the - * mpq object specified by ref has been destroyed, then target - * function specified by 'f' MUST NOT DO ANYTING ELSE except free - * the relative resources. - * f: the function - * argc: the args count - * ...: variable args - * Return value: - * Queued target mpq queue id, checking the result with aosl_mpq_invalid: - * invalid qid: indicates error, check aosl_errno for detail - * valid qid: successful, returns the queue id of selected queue. - **/ -extern __aosl_api__ aosl_mpq_t aosl_mpqp_queue (aosl_mpqp_t qp, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...); - -/** - * The synchronous version, the target f must have been invoked when this function returns. - * Parameter: - * qp: the queue pool object - * ref: the mpq object id for indicating whether the relative operation - * should be aborted and only free the relative resources, if the - * mpq object specified by ref has been destroyed, then target - * function specified by 'f' MUST NOT DO ANYTING ELSE except free - * the relative resources. - * f: the function - * argc: the args count - * ...: variable args - * Return value: - * Queued target mpq queue id, checking the result with aosl_mpq_invalid: - * invalid qid: indicates error, check aosl_errno for detail - * valid qid: successful, returns the queue id of selected queue. - **/ -extern __aosl_api__ aosl_mpq_t aosl_mpqp_call (aosl_mpqp_t qp, aosl_ref_t ref, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...); - -/** - * Run the specified function on the specified mpq pool in async or sync mode: - * 1. identical to aosl_mpqp_queue if the target q of qp pool is not the same as the running q; - * 2. identical to aosl_mpqp_call if the target q of qp pool is just the running q; - **/ -extern __aosl_api__ aosl_mpq_t aosl_mpqp_run (aosl_mpqp_t qp, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...); - -/** - * The same as 'aosl_mpqp_queue' except this function takes a 'va_list' arg for the - * variable args rather than '...'. - **/ -extern __aosl_api__ aosl_mpq_t aosl_mpqp_queue_args (aosl_mpqp_t qp, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args); - -/* The synchronous version, the target f must have been invoked when this function returns */ -extern __aosl_api__ aosl_mpq_t aosl_mpqp_call_args (aosl_mpqp_t qp, aosl_ref_t ref, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args); - -/** - * Run the specified function on the specified mpq pool in async or sync mode: - * 1. identical to aosl_mpqp_queue_args if the target q of qp pool is not the same as the running q; - * 2. identical to aosl_mpqp_call_args if the target q of qp pool is just the running q; - **/ -extern __aosl_api__ aosl_mpq_t aosl_mpqp_run_args (aosl_mpqp_t qp, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args); - -/** - * The same as 'aosl_mpqp_queue' except this function takes a 'uintptr_t *argv' arg for the - * variable args rather than '...'. - **/ -extern __aosl_api__ aosl_mpq_t aosl_mpqp_queue_argv (aosl_mpqp_t qp, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv); - -/* The synchronous version, the target f must have been invoked when this function returns */ -extern __aosl_api__ aosl_mpq_t aosl_mpqp_call_argv (aosl_mpqp_t qp, aosl_ref_t ref, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv); - -/** - * Run the specified function on the specified mpq pool in async or sync mode: - * 1. identical to aosl_mpqp_queue_argv if the target q of qp pool is not the same as the running q; - * 2. identical to aosl_mpqp_call_argv if the target q of qp pool is just the running q; - **/ -extern __aosl_api__ aosl_mpq_t aosl_mpqp_run_argv (aosl_mpqp_t qp, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv); - - -/** - * Queue a function to the pool with a chunk of data for invoking by the target thread which monitoring - * the queue. - * Parameter: - * qp: the queue pool object - * dq: the done queue id, -1 for no done notification - * If dq is a valid mpq id, then the queued function f will be - * queued to the mpq specified by dq, and then got executed again. - * It is the responsibility of the function itself to differentiate the - * reentrance, such as, identify the reentrance according to one of arg. - * ref: the mpq object id for indicating whether the relative operation - * should be aborted and only free the relative resources, if the - * mpq object specified by ref has been destroyed, then target - * function specified by 'f' MUST NOT DO ANYTING ELSE except free - * the relative resources. - * f: the function - * len: the data length in bytes - * data: the data pointer which contains the data(would be copied in) - * Return value: - * Queued target mpq queue id, checking the result with aosl_mpq_invalid: - * invalid qid: indicates error, check aosl_errno for detail - * valid qid: successful, returns the queue id of selected queue. - **/ -extern __aosl_api__ aosl_mpq_t aosl_mpqp_queue_data (aosl_mpqp_t qp, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_mpq_func_data_t f, size_t len, void *data); - -/* The synchronous version, the target f must have been invoked when this function returns */ -extern __aosl_api__ aosl_mpq_t aosl_mpqp_call_data (aosl_mpqp_t qp, aosl_ref_t ref, const char *f_name, aosl_mpq_func_data_t f, size_t len, void *data); - -/** - * Run the specified function on the specified mpq pool in async or sync mode: - * 1. identical to aosl_mpqp_queue_data if the target q of qp pool is not the same as the running q; - * 2. identical to aosl_mpqp_call_data if the target q of qp pool is just the running q; - **/ -extern __aosl_api__ aosl_mpq_t aosl_mpqp_run_data (aosl_mpqp_t qp, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_mpq_func_data_t f, size_t len, void *data); - - -/** - * Queue a function to the pool and promise all queues have done - * the previous queued jobs when invoking the this queued func. - * Parameter: - * qp: the queue pool object - * dq: the done queue id, -1 for no done notification - * If dq is a valid mpq id, then the queued function f will be - * queued to the mpq specified by dq, and then got executed again. - * It is the responsibility of the function itself to differentiate the - * reentrance, such as, identify the reentrance according to one of arg. - * ref: the mpq object id for indicating whether the relative operation - * should be aborted and only free the relative resources, if the - * mpq object specified by ref has been destroyed, then target - * function specified by 'f' MUST NOT DO ANYTING ELSE except free - * the relative resources. - * f: the function - * argc: the args count - * ...: variable args - * Return value: - * <0: indicates error, check aosl_errno for detail - * 0: successful. - **/ -extern __aosl_api__ int aosl_mpqp_pool_tail_queue (aosl_mpqp_t qp, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...); -extern __aosl_api__ int aosl_mpqp_pool_tail_queue_args (aosl_mpqp_t qp, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args); -extern __aosl_api__ int aosl_mpqp_pool_tail_queue_argv (aosl_mpqp_t qp, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t argv []); - - -/** - * Shrink a multiplex queue pool object by 1. - * Parameter: - * qp: the queue pool object to be shrinked - * Return value: - * <0: the pool size is only one now, no permission to shrink any more - * if want shrink to zero size, please use aosl_mpqp_shrink_all; - * 0: shrinked 1 q successfully; - **/ -extern __aosl_api__ int aosl_mpqp_shrink (aosl_mpqp_t qp); - -/** - * Shrink all MPQs in a multiplex queue pool object. - * Parameter: - * qp: the queue pool object to be shrinked - * wait: 0 for not wait, other values for wait - **/ -extern __aosl_api__ void aosl_mpqp_shrink_all (aosl_mpqp_t qp, int wait); - -/** - * Get the system CPUP object. - * Parameter: - * none. - * Return value: - * the CPUP object. - **/ -extern __aosl_api__ aosl_mpqp_t aosl_cpup (void); - -/** - * Get the system GPUP object. - * Parameter: - * none. - * Return value: - * the GPUP object. - **/ -extern __aosl_api__ aosl_mpqp_t aosl_gpup (void); - -/** - * Get the system GENP object. - * Parameter: - * none. - * Return value: - * the GENP object. - **/ -extern __aosl_api__ aosl_mpqp_t aosl_genp (void); - -/** - * Get the system LTWP object. - * Parameter: - * none. - * Return value: - * the LTWP object. - **/ -extern __aosl_api__ aosl_mpqp_t aosl_ltwp (void); - -/** - * Allocate an mpq object for dedicate processing some jobs according to - * the capability of the system. This function is pure different with the - * aosl_mpq_create* series functions which create a new mpq object anyway, - * instead, this function returns an mpq object according to the system - * capability, so the returned mpq id may be identical with some previous - * return value. - * Note: once the dedicated jobs have been done, must use aosl_mpq_free - * to free the allocated mpq. - * Parameter: - * none. - * Return value: - * the allocated mpq id. - **/ -extern __aosl_api__ aosl_mpq_t aosl_mpq_alloc (void); - -/** - * Free an mpq object which returned by aosl_mpq_alloc previously. - * Note: once the dedicated jobs have been done, must use this function - * to free the allocated mpq returned by previous aosl_mpq_alloc. - * Parameter: - * the mpq id. - * Return value: - * 0: for success - * -1: for failure, check aosl_errno for detail - **/ -extern __aosl_api__ int aosl_mpq_free (aosl_mpq_t qid); - -/** - * Destroy a multiplex queue pool object. - * Parameter: - * qp: the queue pool object to be destroyed - * wait: 0 for not wait, other values for wait - **/ -extern __aosl_api__ void aosl_mpqp_destroy (aosl_mpqp_t qp, int wait); - - -#ifdef __cplusplus -} -#endif - -#endif /* __AOSL_MPQP_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_os.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_os.h deleted file mode 100644 index 44e3c7fd4..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_os.h +++ /dev/null @@ -1,42 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Oct 20th, 2020 - * Module: Common Posix compatible APIs used in AOSL - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 ~ 2020 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_OS_H__ -#define __AOSL_OS_H__ - -#include - -#include -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - -extern __aosl_api__ int aosl_os_open (const char *file, int oflag, ...); -extern __aosl_api__ int aosl_os_mkdir (const char *pathname, mode_t mode); -extern __aosl_api__ int aosl_os_rmdir (const char *pathname); -extern __aosl_api__ int aosl_os_unlink (const char *pathname); -extern __aosl_api__ int aosl_os_fstat (int fd, struct stat *statbuf); -extern __aosl_api__ int aosl_os_stat (const char *pathname, struct stat *statbuf); -extern __aosl_api__ int aosl_os_rename (const char *oldpath, const char *newpath); - - -#ifdef __cplusplus -} -#endif - - -#endif /* __AOSL_OS_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_pmdf.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_pmdf.h deleted file mode 100644 index 380366373..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_pmdf.h +++ /dev/null @@ -1,122 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jun 27th, 2021 - * Module: AOSL performance monitor dump file format - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2021 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_PMDF_H__ -#define __AOSL_PMDF_H__ - -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - -#define APMDF_NMAGIC 6 - -typedef struct apmdf_fhdr { - char f_magic [APMDF_NMAGIC]; /* AOSLPM */ - uint16_t f_hchksum; - uint8_t f_type; - uint8_t f_version; - uint8_t f_machine; - uint8_t f_os; - uint16_t f_cpus; - uint16_t f_shentsize; - uint16_t f_shcount; - uint16_t f_shdatidx; - uint32_t f_shoff; - uint32_t f_size; - uint32_t f_period; - uint32_t f_totalhits; - uint32_t f_fchksum; -} aosl_pmdf_fhdr_t; - -#define APMDF_TYPE_PERF 0x1 - -#define APMDF_ARCH_ARM 0x1 -#define APMDF_ARCH_X86 0x2 -#define APMDF_ARCH_MIPS 0x3 -#define APMDF_ARCH_PPC 0x4 -#define APMDF_ARCH_RISCV 0x5 -#define APMDF_ARCH_OPENRISC 0x6 -#define APMDF_ARCH_SPARC 0x7 - -#define APMDF_ARCH_64BIT 0x10 -#define APMDF_EB_BIG 0x20 - -#define APMDF_OS_LINUX 0x1 -#define APMDF_OS_ANDROID 0x2 -#define APMDF_OS_MACOSX 0x3 -#define APMDF_OS_IOS 0x4 -#define APMDF_OS_WINDOWS 0x5 -#define APMDF_OS_SPREADTRUM 0x6 -#define APMDF_OS_LITEOS 0x7 -#define APMDF_OS_LITEOS2 0x8 - -#define APMDF_ST_THRTAB 0x1 -#define APMDF_ST_IMGTAB 0x2 -#define APMDF_ST_SYMTAB 0x3 -#define APMDF_ST_CNTTAB 0x4 -#define APMDF_ST_DATTAB 0x5 -#define APMDF_ST_TLVTAB 0x6 - -typedef struct apmdf_shdr { - uint16_t s_type; - uint16_t s_entsize; /* if being a table */ - uint32_t s_size; - uint32_t s_off; -} aosl_pmdf_shdr_t; - -typedef struct apmdf_thr_ent { - uint32_t thrd_l; - uint32_t thrd_h; /* just for future's potential OSes */ - int32_t name; /* Only valid if none negative */ - uint16_t native; - uint16_t reserved; - uint32_t sys_us; /* sys micro seconds */ - uint32_t usr_us; /* usr micro seconds */ -} aosl_pmdf_thr_ent_t; - -typedef struct apmdf_img_ent { - uint32_t start_l; - uint32_t start_h; - uint32_t name; -} aosl_pmdf_img_ent_t; - -typedef struct apmdf_sym_ent { - uint32_t sym_val; - uint32_t sym_name; -} aosl_pmdf_sym_ent_t; - -typedef struct apmdf_cnt_ent { - uint16_t native; - uint16_t img; - uint32_t addr_off; - int32_t sym; /* Only valid if none negative */ - uint32_t hits; -} aosl_pmdf_cnt_ent_t; - -typedef struct apmdf_tlv_ent { - uint16_t v_tag; - uint16_t v_len; - uint32_t v_voo; /* value or off */ -} aosl_pmdf_tlv_ent_t; - - -#ifdef __cplusplus -} -#endif - - -#endif /* __AOSL_PMDF_H__ */ diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_poll.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_poll.h deleted file mode 100644 index 4eac74a0d..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_poll.h +++ /dev/null @@ -1,51 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : May 30th, 2023 - * Module: AOSL poll functionality definition header file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 ~ 2023 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_POLL_H__ -#define __AOSL_POLL_H__ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - - - -#define AOSL_POLL_ST_NONE 0 -#define AOSL_POLL_ST_SIGNALED 1 -#define AOSL_POLL_ST_DESTROY 2 - -/** - * Poll the objects specified in refs, return their states. - * Parameters: - * refs: the object refs array for input, and the signaled refs array for output; - * count: the number of items for input refs array; - * min: the minimum number of signaled refs for triggering waken up. - * NOTE: if any one of the refs encounters error or destroy, - * then wake up immediately regardless min parameter. - * timeo: maximum waiting time in milliseconds; - * Return value: - * <0: error occured, and aosl_errno indicates which error; - * >=0: the signaled refs count before timeout; - **/ -extern __aosl_api__ ssize_t aosl_poll (aosl_ref_t refs [], size_t count, size_t min, intptr_t timeo); - - - -#ifdef __cplusplus -} -#endif - -#endif /* __AOSL_POLL_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_profile.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_profile.h deleted file mode 100644 index 8cc3c6cc0..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_profile.h +++ /dev/null @@ -1,71 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : May 10th, 2021 - * Module: AOSL profile system header file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2021 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_PROFILE_H__ -#define __AOSL_PROFILE_H__ - -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - -/** - * Dump the profile data callback function. - * Parameter: - * img_name: the profile hitting image name - * img_start: the hitting image start address - * pc_off: the hitting address offset in the image - * native: 1 for native profile; 0 for extern profile - * hits: the hitting count - * arg: the parameter passed in dump function - * Return value: - * None. - **/ -typedef void (*aosl_profile_cb_t) (const char *img_name, uintptr_t img_start, uint32_t pc_off, int native, uint32_t hits, void *arg); - -#define AOSL_PROFILE_DUMP_NATIVE 0x1 -#define AOSL_PROFILE_DUMP_EXTERN 0x2 -/** - * Dump the profile data via specified callback function. - * Parameter: - * cb: the dump callback function of aosl_profile_cb_t type - * flags: bit mask for specifying dump which profile data: - * AOSL_PROFILE_DUMP_NATIVE: dump native profile data - * AOSL_PROFILE_DUMP_EXTERN: dump extern profile data - * threshold: specify the dump minimum threshold in 1/1000 units, 0 for any - * arg: the parameter passed to dump callback - * Return value: - * None. - **/ -extern __aosl_api__ void aosl_profile_data (aosl_profile_cb_t cb, int flags, uint32_t threshold, void *arg); -extern __aosl_api__ void aosl_profile_dump (const char *filepath, int flags, uint32_t threshold); -extern __aosl_api__ void aosl_profile_reset (void); -extern __aosl_api__ void aosl_profile_free (void); - -extern __aosl_api__ void aosl_profile_start (int period); -extern __aosl_api__ void aosl_profile_stop (void); -extern __aosl_api__ int aosl_profile_period (void); - -extern __aosl_api__ int aosl_profile_register_this (const char *name); -extern __aosl_api__ void aosl_profile_clear_registered (void); - -extern __aosl_api__ void aosl_get_times (uint64_t *system_us, uint64_t *user_us); - -#ifdef __cplusplus -} -#endif - -#endif /* __AOSL_PROFILE_H__ */ diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_psb.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_psb.h deleted file mode 100644 index db7739b7f..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_psb.h +++ /dev/null @@ -1,67 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jul 21st, 2018 - * Module: Packet Segment Buffer relatives header file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_PSB_H__ -#define __AOSL_PSB_H__ - - -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - - -#define DFLT_MAX_PSB_PKT (4 << 10) /* default max packet size is 4K */ - -/* AOSL Packet Segment Buffer */ -typedef struct _____psb { - void *data; - size_t len; - struct _____psb *next; -} aosl_psb_t; - - -extern __aosl_api__ aosl_psb_t *aosl_alloc_user_psb (void *buf, size_t bufsz); -extern __aosl_api__ aosl_psb_t *aosl_alloc_psb (size_t size); -extern __aosl_api__ void aosl_psb_attach_buf (aosl_psb_t *psb, void *buf, size_t bufsz); -extern __aosl_api__ void aosl_psb_detach_buf (aosl_psb_t *psb); -extern __aosl_api__ size_t aosl_psb_headroom (const aosl_psb_t *psb); -extern __aosl_api__ size_t aosl_psb_tailroom (const aosl_psb_t *psb); -extern __aosl_api__ int aosl_psb_reserve (aosl_psb_t *psb, size_t len); -extern __aosl_api__ void *aosl_psb_data (const aosl_psb_t *psb); -extern __aosl_api__ size_t aosl_psb_len (const aosl_psb_t *psb); -extern __aosl_api__ size_t aosl_psb_total_len (const aosl_psb_t *psb); -extern __aosl_api__ void *aosl_psb_put (aosl_psb_t *psb, size_t len); -extern __aosl_api__ void *aosl_psb_get (aosl_psb_t *psb, size_t len); -extern __aosl_api__ void *aosl_psb_peek (const aosl_psb_t *psb, size_t len); -extern __aosl_api__ void *aosl_psb_push (aosl_psb_t *psb, size_t len); -extern __aosl_api__ void *aosl_psb_pull (aosl_psb_t *psb, size_t len); -extern __aosl_api__ ssize_t aosl_psb_write (aosl_psb_t *psb, const void *buf, size_t count); -extern __aosl_api__ int aosl_psb_modify (aosl_psb_t *psb, uintptr_t off, const void *buf, size_t count); -extern __aosl_api__ ssize_t aosl_psb_read (aosl_psb_t *psb, void *buf, size_t count); -extern __aosl_api__ int aosl_psb_single (const aosl_psb_t *psb); -extern __aosl_api__ void aosl_psb_reset (aosl_psb_t *psb); -extern __aosl_api__ void aosl_free_psb_list (aosl_psb_t *psb); - - - -#ifdef __cplusplus -} -#endif - - - -#endif /* __AOSL_PSB_H__ */ diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_rbtree.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_rbtree.h deleted file mode 100644 index 8b255fe28..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_rbtree.h +++ /dev/null @@ -1,73 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jul 28th, 2018 - * Module: AOSL Red-Black tree header file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_RBTREE_H__ -#define __AOSL_RBTREE_H__ - -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - -struct aosl_rb_node { - uintptr_t rb_parent_color; - struct aosl_rb_node *rb_right; - struct aosl_rb_node *rb_left; -}; - -typedef int (*aosl_rb_node_cmp_t) (struct aosl_rb_node *rb_node, struct aosl_rb_node *node, va_list args); - -struct aosl_rb_root { - struct aosl_rb_node *rb_node; - aosl_rb_node_cmp_t rb_cmp; - uintptr_t count; -}; - - -#define aosl_rb_entry(ptr, type, member) container_of(ptr, type, member) - -extern __aosl_api__ void aosl_rb_root_init (struct aosl_rb_root *root, aosl_rb_node_cmp_t cmp); - - -extern __aosl_api__ struct aosl_rb_node **aosl_vfind_rb_links (struct aosl_rb_root *root, struct aosl_rb_node **rb_parent, - struct aosl_rb_node **pprev, struct aosl_rb_node **pnext, struct aosl_rb_node *node, va_list args); - -extern __aosl_api__ struct aosl_rb_node **aosl_find_rb_links (struct aosl_rb_root *root, struct aosl_rb_node **rb_parent, - struct aosl_rb_node **pprev, struct aosl_rb_node **pnext, struct aosl_rb_node *node, ...); - -extern __aosl_api__ struct aosl_rb_node *aosl_vfind_rb_node (struct aosl_rb_root *root, struct aosl_rb_node *node, va_list args); -extern __aosl_api__ struct aosl_rb_node *aosl_find_rb_node (struct aosl_rb_root *root, struct aosl_rb_node *node, ...); - -extern __aosl_api__ void aosl_rb_insert_node (struct aosl_rb_root *root, struct aosl_rb_node *node, ...); -extern __aosl_api__ struct aosl_rb_node *aosl_rb_remove (struct aosl_rb_root *root, struct aosl_rb_node *node, ...); - -extern __aosl_api__ void aosl_rb_erase (struct aosl_rb_root *root, struct aosl_rb_node *node); - -typedef int (*aosl_rb_walk_func_t) (struct aosl_rb_node *node, void *arg); - -extern __aosl_api__ void aosl_rb_traverse_dlr (struct aosl_rb_root *root, aosl_rb_walk_func_t func, void *arg); -extern __aosl_api__ void aosl_rb_traverse_ldr (struct aosl_rb_root *root, aosl_rb_walk_func_t func, void *arg); -extern __aosl_api__ void aosl_rb_traverse_lrd (struct aosl_rb_root *root, aosl_rb_walk_func_t func, void *arg); - -/* Only for reverse order traverse. */ -extern __aosl_api__ void aosl_rb_traverse_rdl (struct aosl_rb_root *root, aosl_rb_walk_func_t func, void *arg); - - -#ifdef __cplusplus -} -#endif - -#endif /* __AOSL_RBTREE_H__ */ diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_ref.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_ref.h deleted file mode 100644 index 4a2f439fa..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_ref.h +++ /dev/null @@ -1,260 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Nov 19th, 2018 - * Module: AOSL reference object definition file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_REF_H__ -#define __AOSL_REF_H__ - - -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - - -typedef struct _internal_ref_od_ *aosl_ref_t; - -#define AOSL_REF_INVALID ((aosl_ref_t)(intptr_t)NULL) - -#define aosl_ref_invalid(ref) ((int)(intptr_t)(ref) <= 0) - - -/** - * The reference object destructor function prototype, which invoked when application - * calling aosl_ref_destroy functions to release resources. - * Parameter: - * arg: the parameter passed in when creating the reference object; - * Return value: - * none. - **/ -typedef void (*aosl_ref_dtor_t) (void *arg); - -/** - * The reference object creating function prototype, which is used to create a ref object. - * Parameters: - * arg: the parameter attached with the reference object; - * dtor: the ref object destructor function, which will be invoked when - * the ref object is deleted; - * caller_free: - * none-0 guarantee the ref object relatives must be freed in the caller thread - * 0 the ref object relatives could be freed in any thread - * Return value: - * the ref object id, please use aosl_ref_invalid macro to check whether failed. - **/ -extern __aosl_api__ aosl_ref_t aosl_ref_create (void *arg, aosl_ref_dtor_t dtor, int caller_free); - - -/** - * The ref object callback function prototype. - * Parameter: - * arg: the ref object argument which was passed in when creating; - * argc: specify the argv array elements count, the same as the argc - * when invoking aosl_ref_[get|read|write] functions; - * argv: array for passing variable args, the same as the args - * when invoking aosl_task_exec_* functions; - * Return value: - * none. - **/ -typedef void (*aosl_ref_func_t) (void *arg, uintptr_t argc, uintptr_t argv []); - -/** - * Hold the ref object, and invoke the specified callback function. - * Parameter: - * ref: the ref object id; - * f: the callback function; - * argc: the args count - * ...: variable args - * Return value: - * 0: success - * <0: failure with aosl_errno set - **/ -extern __aosl_api__ int aosl_ref_hold (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...); -extern __aosl_api__ int aosl_ref_hold_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args); -extern __aosl_api__ int aosl_ref_hold_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []); - -/** - * Hold the ref object and read lock it, then invoke the specified callback function. - * Parameter: - * ref: the ref object id; - * f: the callback function; - * argc: the args count - * ...: variable args - * Return value: - * 0: success - * <0: failure with aosl_errno set - **/ -extern __aosl_api__ int aosl_ref_read (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...); -extern __aosl_api__ int aosl_ref_read_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args); -extern __aosl_api__ int aosl_ref_read_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []); - -/** - * Hold the ref object and write lock it, then invoke the specified callback function. - * Parameter: - * ref: the ref object id; - * f: the callback function; - * argc: the args count - * ...: variable args - * Return value: - * 0: success - * <0: failure with aosl_errno set - **/ -extern __aosl_api__ int aosl_ref_write (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...); -extern __aosl_api__ int aosl_ref_write_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args); -extern __aosl_api__ int aosl_ref_write_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []); - -/** - * Hold the ref object and set it unsafe, then invoke the specified callback function. - * Parameter: - * ref: the ref object id; - * f: the callback function; - * argc: the args count - * ...: variable args - * Return value: - * 0: success - * <0: failure with aosl_errno set - **/ -extern __aosl_api__ int aosl_ref_unsafe (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...); -extern __aosl_api__ int aosl_ref_unsafe_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args); -extern __aosl_api__ int aosl_ref_unsafe_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []); - -/** - * Hold the ref object and set it maystall, then invoke the specified callback function. - * Parameter: - * ref: the ref object id; - * f: the callback function; - * argc: the args count - * ...: variable args - * Return value: - * 0: success - * <0: failure with aosl_errno set - **/ -extern __aosl_api__ int aosl_ref_maystall (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...); -extern __aosl_api__ int aosl_ref_maystall_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args); -extern __aosl_api__ int aosl_ref_maystall_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []); - - -typedef void *aosl_refobj_t; - -#define AOSL_FREE_ONLY_OBJ ((aosl_refobj_t)(uintptr_t)1) -#define aosl_is_free_only(robj) ((int)((aosl_refobj_t)(robj) == AOSL_FREE_ONLY_OBJ)) - -/** - * Retrieve the ref object arg. - * Parameters: - * robj: the reference object; - * Return value: - * the ref object arg; - **/ -extern __aosl_api__ void *aosl_refobj_arg (aosl_refobj_t robj); - -/** - * Get the ref id of the specified ref object. - * Parameters: - * robj: the reference object; - * Return value: - * the ref id. - **/ -extern __aosl_api__ aosl_ref_t aosl_refobj_id (aosl_refobj_t robj); - -/** - * Make sure read lock the ref object specified by robj, then invoke the specified callback function. - * Parameter: - * robj: the ref object itself; - * f: the callback function; - * argc: the args count - * ...: variable args - * Return value: - * 0: success - * <0: failure with aosl_errno set - **/ -extern __aosl_api__ int aosl_refobj_read (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, ...); -extern __aosl_api__ int aosl_refobj_read_args (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, va_list args); -extern __aosl_api__ int aosl_refobj_read_argv (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []); - -/** - * Make sure set the ref object specified by robj unsafe, then invoke the specified callback function. - * Parameter: - * robj: the ref object itself; - * f: the callback function; - * argc: the args count - * ...: variable args - * Return value: - * 0: success - * <0: failure with aosl_errno set - **/ -extern __aosl_api__ int aosl_refobj_unsafe (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, ...); -extern __aosl_api__ int aosl_refobj_unsafe_args (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, va_list args); -extern __aosl_api__ int aosl_refobj_unsafe_argv (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []); - -/** - * Make sure set the ref object specified by robj maystall, then invoke the specified callback function. - * Parameter: - * robj: the ref object itself; - * f: the callback function; - * argc: the args count - * ...: variable args - * Return value: - * 0: success - * <0: failure with aosl_errno set - **/ -extern __aosl_api__ int aosl_refobj_maystall (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, ...); -extern __aosl_api__ int aosl_refobj_maystall_args (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, va_list args); -extern __aosl_api__ int aosl_refobj_maystall_argv (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []); - - -/** - * Detect whether the reference object specified by ref is read locked - * by the calling thread. - * Parameter: - * ref: the reference object id - * Return value: - * 0: not read locked - * none zero: read locked by calling thread - **/ -extern __aosl_api__ int aosl_ref_locked (aosl_ref_t ref); - -/** - * Set the living scope ref object of the specified ref object. - * Parameters: - * ref: the ref object ref id; - * scope_ref: the living scope ref, the ref object will be destroyed - * when the object specified by scope_ref was destroyed; - * Return value: - * <0: error occured, and aosl_errno indicates which error; - * >=0: successful; - **/ -extern __aosl_api__ int aosl_ref_set_scope (aosl_ref_t ref, aosl_ref_t scope_ref); - -/** - * Destroy the reference object specified by ref. - * Parameter: - * ref: the reference object id - * do_delete: 0 for just marking it destroyed - * non-0 value for deleting it - * Return value: - * 0: success - * <0: failed, and aosl_errno indicates what error occurs - **/ -extern __aosl_api__ int aosl_ref_destroy (aosl_ref_t ref, int do_delete); - - - -#ifdef __cplusplus -} -#endif - - - -#endif /* __AOSL_REF_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_route.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_route.h deleted file mode 100644 index e481f945b..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_route.h +++ /dev/null @@ -1,123 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jul 29th, 2018 - * Module: Network route relative functionals header file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_NET_API_H__ -#define __AOSL_NET_API_H__ - -#include -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - -typedef enum { - AOSL_NET_EV_NONE = 0, - AOSL_NET_EV_NET_DOWN, - AOSL_NET_EV_NET_UP, - AOSL_NET_EV_NET_UP_CHANGED, - AOSL_NET_EV_NET_SWITCH, -} aosl_net_ev_t; - -typedef struct { - int if_index; - int if_type; - char if_name [64]; -} aosl_netif_t; - -typedef struct { - aosl_netif_t netif; - int if_cellnet; - aosl_sk_addr_t gw; -} aosl_rt_t; - -typedef struct { - aosl_rt_t IPv4; - aosl_rt_t IPv6; -} aosl_def_rt_t; - -extern __aosl_api__ void aosl_init_def_rt (aosl_def_rt_t *def_rt); - -extern __aosl_api__ void aosl_invalidate_rt (aosl_rt_t *rt); -extern __aosl_api__ void aosl_invalidate_def_rt (aosl_def_rt_t *def_rt); - -extern __aosl_api__ int aosl_rt_valid (const aosl_rt_t *rt); -extern __aosl_api__ int aosl_def_rt_valid (const aosl_def_rt_t *def_rt); - -extern __aosl_api__ int aosl_network_is_down (); - -extern __aosl_api__ int aosl_same_rt (const aosl_rt_t *rt1, const aosl_rt_t *rt2); -extern __aosl_api__ int aosl_same_def_rt (const aosl_def_rt_t *def_rt1, const aosl_def_rt_t *def_rt2); - -extern __aosl_api__ const char *aosl_rt_str (const aosl_rt_t *rt, char buf [], size_t buf_size); -extern __aosl_api__ const char *aosl_def_rt_str (const aosl_def_rt_t *def_rt, char buf [], size_t buf_size); - - -typedef void (*aosl_net_ev_func_t) (aosl_net_ev_t ev, void *arg, ...); - -/** - * Subscribe/Unsubscribe the low level network events. - * If f is not NULL, then subscribe the low level network events, and the callback - * function specified by f will be invoked in the calling thread context. Please - * note that only one subscriber allowed in the whole process. - * If f is NULL, then unsubscribe the low level network events. - * Parameters: - * f: the callback function - * arg: the parameter which will be passed when invoking the f callback - * Return values: - * <0: failed with aosl_errno set - * 0: successful - **/ -extern __aosl_api__ int aosl_subscribe_net_events (aosl_net_ev_func_t f, void *arg); - -/** - * Return value is the default route count both for IPv4 and IPv6 we retrieved. - * 0: no default route - * 1: only one of IPv4 or IPv6 has default route - * 2: both IPv4 and IPv6 have default route - **/ -extern __aosl_api__ int aosl_get_default_rt (aosl_def_rt_t *def_rt); - - -extern __aosl_api__ int aosl_is_mobile_net (sa_family_t af); - - -enum { - AOSL_ROUTE_T_NONE = -1, /* No network available now */ - AOSL_ROUTE_T_MOBILE = 0, /* Mobile network */ - AOSL_ROUTE_T_LAN = 1, /* Lan network */ -}; - -/** - * Notify the network has changed, such as Mobile -> Lan - * or Vice Versa. - * Parameters: - * net_type: Active network type - * AOSL_ROUTE_T_NONE: No active network - * AOSL_ROUTE_T_MOBILE: Mobile network active - * AOSL_ROUTE_T_LAN: Lan network active - * arg: OS specific parameter; - * Return values: - * None. - **/ -extern __aosl_api__ void aosl_net_route_changed (int net_type, uintptr_t arg); - - -#ifdef __cplusplus -} -#endif - - -#endif /* __AOSL_NET_API_H__ */ diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_sbus.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_sbus.h deleted file mode 100644 index 8e047859f..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_sbus.h +++ /dev/null @@ -1,160 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Feb 7th, 2023 - * Module: AOSL software bus relative API definition file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 ~ 2023 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_SBUS_H__ -#define __AOSL_SBUS_H__ - - -#include -#include -#include -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - - -/** - * Create a software bus object. - * Parameters: - * name: the software bus name; - * Return value: - * 0: successfully; - * <0: failed with aosl_errno set accordingly. - **/ -extern __aosl_api__ int aosl_sbus_create (const char *name); - -/** - * Action callback function for a bus object, which will be invoked when the bus has data to deliver. - * Parameters: - * robj: the ref object specified when registering; - * name: the bus object name; - * data: the bus data; - * argc: the various args count, passed when registering; - * argv: the various args vector, passed as various args when registering; - * Return value: - * None. - * Remarks: - * If we issue async operation which uses the data object in this callback function, we must increase - * the usage before issuing. - **/ -typedef void (*aosl_sbus_data_t) (aosl_refobj_t robj, const char *name, aosl_data_t data, uintptr_t argc, uintptr_t argv []); - - -/** - * Add an action of the bus object specified by name for processing data. - * Parameters: - * name: the bus object name; - * qid: the mpq you want the target function to be invoked in, if invalid, arbitrary general pool mpq; - * ref: specify a ref object just like the queue operation of an mpq; - * max: the max queued data object count, if exceeds then drop the eldest one automatically; - * f_name: specify the target function name; - * f: the target function; - * dtor: destructor which be invoked when delete the action; - * argc: the various args count; - * ...: the various args; - * Return value: - * non-NULL: successfully; - * NULL: failed with aosl_errno set accordingly. - * The return value only used for unregister, no other usage. - **/ -extern __aosl_api__ void *aosl_sbus_action_add (const char *name, aosl_mpq_t qid, aosl_ref_t ref, uintptr_t max, const char *f_name, aosl_sbus_data_t f, aosl_obj_dtor_t dtor, uintptr_t argc, ...); - -/** - * Add an action of the kobject specified by name for processing data. - * Parameters: - * name: the bus object name; - * qid: the mpq you want the target function to be invoked in, if invalid, arbitrary general pool mpq; - * ref: specify a ref object just like the queue operation of an mpq; - * max: the max queued data object count, if exceeds then drop the eldest one automatically; - * f_name: specify the target function name; - * f: the target function; - * dtor: destructor which be invoked when delete the action; - * argc: the various args count; - * args: the various args; - * Return value: - * Return value: - * non-NULL: successfully; - * NULL: failed with aosl_errno set accordingly. - * The return value only used for unregister, no other usage. - **/ -extern __aosl_api__ void *aosl_sbus_action_add_args (const char *name, aosl_mpq_t qid, aosl_ref_t ref, uintptr_t max, const char *f_name, aosl_sbus_data_t f, aosl_obj_dtor_t dtor, uintptr_t argc, va_list args); - -/** - * Add an action of the bus object specified by name for processing data. - * Parameters: - * name: the bus object name; - * qid: the mpq you want the target function to be invoked in, if invalid, arbitrary general pool mpq; - * ref: specify a ref object just like the queue operation of an mpq; - * max: the max queued data object count, if exceeds then drop the eldest one automatically; - * f_name: specify the target function name; - * f: the target function; - * dtor: destructor which be invoked when delete the action; - * argc: the various args count; - * argv: the various args vector; - * Return value: - * Return value: - * non-NULL: successfully; - * NULL: failed with aosl_errno set accordingly. - * The return value only used for unregister, no other usage. - **/ -extern __aosl_api__ void *aosl_sbus_action_add_argv (const char *name, aosl_mpq_t qid, aosl_ref_t ref, uintptr_t max, const char *f_name, aosl_sbus_data_t f, aosl_obj_dtor_t dtor, uintptr_t argc, uintptr_t argv []); - -/** - * Delete an action of the bus object specified by name. - * Parameters: - * name: the bus object name; - * h_action: the handle returned by the above add functions; - * Return value: - * 0: successfully; - * <0: failed with aosl_errno set accordingly. - **/ -extern __aosl_api__ int aosl_sbus_action_del (const char *name, void *h_action); - -/** - * Send data to the bus object. - * Parameters: - * name: the bus object name; - * data: the data will be sent to bus; - * Return value: - * 0: successfully; - * <0: failed with aosl_errno set accordingly. - * Remarks: - * The function will increase the usage of data automatically, - * so the calling function can decrease the usage just after - * this function returns, and no need to worry about the async - * operations triggerd by this function. - **/ -extern __aosl_api__ int aosl_sbus_send (const char *name, aosl_data_t data); - -/** - * Delete the bus object specified by name. - * Parameters: - * name: the bus object name; - * Return value: - * 0: successfully; - * <0: failed with aosl_errno set accordingly. - **/ -extern __aosl_api__ int aosl_sbus_delete (const char *name); - - -#ifdef __cplusplus -} -#endif - - - -#endif /* __AOSL_SBUS_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_so.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_so.h deleted file mode 100644 index 049567700..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_so.h +++ /dev/null @@ -1,60 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Dec 13th, 2020 - * Module: AOSL so module interface definition header file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2020 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_SO_H__ -#define __AOSL_SO_H__ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define AOSL_SO_DEFAULT_VER (0) - -extern __aosl_api__ int aosl_so_register (const char *name, const void *mod, uintptr_t version); - -#if defined (__GNUC__) -#define AOSL_SO_REGISTER_VER(name, version) \ - static void __attribute__ ((constructor, used)) _##name##_so_reg_ctor (void) \ - { \ - if (aosl_so_register (#name, (const void *)_##name##_so_reg_ctor, version) < 0) \ - aosl_log (AOSL_LOG_WARNING, "so lib %s register failed, err %d.", #name, aosl_errno); \ - } -#elif defined (_MSC_VER) -#pragma section (".CRT$XIG", long, read) - -#define AOSL_SO_REGISTER_VER(name, version) \ - static int _##name##_so_reg_ctor (void) \ - { \ - if (aosl_so_register (#name, (const void *)_##name##_so_reg_ctor, version) < 0) \ - aosl_log (AOSL_LOG_WARNING, "so lib %s register failed, err %d.", #name, aosl_errno); \ - return 0; \ - } \ - __declspec(allocate(".CRT$XIG")) int (*_##name##_so_module_ctor_f) (void) = _##name##_so_reg_ctor; -#else -#error Unsupported Toolchain! -#endif - -#if defined(AOSL_SO_REGISTER_VER) -#define AOSL_SO_REGISTER(name) \ - AOSL_SO_REGISTER_VER(name, AOSL_SO_DEFAULT_VER) -#endif - - -#ifdef __cplusplus -} -#endif - -#endif /* __AOSL_SO_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_socket.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_socket.h deleted file mode 100644 index 34959e663..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_socket.h +++ /dev/null @@ -1,172 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jul 27th, 2020 - * Module: AOSL BSD socket definitions header file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2020 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_SOCKET_H__ -#define __AOSL_SOCKET_H__ - -#include -#include - -#if defined (__linux__) || defined (__MACH__) || defined (__kliteos2__) || defined (_WIN32) -#if defined (__linux__) || defined (__MACH__) || defined (__kliteos2__) -#include -#include -#include -#include -#include -#elif defined (_WIN32) -/** - * We MUST include 'winsock2.h' before any occurrence - * of including 'windows.h', the fucking Windows has - * the fucking issue that many definitions would be - * complained redefinition if not so. - * -- Lionfore Hao Sep 25th, 2018 - **/ -#include -#include -#include -#include -#include -#include -#endif - -typedef struct in6_addr aosl_in6_addr_t; -typedef struct sockaddr_in6 aosl_sockaddr_in6_t; -typedef struct sockaddr_storage aosl_sockaddr_storage_t; -#else /* defined (__linux__) || defined (__MACH__) || defined (__kliteos2__) || defined (_WIN32) */ -#ifdef __cplusplus -extern "C" { -#endif - -#if defined (__kliteos__) || defined (__kaliosthings__) -#include -#include -#elif defined (__kspreadtrum__) -#include -#include -#endif - -typedef struct aosl_in6_addr { - union { - uint8_t u6_addr8[16]; - uint16_t u6_addr16[8]; - uint32_t u6_addr32[4]; - } u6_addr; -} aosl_in6_addr_t; - -#undef s6_addr8 -#undef s6_addr16 -#undef s6_addr32 -#undef s6_addr - -#define s6_addr8 u6_addr.u6_addr8 -#define s6_addr16 u6_addr.u6_addr16 -#define s6_addr32 u6_addr.u6_addr32 -#define s6_addr u6_addr.u6_addr8 - -typedef struct aosl_sockaddr_in6 { - uint16_t sin6_family; - uint16_t sin6_port; - uint32_t sin6_flowinfo; - aosl_in6_addr_t sin6_addr; - uint32_t sin6_scope_id; -} aosl_sockaddr_in6_t; - -/** - * Protocol independent socket structure (RFC 2553). - **/ -#define _AOSL_SS_SIZE 128 /* Implementation specific max size */ -#define _AOSL_SS_PADSIZE (_AOSL_SS_SIZE - sizeof (uint16_t) - sizeof (int64_t)) - -typedef struct aosl_sockaddr_storage { - uint16_t ss_family; - char __ss_padding [_AOSL_SS_PADSIZE]; - int64_t __ss_align; /* Force desired alignment. */ -} aosl_sockaddr_storage_t; - -/** - * PLEASE BE CAREFUL ENOUGH HERE: - * The macro __kspreadtrum__ is not a compiler toolchain - * predefined macro, and makercore building system will - * define this macro when building Spreadtrum system, so - * you must GUARANTEE define it when not using makercore - * building system. - * Use this style name rather than Kbuild CONFIG_* just - * want to keep consistent with __linux__/__MACH__ etc. - * -- Lionfore Hao Aug 1st, 2020 - **/ -#if defined (__kspreadtrum__) -typedef int socklen_t; - -struct sockaddr { - uint16_t sa_family; - char sa_data [14]; -}; - -typedef uint32_t in_addr_t; -struct in_addr { - in_addr_t s_addr; -}; - -/** - * Please keep the size of this struct is 16 bytes. - * -- Lionfore Hao Aug 11th, 2020 - **/ -struct sockaddr_in { - uint16_t sin_family; - uint16_t sin_port; - struct in_addr sin_addr; - unsigned char sin_zero [8]; -}; - -struct hostent { - char* h_name; /* Official name of host. */ - char** h_aliases; /* Alias list. */ - int h_addrtype; /* Host address type. */ - int h_length; /* Length of address. */ -#if !defined (CONFIG_UNISOC_8910) - int h_cntv4; /* count of v4 address. */ - int h_cntv6; /* count of v6 address. */ -#endif - char** h_addr_list; /* List of addresses from name server. */ - char **h_addr6_list; /* List of addresses from name server. */ -#if !defined (CONFIG_UNISOC_8910) - int h_cntsrv; - char **h_srv_list; -#endif -}; - -#ifndef IPPROTO_TCP -#define IPPROTO_TCP TCPIP_IPPROTO_TCP -#endif - -#ifndef IPPROTO_UDP -#define IPPROTO_UDP TCPIP_IPPROTO_UDP -#endif - -#ifndef INET_ADDRSTRLEN -#define INET_ADDRSTRLEN 16 -#endif - -#ifndef INET6_ADDRSTRLEN -#define INET6_ADDRSTRLEN 46 -#endif -#endif /* __kspreadtrum__ */ - - -#ifdef __cplusplus -} -#endif -#endif /* defined (__linux__) || defined (__MACH__) || defined (__kliteos2__) || defined (_WIN32) */ - - -#endif /* __AOSL_SOCKET_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_task.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_task.h deleted file mode 100644 index 46578f528..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_task.h +++ /dev/null @@ -1,168 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Nov 19th, 2018 - * Module: AOSL task object definition file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_TASK_H__ -#define __AOSL_TASK_H__ - - -#include -#include -#include -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - - -typedef enum { - aosl_task_type_cpu, /* CPU sensitive, no any OS waiting operations */ - aosl_task_type_gpu, /* GPU sensitive, might be shrinked when no more GPU operations */ - aosl_task_type_gen, /* General type, can use OS waiting operations */ - aosl_task_type_ltw, /* Time sensitive, can use long time waiting operations */ - aosl_task_type_opa, /* Operation itself is asynchronous */ -} aosl_task_type_t; - - -typedef enum { - aosl_task_act_exec, - aosl_task_act_done, - aosl_task_act_free, -} aosl_task_act_t; - -/** - * The task object function prototype. - * Parameter: - * tobj: the task object itself; - * act: aosl_task_act_exec for async processing; - * aosl_task_act_done for async process done; - * aosl_task_act_free for freeing relative resources only; - * opaque: the async operation opaque data, which is useful for identifying - * the async operation especially for the OPA cases, which should - * be passed when invoking - * argc: specify the argv array elements count, the same as the argc - * when invoking aosl_task_exec_* functions; - * argv: array for passing variable args, the same as the args - * when invoking aosl_task_exec_* functions; - * Return value: - * none. - **/ -typedef void (*aosl_task_func_t) (aosl_refobj_t tobj, aosl_task_act_t act, uintptr_t opaque, uintptr_t argc, uintptr_t argv []); - -/** - * The task object result waiting function prototype. - * Parameter: - * tobj: the task object itself; - * opaque: the async operation opaque data, which is useful for identifying - * the async operation especially for the OPA cases, which should - * be passed when invoking - * argc: specify the argv array elements count, the same as the argc - * when invoking aosl_task_exec_* functions; - * argv: array for passing variable args, the same as the args - * when invoking aosl_task_exec_* functions; - * Return value: - * none. - * NOTE: the task object system assumes this callback function must - * be a sync res waiting function, and task object system will - * start a dedicate thread for waiting the sync result. - * Furthermore, this callback function can only be specified - * when creating an OPA type task object, please pass NULL for - * non OPA task object. - **/ -typedef void (*aosl_task_res_wait_t) (aosl_refobj_t tobj, uintptr_t opaque, uintptr_t argc, uintptr_t argv []); - -/** - * The task object creating function prototype, which is used to create an task object. - * Parameters: - * arg: the parameter attached with the task object; - * dtor: the task object destructor function, which will be invoked when - * the task object is deleted; - * type: the task object type; - * serial: the operations must be serial, and there are 2 different meanings: - * 1) for non OPA task object, serial means any operation must be - * issued after the previous operation was done; - * 2) for OPA task object, serial means the async operation will be - * done orderly according to the issuing order; - * st_op_q: single thread operations MPQ id, AOSL_MPQ_INVALID for non single - * thread operations mode; - * resume: None zero for needing resume, 0 for no need for resuming; - * wait_f: for OPA type of task object, this is the sync callback function - * for waiting the result; - * for non-OPA type of task object, this parameter must be NULL; - **/ -extern __aosl_api__ aosl_ref_t aosl_task_create (void *arg, aosl_ref_dtor_t dtor, - aosl_task_type_t type, int serial, aosl_mpq_t st_op_q, - int resume, aosl_task_res_wait_t wait_f); - -/** - * Get the task type. - * Parameters: - * task: the task object ref; - * Return Value: - * >=0: successful, return the task type; - * <0: failed with aosl_errno set; - **/ -extern __aosl_api__ aosl_task_type_t aosl_task_get_type (aosl_ref_t task); - -/** - * Execute the task action, and the callback function will be invoked. - * Parameters: - * task: the task object ref; - * f_name: the functionality name for the callback function; - * f: the task action callback function; - * argc: arguments count would be passed to the callback function; - * ...: the various arguments would be passed to the callback function; - * Return Value: - * 0: successful, and the async callback will be invoked; - * <0: failed with aosl_errno set; - **/ -extern __aosl_api__ int aosl_task_exec (aosl_ref_t task, const char *f_name, aosl_task_func_t f, uintptr_t argc, ...); - -/* va_list version */ -extern __aosl_api__ int aosl_task_exec_args (aosl_ref_t task, const char *f_name, aosl_task_func_t f, uintptr_t argc, va_list args); - -/* args vector versions */ -extern __aosl_api__ int aosl_task_exec_argv (aosl_ref_t task, const char *f_name, aosl_task_func_t f, uintptr_t argc, uintptr_t argv []); - -/** - * These '*exclusive_exec*' functions just guarantee the callback - * function will be executed exclusively, but not guarantee it is - * executed after the function returns. - * The callback function will be invoked on the calling thread. - **/ -extern __aosl_api__ int aosl_task_exclusive_exec (aosl_ref_t task, aosl_task_func_t exclusive_f, uintptr_t argc, ...); -extern __aosl_api__ int aosl_task_exclusive_exec_args (aosl_ref_t task, aosl_task_func_t exclusive_f, uintptr_t argc, va_list args); -extern __aosl_api__ int aosl_task_exclusive_exec_argv (aosl_ref_t task, aosl_task_func_t exclusive_f, uintptr_t argc, uintptr_t argv []); - -extern __aosl_api__ int aosl_task_waiting_ops_count (aosl_ref_t task); -extern __aosl_api__ int aosl_task_remove_waiting_ops_head (aosl_ref_t task); - -/** - * This is only for aosl_task_type_opa case, the operation itself is - * asynchronous, so please invoke this function when the asynchronous - * operation is done. - **/ -extern __aosl_api__ int aosl_task_async_done (aosl_ref_t task); -extern __aosl_api__ int aosl_task_async_done_opaque (aosl_ref_t task, uintptr_t opaque); - - - -#ifdef __cplusplus -} -#endif - - - -#endif /* __AOSL_TASK_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_thread.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_thread.h deleted file mode 100644 index ecfbb25ec..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_thread.h +++ /dev/null @@ -1,144 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Sep 22nd, 2018 - * Module: AOSL thread relative definitions - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_THREAD_H__ -#define __AOSL_THREAD_H__ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -typedef uintptr_t aosl_thread_t; -typedef uintptr_t aosl_thrdid_t; -typedef uintptr_t aosl_osthrd_t; - -typedef void (*aosl_thread_entry_t) (void *); - -#define AOSL_THRD_PRI_DEFAULT 0 -#define AOSL_THRD_PRI_LOW 1 -#define AOSL_THRD_PRI_NORMAL 2 -#define AOSL_THRD_PRI_HIGH 3 -#define AOSL_THRD_PRI_HIGHEST 4 -#define AOSL_THRD_PRI_RT 5 - -extern __aosl_api__ aosl_thread_t aosl_thread_self (void); -extern __aosl_api__ aosl_thrdid_t aosl_thread_self_id (void); - -/** - * Get the mpq thread name. - * Parameters: - * thrd: the retrieving thread id - * Linux: the thread tid - * XNU: the mach thread id, type is mach_port_t - * Windows: the Windows thread id, type is DWORD - * namebuf: the buf to hold the name - * buflen: the name buf length in bytes - * Return Value: - * 0: success - * <0: failure with aosl_errno set - **/ -extern __aosl_api__ int aosl_thrd_getname (aosl_thrdid_t thrd, char *namebuf, size_t buflen); - -/** - * Get the mpq thread name. - * Parameters: - * thrd: the retrieving thread os kernel identifier - * Linux: the thread tid - * XNU: the mach thread id, type is mach_port_t - * Windows: the Windows kernel thread HANDLE, which must have - * THREAD_QUERY_INFORMATION access right - * running: the variable buf of the indicator which tells whether thread - * is in running state, specify NULL for not care - * system_us: the thread running time in kernel mode, micro seconds, - * NULL for not care - * user_us: the thread running time in user mode, micro seconds, - * NULL for not care - * Return Value: - * 0: success - * <0: failure with aosl_errno set - **/ -extern __aosl_api__ int aosl_get_thread_times (aosl_osthrd_t thrd, int *running, uint64_t *system_us, uint64_t *user_us); - -/** - * Get the mpq thread flags. - * Parameters: - * thrd: the retrieving thread id - * Linux: the thread tid - * XNU: the mach thread id, type is mach_port_t - * Windows: the Windows thread id, type is DWORD - * q_flags: the mpq flags - * Return Value: - * 0: success - * <0: failure with aosl_errno set - **/ -extern __aosl_api__ int aosl_thrd_getflags (aosl_thrdid_t thrd_id, int *q_flags); - -typedef uintptr_t aosl_tls_key_t; - -extern __aosl_api__ int aosl_tls_key_create (aosl_tls_key_t *key, void (*dtor) (void *)); -extern __aosl_api__ void *aosl_tls_key_get (aosl_tls_key_t key); -extern __aosl_api__ int aosl_tls_key_set (aosl_tls_key_t key, void *value); -extern __aosl_api__ int aosl_tls_key_delete (aosl_tls_key_t key); - - -typedef void *aosl_lock_t; - -extern __aosl_api__ aosl_lock_t aosl_lock_create (int recursive); -extern __aosl_api__ void aosl_lock_lock (aosl_lock_t lock); -extern __aosl_api__ int aosl_lock_trylock (aosl_lock_t lock); -extern __aosl_api__ void aosl_lock_unlock (aosl_lock_t lock); -extern __aosl_api__ void aosl_lock_destroy (aosl_lock_t lock); - - -typedef void *aosl_rwlock_t; - -extern __aosl_api__ aosl_rwlock_t aosl_rwlock_create (void); -extern __aosl_api__ void aosl_rwlock_rdlock (aosl_rwlock_t rwlock); -extern __aosl_api__ int aosl_rwlock_tryrdlock (aosl_rwlock_t rwlock); -extern __aosl_api__ void aosl_rwlock_wrlock (aosl_rwlock_t rwlock); -extern __aosl_api__ int aosl_rwlock_trywrlock (aosl_rwlock_t rwlock); -extern __aosl_api__ void aosl_rwlock_rdunlock (aosl_rwlock_t rwlock); -extern __aosl_api__ void aosl_rwlock_wrunlock (aosl_rwlock_t rwlock); -extern __aosl_api__ void aosl_rwlock_rd2wrlock (aosl_rwlock_t rwlock); -extern __aosl_api__ void aosl_rwlock_wr2rdlock (aosl_rwlock_t rwlock); -extern __aosl_api__ void aosl_rwlock_destroy (aosl_rwlock_t rwlock); - - -typedef void *aosl_cond_t; - -extern __aosl_api__ aosl_cond_t aosl_cond_create (void); -extern __aosl_api__ void aosl_cond_signal (aosl_cond_t cond_var); -extern __aosl_api__ void aosl_cond_broadcast (aosl_cond_t cond_var); -extern __aosl_api__ void aosl_cond_wait (aosl_cond_t cond_var, aosl_lock_t lock); -extern __aosl_api__ int aosl_cond_timedwait (aosl_cond_t cond_var, aosl_lock_t lock, intptr_t timeo); -extern __aosl_api__ void aosl_cond_destroy (aosl_cond_t cond_var); - -typedef void *aosl_event_t; - -extern __aosl_api__ aosl_event_t aosl_event_create (void); -extern __aosl_api__ void aosl_event_set (aosl_event_t event_var); -extern __aosl_api__ void aosl_event_pulse (aosl_event_t event_var); -extern __aosl_api__ void aosl_event_wait (aosl_event_t event_var); -extern __aosl_api__ int aosl_event_timedwait (aosl_event_t event_var, intptr_t timeo); -extern __aosl_api__ void aosl_event_reset (aosl_event_t event_var); -extern __aosl_api__ void aosl_event_destroy (aosl_event_t event_var); - - -#ifdef __cplusplus -} -#endif - -#endif /* __AOSL_THREAD_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_time.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_time.h deleted file mode 100644 index 8e1e216da..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_time.h +++ /dev/null @@ -1,79 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jul 26th, 2018 - * Module: Time relative utilities header file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_API_TIME_H__ -#define __AOSL_API_TIME_H__ - -#if defined (__linux__) || defined (__MACH__) || defined (__kliteos2__) || defined (_WIN32) -#include - -#if defined (__MACH__) -#include /* for definition of timeval */ -#endif - -#ifdef _WIN32 -/** - * For struct timeval definition. We MUST include - * 'winsock2.h' before any occurrence of including - * 'windows.h'. - **/ -#include -#include -#endif -#endif - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -extern __aosl_api__ aosl_ts_t aosl_tick_now (); -extern __aosl_api__ aosl_ts_t aosl_tick_us (); -extern __aosl_api__ aosl_ts_t aosl_tick_ns (); - -extern __aosl_api__ aosl_ts_t aosl_time_sec (); -extern __aosl_api__ aosl_ts_t aosl_time_ms (); -extern __aosl_api__ aosl_ts_t aosl_time_us (); - -extern __aosl_api__ aosl_ts_t aosl_start_tick_ns (); -extern __aosl_api__ aosl_ts_t aosl_start_tick_us (); -extern __aosl_api__ aosl_ts_t aosl_start_tick_ms (); - -extern __aosl_api__ aosl_ts_t aosl_start_time_us (); -extern __aosl_api__ aosl_ts_t aosl_start_time_ms (); -extern __aosl_api__ aosl_ts_t aosl_start_time_sec (); - -#if defined (__linux__) || defined (__MACH__) || defined (__kliteos2__) || defined (_WIN32) -extern __aosl_api__ aosl_ts_t aosl_ns_from_tv (const struct timeval *tv); -extern __aosl_api__ aosl_ts_t aosl_us_from_tv (const struct timeval *tv); -extern __aosl_api__ aosl_ts_t aosl_ms_from_tv (const struct timeval *tv); - -#ifndef _WIN32 -extern __aosl_api__ aosl_ts_t aosl_ns_from_ts (const struct timespec *ts); -extern __aosl_api__ aosl_ts_t aosl_us_from_ts (const struct timespec *ts); -extern __aosl_api__ aosl_ts_t aosl_ms_from_ts (const struct timespec *ts); -#endif -#endif - -extern __aosl_api__ void aosl_msleep (uint32_t ms); -extern __aosl_api__ void aosl_usleep (uint32_t us); - - -#ifdef __cplusplus -} -#endif - - -#endif /* __AOSL_API_TIME_H__ */ diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_types.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_types.h deleted file mode 100644 index 6afa42c98..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_types.h +++ /dev/null @@ -1,96 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jul 27th, 2020 - * Module: AOSL POSIX definitions header file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2020 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_TYPES_H__ -#define __AOSL_TYPES_H__ - -#include -#include -#include -#include -#if defined (__linux__) || defined (__MACH__) || defined (__kliteos2__) || defined (_WIN32) -#include -#endif - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -#if !defined (__linux__) && !defined (__MACH__) -/** - * Worry about some guy would like to define a macro - * for this type, so confirm that it is not a macro. - * -- Lionfore Hao Nov 5th, 2018 - **/ -#ifndef __ssize_t_defined -typedef intptr_t ssize_t; -#define __ssize_t_defined -#endif -#endif - - -/* The AOSL timestamp type */ -typedef unsigned long long aosl_ts_t; - -/* The proto for a general aosl var args function with argc & argv. */ -typedef void (*aosl_argv_f) (uintptr_t argc, uintptr_t argv []); - -/* The proto for a general aosl object destructor function. */ -typedef aosl_argv_f aosl_obj_dtor_t; - - -#if !defined (_WIN32) && !defined (__kspreadtrum__) -typedef int aosl_fd_t; -#define AOSL_INVALID_FD ((aosl_fd_t)-1) - -static __inline__ int aosl_fd_invalid (aosl_fd_t fd) -{ - return (int)(fd < 0); -} -#else -#if defined (_WIN32) -/** - * We MUST include 'winsock2.h' before any occurrence - * of including 'windows.h', the fucking Windows has - * the fucking issue that many definitions would be - * complained redefinition if not so. - * -- Lionfore Hao Sep 25th, 2018 - **/ -#include -#include - -typedef HANDLE aosl_fd_t; -#define AOSL_INVALID_FD ((aosl_fd_t)INVALID_HANDLE_VALUE) -#elif defined (__kspreadtrum__) -#include -#include - -typedef TCPIP_SOCKET_T aosl_fd_t; -#define AOSL_INVALID_FD ((aosl_fd_t)-1) -#endif - -static __inline__ int aosl_fd_invalid (aosl_fd_t fd) -{ - return (int)(fd == AOSL_INVALID_FD); -} -#endif - - -#ifdef __cplusplus -} -#endif - - -#endif /* __AOSL_TYPES_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_utils.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_utils.h deleted file mode 100644 index 8916f2361..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_utils.h +++ /dev/null @@ -1,45 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jul 26th, 2018 - * Module: AOSL utilities definition file. - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_UTILS_H__ -#define __AOSL_UTILS_H__ - -#include -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - -extern __aosl_api__ int aosl_get_uuid (char buf [], size_t buf_sz); -extern __aosl_api__ int aosl_os_version (char buf [], size_t buf_sz); - -/* The returned path must be freed via aosl_free when not used any more */ -extern __aosl_api__ const char *aosl_get_data_path (); - -extern __aosl_api__ int aosl_processors_count (void); - -extern __aosl_api__ void *aosl_platform_obj_get (void *o); -extern __aosl_api__ void aosl_platform_obj_put (void *o); - -extern __aosl_api__ const char *aosl_addr_syminfo (uintptr_t addr, uintptr_t *sym_addr); - - -#ifdef __cplusplus -} -#endif - - -#endif /* __AOSL_UTILS_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_value.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_value.h deleted file mode 100644 index 2f0fde345..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_value.h +++ /dev/null @@ -1,518 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Nov 26th, 2022 - * Module: AOSL value object API definition file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 ~ 2022 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_VALUE_H__ -#define __AOSL_VALUE_H__ - - -#include -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - - -typedef enum { - aosl_value_type_none, - aosl_value_type_int8, - aosl_value_type_int16, - aosl_value_type_int32, - aosl_value_type_int64, - aosl_value_type_intptr, - aosl_value_type_pointer, - aosl_value_type_float, - aosl_value_type_double, - aosl_value_type_string, - aosl_value_type_data, -} aosl_value_type_t; - -typedef struct { - aosl_value_type_t type; - uint32_t weight; /* the current weight of the value */ - union { - int8_t i1_val; - int16_t i2_val; - int32_t i4_val; - int64_t i8_val; - intptr_t ip_val; - double f_val; - void *p_val; - struct { - uint32_t m_alloc; - uint32_t d_len; - void *p_data; - }; - }; -} aosl_value_t; - -typedef struct { - aosl_value_t value; - intptr_t copied; /* <0: error; 0: no change; >0: value changed */ -} aosl_kobj_value_notify_t; - -extern __aosl_api__ void aosl_value_init (aosl_value_t *val); -extern __aosl_api__ int aosl_value_compare (const aosl_value_t *v1, const aosl_value_t *v2); -extern __aosl_api__ ssize_t aosl_value_copy (aosl_value_t *dst, const aosl_value_t *src); -extern __aosl_api__ ssize_t aosl_value_copy_to (void *buf, size_t len, const aosl_value_t *val); -extern __aosl_api__ ssize_t aosl_value_copy_from (aosl_value_t *val, const void *buf, size_t len); -extern __aosl_api__ void aosl_value_free (aosl_value_t *val); - -/** - * Set the value to the value object specified by dfd + name. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * val: the value to be set to the value object; - * Return value: - * >0: set the value successfully; - * =0: the value not changed due to identical; - * <0: failed with aosl_errno set accordingly; - **/ -extern __aosl_api__ ssize_t aosl_value_set (aosl_kfd_t dfd, const char *name, const aosl_value_t *val); - -/** - * Set int8 value to the value object specified by dfd + name. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * weight: the setting weight, it must greater than or equal to the weight - * of the value object, otherwise the setting operation would fail; - * v: the value; - * Return value: - * >0: set the value successfully; - * =0: the value not changed due to identical; - * <0: failed with aosl_errno set accordingly; - **/ -extern __aosl_api__ ssize_t aosl_value_set_int8 (aosl_kfd_t dfd, const char *name, uint32_t weight, int8_t v); - -/** - * Set int16 value to the value object specified by dfd + name. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * weight: the setting weight, it must greater than or equal to the weight - * of the value object, otherwise the setting operation would fail; - * v: the value; - * Return value: - * >0: set the value successfully; - * =0: the value not changed due to identical; - * <0: failed with aosl_errno set accordingly; - **/ -extern __aosl_api__ ssize_t aosl_value_set_int16 (aosl_kfd_t dfd, const char *name, uint32_t weight, int16_t v); - -/** - * Set int32 value to the value object specified by dfd + name. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * weight: the setting weight, it must greater than or equal to the weight - * of the value object, otherwise the setting operation would fail; - * v: the value; - * Return value: - * >0: set the value successfully; - * =0: the value not changed due to identical; - * <0: failed with aosl_errno set accordingly; - **/ -extern __aosl_api__ ssize_t aosl_value_set_int32 (aosl_kfd_t dfd, const char *name, uint32_t weight, int32_t v); - -/** - * Set int64 value to the value object specified by dfd + name. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * weight: the setting weight, it must greater than or equal to the weight - * of the value object, otherwise the setting operation would fail; - * v: the value; - * Return value: - * >0: set the value successfully; - * =0: the value not changed due to identical; - * <0: failed with aosl_errno set accordingly; - **/ -extern __aosl_api__ ssize_t aosl_value_set_int64 (aosl_kfd_t dfd, const char *name, uint32_t weight, int64_t v); - -/** - * Set intptr value to the value object specified by dfd + name. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * weight: the setting weight, it must greater than or equal to the weight - * of the value object, otherwise the setting operation would fail; - * v: the value; - * Return value: - * >0: set the value successfully; - * =0: the value not changed due to identical; - * <0: failed with aosl_errno set accordingly; - **/ -extern __aosl_api__ ssize_t aosl_value_set_intptr (aosl_kfd_t dfd, const char *name, uint32_t weight, intptr_t v); - -/** - * Set pointer value to the value object specified by dfd + name. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * weight: the setting weight, it must greater than or equal to the weight - * of the value object, otherwise the setting operation would fail; - * v: the value; - * Return value: - * >0: set the value successfully; - * =0: the value not changed due to identical; - * <0: failed with aosl_errno set accordingly; - **/ -extern __aosl_api__ ssize_t aosl_value_set_pointer (aosl_kfd_t dfd, const char *name, uint32_t weight, void *v); - -/** - * Set float value to the value object specified by dfd + name. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * weight: the setting weight, it must greater than or equal to the weight - * of the value object, otherwise the setting operation would fail; - * v: the value; - * Return value: - * >0: set the value successfully; - * =0: the value not changed due to identical; - * <0: failed with aosl_errno set accordingly; - **/ -extern __aosl_api__ ssize_t aosl_value_set_float (aosl_kfd_t dfd, const char *name, uint32_t weight, float v); - -/** - * Set double value to the value object specified by dfd + name. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * weight: the setting weight, it must greater than or equal to the weight - * of the value object, otherwise the setting operation would fail; - * v: the value; - * Return value: - * >0: set the value successfully; - * =0: the value not changed due to identical; - * <0: failed with aosl_errno set accordingly; - **/ -extern __aosl_api__ ssize_t aosl_value_set_double (aosl_kfd_t dfd, const char *name, uint32_t weight, double v); - -/** - * Set string value to the value object specified by dfd + name. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * weight: the setting weight, it must greater than or equal to the weight - * of the value object, otherwise the setting operation would fail; - * str: the string value, must be '\0' terminated; - * Return value: - * >0: set the value successfully; - * =0: the value not changed due to identical; - * <0: failed with aosl_errno set accordingly; - **/ -extern __aosl_api__ ssize_t aosl_value_set_string (aosl_kfd_t dfd, const char *name, uint32_t weight, const char *str); - -/** - * Set data buffer value to the value object specified by dfd + name. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * weight: the setting weight, it must greater than or equal to the weight - * of the value object, otherwise the setting operation would fail; - * buf: the value memory; - * len: the memory size in bytes; - * Return value: - * >0: set the value successfully; - * =0: the value not changed due to identical; - * <0: failed with aosl_errno set accordingly; - **/ -extern __aosl_api__ ssize_t aosl_value_set_data (aosl_kfd_t dfd, const char *name, uint32_t weight, const void *buf, size_t len); - -/** - * Get the value from the value object specified by dfd + name. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * val: the memory address for holding the value; - * Return value: - * >0: set the value successfully; - * =0: the value not changed due to identical; - * <0: failed with aosl_errno set accordingly; - **/ -extern __aosl_api__ ssize_t aosl_value_get (aosl_kfd_t dfd, const char *name, aosl_value_t *val); - -/** - * Get int8 value from the value object specified by dfd + name. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * v: the memory address for holding the value; - * Return value: - * >0: set the value successfully; - * =0: the value not changed due to identical; - * <0: failed with aosl_errno set accordingly; - **/ -extern __aosl_api__ ssize_t aosl_value_get_int8 (aosl_kfd_t dfd, const char *name, int8_t *v); - -/** - * Get int16 value from the value object specified by dfd + name. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * v: the memory address for holding the value; - * Return value: - * >0: set the value successfully; - * =0: the value not changed due to identical; - * <0: failed with aosl_errno set accordingly; - **/ -extern __aosl_api__ ssize_t aosl_value_get_int16 (aosl_kfd_t dfd, const char *name, int16_t *v); - -/** - * Get int32 value from the value object specified by dfd + name. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * v: the memory address for holding the value; - * Return value: - * >0: set the value successfully; - * =0: the value not changed due to identical; - * <0: failed with aosl_errno set accordingly; - **/ -extern __aosl_api__ ssize_t aosl_value_get_int32 (aosl_kfd_t dfd, const char *name, int32_t *v); - -/** - * Get int64 value from the value object specified by dfd + name. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * v: the memory address for holding the value; - * Return value: - * >0: set the value successfully; - * =0: the value not changed due to identical; - * <0: failed with aosl_errno set accordingly; - **/ -extern __aosl_api__ ssize_t aosl_value_get_int64 (aosl_kfd_t dfd, const char *name, int64_t *v); - -/** - * Get intptr value from the value object specified by dfd + name. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * v: the memory address for holding the value; - * Return value: - * >0: set the value successfully; - * =0: the value not changed due to identical; - * <0: failed with aosl_errno set accordingly; - **/ -extern __aosl_api__ ssize_t aosl_value_get_intptr (aosl_kfd_t dfd, const char *name, intptr_t *v); - -/** - * Get pointer value from the value object specified by dfd + name. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * v: the memory address for holding the value; - * Return value: - * >0: set the value successfully; - * =0: the value not changed due to identical; - * <0: failed with aosl_errno set accordingly; - **/ -extern __aosl_api__ ssize_t aosl_value_get_pointer (aosl_kfd_t dfd, const char *name, void **v); - -/** - * Get float value from the value object specified by dfd + name. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * v: the memory address for holding the value; - * Return value: - * >0: set the value successfully; - * =0: the value not changed due to identical; - * <0: failed with aosl_errno set accordingly; - **/ -extern __aosl_api__ ssize_t aosl_value_get_float (aosl_kfd_t dfd, const char *name, float *v); - -/** - * Get double value from the value object specified by dfd + name. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * v: the memory address for holding the value; - * Return value: - * >0: set the value successfully; - * =0: the value not changed due to identical; - * <0: failed with aosl_errno set accordingly; - **/ -extern __aosl_api__ ssize_t aosl_value_get_double (aosl_kfd_t dfd, const char *name, double *v); - -/** - * Get string value from the value object specified by dfd + name. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * str: the memory address for holding the value; - * len: the memory size in bytes; - * Return value: - * >0: set the value successfully; - * =0: the value not changed due to identical; - * <0: failed with aosl_errno set accordingly; - **/ -extern __aosl_api__ ssize_t aosl_value_get_string (aosl_kfd_t dfd, const char *name, char *str, size_t len); - -/** - * Get data buffer value from the value object specified by dfd + name. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * buf: the memory address for holding the value; - * len: the memory size in bytes; - * Return value: - * >0: set the value successfully; - * =0: the value not changed due to identical; - * <0: failed with aosl_errno set accordingly; - **/ -extern __aosl_api__ ssize_t aosl_value_get_data (aosl_kfd_t dfd, const char *name, void *buf, size_t len); - - -/** - * A registered callback function for verifying a setting value, if returns 0, then the value would - * NOT be set at all, return non-zero if the value is OK for setting. - * Parameters: - * val: the setting value to be verified; - * argc: the various args count, passed when registering; - * argv: the various args vector, passed as various args when registering; - * Return value: - * The return value is a 'boolean' really, so - * 0: the verifying failed, to value would NOT be set at all; - * non-zero: the value is OK for setting; - **/ -typedef int (*aosl_value_verify_t) (const aosl_value_t *val, uintptr_t argc, uintptr_t argv []); -typedef void (*aosl_value_verify_dtor_t) (uintptr_t argc, uintptr_t argv []); - -/** - * Register a verification callback for a value specified by dfd + name. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * f: the target callback function; - * dtor: destructor which be invoked when unregister the notification; - * argc: the various args count; - * ...: the various args; - * Return value: - * non-NULL: successfully; - * NULL: failed with aosl_errno set accordingly. - * The return value only used for unregister, no other usage. - **/ -extern __aosl_api__ void *aosl_value_verify_register (aosl_kfd_t dfd, const char *name, aosl_value_verify_t f, aosl_value_verify_dtor_t dtor, uintptr_t argc, ...); - -/** - * Register a verification callback for a value specified by dfd + name. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * f: the target callback function; - * dtor: destructor which be invoked when unregister the notification; - * argc: the various args count; - * args: the various args; - * Return value: - * non-NULL: successfully; - * NULL: failed with aosl_errno set accordingly. - * The return value only used for unregister, no other usage. - **/ -extern __aosl_api__ void *aosl_value_verify_register_args (aosl_kfd_t dfd, const char *name, aosl_value_verify_t f, aosl_value_verify_dtor_t dtor, uintptr_t argc, va_list args); - -/** - * Register a verification callback for a value specified by dfd + name. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * f: the target callback function; - * dtor: destructor which be invoked when unregister the notification; - * argc: the various args count; - * argv: the various args vector; - * Return value: - * non-NULL: successfully; - * NULL: failed with aosl_errno set accordingly. - * The return value only used for unregister, no other usage. - **/ -extern __aosl_api__ void *aosl_value_verify_register_argv (aosl_kfd_t dfd, const char *name, aosl_value_verify_t f, aosl_value_verify_dtor_t dtor, uintptr_t argc, uintptr_t argv []); - -/** - * Unregister a verification callback for a value specified by dfd + name. - * Parameters: - * dfd: the opened fd of directory, AOSL_KFD_INVALID for root or pwd: - * 1. if the name starts with a '/', then directory is root; - * 2. if the name does not start with a '/', then directory is pwd; - * name: the directory name; - * handle: the handle returned by above register functions; - * Return value: - * 0: successfully; - * <0: failed with aosl_errno set accordingly. - **/ -extern __aosl_api__ int aosl_value_verify_unregister (aosl_kfd_t dfd, const char *name, void *handle); - - - -#ifdef __cplusplus -} -#endif - - - -#endif /* __AOSL_VALUE_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_vcodec.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_vcodec.h deleted file mode 100644 index 921ba7b37..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_vcodec.h +++ /dev/null @@ -1,144 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Mar 2nd, 2023 - * Module: AOSL video codec relative API definition file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 ~ 2023 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_VIDEO_CODEC_H__ -#define __AOSL_VIDEO_CODEC_H__ - - -#include -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - -typedef struct { - int bit_rate_scale; - int cpb_size_scale; - int initial_cpb_removal_delay_length; - int cpb_removal_delay_length; - int dpb_output_delay_length; - int bit_rate_value; - int cpb_size_value; - int cbr_flag; -} aosl_hrd_params_t; - -typedef struct { - /* --- sample aspect ratio (SAR) --- */ - unsigned char aspect_ratio_info_present_flag; - unsigned char aspect_ratio_idc; - unsigned short sar_width; /* sar_width and sar_height are zero if unspecified */ - unsigned short sar_height; - - /* --- overscan --- */ - unsigned char overscan_info_present_flag; - unsigned char overscan_appropriate_flag; - - /* --- video signal type --- */ - unsigned char video_signal_type_present_flag; - unsigned char video_format; - unsigned char video_full_range_flag; - unsigned char colour_description_present_flag; - unsigned char colour_primaries; - unsigned char transfer_characteristics; - unsigned char matrix_coeffs; - - /* --- chroma / interlaced --- */ - unsigned char chroma_loc_info_present_flag; - unsigned char chroma_sample_loc_type_top_field; - unsigned char chroma_sample_loc_type_bottom_field; - unsigned char neutral_chroma_indication_flag; - unsigned char field_seq_flag; - unsigned char frame_field_info_present_flag; - - /* --- default display window --- */ - unsigned char default_display_window_flag; - unsigned int def_disp_win_left_offset; - unsigned int def_disp_win_right_offset; - unsigned int def_disp_win_top_offset; - unsigned int def_disp_win_bottom_offset; - - /* --- timing --- */ - unsigned char vui_timing_info_present_flag; - unsigned int vui_num_units_in_tick; - unsigned int vui_time_scale; - - unsigned char vui_poc_proportional_to_timing_flag; - unsigned int vui_num_ticks_poc_diff_one; - - /* --- hrd parameters --- */ - unsigned char vui_hrd_parameters_present_flag; - aosl_hrd_params_t vui_hrd_parameters; - - /* --- bitstream restriction --- */ - unsigned char bitstream_restriction_flag; - unsigned char tiles_fixed_structure_flag; - unsigned char motion_vectors_over_pic_boundaries_flag; - unsigned char restricted_ref_pic_lists_flag; - unsigned short min_spatial_segmentation_idc; - unsigned char max_bytes_per_pic_denom; - unsigned char max_bits_per_mincu_denom; - unsigned char log2_max_mv_length_horizontal; - unsigned char log2_max_mv_length_vertical; -} aosl_vui_params_t; - -typedef enum { - EXTC_OK = (0x00000000), // Success codes - EXTC_FAIL = (0x80000001), // Unspecified error - - EXTC_OUTOFMEMORY = (0x80000002), // Out of memory - EXTC_POINTER = (0x80000003), // Invalid pointer - EXTC_NOTSUPPORTED = (0x80000004), // NOT support feature encountered - EXTC_NO_INSTANCE = (0x80000005), - - EXTC_NEED_MORE_DATA = (0x90000001), // need push more data -} aosl_extc_code_t; - -typedef enum { - VIDEO_CODEC_H264 = 0, - VIDEO_CODEC_HEVC, -} aosl_vcodec_type_t; - -typedef struct { - aosl_vcodec_type_t codec; - int isEncoder; - int isHardware; - int maxInstances; - int maxDealyFrames; - - int maxWidth; - int maxHeight; - int minWidth; - int minHeight; - int alignment; -} aosl_vcodec_cap_t; - -typedef struct { - int size; - char* name; - aosl_vcodec_cap_t *caps; -} aosl_vcodec_info_t; - -extern aosl_vcodec_info_t *agora_partener_get_codec_info (void); - - - -#ifdef __cplusplus -} -#endif - - - -#endif /* __AOSL_VIDEO_CODEC_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_version.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_version.h deleted file mode 100644 index 11d286a57..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_version.h +++ /dev/null @@ -1,34 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jul 26th, 2018 - * Module: AOSL version definitions. - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 Agora IO - * All rights reserved. - * - ************************************************************/ - -#ifndef __AOSL_VERSION_H__ -#define __AOSL_VERSION_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - - -extern __aosl_api__ const char *aosl_get_git_branch (); -extern __aosl_api__ const char *aosl_get_git_commit (); - - - -#ifdef __cplusplus -} -#endif - - -#endif /* __AOSL_VERSION_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_video.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_video.h deleted file mode 100644 index 90479b604..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_video.h +++ /dev/null @@ -1,245 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jan 26th, 2023 - * Module: AOSL video relative API definition file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 ~ 2023 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_VIDEO_H__ -#define __AOSL_VIDEO_H__ - - -#include -#include -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - - -typedef aosl_data_t aosl_vbuf_t; - -typedef void (*aosl_vbuf_cb_t) (int dev, aosl_vbuf_t vbuf, void *arg); -typedef void (*aosl_vbuf_ev_t) (int dev, int event, void *arg); - -/* aosl_kobj_ioctl (vfd, AOSL_IOCS_VIDEO_CAP_START, 4, , , , ); */ -#define AOSL_IOCS_VIDEO_CAP_START 1 - -/* aosl_kobj_ioctl (vfd, AOSL_IOCS_VIDEO_CAP_STOP, 0); */ -#define AOSL_IOCS_VIDEO_CAP_STOP 2 - - -typedef enum { - AOSL_PIXFMT_UNKNOWN = -1, - - /* one plane interleaved 3 bytes */ - AOSL_PIXFMT_RGB24 = 0, /* 24 RGB-8-8-8 */ - AOSL_PIXFMT_BGR24, /* 24 BGR-8-8-8 */ - AOSL_PIXFMT_RGB32, /* 32 RGB-8-8-8-8 */ - AOSL_PIXFMT_BGR32, /* 32 BGR-8-8-8-8 */ - - /* one plane interleaved 4 bytes */ - AOSL_PIXFMT_YUYV, - AOSL_PIXFMT_YYUV, - AOSL_PIXFMT_YVYU, - AOSL_PIXFMT_UYVY, - AOSL_PIXFMT_VYUY, - - /* two planes: one Y, one Cb+Cr interleaved */ - AOSL_PIXFMT_NV12, /* 12 Y/CbCr 4:2:0 */ - AOSL_PIXFMT_NV21, /* 12 Y/CrCb 4:2:0 */ - AOSL_PIXFMT_NV16, /* 16 Y/CbCr 4:2:2 */ - AOSL_PIXFMT_NV61, /* 16 Y/CrCb 4:2:2 */ - - /* three planes: one for each */ - AOSL_PIXFMT_YUV420, /* 12 YUV 4:2:0 */ - AOSL_PIXFMT_YUV422, /* 16 YUV 4:2:2 */ - - AOSL_PIXFMT_HWSURF, /* Hardware surface */ -} aosl_pixfmt_t; - -typedef enum { - aosl_vbuf_type_dma, - aosl_vbuf_type_win, - aosl_vbuf_type_cpu, -} aosl_vbuf_type_t; - - -/** - * Get the image width of a video buffer object. - * Parameters: - * vbuf: the video buffer object; - * Return value: - * >=0: one of aosl_vbuf_type_t value; - * <0: failed with aosl_errno set; - **/ -extern __aosl_api__ int aosl_vbuf_type (aosl_vbuf_t vbuf); - -/** - * Get the image width of a video buffer object. - * Parameters: - * vbuf: the video buffer object; - * Return value: - * the video image width; - **/ -extern __aosl_api__ int aosl_vbuf_width (aosl_vbuf_t vbuf); - -/** - * Get the image height of a video buffer object. - * Parameters: - * vbuf: the video buffer object; - * Return value: - * the video image height; - **/ -extern __aosl_api__ int aosl_vbuf_height (aosl_vbuf_t vbuf); - -/** - * Get the video data timestamp in microseconds of a video buffer object. - * Parameters: - * vbuf: the video buffer object; - * Return value: - * the video data timestamp in microseconds; - **/ -extern __aosl_api__ aosl_ts_t aosl_vbuf_us (aosl_vbuf_t vbuf); - -/** - * Get the video data format of a video buffer object. - * Parameters: - * vbuf: the video buffer object; - * Return value: - * the video data pixel format; - **/ -extern __aosl_api__ aosl_pixfmt_t aosl_vbuf_pixfmt (aosl_vbuf_t vbuf); - -/** - * normalized rect: range 0.0 ~ 1.0 for each direction - * (0.0, 0.0) <=> (left, bottom) - * (1.0, 1.0) <=> (width, height) - **/ -typedef struct { - double left; - double bottom; - double width; - double height; -} aosl_nmrect_t; - -/** - * Render the video buffer on the specified surface. - * Parameters: - * surface: the surface rendering on - * 1. Unix X11: a Window id; - * 2. MacOSX: an NSWindow pointer; - * 3. Windows: an HWND handle; - * 4. Linux Wayland: ? - * 5. iOS: a UIView pointer; - * 6. Android: an ANativeWindow pointer; - * vbuf: the video buffer object; - * rect: specified the rendering rect on the surface. - * NULL for whole surface area. - * clip: bool value: 1 for clip; 0 for not clip; - * Return value: - * 0: sucessfully; - * <0: failed with aosl_errno set; - **/ -extern __aosl_api__ int aosl_surface_render (void *surface, aosl_vbuf_t vbuf, const aosl_nmrect_t *rect, int clip); - -/** - * Lock the the specified surface for video rendering. - * Parameters: - * surface: the surface rendering on - * 1. Unix X11: a Window id; - * 2. MacOSX: an NSWindow pointer; - * 3. Windows: an HWND handle; - * 4. Linux Wayland: ? - * 5. iOS: a UIView pointer; - * 6. Android: an ANativeWindow pointer; - * Return value: - * 0: sucessfully; - * <0: failed with aosl_errno set; - **/ -extern __aosl_api__ int aosl_surface_lock (void *surface); - -/** - * Unlock the the specified surface for video rendering. - * Parameters: - * surface: the surface rendering on - * 1. Unix X11: a Window id; - * 2. MacOSX: an NSWindow pointer; - * 3. Windows: an HWND handle; - * 4. Linux Wayland: ? - * 5. iOS: a UIView pointer; - * 6. Android: an ANativeWindow pointer; - * Return value: - * 0: sucessfully; - * <0: failed with aosl_errno set; - **/ -extern __aosl_api__ int aosl_surface_unlock (void *surface); - -/** - * Cleanup the rendering resources on the specified surface. - * Parameters: - * surface: the surface rendering on - * 1. Unix X11: a Window id; - * 2. MacOSX: an NSWindow pointer; - * 3. Windows: an HWND handle; - * 4. Linux Wayland: ? - * 5. iOS: a UIView pointer; - * 6. Android: an ANativeWindow pointer; - * Return value: - * 0: sucessfully; - * <0: failed with aosl_errno set; - **/ -extern __aosl_api__ int aosl_surface_cleanup (void *surface); - -/** - * Set the arg for the specified surface. - * Parameters: - * surface: the surface rendering on - * 1. Unix X11: a Window id; - * 2. MacOSX: an NSWindow pointer; - * 3. Windows: an HWND handle; - * 4. Linux Wayland: ? - * 5. iOS: a UIView pointer; - * 6. Android: an ANativeWindow pointer; - * arg: the arg to be set for the surface; - * Return value: - * 0: sucessfully; - * <0: failed with aosl_errno set; - **/ -extern __aosl_api__ int aosl_surface_arg_set (void *surface, void *arg); - -/** - * Get the arg for the specified surface. - * Parameters: - * surface: the surface rendering on - * 1. Unix X11: a Window id; - * 2. MacOSX: an NSWindow pointer; - * 3. Windows: an HWND handle; - * 4. Linux Wayland: ? - * 5. iOS: a UIView pointer; - * 6. Android: an ANativeWindow pointer; - * arg_p: the memory address for saving the arg of the surface; - * Return value: - * 0: sucessfully; - * <0: failed with aosl_errno set; - **/ -extern __aosl_api__ int aosl_surface_arg_get (void *surface, void **arg_p); - - - -#ifdef __cplusplus -} -#endif - - - -#endif /* __AOSL_VIDEO_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_xdump.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_xdump.h deleted file mode 100644 index 7aa932755..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/aosl_xdump.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef __AOSL_XDUMP_H__ -#define __AOSL_XDUMP_H__ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -/** - * xdump callback info about crash: - * @module_ver: the module version - * @module_name: the module name - * @log_file: the full path of log_file - * @type: the dump type: - * 0: crash - * 1: dead loop/dead lock/ANR - * @crash_at: virtual address where the crash happen - * @ld_begin/ld_end: DSO will be loaded on [ld_begin, ld_end) - **/ -#define AOSL_XDUMP_CRASH 0 -#define AOSL_XDUMP_DEAD 1 -typedef struct { - uintptr_t module_ver; - const char *module_name; - const char *log_file; - int type; - void *crash_at; - void *ld_begin; - void *ld_end; - int q_flags; -} xdump_info_t; -typedef void (*xdump_cb_t)(const xdump_info_t *log_file); - -extern __aosl_api__ int aosl_xdump_attach(const char *log_dir, xdump_cb_t cb); -extern __aosl_api__ int aosl_xdump_detach(); - -#ifdef __cplusplus -} -#endif - -#endif /* __AOSL_XDUMP_H__ */ diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/Makefile b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/Makefile deleted file mode 100644 index 14376d9c2..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -header-y += aosl_input_class.h -header-y += aosl_file_class.h -header-y += aosl_mpq_fd_class.h -header-y += aosl_mpq_sk_lambda.h -header-y += aosl_mpq_timer_lambda.h -header-y += aosl_ref_class.h -header-y += aosl_task_class.h -header-y += aosl_thread_class.h -header-y += aosl_kobj_class.h -header-y += aosl_value_class.h -header-y += aosl_data_class.h -header-y += aosl_ares_class.h -header-y += aosl_poll_class.h -header-y += aosl_async_class.h diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_ares_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_ares_class.h deleted file mode 100644 index 634096300..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_ares_class.h +++ /dev/null @@ -1,91 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jun 23rd, 2023 - * Module: AOSL async result object for C++ definition file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 ~ 2023 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_ARES_CLASS_H__ -#define __AOSL_ARES_CLASS_H__ - - -#include - -#include -#include -#include -#include -#include - - -class aosl_ares_class: public aosl_ref_class { -public: - aosl_ares_class (): aosl_ref_class (aosl_ares_create (this)) - { - if (aosl_ref_invalid (ref ())) - abort (); - } - - /** - * The destructor of this class is very different with - * base class and other derivatives, destroy the ref - * in the destructor and the destructor is public. - **/ - virtual ~aosl_ares_class () - { - aosl_ref_t refid = ref (); - if (!aosl_ref_invalid (refid)) - aosl_ref_destroy (refid, true); - } - - /* complete the async result */ - int complete (intptr_t result = 0) - { - return aosl_ares_complete (ref (), result); - } - - /* wait the async result to be completed */ - int wait (intptr_t timeo, intptr_t *result = NULL) - { - return aosl_ares_wait (ref (), timeo, result); - } - - /* reset the signaled state */ - int reset (void) - { - return aosl_ares_reset (ref ()); - } - - operator aosl_ref_t () const - { - return ref (); - } - -private: - /* we do not allow invoke the destroy function of base class */ - int destroy (bool do_delete = true) - { - abort (); - return 0; - } - -#if (__cplusplus >= 201103) || defined (_MSC_VER) -private: - aosl_ares_class (const aosl_ares_class &) = delete; - aosl_ares_class (aosl_ares_class &&) = delete; - aosl_ares_class &operator = (const aosl_ares_class &) = delete; - aosl_ares_class &operator = (aosl_ares_class &&) = delete; -#else -private: - aosl_ares_class (const aosl_ares_class &); - aosl_ares_class &operator = (const aosl_ares_class &); -#endif /* C++11 */ -}; - - -#endif /* __AOSL_ARES_CLASS_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_async_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_async_class.h deleted file mode 100644 index ebec83f23..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_async_class.h +++ /dev/null @@ -1,129 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Aug 15th, 2023 - * Module: AOSL async class for C++11 definition file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 ~ 2023 Agora IO - * All rights reserved. - * - *************************************************************/ - -#if (__cplusplus >= 201103) || defined (_MSC_VER) - -#ifndef __AOSL_ASYNC_CPP_H__ -#define __AOSL_ASYNC_CPP_H__ - - -#include -#include - -#include -#include - -class aosl_async_class { -public: - typedef std::function aosl_async_block_lambda_f; - - static int block (aosl_async_block_lambda_f&& task) - { - aosl_async_block_lambda_f block_f (std::move (task)); - return aosl_async_block (____block_f, 1, &block_f); - } - -private: - static void ____block_f (uintptr_t argc, uintptr_t argv []) - { - aosl_async_block_lambda_f *block_f = reinterpret_cast(argv [0]); - (*block_f) (); - } - -#if (__cplusplus >= 201103) || defined (_MSC_VER) -private: - aosl_async_class () = delete; - aosl_async_class (const aosl_async_class &) = delete; - aosl_async_class (aosl_async_class &&) = delete; - aosl_async_class &operator = (const aosl_async_class &) = delete; - aosl_async_class &operator = (aosl_async_class &&) = delete; - ~aosl_async_class () = delete; -#else -private: - aosl_async_class (); - aosl_async_class (const aosl_async_class &); - aosl_async_class &operator = (const aosl_async_class &); - ~aosl_async_class (); -#endif - -}; - -/** - * Helper async macro for single line code, example: - * __aosl_async__ (some_func ()); - **/ -#define __aosl_async__(_x_y__) { aosl_async_class::block ([&] { _x_y__; }); } - -/** - * Helper async macros for multiple lines code, example: - * - * __aosl_async_begin__ - * // Add your own multiple lines code here: - * aosl_define_stack (stack); - * - * task->async ("", [=] { - * ...... - * }); - * - * aosl_ref_class::resume (stack, AOSL_REF_INVALID, "", [=](int free_only) { - * ...... - * }); - * __aosl_async_end__ - * - **/ -#define __aosl_async_begin__ { aosl_async_class::block ([&] { -#define __aosl_async_end__ }); } - -/** - * Helper async macros for implementing a function with return value, example: - * - * __aosl_async_func_def__ (, , func_name (func args)) - * { - * - * } - * __aosl_async_func_end__ () - * - **/ -#define __aosl_async_func_def__(_ret_type_, _ret_var_, _fn_and_args_) \ -_ret_type_ _fn_and_args_ \ -{ \ - _ret_type_ _ret_var_; \ - aosl_async_class::block ([&] - -#define __aosl_async_func_end__(_ret_var_) \ - ); \ - return _ret_var_; \ -} - -/** - * Helper async macros for implementing a void function, example: - * - * __aosl_async_func_def_void__ (func_name (func args)) - * { - * - * } - * __aosl_async_func_end_void__ () - * - **/ -#define __aosl_async_func_def_void__(_fn_) \ -void _fn_ \ -{ \ - aosl_async_class::block ([&] - -#define __aosl_async_func_end_void__() \ - ); \ -} - - -#endif /* __AOSL_ASYNC_CPP_H__ */ - -#endif /* C++11 */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_data_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_data_class.h deleted file mode 100644 index edf9b265a..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_data_class.h +++ /dev/null @@ -1,486 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Sep 4th, 2023 - * Module: AOSL common data for C++ definition file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 ~ 2023 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_DATA_CLASS_H__ -#define __AOSL_DATA_CLASS_H__ - - -#include -#include - -#include -#include -#include - - -class aosl_data_class { -protected: - aosl_data_t d; - -public: - aosl_data_class (void) - { - d = NULL; - } - - aosl_data_class (const aosl_data_class &src) - { - if (this != &src) { - d = src.d; - if (d != NULL) - aosl_data_get (d); - } - } - - aosl_data_class &operator = (const aosl_data_class &src) - { - if (this != &src) { - if (d != NULL) - aosl_data_put (d); - - d = src.d; - if (d != NULL) - aosl_data_get (d); - } - - return *this; - } - - operator aosl_data_t () const - { - return d; - } - - void *ptr () const - { - if (d != NULL) - return aosl_data_ptr_get (d); - - return NULL; - } - - size_t len () const - { - if (d != NULL) - return aosl_data_len (d); - - return 0; - } - - ~aosl_data_class () - { - if (d != NULL) - aosl_data_put (d); - } - -#if (__cplusplus >= 201103) || defined (_MSC_VER) - aosl_data_class (aosl_data_class &&src) - { - if (this != &src) { - d = src.d; - src.d = NULL; - } - } - - aosl_data_class &operator = (aosl_data_class &&src) - { - if (this != &src) { - if (d != NULL) - aosl_data_put (d); - - d = src.d; - src.d = NULL; - } - - return *this; - } -#endif /* C++11 */ -}; - -class aosl_data_buf: public aosl_data_class { -public: - aosl_data_buf (void) - { - } - - aosl_data_buf (size_t sz) - { - d = aosl_data_create (sz, NULL); - if (d == NULL) - abort (); - } - - aosl_data_buf (const void *src, size_t len) - { - d = aosl_data_create (len, NULL); - if (d == NULL) - abort (); - - if (len > 0) - memcpy (ptr (), src, len); - } - - aosl_data_buf (void *ptr, size_t len, aosl_data_user_free_t dtor) - { - d = aosl_data_user_create (ptr, len, dtor); - if (d == NULL) - abort (); - } - - aosl_data_buf (const char *str) - { - if (str != NULL) { - size_t str_l = strlen (str); - d = aosl_data_create (str_l + 1, NULL); - if (d == NULL) - abort (); - - memcpy (ptr (), str, str_l + 1); - } - } - - aosl_data_buf (char *str, aosl_data_user_free_t dtor) - { - size_t len; - if (str != NULL) { - len = strlen (str) + 1; - } else { - len = 0; - } - - d = aosl_data_user_create (str, len, dtor); - if (d == NULL) - abort (); - } - - aosl_data_buf (aosl_data_t src) - { - d = src; - if (src != NULL) - aosl_data_get (src); - } - - aosl_data_buf (const aosl_data_buf &src) - { - if (this != &src) { - d = src.d; - if (d != NULL) - aosl_data_get (d); - } - } - - aosl_data_buf &operator = (const char *str) - { - if (d != NULL) { - aosl_data_put (d); - d = NULL; - } - - if (str != NULL) { - size_t str_l = strlen (str); - d = aosl_data_create (str_l + 1, NULL); - if (d == NULL) - abort (); - - memcpy (ptr (), str, str_l + 1); - } - - return *this; - } - - aosl_data_buf &operator = (aosl_data_t src) - { - if (d != NULL) - aosl_data_put (d); - - d = src; - if (src != NULL) - aosl_data_get (src); - - return *this; - } - - aosl_data_buf &operator = (const aosl_data_buf &src) - { - if (this != &src) { - if (d != NULL) - aosl_data_put (d); - - d = src.d; - if (d != NULL) - aosl_data_get (d); - } - - return *this; - } - - operator void *() const - { - if (d != NULL) - return ptr (); - - return NULL; - } - - operator char *() const - { - return (char *)ptr (); - } - - operator unsigned char *() const - { - return (unsigned char *)ptr (); - } - - void attach (aosl_data_t src) - { - if (d != NULL) - aosl_data_put (d); - - d = src; - } - - aosl_data_t detach () - { - aosl_data_t data = d; - d = NULL; - return data; - } - -#if (__cplusplus >= 201103) || defined (_MSC_VER) - aosl_data_buf (aosl_data_buf &&src) - { - if (this != &src) { - d = src.d; - src.d = NULL; - } - } - - aosl_data_buf &operator = (aosl_data_buf &&src) - { - if (this != &src) { - if (d != NULL) - aosl_data_put (d); - - d = src.d; - src.d = NULL; - } - - return *this; - } -#endif /* C++11 */ -}; - -/** - * This class is only used in the constructor of aosl_data_var - * to differentiate constructor with variadic args, do not use - * it in any other scenario. - **/ -template -class aosl_data_arg { -private: - const T var; - -public: - aosl_data_arg (T arg): var (arg) {} - operator T () - { - return var; - } -}; - -template -class aosl_data_var: public aosl_data_class { -public: - aosl_data_var (void) - { - d = aosl_data_create (sizeof (T), __data_var_dtor); - if (d == NULL) - abort (); - - new (aosl_data_ptr_get (d)) T; - } - - /** - * We prefer to using this kind of special class arg rather - * than naked aosl_data_t just for differentiating from the - * constructor with variadic args. - **/ - aosl_data_var (aosl_data_arg src_arg) - { - aosl_data_t src = src_arg; - if (src == NULL) - abort (); - - /* The prerequisite is that the src must be a valid T data */ - if (aosl_data_len (src) < sizeof (T)) - abort (); - - aosl_data_get (src); - d = src; - } - - /** - * We prefer to using this kind of special class arg rather - * than naked size_t. - **/ - aosl_data_var (aosl_data_arg nelems) - { - size_t count = nelems; - if (count == 0) - abort (); - - d = aosl_data_create (sizeof (T) * count, __data_var_dtor); - if (d == NULL) - abort (); - - new (aosl_data_ptr_get (d)) T [count]; - } - -#if (__cplusplus >= 201103) || defined (_MSC_VER) - template - aosl_data_var (Targs... args) - { - d = aosl_data_create (sizeof (T), __data_var_dtor); - if (d == NULL) - abort (); - - new (aosl_data_ptr_get (d)) T (args...); - } -#endif - - aosl_data_var (const aosl_data_var &src) - { - if (this != &src) { - d = src.d; - if (d != NULL) - aosl_data_get (d); - } - } - - aosl_data_var &operator = (const aosl_data_var &src) - { - if (this != &src) { - if (d != NULL) - aosl_data_put (d); - - d = src.d; - if (d != NULL) - aosl_data_get (d); - } - - return *this; - } - - aosl_data_var &operator = (const T &v) - { - if (d == NULL) - abort (); - - *(T *)aosl_data_ptr_get (d) = v; - return *this; - } - - operator T () const - { - if (d == NULL) - abort (); - - return *(T *)aosl_data_ptr_get (d); - } - - operator T& () - { - if (d == NULL) - abort (); - - return *(T *)aosl_data_ptr_get (d); - } - - T *operator -> () const - { - if (d == NULL) - abort (); - - return (T *)aosl_data_ptr_get (d); - } - - T operator [] (size_t i) const - { - size_t count; - T *arr; - - if (d == NULL) - abort (); - - count = len () / sizeof (T); - if (i >= count) - abort (); - - arr = (T *)aosl_data_ptr_get (d); - return arr [i]; - } - - T& operator [] (size_t i) - { - size_t count; - T *arr; - - if (d == NULL) - abort (); - - count = len () / sizeof (T); - if (i >= count) - abort (); - - arr = (T *)aosl_data_ptr_get (d); - return arr [i]; - } - -private: - static void __data_var_dtor (void *ptr, size_t len) - { - size_t n = len / sizeof (T); - T *o = (T *)ptr; - T *e = o + n; - while (e > o) { - e--; - e->~T (); - } - } - -#if (__cplusplus >= 201103) || defined (_MSC_VER) - aosl_data_var (aosl_data_var &&src) - { - if (this != &src) { - d = src.d; - src.d = NULL; - } - } - - aosl_data_var &operator = (aosl_data_var &&src) - { - if (this != &src) { - if (d != NULL) - aosl_data_put (d); - - d = src.d; - src.d = NULL; - } - - return *this; - } -#endif /* C++11 */ -}; - - -#endif /* __AOSL_DATA_CLASS_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_file_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_file_class.h deleted file mode 100644 index a8776df9b..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_file_class.h +++ /dev/null @@ -1,284 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Aug 19th, 2020 - * Module: AOSL file operations for C++ definition file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2020 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_FILE_CPP_H__ -#define __AOSL_FILE_CPP_H__ - - -#include - -#include -#include -#include -#include - -#if (__cplusplus >= 201103) || defined (_MSC_VER) -#include -#include -#endif - -class aosl_file_class { -private: - aosl_fd_t fd; - -public: - aosl_file_class () - { - fd = AOSL_INVALID_FD; - } - - aosl_fd_t detach () - { - if (!aosl_fd_invalid (fd)) { - aosl_fd_t _fd = fd; - fd = AOSL_INVALID_FD; - return _fd; - } - - return AOSL_INVALID_FD; - } - - int open (const char *file, int oflag, ...) - { - int mode = 0; - - if (!aosl_fd_invalid (fd)) { - aosl_file_close (fd); - fd = AOSL_INVALID_FD; - } - - if ((oflag & O_CREAT) != 0) { - va_list arg; - va_start (arg, oflag); - mode = va_arg (arg, int); - va_end (arg); - } - - fd = aosl_file_open (file, oflag, mode); - if (aosl_fd_invalid (fd)) - return -1; - - return 0; - } - - ssize_t size () - { - return aosl_file_size (fd); - } - - ssize_t read (void *buf, size_t count) - { - return aosl_file_read (fd, buf, count); - } - - ssize_t write (const void *buf, size_t count) - { - return aosl_file_write (fd, buf, count); - } - - off_t lseek (off_t offset, int whence) - { - return aosl_file_lseek (fd, offset, whence); - } - - int aread (size_t count, aosl_file_aread_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = aosl_file_aread_args (fd, count, f, argc, args); - va_end (args); - - return err; - } - - int aread_args (size_t count, aosl_file_aread_t f, uintptr_t argc, va_list args) - { - return aosl_file_aread_args (fd, count, f, argc, args); - } - - int aread_argv (size_t count, aosl_file_aread_t f, uintptr_t argc, uintptr_t argv []) - { - return aosl_file_aread_argv (fd, count, f, argc, argv); - } - - int awrite (const void *buf, size_t count, aosl_file_awrite_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = aosl_file_awrite_args (fd, buf, count, f, argc, args); - va_end (args); - - return err; - } - - int awrite_args (const void *buf, size_t count, aosl_file_awrite_t f, uintptr_t argc, va_list args) - { - return aosl_file_awrite_args (fd, buf, count, f, argc, args); - } - - int awrite_argv (const void *buf, size_t count, aosl_file_awrite_t f, uintptr_t argc, uintptr_t argv []) - { - return aosl_file_awrite_argv (fd, buf, count, f, argc, argv); - } - - int alseek (off_t offset, int whence, aosl_file_alseek_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = aosl_file_alseek_args (fd, offset, whence, f, argc, args); - va_end (args); - - return err; - } - - int alseek_args (off_t offset, int whence, aosl_file_alseek_t f, uintptr_t argc, va_list args) - { - return aosl_file_alseek_args (fd, offset, whence, f, argc, args); - } - - int alseek_argv (off_t offset, int whence, aosl_file_alseek_t f, uintptr_t argc, uintptr_t argv []) - { - return aosl_file_alseek_argv (fd, offset, whence, f, argc, argv); - } - - /* C++11 lambda encapsulations */ -#if (__cplusplus >= 201103) || defined (_MSC_VER) -public: - typedef std::function aosl_file_aread_lambda_f; - typedef std::function aosl_file_awrite_lambda_f; - typedef std::function aosl_file_alseek_lambda_f; - - int aread (size_t count, aosl_file_aread_lambda_f &&lambda) - { - if (lambda != nullptr) { - aosl_file_aread_lambda_f *lambda_p = new aosl_file_aread_lambda_f (std::move (lambda)); - int err = aread (count, ____aread_f, 1, lambda_p); - if (err < 0) - delete lambda_p; - - return err; - } - - aosl_errno = EINVAL; - return -1; - } - - int awrite (const void *buf, size_t count, aosl_file_awrite_lambda_f &&lambda = nullptr) - { - int err; - - if (lambda == nullptr) { - err = awrite (buf, count, NULL, 0); - } else { - aosl_file_awrite_lambda_f *lambda_p = new aosl_file_awrite_lambda_f (std::move (lambda)); - err = awrite (buf, count, ____awrite_f, 1, lambda_p); - if (err < 0) - delete lambda_p; - } - - return err; - } - - int alseek (off_t offset, int whence, aosl_file_alseek_lambda_f &&lambda = nullptr) - { - int err; - - if (lambda == nullptr) { - err = alseek (offset, whence, NULL, 0); - } else { - aosl_file_alseek_lambda_f *lambda_p = new aosl_file_alseek_lambda_f (std::move (lambda)); - err = alseek (offset, whence, ____alseek_f, 1, lambda_p); - if (err < 0) - delete lambda_p; - } - - return err; - } - -private: - static void ____aread_f (int free_only, aosl_fd_t fd, ssize_t ret, void *buf, uintptr_t argc, uintptr_t argv []) - { - aosl_file_aread_lambda_f *lambda_f = (aosl_file_aread_lambda_f *)argv [0]; - (*lambda_f) ((bool)(free_only != 0), fd, ret, buf); - delete lambda_f; - } - - static void ____awrite_f (int free_only, aosl_fd_t fd, ssize_t ret, uintptr_t argc, uintptr_t argv []) - { - aosl_file_awrite_lambda_f *lambda_f = (aosl_file_awrite_lambda_f *)argv [0]; - (*lambda_f) ((bool)(free_only != 0), fd, ret); - delete lambda_f; - } - - static void ____alseek_f (int free_only, aosl_fd_t fd, off_t ret, uintptr_t argc, uintptr_t argv []) - { - aosl_file_alseek_lambda_f *lambda_f = (aosl_file_alseek_lambda_f *)argv [0]; - (*lambda_f) ((bool)(free_only != 0), fd, ret); - delete lambda_f; - } -#endif /* C++11 */ - -public: - int co_read (aosl_data_t d_ret, aosl_data_t d_buf, uintptr_t buf_off = 0) - { - return aosl_co_file_read (fd, d_ret, d_buf, buf_off); - } - - int co_write (aosl_data_t d_ret, aosl_data_t d_buf) - { - return aosl_co_file_write (fd, d_ret, d_buf); - } - - int co_file_lseek (aosl_data_t d_ret, off_t offset, int whence) - { - return aosl_co_file_lseek (fd, d_ret, offset, whence); - } - - int close () - { - if (!aosl_fd_invalid (fd)) { - int err; - err = aosl_file_close (fd); - fd = AOSL_INVALID_FD; - return err; - } - - return -1; - } - - virtual ~aosl_file_class () - { - if (!aosl_fd_invalid (fd)) - aosl_file_close (fd); - } - -#if (__cplusplus >= 201103) || defined (_MSC_VER) -private: - aosl_file_class (const aosl_file_class &) = delete; - aosl_file_class (aosl_file_class &&) = delete; - aosl_file_class &operator = (const aosl_file_class &) = delete; - aosl_file_class &operator = (aosl_file_class &&) = delete; -#else -private: - aosl_file_class (const aosl_file_class &); - aosl_file_class &operator = (const aosl_file_class &); -#endif /* C++11 */ -}; - - -#endif /* __AOSL_FILE_CPP_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_input_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_input_class.h deleted file mode 100644 index 86cf8023f..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_input_class.h +++ /dev/null @@ -1,193 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : May 21st, 2019 - * Module: AOSL input object for C++ definition file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 ~ 2019 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_INPUT_CLASS_H__ -#define __AOSL_INPUT_CLASS_H__ - - -#include - -#include -#include -#include -#include -#include -#include - -#if (__cplusplus >= 201103) || defined (_MSC_VER) -#include -#include -typedef std::function aosl_input_lambda_f; -#endif - - -class aosl_input_class: public aosl_ref_class { -public: - class aosl_ref_t_oop: public aosl_ref_class::aosl_ref_t_oop { - private: - /** - * We do not allow create any object of this class directly, - * only the pointer of this class is significant. - **/ - aosl_ref_t_oop (); - - public: - static aosl_ref_t_oop *create (uintptr_t waitings_max, aosl_mpq_t input_q = aosl_mpq_main (), void *arg = NULL, aosl_ref_dtor_t dtor = NULL) - { - return (aosl_ref_t_oop *)aosl_input_create (arg, dtor, waitings_max, input_q); - } - - static aosl_ref_t_oop *from_aosl_ref_t (aosl_ref_t ref) - { - return (aosl_ref_t_oop *)ref; - } - - int exec (const char *f_name, aosl_input_func_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = aosl_input_exec_args (ref (), f_name, f, argc, args); - va_end (args); - - return err; - } - - int exec_args (const char *f_name, aosl_input_func_t f, uintptr_t argc, va_list args) - { - return aosl_input_exec_args (ref (), f_name, f, argc, args); - } - - int exec_argv (const char *f_name, aosl_input_func_t f, uintptr_t argc, uintptr_t argv []) - { - return aosl_input_exec_argv (ref (), f_name, f, argc, argv); - } - - int waitings_count () - { - return aosl_input_waitings_count (ref ()); - } - - int remove_waitings_head () - { - return aosl_input_remove_waitings_head (ref ()); - } - - /* C++11 lambda encapsulations */ - #if (__cplusplus >= 201103) || defined (_MSC_VER) - public: - int exec (const char *f_name, aosl_input_lambda_f&& input) - { - aosl_input_lambda_f *input_obj = new aosl_input_lambda_f (std::move (input)); - int err = aosl_ref_t_oop::exec (f_name, ____input_f, 1, input_obj); - if (err < 0) - delete input_obj; - - return err; - } - - private: - static void ____input_f (aosl_refobj_t iobj, int free_only, uintptr_t argc, uintptr_t argv []) - { - aosl_input_lambda_f *input_obj = reinterpret_cast(argv [0]); - (*input_obj) (iobj, (bool)(free_only != 0)); - delete input_obj; - } - #endif /* C++11 */ - }; - -public: - aosl_input_class (uintptr_t waitings_max, aosl_mpq_t input_q = aosl_mpq_main ()) - : aosl_ref_class (aosl_ref_t_oop::create (waitings_max, input_q, this, __dtor)) - { - if (aosl_ref_invalid (ref_oop ())) - abort (); - } - - aosl_ref_t_oop *ref_oop () const - { - return (aosl_ref_t_oop *)aosl_ref_class::ref_oop (); - } - - int exec (const char *f_name, aosl_input_func_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = ref_oop ()->exec_args (f_name, f, argc, args); - va_end (args); - - return err; - } - - int exec_args (const char *f_name, aosl_input_func_t f, uintptr_t argc, va_list args) - { - return ref_oop ()->exec_args (f_name, f, argc, args); - } - - int exec_argv (const char *f_name, aosl_input_func_t f, uintptr_t argc, uintptr_t argv []) - { - return ref_oop ()->exec_argv (f_name, f, argc, argv); - } - - int waitings_count () - { - return ref_oop ()->waitings_count (); - } - - int remove_waitings_head () - { - return ref_oop ()->remove_waitings_head (); - } - -protected: - /* We do not allow delete this object directly. */ - virtual ~aosl_input_class () - { - } - -private: - static void __dtor (void *arg) - { - aosl_input_class *__this = (aosl_input_class *)arg; - ::delete __this; - } - - /* C++11 lambda encapsulations */ -#if (__cplusplus >= 201103) || defined (_MSC_VER) -public: - int exec (const char *f_name, aosl_input_lambda_f&& input) - { - return ref_oop ()->exec (f_name, std::move (input)); - } -#endif /* C++11 */ - -#if (__cplusplus >= 201103) || defined (_MSC_VER) -private: - aosl_input_class (const aosl_input_class &) = delete; - aosl_input_class (aosl_input_class &&) = delete; - aosl_input_class &operator = (const aosl_input_class &) = delete; - aosl_input_class &operator = (aosl_input_class &&) = delete; -#else -private: - aosl_input_class (const aosl_input_class &); - aosl_input_class &operator = (const aosl_input_class &); -#endif /* C++11 */ -}; - - -typedef aosl_ref_unique_ptr aosl_input_class_unique_ptr; - - -#endif /* __AOSL_INPUT_CLASS_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_kobj_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_kobj_class.h deleted file mode 100644 index 011e68b07..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_kobj_class.h +++ /dev/null @@ -1,101 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Dec 8th, 2022 - * Module: AOSL value object for C++ definition file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 ~ 2022 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_KOBJ_CPP_H__ -#define __AOSL_KOBJ_CPP_H__ - - -#include - -#include -#include - -#if (__cplusplus >= 201103) || defined (_MSC_VER) -#include -#include -#endif - - -class aosl_kobj_class { -private: -#if (__cplusplus >= 201103) || defined (_MSC_VER) - aosl_kobj_class () = delete; - aosl_kobj_class (const aosl_kobj_class &) = delete; - aosl_kobj_class (aosl_kobj_class &&) = delete; - aosl_kobj_class &operator = (const aosl_kobj_class &) = delete; - aosl_kobj_class &operator = (aosl_kobj_class &&) = delete; - ~aosl_kobj_class () = delete; -#else - aosl_kobj_class (); - aosl_kobj_class (const aosl_kobj_class &); - aosl_kobj_class &operator = (const aosl_kobj_class &); - ~aosl_kobj_class (); -#endif - -public: - static void *notify_register (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_t f, aosl_obj_dtor_t dtor, uintptr_t argc, ...) - { - va_list args; - void *err; - - va_start (args, argc); - err = aosl_kobj_notify_register_args (dfd, name, touch, qid, ref, f_name, f, dtor, argc, args); - va_end (args); - return err; - } - - static void *notify_register_args (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_t f, aosl_obj_dtor_t dtor, uintptr_t argc, va_list args) - { - return aosl_kobj_notify_register_args (dfd, name, touch, qid, ref, f_name, f, dtor, argc, args); - } - - static void *notify_register_argv (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_t f, aosl_obj_dtor_t dtor, uintptr_t argc, uintptr_t argv []) - { - return aosl_kobj_notify_register_argv (dfd, name, touch, qid, ref, f_name, f, dtor, argc, argv); - } - - static int notify_unregister (aosl_kfd_t dfd, const char *name, aosl_mpq_t qid, aosl_ref_t ref, void *handle) - { - return aosl_kobj_notify_unregister (dfd, name, handle); - } - - /* C++11 lambda encapsulations */ -#if (__cplusplus >= 201103) || defined (_MSC_VER) -public: - typedef std::function aosl_kobj_notify_lambda_f; - static void *notify_register (aosl_kfd_t dfd, const char *name, int touch, aosl_mpq_t qid, aosl_ref_t ref, const char *f_name, aosl_kobj_notify_lambda_f&& task) - { - aosl_kobj_notify_lambda_f *task_obj = new aosl_kobj_notify_lambda_f (std::move (task)); - void *err = notify_register (dfd, name, touch, qid, ref, f_name, ____notify_f, ____notify_dtor, 1, task_obj); - if (err == NULL) - delete task_obj; - - return err; - } - -private: - static void ____notify_f (aosl_refobj_t robj, const char *dirpath, const char *name, void *notif_data, uintptr_t argc, uintptr_t argv []) - { - aosl_kobj_notify_lambda_f *task_obj = reinterpret_cast(argv [0]); - (*task_obj) (robj, dirpath, name, notif_data); - } - - static void ____notify_dtor (uintptr_t argc, uintptr_t argv []) - { - aosl_kobj_notify_lambda_f *task_obj = reinterpret_cast(argv [0]); - delete task_obj; - } -#endif /* C++11 */ -}; - - -#endif /* __AOSL_KOBJ_CPP_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mm_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mm_class.h deleted file mode 100644 index 15c9e020d..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mm_class.h +++ /dev/null @@ -1,45 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jun 17th, 2024 - * Module: AOSL memory management for C++ definition file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 ~ 2024 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_MM_CLASS_H__ -#define __AOSL_MM_CLASS_H__ - - -#include -#include - - -class aosl_mm_class { -public: - static void *operator new (size_t size) - { - return aosl_mm_malloc (size); - } - - static void *operator new [] (size_t size) - { - return aosl_mm_malloc (size); - } - - static void operator delete (void *ptr) - { - aosl_mm_free (ptr); - } - - static void operator delete [] (void *ptr) - { - aosl_mm_free (ptr); - } -}; - - -#endif /* __AOSL_MM_CLASS_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_fd_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_fd_class.h deleted file mode 100644 index a03a74e7d..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_fd_class.h +++ /dev/null @@ -1,117 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao - * Date : Jun 30th, 2019 - * Module: AOSL mpq fd C++ implementation - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2019 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_MPQ_FD_CLASS_H__ -#define __AOSL_MPQ_FD_CLASS_H__ - -#include - -#include -#include -#include - - -class aosl_mpq_fd_class { -public: - aosl_mpq_fd_class (aosl_fd_t fd): attached_fd (fd) - { - ref_id = aosl_ref_create (this, NULL, 1/* MUST BE CALLER-FREE */); - if (aosl_ref_invalid (ref_id)) - abort (); - } - - virtual ~aosl_mpq_fd_class () - { - /** - * Please make sure this is the first action in the destructor of - * each final derived class of this class and its' derivatives. - **/ - ref_destroy (); - if (!aosl_fd_invalid (attached_fd)) - aosl_close (attached_fd); - } - - aosl_ref_t ref (void) - { - return ref_id; - } - - /** - * Please call this function first before freeing any resource relative - * with this class and its' derivatives. - **/ - void ref_destroy (void) - { - if (!aosl_ref_invalid (ref_id)) { - /** - * For caller-free ref object, the destroy will wait other threads - * to release the ref usage count, so this will guarantee the safe - * accessing of 'this' object. - **/ - aosl_ref_destroy (ref_id, 1); - ref_id = AOSL_REF_INVALID; - } - } - - aosl_fd_t get_fd (void) - { - return attached_fd; - } - - aosl_fd_t detach (void) - { - if (!aosl_fd_invalid (attached_fd)) { - aosl_fd_t fd = attached_fd; - attached_fd = AOSL_INVALID_FD; - return fd; - } - - return AOSL_INVALID_FD; - } - -public: - int co_read (aosl_data_t d_ret, aosl_data_t d_buf, uintptr_t buf_off = 0) - { - return aosl_co_read (attached_fd, d_ret, d_buf, buf_off); - } - - ssize_t co_write (aosl_data_t d_ret, aosl_data_t d_buf) - { - return aosl_co_write (attached_fd, d_ret, d_buf); - } - - ssize_t co_buf_write (aosl_data_t d_ret, const void *buf, size_t count) - { - return aosl_co_buf_write (attached_fd, d_ret, buf, count); - } - -private: - aosl_ref_t ref_id; - aosl_fd_t attached_fd; - -#if (__cplusplus >= 201103) || defined (_MSC_VER) -private: - aosl_mpq_fd_class () = delete; - aosl_mpq_fd_class (const aosl_mpq_fd_class &) = delete; - aosl_mpq_fd_class (aosl_mpq_fd_class &&) = delete; - aosl_mpq_fd_class &operator = (const aosl_mpq_fd_class &) = delete; - aosl_mpq_fd_class &operator = (aosl_mpq_fd_class &&) = delete; -#else -private: - aosl_mpq_fd_class (); - aosl_mpq_fd_class (const aosl_mpq_fd_class &); - aosl_mpq_fd_class &operator = (const aosl_mpq_fd_class &); -#endif /* C++11 */ -}; - - -#endif /* __AOSL_MPQ_FD_CLASS_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_sk_lambda.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_sk_lambda.h deleted file mode 100644 index 477488177..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_sk_lambda.h +++ /dev/null @@ -1,393 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao - * Date : Nov 6th, 2018 - * Module: AOSL mpq socket C++ 11 lambda implementation - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_MPQ_SK_LAMBDA_H__ -#define __AOSL_MPQ_SK_LAMBDA_H__ - -#include - -#include -#include -#include -#include -#include -#include - -#if (__cplusplus >= 201103) || defined (_MSC_VER) -#include - -typedef std::function aosl_fd_chk_pkt_lambda_t; -typedef std::function aosl_fd_data_lambda_t; -typedef std::function aosl_dgram_sk_data_lambda_t; -typedef std::function aosl_fd_d_data_lambda_t; /* lambda with aosl_data_t */ -typedef std::function aosl_dgram_sk_d_data_lambda_t; /* lambda with aosl_data_t */ -typedef std::function aosl_fd_event_lambda_t; -typedef std::function aosl_listen_sk_accept_lambda_t; - - -class aosl_mpq_dgram_sk: public aosl_mpq_fd_class { -public: - aosl_mpq_dgram_sk (aosl_fd_t sk, size_t max_pkt_size, - aosl_dgram_sk_data_lambda_t&& data_cb, - aosl_fd_event_lambda_t&& event_cb, - aosl_mpq_t qid = aosl_mpq_this ()) - : aosl_mpq_fd_class (sk), - on_data (std::move (data_cb)), - on_event (std::move (event_cb)) - { - if (aosl_mpq_add_dgram_socket (qid, sk, max_pkt_size, &__on_data, &__on_event, 1, ref ()) < 0) - abort (); - } - - aosl_mpq_dgram_sk (aosl_fd_t sk, size_t max_pkt_size, - aosl_dgram_sk_d_data_lambda_t&& data_cb, - aosl_fd_event_lambda_t&& event_cb, - aosl_mpq_t qid = aosl_mpq_this ()) - : aosl_mpq_fd_class (sk), - on_d_data (std::move (data_cb)), - on_event (std::move (event_cb)) - { - if (aosl_mpq_add_dgram_socket (qid, sk, max_pkt_size, &__on_d_data, &__on_event, 1, ref ()) < 0) - abort (); - } - - virtual ~aosl_mpq_dgram_sk () - { - /** - * Please make sure this is the first action in the destructor of - * each final derived class of this class and its' derivatives. - **/ - ref_destroy (); - } - -private: - static void __on_data (void *data, size_t len, uintptr_t argc, uintptr_t argv [], const aosl_sk_addr_t *addr) - { - aosl_ref_class::hold ((aosl_ref_t)argv [0], [&] (void *arg) { - aosl_mpq_dgram_sk *__this = (aosl_mpq_dgram_sk *)(aosl_mpq_fd_class *)arg; - __this->on_data (data, len, addr); - }); - } - - static void __on_d_data (void *data, size_t len, uintptr_t argc, uintptr_t argv [], const aosl_sk_addr_t *addr) - { - aosl_ref_class::hold ((aosl_ref_t)argv [0], [&] (void *arg) { - aosl_mpq_dgram_sk *__this = (aosl_mpq_dgram_sk *)(aosl_mpq_fd_class *)arg; - __this->on_d_data ((aosl_data_t)argv [argc], data, len, addr); - }); - } - - static void __on_event (aosl_fd_t sk, int event, uintptr_t argc, uintptr_t argv []) - { - aosl_ref_class::hold ((aosl_ref_t)argv [0], [&] (void *arg) { - aosl_mpq_dgram_sk *__this = (aosl_mpq_dgram_sk *)(aosl_mpq_fd_class *)arg; - __this->on_event (sk, event); - }); - } - - const aosl_dgram_sk_data_lambda_t on_data; - const aosl_dgram_sk_d_data_lambda_t on_d_data; - const aosl_fd_event_lambda_t on_event; - -private: - aosl_mpq_dgram_sk () = delete; - aosl_mpq_dgram_sk (const aosl_mpq_dgram_sk &) = delete; - aosl_mpq_dgram_sk (aosl_mpq_dgram_sk &&) = delete; - aosl_mpq_dgram_sk &operator = (const aosl_mpq_dgram_sk &) = delete; - aosl_mpq_dgram_sk &operator = (aosl_mpq_dgram_sk &&) = delete; -}; - -class aosl_mpq_stream_sk: public aosl_mpq_fd_class { -public: - aosl_mpq_stream_sk (aosl_fd_t sk, int enable, size_t max_pkt_size, - aosl_fd_chk_pkt_lambda_t&& chk_pkt_cb, - aosl_fd_data_lambda_t&& data_cb, - aosl_fd_event_lambda_t&& event_cb, - aosl_mpq_t qid = aosl_mpq_this ()) - : aosl_mpq_fd_class (sk), - on_chk_pkt (std::move (chk_pkt_cb)), - on_data (std::move (data_cb)), - on_event (std::move (event_cb)) - { - if (aosl_mpq_add_stream_socket (qid, sk, enable, max_pkt_size, &__on_chk_pkt, &__on_data, &__on_event, 1, ref ()) < 0) - abort (); - } - - aosl_mpq_stream_sk (aosl_fd_t sk, int enable, size_t max_pkt_size, - aosl_fd_chk_pkt_lambda_t&& chk_pkt_cb, - aosl_fd_d_data_lambda_t&& data_cb, - aosl_fd_event_lambda_t&& event_cb, - aosl_mpq_t qid = aosl_mpq_this ()) - : aosl_mpq_fd_class (sk), - on_chk_pkt (std::move (chk_pkt_cb)), - on_d_data (std::move (data_cb)), - on_event (std::move (event_cb)) - { - if (aosl_mpq_add_stream_socket (qid, sk, enable, max_pkt_size, &__on_chk_pkt, &__on_d_data, &__on_event, 1, ref ()) < 0) - abort (); - } - - virtual ~aosl_mpq_stream_sk () - { - /** - * Please make sure this is the first action in the destructor of - * each final derived class of this class and its' derivatives. - **/ - ref_destroy (); - } - -private: - static ssize_t __on_chk_pkt (const void *data, size_t len, uintptr_t argc, uintptr_t argv []) - { - ssize_t ret = -1; - - aosl_ref_class::hold ((aosl_ref_t)argv [0], [&] (void *arg) { - aosl_mpq_stream_sk *__this = (aosl_mpq_stream_sk *)(aosl_mpq_fd_class *)arg; - ret = __this->on_chk_pkt (data, len); - }); - - return ret; - } - - static void __on_data (void *data, size_t len, uintptr_t argc, uintptr_t argv []) - { - aosl_ref_class::hold ((aosl_ref_t)argv [0], [&] (void *arg) { - aosl_mpq_stream_sk *__this = (aosl_mpq_stream_sk *)(aosl_mpq_fd_class *)arg; - __this->on_data (data, len); - }); - } - - static void __on_d_data (void *data, size_t len, uintptr_t argc, uintptr_t argv []) - { - aosl_ref_class::hold ((aosl_ref_t)argv [0], [&] (void *arg) { - aosl_mpq_stream_sk *__this = (aosl_mpq_stream_sk *)(aosl_mpq_fd_class *)arg; - __this->on_d_data ((aosl_data_t)argv [argc], data, len); - }); - } - - static void __on_event (aosl_fd_t sk, int event, uintptr_t argc, uintptr_t argv []) - { - aosl_ref_class::hold ((aosl_ref_t)argv [0], [&] (void *arg) { - aosl_mpq_stream_sk *__this = (aosl_mpq_stream_sk *)(aosl_mpq_fd_class *)arg; - __this->on_event (sk, event); - }); - } - - const aosl_fd_chk_pkt_lambda_t on_chk_pkt; - const aosl_fd_data_lambda_t on_data; - const aosl_fd_d_data_lambda_t on_d_data; - const aosl_fd_event_lambda_t on_event; - -private: - aosl_mpq_stream_sk () = delete; - aosl_mpq_stream_sk (const aosl_mpq_stream_sk &) = delete; - aosl_mpq_stream_sk (aosl_mpq_stream_sk &&) = delete; - aosl_mpq_stream_sk &operator = (const aosl_mpq_stream_sk &) = delete; - aosl_mpq_stream_sk &operator = (aosl_mpq_stream_sk &&) = delete; -}; - -class aosl_mpq_connect_stream_sk: public aosl_mpq_stream_sk { -public: - aosl_mpq_connect_stream_sk (aosl_fd_t sk, size_t max_pkt_size, - aosl_fd_chk_pkt_lambda_t&& chk_pkt_cb, - aosl_fd_data_lambda_t&& data_cb, - aosl_fd_event_lambda_t&& event_cb, - aosl_mpq_t qid = aosl_mpq_this ()) - : aosl_mpq_stream_sk (sk, 0/* !enable */, - max_pkt_size, - std::move (chk_pkt_cb), - std::move (data_cb), - std::move (event_cb), qid) {} - - aosl_mpq_connect_stream_sk (aosl_fd_t sk, size_t max_pkt_size, - aosl_fd_chk_pkt_lambda_t&& chk_pkt_cb, - aosl_fd_d_data_lambda_t&& data_cb, - aosl_fd_event_lambda_t&& event_cb, - aosl_mpq_t qid = aosl_mpq_this ()) - : aosl_mpq_stream_sk (sk, 0/* !enable */, - max_pkt_size, - std::move (chk_pkt_cb), - std::move (data_cb), - std::move (event_cb), qid) {} - - int connect (const struct sockaddr *dest_addr, socklen_t addrlen, int timeo) - { - return aosl_mpq_connect (get_fd (), dest_addr, addrlen, timeo); - } - -private: - aosl_mpq_connect_stream_sk () = delete; - aosl_mpq_connect_stream_sk (const aosl_mpq_connect_stream_sk &) = delete; - aosl_mpq_connect_stream_sk (aosl_mpq_connect_stream_sk &&) = delete; - aosl_mpq_connect_stream_sk &operator = (const aosl_mpq_connect_stream_sk &) = delete; - aosl_mpq_connect_stream_sk &operator = (aosl_mpq_connect_stream_sk &&) = delete; -}; - -class aosl_mpq_accepted_stream_sk: public aosl_mpq_stream_sk { -public: - aosl_mpq_accepted_stream_sk (aosl_fd_t sk, size_t max_pkt_size, - aosl_fd_chk_pkt_lambda_t&& chk_pkt_cb, - aosl_fd_data_lambda_t&& data_cb, - aosl_fd_event_lambda_t&& event_cb, - aosl_mpq_t qid = aosl_mpq_this ()) - : aosl_mpq_stream_sk (sk, 1/*enable*/, - max_pkt_size, - std::move (chk_pkt_cb), - std::move (data_cb), - std::move (event_cb), qid) {} - - aosl_mpq_accepted_stream_sk (aosl_fd_t sk, size_t max_pkt_size, - aosl_fd_chk_pkt_lambda_t&& chk_pkt_cb, - aosl_fd_d_data_lambda_t&& data_cb, - aosl_fd_event_lambda_t&& event_cb, - aosl_mpq_t qid = aosl_mpq_this ()) - : aosl_mpq_stream_sk (sk, 1/*enable*/, - max_pkt_size, - std::move (chk_pkt_cb), - std::move (data_cb), - std::move (event_cb), qid) {} - -private: - aosl_mpq_accepted_stream_sk () = delete; - aosl_mpq_accepted_stream_sk (const aosl_mpq_accepted_stream_sk &) = delete; - aosl_mpq_accepted_stream_sk (aosl_mpq_accepted_stream_sk &&) = delete; - aosl_mpq_accepted_stream_sk &operator = (const aosl_mpq_accepted_stream_sk &) = delete; - aosl_mpq_accepted_stream_sk &operator = (aosl_mpq_accepted_stream_sk &&) = delete; -}; - -class aosl_mpq_listen_sk: public aosl_mpq_fd_class { -public: - aosl_mpq_listen_sk (aosl_fd_t sk, int backlog, - aosl_listen_sk_accept_lambda_t&& accept_cb, - aosl_fd_event_lambda_t&& event_cb, - aosl_mpq_t qid = aosl_mpq_this ()) - : aosl_mpq_fd_class (sk), - on_accept (std::move (accept_cb)), - on_event (std::move (event_cb)) - { - if (aosl_mpq_add_listen_socket (qid, sk, backlog, __on_accept, __on_event, 1, ref ()) < 0) - abort (); - } - - virtual ~aosl_mpq_listen_sk () - { - /** - * Please make sure this is the first action in the destructor of - * each final derived class of this class and its' derivatives. - **/ - ref_destroy (); - } - -private: - static void __on_accept (aosl_accept_data_t *accept_data, size_t len, uintptr_t argc, uintptr_t argv []) - { - aosl_ref_class::hold ((aosl_ref_t)argv [0], [&] (void *arg) { - aosl_mpq_listen_sk *__this = (aosl_mpq_listen_sk *)(aosl_mpq_fd_class *)arg; - __this->on_accept (accept_data); - }); - } - - static void __on_event (aosl_fd_t sk, int event, uintptr_t argc, uintptr_t argv []) - { - aosl_ref_class::hold ((aosl_ref_t)argv [0], [&] (void *arg) { - aosl_mpq_listen_sk *__this = (aosl_mpq_listen_sk *)(aosl_mpq_fd_class *)arg; - __this->on_event (sk, event); - }); - } - - const aosl_listen_sk_accept_lambda_t on_accept; - const aosl_fd_event_lambda_t on_event; - -private: - aosl_mpq_listen_sk () = delete; - aosl_mpq_listen_sk (const aosl_mpq_listen_sk &) = delete; - aosl_mpq_listen_sk (aosl_mpq_listen_sk &&) = delete; - aosl_mpq_listen_sk &operator = (const aosl_mpq_listen_sk &) = delete; - aosl_mpq_listen_sk &operator = (aosl_mpq_listen_sk &&) = delete; -}; -#endif /* C++11 */ - -class aosl_co_sk: public aosl_mpq_fd_class { -public: - aosl_co_sk (int domain, int type, int protocol): aosl_mpq_fd_class (aosl_socket (domain, type, protocol)) - { - } - - aosl_co_sk (aosl_fd_t sk): aosl_mpq_fd_class (sk) - { - } - -public: - int listen (int backlog) - { - return aosl_listen (get_fd (), backlog); - } - - int co_accept (aosl_data_t d_ret, aosl_data_t d_addr) - { - return aosl_co_accept (get_fd (), d_ret, d_addr); - } - - int co_recv (aosl_data_t d_ret, aosl_data_t d_buf, uintptr_t buf_off = 0, int flags = 0) - { - return aosl_co_recv (get_fd (), d_ret, d_buf, buf_off, flags); - } - - int co_recvfrom (aosl_data_t d_ret, aosl_data_t d_buf, aosl_data_t d_addr, uintptr_t buf_off = 0, int flags = 0) - { - return aosl_co_recvfrom (get_fd (), d_ret, d_buf, buf_off, flags, d_addr); - } - - int co_connect (aosl_data_t d_ret, const struct sockaddr *dest_addr, socklen_t addrlen, int timeo) - { - return aosl_co_connect (get_fd (), d_ret, dest_addr, addrlen, timeo); - } - - ssize_t co_send (aosl_data_t d_ret, aosl_data_t d_buf, int flags) - { - return aosl_co_send (get_fd (), d_ret, d_buf, flags); - } - - ssize_t co_sendto (aosl_data_t d_ret, aosl_data_t d_buf, int flags, - const struct sockaddr *dest_addr, socklen_t addrlen) - { - return aosl_co_sendto (get_fd (), d_ret, d_buf, flags, dest_addr, addrlen); - } - - ssize_t co_buf_send (aosl_data_t d_ret, const void *buf, size_t len, int flags) - { - return aosl_co_buf_send (get_fd (), d_ret, buf, len, flags); - } - - ssize_t co_buf_sendto (aosl_data_t d_ret, const void *buf, size_t len, int flags, - const struct sockaddr *dest_addr, socklen_t addrlen) - { - return aosl_co_buf_sendto (get_fd (), d_ret, buf, len, flags, dest_addr, addrlen); - } - -#if (__cplusplus >= 201103) || defined (_MSC_VER) -private: - aosl_co_sk () = delete; - aosl_co_sk (const aosl_co_sk &) = delete; - aosl_co_sk (aosl_co_sk &&) = delete; - aosl_co_sk &operator = (const aosl_co_sk &) = delete; - aosl_co_sk &operator = (aosl_co_sk &&) = delete; -#else -private: - aosl_co_sk (); - aosl_co_sk (const aosl_co_sk &); - aosl_co_sk &operator = (const aosl_co_sk &); -#endif /* C++11 */ -}; - - -#endif /* __AOSL_MPQ_SK_LAMBDA_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_timer_lambda.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_timer_lambda.h deleted file mode 100644 index 7f62cb5b2..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_mpq_timer_lambda.h +++ /dev/null @@ -1,143 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao - * Date : Nov 6th, 2018 - * Module: AOSL mpq timer C++ 11 lambda implementation - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_MPQ_TIMER_LAMBDA_H__ -#define __AOSL_MPQ_TIMER_LAMBDA_H__ - -#include -#include -#include -#include - -#if (__cplusplus >= 201103) || defined (_MSC_VER) -#include - -typedef std::function aosl_timer_lambda_func_t; - -class aosl_mpq_timer_base { -public: - aosl_mpq_timer_base (aosl_timer_lambda_func_t&& timer_cb, uintptr_t interval, aosl_ts_t expire_time, - aosl_mpq_t q = AOSL_MPQ_INVALID, bool start = true): on_timer (std::move (timer_cb)) - { - if (aosl_mpq_invalid (q)) { - q = aosl_mpq_this (); - if (aosl_mpq_invalid (q)) - abort (); - } - - if (expire_time != 0) { - timer = aosl_mpq_set_oneshot_timer (q, expire_time, __on_timer, NULL, 1, this); - } else { - if (interval == AOSL_INVALID_TIMER_INTERVAL) { - timer = aosl_mpq_create_oneshot_timer (q, __on_timer, NULL, 1, this); - } else { - if (start) { - timer = aosl_mpq_set_timer (q, interval, __on_timer, NULL, 1, this); - } else { - timer = aosl_mpq_create_timer (q, interval, __on_timer, NULL, 1, this); - } - } - } - - if (aosl_mpq_timer_invalid (timer)) - abort (); - } - - ~aosl_mpq_timer_base () - { - if (aosl_mpq_kill_timer (timer) < 0) - abort (); - } - - aosl_timer_t timer_id (void) - { - return timer; - } - - int interval (uintptr_t *interval_p) - { - return aosl_mpq_timer_interval (timer, interval_p); - } - - int active (bool *active_p) - { - int active; - int err = aosl_mpq_timer_active (timer, &active); - if (err == 0 && active_p != NULL) - *active_p = (bool)(active != 0); - - return err; - } - - void cancel () - { - aosl_mpq_cancel_timer (timer); - } - -private: - static void __on_timer (aosl_timer_t timer, const aosl_ts_t *now_p, uintptr_t argc, uintptr_t argv []) - { - aosl_mpq_timer_base *__this = (aosl_mpq_timer_base *)argv [0]; - __this->on_timer (*now_p); - } - - aosl_timer_t timer; - const aosl_timer_lambda_func_t on_timer; - -private: - aosl_mpq_timer_base () = delete; - aosl_mpq_timer_base (const aosl_mpq_timer_base &) = delete; - aosl_mpq_timer_base (aosl_mpq_timer_base &&) = delete; - aosl_mpq_timer_base &operator = (const aosl_mpq_timer_base &) = delete; - aosl_mpq_timer_base &operator = (aosl_mpq_timer_base &&) = delete; -}; - - -class aosl_mpq_timer: public aosl_mpq_timer_base { -public: - aosl_mpq_timer (aosl_timer_lambda_func_t&& timer_cb, uintptr_t interval, aosl_mpq_t q = AOSL_MPQ_INVALID, bool start = true) - : aosl_mpq_timer_base (std::move (timer_cb), interval, 0, q, start) {} - - int resched (uintptr_t interval = AOSL_INVALID_TIMER_INTERVAL) - { - return aosl_mpq_resched_timer (timer_id (), interval); - } - -private: - aosl_mpq_timer () = delete; - aosl_mpq_timer (const aosl_mpq_timer &) = delete; - aosl_mpq_timer (aosl_mpq_timer &&) = delete; - aosl_mpq_timer &operator = (const aosl_mpq_timer &) = delete; - aosl_mpq_timer &operator = (aosl_mpq_timer &&) = delete; -}; - -class aosl_mpq_oneshot_timer: public aosl_mpq_timer_base { -public: - aosl_mpq_oneshot_timer (aosl_timer_lambda_func_t&& timer_cb, aosl_ts_t expire_time = 0, aosl_mpq_t q = AOSL_MPQ_INVALID) - : aosl_mpq_timer_base (std::move (timer_cb), AOSL_INVALID_TIMER_INTERVAL, expire_time, q) {} - - int sched (aosl_ts_t expire_time) - { - return aosl_mpq_resched_oneshot_timer (timer_id (), expire_time); - } - -private: - aosl_mpq_oneshot_timer () = delete; - aosl_mpq_oneshot_timer (const aosl_mpq_oneshot_timer &) = delete; - aosl_mpq_oneshot_timer (aosl_mpq_oneshot_timer &&) = delete; - aosl_mpq_oneshot_timer &operator = (const aosl_mpq_oneshot_timer &) = delete; - aosl_mpq_oneshot_timer &operator = (aosl_mpq_oneshot_timer &&) = delete; -}; -#endif /* C++11 */ - - -#endif /* __AOSL_MPQ_TIMER_LAMBDA_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_poll_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_poll_class.h deleted file mode 100644 index 54d1a0560..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_poll_class.h +++ /dev/null @@ -1,135 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jun 23rd, 2023 - * Module: AOSL poll functionality for C++ definition file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 ~ 2023 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_POLL_CLASS_H__ -#define __AOSL_POLL_CLASS_H__ - - -#include -#include -#include -#include -#include - -#if (__cplusplus >= 201103) || defined (_MSC_VER) -#include -#include -#endif - -#include -#include - - -class aosl_poll_class { -private: - std::map poll_refs; - std::vector signaled_refs; - -public: - void add (const aosl_ares_class &tail) - { - poll_refs [tail.ref ()] = &tail; - } - -#if (__cplusplus >= 201103) || defined (_MSC_VER) - template - void add (const T &head, const Targs&... rest) - { - poll_refs [head.ref ()] = &head; - add (rest...); - } - - /* constructor with variable args */ - template - aosl_poll_class (Targs&... args) - { - add (args...); - } -#endif /* C++11 */ - - aosl_poll_class (const aosl_ares_class * const areses [], size_t count) - { - size_t i; - for (i = 0; i < count; i++) - add (*areses [i]); - } - - /* poll the constructed async results */ - int poll (size_t min, intptr_t timeo) - { - aosl_ref_t local_refs [32]; - aosl_ref_t *refs = local_refs; - size_t count = poll_refs.size (); - std::map::iterator it; - int i; - int err; - - if (count > sizeof local_refs / sizeof local_refs [0]) { - refs = new aosl_ref_t [count]; - if (refs == NULL) - return -1; - } - - i = 0; - for (it = poll_refs.begin (); it != poll_refs.end (); it++) - refs [i++] = it->first; - - err = aosl_poll (refs, count, min, timeo); - signaled_refs.clear (); - for (i = 0; i < err; i++) { - it = poll_refs.find (refs [i]); - if (it != poll_refs.end ()) - signaled_refs.push_back (it->second); - } - - if (refs != local_refs) - delete [] refs; - - return err; - } - - /* total async results count */ - size_t total () - { - return poll_refs.size (); - } - - /* signaled async results count */ - size_t signaled () - { - return signaled_refs.size (); - } - - /* operator for accessing the signaled async results */ - const aosl_ares_class *operator [] (size_t idx) - { - if (idx < signaled_refs.size ()) - return signaled_refs [idx]; - - return NULL; - } - -#if (__cplusplus >= 201103) || defined (_MSC_VER) -private: - aosl_poll_class (const aosl_poll_class &) = delete; - aosl_poll_class (aosl_poll_class &&) = delete; - aosl_poll_class &operator = (const aosl_poll_class &) = delete; - aosl_poll_class &operator = (aosl_poll_class &&) = delete; -#else -private: - aosl_poll_class (const aosl_poll_class &); - aosl_poll_class &operator = (const aosl_poll_class &); -#endif -}; - - -#endif /* __AOSL_POLL_CLASS_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_ref_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_ref_class.h deleted file mode 100644 index 4dab3878b..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_ref_class.h +++ /dev/null @@ -1,1956 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Nov 19th, 2018 - * Module: AOSL reference object for C++ definition file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_REF_OBJ_CPP_H__ -#define __AOSL_REF_OBJ_CPP_H__ - - -#include - -#include -#include -#include - -#ifdef COMPILING_WITH_MPQ_H -#include -#ifdef COMPILING_WITH_MPQP_H -#include -#endif -#endif - -#ifdef COMPILING_WITH_ASYNC_H -#include -#endif - -#if (__cplusplus >= 201103) || defined (_MSC_VER) -#include -#include -typedef std::function aosl_ref_lambda_f; -typedef std::function aosl_ref_mpq_lambda_f; -typedef std::function aosl_ref_mpq_lambda_0arg_f; -typedef std::function aosl_async_prepare_lambda_f; -typedef std::function aosl_async_resume_lambda_f; -#endif - -class aosl_ref_class { -public: - class aosl_ref_t_oop { - private: - /** - * We do not allow create any object of this class directly, - * only the pointer of this class is significant. - **/ - aosl_ref_t_oop (); - - public: - static aosl_ref_t_oop *create (void *arg = NULL, aosl_ref_dtor_t dtor = NULL, bool caller_free = true) - { - return (aosl_ref_t_oop *)aosl_ref_create (arg, dtor, (int)caller_free); - } - - static aosl_ref_t_oop *from_aosl_ref_t (aosl_ref_t ref) - { - return (aosl_ref_t_oop *)ref; - } - - static void operator delete (void *ptr) - { - ((aosl_ref_t_oop *)ptr)->destroy (true); - } - - aosl_ref_t ref () const - { - return (aosl_ref_t)this; - } - - int hold (aosl_ref_func_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = aosl_ref_hold_args (ref (), f, argc, args); - va_end (args); - - return err; - } - - int hold_args (aosl_ref_func_t f, uintptr_t argc, va_list args) - { - return aosl_ref_hold_args (ref (), f, argc, args); - } - - int hold_argv (aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) - { - return aosl_ref_hold_argv (ref (), f, argc, argv); - } - - int read (aosl_ref_func_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = aosl_ref_read_args (ref (), f, argc, args); - va_end (args); - - return err; - } - - int read_args (aosl_ref_func_t f, uintptr_t argc, va_list args) - { - return aosl_ref_read_args (ref (), f, argc, args); - } - - int read_argv (aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) - { - return aosl_ref_read_argv (ref (), f, argc, argv); - } - - int write (aosl_ref_func_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = aosl_ref_write_args (ref (), f, argc, args); - va_end (args); - - return err; - } - - int write_args (aosl_ref_func_t f, uintptr_t argc, va_list args) - { - return aosl_ref_write_args (ref (), f, argc, args); - } - - int write_argv (aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) - { - return aosl_ref_write_argv (ref (), f, argc, argv); - } - - int unsafe (aosl_ref_func_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = aosl_ref_unsafe_args (ref (), f, argc, args); - va_end (args); - - return err; - } - - int unsafe_args (aosl_ref_func_t f, uintptr_t argc, va_list args) - { - return aosl_ref_unsafe_args (ref (), f, argc, args); - } - - int unsafe_argv (aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) - { - return aosl_ref_unsafe_argv (ref (), f, argc, argv); - } - - /* The static version of member functions */ - static int hold (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = aosl_ref_hold_args (ref, f, argc, args); - va_end (args); - - return err; - } - - static int hold_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args) - { - return aosl_ref_hold_args (ref, f, argc, args); - } - - static int hold_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) - { - return aosl_ref_hold_argv (ref, f, argc, argv); - } - - static int read (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = aosl_ref_read_args (ref, f, argc, args); - va_end (args); - - return err; - } - - static int read_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args) - { - return aosl_ref_read_args (ref, f, argc, args); - } - - static int read_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) - { - return aosl_ref_read_argv (ref, f, argc, argv); - } - - static int write (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = aosl_ref_write_args (ref, f, argc, args); - va_end (args); - - return err; - } - - static int write_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args) - { - return aosl_ref_write_args (ref, f, argc, args); - } - - static int write_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) - { - return aosl_ref_write_argv (ref, f, argc, argv); - } - - static int unsafe (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = aosl_ref_unsafe_args (ref, f, argc, args); - va_end (args); - - return err; - } - - static int unsafe_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args) - { - return aosl_ref_unsafe_args (ref, f, argc, args); - } - - static int unsafe_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) - { - return aosl_ref_unsafe_argv (ref, f, argc, argv); - } - - static int read (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = aosl_refobj_read_args (robj, f, argc, args); - va_end (args); - - return err; - } - - static int read_args (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, va_list args) - { - return aosl_refobj_read_args (robj, f, argc, args); - } - - static int read_argv (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) - { - return aosl_refobj_read_argv (robj, f, argc, argv); - } - - static int unsafe (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = aosl_refobj_unsafe_args (robj, f, argc, args); - va_end (args); - - return err; - } - - static int unsafe_args (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, va_list args) - { - return aosl_refobj_unsafe_args (robj, f, argc, args); - } - - static int unsafe_argv (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) - { - return aosl_refobj_unsafe_argv (robj, f, argc, argv); - } - - /* set the living scope ref object of this ref object */ - int set_scope (aosl_ref_t scope_ref) - { - return aosl_ref_set_scope (ref (), scope_ref); - } - - int destroy (bool do_delete = true) - { - if (!aosl_ref_invalid (ref ())) - return aosl_ref_destroy (ref (), (int)do_delete); - - return -1; - } - - #ifdef __AOSL_MPQ_H__ - /* MPQ relative encapsulations */ - public: - int queue (aosl_mpq_t tq, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = aosl_mpq_queue_args (tq, dq, ref (), f_name, f, argc, args); - va_end (args); - - return err; - } - - int queue_args (aosl_mpq_t tq, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args) - { - return aosl_mpq_queue_args (tq, dq, ref (), f_name, f, argc, args); - } - - int queue_argv (aosl_mpq_t tq, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv) - { - return aosl_mpq_queue_argv (tq, dq, ref (), f_name, f, argc, argv); - } - - int queue_data (aosl_mpq_t tq, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_data_t f, size_t len, void *data) - { - return aosl_mpq_queue_data (tq, dq, ref (), f_name, f, len, data); - } - - int call (aosl_mpq_t q, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = aosl_mpq_call_args (q, ref (), f_name, f, argc, args); - va_end (args); - - return err; - } - - int call_args (aosl_mpq_t q, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args) - { - return aosl_mpq_call_args (q, ref (), f_name, f, argc, args); - } - - int call_argv (aosl_mpq_t q, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv) - { - return aosl_mpq_call_argv (q, ref (), f_name, f, argc, argv); - } - - int call_data (aosl_mpq_t q, const char *f_name, aosl_mpq_func_data_t f, size_t len, void *data) - { - return aosl_mpq_call_data (q, ref (), f_name, f, len, data); - } - - int run (aosl_mpq_t q, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = aosl_mpq_run_args (q, dq, ref (), f_name, f, argc, args); - va_end (args); - - return err; - } - - int run_args (aosl_mpq_t q, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args) - { - return aosl_mpq_run_args (q, dq, ref (), f_name, f, argc, args); - } - - int run_argv (aosl_mpq_t q, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv) - { - return aosl_mpq_run_argv (q, dq, ref (), f_name, f, argc, argv); - } - - int run_data (aosl_mpq_t q, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_data_t f, size_t len, void *data) - { - return aosl_mpq_run_data (q, dq, ref (), f_name, f, len, data); - } - - #ifdef __AOSL_MPQP_H__ - /* MPQP relative encapsulations */ - aosl_mpq_t queue (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...) - { - va_list args; - aosl_mpq_t qid; - - va_start (args, argc); - qid = aosl_mpqp_queue_args (qp, dq, ref (), f_name, f, argc, args); - va_end (args); - - return qid; - } - - aosl_mpq_t queue_args (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args) - { - return aosl_mpqp_queue_args (qp, dq, ref (), f_name, f, argc, args); - } - - aosl_mpq_t queue_argv (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv) - { - return aosl_mpqp_queue_argv (qp, dq, ref (), f_name, f, argc, argv); - } - - aosl_mpq_t queue_data (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_data_t f, size_t len, void *data) - { - return aosl_mpqp_queue_data (qp, dq, ref (), f_name, f, len, data); - } - - aosl_mpq_t call (aosl_mpqp_t qp, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...) - { - va_list args; - aosl_mpq_t qid; - - va_start (args, argc); - qid = aosl_mpqp_call_args (qp, ref (), f_name, f, argc, args); - va_end (args); - - return qid; - } - - aosl_mpq_t call_args (aosl_mpqp_t qp, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args) - { - return aosl_mpqp_call_args (qp, ref (), f_name, f, argc, args); - } - - aosl_mpq_t call_argv (aosl_mpqp_t qp, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv) - { - return aosl_mpqp_call_argv (qp, ref (), f_name, f, argc, argv); - } - - aosl_mpq_t call_data (aosl_mpqp_t qp, const char *f_name, aosl_mpq_func_data_t f, size_t len, void *data) - { - return aosl_mpqp_call_data (qp, ref (), f_name, f, len, data); - } - - aosl_mpq_t run (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...) - { - va_list args; - aosl_mpq_t qid; - - va_start (args, argc); - qid = aosl_mpqp_run_args (qp, dq, ref (), f_name, f, argc, args); - va_end (args); - - return qid; - } - - aosl_mpq_t run_args (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args) - { - return aosl_mpqp_run_args (qp, dq, ref (), f_name, f, argc, args); - } - - aosl_mpq_t run_argv (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv) - { - return aosl_mpqp_run_argv (qp, dq, ref (), f_name, f, argc, argv); - } - - aosl_mpq_t run_data (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_data_t f, size_t len, void *data) - { - return aosl_mpqp_run_data (qp, dq, ref (), f_name, f, len, data); - } - - int pool_tail_queue (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = aosl_mpqp_pool_tail_queue_args (qp, dq, ref (), f_name, f, argc, args); - va_end (args); - - return err; - } - - int pool_tail_queue_args (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args) - { - return aosl_mpqp_pool_tail_queue_args (qp, dq, ref (), f_name, f, argc, args); - } - - int pool_tail_queue_argv (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv) - { - return aosl_mpqp_pool_tail_queue_argv (qp, dq, ref (), f_name, f, argc, argv); - } - #endif /* __AOSL_MPQP_H__ */ - #endif /* __AOSL_MPQ_H__ */ - - /* C++11 lambda encapsulations */ - #if (__cplusplus >= 201103) || defined (_MSC_VER) - public: - int hold (aosl_ref_lambda_f &&lambda_f) - { - aosl_ref_lambda_f lambda_obj (std::move (lambda_f)); - return aosl_ref_t_oop::hold (____ref_f, 1, &lambda_obj); - } - - int read (aosl_ref_lambda_f &&lambda_f) - { - aosl_ref_lambda_f lambda_obj (std::move (lambda_f)); - return aosl_ref_t_oop::read (____ref_f, 1, &lambda_obj); - } - - int write (aosl_ref_lambda_f &&lambda_f) - { - aosl_ref_lambda_f lambda_obj (std::move (lambda_f)); - return aosl_ref_t_oop::write (____ref_f, 1, &lambda_obj); - } - - int unsafe (aosl_ref_lambda_f &&lambda_f) - { - aosl_ref_lambda_f lambda_obj (std::move (lambda_f)); - return aosl_ref_t_oop::unsafe (____ref_f, 1, &lambda_obj); - } - - static int hold (aosl_ref_t ref, aosl_ref_lambda_f &&lambda_f) - { - aosl_ref_lambda_f lambda_obj (std::move (lambda_f)); - return aosl_ref_t_oop::hold (ref, ____ref_f, 1, &lambda_obj); - } - - static int read (aosl_ref_t ref, aosl_ref_lambda_f &&lambda_f) - { - aosl_ref_lambda_f lambda_obj (std::move (lambda_f)); - return aosl_ref_t_oop::read (ref, ____ref_f, 1, &lambda_obj); - } - - static int write (aosl_ref_t ref, aosl_ref_lambda_f &&lambda_f) - { - aosl_ref_lambda_f lambda_obj (std::move (lambda_f)); - return aosl_ref_t_oop::write (ref, ____ref_f, 1, &lambda_obj); - } - - static int unsafe (aosl_ref_t ref, aosl_ref_lambda_f &&lambda_f) - { - aosl_ref_lambda_f lambda_obj (std::move (lambda_f)); - return aosl_ref_t_oop::unsafe (ref, ____ref_f, 1, &lambda_obj); - } - - static int read (aosl_refobj_t robj, aosl_ref_lambda_f &&lambda_f) - { - aosl_ref_lambda_f lambda_obj (std::move (lambda_f)); - return aosl_ref_t_oop::read (robj, ____ref_f, 1, &lambda_obj); - } - - static int unsafe (aosl_refobj_t robj, aosl_ref_lambda_f &&lambda_f) - { - aosl_ref_lambda_f lambda_obj (std::move (lambda_f)); - return aosl_ref_t_oop::unsafe (robj, ____ref_f, 1, &lambda_obj); - } - - private: - static void ____ref_f (void *arg, uintptr_t argc, uintptr_t argv []) - { - aosl_ref_lambda_f *lambda_obj = reinterpret_cast(argv [0]); - (*lambda_obj) (arg); - } - - #ifdef __AOSL_MPQ_H__ - public: - /* MPQ encapsulations */ - int queue (aosl_mpq_t tq, aosl_mpq_t dq, const char *f_name, aosl_ref_mpq_lambda_f&& task) - { - aosl_ref_mpq_lambda_f *task_obj = new aosl_ref_mpq_lambda_f (std::move (task)); - int err = aosl_ref_t_oop::queue (tq, dq, f_name, ____mpq_f, 1, task_obj); - if (err < 0) - delete task_obj; - - return err; - } - - int call (aosl_mpq_t q, const char *f_name, aosl_ref_mpq_lambda_f&& task, void *task_result = NULL) - { - aosl_ref_mpq_lambda_f *task_obj = new aosl_ref_mpq_lambda_f (std::move (task)); - int err = aosl_ref_t_oop::call (q, f_name, ____mpq_f, 2, task_obj, task_result); - if (err < 0) - delete task_obj; - - return err; - } - - int run (aosl_mpq_t q, const char *f_name, aosl_ref_mpq_lambda_f&& task) - { - aosl_ref_mpq_lambda_f *task_obj = new aosl_ref_mpq_lambda_f (std::move (task)); - int err = aosl_ref_t_oop::run (q, AOSL_MPQ_INVALID, f_name, ____mpq_f, 1, task_obj); - if (err < 0) - delete task_obj; - - return err; - } - - int queue (aosl_mpq_t tq, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task) - { - aosl_ref_mpq_lambda_0arg_f *task_obj = new aosl_ref_mpq_lambda_0arg_f (std::move (task)); - int err = aosl_ref_t_oop::queue (tq, AOSL_MPQ_INVALID, f_name, ____mpq_0arg_f, 1, task_obj); - if (err < 0) - delete task_obj; - - return err; - } - - int call (aosl_mpq_t q, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task, void *task_result = NULL) - { - aosl_ref_mpq_lambda_0arg_f *task_obj = new aosl_ref_mpq_lambda_0arg_f (std::move (task)); - int err = aosl_ref_t_oop::call (q, f_name, ____mpq_0arg_f, 2, task_obj, task_result); - if (err < 0) - delete task_obj; - - return err; - } - - int run (aosl_mpq_t q, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task) - { - aosl_ref_mpq_lambda_0arg_f *task_obj = new aosl_ref_mpq_lambda_0arg_f (std::move (task)); - int err = aosl_ref_t_oop::run (q, AOSL_MPQ_INVALID, f_name, ____mpq_0arg_f, 1, task_obj); - if (err < 0) - delete task_obj; - - return err; - } - - #ifdef __AOSL_MPQP_H__ - /* MPQP encapsulations */ - aosl_mpq_t queue (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_ref_mpq_lambda_f&& task) - { - aosl_ref_mpq_lambda_f *task_obj = new aosl_ref_mpq_lambda_f (std::move (task)); - aosl_mpq_t qid = aosl_ref_t_oop::queue (qp, dq, f_name, ____mpq_f, 1, task_obj); - if (aosl_mpq_invalid (qid)) - delete task_obj; - - return qid; - } - - aosl_mpq_t call (aosl_mpqp_t qp, const char *f_name, aosl_ref_mpq_lambda_f&& task, void *task_result = NULL) - { - aosl_ref_mpq_lambda_f *task_obj = new aosl_ref_mpq_lambda_f (std::move (task)); - aosl_mpq_t qid = aosl_ref_t_oop::call (qp, f_name, ____mpq_f, 2, task_obj, task_result); - if (aosl_mpq_invalid (qid)) - delete task_obj; - - return qid; - } - - aosl_mpq_t run (aosl_mpqp_t qp, const char *f_name, aosl_ref_mpq_lambda_f&& task) - { - aosl_ref_mpq_lambda_f *task_obj = new aosl_ref_mpq_lambda_f (std::move (task)); - aosl_mpq_t qid = aosl_ref_t_oop::run (qp, AOSL_MPQ_INVALID, f_name, ____mpq_f, 1, task_obj); - if (aosl_mpq_invalid (qid)) - delete task_obj; - - return qid; - } - - int pool_tail_queue (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_ref_mpq_lambda_f&& task) - { - aosl_ref_mpq_lambda_f *task_obj = new aosl_ref_mpq_lambda_f (std::move (task)); - int err = aosl_ref_t_oop::pool_tail_queue (qp, dq, f_name, ____mpq_f, 1, task_obj); - if (err < 0) - delete task_obj; - - return err; - } - - aosl_mpq_t queue (aosl_mpqp_t qp, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task) - { - aosl_ref_mpq_lambda_0arg_f *task_obj = new aosl_ref_mpq_lambda_0arg_f (std::move (task)); - aosl_mpq_t qid = aosl_ref_t_oop::queue (qp, AOSL_MPQ_INVALID, f_name, ____mpq_0arg_f, 1, task_obj); - if (aosl_mpq_invalid (qid)) - delete task_obj; - - return qid; - } - - aosl_mpq_t call (aosl_mpqp_t qp, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task, void *task_result = NULL) - { - aosl_ref_mpq_lambda_0arg_f *task_obj = new aosl_ref_mpq_lambda_0arg_f (std::move (task)); - aosl_mpq_t qid = aosl_ref_t_oop::call (qp, f_name, ____mpq_0arg_f, 2, task_obj, task_result); - if (aosl_mpq_invalid (qid)) - delete task_obj; - - return qid; - } - - aosl_mpq_t run (aosl_mpqp_t qp, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task) - { - aosl_ref_mpq_lambda_0arg_f *task_obj = new aosl_ref_mpq_lambda_0arg_f (std::move (task)); - aosl_mpq_t qid = aosl_ref_t_oop::run (qp, AOSL_MPQ_INVALID, f_name, ____mpq_0arg_f, 1, task_obj); - if (aosl_mpq_invalid (qid)) - delete task_obj; - - return qid; - } - - int pool_tail_queue (aosl_mpqp_t qp, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task) - { - aosl_ref_mpq_lambda_0arg_f *task_obj = new aosl_ref_mpq_lambda_0arg_f (std::move (task)); - int err = aosl_ref_t_oop::pool_tail_queue (qp, AOSL_MPQ_INVALID, f_name, ____mpq_0arg_f, 1, task_obj); - if (err < 0) - delete task_obj; - - return err; - } - #endif /* __AOSL_MPQP_H__ */ - - /* MPQ with specified ref encapsulations */ - static int queue (aosl_mpq_t tq, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_f&& task) - { - aosl_ref_mpq_lambda_f *task_obj = new aosl_ref_mpq_lambda_f (std::move (task)); - int err = aosl_mpq_queue (tq, dq, ref, f_name, ____mpq_f, 1, task_obj); - if (err < 0) - delete task_obj; - - return err; - } - - static int call (aosl_mpq_t q, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_f&& task, void *task_result = NULL) - { - aosl_ref_mpq_lambda_f *task_obj = new aosl_ref_mpq_lambda_f (std::move (task)); - int err = aosl_mpq_call (q, ref, f_name, ____mpq_f, 2, task_obj, task_result); - if (err < 0) - delete task_obj; - - return err; - } - - static int run (aosl_mpq_t q, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_f&& task) - { - aosl_ref_mpq_lambda_f *task_obj = new aosl_ref_mpq_lambda_f (std::move (task)); - int err = aosl_mpq_run (q, AOSL_MPQ_INVALID, ref, f_name, ____mpq_f, 1, task_obj); - if (err < 0) - delete task_obj; - - return err; - } - - static int queue (aosl_mpq_t tq, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task) - { - aosl_ref_mpq_lambda_0arg_f *task_obj = new aosl_ref_mpq_lambda_0arg_f (std::move (task)); - int err = aosl_mpq_queue (tq, AOSL_MPQ_INVALID, ref, f_name, ____mpq_0arg_f, 1, task_obj); - if (err < 0) - delete task_obj; - - return err; - } - - static int call (aosl_mpq_t q, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task, void *task_result = NULL) - { - aosl_ref_mpq_lambda_0arg_f *task_obj = new aosl_ref_mpq_lambda_0arg_f (std::move (task)); - int err = aosl_mpq_call (q, ref, f_name, ____mpq_0arg_f, 2, task_obj, task_result); - if (err < 0) - delete task_obj; - - return err; - } - - static int run (aosl_mpq_t q, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task) - { - aosl_ref_mpq_lambda_0arg_f *task_obj = new aosl_ref_mpq_lambda_0arg_f (std::move (task)); - int err = aosl_mpq_run (q, AOSL_MPQ_INVALID, ref, f_name, ____mpq_0arg_f, 1, task_obj); - if (err < 0) - delete task_obj; - - return err; - } - - #ifdef __AOSL_MPQP_H__ - /* MPQP with specified ref encapsulations */ - static aosl_mpq_t queue (aosl_mpqp_t qp, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_f&& task) - { - aosl_ref_mpq_lambda_f *task_obj = new aosl_ref_mpq_lambda_f (std::move (task)); - aosl_mpq_t qid = aosl_mpqp_queue (qp, dq, ref, f_name, ____mpq_f, 1, task_obj); - if (aosl_mpq_invalid (qid)) - delete task_obj; - - return qid; - } - - static aosl_mpq_t call (aosl_mpqp_t qp, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_f&& task, void *task_result = NULL) - { - aosl_ref_mpq_lambda_f *task_obj = new aosl_ref_mpq_lambda_f (std::move (task)); - aosl_mpq_t qid = aosl_mpqp_call (qp, ref, f_name, ____mpq_f, 2, task_obj, task_result); - if (aosl_mpq_invalid (qid)) - delete task_obj; - - return qid; - } - - static aosl_mpq_t run (aosl_mpqp_t qp, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_f&& task) - { - aosl_ref_mpq_lambda_f *task_obj = new aosl_ref_mpq_lambda_f (std::move (task)); - aosl_mpq_t qid = aosl_mpqp_run (qp, AOSL_MPQ_INVALID, ref, f_name, ____mpq_f, 1, task_obj); - if (aosl_mpq_invalid (qid)) - delete task_obj; - - return qid; - } - - static int pool_tail_queue (aosl_mpqp_t qp, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_f&& task) - { - aosl_ref_mpq_lambda_f *task_obj = new aosl_ref_mpq_lambda_f (std::move (task)); - int err = aosl_mpqp_pool_tail_queue (qp, dq, ref, f_name, ____mpq_f, 1, task_obj); - if (err < 0) - delete task_obj; - - return err; - } - - static aosl_mpq_t queue (aosl_mpqp_t qp, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task) - { - aosl_ref_mpq_lambda_0arg_f *task_obj = new aosl_ref_mpq_lambda_0arg_f (std::move (task)); - aosl_mpq_t qid = aosl_mpqp_queue (qp, AOSL_MPQ_INVALID, ref, f_name, ____mpq_0arg_f, 1, task_obj); - if (aosl_mpq_invalid (qid)) - delete task_obj; - - return qid; - } - - static aosl_mpq_t call (aosl_mpqp_t qp, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task, void *task_result = NULL) - { - aosl_ref_mpq_lambda_0arg_f *task_obj = new aosl_ref_mpq_lambda_0arg_f (std::move (task)); - aosl_mpq_t qid = aosl_mpqp_call (qp, ref, f_name, ____mpq_0arg_f, 2, task_obj, task_result); - if (aosl_mpq_invalid (qid)) - delete task_obj; - - return qid; - } - - static aosl_mpq_t run (aosl_mpqp_t qp, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task) - { - aosl_ref_mpq_lambda_0arg_f *task_obj = new aosl_ref_mpq_lambda_0arg_f (std::move (task)); - aosl_mpq_t qid = aosl_mpqp_run (qp, AOSL_MPQ_INVALID, ref, f_name, ____mpq_0arg_f, 1, task_obj); - if (aosl_mpq_invalid (qid)) - delete task_obj; - - return qid; - } - - static int pool_tail_queue (aosl_mpqp_t qp, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task) - { - aosl_ref_mpq_lambda_0arg_f *task_obj = new aosl_ref_mpq_lambda_0arg_f (std::move (task)); - int err = aosl_mpqp_pool_tail_queue (qp, AOSL_MPQ_INVALID, ref, f_name, ____mpq_0arg_f, 1, task_obj); - if (err < 0) - delete task_obj; - - return err; - } - #endif /* __AOSL_MPQP_H__ */ - - static void *call_result_var_addr (void) - { - void *var_addr; - - if (aosl_mpq_run_func_arg (1, (uintptr_t *)&var_addr) < 0) - return NULL; - - return var_addr; - } - - private: - static void ____mpq_f (const aosl_ts_t *queued_ts_p, aosl_refobj_t robj, uintptr_t argc, uintptr_t argv []) - { - aosl_ref_mpq_lambda_f *task_obj = reinterpret_cast(argv [0]); - aosl_mpq_t done_qid = aosl_mpq_run_func_done_qid (); - (*task_obj) (*queued_ts_p, robj); - if (aosl_mpq_invalid (done_qid) || aosl_is_free_only (robj)) { - /** - * We only free the task object when the running function has no - * done mpq id, due to the task object would be still in use if - * the function has a done mpq id when queuing back to the done - * mpq. - * -- Lionfore Hao Nov 19th, 2018 - **/ - delete task_obj; - } - } - - static void ____mpq_0arg_f (const aosl_ts_t *queued_ts_p, aosl_refobj_t robj, uintptr_t argc, uintptr_t argv []) - { - aosl_ref_mpq_lambda_0arg_f *task_obj = reinterpret_cast(argv [0]); - aosl_mpq_t done_qid = aosl_mpq_run_func_done_qid (); - if (!aosl_is_free_only (robj)) - (*task_obj) (); - if (aosl_mpq_invalid (done_qid) || aosl_is_free_only (robj)) { - /** - * We only free the task object when the running function has no - * done mpq id, due to the task object would be still in use if - * the function has a done mpq id when queuing back to the done - * mpq. - * -- Lionfore Hao Nov 19th, 2018 - **/ - delete task_obj; - } - } - #endif /* __AOSL_MPQ_H__ */ - - #ifdef __AOSL_ASYNC_H__ - /** - * The stackless coroutine like implementation in AOSL. We could not - * support the real stackless coroutine except in the language level, - * so we just provide similar equivalent functionals here. - **/ - public: - int prepare (aosl_stack_id_t stack_id, const char *f_name, aosl_async_prepare_lambda_f&& task) - { - aosl_async_prepare_lambda_f *prepare_f = new aosl_async_prepare_lambda_f (std::move (task)); - int err = aosl_async_prepare (stack_id, ref (), f_name, ____async_prepare_f, 1, prepare_f); - if (err < 0) - delete prepare_f; - - return err; - } - - static int prepare (aosl_stack_id_t stack_id, aosl_ref_t ref, const char *f_name, aosl_async_prepare_lambda_f&& task) - { - aosl_async_prepare_lambda_f *prepare_f = new aosl_async_prepare_lambda_f (std::move (task)); - int err = aosl_async_prepare (stack_id, ref, f_name, ____async_prepare_f, 1, prepare_f); - if (err < 0) - delete prepare_f; - - return err; - } - - private: - static int ____async_prepare_f (int free_only, uintptr_t argc, uintptr_t argv []) - { - aosl_async_prepare_lambda_f *prepare_f = reinterpret_cast(argv [0]); - int err; - err = (*prepare_f) (free_only); - delete prepare_f; - return err; - } - - public: - int resume (aosl_stack_id_t stack_id, const char *f_name, aosl_async_resume_lambda_f&& task) - { - aosl_async_resume_lambda_f *resume_f = new aosl_async_resume_lambda_f (std::move (task)); - int err = aosl_async_resume (stack_id, ref (), f_name, ____async_resume_f, 1, resume_f); - if (err < 0) - delete resume_f; - - return err; - } - - static int resume (aosl_stack_id_t stack_id, aosl_ref_t ref, const char *f_name, aosl_async_resume_lambda_f&& task) - { - aosl_async_resume_lambda_f *resume_f = new aosl_async_resume_lambda_f (std::move (task)); - int err = aosl_async_resume (stack_id, ref, f_name, ____async_resume_f, 1, resume_f); - if (err < 0) - delete resume_f; - - return err; - } - - private: - static void ____async_resume_f (int free_only, uintptr_t argc, uintptr_t argv []) - { - aosl_async_resume_lambda_f *resume_f = reinterpret_cast(argv [0]); - (*resume_f) (free_only); - delete resume_f; - } - #endif /* __AOSL_ASYNC_H__ */ - #endif /* C++11 */ - - #if (__cplusplus >= 201103) || defined (_MSC_VER) - private: - aosl_ref_t_oop (const aosl_ref_t_oop &) = delete; - aosl_ref_t_oop (aosl_ref_t_oop &&) = delete; - aosl_ref_t_oop &operator = (const aosl_ref_t_oop &) = delete; - aosl_ref_t_oop &operator = (aosl_ref_t_oop &&) = delete; - #else - private: - aosl_ref_t_oop (const aosl_ref_t_oop &); - aosl_ref_t_oop &operator = (const aosl_ref_t_oop &); - #endif /* C++11 */ - }; - -private: - aosl_ref_t_oop *refoop; - -public: - aosl_ref_class (bool caller_free = true) - { - refoop = aosl_ref_t_oop::create (this, __dtor, caller_free); - if (aosl_ref_invalid (refoop)) - abort (); - } - - aosl_ref_class (aosl_ref_t_oop *obj) - { - refoop = obj; - } - - aosl_ref_class (aosl_ref_t ref) - { - refoop = aosl_ref_t_oop::from_aosl_ref_t (ref); - } - - aosl_ref_t_oop *ref_oop () const - { - return refoop; - } - - aosl_ref_t ref () const - { - return refoop->ref (); - } - - int hold (aosl_ref_func_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = refoop->hold_args (f, argc, args); - va_end (args); - - return err; - } - - int hold_args (aosl_ref_func_t f, uintptr_t argc, va_list args) - { - return refoop->hold_args (f, argc, args); - } - - int hold_argv (aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) - { - return refoop->hold_argv (f, argc, argv); - } - - int read (aosl_ref_func_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = refoop->read_args (f, argc, args); - va_end (args); - - return err; - } - - int read_args (aosl_ref_func_t f, uintptr_t argc, va_list args) - { - return refoop->read_args (f, argc, args); - } - - int read_argv (aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) - { - return refoop->read_argv (f, argc, argv); - } - - int write (aosl_ref_func_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = refoop->write_args (f, argc, args); - va_end (args); - - return err; - } - - int write_args (aosl_ref_func_t f, uintptr_t argc, va_list args) - { - return refoop->write_args (f, argc, args); - } - - int write_argv (aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) - { - return refoop->write_argv (f, argc, argv); - } - - int unsafe (aosl_ref_func_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = refoop->unsafe_args (f, argc, args); - va_end (args); - - return err; - } - - int unsafe_args (aosl_ref_func_t f, uintptr_t argc, va_list args) - { - return refoop->unsafe_args (f, argc, args); - } - - int unsafe_argv (aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) - { - return refoop->unsafe_argv (f, argc, argv); - } - - int maystall (aosl_ref_func_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = refoop->unsafe_args (f, argc, args); - va_end (args); - - return err; - } - - int maystall_args (aosl_ref_func_t f, uintptr_t argc, va_list args) - { - return refoop->unsafe_args (f, argc, args); - } - - int maystall_argv (aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) - { - return refoop->unsafe_argv (f, argc, argv); - } - - /* The static version of member functions */ - static int hold (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = aosl_ref_t_oop::hold_args (ref, f, argc, args); - va_end (args); - - return err; - } - - static int hold_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args) - { - return aosl_ref_t_oop::hold_args (ref, f, argc, args); - } - - static int hold_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) - { - return aosl_ref_t_oop::hold_argv (ref, f, argc, argv); - } - - static int read (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = aosl_ref_t_oop::read_args (ref, f, argc, args); - va_end (args); - - return err; - } - - static int read_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args) - { - return aosl_ref_t_oop::read_args (ref, f, argc, args); - } - - static int read_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) - { - return aosl_ref_t_oop::read_argv (ref, f, argc, argv); - } - - static int write (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = aosl_ref_t_oop::write_args (ref, f, argc, args); - va_end (args); - - return err; - } - - static int write_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args) - { - return aosl_ref_t_oop::write_args (ref, f, argc, args); - } - - static int write_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) - { - return aosl_ref_t_oop::write_argv (ref, f, argc, argv); - } - - static int unsafe (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = aosl_ref_t_oop::unsafe_args (ref, f, argc, args); - va_end (args); - - return err; - } - - static int unsafe_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args) - { - return aosl_ref_t_oop::unsafe_args (ref, f, argc, args); - } - - static int unsafe_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) - { - return aosl_ref_t_oop::unsafe_argv (ref, f, argc, argv); - } - - static int maystall (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = aosl_ref_t_oop::unsafe_args (ref, f, argc, args); - va_end (args); - - return err; - } - - static int maystall_args (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, va_list args) - { - return aosl_ref_t_oop::unsafe_args (ref, f, argc, args); - } - - static int maystall_argv (aosl_ref_t ref, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) - { - return aosl_ref_t_oop::unsafe_argv (ref, f, argc, argv); - } - - static int read (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = aosl_ref_t_oop::read_args (robj, f, argc, args); - va_end (args); - - return err; - } - - static int read_args (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, va_list args) - { - return aosl_ref_t_oop::read_args (robj, f, argc, args); - } - - static int read_argv (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) - { - return aosl_ref_t_oop::read_argv (robj, f, argc, argv); - } - - static int unsafe (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = aosl_ref_t_oop::unsafe_args (robj, f, argc, args); - va_end (args); - - return err; - } - - static int unsafe_args (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, va_list args) - { - return aosl_ref_t_oop::unsafe_args (robj, f, argc, args); - } - - static int unsafe_argv (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) - { - return aosl_ref_t_oop::unsafe_argv (robj, f, argc, argv); - } - - static int maystall (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = aosl_ref_t_oop::unsafe_args (robj, f, argc, args); - va_end (args); - - return err; - } - - static int maystall_args (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, va_list args) - { - return aosl_ref_t_oop::unsafe_args (robj, f, argc, args); - } - - static int maystall_argv (aosl_refobj_t robj, aosl_ref_func_t f, uintptr_t argc, uintptr_t argv []) - { - return aosl_ref_t_oop::unsafe_argv (robj, f, argc, argv); - } - - static aosl_ref_class *from_refobj (aosl_refobj_t robj) - { - return (aosl_ref_class *)aosl_refobj_arg (robj); - } - - /* set the living scope ref object of this ref object */ - int set_scope (aosl_ref_t scope_ref) - { - return refoop->set_scope (scope_ref); - } - - int destroy (bool do_delete = true) - { - int err = refoop->destroy (do_delete); - if (err < 0 && do_delete) { - ::delete this; - return 0; - } - - return err; - } - -public: - class deleter { - public: - void operator () (aosl_ref_class *obj_ptr) const - { - if (obj_ptr != NULL) - obj_ptr->destroy (); - } - }; - -protected: - /* We do not allow delete this object directly. */ - virtual ~aosl_ref_class () - { - } - -private: - static void __dtor (void *arg) - { - aosl_ref_class *__this = (aosl_ref_class *)arg; - ::delete __this; - } - -#ifdef __AOSL_MPQ_H__ - /* MPQ relative encapsulations */ -public: - int queue (aosl_mpq_t tq, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = refoop->queue_args (tq, dq, f_name, f, argc, args); - va_end (args); - - return err; - } - - int queue_args (aosl_mpq_t tq, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args) - { - return refoop->queue_args (tq, dq, f_name, f, argc, args); - } - - int queue_argv (aosl_mpq_t tq, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv) - { - return refoop->queue_argv (tq, dq, f_name, f, argc, argv); - } - - int queue_data (aosl_mpq_t tq, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_data_t f, size_t len, void *data) - { - return refoop->queue_data (tq, dq, f_name, f, len, data); - } - - int call (aosl_mpq_t q, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = refoop->call_args (q, f_name, f, argc, args); - va_end (args); - - return err; - } - - int call_args (aosl_mpq_t q, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args) - { - return refoop->call_args (q, f_name, f, argc, args); - } - - int call_argv (aosl_mpq_t q, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv) - { - return refoop->call_argv (q, f_name, f, argc, argv); - } - - int call_data (aosl_mpq_t q, const char *f_name, aosl_mpq_func_data_t f, size_t len, void *data) - { - return refoop->call_data (q, f_name, f, len, data); - } - - int run (aosl_mpq_t q, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = refoop->run_args (q, dq, f_name, f, argc, args); - va_end (args); - - return err; - } - - int run_args (aosl_mpq_t q, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args) - { - return refoop->run_args (q, dq, f_name, f, argc, args); - } - - int run_argv (aosl_mpq_t q, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv) - { - return refoop->run_argv (q, dq, f_name, f, argc, argv); - } - - int run_data (aosl_mpq_t q, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_data_t f, size_t len, void *data) - { - return refoop->run_data (q, dq, f_name, f, len, data); - } - -#ifdef __AOSL_MPQP_H__ - /* MPQP relative encapsulations */ - aosl_mpq_t queue (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...) - { - va_list args; - aosl_mpq_t qid; - - va_start (args, argc); - qid = refoop->queue_args (qp, dq, f_name, f, argc, args); - va_end (args); - - return qid; - } - - aosl_mpq_t queue_args (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args) - { - return refoop->queue_args (qp, dq, f_name, f, argc, args); - } - - aosl_mpq_t queue_argv (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv) - { - return refoop->queue_argv (qp, dq, f_name, f, argc, argv); - } - - aosl_mpq_t queue_data (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_data_t f, size_t len, void *data) - { - return refoop->queue_data (qp, dq, f_name, f, len, data); - } - - aosl_mpq_t call (aosl_mpqp_t qp, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...) - { - va_list args; - aosl_mpq_t qid; - - va_start (args, argc); - qid = refoop->call_args (qp, f_name, f, argc, args); - va_end (args); - - return qid; - } - - aosl_mpq_t call_args (aosl_mpqp_t qp, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args) - { - return refoop->call_args (qp, f_name, f, argc, args); - } - - aosl_mpq_t call_argv (aosl_mpqp_t qp, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv) - { - return refoop->call_argv (qp, f_name, f, argc, argv); - } - - aosl_mpq_t call_data (aosl_mpqp_t qp, const char *f_name, aosl_mpq_func_data_t f, size_t len, void *data) - { - return refoop->call_data (qp, f_name, f, len, data); - } - - aosl_mpq_t run (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...) - { - va_list args; - aosl_mpq_t qid; - - va_start (args, argc); - qid = refoop->run_args (qp, dq, f_name, f, argc, args); - va_end (args); - - return qid; - } - - aosl_mpq_t run_args (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args) - { - return refoop->run_args (qp, dq, f_name, f, argc, args); - } - - aosl_mpq_t run_argv (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv) - { - return refoop->run_argv (qp, dq, f_name, f, argc, argv); - } - - aosl_mpq_t run_data (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_data_t f, size_t len, void *data) - { - return refoop->run_data (qp, dq, f_name, f, len, data); - } - - int pool_tail_queue (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = refoop->pool_tail_queue_args (qp, dq, f_name, f, argc, args); - va_end (args); - - return err; - } - - int pool_tail_queue_args (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, va_list args) - { - return refoop->pool_tail_queue_args (qp, dq, f_name, f, argc, args); - } - - int pool_tail_queue_argv (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv) - { - return refoop->pool_tail_queue_argv (qp, dq, f_name, f, argc, argv); - } -#endif /* __AOSL_MPQP_H__ */ -#endif /* __AOSL_MPQ_H__ */ - - /* C++11 lambda encapsulations */ -#if (__cplusplus >= 201103) || defined (_MSC_VER) -public: - int hold (aosl_ref_lambda_f &&lambda_f) - { - return refoop->hold (std::move (lambda_f)); - } - - int read (aosl_ref_lambda_f &&lambda_f) - { - return refoop->read (std::move (lambda_f)); - } - - int write (aosl_ref_lambda_f &&lambda_f) - { - return refoop->write (std::move (lambda_f)); - } - - int unsafe (aosl_ref_lambda_f &&lambda_f) - { - return refoop->unsafe (std::move (lambda_f)); - } - - int maystall (aosl_ref_lambda_f &&lambda_f) - { - return refoop->unsafe (std::move (lambda_f)); - } - - static int hold (aosl_ref_t ref, aosl_ref_lambda_f &&lambda_f) - { - return aosl_ref_t_oop::hold (ref, std::move (lambda_f)); - } - - static int read (aosl_ref_t ref, aosl_ref_lambda_f &&lambda_f) - { - return aosl_ref_t_oop::read (ref, std::move (lambda_f)); - } - - static int write (aosl_ref_t ref, aosl_ref_lambda_f &&lambda_f) - { - return aosl_ref_t_oop::write (ref, std::move (lambda_f)); - } - - static int unsafe (aosl_ref_t ref, aosl_ref_lambda_f &&lambda_f) - { - return aosl_ref_t_oop::unsafe (ref, std::move (lambda_f)); - } - - static int maystall (aosl_ref_t ref, aosl_ref_lambda_f &&lambda_f) - { - return aosl_ref_t_oop::unsafe (ref, std::move (lambda_f)); - } - - static int read (aosl_refobj_t robj, aosl_ref_lambda_f &&lambda_f) - { - return aosl_ref_t_oop::read (robj, std::move (lambda_f)); - } - - static int unsafe (aosl_refobj_t robj, aosl_ref_lambda_f &&lambda_f) - { - return aosl_ref_t_oop::unsafe (robj, std::move (lambda_f)); - } - - static int maystall (aosl_refobj_t robj, aosl_ref_lambda_f &&lambda_f) - { - return aosl_ref_t_oop::unsafe (robj, std::move (lambda_f)); - } - -#ifdef __AOSL_MPQ_H__ -public: - typedef std::function aosl_ref_mpq_lambda_f; - typedef std::function aosl_ref_mpq_lambda_0arg_f; - - /* MPQ encapsulations */ - int queue (aosl_mpq_t tq, aosl_mpq_t dq, const char *f_name, aosl_ref_mpq_lambda_f&& task) - { - return refoop->queue (tq, dq, f_name, std::move (task)); - } - - int call (aosl_mpq_t q, const char *f_name, aosl_ref_mpq_lambda_f&& task, void *task_result = NULL) - { - return refoop->call (q, f_name, std::move (task), task_result); - } - - int run (aosl_mpq_t q, const char *f_name, aosl_ref_mpq_lambda_f&& task) - { - return refoop->run (q, f_name, std::move (task)); - } - - int queue (aosl_mpq_t tq, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task) - { - return refoop->queue (tq, f_name, std::move (task)); - } - - int call (aosl_mpq_t q, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task, void *task_result = NULL) - { - return refoop->call (q, f_name, std::move (task), task_result); - } - - int run (aosl_mpq_t q, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task) - { - return refoop->run (q, f_name, std::move (task)); - } - -#ifdef __AOSL_MPQP_H__ - /* MPQP encapsulations */ - aosl_mpq_t queue (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_ref_mpq_lambda_f&& task) - { - return refoop->queue (qp, dq, f_name, std::move (task)); - } - - aosl_mpq_t call (aosl_mpqp_t qp, const char *f_name, aosl_ref_mpq_lambda_f&& task, void *task_result = NULL) - { - return refoop->call (qp, f_name, std::move (task), task_result); - } - - aosl_mpq_t run (aosl_mpqp_t qp, const char *f_name, aosl_ref_mpq_lambda_f&& task) - { - return refoop->run (qp, f_name, std::move (task)); - } - - int pool_tail_queue (aosl_mpqp_t qp, aosl_mpq_t dq, const char *f_name, aosl_ref_mpq_lambda_f&& task) - { - return refoop->pool_tail_queue (qp, dq, f_name, std::move (task)); - } - - aosl_mpq_t queue (aosl_mpqp_t qp, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task) - { - return refoop->queue (qp, f_name, std::move (task)); - } - - aosl_mpq_t call (aosl_mpqp_t qp, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task, void *task_result = NULL) - { - return refoop->call (qp, f_name, std::move (task), task_result); - } - - aosl_mpq_t run (aosl_mpqp_t qp, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task) - { - return refoop->run (qp, f_name, std::move (task)); - } - - int pool_tail_queue (aosl_mpqp_t qp, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task) - { - return refoop->pool_tail_queue (qp, f_name, std::move (task)); - } -#endif /* __AOSL_MPQP_H__ */ - - /* MPQ with specified ref encapsulations */ - static int queue (aosl_mpq_t tq, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_f&& task) - { - return aosl_ref_t_oop::queue (tq, dq, ref, f_name, std::move (task)); - } - - static int call (aosl_mpq_t q, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_f&& task, void *task_result = NULL) - { - return aosl_ref_t_oop::call (q, ref, f_name, std::move (task), task_result); - } - - static int run (aosl_mpq_t q, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_f&& task) - { - return aosl_ref_t_oop::run (q, ref, f_name, std::move (task)); - } - - static int queue (aosl_mpq_t tq, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task) - { - return aosl_ref_t_oop::queue (tq, ref, f_name, std::move (task)); - } - - static int call (aosl_mpq_t q, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task, void *task_result = NULL) - { - return aosl_ref_t_oop::call (q, ref, f_name, std::move (task), task_result); - } - - static int run (aosl_mpq_t q, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task) - { - return aosl_ref_t_oop::run (q, ref, f_name, std::move (task)); - } - -#ifdef __AOSL_MPQP_H__ - /* MPQP with specified ref encapsulations */ - static aosl_mpq_t queue (aosl_mpqp_t qp, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_f&& task) - { - return aosl_ref_t_oop::queue (qp, dq, ref, f_name, std::move (task)); - } - - static aosl_mpq_t call (aosl_mpqp_t qp, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_f&& task, void *task_result = NULL) - { - return aosl_ref_t_oop::call (qp, ref, f_name, std::move (task), task_result); - } - - static aosl_mpq_t run (aosl_mpqp_t qp, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_f&& task) - { - return aosl_ref_t_oop::run (qp, ref, f_name, std::move (task)); - } - - static int pool_tail_queue (aosl_mpqp_t qp, aosl_mpq_t dq, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_f&& task) - { - return aosl_ref_t_oop::pool_tail_queue (qp, dq, ref, f_name, std::move (task)); - } - - static aosl_mpq_t queue (aosl_mpqp_t qp, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task) - { - return aosl_ref_t_oop::queue (qp, ref, f_name, std::move (task)); - } - - static aosl_mpq_t call (aosl_mpqp_t qp, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task, void *task_result = NULL) - { - return aosl_ref_t_oop::call (qp, ref, f_name, std::move (task), task_result); - } - - static aosl_mpq_t run (aosl_mpqp_t qp, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task) - { - return aosl_ref_t_oop::run (qp, ref, f_name, std::move (task)); - } - - static int pool_tail_queue (aosl_mpqp_t qp, aosl_ref_t ref, const char *f_name, aosl_ref_mpq_lambda_0arg_f&& task) - { - return aosl_ref_t_oop::pool_tail_queue (qp, ref, f_name, std::move (task)); - } -#endif /* __AOSL_MPQP_H__ */ -#endif /* __AOSL_MPQ_H__ */ - -#ifdef __AOSL_ASYNC_H__ - /** - * The stackless coroutine like implementation in AOSL. We could not - * support the real stackless coroutine except in the language level, - * so we just provide similar equivalent functionals here. - **/ -public: - int prepare (aosl_stack_id_t stack_id, const char *f_name, aosl_async_prepare_lambda_f&& task) - { - return refoop->prepare (stack_id, f_name, std::move (task)); - } - - static int prepare (aosl_stack_id_t stack_id, aosl_ref_t ref, const char *f_name, aosl_async_prepare_lambda_f&& task) - { - return aosl_ref_t_oop::prepare (stack_id, ref, f_name, std::move (task)); - } - -public: - typedef std::function aosl_async_resume_lambda_f; - - int resume (aosl_stack_id_t stack_id, const char *f_name, aosl_async_resume_lambda_f&& task) - { - return refoop->resume (stack_id, f_name, std::move (task)); - } - - static int resume (aosl_stack_id_t stack_id, aosl_ref_t ref, const char *f_name, aosl_async_resume_lambda_f&& task) - { - return aosl_ref_t_oop::resume (stack_id, ref, f_name, std::move (task)); - } -#endif /* __AOSL_ASYNC_H__ */ -#endif /* C++11 */ - -#if (__cplusplus >= 201103) || defined (_MSC_VER) -private: - aosl_ref_class (const aosl_ref_class &) = delete; - aosl_ref_class (aosl_ref_class &&) = delete; - aosl_ref_class &operator = (const aosl_ref_class &) = delete; - aosl_ref_class &operator = (aosl_ref_class &&) = delete; -#else -private: - aosl_ref_class (const aosl_ref_class &); - aosl_ref_class &operator = (const aosl_ref_class &); -#endif /* C++11 */ -}; - - -/** - * The T_ref_cls argument of this template must be - * aosl_ref_class or its derivatives. - **/ -template -class aosl_ref_unique_ptr { -private: - T_ref_cls *_ptr; - -public: - aosl_ref_unique_ptr (): _ptr (NULL) {} - aosl_ref_unique_ptr (T_ref_cls *p): _ptr (p) {} - - aosl_ref_unique_ptr &operator = (T_ref_cls *p) - { - reset (); - _ptr = p; - return *this; - } - - T_ref_cls *operator -> () const - { - return _ptr; - } - - T_ref_cls *get () const - { - return _ptr; - } - - operator bool () const - { - return _ptr != NULL; - } - - T_ref_cls *release () - { - T_ref_cls *p = _ptr; - _ptr = NULL; - return p; - } - - void reset (T_ref_cls *p = NULL) - { - T_ref_cls *old = _ptr; - - /** - * We do the destroy and not delete the object - * before we set the pointer to the new value, - * this is very important to make sure that no - * any async operation is executing. - **/ - if (old != NULL) - old->destroy (false/* not delete */); - - _ptr = p; - - /** - * The destroy with delete operation must be - * the last action, and don't touch any member - * of this object anymore after it. - **/ - if (old != NULL) - old->destroy (true/* do delete */); - } - - ~aosl_ref_unique_ptr () - { - reset (); - } - -#if (__cplusplus >= 201103) || defined (_MSC_VER) -private: - aosl_ref_unique_ptr (const aosl_ref_unique_ptr &) = delete; - aosl_ref_unique_ptr &operator = (const aosl_ref_unique_ptr &) = delete; - -public: - aosl_ref_unique_ptr (aosl_ref_unique_ptr &&src): _ptr (src.release ()) {} - aosl_ref_unique_ptr &operator = (aosl_ref_unique_ptr &&ptr) - { - reset (ptr.release ()); - return *this; - } -#else -private: - aosl_ref_unique_ptr (const aosl_ref_unique_ptr &); - aosl_ref_unique_ptr &operator = (const aosl_ref_unique_ptr &); -#endif /* C++11 */ -}; - - -template -inline bool operator == (const aosl_ref_unique_ptr &ptr, intptr_t _null) -{ - return ptr.get () == (T_ref_cls *)_null; -} - -template -inline bool operator != (const aosl_ref_unique_ptr &ptr, intptr_t _null) -{ - return ptr.get () != (T_ref_cls *)_null; -} - -template -inline bool operator == (intptr_t _null, const aosl_ref_unique_ptr &ptr) -{ - return (T_ref_cls *)_null == ptr.get (); -} - -template -inline bool operator != (intptr_t _null, const aosl_ref_unique_ptr &ptr) -{ - return (T_ref_cls *)_null != ptr.get (); -} - -#if (__cplusplus >= 201103) || defined (_MSC_VER) -template -inline bool operator == (const aosl_ref_unique_ptr &ptr, std::nullptr_t) -{ - return !ptr; -} - -template -inline bool operator != (const aosl_ref_unique_ptr &ptr, std::nullptr_t) -{ - return ptr; -} - -template -inline bool operator == (std::nullptr_t, const aosl_ref_unique_ptr &ptr) -{ - return !ptr; -} - -template -inline bool operator != (std::nullptr_t, const aosl_ref_unique_ptr &ptr) -{ - return ptr; -} -#endif /* C++11 */ - - -typedef aosl_ref_unique_ptr aosl_ref_class_unique_ptr; - - -#endif /* __AOSL_REF_OBJ_CPP_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_sbus_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_sbus_class.h deleted file mode 100644 index fe853a1fc..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_sbus_class.h +++ /dev/null @@ -1,180 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : May 6th, 2024 - * Module: AOSL software bus relative API C++ definition file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 ~ 2024 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_SBUS_CPP_H__ -#define __AOSL_SBUS_CPP_H__ - - -/* C++11 lambda encapsulations */ -#if (__cplusplus >= 201103) || defined (_MSC_VER) -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - - -class aosl_sbus_class_base { -private: - aosl_sbus_class_base () = delete; - aosl_sbus_class_base (const aosl_sbus_class_base &) = delete; - aosl_sbus_class_base (aosl_sbus_class_base &&) = delete; - aosl_sbus_class_base &operator = (const aosl_sbus_class_base &) = delete; - aosl_sbus_class_base &operator = (aosl_sbus_class_base &&) = delete; - ~aosl_sbus_class_base () = delete; - -public: - typedef std::function aosl_sbus_data_lambda_f; - /* simple version without robj arg, so it means no "free only" for this callback */ - typedef std::function aosl_sbus_data_lambda_2args_f; - - static void *action_add (const char *name, aosl_mpq_t qid, aosl_ref_t ref, uintptr_t max, const char *f_name, aosl_sbus_data_lambda_f&& task) - { - aosl_sbus_data_lambda_f *task_obj = new aosl_sbus_data_lambda_f (std::move (task)); - void *err = aosl_sbus_action_add (name, qid, ref, max, f_name, ____sbus_data, ____action_dtor, 1, task_obj); - if (err == NULL) - delete task_obj; - - return err; - } - - static void *action_add (const char *name, aosl_mpq_t qid, aosl_ref_t ref, uintptr_t max, const char *f_name, aosl_sbus_data_lambda_2args_f&& task) - { - aosl_sbus_data_lambda_2args_f *task_obj = new aosl_sbus_data_lambda_2args_f (std::move (task)); - void *err = aosl_sbus_action_add (name, qid, ref, max, f_name, ____sbus_data_2args, ____action_dtor_2args, 1, task_obj); - if (err == NULL) - delete task_obj; - - return err; - } - - static int action_del (const char *name, void *h_action) - { - return aosl_sbus_action_del (name, h_action); - } - - static int send (const char *name, aosl_data_class &data) - { - return aosl_sbus_send (name, data); - } - -private: - static void ____sbus_data (aosl_refobj_t robj, const char *name, aosl_data_t data, uintptr_t argc, uintptr_t argv []) - { - aosl_sbus_data_lambda_f *task_obj = reinterpret_cast(argv [0]); - (*task_obj) (robj, name, data); - } - - static void ____action_dtor (uintptr_t argc, uintptr_t argv []) - { - aosl_sbus_data_lambda_f *task_obj = reinterpret_cast(argv [0]); - delete task_obj; - } - - static void ____sbus_data_2args (aosl_refobj_t robj, const char *name, aosl_data_t data, uintptr_t argc, uintptr_t argv []) - { - if (!aosl_is_free_only (robj)) { - aosl_sbus_data_lambda_2args_f *task_obj = reinterpret_cast(argv [0]); - (*task_obj) (name, data); - } - } - - static void ____action_dtor_2args (uintptr_t argc, uintptr_t argv []) - { - aosl_sbus_data_lambda_2args_f *task_obj = reinterpret_cast(argv [0]); - delete task_obj; - } -}; - -/** - * Template class for accessing a software bus with the data var format - * specified by type T. - **/ -template -class aosl_sbus_class: public aosl_sbus_class_base { -private: - aosl_sbus_class () = delete; - aosl_sbus_class (const aosl_sbus_class &) = delete; - aosl_sbus_class (aosl_sbus_class &&) = delete; - aosl_sbus_class &operator = (const aosl_sbus_class &) = delete; - aosl_sbus_class &operator = (aosl_sbus_class &&) = delete; - ~aosl_sbus_class () = delete; - -public: - typedef std::function &var)> aosl_sbus_var_lambda_f; - /* simple version without robj arg, so it means no "free only" for this callback */ - typedef std::function &var)> aosl_sbus_var_lambda_2args_f; - - static void *action_add (const char *name, aosl_mpq_t qid, aosl_ref_t ref, uintptr_t max, const char *f_name, aosl_sbus_var_lambda_f&& task) - { - aosl_sbus_var_lambda_f *task_obj = new aosl_sbus_var_lambda_f (std::move (task)); - void *err = aosl_sbus_action_add (name, qid, ref, max, f_name, ____sbus_var, ____action_var_dtor, 1, task_obj); - if (err == NULL) - delete task_obj; - - return err; - } - - static void *action_add (const char *name, aosl_mpq_t qid, aosl_ref_t ref, uintptr_t max, const char *f_name, aosl_sbus_var_lambda_2args_f&& task) - { - aosl_sbus_var_lambda_2args_f *task_obj = new aosl_sbus_var_lambda_2args_f (std::move (task)); - void *err = aosl_sbus_action_add (name, qid, ref, max, f_name, ____sbus_var_2args, ____action_var_dtor_2args, 1, task_obj); - if (err == NULL) - delete task_obj; - - return err; - } - - static int send (const char *name, aosl_data_var &var) - { - return aosl_sbus_send (name, var); - } - -private: - static void ____sbus_var (aosl_refobj_t robj, const char *name, aosl_data_t data, uintptr_t argc, uintptr_t argv []) - { - aosl_sbus_var_lambda_f *task_obj = reinterpret_cast(argv [0]); - aosl_data_var var ((aosl_data_arg (data))); - (*task_obj) (robj, name, var); - } - - static void ____action_var_dtor (uintptr_t argc, uintptr_t argv []) - { - aosl_sbus_var_lambda_f *task_obj = reinterpret_cast(argv [0]); - delete task_obj; - } - - static void ____sbus_var_2args (aosl_refobj_t robj, const char *name, aosl_data_t data, uintptr_t argc, uintptr_t argv []) - { - if (!aosl_is_free_only (robj)) { - aosl_sbus_var_lambda_2args_f *task_obj = reinterpret_cast(argv [0]); - aosl_data_var var ((aosl_data_arg (data))); - (*task_obj) (name, var); - } - } - - static void ____action_var_dtor_2args (uintptr_t argc, uintptr_t argv []) - { - aosl_sbus_var_lambda_2args_f *task_obj = reinterpret_cast(argv [0]); - delete task_obj; - } -}; -#endif /* C++11 */ - - -#endif /* __AOSL_SBUS_CPP_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_task_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_task_class.h deleted file mode 100644 index 876bc2fd2..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_task_class.h +++ /dev/null @@ -1,454 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Nov 19th, 2018 - * Module: AOSL task object for C++ definition file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_TASK_CLASS_H__ -#define __AOSL_TASK_CLASS_H__ - - -#include - -#include -#include -#include -#include -#include -#include -#include - -#if (__cplusplus >= 201103) || defined (_MSC_VER) -#include -#include -typedef std::function aosl_task_exec_lambda_f; -typedef std::function aosl_task_exec_lambda_2args_f; -typedef std::function aosl_task_exec_lambda_1arg_f; -typedef std::function aosl_task_async_lambda_f; -typedef std::function aosl_task_async_lambda_1arg_f; -typedef std::function aosl_task_async_lambda_0arg_f; -#endif - - -class aosl_task_class: public aosl_ref_class { -public: - class aosl_ref_t_oop: public aosl_ref_class::aosl_ref_t_oop { - private: - /** - * We do not allow create any object of this class directly, - * only the pointer of this class is significant. - **/ - aosl_ref_t_oop (); - - public: - static aosl_ref_t_oop *create (aosl_task_type_t type, void *arg = NULL, aosl_ref_dtor_t dtor = NULL, - bool serial = true, aosl_mpq_t st_op_q = aosl_mpq_main (), bool resume = true, - aosl_task_res_wait_t wait_f = NULL) - { - return (aosl_ref_t_oop *)aosl_task_create (arg, dtor, type, (int)(serial == true), st_op_q, (int)(resume == true), wait_f); - } - - static aosl_ref_t_oop *from_aosl_ref_t (aosl_ref_t ref) - { - return (aosl_ref_t_oop *)ref; - } - - aosl_task_type_t get_type () - { - return aosl_task_get_type (ref ()); - } - - int exec (const char *f_name, aosl_task_func_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = aosl_task_exec_args (ref (), f_name, f, argc, args); - va_end (args); - - return err; - } - - int exec_args (const char *f_name, aosl_task_func_t f, uintptr_t argc, va_list args) - { - return aosl_task_exec_args (ref (), f_name, f, argc, args); - } - - int exec_argv (const char *f_name, aosl_task_func_t f, uintptr_t argc, uintptr_t argv []) - { - return aosl_task_exec_argv (ref (), f_name, f, argc, argv); - } - - int exclusive_exec (aosl_task_func_t exclusive_f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = aosl_task_exclusive_exec_args (ref (), exclusive_f, argc, args); - va_end (args); - - return err; - } - - int exclusive_exec_args (aosl_task_func_t exclusive_f, uintptr_t argc, va_list args) - { - return aosl_task_exclusive_exec_args (ref (), exclusive_f, argc, args); - } - - int exclusive_exec_argv (aosl_task_func_t exclusive_f, uintptr_t argc, uintptr_t argv []) - { - return aosl_task_exclusive_exec_argv (ref (), exclusive_f, argc, argv); - } - - int waiting_ops_count () - { - return aosl_task_waiting_ops_count (ref ()); - } - - int remove_waiting_ops_head () - { - return aosl_task_remove_waiting_ops_head (ref ()); - } - - int async_done () - { - return aosl_task_async_done (ref ()); - } - - int async_done (uintptr_t opaque) - { - return aosl_task_async_done_opaque (ref (), opaque); - } - - /* C++11 lambda encapsulations */ - #if (__cplusplus >= 201103) || defined (_MSC_VER) - public: - int exec (const char *f_name, aosl_task_exec_lambda_f&& task) - { - aosl_task_exec_lambda_f *exec_f = new aosl_task_exec_lambda_f (std::move (task)); - int err = aosl_ref_t_oop::exec (f_name, ____task_exec_f, 2, 0, exec_f); - if (err < 0) - delete exec_f; - - return err; - } - - int exec (const char *f_name, aosl_task_exec_lambda_2args_f&& task) - { - aosl_task_exec_lambda_2args_f *exec_f = new aosl_task_exec_lambda_2args_f (std::move (task)); - int err = aosl_ref_t_oop::exec (f_name, ____task_exec_2args_f, 2, 0, exec_f); - if (err < 0) - delete exec_f; - - return err; - } - - int exec (const char *f_name, aosl_task_exec_lambda_1arg_f&& task) - { - aosl_task_exec_lambda_1arg_f *exec_f = new aosl_task_exec_lambda_1arg_f (std::move (task)); - int err = aosl_ref_t_oop::exec (f_name, ____task_exec_1arg_f, 2, 0, exec_f); - if (err < 0) - delete exec_f; - - return err; - } - - int exclusive_exec (aosl_task_exec_lambda_1arg_f&& task) - { - aosl_task_exec_lambda_1arg_f *exc_exec_f = new aosl_task_exec_lambda_1arg_f (std::move (task)); - int err = aosl_ref_t_oop::exclusive_exec (____exclusive_exec_f, 1, exc_exec_f); - if (err < 0) - delete exc_exec_f; - - return err; - } - - private: - static void ____task_exec_f (aosl_refobj_t tobj, aosl_task_act_t action, uintptr_t opaque, uintptr_t argc, uintptr_t argv []) - { - aosl_task_exec_lambda_f *exec_f = reinterpret_cast(argv [1]); - (*exec_f) (action, opaque, tobj, argv [0]); - if (action != aosl_task_act_exec) { - /** - * Do not free the task object for the task object 'run' case, - * because the task object is still used later. - * -- Lionfore Hao Nov 19th, 2018 - **/ - delete exec_f; - } - } - - /** - * Windows SDK 14.35.32215 uses __stdcall, so do not implement these lambdas - * via same callback function with full args, using an separate callback func - * instead. - **/ - static void ____task_exec_2args_f (aosl_refobj_t tobj, aosl_task_act_t action, uintptr_t opaque, uintptr_t argc, uintptr_t argv []) - { - aosl_task_exec_lambda_2args_f *exec_f = reinterpret_cast(argv [1]); - (*exec_f) (action, opaque); - if (action != aosl_task_act_exec) { - /** - * Do not free the task object for the task object 'run' case, - * because the task object is still used later. - * -- Lionfore Hao Nov 19th, 2018 - **/ - delete exec_f; - } - } - - static void ____task_exec_1arg_f (aosl_refobj_t tobj, aosl_task_act_t action, uintptr_t opaque, uintptr_t argc, uintptr_t argv []) - { - aosl_task_exec_lambda_1arg_f *exec_f = reinterpret_cast(argv [1]); - (*exec_f) (action); - if (action != aosl_task_act_exec) { - /** - * Do not free the task object for the task object 'run' case, - * because the task object is still used later. - * -- Lionfore Hao Nov 19th, 2018 - **/ - delete exec_f; - } - } - - static void ____exclusive_exec_f (aosl_refobj_t tobj, aosl_task_act_t action, uintptr_t opaque, uintptr_t argc, uintptr_t argv []) - { - aosl_task_exec_lambda_1arg_f *exc_exec_f = reinterpret_cast(argv [0]); - (*exc_exec_f) (action); - delete exc_exec_f; - } - - public: - int async (const char *f_name, aosl_task_async_lambda_f&& task) - { - aosl_task_async_lambda_f *async_f = new aosl_task_async_lambda_f (std::move (task)); - int err = aosl_ref_t_oop::exec (f_name, ____task_async_f, 2, 0, async_f); - if (err < 0) - delete async_f; - - return err; - } - - int async (const char *f_name, aosl_task_async_lambda_1arg_f&& task) - { - aosl_task_async_lambda_1arg_f *async_f = new aosl_task_async_lambda_1arg_f (std::move (task)); - int err = aosl_ref_t_oop::exec (f_name, ____task_async_1arg_f, 2, 0, async_f); - if (err < 0) - delete async_f; - - return err; - } - - int async (const char *f_name, aosl_task_async_lambda_0arg_f&& task) - { - aosl_task_async_lambda_0arg_f *async_f = new aosl_task_async_lambda_0arg_f (std::move (task)); - int err = aosl_ref_t_oop::exec (f_name, ____task_async_0arg_f, 2, 0, async_f); - if (err < 0) - delete async_f; - - return err; - } - - private: - static void ____task_async_f (aosl_refobj_t tobj, aosl_task_act_t action, uintptr_t opaque, uintptr_t argc, uintptr_t argv []) - { - aosl_task_async_lambda_f *async_f = reinterpret_cast(argv [1]); - if (action == aosl_task_act_exec) { - (*async_f) (opaque, tobj, argv [0]); - } else { - delete async_f; - } - } - - /** - * Windows SDK 14.35.32215 uses __stdcall, so do not implement these lambdas - * via same callback function with full args, using an separate callback func - * instead. - **/ - static void ____task_async_1arg_f (aosl_refobj_t tobj, aosl_task_act_t action, uintptr_t opaque, uintptr_t argc, uintptr_t argv []) - { - aosl_task_async_lambda_1arg_f *async_f = reinterpret_cast(argv [1]); - if (action == aosl_task_act_exec) { - (*async_f) (opaque); - } else { - delete async_f; - } - } - - static void ____task_async_0arg_f (aosl_refobj_t tobj, aosl_task_act_t action, uintptr_t opaque, uintptr_t argc, uintptr_t argv []) - { - aosl_task_async_lambda_0arg_f *async_f = reinterpret_cast(argv [1]); - if (action == aosl_task_act_exec) { - (*async_f) (); - } else { - delete async_f; - } - } - #endif /* C++11 */ - }; - -public: - aosl_task_class (aosl_task_type_t type, bool serial = false, aosl_mpq_t st_op_q = aosl_mpq_main (), bool resume = true, aosl_task_res_wait_t wait_f = NULL) - : aosl_ref_class (aosl_ref_t_oop::create (type, this, __dtor, serial, st_op_q, resume, wait_f)) - { - if (aosl_ref_invalid (ref_oop ())) - abort (); - } - - aosl_task_class (): aosl_ref_class (AOSL_REF_INVALID) - { - } - - aosl_ref_t_oop *ref_oop () const - { - return (aosl_ref_t_oop *)aosl_ref_class::ref_oop (); - } - - aosl_task_type_t get_type () - { - return ref_oop ()->get_type (); - } - - int exec (const char *f_name, aosl_task_func_t f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = ref_oop ()->exec_args (f_name, f, argc, args); - va_end (args); - - return err; - } - - int exec_args (const char *f_name, aosl_task_func_t f, uintptr_t argc, va_list args) - { - return ref_oop ()->exec_args (f_name, f, argc, args); - } - - int exec_argv (const char *f_name, aosl_task_func_t f, uintptr_t argc, uintptr_t argv []) - { - return ref_oop ()->exec_argv (f_name, f, argc, argv); - } - - int exclusive_exec (aosl_task_func_t exclusive_f, uintptr_t argc, ...) - { - va_list args; - int err; - - va_start (args, argc); - err = ref_oop ()->exclusive_exec_args (exclusive_f, argc, args); - va_end (args); - - return err; - } - - int exclusive_exec_args (aosl_task_func_t exclusive_f, uintptr_t argc, va_list args) - { - return ref_oop ()->exclusive_exec_args (exclusive_f, argc, args); - } - - int exclusive_exec_argv (aosl_task_func_t exclusive_f, uintptr_t argc, uintptr_t argv []) - { - return ref_oop ()->exclusive_exec_argv (exclusive_f, argc, argv); - } - - int waiting_ops_count () - { - return ref_oop ()->waiting_ops_count (); - } - - int remove_waiting_ops_head () - { - return ref_oop ()->remove_waiting_ops_head (); - } - - int async_done () - { - return ref_oop ()->async_done (); - } - - int async_done (uintptr_t opaque) - { - return ref_oop ()->async_done (opaque); - } - -protected: - /* We do not allow delete this object directly. */ - virtual ~aosl_task_class () - { - } - -private: - static void __dtor (void *arg) - { - aosl_task_class *__this = (aosl_task_class *)arg; - ::delete __this; - } - - /* C++11 lambda encapsulations */ -#if (__cplusplus >= 201103) || defined (_MSC_VER) -public: - int exec (const char *f_name, aosl_task_exec_lambda_f&& task) - { - return ref_oop ()->exec (f_name, std::move (task)); - } - - int exec (const char *f_name, aosl_task_exec_lambda_2args_f&& task) - { - return ref_oop ()->exec (f_name, std::move (task)); - } - - int exec (const char *f_name, aosl_task_exec_lambda_1arg_f&& task) - { - return ref_oop ()->exec (f_name, std::move (task)); - } - - int exclusive_exec (aosl_task_exec_lambda_1arg_f&& task) - { - return ref_oop ()->exclusive_exec (std::move (task)); - } - - int async (const char *f_name, aosl_task_async_lambda_f&& task) - { - return ref_oop ()->async (f_name, std::move (task)); - } - - int async (const char *f_name, aosl_task_async_lambda_1arg_f&& task) - { - return ref_oop ()->async (f_name, std::move (task)); - } - - int async (const char *f_name, aosl_task_async_lambda_0arg_f&& task) - { - return ref_oop ()->async (f_name, std::move (task)); - } -#endif /* C++11 */ - -#if (__cplusplus >= 201103) || defined (_MSC_VER) -private: - aosl_task_class (const aosl_task_class &) = delete; - aosl_task_class (aosl_task_class &&) = delete; - aosl_task_class &operator = (const aosl_task_class &) = delete; - aosl_task_class &operator = (aosl_task_class &&) = delete; -#else -private: - aosl_task_class (const aosl_task_class &); - aosl_task_class &operator = (const aosl_task_class &); -#endif /* C++11 */ -}; - - -typedef aosl_ref_unique_ptr aosl_task_class_unique_ptr; - - - -#endif /* __AOSL_TASK_CLASS_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_thread_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_thread_class.h deleted file mode 100644 index 902d060ec..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_thread_class.h +++ /dev/null @@ -1,279 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Jul 9th, 2019 - * Module: AOSL thread object for C++ definition file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 ~ 2019 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_THREAD_OBJ_CPP_H__ -#define __AOSL_THREAD_OBJ_CPP_H__ - - -#include - -#include -#include - - -class aosl_lock_class { -private: - aosl_lock_t lk; - -public: - aosl_lock_class (bool recursive = false) - { - lk = aosl_lock_create ((int)recursive); - if (lk == NULL) - abort (); - } - - void lock (void) - { - aosl_lock_lock (lk); - } - - bool try_lock (void) - { - return (bool)(aosl_lock_trylock (lk) != 0); - } - - void unlock (void) - { - aosl_lock_unlock (lk); - } - - ~aosl_lock_class () - { - aosl_lock_destroy (lk); - } - -public: - class scoped { - private: - aosl_lock_class &the_lock; - bool locked; - - public: - scoped (aosl_lock_class &lk): the_lock (lk) - { - the_lock.lock (); - locked = true; - } - - void release (void) - { - if (!locked) - abort (); - - locked = false; - the_lock.unlock (); - } - - void reacquire (void) - { - if (locked) - abort (); - - the_lock.lock (); - locked = true; - } - - ~scoped () - { - if (locked) - the_lock.unlock (); - } - -#if (__cplusplus >= 201103) || defined (_MSC_VER) - private: - scoped (const scoped &) = delete; - scoped (scoped &&) = delete; - scoped &operator = (const scoped &) = delete; - scoped &operator = (scoped &&) = delete; -#else - private: - scoped (const scoped &); - scoped &operator = (const scoped &); -#endif /* C++11 */ - }; - -#if (__cplusplus >= 201103) || defined (_MSC_VER) -private: - aosl_lock_class (const aosl_lock_class &) = delete; - aosl_lock_class (aosl_lock_class &&) = delete; - aosl_lock_class &operator = (const aosl_lock_class &) = delete; - aosl_lock_class &operator = (aosl_lock_class &&) = delete; -#else -private: - aosl_lock_class (const aosl_lock_class &); - aosl_lock_class &operator = (const aosl_lock_class &); -#endif /* C++11 */ -}; - -class aosl_rwlock_class { -private: - aosl_rwlock_t rw; - -public: - aosl_rwlock_class () - { - rw = aosl_rwlock_create (); - if (rw == NULL) - abort (); - } - - void rdlock (void) - { - aosl_rwlock_rdlock (rw); - } - - bool try_rdlock (void) - { - return (bool)(aosl_rwlock_tryrdlock (rw) != 0); - } - - void wrlock (void) - { - aosl_rwlock_wrlock (rw); - } - - bool try_wrlock (void) - { - return (bool)(aosl_rwlock_trywrlock (rw) != 0); - } - - void rdunlock (void) - { - aosl_rwlock_rdunlock (rw); - } - - void wrunlock (void) - { - aosl_rwlock_wrunlock (rw); - } - - ~aosl_rwlock_class () - { - aosl_rwlock_destroy (rw); - } - -public: - class scoped_rdlock { - private: - aosl_rwlock_class &the_rwlock; - bool locked; - - public: - scoped_rdlock (aosl_rwlock_class &rwlock): the_rwlock (rwlock) - { - the_rwlock.rdlock (); - locked = true; - } - - void release (void) - { - if (!locked) - abort (); - - locked = false; - the_rwlock.rdunlock (); - } - - void reacquire (void) - { - if (locked) - abort (); - - the_rwlock.rdlock (); - locked = true; - } - - ~scoped_rdlock () - { - if (locked) - the_rwlock.rdunlock (); - } - -#if (__cplusplus >= 201103) || defined (_MSC_VER) - private: - scoped_rdlock (const scoped_rdlock &) = delete; - scoped_rdlock (scoped_rdlock &&) = delete; - scoped_rdlock &operator = (const scoped_rdlock &) = delete; - scoped_rdlock &operator = (scoped_rdlock &&) = delete; -#else - private: - scoped_rdlock (const scoped_rdlock &); - scoped_rdlock &operator = (const scoped_rdlock &); -#endif /* C++11 */ - }; - - class scoped_wrlock { - private: - aosl_rwlock_class &the_rwlock; - bool locked; - - public: - scoped_wrlock (aosl_rwlock_class &rwlock): the_rwlock (rwlock) - { - the_rwlock.wrlock (); - locked = true; - } - - void release (void) - { - if (!locked) - abort (); - - locked = false; - the_rwlock.wrunlock (); - } - - void reacquire (void) - { - if (locked) - abort (); - - the_rwlock.wrlock (); - locked = true; - } - - ~scoped_wrlock () - { - if (locked) - the_rwlock.wrunlock (); - } - -#if (__cplusplus >= 201103) || defined (_MSC_VER) - private: - scoped_wrlock (const scoped_wrlock &) = delete; - scoped_wrlock (scoped_wrlock &&) = delete; - scoped_wrlock &operator = (const scoped_wrlock &) = delete; - scoped_wrlock &operator = (scoped_wrlock &&) = delete; -#else - private: - scoped_wrlock (const scoped_wrlock &); - scoped_wrlock &operator = (const scoped_wrlock &); -#endif /* C++11 */ - }; - -#if (__cplusplus >= 201103) || defined (_MSC_VER) -private: - aosl_rwlock_class (const aosl_rwlock_class &) = delete; - aosl_rwlock_class (aosl_rwlock_class &&) = delete; - aosl_rwlock_class &operator = (const aosl_rwlock_class &) = delete; - aosl_rwlock_class &operator = (aosl_rwlock_class &&) = delete; -#else -private: - aosl_rwlock_class (const aosl_rwlock_class &); - aosl_rwlock_class &operator = (const aosl_rwlock_class &); -#endif /* C++11 */ -}; - - - -#endif /* __AOSL_THREAD_OBJ_CPP_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_value_class.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_value_class.h deleted file mode 100644 index 0e993e3eb..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/cpp/aosl_value_class.h +++ /dev/null @@ -1,471 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Dec 8th, 2022 - * Module: AOSL value object for C++ definition file - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 ~ 2022 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_VALUE_OBJ_CPP_H__ -#define __AOSL_VALUE_OBJ_CPP_H__ - - -#include - -#include -#include -#include - -#if (__cplusplus >= 201103) || defined (_MSC_VER) -#include -#include -#endif - - -class aosl_value_base: public aosl_kobj_class { -private: -#if (__cplusplus >= 201103) || defined (_MSC_VER) - aosl_value_base () = delete; - aosl_value_base (const aosl_value_base &) = delete; - aosl_value_base (aosl_value_base &&) = delete; - aosl_value_base &operator = (const aosl_value_base &) = delete; - aosl_value_base &operator = (aosl_value_base &&) = delete; - ~aosl_value_base () = delete; -#else - aosl_value_base (); - aosl_value_base (const aosl_value_base &); - aosl_value_base &operator = (const aosl_value_base &); - ~aosl_value_base (); -#endif - -public: - static ssize_t get (const char *key, aosl_value_t &val, aosl_kfd_t dfd = AOSL_KFD_INVALID) - { - aosl_value_init (&val); - return aosl_value_get (dfd, key, &val); - } - - static ssize_t set (const char *key, const aosl_value_t &val, aosl_kfd_t dfd = AOSL_KFD_INVALID) - { - return aosl_value_set (dfd, key, &val); - } - -public: - static void *verify_register (aosl_kfd_t dfd, const char *name, aosl_value_verify_t f, aosl_value_verify_dtor_t dtor, uintptr_t argc, ...) - { - va_list args; - void *err; - - va_start (args, argc); - err = aosl_value_verify_register_args (dfd, name, f, dtor, argc, args); - va_end (args); - return err; - } - - static void *verify_register_args (aosl_kfd_t dfd, const char *name, aosl_value_verify_t f, aosl_value_verify_dtor_t dtor, uintptr_t argc, va_list args) - { - return aosl_value_verify_register_args (dfd, name, f, dtor, argc, args); - } - - static void *verify_register_argv (aosl_kfd_t dfd, const char *name, aosl_value_verify_t f, aosl_value_verify_dtor_t dtor, uintptr_t argc, uintptr_t argv []) - { - return aosl_value_verify_register_argv (dfd, name, f, dtor, argc, argv); - } - - static int verify_unregister (aosl_kfd_t dfd, const char *name, void *handle) - { - return aosl_value_verify_unregister (dfd, name, handle); - } - - /* C++11 lambda encapsulations */ -#if (__cplusplus >= 201103) || defined (_MSC_VER) -public: - typedef std::function aosl_value_verify_lambda_f; - static void *verify_register (aosl_kfd_t dfd, const char *name, aosl_value_verify_lambda_f&& task) - { - aosl_value_verify_lambda_f *task_obj = new aosl_value_verify_lambda_f (std::move (task)); - void *err = verify_register (dfd, name, ____verify_f, ____verify_dtor, 1, task_obj); - if (err == NULL) - delete task_obj; - - return err; - } - -private: - static int ____verify_f (const aosl_value_t *val, uintptr_t argc, uintptr_t argv []) - { - aosl_value_verify_lambda_f *task_obj = reinterpret_cast(argv [0]); - return (*task_obj) (val); - } - - static void ____verify_dtor (uintptr_t argc, uintptr_t argv []) - { - aosl_value_verify_lambda_f *task_obj = reinterpret_cast(argv [0]); - delete task_obj; - } -#endif /* C++11 */ -}; - -class aosl_value_bool: public aosl_value_base { -private: -#if (__cplusplus >= 201103) || defined (_MSC_VER) - aosl_value_bool () = delete; - aosl_value_bool (const aosl_value_bool &) = delete; - aosl_value_bool (aosl_value_bool &&) = delete; - aosl_value_bool &operator = (const aosl_value_bool &) = delete; - aosl_value_bool &operator = (aosl_value_bool &&) = delete; - ~aosl_value_bool () = delete; -#else - aosl_value_bool (); - aosl_value_bool (const aosl_value_bool &); - aosl_value_bool &operator = (const aosl_value_bool &); - ~aosl_value_bool (); -#endif - -public: - static bool get (const char *key, aosl_kfd_t dfd = AOSL_KFD_INVALID, bool error_val = false) - { - int8_t v; - if (aosl_value_get_int8 (dfd, key, &v) != sizeof v) - return error_val; - - return (bool)(v != 0); - } - - static ssize_t set (const char *key, bool v, aosl_kfd_t dfd = AOSL_KFD_INVALID, uint32_t weight = 0) - { - return aosl_value_set_int8 (dfd, key, weight, (int8_t)v); - } -}; - -class aosl_value_int8: public aosl_value_base { -private: -#if (__cplusplus >= 201103) || defined (_MSC_VER) - aosl_value_int8 () = delete; - aosl_value_int8 (const aosl_value_int8 &) = delete; - aosl_value_int8 (aosl_value_int8 &&) = delete; - aosl_value_int8 &operator = (const aosl_value_int8 &) = delete; - aosl_value_int8 &operator = (aosl_value_int8 &&) = delete; - ~aosl_value_int8 () = delete; -#else - aosl_value_int8 (); - aosl_value_int8 (const aosl_value_int8 &); - aosl_value_int8 &operator = (const aosl_value_int8 &); - ~aosl_value_int8 (); -#endif - -public: - static int8_t get (const char *key, aosl_kfd_t dfd = AOSL_KFD_INVALID, int8_t error_val = 0) - { - int8_t v; - if (aosl_value_get_int8 (dfd, key, &v) != sizeof v) - return error_val; - - return v; - } - - static ssize_t set (const char *key, int8_t v, aosl_kfd_t dfd = AOSL_KFD_INVALID, uint32_t weight = 0) - { - return aosl_value_set_int8 (dfd, key, weight, v); - } -}; - -class aosl_value_int16: public aosl_value_base { -private: -#if (__cplusplus >= 201103) || defined (_MSC_VER) - aosl_value_int16 () = delete; - aosl_value_int16 (const aosl_value_int16 &) = delete; - aosl_value_int16 (aosl_value_int16 &&) = delete; - aosl_value_int16 &operator = (const aosl_value_int16 &) = delete; - aosl_value_int16 &operator = (aosl_value_int16 &&) = delete; - ~aosl_value_int16 () = delete; -#else - aosl_value_int16 (); - aosl_value_int16 (const aosl_value_int16 &); - aosl_value_int16 &operator = (const aosl_value_int16 &); - ~aosl_value_int16 (); -#endif - -public: - static int16_t get (const char *key, aosl_kfd_t dfd = AOSL_KFD_INVALID, int16_t error_val = 0) - { - int16_t v; - if (aosl_value_get_int16 (dfd, key, &v) != sizeof v) - return error_val; - - return v; - } - - static ssize_t set (const char *key, int16_t v, aosl_kfd_t dfd = AOSL_KFD_INVALID, uint32_t weight = 0) - { - return aosl_value_set_int16 (dfd, key, weight, v); - } -}; - -class aosl_value_int32: public aosl_value_base { -private: -#if (__cplusplus >= 201103) || defined (_MSC_VER) - aosl_value_int32 () = delete; - aosl_value_int32 (const aosl_value_int32 &) = delete; - aosl_value_int32 (aosl_value_int32 &&) = delete; - aosl_value_int32 &operator = (const aosl_value_int32 &) = delete; - aosl_value_int32 &operator = (aosl_value_int32 &&) = delete; - ~aosl_value_int32 () = delete; -#else - aosl_value_int32 (); - aosl_value_int32 (const aosl_value_int32 &); - aosl_value_int32 &operator = (const aosl_value_int32 &); - ~aosl_value_int32 (); -#endif - -public: - static int32_t get (const char *key, aosl_kfd_t dfd = AOSL_KFD_INVALID, int32_t error_val = 0) - { - int32_t v; - if (aosl_value_get_int32 (dfd, key, &v) != sizeof v) - return error_val; - - return v; - } - - static ssize_t set (const char *key, int32_t v, aosl_kfd_t dfd = AOSL_KFD_INVALID, uint32_t weight = 0) - { - return aosl_value_set_int32 (dfd, key, weight, v); - } -}; - -class aosl_value_int64: public aosl_value_base { -private: -#if (__cplusplus >= 201103) || defined (_MSC_VER) - aosl_value_int64 () = delete; - aosl_value_int64 (const aosl_value_int64 &) = delete; - aosl_value_int64 (aosl_value_int64 &&) = delete; - aosl_value_int64 &operator = (const aosl_value_int64 &) = delete; - aosl_value_int64 &operator = (aosl_value_int64 &&) = delete; - ~aosl_value_int64 () = delete; -#else - aosl_value_int64 (); - aosl_value_int64 (const aosl_value_int64 &); - aosl_value_int64 &operator = (const aosl_value_int64 &); - ~aosl_value_int64 (); -#endif - -public: - static int64_t get (const char *key, aosl_kfd_t dfd = AOSL_KFD_INVALID, int64_t error_val = 0) - { - int64_t v; - if (aosl_value_get_int64 (dfd, key, &v) != sizeof v) - return error_val; - - return v; - } - - static ssize_t set (const char *key, int64_t v, aosl_kfd_t dfd = AOSL_KFD_INVALID, uint32_t weight = 0) - { - return aosl_value_set_int64 (dfd, key, weight, v); - } -}; - -class aosl_value_intptr: public aosl_value_base { -private: -#if (__cplusplus >= 201103) || defined (_MSC_VER) - aosl_value_intptr () = delete; - aosl_value_intptr (const aosl_value_intptr &) = delete; - aosl_value_intptr (aosl_value_intptr &&) = delete; - aosl_value_intptr &operator = (const aosl_value_intptr &) = delete; - aosl_value_intptr &operator = (aosl_value_intptr &&) = delete; - ~aosl_value_intptr () = delete; -#else - aosl_value_intptr (); - aosl_value_intptr (const aosl_value_intptr &); - aosl_value_intptr &operator = (const aosl_value_intptr &); - ~aosl_value_intptr (); -#endif - -public: - static intptr_t get (const char *key, aosl_kfd_t dfd = AOSL_KFD_INVALID, intptr_t error_val = 0) - { - intptr_t v; - if (aosl_value_get_intptr (dfd, key, &v) != sizeof v) - return error_val; - - return v; - } - - static ssize_t set (const char *key, intptr_t v, aosl_kfd_t dfd = AOSL_KFD_INVALID, uint32_t weight = 0) - { - return aosl_value_set_intptr (dfd, key, weight, v); - } -}; - -class aosl_value_pointer: public aosl_value_base { -private: -#if (__cplusplus >= 201103) || defined (_MSC_VER) - aosl_value_pointer () = delete; - aosl_value_pointer (const aosl_value_pointer &) = delete; - aosl_value_pointer (aosl_value_pointer &&) = delete; - aosl_value_pointer &operator = (const aosl_value_pointer &) = delete; - aosl_value_pointer &operator = (aosl_value_pointer &&) = delete; - ~aosl_value_pointer () = delete; -#else - aosl_value_pointer (); - aosl_value_pointer (const aosl_value_pointer &); - aosl_value_pointer &operator = (const aosl_value_pointer &); - ~aosl_value_pointer (); -#endif - -public: - static void *get (const char *key, aosl_kfd_t dfd = AOSL_KFD_INVALID, void *error_val = NULL) - { - void *v; - if (aosl_value_get_pointer (dfd, key, &v) != sizeof v) - return error_val; - - return v; - } - - static ssize_t set (const char *key, void *v, aosl_kfd_t dfd = AOSL_KFD_INVALID, uint32_t weight = 0) - { - return aosl_value_set_pointer (dfd, key, weight, v); - } -}; - -class aosl_value_float: public aosl_value_base { -private: -#if (__cplusplus >= 201103) || defined (_MSC_VER) - aosl_value_float () = delete; - aosl_value_float (const aosl_value_float &) = delete; - aosl_value_float (aosl_value_float &&) = delete; - aosl_value_float &operator = (const aosl_value_float &) = delete; - aosl_value_float &operator = (aosl_value_float &&) = delete; - ~aosl_value_float () = delete; -#else - aosl_value_float (); - aosl_value_float (const aosl_value_float &); - aosl_value_float &operator = (const aosl_value_float &); - ~aosl_value_float (); -#endif - -public: - static float get (const char *key, aosl_kfd_t dfd = AOSL_KFD_INVALID, float error_val = 1.0) - { - float v; - if (aosl_value_get_float (dfd, key, &v) != sizeof v) - return error_val; - - return v; - } - - static ssize_t set (const char *key, float v, aosl_kfd_t dfd = AOSL_KFD_INVALID, uint32_t weight = 0) - { - return aosl_value_set_float (dfd, key, weight, v); - } -}; - -class aosl_value_double: public aosl_value_base { -private: -#if (__cplusplus >= 201103) || defined (_MSC_VER) - aosl_value_double () = delete; - aosl_value_double (const aosl_value_double &) = delete; - aosl_value_double (aosl_value_double &&) = delete; - aosl_value_double &operator = (const aosl_value_double &) = delete; - aosl_value_double &operator = (aosl_value_double &&) = delete; - ~aosl_value_double () = delete; -#else - aosl_value_double (); - aosl_value_double (const aosl_value_double &); - aosl_value_double &operator = (const aosl_value_double &); - ~aosl_value_double (); -#endif - -public: - static double get (const char *key, aosl_kfd_t dfd = AOSL_KFD_INVALID, double error_val = 1.0) - { - double v; - if (aosl_value_get_double (dfd, key, &v) != sizeof v) - return error_val; - - return v; - } - - static ssize_t set (const char *key, double v, aosl_kfd_t dfd = AOSL_KFD_INVALID, uint32_t weight = 0) - { - return aosl_value_set_double (dfd, key, weight, v); - } -}; - -class aosl_value_string: public aosl_value_base { -private: -#if (__cplusplus >= 201103) || defined (_MSC_VER) - aosl_value_string () = delete; - aosl_value_string (const aosl_value_string &) = delete; - aosl_value_string (aosl_value_string &&) = delete; - aosl_value_string &operator = (const aosl_value_string &) = delete; - aosl_value_string &operator = (aosl_value_string &&) = delete; - ~aosl_value_string () = delete; -#else - aosl_value_string (); - aosl_value_string (const aosl_value_string &); - aosl_value_string &operator = (const aosl_value_string &); - ~aosl_value_string (); -#endif - -public: - static ssize_t get (const char *key, char *str, size_t len, aosl_kfd_t dfd = AOSL_KFD_INVALID) - { - return aosl_value_get_string (dfd, key, str, len); - } - - static ssize_t set (const char *key, const char *str, aosl_kfd_t dfd = AOSL_KFD_INVALID, uint32_t weight = 0) - { - return aosl_value_set_string (dfd, key, weight, str); - } -}; - -class aosl_value_data: public aosl_value_base { -private: -#if (__cplusplus >= 201103) || defined (_MSC_VER) - aosl_value_data () = delete; - aosl_value_data (const aosl_value_data &) = delete; - aosl_value_data (aosl_value_data &&) = delete; - aosl_value_data &operator = (const aosl_value_data &) = delete; - aosl_value_data &operator = (aosl_value_data &&) = delete; - ~aosl_value_data () = delete; -#else - aosl_value_data (); - aosl_value_data (const aosl_value_data &); - aosl_value_data &operator = (const aosl_value_data &); - ~aosl_value_data (); -#endif - -public: - static ssize_t get (const char *key, void *buf, size_t len, aosl_kfd_t dfd = AOSL_KFD_INVALID) - { - return aosl_value_get_data (dfd, key, buf, len); - } - - static ssize_t set (const char *key, const void *buf, size_t len, aosl_kfd_t dfd = AOSL_KFD_INVALID, uint32_t weight = 0) - { - return aosl_value_set_data (dfd, key, weight, buf, len); - } -}; - -class aosl_value_class: public aosl_value_t { -public: - aosl_value_class () - { - aosl_value_init (this); - } - - ~aosl_value_class () - { - aosl_value_free (this); - } -}; - - -#endif /* __AOSL_VALUE_OBJ_CPP_H__ */ \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/objc/Makefile b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/objc/Makefile deleted file mode 100644 index f58d4da50..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/objc/Makefile +++ /dev/null @@ -1 +0,0 @@ -header-y += aosl_log.h diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/objc/aosl_log.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/objc/aosl_log.h deleted file mode 100644 index 859ace92b..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/objc/aosl_log.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef __AOSL_LOG_OBJC_H__ -#define __AOSL_LOG_OBJC_H__ - -#import - -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - - -typedef void (*aosl_objc_vlog_t) (int level, const NSString *format, va_list args); - -extern void aosl_set_vlog_func_objc (aosl_objc_vlog_t vlog); - - - -#ifdef __cplusplus -} -#endif - - - -#endif /* __AOSL_LOG_OBJC_H__ */ diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/objc/aosl_objc.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/objc/aosl_objc.h deleted file mode 100644 index 8a94d707d..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/api/objc/aosl_objc.h +++ /dev/null @@ -1,32 +0,0 @@ -/************************************************************* - * Author: Lionfore Hao (haolianfu@agora.io) - * Date : Aug 11th, 2021 - * Module: AOSL objc relative declarations - * - * - * This is a part of the Advanced Operating System Layer. - * Copyright (C) 2018 ~ 2021 Agora IO - * All rights reserved. - * - *************************************************************/ - -#ifndef __AOSL_OBJC_H__ -#define __AOSL_OBJC_H__ - - -#ifdef __cplusplus -extern "C" { -#endif - - -extern void *objc_autoreleasePoolPush (void); -extern void objc_autoreleasePoolPop (void *pool); - - -#ifdef __cplusplus -} -#endif - - - -#endif /* __AOSL_OBJC_H__ */ diff --git a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/time_utils.h b/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/time_utils.h deleted file mode 100644 index bb4759b71..000000000 --- a/HarmonyOS_NEXT/APIExample/entry/src/main/cpp/include/time_utils.h +++ /dev/null @@ -1,85 +0,0 @@ -// -// Agora Media SDK -// -// Copyright (c) 2021 Agora IO. All rights reserved. -// - -#pragma once -#include - -namespace agora { -namespace base { - -class NtpTime { - public: - static const uint64_t ntpFracPerSecond = 4294967296; - - NtpTime() : ms_(0) {} - - NtpTime(uint64_t ms) : ms_(ms) {} - - NtpTime(uint32_t seconds, uint32_t fractions) { - const double fracMs = fractions * 1000.0 / static_cast(ntpFracPerSecond); - ms_ = static_cast(seconds) * 1000 + static_cast(0.5 + fracMs); - } - - operator uint64_t() const { return ms_; } - - /** Gets the NTP time. - * - * @return - * - The wallclock time which is in milliseconds relative to 0h UTC on 1 January 1900. - */ - uint64_t Ms() const { - return ms_; - } - - /** Check that whether the NtpTime object is valid - * - * - `true`: the NtpTime object is valid. - * - `false`: the NtpTime object is invalid. - */ - bool Valid() const { return ms_ != 0; } - - /** Gets the integer part of the NTP timestamp. - * - * @return - * - An uint32_t value. - */ - uint32_t ToSeconds() const { - return static_cast(ms_ / 1000); - } - - /** Gets the fractional part of the NTP timestamp. - * - * @return - * - An uint32_t value. - */ - uint32_t ToFractions() const { - return static_cast((ms_ % 1000) * static_cast(ntpFracPerSecond) / 1000.0); - } - - /** Gets the NTP timestamp. - * - * @note - * - The full resolution NTP timestamp is a 64-bit unsigned fixed-point number with the integer part in the first 32 bits and the fractional part in the last 32 bits. - * - * @return - * - An uint64_t value. - */ - uint64_t ToTimestamp() const { - return ToSeconds() * ntpFracPerSecond + ToFractions(); - } - - private: - uint64_t ms_; -}; - -inline bool operator==(const NtpTime& n1, const NtpTime& n2) { - return static_cast(n1) == static_cast(n2); -} - -inline bool operator!=(const NtpTime& n1, const NtpTime& n2) { return !(n1 == n2); } - -} // namespace base -} // namespace agora From bc57051c6b37dd4e442681c776cae7e6eb63477a Mon Sep 17 00:00:00 2001 From: wushengtao Date: Fri, 25 Oct 2024 11:20:07 +0800 Subject: [PATCH 18/21] feat: fix iOS/Mac sdk download script version --- iOS/APIExample-Audio/Podfile | 2 +- iOS/APIExample-OC/Podfile | 2 +- iOS/APIExample/Podfile | 2 +- macOS/Podfile | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/iOS/APIExample-Audio/Podfile b/iOS/APIExample-Audio/Podfile index a011aa68c..a7009bb77 100644 --- a/iOS/APIExample-Audio/Podfile +++ b/iOS/APIExample-Audio/Podfile @@ -12,5 +12,5 @@ target 'APIExample-Audio' do end pre_install do |installer| - # system("sh .download_script.sh 4.3.2 true") + # system("sh .download_script.sh 4.4.0 true") end diff --git a/iOS/APIExample-OC/Podfile b/iOS/APIExample-OC/Podfile index 5fbcd5c1d..cdb06b277 100644 --- a/iOS/APIExample-OC/Podfile +++ b/iOS/APIExample-OC/Podfile @@ -23,5 +23,5 @@ target 'SimpleFilter' do end pre_install do |installer| - # system("sh .download_script.sh 4.3.2 true") + # system("sh .download_script.sh 4.4.0 true") end diff --git a/iOS/APIExample/Podfile b/iOS/APIExample/Podfile index 1a98a1409..37d272e49 100644 --- a/iOS/APIExample/Podfile +++ b/iOS/APIExample/Podfile @@ -32,5 +32,5 @@ target 'SimpleFilter' do end pre_install do |installer| -# system("sh .download_script.sh 4.3.2 true") +# system("sh .download_script.sh 4.4.0 true") end diff --git a/macOS/Podfile b/macOS/Podfile index ae9f8f091..fcd1d74eb 100644 --- a/macOS/Podfile +++ b/macOS/Podfile @@ -16,7 +16,7 @@ end post_install do |installer| - # system("sh .download_script.sh 4.3.2 true") + # system("sh .download_script.sh 4.4.0 true") installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '10.13' From 381125ce5d4457556051a0c54de38bdbaea75221 Mon Sep 17 00:00:00 2001 From: weileifrank <1138289316@qq.com> Date: Fri, 25 Oct 2024 14:57:38 +0800 Subject: [PATCH 19/21] feat: add test cert --- HarmonyOS_NEXT/APIExample/build-profile.json5 | 13 +++++ .../APIExample/sign/ApiExampleDebug.p7b | Bin 0 -> 4791 bytes .../ac/a9a980ef8fc94220b13c0c721d70d419 | 1 + .../ce/3871a319baf7436a96d016ed72a5a44a | Bin 0 -> 48 bytes .../fd/0/85fcb147c0054f01a714d6d3079ac21c | 1 + .../fd/1/83a97013fd8b48988ba64cdb6a5ba6f8 | 1 + .../fd/2/b65fdda18e50403c81dde2e8692108f6 | 1 + HarmonyOS_NEXT/APIExample/sign/wayang.p12 | Bin 0 -> 1150 bytes .../APIExample/sign/wayangAgora.cer | 50 ++++++++++++++++++ 9 files changed, 67 insertions(+) create mode 100644 HarmonyOS_NEXT/APIExample/sign/ApiExampleDebug.p7b create mode 100644 HarmonyOS_NEXT/APIExample/sign/material/ac/a9a980ef8fc94220b13c0c721d70d419 create mode 100644 HarmonyOS_NEXT/APIExample/sign/material/ce/3871a319baf7436a96d016ed72a5a44a create mode 100644 HarmonyOS_NEXT/APIExample/sign/material/fd/0/85fcb147c0054f01a714d6d3079ac21c create mode 100644 HarmonyOS_NEXT/APIExample/sign/material/fd/1/83a97013fd8b48988ba64cdb6a5ba6f8 create mode 100644 HarmonyOS_NEXT/APIExample/sign/material/fd/2/b65fdda18e50403c81dde2e8692108f6 create mode 100644 HarmonyOS_NEXT/APIExample/sign/wayang.p12 create mode 100644 HarmonyOS_NEXT/APIExample/sign/wayangAgora.cer diff --git a/HarmonyOS_NEXT/APIExample/build-profile.json5 b/HarmonyOS_NEXT/APIExample/build-profile.json5 index 1cc7a6cdc..cf4e938ba 100644 --- a/HarmonyOS_NEXT/APIExample/build-profile.json5 +++ b/HarmonyOS_NEXT/APIExample/build-profile.json5 @@ -1,6 +1,19 @@ { "app": { "signingConfigs": [ + { + "name": "default", + "type": "HarmonyOS", + "material": { + "storePassword": "0000001B9FD70AC09FD6E7090CDBD445D5FB1D72E8AF1A431DFD7D0DE83AED585E00B980B61ECB9AADF9B3", + "certpath": "./sign/wayangAgora.cer", + "keyAlias": "wayangAgora", + "keyPassword": "0000001B0B0DA7F83E89969EDA7C66A97A4F258DA6A0C65BF29AF3ADB4602E45E902CF3DBD625DC2AF5C8D", + "profile": "./sign/ApiExampleDebug.p7b", + "signAlg": "SHA256withECDSA", + "storeFile": "./sign/wayang.p12" + } + } ], "products": [ { diff --git a/HarmonyOS_NEXT/APIExample/sign/ApiExampleDebug.p7b b/HarmonyOS_NEXT/APIExample/sign/ApiExampleDebug.p7b new file mode 100644 index 0000000000000000000000000000000000000000..52ff4aa3981ff6bfcac5f9cd65dfb58a3f99e2f4 GIT binary patch literal 4791 zcmcgw3vgT2nYLubi4!}7yhtD+jzUNiNA|hzdw~$nxerN^CHWyg)~se zq>~y5G)0qWe+RNpH z4)YWh;c1aU4n(uGgXKlZ5oQG45fh{s3Q;1X)3mugluqc0QpJABRrYMI)gR5{ktEZ!mL^hT)z3I`>XgZgV z797=h1cXE$!HbpzN}wnXc1$nHM6)GFBw8pXVu?toWcqZNFQPi#z9w1i47fG7j00-b zI*|3c-SX(TEaOyf92;(e<8HqkE8zZ)J|!i2dV5AHS|l4ZjWc2sBAEvo+*iGDOq~axP-#}Ig zxRFT1lx-ZL=|WY0uhj^+~0y<$13M!Y0s8#0FOV|43a-E>>kFu3URj*317win_(U5QuJ9g3t@x7eir-v0-p#=d!<+2p z{7QGePaZpyS-7{StSh7+>Oj0sQWYSYMs7^-=x{!qgw3T=B#{Xg zBR$Q!ziTX$W6P}W2@hml?wFBM!|8HBFEg=#rpKJBkjrVK!9KpHW85g|6|O?4tcNcq zTLVl@eHSi zbGob3@F&F4kkXS2Gd>jR<+20Ww%*Q4kY>yM&Mm{?Oexv#WXmuf4br}xuS-fsGRA1g zX|B<--h|}Vdo`xNH?4G}ba$t=#RYZ9_$pzUGglfeqZ&_=0K~K$?xra|P)xMvkU!8I z>C0#MQ0I6jRcaL})^K%H*ZQHGB&ceDG#z_Nm3aF|rf-Yf+SOg+MhIJAQY9~D&CcqI zp^{dk0}$kNgAX|>S*rUl6SRvQ=-T4dDTd^>~x2kw}kWIKDM(| za7O$Q+1nv^#JKiy+URK;@yVg?-iT))8))-!BW)vwM;Hl~$JzFz$Y;v>h~ManIrGkF zGpBpSQAtgTvJuF%<4ptEDydbU@&!acD=O2Xm&mn*;<-YoC6rIJM8`szd^!q?Lisdk zMmAT-gwoYv-Vuw2N@Y{X?8CX@(A3mWD4(C6PUxUHAUCF_**SsdL=n+Q5IJ~>qR7}m z-ol|`6n2~zG_Zh}WfDbGg^QqYV5myp=>?{oB_bezI?Qgh3kp^lmKQW662eG4=44gD zvMk9IC22$wi7d#_C`kZqMiPrP%n(`;1gr|Y!eWS2<|S3uRE^<5jX9o^RFT6-5nwM- zh^R?C;b<&T9E~WBRS3ff2%K{Q3&O9-1YEE*qIo29iYy8Y$6=NsGG=5|P#BF-Fwap6 z7Gz4qL{(Wv0pFY~F&t4iiDoI80T)D|8AZba!3;+U5IDz(GOzLw8YN(vp)`dSd66&z zEvq7{h?pmW3h9V4C1@fAE)dTkl@%ag@J}fmO%oO)EQ>tLiC7{6!nC3)65$j?7*VA- zMHMijXhw$MMf04~7z&F5ktKzP3Mw4SGZIG=hNWm$M#= zNHGj0@D!3+O``~{a!A3n45)-;Gy2$PEvG16in6nH`SkFfjmi?2pR*Tg-XUnq0zJJ=W=NOt>HwP|S&u_BT)}k(I z9;&aa?Y7k|vdTW{9MotI<~G#1${{0~pcbKXO~br~xl@KFnK-En(F)U8+py%Uv8gkc zD>ccu$w{LN&ugR+)R{*NVi~Fbyhc`>du_PJ*1t|a zKmWp|ji*+4zxPV$oj?4s$F}Qn&s%HvzV_?oo)6}A@;LS0J*!{7-4b1VsPdCL-(rq# zdUo)o?y;+Of3#h{|N9LmAK9%~(bn6axth97dj5ehb*uH=FTeQQH3y!#mVW80X-D@}Z$9?gX9-J8q(*GKCv?9k8Ixe1pj;>s+ zWP}RQrmjRho5;qSx}pX1Gyud@;Q~ORS;W&UYr=&VXAIG{Gf^~rAx6(bOUxgf*D&AZ z?`p#NymN{L)LOJ=Dv}lEM0+6@OQfSs-cU9akD8b2CM612a}-32&LU@u8nu?$wWP-O zRF=D<|B;v1+(HI_asF-E(N8Y<^@4j(uDSa0!=4NBk;d6S9(?qu{f9r;aA;WBKmU=d zE8kf8>`vu4Kjc4>C;OOdo;WyRSq=uEsE7#bTp`|+)|M7R99BJwq9DMP$%x@Pj zxol)&H%0Hlxk&9U2Gd-%Oq!~fd;`hkT9w{?B{W~7<>n{1oWCUj|?4ZhX@wWzu| z&2^Spvu0Z@OV0jWdkZvtPJBNzU%AsOmbSP3tx4;|92;SD(8cYmLMFtA9tgZpR+blP3 zwN8v#YHf2+9sH}CYq88k+BE9ZH`)#yJ^JY>=7eYAzje%8rTvV3qOkg=bxq2=dG@`^ zT?<|vJ9X!}BXrAnZvTN7?~Ys1;K>)RI~KFQbHj~4eqo*R)9bgr{nDXr*KN0+2z}+Y z)^_U2cV0NTe&EGrAAdKt%eOuidJIj})&T0Sn@0UbSHATlec>C=&Wz>nBTr{E5e{v7 zN)xLRIX(ObQSJW_$@>>w{>GDEWtOhm`oleQcWkfRGji}-w_fjeIK~ps_22i|*LUu% zy!+sV`t9Ta2r$DDfio@qIa+}A z&xrvF9-AV@5E?{VCxer{ySk@|@&EWKf~2LRrBcdRIx2tIx5sgJL}VBqnG+Z@*%UOJ{-`>VnC+b3SW;<5WaI==Hi zmue3#NIvYRw%q;Evv(g2Q4*&X<`Fb0!lY52v5{)Ynolclr^K z1@0K92lcb4bKp>5k;K4L5@encsP*iujk4RCR-8NVqx<$Zu;V{lec}P-2lwvZ(9LZR z`1Up|f3xmOzkI4ZgW*=23u)HXHD5o}nVSE=ivM_;?=0Uh9$V7&2kHGskNAy;Hotv~ v_SmVzu;eNK<@@%H9qV~*`*)xDbkE4DHqxYj|N4`cm#-N9{(tXZwEcepq_dMG literal 0 HcmV?d00001 diff --git a/HarmonyOS_NEXT/APIExample/sign/material/ac/a9a980ef8fc94220b13c0c721d70d419 b/HarmonyOS_NEXT/APIExample/sign/material/ac/a9a980ef8fc94220b13c0c721d70d419 new file mode 100644 index 000000000..9c9774964 --- /dev/null +++ b/HarmonyOS_NEXT/APIExample/sign/material/ac/a9a980ef8fc94220b13c0c721d70d419 @@ -0,0 +1 @@ +vW kv? \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/sign/material/ce/3871a319baf7436a96d016ed72a5a44a b/HarmonyOS_NEXT/APIExample/sign/material/ce/3871a319baf7436a96d016ed72a5a44a new file mode 100644 index 0000000000000000000000000000000000000000..e3d16f7514e2a585f312c976255d7aa5f27571c1 GIT binary patch literal 48 zcmV-00MGvb001CvuH_~rk6Iaaz~WPtzvDbb7vDtz+K_k~GJyqAeGse(|3T1X5}<|N GSBj;`%M>L5 literal 0 HcmV?d00001 diff --git a/HarmonyOS_NEXT/APIExample/sign/material/fd/0/85fcb147c0054f01a714d6d3079ac21c b/HarmonyOS_NEXT/APIExample/sign/material/fd/0/85fcb147c0054f01a714d6d3079ac21c new file mode 100644 index 000000000..80ca49202 --- /dev/null +++ b/HarmonyOS_NEXT/APIExample/sign/material/fd/0/85fcb147c0054f01a714d6d3079ac21c @@ -0,0 +1 @@ +/*';'"9 \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/sign/material/fd/1/83a97013fd8b48988ba64cdb6a5ba6f8 b/HarmonyOS_NEXT/APIExample/sign/material/fd/1/83a97013fd8b48988ba64cdb6a5ba6f8 new file mode 100644 index 000000000..02cfb8630 --- /dev/null +++ b/HarmonyOS_NEXT/APIExample/sign/material/fd/1/83a97013fd8b48988ba64cdb6a5ba6f8 @@ -0,0 +1 @@ +XoOQ+9 + \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/sign/material/fd/2/b65fdda18e50403c81dde2e8692108f6 b/HarmonyOS_NEXT/APIExample/sign/material/fd/2/b65fdda18e50403c81dde2e8692108f6 new file mode 100644 index 000000000..7b7e465c4 --- /dev/null +++ b/HarmonyOS_NEXT/APIExample/sign/material/fd/2/b65fdda18e50403c81dde2e8692108f6 @@ -0,0 +1 @@ +pvӇD_b\2? \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/sign/wayang.p12 b/HarmonyOS_NEXT/APIExample/sign/wayang.p12 new file mode 100644 index 0000000000000000000000000000000000000000..b36cceb223040037de29697297ebfc27e323b189 GIT binary patch literal 1150 zcmXqLVyR+cWHxAGQDNiMYV&CO&dbQoxS)wel%sMrUi|A4H|bDq`}p*@)|@MSRlAO2HGqlKeKX9sWhi;ZxP3s_*9%ab!+E zcu(Yz|K|3)h7ytgLvteR5?WT<%`t7eVb|d?#B>NK zw2z6A0Z45}$S@KLE)8j^?+x`I&V39?+mL#^iDmQ2Ef-{LEj^mT#XQ66BRqS-kF9OVBjo%Ung0?K`EbW}X#FGEUla+_oW)aT4!@ zeL9;il}h%#3=3b%P`7vEe5q-PlEznSi~meE{5yG-`8iWQef<=-2Wg%y`oT?A>h7LX z7i|!nQ4~}2U}>yYN4KqI{i|&kL_F`sy>?So-}trmpmu$o^Y(9n?A)^^dIzzvJ4yai z+bZ+qW{wr#nsO7P$rq~JTk~IUo*qAYcfh=q|0WOo=c=XOnJ(rN_4&;EAcrT*ruM{! zMeKc}Xi?CZymsF1%rLEvvil}npN}5xdd=CZ#`=8Xlt>Rx&joFrcPD*je%5jzUBkxv z4-30%xR@`LF*#2(T8E?sba*qRXO?L^wk>Sx z+^)02-y~1f_pVpYE4?pA7VP=jaP8N(Ta12>uD)#Rd&N`p<1m-ey|;@GUM!d+K8LaQ z#4;9-pDR7T9XsT$GnYN9ZgQ4nTBTp=p>1B0%_XvSJAZFUKbRZVn#@E<6%-*Rtl{+&Kw<@kQ*`+QefL|P_&_HJlR-@5aVyW5;? N)pfFaBYi Date: Fri, 25 Oct 2024 15:14:38 +0800 Subject: [PATCH 20/21] feat: update readme --- HarmonyOS_NEXT/APIExample/README.md | 3 ++- HarmonyOS_NEXT/APIExample/README.zh.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/HarmonyOS_NEXT/APIExample/README.md b/HarmonyOS_NEXT/APIExample/README.md index 569077e2a..56a1f489f 100644 --- a/HarmonyOS_NEXT/APIExample/README.md +++ b/HarmonyOS_NEXT/APIExample/README.md @@ -32,7 +32,8 @@ To build and run the sample application, get an App Id: export const AppCertificate: String = YOUR APP CERTIFICATE ``` -6. Download the har package from the [official website](https://doc.shengwang.cn/doc/rtc/harmonyos/resources#%E4%B8%8B%E8%BD%BD-sdk) and copy it to `HarmonyOS_NEXT/APIExample/entry/libs/AgoraRtcSdk.har` +6. Download the har package from the [official website](https://download.agora.io/sdk/release/Agora_Native_SDK_for_HarmonyOS_v4.4.1_FULL.har) and rename`AgoraRtcSdk.har`,then copy it to `HarmonyOS_NEXT/APIExample/entry/libs/AgoraRtcSdk.har` +7. replace sign You are all set. Now connect your HarmonyOS NEXT device and run the project. diff --git a/HarmonyOS_NEXT/APIExample/README.zh.md b/HarmonyOS_NEXT/APIExample/README.zh.md index 10897ee44..74e16fdd3 100644 --- a/HarmonyOS_NEXT/APIExample/README.zh.md +++ b/HarmonyOS_NEXT/APIExample/README.zh.md @@ -31,7 +31,8 @@ // 注意:App证书放在客户端不安全,推荐放在服务端以确保 App 证书不会泄露。 export const AppCertificate: String = YOUR APP CERTIFICATE ``` -6. 在[官网](https://doc.shengwang.cn/doc/rtc/harmonyos/resources#%E4%B8%8B%E8%BD%BD-sdk)上下载har包,并复制到`HarmonyOS_NEXT/APIExample/entry/libs/AgoraRtcSdk.har` +6. 在[官网](https://download.agora.io/sdk/release/Agora_Native_SDK_for_HarmonyOS_v4.4.1_FULL.har)上下载har包,重命名`AgoraRtcSdk.har`并复制到`HarmonyOS_NEXT/APIExample/entry/libs/AgoraRtcSdk.har` +7. Replace the signature information in `build-profile.json5` under the root directory with your own. 然后你就可以编译并运行项目了。 From 051cd3a68e522d78326f10b238673911ad5e4d8d Mon Sep 17 00:00:00 2001 From: weileifrank <1138289316@qq.com> Date: Fri, 25 Oct 2024 15:45:08 +0800 Subject: [PATCH 21/21] feat: delete test cert --- HarmonyOS_NEXT/APIExample/README.md | 2 +- HarmonyOS_NEXT/APIExample/README.zh.md | 2 +- HarmonyOS_NEXT/APIExample/build-profile.json5 | 16 +----- .../APIExample/sign/ApiExampleDebug.p7b | Bin 4791 -> 0 bytes .../ac/a9a980ef8fc94220b13c0c721d70d419 | 1 - .../ce/3871a319baf7436a96d016ed72a5a44a | Bin 48 -> 0 bytes .../fd/0/85fcb147c0054f01a714d6d3079ac21c | 1 - .../fd/1/83a97013fd8b48988ba64cdb6a5ba6f8 | 1 - .../fd/2/b65fdda18e50403c81dde2e8692108f6 | 1 - HarmonyOS_NEXT/APIExample/sign/wayang.p12 | Bin 1150 -> 0 bytes .../APIExample/sign/wayangAgora.cer | 50 ------------------ 11 files changed, 3 insertions(+), 71 deletions(-) delete mode 100644 HarmonyOS_NEXT/APIExample/sign/ApiExampleDebug.p7b delete mode 100644 HarmonyOS_NEXT/APIExample/sign/material/ac/a9a980ef8fc94220b13c0c721d70d419 delete mode 100644 HarmonyOS_NEXT/APIExample/sign/material/ce/3871a319baf7436a96d016ed72a5a44a delete mode 100644 HarmonyOS_NEXT/APIExample/sign/material/fd/0/85fcb147c0054f01a714d6d3079ac21c delete mode 100644 HarmonyOS_NEXT/APIExample/sign/material/fd/1/83a97013fd8b48988ba64cdb6a5ba6f8 delete mode 100644 HarmonyOS_NEXT/APIExample/sign/material/fd/2/b65fdda18e50403c81dde2e8692108f6 delete mode 100644 HarmonyOS_NEXT/APIExample/sign/wayang.p12 delete mode 100644 HarmonyOS_NEXT/APIExample/sign/wayangAgora.cer diff --git a/HarmonyOS_NEXT/APIExample/README.md b/HarmonyOS_NEXT/APIExample/README.md index 56a1f489f..3734c8ee1 100644 --- a/HarmonyOS_NEXT/APIExample/README.md +++ b/HarmonyOS_NEXT/APIExample/README.md @@ -33,7 +33,7 @@ To build and run the sample application, get an App Id: ``` 6. Download the har package from the [official website](https://download.agora.io/sdk/release/Agora_Native_SDK_for_HarmonyOS_v4.4.1_FULL.har) and rename`AgoraRtcSdk.har`,then copy it to `HarmonyOS_NEXT/APIExample/entry/libs/AgoraRtcSdk.har` -7. replace sign +7. config the signature information in `build-profile.json5` under the root directory with your own You are all set. Now connect your HarmonyOS NEXT device and run the project. diff --git a/HarmonyOS_NEXT/APIExample/README.zh.md b/HarmonyOS_NEXT/APIExample/README.zh.md index 74e16fdd3..2a4c9a9ab 100644 --- a/HarmonyOS_NEXT/APIExample/README.zh.md +++ b/HarmonyOS_NEXT/APIExample/README.zh.md @@ -32,7 +32,7 @@ export const AppCertificate: String = YOUR APP CERTIFICATE ``` 6. 在[官网](https://download.agora.io/sdk/release/Agora_Native_SDK_for_HarmonyOS_v4.4.1_FULL.har)上下载har包,重命名`AgoraRtcSdk.har`并复制到`HarmonyOS_NEXT/APIExample/entry/libs/AgoraRtcSdk.har` -7. Replace the signature information in `build-profile.json5` under the root directory with your own. +7. 在根目录下面的 `build-profile.json5` 文件配置你的签名 然后你就可以编译并运行项目了。 diff --git a/HarmonyOS_NEXT/APIExample/build-profile.json5 b/HarmonyOS_NEXT/APIExample/build-profile.json5 index cf4e938ba..516034e9c 100644 --- a/HarmonyOS_NEXT/APIExample/build-profile.json5 +++ b/HarmonyOS_NEXT/APIExample/build-profile.json5 @@ -1,20 +1,6 @@ { "app": { - "signingConfigs": [ - { - "name": "default", - "type": "HarmonyOS", - "material": { - "storePassword": "0000001B9FD70AC09FD6E7090CDBD445D5FB1D72E8AF1A431DFD7D0DE83AED585E00B980B61ECB9AADF9B3", - "certpath": "./sign/wayangAgora.cer", - "keyAlias": "wayangAgora", - "keyPassword": "0000001B0B0DA7F83E89969EDA7C66A97A4F258DA6A0C65BF29AF3ADB4602E45E902CF3DBD625DC2AF5C8D", - "profile": "./sign/ApiExampleDebug.p7b", - "signAlg": "SHA256withECDSA", - "storeFile": "./sign/wayang.p12" - } - } - ], + "signingConfigs": [], "products": [ { "name": "default", diff --git a/HarmonyOS_NEXT/APIExample/sign/ApiExampleDebug.p7b b/HarmonyOS_NEXT/APIExample/sign/ApiExampleDebug.p7b deleted file mode 100644 index 52ff4aa3981ff6bfcac5f9cd65dfb58a3f99e2f4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4791 zcmcgw3vgT2nYLubi4!}7yhtD+jzUNiNA|hzdw~$nxerN^CHWyg)~se zq>~y5G)0qWe+RNpH z4)YWh;c1aU4n(uGgXKlZ5oQG45fh{s3Q;1X)3mugluqc0QpJABRrYMI)gR5{ktEZ!mL^hT)z3I`>XgZgV z797=h1cXE$!HbpzN}wnXc1$nHM6)GFBw8pXVu?toWcqZNFQPi#z9w1i47fG7j00-b zI*|3c-SX(TEaOyf92;(e<8HqkE8zZ)J|!i2dV5AHS|l4ZjWc2sBAEvo+*iGDOq~axP-#}Ig zxRFT1lx-ZL=|WY0uhj^+~0y<$13M!Y0s8#0FOV|43a-E>>kFu3URj*317win_(U5QuJ9g3t@x7eir-v0-p#=d!<+2p z{7QGePaZpyS-7{StSh7+>Oj0sQWYSYMs7^-=x{!qgw3T=B#{Xg zBR$Q!ziTX$W6P}W2@hml?wFBM!|8HBFEg=#rpKJBkjrVK!9KpHW85g|6|O?4tcNcq zTLVl@eHSi zbGob3@F&F4kkXS2Gd>jR<+20Ww%*Q4kY>yM&Mm{?Oexv#WXmuf4br}xuS-fsGRA1g zX|B<--h|}Vdo`xNH?4G}ba$t=#RYZ9_$pzUGglfeqZ&_=0K~K$?xra|P)xMvkU!8I z>C0#MQ0I6jRcaL})^K%H*ZQHGB&ceDG#z_Nm3aF|rf-Yf+SOg+MhIJAQY9~D&CcqI zp^{dk0}$kNgAX|>S*rUl6SRvQ=-T4dDTd^>~x2kw}kWIKDM(| za7O$Q+1nv^#JKiy+URK;@yVg?-iT))8))-!BW)vwM;Hl~$JzFz$Y;v>h~ManIrGkF zGpBpSQAtgTvJuF%<4ptEDydbU@&!acD=O2Xm&mn*;<-YoC6rIJM8`szd^!q?Lisdk zMmAT-gwoYv-Vuw2N@Y{X?8CX@(A3mWD4(C6PUxUHAUCF_**SsdL=n+Q5IJ~>qR7}m z-ol|`6n2~zG_Zh}WfDbGg^QqYV5myp=>?{oB_bezI?Qgh3kp^lmKQW662eG4=44gD zvMk9IC22$wi7d#_C`kZqMiPrP%n(`;1gr|Y!eWS2<|S3uRE^<5jX9o^RFT6-5nwM- zh^R?C;b<&T9E~WBRS3ff2%K{Q3&O9-1YEE*qIo29iYy8Y$6=NsGG=5|P#BF-Fwap6 z7Gz4qL{(Wv0pFY~F&t4iiDoI80T)D|8AZba!3;+U5IDz(GOzLw8YN(vp)`dSd66&z zEvq7{h?pmW3h9V4C1@fAE)dTkl@%ag@J}fmO%oO)EQ>tLiC7{6!nC3)65$j?7*VA- zMHMijXhw$MMf04~7z&F5ktKzP3Mw4SGZIG=hNWm$M#= zNHGj0@D!3+O``~{a!A3n45)-;Gy2$PEvG16in6nH`SkFfjmi?2pR*Tg-XUnq0zJJ=W=NOt>HwP|S&u_BT)}k(I z9;&aa?Y7k|vdTW{9MotI<~G#1${{0~pcbKXO~br~xl@KFnK-En(F)U8+py%Uv8gkc zD>ccu$w{LN&ugR+)R{*NVi~Fbyhc`>du_PJ*1t|a zKmWp|ji*+4zxPV$oj?4s$F}Qn&s%HvzV_?oo)6}A@;LS0J*!{7-4b1VsPdCL-(rq# zdUo)o?y;+Of3#h{|N9LmAK9%~(bn6axth97dj5ehb*uH=FTeQQH3y!#mVW80X-D@}Z$9?gX9-J8q(*GKCv?9k8Ixe1pj;>s+ zWP}RQrmjRho5;qSx}pX1Gyud@;Q~ORS;W&UYr=&VXAIG{Gf^~rAx6(bOUxgf*D&AZ z?`p#NymN{L)LOJ=Dv}lEM0+6@OQfSs-cU9akD8b2CM612a}-32&LU@u8nu?$wWP-O zRF=D<|B;v1+(HI_asF-E(N8Y<^@4j(uDSa0!=4NBk;d6S9(?qu{f9r;aA;WBKmU=d zE8kf8>`vu4Kjc4>C;OOdo;WyRSq=uEsE7#bTp`|+)|M7R99BJwq9DMP$%x@Pj zxol)&H%0Hlxk&9U2Gd-%Oq!~fd;`hkT9w{?B{W~7<>n{1oWCUj|?4ZhX@wWzu| z&2^Spvu0Z@OV0jWdkZvtPJBNzU%AsOmbSP3tx4;|92;SD(8cYmLMFtA9tgZpR+blP3 zwN8v#YHf2+9sH}CYq88k+BE9ZH`)#yJ^JY>=7eYAzje%8rTvV3qOkg=bxq2=dG@`^ zT?<|vJ9X!}BXrAnZvTN7?~Ys1;K>)RI~KFQbHj~4eqo*R)9bgr{nDXr*KN0+2z}+Y z)^_U2cV0NTe&EGrAAdKt%eOuidJIj})&T0Sn@0UbSHATlec>C=&Wz>nBTr{E5e{v7 zN)xLRIX(ObQSJW_$@>>w{>GDEWtOhm`oleQcWkfRGji}-w_fjeIK~ps_22i|*LUu% zy!+sV`t9Ta2r$DDfio@qIa+}A z&xrvF9-AV@5E?{VCxer{ySk@|@&EWKf~2LRrBcdRIx2tIx5sgJL}VBqnG+Z@*%UOJ{-`>VnC+b3SW;<5WaI==Hi zmue3#NIvYRw%q;Evv(g2Q4*&X<`Fb0!lY52v5{)Ynolclr^K z1@0K92lcb4bKp>5k;K4L5@encsP*iujk4RCR-8NVqx<$Zu;V{lec}P-2lwvZ(9LZR z`1Up|f3xmOzkI4ZgW*=23u)HXHD5o}nVSE=ivM_;?=0Uh9$V7&2kHGskNAy;Hotv~ v_SmVzu;eNK<@@%H9qV~*`*)xDbkE4DHqxYj|N4`cm#-N9{(tXZwEcepq_dMG diff --git a/HarmonyOS_NEXT/APIExample/sign/material/ac/a9a980ef8fc94220b13c0c721d70d419 b/HarmonyOS_NEXT/APIExample/sign/material/ac/a9a980ef8fc94220b13c0c721d70d419 deleted file mode 100644 index 9c9774964..000000000 --- a/HarmonyOS_NEXT/APIExample/sign/material/ac/a9a980ef8fc94220b13c0c721d70d419 +++ /dev/null @@ -1 +0,0 @@ -vW kv? \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/sign/material/ce/3871a319baf7436a96d016ed72a5a44a b/HarmonyOS_NEXT/APIExample/sign/material/ce/3871a319baf7436a96d016ed72a5a44a deleted file mode 100644 index e3d16f7514e2a585f312c976255d7aa5f27571c1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 48 zcmV-00MGvb001CvuH_~rk6Iaaz~WPtzvDbb7vDtz+K_k~GJyqAeGse(|3T1X5}<|N GSBj;`%M>L5 diff --git a/HarmonyOS_NEXT/APIExample/sign/material/fd/0/85fcb147c0054f01a714d6d3079ac21c b/HarmonyOS_NEXT/APIExample/sign/material/fd/0/85fcb147c0054f01a714d6d3079ac21c deleted file mode 100644 index 80ca49202..000000000 --- a/HarmonyOS_NEXT/APIExample/sign/material/fd/0/85fcb147c0054f01a714d6d3079ac21c +++ /dev/null @@ -1 +0,0 @@ -/*';'"9 \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/sign/material/fd/1/83a97013fd8b48988ba64cdb6a5ba6f8 b/HarmonyOS_NEXT/APIExample/sign/material/fd/1/83a97013fd8b48988ba64cdb6a5ba6f8 deleted file mode 100644 index 02cfb8630..000000000 --- a/HarmonyOS_NEXT/APIExample/sign/material/fd/1/83a97013fd8b48988ba64cdb6a5ba6f8 +++ /dev/null @@ -1 +0,0 @@ -XoOQ+9 + \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/sign/material/fd/2/b65fdda18e50403c81dde2e8692108f6 b/HarmonyOS_NEXT/APIExample/sign/material/fd/2/b65fdda18e50403c81dde2e8692108f6 deleted file mode 100644 index 7b7e465c4..000000000 --- a/HarmonyOS_NEXT/APIExample/sign/material/fd/2/b65fdda18e50403c81dde2e8692108f6 +++ /dev/null @@ -1 +0,0 @@ -pvӇD_b\2? \ No newline at end of file diff --git a/HarmonyOS_NEXT/APIExample/sign/wayang.p12 b/HarmonyOS_NEXT/APIExample/sign/wayang.p12 deleted file mode 100644 index b36cceb223040037de29697297ebfc27e323b189..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1150 zcmXqLVyR+cWHxAGQDNiMYV&CO&dbQoxS)wel%sMrUi|A4H|bDq`}p*@)|@MSRlAO2HGqlKeKX9sWhi;ZxP3s_*9%ab!+E zcu(Yz|K|3)h7ytgLvteR5?WT<%`t7eVb|d?#B>NK zw2z6A0Z45}$S@KLE)8j^?+x`I&V39?+mL#^iDmQ2Ef-{LEj^mT#XQ66BRqS-kF9OVBjo%Ung0?K`EbW}X#FGEUla+_oW)aT4!@ zeL9;il}h%#3=3b%P`7vEe5q-PlEznSi~meE{5yG-`8iWQef<=-2Wg%y`oT?A>h7LX z7i|!nQ4~}2U}>yYN4KqI{i|&kL_F`sy>?So-}trmpmu$o^Y(9n?A)^^dIzzvJ4yai z+bZ+qW{wr#nsO7P$rq~JTk~IUo*qAYcfh=q|0WOo=c=XOnJ(rN_4&;EAcrT*ruM{! zMeKc}Xi?CZymsF1%rLEvvil}npN}5xdd=CZ#`=8Xlt>Rx&joFrcPD*je%5jzUBkxv z4-30%xR@`LF*#2(T8E?sba*qRXO?L^wk>Sx z+^)02-y~1f_pVpYE4?pA7VP=jaP8N(Ta12>uD)#Rd&N`p<1m-ey|;@GUM!d+K8LaQ z#4;9-pDR7T9XsT$GnYN9ZgQ4nTBTp=p>1B0%_XvSJAZFUKbRZVn#@E<6%-*Rtl{+&Kw<@kQ*`+QefL|P_&_HJlR-@5aVyW5;? N)pfFaBYi