Переглянути джерело

添加fmp4各个盒子的编码及测试

tags/v1.1.0
SmallChi(Koike) 4 роки тому
джерело
коміт
4d95994b20
42 змінених файлів з 1448 додано та 78 видалено
  1. +42
    -0
      src/JT1078.FMp4.Test/Boxs/DataInformationBox_Test.cs
  2. +37
    -0
      src/JT1078.FMp4.Test/Boxs/DataReferenceBox_Test.cs
  3. +38
    -0
      src/JT1078.FMp4.Test/Boxs/HandlerBox_Test.cs
  4. +52
    -3
      src/JT1078.FMp4/Boxs/AVCConfigurationBox.cs
  5. +9
    -2
      src/JT1078.FMp4/Boxs/ChunkOffsetBox.cs
  6. +24
    -2
      src/JT1078.FMp4/Boxs/CleanApertureBox.cs
  7. +9
    -2
      src/JT1078.FMp4/Boxs/CompositionOffsetBox.cs
  8. +6
    -2
      src/JT1078.FMp4/Boxs/DataEntryBox.cs
  9. +13
    -1
      src/JT1078.FMp4/Boxs/DataEntryUrlBox.cs
  10. +15
    -1
      src/JT1078.FMp4/Boxs/DataEntryUrnBox.cs
  11. +20
    -2
      src/JT1078.FMp4/Boxs/DataInformationBox.cs
  12. +32
    -3
      src/JT1078.FMp4/Boxs/DataReferenceBox.cs
  13. +3
    -0
      src/JT1078.FMp4/Boxs/FileTypeBox.cs
  14. +35
    -3
      src/JT1078.FMp4/Boxs/HandlerBox.cs
  15. +19
    -2
      src/JT1078.FMp4/Boxs/MPEG4BitRateBox.cs
  16. +15
    -1
      src/JT1078.FMp4/Boxs/MediaBox.cs
  17. +9
    -1
      src/JT1078.FMp4/Boxs/MediaHeaderBox.cs
  18. +24
    -3
      src/JT1078.FMp4/Boxs/MediaInformationBox.cs
  19. +28
    -3
      src/JT1078.FMp4/Boxs/MovieBox.cs
  20. +6
    -0
      src/JT1078.FMp4/Boxs/MovieExtendsBox.cs
  21. +9
    -1
      src/JT1078.FMp4/Boxs/MovieHeaderBox.cs
  22. +17
    -2
      src/JT1078.FMp4/Boxs/PixelAspectRatioBox.cs
  23. +33
    -6
      src/JT1078.FMp4/Boxs/SampleDescriptionBox.cs
  24. +47
    -13
      src/JT1078.FMp4/Boxs/SampleTableBox.cs
  25. +10
    -2
      src/JT1078.FMp4/Boxs/SampleToChunkBox.cs
  26. +9
    -2
      src/JT1078.FMp4/Boxs/TimeToSampleBox.cs
  27. +13
    -1
      src/JT1078.FMp4/Boxs/TrackBox.cs
  28. +9
    -1
      src/JT1078.FMp4/Boxs/TrackHeaderBox.cs
  29. +20
    -2
      src/JT1078.FMp4/Boxs/URIBox.cs
  30. +26
    -2
      src/JT1078.FMp4/Boxs/URIInitBox.cs
  31. +34
    -0
      src/JT1078.FMp4/Enums/HandlerType.cs
  32. +24
    -2
      src/JT1078.FMp4/FMp4Box.cs
  33. +1
    -1
      src/JT1078.FMp4/FullBox.cs
  34. +512
    -1
      src/JT1078.FMp4/JT1078.FMp4.xml
  35. +7
    -0
      src/JT1078.FMp4/MessagePack/FMp4MessagePackWriter.cs
  36. +26
    -2
      src/JT1078.FMp4/Samples/AVC1SampleEntry.cs
  37. +24
    -2
      src/JT1078.FMp4/Samples/HintSampleEntry.cs
  38. +26
    -2
      src/JT1078.FMp4/Samples/SampleEntry.cs
  39. +32
    -1
      src/JT1078.FMp4/Samples/TextMetaDataSampleEntry.cs
  40. +38
    -1
      src/JT1078.FMp4/Samples/URIMetaSampleEntry.cs
  41. +52
    -1
      src/JT1078.FMp4/Samples/VisualSampleEntry.cs
  42. +43
    -2
      src/JT1078.FMp4/Samples/XMLMetaDataSampleEntry.cs

+ 42
- 0
src/JT1078.FMp4.Test/Boxs/DataInformationBox_Test.cs Переглянути файл

@@ -0,0 +1,42 @@
using JT1078.FMp4.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;
using Xunit;
using JT1078.Protocol.Extensions;
using JT1078.FMp4.Enums;

namespace JT1078.FMp4.Test.Boxs
{
public class DataInformationBox_Test
{
/// <summary>
/// 使用doc/video/demo.mp4
/// </summary>
[Fact]
public void Test1()
{
// 00 00 00 24--box size 36
// 64 69 6e 66--box type dinf
//--------------
// 00 00 00 1c--box size 28
// 64 72 65 66--box type dref
// 00--version
// 00 00 00--flags
// 00 00 00 01--entry_count
//----------------
// 00 00 00 0c--box size 12
// 75 72 6c 20--box type "url " 有个空格
// 00--version
// 00 00 01--flags
DataInformationBox dataInformationBox = new DataInformationBox();
DataReferenceBox dataReferenceBox = new DataReferenceBox();
dataReferenceBox.DataEntryBoxes.Add(new DataEntryUrlBox(version: 0, flags: 1));
dataInformationBox.DataReferenceBox = dataReferenceBox;
FMp4MessagePackWriter writer = new MessagePack.FMp4MessagePackWriter(new byte[48]);
dataInformationBox.ToBuffer(ref writer);
var hex = writer.FlushAndGetArray().ToHexString();
Assert.Equal("0000002464696e660000001c6472656600000000000000010000000c75726c2000000001".ToUpper(), hex);
}
}
}

+ 37
- 0
src/JT1078.FMp4.Test/Boxs/DataReferenceBox_Test.cs Переглянути файл

@@ -0,0 +1,37 @@
using JT1078.FMp4.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;
using Xunit;
using JT1078.Protocol.Extensions;
using JT1078.FMp4.Enums;

namespace JT1078.FMp4.Test.Boxs
{
public class DataReferenceBox_Test
{
/// <summary>
/// 使用doc/video/demo.mp4
/// </summary>
[Fact]
public void Test1()
{
// 00 00 00 1c--box size 28
// 64 72 65 66--box type dref
// 00--version
// 00 00 00--flags
// 00 00 00 01--entry_count
//----------------
// 00 00 00 0c--box size 12
// 75 72 6c 20--box type "url " 有个空格
// 00--version
// 00 00 01--flags
DataReferenceBox dataReferenceBox = new DataReferenceBox();
dataReferenceBox.DataEntryBoxes.Add(new DataEntryUrlBox(version:0,flags:1));
FMp4MessagePackWriter writer = new MessagePack.FMp4MessagePackWriter(new byte[48]);
dataReferenceBox.ToBuffer(ref writer);
var hex = writer.FlushAndGetArray().ToHexString();
Assert.Equal("0000001c6472656600000000000000010000000c75726c2000000001".ToUpper(), hex);
}
}
}

+ 38
- 0
src/JT1078.FMp4.Test/Boxs/HandlerBox_Test.cs Переглянути файл

@@ -0,0 +1,38 @@
using JT1078.FMp4.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;
using Xunit;
using JT1078.Protocol.Extensions;
using JT1078.FMp4.Enums;

