All Products
Search
Document Center

:Upgrade LinkVisual Media SDK for Android from V1.x.x to V2.x.x

Last Updated:Jun 01, 2023

LinkVisual Media SDK for Android V2.0.0 has introduced major changes to operations, methods, and classes. If your SDK version is earlier than 2.0.0, we recommend that you follow the instructions in this topic to upgrade your SDK.

Major changes

Feature

V1.x.x

V2.x.x

Rendering components

The TextureView and GLSurfaceView components are supported.

Only the TextureView component is supported. The GLSurfaceView component is no longer supported.

Live players

LivePlayer

The class used to create live players is renamed LVLivePlayer.

Video-on-demand (VOD) players

The class used to create VOD players for on-premises recordings is renamed VodPlayer.

The class used to create VOD players for cloud recordings is renamed HlsPlayer.

The class used to create VOD players for on-premises recordings and the class used to create VOD players for cloud recordings are merged into one class named LVVodPlayer. The LVVodPlayer class automatically identifies the specified data source and creates a VOD player of a type that corresponds to the data source.

Voice intercom

LiveIntercomV2.

The class used to create voice intercom sessions is renamed LVLiveIntercom.

Procedure

The method used to integrate LinkVisual Media SDK for Android by using Gradle is similar between versions. You need to only specify the corresponding version number. The obfuscation configuration remains unchanged.

Note

In V2.0.0 and later, ExoPlayer is no longer integrated into LinkVisual Media SDK for Android by default. If you want to use ExoPlayer, add the following code to import the required dependencies:

implementation('com.google.android.exoplayer:exoplayer-core:2.10.5')
implementation('com.google.android.exoplayer:exoplayer-ui:2.8.3')
implementation('com.google.android.exoplayer:exoplayer-hls:2.10.5')

Add the following code to the obfuscation configuration:

-dontwarn com.google.android.exoplayer2.**

API changes (search for changes by keyword)

Global components

Change

1.x.x

2.x.x

Usage notes

The SDK and the class are renamed.

com.aliyun.iotx.linkvisual.media.LinkVisualMedia

com.aliyun.iotx.linkvisual.media.LVMedia

Rename the SDK and the class.

Live players

Change

1.x.x

2.x.x

Usage notes

The SDK and the class are renamed.

com.aliyun.iotx.linkvisual.media.video.player.LivePlayer

com.aliyun.iotx.linkvisual.media.player.LVLivePlayer

Rename the SDK and the class.

The values of the decryptIv and decryptKey parameters of the operation that encrypts the data of a data source that stores streaming data are changed from the binary data after Base64 decoding to the original Base64-encoded strings.

void setDataSource(String url, boolean isEncrypted, byte[] decryptIv, byte[] decryptKey)

LVPlayerCode setDataSource(String url, boolean isEncrypted, String decryptIvBase64, String decryptKeyBase64)

Important

Decode Base64-encoded strings by using the SDK.

The operations that make preparations are removed.

  1. prepare()

  2. void setOnPreparedListener(OnPreparedListener listener)

  3. com.aliyun.iotx.linkvisual.media.video.listener.OnPreparedListener

N/A

After you specify a data source, you can call the start() operation to start a playback without the need to call the prepare() operation.

Return values are added to operations, such as setDataSource(), start(), stop(), and release().

N/A

Enumerated return values:

enum LVPlayerCode{ /** Executed */ LV_PLAYER_SUCCESS = 0, /** Execution failed due to a common error */ LV_PLAYER_ERROR_FAILED = -1, /** Invalid input parameters */ LV_PLAYER_ERROR_INVALID_PARAMETER = -2, /** API not supported */ LV_PLAYER_ERROR_UNSUPPORTED = -3, };

Check whether an operation is successful based on the return values.

The operations that obtain the height and width of a streaming video are added.

N/A

  1. int getVideoWidth()

  2. int getVideoHeight()

None

The classes that configure decoding policies and enumerate decoding types are renamed.

  1. com.aliyun.iotx.linkvisual.media.video.HardwareDecoderable.DecoderStrategy

  2. com.aliyun.iotx.linkvisual.media.video.HardwareDecoderable.DecoderType

  1. com.aliyun.iotx.linkvisual.media.player.bean.LVDecoderStrategy

  2. com.aliyun.iotx.linkvisual.media.player.bean.LVDecoderType

Rename the classes.

The operations that configure and cancel volume settings are replaced by the mute and unmute operations.

  1. void setVolume(float audioVolume)

  2. float getVolume()

  1. LVPlayerCode mute(boolean isMute)

  2. boolean isMute()

