Skip to content

07 智能摄像机模块

Xiaomi-Yule edited this page Apr 9, 2021 · 3 revisions

miot/service/miotcamera

摄像机 API

Export: public
Doc_name: 智能摄像机模块
Doc_index: 7
Doc_directory: service


miot/service/miotcamera~IMiotCamera

Kind: inner class of miot/service/miotcamera
Export:


iMiotCamera.connectToDeviceWithStateChangeCallBack(callbackName)

连接设备

Kind: instance method of IMiotCamera

Param Type Description
callbackName string 链接状态变更回调 { state: MISSConnectState, error: MISSError }

iMiotCamera.disconnectToDevice()

断开连接设备

Kind: instance method of IMiotCamera
Since: 10033


iMiotCamera.sendP2PCommandToDevice(command, paramsJson) ⇒ [ 'Promise' ].<number>

发送miss命令到设备

Kind: instance method of IMiotCamera
Returns: [ 'Promise' ].<number> - a promise with return code

Param Type Description
command MISSCommand miss 命令
paramsJson object 参数 要求是符合jsonObj形式的数据

iMiotCamera.sendP2PCommandToDeviceWithStringParam(command, paramStr) ⇒ [ 'Promise' ].<number>

发送miss命令到设备 主要处理部分model发送命令的参数不是json格式,也不是 byte数组编码得到的str,而是普通的字串

Kind: instance method of IMiotCamera
Returns: [ 'Promise' ].<number> - a promise with return code

Param Type Description
command MISSCommand miss 命令 如果是tutk,米家标准的命令号要转为用Miss的命令号,如果是自定义命令 直接发送
paramStr string 参数: string参数,非json 非 base64

iMiotCamera.sendP2PCommandToDeviceWithBase64Param(command, base64Param) ⇒ [ 'Promise' ].<number>

发送miss命令到设备 主要处理部分model发送命令的参数不是json格式,而是byte数组形式的命令。 byte数组请用base64编码得到string再调用这个接口。

Kind: instance method of IMiotCamera
Returns: [ 'Promise' ].<number> - a promise with return code
Warn: miss固件 android端不支持直接发送byte[],此时调用该接口会直接返回错误。

Param Type Description
command MISSCommand miss 命令 如果是tutk,米家标准的命令号要转为用Miss的命令号,如果是自定义命令 直接发送
base64Param string 参数: byte[]数组base64 encode后的字串

iMiotCamera.bindP2PCommandReceiveCallback(callbackName)

注册接收命令回调

Kind: instance method of IMiotCamera

Param Type Description
callbackName string 收到p2p command回调 { command: MISSCommand, data: Object/Base64String }

iMiotCamera.sendRDTJSONCommandToDevice(params) ⇒ [ 'Promise' ].<number>

发送RDT命令到设备

Kind: instance method of IMiotCamera
Returns: [ 'Promise' ].<number> - a promise with return code

Param Type Description
params object json data

iMiotCamera.sendRDTCommandToDevice(params) ⇒ [ 'Promise' ].<number>

发送RDT命令到设备

Kind: instance method of IMiotCamera
Returns: [ 'Promise' ].<number> - a promise with return code

Param Type Description
params string base64 encoded data

iMiotCamera.bindRDTDataReceiveCallback(callbackName)

注册接收RDT命令回调

Kind: instance method of IMiotCamera

Param Type Description
callbackName string 收到RDT回调 { data: Object/Base64String }

iMiotCamera.showAlarmVideos(isNewPlugin, localRecognizeEvents)

打开报警视频页面 这个接口按照现有的标准报警视频交互,报警视频列表页筛选项默认有:全部、物体移动、人性移动、AI;如果是vip用户,就再加上人脸、宝宝哭声这两个筛选项; 这里添加这个localRecognizeEvents的目的是:主要处理,部分model不是vip,也会有宝宝哭声的筛选项,这个参数的作用:用户如果不是vip,但是又有默认选项之外的筛选项时,通过这个参数来添加人脸或者宝宝哭声的选项。

现在除创米021那几款摄像头,都只传0就行了

Kind: instance method of IMiotCamera
Updated: 10047
Since: 10033

