mirror of
https://github.com/kerberos-io/agent.git
synced 2026-10-19 17:38:25 +00:00
Add audio files and implement audio handling in ONVIF and backchannel components
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -2,6 +2,7 @@ package components
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"sync/atomic"
|
||||
@@ -297,6 +298,18 @@ func RunAgent(configDirectory string, configuration *models.Configuration, commu
|
||||
communication.HasBackChannel = true
|
||||
go WriteFileToBackChannel(communication, rtspBackChannelClient)
|
||||
}
|
||||
//go onvif.HandleAudioActions(configuration, communication, rtspBackChannelClient)
|
||||
go func() {
|
||||
for action := range communication.HandleAudio {
|
||||
fmt.Println("onvif.HandleAudioActions(): action", action)
|
||||
// Ensure cloud.WriteFileToBackChannel is implemented or replace with a valid function
|
||||
if WriteFileToBackChannel != nil {
|
||||
WriteFileToBackChannel(communication, rtspBackChannelClient)
|
||||
} else {
|
||||
fmt.Println("cloud.WriteFileToBackChannel is not defined")
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
// If we reach this point, we have a working RTSP connection.
|
||||
communication.CameraConnected = true
|
||||
|
||||
@@ -75,7 +75,7 @@ func WriteFileToBackChannel(communication *models.Communication, rtspClient capt
|
||||
sequenceNumber := uint16(0)
|
||||
|
||||
// Do the warmup!
|
||||
file, err := os.Open("./aandacht.wav")
|
||||
file, err := os.Open("./audio/air-raid.wav")
|
||||
if err != nil {
|
||||
fmt.Println("WriteFileToBackChannel: error opening audiofile.bye file")
|
||||
}
|
||||
@@ -94,7 +94,6 @@ func WriteFileToBackChannel(communication *models.Communication, rtspClient capt
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
|
||||
// Encode PCM to MULAW
|
||||
bufferUlaw := g711.EncodeUlaw(buffer)
|
||||
fmt.Println("WriteFileToBackChannel: bufferUlaw", bufferUlaw)
|
||||
|
||||
@@ -166,6 +166,12 @@ func ProcessMotion(motionCursor *packets.QueueCursor, configuration *models.Conf
|
||||
NumberOfChanges: changesToReturn,
|
||||
}
|
||||
communication.HandleMotion <- dataToPass //Save data to the channel
|
||||
|
||||
audioToPass := models.AudioDataPartial{
|
||||
Timestamp: time.Now().Unix(),
|
||||
Data: []int16{},
|
||||
}
|
||||
communication.HandleAudio <- audioToPass //Save data to the channel
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
|
||||
onvifc "github.com/cedricve/go-onvif"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/kerberos-io/agent/machinery/src/capture"
|
||||
"github.com/kerberos-io/agent/machinery/src/log"
|
||||
"github.com/kerberos-io/agent/machinery/src/models"
|
||||
"github.com/kerberos-io/onvif"
|
||||
@@ -189,6 +190,16 @@ func HandleONVIFActions(configuration *models.Configuration, communication *mode
|
||||
log.Log.Debug("onvif.HandleONVIFActions(): finished")
|
||||
}
|
||||
|
||||
func HandleAudioActions(configuration *models.Configuration, communication *models.Communication, backchannel capture.RTSPClient) {
|
||||
log.Log.Debug("onvif.HandleAudioActions(): started")
|
||||
|
||||
/*for action := range communication.HandleAudio {
|
||||
fmt.Println("onvif.HandleAudioActions(): action", action)
|
||||
cloud.WriteFileToBackChannel(communication, backchannel)
|
||||
}*/
|
||||
log.Log.Debug("onvif.HandleAudioActions(): finished")
|
||||
}
|
||||
|
||||
func ConnectToOnvifDevice(cameraConfiguration *models.IPCamera) (*onvif.Device, device.GetCapabilitiesResponse, error) {
|
||||
log.Log.Debug("onvif.ConnectToOnvifDevice(): started")
|
||||
dev, err := onvif.NewDevice(onvif.DeviceParams{
|
||||
|
||||
Reference in New Issue
Block a user