@@ -0,0 +1,21 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace JT1078.Flv | |||||
{ | |||||
public static class Amf0 | |||||
{ | |||||
public readonly static byte[] Buffer; | |||||
public readonly static byte[] FixedData = new byte[] { 0x6F, 0x6E, 0x4D, 0x65, 0x74, 0x61, 0x44, 0x61, 0x74, 0x61 }; | |||||
static Amf0() | |||||
{ | |||||
Buffer = new byte[13]; | |||||
Buffer[0] = 0x02; | |||||
Buffer[1] = 0; | |||||
Buffer[2] = 10; | |||||
Array.Copy(FixedData, 0, Buffer, 3, 10); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,11 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace JT1078.Flv | |||||
{ | |||||
public static class Amf3 | |||||
{ | |||||
} | |||||
} |
@@ -0,0 +1,12 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace JT1078.Flv | |||||
{ | |||||
public enum AacPacketType | |||||
{ | |||||
SequenceHeader, | |||||
Raw | |||||
} | |||||
} |
@@ -0,0 +1,17 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace JT1078.Flv | |||||
{ | |||||
public enum CodecId | |||||
{ | |||||
Jpeg = 1, | |||||
H263, | |||||
ScreenVideo, | |||||
Vp6, | |||||
Vp6WithAlpha, | |||||
ScreenVideo2, | |||||
Avc | |||||
} | |||||
} |
@@ -0,0 +1,15 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace JT1078.Flv | |||||
{ | |||||
public enum FrameType | |||||
{ | |||||
KeyFrame = 1, | |||||
InterFrame, | |||||
DisposableInterFrame, | |||||
GeneratedKeyFrame, | |||||
VideoInfoOrCommandFrame | |||||
} | |||||
} |
@@ -0,0 +1,24 @@ | |||||
using System.Buffers; | |||||
namespace JT1078.Flv | |||||
{ | |||||
internal static class FlvArrayPool | |||||
{ | |||||
private readonly static ArrayPool<byte> ArrayPool; | |||||
static FlvArrayPool() | |||||
{ | |||||
ArrayPool = ArrayPool<byte>.Create(); | |||||
} | |||||
public static byte[] Rent(int minimumLength) | |||||
{ | |||||
return ArrayPool.Rent(minimumLength); | |||||
} | |||||
public static void Return(byte[] array, bool clearArray = false) | |||||
{ | |||||
ArrayPool.Return(array, clearArray); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,15 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace JT1078.Flv | |||||
{ | |||||
public class FlvBody | |||||
{ | |||||
/// <summary> | |||||
/// 前一个tag的长度 | |||||
/// </summary> | |||||
public uint PreviousTagSize { get; set; } | |||||
public FlvTag Tag { get; set; } | |||||
} | |||||
} |
@@ -0,0 +1,33 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Buffers.Binary; | |||||
namespace JT1078.Flv | |||||
{ | |||||
public struct FlvHeader | |||||
{ | |||||
public FlvHeader(bool hasVideo,bool hasAudio) | |||||
{ | |||||
byte audioFlag = 0x01 << 2; | |||||
byte videoFlag = 0x01; | |||||
Flags = 0x00; | |||||
if (hasAudio) Flags |= audioFlag; | |||||
if (hasVideo) Flags |= videoFlag; | |||||
} | |||||
private byte Flags; | |||||
public ReadOnlySpan<byte> ToArray() | |||||
{ | |||||
Span<byte> tmp = new byte[9]; | |||||
tmp[0] = 0x46; | |||||
tmp[1] = 0x4c; | |||||
tmp[2] = 0x66; | |||||
tmp[3] = 0x01; | |||||
tmp[4] = Flags; | |||||
BinaryPrimitives.WriteInt32BigEndian(tmp.Slice(5), 9); | |||||
return tmp; | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,15 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace JT1078.Flv | |||||
{ | |||||
public class FlvMuxer | |||||
{ | |||||
private readonly FlvHeader VideoFlvHeader = new FlvHeader(true, false); | |||||
public void FlvVideoMuxer() | |||||
{ | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,11 @@ | |||||
namespace JT1078.Flv | |||||
{ | |||||
public class FlvTag | |||||
{ | |||||
public FlvTagHeader TagHeader { get; set; } | |||||
/// <summary> | |||||
/// 根据tag类型 | |||||
/// </summary> | |||||
public byte[] TagData { get; set; } | |||||
} | |||||
} |
@@ -0,0 +1,27 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace JT1078.Flv | |||||
{ | |||||
public class FlvTagHeader | |||||
{ | |||||
public byte Type { get; set; } | |||||
/// <summary> | |||||
/// Tag Data部分大小 | |||||
/// 3个字节 | |||||
/// </summary> | |||||
public uint DataSize { get; set; } | |||||
/// <summary> | |||||
/// Tag时间戳 | |||||
/// 3个字节 | |||||
/// </summary> | |||||
public uint Timestamp { get; set; } | |||||
public byte TimestampExt { get; set; } = 0; | |||||
/// <summary> | |||||
/// stream id 总是0 | |||||
/// 3个字节 | |||||
/// </summary> | |||||
public uint StreamId { get; set; } = 0; | |||||
} | |||||
} |
@@ -0,0 +1,10 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | |||||
<TargetFramework>netstandard2.0</TargetFramework> | |||||
</PropertyGroup> | |||||
<ItemGroup> | |||||
<PackageReference Include="System.Memory" Version="4.5.3" /> | |||||
</ItemGroup> | |||||
</Project> |
@@ -27,6 +27,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution | |||||
EndProject | EndProject | ||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Protocol.Extensions.WebApiTest", "JT808.Protocol.Extensions.WebApiTest\JT808.Protocol.Extensions.WebApiTest.csproj", "{9DB37370-AC73-434B-9CE2-6659321858C8}" | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Protocol.Extensions.WebApiTest", "JT808.Protocol.Extensions.WebApiTest\JT808.Protocol.Extensions.WebApiTest.csproj", "{9DB37370-AC73-434B-9CE2-6659321858C8}" | ||||
EndProject | EndProject | ||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JT1078.Flv", "JT1078.Flv\JT1078.Flv.csproj", "{33E54FFC-7D91-42E5-9DC1-853738AB8980}" | |||||
EndProject | |||||
Global | Global | ||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||||
Debug|Any CPU = Debug|Any CPU | Debug|Any CPU = Debug|Any CPU | ||||
@@ -65,6 +67,10 @@ Global | |||||
{9DB37370-AC73-434B-9CE2-6659321858C8}.Debug|Any CPU.Build.0 = Debug|Any CPU | {9DB37370-AC73-434B-9CE2-6659321858C8}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||||
{9DB37370-AC73-434B-9CE2-6659321858C8}.Release|Any CPU.ActiveCfg = Release|Any CPU | {9DB37370-AC73-434B-9CE2-6659321858C8}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||||
{9DB37370-AC73-434B-9CE2-6659321858C8}.Release|Any CPU.Build.0 = Release|Any CPU | {9DB37370-AC73-434B-9CE2-6659321858C8}.Release|Any CPU.Build.0 = Release|Any CPU | ||||
{33E54FFC-7D91-42E5-9DC1-853738AB8980}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||||
{33E54FFC-7D91-42E5-9DC1-853738AB8980}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||||
{33E54FFC-7D91-42E5-9DC1-853738AB8980}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||||
{33E54FFC-7D91-42E5-9DC1-853738AB8980}.Release|Any CPU.Build.0 = Release|Any CPU | |||||
EndGlobalSection | EndGlobalSection | ||||
GlobalSection(SolutionProperties) = preSolution | GlobalSection(SolutionProperties) = preSolution | ||||
HideSolutionNode = FALSE | HideSolutionNode = FALSE | ||||