IAliEngineMediaEngine class

更新时间:
复制 MD 格式

This topic describes the methods of the IAliEngineMediaEngine class provided by Real-Time Communication (RTC) SDK for Windows.

SDK reference

For more information about the IAliEngineMediaEngine class, see AliRTCSdk::IAliEngineMediaEngine.

List of methods

Methods for a media engine

MethodDescriptionSupported earliest version
RegisterVideoSampleObserverSubscribes to the data output of a video track. V2.1
UnRegisterVideoSampleObserverUnsubscribes from the data output of a video track. V2.1
RegisterLocalVideoTextureObserverSubscribes to the texture data of a local video track. V2.1
UnRegisterLocalVideoTextureObserverUnsubscribes from the texture data of a local video track. V2.1
RegisterAudioFrameObserverSubscribes to the data output of an audio track. V2.1
UnRegisterAudioFrameObserverUnsubscribes from the data output of an audio track. V2.1
RegisterAudioEventObserverSubscribes to audio-related events. By default, audio-related events are subscribed to. V2.1
UnRegisterAudioEventObserverUnsubscribes from audio-related events. V2.1
SetSubscribeAudioNumChannelSpecifies the number of sound channels for the output data of an audio track. You cannot set the audioNumChannel parameter before audio mixing. V2.1
SetSubscribeAudioSampleRateSpecifies the sampling rate for the output data of an audio track. You cannot set the audioSampleRate parameter before audio mixing. V2.1
SubscribeAudioDataSubscribes to the data of an audio track. V2.1
UnsubscribeAudioDataUnsubscribes from the data of an audio track. V2.1
SetExternalVideoSourceSpecifies whether to enable an external video source. V2.1
PushExternalVideoFrameImports video data from an external video source. V2.1
SetExternalAudioSourceSpecifies whether to enable an external audio source. V2.1
PushExternalAudioFrameRawDataImports audio data from an external audio source. V2.1
SetExternalAudioPublishVolumeSets the volume of audio mixing. V2.1
GetExternalAudioPublishVolumeQueries the volume of audio mixing. V2.1
SetMixedWithMicSpecifies whether to mix the data of an audio track with microphone-collected audio. V2.1
SetExteranlAudioRenderSpecifies whether to enable an external audio source for playback. V2.1
PushExternalAudioRenderRawDataImports audio data from an external audio source for playback. V2.1
SetExternalAudioRenderVolumeSets the volume of an external audio source. V2.1
GetExternalAudioRenderVolumeQueries the volume of an external audio source. V2.1

