add client status

This commit is contained in:
Lidashuang 2024-03-14 17:56:17 +08:00
parent 64bb2d145a
commit 42c53daeab
2 changed files with 10 additions and 2 deletions

View File

@ -97,6 +97,7 @@ type RTSPClient struct {
sequenceNumber int sequenceNumber int
end int end int
offset int offset int
status string
} }
type RTSPClientOptions struct { type RTSPClientOptions struct {
@ -280,6 +281,10 @@ func (client *RTSPClient) startStream() {
} }
timer = time.Now() timer = time.Now()
} }
if client.status == PAUSE {
// client.Println("RTSP Client PAUSE")
continue
}
if !fixed { if !fixed {
nb, err := io.ReadFull(client.connRW, header) nb, err := io.ReadFull(client.connRW, header)
if err != nil || nb != 4 { if err != nil || nb != 4 {
@ -505,10 +510,12 @@ func (client *RTSPClient) request(method string, customHeaders map[string]string
} }
func (client *RTSPClient) Pause() error { func (client *RTSPClient) Pause() error {
client.status = PAUSE
return client.request(PAUSE, nil, client.pURL.String(), false, true) return client.request(PAUSE, nil, client.pURL.String(), false, true)
} }
func (client *RTSPClient) Play(customHeaders map[string]string) error { func (client *RTSPClient) Play(customHeaders map[string]string) error {
client.status = PLAY
return client.request(PLAY, customHeaders, client.pURL.String(), false, true) return client.request(PLAY, customHeaders, client.pURL.String(), false, true)
} }

View File

@ -2,12 +2,13 @@ package rtspv2
import ( import (
"encoding/binary" "encoding/binary"
"math"
"time"
"github.com/deepch/vdk/av" "github.com/deepch/vdk/av"
"github.com/deepch/vdk/codec/aacparser" "github.com/deepch/vdk/codec/aacparser"
"github.com/deepch/vdk/codec/h264parser" "github.com/deepch/vdk/codec/h264parser"
"github.com/deepch/vdk/codec/h265parser" "github.com/deepch/vdk/codec/h265parser"
"math"
"time"
) )
const ( const (