The national standard GB28181 protocol video platform EasyGBS can be cascaded through the GB28181 protocol. In addition to cascading with video platforms such as Hikvision and Univision, it can also be cascaded with the developer’s own video platform ( How EasyGBS achieves the superior video streaming United ).
The EasyGBS video platform can also be cascaded to the voice of the upper-level platform, but during the test of the cascading voice, we found that the upper-level voice was normal for the first time, but the voice sent after the second time was the previous voice.
So we analyze the cause of the problem by capturing packets, and we can see from the packet capture results that the first and second audios are consistent.
But when the audio is collected for the second time, the upper-level platform sends the newly collected audio, while the lower-level platform sends the last audio to the device.
The investigation code found that because each established udp link is read in a buffered buf array, and the udp monitoring link is not closed, it will cause data confusion and send the last data.
case audioOnOff := <-Server.UacAudioOnOff[key]:
if dataConn != nil {
Server.UacAudioUdpConn[key] = nil
bufUDP := make([]byte, 102400)
//err := dataConn.SetReadDeadline(time.Now().Add(time.Second * 5))
//if err != nil {
// Server.UacAudioUdpConn[key].Close()
// log.Println("超时处理")
// return
//}
time.Sleep(time.Second * 1)
for audioOnOff {
n, _, err := dataConn.ReadFromUDP(bufUDP)
if err != nil {
//Server.UacAudioUdpConn[key].Close()
log.Printf("udp read error, %v", err)
continue
}
rtpBuf := make([]byte, n)
copy(rtpBuf, bufUDP[:n])
tempint, err := transportMS.UDPConn.Write(rtpBuf)
if err != nil {
log.Printf("发送rtperr : %s ,tempint :%d", err, tempint)
return
}
time.Sleep(80 * time.Millisecond)
log.Println("发送tempint", tempint)
}
}
Need to add the following code
Server.UacAudioUdpConn[key] = nil
Every time a udp connection is obtained, leave the link used this time blank:
case audioOnOff := <-Server.UacAudioOnOff[key]:
if dataConn != nil {
Server.UacAudioUdpConn[key] = nil
bufUDP := make([]byte, 102400)
//err := dataConn.SetReadDeadline(time.Now().Add(time.Second * 5))
//if err != nil {
// Server.UacAudioUdpConn[key].Close()
// log.Println("超时处理")
// return
//}
time.Sleep(time.Second * 1)
for audioOnOff {
n, _, err := dataConn.ReadFromUDP(bufUDP)
if err != nil {
//Server.UacAudioUdpConn[key].Close()
log.Printf("udp read error, %v", err)
continue
}
rtpBuf := make([]byte, n)
copy(rtpBuf, bufUDP[:n])
tempint, err := transportMS.UDPConn.Write(rtpBuf)
if err != nil {
log.Printf("发送rtperr : %s ,tempint :%d", err, tempint)
return
}
time.Sleep(80 * time.Millisecond)
log.Println("发送tempint", tempint)
}
}
If it is used again, the voice sent each time is the same as the voice sent by the superior.
Note: When the camera device supports voice, it can receive voice through EasyGBS cascade, and the camera device cannot receive voice if it does not support voice.
The EasyGBS video platform can support pan-tilt control, create an intelligent network based on dynamic networking services, select network members that need networking to achieve point-to-point interconnection, and can provide multiple stream outputs, including RTSP, RTMP, HTTP-FLV, HLS, etc. Multiple protocol streams, users can choose the appropriate video stream according to their own project requirements.
In addition to EasyGBS, TSINGSEE Qingxi Video also has other video solutions, such as EasyNVR that supports RTSP protocol, and EasyDSS video platform that supports RTMP protocol. For more video-related solutions, please contact us for more information.