Compare commits

...

7 Commits

Author SHA1 Message Date
Cédric Verstraeten
afefd32a1f Merge pull request #102 from lubikx/master
Alpine+go combination doesn't resolve DNS correctly under docker comp…
2023-05-30 09:07:52 +02:00
Lubor Nosek
89e01e065c Alpine+go combination doesn't resolve DNS correctly under docker compose environment 2023-05-30 08:30:24 +02:00
Cedric Verstraeten
02f3e6a1e2 Update README.md 2023-05-16 12:01:09 +02:00
Cedric Verstraeten
ec5a00f3df get rid of print! 2023-05-10 14:41:32 +02:00
Cedric Verstraeten
2860775954 unused var 2023-05-10 11:43:23 +02:00
Cedric Verstraeten
d2e8e04833 upgrade joy4, allow OPUS 2023-05-10 11:33:38 +02:00
Cedric Verstraeten
fad90390a6 disable transcoder, will free up some memory + add support for audio 2023-05-10 11:33:03 +02:00
6 changed files with 45 additions and 31 deletions

View File

@@ -32,7 +32,7 @@ RUN cat /go/src/github.com/kerberos-io/agent/machinery/version
RUN cd /go/src/github.com/kerberos-io/agent/machinery && \
go mod download && \
go build -tags timetzdata --ldflags '-s -w -extldflags "-static -latomic"' main.go && \
go build -tags timetzdata,netgo --ldflags '-s -w -extldflags "-static -latomic"' main.go && \
mkdir -p /agent && \
mv main /agent && \
mv version /agent && \

View File

