change DebugConn to DebugRtsp, add DebugRtp
This commit is contained in:
parent
cd8f5fd673
commit
d2ad170d67
29
client.go
29
client.go
@ -27,7 +27,8 @@ import (
|
|||||||
var ErrCodecDataChange = fmt.Errorf("rtsp: codec data change, please call HandleCodecDataChange()")
|
var ErrCodecDataChange = fmt.Errorf("rtsp: codec data change, please call HandleCodecDataChange()")
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
DebugConn bool
|
DebugRtsp bool
|
||||||
|
DebugRtp bool
|
||||||
Headers []string
|
Headers []string
|
||||||
|
|
||||||
RtspTimeout time.Duration
|
RtspTimeout time.Duration
|
||||||
@ -127,7 +128,7 @@ func (self *Client) sendRtpKeepalive() (err error) {
|
|||||||
self.rtpKeepaliveTimer = time.Now()
|
self.rtpKeepaliveTimer = time.Now()
|
||||||
} else if time.Now().Sub(self.rtpKeepaliveTimer) > self.RtpKeepAliveTimeout {
|
} else if time.Now().Sub(self.rtpKeepaliveTimer) > self.RtpKeepAliveTimeout {
|
||||||
self.rtpKeepaliveTimer = time.Now()
|
self.rtpKeepaliveTimer = time.Now()
|
||||||
if self.DebugConn {
|
if self.DebugRtsp {
|
||||||
fmt.Println("rtp: keep alive")
|
fmt.Println("rtp: keep alive")
|
||||||
}
|
}
|
||||||
if err = self.Options(); err != nil {
|
if err = self.Options(); err != nil {
|
||||||
@ -166,7 +167,7 @@ func (self *Client) WriteRequest(req Request) (err error) {
|
|||||||
|
|
||||||
bufout := buf.Bytes()
|
bufout := buf.Bytes()
|
||||||
|
|
||||||
if self.DebugConn {
|
if self.DebugRtsp {
|
||||||
fmt.Print("> ", string(bufout))
|
fmt.Print("> ", string(bufout))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,7 +217,7 @@ func (self *Client) ReadResponse() (res Response, err error) {
|
|||||||
// $
|
// $
|
||||||
res.BlockLength = int(h[2])<<8 + int(h[3])
|
res.BlockLength = int(h[2])<<8 + int(h[3])
|
||||||
res.BlockNo = int(h[1])
|
res.BlockNo = int(h[1])
|
||||||
if self.DebugConn {
|
if self.DebugRtsp {
|
||||||
fmt.Println("block: len", res.BlockLength, "no", res.BlockNo)
|
fmt.Println("block: len", res.BlockLength, "no", res.BlockNo)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -227,7 +228,7 @@ func (self *Client) ReadResponse() (res Response, err error) {
|
|||||||
self.conn.Timeout = self.RtpTimeout
|
self.conn.Timeout = self.RtpTimeout
|
||||||
|
|
||||||
for {
|
for {
|
||||||
if self.DebugConn {
|
if self.DebugRtsp {
|
||||||
fmt.Println("block: relocate try")
|
fmt.Println("block: relocate try")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,7 +252,7 @@ func (self *Client) ReadResponse() (res Response, err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.DebugConn {
|
if self.DebugRtsp {
|
||||||
fmt.Println("block: relocate done")
|
fmt.Println("block: relocate done")
|
||||||
fmt.Println("block: len", res.BlockLength, "no", res.BlockNo)
|
fmt.Println("block: len", res.BlockLength, "no", res.BlockNo)
|
||||||
}
|
}
|
||||||
@ -265,7 +266,7 @@ func (self *Client) ReadResponse() (res Response, err error) {
|
|||||||
if line, err = tp.ReadLine(); err != nil {
|
if line, err = tp.ReadLine(); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if self.DebugConn {
|
if self.DebugRtsp {
|
||||||
fmt.Println("<", line)
|
fmt.Println("<", line)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,7 +284,7 @@ func (self *Client) ReadResponse() (res Response, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.DebugConn {
|
if self.DebugRtsp {
|
||||||
for k, s := range header {
|
for k, s := range header {
|
||||||
fmt.Println(k, s)
|
fmt.Println(k, s)
|
||||||
}
|
}
|
||||||
@ -443,7 +444,7 @@ func (self *Client) Describe() (streams []av.CodecData, err error) {
|
|||||||
|
|
||||||
body := string(res.Body)
|
body := string(res.Body)
|
||||||
|
|
||||||
if self.DebugConn {
|
if self.DebugRtsp {
|
||||||
fmt.Println("<", body)
|
fmt.Println("<", body)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -591,25 +592,25 @@ func (self *Stream) handleH264Payload(naluType byte, timestamp uint32, packet []
|
|||||||
case 6: // SEI ignored
|
case 6: // SEI ignored
|
||||||
|
|
||||||
case 7: // sps
|
case 7: // sps
|
||||||
if self.client != nil && self.client.DebugConn {
|
if self.client != nil && self.client.DebugRtp {
|
||||||
fmt.Println("rtsp: got sps")
|
fmt.Println("rtsp: got sps")
|
||||||
}
|
}
|
||||||
if bytes.Compare(self.sps, packet) != 0 {
|
if bytes.Compare(self.sps, packet) != 0 {
|
||||||
self.spsChanged = true
|
self.spsChanged = true
|
||||||
self.sps = packet
|
self.sps = packet
|
||||||
if self.client != nil && self.client.DebugConn {
|
if self.client != nil && self.client.DebugRtp {
|
||||||
fmt.Println("rtsp: sps changed")
|
fmt.Println("rtsp: sps changed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case 8: // pps
|
case 8: // pps
|
||||||
if self.client != nil && self.client.DebugConn {
|
if self.client != nil && self.client.DebugRtp {
|
||||||
fmt.Println("rtsp: got pps")
|
fmt.Println("rtsp: got pps")
|
||||||
}
|
}
|
||||||
if bytes.Compare(self.pps, packet) != 0 {
|
if bytes.Compare(self.pps, packet) != 0 {
|
||||||
self.ppsChanged = true
|
self.ppsChanged = true
|
||||||
self.pps = packet
|
self.pps = packet
|
||||||
if self.client != nil && self.client.DebugConn {
|
if self.client != nil && self.client.DebugRtp {
|
||||||
fmt.Println("rtsp: pps changed")
|
fmt.Println("rtsp: pps changed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -837,7 +838,7 @@ func (self *Client) parseBlock(blockNo int, packet []byte) (streamIndex int, err
|
|||||||
*/
|
*/
|
||||||
//payloadType := packet[1]&0x7f
|
//payloadType := packet[1]&0x7f
|
||||||
|
|
||||||
if self.DebugConn {
|
if self.DebugRtsp {
|
||||||
//fmt.Println("packet:", stream.Type(), "offset", payloadOffset, "pt", payloadType)
|
//fmt.Println("packet:", stream.Type(), "offset", payloadOffset, "pt", payloadType)
|
||||||
if len(packet) > 24 {
|
if len(packet) > 24 {
|
||||||
fmt.Println(hex.Dump(packet[:24]))
|
fmt.Println(hex.Dump(packet[:24]))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user