You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 line
2.8 KiB

  1. using JT808.Protocol.Formatters;
  2. using JT808.Protocol.MessagePack;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Text;
  6. namespace JT808.Protocol.Extensions.JT1078.MessageBody
  7. {
  8. /// <summary>
  9. /// 实时音视频传输请求
  10. /// </summary>
  11. public class JT808_0x9101:JT808Bodies, IJT808MessagePackFormatter<JT808_0x9101>
  12. {
  13. public override ushort MsgId => 0x9101;
  14. /// <summary>
  15. /// 服务器IP地址长度
  16. /// </summary>
  17. public byte ServerIPAddressLength { get; set; }
  18. /// <summary>
  19. /// 服务器IP地址
  20. /// </summary>
  21. public string ServerIPAddress { get; set; }
  22. /// <summary>
  23. /// 服务器视频通道监听端口号(TCP)
  24. /// </summary>
  25. public ushort ServerVideoChannelTcpPort { get; set; }
  26. /// <summary>
  27. /// 服务器视频通道监听端口号(UDP)
  28. /// </summary>
  29. public ushort ServerVideoChannelUdpPort { get; set; }
  30. /// <summary>
  31. /// 逻辑通道号
  32. /// </summary>
  33. public byte LogicalChannelNo { get; set; }
  34. /// <summary>
  35. /// 数据类型
  36. /// 0:音视频
  37. /// 1:视频
  38. /// 2:双向对讲
  39. /// 3:监听
  40. /// 4:中心广播
  41. /// 5:透传
  42. /// </summary>
  43. public byte DataType { get; set; }
  44. /// <summary>
  45. /// 码流类型
  46. /// 0:主码流
  47. /// 1:子码流
  48. /// </summary>
  49. public byte StreamType { get; set; }
  50. public JT808_0x9101 Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
  51. {
  52. JT808_0x9101 jT808_0X9101 = new JT808_0x9101();
  53. jT808_0X9101.ServerIPAddressLength = reader.ReadByte();
  54. jT808_0X9101.ServerIPAddress = reader.ReadString(jT808_0X9101.ServerIPAddressLength);
  55. jT808_0X9101.ServerVideoChannelTcpPort = reader.ReadUInt16();
  56. jT808_0X9101.ServerVideoChannelUdpPort = reader.ReadUInt16();
  57. jT808_0X9101.LogicalChannelNo = reader.ReadByte();
  58. jT808_0X9101.DataType = reader.ReadByte();
  59. jT808_0X9101.StreamType = reader.ReadByte();
  60. return jT808_0X9101;
  61. }
  62. public void Serialize(ref JT808MessagePackWriter writer, JT808_0x9101 value, IJT808Config config)
  63. {
  64. writer.Skip(1, out int position);
  65. writer.WriteString(value.ServerIPAddress);
  66. writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - position - 1), position);
  67. writer.WriteUInt16(value.ServerVideoChannelTcpPort);
  68. writer.WriteUInt16(value.ServerVideoChannelUdpPort);
  69. writer.WriteByte(value.LogicalChannelNo);
  70. writer.WriteByte(value.DataType);
  71. writer.WriteByte(value.StreamType);
  72. }
  73. }
  74. }