@@ -324,14 +324,6 @@ By running the `docker build` command, you will create the Kerberos Agent Docker
docker build -t kerberos/agent .
## Support our project
If you like our product please feel free to execute an Ethereum donation. All donations will flow back and split to our Open Source contributors, as they are the heart of this community.
<img width="272" alt="Ethereum donation linke" src="https://user-images.githubusercontent.com/1546779/173443671-3d773068-ae10-4862-a990-dc7c89f3d9c2.png">
Ethereum Address: `0xf4a759C9436E2280Ea9cdd23d3144D95538fF4bE`
## What is new?
This repository contains the next generation of Kerberos.io, **Kerberos Agent (v3)**, and is the successor of the machinery and web repositories. A switch in technologies and architecture has been made. This version is still under active development and can be followed on the [develop branch](https://github.com/kerberos-io/agent/tree/develop) and [project overview](https://github.com/kerberos-io/agent/projects/1).

View File

@@ -25,7 +25,7 @@ require (
github.com/golang-module/carbon/v2 v2.2.3
github.com/gorilla/websocket v1.5.0
github.com/kellydunn/golang-geo v0.7.0
github.com/kerberos-io/joy4 v1.0.55
github.com/kerberos-io/joy4 v1.0.57
github.com/kerberos-io/onvif v0.0.5
github.com/minio/minio-go/v6 v6.0.57
github.com/nsmith5/mjpeg v0.0.0-20200913181537-54b8ada0e53e

View File

@@ -259,8 +259,8 @@ github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/kellydunn/golang-geo v0.7.0 h1:A5j0/BvNgGwY6Yb6inXQxzYwlPHc6WVZR+MrarZYNNg=
github.com/kellydunn/golang-geo v0.7.0/go.mod h1:YYlQPJ+DPEzrHx8kT3oPHC/NjyvCCXE+IuKGKdrjrcU=
github.com/kerberos-io/joy4 v1.0.55 h1:P5RISBp8kUowgb/bvqLPVKPJL9n9jI/wXBCLs+XFMWg=
github.com/kerberos-io/joy4 v1.0.55/go.mod h1:nZp4AjvKvTOXRrmDyAIOw+Da+JA5OcSo/JundGfOlFU=
github.com/kerberos-io/joy4 v1.0.57 h1:/8epNAJv4cOzBG8pFiM9hVNXfwsgA+8/2nHQ2yOeyII=
github.com/kerberos-io/joy4 v1.0.57/go.mod h1:nZp4AjvKvTOXRrmDyAIOw+Da+JA5OcSo/JundGfOlFU=
github.com/kerberos-io/onvif v0.0.5 h1:kq9mnHZkih9Jl4DyIJ4Rzt++Y3DDKy3nI8S2ESEfZ5w=
github.com/kerberos-io/onvif v0.0.5/go.mod h1:Hr2dJOH2LM5SpYKk17gYZ1CMjhGhUl+QlT5kwYogrW0=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=

View File

@@ -471,8 +471,9 @@ func HandleLiveStreamHD(livestreamCursor *pubsub.QueueCursor, configuration *mod
if config.Capture.Liveview != "false" {
// Should create a track here.
track := webrtc.NewVideoTrack()
go webrtc.WriteToTrack(livestreamCursor, configuration, communication, mqttClient, track, codecs, decoder, decoderMutex)
videoTrack := webrtc.NewVideoTrack(codecs)
audioTrack := webrtc.NewAudioTrack(codecs)
go webrtc.WriteToTrack(livestreamCursor, configuration, communication, mqttClient, videoTrack, audioTrack, codecs, decoder, decoderMutex)
if config.Capture.ForwardWebRTC == "true" {
// We get a request with an offer, but we'll forward it.
@@ -495,7 +496,7 @@ func HandleLiveStreamHD(livestreamCursor *pubsub.QueueCursor, configuration *mod
webrtc.CandidateArrays[key] = make(chan string, 30)
}
webrtc.CandidatesMutex.Unlock()
webrtc.InitializeWebRTCConnection(configuration, communication, mqttClient, track, handshake, webrtc.CandidateArrays[key])
webrtc.InitializeWebRTCConnection(configuration, communication, mqttClient, videoTrack, audioTrack, handshake, webrtc.CandidateArrays[key])
}
}

View File

@@ -27,7 +27,7 @@ var (
CandidateArrays map[string](chan string)
peerConnectionCount int64
peerConnections map[string]*pionWebRTC.PeerConnection
encoder *ffmpeg.VideoEncoder
//encoder *ffmpeg.VideoEncoder
)
type WebRTC struct {
@@ -40,7 +40,8 @@ type WebRTC struct {
PacketsCount chan int
}
func init() {
// No longer used, is for transcoding, might comeback on this!
/*func init() {
// Encoder is created for once and for all.
var err error
encoder, err = ffmpeg.NewVideoEncoderByCodecType(av.H264)
@@ -55,7 +56,7 @@ func init() {
encoder.SetPixelFormat(av.I420)
encoder.SetBitrate(1000000) // 1MB
encoder.SetGopSize(30 / 1) // 1s
}
}*/
func CreateWebRTC(name string, stunServers []string, turnServers []string, turnServersUsername string, turnServersCredential string) *WebRTC {
return &WebRTC{
@@ -86,7 +87,7 @@ func (w WebRTC) CreateOffer(sd []byte) pionWebRTC.SessionDescription {
return offer
}
func InitializeWebRTCConnection(configuration *models.Configuration, communication *models.Communication, mqttClient mqtt.Client, track *pionWebRTC.TrackLocalStaticSample, handshake models.SDPPayload, candidates chan string) {
func InitializeWebRTCConnection(configuration *models.Configuration, communication *models.Communication, mqttClient mqtt.Client, videoTrack *pionWebRTC.TrackLocalStaticSample, audioTrack *pionWebRTC.TrackLocalStaticSample, handshake models.SDPPayload, candidates chan string) {
config := configuration.Config
@@ -127,15 +128,13 @@ func InitializeWebRTCConnection(configuration *models.Configuration, communicati
if err == nil && peerConnection != nil {
if _, err = peerConnection.AddTrack(track); err != nil {
if _, err = peerConnection.AddTrack(videoTrack); err != nil {
panic(err)
}
_, err = peerConnection.AddTransceiverFromTrack(track,
pionWebRTC.RtpTransceiverInit{
Direction: pionWebRTC.RTPTransceiverDirectionSendonly,
},
)
if _, err = peerConnection.AddTrack(audioTrack); err != nil {
panic(err)
}
if err != nil {
panic(err)
@@ -214,12 +213,29 @@ func InitializeWebRTCConnection(configuration *models.Configuration, communicati
}
}
func NewVideoTrack() *pionWebRTC.TrackLocalStaticSample {
outboundVideoTrack, _ := pionWebRTC.NewTrackLocalStaticSample(pionWebRTC.RTPCodecCapability{MimeType: "video/h264"}, "video", "pion124")
func NewVideoTrack(codecs []av.CodecData) *pionWebRTC.TrackLocalStaticSample {
var mimeType string
mimeType = pionWebRTC.MimeTypeH264
outboundVideoTrack, _ := pionWebRTC.NewTrackLocalStaticSample(pionWebRTC.RTPCodecCapability{MimeType: mimeType}, "video", "pion124")
return outboundVideoTrack
}
func WriteToTrack(livestreamCursor *pubsub.QueueCursor, configuration *models.Configuration, communication *models.Communication, mqttClient mqtt.Client, track *pionWebRTC.TrackLocalStaticSample, codecs []av.CodecData, decoder *ffmpeg.VideoDecoder, decoderMutex *sync.Mutex) {
func NewAudioTrack(codecs []av.CodecData) *pionWebRTC.TrackLocalStaticSample {
var mimeType string
for _, codec := range codecs {
if codec.Type().String() == "OPUS" {
mimeType = pionWebRTC.MimeTypeOpus
} else if codec.Type().String() == "PCM_MULAW" {
mimeType = pionWebRTC.MimeTypePCMU
} else if codec.Type().String() == "PCM_ALAW" {
mimeType = pionWebRTC.MimeTypePCMA
}
}
outboundAudioTrack, _ := pionWebRTC.NewTrackLocalStaticSample(pionWebRTC.RTPCodecCapability{MimeType: mimeType}, "audio", "pion124")
return outboundAudioTrack
}
func WriteToTrack(livestreamCursor *pubsub.QueueCursor, configuration *models.Configuration, communication *models.Communication, mqttClient mqtt.Client, videoTrack *pionWebRTC.TrackLocalStaticSample, audioTrack *pionWebRTC.TrackLocalStaticSample, codecs []av.CodecData, decoder *ffmpeg.VideoDecoder, decoderMutex *sync.Mutex) {
config := configuration.Config
@@ -233,7 +249,7 @@ func WriteToTrack(livestreamCursor *pubsub.QueueCursor, configuration *models.Co
for i, codec := range codecs {
if codec.Type().String() == "H264" && videoIdx < 0 {
videoIdx = i
} else if codec.Type().String() == "PCM_MULAW" && audioIdx < 0 {
} else if (codec.Type().String() == "OPUS" || codec.Type().String() == "PCM_MULAW" || codec.Type().String() == "PCM_ALAW") && audioIdx < 0 {
audioIdx = i
}
}
@@ -363,13 +379,17 @@ func WriteToTrack(livestreamCursor *pubsub.QueueCursor, configuration *models.Co
log.Log.Info("WriteToTrack: Error marshalling frame, " + err.Error())
}
} else {
if err := track.WriteSample(sample); err != nil && err != io.ErrClosedPipe {
if err := videoTrack.WriteSample(sample); err != nil && err != io.ErrClosedPipe {
log.Log.Error("WriteToTrack: something went wrong while writing sample: " + err.Error())
}
}
}
case audioIdx:
//log.Log.Info("WriteToTrack: not writing audio for the moment.")
// We will send the audio
sample := pionMedia.Sample{Data: pkt.Data, Duration: pkt.Time}
if err := audioTrack.WriteSample(sample); err != nil && err != io.ErrClosedPipe {
log.Log.Error("WriteToTrack: something went wrong while writing sample: " + err.Error())
}
}
}
}
@@ -378,6 +398,7 @@ func WriteToTrack(livestreamCursor *pubsub.QueueCursor, configuration *models.Co
p.Close()
}
}
peerConnectionCount = 0
log.Log.Info("WriteToTrack: stop writing to track.")
}