From 49da18f2638832e9def10c50a1cedef332398cf4 Mon Sep 17 00:00:00 2001 From: kunmeng Date: Thu, 9 Oct 2025 16:32:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=80=E4=BA=9B=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- format/rtspv2/client.go | 3 ++- format/rtspv2/demuxer.go | 6 ++++-- format/rtspv2/rtsp_test.go | 24 ++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 format/rtspv2/rtsp_test.go diff --git a/format/rtspv2/client.go b/format/rtspv2/client.go index 1a2684b..2cd829d 100644 --- a/format/rtspv2/client.go +++ b/format/rtspv2/client.go @@ -191,6 +191,7 @@ func Dial(options RTSPClientOptions) (*RTSPClient, error) { client.CodecData = append(client.CodecData, h265parser.CodecData{}) } client.videoCodec = av.H265 + // Todo: 这里是 WebCoder 需要的扩展内容 } else { client.Println("SDP Video Codec Type Not Supported", i2.Type) @@ -810,7 +811,7 @@ func (client *RTSPClient) CodecUpdateVPS(val []byte) { // Println mini logging functions func (client *RTSPClient) Println(v ...interface{}) { if client.options.Debug { - log.Println(v) + log.Println(v...) } } diff --git a/format/rtspv2/demuxer.go b/format/rtspv2/demuxer.go index 0727457..4335785 100644 --- a/format/rtspv2/demuxer.go +++ b/format/rtspv2/demuxer.go @@ -107,6 +107,7 @@ func (client *RTSPClient) handleVideo(content []byte) ([]*av.Packet, bool) { var retmap []*av.Packet for _, nal := range nalRaw { if client.videoCodec == av.H265 { + //fmt.Printf("Content Len:%d\n", len(content)) retmap = client.handleH265Payload(nal, retmap) } else if client.videoCodec == av.H264 { retmap = client.handleH264Payload(content, nal, retmap) @@ -183,7 +184,7 @@ func (client *RTSPClient) handleH264Payload(content, nal []byte, retmap []*av.Pa } } default: - //client.Println("Unsupported NAL Type", naluType) + client.Println("Unsupported NAL Type", naluType) } return retmap @@ -219,7 +220,8 @@ func (client *RTSPClient) handleH265Payload(nal []byte, retmap []*av.Packet) []* client.BufferRtpPacket.Write(nal[3:]) } default: - //client.Println("Unsupported Nal", naluType) + // Todo: 这里少东西,需要处理 + client.Println("Unsupported Nal", naluType) } return retmap } diff --git a/format/rtspv2/rtsp_test.go b/format/rtspv2/rtsp_test.go new file mode 100644 index 0000000..abaf886 --- /dev/null +++ b/format/rtspv2/rtsp_test.go @@ -0,0 +1,24 @@ +package rtspv2 + +import ( + "testing" + "time" +) + +func Test(t *testing.T) { + dial, err := Dial(RTSPClientOptions{URL: "rtsp://192.168.211.9:554/pano/0", DisableAudio: true, DialTimeout: 10 * time.Second, ReadWriteTimeout: 10 * time.Second, Debug: true}) + //dial, err := Dial(RTSPClientOptions{URL: "rtsp://192.168.211.200:8554", DisableAudio: true, DialTimeout: 10 * time.Second, ReadWriteTimeout: 10 * time.Second, Debug: true}) + if err != nil { + return + } + for { + select { + case signals := <-dial.Signals: + println(signals) + continue + case <-dial.OutgoingPacketQueue: + //println(time.Now().UnixMilli()) + continue + } + } +}