package aoiprxkit

import "testing"

func TestParseSAPPacket(t *testing.T) {
	payload := []byte("application/sdp\x00v=0\n" +
		"o=- 1 1 IN IP4 192.168.1.10\n" +
		"s=Test\n" +
		"c=IN IP4 239.69.0.1/32\n" +
		"t=0 0\n" +
		"m=audio 5004 RTP/AVP 97\n" +
		"a=rtpmap:97 L24/48000/2\n")
	pkt := []byte{
		0x20, // V=1, IPv4, announce, no enc/compress
		0x00, // auth len
		0x12, 0x34,
		192, 168, 1, 50,
	}
	pkt = append(pkt, payload...)

	got, err := ParseSAPPacket(pkt)
	if err != nil {
		t.Fatalf("unexpected err: %v", err)
	}
	if got.Version != 1 || got.MessageIDHash != 0x1234 || got.PayloadType != "application/sdp" || got.OriginSource.String() != "192.168.1.50" {
		t.Fatalf("unexpected SAP packet: %+v", got)
	}
}