Param Type Default Description
isNewPlugin bool false 是否是新固件
localRecognizeEvents number AlarmEventType 里 几个筛选项的或值。 isNewPlugin = false的情况下,兼容以前的逻辑,非vip会读localRecognizeEvents变量里是否有宝宝哭声和人脸识别选项,有就展示 vip则包含所有的筛选项 isNewPlugin = true时,localRecognizeEvents的含义:js端由该变量控制显示哪些筛选项,例如v3设备: 非vip localRecognizeEvents= EventType_All

iMiotCamera.showPlaybackVideos(jsonobj)

打开回看页面

Kind: instance method of IMiotCamera
Since: 10048

Param Type Default Description
jsonobj data >str,包含打开回看需要的sdcardStatus, isVip等信息

Example

data = {sdcardGetSuccess: true, sdcardStatus: 0, isVip: false}
        Service.miotcamera.showPlaybackVideos(JSON.stringify(data));

iMiotCamera.showAlbum(jsonobj)

打开相册

Kind: instance method of IMiotCamera
Since: 10051

Param Type Default
jsonobj data >str,预留

Example

data = {};
        Service.miotcamera.showPlaybackVideos(JSON.stringify(data));

iMiotCamera.showLastAlbumMediaFile(jsonobj)

打开设备相册中最新的图片或视频

Kind: instance method of IMiotCamera
Since: 10051

Param Type Default
jsonobj data >str,包含albumName等信息

Example

data = { albumName: albumName};
        Service.miotcamera.showLastAlbumMediaFile(JSON.stringify(data));

iMiotCamera.getAlbumName()

获取设备对应的相册名字

Kind: instance method of IMiotCamera
Since: 10051


iMiotCamera.showCloudStorage(supportHevc, 是否使用, 默認參數, @since)

打开云储存页面

Kind: instance method of IMiotCamera
Since: 10033

Param Type Description
supportHevc BOOL 是否支持 H265
是否使用 useV2API V2 接口
默認參數 did did
@since cloudStoragePurchaseUrl 10051 默認爲空,兼容以前的邏輯,不是vip就打開攝像頭的雲存購買連接;如果是低功耗設備,需要自己填入雲存購買連接。

iMiotCamera.showCloudStorageSetting()

打开云储存设置页面

Kind: instance method of IMiotCamera
Since: 10033


iMiotCamera.openAlarmVideoPlayer(data)

打开报警视频播放页面

Kind: instance method of IMiotCamera
Since: 10037

Param Description
data jsonobj=>str 从push点击跳转进来后,如果是smartscene 就把extra字段捞出来放到这里

iMiotCamera.loadMonitoringDetail(model, did) ⇒

Kind: instance method of IMiotCamera
Returns: true, 最新报警视频的时间和事件描述字符串;false,错误描述
Since: 10047

Param
model
did

iMiotCamera.showFaceRecognize(isVip)

打开人脸识别页面

Kind: instance method of IMiotCamera
Since: 10033

Param Type
isVip BOOL

iMiotCamera.bindBPSReceiveCallback(callbackName)

注册收到数据速率 Bytes per second,每秒回调一次

Kind: instance method of IMiotCamera
Since: 10036

Param Type Description
callbackName string 回调名称 { rate: number }

iMiotCamera.ffmpegCommand(command, callback, complete)

执行FFmpeg命令

Kind: instance method of IMiotCamera

Param Type Description
command object string
callback String string
complete Block (eror) =>

iMiotCamera.downloadM3U8ToMP4(fileId, filePath, callbackName, isAlarm, videoCodec) ⇒

下载m3u8视频并合成mp4

Kind: instance method of IMiotCamera
Returns: state : 1. onStart (开始下载) 2. onComplete(下载完成) 3. onError(失败) 4. onProgress(下载进度) errorInfo : 失败描述(state = onError时才有) progress : 下载进度0 - 100 (state = onProgress时才有)
Since: 10038

Param Default Description
fileId
filePath
callbackName
isAlarm false 是否报警视频
videoCodec H265 视频编码如 "H264", "H265"

iMiotCamera.getVideoFileUrl(fileId, isAlarm, videoCodec)

获取报警视频m3u8播放地址

Kind: instance method of IMiotCamera
Since: 10037

Param Description
fileId 视频fileId
isAlarm 是否报警视频
videoCodec 视频编码如 "H264", "H265"

iMiotCamera.getFileIdImage(imgStoreId) ⇒ [ 'Promise' ].<String>

获取视频缩略图片接口(如报警视频列表缩略图)

Kind: instance method of IMiotCamera
Returns: [ 'Promise' ].<String> - 文件路径
Since: 10037

