add TEARDOWN

This commit is contained in:
Andrey Semochkin 2021-02-18 13:56:44 +03:00
parent dd938d5e11
commit f6de3acad0

View File

@ -43,6 +43,7 @@ const (
OPTIONS = "OPTIONS" OPTIONS = "OPTIONS"
PLAY = "PLAY" PLAY = "PLAY"
SETUP = "SETUP" SETUP = "SETUP"
TEARDOWN = "TEARDOWN"
) )
type RTSPClient struct { type RTSPClient struct {
@ -458,6 +459,8 @@ func (client *RTSPClient) request(method string, customHeaders map[string]string
func (client *RTSPClient) Close() { func (client *RTSPClient) Close() {
if client.conn != nil { if client.conn != nil {
client.conn.SetDeadline(time.Now().Add(time.Second))
client.request(TEARDOWN, nil, client.control, false, true)
err := client.conn.Close() err := client.conn.Close()
client.Println("RTSP Client Close", err) client.Println("RTSP Client Close", err)
} }
@ -744,7 +747,7 @@ func (client *RTSPClient) RTPDemuxer(payloadRAW *[]byte) ([]*av.Packet, bool) {
return retmap, true return retmap, true
} }
default: default:
client.Println("Unsuported Intervaled data packet", int(content[1]), content[offset:end]) //client.Println("Unsuported Intervaled data packet", int(content[1]), content[offset:end])
} }
return nil, false return nil, false
} }
@ -764,6 +767,7 @@ func (client *RTSPClient) CodecUpdateSPS(val []byte) {
var err error var err error
switch client.videoCodec { switch client.videoCodec {
case av.H264: case av.H264:
client.Println("Codec Update SPS", val)
codecData, err = h264parser.NewCodecDataFromSPSAndPPS(val, client.pps) codecData, err = h264parser.NewCodecDataFromSPSAndPPS(val, client.pps)
if err != nil { if err != nil {
client.Println("Parse Codec Data Error", err) client.Println("Parse Codec Data Error", err)
@ -803,6 +807,7 @@ func (client *RTSPClient) CodecUpdatePPS(val []byte) {
var err error var err error
switch client.videoCodec { switch client.videoCodec {
case av.H264: case av.H264:
client.Println("Codec Update PPS", val)
codecData, err = h264parser.NewCodecDataFromSPSAndPPS(client.sps, val) codecData, err = h264parser.NewCodecDataFromSPSAndPPS(client.sps, val)
if err != nil { if err != nil {
client.Println("Parse Codec Data Error", err) client.Println("Parse Codec Data Error", err)