namespace JT1078.FMp4.Test.Boxs
{
public class HandlerBox_Test
{
/// <summary>
/// 使用doc/video/demo.mp4
/// </summary>
[Fact]
public void Test1()
{
//00 00 00 35--box size
//68 64 6c 72--box type hdlr
//00--version
//00 00 00--flags
//00 00 00 00--pre_defined
//73 6f 75 6e--handler_type
//00 00 00 00--reserved3 - 1
//00 00 00 00--reserved3 - 2
//00 00 00 00--reserved3 - 3
//42 65 6e 74 6f 34 20 53 6f 75 6e 64 20 48 61 6e 64 6c 65 72 00--Name
HandlerBox handlerBox = new HandlerBox(version:0,flags:0);
handlerBox.HandlerType = HandlerType.soun;
handlerBox.Name = Encoding.UTF8.GetString("42 65 6e 74 6f 34 20 53 6f 75 6e 64 20 48 61 6e 64 6c 65 72 00".ToHexBytes());
FMp4MessagePackWriter writer = new MessagePack.FMp4MessagePackWriter(new byte[0x35]);
handlerBox.ToBuffer(ref writer);
var hex = writer.FlushAndGetArray().ToHexString();
Assert.Equal("0000003568646c720000000000000000736f756e00000000000000000000000042656e746f3420536f756e642048616e646c657200".ToUpper(), hex);
}
}
}

+ 52
- 3
src/JT1078.FMp4/Boxs/AVCConfigurationBox.cs Переглянути файл

@@ -1,14 +1,63 @@
using System;
using JT1078.FMp4.Interfaces;
using JT1078.FMp4.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;

namespace JT1078.FMp4
{
public class AVCConfigurationBox : Mp4Box
/// <summary>
/// avcC
/// </summary>
public class AVCConfigurationBox : Mp4Box,IFMp4MessagePackFormatter
{
/// <summary>
/// avcC
/// </summary>
public AVCConfigurationBox() : base("avcC")
{
}
public AVCDecoderConfigurationRecord AVCDecoderConfigurationRecord { get; set; }

//AVCDecoderConfigurationRecord 结构的定义:
//aligned(8) class AVCDecoderConfigurationRecord
//{
//unsigned int (8) configurationVersion = 1;
//unsigned int (8) AVCProfileIndication;
//unsigned int (8) profile_compatibility;
//unsigned int (8) AVCLevelIndication;
//bit(6) reserved = ‘111111’b;
//unsigned int (2) lengthSizeMinusOne;
//bit(3) reserved = ‘111’b;
//unsigned int (5) numOfSequenceParameterSets;
//for (i=0; i<numOfSequenceParameterSets; i++) {
//unsigned int (16) sequenceParameterSetLength ;
//bit(8*sequenceParameterSetLength) sequenceParameterSetNALUnit;
//}
//unsigned int (8) numOfPictureParameterSets;
//for (i=0; i<numOfPictureParameterSets; i++) {
//unsigned int (16) pictureParameterSetLength;
//bit(8*pictureParameterSetLength) pictureParameterSetNALUnit;
//}
//}
public 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; }

public void ToBuffer(ref FMp4MessagePackWriter writer)
{
Start(ref writer);
//todo:AVCConfigurationBox


End(ref writer);
}
}
}

+ 9
- 2
src/JT1078.FMp4/Boxs/ChunkOffsetBox.cs Переглянути файл

@@ -1,10 +1,12 @@
using System;
using JT1078.FMp4.Interfaces;
using JT1078.FMp4.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;

namespace JT1078.FMp4
{
public class ChunkOffsetBox : FullBox
public class ChunkOffsetBox : FullBox, IFMp4MessagePackFormatter
{
public ChunkOffsetBox( byte version=0, uint flags=0) : base("stco", version, flags)
{
@@ -15,5 +17,10 @@ namespace JT1078.FMp4
/// length:EntryCount
/// </summary>
public List<uint> ChunkOffset { get; set; }

public void ToBuffer(ref FMp4MessagePackWriter writer)
{
throw new NotImplementedException();
}
}
}

+ 24
- 2
src/JT1078.FMp4/Boxs/CleanApertureBox.cs Переглянути файл

@@ -1,11 +1,19 @@
using System;
using JT1078.FMp4.Interfaces;
using JT1078.FMp4.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;

namespace JT1078.FMp4
{
public class CleanApertureBox : Mp4Box
/// <summary>
/// clap
/// </summary>
public class CleanApertureBox : Mp4Box,IFMp4MessagePackFormatter
{
/// <summary>
/// clap
/// </summary>
public CleanApertureBox() : base("clap")
{
}
@@ -18,5 +26,19 @@ namespace JT1078.FMp4
public uint HorizOffD { get; set; }
public uint VertOffN { get; set; }
public uint VertOffD { get; set; }

public void ToBuffer(ref FMp4MessagePackWriter writer)
{
Start(ref writer);
writer.WriteUInt32(CleanApertureWidthN);
writer.WriteUInt32(CleanApertureWidthD);
writer.WriteUInt32(CleanApertureHeightN);
writer.WriteUInt32(CleanApertureHeightD);
writer.WriteUInt32(HorizOffN);
writer.WriteUInt32(HorizOffD);
writer.WriteUInt32(VertOffN);
writer.WriteUInt32(VertOffD);
End(ref writer);
}
}
}

+ 9
- 2
src/JT1078.FMp4/Boxs/CompositionOffsetBox.cs Переглянути файл

@@ -1,10 +1,12 @@
using System;
using JT1078.FMp4.Interfaces;
using JT1078.FMp4.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;

namespace JT1078.FMp4
{
public class CompositionOffsetBox : FullBox
public class CompositionOffsetBox : FullBox, IFMp4MessagePackFormatter
{
public CompositionOffsetBox(byte version=0, uint flags=0) : base("ctts", version, flags)
{
@@ -13,6 +15,11 @@ namespace JT1078.FMp4

public List<CompositionOffsetInfo> CompositionOffsetInfos { get; set; }

public void ToBuffer(ref FMp4MessagePackWriter writer)
{
throw new NotImplementedException();
}

public class CompositionOffsetInfo
{
public uint SampleCount { get; set; }


+ 6
- 2
src/JT1078.FMp4/Boxs/DataEntryBox.cs Переглянути файл

@@ -1,13 +1,17 @@
using System;
using JT1078.FMp4.Interfaces;
using JT1078.FMp4.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;

namespace JT1078.FMp4
{
public abstract class DataEntryBox : FullBox
public abstract class DataEntryBox : FullBox,IFMp4MessagePackFormatter
{
public DataEntryBox(string boxType, byte version, uint flags) : base(boxType, version, flags)
{
}

public abstract void ToBuffer(ref FMp4MessagePackWriter writer);
}
}

+ 13
- 1
src/JT1078.FMp4/Boxs/DataEntryUrlBox.cs Переглянути файл

@@ -1,4 +1,5 @@
using System;
using JT1078.FMp4.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;

@@ -15,5 +16,16 @@ namespace JT1078.FMp4
}

public string Location { get; set; }

public override void ToBuffer(ref FMp4MessagePackWriter writer)
{
Start(ref writer);
WriterFullBoxToBuffer(ref writer);
if (!string.IsNullOrEmpty(Location))
{
writer.WriteUTF8(Location);
}
End(ref writer);
}
}
}

+ 15
- 1
src/JT1078.FMp4/Boxs/DataEntryUrnBox.cs Переглянути файл

@@ -1,4 +1,5 @@
using System;
using JT1078.FMp4.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;

@@ -15,5 +16,18 @@ namespace JT1078.FMp4

public string Name { get; set; }
public string Location { get; set; }
public override void ToBuffer(ref FMp4MessagePackWriter writer)
{
Start(ref writer);
if (!string.IsNullOrEmpty(Name))
{
writer.WriteUTF8(Name);
}
if (!string.IsNullOrEmpty(Location))
{
writer.WriteUTF8(Location);
}
End(ref writer);
}
}
}

+ 20
- 2
src/JT1078.FMp4/Boxs/DataInformationBox.cs Переглянути файл

@@ -1,14 +1,32 @@
using System;
using JT1078.FMp4.Interfaces;
using JT1078.FMp4.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;

namespace JT1078.FMp4
{
public class DataInformationBox : Mp4Box
/// <summary>
/// dinf
/// </summary>
public class DataInformationBox : Mp4Box, IFMp4MessagePackFormatter
{
/// <summary>
/// dinf
/// </summary>
public DataInformationBox() : base("dinf")
{
}
/// <summary>
/// dref
/// </summary>
public DataReferenceBox DataReferenceBox { get; set; }

public void ToBuffer(ref FMp4MessagePackWriter writer)
{
Start(ref writer);
DataReferenceBox.ToBuffer(ref writer);
End(ref writer);
}
}
}

