Пример #1
0
 public void Write(BinaryWriter writer, string message = null)
 {
     writer.Write(nameof(OverlayInfo).GetHashCode());
     writer.Write(message ?? string.Empty);
     writer.Write(KeyFrame);
     format.WriteFrame(writer, this);
 }
Пример #2
0
 public OverlayInfo this[int frameNumber]
 {
     get
     {
         lock (stream)
         {
             if (stream.Length == 0)
             {
                 return(null);
             }
             CheckHeader();
             stream.Position = 1 + format.FrameSize * frameNumber;
             if (stream.Position >= stream.Length)
             {
                 return(null);
             }
             return(format.ReadFrame(reader));
         }
     }
     set
     {
         lock (stream)
         {
             WriteHeader();
             stream.Position = 1 + format.FrameSize * frameNumber;
             var writer = new BinaryWriter(stream);
             if (value == null)
             {
                 writer.Write(0);
             }
             else
             {
                 value.FrameNumber = frameNumber;
                 format.WriteFrame(writer, value);
             }
             writer.Flush();
         }
     }
 }
Пример #3
0
 public void ToFrame(VideoFrame frame)
 {
     unsafe
     {
         using (var stream = new UnmanagedMemoryStream((byte *)frame.GetWritePtr().ToPointer(),
                                                       frame.GetRowSize(), frame.GetRowSize(), FileAccess.Write))
             using (var writer = new BinaryWriter(stream))
             {
                 writer.Write(nameof(OverlayInfo));
                 format.WriteFrame(writer, this);
             }
     }
 }