lib32100
1.0.0
实现许多 P2P 摄像机使用的端口 32100 UDP 云协议的库。您可以在 wiki 中找到该协议的描述
npm install --save lib32100
需要图书馆
const lib32100 = require ( 'lib32100' )
实例化一个客户端
const client = lib32100 . client ( )
请注意,每个客户端可以处理一台设备(相机)和多个云服务器。
添加服务器
client . addServer ( { host : "myserver.example.com" , port : 32100 } )
设置设备UID
client . setUid ( 'PROD123456ABCDE' )
添加监听器
client . on ( 'stun' , ( e ) => console . log ( JSON . stringify ( e ) ) )
client . on ( 'lookup' , ( e ) => console . log ( JSON . stringify ( e ) ) )
向云服务器发送命令
client . sendSTUNRequest ( )
client . lookupUid ( )
添加相机地址
client . addCamAddress ( { host : "192.168.0.100" , port : 10088 } )
设置相机凭据
client . setCamCredentials ( { user : 'admin' , pass : 'password' } )
打开直接相机会话
client . openDirectCamSession ( { host : "192.168.0.100" , port : 10088 } )
检查凭据
client . checkCredentials ( )
获取快照
client . getSnapshot ( )
发送自定义 GET 请求
client . sendGet ( '/custom_url.cgi?myparam=hello' )
发送多个 GET 请求
client . sendMultipleGet ( [ '/custom_url1.cgi' , '/custom_url2.cgi' , '/custom_url3.cgi' ] )
获取实时视频流
client . getVideoStream ( )
获取实时音频流
client . getAudioStream ( )
停止视频流
client . stopVideoStream ( )
停止音频流
client . stopAudioStream ( )
获取各种信息
client . getParams ( )
client . getCameraParams ( )
client . getFactoryParam ( )
client . getStatus ( )
client . cameraControl ( )
client . getMisc ( )
client . login ( )
client . getRtsp ( )
client . getOnvif ( )
client . getRecord ( )
client . wifiScan ( )
client . getWifiScanResult ( )
按步骤方向移动
client . stepDown ( )
client . stepLeft ( )
client . stepRight ( )
client . stepUp ( )
朝方向移动
client . moveDown ( )
client . moveLeft ( )
client . moveRight ( )
client . moveUp ( )
client . stopMove ( )
结束会议
client . closeCamSession ( )
您可以监听以下事件:
stun (server response)
lookup (server response)
lookupACK (server response)
unknownMsg (any message not yet parsable by the library)
pingpong (camera ping or pong)
close (camera closed session)
confirmed (camera comfirmed ID i.e. session opened)
ack (camera acked a message)
http (an http response)
audio (live audio data)
video (live video data)
complete (a complete http response)
lostConnection (the connection was lost)
此实现并非基于官方规范,而是纯粹基于协议的逆向工程。我不能保证它适用于所有设备。
麻省理工学院。版权所有 (c) Fabrizio Bertone