Abstract Adds one IMediaEngineEvent listener. After calling this method, you can listen for the corresponding events in the IMediaEngine object and obtain data through IMediaEngineEvent. Depending on your project needs, you can add multiple listeners for the same event.
The name of the target event to listen for. See IMediaEngineEvent.
The callback function for eventType. Take adding a listener for onPlaybackAudioFrameBeforeMixing as an example: // Create an onPlaybackAudioFrameBeforeMixing object const onPlaybackAudioFrameBeforeMixing = (channelId: string, uid: number, audioFrame: AudioFrame) => {}; // Add one onPlaybackAudioFrameBeforeMixing listener engine.addListener('onPlaybackAudioFrameBeforeMixing', onPlaybackAudioFrameBeforeMixing);
Abstract createCreates a customized audio track. When you need to publish multiple custom captured audios in the channel, you can refer to the following steps:Call this method to create a custom audio track and get the audio track ID.In ChannelMediaOptions of each channel, set publishCustomAduioTrackId to the audio track ID that you want to publish, and set publishCustomAudioTrack to true.If you call pushAudioFrame trackId as the audio track ID set in step 2, you can publish the corresponding custom audio source in multiple channels.
If the method call is successful, the audio track ID is returned as the unique identifier of the audio track.If the method call fails, a negative value is returned.
The type of the custom audio track. See AudioTrackType .
The configuration of the custom audio track. See AudioTrackConfig .
Abstract destroyAbstract pullPulls the remote audio data. Before calling this method, you need to call setExternalAudioSink to notify the app to enable and set the external rendering.After a successful method call, the app pulls the decoded and mixed audio data for playback.This method only supports pulling data from custom audio source. If you need to pull the data captured by the SDK, do not call this method.Call this method after joining a channel.Once you enable the external audio sink, the app will not retrieve any audio data from the onPlaybackAudioFrame callback.The difference between this method and the onPlaybackAudioFrame callback is as follows:The SDK sends the audio data to the app through the onPlaybackAudioFrame callback. Any delay in processing the audio frames may result in audio jitter.After a successful method call, the app automatically pulls the audio data from the SDK. After setting the audio data parameters, the SDK adjusts the frame buffer and avoids problems caused by jitter in the external audio playback.
The AudioFrame instance, if the method call succeeds.An error code, if the call fails,.
Abstract pushPushes the external audio frame.
0: Success.< 0: Failure.
The external audio frame. See AudioFrame .
Optional trackId: numberThe audio track ID. If you want to publish a custom external audio source, set this parameter to the ID of the corresponding custom audio track you want to publish.
Abstract pushPushes the external raw video frame to the SDK. If you call createCustomVideoTrack method to get the video track ID, set the customVideoTrackId parameter to the video track ID you want to publish in the ChannelMediaOptions of each channel, and set the publishCustomVideoTrack parameter to true, you can call this method to push the unencoded external video frame to the SDK.
0: Success.< 0: Failure.
The external raw video frame to be pushed. See ExternalVideoFrame .
Optional videoTrackId: numberThe video track ID returned by calling the createCustomVideoTrack method. The default value is 0.
Abstract registerRegisters an audio frame observer object. Call this method to register an audio frame observer object (register a callback). When you need the SDK to trigger onMixedAudioFrame , onRecordAudioFrame , onPlaybackAudioFrame or onEarMonitoringAudioFrame callback, you need to use this method to register the callbacks.Ensure that you call this method before joining a channel.
0: Success.< 0: Failure.
The observer object instance. See IAudioFrameObserver . Agora recommends calling this method after receiving onLeaveChannel to release the audio observer object.
Abstract registerRegisters a receiver object for the encoded video image. If you only want to observe encoded video frames (such as h.264 format) without decoding and rendering the video, Agora recommends that you implement one IVideoEncodedFrameObserver class through this method.If you want to obtain the original video data of some remote users (referred to as group A) and the encoded video data of other remote users (referred to as group B), you can refer to the following steps:Call registerVideoFrameObserver to register the raw video frame observer before joining the channel.Call registerVideoEncodedFrameObserver to register the encoded video frame observer before joining the channel.After joining the channel, get the user IDs of group B users through onUserJoined , and then call setRemoteVideoSubscriptionOptions to set the encodedFrameOnly of this group of users to true.Call muteAllRemoteVideoStreams (false) to start receiving the video streams of all remote users. Then:The raw video data of group A users can be obtained through the callback in IVideoFrameObserver , and the SDK renders the data by default.The encoded video data of group B users can be obtained through the callback in IVideoEncodedFrameObserver .Call this method before joining a channel.
0: Success.< 0: Failure.
The video frame observer object. See IVideoEncodedFrameObserver .
Abstract registerRegisters a raw video frame observer object. If you want to obtain the original video data of some remote users (referred to as group A) and the encoded video data of other remote users (referred to as group B), you can refer to the following steps: Call registerVideoFrameObserver to register the raw video frame observer before joining the channel. Call registerVideoEncodedFrameObserver to register the encoded video frame observer before joining the channel. After joining the channel, get the user IDs of group B users through onUserJoined , and then call setRemoteVideoSubscriptionOptions to set the encodedFrameOnly of this group of users to true. Call muteAllRemoteVideoStreams (false) to start receiving the video streams of all remote users. Then: The raw video data of group A users can be obtained through the callback in IVideoFrameObserver , and the SDK renders the data by default. The encoded video data of group B users can be obtained through the callback in IVideoEncodedFrameObserver . If you want to observe raw video frames (such as YUV or RGBA format), Agora recommends that you implement one IVideoFrameObserver class with this method.When calling this method to register a video observer, you can register callbacks in the IVideoFrameObserver class as needed. After you successfully register the video frame observer, the SDK triggers the registered callbacks each time a video frame is received.Ensure that you call this method before joining a channel.When handling the video data returned in the callbacks, pay attention to the changes in the width and height parameters, which may be adapted under the following circumstances:When network conditions deteriorate, the video resolution decreases incrementally.If the user adjusts the video profile, the resolution of the video returned in the callbacks also changes.After registering the raw video observer, you can use the obtained raw video data in various video pre-processing scenarios, such as implementing virtual backgrounds and image enhacement scenarios by yourself, Agora provides some open source sample projects on GitHub for your reference.
0: Success.< 0: Failure.
The observer object instance. See IVideoFrameObserver .
Removes all listeners for the specified event.
Optional eventType: EventTypeThe name of the target event to listen for. See IMediaEngineEvent.
Removes the specified IMediaEngineEvent listener. For listened events, if you no longer need to receive the callback message, you can call this method to remove the corresponding listener.
The name of the target event to listen for. See IMediaEngineEvent.
Optional listener: IMediaEngineEvent[EventType]The callback function for eventType. Must pass in the same function object in addListener . Take removing the listener for onJoinChannelSuccess as an example: // Create an onPlaybackAudioFrameBeforeMixing object const onPlaybackAudioFrameBeforeMixing = (channelId: string, uid: number, audioFrame: AudioFrame) => {}; // Add one onPlaybackAudioFrameBeforeMixing listener engine.addListener('onPlaybackAudioFrameBeforeMixing', onPlaybackAudioFrameBeforeMixing); // Remove the onPlaybackAudioFrameBeforeMixing listener engine.removeListener('onPlaybackAudioFrameBeforeMixing', onPlaybackAudioFrameBeforeMixing);
Abstract setSets the external audio sink. This method applies to scenarios where you want to use external audio data for playback. After you set the external audio sink, you can call pullAudioFrame to pull remote audio frames. The app can process the remote audio and play it with the audio effects that you want.
0: Success.< 0: Failure.
Whether to enable or disable the external audio sink:true: Enables the external audio sink.false: (Default) Disables the external audio sink.
The sample rate (Hz) of the external audio sink, which can be set as 16000, 32000, 44100, or 48000.
The number of audio channels of the external audio sink:1: Mono.2: Stereo.
Abstract setSets the external audio source parameters. Call this method before joining a channel.
0: Success.< 0: Failure.
Whether to enable the external audio source:true: Enable the external audio source.false: (Default) Disable the external audio source.
The sample rate (Hz) of the external audio source which can be set as 8000, 16000, 32000, 44100, or 48000.
The number of channels of the external audio source, which can be set as 1 (Mono) or 2 (Stereo).
Optional localPlayback: booleanWhether to play the external audio source:true: Play the external audio source.false: (Default) Do not play the external source.
Optional publish: booleanWhether to publish audio to the remote users:true: (Default) Publish audio to the remote users.false: Do not publish audio to the remote users.
Abstract setConfigures the external video source. Call this method before joining a channel.
0: Success.< 0: Failure.
Whether to use the external video source:true: Use the external video source. The SDK prepares to accept the external video frame.false: (Default) Do not use the external video source.
Whether to use the external video frame in the Texture format.true: Use the external video frame in the Texture format.false: (Default) Do not use the external video frame in the Texture format.
Optional sourceType: ExternalVideoSourceTypeWhether the external video frame is encoded. See ExternalVideoSourceType .
Optional encodedVideoOption: SenderOptionsVideo encoding options. This parameter needs to be set if sourceType is EncodedVideoFrame. To set this parameter, contact .
Abstract unregisterUnregisters an audio frame observer.
0: Success.< 0: Failure.
The audio frame observer, reporting the reception of each audio frame. See IAudioFrameObserver .
Abstract unregisterUnregisters a receiver object for the encoded video image.
0: Success.< 0: Failure.
The video observer, reporting the reception of each video frame. See IVideoEncodedFrameObserver .
Abstract unregisterUnregisters the video frame observer.
0: Success.< 0: Failure.
The video observer, reporting the reception of each video frame. See IVideoFrameObserver .
Generated using TypeDoc
The IMediaEngine class.