public void RecordFrame(byte[] jpeg, FrameRate FPS)
        {
            if (!File.Exists(RecordVDB))
            {
                CreateFile(RecordVDB, TypeofFile.VDB);
                if (!File.Exists(RecordVDI))
                {
                    CreateFile(RecordVDI, TypeofFile.VDI);
                }
            }

            try
            {
                using (FileStream fileStreamVDB = File.OpenWrite(RecordVDB))
                {
                    if (Offsets.Count == 0)
                    {
                        fileStreamVDB.Position = 0;
                    }
                    else
                    {
                        fileStreamVDB.Position = Offsets[CurrentPosition];
                    }
                    ArVDB = new ArchiveSerialization.Archive(fileStreamVDB, ArchiveSerialization.ArchiveOp.store);
                    VDBSerialize(jpeg, ArVDB, fileStreamVDB.Length);

                    if (fileStreamVDB.Length > 1074279092)
                    {
                        this.NumberOfPartition++;
                        RecordVDB = GenerateVDBName(RecordVDI, NumberOfPartition, 1);
                        Offsets[CurrentPosition] = 0;
                    }
                }
            }
            catch { }

            try
            {
                using (FileStream fileStreamVDI = File.OpenWrite(RecordVDI))
                {
                    if (OffsetsVDI.Count == 0)
                    {
                        fileStreamVDI.Position = 0;
                    }
                    else
                    {
                        fileStreamVDI.Position = OffsetsVDI[CurrentPosition - 1];
                    }
                    ArVDI = new ArchiveSerialization.Archive(fileStreamVDI, ArchiveSerialization.ArchiveOp.store);
                    VDISerialize(ArVDI, fileStreamVDI.Length);
                }
            }
            catch { }

            System.Threading.Thread.Sleep((int)FPS);
        }
 private void CreateFile(string Name, TypeofFile typeData)
 {
     File.Create(Name);
     System.Threading.Thread.Sleep(500);
     if (typeData == TypeofFile.VDB)
     {
         using (FileStream fileStreamVDB = File.OpenWrite(RecordVDB))
         {
             ArVDB = new ArchiveSerialization.Archive(fileStreamVDB, ArchiveSerialization.ArchiveOp.store);
             CreateVDBHandle(ArVDB);
         }
     }
 }
예제 #3
0
 private void OpenFile(SGTProduce sgt, string SGTPath)
 {
     try
     {
         string filename = SGTPath;
         using (FileStream fileStream = File.OpenRead(filename))
         {
             ArchiveSerialization.Archive Ar = new ArchiveSerialization.Archive(fileStream, ArchiveSerialization.ArchiveOp.load);
             sgt.Serialize(Ar);
         }
     }
     catch (Exception Ex)
     {
         MessageBox.Show("При загрузке файла произошла ошибка:" + "\n" + Ex.Message);
     }
 }