LinkVisual Media SDK(Android) v2.7.0-ilop
Public Member Functions | Static Public Attributes | List of all members
com.aliyun.iotx.linkvisual.media.player.LVLivePlayer Class Reference

直播播放器 More...

Public Member Functions

 LVLivePlayer (final Context context)
 
LVPlayerCode setDataSource (String url)
 
LVPlayerCode setDataSource (String url, boolean isEncrypted, String decryptIvBase64, String decryptKeyBase64)
 
LVPlayerCode setDataSource (String url, boolean isEncrypted, String decryptIvBase64, String decryptKeyBase64, String stunInfo)
 
LVPlayerCode setLiveDataSource (String iotId, LVStreamType streamType)
 
LVPlayerCode setLiveDataSource (String iotId, LVStreamType streamType, int cacheDurationInMs)
 
LVPlayerCode start ()
 
LVPlayerCode stop ()
 
LVPlayerCode reset ()
 
LVPlayerCode release ()
 
LVPlayerCode setReconnectCount (int count)
 
LVPlayerCode setBufferedFrameCount (int frameCount)
 
LVPlayerCode setMaxJitterBufferSizeInMs (int jitterBufferSizeInMs)
 
LVPlayerCode setDecoderStrategy (LVDecoderStrategy decoderStrategy)
 
LVDecoderType getDecoderType ()
 
LVPlayerCode mute (boolean isMute)
 
boolean isMute ()
 
LVPlayerCode audioFocus ()
 
boolean isAudioFocus ()
 
int getVideoWidth ()
 
int getVideoHeight ()
 
LVPlayerCode setTextureView (TextureView textureView)
 
LVPlayerCode setTextureView (TextureView textureView, LVVideoRotationMode rotationMode)
 
LVVideoRotationMode getWindowRotationMode ()
 
LVPlayerCode setVideoScalingMode (LVVideoScalingMode videoScalingMode)
 
LVPlayerCode setPlayerStoppedDrawingMode (LVPlayerStoppedDrawingMode playerStoppedDrawingMode)
 
Bitmap snapShot ()
 
Bitmap snapShot (LVVideoRotationMode rotationMode)
 
LVPlayerCode snapShotToFile (String jpegFilePath)
 
LVPlayerCode snapShotToFile (String jpegFilePath, LVVideoRotationMode rotationMode)
 
LVPlayerCode startRecordingContent (String contentFilePath)
 
LVPlayerCode stopRecordingContent ()
 
long getCurrentRecordingContentDurationInMs ()
 
LVPlayerState getPlayerState ()
 
LVStreamConnectType getStreamConnectType ()
 
LVPlayInfo getCurrentPlayInfo ()
 
LVPlayerCode setPlayerListener (ILVPlayerListener listener)
 
LVPlayerCode setUseExternalRender (boolean useExternalVideoRender, boolean useExternalAudioRender, ILVPlayerExternalRenderListener listener)
 
Yuv420pFrame getYuv420pFrame ()
 
Yuv420pFrame getYuv420pFrame (LVVideoRotationMode rotationMode)
 
String getStatisticsInfo ()
 
Yuv420pFrame lockAndGetYuv420pFrame (LVVideoRotationMode rotationMode)
 
LVPlayerCode unlockYuv420pFrame ()
 
LVPlayerCode sendExtendedCommand (String command)
 
LVPlayerCode setPlayerStreamListener (boolean isOnlyStream, ILVPlayerStreamListener listener)
 
LVPlayerCode setAudioStreamInCall (boolean useInCallMode)
 
void setSupportExternalHeadset (boolean supportExternalHeadset)
 
boolean isSupportExternalHeadset ()
 

Static Public Attributes

static final String TAG = "LVLivePlayer"
 

Detailed Description

直播播放器

Constructor & Destructor Documentation

◆ LVLivePlayer()

com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.LVLivePlayer ( final Context  context)
inline

创建直播播放器

Parameters
contextApplication context

Member Function Documentation

◆ audioFocus()

LVPlayerCode com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.audioFocus ( )
inline

当前播放器获取音频焦点 仅有持有焦点的播放器允许播放音频, 至多只有一个播放器可以获取焦点 当存在多路观看(如NVR多分屏)场景时, 请交由用户来调用关心的那一路播放器的audioFocus()接口来完成多路播放器之间声音播放的切换

Returns
是否操作成功

◆ getCurrentPlayInfo()

LVPlayInfo com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.getCurrentPlayInfo ( )
inline

获取播放器当前的帧率/码率等信息 需在LVPlayerState#STATE_READY时调用有效

Returns
playInfo 帧率/码率信息

