Skip to content

Commit

Permalink
[release] v3.1.4
Browse files Browse the repository at this point in the history
- hot-fix: preserve width and height of both main and sub stream
  • Loading branch information
cedricve committed Jan 10, 2024
1 parent 9339ae3 commit 83ba7ba
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 40 deletions.
12 changes: 10 additions & 2 deletions machinery/src/capture/Gortsplib.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,10 +497,18 @@ func (g *Golibrtsp) Start(ctx context.Context, streamType string, queue *packets
if errSPS == nil {
// Get width
g.Streams[g.VideoH264Index].Width = sps.Width()
configuration.Config.Capture.IPCamera.Width = sps.Width()
if streamType == "main" {
configuration.Config.Capture.IPCamera.Width = sps.Width()
} else if streamType == "sub" {
configuration.Config.Capture.IPCamera.SubWidth = sps.Width()
}
// Get height
g.Streams[g.VideoH264Index].Height = sps.Height()
configuration.Config.Capture.IPCamera.Height = sps.Height()
if streamType == "main" {
configuration.Config.Capture.IPCamera.Height = sps.Height()
} else if streamType == "sub" {
configuration.Config.Capture.IPCamera.SubHeight = sps.Height()
}
// Get FPS
g.Streams[g.VideoH264Index].FPS = sps.FPS()
g.VideoH264Forma.SPS = nalu
Expand Down
38 changes: 2 additions & 36 deletions machinery/src/components/Kerberos.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,42 +206,8 @@ func RunAgent(configDirectory string, configuration *models.Configuration, commu
height := videoSubStream.Height

// Set config values as well
configuration.Config.Capture.IPCamera.Width = width
configuration.Config.Capture.IPCamera.Height = height
}

if cameraSettings.RTSP != rtspUrl ||
cameraSettings.SubRTSP != subRtspUrl ||
cameraSettings.Width != width ||
cameraSettings.Height != height {

// TODO: this condition is used to reset the decoder when the camera settings change.
// The main idea is that you only set the decoder once, and then reuse it on each restart (no new memory allocation).
// However the stream settings of the camera might have been changed, and so the decoder might need to be reloaded.
// .... Not used for the moment ....

if cameraSettings.RTSP != "" && cameraSettings.SubRTSP != "" && cameraSettings.Initialized {
//decoder.Close()
//if subStreamEnabled {
// subDecoder.Close()
//}
}

// At some routines we will need to decode the image.
// Make sure its properly locked as we only have a single decoder.
log.Log.Info("components.Kerberos.RunAgent(): camera settings changed, reloading decoder")
//capture.GetVideoDecoder(decoder, streams)
//if subStreamEnabled {
// capture.GetVideoDecoder(subDecoder, subStreams)
//}

cameraSettings.RTSP = rtspUrl
cameraSettings.SubRTSP = subRtspUrl
cameraSettings.Width = width
cameraSettings.Height = height
cameraSettings.Initialized = true
} else {
log.Log.Info("components.Kerberos.RunAgent(): camera settings did not change, keeping decoder")
configuration.Config.Capture.IPCamera.SubWidth = width
configuration.Config.Capture.IPCamera.SubHeight = height
}

// We are creating a queue to store the RTSP frames in, these frames will be
Expand Down
5 changes: 4 additions & 1 deletion machinery/src/models/Config.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,14 @@ type Capture struct {
// IPCamera configuration, such as the RTSP url of the IPCamera and the FPS.
// Also includes ONVIF integration
type IPCamera struct {
RTSP string `json:"rtsp"`
Width int `json:"width"`
Height int `json:"height"`
FPS string `json:"fps"`
RTSP string `json:"rtsp"`
SubRTSP string `json:"sub_rtsp"`
SubWidth int `json:"sub_width"`
SubHeight int `json:"sub_height"`
SubFPS string `json:"sub_fps"`
ONVIF string `json:"onvif,omitempty" bson:"onvif"`
ONVIFXAddr string `json:"onvif_xaddr" bson:"onvif_xaddr"`
ONVIFUsername string `json:"onvif_username" bson:"onvif_username"`
Expand Down
7 changes: 7 additions & 0 deletions machinery/src/routers/mqtt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,13 @@ func HandleRequestConfig(mqttClient mqtt.Client, hubKey string, payload models.P
// Copy the config, as we don't want to share the encryption part.
deepCopy := configuration.Config

// We need a fix for the width and height if a substream.
// The ROI requires the width and height of the sub stream.
if configuration.Config.Capture.IPCamera.SubRTSP != "" {
deepCopy.Capture.IPCamera.Width = configuration.Config.Capture.IPCamera.SubWidth
deepCopy.Capture.IPCamera.Height = configuration.Config.Capture.IPCamera.SubHeight
}

var configMap map[string]interface{}
inrec, _ := json.Marshal(deepCopy)
json.Unmarshal(inrec, &configMap)
Expand Down
2 changes: 1 addition & 1 deletion ui/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class App extends React.Component {
</div>
)}
<div id="page-root">
<Sidebar logo={logo} title="Kerberos Agent" version="v3.1.3" mobile>
<Sidebar logo={logo} title="Kerberos Agent" version="v3.1.5" mobile>
<Profilebar
username={username}
email="[email protected]"
Expand Down

0 comments on commit 83ba7ba

Please sign in to comment.