From ffeb473918816148071786703812ccc27b8ea3f7 Mon Sep 17 00:00:00 2001 From: Alexey Khit Date: Wed, 31 May 2023 14:36:00 +0300 Subject: [PATCH] Remove broken tests --- pkg/h264/ps/sps_pps_test.go | 56 ------------------------------ pkg/mpegts/mpegts_test.go | 48 -------------------------- pkg/webrtc/webrtc_test.go | 68 ------------------------------------- 3 files changed, 172 deletions(-) delete mode 100644 pkg/h264/ps/sps_pps_test.go delete mode 100644 pkg/mpegts/mpegts_test.go delete mode 100644 pkg/webrtc/webrtc_test.go diff --git a/pkg/h264/ps/sps_pps_test.go b/pkg/h264/ps/sps_pps_test.go deleted file mode 100644 index 2102c3ba..00000000 --- a/pkg/h264/ps/sps_pps_test.go +++ /dev/null @@ -1,56 +0,0 @@ -package ps - -import ( - "bytes" - "testing" -) - -func TestUnmarshalSPS(t *testing.T) { - raw := []byte{0x67, 0x42, 0x00, 0x0a, 0xf8, 0x41, 0xa2} - s := SPS{} - if err := s.Unmarshal(raw); err != nil { - t.Fatal(err) - } - raw2 := s.Marshal() - if bytes.Compare(raw, raw2) != 0 { - t.Fatal() - } -} - -func TestUnmarshalPPS(t *testing.T) { - raw := []byte{0x68, 0xce, 0x38, 0x80} - p := PPS{} - if err := p.Unmarshal(raw); err != nil { - t.Fatal(err) - } - raw2 := p.Marshal() - if bytes.Compare(raw, raw2) != 0 { - t.Fatal() - } -} - -func TestUnmarshalPPS2(t *testing.T) { - raw := []byte{72, 238, 60, 128} - p := PPS{} - if err := p.Unmarshal(raw); err != nil { - t.Fatal(err) - } - raw2 := p.Marshal() - if bytes.Compare(raw, raw2) != 0 { - t.Fatal() - } -} - -func TestSafari(t *testing.T) { - // CB66, L3.1: chrome, edge, safari, android chrome - s := EncodeProfile(0x42, 0xE0) - t.Logf("Profile: %s, Level: %d", s, 0x1F) - - // B66, L3.1: chrome, edge - s = EncodeProfile(0x42, 0x00) - t.Logf("Profile: %s, Level: %d", s, 0x1F) - - // M77, L3.1: chrome, edge - s = EncodeProfile(0x4D, 0x00) - t.Logf("Profile: %s, Level: %d", s, 0x1F) -} diff --git a/pkg/mpegts/mpegts_test.go b/pkg/mpegts/mpegts_test.go deleted file mode 100644 index e1cc379f..00000000 --- a/pkg/mpegts/mpegts_test.go +++ /dev/null @@ -1,48 +0,0 @@ -package mpegts - -import ( - "encoding/hex" - "github.com/stretchr/testify/assert" - "strings" - "testing" -) - -func TestTime(t *testing.T) { - w := NewWriter() - w.WriteTime(0xFFFFFFFF) - assert.Equal(t, []byte{0x27, 0xFF, 0xFF, 0xFF, 0xFF}, w.Bytes()) - ts := ParseTime(w.Bytes()) - assert.Equal(t, uint32(0xFFFFFFFF), ts) -} - -func dec(s string) []byte { - s = strings.ReplaceAll(s, " ", "") - b, _ := hex.DecodeString(s) - return b -} - -//func TestStream(t *testing.T) { -// // ffmpeg -// annexb := dec("00000001 09f0 00000001 6764001fac2484014016ec0440000003004000000c23c60c92 00000001 68ee32c8b0 000001 6588808003 00000001 09") -// avc, i := ParseAVC(annexb) -// assert.Equal(t, dec("00000019 6764001fac2484014016ec0440000003004000000c23c60c92 00000005 68ee32c8b0 00000005 6588808003"), avc) -// assert.Equal(t, dec("00000001 09"), annexb[i:]) -// -// // http mpeg ts -// annexb = dec("00000001 0950 000001 6764001facd2014016e8400000fa400030e081 000001 68ea8f2c 000001 65b8400eff 00000001 09") -// avc, i = ParseAVC(annexb) -// assert.Equal(t, dec("00000013 6764001facd2014016e8400000fa400030e081 00000004 68ea8f2c 00000005 65b8400eff"), avc) -// assert.Equal(t, dec("00000001 09"), annexb[i:]) -// -// // tapo TC60 -// annexb = dec("00000001 67640028ac1ad00a00b74dc0404050000003001000000301e8f1422a 00000001 68ee04c92240 00000001 45b80000d0 00000001 67") -// avc, i = ParseAVC(annexb) -// assert.Equal(t, dec("0000001C 67640028ac1ad00a00b74dc0404050000003001000000301e8f1422a 00000006 68ee04c92240 00000005 45b80000d0"), avc) -// assert.Equal(t, dec("00000001 67"), annexb[i:]) -// -// // Tapo ? -// annexb = dec("00000001 674d0032e90048014742000007d2000138d108 00000001 68ea8f20 00000001 65b8400cff 00000001 67") -// avc, i = ParseAVC(annexb) -// assert.Equal(t, dec("00000013 674d0032e90048014742000007d2000138d108 00000004 68ea8f20 00000005 65b8400cff"), avc) -// assert.Equal(t, dec("00000001 67"), annexb[i:]) -//} diff --git a/pkg/webrtc/webrtc_test.go b/pkg/webrtc/webrtc_test.go deleted file mode 100644 index 0b5a89b8..00000000 --- a/pkg/webrtc/webrtc_test.go +++ /dev/null @@ -1,68 +0,0 @@ -package webrtc - -import ( - "github.com/pion/ice/v2" - "github.com/pion/sdp/v3" - "github.com/pion/webrtc/v3" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "testing" -) - -func TestCandidates(t *testing.T) { - conf := &ice.CandidateHostConfig{ - Network: "udp", - Address: "192.168.1.123", - Port: 8555, - Component: ice.ComponentRTP, - } - cand, err := ice.NewCandidateHost(conf) - require.Nil(t, err) - assert.Equal(t, "candidate:"+cand.Marshal(), CandidateManualHostUDP(conf.Address, conf.Port)) - - conf = &ice.CandidateHostConfig{ - Network: "tcp", - Address: "192.168.1.123", - Port: 8555, - Component: ice.ComponentRTP, - TCPType: ice.TCPTypePassive, - } - cand, err = ice.NewCandidateHost(conf) - require.Nil(t, err) - assert.Equal(t, "candidate:"+cand.Marshal(), CandidateManualHostTCPPassive(conf.Address, conf.Port)) -} - -func TestPublicIP(t *testing.T) { - ip, err := GetPublicIP() - assert.Nil(t, err) - assert.NotNil(t, ip) - t.Logf("your public IP: %s", ip.String()) -} - -func TestMedia(t *testing.T) { - codec := webrtc.RTPCodecParameters{ - RTPCodecCapability: webrtc.RTPCodecCapability{ - MimeType: webrtc.MimeTypeH264, - ClockRate: 90000, - SDPFmtpLine: "level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f", - }, - PayloadType: 96, - } - - md := &sdp.MediaDescription{ - MediaName: sdp.MediaName{ - Media: "video", Protos: []string{"RTP", "AVP"}, - }, - } - md.WithCodec( - uint8(codec.PayloadType), codec.MimeType[6:], codec.ClockRate, - codec.Channels, codec.SDPFmtpLine, - ) - - sd := &sdp.SessionDescription{ - MediaDescriptions: []*sdp.MediaDescription{md}, - } - data, err := sd.Marshal() - assert.Nil(t, err) - assert.NotNil(t, data) -}