Skip to content

Commit

Permalink
disable MQTT message on motion + rework cloud upload (new option Remo…
Browse files Browse the repository at this point in the history
…veAfterUpload) + sidebar
  • Loading branch information
cedricve committed Mar 21, 2023
1 parent d9694ac commit 71cd315
Show file tree
Hide file tree
Showing 27 changed files with 756 additions and 331 deletions.
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,13 @@ Next to attaching the configuration file, it is also possible to override the co
| `AGENT_KEY` | A unique identifier for your Kerberos Agent, this is auto-generated but can be overriden. | "" |
| `AGENT_NAME` | The agent friendly-name. | "agent" |
| `AGENT_TIMEZONE` | Timezone which is used for converting time. | "Africa/Ceuta" |
| `AGENT_REMOVE_AFTER_UPLOAD` | When enabled, recordings uploaded successfully to a storage will be removed from disk. | "true" |
| `AGENT_OFFLINE` | Makes sure no external connection is made. | "false" |
| `AGENT_AUTO_CLEAN` | Cleans up the recordings directory. | "true" |
| `AGENT_AUTO_CLEAN_MAX_SIZE` | If `AUTO_CLEAN` enabled, set the max size of the recordings directory in (MB). | "100" |
| `AGENT_TIME` | Enable the timetable for Kerberos Agent | "false" |
| `AGENT_TIMETABLE` | A (weekly) time table to specify when to make recordings "start1,end1,start2,end2;start1.. | "" |
| `AGENT_REGION_POLYGON` | A single polygon set for motion detection: "x1,y1;x2,y2;x3,y3;... | "" |
| `AGENT_CAPTURE_IPCAMERA_RTSP` | Full-HD RTSP endpoint to the camera you're targetting. | "" |
| `AGENT_CAPTURE_IPCAMERA_SUB_RTSP` | Sub-stream RTSP endpoint used for livestreaming (WebRTC). | "" |
| `AGENT_CAPTURE_IPCAMERA_ONVIF` | Mark as a compliant ONVIF device. | "" |
Expand All @@ -179,23 +183,20 @@ Next to attaching the configuration file, it is also possible to override the co
| `AGENT_CAPTURE_PIXEL_CHANGE` | If `CONTINUOUS` set to `false`, the number of pixel require to change before motion triggers. | "150" |
| `AGENT_CAPTURE_FRAGMENTED` | Set the format of the recorded MP4 to fragmented (suitable for HLS). | "false" |
| `AGENT_CAPTURE_FRAGMENTED_DURATION` | If `AGENT_CAPTURE_FRAGMENTED` set to `true`, define the duration (seconds) of a fragment. | "8" |
| `AGENT_CLOUD` | Store recordings in a Kerberos Hub (s3) or your Kerberos Vault (kstorage). | "s3" |
| `AGENT_HUB_URI` | The Kerberos Hub API, defaults to our Kerberos Hub SAAS. | "https://api.cloud.kerberos.io" |
| `AGENT_HUB_KEY` | The access key linked to your account in Kerberos Hub. | "" |
| `AGENT_HUB_PRIVATE_KEY` | The secret access key linked to your account in Kerberos Hub. | "" |
| `AGENT_HUB_USERNAME` | Your Kerberos Hub username, which owns the above access and secret keys. | "" |
| `AGENT_HUB_SITE` | The site ID of a site you've created in your Kerberos Hub account. | "" |
| `AGENT_HUB_TIME` | Enable the timetable for Kerberos Agent | "false" |
| `AGENT_HUB_TIMETABLE` | A (weekly) time table to specify when to make recordings "start1,end1,start2,end2;start1.. | "" |
| `AGENT_HUB_REGION_POLYGON` | A single polygon set for motion detection: "x1,y1;x2,y2;x3,y3;... | "" |
| `AGENT_MQTT_URI` | A MQTT broker endpoint that is used for bi-directional communication (live view, onvif, etc) | "tcp://mqtt.kerberos.io:1883" |
| `AGENT_MQTT_USERNAME` | Username of the MQTT broker. | "" |
| `AGENT_MQTT_PASSWORD` | Password of the MQTT broker. | "" |
| `AGENT_STUN_URI` | When using WebRTC, you'll need to provide a STUN server. | "stun:turn.kerberos.io:8443" |
| `AGENT_TURN_URI` | When using WebRTC, you'll need to provide a TURN server. | "turn:turn.kerberos.io:8443" |
| `AGENT_TURN_USERNAME` | TURN username used for WebRTC. | "username1" |
| `AGENT_TURN_USERNAME` | TURN username used for WebRTC. | "username1" |0
| `AGENT_TURN_PASSWORD` | TURN password used for WebRTC. | "password1" |
| `AGENT_KERBEROSVAULT_URI` | The Kerberos Vault API url. | "" . |
| `AGENT_CLOUD` | Store recordings in a Kerberos Hub (s3) or your Kerberos Vault (kstorage). | "s3" |
| `AGENT_HUB_URI` | The Kerberos Hub API, defaults to our Kerberos Hub SAAS. | "https://api.cloud.kerberos.io" |
| `AGENT_HUB_KEY` | The access key linked to your account in Kerberos Hub. | "" |
| `AGENT_HUB_PRIVATE_KEY` | The secret access key linked to your account in Kerberos Hub. | "" |
| `AGENT_HUB_USERNAME` | Your Kerberos Hub username, which owns the above access and secret keys. | "" |
| `AGENT_HUB_SITE` | The site ID of a site you've created in your Kerberos Hub account. | "" |
| `AGENT_KERBEROSVAULT_URI` | The Kerberos Vault API url. | "" |
| `AGENT_KERBEROSVAULT_ACCESS_KEY` | The access key of a Kerberos Vault account. | "" |
| `AGENT_KERBEROSVAULT_SECRET_KEY` | The secret key of a Kerberos Vault account. | "" |
| `AGENT_KERBEROSVAULT_PROVIDER` | A Kerberos Vault provider you have created (optional). | "" |
Expand Down
1 change: 1 addition & 0 deletions machinery/data/config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"time": "false",
"offline": "false",
"auto_clean": "true",
"remove_after_upload": "true",
"max_directory_size": 100,
"timezone": "Africa/Ceuta",
"capture": {
Expand Down
29 changes: 15 additions & 14 deletions machinery/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"fmt"
"os"
"time"

Expand All @@ -26,7 +25,7 @@ func main() {
} else {
service := os.Getenv("DATADOG_AGENT_SERVICE")
environment := os.Getenv("DATADOG_AGENT_ENVIRONMENT")
fmt.Println("Starting Datadog Agent with service: " + service + " and environment: " + environment)
log.Log.Info("Starting Datadog Agent with service: " + service + " and environment: " + environment)
rules := []tracer.SamplingRule{tracer.RateRule(1)}
tracer.Start(
tracer.WithSamplingRules(rules),
Expand Down Expand Up @@ -60,25 +59,20 @@ func main() {
case "version":
log.Log.Info("You are currrently running Kerberos Agent " + VERSION)

case "pending-upload":
name := os.Args[2]
fmt.Println(name)

case "discover":
timeout := os.Args[2]
fmt.Println(timeout)
log.Log.Info(timeout)

case "run":
{
name := os.Args[2]
port := os.Args[3]

// Check the folder permissions, it might be that we do not have permissions to write
// recordings, update the configuration or save snapshots.
err := utils.CheckDataDirectoryPermissions()
if err != nil {
log.Log.Fatal(err.Error())
}
// Print Kerberos.io ASCII art
utils.PrintASCIIArt()

// Print the environment variables which include "AGENT_" as prefix.
utils.PrintEnvironmentVariables()

// Read the config on start, and pass it to the other
// function and features. Please note that this might be changed
Expand All @@ -93,6 +87,13 @@ func main() {
// We will override the configuration with the environment variables
components.OverrideWithEnvironmentVariables(&configuration)

// Printing final configuration
utils.PrintConfiguration(&configuration)

// Check the folder permissions, it might be that we do not have permissions to write
// recordings, update the configuration or save snapshots.
utils.CheckDataDirectoryPermissions()

// Set timezone
timezone, _ := time.LoadLocation(configuration.Config.Timezone)
log.Log.Init(timezone)
Expand Down Expand Up @@ -120,6 +121,6 @@ func main() {
routers.StartWebserver(&configuration, &communication)
}
default:
fmt.Println("Sorry I don't understand :(")
log.Log.Error("Main: Sorry I don't understand :(")
}
}
54 changes: 0 additions & 54 deletions machinery/src/capture/IPCamera.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,60 +60,6 @@ func DecodeImage(frame *ffmpeg.VideoFrame, pkt av.Packet, decoder *ffmpeg.VideoD
return img, err
}

func GetStreamInsights(infile av.DemuxCloser, streams []av.CodecData) (int, int, int, int) {
var width, height, fps, gopsize int
for _, stream := range streams {
if stream.Type().IsAudio() {
//astream := stream.(av.AudioCodecData)
} else if stream.Type().IsVideo() {
vstream := stream.(av.VideoCodecData)
width = vstream.Width()
height = vstream.Height()
}
}

loop:
for timeout := time.After(1 * time.Second); ; {
var err error
if _, err = infile.ReadPacket(); err != nil { // sometimes this throws an end of file..
log.Log.Error("HandleStream: " + err.Error())
}
fps++
select {
case <-timeout:
break loop
default:
}
}

gopCounter := 0
start := false
for {
var pkt av.Packet
var err error
if pkt, err = infile.ReadPacket(); err != nil { // sometimes this throws an end of file..
log.Log.Error("HandleStream: " + err.Error())
}
// Could be that a decode is throwing errors.
if len(pkt.Data) > 0 {
if start {
gopCounter = gopCounter + 1
}

if pkt.IsKeyFrame {
if start == false {
start = true
} else {
gopsize = gopCounter
break
}
}
}
}

return width, height, fps, gopsize
}

func HandleStream(infile av.DemuxCloser, queue *pubsub.Queue, communication *models.Communication) { //, wg *sync.WaitGroup) {

log.Log.Debug("HandleStream: started")
Expand Down
Loading

0 comments on commit 71cd315

Please sign in to comment.