mutext on ts/muxer and get_parameter for keep alive

This commit is contained in:
Dimitrii 2020-08-27 14:45:52 +03:00
parent 061613f0e1
commit d22f3dc929
2 changed files with 9 additions and 4 deletions

View File

@ -197,7 +197,7 @@ func (self *Client) SendRtpKeepalive() (err error) {
fmt.Println("rtp: keep alive") fmt.Println("rtp: keep alive")
} }
req := Request{ req := Request{
Method: "OPTIONS", Method: "GET_PARAMETER",
Uri: self.requestUri, Uri: self.requestUri,
} }
if self.session != "" { if self.session != "" {

View File

@ -3,6 +3,7 @@ package ts
import ( import (
"fmt" "fmt"
"io" "io"
"sync"
"time" "time"
"github.com/deepch/vdk/av" "github.com/deepch/vdk/av"
@ -14,9 +15,9 @@ import (
var CodecTypes = []av.CodecType{av.H264, av.AAC} var CodecTypes = []av.CodecType{av.H264, av.AAC}
type Muxer struct { type Muxer struct {
w io.Writer w io.Writer
streams map[int]*Stream streams map[int]*Stream
mutex sync.Mutex
PaddingToMakeCounterCont bool PaddingToMakeCounterCont bool
psidata []byte psidata []byte
@ -63,6 +64,10 @@ func (self *Muxer) newStream(idx int, codec av.CodecData) (err error) {
pid: pid, pid: pid,
tsw: tsio.NewTSWriter(pid), tsw: tsio.NewTSWriter(pid),
} }
defer self.mutex.Unlock()
self.mutex.Lock()
self.streams[idx] = stream self.streams[idx] = stream
return return
} }