From d22f3dc9293ea33194d56f747d45035530cdd55b Mon Sep 17 00:00:00 2001 From: Dimitrii Date: Thu, 27 Aug 2020 14:45:52 +0300 Subject: [PATCH] mutext on ts/muxer and get_parameter for keep alive --- format/rtsp/client.go | 2 +- format/ts/muxer.go | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/format/rtsp/client.go b/format/rtsp/client.go index 532a3fa..5148cdd 100644 --- a/format/rtsp/client.go +++ b/format/rtsp/client.go @@ -197,7 +197,7 @@ func (self *Client) SendRtpKeepalive() (err error) { fmt.Println("rtp: keep alive") } req := Request{ - Method: "OPTIONS", + Method: "GET_PARAMETER", Uri: self.requestUri, } if self.session != "" { diff --git a/format/ts/muxer.go b/format/ts/muxer.go index 7551590..6bba9cb 100644 --- a/format/ts/muxer.go +++ b/format/ts/muxer.go @@ -3,6 +3,7 @@ package ts import ( "fmt" "io" + "sync" "time" "github.com/deepch/vdk/av" @@ -14,9 +15,9 @@ import ( var CodecTypes = []av.CodecType{av.H264, av.AAC} type Muxer struct { - w io.Writer - streams map[int]*Stream - + w io.Writer + streams map[int]*Stream + mutex sync.Mutex PaddingToMakeCounterCont bool psidata []byte @@ -63,6 +64,10 @@ func (self *Muxer) newStream(idx int, codec av.CodecData) (err error) { pid: pid, tsw: tsio.NewTSWriter(pid), } + + defer self.mutex.Unlock() + self.mutex.Lock() + self.streams[idx] = stream return }