Skip to content

Commit

Permalink
feat: adm
Browse files Browse the repository at this point in the history
  • Loading branch information
guoxianzhe committed Aug 8, 2024
1 parent b3b098c commit dfb7a3c
Show file tree
Hide file tree
Showing 17 changed files with 684 additions and 224 deletions.
2 changes: 1 addition & 1 deletion packages/fake/rtc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"dependencies": {
"@iris/native-rtc": "workspace: *",
"agora-rtc-sdk-ng": "4.21.0",
"@agoraio-extensions/agora-rtc-sdk-ng-fake": "^1.0.12",
"@agoraio-extensions/agora-rtc-sdk-ng-fake": "^1.0.13",
"iris-web-rtc": "workspace: *"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/rtc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"author": "AgoraIO-Extensions",
"license": "MIT",
"dependencies": {
"@agoraio-extensions/agora-rtc-sdk-ng-fake": "^1.0.12",
"@agoraio-extensions/agora-rtc-sdk-ng-fake": "^1.0.13",
"@iris/native-rtc": "workspace: *",
"agora-rtc-sdk-ng": "4.21.0",
"iris-web-core": "workspace: *"
Expand Down
10 changes: 4 additions & 6 deletions packages/rtc/src/binding/IAgoraRtcEngineDispatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,8 @@ import { ApiParam, CallApiReturnType, IrisCore } from 'iris-web-core';
import { IrisRtcEngine } from '../engine/IrisRtcEngine';
import { callApiBufferExtension } from '../extensions/CallApiBufferExtensions';
import { eventHandlerBufferExtension } from '../extensions/EventhandlerBufferExtensions';
import {
IRtcEngineImpl,
IVideoDeviceManagerImpl,
} from '../impl/IAgoraRtcEngineImpl';
import { IRtcEngineImpl } from '../impl/IAgoraRtcEngineImpl';
import { IVideoDeviceManagerImpl } from '../impl/IVideoDeviceManagerImpl';
import { AgoraConsole } from '../util/AgoraConsole';

export class IRtcEngineEventHandler {
Expand Down Expand Up @@ -4437,7 +4435,7 @@ export class IRtcEngineDispatch implements IRtcEngine {
}
let userInfo = obj.userInfo;

return this._impl.getUserInfoByUserAccount_c6a8f08(userAccount, userInfo);
return this._impl.getUserInfoByUserAccount_c6a8f08(userAccount);
}

// @ts-ignore
Expand All @@ -4450,7 +4448,7 @@ export class IRtcEngineDispatch implements IRtcEngine {
}
let userInfo = obj.userInfo;

return this._impl.getUserInfoByUid_6b7aee8(uid, userInfo);
return this._impl.getUserInfoByUid_6b7aee8(uid);
}

// @ts-ignore
Expand Down
59 changes: 31 additions & 28 deletions packages/rtc/src/binding/IAudioDeviceManagerDispatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,46 @@ import { ERROR_CODE_TYPE, IAudioDeviceManager } from '@iris/native-rtc';
import { ApiParam, CallApiReturnType } from 'iris-web-core';

import { IrisRtcEngine } from '../engine/IrisRtcEngine';
import { IAudioDeviceManagerImpl } from '../impl/IAudioDeviceManagerImpl';
import { AgoraConsole } from '../util/AgoraConsole';

export class IAudioDeviceManagerDispatch implements IAudioDeviceManager {
// @ts-ignore
_impl: IAudioDeviceManagerImpl;
_engine: IrisRtcEngine;

constructor(engine: IrisRtcEngine) {
this._impl = new IAudioDeviceManagerImpl(engine);
this._engine = engine;
}
// @ts-ignore
enumeratePlaybackDevices(): CallApiReturnType {
AgoraConsole.warn(
'AudioDeviceManager_enumeratePlaybackDevices not supported in this platform!'
);
return this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
return this._impl.enumeratePlaybackDevices();
}

// @ts-ignore
enumerateRecordingDevices(): CallApiReturnType {
AgoraConsole.warn(
'AudioDeviceManager_enumerateRecordingDevices not supported in this platform!'
);
return this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
return this._impl.enumerateRecordingDevices();
}

// @ts-ignore
setPlaybackDevice_4ad5f6e(apiParam: ApiParam): CallApiReturnType {
AgoraConsole.warn(
'AudioDeviceManager_setPlaybackDevice_4ad5f6e not supported in this platform!'
);
return this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
let obj = JSON.parse(apiParam.data) as any;
let deviceId = obj.deviceId;
if (deviceId === undefined) {
AgoraConsole.error('deviceId is undefined');
throw 'deviceId is undefined';
}

return this._impl.setPlaybackDevice_4ad5f6e(deviceId);
}

// @ts-ignore
getPlaybackDevice_73b9872(apiParam: ApiParam): CallApiReturnType {
AgoraConsole.warn(
'AudioDeviceManager_getPlaybackDevice_73b9872 not supported in this platform!'
);
return this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
let obj = JSON.parse(apiParam.data) as any;
let deviceId = obj.deviceId;

return this._impl.getPlaybackDevice_73b9872();
}

// @ts-ignore
Expand Down Expand Up @@ -70,18 +72,22 @@ export class IAudioDeviceManagerDispatch implements IAudioDeviceManager {

// @ts-ignore
setRecordingDevice_4ad5f6e(apiParam: ApiParam): CallApiReturnType {
AgoraConsole.warn(
'AudioDeviceManager_setRecordingDevice_4ad5f6e not supported in this platform!'
);
return this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
let obj = JSON.parse(apiParam.data) as any;
let deviceId = obj.deviceId;
if (deviceId === undefined) {
AgoraConsole.error('deviceId is undefined');
throw 'deviceId is undefined';
}

return this._impl.setRecordingDevice_4ad5f6e(deviceId);
}

// @ts-ignore
getRecordingDevice_73b9872(apiParam: ApiParam): CallApiReturnType {
AgoraConsole.warn(
'AudioDeviceManager_getRecordingDevice_73b9872 not supported in this platform!'
);
return this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
let obj = JSON.parse(apiParam.data) as any;
let deviceId = obj.deviceId;

return this._impl.getRecordingDevice_73b9872();
}

// @ts-ignore
Expand Down Expand Up @@ -230,9 +236,6 @@ export class IAudioDeviceManagerDispatch implements IAudioDeviceManager {

// @ts-ignore
release(): CallApiReturnType {
AgoraConsole.warn(
'AudioDeviceManager_release not supported in this platform!'
);
return this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
return this._impl.release();
}
}
18 changes: 17 additions & 1 deletion packages/rtc/src/helper/TrackHelper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import * as NATIVE_RTC from '@iris/native-rtc';
import {
ICameraVideoTrack,
ILocalAudioTrack,
ILocalTrack,
IMicrophoneAudioTrack,
IRemoteAudioTrack,
ITrack,
} from 'agora-rtc-sdk-ng';
Expand Down Expand Up @@ -69,7 +71,7 @@ export class TrackHelper {
}
}
public async setDevice(
track: ICameraVideoTrack,
track: ICameraVideoTrack | IMicrophoneAudioTrack,
deviceId: string
): Promise<void> {
try {
Expand All @@ -82,4 +84,18 @@ export class TrackHelper {
throw e;
}
}
public async setPlaybackDevice(
track: ILocalAudioTrack | IRemoteAudioTrack,
deviceId: string
): Promise<void> {
try {
await track?.setPlaybackDevice(deviceId);
} catch (e) {
AgoraConsole.error(e);
Promise.resolve(
new CallIrisApiResult(-NATIVE_RTC.ERROR_CODE_TYPE.ERR_FAILED, e)
);
throw e;
}
}
}
105 changes: 2 additions & 103 deletions packages/rtc/src/impl/IAgoraRtcEngineImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1111,10 +1111,7 @@ export class IRtcEngineImpl implements IRtcEngineExtensions {
return this._engine.execute(processJoinChannel);
}

getUserInfoByUserAccount_c6a8f08(
userAccount: string,
userInfo: NATIVE_RTC.UserInfo
): CallApiReturnType {
getUserInfoByUserAccount_c6a8f08(userAccount: string): CallApiReturnType {
let user = this._engine.irisClientManager.getUserInfoByUserAccount(
userAccount
);
Expand All @@ -1128,10 +1125,7 @@ export class IRtcEngineImpl implements IRtcEngineExtensions {
);
}

getUserInfoByUid_6b7aee8(
uid: number,
userInfo: NATIVE_RTC.UserInfo
): CallApiReturnType {
getUserInfoByUid_6b7aee8(uid: number): CallApiReturnType {
let user = this._engine.irisClientManager.getUserInfoByUid(uid);
return this._engine.returnResult(
true,
Expand All @@ -1143,98 +1137,3 @@ export class IRtcEngineImpl implements IRtcEngineExtensions {
);
}
}

//@ts-ignore
export class IVideoDeviceManagerImpl implements NATIVE_RTC.IVideoDeviceManager {
private _engine: IrisRtcEngine;

public constructor(engine: IrisRtcEngine) {
this._engine = engine;
}

enumerateVideoDevices(): CallApiReturnType {
let deviceList: MediaDeviceInfo[] = [];
let process = async () => {
try {
deviceList = (await this._engine.implHelper.enumerateDevices())
?.videoDevices;
} catch (e) {
AgoraConsole.log(e);
return this._engine.returnResult(false);
}
return this._engine.returnResult(
true,
0,
JSON.stringify({ result: deviceList })
);
};
return this._engine.execute(process);
}
setDevice_4ad5f6e(deviceIdUTF8: string): CallApiReturnType {
let process = async () => {
this._engine.globalState.videoDeviceId = deviceIdUTF8;

for (let videoTrackPackage of this._engine.irisClientManager
.localVideoTrackPackages) {
if (videoTrackPackage.track) {
if (
videoTrackPackage.type ==
NATIVE_RTC.VIDEO_SOURCE_TYPE.VIDEO_SOURCE_CAMERA_PRIMARY ||
videoTrackPackage.type ==
NATIVE_RTC.VIDEO_SOURCE_TYPE.VIDEO_SOURCE_CAMERA_SECONDARY ||
videoTrackPackage.type ==
NATIVE_RTC.VIDEO_SOURCE_TYPE.VIDEO_SOURCE_CAMERA_THIRD ||
videoTrackPackage.type ==
NATIVE_RTC.VIDEO_SOURCE_TYPE.VIDEO_SOURCE_CAMERA_FOURTH
) {
await this._engine.trackHelper.setDevice(
videoTrackPackage.track as ICameraVideoTrack,
deviceIdUTF8
);
}
}
}

return this._engine.returnResult();
};
return this._engine.execute(process);
}
getDevice_73b9872(): CallApiReturnType {
let process = async () => {
let list: MediaDeviceInfo[] = [];
let deviceId = '';
if (this._engine.globalState.videoDeviceId) {
deviceId = this._engine.globalState.videoDeviceId;
} else {
try {
list = await this._engine.globalState.AgoraRTC.getCameras();
} catch (e) {
return this._engine.returnResult(false);
}
if (list && list.length > 0) {
deviceId = list[0].deviceId;
}
}
return this._engine.returnResult(
true,
0,
JSON.stringify({
result: NATIVE_RTC.ERROR_CODE_TYPE.ERR_OK,
deviceIdUTF8: deviceId,
})
);
};
return this._engine.execute(process);
}

release(): CallApiReturnType {
let process = async () => {
let engine = this._engine;
engine.globalState.playbackDevices = new Array();
engine.globalState.recordingDevices = new Array();
engine.globalState.videoDevices = new Array();
return this._engine.returnResult();
};
return this._engine.execute(process);
}
}
Loading

0 comments on commit dfb7a3c

Please sign in to comment.