You cannot separately control player volume in an app. The system performs volume control in a centralized manner.

The operations that manage audio focuses are added.

N/A

  1. LVPlayerCode audioFocus()

  2. boolean isAudioFocus()

In V2.0.0 and later, the SDK cannot simultaneously play multiple audio streams but can play only one audio stream. For example, if multiple audio streams are simultaneously played on multiple views of a network video recorder (NVR), you can call the audioFocus() operation to select the audio stream that you want to play.

The operation that configures a channel for audio streams is removed.

void setAudioStreamType(final int streamType)

N/A

Live players use only the AudioManager.STREAM_MUSIC channel and you can no longer switch channels.

The operations that support the GLSurfaceView component are removed.

  1. void setSurfaceView(SurfaceView mSurfaceView)

  2. void clearSurfaceView()

N/A

Replace the GLSurfaceView component with the TextureView component. Compared with the GLSurfaceView component, the TextureView component provides the following advantages:

  1. Supports hardware acceleration. A player window can scale with a view without black bars.

  2. Supports electronic zoom. To enable this feature, we recommend that you use the ZoomableTextureView component of the SDK.

  3. Supports multi-window playback.

The operation that configures the scaling mode of videos is replaced by a new operation. The parameter is renamed and a new class is added.

void setVideoScalingMode(int mVideoScalingMode)

LVPlayerCode setVideoScalingMode(LVVideoScalingMode videoScalingMode)

