From ffd11da975c56a8d89a64e9543a04aaf3e01f265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B5=D0=BD=D0=B8=D1=81=20=D0=9A=D1=83=D0=B7=D0=BD?= =?UTF-8?q?=D0=B5=D1=86=D0=BE=D0=B2?= Date: Fri, 27 Oct 2023 12:19:25 +0300 Subject: [PATCH] 20231027-2 --- rtp.cs | 129 ++++++++++++++++++++++++++++-------------------------- udplib.cs | 86 +++++++++++++++++++----------------- 2 files changed, 113 insertions(+), 102 deletions(-) diff --git a/rtp.cs b/rtp.cs index 14286e9..9ce48f0 100644 --- a/rtp.cs +++ b/rtp.cs @@ -9,7 +9,9 @@ namespace nRTP public static class RTP { //RTPMsgHeader - private const UInt32 _len_pack = 50; + private const UInt32 _len_pack = 60; + private const UInt32 _len_head = 20; + private static UInt32 _len_data = _len_pack - _len_head; private static Byte _VerPXCC = 2; private static Byte _Ver = 2; // версия протокола (текущая версия 2) @@ -146,10 +148,10 @@ namespace nRTP public static Byte SD_rezerv; //RTPVideoSupplementalDataExtra - public static UInt32 DE_TLV_X; // Линия визирования цели в растроввых координатах - public static UInt32 DE_TLV_Y; // - public static UInt32 DE_TLV_dX; // поправки для линии визирования цели в растроввых координатах - public static UInt32 DE_TLV_dY; // + //public static UInt32 DE_TLV_X; // Линия визирования цели в растроввых координатах + //public static UInt32 DE_TLV_Y; // + //public static UInt32 DE_TLV_dX; // поправки для линии визирования цели в растроввых координатах + //public static UInt32 DE_TLV_dY; // public static UInt32 SeqCounter { @@ -164,47 +166,48 @@ namespace nRTP } } - public static Byte[] DataH0 = new Byte[76]; - public static Byte[] DataH1 = new Byte[20]; + public static Byte[] DataH0 = new Byte[_len_pack]; + //public static Byte[] DataH0 = new Byte[76]; + public static Byte[] DataH1 = new Byte[_len_head]; public static void MakeDataH0() { - Array.Copy(BitConverter.GetBytes(MH_VerPXCC), 0, DataH0, 0, 1); - Array.Copy(BitConverter.GetBytes(MH_MPT), 0, DataH0, 1, 1); - Array.Copy(BitConverter.GetBytes(MH_SeqCounter_Low), 0, DataH0, 2, 2); - Array.Copy(BitConverter.GetBytes(MH_Timestamp), 0, DataH0, 4, 4); - Array.Copy(BitConverter.GetBytes(MH_SSRC), 0, DataH0, 8, 4); - Array.Copy(BitConverter.GetBytes(MH_SeqCounter_Hi), 0, DataH0, 12, 2); - Array.Copy(BitConverter.GetBytes(MH_DataLen), 0, DataH0, 14, 2); - Array.Copy(BitConverter.GetBytes(MH_RowNumber), 0, DataH0, 16, 2); - Array.Copy(BitConverter.GetBytes(MH_Offset), 0, DataH0, 18, 2); - - Array.Copy(BitConverter.GetBytes(SD_Width), 0, DataH0, 20, 2); - Array.Copy(BitConverter.GetBytes(SD_Height), 0, DataH0, 22, 2); - Array.Copy(BitConverter.GetBytes(SD_AzUpr), 0, DataH0, 24, 4); - Array.Copy(BitConverter.GetBytes(SD_ElUpr), 0, DataH0, 28, 4); - - Array.Copy(BitConverter.GetBytes(SD_Shirota), 0, DataH0, 32, 4); - Array.Copy(BitConverter.GetBytes(SD_Dolgota), 0, DataH0, 36, 4); - Array.Copy(BitConverter.GetBytes(SD_Vysota), 0, DataH0, 40, 4); - - Array.Copy(BitConverter.GetBytes(SD_Course), 0, DataH0, 44, 2); - Array.Copy(BitConverter.GetBytes(SD_Roll), 0, DataH0, 46, 2); - Array.Copy(BitConverter.GetBytes(SD_Pitch), 0, DataH0, 48, 2); - Array.Copy(BitConverter.GetBytes(SD_FrameId), 0, DataH0, 50, 2); - - Array.Copy(BitConverter.GetBytes(rez0), 0, DataH0, 52, 2); - Array.Copy(BitConverter.GetBytes(rez1), 0, DataH0, 54, 2); - - Array.Copy(BitConverter.GetBytes(rez2), 0, DataH0, 56, 1); - Array.Copy(BitConverter.GetBytes(rez3), 0, DataH0, 57, 1); - Array.Copy(BitConverter.GetBytes(SD_Status), 0, DataH0, 58, 1); - Array.Copy(BitConverter.GetBytes(SD_rezerv), 0, DataH0, 59, 1); - - Array.Copy(BitConverter.GetBytes(DE_TLV_X), 0, DataH0, 60, 4); - Array.Copy(BitConverter.GetBytes(DE_TLV_Y), 0, DataH0, 64, 4); - Array.Copy(BitConverter.GetBytes(DE_TLV_dX), 0, DataH0, 68, 4); - Array.Copy(BitConverter.GetBytes(DE_TLV_dY), 0, DataH0, 72, 4); + Array.Copy(BitConverter.GetBytes(MH_VerPXCC), 0, DataH0, 0, 1); // 0 - 0 + Array.Copy(BitConverter.GetBytes(MH_MPT), 0, DataH0, 1, 1); // 1 - 1 + Array.Copy(BitConverter.GetBytes(MH_SeqCounter_Low), 0, DataH0, 2, 2); // 2 - 3 + Array.Copy(BitConverter.GetBytes(MH_Timestamp), 0, DataH0, 4, 4); // 4 - 7 + Array.Copy(BitConverter.GetBytes(MH_SSRC), 0, DataH0, 8, 4); // 8 - 11 + Array.Copy(BitConverter.GetBytes(MH_SeqCounter_Hi), 0, DataH0, 12, 2); // 12 - 13 + Array.Copy(BitConverter.GetBytes(MH_DataLen), 0, DataH0, 14, 2); // 14 - 15 + Array.Copy(BitConverter.GetBytes(MH_RowNumber), 0, DataH0, 16, 2); // 16 - 17 + Array.Copy(BitConverter.GetBytes(MH_Offset), 0, DataH0, 18, 2); // 18 - 19 + + Array.Copy(BitConverter.GetBytes(SD_Width), 0, DataH0, 20, 2); // 20 - 21 + Array.Copy(BitConverter.GetBytes(SD_Height), 0, DataH0, 22, 2); // 22 - 23 + Array.Copy(BitConverter.GetBytes(SD_AzUpr), 0, DataH0, 24, 4); // 24 - 27 + Array.Copy(BitConverter.GetBytes(SD_ElUpr), 0, DataH0, 28, 4); // 28 - 31 + + Array.Copy(BitConverter.GetBytes(SD_Shirota), 0, DataH0, 32, 4); // 32 - 35 + Array.Copy(BitConverter.GetBytes(SD_Dolgota), 0, DataH0, 36, 4); // 36 - 39 + Array.Copy(BitConverter.GetBytes(SD_Vysota), 0, DataH0, 40, 4); // 40 - 43 + + Array.Copy(BitConverter.GetBytes(SD_Course), 0, DataH0, 44, 2); // 44 - 45 + Array.Copy(BitConverter.GetBytes(SD_Roll), 0, DataH0, 46, 2); // 46 - 47 + Array.Copy(BitConverter.GetBytes(SD_Pitch), 0, DataH0, 48, 2); // 48 - 49 + Array.Copy(BitConverter.GetBytes(SD_FrameId), 0, DataH0, 50, 2); // 50 - 51 + + Array.Copy(BitConverter.GetBytes(rez0), 0, DataH0, 52, 2); // 52 - 53 + Array.Copy(BitConverter.GetBytes(rez1), 0, DataH0, 54, 2); // 54 - 55 + + Array.Copy(BitConverter.GetBytes(rez2), 0, DataH0, 56, 1); // 56 - 56 + Array.Copy(BitConverter.GetBytes(rez3), 0, DataH0, 57, 1); // 57 - 57 + Array.Copy(BitConverter.GetBytes(SD_Status), 0, DataH0, 58, 1); // 58 - 58 + Array.Copy(BitConverter.GetBytes(SD_rezerv), 0, DataH0, 59, 1); // 59 - 59 + + //Array.Copy(BitConverter.GetBytes(DE_TLV_X), 0, DataH0, 60, 4); // 60 - 63 + //Array.Copy(BitConverter.GetBytes(DE_TLV_Y), 0, DataH0, 64, 4); // 64 - 67 + //Array.Copy(BitConverter.GetBytes(DE_TLV_dX), 0, DataH0, 68, 4); // 68 - 71 + //Array.Copy(BitConverter.GetBytes(DE_TLV_dY), 0, DataH0, 72, 4); // 72 - 75 } public static void MakeDataH1() { @@ -246,10 +249,10 @@ namespace nRTP rez3 = DataH0[57]; SD_Status = DataH0[58]; SD_rezerv = DataH0[59]; - DE_TLV_X = BitConverter.ToUInt32(DataH0, 60); - DE_TLV_Y = BitConverter.ToUInt32(DataH0, 64); - DE_TLV_dX = BitConverter.ToUInt32(DataH0, 68); - DE_TLV_dY = BitConverter.ToUInt32(DataH0, 72); + //DE_TLV_X = BitConverter.ToUInt32(DataH0, 60); + //DE_TLV_Y = BitConverter.ToUInt32(DataH0, 64); + //DE_TLV_dX = BitConverter.ToUInt32(DataH0, 68); + //DE_TLV_dY = BitConverter.ToUInt32(DataH0, 72); } public static void GetDataH1() { @@ -268,7 +271,9 @@ namespace nRTP public static class RTPet { //RTPMsgHeader - private const UInt32 _len_pack = 50; + private const UInt32 _len_pack = 60; + private const UInt32 _len_head = 20; + private static UInt32 _len_data = _len_pack - _len_head; private static Byte _VerPXCC = 2; private static Byte _Ver = 2; // версия протокола (текущая версия 2) @@ -405,10 +410,10 @@ namespace nRTP public static Byte SD_rezerv; //RTPVideoSupplementalDataExtra - public static UInt32 DE_TLV_X; // Линия визирования цели в растроввых координатах - public static UInt32 DE_TLV_Y; // - public static UInt32 DE_TLV_dX; // поправки для линии визирования цели в растроввых координатах - public static UInt32 DE_TLV_dY; // + //public static UInt32 DE_TLV_X; // Линия визирования цели в растроввых координатах + //public static UInt32 DE_TLV_Y; // + //public static UInt32 DE_TLV_dX; // поправки для линии визирования цели в растроввых координатах + //public static UInt32 DE_TLV_dY; // public static UInt32 SeqCounter { @@ -423,8 +428,8 @@ namespace nRTP } } - public static Byte[] DataH0 = new Byte[76]; - public static Byte[] DataH1 = new Byte[20]; + public static Byte[] DataH0 = new Byte[_len_pack]; + public static Byte[] DataH1 = new Byte[_len_head]; public static void MakeDataH0() { @@ -460,10 +465,10 @@ namespace nRTP Array.Copy(BitConverter.GetBytes(SD_Status), 0, DataH0, 58, 1); Array.Copy(BitConverter.GetBytes(SD_rezerv), 0, DataH0, 59, 1); - Array.Copy(BitConverter.GetBytes(DE_TLV_X), 0, DataH0, 60, 4); - Array.Copy(BitConverter.GetBytes(DE_TLV_Y), 0, DataH0, 64, 4); - Array.Copy(BitConverter.GetBytes(DE_TLV_dX), 0, DataH0, 68, 4); - Array.Copy(BitConverter.GetBytes(DE_TLV_dY), 0, DataH0, 72, 4); + //Array.Copy(BitConverter.GetBytes(DE_TLV_X), 0, DataH0, 60, 4); + //Array.Copy(BitConverter.GetBytes(DE_TLV_Y), 0, DataH0, 64, 4); + //Array.Copy(BitConverter.GetBytes(DE_TLV_dX), 0, DataH0, 68, 4); + //Array.Copy(BitConverter.GetBytes(DE_TLV_dY), 0, DataH0, 72, 4); } public static void MakeDataH1() { @@ -505,10 +510,10 @@ namespace nRTP SD_ly = DataH0[57]; SD_Status = DataH0[58]; SD_rezerv = DataH0[59]; - DE_TLV_X = BitConverter.ToUInt32(DataH0, 60); - DE_TLV_Y = BitConverter.ToUInt32(DataH0, 64); - DE_TLV_dX = BitConverter.ToUInt32(DataH0, 68); - DE_TLV_dY = BitConverter.ToUInt32(DataH0, 72); + //DE_TLV_X = BitConverter.ToUInt32(DataH0, 60); + //DE_TLV_Y = BitConverter.ToUInt32(DataH0, 64); + //DE_TLV_dX = BitConverter.ToUInt32(DataH0, 68); + //DE_TLV_dY = BitConverter.ToUInt32(DataH0, 72); } public static void GetDataH1() { diff --git a/udplib.cs b/udplib.cs index ad29fe6..c58d01a 100644 --- a/udplib.cs +++ b/udplib.cs @@ -285,61 +285,67 @@ namespace UDPLIB //}; // RTPMsgHeader - RTP.MH_VerPXCC = 2; - RTP.MH_MPT = 0xC6; - RTP.SeqCounter = 0; //! - RTP.MH_Timestamp = (uint)DateTimeOffset.Now.ToUnixTimeSeconds(); //! - RTP.MH_PT = 99; - RTP.MH_M = 0; - RTP.MH_SSRC = 12345678; - RTP.MH_DataLen = 36; - RTP.MH_RowNumber = 0; - RTP.MH_Offset = 0; + RTPet.MH_VerPXCC = 2; + RTPet.MH_MPT = 0xC6; + RTPet.SeqCounter = 0; //! + RTPet.MH_Timestamp = (uint)DateTimeOffset.Now.ToUnixTimeSeconds(); //! + RTPet.MH_PT = 99; + RTPet.MH_M = 0; + RTPet.MH_SSRC = 12345678; + RTPet.MH_DataLen = 36; + RTPet.MH_RowNumber = 0; + RTPet.MH_Offset = 0; // RTPVideoSupplementalData - RTP.SD_Width = (ushort)Res.Crop.Width; - RTP.SD_Height = (ushort)Res.Crop.Height; - RTP.SD_AzUpr = 0; - RTP.SD_ElUpr = 0; - RTP.SD_Course = 0; - RTP.SD_Roll = 0; - RTP.SD_Pitch = 0; - RTP.SD_FrameId = 0; + RTPet.SD_Width = (ushort)Res.Crop.Width; + RTPet.SD_Height = (ushort)Res.Crop.Height; + RTPet.SD_AzUpr = 0; + RTPet.SD_ElUpr = 0; + RTPet.SD_Course = 0; + RTPet.SD_Roll = 0; + RTPet.SD_Pitch = 0; + RTPet.SD_FrameId = 0; + RTPet.SD_X = 0; + RTPet.SD_Y = 0; + RTPet.SD_lx = 0; + RTPet.SD_ly = 0; + RTPet.SD_rejim_oes = 0; + RTPet.SD_color = 0; // RTPVideoSupplementalDataExtra - RTP.DE_TLV_X = 0; - RTP.DE_TLV_Y = 0; - RTP.DE_TLV_dX = 0; - RTP.DE_TLV_dY = 0; + //RTP.DE_TLV_X = 0; + //RTP.DE_TLV_Y = 0; + //RTP.DE_TLV_dX = 0; + //RTP.DE_TLV_dY = 0; - RTP.MakeDataH0(); - transmitter.Send(RTP.DataH0, RTP.DataH0.Length); + RTPet.MakeDataH0(); + transmitter.Send(RTPet.DataH0, RTPet.DataH0.Length); - Byte[] dataudp = new Byte[20 + RTP.SD_Width * 3]; + Byte[] dataudp = new Byte[20 + RTPet.SD_Width * 3]; - Byte[] dataimg = new Byte[RTP.SD_Width * 3]; - for (int i = 0; i < RTP.SD_Height; i++) + Byte[] dataimg = new Byte[RTPet.SD_Width * 3]; + for (int i = 0; i < RTPet.SD_Height; i++) { // RTPMsgHeader - RTP.MH_VerPXCC = 2; - if (i == RTP.SD_Height - 1) + RTPet.MH_VerPXCC = 2; + if (i == RTPet.SD_Height - 1) { - RTP.MH_PT = 99; - RTP.MH_M = 1; + RTPet.MH_PT = 99; + RTPet.MH_M = 1; } else { - RTP.MH_PT = 99; - RTP.MH_M = 0; + RTPet.MH_PT = 99; + RTPet.MH_M = 0; } - ++RTP.SeqCounter; - RTP.MH_RowNumber = (ushort)(i + 1); - RTP.MH_DataLen = (ushort)(RTP.SD_Width * 3); - RTP.MakeDataH1(); + ++RTPet.SeqCounter; + RTPet.MH_RowNumber = (ushort)(i + 1); + RTPet.MH_DataLen = (ushort)(RTPet.SD_Width * 3); + RTPet.MakeDataH1(); uint ccc = 0; try { - for (int j = 0; j < RTP.SD_Width; j++) + for (int j = 0; j < RTPet.SD_Width; j++) { Color c = Res.Crop.GetPixel(j, i); dataimg[ccc++] = c.B; @@ -353,8 +359,8 @@ namespace UDPLIB Console.WriteLine("Error 4 getpixel"); return; } - Array.Copy(RTP.DataH1, dataudp, RTP.DataH1.Length); - Array.Copy(dataimg, 0, dataudp, RTP.DataH1.Length, dataimg.Length); + Array.Copy(RTPet.DataH1, dataudp, RTPet.DataH1.Length); + Array.Copy(dataimg, 0, dataudp, RTPet.DataH1.Length, dataimg.Length); transmitter.Send(dataudp, dataudp.Length); } transmitter.Close();