public void TestPacketSDP() { // property to flag SapPacket sap = new SapPacket() { Version = SAPLib.Version.SAPv1, AdressType = SAPLib.AdressType.IPv4, Reserved = SAPLib.Reserved.UnSet, MessageType = SAPLib.MessageType.Announcement, Encryption = false, Compression = false, MessageIdentifierHash = 0x5192, OriginatingSource = IPAddress.Parse("169.254.106.134"), }; StringBuilder sdp = new StringBuilder(); sdp.AppendLine("v=0"); sdp.AppendLine("o=- 1 0 IN IP4 169.254.106.134"); sdp.AppendLine("s=CoreAudio (on alexs-macbook-pro)_1"); sdp.AppendLine("c=IN IP4 239.1.106.134/15"); sdp.AppendLine("t=0 0"); sdp.AppendLine("a=clock-domain:PTPv2 0"); sdp.AppendLine("a=ts-refclk:ptp=IEEE1588-2008:00-1D-C1-FF-FE-91-C4-F5:0"); sdp.AppendLine("a=mediaclk:direct=0"); sdp.AppendLine("m=audio 5004 RTP/AVP 98"); sdp.AppendLine("c=IN IP4 239.1.106.134/15"); sdp.AppendLine("a=rtpmap:98 L24/44100/8"); sdp.AppendLine("a=source-filter: incl IN IP4 239.1.106.134 169.254.106.134"); sdp.AppendLine("a=clock-domain:PTPv2 0"); sdp.AppendLine("a=sync-time:0"); sdp.AppendLine("a=framecount:48"); sdp.AppendLine("a=palign:0"); sdp.AppendLine("a=ptime:1.08843541"); sdp.AppendLine("a=ts-refclk:ptp=IEEE1588-2008:00-1D-C1-FF-FE-91-C4-F5:0"); sdp.AppendLine("a=mediaclk:direct=0"); sdp.AppendLine("a=recvonly"); sap.AttachSDP(sdp); //Assert Assert.Equal( new byte[] { 0x20, 0x00, 0x92, 0x51, 0xa9, 0xfe, 0x6a, 0x86, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x73, 0x64, 0x70, 0x00, 0x76, 0x3d, 0x30, 0x0d, 0x0a, 0x6f, 0x3d, 0x2d, 0x20, 0x31, 0x20, 0x30, 0x20, 0x49, 0x4e, 0x20, 0x49, 0x50, 0x34, 0x20, 0x31, 0x36, 0x39, 0x2e, 0x32, 0x35, 0x34, 0x2e, 0x31, 0x30, 0x36, 0x2e, 0x31, 0x33, 0x34, 0x0d, 0x0a, 0x73, 0x3d, 0x43, 0x6f, 0x72, 0x65, 0x41, 0x75, 0x64, 0x69, 0x6f, 0x20, 0x28, 0x6f, 0x6e, 0x20, 0x61, 0x6c, 0x65, 0x78, 0x73, 0x2d, 0x6d, 0x61, 0x63, 0x62, 0x6f, 0x6f, 0x6b, 0x2d, 0x70, 0x72, 0x6f, 0x29, 0x5f, 0x31, 0x0d, 0x0a, 0x63, 0x3d, 0x49, 0x4e, 0x20, 0x49, 0x50, 0x34, 0x20, 0x32, 0x33, 0x39, 0x2e, 0x31, 0x2e, 0x31, 0x30, 0x36, 0x2e, 0x31, 0x33, 0x34, 0x2f, 0x31, 0x35, 0x0d, 0x0a, 0x74, 0x3d, 0x30, 0x20, 0x30, 0x0d, 0x0a, 0x61, 0x3d, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x2d, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x3a, 0x50, 0x54, 0x50, 0x76, 0x32, 0x20, 0x30, 0x0d, 0x0a, 0x61, 0x3d, 0x74, 0x73, 0x2d, 0x72, 0x65, 0x66, 0x63, 0x6c, 0x6b, 0x3a, 0x70, 0x74, 0x70, 0x3d, 0x49, 0x45, 0x45, 0x45, 0x31, 0x35, 0x38, 0x38, 0x2d, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x30, 0x30, 0x2d, 0x31, 0x44, 0x2d, 0x43, 0x31, 0x2d, 0x46, 0x46, 0x2d, 0x46, 0x45, 0x2d, 0x39, 0x31, 0x2d, 0x43, 0x34, 0x2d, 0x46, 0x35, 0x3a, 0x30, 0x0d, 0x0a, 0x61, 0x3d, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x63, 0x6c, 0x6b, 0x3a, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x3d, 0x30, 0x0d, 0x0a, 0x6d, 0x3d, 0x61, 0x75, 0x64, 0x69, 0x6f, 0x20, 0x35, 0x30, 0x30, 0x34, 0x20, 0x52, 0x54, 0x50, 0x2f, 0x41, 0x56, 0x50, 0x20, 0x39, 0x38, 0x0d, 0x0a, 0x63, 0x3d, 0x49, 0x4e, 0x20, 0x49, 0x50, 0x34, 0x20, 0x32, 0x33, 0x39, 0x2e, 0x31, 0x2e, 0x31, 0x30, 0x36, 0x2e, 0x31, 0x33, 0x34, 0x2f, 0x31, 0x35, 0x0d, 0x0a, 0x61, 0x3d, 0x72, 0x74, 0x70, 0x6d, 0x61, 0x70, 0x3a, 0x39, 0x38, 0x20, 0x4c, 0x32, 0x34, 0x2f, 0x34, 0x34, 0x31, 0x30, 0x30, 0x2f, 0x38, 0x0d, 0x0a, 0x61, 0x3d, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2d, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x3a, 0x20, 0x69, 0x6e, 0x63, 0x6c, 0x20, 0x49, 0x4e, 0x20, 0x49, 0x50, 0x34, 0x20, 0x32, 0x33, 0x39, 0x2e, 0x31, 0x2e, 0x31, 0x30, 0x36, 0x2e, 0x31, 0x33, 0x34, 0x20, 0x31, 0x36, 0x39, 0x2e, 0x32, 0x35, 0x34, 0x2e, 0x31, 0x30, 0x36, 0x2e, 0x31, 0x33, 0x34, 0x0d, 0x0a, 0x61, 0x3d, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x2d, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x3a, 0x50, 0x54, 0x50, 0x76, 0x32, 0x20, 0x30, 0x0d, 0x0a, 0x61, 0x3d, 0x73, 0x79, 0x6e, 0x63, 0x2d, 0x74, 0x69, 0x6d, 0x65, 0x3a, 0x30, 0x0d, 0x0a, 0x61, 0x3d, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x3a, 0x34, 0x38, 0x0d, 0x0a, 0x61, 0x3d, 0x70, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x30, 0x0d, 0x0a, 0x61, 0x3d, 0x70, 0x74, 0x69, 0x6d, 0x65, 0x3a, 0x31, 0x2e, 0x30, 0x38, 0x38, 0x34, 0x33, 0x35, 0x34, 0x31, 0x0d, 0x0a, 0x61, 0x3d, 0x74, 0x73, 0x2d, 0x72, 0x65, 0x66, 0x63, 0x6c, 0x6b, 0x3a, 0x70, 0x74, 0x70, 0x3d, 0x49, 0x45, 0x45, 0x45, 0x31, 0x35, 0x38, 0x38, 0x2d, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x30, 0x30, 0x2d, 0x31, 0x44, 0x2d, 0x43, 0x31, 0x2d, 0x46, 0x46, 0x2d, 0x46, 0x45, 0x2d, 0x39, 0x31, 0x2d, 0x43, 0x34, 0x2d, 0x46, 0x35, 0x3a, 0x30, 0x0d, 0x0a, 0x61, 0x3d, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x63, 0x6c, 0x6b, 0x3a, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x3d, 0x30, 0x0d, 0x0a, 0x61, 0x3d, 0x72, 0x65, 0x63, 0x76, 0x6f, 0x6e, 0x6c, 0x79, 0x0d, 0x0a } , sap); }
public Task StartAsync(CancellationToken cancellationToken) { _logger.LogInformation($"AES67Discovery Server started at: { DateTime.Now }"); _logger.LogInformation($"SapSettings: { JsonSerializer.Serialize(this._settings) }"); _sap = new SAPLib.SAPService() { Interval = TimeSpan.FromMilliseconds(_settings.Interval) }; _sap.OnMessageSend += delegate(Object o, MessageSendEventArgs args) { _logger.LogInformation("Send SAP/SDP packet (0x{0:X02})", args.Packet.MessageIdentifierHash); }; if (!String.IsNullOrEmpty(_settings.NetInterface)) { _logger.LogInformation($"Setting multicast send interface to: { _settings.NetInterface }"); _sap.SetSendInterface(IPAddress.Parse(_settings.NetInterface)); } foreach (string item in this._settings.SDPFiles) { try { SapPacket program = new SapPacket(); program.OriginatingSource = String.IsNullOrEmpty(_settings.NetInterface) ? SAPService.GetLocalIPAddress() : IPAddress.Parse(_settings.NetInterface);; program.AttachSDP(item); _sap.Program.Add(item, program); } catch (FileNotFoundException e) { _logger.LogError(e.Message); } catch (Exception e) { _logger.LogError(e.Message); } } _sap.Start(); return(Task.CompletedTask); }
public void FlagTest( SAPLib.Version version, SAPLib.AdressType adressType, SAPLib.Reserved reserved, SAPLib.MessageType messageType, bool encryption, bool compression, byte flag) { // property to flag SapPacket sap = new SapPacket() { Version = version, AdressType = adressType, Reserved = reserved, MessageType = messageType, Encryption = encryption, Compression = compression, }; //Assert Assert.Equal(flag, sap.Flag); // flag to property SapPacket sap1 = new SapPacket() { Flag = flag }; //Assert Assert.Equal(version, sap1.Version); Assert.Equal(adressType, sap1.AdressType); Assert.Equal(reserved, sap1.Reserved); Assert.Equal(messageType, sap1.MessageType); Assert.Equal(encryption, sap1.Encryption); Assert.Equal(compression, sap1.Compression); }