Param Type Description
imgStoreId string 图片id

iMiotCamera.getFaceImgWithDid(faceId) ⇒ [ 'Promise' ].<String>

获取人脸图片接口

Kind: instance method of IMiotCamera
Returns: [ 'Promise' ].<String> - 文件路径
Since: 10040

Param Type Description
faceId string 人脸id

iMiotCamera.getCommonImgWithParams(imgId, hostParams, pathParams) ⇒ [ 'Promise' ].<String>

获取通用图片接口(如云存储视频缩略图)

Kind: instance method of IMiotCamera
Returns: [ 'Promise' ].<String> - 文件路径
Since: 10041

Param Type Description
imgId string 图片唯一标识ID 如imgStoreId
hostParams string json字符串,接口信息: 如获取云存储缩略图{"prefix":"business.smartcamera.", "method":"GET", "path":"/miot/camera/app/v1/img"} 注:key固定的
pathParams string json字符串,请求参数: 如获取云存储缩略图{"did":"xxxx", "fileId":"xxxx", "stoId":"xxxxxxxx"}

iMiotCamera.setTimelinePlaybackMode(isTimelinePlayback) ⇒ null

通知native端现在是不是回看时间轴模式

Kind: instance method of IMiotCamera
Since: 10038

Param Type Description
isTimelinePlayback boolean 是不是回看时间轴模式

iMiotCamera.bindTimelinePlaybackEndListener(timelinePlaybackEndListenerName) ⇒ null

绑定回调,native端 在时间轴回看的模式下,如果从点播切换成直播了,就通过这个回调告诉js端

Kind: instance method of IMiotCamera
Since: 10038

Param Type Description
timelinePlaybackEndListenerName string native端在回看时间轴模式下,从点播切换成直播了,通过DeviceEmitter发送这个时间给js端

iMiotCamera.getCurrentSpeakerVolumn()

获取当前语音对讲过程中的音量大小

Kind: instance method of IMiotCamera
Since: 10038 return {promise}


iMiotCamera.setCurrentDeviceIsMissFirmware(boolean)

设置当前model是不是miss固件

Kind: instance method of IMiotCamera
Since: 10038

Param Description
boolean isMissFirmware 是否是miss固件,true 是; false tutk固件。

iMiotCamera.showNASSetting()

打开摄像机NAS存储设置页面。

Kind: instance method of IMiotCamera
Since: 10038


iMiotCamera.openFloatWindow()

开启悬浮窗模式

Kind: instance method of IMiotCamera
Since: 10039


iMiotCamera.closeFloatWindow()

关闭悬浮窗

Kind: instance method of IMiotCamera
Since: 10040


iMiotCamera.tryBindAlarmNotifyWithWechatMijia()

绑定摄像头的报警视频到微信米家公众号里,有报警视频推送到微信公共号

Kind: instance method of IMiotCamera
Since: 10040


iMiotCamera.queryDevicePassword(did)

查询设备的pipUid和password,提供给部分model进行固件交互 仅仅允许华来部分model使用,其他model访问会得到一个错误。 resolve返回的值即为服务器返回的json字串。

Kind: instance method of IMiotCamera
Since: 10041

Param Description
did 设备did

iMiotCamera.setCurrentDeviceUseFixedUid(isUseFixedUid, did)

设置当前设备为直连模式,使用固定的uid 和 password连接设备,目前只有华来的小方设备使用到了该功能。 切换直连为非直连模式,需要断开原有连接,设置该接口为false,重新连接设备。 先设置是否是miss固件,在调用连接前设置该接口。

Kind: instance method of IMiotCamera
Since: 10047

Param Description
isUseFixedUid 是否使用直连模式, 默认false
did 设备did

iMiotCamera.decryptBigFile(fileData, nonce, shareKey)

使用chacha20_xor解密大文件

Kind: instance method of IMiotCamera
Since: 10041

Param Type Description
fileData string byte array encoded into string 待解密的文件体
nonce * byte array encoded into string chacha20_xor解密需要的nonce
shareKey * byte array encoded into string chacha20_xor解密需要的sharekey

iMiotCamera.decryptSmallFile(fileData, nonce, shareKey)

使用chacha20_xor解密小文件

Kind: instance method of IMiotCamera
Since: 10041

Param Type Description
fileData string byte array base64 encoded into string 待解密的文件体
nonce string byte array base64 encoded into string chacha20_xor解密需要的nonce
shareKey string byte array base64 encoded into string chacha20_xor解密需要的sharekey