+ 32
- 3
src/JT1078.FMp4/Boxs/DataReferenceBox.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 DataReferenceBox : FullBox
/// <summary>
/// dref
/// </summary>
public class DataReferenceBox : FullBox, IFMp4MessagePackFormatter
{
/// <summary>
/// dref
/// </summary>
/// <param name="version"></param>
/// <param name="flags"></param>
public DataReferenceBox(byte version=0, uint flags=0) : base("dref", version, flags)
{
}
@@ -15,6 +25,25 @@ namespace JT1078.FMp4
/// <summary>
/// length:EntryCount
/// </summary>
public List<DataEntryBox> DataEntryBoxes { get; set; }
public List<DataEntryBox> DataEntryBoxes { get; set; }= new List<DataEntryBox>();

public void ToBuffer(ref FMp4MessagePackWriter writer)
{
Start(ref writer);
WriterFullBoxToBuffer(ref writer);
if (DataEntryBoxes!=null && DataEntryBoxes.Count > 0)
{
writer.WriteUInt32((uint)DataEntryBoxes.Count);
foreach(var item in DataEntryBoxes)
{
item.ToBuffer(ref writer);
}
}
else
{
writer.WriteUInt32(0);
}
End(ref writer);
}
}
}

+ 3
- 0
src/JT1078.FMp4/Boxs/FileTypeBox.cs Переглянути файл