◆ getCurrentRecordingContentDurationInMs()

long com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.getCurrentRecordingContentDurationInMs ( )
inline

获取当前录制的视频时长 注意, 实际内容时长可能小于总的录制时间

Returns
单位ms

◆ getDecoderType()

LVDecoderType com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.getDecoderType ( )
inline

获取当前流的解码器类型, 仅在播放器开播后有效

Returns
软解或硬解

◆ getPlayerState()

LVPlayerState com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.getPlayerState ( )
inline

获取播放状态

Returns
状态枚举

◆ getStatisticsInfo()

String com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.getStatisticsInfo ( )
inline

获取播放统计数据

Returns
统计数据的json字符串

◆ getStreamConnectType()

LVStreamConnectType com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.getStreamConnectType ( )
inline

获取播放器当前流的连接类型 需在播放器状态为LVPlayerState#STATE_READY后过5S调用能准确反映当前使用的流类型

Returns
P2P直连/P2P穿透/云转

◆ getVideoHeight()

int com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.getVideoHeight ( )
inline

获取视频高

Returns
高值像素点

◆ getVideoWidth()

int com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.getVideoWidth ( )
inline

获取视频宽

Returns
宽值像素点

◆ getWindowRotationMode()

LVVideoRotationMode com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.getWindowRotationMode ( )
inline

获取窗口画面旋转方向, 与setTextureView(TextureView, LVVideoRotationMode)时传入的一致

Returns
画面旋转角度

◆ getYuv420pFrame() [1/2]

Yuv420pFrame com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.getYuv420pFrame ( )
inline

获取当前最新的YUV420p数据帧 该接口请不要在ILVPlayerExternalRenderListener#onVideoFrameUpdate(int, int, long)回调中执行, 否则会引起死锁

Returns
YUV420p数据帧
Deprecated:
建议使用lockAndGetYuv420pFrame(LVVideoRotationMode)unlockYuv420pFrame来替代

◆ getYuv420pFrame() [2/2]

Yuv420pFrame com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.getYuv420pFrame ( LVVideoRotationMode  rotationMode)
inline

获取当前最新的YUV420p数据帧 该接口请不要在ILVPlayerExternalRenderListener#onVideoFrameUpdate(int, int, long)回调中执行, 否则会引起死锁

Parameters
rotationMode画面旋转角度
Returns
YUV420p数据帧
Deprecated:
建议使用lockAndGetYuv420pFrame(LVVideoRotationMode)unlockYuv420pFrame来替代

◆ isAudioFocus()

boolean com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.isAudioFocus ( )
inline

当前播放器是否有音频焦点

Returns
焦点与否

◆ isMute()

boolean com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.isMute ( )
inline

当前播放器是否静音

Returns
静音与否

◆ isSupportExternalHeadset()

boolean com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.isSupportExternalHeadset ( )
inline

当前是否开启对蓝牙和有线耳机外设的支持

Returns
是否开启对蓝牙和有线耳机外设的支持

◆ lockAndGetYuv420pFrame()

Yuv420pFrame com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.lockAndGetYuv420pFrame ( LVVideoRotationMode  rotationMode)
inline

锁定并获取当前最新的YUV420p数据帧 该接口请不要在ILVPlayerExternalRenderListener#onVideoFrameUpdate(int, int, long)回调中执行, 否则会引起死锁

Returns
YUV420p数据帧

◆ mute()

LVPlayerCode com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.mute ( boolean  isMute)
inline

播放静音

Parameters
isMute静音与否
Returns
是否操作成功

◆ release()

LVPlayerCode com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.release ( )
inline

释放播放器

◆ reset()

LVPlayerCode com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.reset ( )
inline

重置数据源, 重置后需要重新设置数据源

Returns
是否操作成功

◆ sendExtendedCommand()

LVPlayerCode com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.sendExtendedCommand ( String  command)
inline

向设备发送扩展指令,仅在LVPlayerState#STATE_READY时调用有效 通过媒体通道可以更快的给设备发送指令,应用于需要实时响应高的指令下发,如PTZ云台控制

if(liveplayer.sendExtendedCommand("ptz action") != LV_PLAYER_SUCCESS){
// 继续使用物模型发送PTZ指令
}

该特性需要设备端升级到2.5.0及其以上

Parameters
command指令消息体,长度不超过1024字节
Returns
操作是否成功,若设备不支持将返回LV_PLAYER_ERROR_UNSUPPORTED

◆ setAudioStreamInCall()

LVPlayerCode com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.setAudioStreamInCall ( boolean  useInCallMode)
inline

