From 56eb66a6cf83fb3976e3bfa1705d1d8093b57621 Mon Sep 17 00:00:00 2001 From: guoxianzhe Date: Mon, 29 Jan 2024 08:06:26 +0000 Subject: [PATCH] [AUTO] Generate code by terra --- .../src/binding/IAgoraRtcEngineDispatch.ts | 106 +++++++++--- .../src/binding/IAgoraRtcEngineExDispatch.ts | 42 +++-- .../binding/IAgoraRtcEngineDispatch.test.ts | 162 ++++++++++++------ .../binding/IAgoraRtcEngineExDispatch.test.ts | 135 ++++++++++++--- 4 files changed, 338 insertions(+), 107 deletions(-) diff --git a/packages/rtc/src/binding/IAgoraRtcEngineDispatch.ts b/packages/rtc/src/binding/IAgoraRtcEngineDispatch.ts index f1d42760..83817df6 100644 --- a/packages/rtc/src/binding/IAgoraRtcEngineDispatch.ts +++ b/packages/rtc/src/binding/IAgoraRtcEngineDispatch.ts @@ -1222,10 +1222,29 @@ export class IRtcEngineEventHandler { reason: REMOTE_VIDEO_STATE_REASON, elapsed: number ): void { - AgoraConsole.warn( - 'onRemoteVideoStateChanged_a14e9d1 not supported in this platform!' + let _obj = { + connection, + remoteUid, + state, + reason, + elapsed, + }; + let _json = JSON.stringify(_obj); + let eventParam = new IrisCore.EventParam( + 'RtcEngineEventHandler_onRemoteVideoStateChanged_a14e9d1', + _json, + 0, + '', + [], + [], + 0 ); - this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED); + AgoraConsole.log( + `onRemoteVideoStateChanged_a14e9d1 eventParam ${JSON.stringify( + eventParam + )}` + ); + this.notifyEvent(eventParam); } onFirstRemoteVideoFrame_a68170a( @@ -1523,10 +1542,28 @@ export class IRtcEngineEventHandler { length: number, sentTs: number ): void { - AgoraConsole.warn( - 'onStreamMessage_99898cb not supported in this platform!' + let _obj = { + connection, + remoteUid, + streamId, + data, + length, + sentTs, + }; + let _json = JSON.stringify(_obj); + let eventParam = new IrisCore.EventParam( + 'RtcEngineEventHandler_onStreamMessage_99898cb', + _json, + 0, + '', + [], + [], + 0 ); - this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED); + AgoraConsole.log( + `onStreamMessage_99898cb eventParam ${JSON.stringify(eventParam)}` + ); + this.notifyEvent(eventParam); } onStreamMessageError_fe302fc( @@ -1537,10 +1574,28 @@ export class IRtcEngineEventHandler { missed: number, cached: number ): void { - AgoraConsole.warn( - 'onStreamMessageError_fe302fc not supported in this platform!' + let _obj = { + connection, + remoteUid, + streamId, + code, + missed, + cached, + }; + let _json = JSON.stringify(_obj); + let eventParam = new IrisCore.EventParam( + 'RtcEngineEventHandler_onStreamMessageError_fe302fc', + _json, + 0, + '', + [], + [], + 0 ); - this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED); + AgoraConsole.log( + `onStreamMessageError_fe302fc eventParam ${JSON.stringify(eventParam)}` + ); + this.notifyEvent(eventParam); } onRequestToken_c81e1a4(connection: RtcConnection): void { @@ -2468,10 +2523,11 @@ export class IRtcEngineDispatch implements IRtcEngine { // @ts-ignore muteLocalVideoStream_5039d15(apiParam: ApiParam): CallApiReturnType { - AgoraConsole.warn( - 'muteLocalVideoStream_5039d15 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 mute = obj.mute; + if (mute === undefined) throw 'mute is undefined'; + + return this._impl.muteLocalVideoStream_5039d15(mute); } // @ts-ignore @@ -3941,18 +3997,26 @@ export class IRtcEngineDispatch implements IRtcEngine { // @ts-ignore createDataStream_5862815(apiParam: ApiParam): CallApiReturnType { - AgoraConsole.warn( - 'createDataStream_5862815 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 streamId = obj.streamId; + if (streamId === undefined) throw 'streamId is undefined'; + let config = obj.config; + if (config === undefined) throw 'config is undefined'; + + return this._impl.createDataStream_5862815(streamId, config); } // @ts-ignore sendStreamMessage_8715a45(apiParam: ApiParam): CallApiReturnType { - AgoraConsole.warn( - 'sendStreamMessage_8715a45 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 streamId = obj.streamId; + if (streamId === undefined) throw 'streamId is undefined'; + let data = obj.data; + if (data === undefined) throw 'data is undefined'; + let length = obj.length; + if (length === undefined) throw 'length is undefined'; + + return this._impl.sendStreamMessage_8715a45(streamId, data, length); } // @ts-ignore diff --git a/packages/rtc/src/binding/IAgoraRtcEngineExDispatch.ts b/packages/rtc/src/binding/IAgoraRtcEngineExDispatch.ts index 3b913753..ffb80649 100644 --- a/packages/rtc/src/binding/IAgoraRtcEngineExDispatch.ts +++ b/packages/rtc/src/binding/IAgoraRtcEngineExDispatch.ts @@ -122,10 +122,13 @@ export class IRtcEngineExDispatch extends IRtcEngineDispatch // @ts-ignore muteLocalVideoStreamEx_3cf17a4(apiParam: ApiParam): CallApiReturnType { - AgoraConsole.warn( - 'muteLocalVideoStreamEx_3cf17a4 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 mute = obj.mute; + if (mute === undefined) throw 'mute is undefined'; + let connection = obj.connection; + if (connection === undefined) throw 'connection is undefined'; + + return this._impl.muteLocalVideoStreamEx_3cf17a4(mute, connection); } // @ts-ignore @@ -275,18 +278,35 @@ export class IRtcEngineExDispatch extends IRtcEngineDispatch // @ts-ignore createDataStreamEx_9f641b6(apiParam: ApiParam): CallApiReturnType { - AgoraConsole.warn( - 'createDataStreamEx_9f641b6 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 streamId = obj.streamId; + if (streamId === undefined) throw 'streamId is undefined'; + let config = obj.config; + if (config === undefined) throw 'config is undefined'; + let connection = obj.connection; + if (connection === undefined) throw 'connection is undefined'; + + return this._impl.createDataStreamEx_9f641b6(streamId, config, connection); } // @ts-ignore sendStreamMessageEx_0c34857(apiParam: ApiParam): CallApiReturnType { - AgoraConsole.warn( - 'sendStreamMessageEx_0c34857 not supported in this platform!' + let obj = JSON.parse(apiParam.data) as any; + let streamId = obj.streamId; + if (streamId === undefined) throw 'streamId is undefined'; + let data = obj.data; + if (data === undefined) throw 'data is undefined'; + let length = obj.length; + if (length === undefined) throw 'length is undefined'; + let connection = obj.connection; + if (connection === undefined) throw 'connection is undefined'; + + return this._impl.sendStreamMessageEx_0c34857( + streamId, + data, + length, + connection ); - return this._engine.returnResult(false, -ERROR_CODE_TYPE.ERR_NOT_SUPPORTED); } // @ts-ignore diff --git a/packages/rtc/test/binding/IAgoraRtcEngineDispatch.test.ts b/packages/rtc/test/binding/IAgoraRtcEngineDispatch.test.ts index a80aa0dd..c7aececb 100644 --- a/packages/rtc/test/binding/IAgoraRtcEngineDispatch.test.ts +++ b/packages/rtc/test/binding/IAgoraRtcEngineDispatch.test.ts @@ -1799,9 +1799,6 @@ describe('IRtcEngineEventHandler', () => { test('RtcEngineEventHandler_onRemoteVideoStateChanged_a14e9d1 impl call', async () => { let eventHandler = new bindingAPI.IRtcEngineEventHandler(irisRtcEngine); jest.spyOn(eventHandler._engine.irisEventHandlerManager, 'notifyEvent'); - jest - .spyOn(irisRtcEngine, 'returnResult') - .mockResolvedValue(new CallIrisApiResult(0, '')); eventHandler.onRemoteVideoStateChanged_a14e9d1( undefined, undefined, @@ -1811,12 +1808,7 @@ describe('IRtcEngineEventHandler', () => { ); expect( eventHandler._engine.irisEventHandlerManager.notifyEvent - ).toBeCalledTimes(0); - expect(irisRtcEngine.returnResult).toBeCalledTimes(1); - expect(irisRtcEngine.returnResult).toBeCalledWith( - false, - -NATIVE_RTC.ERROR_CODE_TYPE.ERR_NOT_SUPPORTED - ); + ).toBeCalledTimes(1); }); test('RtcEngineEventHandler_onFirstRemoteVideoFrame_a68170a impl call', async () => { let eventHandler = new bindingAPI.IRtcEngineEventHandler(irisRtcEngine); @@ -1975,9 +1967,6 @@ describe('IRtcEngineEventHandler', () => { test('RtcEngineEventHandler_onStreamMessage_99898cb impl call', async () => { let eventHandler = new bindingAPI.IRtcEngineEventHandler(irisRtcEngine); jest.spyOn(eventHandler._engine.irisEventHandlerManager, 'notifyEvent'); - jest - .spyOn(irisRtcEngine, 'returnResult') - .mockResolvedValue(new CallIrisApiResult(0, '')); eventHandler.onStreamMessage_99898cb( undefined, undefined, @@ -1988,19 +1977,11 @@ describe('IRtcEngineEventHandler', () => { ); expect( eventHandler._engine.irisEventHandlerManager.notifyEvent - ).toBeCalledTimes(0); - expect(irisRtcEngine.returnResult).toBeCalledTimes(1); - expect(irisRtcEngine.returnResult).toBeCalledWith( - false, - -NATIVE_RTC.ERROR_CODE_TYPE.ERR_NOT_SUPPORTED - ); + ).toBeCalledTimes(1); }); test('RtcEngineEventHandler_onStreamMessageError_fe302fc impl call', async () => { let eventHandler = new bindingAPI.IRtcEngineEventHandler(irisRtcEngine); jest.spyOn(eventHandler._engine.irisEventHandlerManager, 'notifyEvent'); - jest - .spyOn(irisRtcEngine, 'returnResult') - .mockResolvedValue(new CallIrisApiResult(0, '')); eventHandler.onStreamMessageError_fe302fc( undefined, undefined, @@ -2011,12 +1992,7 @@ describe('IRtcEngineEventHandler', () => { ); expect( eventHandler._engine.irisEventHandlerManager.notifyEvent - ).toBeCalledTimes(0); - expect(irisRtcEngine.returnResult).toBeCalledTimes(1); - expect(irisRtcEngine.returnResult).toBeCalledWith( - false, - -NATIVE_RTC.ERROR_CODE_TYPE.ERR_NOT_SUPPORTED - ); + ).toBeCalledTimes(1); }); test('RtcEngineEventHandler_onRequestToken_c81e1a4 impl call', async () => { let eventHandler = new bindingAPI.IRtcEngineEventHandler(irisRtcEngine); @@ -4598,9 +4574,37 @@ describe('IRtcEngine', () => { ).toBeCalledWith('test', 'test'); }); + test('RtcEngine_muteLocalVideoStream_5039d15 parameter', async () => { + let nParam = { + mute: undefined, + }; + for (let i in nParam) { + try { + await IrisCore.callIrisApi( + apiEnginePtr, + new IrisCore.EventParam( + 'RtcEngine_muteLocalVideoStream_5039d15', + JSON.stringify(nParam), + 0, + '', + ['test'], + [], + 1 + ) + ); + } catch (e) { + expect(e).toEqual(i + ' is undefined'); + } + nParam[i] = 'test'; + } + }); + test('RtcEngine_muteLocalVideoStream_5039d15 impl call', async () => { jest - .spyOn(irisRtcEngine, 'returnResult') + .spyOn( + irisRtcEngine.implDispatchesMap.get('RtcEngine')._impl, + 'muteLocalVideoStream_5039d15' + ) .mockResolvedValue(new CallIrisApiResult(0, '')); let nParam = { mute: 'test', @@ -4617,13 +4621,12 @@ describe('IRtcEngine', () => { await IrisCore.callIrisApi(apiEnginePtr, apiParam); expect( irisRtcEngine.implDispatchesMap.get('RtcEngine')._impl - ?.muteLocalVideoStream_5039d15 - ).toBeUndefined(); - expect(irisRtcEngine.returnResult).toBeCalledTimes(1); - expect(irisRtcEngine.returnResult).toBeCalledWith( - false, - -NATIVE_RTC.ERROR_CODE_TYPE.ERR_NOT_SUPPORTED - ); + .muteLocalVideoStream_5039d15 + ).toBeCalledTimes(1); + expect( + irisRtcEngine.implDispatchesMap.get('RtcEngine')._impl + .muteLocalVideoStream_5039d15 + ).toBeCalledWith('test'); }); test('RtcEngine_enableLocalVideo_5039d15 impl call', async () => { @@ -9959,9 +9962,38 @@ describe('IRtcEngine', () => { ); }); + test('RtcEngine_createDataStream_5862815 parameter', async () => { + let nParam = { + streamId: undefined, + config: undefined, + }; + for (let i in nParam) { + try { + await IrisCore.callIrisApi( + apiEnginePtr, + new IrisCore.EventParam( + 'RtcEngine_createDataStream_5862815', + JSON.stringify(nParam), + 0, + '', + ['test'], + [], + 1 + ) + ); + } catch (e) { + expect(e).toEqual(i + ' is undefined'); + } + nParam[i] = 'test'; + } + }); + test('RtcEngine_createDataStream_5862815 impl call', async () => { jest - .spyOn(irisRtcEngine, 'returnResult') + .spyOn( + irisRtcEngine.implDispatchesMap.get('RtcEngine')._impl, + 'createDataStream_5862815' + ) .mockResolvedValue(new CallIrisApiResult(0, '')); let nParam = { streamId: 'test', @@ -9979,18 +10011,47 @@ describe('IRtcEngine', () => { await IrisCore.callIrisApi(apiEnginePtr, apiParam); expect( irisRtcEngine.implDispatchesMap.get('RtcEngine')._impl - ?.createDataStream_5862815 - ).toBeUndefined(); - expect(irisRtcEngine.returnResult).toBeCalledTimes(1); - expect(irisRtcEngine.returnResult).toBeCalledWith( - false, - -NATIVE_RTC.ERROR_CODE_TYPE.ERR_NOT_SUPPORTED - ); + .createDataStream_5862815 + ).toBeCalledTimes(1); + expect( + irisRtcEngine.implDispatchesMap.get('RtcEngine')._impl + .createDataStream_5862815 + ).toBeCalledWith('test', 'test'); + }); + + test('RtcEngine_sendStreamMessage_8715a45 parameter', async () => { + let nParam = { + streamId: undefined, + data: undefined, + length: undefined, + }; + for (let i in nParam) { + try { + await IrisCore.callIrisApi( + apiEnginePtr, + new IrisCore.EventParam( + 'RtcEngine_sendStreamMessage_8715a45', + JSON.stringify(nParam), + 0, + '', + ['test'], + [], + 1 + ) + ); + } catch (e) { + expect(e).toEqual(i + ' is undefined'); + } + nParam[i] = 'test'; + } }); test('RtcEngine_sendStreamMessage_8715a45 impl call', async () => { jest - .spyOn(irisRtcEngine, 'returnResult') + .spyOn( + irisRtcEngine.implDispatchesMap.get('RtcEngine')._impl, + 'sendStreamMessage_8715a45' + ) .mockResolvedValue(new CallIrisApiResult(0, '')); let nParam = { streamId: 'test', @@ -10009,13 +10070,12 @@ describe('IRtcEngine', () => { await IrisCore.callIrisApi(apiEnginePtr, apiParam); expect( irisRtcEngine.implDispatchesMap.get('RtcEngine')._impl - ?.sendStreamMessage_8715a45 - ).toBeUndefined(); - expect(irisRtcEngine.returnResult).toBeCalledTimes(1); - expect(irisRtcEngine.returnResult).toBeCalledWith( - false, - -NATIVE_RTC.ERROR_CODE_TYPE.ERR_NOT_SUPPORTED - ); + .sendStreamMessage_8715a45 + ).toBeCalledTimes(1); + expect( + irisRtcEngine.implDispatchesMap.get('RtcEngine')._impl + .sendStreamMessage_8715a45 + ).toBeCalledWith('test', 'test', 'test'); }); test('RtcEngine_addVideoWatermark_eaef16d impl call', async () => { diff --git a/packages/rtc/test/binding/IAgoraRtcEngineExDispatch.test.ts b/packages/rtc/test/binding/IAgoraRtcEngineExDispatch.test.ts index 5cbab66c..1e110d17 100644 --- a/packages/rtc/test/binding/IAgoraRtcEngineExDispatch.test.ts +++ b/packages/rtc/test/binding/IAgoraRtcEngineExDispatch.test.ts @@ -501,9 +501,38 @@ describe('IRtcEngineEx', () => { ).toBeCalledWith('test', 'test'); }); + test('RtcEngineEx_muteLocalVideoStreamEx_3cf17a4 parameter', async () => { + let nParam = { + mute: undefined, + connection: undefined, + }; + for (let i in nParam) { + try { + await IrisCore.callIrisApi( + apiEnginePtr, + new IrisCore.EventParam( + 'RtcEngineEx_muteLocalVideoStreamEx_3cf17a4', + JSON.stringify(nParam), + 0, + '', + ['test'], + [], + 1 + ) + ); + } catch (e) { + expect(e).toEqual(i + ' is undefined'); + } + nParam[i] = 'test'; + } + }); + test('RtcEngineEx_muteLocalVideoStreamEx_3cf17a4 impl call', async () => { jest - .spyOn(irisRtcEngine, 'returnResult') + .spyOn( + irisRtcEngine.implDispatchesMap.get('RtcEngineEx')._impl, + 'muteLocalVideoStreamEx_3cf17a4' + ) .mockResolvedValue(new CallIrisApiResult(0, '')); let nParam = { mute: 'test', @@ -521,13 +550,12 @@ describe('IRtcEngineEx', () => { await IrisCore.callIrisApi(apiEnginePtr, apiParam); expect( irisRtcEngine.implDispatchesMap.get('RtcEngineEx')._impl - ?.muteLocalVideoStreamEx_3cf17a4 - ).toBeUndefined(); - expect(irisRtcEngine.returnResult).toBeCalledTimes(1); - expect(irisRtcEngine.returnResult).toBeCalledWith( - false, - -NATIVE_RTC.ERROR_CODE_TYPE.ERR_NOT_SUPPORTED - ); + .muteLocalVideoStreamEx_3cf17a4 + ).toBeCalledTimes(1); + expect( + irisRtcEngine.implDispatchesMap.get('RtcEngineEx')._impl + .muteLocalVideoStreamEx_3cf17a4 + ).toBeCalledWith('test', 'test'); }); test('RtcEngineEx_muteAllRemoteAudioStreamsEx_3cf17a4 parameter', async () => { @@ -1065,9 +1093,39 @@ describe('IRtcEngineEx', () => { ); }); + test('RtcEngineEx_createDataStreamEx_9f641b6 parameter', async () => { + let nParam = { + streamId: undefined, + config: undefined, + connection: undefined, + }; + for (let i in nParam) { + try { + await IrisCore.callIrisApi( + apiEnginePtr, + new IrisCore.EventParam( + 'RtcEngineEx_createDataStreamEx_9f641b6', + JSON.stringify(nParam), + 0, + '', + ['test'], + [], + 1 + ) + ); + } catch (e) { + expect(e).toEqual(i + ' is undefined'); + } + nParam[i] = 'test'; + } + }); + test('RtcEngineEx_createDataStreamEx_9f641b6 impl call', async () => { jest - .spyOn(irisRtcEngine, 'returnResult') + .spyOn( + irisRtcEngine.implDispatchesMap.get('RtcEngineEx')._impl, + 'createDataStreamEx_9f641b6' + ) .mockResolvedValue(new CallIrisApiResult(0, '')); let nParam = { streamId: 'test', @@ -1086,18 +1144,48 @@ describe('IRtcEngineEx', () => { await IrisCore.callIrisApi(apiEnginePtr, apiParam); expect( irisRtcEngine.implDispatchesMap.get('RtcEngineEx')._impl - ?.createDataStreamEx_9f641b6 - ).toBeUndefined(); - expect(irisRtcEngine.returnResult).toBeCalledTimes(1); - expect(irisRtcEngine.returnResult).toBeCalledWith( - false, - -NATIVE_RTC.ERROR_CODE_TYPE.ERR_NOT_SUPPORTED - ); + .createDataStreamEx_9f641b6 + ).toBeCalledTimes(1); + expect( + irisRtcEngine.implDispatchesMap.get('RtcEngineEx')._impl + .createDataStreamEx_9f641b6 + ).toBeCalledWith('test', 'test', 'test'); + }); + + test('RtcEngineEx_sendStreamMessageEx_0c34857 parameter', async () => { + let nParam = { + streamId: undefined, + data: undefined, + length: undefined, + connection: undefined, + }; + for (let i in nParam) { + try { + await IrisCore.callIrisApi( + apiEnginePtr, + new IrisCore.EventParam( + 'RtcEngineEx_sendStreamMessageEx_0c34857', + JSON.stringify(nParam), + 0, + '', + ['test'], + [], + 1 + ) + ); + } catch (e) { + expect(e).toEqual(i + ' is undefined'); + } + nParam[i] = 'test'; + } }); test('RtcEngineEx_sendStreamMessageEx_0c34857 impl call', async () => { jest - .spyOn(irisRtcEngine, 'returnResult') + .spyOn( + irisRtcEngine.implDispatchesMap.get('RtcEngineEx')._impl, + 'sendStreamMessageEx_0c34857' + ) .mockResolvedValue(new CallIrisApiResult(0, '')); let nParam = { streamId: 'test', @@ -1117,13 +1205,12 @@ describe('IRtcEngineEx', () => { await IrisCore.callIrisApi(apiEnginePtr, apiParam); expect( irisRtcEngine.implDispatchesMap.get('RtcEngineEx')._impl - ?.sendStreamMessageEx_0c34857 - ).toBeUndefined(); - expect(irisRtcEngine.returnResult).toBeCalledTimes(1); - expect(irisRtcEngine.returnResult).toBeCalledWith( - false, - -NATIVE_RTC.ERROR_CODE_TYPE.ERR_NOT_SUPPORTED - ); + .sendStreamMessageEx_0c34857 + ).toBeCalledTimes(1); + expect( + irisRtcEngine.implDispatchesMap.get('RtcEngineEx')._impl + .sendStreamMessageEx_0c34857 + ).toBeCalledWith('test', 'test', 'test', 'test'); }); test('RtcEngineEx_addVideoWatermarkEx_ad7daa3 impl call', async () => {