This topic describes the AliRtcEngine operation of the Linux SDK for Java.

Contents

Basic methods

API Description Supported earliest version
createInstance Create an AliRTCEngine instance. 1.18.1
destroy Destroy the AliRTCEngine instance. 1.18.1

Channel-related interfaces

API Description Supported earliest version
joinChannel Join the channel. 1.18.1
leaveChannel Off the channel. 1.18.1

Publish related interfaces

API Description Supported earliest version
setVideoProfile Set video stream ingest parameters. 1.18.1
getVideoProfile Obtain the stream ingest parameters of a video stream. 1.18.1
configLocalCameraPublish Specify whether to allow pushing camera streams. 1.18.1
isLocalCameraPublishEnabled Queries whether to allow pushing camera streams. 1.18.1
configLocalScreenPublish Specify whether to allow push screen streams. 1.18.1
isLocalScreenPublishEnabled Queries whether push screen streams are allowed. 1.18.1
configLocalAudioPublish Specifies whether to allow pushing audio streams. 1.18.1
isLocalAudioPublishEnabled Queries whether push audio streams are allowed. 1.18.1
configLocalSimulcast Specifies whether to allow the push of minor video streams. 1.18.1
isLocalSimulcastEnabled You can call this operation to query whether minor video streams are allowed to be pushed. 1.18.1
publish Manually push video and audio streams. 1.18.1

Recording-related interfaces

API Description Supported earliest version
startRecording Manually enable recording. 1.18.1
stopRecording Manually stop recording. 1.18.1

Video-related methods

API Description Supported earliest version
setExternalVideoSource Specifies whether to enable an external video input source. 1.18.1
pushExternalVideoFrame Enter external video data. 1.18.1
addVideoWatermark Add a watermark. 1.18.11
clearVideoWatermark Clears the watermark information of the corresponding data stream. 1.18.11

Audio-related methods

API Description Supported earliest version
setExternalAudioSource Specifies whether to enable external audio input ingest. 1.18.1
pushExternalAudioFrameRawData Inputting external audio data into streams. 1.18.1
setExternalAudioPublishVolume Set the volume of the external input audio ingest mix. 1.18.1
getExternalAudioPublishVolume Gets the volume of the external input audio ingest mix. 1.18.1
setAudioChannels Sets the streaming mode of the audio. 1.18.12

Media player-related interfaces

API Description Supported earliest version
createMediaPlayer Create a media player. 1.18.1
destroyMediaPlayer Destroy the media player. 1.18.1
setEventHandler Set player status and event callback notifications. 1.18.1
loadResource Loads playback resources. 1.18.1
start Start the playback. 1.18.1
stop Stop the playback. 1.18.1
pause Pause the playback. 1.18.1
resume Resume playback. 1.18.1
seekTo Jump to play. 1.18.1
setVideoSource Specifies whether the video data of the player is ingested. 1.18.1
enableAudioSource Specifies whether the audio data of the player is ingested. 1.18.1
setVolume Sets the volume of the player (affects the volume of the stream). 1.18.1
getDuration Gets the total duration of playback. 1.18.1
getCurrentPlaybackTime Gets the current playback position. 1.18.1
getCurrentVomume Gets the current playback volume. 1.18.1
getCurrentPlaybackState Gets the current playback status. 1.18.1
getIndex Obtains the current player ID. 1.18.1

