]> git.feebdaed.xyz Git - gomehub.git/commitdiff
Working cctv streaming api
authorseantywork <seantywork@gmail.com>
Tue, 18 Jun 2024 08:00:09 +0000 (17:00 +0900)
committerseantywork <seantywork@gmail.com>
Tue, 18 Jun 2024 08:00:09 +0000 (17:00 +0900)
Makefile
config.yaml
ctl/config.go
ctl/ctl.go
pkg/stream/stream_cctv.go

index a56010ab67b4933c26e7a2c2ea36627a15632fd7..f4e3ccc38b250f803bc06a75d742ee5b8dccd636 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -53,7 +53,7 @@ $(VENDOR_FFMPEG):
 
 build:
 
-       go build -o tv.out .
+       go build -o soliagain.out .
 
 
 .PHONY: test
index f10061473e5121c10ec2a425827616fbb3073994..94076b6223f6a496fb41158c3e262861e2e5ffd8 100644 (file)
@@ -3,11 +3,12 @@ serveAddr: "0.0.0.0"
 servePort: "8080"
 maxFileSize: 838860800
 stream:
-  turnServerAddr: "stun.l.google.com:19302"
+  turnServerAddr: "stun:stun.l.google.com:19302"
   rtcpPLIInterval: 3
   uploadDest: "./upload/"
   extAllowList:
     - "mp4"
+  udpBufferByteSize: 300000 
   signalPort: "8082"
   rtpReceivePort: "8084"
 utils:
index ddef72eb92f7855774b2b498d07529d2acc27797..4ac7c7546e9715c8593e0947fc1de0e58948f9b3 100644 (file)
@@ -2,7 +2,6 @@ package controller
 
 import (
        "os"
-       "time"
 
        "gopkg.in/yaml.v3"
 )
@@ -13,12 +12,13 @@ type SOLIAGAIN_CONFIG struct {
        ServePort   string `yaml:"servePort"`
        MaxFileSize int64  `yaml:"maxFileSize"`
        Stream      struct {
-               TurnServerAddr  string        `yaml:"turnServerAddr"`
-               RtcpPLIInterval time.Duration `yaml:"rtcpPLIInterval"`
-               UploadDest      string        `yaml:"uploadDest"`
-               ExtAllowList    []string      `yaml:"extAllowList"`
-               SignalPort      string        `yaml:"signalPort"`
-               RtpReceivePort  string        `yaml:"rtpReceivePort"`
+               TurnServerAddr    string   `yaml:"turnServerAddr"`
+               RtcpPLIInterval   int      `yaml:"rtcpPLIInterval"`
+               UploadDest        string   `yaml:"uploadDest"`
+               ExtAllowList      []string `yaml:"extAllowList"`
+               UdpBufferByteSize int      `yaml:"udpBufferByteSize"`
+               SignalPort        string   `yaml:"signalPort"`
+               RtpReceivePort    string   `yaml:"rtpReceivePort"`
        } `yaml:"stream"`
        Utils struct {
                UseCompress bool `yaml:"useCompress"`
index fd0ee835c5ec0f76957ef9b0773d9ece0dd08ebb..fbf2a0ae8738977a9f4768f9c78b7c50facbaa1d 100644 (file)
@@ -17,10 +17,12 @@ func CreateServer() *gin.Engine {
        pkgstream.EXTERNAL_URL = CONF.ExternalUrl
 
        pkgstream.TURN_SERVER_ADDR = CONF.Stream.TurnServerAddr
-       pkgstream.RTCP_PLI_INTERVAL = time.Second * CONF.Stream.RtcpPLIInterval
+       pkgstream.RTCP_PLI_INTERVAL = time.Second * time.Duration(CONF.Stream.RtcpPLIInterval)
        pkgstream.UPLOAD_DEST = CONF.Stream.UploadDest
        pkgstream.EXTENSION_ALLOWLIST = CONF.Stream.ExtAllowList
 
+       pkgstream.UDP_BUFFER_BYTE_SIZE = CONF.Stream.UdpBufferByteSize
+
        pkgstream.SIGNAL_ADDR = CONF.ServeAddr
        pkgstream.SIGNAL_PORT = CONF.Stream.SignalPort
 
index e2848e1fa850c094f5d67b809d7f21b6f9cdc897..bdd7becc41685589c5da322db453b11441e065e0 100644 (file)
@@ -12,6 +12,8 @@ import (
        pkgutils "github.com/seantywork/sorrylinus-again/pkg/utils"
 )
 
+var UDP_BUFFER_BYTE_SIZE int
+
 var RTP_RECEIVE_ADDR string
 
 var RTP_RECEIVE_PORT string
@@ -76,8 +78,6 @@ func startCCTVReceiver(offer_in string, offer_out chan string) {
                panic(err)
        }
 
-       // Open a UDP Listener for RTP Packets on port 5004
-
        var udp_port int
 
        fmt.Sscanf(RTP_RECEIVE_PORT, "%d", &udp_port)
@@ -89,7 +89,7 @@ func startCCTVReceiver(offer_in string, offer_out chan string) {
 
        // Increase the UDP receive buffer size
        // Default UDP buffer sizes vary on different operating systems
-       bufferSize := 300000 // 300KB
+       bufferSize := UDP_BUFFER_BYTE_SIZE // 300KB
        err = listener.SetReadBuffer(bufferSize)
        if err != nil {
                panic(err)