Control stream using SNMP - Openwide-Ingenierie/openvivoe GitHub Wiki
Simple Network Management Protocol
OpenVivoe uses SNMPv2 to control it streams. SNMP is based on the idea that a network will contain an manager and managed devices. Each managed device will keep updated a data base: the Management Information Base (or MIB), that contains relevant information. The manager can then query each managed device using SNMP requests such as :
- GET request: to get information from the MIB
- SET request: to set information in the MIB
An managed device should run a SNMP Agent to be able to respond to the manager's requests. It can also send Trap notification messages to the manager, if a unexpected error occurs.
This is the protocol used in OpenVivoe to control the streams. In addition, in OpenVivoe there are 4 different kinds of devices:
- Service Providers ( devices that have cameras connected)
- Service Users (devices that have screens connected)
- Both (devices that have both camera(s) and screen(s) connected)
- The manager (the device that will control others trough SNMP)
Service Providers are used to send stream through multicast, Service User are used to receive streams from multicast groups, and device labelled as "Both" can both stream and receive streams. The manager is the device that will command managed devices to start/stop streaming, that will specify to Service User the multicast group they should listen to.
Let's image this scenario: you have three devices:
- device 1: with a webcam, with IP: 192.168.1.1
- device 2: with a screen, with IP: 192.168.1.2
- device 3: A manager
You have configured vivoe-mibs.conf
to have device in normal Mode: deviceMode=1
Thus, you should have this configuration files:
For the device 1 :
`[deviceInfo]
deviceUserDesc=device1
deviceType=1
deviceMode=1
[source_1]
gst_source=v4l2src device=/dev/video0 ! capsfilter caps="video/x-raw,width=1920,height=1080,interlace-mode=(string)progressive,framerate=(fraction)30/1" ! avenc_mpeg4`
For the device 2 :
[deviceInfo]
deviceUserDesc=device2
deviceType=2
deviceMode=1
[receiver_1]
gst_sink=avdec_mpeg4 ! xvimagesink
Then, once OpenVivoe is launched on both devices 1 and 2. We can launched the stream thanks to device 3, the manager. Start the streaming from device 1.
snmpset -c private -v 2c 192.168.1.1 channelStatus.1 i 1
Thus device 1 will start streaming to the multicast group: 239.192.1.1
On device 2, to start listening to the device 1's streaming:
snmpset -c private -v 2c 192.168.1.2 channelReceiveIpAddress.1 i 1
And to strat desplaying the stream:
snmpset -c private -v 2c 192.168.1.2 channelStatus.1 i 1
You should see your stream from device 1 appearing on device 2' screen!
Now: here are the list of useful command to retrieve information from the MIBs of both devices:
To get the content of device 1's device User Desc :
snmpget -c public -v 2c 192.168.1.1 deviceUserDesc
To set deviceUserDesc parameter of device 2 :
snmpset -c private -v 2c 192.168.1.2 deviceMode i 3
First set device in Maintenance Mode, and then:
snmpset -c private -v 2c 192.168.1.2 deviceUserDesc s "new description for device 2"
To get the content of the video format table of the device 1 :
snmpwalk -c public -v 2c 192.168.1.1 videoFormatTable
To get the content of the channel table of device 2 :
snmpwalk -c public -v 2c 192.168.1.2 channelTable
To get only the second line of the ethernet interface table of device 2 (ethernetIfTable):
snmpget -c public -v 2c 192.168.1.2 ethernetIfTable.2