com.aliyun.iotx.linkvisual.media.player.bean.LVVideoScalingMode { //Aspect ratio-based fit LV_VIDEO_SCALING_MODE_FIT, //Autofill LV_VIDEO_SCALING_MODE_FILL; }

Rename the operation and the parameter, and add the new class.

The operations that configure recording for the playing content are replaced by new operations.

  1. boolean startRecordingContent(File contentFile)

  2. boolean stopRecordingContent()

  3. long getCurrentRecordingContentDuration()

  1. LVPlayerCode startRecordingContent(String contentFilePath)

  2. LVPlayerCode stopRecordingContent()

  3. long getCurrentRecordingContentDurationInMs()

  1. The contentFile parameter is renamed contentFilePath and the type of the contentFile parameter is changed from File to String.

  2. Rename the getCurrentRecordingContentDuration operation getCurrentRecordingContentDurationInMs.

The operations that configure display behaviors when a playback stops are removed.

  1. void setPlayerStoppedDrawingMode(PlayerStoppedDrawingMode playerStoppedDrawingMode)

  2. PlayerStoppedDrawingMode getPlayerStoppedDrawingMode()

N/A

None

The operation that obtains the status of a player is replaced by a new operation.

int getPlayState()

  1. LVPlayerState getPlayerState()

  2. com.aliyun.iotx.linkvisual.media.player.bean.LVPlayerState

The type of the returned status value is changed from INTEGER to ENUM. This helps you understand and maintain the code with ease.

The operation that obtains the stream connection type of a player is replaced by a new operation and a new class is added.

StreamConnectType getStreamConnectType()

  1. LVStreamConnectType getStreamConnectType()

  2. com.aliyun.iotx.linkvisual.media.player.bean.LVStreamConnectType

Rename the operation and add the new class.

The operation that obtains information about the frame rate or bitrate of a player is replaced by a new operation and a new class is added.

PlayInfo getCurrentPlayInfo()

  1. LVPlayInfo getCurrentPlayInfo()

  2. com.aliyun.iotx.linkvisual.media.player.bean.LVPlayInfo

Rename the operation and add the new class.

The operations that configure callbacks for live players are replaced by a new operation.

  1. void setOnRenderedFirstFrameListener(OnRenderedFirstFrameListener listener)

  2. void setOnErrorListener(OnErrorListener listener)

  3. void setOnPlayerStateChangedListener(OnPlayerStateChangedListener listener)

  4. void setOnVideoSizeChangedListener(OnVideoSizeChangedListener listener)

  5. void setOnVideoQualityListener(OnVideoQualityListener listener)

  6. void setOnSeiInfoListener(SeiInfoBuffer seiInfoBuffer, OnSeiInfoListener onSeiInfoListener)

LVPlayerCode setPlayerListener(ILVPlayerListener listener)

com.aliyun.iotx.linkvisual.media.player.listener.ILVPlayerListener { void onError(LVPlayerError error); void onPlayerStateChange(LVPlayerState state); void onRenderedFirstFrame(int elapsedTimeInMs); void onVideoSizeChanged(int width, int height); void onSeiInfoUpdate(byte[] buffer, int length, long timeStamp); void onVideoJitterBufferEmpty(); }

Merge multiple listeners into one listener.

The operations that configure external rendering for players are replaced by a new operation.

  1. void setUseExternalRender(boolean mUseExternalRender)

  2. void setOnExternalRenderListener

  3. boolean useExternalRender()

LVPlayerCode setUseExternalRender(boolean useExternalVideoRender, boolean useExternalAudioRender, ILVPlayerExternalRenderListener listener)

com.aliyun.iotx.linkvisual.media.player.listener.ILVPlayerExternalRenderListener { void onVideoFrameUpdate(int width, int height, long timestampInMs); void onAudioHeader(int audioBitPerSample, int audioSamplesPerSec, int audioChannel); boolean onAudioData(byte[] buffer, int offset, int length); }

In V2.0.0 and later, LinkVisual Media SDK for Android supports callbacks for video data in the YUV format and callbacks for audio data in the PCM format.

The operation that obtains a frame of YUV data is replaced by a new operation.

Yuv420pFrame getYuvFrame()

Yuv420pFrame getYuv420pFrame()

Rename the operation.

VOD players

Change

1.x.x

2.x.x

Usage notes

The SDK and the classes are renamed.

  1. com.aliyun.iotx.linkvisual.media.video.player.VodPlayer

  2. com.aliyun.iotx.linkvisual.media.video.player.HlsPlayer

com.aliyun.iotx.linkvisual.media.player.LVVodPlayer

Rename the SDK and the classes. In V2.0.0 and later, LinkVisual Media SDK for Android merges VOD players that play recordings in the storage cards of IP cameras and VOD players that play cloud recordings into only one type of VOD players.

The values of the decryptIv and decryptKey parameters of the operation that encrypts the data of a data source that stores the VOD recordings of the storage cards of an IP camera are changed from the binary data after Base64 decoding to the original Base64-encoded strings.

void setDataSource(String url, boolean isEncrypted, byte[] decryptIv, byte[] decryptKey)

LVPlayerCode setDataSource(String url, boolean isEncrypted, String decryptIvBase64, String decryptKeyBase64)

Important

Decode Base64-encoded strings by using the SDK.

The operations that make preparations are removed.

  1. prepare()

  2. void setOnPreparedListener(OnPreparedListener listener)

  3. com.aliyun.iotx.linkvisual.media.video.listener.OnPreparedListener

N/A

After you specify a data source, you can call the start() operation to start a playback without the need to call the prepare() operations.

Return values are added to specific operations, such as setDataSource(), start(), stop(), and release().

None

Enumerated return values:

enum LVPlayerCode{ /** Executed successfully */ LV_PLAYER_SUCCESS = 0, /** Execution failed due to a common error */ LV_PLAYER_ERROR_FAILED = -1, /** Invalid input parameters */ LV_PLAYER_ERROR_INVALID_PARAMETER = -2, /** API not supported */ LV_PLAYER_ERROR_UNSUPPORTED = -3, };

Check whether an operation is successful based on the return value.

A separate operation that resumes a playback is added.

void start()

LVPlayerCode resume()

In V2.0.0 and later, the resume operation of VOD players is no longer integrated with the start() operation.

The operations that obtain the playback duration of a VOD player are replaced by new operations.

  1. long getDuration()

  2. long getCurrentPosition()

  1. long getDurationMs()

  2. long getCurrentPositionMs()

Rename the operations.

The operations that obtain the height and width of a streaming video are added.

N/A

  1. int getVideoWidth()

  2. int getVideoHeight()

None

The classes that enumerate decoding policies and types are renamed.

  1. com.aliyun.iotx.linkvisual.media.video.HardwareDecoderable.DecoderStrategy

  2. com.aliyun.iotx.linkvisual.media.video.HardwareDecoderable.DecoderType

  1. com.aliyun.iotx.linkvisual.media.player.bean.LVDecoderStrategy

  2. com.aliyun.iotx.linkvisual.media.player.bean.LVDecoderType

Rename the classes.

The operations that configure and cancel volume settings are replaced by the mute and unmute operations.

  1. void setVolume(float audioVolume)

  2. float getVolume()

  1. LVPlayerCode mute(boolean isMute)

  2. boolean isMute()

You cannot separately control player volume in an app. The system performs volume control in a centralized manner.

Operations that manage audio focuses are added.

N/A

  1. LVPlayerCode audioFocus()

  2. boolean isAudioFocus()

In V2.0.0 and later, the SDK cannot simultaneously play multiple audio streams but can play only one audio stream. For example, if multiple audio streams are simultaneously played on multiple views of a NVR, you can call the audioFocus() operation to select the audio stream that you want to play.

The operation that configures a channel for audio streams is removed.

void setAudioStreamType(final int streamType)

N/A

Live players use only the AudioManager.STREAM_MUSIC channel and you can no longer switch channels.

The operations that support the GLSurfaceView component are removed.

  1. void setSurfaceView(SurfaceView mSurfaceView)

  2. void clearSurfaceView()

N/A

Replace the GLSurfaceView component with the TextureView component. Compared with the GLSurfaceView component, the TextureView component provides the following advantages:

  1. Supports hardware acceleration. A player window can scale with a view without black bars.

  2. Supports electronic zoom. To enable this feature, we recommend that you use the ZoomableTextureView component of the SDK.

  3. Supports multi-window playback.

The operation that configures the scaling mode of videos is replaced by a new operation. The parameter is renamed and a new class is added.

void setVideoScalingMode(int mVideoScalingMode)

LVPlayerCode setVideoScalingMode(LVVideoScalingMode videoScalingMode)

com.aliyun.iotx.linkvisual.media.player.bean.LVVideoScalingMode { //Aspect ratio-based fit LV_VIDEO_SCALING_MODE_FIT, //Autofill LV_VIDEO_SCALING_MODE_FILL; }

Rename the operation and the parameter, and add the new class.

The operations that configure recording for the playing content are replaced by new operations.

  1. boolean startRecordingContent(File contentFile)

  2. boolean stopRecordingContent()

  3. long getCurrentRecordingContentDuration()

  1. LVPlayerCode startRecordingContent(String contentFilePath)

  2. LVPlayerCode stopRecordingContent()

  3. long getCurrentRecordingContentDurationInMs()

  1. The contentFile parameter is renamed contentFilePath and the type of the contentFile parameter is changed from File to String.

  2. Rename the getCurrentRecordingContentDuration operation getCurrentRecordingContentDurationInMs.

The operations that configure display behaviors when a playback stops are removed.

  1. void setPlayerStoppedDrawingMode(PlayerStoppedDrawingMode playerStoppedDrawingMode)

  2. PlayerStoppedDrawingMode getPlayerStoppedDrawingMode()

N/A

None

The operation that obtains the status of a player is replaced by a new operation.

int getPlayState()

  1. LVPlayerState getPlayerState()

  2. com.aliyun.iotx.linkvisual.media.player.bean.LVPlayerState

The type of the returned status value is changed from INTEGER to ENUM. This helps you understand and maintain the code with ease.

The operation that obtains the stream connection type of a player is replaced by a new operation and a new class is added.

StreamConnectType getStreamConnectType()

  1. LVStreamConnectType getStreamConnectType()

  2. com.aliyun.iotx.linkvisual.media.player.bean.LVStreamConnectType

Rename the operation and add the new class.

The operation that obtains information about the frame rate or bitrate of a player is replaced by a new operation and a new class is added.

PlayInfo getCurrentPlayInfo()

  1. LVPlayInfo getCurrentPlayInfo()

  2. com.aliyun.iotx.linkvisual.media.player.bean.LVPlayInfo

Rename the operation and add the new class.

The operations that configure callbacks for VOD players are replaced by new operations.

  1. void setOnRenderedFirstFrameListener(OnRenderedFirstFrameListener listener)

  2. void setOnErrorListener(OnErrorListener listener)

  3. void setOnPlayerStateChangedListener(OnPlayerStateChangedListener listener)

  4. void setOnVideoSizeChangedListener(OnVideoSizeChangedListener listener)

  5. void setOnVideoQualityListener(OnVideoQualityListener listener)

  6. void setOnSeiInfoListener(SeiInfoBuffer seiInfoBuffer, OnSeiInfoListener onSeiInfoListener)

  7. void setOnCompletionListener(OnCompletionListener listener)

LVPlayerCode setPlayerListener(ILVPlayerListener listener)

com.aliyun.iotx.linkvisual.media.player.listener.ILVPlayerListener {
    void onError(LVPlayerError error);
    void onPlayerStateChange(LVPlayerState state);
    void onRenderedFirstFrame(int elapsedTimeInMs);
    void onVideoSizeChanged(int width, int height);
    void onSeiInfoUpdate(byte[] buffer, int length, long timeStamp);    void onVideoJitterBufferEmpty();
}

LVPlayerCode setVodCompletionListener(ILVVodPlayerCompletionListener listener)

com.aliyun.iotx.linkvisual.media.player.listener.ILVVodPlayerCompletionListener{
    void onCompletion();
}

Merge multiple listeners into two listeners.

The operations that configure external rendering for players are replaced by a new operation.

  1. void setUseExternalRender(boolean mUseExternalRender)

  2. void setOnExternalRenderListener

  3. boolean useExternalRender()

LVPlayerCode setUseExternalRender(boolean useExternalVideoRender, boolean useExternalAudioRender, ILVPlayerExternalRenderListener listener)

com.aliyun.iotx.linkvisual.media.player.listener.ILVPlayerExternalRenderListener {
    void onVideoFrameUpdate(int width, int height, long timestampInMs);
    void onAudioHeader(int audioBitPerSample, int audioSamplesPerSec, int audioChannel);
    boolean onAudioData(byte[] buffer, int offset, int length);
}

In V2.0.0 and later, LinkVisual Media SDK for Android supports callbacks for video data in the YUV format and callbacks for audio data in the PCM format.

The operation that obtains a frame of YUV data is replaced by a new operation.

Yuv420pFrame getYuvFrame()

Yuv420pFrame getYuv420pFrame()

Rename the operation.

Voice intercom

Change

1.x.x

2.x.x

Usage notes

The SDK and the class are renamed.

com.aliyun.iotx.linkvisual.media.audio.LiveIntercomV2

com.aliyun.iotx.linkvisual.media.liveintercom.LVLiveIntercom

Rename the SDK and the class.

The operation that initializes a voice intercom session is replaced by a new operation.

LiveIntercomV2(Context context, final String iotId, final LiveIntercomMode liveIntercomMode, final AudioParams audioParams)

LVLiveIntercom(Context context, AudioParams audioParams)

In V2.0.0 and later, you do not need to specify an IoT device ID and voice intercom mode during the initialization of the SDK. You can specify an IoT device ID for the start() operation and a voice intercom mode for the setLiveIntercomMode() operation.

Return values are added to operations, such as start(), stop(), and release().

N/A

Enumerated return values:

LVLiveIntercomCode { //Executed successfully LV_LIVE_INTERCOM_SUCCESS, //Execution failed due to a common error LV_LIVE_INTERCOM_ERROR_FAILED, //Invalid input parameters LV_LIVE_INTERCOM_ERROR_INVALID_PARAMETER, //API not supported LV_LIVE_INTERCOM_ERROR_UNSUPPORTED }

Check whether an operation is successful based on the return value.

An operation that specifies a voice intercom mode is added.

None

LVLiveIntercomCode setLiveIntercomMode(LVLiveIntercomMode liveIntercomMode)

In V2.0.0 and later, the DoubleTalkWithLive mode is added to voice intercom. In this mode, an IP camera must support acoustic echo cancellation (AEC), and the IP camera and the related app simultaneously collect and play audio. This mode requires live streaming channels with live streams because the audio is played over a live streaming channel of the IP camera. To select a live streaming channel before the voice intercom session starts, you canYou can call the LVLivePlayer.audioFocus() method.

The operation that starts a voice intercom session with an IP camera that is specified by a URL is replaced by a new operation.

void startWithExternalRequest(LiveIntercomRequest liveIntercomRequest)

LVLiveIntercomCode start(String url, String decryptIvBase64, String decryptKeyBase64)

Rename the operation. The values of the decryptIvBase64 and decryptKeyBase64 parameters are Base64-encoded strings.

The operation that configures a listener for a voice intercom session is replaced by a new operation.

void setLiveIntercomV2Listener(LiveIntercomV2Listener listener)

LVLiveIntercomCode setLiveIntercomListener(ILVLiveIntercomListener listener)

ILVLiveIntercomListener { void onTalkReady(); void onRecorderStart(); void onRecorderEnd(); void onRecorderVolume(int volume); void onError(LVLiveIntercomError error); }

Rename the operation.

The operation that implements the external voice change feature is replaced by a new operation.

void setExternalVoiceChangeImpl(IVoiceChange voiceChangeImpl)

LVLiveIntercomCode setUseExternalVoiceChange(boolean useExternal, ILVLiveIntercomVoiceChangeListener listener)

ILVLiveIntercomVoiceChangeListener{ boolean onAudioData(byte[] pcm, int length); }

Rename the operation.

The operation that specifies an internal voice change type is replaced by a new operation.

void setVoiceChangeType(LiveIntercomVoiceType voiceType)

LVLiveIntercomCode setVoiceChangeType(LVLiveIntercomVoiceType liveIntercomVoiceType)

Rename the operation.