Skip to content

Commit

Permalink
feat: add onNetworkQualityEx (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
guoxianzhe authored Oct 25, 2023
1 parent edbb123 commit ea8ac37
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 42 deletions.
74 changes: 45 additions & 29 deletions packages/rtc/src/binding/IAgoraRtcEngineExDispatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ export class IRtcEngineEventHandlerEx extends IRtcEngineEventHandler {
}

onRejoinChannelSuccessEx(connection: RtcConnection, elapsed: number): void {
AgoraConsole.warn('onRejoinChannelSuccess not supported in this platform!');
AgoraConsole.warn(
'onRejoinChannelSuccessEx not supported in this platform!'
);
this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
}

Expand All @@ -84,7 +86,7 @@ export class IRtcEngineEventHandlerEx extends IRtcEngineEventHandler {
delay: number,
lost: number
): void {
AgoraConsole.warn('onAudioQuality not supported in this platform!');
AgoraConsole.warn('onAudioQualityEx not supported in this platform!');
this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
}

Expand Down Expand Up @@ -126,7 +128,7 @@ export class IRtcEngineEventHandlerEx extends IRtcEngineEventHandler {
}

onRtcStatsEx(connection: RtcConnection, stats: RtcStats): void {
AgoraConsole.warn('onRtcStats not supported in this platform!');
AgoraConsole.warn('onRtcStatsEx not supported in this platform!');
this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
}

Expand All @@ -136,12 +138,26 @@ export class IRtcEngineEventHandlerEx extends IRtcEngineEventHandler {
txQuality: number,
rxQuality: number
): void {
AgoraConsole.warn('onNetworkQuality not supported in this platform!');
this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
let _obj = {
connection,
remoteUid,
txQuality,
rxQuality,
};
let _json = JSON.stringify(_obj);
let _key = this.eventKey('onNetworkQualityEx');

let eventParam = new IrisCore.EventParam(_key, _json, 0, '', [], [], 0);
AgoraConsole.log(
`onNetworkQualityEx eventParam ${JSON.stringify(eventParam)}`
);
this.notifyEvent(eventParam);
}

onIntraRequestReceivedEx(connection: RtcConnection): void {
AgoraConsole.warn('onIntraRequestReceived not supported in this platform!');
AgoraConsole.warn(
'onIntraRequestReceivedEx not supported in this platform!'
);
this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
}

Expand Down Expand Up @@ -177,7 +193,7 @@ export class IRtcEngineEventHandlerEx extends IRtcEngineEventHandler {
height: number,
rotation: number
): void {
AgoraConsole.warn('onVideoSizeChanged not supported in this platform!');
AgoraConsole.warn('onVideoSizeChangedEx not supported in this platform!');
this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
}

Expand All @@ -189,7 +205,7 @@ export class IRtcEngineEventHandlerEx extends IRtcEngineEventHandler {
elapsed: number
): void {
AgoraConsole.warn(
'onRemoteVideoStateChanged not supported in this platform!'
'onRemoteVideoStateChangedEx not supported in this platform!'
);
this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
}
Expand Down Expand Up @@ -301,7 +317,7 @@ export class IRtcEngineEventHandlerEx extends IRtcEngineEventHandler {
remoteUid: number,
enabled: boolean
): void {
AgoraConsole.warn('onUserEnableVideo not supported in this platform!');
AgoraConsole.warn('onUserEnableVideoEx not supported in this platform!');
this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
}

Expand Down Expand Up @@ -346,23 +362,23 @@ export class IRtcEngineEventHandlerEx extends IRtcEngineEventHandler {
}

onLocalAudioStatsEx(connection: RtcConnection, stats: LocalAudioStats): void {
AgoraConsole.warn('onLocalAudioStats not supported in this platform!');
AgoraConsole.warn('onLocalAudioStatsEx not supported in this platform!');
this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
}

onRemoteAudioStatsEx(
connection: RtcConnection,
stats: RemoteAudioStats
): void {
AgoraConsole.warn('onRemoteAudioStats not supported in this platform!');
AgoraConsole.warn('onRemoteAudioStatsEx not supported in this platform!');
this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
}

onRemoteVideoStatsEx(
connection: RtcConnection,
stats: RemoteVideoStats
): void {
AgoraConsole.warn('onRemoteVideoStats not supported in this platform!');
AgoraConsole.warn('onRemoteVideoStatsEx not supported in this platform!');
this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
}

Expand Down Expand Up @@ -416,7 +432,7 @@ export class IRtcEngineEventHandlerEx extends IRtcEngineEventHandler {
length: number,
sentTs: number
): void {
AgoraConsole.warn('onStreamMessage not supported in this platform!');
AgoraConsole.warn('onStreamMessageEx not supported in this platform!');
this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
}

Expand All @@ -428,7 +444,7 @@ export class IRtcEngineEventHandlerEx extends IRtcEngineEventHandler {
missed: number,
cached: number
): void {
AgoraConsole.warn('onStreamMessageError not supported in this platform!');
AgoraConsole.warn('onStreamMessageErrorEx not supported in this platform!');
this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
}

Expand All @@ -451,7 +467,7 @@ export class IRtcEngineEventHandlerEx extends IRtcEngineEventHandler {
reason: LICENSE_ERROR_TYPE
): void {
AgoraConsole.warn(
'onLicenseValidationFailure not supported in this platform!'
'onLicenseValidationFailureEx not supported in this platform!'
);
this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
}
Expand All @@ -476,7 +492,7 @@ export class IRtcEngineEventHandlerEx extends IRtcEngineEventHandler {
elapsed: number
): void {
AgoraConsole.warn(
'onFirstLocalAudioFramePublished not supported in this platform!'
'onFirstLocalAudioFramePublishedEx not supported in this platform!'
);
this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
}
Expand Down Expand Up @@ -527,7 +543,7 @@ export class IRtcEngineEventHandlerEx extends IRtcEngineEventHandler {
error: LOCAL_AUDIO_STREAM_ERROR
): void {
AgoraConsole.warn(
'onLocalAudioStateChanged not supported in this platform!'
'onLocalAudioStateChangedEx not supported in this platform!'
);
this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
}
Expand All @@ -540,13 +556,13 @@ export class IRtcEngineEventHandlerEx extends IRtcEngineEventHandler {
elapsed: number
): void {
AgoraConsole.warn(
'onRemoteAudioStateChanged not supported in this platform!'
'onRemoteAudioStateChangedEx not supported in this platform!'
);
this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
}

onActiveSpeakerEx(connection: RtcConnection, uid: number): void {
AgoraConsole.warn('onActiveSpeaker not supported in this platform!');
AgoraConsole.warn('onActiveSpeakerEx not supported in this platform!');
this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
}

Expand Down Expand Up @@ -578,7 +594,7 @@ export class IRtcEngineEventHandlerEx extends IRtcEngineEventHandler {
currentRole: CLIENT_ROLE_TYPE
): void {
AgoraConsole.warn(
'onClientRoleChangeFailed not supported in this platform!'
'onClientRoleChangeFailedEx not supported in this platform!'
);
this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
}
Expand All @@ -591,7 +607,7 @@ export class IRtcEngineEventHandlerEx extends IRtcEngineEventHandler {
rxKBitRate: number
): void {
AgoraConsole.warn(
'onRemoteAudioTransportStats not supported in this platform!'
'onRemoteAudioTransportStatsEx not supported in this platform!'
);
this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
}
Expand All @@ -604,7 +620,7 @@ export class IRtcEngineEventHandlerEx extends IRtcEngineEventHandler {
rxKBitRate: number
): void {
AgoraConsole.warn(
'onRemoteVideoTransportStats not supported in this platform!'
'onRemoteVideoTransportStatsEx not supported in this platform!'
);
this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
}
Expand Down Expand Up @@ -635,7 +651,7 @@ export class IRtcEngineEventHandlerEx extends IRtcEngineEventHandler {
action: WLACC_SUGGEST_ACTION,
wlAccMsg: string
): void {
AgoraConsole.warn('onWlAccMessage not supported in this platform!');
AgoraConsole.warn('onWlAccMessageEx not supported in this platform!');
this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
}

Expand All @@ -644,12 +660,12 @@ export class IRtcEngineEventHandlerEx extends IRtcEngineEventHandler {
currentStats: WlAccStats,
averageStats: WlAccStats
): void {
AgoraConsole.warn('onWlAccStats not supported in this platform!');
AgoraConsole.warn('onWlAccStatsEx not supported in this platform!');
this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
}

onNetworkTypeChangedEx(connection: RtcConnection, type: NETWORK_TYPE): void {
AgoraConsole.warn('onNetworkTypeChanged not supported in this platform!');
AgoraConsole.warn('onNetworkTypeChangedEx not supported in this platform!');
this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
}

Expand Down Expand Up @@ -677,7 +693,7 @@ export class IRtcEngineEventHandlerEx extends IRtcEngineEventHandler {
success: boolean,
reason: UPLOAD_ERROR_REASON
): void {
AgoraConsole.warn('onUploadLogResult not supported in this platform!');
AgoraConsole.warn('onUploadLogResultEx not supported in this platform!');
this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
}

Expand All @@ -686,7 +702,7 @@ export class IRtcEngineEventHandlerEx extends IRtcEngineEventHandler {
remoteUid: number,
userAccount: string
): void {
AgoraConsole.warn('onUserAccountUpdated not supported in this platform!');
AgoraConsole.warn('onUserAccountUpdatedEx not supported in this platform!');
this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
}

Expand All @@ -698,7 +714,7 @@ export class IRtcEngineEventHandlerEx extends IRtcEngineEventHandler {
height: number,
errCode: number
): void {
AgoraConsole.warn('onSnapshotTaken not supported in this platform!');
AgoraConsole.warn('onSnapshotTakenEx not supported in this platform!');
this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
}

Expand All @@ -709,7 +725,7 @@ export class IRtcEngineEventHandlerEx extends IRtcEngineEventHandler {
tracingInfo: VideoRenderingTracingInfo
): void {
AgoraConsole.warn(
'onVideoRenderingTracingResult not supported in this platform!'
'onVideoRenderingTracingResultEx not supported in this platform!'
);
this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/rtc/src/engine/IrisClientManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ export class IrisClientManager {
this._engine.rtcEngineEventHandler.onNetworkQualityEx(
connection,
remoteUserPackage.uid as number,
stats[remoteUserPackage.uid].downlinkNetworkQuality,
stats[remoteUserPackage.uid].uplinkNetworkQuality
stats[remoteUserPackage.uid]?.downlinkNetworkQuality,
stats[remoteUserPackage.uid]?.uplinkNetworkQuality
);
}, this._engine.globalState.networkQualityInterval);
this._engine.addIrisInterval(
Expand Down
13 changes: 3 additions & 10 deletions packages/rtc/test/binding/IAgoraRtcEngineExDispatch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,19 +141,12 @@ describe('IRtcEngineEventHandlerEx', () => {
let eventHandler = new bindingAPI.IRtcEngineEventHandlerEx(irisRtcEngine);
jest.spyOn(eventHandler._engine.irisEventHandlerManager, 'notifyEvent');
jest.spyOn(eventHandler, 'eventKey');
jest
.spyOn(irisRtcEngine, 'returnResult')
.mockResolvedValue(new CallIrisApiResult(0, ''));
eventHandler.onNetworkQualityEx(undefined, undefined, undefined, undefined);
expect(
eventHandler._engine.irisEventHandlerManager.notifyEvent
).toBeCalledTimes(0);
expect(eventHandler.eventKey).toBeCalledTimes(0);
expect(irisRtcEngine.returnResult).toBeCalledTimes(1);
expect(irisRtcEngine.returnResult).toBeCalledWith(
false,
-NATIVE_RTC.ERROR_CODE_TYPE.ERR_NOT_SUPPORTED
);
).toBeCalledTimes(1);
expect(eventHandler.eventKey).toBeCalledTimes(1);
expect(eventHandler.eventKey).toBeCalledWith('onNetworkQualityEx');
});
test('onIntraRequestReceivedEx impl call', async () => {
let eventHandler = new bindingAPI.IRtcEngineEventHandlerEx(irisRtcEngine);
Expand Down
1 change: 1 addition & 0 deletions scripts/terra/config/support_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"agora::rtc::IRtcEngineEventHandlerEx.onUserMuteAudio",
"agora::rtc::IRtcEngineEventHandlerEx.onUserStateChanged",
"agora::rtc::IRtcEngineEventHandlerEx.onClientRoleChanged",
"agora::rtc::IRtcEngineEventHandlerEx.onNetworkQuality",
"agora::rtc::IRtcEngineEventHandlerEx.onUserMuteVideo",
"agora::rtc::IRtcEngineEventHandlerEx.onUserEnableLocalVideo",
"agora::rtc::IRtcEngineEventHandlerEx.onAudioVolumeIndication",
Expand Down
2 changes: 1 addition & 1 deletion scripts/terra/templates/binding/file_content.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class {{name}} {{#base_clazzs}}extends {{.}}{{/base_clazzs}}{
this.notifyEvent(eventParam);
{{/user_data.isSupport}}
{{^user_data.isSupport}}
AgoraConsole.warn('{{name}} not supported in this platform!');
AgoraConsole.warn('{{name}}{{user_data._prefix}} not supported in this platform!');
this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED);
{{/user_data.isSupport}}
}
Expand Down

0 comments on commit ea8ac37

Please sign in to comment.