Skip to content

Commit

Permalink
chore: optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
guoxianzhe committed Mar 21, 2024
1 parent db6b3ad commit 022be46
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 42 deletions.
1 change: 0 additions & 1 deletion scripts/terra/generate-code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ cd ${PROJECT_ROOT}

npm run build:ts-interface

npm run lint -- --fix
36 changes: 36 additions & 0 deletions ts/Private/AgoraBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,28 @@ export enum VideoCodecType {
VideoCodecGenericJpeg = 20,
}

/**
* @ignore
*/
export enum CameraFocalLengthType {
/**
* @ignore
*/
CameraFocalLengthDefault = 0,
/**
* @ignore
*/
CameraFocalLengthWideAngle = 1,
/**
* @ignore
*/
CameraFocalLengthUrltraWide = 2,
/**
* @ignore
*/
CameraFocalLengthTelephoto = 3,
}

/**
* @ignore
*/
Expand Down Expand Up @@ -1330,6 +1352,20 @@ export class CodecCapInfo {
codecLevels?: CodecCapLevels;
}

/**
* @ignore
*/
export class FocalLengthInfo {
/**
* @ignore
*/
cameraDirection?: number;
/**
* @ignore
*/
focalLengthType?: CameraFocalLengthType;
}

/**
* Video encoder configurations.
*/
Expand Down
68 changes: 27 additions & 41 deletions ts/Private/IAgoraRtcEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
AudioSessionOperationRestriction,
AudioVolumeInfo,
BeautyOptions,
CameraFocalLengthType,
CameraStabilizationMode,
CaptureBrightnessLevelType,
ChannelMediaRelayConfiguration,
Expand All @@ -32,6 +33,7 @@ import {
EncryptionConfig,
EncryptionErrorType,
ErrorCodeType,
FocalLengthInfo,
HeadphoneEqualizerPreset,
IAudioEncodedFrameObserver,
LastmileProbeConfig,
Expand Down Expand Up @@ -856,6 +858,10 @@ export class CameraCapturerConfiguration {
* @ignore
*/
cameraDirection?: CameraDirection;
/**
* @ignore
*/
cameraFocalLengthType?: CameraFocalLengthType;
/**
* This method applies to Windows only. The ID of the camera. The maximum length is MaxDeviceIdLengthType.
*/
Expand Down Expand Up @@ -1810,6 +1816,17 @@ export interface IRtcEngineEventHandler {
numFaces: number
): void;

/**
* @ignore
*/
onCameraCapturerConfigurationChanged?(
direction: number,
focalLengthType: number,
width: number,
height: number,
frameRate: number
): void;

/**
* Occurs when the video stops playing.
*
Expand Down Expand Up @@ -2981,38 +2998,7 @@ export abstract class IRtcEngine {
): number;

/**
* Preloads a channel with token, channelId, and userAccount.
*
* When audience members need to switch between different channels frequently, calling the method can help shortening the time of joining a channel, thus reducing the time it takes for audience members to hear and see the host. As it may take a while for the SDK to preload a channel, Agora recommends that you call this method as soon as possible after obtaining the channel name and user ID to join a channel. If you join a preloaded channel, leave it and want to rejoin the same channel, you do not need to call this method unless the token for preloading the channel expires.
* Failing to preload a channel does not mean that you can't join a channel, nor will it increase the time of joining a channel.
* One IRtcEngine instance supports preloading 20 channels at most. When exceeding this limit, the latest 20 preloaded channels take effect.
* When calling this method, ensure you set the user role as audience and do not set the audio scenario as AudioScenarioChorus, otherwise, this method does not take effect.
* You also need to make sure that the User Account, channel ID and token passed in for preloading are the same as the values passed in when joining the channel, otherwise, this method does not take effect.
*
* @param token The token generated on your server for authentication. When the token for preloading channels expires, you can update the token based on the number of channels you preload.
* When preloading one channel, calling this method to pass in the new token.
* When preloading more than one channels:
* If you use a wildcard token for all preloaded channels, call updatePreloadChannelToken to update the token. When generating a wildcard token, ensure the user ID is not set as 0.
* If you use different tokens to preload different channels, call this method to pass in your user ID, channel name and the new token.
* @param channelId The channel name that you want to preload. 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 characters (89 characters in total):
* All lowercase English letters: a to z.
* All uppercase English letters: A to Z.
* All numeric characters: 0 to 9.
* Space
* "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","
* @param userAccount The user account. This parameter is used to identify the user in the channel for real-time audio and video engagement. You need to set and manage user accounts yourself and ensure that each user account in the same channel is unique. The maximum length of this parameter is 255 bytes. Ensure that you set this parameter and do not set it as null. Supported characters are (89 in total):
* The 26 lowercase English letters: a to z.
* The 26 uppercase English letters: A to Z.
* All numeric characters: 0 to 9.
* Space
* "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","
*
* @returns
* 0: Success.
* < 0: Failure.
* -2: The parameter is invalid. For example, the User Account is empty. You need to pass in a valid parameter and join 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 and join the channel again.
* @ignore
*/
abstract preloadChannelWithUserAccount(
token: string,
Expand Down Expand Up @@ -5528,15 +5514,7 @@ export abstract class IRtcEngine {
): number;

/**
* Gets the audio device information.
*
* After calling this method, you can get whether the audio device supports ultra-low-latency capture and playback.
* You can call this method either before or after joining a channel.
*
* @returns
* The DeviceInfo object that identifies the audio device information.
* Not null: Success.
* Null: Failure.
* @ignore
*/
abstract getAudioDeviceInfo(): DeviceInfo;

Expand Down Expand Up @@ -5626,6 +5604,14 @@ export abstract class IRtcEngine {
*/
abstract queryScreenCaptureCapability(): number;

/**
* @ignore
*/
abstract queryCameraFocalLengthCapability(): {
focalLengthInfos: FocalLengthInfo;
size: number;
};

/**
* Sets the screen sharing scenario.
*
Expand Down
32 changes: 32 additions & 0 deletions ts/Private/impl/IAgoraRtcEngineImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
EarMonitoringFilterType,
EchoTestConfiguration,
EncryptionConfig,
FocalLengthInfo,
HeadphoneEqualizerPreset,
IAudioEncodedFrameObserver,
LastmileProbeConfig,
Expand Down Expand Up @@ -465,6 +466,18 @@ export function processIRtcEngineEventHandler(
}
break;

case 'onCameraCapturerConfigurationChanged':
if (handler.onCameraCapturerConfigurationChanged !== undefined) {
handler.onCameraCapturerConfigurationChanged(
jsonParams.direction,
jsonParams.focalLengthType,
jsonParams.width,
jsonParams.height,
jsonParams.frameRate
);
}
break;

case 'onVideoStopped':
if (handler.onVideoStopped !== undefined) {
handler.onVideoStopped();
Expand Down Expand Up @@ -5259,6 +5272,25 @@ export class IRtcEngineImpl implements IRtcEngine {
return 'RtcEngine_queryScreenCaptureCapability';
}

queryCameraFocalLengthCapability(): {
focalLengthInfos: FocalLengthInfo;
size: number;
} {
const apiType = this.getApiTypeFromQueryCameraFocalLengthCapability();
const jsonParams = {};
const jsonResults = callIrisApi.call(this, apiType, jsonParams);
const focalLengthInfos = jsonResults.focalLengthInfos;
const size = jsonResults.size;
return {
focalLengthInfos,
size,
};
}

protected getApiTypeFromQueryCameraFocalLengthCapability(): string {
return 'RtcEngine_queryCameraFocalLengthCapability_2dee6af';
}

setScreenCaptureScenario(screenScenario: ScreenScenarioType): number {
const apiType = this.getApiTypeFromSetScreenCaptureScenario(screenScenario);
const jsonParams = {
Expand Down
1 change: 1 addition & 0 deletions ts/Private/ti/IAgoraRtcEngine-ti.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const IRtcEngineEventHandler = t.iface([], {
"onCameraFocusAreaChanged": t.opt(t.func("void", t.param("x", "number"), t.param("y", "number"), t.param("width", "number"), t.param("height", "number"))),
"onCameraExposureAreaChanged": t.opt(t.func("void", t.param("x", "number"), t.param("y", "number"), t.param("width", "number"), t.param("height", "number"))),
"onFacePositionChanged": t.opt(t.func("void", t.param("imageWidth", "number"), t.param("imageHeight", "number"), t.param("vecRectangle", t.array("Rectangle")), t.param("vecDistance", t.array("number")), t.param("numFaces", "number"))),
"onCameraCapturerConfigurationChanged": t.opt(t.func("void", t.param("direction", "number"), t.param("focalLengthType", "number"), t.param("width", "number"), t.param("height", "number"), t.param("frameRate", "number"))),
"onVideoStopped": t.opt(t.func("void")),
"onAudioMixingStateChanged": t.opt(t.func("void", t.param("state", "AudioMixingStateType"), t.param("reason", "AudioMixingReasonType"))),
"onRhythmPlayerStateChanged": t.opt(t.func("void", t.param("state", "RhythmPlayerStateType"), t.param("reason", "RhythmPlayerReason"))),
Expand Down

0 comments on commit 022be46

Please sign in to comment.