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