From a72fa7fb23dcd43eaf8d7dab26404c8f6aa5fe50 Mon Sep 17 00:00:00 2001 From: Alexey Khit Date: Sat, 11 Feb 2023 12:46:29 +0300 Subject: [PATCH] Code refactoring --- pkg/dvrip/client.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/dvrip/client.go b/pkg/dvrip/client.go index e8913245..c2ae584a 100644 --- a/pkg/dvrip/client.go +++ b/pkg/dvrip/client.go @@ -119,11 +119,7 @@ func (c *Client) Play() (err error) { } data = fmt.Sprintf(format, c.session, "Start", c.stream) - if err = c.Request(OPMonitorStart, data); err != nil { - return - } - - return + return c.Request(OPMonitorStart, data) } func (c *Client) Handle() error { @@ -170,6 +166,8 @@ func (c *Client) Handle() error { continue // need to collect data from next packets } + //log.Printf("[DVR] type: %d, len: %d", dataType, len(b)) + switch dataType { case 0x1FC, 0x1FE: // video IFrame payload := h264.AnnexB2AVC(b[16:]) @@ -178,6 +176,7 @@ func (c *Client) Handle() error { fps := b[5] //width := uint16(b[6]) * 8 //height := uint16(b[7]) * 8 + //println(width, height) ts := b[8:] // the exact value of the start TS does not matter @@ -364,6 +363,7 @@ func (c *Client) AddVideoTrack(mediaCode byte, payload []byte) { } } default: + println("[DVRIP] unsupported video codec:", mediaCode) return } @@ -393,6 +393,7 @@ func (c *Client) AddAudioTrack(mediaCode byte, sampleRate byte) { Name: streamer.CodecPCMA, } default: + println("[DVRIP] unsupported audio codec:", mediaCode) return }