Details of methods

  • RegisterVideoSampleObserver: subscribes to the data output of a video track.
    void RegisterVideoSampleObserver(IVideoFrameObserver* observer);
    Parameters
    ParameterTypeDescription
    observerIVideoFrameObserver*The recipient of the video data.
    Note The data is returned by the callbacks of the IVideoFrameObserver class.
  • UnRegisterVideoSampleObserver: unsubscribes from the data output of a video track.
    void UnRegisterVideoSampleObserver(IVideoFrameObserver* observer);
    Parameters
    ParameterTypeDescription
    observerIVideoFrameObserver*The recipient of the video data.
  • RegisterLocalVideoTextureObserver: subscribes to the texture data of a local video track.
    void RegisterLocalVideoTextureObserver(IVideoTextureObserver* observer);
    Parameters
    ParameterTypeDescription
    observerIVideoTextureObserver*The recipient of the video data.
    Note The data is returned by the callbacks of the IVideoTextureObserver class.
  • UnRegisterLocalVideoTextureObserver: unsubscribes from the texture data of a local video track.
    void UnRegisterLocalVideoTextureObserver(IVideoTextureObserver* observer);
    Parameters
    ParameterTypeDescription
    observerIVideoTextureObserver*The recipient of the video data.
  • RegisterAudioFrameObserver: subscribes to the data output of an audio track.
    int RegisterAudioFrameObserver(IAudioFrameObserver* observer);
    Parameters
    ParameterTypeDescription
    observerIAudioFrameObserver*The recipient of the audio data.
  • UnRegisterAudioFrameObserver: unsubscribes from the data output of an audio track.
    void UnRegisterAudioFrameObserver(IAudioFrameObserver* observer);
    Parameters
    ParameterTypeDescription
    observerIAudioFrameObserver*The recipient of the audio data.
  • RegisterAudioEventObserver: subscribes to audio-related events such as howling noise. By default, audio-related events are subscribed to.
    int RegisterAudioEventObserver();
    Return value description

    If 0 is returned, the call is successful. Otherwise, the call fails.

  • UnRegisterAudioEventObserver: unsubscribes from audio-related events.
    void UnRegisterAudioEventObserver();
  • SetSubscribeAudioNumChannel: specifies the number of sound channels for the output data of an audio track. You cannot set the audioNumChannel parameter before audio mixing.
    void SetSubscribeAudioNumChannel(AliEngineAudioNumChannelType audioNumChannel);
    Parameters
    ParameterTypeDescription
    audioNumChannelAliEngineAudioNumChannelTypeThe number of sound channels. By default, the output data of the audio track is in mono mode.
  • SetSubscribeAudioSampleRate: specifies the sampling rate for the output data of an audio track. You cannot set the audioSampleRate parameter before audio mixing.
    void SetSubscribeAudioSampleRate(AliEngineAudioSampleRate audioSampleRate);
    Parameters
    ParameterTypeDescription
    audioSampleRateAliEngineAudioSampleRateThe sampling rate. Unit: kHz. Default value: 44.1.
  • SubscribeAudioData: subscribes to the data of an audio track.
    void SubscribeAudioData(AliEngineAudioSource audioSource);
    Parameters
    ParameterTypeDescription
    audioSourceAliEngineAudioSourceThe audio track.
    Note Before you subscribe to the data output of an audio track, call the SetSubscribeAudioNumChannel and SetSubscribeAudioSampleRate methods to set parameters for the output data of the audio track.
  • UnsubscribeAudioData: unsubscribes from the data of an audio track.
    void UnsubscribeAudioData(AliEngineAudioSource audioSource);
    Parameters
    ParameterTypeDescription
    audioSourceAliEngineAudioSourceThe audio track.
  • SetExternalVideoSource: specifies whether to enable an external video source.
    int SetExternalVideoSource(bool enable, bool useTexture, AliEngineVideoTrack type, AliEngineRenderMode renderMode);
    Parameters
    ParameterTypeDescription
    enableBooleanSpecifies whether to enable the external video source. Valid values:
    • true: enables the external video source.
    • false: disables the external video source.
    useTextureBooleanSpecifies whether to use the texture mode.
    typeAliEngineVideoTrackThe type of the video track.
    renderModeAliEngineRenderModeThe rendering mode.
    Return value description

    If 0 is returned, the call is successful. Otherwise, the call fails.

  • PushExternalVideoFrame: imports video data from an external video source.
    int PushExternalVideoFrame(const AliEngineVideoRawData &frame, AliEngineVideoTrack type);
    Parameters
    ParameterTypeDescription
    frameconst AliEngineVideoRawData &The information about the video data.
    typeAliEngineVideoTrackThe type of the video track.
    Return value description

    If 0 is returned, the call is successful. Otherwise, the call fails.

  • SetExternalAudioSource: specifies whether to enable an external audio source.
    int SetExternalAudioSource(bool enable, unsigned int sampleRate, unsigned int channelsPerFrame);
    Parameters
    ParameterTypeDescription
    enableBooleanSpecifies whether to enable the external audio source. Valid values:
    • true: enables the external audio source.
    • false: disables the external audio source. This is the default value.
    sampleRateunsigned intThe sampling rate. Unit: kHz. Example: 16 kHz or 48 kHz.
    channelsPerFrameunsigned intThe number of sound channels. Example: 1 or 2.
    Return value description

    If 0 is returned, the call is successful. Otherwise, the call fails.

  • PushExternalAudioFrameRawData: imports audio data from an external audio source.
    int PushExternalAudioFrameRawData(const void * data, unsigned int sampleLen, double timestamp);
    Parameters
    ParameterTypeDescription
    dataconst void *The information about the audio data. We recommend that you import audio data of up to 40 ms in length.
    sampleLenunsigned intThe sampling rate.
    timestampdoubleThe timestamp.
    Return value description

    If 0 is returned, the call is successful. Otherwise, the call fails.

  • SetExternalAudioPublishVolume: sets the volume of audio mixing.
    int SetExternalAudioPublishVolume(int vol);
    Parameters
    ParameterTypeDescription
    volintThe volume. Valid values: 0 to 100. Default value: 50.
    Return value description

    If 0 is returned, the call is successful. Otherwise, the call fails.

  • GetExternalAudioPublishVolume: queries the volume of audio mixing.
    int GetExternalAudioPublishVolume();
    Return value description

    Returns the volume of audio mixing.

  • SetMixedWithMic: specifies whether to mix the data of an audio track with microphone-collected audio.
    int SetMixedWithMic(bool mixed);
    Parameters
    ParameterTypeDescription
    mixedBooleanSpecifies whether to mix the data of the audio track with microphone-collected audio. Valid values:
    • true: mixes the data of the audio track with microphone-collected audio. This is the default value.
    • false: replaces microphone-collected audio with the data of the audio track.
    Return value description

    If 0 is returned, the call is successful. Otherwise, the call fails.

  • SetExteranlAudioRender: specifies whether to enable an external audio source for playback.
    int SetExteranlAudioRender(bool enable, unsigned int sampleRate, unsigned int channelsPerFrame);
    Parameters
    ParameterTypeDescription
    enableBooleanSpecifies whether to enable the external audio source for playback. Valid values:
    • true: enables the external audio source for playback.
    • false: disables the external audio source for playback. This is the default value.
    sampleRateunsigned intThe sampling rate. Unit: kHz. Example: 16 kHz or 48 kHz.
    channelsPerFrameunsigned intThe number of sound channels. Example: 1 or 2.
    Return value description

    If 0 is returned, the call is successful. Otherwise, the call fails.

  • PushExternalAudioRenderRawData: imports audio data from an external audio source for playback.
    int PushExternalAudioRenderRawData(const void* audioSamples, unsigned int sampleLength, unsigned int sampleRate, unsigned int channelsPerFrame, long long timestamp);
    Parameters
    ParameterTypeDescription
    audioSamplesconst void*The information about the audio data.
    sampleLengthunsigned intThe length of the audio data.
    sampleRateunsigned intThe sampling rate.
    channelsPerFrameunsigned intThe number of sound channels.
    timestamplong longThe timestamp.
    Return value description

    If 0 is returned, the call is successful. Otherwise, the call fails.

  • SetExternalAudioRenderVolume: sets the volume of an external audio source.
    int SetExternalAudioRenderVolume(int volScal);
    Parameters
    ParameterTypeDescription
    volScalintThe volume. Valid values: 0 to 100. Default value: 50.
    Return value description

    If 0 is returned, the call is successful. Otherwise, the call fails.

  • GetExternalAudioRenderVolume: queries the volume of an external audio source.
    int GetExternalAudioRenderVolume();
    Return value description

    If 0 is returned, the call is successful. Otherwise, the call fails.