@@ -12,6 +12,9 @@ namespace JT1078.FMp4
/// </summary>
public class FileTypeBox : Mp4Box, IFMp4MessagePackFormatter
{
/// <summary>
/// ftyp
/// </summary>
public FileTypeBox() : base("ftyp")
{
}


+ 35
- 3
src/JT1078.FMp4/Boxs/HandlerBox.cs Переглянути файл

@@ -1,18 +1,50 @@
using System;
using JT1078.FMp4.Enums;
using JT1078.FMp4.Interfaces;
using JT1078.FMp4.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;

namespace JT1078.FMp4
{
public class HandlerBox : FullBox
/// <summary>
/// hdlr
/// </summary>
public class HandlerBox : FullBox, IFMp4MessagePackFormatter
{
/// <summary>
/// hdlr
/// </summary>
/// <param name="version"></param>
/// <param name="flags"></param>
public HandlerBox(byte version=0, uint flags=0) : base("hdlr", version, flags)
{
}

public uint PreDefined { get; set; }
public string HandlerType { get; set; }
public HandlerType HandlerType { get; set; }
public uint[] Reserved { get; set; } = new uint[3];
public string Name { get; set; }

public void ToBuffer(ref FMp4MessagePackWriter writer)
{
Start(ref writer);
WriterFullBoxToBuffer(ref writer);
writer.WriteUInt32(PreDefined);
if(HandlerType== HandlerType.none)
{
writer.WriteASCII("null");
}
else
{
writer.WriteASCII(HandlerType.ToString());
}
foreach(var r in Reserved)
{
writer.WriteUInt32(r);
}
writer.WriteUTF8(Name??"\0");
End(ref writer);
}
}
}

+ 19
- 2
src/JT1078.FMp4/Boxs/MPEG4BitRateBox.cs Переглянути файл

@@ -1,11 +1,19 @@
using System;
using JT1078.FMp4.Interfaces;
using JT1078.FMp4.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;

namespace JT1078.FMp4
{
public class MPEG4BitRateBox : Mp4Box
/// <summary>
/// btrt
/// </summary>
public class MPEG4BitRateBox : Mp4Box, IFMp4MessagePackFormatter
{
/// <summary>
/// btrt
/// </summary>
public MPEG4BitRateBox() : base("btrt")
{
}
@@ -13,5 +21,14 @@ namespace JT1078.FMp4
public uint BufferSizeDB { get; set; }
public uint MaxBitRate { get; set; }
public uint AvgBitRate { get; set; }

public void ToBuffer(ref FMp4MessagePackWriter writer)
{
Start(ref writer);
writer.WriteUInt32(BufferSizeDB);
writer.WriteUInt32(MaxBitRate);
writer.WriteUInt32(AvgBitRate);
End(ref writer);
}
}
}

+ 15
- 1
src/JT1078.FMp4/Boxs/MediaBox.cs Переглянути файл

@@ -4,14 +4,28 @@ using System.Text;

namespace JT1078.FMp4
{
/// <summary>
/// mdia
/// </summary>
public class MediaBox : Mp4Box
{
/// <summary>
/// mdia
/// </summary>
public MediaBox() : base("mdia")
{
}

/// <summary>
/// mdhd
/// </summary>
public MediaHeaderBox MediaHeaderBox { get; set; }
/// <summary>
/// hdlr
/// </summary>
public HandlerBox HandlerBox { get; set; }
/// <summary>
/// minf
/// </summary>
public MediaInformationBox MediaInformationBox { get; set; }
}
}

+ 9
- 1
src/JT1078.FMp4/Boxs/MediaHeaderBox.cs Переглянути файл

@@ -6,8 +6,16 @@ using System.Text;

namespace JT1078.FMp4
{
/// <summary>
/// mdhd
/// </summary>
public class MediaHeaderBox : FullBox, IFMp4MessagePackFormatter
{
/// <summary>
/// mdhd
/// </summary>
/// <param name="version"></param>
/// <param name="flags"></param>
public MediaHeaderBox(byte version, uint flags=0) : base("mdhd", version, flags)
{
}
@@ -27,7 +35,7 @@ namespace JT1078.FMp4
public void ToBuffer(ref FMp4MessagePackWriter writer)
{
Start(ref writer);
WriterToBuffer(ref writer);
WriterFullBoxToBuffer(ref writer);
if (Version == 1)
{
writer.WriteUInt64(CreationTime);


+ 24
- 3
src/JT1078.FMp4/Boxs/MediaInformationBox.cs Переглянути файл

@@ -1,16 +1,37 @@
using System;
using JT1078.FMp4.Interfaces;
using JT1078.FMp4.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;

namespace JT1078.FMp4
{
public class MediaInformationBox : Mp4Box
/// <summary>
/// minf
/// </summary>
public class MediaInformationBox : Mp4Box,IFMp4MessagePackFormatter
{
/// <summary>
/// minf
/// </summary>
public MediaInformationBox() : base("minf")
{
}
public FullBox MediaHeaderBox { get; set; }
/// <summary>
/// dinf
/// </summary>
public DataInformationBox DataInformationBox { get; set; }
/// <summary>
/// stbl
/// </summary>
public SampleTableBox SampleTableBox { get; set; }

public void ToBuffer(ref FMp4MessagePackWriter writer)
{
Start(ref writer);
DataInformationBox.ToBuffer(ref writer);
SampleTableBox.ToBuffer(ref writer);
End(ref writer);
}
}
}

+ 28
- 3
src/JT1078.FMp4/Boxs/MovieBox.cs Переглянути файл

@@ -1,17 +1,42 @@
using System;
using JT1078.FMp4.Interfaces;
using JT1078.FMp4.MessagePack;
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;

namespace JT1078.FMp4
{
public class MovieBox : Mp4Box
/// <summary>
/// moov
/// </summary>
public class MovieBox : Mp4Box,IFMp4MessagePackFormatter
{
/// <summary>
/// moov
/// </summary>
public MovieBox() : base("moov")
{
}
/// <summary>
/// mvhd
/// </summary>
public MovieHeaderBox MovieHeaderBox { get; set; }
/// <summary>
/// trak
/// </summary>
public TrackBox TrackBox { get; set; }
public MovieExtendsBox MovieExtendsBox { get; set; }
/// <summary>
/// trak
/// </summary>
public MovieExtendsBox MovieExtendsBox { get; set; }

public void ToBuffer(ref FMp4MessagePackWriter writer)
{
Start(ref writer);
MovieHeaderBox.ToBuffer(ref writer);
End(ref writer);
}
}
}

+ 6
- 0
src/JT1078.FMp4/Boxs/MovieExtendsBox.cs Переглянути файл

@@ -4,8 +4,14 @@ using System.Text;

namespace JT1078.FMp4
{
/// <summary>
/// mvex
/// </summary>
public class MovieExtendsBox : Mp4Box
{
/// <summary>
/// mvex
/// </summary>
public MovieExtendsBox() : base("mvex")
{
}


+ 9
- 1
src/JT1078.FMp4/Boxs/MovieHeaderBox.cs Переглянути файл

@@ -6,8 +6,16 @@ using System.Text;

namespace JT1078.FMp4
{
/// <summary>
/// mvhd
/// </summary>
public class MovieHeaderBox : FullBox, IFMp4MessagePackFormatter
{
/// <summary>
/// mvhd
/// </summary>
/// <param name="version"></param>
/// <param name="flags"></param>
public MovieHeaderBox(byte version, uint flags=0) : base("mvhd", version, flags)
{
}
@@ -25,7 +33,7 @@ namespace JT1078.FMp4
public void ToBuffer(ref FMp4MessagePackWriter writer)
{
Start(ref writer);
WriterToBuffer(ref writer);
WriterFullBoxToBuffer(ref writer);
if (Version == 1)
{
writer.WriteUInt64(CreationTime);


+ 17
- 2
src/JT1078.FMp4/Boxs/PixelAspectRatioBox.cs Переглянути файл

@@ -1,15 +1,30 @@
using System;
using JT1078.FMp4.Interfaces;
using JT1078.FMp4.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;

namespace JT1078.FMp4
{
public class PixelAspectRatioBox : Mp4Box
/// <summary>
/// pasp
/// </summary>
public class PixelAspectRatioBox : Mp4Box, IFMp4MessagePackFormatter
{
/// <summary>
/// pasp
/// </summary>
public PixelAspectRatioBox() : base("pasp")
{
}
public uint HSpacing { get; set; }
public uint VSpacing { get; set; }
public void ToBuffer(ref FMp4MessagePackWriter writer)
{
Start(ref writer);
writer.WriteUInt32(HSpacing);
writer.WriteUInt32(VSpacing);
End(ref writer);
}
}
}

+ 33
- 6
src/JT1078.FMp4/Boxs/SampleDescriptionBox.cs Переглянути файл

@@ -1,20 +1,47 @@
using JT1078.FMp4.Samples;
using JT1078.FMp4.Enums;
using JT1078.FMp4.Interfaces;
using JT1078.FMp4.MessagePack;
using JT1078.FMp4.Samples;
using System;
using System.Collections.Generic;
using System.Text;

namespace JT1078.FMp4
{
public class SampleDescriptionBox : FullBox
/// <summary>
/// stsd
/// </summary>
public class SampleDescriptionBox : FullBox, IFMp4MessagePackFormatter
{
public string HandlerType { get; set; }
public SampleDescriptionBox(string handlerType,byte version=0, uint flags=0) : base("stsd", version, flags)
/// <summary>
/// stsd
/// </summary>
/// <param name="handlerType"></param>
/// <param name="version"></param>
/// <param name="flags"></param>
public SampleDescriptionBox(HandlerType handlerType,byte version=0, uint flags=0) : base("stsd", version, flags)
{
HandlerType = handlerType;
}

public HandlerType HandlerType { get; set; }
public uint EntryCount { get; set; }
public List<SampleEntry> SampleEntries { get; set; }
public void ToBuffer(ref FMp4MessagePackWriter writer)
{
Start(ref writer);
WriterFullBoxToBuffer(ref writer);
if(SampleEntries!=null && SampleEntries.Count > 0)
{
foreach(var item in SampleEntries)
{
item.ToBuffer(ref writer);
}
}
else
{
writer.WriteUInt32(0);
}
End(ref writer);
}
}
}

+ 47
- 13
src/JT1078.FMp4/Boxs/SampleTableBox.cs Переглянути файл

@@ -1,29 +1,63 @@
using System;
using JT1078.FMp4.Interfaces;
using JT1078.FMp4.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;

namespace JT1078.FMp4
{
public class SampleTableBox : Mp4Box
/// <summary>
/// stbl
/// </summary>
public class SampleTableBox : Mp4Box, IFMp4MessagePackFormatter
{
/// <summary>
/// stbl
/// </summary>
public SampleTableBox() : base("stbl")
{
}
/// <summary>
/// stsd
/// </summary>
public SampleDescriptionBox SampleDescriptionBox { get; set; }
/// <summary>
/// stts
/// </summary>
public TimeToSampleBox TimeToSampleBox { get; set; }
/// <summary>
/// ctts
/// </summary>
public CompositionOffsetBox CompositionOffsetBox { get; set; }
/// <summary>
/// stsc
/// </summary>
public SampleToChunkBox SampleToChunkBox { get; set; }
public SampleSizeBox SampleSizeBox { get; set; }
public CompactSampleSizeBox CompactSampleSizeBox { get; set; }
//public SampleSizeBox SampleSizeBox { get; set; }
//public CompactSampleSizeBox CompactSampleSizeBox { get; set; }
/// <summary>
/// stco
/// </summary>
public ChunkOffsetBox ChunkOffsetBox { get; set; }
public ChunkLargeOffsetBox ChunkLargeOffsetBox { get; set; }
public SyncSampleBox SyncSampleBox { get; set; }
public ShadowSyncSampleBox ShadowSyncSampleBox { get; set; }
public PaddingBitsBox PaddingBitsBox { get; set; }
public DegradationPriorityBox DegradationPriorityBox { get; set; }
public SampleDependencyTypeBox SampleDependencyTypeBox { get; set; }
public SampleToGroupBox SampleToGroupBox { get; set; }
public SampleGroupDescriptionBox SampleGroupDescriptionBox { get; set; }
public SubSampleInformationBox SubSampleInformationBox { get; set; }
//public ChunkLargeOffsetBox ChunkLargeOffsetBox { get; set; }
//public SyncSampleBox SyncSampleBox { get; set; }
//public ShadowSyncSampleBox ShadowSyncSampleBox { get; set; }
//public PaddingBitsBox PaddingBitsBox { get; set; }
//public DegradationPriorityBox DegradationPriorityBox { get; set; }
//public SampleDependencyTypeBox SampleDependencyTypeBox { get; set; }
//public SampleToGroupBox SampleToGroupBox { get; set; }
//public SampleGroupDescriptionBox SampleGroupDescriptionBox { get; set; }
//public SubSampleInformationBox SubSampleInformationBox { get; set; }

public void ToBuffer(ref FMp4MessagePackWriter writer)
{
Start(ref writer);
SampleDescriptionBox.ToBuffer(ref writer);
TimeToSampleBox.ToBuffer(ref writer);
CompositionOffsetBox.ToBuffer(ref writer);
SampleToChunkBox.ToBuffer(ref writer);
ChunkOffsetBox.ToBuffer(ref writer);
End(ref writer);
}
}
}

+ 10
- 2
src/JT1078.FMp4/Boxs/SampleToChunkBox.cs Переглянути файл

@@ -1,16 +1,24 @@
using System;
using JT1078.FMp4.Interfaces;
using JT1078.FMp4.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;

namespace JT1078.FMp4
{
public class SampleToChunkBox : FullBox
public class SampleToChunkBox : FullBox, IFMp4MessagePackFormatter
{
public SampleToChunkBox(byte version=0, uint flags=0) : base("stsc", version, flags)
{
}
public uint EntryCount { get; set; }
public List<SampleToChunkInfo> SampleToChunkInfos { get; set; }

public void ToBuffer(ref FMp4MessagePackWriter writer)
{
throw new NotImplementedException();
}

public class SampleToChunkInfo
{
public uint FirstChunk { get; set; }


+ 9
- 2
src/JT1078.FMp4/Boxs/TimeToSampleBox.cs Переглянути файл

@@ -1,10 +1,12 @@
using System;
using JT1078.FMp4.Interfaces;
using JT1078.FMp4.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;

namespace JT1078.FMp4
{
public class TimeToSampleBox : FullBox
public class TimeToSampleBox : FullBox, IFMp4MessagePackFormatter
{
public TimeToSampleBox(byte version = 0, uint flags = 0) : base("stts", version, flags)
{
@@ -14,6 +16,11 @@ namespace JT1078.FMp4

public List<TimeToSampleInfo> TimeToSampleInfos { get; set; }

public void ToBuffer(ref FMp4MessagePackWriter writer)
{
throw new NotImplementedException();
}

public class TimeToSampleInfo
{
public uint SampleCount { get; set; }


+ 13
- 1
src/JT1078.FMp4/Boxs/TrackBox.cs Переглянути файл

@@ -4,14 +4,26 @@ using System.Text;

namespace JT1078.FMp4
{
/// <summary>
/// trak
/// </summary>
public class TrackBox : Mp4Box
{
/// <summary>
/// trak
/// </summary>
public TrackBox() : base("trak")
{
}
public TrackHeaderBox TrackHeaderBox { get; set; }
/// <summary>
/// tkhd
/// </summary>
public TrackHeaderBox TrackHeaderBox { get; set; }
//不是必须的 public TrackReferenceBox TrackReferenceBox { get; set; }
//不是必须的 public EditBox EditBox { get; set; }
/// <summary>
/// mdia
/// </summary>
public MediaBox MediaBox { get; set; }
}
}

+ 9
- 1
src/JT1078.FMp4/Boxs/TrackHeaderBox.cs Переглянути файл

@@ -6,8 +6,16 @@ using System.Text;

namespace JT1078.FMp4
{
/// <summary>
/// tkhd
/// </summary>
public class TrackHeaderBox : FullBox, IFMp4MessagePackFormatter
{
/// <summary>
/// tkhd
/// </summary>
/// <param name="version"></param>
/// <param name="flags"></param>
public TrackHeaderBox(byte version, uint flags) : base("tkhd", version, flags)
{
}
@@ -27,7 +35,7 @@ namespace JT1078.FMp4
public void ToBuffer(ref FMp4MessagePackWriter writer)
{
Start(ref writer);
WriterToBuffer(ref writer);
WriterFullBoxToBuffer(ref writer);
if (Version == 1)
{
writer.WriteUInt64(CreationTime);


+ 20
- 2
src/JT1078.FMp4/Boxs/URIBox.cs Переглянути файл

@@ -1,15 +1,33 @@
using System;
using JT1078.FMp4.Interfaces;
using JT1078.FMp4.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;

namespace JT1078.FMp4
{
public class URIBox : FullBox
/// <summary>
/// uri
/// </summary>
public class URIBox : FullBox, IFMp4MessagePackFormatter
{
/// <summary>
/// uri
/// </summary>
/// <param name="version"></param>
/// <param name="flags"></param>
public URIBox(byte version=0, uint flags=0) : base("uri ", version, flags)
{
}

public string TheURI { get; set; }

public void ToBuffer(ref FMp4MessagePackWriter writer)
{
Start(ref writer);
WriterFullBoxToBuffer(ref writer);
writer.WriteUTF8(TheURI ?? "\0");
End(ref writer);
}
}
}

+ 26
- 2
src/JT1078.FMp4/Boxs/URIInitBox.cs Переглянути файл

@@ -1,15 +1,39 @@
using System;
using JT1078.FMp4.Interfaces;
using JT1078.FMp4.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;

namespace JT1078.FMp4
{
public class URIInitBox : FullBox
/// <summary>
/// uriI
/// </summary>
public class URIInitBox : FullBox, IFMp4MessagePackFormatter
{
/// <summary>
/// uriI
/// </summary>
/// <param name="version"></param>
/// <param name="flags"></param>
public URIInitBox(byte version=0, uint flags=0) : base("uriI", version, flags)
{
}

public byte[] UriInitializationData { get; set; }

public void ToBuffer(ref FMp4MessagePackWriter writer)
{
Start(ref writer);
WriterFullBoxToBuffer(ref writer);
if(UriInitializationData!=null && UriInitializationData.Length>0)
{
foreach(var item in UriInitializationData)
{
writer.WriteByte(item);
}
}
End(ref writer);
}
}
}

+ 34
- 0
src/JT1078.FMp4/Enums/HandlerType.cs Переглянути файл

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace JT1078.FMp4.Enums
{
public enum HandlerType
{
/// <summary>
/// null
/// </summary>
none,
/// <summary>
/// Video track
/// </summary>
vide,
/// <summary>
/// Audio track
/// </summary>
soun,
/// <summary>
/// Hint track
/// </summary>
hint,
/// <summary>
/// Timed Metadata track
/// </summary>
meta,
/// <summary>
/// Auxiliary Video track
/// </summary>
auxv
}
}

+ 24
- 2
src/JT1078.FMp4/FMp4Box.cs Переглянути файл

@@ -1,14 +1,36 @@
using System;
using JT1078.FMp4.Interfaces;
using JT1078.FMp4.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;

namespace JT1078.FMp4
{
public class FMp4Box
/// <summary>
/// fmp4
/// </summary>
public class FMp4Box:IFMp4MessagePackFormatter
{
/// <summary>
/// ftyp
/// </summary>
public FileTypeBox FileTypeBox { get; set; }
/// <summary>
/// moov
/// </summary>
public MovieBox MovieBox { get; set; }
/// <summary>
///
/// </summary>
public List<FragmentBox> FragmentBoxs { get; set; }
/// <summary>
///
/// </summary>
public MovieFragmentRandomAccessBox MovieFragmentRandomAccessBox { get; set; }

public void ToBuffer(ref FMp4MessagePackWriter writer)
{
FileTypeBox.ToBuffer(ref writer);
}
}
}

+ 1
- 1
src/JT1078.FMp4/FullBox.cs Переглянути файл

@@ -25,7 +25,7 @@ namespace JT1078.FMp4
///
/// </summary>
/// <param name="writer"></param>
protected void WriterToBuffer(ref FMp4MessagePackWriter writer)
protected void WriterFullBoxToBuffer(ref FMp4MessagePackWriter writer)
{
writer.WriteByte(Version);
writer.WriteUInt24(Flags);


+ 512
- 1
src/JT1078.FMp4/JT1078.FMp4.xml Переглянути файл

@@ -4,6 +4,16 @@
<name>JT1078.FMp4</name>
</assembly>
<members>
<member name="T:JT1078.FMp4.AVCConfigurationBox">
<summary>
avcC
</summary>
</member>
<member name="M:JT1078.FMp4.AVCConfigurationBox.#ctor">
<summary>
avcC
</summary>
</member>
<member name="T:JT1078.FMp4.AVCDecoderConfigurationRecord">
<summary>
@@ -19,6 +29,16 @@
length:EntryCount
</summary>
</member>
<member name="T:JT1078.FMp4.CleanApertureBox">
<summary>
clap
</summary>
</member>
<member name="M:JT1078.FMp4.CleanApertureBox.#ctor">
<summary>
clap
</summary>
</member>
<member name="P:JT1078.FMp4.CompactSampleSizeBox.FieldSize">
<summary>
4, 8 or 16
@@ -46,6 +66,33 @@
ISO-639-2/T language code
</summary>
</member>
<member name="T:JT1078.FMp4.DataInformationBox">
<summary>
dinf
</summary>
</member>
<member name="M:JT1078.FMp4.DataInformationBox.#ctor">
<summary>
dinf
</summary>
</member>
<member name="P:JT1078.FMp4.DataInformationBox.DataReferenceBox">
<summary>
dref
</summary>
</member>
<member name="T:JT1078.FMp4.DataReferenceBox">
<summary>
dref
</summary>
</member>
<member name="M:JT1078.FMp4.DataReferenceBox.#ctor(System.Byte,System.UInt32)">
<summary>
dref
</summary>
<param name="version"></param>
<param name="flags"></param>
</member>
<member name="P:JT1078.FMp4.DataReferenceBox.DataEntryBoxes">
<summary>
length:EntryCount
@@ -81,6 +128,11 @@
ftyp 盒子相当于就是该 mp4 的纲领性说明。即,告诉解码器它的基本解码版本,兼容格式。简而言之,就是用来告诉客户端,该 MP4 的使用的解码标准。通常,ftyp 都是放在 MP4 的开头。
</summary>
</member>
<member name="M:JT1078.FMp4.FileTypeBox.#ctor">
<summary>
ftyp
</summary>
</member>
<member name="P:JT1078.FMp4.FileTypeBox.MajorBrand">
<summary>
因为兼容性一般可以分为推荐兼容性和默认兼容性。这里 major_brand 就相当于是推荐兼容性。通常,在 Web 中解码,一般而言都是使用 isom 这个万金油即可。如果是需要特定的格式,可以自行定义。
@@ -109,6 +161,18 @@
填充数量
</summary>
</member>
<member name="T:JT1078.FMp4.HandlerBox">
<summary>
hdlr
</summary>
</member>
<member name="M:JT1078.FMp4.HandlerBox.#ctor(System.Byte,System.UInt32)">
<summary>
hdlr
</summary>
<param name="version"></param>
<param name="flags"></param>
</member>
<member name="P:JT1078.FMp4.ItemLocationBox.OffsetSize">
<summary>
0, 4, 8
@@ -165,6 +229,43 @@
assignment_type == 4
</summary>
</member>
<member name="T:JT1078.FMp4.MediaBox">
<summary>
mdia
</summary>
</member>
<member name="M:JT1078.FMp4.MediaBox.#ctor">
<summary>
mdia
</summary>
</member>
<member name="P:JT1078.FMp4.MediaBox.MediaHeaderBox">
<summary>
mdhd
</summary>
</member>
<member name="P:JT1078.FMp4.MediaBox.HandlerBox">
<summary>
hdlr
</summary>
</member>
<member name="P:JT1078.FMp4.MediaBox.MediaInformationBox">
<summary>
minf
</summary>
</member>
<member name="T:JT1078.FMp4.MediaHeaderBox">
<summary>
mdhd
</summary>
</member>
<member name="M:JT1078.FMp4.MediaHeaderBox.#ctor(System.Byte,System.UInt32)">
<summary>
mdhd
</summary>
<param name="version"></param>
<param name="flags"></param>
</member>
<member name="P:JT1078.FMp4.MediaHeaderBox.Language">
<summary>
ISO-639-2/T language code
@@ -172,6 +273,93 @@
und-undetermined
</summary>
</member>
<member name="T:JT1078.FMp4.MediaInformationBox">
<summary>
minf
</summary>
</member>
<member name="M:JT1078.FMp4.MediaInformationBox.#ctor">
<summary>
minf
</summary>
</member>
<member name="P:JT1078.FMp4.MediaInformationBox.DataInformationBox">
<summary>
dinf
</summary>
</member>
<member name="P:JT1078.FMp4.MediaInformationBox.SampleTableBox">
<summary>
stbl
</summary>
</member>
<member name="T:JT1078.FMp4.MovieBox">
<summary>
moov
</summary>
</member>
<member name="M:JT1078.FMp4.MovieBox.#ctor">
<summary>
moov
</summary>
</member>
<member name="P:JT1078.FMp4.MovieBox.MovieHeaderBox">
<summary>
mvhd
</summary>
</member>
<member name="P:JT1078.FMp4.MovieBox.TrackBox">
<summary>
trak
</summary>
</member>
<member name="P:JT1078.FMp4.MovieBox.MovieExtendsBox">
<summary>
trak
</summary>
</member>
<member name="T:JT1078.FMp4.MovieExtendsBox">
<summary>
mvex
</summary>
</member>
<member name="M:JT1078.FMp4.MovieExtendsBox.#ctor">
<summary>
mvex
</summary>
</member>
<member name="T:JT1078.FMp4.MovieHeaderBox">
<summary>
mvhd
</summary>
</member>
<member name="M:JT1078.FMp4.MovieHeaderBox.#ctor(System.Byte,System.UInt32)">
<summary>
mvhd
</summary>
<param name="version"></param>
<param name="flags"></param>
</member>
<member name="T:JT1078.FMp4.MPEG4BitRateBox">
<summary>
btrt
</summary>
</member>
<member name="M:JT1078.FMp4.MPEG4BitRateBox.#ctor">
<summary>
btrt
</summary>
</member>
<member name="T:JT1078.FMp4.PixelAspectRatioBox">
<summary>
pasp
</summary>
</member>
<member name="M:JT1078.FMp4.PixelAspectRatioBox.#ctor">
<summary>
pasp
</summary>
</member>
<member name="P:JT1078.FMp4.ProducerReferenceTimeBox.MediaTime">
<summary>
if (version==0)
@@ -202,6 +390,19 @@
is taken from the sample_count in the Sample Size Box ('stsz') or Compact Sample Size Box(‘stz2’).
</summary>
</member>
<member name="T:JT1078.FMp4.SampleDescriptionBox">
<summary>
stsd
</summary>
</member>
<member name="M:JT1078.FMp4.SampleDescriptionBox.#ctor(JT1078.FMp4.Enums.HandlerType,System.Byte,System.UInt32)">
<summary>
stsd
</summary>
<param name="handlerType"></param>
<param name="version"></param>
<param name="flags"></param>
</member>
<member name="P:JT1078.FMp4.SampleGroupDescriptionBox.DefaultLength">
<summary>
if (version==1)
@@ -213,6 +414,41 @@
length:sample_count
</summary>
</member>
<member name="T:JT1078.FMp4.SampleTableBox">
<summary>
stbl
</summary>
</member>
<member name="M:JT1078.FMp4.SampleTableBox.#ctor">
<summary>
stbl
</summary>
</member>
<member name="P:JT1078.FMp4.SampleTableBox.SampleDescriptionBox">
<summary>
stsd
</summary>
</member>
<member name="P:JT1078.FMp4.SampleTableBox.TimeToSampleBox">
<summary>
stts
</summary>
</member>
<member name="P:JT1078.FMp4.SampleTableBox.CompositionOffsetBox">
<summary>
ctts
</summary>
</member>
<member name="P:JT1078.FMp4.SampleTableBox.SampleToChunkBox">
<summary>
stsc
</summary>
</member>
<member name="P:JT1078.FMp4.SampleTableBox.ChunkOffsetBox">
<summary>
stco
</summary>
</member>
<member name="P:JT1078.FMp4.SampleToGroupBox.GroupingTypeParameter">
<summary>
version == 1
@@ -304,6 +540,26 @@
length:ItemCount
</summary>
</member>
<member name="T:JT1078.FMp4.TrackBox">
<summary>
trak
</summary>
</member>
<member name="M:JT1078.FMp4.TrackBox.#ctor">
<summary>
trak
</summary>
</member>
<member name="P:JT1078.FMp4.TrackBox.TrackHeaderBox">
<summary>
tkhd
</summary>
</member>
<member name="P:JT1078.FMp4.TrackBox.MediaBox">
<summary>
mdia
</summary>
</member>
<member name="P:JT1078.FMp4.TrackFragmentRandomAccessBox.Reserved">
<summary>
4byte 32-26
@@ -324,6 +580,18 @@
4byte 32-32
</summary>
</member>
<member name="T:JT1078.FMp4.TrackHeaderBox">
<summary>
tkhd
</summary>
</member>
<member name="M:JT1078.FMp4.TrackHeaderBox.#ctor(System.Byte,System.UInt32)">
<summary>
tkhd
</summary>
<param name="version"></param>
<param name="flags"></param>
</member>
<member name="P:JT1078.FMp4.TrackRunBox.DataOffset">
<summary>
可选的
@@ -339,11 +607,90 @@
version == 0
</summary>
</member>
<member name="T:JT1078.FMp4.URIBox">
<summary>
uri
</summary>
</member>
<member name="M:JT1078.FMp4.URIBox.#ctor(System.Byte,System.UInt32)">
<summary>
uri
</summary>
<param name="version"></param>
<param name="flags"></param>
</member>
<member name="T:JT1078.FMp4.URIInitBox">
<summary>
uriI
</summary>
</member>
<member name="M:JT1078.FMp4.URIInitBox.#ctor(System.Byte,System.UInt32)">
<summary>
uriI
</summary>
<param name="version"></param>
<param name="flags"></param>
</member>
<member name="T:JT1078.FMp4.Buffers.FMp4BufferWriter">
<summary>
<see cref="!:System.Buffers.Writer"/>
</summary>
</member>
<member name="F:JT1078.FMp4.Enums.HandlerType.none">
<summary>
null
</summary>
</member>
<member name="F:JT1078.FMp4.Enums.HandlerType.vide">
<summary>
Video track
</summary>
</member>
<member name="F:JT1078.FMp4.Enums.HandlerType.soun">
<summary>
Audio track
</summary>
</member>
<member name="F:JT1078.FMp4.Enums.HandlerType.hint">
<summary>
Hint track
</summary>
</member>
<member name="F:JT1078.FMp4.Enums.HandlerType.meta">
<summary>
Timed Metadata track
</summary>
</member>
<member name="F:JT1078.FMp4.Enums.HandlerType.auxv">
<summary>
Auxiliary Video track
</summary>
</member>
<member name="T:JT1078.FMp4.FMp4Box">
<summary>
fmp4
</summary>
</member>
<member name="P:JT1078.FMp4.FMp4Box.FileTypeBox">
<summary>
ftyp
</summary>
</member>
<member name="P:JT1078.FMp4.FMp4Box.MovieBox">
<summary>
moov
</summary>
</member>
<member name="P:JT1078.FMp4.FMp4Box.FragmentBoxs">
<summary>
</summary>
</member>
<member name="P:JT1078.FMp4.FMp4Box.MovieFragmentRandomAccessBox">
<summary>
</summary>
</member>
<member name="F:JT1078.FMp4.FMp4Constants.DateLimitYear">
<summary>
日期限制于2000年
@@ -359,7 +706,7 @@
bit(24)
</summary>
</member>
<member name="M:JT1078.FMp4.FullBox.WriterToBuffer(JT1078.FMp4.MessagePack.FMp4MessagePackWriter@)">
<member name="M:JT1078.FMp4.FullBox.WriterFullBoxToBuffer(JT1078.FMp4.MessagePack.FMp4MessagePackWriter@)">
<summary>
</summary>
@@ -401,5 +748,169 @@
<param name="writer"></param>
</member>
<!-- Badly formed XML comment ignored for member "P:JT1078.FMp4.Samples.AudioSampleEntry.Samplerate" -->
<member name="T:JT1078.FMp4.Samples.AVC1SampleEntry">
<summary>
avc1
</summary>
</member>
<member name="M:JT1078.FMp4.Samples.AVC1SampleEntry.#ctor">
<summary>
avc1
</summary>
</member>
<member name="P:JT1078.FMp4.Samples.AVC1SampleEntry.AVCConfigurationBox">
<summary>
avcC
</summary>
</member>
<member name="P:JT1078.FMp4.Samples.AVC1SampleEntry.MPEG4BitRateBox">
<summary>
btrt
</summary>
</member>
<member name="T:JT1078.FMp4.Samples.HintSampleEntry">
<summary>
HintSampleEntry
</summary>
</member>
<member name="M:JT1078.FMp4.Samples.HintSampleEntry.#ctor(System.String)">
<summary>
HintSampleEntry
</summary>
<param name="protocol"></param>
</member>
<member name="T:JT1078.FMp4.Samples.SampleEntry">
<summary>
SampleEntry
</summary>
</member>
<member name="M:JT1078.FMp4.Samples.SampleEntry.#ctor(System.String)">
<summary>
SampleEntry
</summary>
<param name="boxType"></param>
</member>
<member name="M:JT1078.FMp4.Samples.SampleEntry.WriterSampleEntryToBuffer(JT1078.FMp4.MessagePack.FMp4MessagePackWriter@)">
<summary>
</summary>
<param name="writer"></param>
</member>
<member name="T:JT1078.FMp4.Samples.TextMetaDataSampleEntry">
<summary>
mett
</summary>
</member>
<member name="M:JT1078.FMp4.Samples.TextMetaDataSampleEntry.#ctor">
<summary>
mett
</summary>
</member>
<member name="P:JT1078.FMp4.Samples.TextMetaDataSampleEntry.ContentEncoding">
<summary>
optional
</summary>
</member>
<member name="P:JT1078.FMp4.Samples.TextMetaDataSampleEntry.MimeFormat">
<summary>
</summary>
</member>
<member name="P:JT1078.FMp4.Samples.TextMetaDataSampleEntry.BitRateBox">
<summary>
btrt
optional
</summary>
</member>
<member name="T:JT1078.FMp4.Samples.URIMetaSampleEntry">
<summary>
urim
</summary>
</member>
<member name="M:JT1078.FMp4.Samples.URIMetaSampleEntry.#ctor">
<summary>
urim
</summary>
</member>
<member name="P:JT1078.FMp4.Samples.URIMetaSampleEntry.TheLabel">
<summary>
uri
</summary>
</member>
<member name="P:JT1078.FMp4.Samples.URIMetaSampleEntry.Init">
<summary>
uriI
optional
</summary>
</member>
<member name="P:JT1078.FMp4.Samples.URIMetaSampleEntry.BitRateBox">
<summary>
btrt
optional
</summary>
</member>
<member name="T:JT1078.FMp4.Samples.VisualSampleEntry">
<summary>
VisualSampleEntry
</summary>
</member>
<member name="M:JT1078.FMp4.Samples.VisualSampleEntry.#ctor(System.String)">
<summary>
VisualSampleEntry
</summary>
<param name="boxType"></param>
</member>
<member name="P:JT1078.FMp4.Samples.VisualSampleEntry.Clap">
<summary>
clap
optional
</summary>
</member>
<member name="P:JT1078.FMp4.Samples.VisualSampleEntry.Pasp">
<summary>
pasp
optional
</summary>
</member>
<member name="M:JT1078.FMp4.Samples.VisualSampleEntry.WriterVisualSampleEntryToBuffer(JT1078.FMp4.MessagePack.FMp4MessagePackWriter@)">
<summary>
</summary>
<param name="writer"></param>
</member>
<member name="T:JT1078.FMp4.Samples.XMLMetaDataSampleEntry">
<summary>
metx
</summary>
</member>
<member name="M:JT1078.FMp4.Samples.XMLMetaDataSampleEntry.#ctor">
<summary>
metx
</summary>
</member>
<member name="P:JT1078.FMp4.Samples.XMLMetaDataSampleEntry.ContentEncoding">
<summary>
optional
</summary>
</member>
<member name="P:JT1078.FMp4.Samples.XMLMetaDataSampleEntry.Namespace">
<summary>
Namespace
</summary>
</member>
<member name="P:JT1078.FMp4.Samples.XMLMetaDataSampleEntry.SchemaLocation">
<summary>
optional
</summary>
</member>
<member name="P:JT1078.FMp4.Samples.XMLMetaDataSampleEntry.BitRateBox">
<summary>
optional
</summary>
</member>
</members>
</doc>

+ 7
- 0
src/JT1078.FMp4/MessagePack/FMp4MessagePackWriter.cs Переглянути файл

@@ -65,6 +65,13 @@ namespace JT1078.FMp4.MessagePack
writer.Advance(data.Length);
}

public void WriteUTF8(string value)
{
var data = Encoding.UTF8.GetBytes(value);
data.CopyTo(writer.Free);
writer.Advance(data.Length);
}

public void WriteArray(ReadOnlySpan<byte> src)
{
src.CopyTo(writer.Free);


+ 26
- 2
src/JT1078.FMp4/Samples/AVC1SampleEntry.cs Переглянути файл

@@ -1,17 +1,41 @@
using System;
using JT1078.FMp4.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;

namespace JT1078.FMp4.Samples
{
/// <summary>
/// avc1
/// </summary>
public class AVC1SampleEntry : VisualSampleEntry
{
/// <summary>
/// avc1
/// </summary>
public AVC1SampleEntry() : base("avc1")
{
}
/// <summary>
/// avcC
/// </summary>
public AVCConfigurationBox AVCConfigurationBox { get; set; }

/// <summary>
/// btrt
/// </summary>
public MPEG4BitRateBox MPEG4BitRateBox { get; set; }

public override void ToBuffer(ref FMp4MessagePackWriter writer)
{
Start(ref writer);
WriterVisualSampleEntryToBuffer(ref writer);
AVCConfigurationBox.ToBuffer(ref writer);
if (MPEG4BitRateBox != null)
{
MPEG4BitRateBox.ToBuffer(ref writer);
}
End(ref writer);
}
//todo:public MPEG4ExtensionDescriptorsBox MPEG4BitRateBox { get; set; }
}
}

+ 24
- 2
src/JT1078.FMp4/Samples/HintSampleEntry.cs Переглянути файл

@@ -1,14 +1,36 @@
using System;
using JT1078.FMp4.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;

namespace JT1078.FMp4.Samples
{
/// <summary>
/// HintSampleEntry
/// </summary>
public class HintSampleEntry : SampleEntry
{
/// <summary>
/// HintSampleEntry
/// </summary>
/// <param name="protocol"></param>
public HintSampleEntry(string protocol) : base(protocol)
{
}
public List<byte> Data { get; set; }
public List<byte> Data { get; set; } = new List<byte>();

public override void ToBuffer(ref FMp4MessagePackWriter writer)
{
Start(ref writer);
WriterSampleEntryToBuffer(ref writer);
if (Data != null && Data.Count > 0)
{
foreach (var item in Data)
{
writer.WriteByte(item);
}
}
End(ref writer);
}
}
}

+ 26
- 2
src/JT1078.FMp4/Samples/SampleEntry.cs Переглянути файл

@@ -1,15 +1,39 @@
using System;
using JT1078.FMp4.Interfaces;
using JT1078.FMp4.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;

namespace JT1078.FMp4.Samples
{
public abstract class SampleEntry : Mp4Box
/// <summary>
/// SampleEntry
/// </summary>
public abstract class SampleEntry : Mp4Box,IFMp4MessagePackFormatter
{
/// <summary>
/// SampleEntry
/// </summary>
/// <param name="boxType"></param>
public SampleEntry(string boxType) : base(boxType)
{
}
public byte[] Reserved { get; set; } = new byte[6];
public ushort DataReferenceIndex { get; set; }

/// <summary>
///
/// </summary>
/// <param name="writer"></param>
protected void WriterSampleEntryToBuffer(ref FMp4MessagePackWriter writer)
{
foreach(var item in Reserved)
{
writer.WriteByte(item);
}
writer.WriteUInt16(DataReferenceIndex);
}

public abstract void ToBuffer(ref FMp4MessagePackWriter writer);
}
}

+ 32
- 1
src/JT1078.FMp4/Samples/TextMetaDataSampleEntry.cs Переглянути файл

@@ -1,16 +1,47 @@
using System;
using JT1078.FMp4.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;

namespace JT1078.FMp4.Samples
{
/// <summary>
/// mett
/// </summary>
public class TextMetaDataSampleEntry : SampleEntry
{
/// <summary>
/// mett
/// </summary>
public TextMetaDataSampleEntry() : base("mett")
{
}
/// <summary>
///
/// optional
/// </summary>
public string ContentEncoding { get; set; }
/// <summary>
///
/// </summary>
public string MimeFormat { get; set; }
/// <summary>
/// btrt
/// optional
/// </summary>
public MPEG4BitRateBox BitRateBox { get; set; }

public override void ToBuffer(ref FMp4MessagePackWriter writer)
{
if (!string.IsNullOrEmpty(ContentEncoding))
{
writer.WriteUTF8(ContentEncoding);
}
writer.WriteUTF8(MimeFormat??"\0");
if (BitRateBox != null)
{
BitRateBox.ToBuffer(ref writer);
}
}
}
}

+ 38
- 1
src/JT1078.FMp4/Samples/URIMetaSampleEntry.cs Переглянути файл

@@ -1,16 +1,53 @@
using System;
using JT1078.FMp4.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;

namespace JT1078.FMp4.Samples
{
/// <summary>
/// urim
/// </summary>
public class URIMetaSampleEntry : SampleEntry
{
/// <summary>
/// urim
/// </summary>
public URIMetaSampleEntry() : base("urim")
{
}
/// <summary>
/// uri
/// </summary>
public URIBox TheLabel { get; set; }
/// <summary>
/// uriI
/// optional
/// </summary>
public URIInitBox Init { get; set; }
/// <summary>
/// btrt
/// optional
/// </summary>
public MPEG4BitRateBox BitRateBox { get; set; }

public override void ToBuffer(ref FMp4MessagePackWriter writer)
{
Start(ref writer);
WriterSampleEntryToBuffer(ref writer);
if (TheLabel != null)
{
TheLabel.ToBuffer(ref writer);
}
if (Init != null)
{
Init.ToBuffer(ref writer);
}
if (BitRateBox != null)
{
BitRateBox.ToBuffer(ref writer);
}
End(ref writer);
}
}
}

+ 52
- 1
src/JT1078.FMp4/Samples/VisualSampleEntry.cs Переглянути файл

@@ -1,11 +1,19 @@
using System;
using JT1078.FMp4.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;

namespace JT1078.FMp4.Samples
{
/// <summary>
/// VisualSampleEntry
/// </summary>
public abstract class VisualSampleEntry : SampleEntry
{
/// <summary>
/// VisualSampleEntry
/// </summary>
/// <param name="boxType"></param>
public VisualSampleEntry(string boxType) : base(boxType)
{
}
@@ -22,7 +30,50 @@ namespace JT1078.FMp4.Samples
public string CompressorName { get; set; }
public ushort Depth { get; set; } = 0x0018;
public short PreDefined3 { get; set; } = 0x1111;
/// <summary>
/// clap
/// optional
/// </summary>
public CleanApertureBox Clap { get; set; }
/// <summary>
/// pasp
/// optional
/// </summary>
public PixelAspectRatioBox Pasp { get; set; }

/// <summary>
///
/// </summary>
/// <param name="writer"></param>
protected void WriterVisualSampleEntryToBuffer(ref FMp4MessagePackWriter writer)
{
writer.WriteUInt16(PreDefined1);
writer.WriteUInt16(Reserved1);
foreach(var item in PreDefined2)
{
writer.WriteUInt32(item);
}
writer.WriteUInt16(Width);
writer.WriteUInt16(Height);
writer.WriteUInt32(HorizreSolution);
writer.WriteUInt32(VertreSolution);
writer.WriteUInt32(Reserved3);
writer.WriteUInt16(FrameCount);
if (string.IsNullOrEmpty(CompressorName))
{
CompressorName = "";
}
writer.WriteUTF8(CompressorName.PadLeft(32, '\0'));
writer.WriteUInt16(Depth);
writer.WriteInt16(PreDefined3);
if (Clap != null)
{
Clap.ToBuffer(ref writer);
}
if (Pasp != null)
{
Pasp.ToBuffer(ref writer);
}
}
}
}

+ 43
- 2
src/JT1078.FMp4/Samples/XMLMetaDataSampleEntry.cs Переглянути файл

@@ -1,18 +1,59 @@
using System;
using JT1078.FMp4.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;

namespace JT1078.FMp4.Samples
{
/// <summary>
/// metx
/// </summary>
public class XMLMetaDataSampleEntry : SampleEntry
{
/// <summary>
/// metx
/// </summary>
public XMLMetaDataSampleEntry() : base("metx")
{
}

/// <summary>
///
/// optional
/// </summary>
public string ContentEncoding { get; set; }
/// <summary>
/// Namespace
/// </summary>
public string Namespace { get; set; }
/// <summary>
///
/// optional
/// </summary>
public string SchemaLocation { get; set; }
/// <summary>
///
/// optional
/// </summary>
public MPEG4BitRateBox BitRateBox { get; set; }

public override void ToBuffer(ref FMp4MessagePackWriter writer)
{
Start(ref writer);
WriterSampleEntryToBuffer(ref writer);
if (!string.IsNullOrEmpty(ContentEncoding))
{
writer.WriteUTF8(ContentEncoding);
}
writer.WriteUTF8(Namespace ?? "\0");
if (!string.IsNullOrEmpty(SchemaLocation))
{
writer.WriteUTF8(SchemaLocation);
}
if (BitRateBox != null)
{
BitRateBox.ToBuffer(ref writer);
}
End(ref writer);
}
}
}

Завантаження…
Відмінити
Зберегти