iMiotCamera.markCurrentDeviceUseHualaiEncrypted(isEncrypted, did)

标记当前是否使用华来的音视频解密方案,只对tutk生效,需要在连接成功之后,收到视频流之前调用

Kind: instance method of IMiotCamera
Since: 10042

Param Type
isEncrypted bool
did string

iMiotCamera.setCurrentDeviceUseFixedRdtChannel(useFixedRdtChannel, did)

在连接成功后,发送rdt命令前调用,标记当前设备是否使用固定rdtChannel方案。

Kind: instance method of IMiotCamera
Since: 10042

Param Type
useFixedRdtChannel bool
did string

iMiotCamera.setUseIjkDecoderGlobal(isEnableIjk, did)

设置开启/关闭ijk解码。

Kind: instance method of IMiotCamera
Since: 10043

Param Type Description
isEnableIjk bool 是否开启ijk 一启用,所有的设备都会被启用。
did string

iMiotCamera.setCurrrentVoiceChangerType(simpleRate, type, channel, did)

设置speaker变声类型, 初次设置会触发初始化,后续simpleRate or channel发生改变 都不会触发初始化。

Kind: instance method of IMiotCamera

Param Type Default Description
simpleRate int 音频采样率 与CameraRenderView里定义的MISSSampleRate一致
type int 变声类型,目前米家只提供 0 == 正常 1 == 小丑 2 == 大叔这三种类型
channel int 1 单双通道 1 单声道, 2 立体声 默认为1
did string

iMiotCamera.showScreenLinkagePage(isMultiChoice, screenCount, did)

打开门铃的带屏设备联动页面

Kind: instance method of IMiotCamera
Since: 10044

Param Type
isMultiChoice bool
screenCount number
did string

iMiotCamera.openCloudSettingDownloadListPage(did)

打开云存下载列表页面

Kind: instance method of IMiotCamera
Since: 10046

Param Type
did string

iMiotCamera.downloadCloudVideoIntoCloudSetting(did, fileId, isAlarmFile, startTime, duration, register, thumbId)

下载云存视频到 云存管理-》下载列表里 promise仅仅代表提交任务时是否成功; 监听任务状态 需要通过EventEmitter监听 cloudVideoDownloadProgressCallbackName

EventEmitter里返回的数据解释: status: 0 下载错误 1 开始下载 2 停止下载 3 下载结束 4 下载取消 (Android端目前仅有onFinish回调 status:3) errorCode:错误码 0代表无错误。 fileId:当前哪个fileId 对应的视频下载状态

Kind: instance method of IMiotCamera
Since: 10047

Param Type Default Description
did *
fileId * 视频的fileId
isAlarmFile * 是否是报警视频(短视频 true)/云存视频(长视频 false)
startTime * 视频的开始时间
duration * 视频的duration,通过播放器返回的时长或者其他方式获取到
register * true true时 native 层会监听下载状态并发送cloudVideoDownloadProgressCallbackName, false时取消监听并停止发送
thumbId * 视频缩略图id

iMiotCamera.downloadCloudVideoMp4(did, fileId, stoId)

下载mp4类型的云存视频

Kind: instance method of IMiotCamera
Since: 10047

Param Type Description
did string 设备did
fileId string 从服务端拿到的fileId
stoId string 从服务器端拿到的stoId

iMiotCamera.convertG711VideoIntoAACVideo(filePath, audioParam)

将携带g711音频的mp4视频 转换成 aac音频的mp4视频,返回resolve的情况下,filepath对应的文件被替换成aac mp4文件了。

Kind: instance method of IMiotCamera
Since: 10047

Param Type Description
filePath string 必须是以Host.file.storageBasePath 作为前缀开始传入。
audioParam object {sampleRate:MISSSampleRate.FLAG_AUDIO_SAMPLE_8K, channel:MISSAudioChannel.FLAG_AUDIO_CHANNEL_MONO, bitRate:MISSAudioBitRate.FLAG_AUDIO_BIT_RATE_16K}

iMiotCamera.reactNativeVideoScreenShot(viewRef, imagePath) ⇒ [ 'Promise' ].<string>

react-native-video 截屏,用来截video标签里video控件的内容

Kind: instance method of IMiotCamera
Returns: [ 'Promise' ].<string> - 成功时:{"code":xxxx} 失败时:{"code":xxx, "message":"xxx" }
Since: 10049

