Package com.zego.zegoavkit2
Class ZegoVideoCaptureClient
- java.lang.Object
-
- com.zego.zegoavkit2.ZegoVideoCaptureClient
-
- All Implemented Interfaces:
ZegoVideoCaptureDevice.Client
public class ZegoVideoCaptureClient extends java.lang.Object implements ZegoVideoCaptureDevice.Client
外部采集代理,用于应用通知 SDK 处理进度与结果。Copyright © 2017 Zego. All rights reserved.
-
-
Constructor Summary
Constructors Constructor Description ZegoVideoCaptureClient()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy()
android.graphics.SurfaceTexture
getSurfaceTexture()
void
onByteBufferFrameCaptured(byte[] data, int size, ZegoVideoCaptureDevice.VideoCaptureFormat frame_format, long reference_time, int reference_time_scale)
void
onByteBufferFrameCaptured(java.nio.ByteBuffer data, int size, ZegoVideoCaptureDevice.VideoCaptureFormat frame_format, long reference_time, int reference_time_scale)
void
onEncodedFrameCaptured(java.nio.ByteBuffer data, int size, ZegoVideoCaptureDevice.VideoCodecConfig config, boolean is_key_frame, double reference_time_ms)
通知SDK采集到编码数据,SDK会切换到内部线程进行发送。void
onTakeSnapshot(android.graphics.Bitmap image)
void
onTextureCaptured(int texture_id, int width, int height, double reference_time_ms)
void
resetTextureContext()
当纹理相关的上下文 (例如 EglContext) 发生变化时,可以调用此函数来清除 SDK 缓存的上下文状态 注意必须和 onTextureCaptured 在同一个线程调用,不保证线程安全void
setFillMode(int mode)
设置填充模式void
setFlipMode(int mode)
设置翻转模式 supportBufferType为PIXEL_BUFFER_TYPE_GL_TEXTURE_2D 时才有效 默认值 ZegoVideoFlipMode.Vertical,如果不需要,设置为Nonevoid
setRotation(int rotation)
设置旋转角度, 用于修正图像的角度; supportBufferType 为 PIXEL_BUFFER_TYPE_GL_TEXTURE_2D 或 PIXEL_BUFFER_TYPE_GL_TEXTURE_EXTERNAL_OES 时才有效。void
setStatusReason(boolean is_closed, int reason)
通知SDK设备状态信息。 DeviceErrorReason.Disabled/DeviceErrorReason.Mute是不能设置的,Disabled通过enableCamera触发的,Mute通过muteVideoPublish触发 初始化外部采集后默认设备状态是好的,用户需要在外部采集通知StartCapture后补一个初始状态,如果前后原因都是属于设备关闭,那么引擎只会通知第一个原因void
setTextureResolution(int width, int height)
同步纹理的宽高void
setTransformMatrix(float[] matrix)
设置变换矩阵; supportBufferType 为 PIXEL_BUFFER_TYPE_GL_TEXTURE_2D 或 PIXEL_BUFFER_TYPE_GL_TEXTURE_EXTERNAL_OES 时才有效。
-
-
-
Method Detail
-
destroy
public void destroy()
- Specified by:
destroy
in interfaceZegoVideoCaptureDevice.Client
-
onByteBufferFrameCaptured
public void onByteBufferFrameCaptured(byte[] data, int size, ZegoVideoCaptureDevice.VideoCaptureFormat frame_format, long reference_time, int reference_time_scale)
- Specified by:
onByteBufferFrameCaptured
in interfaceZegoVideoCaptureDevice.Client
-
onByteBufferFrameCaptured
public void onByteBufferFrameCaptured(java.nio.ByteBuffer data, int size, ZegoVideoCaptureDevice.VideoCaptureFormat frame_format, long reference_time, int reference_time_scale)
- Specified by:
onByteBufferFrameCaptured
in interfaceZegoVideoCaptureDevice.Client
-
onEncodedFrameCaptured
public void onEncodedFrameCaptured(java.nio.ByteBuffer data, int size, ZegoVideoCaptureDevice.VideoCodecConfig config, boolean is_key_frame, double reference_time_ms)
Description copied from interface:ZegoVideoCaptureDevice.Client
通知SDK采集到编码数据,SDK会切换到内部线程进行发送。注意:推荐每 2S 一个 gop,每个 I 帧必须携带 sps 和 pps,且放在最前面。仅接受 I 帧 和 P 帧,不接受 B 帧
- Specified by:
onEncodedFrameCaptured
in interfaceZegoVideoCaptureDevice.Client
- Parameters:
data
- 码流数据,目前只支持 H.264 码流size
- 码流长度config
- 码流的信息,参考ZegoVideoCaptureDevice.VideoCodecConfig
is_key_frame
- 是否为关键帧,建议关键帧间隔在 2S 左右reference_time_ms
- 采集到该帧的时间戳,单位毫秒,不能超过2^52, 用于音画同步,如果采集实现是摄像头,最好使用系统采集回调的原始时间戳,如果不是,最好是生成该帧的UTC时间戳
-
setStatusReason
public void setStatusReason(boolean is_closed, int reason)
Description copied from interface:ZegoVideoCaptureDevice.Client
通知SDK设备状态信息。 DeviceErrorReason.Disabled/DeviceErrorReason.Mute是不能设置的,Disabled通过enableCamera触发的,Mute通过muteVideoPublish触发 初始化外部采集后默认设备状态是好的,用户需要在外部采集通知StartCapture后补一个初始状态,如果前后原因都是属于设备关闭,那么引擎只会通知第一个原因- Specified by:
setStatusReason
in interfaceZegoVideoCaptureDevice.Client
- Parameters:
is_closed
- 当前设备是否处于关闭状态reason
- 错误原因,参考ZegoConstants.DeviceErrorReason
-
onTakeSnapshot
public void onTakeSnapshot(android.graphics.Bitmap image)
- Specified by:
onTakeSnapshot
in interfaceZegoVideoCaptureDevice.Client
-
getSurfaceTexture
public android.graphics.SurfaceTexture getSurfaceTexture()
- Specified by:
getSurfaceTexture
in interfaceZegoVideoCaptureDevice.Client
-
onTextureCaptured
public void onTextureCaptured(int texture_id, int width, int height, double reference_time_ms)
- Specified by:
onTextureCaptured
in interfaceZegoVideoCaptureDevice.Client
-
setFillMode
public void setFillMode(int mode)
Description copied from interface:ZegoVideoCaptureDevice.Client
设置填充模式- Specified by:
setFillMode
in interfaceZegoVideoCaptureDevice.Client
- Parameters:
mode
- 0: 黑边,1:裁剪,2:拉伸
-
setFlipMode
public void setFlipMode(int mode)
Description copied from interface:ZegoVideoCaptureDevice.Client
设置翻转模式 supportBufferType为PIXEL_BUFFER_TYPE_GL_TEXTURE_2D 时才有效 默认值 ZegoVideoFlipMode.Vertical,如果不需要,设置为None- Specified by:
setFlipMode
in interfaceZegoVideoCaptureDevice.Client
- Parameters:
mode
-ZegoVideoCaptureDevice.ZegoVideoFlipMode
-
setTransformMatrix
public void setTransformMatrix(float[] matrix)
Description copied from interface:ZegoVideoCaptureDevice.Client
设置变换矩阵; supportBufferType 为 PIXEL_BUFFER_TYPE_GL_TEXTURE_2D 或 PIXEL_BUFFER_TYPE_GL_TEXTURE_EXTERNAL_OES 时才有效。- Specified by:
setTransformMatrix
in interfaceZegoVideoCaptureDevice.Client
- Parameters:
matrix
- 4x4的变换矩阵。可以包含旋转/翻转/缩放,SDK 会先执行变换,再执行其他操作
-
setRotation
public void setRotation(int rotation)
Description copied from interface:ZegoVideoCaptureDevice.Client
设置旋转角度, 用于修正图像的角度; supportBufferType 为 PIXEL_BUFFER_TYPE_GL_TEXTURE_2D 或 PIXEL_BUFFER_TYPE_GL_TEXTURE_EXTERNAL_OES 时才有效。- Specified by:
setRotation
in interfaceZegoVideoCaptureDevice.Client
- Parameters:
rotation
- 顺时针旋转角度, 角度旋转在矩阵变换后执行,注意不要重复计算 rotation
-
resetTextureContext
public void resetTextureContext()
Description copied from interface:ZegoVideoCaptureDevice.Client
当纹理相关的上下文 (例如 EglContext) 发生变化时,可以调用此函数来清除 SDK 缓存的上下文状态 注意必须和 onTextureCaptured 在同一个线程调用,不保证线程安全- Specified by:
resetTextureContext
in interfaceZegoVideoCaptureDevice.Client
-
setTextureResolution
public void setTextureResolution(int width, int height)
Description copied from interface:ZegoVideoCaptureDevice.Client
同步纹理的宽高- Specified by:
setTextureResolution
in interfaceZegoVideoCaptureDevice.Client
- Parameters:
width
- 纹理宽度height
- 纹理高度 注意该方法为同步接口,为避免造成卡顿,仅当纹理分辨率和编码分辨率不一致时才调用
-
-