Details

  • createInstance: creates an AliRTCEngine instance.
    public static AliRTCLinuxEngine createInstance(AliRTCLinuxEngineListener listener, int lowPort, int highPort, String logPath, String coreServicePath) {
                        return new AliRTCLinuxEngineImpl(listener, lowPort, highPort, logPath, coreServicePath);
                    }
    Parameter Type Description
    listener AliRTCLinuxEngineListener The event triggered by the recording SDK is notified by using the AliRTCLinuxEngineListener class callback.
    lowPort int The smallest available port.
    Note To create an SDK instance, you need to occupy one system port for audio and video Data Transmission Service. We recommend that you set the port range to 42000 to 45000 and ensure that other services do not occupy ports in this range.
    highPort int The largest available port.
    Note To create an SDK instance, you need to occupy one system port for audio and video Data Transmission Service. We recommend that you set the port range to 42000 to 45000 and ensure that other services do not occupy ports in this range.
    logPath String The path where logs are saved.
    coreServicePath String AliRtcCoreService the absolute path where the executable program is stored.
  • destroy: destroys the AliRTCEngine instance.
    public abstract void destroy();
  • joinChannel: joins a channel.
    public abstract int joinChannel(AuthInfo authInfo, JoinChannelConfig config);
    Parameter Type Description
    authInfo AuthInfo The authentication information is obtained from App Server.
    config JoinChannelConfig Specifies the settings items when joining the channel.
  • leaveChannel: leaves the channel.
    public abstract int leaveChannel();
  • setVideoProfile: Set video stream ingest parameters.
    Note The settings will not take effect until the next stream ingest.
    public abstract void setVideoProfile(VideoProfile profile, VideoTrack track);
    Parameter Type Description
    profile VideoProfile The predefined video resolution and frame rate. For more information, see VideoProfile.
    track VideoTrack The type of the video stream. For more information, see VideoTrack.
  • getVideoProfile: Obtain the stream ingest parameters of the video stream.
    Note The video resolution and frame rate that are in use (already in stream ingest) or will be used soon (the next stream ingest will take effect) are returned. For more information, see VideoProfile. The return value is not necessarily the VideoProfile being used. In addition, VideoTrackScreen is not supported.
    public abstract int getVideoProfile(VideoTrack track);
    Parameter Type Description
    track VideoTrack The type of the video stream. For more information, see VideoTrack.
  • configLocalCameraPublish: Specify whether to allow pushing camera streams.
    Note You need to call the publish to take effect. By default, camera stream ingestion is allowed.
    public abstract void configLocalCameraPublish(boolean enable);
    Parameter Type Description
    enable boolean Specifies whether to allow the push camera stream. Valid values:
    • true: Log Service is allowed to send text messages to the phone number.
    • false: disabled.
  • isLocalCameraPublishEnabled: queries whether to allow pushing camera streams.
    public abstract boolean isLocalCameraPublishEnabled();
    Return result

    Returns true to allow, and false to prohibit.

  • configLocalScreenPublish: specifies whether to allow push screen streams.
    Note You need to call the publish operation to take effect. By default, screen stream ingestion is not allowed.
    public abstract void configLocalScreenPublish(boolean enable);
    Parameter Type Description
    enable boolean Specifies whether to allow push screen streams. Valid values:
    • true: Log Service is allowed to send text messages to the phone number.
    • false: disabled.
  • isLocalScreenPublishEnabled: queries whether push screen streams are allowed.
    public abstract boolean isLocalScreenPublishEnabled();
    Return result

    Returns true to allow, and false to prohibit.

  • configLocalAudioPublish: specifies whether to allow audio streams to be pushed.
    Note You need to call the publish operation to take effect. By default, audio ingestion is allowed.
    public abstract void configLocalAudioPublish(boolean enable);
    Parameter Type Description
    enable boolean Specifies whether to allow pushing audio streams. Valid values:
    • true: Log Service is allowed to send text messages to the phone number.
    • false: disabled.
  • isLocalAudioPublishEnabled: queries whether to allow audio streams to be pushed.
    public abstract boolean isLocalAudioPublishEnabled();
    Return result

    Returns true to allow, and false to prohibit.

  • configLocalSimulcast: specifies whether to allow small streams of secondary video streams to be pushed.
    Note You need to call the publish operation to take effect. By default, the push of secondary video streams is allowed. Currently, only camera streaming is supported. Screen streaming is not supported.
    public abstract int configLocalSimulcast(boolean enabled, VideoTrack track);
    Parameter Type Description
    enabled boolean Specifies whether to allow the push of minor video streams. Valid values:
    • true: Log Service is allowed to send text messages to the phone number.
    • false: disabled.
    track VideoTrack The type of the video stream. For more information, see VideoTrack.
  • isLocalSimulcastEnabled: queries whether small streams of secondary video streams are allowed to be pushed.
    public abstract boolean isLocalSimulcastEnabled();
    Return result

    Returns true to allow, and false to prohibit.

  • publish: manually pushes video and audio streams.
    Note The streams to be pushed are set through API configLocalAudioPublish, configLocalCameraPublish, and configLocalScreenPublish.
    public abstract int publish();
  • startRecording: manually enables recording.
    Note If you need to manually configure all ingest and pull streams, you must JoinChannelConfig the fields and select RecordingManually when joinChannel.
    public abstract int startRecording();
  • stopRecording: manually stops recording.
    public abstract int stopRecording();
  • setExternalVideoSource: specifies whether to enable an external video input source.
    Note Use the PushExternalVideoFrame port to enter video data when enabled.
    public abstract int setExternalVideoSource(boolean enable, boolean useTexture, VideoSource source, RenderMode renderMode);
    Parameter Type Description
    enable boolean Specifies whether to enable an external video input source. Valid values:
    • true: The alert rule is enabled.
    • false: disables the trigger.
    useTexture boolean Specifies whether to use the texture mode. Currently, only false is supported.
    source VideoSource The type of the streams to query.
    renderMode RenderMode The drawing mode.
  • pushExternalVideoFrame: Enter external video data.
    Note Currently, the input video type only supports I420.
    public abstract int pushExternalVideoFrame(VideoDataSample frame, VideoSource source);
    Parameter Type Description
    frame VideoDataSample Frame data.
    source VideoSource The type of the streams to query.
  • addVideoWatermark: Add a watermark.
    /**
     * @brief Add a watermark through the local file path.
     * @param sourceType The type of the video stream to which the watermark is added.
     * @ The path of the param image_url watermark image. Only the local path is supported.
     * @param config watermark configuration
     * @return 0: The call is successful. -1: The call fails.
     * @note The return value of this operation only indicates whether the operation is called successfully and whether the actual watermark is added successfully is returned by the callback function.
    */
    public abstract int addVideoWatermark(VideoSource sourceType, String imageUrl, WaterMarkConfig config);
    /**
     * @brief Add a watermark by using the image memory address.
     * @param sourceType The type of the video stream to which the watermark is added.
     * @param imageData The memory address of the watermark image.
     * @param imageLength The length of the watermark.
     * @param config watermark configuration
     * @return 0: The call is successful. -1: The call fails.
     * @note The return value of this operation only indicates whether the operation is called successfully and whether the actual watermark is added successfully is returned by the callback function.
     */
    public abstract int addVideoWatermark(VideoSource sourceType, byte[] imageData, int imageLength, WaterMarkConfig config);
  • clearVideoWatermark: clears the watermark information of the corresponding data stream.
    /**
     * @brief Clears the watermark of the corresponding data stream.
     * @param sourceType The type of the video stream for which the watermark is cleared.
     * @return 0: The call is successful. -1: The call fails.
     * @note The return value of this interface only indicates whether the call is successful and whether the actual watermark is cleared is returned by the callback function.
       */
      public abstract int clearVideoWatermark(VideoSource sourceType);
  • setExternalAudioSource: specifies whether to enable external audio input ingest.
    Note You can use the setExternalAudioPublishVolume to set the input audio ingest volume.
    public abstract int setExternalAudioSource(boolean enable, int sampleRate, int channelsPerFrame);
    Parameter Type Description
    enable boolean Specifies whether to enable external audio input ingest. Valid values:
    • true: The alert rule is enabled.
    • false: disables the trigger.
    sampleRate int The sampling rate.
    channelsPerFrame int The sampling rate.
    Return result

    If the return value is greater than or equal to 0, the setting is successful. If the return value is less than 0, the setting fails.

  • pushExternalAudioFrameRawData: Enter external audio data to ingest streams.
    public abstract int pushExternalAudioFrameRawData(byte[] audioSamples, int sampleLength, long timestamp);
    Parameter Type Description
    audioSamples byte[] The audio data.
    sampleLength int The length of the audio data.
    timestamp long Timestamp.
    Return result

    If the return value is greater than or equal to 0, the call is successful. If the return value is less than 0, the call fails.

    Note If the return value is ERR_AUDIO_BUFFER_FULL, you need to retry the delivery again after the length of time the data is delivered at the interval.
  • setExternalAudioPublishVolume: Set the volume of the external input audio ingest and mixing.
    public abstract int setExternalAudioPublishVolume(int volume);
    Parameter Type Description
    volume int The volume. Valid values: 0 to 100.
  • getExternalAudioPublishVolume: obtains the volume of the external input audio ingest stream mixing.
    public abstract int getExternalAudioPublishVolume();
  • setAudioChannels: sets the streaming mode of the audio.
    public abstract int setAudioChannels(ExpectedAudioType type);

    Parameter description

    Parameter Type Description
    type ExpectedAudioType The number of sound channels.
    Return result

    If a value of 0 is returned, the call is successful. If a value of -1 is returned, the call fails.

  • createMediaPlayer: Create a media player.
    public abstract AliRTCLinuxMediaPlayer createMediaPlayer();
  • destroyMediaPlayer: Destroy the media player.
    public abstract int destroyMediaPlayer(AliRTCLinuxMediaPlayer player);
  • setEventHandler: sets player status and event callback notifications.
    public int setEventHandler(AliRTCLinuxMediaPlayerListener eventHandler);
    Parameter Type Description
    eventHandler AliRTCLinuxMediaPlayerListener Player status and event callback handles.
    Return result

    If 0 is returned, the setting is successful. Others indicate that the setting fails.

  • loadResource: loads playback resources. The success of truly loading resources needs to be determined by the state in the OnStateChange callback interface.
    public int loadResource(String path);
    Parameter Type Description
    path String The address of the playback resource. Currently, local absolute paths and online addresses are supported.
    Return result

    If a value of 0 is returned, the call is successful. If another value is returned, the call fails.

  • start: starts the playback.
    Note This operation can be called only after the player status changes to MediaPlayerStatePrepared.
    public int start();
    Return result

    If a value of 0 is returned, the call is successful. If another value is returned, the call fails.

  • stop: The playback is stopped.
    public int stop();
    Return result

    If a value of 0 is returned, the call is successful. If another value is returned, the call fails.

  • pause: The playback is paused.
    public int pause();
    Return result

    If a value of 0 is returned, the call is successful. If another value is returned, the call fails.

  • resume: The playback is resumed.
    public int resume();
    Return result

    If a value of 0 is returned, the call is successful. If another value is returned, the call fails.

  • seekTo: redirects playback.
    public int seekTo(long millisecond);
    Parameter Type Description
    millisecond long The playback position to which you are redirected. Unit: milliseconds.
    Return result

    If a value of 0 is returned, the call is successful. If another value is returned, the call fails.

  • setVideoSource: specifies whether the video data of the player is ingested.
    public int setVideoSource(boolean enable, AliRTCLinuxEngine.VideoSource source, AliRTCLinuxEngine.RenderMode renderMode);
    Parameter Type Description
    enable boolean Specifies whether to ingest streams. Valid values:
    • true: Log Service is allowed to send text messages to the phone number.
    • false: disabled.
    source AliRTCLinuxEngine.VideoSource Select a video source to ingest streams.
    renderMode AliRTCLinuxEngine.RenderMode The zoom mode of the video source.
    Return result

    If a value of 0 is returned, the call is successful. If another value is returned, the call fails.

  • enableAudioSource: specifies whether the audio data of the player is ingested.
    public int enableAudioSource(boolean enable);
    Parameter Type Description
    enable boolean Specifies whether to ingest streams. Valid values:
    • true: Log Service is allowed to send text messages to the phone number.
    • false: disabled.
    Return result

    If a value of 0 is returned, the call is successful. If another value is returned, the call fails.

  • setVolume: sets the volume of the player (which affects the volume of ingested streams).
    public int setVolume(int volume);
    Parameter Type Description
    volume int The volume. Valid values: 0 to 100.
    Return result

    If a value of 0 is returned, the call is successful. If another value is returned, the call fails.

  • getDuration: obtains the total playback duration.
    Note You need to wait until the status of the player is MediaPlayerStatePrepared to obtain the exact duration.
    public long getDuration();
  • getCurrentPlaybackTime: obtains the current playback position.
    Note You need to wait until the player's status is MediaPlayerStatePrepared to get the exact current location.
    public long getCurrentPlaybackTime();
  • getCurrentVomume: obtains the current playback volume.
    Note You need to wait until the player's status is MediaPlayerStatePrepared to get the exact current volume.
    public int getCurrentVomume();
  • getCurrentPlaybackState: obtains the current playback status.
    public MediaPlayerState getCurrentPlaybackState();
  • getIndex: obtains the current player ID.
    Note You can create multiple players at the same time. This interface can be used to distinguish each player.
    public int getIndex();