github.com/cnotch/ipchub@v1.1.0/service/rtsp/sdp_test.go (about) 1 // Copyright (c) 2019,CAOHONGJU All rights reserved. 2 // Use of this source code is governed by a MIT-style 3 // license that can be found in the LICENSE file. 4 5 package rtsp 6 7 import ( 8 "testing" 9 10 "github.com/pixelbender/go-sdp/sdp" 11 ) 12 13 const sdpRaw = `v=0 14 o=- 0 0 IN IP4 127.0.0.1 15 s=No Name 16 c=IN IP4 127.0.0.1 17 t=0 0 18 a=tool:libavformat 58.20.100 19 m=video 0 RTP/AVP 96 20 b=AS:2500 21 a=rtpmap:96 H264/90000 22 a=fmtp:96 packetization-mode=1; sprop-parameter-sets=Z2QAH6zZQFAFuhAAAAMAEAAAAwPI8YMZYA==,aO+8sA==; profile-level-id=64001F 23 a=control:streamid=0 24 m=audio 0 RTP/AVP 97 25 b=AS:160 26 a=rtpmap:97 MPEG4-GENERIC/44100/2 27 a=fmtp:97 profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3; config=121056E500 28 a=control:streamid=1 29 ` 30 31 const sdpRaw2 = `v=0 32 o=- 946684871882903 1 IN IP4 192.168.1.154 33 s=RTSP/RTP stream from IPNC 34 i=h264 35 t=0 0 36 a=tool:LIVE555 Streaming Media v2008.04.02 37 a=type:broadcast 38 a=control:* 39 a=source-filter: incl IN IP4 * 192.168.1.154 40 a=rtcp-unicast: reflection 41 a=range:npt=0- 42 a=x-qt-text-nam:RTSP/RTP stream from IPNC 43 a=x-qt-text-inf:h264 44 m=audio 18888 RTP/AVP 0 45 c=IN IP4 232.190.161.0/255 46 a=control:track1 47 m=video 16666 RTP/AVP 96 48 c=IN IP4 232.248.88.236/255 49 a=rtpmap:96 H264/90000 50 a=fmtp:96 packetization-mode=1;profile-level-id=EE3CB0;sprop-parameter-sets=H264 51 a=control:track2 52 ` 53 54 const sdpRaw3 = `v=0 55 o=- 0 0 IN IP6 ::1 56 s=No Name 57 c=IN IP6 ::1 58 t=0 0 59 a=tool:libavformat 58.20.100 60 m=video 0 RTP/AVP 96 61 a=rtpmap:96 H264/90000 62 a=fmtp:96 packetization-mode=1; sprop-parameter-sets=Z3oAH7y0AoAt0IAAAAMAgAAAHkeMGVA=,aO8Pyw==; profile-level-id=7A001F 63 a=control:streamid=0 64 m=audio 0 RTP/AVP 97 65 b=AS:128 66 a=rtpmap:97 MPEG4-GENERIC/44100/2 67 a=fmtp:97 profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3; config=121056E500` 68 69 // 4k mp4 70 const sdpRaw4 = `v=0 71 o=- 0 0 IN IP6 ::1 72 s=No Name 73 c=IN IP6 ::1 74 t=0 0 75 a=tool:libavformat 58.20.100 76 m=video 0 RTP/AVP 96 77 b=AS:31998 78 a=rtpmap:96 H264/90000 79 a=fmtp:96 packetization-mode=1; sprop-parameter-sets=Z2QAM6wspADwAQ+wFSAgICgAAB9IAAdTBO0LFok=,aOtzUlA=; profile-level-id=640033 80 a=control:streamid=0 81 m=audio 0 RTP/AVP 97 82 b=AS:317 83 a=rtpmap:97 MPEG4-GENERIC/48000/2 84 a=fmtp:97 profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3; config=1190 85 a=control:streamid=1` 86 87 const sdpH265Raw = `v=0 88 o=- 0 0 IN IP6 ::1 89 s=No Name 90 c=IN IP6 ::1 91 t=0 0 92 a=tool:libavformat 58.20.100 93 m=video 0 RTP/AVP 96 94 a=rtpmap:96 H265/90000 95 a=fmtp:96 sprop-vps=QAEMAf//BAgAAAMAnQgAAAMAAF26AkA=; sprop-sps=QgEBBAgAAAMAnQgAAAMAAF2wAoCALRZbqSTK4BAAAAMAEAAAAwHggA==; sprop-pps=RAHBcrRiQA== 96 a=control:streamid=0 97 m=audio 0 RTP/AVP 97 98 b=AS:128 99 a=rtpmap:97 MPEG4-GENERIC/44100/2 100 a=fmtp:97 profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3; config=121056E500 101 a=control:streamid=1 102 ` 103 104 func Benchmark_ThirdSdpParse(b *testing.B) { 105 b.ResetTimer() 106 b.RunParallel(func(pb *testing.PB) { 107 for pb.Next() { 108 sdp.ParseString(sdpRaw2) 109 } 110 }) 111 } 112 113 func Test_SDPParse(t *testing.T) { 114 t.Run("Test_SDPParse", func(t *testing.T) { 115 s1, err := sdp.ParseString(sdpRaw) 116 if err != nil { 117 t.Errorf("sdp.ParseString() error = %v", err) 118 } 119 _ = s1 120 121 s2, err := sdp.ParseString(sdpRaw2) 122 if err != nil { 123 t.Errorf("sdp.ParseString() error = %v", err) 124 } 125 _ = s2 126 }) 127 }