From 347d1dfb07f230b435fc51cc3bd628a9437996b8 Mon Sep 17 00:00:00 2001
From: "SmallChi(Koike)" <564952747@qq.com>
Date: Wed, 2 Dec 2020 21:56:32 +0800
Subject: [PATCH] =?UTF-8?q?1.=E7=BB=84=E8=A3=85=E6=B5=8B=E8=AF=95fmp4?=
=?UTF-8?q?=E7=9B=92=E5=AD=90=202.=E5=8D=87=E7=BA=A7808=E5=BA=93?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Boxs/AVCConfigurationBoxTest.cs | 58 +++++++++++++
src/JT1078.FMp4.Test/FMp4Box_Test.cs | 84 +++++++++++++++----
.../Samples/AVC1SampleEntryTest.cs | 79 +++++++++++++++++
src/JT1078.FMp4/Boxs/AVCConfigurationBox.cs | 50 ++++++++---
src/JT1078.FMp4/Boxs/MovieExtendsBox.cs | 6 ++
src/JT1078.FMp4/Boxs/SampleSizeBox.cs | 33 +++++++-
src/JT1078.FMp4/Boxs/SampleTableBox.cs | 10 ++-
src/JT1078.FMp4/Boxs/TrackExtendsBox.cs | 8 ++
src/JT1078.FMp4/JT1078.FMp4.xml | 17 ++++
src/JT1078.FMp4/Samples/AVC1SampleEntry.cs | 8 +-
src/JT1078.FMp4/Samples/VisualSampleEntry.cs | 26 +++---
.../JT808.Protocol.Extensions.JT1078.csproj | 4 +-
12 files changed, 335 insertions(+), 48 deletions(-)
create mode 100644 src/JT1078.FMp4.Test/Boxs/AVCConfigurationBoxTest.cs
create mode 100644 src/JT1078.FMp4.Test/Samples/AVC1SampleEntryTest.cs
diff --git a/src/JT1078.FMp4.Test/Boxs/AVCConfigurationBoxTest.cs b/src/JT1078.FMp4.Test/Boxs/AVCConfigurationBoxTest.cs
new file mode 100644
index 0000000..28a8a8f
--- /dev/null
+++ b/src/JT1078.FMp4.Test/Boxs/AVCConfigurationBoxTest.cs
@@ -0,0 +1,58 @@
+using JT1078.FMp4.MessagePack;
+using JT1078.Protocol.Extensions;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace JT1078.FMp4.Test.Boxs
+{
+ public class AVCConfigurationBoxTest
+ {
+ ///
+ /// 使用doc/video/fragmented_demo.mp4
+ ///
+ [Fact]
+ public void Test1()
+ {
+ //0000002f617663430164001fffe100176764001facd940881e684000f4240037b40883c60c658001000568efbcb000
+ //00 00 00 2f
+ //61 76 63 43
+ //01
+ //64
+ //00
+ //1f
+ //ff
+ //e1 numOfSequenceParameterSets 1
+ //00 17
+ //67 64 00 1f
+ //ac d9 40 88
+ //1e 68 40 00
+ //f4 24 00 37
+ //b4 08 83 c6
+ //0c 65 80
+ //01 NumOfPictureParameterSets 1
+ //00 05
+ //68 ef bc b0 00
+ AVCConfigurationBox aVCConfigurationBox = new AVCConfigurationBox();
+ aVCConfigurationBox.AVCProfileIndication = 0x64;
+ aVCConfigurationBox.ProfileCompatibility = 0;
+ aVCConfigurationBox.AVCLevelIndication = 0x1f;
+ aVCConfigurationBox.LengthSizeMinusOne = 0xff;
+ aVCConfigurationBox.SPSs = new List()
+ {
+ "6764001facd940881e684000f4240037b40883c60c6580".ToHexBytes()
+ };
+ aVCConfigurationBox.PPSs = new List()
+ {
+ "68efbcb000".ToHexBytes()
+ };
+ FMp4MessagePackWriter writer = new FMp4MessagePackWriter(new byte[0x0000002f]);
+ aVCConfigurationBox.ToBuffer(ref writer);
+ var hex = writer.FlushAndGetArray().ToHexString();
+ Assert.Equal("0000002f617663430164001fffe100176764001facd940881e684000f4240037b40883c60c658001000568efbcb000".ToUpper(), hex);
+ }
+ }
+}
diff --git a/src/JT1078.FMp4.Test/FMp4Box_Test.cs b/src/JT1078.FMp4.Test/FMp4Box_Test.cs
index a889290..3544b6b 100644
--- a/src/JT1078.FMp4.Test/FMp4Box_Test.cs
+++ b/src/JT1078.FMp4.Test/FMp4Box_Test.cs
@@ -4,6 +4,8 @@ using System.Collections.Generic;
using System.Text;
using Xunit;
using JT1078.Protocol.Extensions;
+using JT1078.FMp4.Enums;
+using JT1078.FMp4.Samples;
namespace JT1078.FMp4.Test
{
@@ -49,8 +51,8 @@ namespace JT1078.FMp4.Test
///
/// 使用doc/video/fragmented_demo.mp4
///
- [Fact(DisplayName = "trak_tkhd")]
- public void trak_tkhd_test()
+ [Fact(DisplayName = "moov_trak_tkhd")]
+ public void moov_trak_tkhd_test()
{
TrackHeaderBox trackHeaderBox = new TrackHeaderBox(0,3);
trackHeaderBox.CreationTime = 0;
@@ -67,8 +69,8 @@ namespace JT1078.FMp4.Test
///
/// 使用doc/video/fragmented_demo.mp4
///
- [Fact(DisplayName = "trak_mdia")]
- public void trak_mdia_test()
+ [Fact(DisplayName = "moov_trak_mdia")]
+ public void moov_trak_mdia_test()
{
@@ -76,8 +78,8 @@ namespace JT1078.FMp4.Test
///
/// 使用doc/video/fragmented_demo.mp4
///
- [Fact(DisplayName = "trak_mdia_mdhd")]
- public void trak_mdia_mdhd_test()
+ [Fact(DisplayName = "moov_trak_mdia_mdhd")]
+ public void moov_trak_mdia_mdhd_test()
{
MediaHeaderBox mediaHeaderBox = new MediaHeaderBox(0, 0);
@@ -104,8 +106,8 @@ namespace JT1078.FMp4.Test
///
/// 使用doc/video/fragmented_demo.mp4
///
- [Fact(DisplayName = "trak_mdia_hdlr")]
- public void trak_mdia_hdlr_test()
+ [Fact(DisplayName = "moov_trak_mdia_hdlr")]
+ public void moov_trak_mdia_hdlr_test()
{
HandlerBox handlerBox = new HandlerBox(0, 0);
handlerBox.HandlerType = Enums.HandlerType.vide;
@@ -118,8 +120,8 @@ namespace JT1078.FMp4.Test
///
/// 使用doc/video/fragmented_demo.mp4
///
- [Fact(DisplayName = "trak_mdia_hdlr_minf")]
- public void trak_mdia_hdlr_minf_test()
+ [Fact(DisplayName = "moov_trak_mdia_hdlr_minf")]
+ public void moov_trak_mdia_hdlr_minf_test()
{
HandlerBox handlerBox = new HandlerBox(0, 0);
handlerBox.HandlerType = Enums.HandlerType.vide;
@@ -132,8 +134,8 @@ namespace JT1078.FMp4.Test
///
/// 使用doc/video/fragmented_demo.mp4
///
- [Fact(DisplayName = "trak_mdia_hdlr_minf_vmhd")]
- public void trak_mdia_hdlr_minf_vmhd_test()
+ [Fact(DisplayName = "moov_trak_mdia_hdlr_minf_vmhd")]
+ public void moov_trak_mdia_hdlr_minf_vmhd_test()
{
VideoMediaHeaderBox videoMediaHeaderBox = new VideoMediaHeaderBox();
FMp4MessagePackWriter writer = new MessagePack.FMp4MessagePackWriter(new byte[10240]);
@@ -144,8 +146,8 @@ namespace JT1078.FMp4.Test
///
/// 使用doc/video/fragmented_demo.mp4
///
- [Fact(DisplayName = "trak_mdia_hdlr_minf_dinf")]
- public void trak_mdia_hdlr_minf_dinf_test()
+ [Fact(DisplayName = "moov_trak_mdia_hdlr_minf_dinf")]
+ public void moov_trak_mdia_hdlr_minf_dinf_test()
{
DataInformationBox dataInformationBox = new DataInformationBox();
DataReferenceBox dataReferenceBox = new DataReferenceBox();
@@ -161,10 +163,58 @@ namespace JT1078.FMp4.Test
///
/// 使用doc/video/fragmented_demo.mp4
///
- [Fact(DisplayName = "trak_mdia_hdlr_minf_stbl")]
- public void trak_mdia_hdlr_minf_stbl_test()
+ [Fact(DisplayName = "moov_trak_mdia_hdlr_minf_stbl")]
+ public void moov_trak_mdia_hdlr_minf_stbl_test()
{
-
+ //000000e17374626c000000957374736400000000000000010000008561766331000000000000000100000000000000000000000000000000022003c0004800000048000000000000000100000000000000000000000000000000000000000000000000000000000000000018ffff0000002f617663430164001fffe100176764001facd940881e684000f4240037b40883c60c658001000568efbcb0000000001073747473000000000000000000000010737473630000000000000000000000147374737a000000000000000000000000000000107374636f0000000000000000
+ //stbl
+ SampleTableBox sampleTableBox = new SampleTableBox();
+ //stbl->stsd
+ SampleDescriptionBox sampleDescriptionBox = new SampleDescriptionBox(HandlerType.none);
+ //stbl->stsd->avc1
+ AVC1SampleEntry aVC1SampleEntry = new AVC1SampleEntry();
+ aVC1SampleEntry.Width = 0x0220;
+ aVC1SampleEntry.Height = 0x03c0;
+ //stbl->stsd->avc1->avcc
+ AVCConfigurationBox aVCConfigurationBox = new AVCConfigurationBox();
+ aVCConfigurationBox.AVCProfileIndication = 0x64;
+ aVCConfigurationBox.ProfileCompatibility = 0;
+ aVCConfigurationBox.AVCLevelIndication = 0x1f;
+ aVCConfigurationBox.LengthSizeMinusOne = 0xff;
+ aVCConfigurationBox.SPSs = new List()
+ {
+ "6764001facd940881e684000f4240037b40883c60c6580".ToHexBytes()
+ };
+ aVCConfigurationBox.PPSs = new List()
+ {
+ "68efbcb000".ToHexBytes()
+ };
+ aVC1SampleEntry.AVCConfigurationBox = aVCConfigurationBox;
+ sampleDescriptionBox.SampleEntries = new List()
+ {
+ aVC1SampleEntry
+ };
+ sampleTableBox.SampleDescriptionBox = sampleDescriptionBox;
+ //stbl->stts
+ sampleTableBox.TimeToSampleBox = new TimeToSampleBox();
+ //stbl->stsc
+ sampleTableBox.SampleToChunkBox = new SampleToChunkBox();
+ //stbl->stsz
+ sampleTableBox.SampleSizeBox = new SampleSizeBox();
+ //stbl->stco
+ sampleTableBox.ChunkOffsetBox = new ChunkOffsetBox();
+ FMp4MessagePackWriter writer = new MessagePack.FMp4MessagePackWriter(new byte[0x000000e1]);
+ sampleTableBox.ToBuffer(ref writer);
+ var hex = writer.FlushAndGetArray().ToHexString();
+ Assert.Equal("000000e17374626c000000957374736400000000000000010000008561766331000000000000000100000000000000000000000000000000022003c0004800000048000000000000000100000000000000000000000000000000000000000000000000000000000000000018ffff0000002f617663430164001fffe100176764001facd940881e684000f4240037b40883c60c658001000568efbcb0000000001073747473000000000000000000000010737473630000000000000000000000147374737a000000000000000000000000000000107374636f0000000000000000".ToUpper(), hex);
+ }
+ ///
+ /// 使用doc/video/fragmented_demo.mp4
+ ///
+ [Fact(DisplayName = "moov_mvex")]
+ public void trak_mvex_test()
+ {
+ //todo:moov_mvex
}
}
}
diff --git a/src/JT1078.FMp4.Test/Samples/AVC1SampleEntryTest.cs b/src/JT1078.FMp4.Test/Samples/AVC1SampleEntryTest.cs
new file mode 100644
index 0000000..2d09457
--- /dev/null
+++ b/src/JT1078.FMp4.Test/Samples/AVC1SampleEntryTest.cs
@@ -0,0 +1,79 @@
+using JT1078.FMp4.MessagePack;
+using JT1078.FMp4.Samples;
+using JT1078.Protocol.Extensions;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace JT1078.FMp4.Test.Samples
+{
+ public class AVC1SampleEntryTest
+ {
+ ///
+ /// 使用doc/video/fragmented_demo.mp4
+ ///
+ [Fact]
+ public void Test1()
+ {
+ //0000008561766331000000000000000100000000000000000000000000000000022003C0004800000048000000000000000100000000000000000000000000000000000000000000000000000000000000000018FFFF0000002F617663430164001FFFE100176764001FACD940881E684000F4240037B40883C60C658001000568EFBCB000
+ //1.avc1
+ //0000008561766331000000000000000100000000000000000000000000000000022003C0004800000048000000000000000100000000000000000000000000000000000000000000000000000000000000000018FFFF
+ //2.avc1->avcc
+ //0000002F617663430164001FFFE100176764001FACD940881E684000F4240037B40883C60C658001000568EFBCB000
+ //0000008561766331000000000000000100000000000000000000000000000000022003c0004800000048000000000000000100000000000000000000000000000000000000000000000000000000000000000018ffff
+
+ //-------------avc1
+ //00 00 00 85
+ //61 76 63 31
+ //00 00 00
+ //00 00 00
+ //00 01
+ //00 00
+ //00 00
+ //00 00 00 00
+ //00 00 00 00
+ //00 00 00 00
+ //02 20
+ //03 c0
+ //00 48 00 00
+ //00 48 00 00
+ //00 00 00 00
+ //00 01
+ //00
+ //00 00 00 00
+ //00 00 00 00
+ //00 00 00 00
+ //00 00 00 00
+ //00 00 00 00
+ //00 00 00 00
+ //00 00 00 00
+ //00 00 00
+ //00 18
+ //ff ff
+ AVC1SampleEntry aVC1SampleEntry = new AVC1SampleEntry();
+ aVC1SampleEntry.Width = 0x0220;
+ aVC1SampleEntry.Height = 0x03c0;
+ AVCConfigurationBox aVCConfigurationBox = new AVCConfigurationBox();
+ aVCConfigurationBox.AVCProfileIndication = 0x64;
+ aVCConfigurationBox.ProfileCompatibility = 0;
+ aVCConfigurationBox.AVCLevelIndication = 0x1f;
+ aVCConfigurationBox.LengthSizeMinusOne = 0xff;
+ aVCConfigurationBox.SPSs = new List()
+ {
+ "6764001facd940881e684000f4240037b40883c60c6580".ToHexBytes()
+ };
+ aVCConfigurationBox.PPSs = new List()
+ {
+ "68efbcb000".ToHexBytes()
+ };
+ aVC1SampleEntry.AVCConfigurationBox = aVCConfigurationBox;
+ FMp4MessagePackWriter writer = new FMp4MessagePackWriter(new byte[0x00000085]);
+ aVC1SampleEntry.ToBuffer(ref writer);
+ var hex = writer.FlushAndGetArray().ToHexString();
+ Assert.Equal("0000008561766331000000000000000100000000000000000000000000000000022003C0004800000048000000000000000100000000000000000000000000000000000000000000000000000000000000000018FFFF0000002F617663430164001FFFE100176764001FACD940881E684000F4240037B40883C60C658001000568EFBCB000".ToUpper(), hex);
+ }
+ }
+}
diff --git a/src/JT1078.FMp4/Boxs/AVCConfigurationBox.cs b/src/JT1078.FMp4/Boxs/AVCConfigurationBox.cs
index 364a98b..676d4ec 100644
--- a/src/JT1078.FMp4/Boxs/AVCConfigurationBox.cs
+++ b/src/JT1078.FMp4/Boxs/AVCConfigurationBox.cs
@@ -45,17 +45,15 @@ namespace JT1078.FMp4
//bit(8*pictureParameterSetLength) pictureParameterSetNALUnit;
//}
//}
- public byte ConfigurationVersion { get; set; } = 1;
+ private byte ConfigurationVersion { get; set; } = 1;
public byte AVCProfileIndication { get; set; }
public byte ProfileCompatibility { get; set; }
public byte AVCLevelIndication { get; set; }
public int LengthSizeMinusOne { get; set; }
- public int NumOfSequenceParameterSets { get; set; }
- //public List<(ushort SequenceParameterSetLength,byte[] SequenceParameterSetNALUnit)> SPS { get; set; }
- public byte[] SPSBuffer { get; set; }
- public byte NumOfPictureParameterSets { get; set; } = 1;
- //public List<(ushort PictureParameterSetLength,byte[] PictureParameterSetNALUnit)> PPS { get; set; }
- public byte[] PPSBuffer { get; set; }
+ //private byte NumOfSequenceParameterSets { get; set; }
+ public List SPSs { get; set; }
+ //private byte NumOfPictureParameterSets { get; set; } = 1;
+ public List PPSs { get; set; }
public void ToBuffer(ref FMp4MessagePackWriter writer)
{
@@ -65,12 +63,38 @@ namespace JT1078.FMp4
writer.WriteByte(ProfileCompatibility);
writer.WriteByte(AVCLevelIndication);
writer.WriteByte((byte)(0xfc | LengthSizeMinusOne));
- writer.WriteByte((byte)(0xE0 | NumOfSequenceParameterSets));
- writer.WriteUInt16((ushort)SPSBuffer.Length);
- writer.WriteArray(SPSBuffer);
- writer.WriteByte(NumOfPictureParameterSets);
- writer.WriteUInt16((ushort)PPSBuffer.Length);
- writer.WriteArray(PPSBuffer);
+ if (SPSs!=null && SPSs.Count > 0)
+ {
+ //NumOfSequenceParameterSets
+ writer.WriteByte((byte)(0xE0 | SPSs.Count));
+ foreach(var sps in SPSs)
+ {
+ //SequenceParameterSetLength
+ writer.WriteUInt16((ushort)sps.Length);
+ writer.WriteArray(sps);
+ }
+ }
+ else
+ {
+ //NumOfSequenceParameterSets
+ writer.WriteByte(0xE0);
+ }
+ if (PPSs != null && PPSs.Count > 0)
+ {
+ //NumOfPictureParameterSets
+ writer.WriteByte((byte)PPSs.Count);
+ foreach (var pps in PPSs)
+ {
+ //PictureParameterSetLength
+ writer.WriteUInt16((ushort)pps.Length);
+ writer.WriteArray(pps);
+ }
+ }
+ else
+ {
+ //NumOfPictureParameterSets
+ writer.WriteByte(0);
+ }
End(ref writer);
}
}
diff --git a/src/JT1078.FMp4/Boxs/MovieExtendsBox.cs b/src/JT1078.FMp4/Boxs/MovieExtendsBox.cs
index ceeb636..0f5a16f 100644
--- a/src/JT1078.FMp4/Boxs/MovieExtendsBox.cs
+++ b/src/JT1078.FMp4/Boxs/MovieExtendsBox.cs
@@ -17,7 +17,13 @@ namespace JT1078.FMp4
public MovieExtendsBox() : base("mvex")
{
}
+ ///
+ /// mehd
+ ///
public MovieExtendsHeaderBox MovieExtendsHeaderBox { get; set; }
+ ///
+ /// trex
+ ///
public List TrackExtendsBoxs { get; set; }
public void ToBuffer(ref FMp4MessagePackWriter writer)
diff --git a/src/JT1078.FMp4/Boxs/SampleSizeBox.cs b/src/JT1078.FMp4/Boxs/SampleSizeBox.cs
index 6a0e5dc..bffccc7 100644
--- a/src/JT1078.FMp4/Boxs/SampleSizeBox.cs
+++ b/src/JT1078.FMp4/Boxs/SampleSizeBox.cs
@@ -1,11 +1,21 @@
-using System;
+using JT1078.FMp4.Interfaces;
+using JT1078.FMp4.MessagePack;
+using System;
using System.Collections.Generic;
using System.Text;
namespace JT1078.FMp4
{
- public class SampleSizeBox : FullBox
+ ///
+ /// stsz
+ ///
+ public class SampleSizeBox : FullBox, IFMp4MessagePackFormatter
{
+ ///
+ /// stsz
+ ///
+ ///
+ ///
public SampleSizeBox(byte version=0, uint flags=0) : base("stsz", version, flags)
{
}
@@ -17,5 +27,24 @@ namespace JT1078.FMp4
/// length:sample_count
///
public List EntrySize { get; set; }
+ public void ToBuffer(ref FMp4MessagePackWriter writer)
+ {
+ Start(ref writer);
+ WriterFullBoxToBuffer(ref writer);
+ writer.WriteUInt32(SampleSize);
+ if (EntrySize != null && EntrySize.Count > 0)
+ {
+ writer.WriteUInt32((uint)EntrySize.Count);
+ foreach (var item in EntrySize)
+ {
+ writer.WriteUInt32(item);
+ }
+ }
+ else
+ {
+ writer.WriteUInt32(0);
+ }
+ End(ref writer);
+ }
}
}
diff --git a/src/JT1078.FMp4/Boxs/SampleTableBox.cs b/src/JT1078.FMp4/Boxs/SampleTableBox.cs
index b95f69d..d46a2ab 100644
--- a/src/JT1078.FMp4/Boxs/SampleTableBox.cs
+++ b/src/JT1078.FMp4/Boxs/SampleTableBox.cs
@@ -33,7 +33,10 @@ namespace JT1078.FMp4
/// stsc
///
public SampleToChunkBox SampleToChunkBox { get; set; }
- //public SampleSizeBox SampleSizeBox { get; set; }
+ ///
+ /// stsz
+ ///
+ public SampleSizeBox SampleSizeBox { get; set; }
//public CompactSampleSizeBox CompactSampleSizeBox { get; set; }
///
/// stco
@@ -54,8 +57,11 @@ namespace JT1078.FMp4
Start(ref writer);
SampleDescriptionBox.ToBuffer(ref writer);
TimeToSampleBox.ToBuffer(ref writer);
- CompositionOffsetBox.ToBuffer(ref writer);
+ if(CompositionOffsetBox!=null)
+ CompositionOffsetBox.ToBuffer(ref writer);
SampleToChunkBox.ToBuffer(ref writer);
+ if (SampleSizeBox != null)
+ SampleSizeBox.ToBuffer(ref writer);
ChunkOffsetBox.ToBuffer(ref writer);
End(ref writer);
}
diff --git a/src/JT1078.FMp4/Boxs/TrackExtendsBox.cs b/src/JT1078.FMp4/Boxs/TrackExtendsBox.cs
index 6fc6017..2f6c2aa 100644
--- a/src/JT1078.FMp4/Boxs/TrackExtendsBox.cs
+++ b/src/JT1078.FMp4/Boxs/TrackExtendsBox.cs
@@ -6,8 +6,16 @@ using System.Text;
namespace JT1078.FMp4
{
+ ///
+ /// trex
+ ///
public class TrackExtendsBox : FullBox, IFMp4MessagePackFormatter
{
+ ///
+ /// trex
+ ///
+ ///
+ ///
public TrackExtendsBox(byte version=0, uint flags=0) : base("trex", version, flags)
{
}
diff --git a/src/JT1078.FMp4/JT1078.FMp4.xml b/src/JT1078.FMp4/JT1078.FMp4.xml
index d9048f4..fc38cd5 100644
--- a/src/JT1078.FMp4/JT1078.FMp4.xml
+++ b/src/JT1078.FMp4/JT1078.FMp4.xml
@@ -545,6 +545,18 @@
if (version==1)
+
+
+ stsz
+
+
+
+
+ stsz
+
+
+
+
if (sample_size==0)
@@ -581,6 +593,11 @@
stsc
+
+
+ stsz
+
+
stco
diff --git a/src/JT1078.FMp4/Samples/AVC1SampleEntry.cs b/src/JT1078.FMp4/Samples/AVC1SampleEntry.cs
index f556c4c..f4e5fc2 100644
--- a/src/JT1078.FMp4/Samples/AVC1SampleEntry.cs
+++ b/src/JT1078.FMp4/Samples/AVC1SampleEntry.cs
@@ -15,6 +15,8 @@ namespace JT1078.FMp4.Samples
///
public AVC1SampleEntry() : base("avc1")
{
+ DataReferenceIndex = 1;
+ PreDefined3 = 0xffff;
}
///
/// avcC
@@ -28,8 +30,12 @@ namespace JT1078.FMp4.Samples
public override void ToBuffer(ref FMp4MessagePackWriter writer)
{
Start(ref writer);
+ WriterSampleEntryToBuffer(ref writer);
WriterVisualSampleEntryToBuffer(ref writer);
- AVCConfigurationBox.ToBuffer(ref writer);
+ if (AVCConfigurationBox != null)
+ {
+ AVCConfigurationBox.ToBuffer(ref writer);
+ }
if (MPEG4BitRateBox != null)
{
MPEG4BitRateBox.ToBuffer(ref writer);
diff --git a/src/JT1078.FMp4/Samples/VisualSampleEntry.cs b/src/JT1078.FMp4/Samples/VisualSampleEntry.cs
index 1fe2981..0ef485f 100644
--- a/src/JT1078.FMp4/Samples/VisualSampleEntry.cs
+++ b/src/JT1078.FMp4/Samples/VisualSampleEntry.cs
@@ -10,6 +10,7 @@ namespace JT1078.FMp4.Samples
///
public abstract class VisualSampleEntry : SampleEntry
{
+ const string COMPRESSORNAME = "jt1078&SmallChi(koike)&TK";
///
/// VisualSampleEntry
///
@@ -27,9 +28,13 @@ namespace JT1078.FMp4.Samples
public uint VertreSolution { get; set; }= 0x00480000;
public uint Reserved3{ get; set; }
public ushort FrameCount { get; set; } = 1;
+#if DEBUG
public string CompressorName { get; set; }
+#else
+ public string CompressorName { get; set; } = COMPRESSORNAME;
+#endif
public ushort Depth { get; set; } = 0x0018;
- public short PreDefined3 { get; set; } = 0x1111;
+ public ushort PreDefined3 { get; set; } = 0x1111;
///
/// clap
/// optional
@@ -61,19 +66,18 @@ namespace JT1078.FMp4.Samples
writer.WriteUInt16(FrameCount);
if (string.IsNullOrEmpty(CompressorName))
{
- CompressorName = "";
+ //CompressorNameLength
+ writer.WriteByte(0);
+ writer.WriteArray(new byte[31]);
}
- writer.WriteUTF8(CompressorName.PadLeft(32, '\0'));
- writer.WriteUInt16(Depth);
- writer.WriteInt16(PreDefined3);
- if (Clap != null)
- {
- Clap.ToBuffer(ref writer);
- }
- if (Pasp != null)
+ else
{
- Pasp.ToBuffer(ref writer);
+ //CompressorNameLength
+ writer.WriteByte((byte)CompressorName.Length);
+ writer.WriteUTF8(CompressorName.PadRight(31, '\0'));
}
+ writer.WriteUInt16(Depth);
+ writer.WriteUInt16(PreDefined3);
}
}
}
diff --git a/src/JT808.Protocol.Extensions.JT1078/JT808.Protocol.Extensions.JT1078.csproj b/src/JT808.Protocol.Extensions.JT1078/JT808.Protocol.Extensions.JT1078.csproj
index 6fc50c9..774de34 100644
--- a/src/JT808.Protocol.Extensions.JT1078/JT808.Protocol.Extensions.JT1078.csproj
+++ b/src/JT808.Protocol.Extensions.JT1078/JT808.Protocol.Extensions.JT1078.csproj
@@ -15,14 +15,14 @@
https://github.com/SmallChi/JT1078/blob/master/LICENSE
https://github.com/SmallChi/JT1078/blob/master/LICENSE
false
- 2.3.0
+ 2.3.1
LICENSE
JT808.Protocol.Extensions.JT1078.xml
-
+