瀏覽代碼

包装Flv

tags/v1.1.0
smallchi 5 年之前
父節點
當前提交
a49a11eb2e
共有 13 個文件被更改,包括 217 次插入0 次删除
  1. +21
    -0
      src/JT1078.Flv/Amf/Amf0.cs
  2. +11
    -0
      src/JT1078.Flv/Amf/Amf3.cs
  3. +12
    -0
      src/JT1078.Flv/Enums/AacPacketType.cs
  4. +17
    -0
      src/JT1078.Flv/Enums/CodecId.cs
  5. +15
    -0
      src/JT1078.Flv/Enums/FrameType.cs
  6. +24
    -0
      src/JT1078.Flv/FlvArrayPool.cs
  7. +15
    -0
      src/JT1078.Flv/FlvBody.cs
  8. +33
    -0
      src/JT1078.Flv/FlvHeader.cs
  9. +15
    -0
      src/JT1078.Flv/FlvMuxer.cs
  10. +11
    -0
      src/JT1078.Flv/FlvTag.cs
  11. +27
    -0
      src/JT1078.Flv/FlvTagHeader.cs
  12. +10
    -0
      src/JT1078.Flv/JT1078.Flv.csproj
  13. +6
    -0
      src/JT1078.sln

+ 21
- 0
src/JT1078.Flv/Amf/Amf0.cs 查看文件

@@ -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);
}
}
}

+ 11
- 0
src/JT1078.Flv/Amf/Amf3.cs 查看文件

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

namespace JT1078.Flv
{
public static class Amf3
{
}
}

+ 12
- 0
src/JT1078.Flv/Enums/AacPacketType.cs 查看文件

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

namespace JT1078.Flv
{
public enum AacPacketType
{
SequenceHeader,
Raw
}
}

+ 17
- 0
src/JT1078.Flv/Enums/CodecId.cs 查看文件

@@ -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
}
}

+ 15
- 0
src/JT1078.Flv/Enums/FrameType.cs 查看文件

@@ -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
}
}

+ 24
- 0
src/JT1078.Flv/FlvArrayPool.cs 查看文件

@@ -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);
}
}
}

+ 15
- 0
src/JT1078.Flv/FlvBody.cs 查看文件

@@ -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; }
}
}

+ 33
- 0
src/JT1078.Flv/FlvHeader.cs 查看文件

@@ -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;
}
}
}

+ 15
- 0
src/JT1078.Flv/FlvMuxer.cs 查看文件

@@ -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()
{
}
}
}

+ 11
- 0
src/JT1078.Flv/FlvTag.cs 查看文件

@@ -0,0 +1,11 @@
namespace JT1078.Flv
{
public class FlvTag
{
public FlvTagHeader TagHeader { get; set; }
/// <summary>
/// 根据tag类型
/// </summary>
public byte[] TagData { get; set; }
}
}

+ 27
- 0
src/JT1078.Flv/FlvTagHeader.cs 查看文件

@@ -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;
}
}

+ 10
- 0
src/JT1078.Flv/JT1078.Flv.csproj 查看文件

@@ -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>

+ 6
- 0
src/JT1078.sln 查看文件

@@ -27,6 +27,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
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}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JT1078.Flv", "JT1078.Flv\JT1078.Flv.csproj", "{33E54FFC-7D91-42E5-9DC1-853738AB8980}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
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}.Release|Any CPU.ActiveCfg = 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
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE


Loading…
取消
儲存