Param Type Description
viewRef number scrollView的引用
imagePath string 存储图片的位置,必须以Host.file.baseStoragePath开始,再加上文件存储名

Example

let findNodeHandle = require('findNodeHandle');
 let reactNativeVideo = findNodeHandle(this.refs.reactNativeVideo);
 Service.miotcamera.reactNativeVideoScreenShot(reactNativeVideo, Host.file.storageBasePath + '/test2.png').then(result=>{
     console.log(result);
 });

 

iMiotCamera.convertH26xVideoIntoMp4(paramsJson, videoPath, videoType, aacAudioPath, targetPath, fps, videoWidth, videoHeight)

Kind: instance method of IMiotCamera
Since: 10050

Param Type Description
paramsJson 包含如下参数:
videoPath string h264 或者h265的源文件绝对路径 必须以Host.file.storageBasePath开始
videoType CameraRenderView.MISSCodec 视频源文件的路径 MISSCodec里定义的h264 或者h265
aacAudioPath string aac 的源文件路径 没有就填写 "" 有值时必须以Host.file.storageBasePath开始, 音频文件只支持aac格式
targetPath string 最终的输出文件目录 同上,必须以Host.file.storageBasePath开始 以下参数只用于ios
fps int
videoWidth int
videoHeight int Android json demo: {"videoPath":vPath, "videoType": vType, "aacAudioPath": aacAPath, "targetPath": tPath} IOS json demo: {"videoPath":vPath, "videoType": vType, "aacAudioPath": aacAPath, "targetPath": tPath, "fps": fps, "videoWidth": vWidth, "videoHeight": vHeight}

miot/service/miotcamera~MISSCommand : object

MISS 命令

Kind: inner namespace of miot/service/miotcamera


MISSCommand.MISS_CMD_VIDEO_STOP

< C->S, video start

Kind: static property of MISSCommand


MISSCommand.MISS_CMD_AUDIO_START

< C->S, video stop

Kind: static property of MISSCommand


MISSCommand.MISS_CMD_AUDIO_STOP

< C->S, audio start

Kind: static property of MISSCommand


MISSCommand.MISS_CMD_SPEAKER_START_REQ

< C->S, audio stop

Kind: static property of MISSCommand


MISSCommand.MISS_CMD_SPEAKER_START_RESP

< C->S, speaker start req

Kind: static property of MISSCommand


MISSCommand.MISS_CMD_SPEAKER_STOP

< C->S, speaker start resp

Kind: static property of MISSCommand


MISSCommand.MISS_CMD_STREAM_CTRL_REQ

< C->S, speaker stop

Kind: static property of MISSCommand


MISSCommand.MISS_CMD_STREAM_CTRL_RESP

< C->S, video quality req

Kind: static property of MISSCommand


MISSCommand.MISS_CMD_GET_AUDIO_FORMAT_REQ

< S->C, video quality response

Kind: static property of MISSCommand


MISSCommand.MISS_CMD_GET_AUDIO_FORMAT_RESP

< C->S, get audio format

Kind: static property of MISSCommand


MISSCommand.MISS_CMD_PLAYBACK_REQ

< S->C, audio format response

Kind: static property of MISSCommand


MISSCommand.MISS_CMD_PLAYBACK_RESP

< C->S, playback request

Kind: static property of MISSCommand


MISSCommand.MISS_CMD_PLAYBACK_SET_SPEED

< S->C, playback response

Kind: static property of MISSCommand


MISSCommand.MISS_CMD_DEVINFO_REQ

< C->S, playback speed

Kind: static property of MISSCommand


MISSCommand.MISS_CMD_DEVINFO_RESP

< C->S, device info request

Kind: static property of MISSCommand


MISSCommand.MISS_CMD_MOTOR_REQ

< S->C, device info response

Kind: static property of MISSCommand


MISSCommand.MISS_CMD_MOTOR_RESP

< C->S, device motor control

Kind: static property of MISSCommand


miot/service/miotcamera~MISSError : object

MISS Error

Kind: inner namespace of miot/service/miotcamera


miot/service/miotcamera~MISSConnectState : object

MISS Connection State

Kind: inner namespace of miot/service/miotcamera


miot/service/miotcamera~AlarmEventType : object

Alarm Event Type

Kind: inner namespace of miot/service/miotcamera


Clone this wiki locally