选择是否直播的音频通过通话模式播放声音 播放器默认直播采用多媒体模式播放声音

Parameters
useInCallMode音频是否通过通话模式播放
Returns
操作是否成功

◆ setBufferedFrameCount()

LVPlayerCode com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.setBufferedFrameCount ( int  frameCount)
inline

设置播放器固定缓存帧数

Parameters
frameCount播放器固定缓存帧数, 取值范围:0帧~50帧, 数值越大播放器延迟越大, 流畅性越好, 默认5帧
Returns
是否操作成功

◆ setDataSource() [1/3]

LVPlayerCode com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.setDataSource ( String  url)
inline

设置数据源

Parameters
url未加密的rtmp直播地址
Returns
是否操作成功

◆ setDataSource() [2/3]

LVPlayerCode com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.setDataSource ( String  url,
boolean  isEncrypted,
String  decryptIvBase64,
String  decryptKeyBase64 
)
inline

设置基于物联网智能视频服务接入的摄像头直播数据源

Parameters
urlrtmp直播地址
isEncrypted是否开启加密, 开启后仅适配物联网视频平台提供的rtmp地址
decryptIvBase64解密向量(base64加密后的字符串)
decryptKeyBase64解密密钥(base64加密后的字符串)
Returns
是否操作成功

◆ setDataSource() [3/3]

LVPlayerCode com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.setDataSource ( String  url,
boolean  isEncrypted,
String  decryptIvBase64,
String  decryptKeyBase64,
String  stunInfo 
)
inline

设置基于物联网智能视频服务接入的摄像头直播数据源

Parameters
urlrtmp直播地址
isEncrypted是否开启加密, 开启后仅适配物联网视频平台提供的rtmp地址
decryptIvBase64解密向量(base64加密后的字符串)
decryptKeyBase64解密密钥(base64加密后的字符串)
stunInfop2p服务信息(用于与设备建立P2P通道以降低云转发流量)
Returns
是否操作成功

◆ setDecoderStrategy()

LVPlayerCode com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.setDecoderStrategy ( LVDecoderStrategy  decoderStrategy)
inline

设置解码器策略, 全局生效 默认使用硬解码优先

Parameters
decoderStrategy支持硬解码优先和强制软解码两种模式
Returns
是否操作成功

◆ setLiveDataSource() [1/2]

LVPlayerCode com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.setLiveDataSource ( String  iotId,
LVStreamType  streamType 
)
inline

设置基于生活物联网平台接入的摄像头直播数据源 该接口已开启加密和强制I帧.

Parameters
iotId设备的iotId
streamType流的类型: LVStreamType#LV_STREAM_TYPE_MAJOR-主码流, LVStreamType#LV_STREAM_TYPE_MINOR-辅码流
Returns
是否操作成功

◆ setLiveDataSource() [2/2]

LVPlayerCode com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.setLiveDataSource ( String  iotId,
LVStreamType  streamType,
int  cacheDurationInMs 
)
inline

设置基于生活物联网平台接入的摄像头直播数据源 该接口已开启加密和强制I帧

Parameters
iotId设备的iotId
streamType流的类型: LVStreamType#LV_STREAM_TYPE_MAJOR-主码流, LVStreamType#LV_STREAM_TYPE_MINOR-辅码流
cacheDurationInMs云端缓存的视频长度, 单位ms, 该值建议不超过1个GOP长度, 若有数据, 这段时长的数据将会被加速快放
Returns
是否操作成功

◆ setMaxJitterBufferSizeInMs()

LVPlayerCode com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.setMaxJitterBufferSizeInMs ( int  jitterBufferSizeInMs)
inline

设置播放器抗抖动最大缓冲区时长

Parameters
jitterBufferSizeInMs默认1000ms, 范围200-3000ms
Returns
是否操作成功

◆ setPlayerListener()

LVPlayerCode com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.setPlayerListener ( ILVPlayerListener  listener)
inline

设置播放器回调

Parameters
listener包括状态/错误等监听的回调对象
Returns
是否操作成功

◆ setPlayerStoppedDrawingMode()

LVPlayerCode com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.setPlayerStoppedDrawingMode ( LVPlayerStoppedDrawingMode  playerStoppedDrawingMode)
inline

设置播放停止时画面绘制策略

Parameters
playerStoppedDrawingMode支持保留最后一帧和强制黑色两种模式, 默认强制黑色
Returns
是否操作成功

◆ setPlayerStreamListener()

LVPlayerCode com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.setPlayerStreamListener ( boolean  isOnlyStream,
ILVPlayerStreamListener  listener 
)
inline

