コード例 #1
0
ファイル: IndexesPacket.cs プロジェクト: windygu/SeecoolCCTV2
 public static byte[] Encode(IndexesPacket data)
 {
     using (MemoryStream ms = new MemoryStream())
     {
         PacketBase.WriteBytes(ms, data.BeginTime);
         PacketBase.WriteBytes(ms, data.EndTime);
         PacketBase.WriteBytes(ms, data.StartIndex);
         return(ms.ToArray());
     }
 }
コード例 #2
0
ファイル: FileManager.cs プロジェクト: windygu/SeecoolCCTV2
        private static List <IndexesPacket> readIndexesDatas(Stream fs)
        {
            List <IndexesPacket> indexesDatas = new List <IndexesPacket>();

            while (fs != null && fs.Position < fs.Length)
            {
                byte[] buffer = readStream(fs);
                var    data   = IndexesPacket.Decode(buffer);
                indexesDatas.Add(data);
            }
            return(indexesDatas);
        }
コード例 #3
0
 private void writeToIndexes(DateTime curTime)
 {
     if (_fsIndexes != null && _keyStartPosition >= 0 && curTime >= _keyStartTime)
     {
         IndexesPacket indexesData = new IndexesPacket(_keyStartTime, curTime, _keyStartPosition);
         byte[]        bytes       = IndexesPacket.Encode(indexesData);
         writeBuffer(_fsIndexes, bytes);
         _keyStartPosition = -1;
         _keyStartTime     = DateTime.MaxValue;
         _fsStream.Flush();
         _fsIndexes.Flush();
     }
 }
コード例 #4
0
ファイル: FolderManager.cs プロジェクト: windygu/SeecoolCCTV2
        /// <summary>
        /// 获取路径下指定时间点对应的视频流信息
        /// </summary>
        /// <param name="path"></param>
        /// <param name="time"></param>
        /// <returns></returns>
        public static VideoStreamsPacket GetVideoStreamsPacket(string path, DateTime time)
        {
            string        indexesFileName = null;
            IndexesPacket indexesPacket   = GetIndexesPacket(path, time, ref indexesFileName);

            if (indexesPacket != null && indexesFileName != null)
            {
                string         videoFile    = GlobalProcess.GetRecFileName(indexesFileName);
                StreamPacket[] streamPacket = FileManager.GetStreamPacket(videoFile, indexesPacket.StartIndex);
                return(new VideoStreamsPacket(indexesPacket, streamPacket));
            }
            Logger.Default.Trace("{0} 未找到 {1} 对应的索引文件! {2}", path, time, indexesFileName);
            return(null);
        }