@@ -0,0 +1,31 @@ | |||
name: .NET Core | |||
on: [push] | |||
jobs: | |||
build: | |||
runs-on: ubuntu-latest | |||
steps: | |||
- uses: actions/checkout@master | |||
- name: Setup .NET Core | |||
uses: actions/setup-dotnet@master | |||
with: | |||
dotnet-version: 3.1.101 | |||
- name: dotnet info | |||
run: dotnet --info | |||
- name: dotnet restore | |||
run: dotnet restore ./src/JT1078.sln | |||
- name: dotnet JT1078.Protocol.Test build | |||
run: dotnet build ./src/JT1078.Protocol.Test/JT1078.Protocol.Test.csproj | |||
- name: dotnet JT1078.Protocol.Test test | |||
run: dotnet test ./src/JT1078.Protocol.Test/JT1078.Protocol.Test.csproj | |||
- name: dotnet JT808.Protocol.Extensions.JT1078.Test build | |||
run: dotnet build ./src/JT808.Protocol.Extensions.JT1078.Test/JT808.Protocol.Extensions.JT1078.Test.csproj | |||
- name: dotnet JT808.Protocol.Extensions.JT1078.Test test | |||
run: dotnet test ./src/JT808.Protocol.Extensions.JT1078.Test/JT808.Protocol.Extensions.JT1078.Test.csproj | |||
- name: dotnet JT809.Protocol.Extensions.JT1078.Test build | |||
run: dotnet build ./src/JT809.Protocol.Extensions.JT1078.Test/JT809.Protocol.Extensions.JT1078.Test.csproj | |||
- name: dotnet JT809.Protocol.Extensions.JT1078.Test test | |||
run: dotnet test ./src/JT809.Protocol.Extensions.JT1078.Test/JT809.Protocol.Extensions.JT1078.Test.csproj |
@@ -1,19 +0,0 @@ | |||
language: csharp | |||
solution: JT1078.sln | |||
dotnet: 3.1.100 | |||
os: linux | |||
mono: none | |||
dist: trusty2 | |||
script: | |||
- dotnet restore src/JT1078.sln | |||
- dotnet build src/JT1078.Protocol.Test/JT1078.Protocol.Test.csproj | |||
- dotnet test src/JT1078.Protocol.Test/JT1078.Protocol.Test.csproj | |||
- dotnet build src/JT808.Protocol.Extensions.JT1078.Test/JT808.Protocol.Extensions.JT1078.Test.csproj | |||
- dotnet test src/JT808.Protocol.Extensions.JT1078.Test/JT808.Protocol.Extensions.JT1078.Test.csproj | |||
- dotnet build src/JT809.Protocol.Extensions.JT1078.Test/JT809.Protocol.Extensions.JT1078.Test.csproj | |||
- dotnet test src/JT809.Protocol.Extensions.JT1078.Test/JT809.Protocol.Extensions.JT1078.Test.csproj | |||
after_success: | |||
- echo successful build! | |||
branches: | |||
only: | |||
- master |
@@ -8,7 +8,7 @@ | |||
3.1 [将1078的数据(h264)编码成FLV](#1078flv) | |||
3.2 [将1078的数据(h264)编码成HLS(尚未实现)](#1078HLS) | |||
[](https://github.com/SmallChi/JT1078/blob/master/LICENSE)[](https://travis-ci.org/SmallChi/JT1078) | |||
[](https://github.com/SmallChi/JT1078/blob/master/LICENSE)[]() | |||
## NuGet安装 | |||
@@ -159,18 +159,15 @@ Platform=AnyCpu Server=False Toolchain=.NET Core 3.1 | |||
### 关注点 | |||
1. 在组包Flv的时候需要注意PreviousTagSize这个属性,因为该属性涉及到了新老用户、以及主次码流切换是否能播放成功。 | |||
1. 在组包FLV的时候需要注意将解析的NALU值放入VideoTagsData中,格式:[NALU.Length 长度]+[NALU 值]...[NALU.Length 长度]+[NALU 值]可以存放多个NALU。 | |||
2. 在组包FLV的时候需要注意将解析的NALU值放入VideoTagsData中,格式:[NALU.Length 长度]+[NALU 值]...[NALU.Length 长度]+[NALU 值]可以存放多个NALU。 | |||
3. JT1078的属性大有用处。 | |||
2. JT1078的属性大有用处。 | |||
| JT1078属性 | FLV属性 | | |||
| :--- | :----| | |||
|Timestamp|JT1078的Timestamp为FLv的Timestamp累加值(当前的1078包与上一包1078的时间戳相减再进行累加)| | |||
|Timestamp|JT1078的Timestamp为FLv的Timestamp| | |||
|DataType|JT1078的DataType为FLv的FrameType的值(判断是否为关键帧)| | |||
|LastIFrameInterval|JT1078的LastIFrameInterval为FLv(关键帧)的CompositionTime值| | |||
|LastFrameInterval|JT1078的LastIFrameInterval为FLv(B/P帧)的CompositionTime值| | |||
|LastFrameInterval|JT1078的LastFrameInterval为FLv(B/P帧)的CompositionTime值| | |||
### 使用BenchmarkDotNet性能测试报告(只是玩玩,不能当真) | |||
@@ -20,306 +20,133 @@ namespace JT1078.Flv.Test | |||
[Fact] | |||
public void 测试第一帧的数据() | |||
{ | |||
JT1078Package Package = null; | |||
var lines = File.ReadAllLines(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "H264", "JT1078_1.txt")); | |||
int mergeBodyLength = 0; | |||
foreach (var line in lines) | |||
FileStream fileStream = null; | |||
try | |||
{ | |||
var data = line.Split(','); | |||
var bytes = data[6].ToHexBytes(); | |||
JT1078Package package = JT1078Serializer.Deserialize(bytes); | |||
mergeBodyLength += package.DataBodyLength; | |||
Package = JT1078Serializer.Merge(package); | |||
var lines = File.ReadAllLines(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "H264", "JT1078_1.txt")); | |||
var filepath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "H264", "JT1078_1.flv"); | |||
fileStream = new FileStream(filepath, FileMode.OpenOrCreate, FileAccess.Write); | |||
bool isNeedFirstHeadler = true; | |||
FlvEncoder encoder = new FlvEncoder(); | |||
foreach (var line in lines) | |||
{ | |||
var data = line.Split(','); | |||
var bytes = data[6].ToHexBytes(); | |||
JT1078Package package = JT1078Serializer.Deserialize(bytes); | |||
JT1078Package fullpackage = JT1078Serializer.Merge(package); | |||
if (fullpackage != null) | |||
{ | |||
var videoTag = encoder.EncoderVideoTag(fullpackage, isNeedFirstHeadler); | |||
fileStream.Write(videoTag); | |||
isNeedFirstHeadler = false; | |||
} | |||
} | |||
} | |||
H264Decoder decoder = new H264Decoder(); | |||
//7 8 6 5 1 1 1 1 1 7 8 6 5 1 1 1 1 | |||
var nalus = decoder.ParseNALU(Package); | |||
Assert.Equal(4, nalus.Count); | |||
catch (Exception ex) | |||
{ | |||
FlvEncoder encoder = new FlvEncoder(); | |||
var filepath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "H264", "JT1078_1.flv"); | |||
if (File.Exists(filepath)) | |||
} | |||
finally | |||
{ | |||
File.Delete(filepath); | |||
fileStream?.Close(); | |||
fileStream?.Dispose(); | |||
} | |||
FileStream fileStream = new FileStream(filepath, FileMode.OpenOrCreate, FileAccess.Write); | |||
fileStream.Write(encoder.EncoderFlvHeader()); | |||
fileStream.Write(encoder.EncoderScriptTag()); | |||
fileStream.Write(encoder.EncoderVideoTag(Package, true)); | |||
fileStream.Close(); | |||
} | |||
//[Fact] | |||
//public void 测试前几帧的数据() | |||
//{ | |||
// FileStream fileStream = null; | |||
// try | |||
// { | |||
// JT1078Package Package = null; | |||
// List<H264NALU> h264NALULs = new List<H264NALU>(); | |||
// H264Decoder decoder = new H264Decoder(); | |||
// FlvEncoder encoder = new FlvEncoder(); | |||
// var lines = File.ReadAllLines(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "H264", "JT1078_2.txt")); | |||
// foreach (var line in lines) | |||
// { | |||
// var data = line.Split(','); | |||
// var bytes = data[6].ToHexBytes(); | |||
// JT1078Package package = JT1078Serializer.Deserialize(bytes); | |||
// Package = JT1078Serializer.Merge(package); | |||
// if (Package != null) | |||
// { | |||
// var tmp = decoder.ParseNALU(Package); | |||
// if (tmp != null && tmp.Count > 0) | |||
// { | |||
// h264NALULs = h264NALULs.Concat(tmp).ToList(); | |||
// } | |||
// } | |||
// } | |||
// var filepath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "H264", "JT1078_2.flv"); | |||
// if (File.Exists(filepath)) | |||
// { | |||
// File.Delete(filepath); | |||
// } | |||
// fileStream = new FileStream(filepath, FileMode.OpenOrCreate, FileAccess.Write); | |||
// fileStream.Write(FlvEncoder.VideoFlvHeaderBuffer); | |||
// var totalPage = (h264NALULs.Count + 10 - 1) / 10; | |||
// for (var i = 0; i < totalPage; i++) | |||
// { | |||
// var flv2 = encoder.CreateFlvFrame(h264NALULs.Skip(i * 10).Take(10).ToList()); | |||
// if (flv2.Length != 0) | |||
// { | |||
// fileStream.Write(flv2); | |||
// } | |||
// } | |||
// } | |||
// catch (Exception ex) | |||
// { | |||
// } | |||
// finally | |||
// { | |||
// fileStream?.Close(); | |||
// fileStream?.Dispose(); | |||
// } | |||
//} | |||
//[Fact] | |||
//public void 测试可以播放的Flv1() | |||
//{ | |||
// FileStream fileStream = null; | |||
// H264Decoder decoder = new H264Decoder(); | |||
// List<H264NALU> h264NALULs = new List<H264NALU>(); | |||
// FlvEncoder encoder = new FlvEncoder(); | |||
// try | |||
// { | |||
// var filepath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "H264", "JT1078_3.flv"); | |||
// var lines = File.ReadAllLines(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "H264", "JT1078_3.txt")); | |||
// if (File.Exists(filepath)) | |||
// { | |||
// File.Delete(filepath); | |||
// } | |||
// JT1078Package Package = null; | |||
// foreach (var line in lines) | |||
// { | |||
// var data = line.Split(','); | |||
// var bytes = data[6].ToHexBytes(); | |||
// JT1078Package package = JT1078Serializer.Deserialize(bytes); | |||
// Package = JT1078Serializer.Merge(package); | |||
// if (Package != null) | |||
// { | |||
// var tmp = decoder.ParseNALU(Package); | |||
// if (tmp != null && tmp.Count > 0) | |||
// { | |||
// h264NALULs = h264NALULs.Concat(tmp).ToList(); | |||
// } | |||
// } | |||
// } | |||
// fileStream = new FileStream(filepath, FileMode.OpenOrCreate, FileAccess.Write); | |||
// fileStream.Write(FlvEncoder.VideoFlvHeaderBuffer); | |||
// var totalPage = (h264NALULs.Count + 10 - 1) / 10; | |||
// for (var i = 0; i < totalPage; i++) | |||
// { | |||
// var flv2 = encoder.CreateFlvFrame(h264NALULs.Skip(i * 10).Take(10).ToList()); | |||
// if (flv2.Length != 0) | |||
// { | |||
// fileStream.Write(flv2); | |||
// } | |||
// } | |||
// } | |||
// catch (Exception ex) | |||
// { | |||
// Assert.Throws<Exception>(() => { }); | |||
// } | |||
// finally | |||
// { | |||
// fileStream?.Close(); | |||
// fileStream?.Dispose(); | |||
// } | |||
//} | |||
//[Fact] | |||
//public void 测试可以播放的Flv2() | |||
//{ | |||
// FileStream fileStream = null; | |||
// H264Decoder decoder = new H264Decoder(); | |||
// List<H264NALU> h264NALULs = new List<H264NALU>(); | |||
// FlvEncoder encoder = new FlvEncoder(); | |||
// try | |||
// { | |||
// var filepath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "H264", "JT1078_4.flv"); | |||
// var lines = File.ReadAllLines(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "H264", "JT1078_4.txt")); | |||
// if (File.Exists(filepath)) | |||
// { | |||
// File.Delete(filepath); | |||
// } | |||
// JT1078Package Package = null; | |||
// foreach (var line in lines) | |||
// { | |||
// var data = line.Split(','); | |||
// var bytes = data[6].ToHexBytes(); | |||
// JT1078Package package = JT1078Serializer.Deserialize(bytes); | |||
// Package = JT1078Serializer.Merge(package); | |||
// if (Package != null) | |||
// { | |||
// var tmp = decoder.ParseNALU(Package); | |||
// if (tmp != null && tmp.Count > 0) | |||
// { | |||
// h264NALULs = h264NALULs.Concat(tmp).ToList(); | |||
// } | |||
// } | |||
// } | |||
// fileStream = new FileStream(filepath, FileMode.OpenOrCreate, FileAccess.Write); | |||
// fileStream.Write(FlvEncoder.VideoFlvHeaderBuffer); | |||
// var totalPage = (h264NALULs.Count + 10 - 1) / 10; | |||
// for (var i = 0; i < totalPage; i++) | |||
// { | |||
// var flv2 = encoder.CreateFlvFrame(h264NALULs.Skip(i * 10).Take(10).ToList()); | |||
// if (flv2.Length != 0) | |||
// { | |||
// fileStream.Write(flv2); | |||
// } | |||
// } | |||
// } | |||
// catch (Exception ex) | |||
// { | |||
// Assert.Throws<Exception>(() => { }); | |||
// } | |||
// finally | |||
// { | |||
// fileStream?.Close(); | |||
// fileStream?.Dispose(); | |||
// } | |||
//} | |||
//[Fact] | |||
//public void 测试主次码流切换() | |||
//{ | |||
// FileStream fileStream = null; | |||
// H264Decoder decoder = new H264Decoder(); | |||
// List<H264NALU> h264NALULs = new List<H264NALU>(); | |||
// FlvEncoder encoder = new FlvEncoder(); | |||
// try | |||
// { | |||
// var filepath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "H264", "JT1078_5.flv"); | |||
// var lines = File.ReadAllLines(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "H264", "JT1078_5.txt")); | |||
// if (File.Exists(filepath)) | |||
// { | |||
// File.Delete(filepath); | |||
// } | |||
// JT1078Package Package = null; | |||
[Fact] | |||
public void 测试前几帧的数据() | |||
{ | |||
FileStream fileStream = null; | |||
try | |||
{ | |||
var lines = File.ReadAllLines(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "H264", "JT1078_2.txt")); | |||
var filepath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "H264", "JT1078_2.flv"); | |||
fileStream = new FileStream(filepath, FileMode.OpenOrCreate, FileAccess.Write); | |||
bool isNeedFirstHeadler = true; | |||
FlvEncoder encoder = new FlvEncoder(); | |||
foreach (var line in lines) | |||
{ | |||
var data = line.Split(','); | |||
var bytes = data[6].ToHexBytes(); | |||
JT1078Package package = JT1078Serializer.Deserialize(bytes); | |||
JT1078Package fullpackage = JT1078Serializer.Merge(package); | |||
if (fullpackage != null) | |||
{ | |||
var videoTag = encoder.EncoderVideoTag(fullpackage, isNeedFirstHeadler); | |||
fileStream.Write(videoTag); | |||
isNeedFirstHeadler = false; | |||
} | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
// foreach (var line in lines) | |||
// { | |||
// var data = line.Split(','); | |||
// var bytes = data[6].ToHexBytes(); | |||
// JT1078Package package = JT1078Serializer.Deserialize(bytes); | |||
// Package = JT1078Serializer.Merge(package); | |||
// if (Package != null) | |||
// { | |||
// var tmp = decoder.ParseNALU(Package); | |||
// if (tmp != null && tmp.Count > 0) | |||
// { | |||
// h264NALULs = h264NALULs.Concat(tmp).ToList(); | |||
// } | |||
// } | |||
// } | |||
// var tmp1 = h264NALULs.Where(w => w.NALUHeader.NalUnitType == 7).ToList(); | |||
// List<SPSInfo> tmpSpss = new List<SPSInfo>(); | |||
// List<ulong> times = new List<ulong>(); | |||
// List<ushort> lastIFrameIntervals = new List<ushort>(); | |||
// List<ushort> lastFrameIntervals = new List<ushort>(); | |||
// List<int> type = new List<int>(); | |||
// foreach (var item in h264NALULs) | |||
// { | |||
// //type.Add(item.NALUHeader.NalUnitType); | |||
// times.Add(item.Timestamp); | |||
// lastFrameIntervals.Add(item.LastFrameInterval); | |||
// lastIFrameIntervals.Add(item.LastIFrameInterval); | |||
// if (item.NALUHeader.NalUnitType == 7) | |||
// { | |||
// ExpGolombReader expGolombReader = new ExpGolombReader(item.RawData); | |||
// tmpSpss.Add(expGolombReader.ReadSPS()); | |||
// } | |||
// } | |||
// fileStream = new FileStream(filepath, FileMode.OpenOrCreate, FileAccess.Write); | |||
// var totalPage = (h264NALULs.Count + 10 - 1) / 10; | |||
// for (var i = 0; i < totalPage; i++) | |||
// { | |||
// var flv2 = encoder.CreateFlvFrame(h264NALULs.Skip(i * 10).Take(10).ToList()); | |||
// if (flv2.Length != 0) | |||
// { | |||
// //fileStream.Write(flv2); | |||
// } | |||
// } | |||
// } | |||
// catch (Exception ex) | |||
// { | |||
// Assert.Throws<Exception>(() => { }); | |||
// } | |||
// finally | |||
// { | |||
// fileStream?.Close(); | |||
// fileStream?.Dispose(); | |||
// } | |||
//} | |||
} | |||
finally | |||
{ | |||
fileStream?.Close(); | |||
fileStream?.Dispose(); | |||
} | |||
} | |||
//[Fact] | |||
//public void CreateScriptTagFrameTest() | |||
//{ | |||
// FlvEncoder flvEncoder = new FlvEncoder(); | |||
// var hexData = flvEncoder.CreateScriptTagFrame(288, 352); | |||
// Assert.Equal(151, hexData.Length); | |||
//} | |||
[Fact] | |||
public void 测试可以播放的Flv3() | |||
{ | |||
FileStream fileStream = null; | |||
try | |||
{ | |||
var filepath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "H264", "JT1078_3.flv"); | |||
var lines = File.ReadAllLines(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "H264", "JT1078_3.txt")); | |||
fileStream = new FileStream(filepath, FileMode.OpenOrCreate, FileAccess.Write); | |||
bool isNeedFirstHeadler = true; | |||
FlvEncoder encoder = new FlvEncoder(); | |||
foreach (var line in lines) | |||
{ | |||
var data = line.Split(','); | |||
var bytes = data[6].ToHexBytes(); | |||
JT1078Package package = JT1078Serializer.Deserialize(bytes); | |||
JT1078Package fullpackage = JT1078Serializer.Merge(package); | |||
if (fullpackage != null) | |||
{ | |||
var videoTag = encoder.EncoderVideoTag(fullpackage, isNeedFirstHeadler); | |||
fileStream.Write(videoTag); | |||
isNeedFirstHeadler = false; | |||
} | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
Assert.Throws<Exception>(() => { }); | |||
} | |||
finally | |||
{ | |||
fileStream?.Close(); | |||
fileStream?.Dispose(); | |||
} | |||
} | |||
//[Fact] | |||
//public void CreateVideoTag0FrameTest() | |||
//{ | |||
// FlvEncoder flvEncoder = new FlvEncoder(); | |||
// var hexData = flvEncoder.CreateVideoTag0Frame( | |||
// new byte[] { 0x67, 0x4D, 0, 0x14, 0x95, 0xA8, 0x58, 0x25, 0x90 }, | |||
// new byte[] { 0x68, 0xEE, 0x3C, 0x80 }, | |||
// new SPSInfo { levelIdc = 0x14, profileIdc = 0x4d, profileCompat = 0 }); | |||
// Assert.Equal(40, hexData.Length); | |||
//} | |||
[Fact] | |||
public void EncoderScriptTag() | |||
{ | |||
FlvEncoder flvEncoder = new FlvEncoder(); | |||
var hexData = flvEncoder.EncoderScriptTag(new SPSInfo { width = 288, height = 352 }); | |||
Assert.Equal(155, hexData.Length); | |||
} | |||
//[Fact] | |||
//public void GetFirstFlvFrameTest() | |||
//{ | |||
// FlvEncoder flvEncoder = new FlvEncoder(); | |||
// string key = "test"; | |||
// var bufferFlvFrame = new byte[] { 0xA, 0xB, 0xC, 0xD, 0xE, 0xF }; | |||
// FlvEncoder.FirstFlvFrameCache.TryAdd(key, (2, new byte[] { 1, 2, 3, 4, 5, 6 }, true)); | |||
// var buffer = flvEncoder.GetFirstFlvFrame(key, bufferFlvFrame); | |||
// //替换PreviousTagSize 4位的长度为首帧的 PreviousTagSize | |||
// Assert.Equal(new byte[] { 1, 2, 3, 4, 5, 6, 0, 0, 0, 2, 0xE, 0xF }, buffer); | |||
//} | |||
[Fact] | |||
public void EncoderFirstVideoTag() | |||
{ | |||
FlvEncoder flvEncoder = new FlvEncoder(); | |||
var hexData = flvEncoder.EncoderFirstVideoTag( | |||
new SPSInfo { levelIdc = 0x14, profileIdc = 0x4d, profileCompat = 0 }, | |||
new H264NALU { RawData = new byte[] { 0x67, 0x4D, 0, 0x14, 0x95, 0xA8, 0x58, 0x25, 0x90 } }, | |||
new H264NALU { RawData = new byte[] { 0x68, 0xEE, 0x3C, 0x80 } }, | |||
new H264NALU() | |||
); | |||
Assert.Equal(44, hexData.Length); | |||
} | |||
} | |||
} |
@@ -12,6 +12,9 @@ namespace JT1078.Flv.Test | |||
{ | |||
public class H264ToFlvTest | |||
{ | |||
/// <summary> | |||
/// jt1078 转成 H264数据包 | |||
/// </summary> | |||
[Fact] | |||
public void Test_1() | |||
{ | |||
@@ -22,7 +22,8 @@ namespace JT1078.Flv | |||
/// </para> | |||
/// | |||
/// 手动编码 | |||
/// 1、<see cref="EncoderFlvHeader"/> | |||
/// 0、<see cref="EncoderFlvHeader"/> | |||
/// 1、插入 PriviousTagSize =0 always equal 0 | |||
/// 2、<see cref="EncoderScriptTag"/> | |||
/// 3、<see cref="EncoderFirstVideoTag"/> | |||
/// 4、<see cref="EncoderFirstAudioTag"/> | |||
@@ -36,11 +37,8 @@ namespace JT1078.Flv | |||
/// </summary> | |||
public class FlvEncoder : IDisposable | |||
{ | |||
uint previousTagSize; | |||
FlvHeader flvHeader = new FlvHeader(true, true); | |||
readonly FaacEncoder faacEncoder; | |||
readonly H264Decoder h264Decoder = new H264Decoder(); | |||
public FlvEncoder(int sampleRate = 8000, int channels = 1, int sampleBit = 16, bool adts = false) | |||
{ | |||
faacEncoder = new FaacEncoder(sampleRate, channels, sampleBit, adts); | |||
@@ -48,32 +46,24 @@ namespace JT1078.Flv | |||
/// <summary> | |||
/// 编码flv头 | |||
/// <para> | |||
/// 注意:本方法已写入<see cref="previousTagSize"/> | |||
/// </para> | |||
/// </summary> | |||
/// <param name="hasVideo"></param> | |||
/// <param name="hasAudio"></param> | |||
/// <param name="hasVideo">是否有视频</param> | |||
/// <param name="hasAudio">是否有音频</param> | |||
/// <returns></returns> | |||
public byte[] EncoderFlvHeader(bool hasVideo = true, bool hasAudio = false) | |||
{ | |||
previousTagSize = 0; | |||
flvHeader = new FlvHeader(hasVideo, hasAudio); | |||
var flvHeader = new FlvHeader(hasVideo, hasAudio); | |||
return flvHeader.ToArray().ToArray(); | |||
} | |||
/// <summary> | |||
/// 编码脚本Tag | |||
/// <para> | |||
/// 注意:本方法已写入<see cref="previousTagSize"/> | |||
/// </para> | |||
/// </summary> | |||
/// <param name="width">视频宽度</param> | |||
/// <param name="height">视频高度</param> | |||
/// <param name="hasAudio">是否含有音频,如果有,则写入音频配置,后来发现即便是有音频,这里给<c>false</c>也没关系</param> | |||
/// <param name="frameRate">帧率</param> | |||
/// <param name="spsInfo">解析后的sps信息</param> | |||
/// <param name="hasAudio">是否有音频</param> | |||
/// <param name="frameRate">帧率 默认25d 即每秒25帧</param> | |||
/// <returns></returns> | |||
public byte[] EncoderScriptTag(bool hasAudio = false, double frameRate = 25d) | |||
public byte[] EncoderScriptTag(SPSInfo spsInfo, bool hasAudio = false, double frameRate = 25d) | |||
{ | |||
byte[] buffer = FlvArrayPool.Rent(1024); | |||
try | |||
@@ -93,8 +83,12 @@ namespace JT1078.Flv | |||
new Amf3Metadata_VideoDataRate{Value = 0d}, | |||
new Amf3Metadata_VideoCodecId{Value = 7d}, | |||
new Amf3Metadata_FrameRate{Value = frameRate}, | |||
new Amf3Metadata_Width(), | |||
new Amf3Metadata_Height(), | |||
new Amf3Metadata_Width(){ | |||
Value=spsInfo.width | |||
}, | |||
new Amf3Metadata_Height(){ | |||
Value=spsInfo.height | |||
}, | |||
} | |||
} | |||
}; | |||
@@ -105,11 +99,9 @@ namespace JT1078.Flv | |||
flvTags.DataTagsData.Amf3Metadatas.Add(new Amf3Metadata_AudioSampleSize()); | |||
flvTags.DataTagsData.Amf3Metadatas.Add(new Amf3Metadata_AudioStereo()); | |||
} | |||
flvMessagePackWriter.WriteUInt32(previousTagSize); | |||
flvMessagePackWriter.WriteFlvTag(flvTags); | |||
var data = flvMessagePackWriter.FlushAndGetArray(); | |||
previousTagSize = (uint)(flvTags.DataSize + 11); | |||
return data; | |||
flvMessagePackWriter.WriteUInt32((uint)(flvTags.DataSize + 11)); | |||
return flvMessagePackWriter.FlushAndGetArray(); | |||
} | |||
finally | |||
{ | |||
@@ -118,24 +110,19 @@ namespace JT1078.Flv | |||
} | |||
/// <summary> | |||
/// 编码首帧视频,即videoTag[0] | |||
/// <para> | |||
/// 注意:本方法已写入<see cref="previousTagSize"/> | |||
/// </para> | |||
/// 编码首帧视频,即videoTag[0] | |||
/// </summary> | |||
/// <param name="spsInfo">sps 解析后的数据</param> | |||
/// <param name="sps"></param> | |||
/// <param name="pps"></param> | |||
/// <param name="sei"></param> | |||
/// <returns></returns> | |||
public byte[] EncoderFirstVideoTag(H264NALU sps, H264NALU pps, H264NALU sei) | |||
public byte[] EncoderFirstVideoTag(SPSInfo spsInfo, H264NALU sps, H264NALU pps, H264NALU sei) | |||
{ | |||
byte[] buffer = FlvArrayPool.Rent(2048); | |||
try | |||
{ | |||
FlvMessagePackWriter flvMessagePackWriter = new FlvMessagePackWriter(buffer); | |||
var rawData = h264Decoder.DiscardEmulationPreventionBytes(sps.RawData); | |||
ExpGolombReader h264GolombReader = new ExpGolombReader(rawData); | |||
SPSInfo spsInfo = h264GolombReader.ReadSPS(); | |||
//flv body video tag | |||
//flv body tag header | |||
FlvTags flvTags = new FlvTags | |||
@@ -163,11 +150,9 @@ namespace JT1078.Flv | |||
SPSBuffer = sps.RawData | |||
}; | |||
flvTags.VideoTagsData.VideoData.AVCDecoderConfiguration = aVCDecoderConfigurationRecord; | |||
flvMessagePackWriter.WriteUInt32(previousTagSize); | |||
flvMessagePackWriter.WriteFlvTag(flvTags); | |||
var data = flvMessagePackWriter.FlushAndGetArray(); | |||
previousTagSize = (uint)(flvTags.DataSize + 11); | |||
return data; | |||
flvMessagePackWriter.WriteUInt32((uint)(flvTags.DataSize + 11)); | |||
return flvMessagePackWriter.FlushAndGetArray(); | |||
} | |||
finally | |||
{ | |||
@@ -177,10 +162,8 @@ namespace JT1078.Flv | |||
/// <summary> | |||
/// 编码首帧音频,即audioTag[0] | |||
/// <para> | |||
/// 注意:本方法已写入<see cref="previousTagSize"/> | |||
/// </para> | |||
/// </summary> | |||
/// <param name="timestamp"></param> | |||
/// <returns></returns> | |||
public byte[] EncoderFirstAudioTag(ulong timestamp) | |||
{ | |||
@@ -197,11 +180,9 @@ namespace JT1078.Flv | |||
//flv body tag body | |||
AudioTagsData = new AudioTags(AACPacketType.AudioSpecificConfig) | |||
}; | |||
flvMessagePackWriter.WriteUInt32(previousTagSize); | |||
flvMessagePackWriter.WriteFlvTag(flvTags); | |||
var data = flvMessagePackWriter.FlushAndGetArray(); | |||
previousTagSize = (uint)(flvTags.DataSize + 11); | |||
return data; | |||
flvMessagePackWriter.WriteUInt32((uint)(flvTags.DataSize + 11)); | |||
return flvMessagePackWriter.FlushAndGetArray(); | |||
} | |||
finally | |||
{ | |||
@@ -210,9 +191,9 @@ namespace JT1078.Flv | |||
} | |||
/// <summary> | |||
/// 编码非首帧视频 | |||
/// 编码视频 | |||
/// </summary> | |||
/// <param name="package"></param> | |||
/// <param name="package">1078包</param> | |||
/// <param name="needVideoHeader">是否需要首帧视频</param> | |||
/// <returns></returns> | |||
public byte[] EncoderVideoTag(JT1078Package package, bool needVideoHeader = false) | |||
@@ -231,14 +212,30 @@ namespace JT1078.Flv | |||
nalus.Remove(sei); | |||
if (needVideoHeader) | |||
{ | |||
var firstVideoTag = EncoderFirstVideoTag(sps, pps, sei); | |||
//flv header | |||
var flvHeader = EncoderFlvHeader(true, false); | |||
flvMessagePackWriter.WriteArray(flvHeader); | |||
// always 0 | |||
flvMessagePackWriter.WriteUInt32(0); | |||
//解析sps | |||
if (sps == null) | |||
{ | |||
return null; | |||
} | |||
var rawData = h264Decoder.DiscardEmulationPreventionBytes(sps.RawData); | |||
ExpGolombReader h264GolombReader = new ExpGolombReader(rawData); | |||
SPSInfo spsInfo = h264GolombReader.ReadSPS(); | |||
//script tag | |||
var scriptTag = EncoderScriptTag(spsInfo); | |||
flvMessagePackWriter.WriteArray(scriptTag); | |||
// first video tag | |||
var firstVideoTag = EncoderFirstVideoTag(spsInfo, sps, pps, sei); | |||
flvMessagePackWriter.WriteArray(firstVideoTag); | |||
} | |||
foreach (var naln in nalus) | |||
{ | |||
flvMessagePackWriter.WriteUInt32(previousTagSize); | |||
var videoTag = ConversionNaluToVideoTag(naln); | |||
flvMessagePackWriter.WriteArray(videoTag); | |||
var otherVideoTag = EncoderOtherVideoTag(naln); | |||
flvMessagePackWriter.WriteArray(otherVideoTag); | |||
} | |||
} | |||
return flvMessagePackWriter.FlushAndGetArray(); | |||
@@ -280,15 +277,17 @@ namespace JT1078.Flv | |||
} | |||
if (aacFrameData != null && aacFrameData.Any())//编码成功,此时为一帧aac音频数据 | |||
{ | |||
// PreviousTagSize | |||
flvMessagePackWriter.WriteUInt32(previousTagSize); | |||
// Data Tag Frame | |||
flvMessagePackWriter.WriteArray(ConversionAacDataToAudioTag((uint)package.Timestamp, aacFrameData)); | |||
flvMessagePackWriter.WriteArray(EncoderAacAudioTag((uint)package.Timestamp, aacFrameData)); | |||
} | |||
return flvMessagePackWriter.FlushAndGetArray(); | |||
} | |||
byte[] ConversionNaluToVideoTag(H264NALU nALU) | |||
/// <summary> | |||
/// 编码非首帧视频 | |||
/// </summary> | |||
/// <param name="nALU"></param> | |||
/// <returns></returns> | |||
public byte[] EncoderOtherVideoTag(H264NALU nALU) | |||
{ | |||
byte[] buffer = FlvArrayPool.Rent(65535); | |||
try | |||
@@ -330,9 +329,8 @@ namespace JT1078.Flv | |||
// flvTags.VideoTagsData.VideoData.MultiData.Add(sei.RawData); | |||
//} | |||
flvMessagePackWriter.WriteFlvTag(flvTags); | |||
var data = flvMessagePackWriter.FlushAndGetArray(); | |||
previousTagSize = (uint)(flvTags.DataSize + 11); | |||
return data; | |||
flvMessagePackWriter.WriteUInt32((uint)(flvTags.DataSize + 11)); | |||
return flvMessagePackWriter.FlushAndGetArray(); | |||
} | |||
finally | |||
{ | |||
@@ -340,7 +338,7 @@ namespace JT1078.Flv | |||
} | |||
} | |||
byte[] ConversionAacDataToAudioTag(uint timestamp, byte[] aacFrameData) | |||
byte[] EncoderAacAudioTag(uint timestamp, byte[] aacFrameData) | |||
{ | |||
byte[] buffer = FlvArrayPool.Rent(65535); | |||
try | |||
@@ -358,7 +356,7 @@ namespace JT1078.Flv | |||
AudioTagsData = new AudioTags(AACPacketType.AudioFrame, aacFrameData) | |||
}; | |||
flvMessagePackWriter.WriteFlvTag(flvTags); | |||
previousTagSize = (uint)(flvTags.DataSize + 11); | |||
flvMessagePackWriter.WriteUInt32((uint)(flvTags.DataSize + 11)); | |||
return flvMessagePackWriter.FlushAndGetArray(); | |||
} | |||
finally | |||
@@ -10,7 +10,7 @@ namespace JT1078.Flv | |||
/// Tag Data部分大小 | |||
/// 3个字节 | |||
/// </summary> | |||
public uint DataSize { get; set; } | |||
public int DataSize { get; set; } | |||
/// <summary> | |||
/// Tag时间戳 | |||
/// 3个字节 | |||
@@ -214,73 +214,63 @@ | |||
</para> | |||
手动编码 | |||
1、<see cref="M:JT1078.Flv.FlvEncoder.DecoderFlvHeader(System.Boolean,System.Boolean)"/> | |||
2、<see cref="M:JT1078.Flv.FlvEncoder.DecoderScriptTag(System.Boolean,System.Double)"/> | |||
3、<see cref="M:JT1078.Flv.FlvEncoder.DecoderFirstVideoTag(JT1078.Protocol.H264.H264NALU,JT1078.Protocol.H264.H264NALU,JT1078.Protocol.H264.H264NALU)"/> | |||
4、<see cref="M:JT1078.Flv.FlvEncoder.DecoderFirstAudioTag(System.UInt64)"/> | |||
5、<see cref="M:JT1078.Flv.FlvEncoder.DecoderVideoTag(JT1078.Protocol.JT1078Package,System.Boolean)"/>第二个参数传false | |||
6、<see cref="M:JT1078.Flv.FlvEncoder.DecoderAudioTag(JT1078.Protocol.JT1078Package,System.Boolean)"/>第二个参数传false | |||
0、<see cref="M:JT1078.Flv.FlvEncoder.EncoderFlvHeader(System.Boolean,System.Boolean)"/> | |||
1、插入 PriviousTagSize =0 always equal 0 | |||
2、<see cref="M:JT1078.Flv.FlvEncoder.EncoderScriptTag(JT1078.Protocol.MessagePack.SPSInfo,System.Boolean,System.Double)"/> | |||
3、<see cref="M:JT1078.Flv.FlvEncoder.EncoderFirstVideoTag(JT1078.Protocol.MessagePack.SPSInfo,JT1078.Protocol.H264.H264NALU,JT1078.Protocol.H264.H264NALU,JT1078.Protocol.H264.H264NALU)"/> | |||
4、<see cref="M:JT1078.Flv.FlvEncoder.EncoderFirstAudioTag(System.UInt64)"/> | |||
5、<see cref="M:JT1078.Flv.FlvEncoder.EncoderVideoTag(JT1078.Protocol.JT1078Package,System.Boolean)"/>第二个参数传false | |||
6、<see cref="M:JT1078.Flv.FlvEncoder.EncoderAudioTag(JT1078.Protocol.JT1078Package,System.Boolean)"/>第二个参数传false | |||
自动编码 | |||
1、<see cref="M:JT1078.Flv.FlvEncoder.DecoderFlvHeader(System.Boolean,System.Boolean)"/> | |||
2、<see cref="M:JT1078.Flv.FlvEncoder.DecoderScriptTag(System.Boolean,System.Double)"/> | |||
3、<see cref="M:JT1078.Flv.FlvEncoder.DecoderVideoTag(JT1078.Protocol.JT1078Package,System.Boolean)"/>第二个参数传true | |||
4、<see cref="M:JT1078.Flv.FlvEncoder.DecoderAudioTag(JT1078.Protocol.JT1078Package,System.Boolean)"/>第二个参数传true | |||
1、<see cref="M:JT1078.Flv.FlvEncoder.EncoderFlvHeader(System.Boolean,System.Boolean)"/> | |||
2、<see cref="M:JT1078.Flv.FlvEncoder.EncoderScriptTag(JT1078.Protocol.MessagePack.SPSInfo,System.Boolean,System.Double)"/> | |||
3、<see cref="M:JT1078.Flv.FlvEncoder.EncoderVideoTag(JT1078.Protocol.JT1078Package,System.Boolean)"/>第二个参数传true | |||
4、<see cref="M:JT1078.Flv.FlvEncoder.EncoderAudioTag(JT1078.Protocol.JT1078Package,System.Boolean)"/>第二个参数传true | |||
</summary> | |||
</member> | |||
<member name="M:JT1078.Flv.FlvEncoder.DecoderFlvHeader(System.Boolean,System.Boolean)"> | |||
<member name="M:JT1078.Flv.FlvEncoder.EncoderFlvHeader(System.Boolean,System.Boolean)"> | |||
<summary> | |||
编码flv头 | |||
<para> | |||
注意:本方法已写入<see cref="F:JT1078.Flv.FlvEncoder.previousTagSize"/> | |||
</para> | |||
</summary> | |||
<param name="hasVideo"></param> | |||
<param name="hasAudio"></param> | |||
<param name="hasVideo">是否有视频</param> | |||
<param name="hasAudio">是否有音频</param> | |||
<returns></returns> | |||
</member> | |||
<member name="M:JT1078.Flv.FlvEncoder.DecoderScriptTag(System.Boolean,System.Double)"> | |||
<member name="M:JT1078.Flv.FlvEncoder.EncoderScriptTag(JT1078.Protocol.MessagePack.SPSInfo,System.Boolean,System.Double)"> | |||
<summary> | |||
编码脚本Tag | |||
<para> | |||
注意:本方法已写入<see cref="F:JT1078.Flv.FlvEncoder.previousTagSize"/> | |||
</para> | |||
</summary> | |||
<param name="width">视频宽度</param> | |||
<param name="height">视频高度</param> | |||
<param name="hasAudio">是否含有音频,如果有,则写入音频配置,后来发现即便是有音频,这里给<c>false</c>也没关系</param> | |||
<param name="frameRate">帧率</param> | |||
<param name="spsInfo">解析后的sps信息</param> | |||
<param name="hasAudio">是否有音频</param> | |||
<param name="frameRate">帧率 默认25d 即每秒25帧</param> | |||
<returns></returns> | |||
</member> | |||
<member name="M:JT1078.Flv.FlvEncoder.DecoderFirstVideoTag(JT1078.Protocol.H264.H264NALU,JT1078.Protocol.H264.H264NALU,JT1078.Protocol.H264.H264NALU)"> | |||
<member name="M:JT1078.Flv.FlvEncoder.EncoderFirstVideoTag(JT1078.Protocol.MessagePack.SPSInfo,JT1078.Protocol.H264.H264NALU,JT1078.Protocol.H264.H264NALU,JT1078.Protocol.H264.H264NALU)"> | |||
<summary> | |||
编码首帧视频,即videoTag[0] | |||
<para> | |||
注意:本方法已写入<see cref="F:JT1078.Flv.FlvEncoder.previousTagSize"/> | |||
</para> | |||
编码首帧视频,即videoTag[0] | |||
</summary> | |||
<param name="spsInfo">sps 解析后的数据</param> | |||
<param name="sps"></param> | |||
<param name="pps"></param> | |||
<param name="sei"></param> | |||
<returns></returns> | |||
</member> | |||
<member name="M:JT1078.Flv.FlvEncoder.DecoderFirstAudioTag(System.UInt64)"> | |||
<member name="M:JT1078.Flv.FlvEncoder.EncoderFirstAudioTag(System.UInt64)"> | |||
<summary> | |||
编码首帧音频,即audioTag[0] | |||
<para> | |||
注意:本方法已写入<see cref="F:JT1078.Flv.FlvEncoder.previousTagSize"/> | |||
</para> | |||
</summary> | |||
<param name="timestamp"></param> | |||
<returns></returns> | |||
</member> | |||
<member name="M:JT1078.Flv.FlvEncoder.DecoderVideoTag(JT1078.Protocol.JT1078Package,System.Boolean)"> | |||
<member name="M:JT1078.Flv.FlvEncoder.EncoderVideoTag(JT1078.Protocol.JT1078Package,System.Boolean)"> | |||
<summary> | |||
编码非首帧视频 | |||
编码视频 | |||
</summary> | |||
<param name="package"></param> | |||
<param name="package">1078包</param> | |||
<param name="needVideoHeader">是否需要首帧视频</param> | |||
<returns></returns> | |||
</member> | |||
<member name="M:JT1078.Flv.FlvEncoder.DecoderAudioTag(JT1078.Protocol.JT1078Package,System.Boolean)"> | |||
<member name="M:JT1078.Flv.FlvEncoder.EncoderAudioTag(JT1078.Protocol.JT1078Package,System.Boolean)"> | |||
<summary> | |||
编码非首帧音频 | |||
</summary> | |||
@@ -288,6 +278,13 @@ | |||
<param name="needAacHeader">是否需要首帧音频</param> | |||
<returns></returns> | |||
</member> | |||
<member name="M:JT1078.Flv.FlvEncoder.EncoderOtherVideoTag(JT1078.Protocol.H264.H264NALU)"> | |||
<summary> | |||
编码非首帧视频 | |||
</summary> | |||
<param name="nALU"></param> | |||
<returns></returns> | |||
</member> | |||
<member name="P:JT1078.Flv.FlvTags.DataSize"> | |||
<summary> | |||
Tag Data部分大小 | |||
@@ -33,7 +33,8 @@ namespace JT1078.Flv.MessagePack | |||
//todo:VIDEODATA | |||
break; | |||
} | |||
WriteInt24Return(GetCurrentPosition() - DataSizePosition -3-7, DataSizePosition); | |||
tag.DataSize = GetCurrentPosition() - 11; | |||
WriteInt24Return(tag.DataSize, DataSizePosition); | |||
} | |||
public void WriteUInt24(uint value) | |||
@@ -21,7 +21,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT1078.Protocol.Benchmark", | |||
EndProject | |||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E378A80C-5708-4D0C-BA1A-73EEF08957F6}" | |||
ProjectSection(SolutionItems) = preProject | |||
..\.travis.yml = ..\.travis.yml | |||
..\README.md = ..\README.md | |||
EndProjectSection | |||
EndProject | |||
@@ -5,9 +5,9 @@ | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.0" /> | |||
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.0" /> | |||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" /> | |||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.2" /> | |||
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.2" /> | |||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" /> | |||
<PackageReference Include="xunit" Version="2.4.1" /> | |||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1"> | |||
<PrivateAssets>all</PrivateAssets> | |||
@@ -39,32 +39,33 @@ namespace JT808.Protocol.Extensions.JT1078.Test | |||
}; | |||
jT808UploadLocationRequest.JT808LocationAttachData.Add(0x14, new JT808_0x0200_0x14 | |||
{ | |||
VideoRelateAlarm = 100 | |||
VideoRelateAlarm = 100 | |||
}); | |||
jT808UploadLocationRequest.JT808LocationAttachData.Add(0x15, new JT808_0x0200_0x15 | |||
{ | |||
VideoSignalLoseAlarmStatus = 100 | |||
VideoSignalLoseAlarmStatus = 100 | |||
}); | |||
jT808UploadLocationRequest.JT808LocationAttachData.Add(0x16, new JT808_0x0200_0x16 | |||
{ | |||
VideoSignalOcclusionAlarmStatus = 100 | |||
VideoSignalOcclusionAlarmStatus = 100 | |||
}); | |||
jT808UploadLocationRequest.JT808LocationAttachData.Add(0x17, new JT808_0x0200_0x17 | |||
{ | |||
StorageFaultAlarmStatus = 100 | |||
StorageFaultAlarmStatus = 100 | |||
}); | |||
jT808UploadLocationRequest.JT808LocationAttachData.Add(0x18, new JT808_0x0200_0x18 | |||
{ | |||
AbnormalDrivingBehaviorAlarmInfo = 100 | |||
AbnormalDrivingBehaviorAlarmType = 100, | |||
FatigueLevel = 88 | |||
}); | |||
var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString(); | |||
Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C00001807151010101404000000641504000000641604000000641702006418020064", hex); | |||
Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C0000180715101010140400000064150400000064160400000064170200641803006458", hex); | |||
} | |||
[Fact] | |||
public void Test2() | |||
{ | |||
byte[] bodys = "000000010000000200BA7F0E07E4F11C0028003C00001807151010101404000000641504000000641604000000641702006418020064".ToHexBytes(); | |||
byte[] bodys = "000000010000000200BA7F0E07E4F11C0028003C0000180715101010140400000064150400000064160400000064170200641803006458".ToHexBytes(); | |||
JT808_0x0200 jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808_0x0200>(bodys); | |||
Assert.Equal(1u, jT808UploadLocationRequest.AlarmFlag); | |||
Assert.Equal(DateTime.Parse("2018-07-15 10:10:10"), jT808UploadLocationRequest.GPSTime); | |||
@@ -76,7 +77,15 @@ namespace JT808.Protocol.Extensions.JT1078.Test | |||
Assert.Equal(100u, ((JT808_0x0200_0x15)jT808UploadLocationRequest.JT808LocationAttachData[0x15]).VideoSignalLoseAlarmStatus); | |||
Assert.Equal(100u, ((JT808_0x0200_0x16)jT808UploadLocationRequest.JT808LocationAttachData[0x16]).VideoSignalOcclusionAlarmStatus); | |||
Assert.Equal(100u, ((JT808_0x0200_0x17)jT808UploadLocationRequest.JT808LocationAttachData[0x17]).StorageFaultAlarmStatus); | |||
Assert.Equal(100u, ((JT808_0x0200_0x18)jT808UploadLocationRequest.JT808LocationAttachData[0x18]).AbnormalDrivingBehaviorAlarmInfo); | |||
Assert.Equal(100u, ((JT808_0x0200_0x18)jT808UploadLocationRequest.JT808LocationAttachData[0x18]).AbnormalDrivingBehaviorAlarmType); | |||
Assert.Equal(88, ((JT808_0x0200_0x18)jT808UploadLocationRequest.JT808LocationAttachData[0x18]).FatigueLevel); | |||
} | |||
[Fact] | |||
public void Test3() | |||
{ | |||
byte[] bodys = "000000010000000200BA7F0E07E4F11C0028003C0000180715101010140400000064150400000064160400000064170200641803006458".ToHexBytes(); | |||
string json = JT808Serializer.Analyze<JT808_0x0200>(bodys); | |||
} | |||
} | |||
} |
@@ -0,0 +1,114 @@ | |||
using JT808.Protocol.Extensions.JT1078.MessageBody; | |||
using JT808.Protocol.Extensions.JT1078.Enums; | |||
using JT808.Protocol.MessageBody; | |||
using Microsoft.Extensions.DependencyInjection; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using Xunit; | |||
namespace JT808.Protocol.Extensions.JT1078.Test | |||
{ | |||
public class JT808_0x0200Test | |||
{ | |||
JT808Serializer JT808Serializer; | |||
public JT808_0x0200Test() | |||
{ | |||
IServiceCollection serviceDescriptors1 = new ServiceCollection(); | |||
serviceDescriptors1 | |||
.AddJT808Configure() | |||
.AddJT1078Configure(); | |||
var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); | |||
var defaultConfig = ServiceProvider1.GetRequiredService<IJT808Config>(); | |||
JT808Serializer = defaultConfig.GetSerializer(); | |||
} | |||
[Fact] | |||
public void Test_0x14_1() | |||
{ | |||
JT808_0x0200 jT808UploadLocationRequest = new JT808_0x0200 | |||
{ | |||
AlarmFlag = 1, | |||
Altitude = 40, | |||
GPSTime = DateTime.Parse("2020-01-31 20:20:20"), | |||
Lat = 12222222, | |||
Lng = 132444444, | |||
Speed = 60, | |||
Direction = 0, | |||
StatusFlag = 2, | |||
JT808LocationAttachData = new Dictionary<byte, JT808_0x0200_BodyBase>() | |||
}; | |||
jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_JT1078_Constants.JT808_0X0200_0x14, new JT808_0x0200_0x14 | |||
{ | |||
VideoRelateAlarm = (uint)(VideoRelateAlarmType.视频信号遮挡报警 | VideoRelateAlarmType.其他视频设备故障报警) | |||
}); | |||
var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString(); | |||
Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C000020013120202014040000000A", hex); | |||
} | |||
[Fact] | |||
public void Test_0x14_2() | |||
{ | |||
byte[] bodys = "000000010000000200BA7F0E07E4F11C0028003C000020013120202014040000000A".ToHexBytes(); | |||
JT808_0x0200 jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808_0x0200>(bodys); | |||
Assert.Equal((uint)1, jT808UploadLocationRequest.AlarmFlag); | |||
Assert.Equal(DateTime.Parse("2020-01-31 20:20:20"), jT808UploadLocationRequest.GPSTime); | |||
Assert.Equal(12222222, jT808UploadLocationRequest.Lat); | |||
Assert.Equal(132444444, jT808UploadLocationRequest.Lng); | |||
Assert.Equal(60, jT808UploadLocationRequest.Speed); | |||
Assert.Equal((uint)2, jT808UploadLocationRequest.StatusFlag); | |||
Assert.Equal((uint)(VideoRelateAlarmType.视频信号遮挡报警 | VideoRelateAlarmType.其他视频设备故障报警), ((JT808_0x0200_0x14)jT808UploadLocationRequest.JT808LocationAttachData[JT808_JT1078_Constants.JT808_0X0200_0x14]).VideoRelateAlarm); | |||
} | |||
[Fact] | |||
public void Test_0x14_3() | |||
{ | |||
byte[] bodys = "000000010000000200BA7F0E07E4F11C0028003C000020013120202014040000000A".ToHexBytes(); | |||
string json = JT808Serializer.Analyze<JT808_0x0200>(bodys); | |||
} | |||
[Fact] | |||
public void Test_0x15_1() | |||
{ | |||
JT808_0x0200 jT808UploadLocationRequest = new JT808_0x0200 | |||
{ | |||
AlarmFlag = 1, | |||
Altitude = 40, | |||
GPSTime = DateTime.Parse("2020-01-31 20:20:20"), | |||
Lat = 12222222, | |||
Lng = 132444444, | |||
Speed = 60, | |||
Direction = 0, | |||
StatusFlag = 2, | |||
JT808LocationAttachData = new Dictionary<byte, JT808_0x0200_BodyBase>() | |||
}; | |||
jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_JT1078_Constants.JT808_0X0200_0x15, new JT808_0x0200_0x15 | |||
{ | |||
VideoSignalLoseAlarmStatus=3 | |||
}); | |||
var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString(); | |||
Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C0000200131202020150400000003", hex); | |||
} | |||
[Fact] | |||
public void Test_0x15_2() | |||
{ | |||
byte[] bodys = "000000010000000200BA7F0E07E4F11C0028003C0000200131202020150400000003".ToHexBytes(); | |||
JT808_0x0200 jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808_0x0200>(bodys); | |||
Assert.Equal((uint)1, jT808UploadLocationRequest.AlarmFlag); | |||
Assert.Equal(DateTime.Parse("2020-01-31 20:20:20"), jT808UploadLocationRequest.GPSTime); | |||
Assert.Equal(12222222, jT808UploadLocationRequest.Lat); | |||
Assert.Equal(132444444, jT808UploadLocationRequest.Lng); | |||
Assert.Equal(60, jT808UploadLocationRequest.Speed); | |||
Assert.Equal((uint)2, jT808UploadLocationRequest.StatusFlag); | |||
Assert.Equal(3u, ((JT808_0x0200_0x15)jT808UploadLocationRequest.JT808LocationAttachData[JT808_JT1078_Constants.JT808_0X0200_0x15]).VideoSignalLoseAlarmStatus); | |||
} | |||
[Fact] | |||
public void Test_0x15_3() | |||
{ | |||
byte[] bodys = "000000010000000200BA7F0E07E4F11C0028003C0000200131202020150400000003".ToHexBytes(); | |||
string json = JT808Serializer.Analyze<JT808_0x0200>(bodys); | |||
} | |||
} | |||
} |
@@ -56,5 +56,10 @@ namespace JT808.Protocol.Extensions.JT1078.Test | |||
Assert.Equal(7, jT808_0x1003.TerminalSupportedMaxNumberOfAudioPhysicalChannels); | |||
Assert.Equal(8, jT808_0x1003.TerminalSupportedMaxNumberOfVideoPhysicalChannels); | |||
} | |||
[Fact] | |||
public void Test3() | |||
{ | |||
var json = JT808Serializer.Analyze<JT808_0x1003>("03020504000101060708".ToHexBytes()); | |||
} | |||
} | |||
} |
@@ -57,5 +57,10 @@ namespace JT808.Protocol.Extensions.JT1078.Test | |||
Assert.Equal(1, jT808_0x1005.GettingOffNumber); | |||
Assert.Equal(1, jT808_0x1005.GettingOnNumber); | |||
} | |||
[Fact] | |||
public void Test3() | |||
{ | |||
var json = JT808Serializer.Analyze<JT808_0x1005>("19071610200119071610250200010001".ToHexBytes()); | |||
} | |||
} | |||
} |
@@ -93,5 +93,10 @@ namespace JT808.Protocol.Extensions.JT1078.Test | |||
Assert.Equal(51, jT808_0x1205.AVResouces[1].MemoryType); | |||
Assert.Equal(61, jT808_0x1205.AVResouces[1].StreamType); | |||
} | |||
[Fact] | |||
public void Test3() | |||
{ | |||
var json = JT808Serializer.Analyze<JT808_0x1205>("000100000002041907161020011907161025010000000102060500000003291907161120011907161125020000000B153D330000001F".ToHexBytes()); | |||
} | |||
} | |||
} |
@@ -53,5 +53,10 @@ namespace JT808.Protocol.Extensions.JT1078.Test | |||
Assert.Equal(1, jT808_0x1206.MsgNum); | |||
Assert.Equal(1, jT808_0x1206.Result); | |||
} | |||
[Fact] | |||
public void Test3() | |||
{ | |||
var jT808_0x1206 = JT808Serializer.Analyze<JT808_0x1206>("000101".ToHexBytes()); | |||
} | |||
} | |||
} |
@@ -285,6 +285,13 @@ namespace JT808.Protocol.Extensions.JT1078.Test | |||
} | |||
} | |||
} | |||
[Fact] | |||
public void Test3() | |||
{ | |||
byte[] bytes = "7E8103009C000123456789000A070000007515030500040700000006080A00090C0000000B000201000000761B02010303020001070604050B0A08090F0E0C0D1312101117161415000000772B0201030500040700000006080A00090C0000000B000201030500040700000006080A00090C0000000B000200000079030302010000007A04000000010000007B0201020000007C140103020A00230012004500340067005600890078587E".ToHexBytes(); | |||
var jT808_0X8103 = JT808Serializer.Analyze(bytes); | |||
} | |||
} | |||
class DefaultGlobalConfig : GlobalConfigBase | |||
{ | |||
@@ -71,5 +71,10 @@ namespace JT808.Protocol.Extensions.JT1078.Test | |||
Assert.Equal("7E910100110123456798100001093132372E302E302E31076000000101014C7E", hex); | |||
//7E910100110123456798100001093132372E302E302E31076000000101014C7E | |||
} | |||
[Fact] | |||
public void Test4() | |||
{ | |||
var jT808_0X9101 = JT808Serializer.Analyze<JT808_0x9101>("093132372E302E302E3107600000010101".ToHexBytes()); | |||
} | |||
} | |||
} |
@@ -64,5 +64,10 @@ namespace JT808.Protocol.Extensions.JT1078.Test | |||
//7E910200040123456798100001010100001E7E | |||
Assert.Equal("7E910200040123456798100001010100001E7E", hex); | |||
} | |||
[Fact] | |||
public void Test4() | |||
{ | |||
var jT808_0rX9102 = JT808Serializer.Analyze<JT808_0x9102>("01010000".ToHexBytes()); | |||
} | |||
} | |||
} |
@@ -53,5 +53,10 @@ namespace JT808.Protocol.Extensions.JT1078.Test | |||
Assert.Equal(1, jT808_0x9105.LogicChannelNo); | |||
Assert.Equal(2, jT808_0x9105.DropRate); | |||
} | |||
[Fact] | |||
public void Test3() | |||
{ | |||
var jT808_0x9105 = JT808Serializer.Analyze<JT808_0x9105>("0102".ToHexBytes()); | |||
} | |||
} | |||
} |
@@ -43,8 +43,7 @@ namespace JT808.Protocol.Extensions.JT1078.Test | |||
AVItemType = 2, | |||
BeginTime = Convert.ToDateTime("2019-07-16 10:10:10"), | |||
EndTime = Convert.ToDateTime("2019-07-16 10:10:10"), | |||
FastForwardOrFastRewindMultiples1=3, | |||
FastForwardOrFastRewindMultiples2=4, | |||
FastForwardOrFastRewindMultiples=3, | |||
MemType=5, | |||
PlayBackWay=6, | |||
ServerIp="127.0.0.1", | |||
@@ -54,19 +53,18 @@ namespace JT808.Protocol.Extensions.JT1078.Test | |||
UdpPort=8080 | |||
}; | |||
var hex = JT808Serializer.Serialize(jT808_0x9201).ToHexString(); | |||
Assert.Equal("093132372E302E302E3100501F9001020705060304190716101010190716101010", hex); | |||
Assert.Equal("093132372E302E302E3100501F90010207050603190716101010190716101010", hex); | |||
} | |||
[Fact] | |||
public void Test2() | |||
{ | |||
var jT808_0x9201 = JT808Serializer.Deserialize<JT808_0x9201>("093132372E302E302E3100501F9001020705060304190716101010190716101010".ToHexBytes()); | |||
var jT808_0x9201 = JT808Serializer.Deserialize<JT808_0x9201>("093132372E302E302E3100501F90010207050603190716101010190716101010".ToHexBytes()); | |||
Assert.Equal(1, jT808_0x9201.LogicChannelNo); | |||
Assert.Equal(2, jT808_0x9201.AVItemType); | |||
Assert.Equal(Convert.ToDateTime("2019-07-16 10:10:10"), jT808_0x9201.BeginTime); | |||
Assert.Equal(Convert.ToDateTime("2019-07-16 10:10:10"), jT808_0x9201.EndTime); | |||
Assert.Equal(3, jT808_0x9201.FastForwardOrFastRewindMultiples1); | |||
Assert.Equal(4, jT808_0x9201.FastForwardOrFastRewindMultiples2); | |||
Assert.Equal(3, jT808_0x9201.FastForwardOrFastRewindMultiples); | |||
Assert.Equal(5, jT808_0x9201.MemType); | |||
Assert.Equal(6, jT808_0x9201.PlayBackWay); | |||
Assert.Equal("127.0.0.1", jT808_0x9201.ServerIp); | |||
@@ -75,5 +73,10 @@ namespace JT808.Protocol.Extensions.JT1078.Test | |||
Assert.Equal(80, jT808_0x9201.TcpPort); | |||
Assert.Equal(8080, jT808_0x9201.UdpPort); | |||
} | |||
[Fact] | |||
public void Test3() | |||
{ | |||
var jT808_0x9201 = JT808Serializer.Analyze<JT808_0x9201>("093132372E302E302E3100501F90010207050603190716101010190716101010".ToHexBytes()); | |||
} | |||
} | |||
} |
@@ -57,5 +57,10 @@ namespace JT808.Protocol.Extensions.JT1078.Test | |||
Assert.Equal(2, jT808_0x9202.FastForwardOrFastRewindMultiples); | |||
Assert.Equal(3, jT808_0x9202.PlayBackControl); | |||
} | |||
[Fact] | |||
public void Test3() | |||
{ | |||
var jT808_0x9202 = JT808Serializer.Analyze<JT808_0x9202>("010302190716101010".ToHexBytes()); | |||
} | |||
} | |||
} |
@@ -63,5 +63,10 @@ namespace JT808.Protocol.Extensions.JT1078.Test | |||
Assert.Equal(4, jT808_0x9205.MemoryType); | |||
Assert.Equal(5, jT808_0x9205.StreamType); | |||
} | |||
[Fact] | |||
public void Test3() | |||
{ | |||
var jT808_0x9205 = JT808Serializer.Analyze<JT808_0x9205>("0319071610101019071610101100000001020504".ToHexBytes()); | |||
} | |||
} | |||
} |
@@ -83,5 +83,10 @@ namespace JT808.Protocol.Extensions.JT1078.Test | |||
Assert.Equal("tk", jT808_0x9206.UserName); | |||
Assert.Equal(2, jT808_0x9206.UserNameLength); | |||
} | |||
[Fact] | |||
public void Test3() | |||
{ | |||
var jT808_0x9206 = JT808Serializer.Analyze<JT808_0x9206>("093132372E302E302E31032802746B0631323334353608443A2F2F31313132031907161010101907161010110000000102050407".ToHexBytes()); | |||
} | |||
} | |||
} |
@@ -53,5 +53,10 @@ namespace JT808.Protocol.Extensions.JT1078.Test | |||
Assert.Equal(1, jT808_0x9207.MgsNum); | |||
Assert.Equal(2, jT808_0x9207.UploadControl); | |||
} | |||
[Fact] | |||
public void Test3() | |||
{ | |||
var jT808_0x9207 = JT808Serializer.Analyze<JT808_0x9207>("000102".ToHexBytes()); | |||
} | |||
} | |||
} |
@@ -55,5 +55,11 @@ namespace JT808.Protocol.Extensions.JT1078.Test | |||
Assert.Equal(2, jT808_0x9301.Speed); | |||
Assert.Equal(3, jT808_0x9301.Direction); | |||
} | |||
[Fact] | |||
public void Test3() | |||
{ | |||
var jT808_0x9301 = JT808Serializer.Analyze<JT808_0x9301>("010302".ToHexBytes()); | |||
} | |||
} | |||
} |
@@ -53,5 +53,11 @@ namespace JT808.Protocol.Extensions.JT1078.Test | |||
Assert.Equal(1, jT808_0x9302.LogicChannelNo); | |||
Assert.Equal(2, jT808_0x9302.FocusAdjustmentDirection); | |||
} | |||
[Fact] | |||
public void Test3() | |||
{ | |||
var jT808_0x9302 = JT808Serializer.Analyze<JT808_0x9302>("0102".ToHexBytes()); | |||
} | |||
} | |||
} |
@@ -53,5 +53,11 @@ namespace JT808.Protocol.Extensions.JT1078.Test | |||
Assert.Equal(1, jT808_0x9303.LogicChannelNo); | |||
Assert.Equal(2, jT808_0x9303.IrisAdjustment); | |||
} | |||
[Fact] | |||
public void Test3() | |||
{ | |||
var jT808_0x9303 = JT808Serializer.Analyze<JT808_0x9303>("0102".ToHexBytes()); | |||
} | |||
} | |||
} |
@@ -53,5 +53,11 @@ namespace JT808.Protocol.Extensions.JT1078.Test | |||
Assert.Equal(1, jT808_0x9304.LogicChannelNo); | |||
Assert.Equal(2, jT808_0x9304.StartOrStop); | |||
} | |||
[Fact] | |||
public void Test3() | |||
{ | |||
var jT808_0x9304 = JT808Serializer.Analyze<JT808_0x9304>("0102".ToHexBytes()); | |||
} | |||
} | |||
} |
@@ -49,9 +49,8 @@ namespace JT808.Protocol.Extensions.JT1078.Test | |||
[Fact] | |||
public void Test2() | |||
{ | |||
var jT808_0x9305 = JT808Serializer.Deserialize<JT808_0x9305>("0102".ToHexBytes()); | |||
Assert.Equal(1, jT808_0x9305.LogicChannelNo); | |||
Assert.Equal(2, jT808_0x9305.StartOrStop); | |||
var jT808_0x9305 = JT808Serializer.Analyze<JT808_0x9305>("0102".ToHexBytes()); | |||
} | |||
} | |||
} |
@@ -53,5 +53,11 @@ namespace JT808.Protocol.Extensions.JT1078.Test | |||
Assert.Equal(1, jT808_0x9306.LogicChannelNo); | |||
Assert.Equal(2, jT808_0x9306.ChangeMultipleControl); | |||
} | |||
[Fact] | |||
public void Test3() | |||
{ | |||
var jT808_0x9306 = JT808Serializer.Analyze<JT808_0x9306>("0102".ToHexBytes()); | |||
} | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
namespace JT808.Protocol.Extensions.JT1078.Enums | |||
{ | |||
[Flags] | |||
public enum VideoRelateAlarmType:uint | |||
{ | |||
视频信号丢失报警=0, | |||
视频信号遮挡报警=2, | |||
存储单元故障报警=4, | |||
其他视频设备故障报警=8, | |||
客车超员报警=16, | |||
异常驾驶行为报警=32, | |||
特殊报警录像达到存储阈值报警=64, | |||
} | |||
} |
@@ -15,7 +15,7 @@ | |||
<licenseUrl>https://github.com/SmallChi/JT1078/blob/master/LICENSE</licenseUrl> | |||
<license>https://github.com/SmallChi/JT1078/blob/master/LICENSE</license> | |||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild> | |||
<Version>2.2.3</Version> | |||
<Version>2.2.7</Version> | |||
<PackageLicenseFile>LICENSE</PackageLicenseFile> | |||
</PropertyGroup> | |||
@@ -28,7 +28,7 @@ | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="JT808" Version="2.2.3" /> | |||
<PackageReference Include="JT808" Version="2.2.8" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
@@ -78,6 +78,7 @@ | |||
<member name="P:JT808.Protocol.Extensions.JT1078.MessageBody.JT808_0x0200_0x14.VideoRelateAlarm"> | |||
<summary> | |||
视频相关报警 | |||
<see cref="T:JT808.Protocol.Extensions.JT1078.Enums.VideoRelateAlarmType"/> | |||
</summary> | |||
</member> | |||
<member name="T:JT808.Protocol.Extensions.JT1078.MessageBody.JT808_0x0200_0x15"> | |||
@@ -139,9 +140,14 @@ | |||
数据 长度 | |||
</summary> | |||
</member> | |||
<member name="P:JT808.Protocol.Extensions.JT1078.MessageBody.JT808_0x0200_0x18.AbnormalDrivingBehaviorAlarmInfo"> | |||
<member name="P:JT808.Protocol.Extensions.JT1078.MessageBody.JT808_0x0200_0x18.AbnormalDrivingBehaviorAlarmType"> | |||
<summary> | |||
异常驾驶行为报警详细描述 | |||
异常驾驶行为报警类型 | |||
</summary> | |||
</member> | |||
<member name="P:JT808.Protocol.Extensions.JT1078.MessageBody.JT808_0x0200_0x18.FatigueLevel"> | |||
<summary> | |||
疲劳程度 | |||
</summary> | |||
</member> | |||
<member name="T:JT808.Protocol.Extensions.JT1078.MessageBody.JT808_0x1003"> | |||
@@ -784,7 +790,7 @@ | |||
</member> | |||
<member name="P:JT808.Protocol.Extensions.JT1078.MessageBody.JT808_0x9201.ServerIpLength"> | |||
<summary> | |||
服务器IP地址服务 | |||
服务器IP地址长度 | |||
</summary> | |||
</member> | |||
<member name="P:JT808.Protocol.Extensions.JT1078.MessageBody.JT808_0x9201.ServerIp"> | |||
@@ -827,12 +833,7 @@ | |||
回放方式 | |||
</summary> | |||
</member> | |||
<member name="P:JT808.Protocol.Extensions.JT1078.MessageBody.JT808_0x9201.FastForwardOrFastRewindMultiples1"> | |||
<summary> | |||
快进或快退倍数 | |||
</summary> | |||
</member> | |||
<member name="P:JT808.Protocol.Extensions.JT1078.MessageBody.JT808_0x9201.FastForwardOrFastRewindMultiples2"> | |||
<member name="P:JT808.Protocol.Extensions.JT1078.MessageBody.JT808_0x9201.FastForwardOrFastRewindMultiples"> | |||
<summary> | |||
快进或快退倍数 | |||
</summary> | |||
@@ -1,6 +1,10 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.MessageBody; | |||
using JT808.Protocol.MessagePack; | |||
using JT808.Protocol.Interfaces; | |||
using System.Text.Json; | |||
using JT808.Protocol.Extensions.JT1078.Enums; | |||
using System.Linq; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
@@ -8,7 +12,7 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// 视频相关报警 | |||
/// 0x0200_0x14 | |||
/// </summary> | |||
public class JT808_0x0200_0x14 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x14> | |||
public class JT808_0x0200_0x14 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x14>,IJT808Analyze | |||
{ | |||
public override byte AttachInfoId { get; set; } = 0x14; | |||
/// <summary> | |||
@@ -17,16 +21,38 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
public override byte AttachInfoLength { get; set; } = 4; | |||
/// <summary> | |||
/// 视频相关报警 | |||
/// <see cref="JT808.Protocol.Extensions.JT1078.Enums.VideoRelateAlarmType"/> | |||
/// </summary> | |||
public uint VideoRelateAlarm { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x0200_0x14 value = new JT808_0x0200_0x14(); | |||
value.AttachInfoId = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.AttachInfoId.ReadNumber()}]附加信息Id", value.AttachInfoId); | |||
value.AttachInfoLength = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength); | |||
value.VideoRelateAlarm = reader.ReadUInt32(); | |||
writer.WriteNumber($"[{value.VideoRelateAlarm.ReadNumber()}]视频相关报警", value.VideoRelateAlarm); | |||
var videoRelateAlarmFlags = JT808EnumExtensions.GetEnumTypes<VideoRelateAlarmType>((int)value.VideoRelateAlarm, 32); | |||
if (videoRelateAlarmFlags.Any()) | |||
{ | |||
writer.WriteStartArray("视频报警集合"); | |||
foreach (var item in videoRelateAlarmFlags) | |||
{ | |||
writer.WriteStringValue(item.ToString()); | |||
} | |||
writer.WriteEndArray(); | |||
} | |||
} | |||
public JT808_0x0200_0x14 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x0200_0x14 jT808_0x0200_0x14 = new JT808_0x0200_0x14(); | |||
jT808_0x0200_0x14.AttachInfoId = reader.ReadByte(); | |||
jT808_0x0200_0x14.AttachInfoLength = reader.ReadByte(); | |||
jT808_0x0200_0x14.VideoRelateAlarm = reader.ReadUInt32(); | |||
return jT808_0x0200_0x14; | |||
JT808_0x0200_0x14 value = new JT808_0x0200_0x14(); | |||
value.AttachInfoId = reader.ReadByte(); | |||
value.AttachInfoLength = reader.ReadByte(); | |||
value.VideoRelateAlarm = reader.ReadUInt32(); | |||
return value; | |||
} | |||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x14 value, IJT808Config config) | |||
@@ -1,6 +1,9 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessageBody; | |||
using JT808.Protocol.MessagePack; | |||
using System; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
@@ -8,7 +11,7 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// 视频信号丢失报警状态 | |||
/// 0x0200_0x15 | |||
/// </summary> | |||
public class JT808_0x0200_0x15 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x15> | |||
public class JT808_0x0200_0x15 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x15>, IJT808Analyze | |||
{ | |||
public override byte AttachInfoId { get; set; } = 0x15; | |||
/// <summary> | |||
@@ -20,13 +23,40 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// </summary> | |||
public uint VideoSignalLoseAlarmStatus { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x0200_0x15 value = new JT808_0x0200_0x15(); | |||
value.AttachInfoId = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.AttachInfoId.ReadNumber()}]附加信息Id", value.AttachInfoId); | |||
value.AttachInfoLength = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength); | |||
value.VideoSignalLoseAlarmStatus = reader.ReadUInt32(); | |||
writer.WriteNumber($"[{value.VideoSignalLoseAlarmStatus.ReadNumber()}]视频信号丢失报警状态", value.VideoSignalLoseAlarmStatus); | |||
var videoSignalLoseAlarmStatusSpan = Convert.ToString(value.VideoSignalLoseAlarmStatus, 2).PadLeft(32, '0').AsSpan(); | |||
writer.WriteStartArray("视频信号丢失报警状态集合"); | |||
int index = 0; | |||
foreach (var item in videoSignalLoseAlarmStatusSpan) | |||
{ | |||
if (item == '1') | |||
{ | |||
writer.WriteStringValue($"{index}通道视频信号丢失"); | |||
} | |||
else | |||
{ | |||
writer.WriteStringValue($"{index}通道视频正常"); | |||
} | |||
index++; | |||
} | |||
writer.WriteEndArray(); | |||
} | |||
public JT808_0x0200_0x15 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x0200_0x15 jT808_0x0200_0x15 = new JT808_0x0200_0x15(); | |||
jT808_0x0200_0x15.AttachInfoId = reader.ReadByte(); | |||
jT808_0x0200_0x15.AttachInfoLength = reader.ReadByte(); | |||
jT808_0x0200_0x15.VideoSignalLoseAlarmStatus = reader.ReadUInt32(); | |||
return jT808_0x0200_0x15; | |||
JT808_0x0200_0x15 value = new JT808_0x0200_0x15(); | |||
value.AttachInfoId = reader.ReadByte(); | |||
value.AttachInfoLength = reader.ReadByte(); | |||
value.VideoSignalLoseAlarmStatus = reader.ReadUInt32(); | |||
return value; | |||
} | |||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x15 value, IJT808Config config) | |||
@@ -1,6 +1,9 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessageBody; | |||
using JT808.Protocol.MessagePack; | |||
using System; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
@@ -8,7 +11,7 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// 视频信号遮挡报警状态 | |||
/// 0x0200_0x16 | |||
/// </summary> | |||
public class JT808_0x0200_0x16 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x16> | |||
public class JT808_0x0200_0x16 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x16>, IJT808Analyze | |||
{ | |||
public override byte AttachInfoId { get; set; } = 0x16; | |||
/// <summary> | |||
@@ -20,13 +23,40 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// </summary> | |||
public uint VideoSignalOcclusionAlarmStatus { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x0200_0x16 value = new JT808_0x0200_0x16(); | |||
value.AttachInfoId = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.AttachInfoId.ReadNumber()}]附加信息Id", value.AttachInfoId); | |||
value.AttachInfoLength = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength); | |||
value.VideoSignalOcclusionAlarmStatus = reader.ReadUInt32(); | |||
writer.WriteNumber($"[{value.VideoSignalOcclusionAlarmStatus.ReadNumber()}]视频信号遮挡报警状态", value.VideoSignalOcclusionAlarmStatus); | |||
var videoSignalOcclusionAlarmStatusSpan = Convert.ToString(value.VideoSignalOcclusionAlarmStatus, 2).PadLeft(32, '0').AsSpan(); | |||
writer.WriteStartArray("视频信号遮挡报警状态集合"); | |||
int index = 0; | |||
foreach (var item in videoSignalOcclusionAlarmStatusSpan) | |||
{ | |||
if (item == '1') | |||
{ | |||
writer.WriteStringValue($"{index}通道视频信号遮挡"); | |||
} | |||
else | |||
{ | |||
writer.WriteStringValue($"{index}通道视频正常"); | |||
} | |||
index++; | |||
} | |||
writer.WriteEndArray(); | |||
} | |||
public JT808_0x0200_0x16 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x0200_0x16 jT808_0x0200_0x16 = new JT808_0x0200_0x16(); | |||
jT808_0x0200_0x16.AttachInfoId = reader.ReadByte(); | |||
jT808_0x0200_0x16.AttachInfoLength = reader.ReadByte(); | |||
jT808_0x0200_0x16.VideoSignalOcclusionAlarmStatus = reader.ReadUInt32(); | |||
return jT808_0x0200_0x16; | |||
JT808_0x0200_0x16 value = new JT808_0x0200_0x16(); | |||
value.AttachInfoId = reader.ReadByte(); | |||
value.AttachInfoLength = reader.ReadByte(); | |||
value.VideoSignalOcclusionAlarmStatus = reader.ReadUInt32(); | |||
return value; | |||
} | |||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x16 value, IJT808Config config) | |||
@@ -1,6 +1,9 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessageBody; | |||
using JT808.Protocol.MessagePack; | |||
using System; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
@@ -8,7 +11,7 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// 存储器故障报警状态 | |||
/// 0x0200_0x17 | |||
/// </summary> | |||
public class JT808_0x0200_0x17 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x17> | |||
public class JT808_0x0200_0x17 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x17>, IJT808Analyze | |||
{ | |||
public override byte AttachInfoId { get; set; } = 0x17; | |||
/// <summary> | |||
@@ -20,13 +23,54 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// </summary> | |||
public ushort StorageFaultAlarmStatus{ get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x0200_0x17 value = new JT808_0x0200_0x17(); | |||
value.AttachInfoId = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.AttachInfoId.ReadNumber()}]附加信息Id", value.AttachInfoId); | |||
value.AttachInfoLength = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength); | |||
value.StorageFaultAlarmStatus = reader.ReadUInt16(); | |||
writer.WriteNumber($"[{value.StorageFaultAlarmStatus.ReadNumber()}]存储器故障报警状态", value.StorageFaultAlarmStatus); | |||
var storageFaultAlarmStatusSpan = Convert.ToString(value.StorageFaultAlarmStatus, 2).PadLeft(16, '0').AsSpan(); | |||
writer.WriteStartArray("存储器故障报警状态集合"); | |||
int index = 0; | |||
foreach (var item in storageFaultAlarmStatusSpan) | |||
{ | |||
if (index < 4) | |||
{ | |||
if (item == '1') | |||
{ | |||
writer.WriteStringValue($"{index}灾备存储装置故障"); | |||
} | |||
else | |||
{ | |||
writer.WriteStringValue($"{index}灾备存储装置正常"); | |||
} | |||
} | |||
else | |||
{ | |||
if (item == '1') | |||
{ | |||
writer.WriteStringValue($"{index}主存储器故障"); | |||
} | |||
else | |||
{ | |||
writer.WriteStringValue($"{index}主存储器正常"); | |||
} | |||
} | |||
index++; | |||
} | |||
writer.WriteEndArray(); | |||
} | |||
public JT808_0x0200_0x17 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x0200_0x17 jT808_0x0200_0x17 = new JT808_0x0200_0x17(); | |||
jT808_0x0200_0x17.AttachInfoId = reader.ReadByte(); | |||
jT808_0x0200_0x17.AttachInfoLength = reader.ReadByte(); | |||
jT808_0x0200_0x17.StorageFaultAlarmStatus = reader.ReadUInt16(); | |||
return jT808_0x0200_0x17; | |||
JT808_0x0200_0x17 value = new JT808_0x0200_0x17(); | |||
value.AttachInfoId = reader.ReadByte(); | |||
value.AttachInfoLength = reader.ReadByte(); | |||
value.StorageFaultAlarmStatus = reader.ReadUInt16(); | |||
return value; | |||
} | |||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x17 value, IJT808Config config) | |||
@@ -1,6 +1,9 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessageBody; | |||
using JT808.Protocol.MessagePack; | |||
using System; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
@@ -8,31 +11,80 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// 异常驾驶行为报警详细描述 | |||
/// 0x0200_0x18 | |||
/// </summary> | |||
public class JT808_0x0200_0x18 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x18> | |||
public class JT808_0x0200_0x18 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x18>, IJT808Analyze | |||
{ | |||
public override byte AttachInfoId { get; set; } = 0x18; | |||
/// <summary> | |||
/// 数据 长度 | |||
/// </summary> | |||
public override byte AttachInfoLength { get; set; } = 2; | |||
public override byte AttachInfoLength { get; set; } = 3; | |||
/// <summary> | |||
/// 异常驾驶行为报警详细描述 | |||
/// 异常驾驶行为报警类型 | |||
/// </summary> | |||
public ushort AbnormalDrivingBehaviorAlarmInfo { get; set; } | |||
public ushort AbnormalDrivingBehaviorAlarmType{ get; set; } | |||
/// <summary> | |||
/// 疲劳程度 | |||
/// </summary> | |||
public byte FatigueLevel { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x0200_0x18 value = new JT808_0x0200_0x18(); | |||
value.AttachInfoId = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.AttachInfoId.ReadNumber()}]附加信息Id", value.AttachInfoId); | |||
value.AttachInfoLength = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength); | |||
value.AbnormalDrivingBehaviorAlarmType = reader.ReadUInt16(); | |||
writer.WriteNumber($"[{value.AbnormalDrivingBehaviorAlarmType.ReadNumber()}]异常驾驶行为报警类型", value.AbnormalDrivingBehaviorAlarmType); | |||
writer.WriteStartArray("视频信号遮挡报警状态集合"); | |||
var abnormalDrivingBehaviorAlarmTypeSpan = Convert.ToString(value.AbnormalDrivingBehaviorAlarmType, 2).PadLeft(16, '0').AsSpan(); | |||
int index = 0; | |||
foreach (var item in abnormalDrivingBehaviorAlarmTypeSpan) | |||
{ | |||
string tmpResult = item == '1' ? "有" : "无"; | |||
if (index == 0) | |||
{ | |||
writer.WriteStringValue($"[bit{index}疲劳]_{tmpResult}"); | |||
} | |||
else if (index == 1) | |||
{ | |||
writer.WriteStringValue($"[bit{index}打电话]_{tmpResult}"); | |||
} | |||
else if (index == 2) | |||
{ | |||
writer.WriteStringValue($"[bit{index}抽烟]_{tmpResult}"); | |||
} | |||
else if (index>=3 && index<=10) | |||
{ | |||
writer.WriteStringValue($"[bit{index}保留]_{tmpResult}"); | |||
} | |||
else | |||
{ | |||
writer.WriteStringValue($"[bit{index}自定义]_{tmpResult}"); | |||
} | |||
index++; | |||
} | |||
writer.WriteEndArray(); | |||
value.FatigueLevel = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.FatigueLevel.ReadNumber()}]疲劳程度", value.FatigueLevel); | |||
} | |||
public JT808_0x0200_0x18 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x0200_0x18 jT808_0x0200_0x18 = new JT808_0x0200_0x18(); | |||
jT808_0x0200_0x18.AttachInfoId = reader.ReadByte(); | |||
jT808_0x0200_0x18.AttachInfoLength = reader.ReadByte(); | |||
jT808_0x0200_0x18.AbnormalDrivingBehaviorAlarmInfo = reader.ReadUInt16(); | |||
return jT808_0x0200_0x18; | |||
JT808_0x0200_0x18 value = new JT808_0x0200_0x18(); | |||
value.AttachInfoId = reader.ReadByte(); | |||
value.AttachInfoLength = reader.ReadByte(); | |||
value.AbnormalDrivingBehaviorAlarmType = reader.ReadUInt16(); | |||
value.FatigueLevel = reader.ReadByte(); | |||
return value; | |||
} | |||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x18 value, IJT808Config config) | |||
{ | |||
writer.WriteByte(value.AttachInfoId); | |||
writer.WriteByte(value.AttachInfoLength); | |||
writer.WriteUInt16(value.AbnormalDrivingBehaviorAlarmInfo); | |||
writer.WriteUInt16(value.AbnormalDrivingBehaviorAlarmType); | |||
writer.WriteByte(value.FatigueLevel); | |||
} | |||
} | |||
} |
@@ -1,15 +1,17 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessagePack; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
/// <summary> | |||
/// 终端上传音视频属性 | |||
/// </summary> | |||
public class JT808_0x1003 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x1003> | |||
public class JT808_0x1003 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x1003>, IJT808Analyze | |||
{ | |||
/// <summary> | |||
/// 输入音频编码方式 | |||
@@ -50,6 +52,82 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
public override ushort MsgId => 0x1003; | |||
public override string Description => "终端上传音视频属性"; | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x1003 value = new JT808_0x1003(); | |||
value.EnterAudioEncoding = reader.ReadByte(); | |||
writer.WriteString($"[{value.EnterAudioEncoding.ReadNumber()}]输入音频编码方式", AudioVideoEncodingDisplay(value.EnterAudioEncoding)); | |||
value.EnterAudioChannelsNumber = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.EnterAudioChannelsNumber.ReadNumber()}]输入音频声道数", value.EnterAudioChannelsNumber); | |||
value.EnterAudioSampleRate = reader.ReadByte(); | |||
writer.WriteString($"[{value.EnterAudioSampleRate.ReadNumber()}]输入音频采样率", AudioSampleRateDisplay(value.EnterAudioSampleRate)); | |||
value.EnterAudioSampleDigits = reader.ReadByte(); | |||
writer.WriteString($"[{value.EnterAudioSampleDigits.ReadNumber()}]输入音频采样位数", AudioSampleDigitsDisplay(value.EnterAudioSampleDigits)); | |||
value.AudioFrameLength = reader.ReadUInt16(); | |||
writer.WriteNumber($"[{value.AudioFrameLength.ReadNumber()}]音频帧长度", value.AudioFrameLength); | |||
value.IsSupportedAudioOutput = reader.ReadByte(); | |||
writer.WriteString($"[{value.IsSupportedAudioOutput.ReadNumber()}]是否支持音频输出", value.IsSupportedAudioOutput==0?"不支持":"支持"); | |||
value.VideoEncoding = reader.ReadByte(); | |||
writer.WriteString($"[{value.VideoEncoding.ReadNumber()}]视频编码方式", AudioVideoEncodingDisplay(value.VideoEncoding)); | |||
value.TerminalSupportedMaxNumberOfAudioPhysicalChannels = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.TerminalSupportedMaxNumberOfAudioPhysicalChannels.ReadNumber()}]终端支持的最大音频物理通道数量", value.TerminalSupportedMaxNumberOfAudioPhysicalChannels); | |||
value.TerminalSupportedMaxNumberOfVideoPhysicalChannels = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.TerminalSupportedMaxNumberOfVideoPhysicalChannels.ReadNumber()}]终端支持的最大视频物理通道数量", value.TerminalSupportedMaxNumberOfVideoPhysicalChannels); | |||
string AudioVideoEncodingDisplay(byte AudioVideoEncoding) { | |||
switch (AudioVideoEncoding) | |||
{ | |||
case 19: | |||
return "AAC"; | |||
case 25: | |||
return "MP3"; | |||
case 91: | |||
return "透传"; | |||
case 98: | |||
return "H.264"; | |||
case 99: | |||
return "H.265"; | |||
default: | |||
break; | |||
} | |||
return "未解析"; | |||
} | |||
string AudioSampleRateDisplay(byte AudioSampleRate) { | |||
switch (AudioSampleRate) | |||
{ | |||
case 0: | |||
return "8 kHz"; | |||
case 1: | |||
return "22.05 kHz"; | |||
case 2: | |||
return "44.1 kHz"; | |||
case 3: | |||
return "48 kHz"; | |||
default: | |||
break; | |||
} | |||
return "未知"; | |||
} | |||
string AudioSampleDigitsDisplay(byte AudioSampleDigits) { | |||
switch (AudioSampleDigits) | |||
{ | |||
case 0: | |||
return "8 位"; | |||
case 1: | |||
return "16 位"; | |||
case 2: | |||
return "32 位"; | |||
default: | |||
break; | |||
} | |||
return "未知"; | |||
} | |||
} | |||
public JT808_0x1003 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x1003 jT808_0x1003 = new JT808_0x1003(); | |||
@@ -1,16 +1,19 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessagePack; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
/// <summary> | |||
/// 终端上传乘客流量 | |||
/// </summary> | |||
public class JT808_0x1005 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x1005> | |||
public class JT808_0x1005 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x1005>, IJT808Analyze | |||
{ | |||
public override string Description => "终端上传乘客流量"; | |||
public override ushort MsgId => 0x1005; | |||
/// <summary> | |||
/// 起始时间 | |||
@@ -29,6 +32,19 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// </summary> | |||
public ushort GettingOffNumber { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x1005 value = new JT808_0x1005(); | |||
value.BeginTime = reader.ReadDateTime6(); | |||
writer.WriteString($"[{value.BeginTime.ToString("yyMMddHHmmss")}]开始时间", value.BeginTime.ToString("yyyy-MM-dd HH:mm:ss")); | |||
value.EndTime = reader.ReadDateTime6(); | |||
writer.WriteString($"[{value.EndTime.ToString("yyMMddHHmmss")}]结束时间", value.EndTime.ToString("yyyy-MM-dd HH:mm:ss")); | |||
value.GettingOnNumber = reader.ReadUInt16(); | |||
writer.WriteNumber($"[{value.GettingOnNumber.ReadNumber()}]从开始时间到结束时间的上车人数",value.GettingOnNumber); | |||
value.GettingOffNumber = reader.ReadUInt16(); | |||
writer.WriteNumber($"[{value.GettingOffNumber.ReadNumber()}]从开始时间到结束时间的下车人数", value.GettingOffNumber); | |||
} | |||
public JT808_0x1005 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x1005 jT808_0x1005 = new JT808_0x1005(); | |||
@@ -1,17 +1,20 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessagePack; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
/// <summary> | |||
/// 终端上传音视频资源列表 | |||
/// </summary> | |||
public class JT808_0x1205 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x1205> | |||
public class JT808_0x1205 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x1205>, IJT808Analyze | |||
{ | |||
public override string Description => "终端上传音视频资源列表"; | |||
public override ushort MsgId => 0x1205; | |||
/// <summary> | |||
/// 流水号 | |||
@@ -26,6 +29,25 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// </summary> | |||
public List<JT808_0x1205_AVResouce> AVResouces { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x1205 value = new JT808_0x1205(); | |||
value.MsgNum = reader.ReadUInt16(); | |||
writer.WriteNumber($"[{value.MsgNum.ReadNumber()}]流水号", value.MsgNum); | |||
value.AVResouceTotal = reader.ReadUInt32(); | |||
writer.WriteNumber($"[{value.AVResouceTotal.ReadNumber()}]音视频资源总数", value.AVResouceTotal); | |||
writer.WriteStartArray("音视频资源列表"); | |||
var formatter = config.GetMessagePackFormatter<JT808_0x1205_AVResouce>(); | |||
for (int i = 0; i < value.AVResouceTotal; i++) | |||
{ | |||
writer.WriteStartObject(); | |||
formatter.Analyze(ref reader, writer, config); | |||
writer.WriteEndObject(); | |||
} | |||
writer.WriteEndArray(); | |||
} | |||
public JT808_0x1205 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x1205 jT808_0x1205 = new JT808_0x1205(); | |||
@@ -1,15 +1,17 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessagePack; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
/// <summary> | |||
/// 终端上传音视频资源列表 | |||
/// </summary> | |||
public class JT808_0x1205_AVResouce:IJT808MessagePackFormatter<JT808_0x1205_AVResouce> | |||
public class JT808_0x1205_AVResouce:IJT808MessagePackFormatter<JT808_0x1205_AVResouce>, IJT808Analyze | |||
{ | |||
/// <summary> | |||
/// 逻辑通道号 | |||
@@ -44,6 +46,102 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// </summary> | |||
public uint FileSize { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x1205_AVResouce value = new JT808_0x1205_AVResouce(); | |||
value.LogicChannelNo = reader.ReadByte(); | |||
writer.WriteString($"[{value.LogicChannelNo.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.LogicChannelNo)); | |||
value.BeginTime = reader.ReadDateTime6(); | |||
writer.WriteString($"[{value.BeginTime.ToString("yyMMddHHmmss")}]开始时间", value.BeginTime.ToString("yyyy-MM-dd HH:mm:ss")); | |||
value.BeginTime = reader.ReadDateTime6(); | |||
writer.WriteString($"[{value.BeginTime.ToString("yyMMddHHmmss")}]开始时间", value.BeginTime.ToString("yyyy-MM-dd HH:mm:ss")); | |||
value.AlarmFlag = reader.ReadUInt32(); | |||
writer.WriteNumber($"[{value.AlarmFlag.ReadNumber()}]报警标志", value.AlarmFlag);//此处的报警标志不是很明白 | |||
value.AVResourceType = reader.ReadByte(); | |||
writer.WriteString($"[{value.AVResourceType.ReadNumber()}]音视频资源类型", AVResourceTypeDisplay(value.AVResourceType)); | |||
value.StreamType = reader.ReadByte(); | |||
writer.WriteString($"[{value.StreamType.ReadNumber()}]码流类型", StreamTypeDisplay(value.StreamType)); | |||
value.MemoryType = reader.ReadByte(); | |||
writer.WriteString($"[{value.MemoryType.ReadNumber()}]存储器类型", MemoryTypeDisplay(value.MemoryType)); | |||
value.FileSize = reader.ReadUInt32(); | |||
writer.WriteNumber($"[{value.FileSize.ReadNumber()}]文件大小(B)", value.FileSize); | |||
string LogicalChannelNoDisplay(byte LogicalChannelNo) | |||
{ | |||
switch (LogicalChannelNo) | |||
{ | |||
case 1: | |||
return "驾驶员"; | |||
case 2: | |||
return "车辆正前方"; | |||
case 3: | |||
return "车前门"; | |||
case 4: | |||
return "车厢前部"; | |||
case 5: | |||
return "车厢后部"; | |||
case 7: | |||
return "行李舱"; | |||
case 8: | |||
return "车辆左侧"; | |||
case 9: | |||
return "车辆右侧"; | |||
case 10: | |||
return "车辆正后方"; | |||
case 11: | |||
return "车厢中部"; | |||
case 12: | |||
return "车中门"; | |||
case 13: | |||
return "驾驶席车门"; | |||
case 33: | |||
return "驾驶员"; | |||
case 36: | |||
return "车厢前部"; | |||
case 37: | |||
return "车厢后部"; | |||
default: | |||
return "预留"; | |||
} | |||
} | |||
string AVResourceTypeDisplay(byte AVResourceType) { | |||
switch (AVResourceType) | |||
{ | |||
case 0: | |||
return "音视频"; | |||
case 1: | |||
return "音频"; | |||
case 2: | |||
return "视频"; | |||
default: | |||
break; | |||
} | |||
return "未知"; | |||
} | |||
string StreamTypeDisplay(byte StreamType) { | |||
switch (StreamType) | |||
{ | |||
case 1: | |||
return "主码流"; | |||
case 2: | |||
return "子码流"; | |||
default: | |||
return "未知"; | |||
} | |||
} | |||
string MemoryTypeDisplay(byte MemoryType) | |||
{ | |||
switch (MemoryType) | |||
{ | |||
case 1: | |||
return "主存储器"; | |||
case 2: | |||
return "灾备存储器"; | |||
default: | |||
return "未知"; | |||
} | |||
} | |||
} | |||
public JT808_0x1205_AVResouce Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x1205_AVResouce jT808_0x1205_AVResouce = new JT808_0x1205_AVResouce(); | |||
@@ -1,16 +1,19 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessagePack; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
/// <summary> | |||
/// 文件上传完成通知 | |||
/// </summary> | |||
public class JT808_0x1206 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x1206> | |||
public class JT808_0x1206 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x1206>, IJT808Analyze | |||
{ | |||
public override string Description => "文件上传完成通知"; | |||
public override ushort MsgId => 0x1206; | |||
/// <summary> | |||
/// 流水号 | |||
@@ -20,6 +23,27 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// 结果 | |||
/// </summary> | |||
public byte Result{ get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x1206 value = new JT808_0x1206(); | |||
value.MsgNum = reader.ReadUInt16(); | |||
writer.WriteNumber($"[{value.MsgNum.ReadNumber()}]流水号", value.MsgNum); | |||
value.Result = reader.ReadByte(); | |||
writer.WriteString($"[{value.Result.ReadNumber()}]结果", ResultDisplay(value.Result)); | |||
string ResultDisplay(byte Result) { | |||
switch (Result) | |||
{ | |||
case 0: | |||
return "成功"; | |||
case 1: | |||
return "失败"; | |||
default: | |||
return "未知"; | |||
} | |||
} | |||
} | |||
public JT808_0x1206 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x1206 jT808_0x1206 = new JT808_0x1206(); | |||
@@ -1,6 +1,9 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessageBody; | |||
using JT808.Protocol.MessagePack; | |||
using System; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
@@ -8,7 +11,7 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// 音视频参数设置 | |||
/// 0x8103_0x0075 | |||
/// </summary> | |||
public class JT808_0x8103_0x0075 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter<JT808_0x8103_0x0075> | |||
public class JT808_0x8103_0x0075 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter<JT808_0x8103_0x0075>, IJT808Analyze | |||
{ | |||
public override uint ParamId { get; set; } = 0x0075; | |||
/// <summary> | |||
@@ -70,6 +73,124 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// </summary> | |||
public byte AudioOutputEnabled { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x8103_0x0075 value = new JT808_0x8103_0x0075(); | |||
value.ParamId = reader.ReadUInt32(); | |||
writer.WriteNumber($"[{value.ParamId.ReadNumber()}]参数 ID", value.ParamId); | |||
value.ParamLength = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.ParamLength.ReadNumber()}]数据长度", value.ParamLength); | |||
value.RTS_EncodeMode = reader.ReadByte(); | |||
writer.WriteString($"[{value.RTS_EncodeMode.ReadNumber()}]实时流编码模式", RTS_EncodeModeDisplay(value.RTS_EncodeMode)); | |||
value.RTS_Resolution = reader.ReadByte(); | |||
writer.WriteString($"[{value.RTS_Resolution.ReadNumber()}]实时流分辨率", RTS_ResolutionDisplay(value.RTS_Resolution)); | |||
value.RTS_KF_Interval = reader.ReadUInt16(); | |||
writer.WriteNumber($"[{value.RTS_KF_Interval.ReadNumber()}]实时流关键帧间隔(帧)", value.RTS_KF_Interval); | |||
value.RTS_Target_FPS = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.RTS_Target_FPS.ReadNumber()}]实时流目标帧率(帧/s)", value.RTS_Target_FPS); | |||
value.RTS_Target_CodeRate = reader.ReadUInt32(); | |||
writer.WriteNumber($"[{value.RTS_Target_CodeRate.ReadNumber()}]实时流目标码流(kbps)", value.RTS_Target_CodeRate); | |||
value.StreamStore_EncodeMode = reader.ReadByte(); | |||
writer.WriteString($"[{value.StreamStore_EncodeMode.ReadNumber()}]存储量编码模式", StreamStore_EncodeModeDisplay(value.StreamStore_EncodeMode)); | |||
value.StreamStore_Resolution = reader.ReadByte(); | |||
writer.WriteString($"[{value.StreamStore_Resolution.ReadNumber()}]存储流分辨率", StreamStore_ResolutionDisplay(value.StreamStore_Resolution)); | |||
value.StreamStore_KF_Interval = reader.ReadUInt16(); | |||
writer.WriteNumber($"[{value.StreamStore_KF_Interval.ReadNumber()}]存储流关键帧间隔(帧)", value.StreamStore_KF_Interval); | |||
value.StreamStore_Target_FPS = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.StreamStore_Target_FPS.ReadNumber()}]存储流目标帧率(帧/s)", value.StreamStore_Target_FPS); | |||
value.StreamStore_Target_CodeRate = reader.ReadUInt32(); | |||
writer.WriteNumber($"[{value.StreamStore_Target_CodeRate.ReadNumber()}]存储流目标码流(kbps)", value.StreamStore_Target_CodeRate); | |||
value.OSD = reader.ReadUInt16(); | |||
writer.WriteString($"[{value.OSD.ReadNumber()}]OBD字幕叠加设置", OBDDisplay(value.OSD)); | |||
value.AudioOutputEnabled = reader.ReadByte(); | |||
writer.WriteString($"[{value.AudioOutputEnabled.ReadNumber()}]是否启用音频输出", value.AudioOutputEnabled == 0 ? "不启用" : "启用"); | |||
string RTS_EncodeModeDisplay(byte RTS_EncodeMode) { | |||
switch (RTS_EncodeMode) | |||
{ | |||
case 0: | |||
return "CBR固定码流"; | |||
case 1: | |||
return "VBR可变码流"; | |||
case 2: | |||
return "ABR平均码流"; | |||
default: | |||
break; | |||
} | |||
return "未知"; | |||
} | |||
string RTS_ResolutionDisplay(byte RTS_Resolution) { | |||
switch (RTS_Resolution) | |||
{ | |||
case 0: | |||
return "QCIF"; | |||
case 1: | |||
return "CIF"; | |||
case 2: | |||
return "WCIF"; | |||
case 3: | |||
return "D1"; | |||
case 4: | |||
return "WD1"; | |||
case 5: | |||
return "720P"; | |||
case 6: | |||
return "1080P"; | |||
default: | |||
break; | |||
} | |||
return "未知"; | |||
} | |||
string StreamStore_EncodeModeDisplay(byte StreamStore_EncodeMode) { | |||
{ | |||
switch (RTS_EncodeMode) | |||
{ | |||
case 0: | |||
return "CBR固定码流"; | |||
case 1: | |||
return "VBR可变码流"; | |||
case 2: | |||
return "ABR平均码流"; | |||
default: | |||
break; | |||
} | |||
return "未知"; | |||
} | |||
} | |||
string StreamStore_ResolutionDisplay(byte StreamStore_Resolution) { | |||
switch (RTS_Resolution) | |||
{ | |||
case 0: | |||
return "QCIF"; | |||
case 1: | |||
return "CIF"; | |||
case 2: | |||
return "WCIF"; | |||
case 3: | |||
return "D1"; | |||
case 4: | |||
return "WD1"; | |||
case 5: | |||
return "720P"; | |||
case 6: | |||
return "1080P"; | |||
default: | |||
break; | |||
} | |||
return "未知"; | |||
} | |||
string OBDDisplay(ushort OBD) { | |||
string obdDisplay = string.Empty; | |||
obdDisplay += ((OBD & 0x0001) == 1) ? ",日期和时间" : ""; | |||
obdDisplay += ((OBD >> 1 & 0x0001) == 1) ? ",车牌号码" : ""; | |||
obdDisplay += ((OBD >> 2 & 0x0001) == 1) ? ",逻辑通道号" : ""; | |||
obdDisplay += ((OBD >> 3 & 0x0001) == 1) ? ",经纬度" : ""; | |||
obdDisplay += ((OBD >> 4 & 0x0001) == 1) ? ",行驶记录速度" : ""; | |||
obdDisplay += ((OBD >> 5 & 0x0001) == 1) ? ",卫星定位速度" : ""; | |||
obdDisplay += ((OBD >> 6 & 0x0001) == 1) ? ",连续驾驶时间" : ""; | |||
return obdDisplay.Length>0? obdDisplay.Substring(1):""; | |||
} | |||
} | |||
public JT808_0x8103_0x0075 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x8103_0x0075 jT808_0X8103_0X0075 = new JT808_0x8103_0x0075(); | |||
@@ -1,8 +1,10 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessageBody; | |||
using JT808.Protocol.MessagePack; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
@@ -10,7 +12,7 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// 音视频通道列表设置 | |||
/// 0x8103_0x0076 | |||
/// </summary> | |||
public class JT808_0x8103_0x0076 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter<JT808_0x8103_0x0076> | |||
public class JT808_0x8103_0x0076 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter<JT808_0x8103_0x0076>, IJT808Analyze | |||
{ | |||
public override uint ParamId { get; set; } = 0x0076; | |||
/// <summary> | |||
@@ -38,6 +40,32 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// </summary> | |||
public List<JT808_0x8103_0x0076_AVChannelRefTable> AVChannelRefTables { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x8103_0x0076 value = new JT808_0x8103_0x0076(); | |||
value.ParamId = reader.ReadUInt32(); | |||
writer.WriteNumber($"[{value.ParamId.ReadNumber()}]参数 ID", value.ParamId); | |||
value.ParamLength = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.ParamLength.ReadNumber()}]数据长度", value.ParamLength); | |||
value.AVChannelTotal = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.AVChannelTotal.ReadNumber()}]音视频通道总数", value.AVChannelTotal); | |||
value.AudioChannelTotal = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.AudioChannelTotal.ReadNumber()}]音频通道总数", value.AudioChannelTotal); | |||
value.VudioChannelTotal = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.VudioChannelTotal.ReadNumber()}]视频通道总数", value.VudioChannelTotal); | |||
var channelTotal = value.AVChannelTotal + value.AudioChannelTotal + value.VudioChannelTotal;//通道总数 | |||
writer.WriteStartArray("音视频通道对照表"); | |||
for (int i = 0; i < channelTotal; i++) | |||
{ | |||
writer.WriteStartObject(); | |||
var formatter = config.GetMessagePackFormatter<JT808_0x8103_0x0076_AVChannelRefTable>(); | |||
formatter.Analyze(ref reader, writer, config); | |||
writer.WriteEndObject(); | |||
} | |||
writer.WriteEndArray(); | |||
} | |||
public JT808_0x8103_0x0076 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x8103_0x0076 jT808_0X8103_0X0076 = new JT808_0x8103_0x0076(); | |||
@@ -1,5 +1,7 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessagePack; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
@@ -7,7 +9,7 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// 音视频通道列表设置 | |||
/// 0x8103_0x0076_AVChannelRefTable | |||
/// </summary> | |||
public class JT808_0x8103_0x0076_AVChannelRefTable: IJT808MessagePackFormatter<JT808_0x8103_0x0076_AVChannelRefTable> | |||
public class JT808_0x8103_0x0076_AVChannelRefTable: IJT808MessagePackFormatter<JT808_0x8103_0x0076_AVChannelRefTable>, IJT808Analyze | |||
{ | |||
/// <summary> | |||
/// 物理通道号 | |||
@@ -25,6 +27,82 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// 是否链接云台 | |||
/// </summary> | |||
public byte IsConnectCloudPlat { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x8103_0x0076_AVChannelRefTable value = new JT808_0x8103_0x0076_AVChannelRefTable(); | |||
value.PhysicalChannelNo = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.PhysicalChannelNo.ReadNumber()}]物理通道号", value.PhysicalChannelNo); | |||
value.LogicChannelNo = reader.ReadByte(); | |||
writer.WriteString($"[{value.LogicChannelNo.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.LogicChannelNo)); | |||
value.ChannelType = reader.ReadByte(); | |||
writer.WriteString($"[{value.ChannelType.ReadNumber()}]通道类型", ChannelTypeDisplay(value.ChannelType)); | |||
value.IsConnectCloudPlat = reader.ReadByte(); | |||
writer.WriteString($"[{value.IsConnectCloudPlat.ReadNumber()}]是否链接云台", IsConnectCloudPlatDisplay(value.IsConnectCloudPlat)); | |||
string LogicalChannelNoDisplay(byte LogicalChannelNo) | |||
{ | |||
switch (LogicalChannelNo) | |||
{ | |||
case 1: | |||
return "驾驶员"; | |||
case 2: | |||
return "车辆正前方"; | |||
case 3: | |||
return "车前门"; | |||
case 4: | |||
return "车厢前部"; | |||
case 5: | |||
return "车厢后部"; | |||
case 7: | |||
return "行李舱"; | |||
case 8: | |||
return "车辆左侧"; | |||
case 9: | |||
return "车辆右侧"; | |||
case 10: | |||
return "车辆正后方"; | |||
case 11: | |||
return "车厢中部"; | |||
case 12: | |||
return "车中门"; | |||
case 13: | |||
return "驾驶席车门"; | |||
case 33: | |||
return "驾驶员"; | |||
case 36: | |||
return "车厢前部"; | |||
case 37: | |||
return "车厢后部"; | |||
default: | |||
return "预留"; | |||
} | |||
} | |||
string ChannelTypeDisplay(byte ChannelType) { | |||
switch (ChannelType) | |||
{ | |||
case 0: | |||
return "音视频"; | |||
case 1: | |||
return "音频"; | |||
case 2: | |||
return "视频"; | |||
default: | |||
return "未知"; | |||
} | |||
} | |||
string IsConnectCloudPlatDisplay(byte IsConnectCloudPlat) { | |||
switch (IsConnectCloudPlat) | |||
{ | |||
case 0: | |||
return "未连接"; | |||
case 1: | |||
return "连接"; | |||
default: | |||
return "未知"; | |||
} | |||
} | |||
} | |||
public JT808_0x8103_0x0076_AVChannelRefTable Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x8103_0x0076_AVChannelRefTable jT808_0X8103_0X0076_AVChannelRefTable = new JT808_0x8103_0x0076_AVChannelRefTable(); | |||
@@ -1,8 +1,10 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessageBody; | |||
using JT808.Protocol.MessagePack; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
@@ -10,7 +12,7 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
///单独视频通道参数设置 | |||
/// 0x8103_0x0077 | |||
/// </summary> | |||
public class JT808_0x8103_0x0077 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter<JT808_0x8103_0x0077> | |||
public class JT808_0x8103_0x0077 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter<JT808_0x8103_0x0077>, IJT808Analyze | |||
{ | |||
public override uint ParamId { get; set; } = 0x0077; | |||
/// <summary> | |||
@@ -24,6 +26,26 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
public List<JT808_0x8103_0x0077_SignalChannel> SignalChannels { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x8103_0x0077 value = new JT808_0x8103_0x0077(); | |||
value.ParamId = reader.ReadUInt32(); | |||
writer.WriteNumber($"[{value.ParamId.ReadNumber()}]参数 ID", value.ParamId); | |||
value.ParamLength = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.ParamLength.ReadNumber()}]数据长度", value.ParamLength); | |||
value.NeedSetChannelTotal = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.NeedSetChannelTotal.ReadNumber()}]需单独设置视频参数的通道数量", value.NeedSetChannelTotal); | |||
writer.WriteStartArray("音视频通道对照表"); | |||
for (int i = 0; i < value.NeedSetChannelTotal; i++) | |||
{ | |||
writer.WriteStartObject(); | |||
var formatter = config.GetMessagePackFormatter<JT808_0x8103_0x0077_SignalChannel>(); | |||
formatter.Analyze(ref reader, writer, config); | |||
writer.WriteEndObject(); | |||
} | |||
writer.WriteEndArray(); | |||
} | |||
public JT808_0x8103_0x0077 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x8103_0x0077 jT808_0X8103_0X0077 = new JT808_0x8103_0x0077(); | |||
@@ -1,12 +1,14 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessagePack; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
public class JT808_0x8103_0x0077_SignalChannel: IJT808MessagePackFormatter<JT808_0x8103_0x0077_SignalChannel> | |||
public class JT808_0x8103_0x0077_SignalChannel: IJT808MessagePackFormatter<JT808_0x8103_0x0077_SignalChannel>, IJT808Analyze | |||
{ | |||
/// <summary> | |||
/// 逻辑通道号 | |||
@@ -60,6 +62,164 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
///OSD字幕叠加设置 | |||
/// </summary> | |||
public ushort OSD { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x8103_0x0077_SignalChannel value = new JT808_0x8103_0x0077_SignalChannel(); | |||
value.LogicChannelNo = reader.ReadByte(); | |||
writer.WriteString($"[{value.LogicChannelNo.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.LogicChannelNo)); | |||
value.RTS_EncodeMode = reader.ReadByte(); | |||
writer.WriteString($"[{value.RTS_EncodeMode.ReadNumber()}]实时流编码模式", RTS_EncodeModeDisplay(value.RTS_EncodeMode)); | |||
value.RTS_Resolution = reader.ReadByte(); | |||
writer.WriteString($"[{value.RTS_Resolution.ReadNumber()}]实时流分辨率", RTS_ResolutionDisplay(value.RTS_Resolution)); | |||
value.RTS_KF_Interval = reader.ReadUInt16(); | |||
writer.WriteNumber($"[{value.RTS_KF_Interval.ReadNumber()}]实时流关键帧间隔(帧)", value.RTS_KF_Interval); | |||
value.RTS_Target_FPS = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.RTS_Target_FPS.ReadNumber()}]实时流目标帧率(帧/s)", value.RTS_Target_FPS); | |||
value.RTS_Target_CodeRate = reader.ReadUInt32(); | |||
writer.WriteNumber($"[{value.RTS_Target_CodeRate.ReadNumber()}]实时流目标码率(kbps)", value.RTS_Target_CodeRate); | |||
value.StreamStore_EncodeMode = reader.ReadByte(); | |||
writer.WriteString($"[{value.StreamStore_EncodeMode.ReadNumber()}]存储流编码模式", StreamStore_EncodeModeDisplay(value.StreamStore_EncodeMode)); | |||
value.StreamStore_Resolution = reader.ReadByte(); | |||
writer.WriteString($"[{value.StreamStore_Resolution.ReadNumber()}]存储流分辨率", StreamStore_ResolutionDisplay(value.StreamStore_Resolution)); | |||
value.StreamStore_KF_Interval = reader.ReadUInt16(); | |||
writer.WriteNumber($"[{value.StreamStore_KF_Interval.ReadNumber()}]存储流关键帧间隔(帧)", value.StreamStore_KF_Interval); | |||
value.StreamStore_Target_FPS = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.StreamStore_Target_FPS.ReadNumber()}]存储流目标帧率(帧/s)", value.StreamStore_Target_FPS); | |||
value.StreamStore_Target_CodeRate = reader.ReadUInt32(); | |||
writer.WriteNumber($"[{value.StreamStore_Target_CodeRate.ReadNumber()}]存储流目标码率(kbps)", value.StreamStore_Target_CodeRate); | |||
value.OSD = reader.ReadUInt16(); | |||
writer.WriteString($"[{value.OSD.ReadNumber()}]OSD字幕叠加设置", OBDDisplay(value.OSD)); | |||
string LogicalChannelNoDisplay(byte LogicalChannelNo) | |||
{ | |||
switch (LogicalChannelNo) | |||
{ | |||
case 1: | |||
return "驾驶员"; | |||
case 2: | |||
return "车辆正前方"; | |||
case 3: | |||
return "车前门"; | |||
case 4: | |||
return "车厢前部"; | |||
case 5: | |||
return "车厢后部"; | |||
case 7: | |||
return "行李舱"; | |||
case 8: | |||
return "车辆左侧"; | |||
case 9: | |||
return "车辆右侧"; | |||
case 10: | |||
return "车辆正后方"; | |||
case 11: | |||
return "车厢中部"; | |||
case 12: | |||
return "车中门"; | |||
case 13: | |||
return "驾驶席车门"; | |||
case 33: | |||
return "驾驶员"; | |||
case 36: | |||
return "车厢前部"; | |||
case 37: | |||
return "车厢后部"; | |||
default: | |||
return "预留"; | |||
} | |||
} | |||
string RTS_EncodeModeDisplay(byte RTS_EncodeMode) | |||
{ | |||
switch (RTS_EncodeMode) | |||
{ | |||
case 0: | |||
return "CBR固定码流"; | |||
case 1: | |||
return "VBR可变码流"; | |||
case 2: | |||
return "ABR平均码流"; | |||
default: | |||
break; | |||
} | |||
return "未知"; | |||
} | |||
string RTS_ResolutionDisplay(byte RTS_Resolution) | |||
{ | |||
switch (RTS_Resolution) | |||
{ | |||
case 0: | |||
return "QCIF"; | |||
case 1: | |||
return "CIF"; | |||
case 2: | |||
return "WCIF"; | |||
case 3: | |||
return "D1"; | |||
case 4: | |||
return "WD1"; | |||
case 5: | |||
return "720P"; | |||
case 6: | |||
return "1080P"; | |||
default: | |||
break; | |||
} | |||
return "未知"; | |||
} | |||
string StreamStore_EncodeModeDisplay(byte StreamStore_EncodeMode) | |||
{ | |||
{ | |||
switch (StreamStore_EncodeMode) | |||
{ | |||
case 0: | |||
return "CBR固定码流"; | |||
case 1: | |||
return "VBR可变码流"; | |||
case 2: | |||
return "ABR平均码流"; | |||
default: | |||
break; | |||
} | |||
return "未知"; | |||
} | |||
} | |||
string StreamStore_ResolutionDisplay(byte StreamStore_Resolution) | |||
{ | |||
switch (StreamStore_Resolution) | |||
{ | |||
case 0: | |||
return "QCIF"; | |||
case 1: | |||
return "CIF"; | |||
case 2: | |||
return "WCIF"; | |||
case 3: | |||
return "D1"; | |||
case 4: | |||
return "WD1"; | |||
case 5: | |||
return "720P"; | |||
case 6: | |||
return "1080P"; | |||
default: | |||
break; | |||
} | |||
return "未知"; | |||
} | |||
string OBDDisplay(ushort OBD) | |||
{ | |||
string obdDisplay = string.Empty; | |||
obdDisplay += ((OBD & 0x0001) == 1) ? ",日期和时间" : ""; | |||
obdDisplay += ((OBD >> 1 & 0x0001) == 1) ? ",车牌号码" : ""; | |||
obdDisplay += ((OBD >> 2 & 0x0001) == 1) ? ",逻辑通道号" : ""; | |||
obdDisplay += ((OBD >> 3 & 0x0001) == 1) ? ",经纬度" : ""; | |||
obdDisplay += ((OBD >> 4 & 0x0001) == 1) ? ",行驶记录速度" : ""; | |||
obdDisplay += ((OBD >> 5 & 0x0001) == 1) ? ",卫星定位速度" : ""; | |||
obdDisplay += ((OBD >> 6 & 0x0001) == 1) ? ",连续驾驶时间" : ""; | |||
return obdDisplay.Length > 0 ? obdDisplay.Substring(1) : ""; | |||
} | |||
} | |||
public JT808_0x8103_0x0077_SignalChannel Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x8103_0x0077_SignalChannel jT808_0X8103_0X0077_SignalChannel = new JT808_0x8103_0x0077_SignalChannel(); | |||
@@ -1,7 +1,9 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessageBody; | |||
using JT808.Protocol.MessagePack; | |||
using System.Collections.Generic; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
@@ -9,7 +11,7 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// 特殊报警录像参数设置 | |||
/// 0x8103_0x0079 | |||
/// </summary> | |||
public class JT808_0x8103_0x0079 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter<JT808_0x8103_0x0079> | |||
public class JT808_0x8103_0x0079 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter<JT808_0x8103_0x0079>, IJT808Analyze | |||
{ | |||
public override uint ParamId { get; set; } = 0x0079; | |||
/// <summary> | |||
@@ -30,6 +32,21 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// </summary> | |||
public byte BeginMinute { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x8103_0x0079 value = new JT808_0x8103_0x0079(); | |||
value.ParamId = reader.ReadUInt32(); | |||
writer.WriteNumber($"[{value.ParamId.ReadNumber()}]参数 ID", value.ParamId); | |||
value.ParamLength = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.ParamLength.ReadNumber()}]数据长度", value.ParamLength); | |||
value.StorageThresholds = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.StorageThresholds.ReadNumber()}]特殊报警录像存储阈值(百分比)", value.StorageThresholds); | |||
value.Duration = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.Duration.ReadNumber()}]特殊报警录像持续时间(分钟)", value.Duration); | |||
value.BeginMinute = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.BeginMinute.ReadNumber()}]特殊报警标识起始时间(分钟)", value.BeginMinute); | |||
} | |||
public JT808_0x8103_0x0079 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x8103_0x0079 jT808_0x8103_0x0079 = new JT808_0x8103_0x0079(); | |||
@@ -1,7 +1,9 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessageBody; | |||
using JT808.Protocol.MessagePack; | |||
using System.Collections.Generic; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
@@ -9,7 +11,7 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// 视频相关报警屏蔽字 | |||
/// 0x8103_0x007A | |||
/// </summary> | |||
public class JT808_0x8103_0x007A : JT808_0x8103_BodyBase, IJT808MessagePackFormatter<JT808_0x8103_0x007A> | |||
public class JT808_0x8103_0x007A : JT808_0x8103_BodyBase, IJT808MessagePackFormatter<JT808_0x8103_0x007A>, IJT808Analyze | |||
{ | |||
public override uint ParamId { get; set; } = 0x007A; | |||
/// <summary> | |||
@@ -20,6 +22,37 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// 视频相关屏蔽报警字 | |||
/// </summary> | |||
public uint AlarmShielding { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x8103_0x007A value = new JT808_0x8103_0x007A(); | |||
value.ParamId = reader.ReadUInt32(); | |||
writer.WriteNumber($"[{value.ParamId.ReadNumber()}]参数 ID", value.ParamId); | |||
value.ParamLength = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.ParamLength.ReadNumber()}]数据长度", value.ParamLength); | |||
value.AlarmShielding = reader.ReadUInt32(); | |||
writer.WriteString($"[{value.AlarmShielding.ReadNumber()}]视频相关屏蔽报警字", AlarmShieldingDisplay(value.AlarmShielding)); | |||
string AlarmShieldingDisplay(uint AlarmShielding) | |||
{ | |||
switch (AlarmShielding) | |||
{ | |||
case 0x14: | |||
return "视频相关报警"; | |||
case 0x15: | |||
return "视频信号丢失报警状态"; | |||
case 0x16: | |||
return "视频信号遮挡报警状态"; | |||
case 0x17: | |||
return "存储器故障报警状态"; | |||
case 0x18: | |||
return "异常驾驶行为详细描述"; | |||
default: | |||
break; | |||
} | |||
return "未知"; | |||
} | |||
} | |||
public JT808_0x8103_0x007A Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x8103_0x007A jT808_0x8103_0x007A = new JT808_0x8103_0x007A(); | |||
@@ -1,7 +1,9 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessageBody; | |||
using JT808.Protocol.MessagePack; | |||
using System.Collections.Generic; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
@@ -9,7 +11,7 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// 图像分析报警参数设置 | |||
/// 0x8103_0x007B | |||
/// </summary> | |||
public class JT808_0x8103_0x007B : JT808_0x8103_BodyBase, IJT808MessagePackFormatter<JT808_0x8103_0x007B> | |||
public class JT808_0x8103_0x007B : JT808_0x8103_BodyBase, IJT808MessagePackFormatter<JT808_0x8103_0x007B>, IJT808Analyze | |||
{ | |||
public override uint ParamId { get; set; } = 0x007B; | |||
/// <summary> | |||
@@ -25,6 +27,19 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// </summary> | |||
public byte FatigueThreshold { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x8103_0x007B value = new JT808_0x8103_0x007B(); | |||
value.ParamId = reader.ReadUInt32(); | |||
writer.WriteNumber($"[{value.ParamId.ReadNumber()}]参数 ID", value.ParamId); | |||
value.ParamLength = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.ParamLength.ReadNumber()}]数据长度", value.ParamLength); | |||
value.NuclearLoadNumber = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.NuclearLoadNumber.ReadNumber()}]车辆核载人数", value.NuclearLoadNumber); | |||
value.FatigueThreshold = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.FatigueThreshold.ReadNumber()}]疲劳程度阈值", value.FatigueThreshold); | |||
} | |||
public JT808_0x8103_0x007B Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x8103_0x007B jT808_0x8103_0x007B = new JT808_0x8103_0x007B(); | |||
@@ -1,7 +1,9 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessageBody; | |||
using JT808.Protocol.MessagePack; | |||
using System.Collections.Generic; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
@@ -9,7 +11,7 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
///终端休眠模式唤醒设置 | |||
/// 0x8103_0x007C | |||
/// </summary> | |||
public class JT808_0x8103_0x007C : JT808_0x8103_BodyBase, IJT808MessagePackFormatter<JT808_0x8103_0x007C> | |||
public class JT808_0x8103_0x007C : JT808_0x8103_BodyBase, IJT808MessagePackFormatter<JT808_0x8103_0x007C>, IJT808Analyze | |||
{ | |||
public override uint ParamId { get; set; } = 0x007C; | |||
/// <summary> | |||
@@ -33,6 +35,51 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// </summary> | |||
public JT808_0x8103_0x007C_TimerWakeDayParamter TimerWakeDayParamter { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x8103_0x007C value = new JT808_0x8103_0x007C(); | |||
value.ParamId = reader.ReadUInt32(); | |||
writer.WriteNumber($"[{value.ParamId.ReadNumber()}]参数 ID", value.ParamId); | |||
value.ParamLength = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.ParamLength.ReadNumber()}]数据长度", value.ParamLength); | |||
value.SleepWakeMode = reader.ReadByte(); | |||
writer.WriteString($"[{value.SleepWakeMode.ReadNumber()}]休眠唤醒模式", SleepWakeModeDisplay(value.SleepWakeMode)); | |||
value.WakeConditionType = reader.ReadByte(); | |||
writer.WriteString($"[{value.WakeConditionType.ReadNumber()}]唤醒条件类型", WakeConditionTypeDisplay(value.WakeConditionType)); | |||
value.TimerWakeDaySet = reader.ReadByte(); | |||
writer.WriteString($"[{value.TimerWakeDaySet.ReadNumber()}]定时唤醒日设置", TimerWakeDaySetDisplay(value.TimerWakeDaySet)); | |||
writer.WriteStartObject("日定时唤醒参数列表"); | |||
config.GetMessagePackFormatter<JT808_0x8103_0x007C_TimerWakeDayParamter>().Analyze(ref reader,writer, config); | |||
writer.WriteEndObject(); | |||
string SleepWakeModeDisplay(byte SleepWakeMode) { | |||
string sleepWakeModeDisplay = string.Empty; | |||
sleepWakeModeDisplay += (SleepWakeMode & 0x01) == 1 ? ",条件唤醒" : ""; | |||
sleepWakeModeDisplay += (SleepWakeMode>>1 & 0x01) == 1 ? ",定时唤醒" : ""; | |||
sleepWakeModeDisplay += (SleepWakeMode>>2 & 0x01) == 1 ? ",手动唤醒" : ""; | |||
return sleepWakeModeDisplay.Length>0? sleepWakeModeDisplay.Substring(1):""; | |||
} | |||
string WakeConditionTypeDisplay(byte WakeConditionType) | |||
{ | |||
string wakeConditionTypeDisplay = string.Empty; | |||
wakeConditionTypeDisplay += (WakeConditionType & 0x01) == 1 ? ",紧急报警" : ""; | |||
wakeConditionTypeDisplay += (WakeConditionType >> 1 & 0x01) == 1 ? ",碰撞侧翻报警" : ""; | |||
wakeConditionTypeDisplay += (WakeConditionType >> 2 & 0x01) == 1 ? ",车辆开门" : ""; | |||
return wakeConditionTypeDisplay.Length>0? wakeConditionTypeDisplay.Substring(1):""; | |||
} | |||
string TimerWakeDaySetDisplay(byte TimerWakeDaySet) | |||
{ | |||
string timerWakeDaySetDisplay = string.Empty; | |||
timerWakeDaySetDisplay+= (TimerWakeDaySet & 0x01) == 1 ? ",周一":""; | |||
timerWakeDaySetDisplay+= (TimerWakeDaySet >> 1 & 0x01) == 1 ? ",周二" :""; | |||
timerWakeDaySetDisplay+= (TimerWakeDaySet >> 1 & 0x02) == 1 ? ",周三" :""; | |||
timerWakeDaySetDisplay+= (TimerWakeDaySet >> 1 & 0x03) == 1 ? ",周四" :""; | |||
timerWakeDaySetDisplay+= (TimerWakeDaySet >> 1 & 0x04) == 1 ? ",周五" :""; | |||
timerWakeDaySetDisplay+= (TimerWakeDaySet >> 1 & 0x05) == 1 ? ",周六" :""; | |||
timerWakeDaySetDisplay += (TimerWakeDaySet >> 1 & 0x06) == 1 ? ",周日" : ""; | |||
return timerWakeDaySetDisplay.Length>0? timerWakeDaySetDisplay.Substring(1):""; | |||
} | |||
} | |||
public JT808_0x8103_0x007C Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x8103_0x007C jT808_0x8103_0x007C = new JT808_0x8103_0x007C(); | |||
@@ -1,7 +1,9 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessageBody; | |||
using JT808.Protocol.MessagePack; | |||
using System.Collections.Generic; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
@@ -9,7 +11,7 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
///终端休眠模式唤醒设置 | |||
/// 0x8103_0x007C | |||
/// </summary> | |||
public class JT808_0x8103_0x007C_TimerWakeDayParamter:IJT808MessagePackFormatter<JT808_0x8103_0x007C_TimerWakeDayParamter> | |||
public class JT808_0x8103_0x007C_TimerWakeDayParamter:IJT808MessagePackFormatter<JT808_0x8103_0x007C_TimerWakeDayParamter>, IJT808Analyze | |||
{ | |||
/// <summary> | |||
/// 定时唤醒启用标志 | |||
@@ -56,6 +58,37 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// </summary> | |||
public string TimePeriod4CloseTime { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x8103_0x007C_TimerWakeDayParamter value = new JT808_0x8103_0x007C_TimerWakeDayParamter(); | |||
value.TimerWakeEnableFlag = reader.ReadByte(); | |||
writer.WriteString($"[{value.TimerWakeEnableFlag.ReadNumber()}]定时唤醒启用标志", TimerWakeEnableFlagDisplay(value.TimerWakeEnableFlag)); | |||
value.TimePeriod1WakeTime = reader.ReadBCD(4); | |||
writer.WriteString($"[{value.TimePeriod1WakeTime}]时间段1唤醒时间", value.TimePeriod1WakeTime); | |||
value.TimePeriod1CloseTime = reader.ReadBCD(4); | |||
writer.WriteString($"[{value.TimePeriod1CloseTime}]时间段1关闭时间", value.TimePeriod1CloseTime); | |||
value.TimePeriod2WakeTime = reader.ReadBCD(4); | |||
writer.WriteString($"[{value.TimePeriod2WakeTime}]时间段2唤醒时间", value.TimePeriod2WakeTime); | |||
value.TimePeriod2CloseTime = reader.ReadBCD(4); | |||
writer.WriteString($"[{value.TimePeriod2CloseTime}]时间段2关闭时间", value.TimePeriod2CloseTime); | |||
value.TimePeriod3WakeTime = reader.ReadBCD(4); | |||
writer.WriteString($"[{value.TimePeriod3WakeTime}]时间段3唤醒时间", value.TimePeriod3WakeTime); | |||
value.TimePeriod3CloseTime = reader.ReadBCD(4); | |||
writer.WriteString($"[{value.TimePeriod3CloseTime}]时间段3关闭时间", value.TimePeriod3CloseTime); | |||
value.TimePeriod4WakeTime = reader.ReadBCD(4); | |||
writer.WriteString($"[{value.TimePeriod4WakeTime}]时间段4唤醒时间", value.TimePeriod4WakeTime); | |||
value.TimePeriod4CloseTime = reader.ReadBCD(4); | |||
writer.WriteString($"[{value.TimePeriod4CloseTime}]时间段4关闭时间", value.TimePeriod4CloseTime); | |||
string TimerWakeEnableFlagDisplay(byte TimerWakeEnableFlag) { | |||
string timerWakeEnableFlagDisplay = string.Empty; | |||
timerWakeEnableFlagDisplay += (TimerWakeEnableFlag & 0x01) == 1 ? ",时间段1唤醒时间启用" : ""; | |||
timerWakeEnableFlagDisplay += (TimerWakeEnableFlag & 0x01) == 1 ? ",时间段2唤醒时间启用" : ""; | |||
timerWakeEnableFlagDisplay += (TimerWakeEnableFlag & 0x01) == 1 ? ",时间段3唤醒时间启用" : ""; | |||
timerWakeEnableFlagDisplay += (TimerWakeEnableFlag & 0x01) == 1 ? ",时间段4唤醒时间启用" : ""; | |||
return timerWakeEnableFlagDisplay.Length > 0 ? timerWakeEnableFlagDisplay.Substring(1) : ""; | |||
} | |||
} | |||
public JT808_0x8103_0x007C_TimerWakeDayParamter Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x8103_0x007C_TimerWakeDayParamter jT808_0x8103_0x007C_TimerWakeDayParamter = new JT808_0x8103_0x007C_TimerWakeDayParamter(); | |||
@@ -9,6 +9,7 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// </summary> | |||
public class JT808_0x9003:JT808Bodies | |||
{ | |||
public override string Description => "查询终端音视频属性"; | |||
public override ushort MsgId => 0x9003; | |||
public override bool SkipSerialization { get; set; } = true; | |||
} | |||
@@ -1,16 +1,19 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessagePack; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
/// <summary> | |||
/// 实时音视频传输请求 | |||
/// </summary> | |||
public class JT808_0x9101:JT808Bodies, IJT808MessagePackFormatter<JT808_0x9101> | |||
public class JT808_0x9101: JT808Bodies, IJT808MessagePackFormatter<JT808_0x9101>, IJT808Analyze | |||
{ | |||
public override string Description => "实时音视频传输请求"; | |||
public override ushort MsgId => 0x9101; | |||
/// <summary> | |||
/// 服务器IP地址长度 | |||
@@ -49,6 +52,84 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// </summary> | |||
public byte StreamType { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x9101 value = new JT808_0x9101(); | |||
value.ServerIPAddressLength = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.ServerIPAddressLength.ReadNumber()}]服务器IP地址长度", value.ServerIPAddressLength); | |||
string ipHex = reader.ReadVirtualArray(value.ServerIPAddressLength).ToArray().ToHexString(); | |||
value.ServerIPAddress = reader.ReadString(value.ServerIPAddressLength); | |||
writer.WriteString($"[{ipHex}]服务器IP地址", value.ServerIPAddress); | |||
value.ServerVideoChannelTcpPort = reader.ReadUInt16(); | |||
writer.WriteNumber($"[{value.ServerVideoChannelTcpPort.ReadNumber()}]服务器视频通道监听端口号(TCP)", value.ServerVideoChannelTcpPort); | |||
value.ServerVideoChannelUdpPort = reader.ReadUInt16(); | |||
writer.WriteNumber($"[{value.ServerVideoChannelUdpPort.ReadNumber()}]服务器视频通道监听端口号(UDP)", value.ServerVideoChannelUdpPort); | |||
value.LogicalChannelNo = reader.ReadByte(); | |||
writer.WriteString($"[{value.LogicalChannelNo.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.LogicalChannelNo)); | |||
value.DataType = reader.ReadByte(); | |||
writer.WriteString($"[{value.DataType.ReadNumber()}]数据类型", DataTypeDisplay(value.DataType)); | |||
value.StreamType = reader.ReadByte(); | |||
writer.WriteString($"[{value.StreamType.ReadNumber()}]码流类型", value.StreamType==0?"主码流":"子码流"); | |||
string DataTypeDisplay(byte DataType) { | |||
switch (DataType) | |||
{ | |||
case 0: | |||
return "音视频"; | |||
case 1: | |||
return "视频"; | |||
case 2: | |||
return "双向对讲"; | |||
case 3: | |||
return "监听"; | |||
case 4: | |||
return "中心广播"; | |||
case 5: | |||
return "透传"; | |||
default: | |||
break; | |||
} | |||
return "未知"; | |||
} | |||
string LogicalChannelNoDisplay(byte LogicalChannelNo) { | |||
switch (LogicalChannelNo) | |||
{ | |||
case 1: | |||
return "驾驶员"; | |||
case 2: | |||
return "车辆正前方"; | |||
case 3: | |||
return "车前门"; | |||
case 4: | |||
return "车厢前部"; | |||
case 5: | |||
return "车厢后部"; | |||
case 7: | |||
return "行李舱"; | |||
case 8: | |||
return "车辆左侧"; | |||
case 9: | |||
return "车辆右侧"; | |||
case 10: | |||
return "车辆正后方"; | |||
case 11: | |||
return "车厢中部"; | |||
case 12: | |||
return "车中门"; | |||
case 13: | |||
return "驾驶席车门"; | |||
case 33: | |||
return "驾驶员"; | |||
case 36: | |||
return "车厢前部"; | |||
case 37: | |||
return "车厢后部"; | |||
default: | |||
return "预留"; | |||
} | |||
} | |||
} | |||
public JT808_0x9101 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x9101 jT808_0X9101 = new JT808_0x9101(); | |||
@@ -1,16 +1,19 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessagePack; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
/// <summary> | |||
/// 音视频实时传输控制 | |||
/// </summary> | |||
public class JT808_0x9102:JT808Bodies, IJT808MessagePackFormatter<JT808_0x9102> | |||
public class JT808_0x9102: JT808Bodies, IJT808MessagePackFormatter<JT808_0x9102>, IJT808Analyze | |||
{ | |||
public override string Description => "音视频实时传输控制"; | |||
public override ushort MsgId => 0x9102; | |||
/// <summary> | |||
/// 逻辑通道号 | |||
@@ -42,6 +45,88 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// </summary> | |||
public byte SwitchStreamType { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x9102 value = new JT808_0x9102(); | |||
value.LogicalChannelNo = reader.ReadByte(); | |||
writer.WriteString($"[{value.LogicalChannelNo.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.LogicalChannelNo)); | |||
value.ControlCmd = reader.ReadByte(); | |||
writer.WriteString($"[{value.ControlCmd.ReadNumber()}]控制指令", ControlCmdDisplay(value.ControlCmd)); | |||
value.CloseAVData = reader.ReadByte(); | |||
writer.WriteString($"[{value.CloseAVData.ReadNumber()}]关闭音视频类型", CloseAVDataDisplay(value.CloseAVData)); | |||
value.SwitchStreamType = reader.ReadByte(); | |||
writer.WriteString($"[{value.SwitchStreamType.ReadNumber()}]切换码流类型", value.SwitchStreamType==0?"主码流":"子码流"); | |||
string CloseAVDataDisplay(byte CloseAVData) { | |||
switch (CloseAVData) | |||
{ | |||
case 0: | |||
return "关闭该通道有关的音视频数据"; | |||
case 1: | |||
return "只关闭该通道有关的音频,保留该通道有关的视频"; | |||
case 2: | |||
return "只关闭该通道有关的视频,保留该通道有关的音频"; | |||
default: | |||
return "未知"; | |||
} | |||
} | |||
string ControlCmdDisplay(byte ControlCmd) { | |||
switch (ControlCmd) | |||
{ | |||
case 0: | |||
return "关闭音视频传输指令"; | |||
case 1: | |||
return "切换码流(增加暂停和继续)"; | |||
case 2: | |||
return "暂停该通道所有流的发送"; | |||
case 3: | |||
return "恢复暂停前流的发送,与暂停前的流类型一致"; | |||
case 4: | |||
return "关闭双向对讲"; | |||
default: | |||
return "未知"; | |||
} | |||
} | |||
string LogicalChannelNoDisplay(byte LogicalChannelNo) | |||
{ | |||
switch (LogicalChannelNo) | |||
{ | |||
case 1: | |||
return "驾驶员"; | |||
case 2: | |||
return "车辆正前方"; | |||
case 3: | |||
return "车前门"; | |||
case 4: | |||
return "车厢前部"; | |||
case 5: | |||
return "车厢后部"; | |||
case 7: | |||
return "行李舱"; | |||
case 8: | |||
return "车辆左侧"; | |||
case 9: | |||
return "车辆右侧"; | |||
case 10: | |||
return "车辆正后方"; | |||
case 11: | |||
return "车厢中部"; | |||
case 12: | |||
return "车中门"; | |||
case 13: | |||
return "驾驶席车门"; | |||
case 33: | |||
return "驾驶员"; | |||
case 36: | |||
return "车厢前部"; | |||
case 37: | |||
return "车厢后部"; | |||
default: | |||
return "预留"; | |||
} | |||
} | |||
} | |||
public JT808_0x9102 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x9102 jT808_0X9102 = new JT808_0x9102(); | |||
@@ -1,16 +1,19 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessagePack; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
/// <summary> | |||
/// 实时音视频传输状态通知 | |||
/// </summary> | |||
public class JT808_0x9105 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9105> | |||
public class JT808_0x9105 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9105>, IJT808Analyze | |||
{ | |||
public override string Description => "实时音视频传输状态通知"; | |||
public override ushort MsgId => 0x9105; | |||
/// <summary> | |||
/// 逻辑通道号 | |||
@@ -21,6 +24,53 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// </summary> | |||
public byte DropRate { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x9105 value = new JT808_0x9105(); | |||
value.LogicChannelNo = reader.ReadByte(); | |||
writer.WriteString($"[{value.LogicChannelNo.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.LogicChannelNo)); | |||
value.DropRate = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.DropRate.ReadNumber()}]丢包率", value.DropRate); | |||
string LogicalChannelNoDisplay(byte LogicalChannelNo) | |||
{ | |||
switch (LogicalChannelNo) | |||
{ | |||
case 1: | |||
return "驾驶员"; | |||
case 2: | |||
return "车辆正前方"; | |||
case 3: | |||
return "车前门"; | |||
case 4: | |||
return "车厢前部"; | |||
case 5: | |||
return "车厢后部"; | |||
case 7: | |||
return "行李舱"; | |||
case 8: | |||
return "车辆左侧"; | |||
case 9: | |||
return "车辆右侧"; | |||
case 10: | |||
return "车辆正后方"; | |||
case 11: | |||
return "车厢中部"; | |||
case 12: | |||
return "车中门"; | |||
case 13: | |||
return "驾驶席车门"; | |||
case 33: | |||
return "驾驶员"; | |||
case 36: | |||
return "车厢前部"; | |||
case 37: | |||
return "车厢后部"; | |||
default: | |||
return "预留"; | |||
} | |||
} | |||
} | |||
public JT808_0x9105 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x9105 jT808_0x9105 = new JT808_0x9105(); | |||
@@ -1,19 +1,22 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessagePack; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
/// <summary> | |||
/// 平台下发远程录像回放请求 | |||
/// </summary> | |||
public class JT808_0x9201 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9201> | |||
public class JT808_0x9201 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9201>, IJT808Analyze | |||
{ | |||
public override string Description => "平台下发远程录像回放请求"; | |||
public override ushort MsgId => 0x9201; | |||
/// <summary> | |||
/// 服务器IP地址服务 | |||
/// 服务器IP地址长度 | |||
/// </summary> | |||
public byte ServerIpLength { get; set; } | |||
/// <summary> | |||
@@ -51,11 +54,7 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// <summary> | |||
/// 快进或快退倍数 | |||
/// </summary> | |||
public byte FastForwardOrFastRewindMultiples1 { get; set; } | |||
/// <summary> | |||
/// 快进或快退倍数 | |||
/// </summary> | |||
public byte FastForwardOrFastRewindMultiples2 { get; set; } | |||
public byte FastForwardOrFastRewindMultiples { get; set; } | |||
/// <summary> | |||
/// 起始时间 | |||
/// </summary> | |||
@@ -65,6 +64,156 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// </summary> | |||
public DateTime EndTime { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x9201 value = new JT808_0x9201(); | |||
value.ServerIpLength = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.ServerIpLength.ReadNumber()}]服务器IP地址长度", value.ServerIpLength); | |||
string ipHex = reader.ReadVirtualArray(value.ServerIpLength).ToArray().ToHexString(); | |||
value.ServerIp = reader.ReadString(value.ServerIpLength); | |||
writer.WriteString($"[{ipHex}]服务器IP地址", value.ServerIp); | |||
value.TcpPort = reader.ReadUInt16(); | |||
writer.WriteNumber($"[{value.TcpPort.ReadNumber()}]服务器视频通道监听端口号(TCP)", value.TcpPort); | |||
value.UdpPort = reader.ReadUInt16(); | |||
writer.WriteNumber($"[{value.UdpPort.ReadNumber()}]服务器视频通道监听端口号(UDP)", value.UdpPort); | |||
value.LogicChannelNo = reader.ReadByte(); | |||
writer.WriteString($"[{value.LogicChannelNo.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.LogicChannelNo)); | |||
value.AVItemType = reader.ReadByte(); | |||
writer.WriteString($"[{value.AVItemType.ReadNumber()}]音视频类型", AVItemTypeDisplay(value.AVItemType)); | |||
value.StreamType = reader.ReadByte(); | |||
writer.WriteString($"[{value.StreamType.ReadNumber()}]码流类型", StreamTypeDisplay(value.StreamType)); | |||
value.MemType = reader.ReadByte(); | |||
writer.WriteString($"[{value.MemType.ReadNumber()}]存储器类型", MemTypeDisplay(value.MemType)); | |||
value.PlayBackWay = reader.ReadByte(); | |||
writer.WriteString($"[{value.PlayBackWay.ReadNumber()}]回访方式", PlayBackWayDisplay(value.PlayBackWay)); | |||
value.FastForwardOrFastRewindMultiples = reader.ReadByte(); | |||
writer.WriteString($"[{value.FastForwardOrFastRewindMultiples.ReadNumber()}]快进或快退倍数", FastForwardOrFastRewindMultiplesDisplay(value.FastForwardOrFastRewindMultiples)); | |||
value.BeginTime = reader.ReadDateTime6(); | |||
writer.WriteString($"[{value.BeginTime.ToString("yyMMddHHmmss")}]起始时间", value.BeginTime.ToString("yyyy-MM-dd HH:mm:ss")); | |||
value.EndTime = reader.ReadDateTime6(); | |||
writer.WriteString($"[{value.EndTime.ToString("yyMMddHHmmss")}]结束时间", value.EndTime.ToString("yyyy-MM-dd HH:mm:ss")); | |||
string AVItemTypeDisplay(byte AVItemType) | |||
{ | |||
switch (AVItemType) | |||
{ | |||
case 0: | |||
return "音视频"; | |||
case 1: | |||
return "音频"; | |||
case 2: | |||
return "视频"; | |||
case 3: | |||
return "音频或视频"; | |||
default: | |||
return "未知"; | |||
} | |||
} | |||
string StreamTypeDisplay(byte StreamType) | |||
{ | |||
switch (StreamType) | |||
{ | |||
case 0: | |||
return "主码流或子码流"; | |||
case 1: | |||
return "主码流"; | |||
case 2: | |||
return "子码流"; | |||
default: | |||
return "未知"; | |||
} | |||
} | |||
string MemTypeDisplay(byte MemType) | |||
{ | |||
switch (MemType) | |||
{ | |||
case 0: | |||
return "主存储器或灾备服务器"; | |||
case 1: | |||
return "主存储器"; | |||
case 2: | |||
return "灾备服务器"; | |||
default: | |||
return "未知"; | |||
} | |||
} | |||
string PlayBackWayDisplay(byte PlayBackWay) | |||
{ | |||
switch (PlayBackWay) | |||
{ | |||
case 0: | |||
return "正常回放"; | |||
case 1: | |||
return "快进回放"; | |||
case 2: | |||
return "关键帧快退回访"; | |||
case 3: | |||
return "关键帧播放"; | |||
case 4: | |||
return "单帧上传"; | |||
default: | |||
return "未知"; | |||
} | |||
} | |||
string FastForwardOrFastRewindMultiplesDisplay(byte FastForwardOrFastRewindMultiples) | |||
{ | |||
switch (FastForwardOrFastRewindMultiples) | |||
{ | |||
case 0: | |||
return "无效"; | |||
case 1: | |||
return "1倍"; | |||
case 2: | |||
return "2倍"; | |||
case 3: | |||
return "4倍"; | |||
case 4: | |||
return "8倍"; | |||
case 5: | |||
return "16倍"; | |||
default: | |||
return "未知"; | |||
} | |||
} | |||
string LogicalChannelNoDisplay(byte LogicalChannelNo) | |||
{ | |||
switch (LogicalChannelNo) | |||
{ | |||
case 1: | |||
return "驾驶员"; | |||
case 2: | |||
return "车辆正前方"; | |||
case 3: | |||
return "车前门"; | |||
case 4: | |||
return "车厢前部"; | |||
case 5: | |||
return "车厢后部"; | |||
case 7: | |||
return "行李舱"; | |||
case 8: | |||
return "车辆左侧"; | |||
case 9: | |||
return "车辆右侧"; | |||
case 10: | |||
return "车辆正后方"; | |||
case 11: | |||
return "车厢中部"; | |||
case 12: | |||
return "车中门"; | |||
case 13: | |||
return "驾驶席车门"; | |||
case 33: | |||
return "驾驶员"; | |||
case 36: | |||
return "车厢前部"; | |||
case 37: | |||
return "车厢后部"; | |||
default: | |||
return "预留"; | |||
} | |||
} | |||
} | |||
public JT808_0x9201 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x9201 jT808_0x9201 = new JT808_0x9201(); | |||
@@ -77,8 +226,7 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
jT808_0x9201.StreamType = reader.ReadByte(); | |||
jT808_0x9201.MemType = reader.ReadByte(); | |||
jT808_0x9201.PlayBackWay = reader.ReadByte(); | |||
jT808_0x9201.FastForwardOrFastRewindMultiples1 = reader.ReadByte(); | |||
jT808_0x9201.FastForwardOrFastRewindMultiples2 = reader.ReadByte(); | |||
jT808_0x9201.FastForwardOrFastRewindMultiples = reader.ReadByte(); | |||
jT808_0x9201.BeginTime = reader.ReadDateTime6(); | |||
jT808_0x9201.EndTime = reader.ReadDateTime6(); | |||
return jT808_0x9201; | |||
@@ -96,8 +244,7 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
writer.WriteByte(value.StreamType); | |||
writer.WriteByte(value.MemType); | |||
writer.WriteByte(value.PlayBackWay); | |||
writer.WriteByte(value.FastForwardOrFastRewindMultiples1); | |||
writer.WriteByte(value.FastForwardOrFastRewindMultiples2); | |||
writer.WriteByte(value.FastForwardOrFastRewindMultiples); | |||
writer.WriteDateTime6(value.BeginTime); | |||
writer.WriteDateTime6(value.EndTime); | |||
} | |||
@@ -1,16 +1,19 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessagePack; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
/// <summary> | |||
/// 平台下发远程录像回放控制 | |||
/// </summary> | |||
public class JT808_0x9202 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9202> | |||
public class JT808_0x9202 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9202>, IJT808Analyze | |||
{ | |||
public override string Description => "平台下发远程录像回放控制"; | |||
public override ushort MsgId => 0x9202; | |||
/// <summary> | |||
/// 音视频通道号 | |||
@@ -29,6 +32,98 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// </summary> | |||
public DateTime DragPlaybackPosition { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x9202 value = new JT808_0x9202(); | |||
value.AVChannelNo = reader.ReadByte(); | |||
writer.WriteString($"[{value.AVChannelNo.ReadNumber()}]音视频通道号", AVChannelNoDisplay(value.AVChannelNo)); | |||
value.PlayBackControl = reader.ReadByte(); | |||
writer.WriteString($"[{value.PlayBackControl.ReadNumber()}]回放控制", PlayBackControlDisplay(value.PlayBackControl)); | |||
value.FastForwardOrFastRewindMultiples = reader.ReadByte(); | |||
writer.WriteString($"[{value.FastForwardOrFastRewindMultiples.ReadNumber()}]快进或快退倍数", FastForwardOrFastRewindMultiplesDisplay(value.FastForwardOrFastRewindMultiples)); | |||
value.DragPlaybackPosition = reader.ReadDateTime6(); | |||
writer.WriteString($"[{value.DragPlaybackPosition.ToString("yyMMddHHmmss")}]拖动回放位置", value.DragPlaybackPosition.ToString("yyyy-MM-dd HH:mm:ss")); | |||
string AVChannelNoDisplay(byte LogicalChannelNo) | |||
{ | |||
switch (LogicalChannelNo) | |||
{ | |||
case 1: | |||
return "驾驶员"; | |||
case 2: | |||
return "车辆正前方"; | |||
case 3: | |||
return "车前门"; | |||
case 4: | |||
return "车厢前部"; | |||
case 5: | |||
return "车厢后部"; | |||
case 7: | |||
return "行李舱"; | |||
case 8: | |||
return "车辆左侧"; | |||
case 9: | |||
return "车辆右侧"; | |||
case 10: | |||
return "车辆正后方"; | |||
case 11: | |||
return "车厢中部"; | |||
case 12: | |||
return "车中门"; | |||
case 13: | |||
return "驾驶席车门"; | |||
case 33: | |||
return "驾驶员"; | |||
case 36: | |||
return "车厢前部"; | |||
case 37: | |||
return "车厢后部"; | |||
default: | |||
return "预留"; | |||
} | |||
} | |||
string PlayBackControlDisplay(byte PlayBackControl) { | |||
switch (PlayBackControl) | |||
{ | |||
case 0: | |||
return "开始回放"; | |||
case 1: | |||
return "暂停回放"; | |||
case 2: | |||
return "结束回放"; | |||
case 3: | |||
return "快进回放"; | |||
case 4: | |||
return "关键帧快退回放"; | |||
case 5: | |||
return "拖动回放"; | |||
case 6: | |||
return "关键帧播放"; | |||
default: | |||
return "未知"; | |||
} | |||
} | |||
string FastForwardOrFastRewindMultiplesDisplay(byte FastForwardOrFastRewindMultiples) | |||
{ | |||
switch (FastForwardOrFastRewindMultiples) | |||
{ | |||
case 0: | |||
return "无效"; | |||
case 1: | |||
return "1倍"; | |||
case 2: | |||
return "2倍"; | |||
case 3: | |||
return "4倍"; | |||
case 4: | |||
return "8倍"; | |||
case 5: | |||
return "16倍"; | |||
default: | |||
return "未知"; | |||
} | |||
} | |||
} | |||
public JT808_0x9202 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x9202 jT808_0x9202 = new JT808_0x9202(); | |||
@@ -1,16 +1,19 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessagePack; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
/// <summary> | |||
/// 查询资源列表 | |||
/// </summary> | |||
public class JT808_0x9205 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9205> | |||
public class JT808_0x9205 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9205>, IJT808Analyze | |||
{ | |||
public override string Description => "查询资源列表"; | |||
public override ushort MsgId => 0x9205; | |||
/// <summary> | |||
/// 逻辑通道号 | |||
@@ -41,6 +44,108 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// </summary> | |||
public byte MemoryType { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x9205 value = new JT808_0x9205(); | |||
value.LogicChannelNo = reader.ReadByte(); | |||
writer.WriteString($"[{value.LogicChannelNo.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.LogicChannelNo)); | |||
value.BeginTime = reader.ReadDateTime6(); | |||
writer.WriteString($"[{value.BeginTime.ToString("yyMMddHHmmss")}]起始时间", value.BeginTime.ToString("yyyy-MM-dd HH:mm:ss")); | |||
value.EndTime = reader.ReadDateTime6(); | |||
writer.WriteString($"[{value.EndTime.ToString("yyMMddHHmmss")}]起始时间", value.EndTime.ToString("yyyy-MM-dd HH:mm:ss")); | |||
value.AlarmFlag = reader.ReadUInt32(); | |||
writer.WriteNumber($"[{value.AlarmFlag.ReadNumber()}]报警标志", value.AlarmFlag); | |||
value.AVResourceType = reader.ReadByte(); | |||
writer.WriteString($"[{value.AVResourceType.ReadNumber()}]音视频类型", AVResourceTypeDisplay(value.AVResourceType)); | |||
value.StreamType = reader.ReadByte(); | |||
writer.WriteString($"[{value.StreamType.ReadNumber()}]码流类型", StreamTypeDisplay(value.StreamType)); | |||
value.MemoryType = reader.ReadByte(); | |||
writer.WriteString($"[{value.MemoryType.ReadNumber()}]存储器类型", MemoryTypeDisplay(value.MemoryType)); | |||
string AVResourceTypeDisplay(byte AVResourceType) | |||
{ | |||
switch (AVResourceType) | |||
{ | |||
case 0: | |||
return "音视频"; | |||
case 1: | |||
return "音频"; | |||
case 2: | |||
return "视频"; | |||
case 3: | |||
return "音频或视频"; | |||
default: | |||
return "未知"; | |||
} | |||
} | |||
string StreamTypeDisplay(byte StreamType) | |||
{ | |||
switch (StreamType) | |||
{ | |||
case 0: | |||
return "所有码流"; | |||
case 1: | |||
return "主码流"; | |||
case 2: | |||
return "子码流"; | |||
default: | |||
return "未知"; | |||
} | |||
} | |||
string MemoryTypeDisplay(byte MemType) | |||
{ | |||
switch (MemType) | |||
{ | |||
case 0: | |||
return "所有存储器"; | |||
case 1: | |||
return "主存储器"; | |||
case 2: | |||
return "灾备服务器"; | |||
default: | |||
return "未知"; | |||
} | |||
} | |||
string LogicalChannelNoDisplay(byte LogicalChannelNo) | |||
{ | |||
switch (LogicalChannelNo) | |||
{ | |||
case 1: | |||
return "驾驶员"; | |||
case 2: | |||
return "车辆正前方"; | |||
case 3: | |||
return "车前门"; | |||
case 4: | |||
return "车厢前部"; | |||
case 5: | |||
return "车厢后部"; | |||
case 7: | |||
return "行李舱"; | |||
case 8: | |||
return "车辆左侧"; | |||
case 9: | |||
return "车辆右侧"; | |||
case 10: | |||
return "车辆正后方"; | |||
case 11: | |||
return "车厢中部"; | |||
case 12: | |||
return "车中门"; | |||
case 13: | |||
return "驾驶席车门"; | |||
case 33: | |||
return "驾驶员"; | |||
case 36: | |||
return "车厢前部"; | |||
case 37: | |||
return "车厢后部"; | |||
default: | |||
return "预留"; | |||
} | |||
} | |||
} | |||
public JT808_0x9205 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x9205 jT808_0x9205 = new JT808_0x9205(); | |||
@@ -1,16 +1,19 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessagePack; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
/// <summary> | |||
/// 文件上传指令 | |||
/// </summary> | |||
public class JT808_0x9206 : JT808Bodies,IJT808MessagePackFormatter<JT808_0x9206> | |||
public class JT808_0x9206 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9206>, IJT808Analyze | |||
{ | |||
public override string Description => "文件上传指令"; | |||
public override ushort MsgId => 0x9206; | |||
/// <summary> | |||
/// 服务器IP地址服务 | |||
@@ -81,6 +84,140 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// </summary> | |||
public byte TaskExcuteCondition { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x9206 value = new JT808_0x9206(); | |||
value.ServerIpLength = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.ServerIpLength.ReadNumber()}]服务器IP地址长度", value.ServerIpLength); | |||
string ipHex = reader.ReadVirtualArray(value.ServerIpLength).ToArray().ToHexString(); | |||
value.ServerIp = reader.ReadString(value.ServerIpLength); | |||
writer.WriteString($"[{ipHex}]服务器IP地址", value.ServerIp); | |||
value.Port = reader.ReadUInt16(); | |||
writer.WriteNumber($"[{value.Port.ReadNumber()}]服务器端口", value.Port); | |||
value.UserNameLength = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.UserNameLength.ReadNumber()}]用户名长度", value.UserNameLength); | |||
string userNameHex = reader.ReadVirtualArray(value.UserNameLength).ToArray().ToHexString(); | |||
value.UserName = reader.ReadString(value.UserNameLength); | |||
writer.WriteString($"[{userNameHex}]用户名", value.UserName); | |||
value.PasswordLength = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.PasswordLength.ReadNumber()}]密码长度", value.PasswordLength); | |||
string passwordHex = reader.ReadVirtualArray(value.PasswordLength).ToArray().ToHexString(); | |||
value.Password = reader.ReadString(value.PasswordLength); | |||
writer.WriteString($"[{passwordHex}]密码", value.Password); | |||
value.FileUploadPathLength = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.FileUploadPathLength.ReadNumber()}]文件上传路径长度", value.FileUploadPathLength); | |||
string fileUploadPathHex = reader.ReadVirtualArray(value.FileUploadPathLength).ToArray().ToHexString(); | |||
value.FileUploadPath = reader.ReadString(value.FileUploadPathLength); | |||
writer.WriteString($"[{fileUploadPathHex}]文件上传路径", value.FileUploadPath); | |||
value.LogicChannelNo = reader.ReadByte(); | |||
writer.WriteString($"[{value.LogicChannelNo.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.LogicChannelNo)); | |||
value.BeginTime = reader.ReadDateTime6(); | |||
writer.WriteString($"[{value.BeginTime.ToString("yyMMddHHmmss")}]起始时间", value.BeginTime.ToString("yyyy-MM-dd HH:mm:ss")); | |||
value.EndTime = reader.ReadDateTime6(); | |||
writer.WriteString($"[{value.EndTime.ToString("yyMMddHHmmss")}]起始时间", value.EndTime.ToString("yyyy-MM-dd HH:mm:ss")); | |||
value.AlarmFlag = reader.ReadUInt32(); | |||
writer.WriteNumber($"[{value.AlarmFlag.ReadNumber()}]报警标志", value.AlarmFlag); | |||
value.AVResourceType = reader.ReadByte(); | |||
writer.WriteString($"[{value.AVResourceType.ReadNumber()}]音视频类型", AVResourceTypeDisplay(value.AVResourceType)); | |||
value.StreamType = reader.ReadByte(); | |||
writer.WriteString($"[{value.StreamType.ReadNumber()}]码流类型", StreamTypeDisplay(value.StreamType)); | |||
value.MemoryPositon = reader.ReadByte(); | |||
writer.WriteString($"[{value.MemoryPositon.ReadNumber()}]存储器类型", MemoryPositonDisplay(value.MemoryPositon)); | |||
value.TaskExcuteCondition = reader.ReadByte(); | |||
writer.WriteString($"[{value.TaskExcuteCondition.ReadNumber()}]任务执行条件", TaskExcuteConditionDisplay(value.TaskExcuteCondition)); | |||
string AVResourceTypeDisplay(byte AVResourceType) | |||
{ | |||
switch (AVResourceType) | |||
{ | |||
case 0: | |||
return "音视频"; | |||
case 1: | |||
return "音频"; | |||
case 2: | |||
return "视频"; | |||
case 3: | |||
return "音频或视频"; | |||
default: | |||
return "未知"; | |||
} | |||
} | |||
string StreamTypeDisplay(byte StreamType) | |||
{ | |||
switch (StreamType) | |||
{ | |||
case 0: | |||
return "所有码流"; | |||
case 1: | |||
return "主码流"; | |||
case 2: | |||
return "子码流"; | |||
default: | |||
return "未知"; | |||
} | |||
} | |||
string MemoryPositonDisplay(byte MemoryPositon) | |||
{ | |||
switch (MemoryPositon) | |||
{ | |||
case 0: | |||
return "主存储器或灾备服务器"; | |||
case 1: | |||
return "主存储器"; | |||
case 2: | |||
return "灾备服务器"; | |||
default: | |||
return "未知"; | |||
} | |||
} | |||
string LogicalChannelNoDisplay(byte LogicalChannelNo) | |||
{ | |||
switch (LogicalChannelNo) | |||
{ | |||
case 1: | |||
return "驾驶员"; | |||
case 2: | |||
return "车辆正前方"; | |||
case 3: | |||
return "车前门"; | |||
case 4: | |||
return "车厢前部"; | |||
case 5: | |||
return "车厢后部"; | |||
case 7: | |||
return "行李舱"; | |||
case 8: | |||
return "车辆左侧"; | |||
case 9: | |||
return "车辆右侧"; | |||
case 10: | |||
return "车辆正后方"; | |||
case 11: | |||
return "车厢中部"; | |||
case 12: | |||
return "车中门"; | |||
case 13: | |||
return "驾驶席车门"; | |||
case 33: | |||
return "驾驶员"; | |||
case 36: | |||
return "车厢前部"; | |||
case 37: | |||
return "车厢后部"; | |||
default: | |||
return "预留"; | |||
} | |||
} | |||
string TaskExcuteConditionDisplay(byte TaskExcuteCondition) { | |||
string taskExcuteConditionDisplay = string.Empty; | |||
taskExcuteConditionDisplay += (TaskExcuteCondition & 0x01) == 1 ? ",WIFI":""; | |||
taskExcuteConditionDisplay += (TaskExcuteCondition & 0x01) == 1 ? ",LAN" : ""; | |||
taskExcuteConditionDisplay += (TaskExcuteCondition & 0x01) == 1 ? ",3G/4G" : ""; | |||
return taskExcuteConditionDisplay.Length > 0 ? taskExcuteConditionDisplay.Substring(1) : ""; | |||
} | |||
} | |||
public JT808_0x9206 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x9206 jT808_0x9206 = new JT808_0x9206(); | |||
@@ -1,16 +1,19 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessagePack; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
/// <summary> | |||
/// 文件上传控制 | |||
/// </summary> | |||
public class JT808_0x9207 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9207> | |||
public class JT808_0x9207 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9207>, IJT808Analyze | |||
{ | |||
public override string Description => "文件上传控制"; | |||
public override ushort MsgId => 0x9207; | |||
/// <summary> | |||
/// 流水号 | |||
@@ -20,6 +23,29 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// 上传控制 | |||
/// </summary> | |||
public byte UploadControl { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x9207 value = new JT808_0x9207(); | |||
value.MgsNum = reader.ReadUInt16(); | |||
writer.WriteNumber($"[{value.MgsNum.ReadNumber()}]流水号", value.MgsNum); | |||
value.UploadControl = reader.ReadByte(); | |||
writer.WriteString($"[{value.UploadControl.ReadNumber()}]上传控制", UploadControlDisplay(value.UploadControl)); | |||
string UploadControlDisplay(byte UploadControl) { | |||
switch (UploadControl) | |||
{ | |||
case 0: | |||
return "暂停"; | |||
case 1: | |||
return "继续"; | |||
case 2: | |||
return "取消"; | |||
default: | |||
return "未知"; | |||
} | |||
} | |||
} | |||
public JT808_0x9207 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x9207 jT808_0x9207 = new JT808_0x9207(); | |||
@@ -1,16 +1,19 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessagePack; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
/// <summary> | |||
/// 云台旋转 | |||
/// </summary> | |||
public class JT808_0x9301 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9301> | |||
public class JT808_0x9301 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9301>, IJT808Analyze | |||
{ | |||
public override string Description => "云台旋转"; | |||
public override ushort MsgId => 0x9301; | |||
/// <summary> | |||
/// 逻辑通道号 | |||
@@ -25,6 +28,72 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// </summary> | |||
public byte Speed { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x9301 value = new JT808_0x9301(); | |||
value.LogicChannelNo = reader.ReadByte(); | |||
writer.WriteString($"[{value.LogicChannelNo.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.LogicChannelNo)); | |||
value.Direction = reader.ReadByte(); | |||
writer.WriteString($"[{value.Direction.ReadNumber()}]方向", DirectionDisplay(value.Direction)); | |||
value.Speed = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.Speed.ReadNumber()}]速度", value.Speed); | |||
string LogicalChannelNoDisplay(byte LogicalChannelNo) | |||
{ | |||
switch (LogicalChannelNo) | |||
{ | |||
case 1: | |||
return "驾驶员"; | |||
case 2: | |||
return "车辆正前方"; | |||
case 3: | |||
return "车前门"; | |||
case 4: | |||
return "车厢前部"; | |||
case 5: | |||
return "车厢后部"; | |||
case 7: | |||
return "行李舱"; | |||
case 8: | |||
return "车辆左侧"; | |||
case 9: | |||
return "车辆右侧"; | |||
case 10: | |||
return "车辆正后方"; | |||
case 11: | |||
return "车厢中部"; | |||
case 12: | |||
return "车中门"; | |||
case 13: | |||
return "驾驶席车门"; | |||
case 33: | |||
return "驾驶员"; | |||
case 36: | |||
return "车厢前部"; | |||
case 37: | |||
return "车厢后部"; | |||
default: | |||
return "预留"; | |||
} | |||
} | |||
string DirectionDisplay(byte Direction) { | |||
switch (Direction) | |||
{ | |||
case 0: | |||
return "停止"; | |||
case 1: | |||
return "上"; | |||
case 2: | |||
return "下"; | |||
case 3: | |||
return "左"; | |||
case 4: | |||
return "右"; | |||
default: | |||
return "未知"; | |||
} | |||
} | |||
} | |||
public JT808_0x9301 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x9301 jT808_0x9301 = new JT808_0x9301(); | |||
@@ -1,16 +1,19 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessagePack; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
/// <summary> | |||
/// 云台调整焦距控制 | |||
/// </summary> | |||
public class JT808_0x9302 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9302> | |||
public class JT808_0x9302 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9302>, IJT808Analyze | |||
{ | |||
public override string Description => "云台调整焦距控制"; | |||
public override ushort MsgId => 0x9302; | |||
/// <summary> | |||
/// 逻辑通道号 | |||
@@ -21,6 +24,55 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// </summary> | |||
public byte FocusAdjustmentDirection { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x9302 value = new JT808_0x9302(); | |||
value.LogicChannelNo = reader.ReadByte(); | |||
writer.WriteString($"[{value.LogicChannelNo.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.LogicChannelNo)); | |||
value.FocusAdjustmentDirection = reader.ReadByte(); | |||
writer.WriteString($"[{value.FocusAdjustmentDirection.ReadNumber()}]焦距调整方向", value.FocusAdjustmentDirection==0?"焦距调大":"焦距调小"); | |||
string LogicalChannelNoDisplay(byte LogicalChannelNo) | |||
{ | |||
switch (LogicalChannelNo) | |||
{ | |||
case 1: | |||
return "驾驶员"; | |||
case 2: | |||
return "车辆正前方"; | |||
case 3: | |||
return "车前门"; | |||
case 4: | |||
return "车厢前部"; | |||
case 5: | |||
return "车厢后部"; | |||
case 7: | |||
return "行李舱"; | |||
case 8: | |||
return "车辆左侧"; | |||
case 9: | |||
return "车辆右侧"; | |||
case 10: | |||
return "车辆正后方"; | |||
case 11: | |||
return "车厢中部"; | |||
case 12: | |||
return "车中门"; | |||
case 13: | |||
return "驾驶席车门"; | |||
case 33: | |||
return "驾驶员"; | |||
case 36: | |||
return "车厢前部"; | |||
case 37: | |||
return "车厢后部"; | |||
default: | |||
return "预留"; | |||
} | |||
} | |||
} | |||
public JT808_0x9302 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x9302 jT808_0x9302 = new JT808_0x9302(); | |||
@@ -1,16 +1,19 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessagePack; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
/// <summary> | |||
/// 云台调整光圈控制 | |||
/// </summary> | |||
public class JT808_0x9303 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9303> | |||
public class JT808_0x9303 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9303>, IJT808Analyze | |||
{ | |||
public override string Description => "云台调整光圈控制"; | |||
public override ushort MsgId => 0x9303; | |||
/// <summary> | |||
/// 逻辑通道号 | |||
@@ -20,6 +23,54 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// 光圈调整方式 | |||
/// </summary> | |||
public byte IrisAdjustment { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x9303 value = new JT808_0x9303(); | |||
value.LogicChannelNo = reader.ReadByte(); | |||
writer.WriteString($"[{value.LogicChannelNo.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.LogicChannelNo)); | |||
value.IrisAdjustment = reader.ReadByte(); | |||
writer.WriteString($"[{value.IrisAdjustment.ReadNumber()}]光圈调整方式", value.IrisAdjustment == 0 ? "调大" : "调小"); | |||
string LogicalChannelNoDisplay(byte LogicalChannelNo) | |||
{ | |||
switch (LogicalChannelNo) | |||
{ | |||
case 1: | |||
return "驾驶员"; | |||
case 2: | |||
return "车辆正前方"; | |||
case 3: | |||
return "车前门"; | |||
case 4: | |||
return "车厢前部"; | |||
case 5: | |||
return "车厢后部"; | |||
case 7: | |||
return "行李舱"; | |||
case 8: | |||
return "车辆左侧"; | |||
case 9: | |||
return "车辆右侧"; | |||
case 10: | |||
return "车辆正后方"; | |||
case 11: | |||
return "车厢中部"; | |||
case 12: | |||
return "车中门"; | |||
case 13: | |||
return "驾驶席车门"; | |||
case 33: | |||
return "驾驶员"; | |||
case 36: | |||
return "车厢前部"; | |||
case 37: | |||
return "车厢后部"; | |||
default: | |||
return "预留"; | |||
} | |||
} | |||
} | |||
public JT808_0x9303 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x9303 jT808_0x9303 = new JT808_0x9303(); | |||
@@ -1,16 +1,19 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessagePack; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
/// <summary> | |||
/// 云台雨刷控制 | |||
/// </summary> | |||
public class JT808_0x9304 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9304> | |||
public class JT808_0x9304 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9304>, IJT808Analyze | |||
{ | |||
public override string Description => "云台雨刷控制"; | |||
public override ushort MsgId => 0x9304; | |||
/// <summary> | |||
/// 逻辑通道号 | |||
@@ -20,6 +23,54 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// 启停标识 | |||
/// </summary> | |||
public byte StartOrStop { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x9304 value = new JT808_0x9304(); | |||
value.LogicChannelNo = reader.ReadByte(); | |||
writer.WriteString($"[{value.LogicChannelNo.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.LogicChannelNo)); | |||
value.StartOrStop = reader.ReadByte(); | |||
writer.WriteString($"[{value.StartOrStop.ReadNumber()}]启停标识", value.StartOrStop == 0 ? "停止" : "启动"); | |||
string LogicalChannelNoDisplay(byte LogicalChannelNo) | |||
{ | |||
switch (LogicalChannelNo) | |||
{ | |||
case 1: | |||
return "驾驶员"; | |||
case 2: | |||
return "车辆正前方"; | |||
case 3: | |||
return "车前门"; | |||
case 4: | |||
return "车厢前部"; | |||
case 5: | |||
return "车厢后部"; | |||
case 7: | |||
return "行李舱"; | |||
case 8: | |||
return "车辆左侧"; | |||
case 9: | |||
return "车辆右侧"; | |||
case 10: | |||
return "车辆正后方"; | |||
case 11: | |||
return "车厢中部"; | |||
case 12: | |||
return "车中门"; | |||
case 13: | |||
return "驾驶席车门"; | |||
case 33: | |||
return "驾驶员"; | |||
case 36: | |||
return "车厢前部"; | |||
case 37: | |||
return "车厢后部"; | |||
default: | |||
return "预留"; | |||
} | |||
} | |||
} | |||
public JT808_0x9304 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x9304 jT808_0x9304 = new JT808_0x9304(); | |||
@@ -1,16 +1,19 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessagePack; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
/// <summary> | |||
/// 红外补光控制 | |||
/// </summary> | |||
public class JT808_0x9305 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9305> | |||
public class JT808_0x9305 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9305>, IJT808Analyze | |||
{ | |||
public override string Description => "红外补光控制"; | |||
public override ushort MsgId => 0x9305; | |||
/// <summary> | |||
/// 逻辑通道号 | |||
@@ -20,6 +23,54 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// 启停标识 | |||
/// </summary> | |||
public byte StartOrStop { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x9305 value = new JT808_0x9305(); | |||
value.LogicChannelNo = reader.ReadByte(); | |||
writer.WriteString($"[{value.LogicChannelNo.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.LogicChannelNo)); | |||
value.StartOrStop = reader.ReadByte(); | |||
writer.WriteString($"[{value.StartOrStop.ReadNumber()}]启停标识", value.StartOrStop == 0 ? "停止" : "启动"); | |||
string LogicalChannelNoDisplay(byte LogicalChannelNo) | |||
{ | |||
switch (LogicalChannelNo) | |||
{ | |||
case 1: | |||
return "驾驶员"; | |||
case 2: | |||
return "车辆正前方"; | |||
case 3: | |||
return "车前门"; | |||
case 4: | |||
return "车厢前部"; | |||
case 5: | |||
return "车厢后部"; | |||
case 7: | |||
return "行李舱"; | |||
case 8: | |||
return "车辆左侧"; | |||
case 9: | |||
return "车辆右侧"; | |||
case 10: | |||
return "车辆正后方"; | |||
case 11: | |||
return "车厢中部"; | |||
case 12: | |||
return "车中门"; | |||
case 13: | |||
return "驾驶席车门"; | |||
case 33: | |||
return "驾驶员"; | |||
case 36: | |||
return "车厢前部"; | |||
case 37: | |||
return "车厢后部"; | |||
default: | |||
return "预留"; | |||
} | |||
} | |||
} | |||
public JT808_0x9305 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x9305 jT808_0x9305 = new JT808_0x9305(); | |||
@@ -1,16 +1,19 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessagePack; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
/// <summary> | |||
/// 云台变倍控制 | |||
/// </summary> | |||
public class JT808_0x9306 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9306> | |||
public class JT808_0x9306 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9306>, IJT808Analyze | |||
{ | |||
public override string Description => "云台变倍控制"; | |||
public override ushort MsgId => 0x9306; | |||
/// <summary> | |||
/// 逻辑通道号 | |||
@@ -21,6 +24,53 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// </summary> | |||
public byte ChangeMultipleControl { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x9306 value = new JT808_0x9306(); | |||
value.LogicChannelNo = reader.ReadByte(); | |||
writer.WriteString($"[{value.LogicChannelNo.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.LogicChannelNo)); | |||
value.ChangeMultipleControl = reader.ReadByte(); | |||
writer.WriteString($"[{value.ChangeMultipleControl.ReadNumber()}]变倍控制", value.ChangeMultipleControl == 0 ? "调大" : "调小"); | |||
string LogicalChannelNoDisplay(byte LogicalChannelNo) | |||
{ | |||
switch (LogicalChannelNo) | |||
{ | |||
case 1: | |||
return "驾驶员"; | |||
case 2: | |||
return "车辆正前方"; | |||
case 3: | |||
return "车前门"; | |||
case 4: | |||
return "车厢前部"; | |||
case 5: | |||
return "车厢后部"; | |||
case 7: | |||
return "行李舱"; | |||
case 8: | |||
return "车辆左侧"; | |||
case 9: | |||
return "车辆右侧"; | |||
case 10: | |||
return "车辆正后方"; | |||
case 11: | |||
return "车厢中部"; | |||
case 12: | |||
return "车中门"; | |||
case 13: | |||
return "驾驶席车门"; | |||
case 33: | |||
return "驾驶员"; | |||
case 36: | |||
return "车厢前部"; | |||
case 37: | |||
return "车厢后部"; | |||
default: | |||
return "预留"; | |||
} | |||
} | |||
} | |||
public JT808_0x9306 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x9306 jT808_0x9306 = new JT808_0x9306(); | |||