设置播放器原始码流回调, 包括音/视频帧, 单帧大小不超过1MB。该接口为高级特性。一般使用无需关注。

Parameters
isOnlyStream是否仅取原始流,开启后将不启用内置的解码和渲染,需要使用方自行完成解码渲染
listener原始音视频数据回调(视频H264/H265,音频G711/AAC/PCM)
Returns
操作是否成功

◆ setReconnectCount()

LVPlayerCode com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.setReconnectCount ( int  count)
inline

设置直播播放重连次数 需在开始播放前设置, 只针对发生LVPlayerError#LV_PLAYER_ERROR_SUB_CODE_UNEXPECTED_PULL_STREAM_TIMEOUT错误时做重连

Parameters
count默认为0, 建议不超过3次
Returns
是否操作成功

◆ setSupportExternalHeadset()

void com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.setSupportExternalHeadset ( boolean  supportExternalHeadset)
inline

设置是否开启对蓝牙和有线耳机外设的支持, 开启后优先使用外设进行录放音, 仅在直播的音频通过通话模式播放声音时有效,默认支持

Parameters
supportExternalHeadset是否开启对蓝牙和有线耳机外设的支持

◆ setTextureView() [1/2]

LVPlayerCode com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.setTextureView ( TextureView  textureView)
inline

设置视频渲染窗口

Parameters
textureView窗口view
Returns
是否操作成功

◆ setTextureView() [2/2]

LVPlayerCode com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.setTextureView ( TextureView  textureView,
LVVideoRotationMode  rotationMode 
)
inline

设置视频渲染窗口

Parameters
textureView窗口view
rotationMode画面旋转角度
Returns
是否操作成功

◆ setUseExternalRender()

LVPlayerCode com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.setUseExternalRender ( boolean  useExternalVideoRender,
boolean  useExternalAudioRender,
ILVPlayerExternalRenderListener  listener 
)
inline

设置外部渲染开关及相应的数据回调。该接口为高级特性。一般使用无需关注。

Parameters
useExternalVideoRender是否开启外部渲染, 开启后内部将不再绘制, 请在渲染线程中调用getYuv420pFrame()接口获取YUV420p数据渲染
useExternalAudioRender是否开启外部音频播放, 开启后内部将不再播放音频
listener视频渲染通知及音频数据回调, 设置后始终回调YUV数据及音频PCM数据
Returns
是否操作成功

◆ setVideoScalingMode()

LVPlayerCode com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.setVideoScalingMode ( LVVideoScalingMode  videoScalingMode)
inline

设置画面缩放模式

Parameters
videoScalingMode支持保持宽高比和强制拉伸两种模式
Returns
是否操作成功

◆ snapShot() [1/2]

Bitmap com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.snapShot ( )
inline

窗口截图

Returns
bitmap对象, 如果未播放则返回null

◆ snapShot() [2/2]

Bitmap com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.snapShot ( LVVideoRotationMode  rotationMode)
inline

窗口截图

Parameters
rotationMode图片旋转角度
Returns
bitmap对象, 如果未播放则返回null

◆ snapShotToFile() [1/2]

LVPlayerCode com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.snapShotToFile ( String  jpegFilePath)
inline

截图到文件

Parameters
jpegFilePath保存截图jpeg的文件绝对路径
Returns
是否操作成功

◆ snapShotToFile() [2/2]

LVPlayerCode com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.snapShotToFile ( String  jpegFilePath,
LVVideoRotationMode  rotationMode 
)
inline

截图到文件

Parameters
jpegFilePath保存截图jpeg的文件绝对路径
rotationMode画面旋转角度
Returns
是否操作成功

◆ start()

LVPlayerCode com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.start ( )
inline

开启播放

Returns
是否操作成功

◆ startRecordingContent()

LVPlayerCode com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.startRecordingContent ( String  contentFilePath)
inline

开始录制当前播放内容, 生成MPEG-4格式转存到指定的文件中 需在LVPlayerState#STATE_READY时调用有效

Parameters
contentFilePath文件绝对路径, 文件名后缀必须为.mp4
Returns
是否操作成功

◆ stop()

LVPlayerCode com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.stop ( )
inline

停止播放

Returns
是否操作成功

◆ stopRecordingContent()

LVPlayerCode com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.stopRecordingContent ( )
inline

停止记录播放内容 stop()/release()内部会主动调用该接口, 如已调用以上接口, 则该接口无需再主动调用

Returns
是否操作成功

◆ unlockYuv420pFrame()

LVPlayerCode com.aliyun.iotx.linkvisual.media.player.LVLivePlayer.unlockYuv420pFrame ( )
inline

解除锁定

Returns
是否操作成功