Go-based FM stereo transmitter with RDS, Windows-first and cross-platform
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
719B

  1. package aoiprxkit
  2. import "testing"
  3. func TestParseSAPPacket(t *testing.T) {
  4. payload := []byte("application/sdp\x00v=0\n" +
  5. "o=- 1 1 IN IP4 192.168.1.10\n" +
  6. "s=Test\n" +
  7. "c=IN IP4 239.69.0.1/32\n" +
  8. "t=0 0\n" +
  9. "m=audio 5004 RTP/AVP 97\n" +
  10. "a=rtpmap:97 L24/48000/2\n")
  11. pkt := []byte{
  12. 0x20, // V=1, IPv4, announce, no enc/compress
  13. 0x00, // auth len
  14. 0x12, 0x34,
  15. 192, 168, 1, 50,
  16. }
  17. pkt = append(pkt, payload...)
  18. got, err := ParseSAPPacket(pkt)
  19. if err != nil {
  20. t.Fatalf("unexpected err: %v", err)
  21. }
  22. if got.Version != 1 || got.MessageIDHash != 0x1234 || got.PayloadType != "application/sdp" || got.OriginSource.String() != "192.168.1.50" {
  23. t.Fatalf("unexpected SAP packet: %+v", got)
  24. }
  25. }