skyscraper8/skyscraper8/Scorcher/PmtGeneratorStream.cs
feyris-tan ef86554f9a Import
2025-05-12 22:09:16 +02:00

41 lines
1023 B
C#

using System.Collections.Generic;
using System.IO;
using skyscraper5.Mpeg2;
using skyscraper5.Skyscraper.IO;
namespace skyscraper5.Scorcher
{
public class PmtGeneratorStream
{
public PmtGeneratorStream(byte type, ushort pid)
{
descriptors = new List<TsDescriptor>();
this.StreamType = type;
this.ElementaryPid = pid;
}
private List<TsDescriptor> descriptors;
public byte StreamType { get; }
public ushort ElementaryPid { get; }
public byte[] SerializeDescriptors()
{
MemoryStream ms = new MemoryStream();
foreach (TsDescriptor descriptor in descriptors)
{
ms.WriteUInt8(descriptor.GetDescriptorId()); //descriptor_tag
byte[] descriptorBytes = descriptor.Serialize();
ms.WriteUInt8((byte)descriptorBytes.Length); //descriptor_length
ms.Write(descriptorBytes, 0, descriptorBytes.Length);
}
return ms.ToArray();
}
public void AddDescriptor(TsDescriptor privateDataSpecifierDescriptor)
{
descriptors.Add(privateDataSpecifierDescriptor);
}
}
}