public void TestFolderManager_GetVideoHeader()
        {
            Assert.IsNull(FolderManager.GetVideoHeader("", DateTime.MinValue, DateTime.MaxValue));
            Assert.IsNull(FolderManager.GetVideoHeader(@"D:\视频录像\videoId_2\", DateTime.MinValue, DateTime.MaxValue));
            DateTime start = new DateTime(2016, 3, 22, 23, 51, 01, 156);

            Assert.IsNull(FolderManager.GetVideoHeader(@"D:\视频录像\videoId_2\2016\03\22", start.Subtract(TimeSpan.FromMinutes(5)), start));
            Assert.IsNotNull(FolderManager.GetVideoHeader(@"D:\视频录像\videoId_2\2016\03\22", start, start.AddMinutes(3)));
        }
Beispiel #2
0
        /// <summary>获取某通道视频在某时段对应文件的首个视频头</summary>
        public static VideoBasePacket GetVideoBaseInfom(string videoId, int streamId, DateTime beginTime, DateTime endTime)
        {
            string path = GlobalData.VideoPath(videoId, streamId);

            DateTime[] dates = GetFolderPaths(videoId, streamId, beginTime, endTime);
            foreach (var date in dates)
            {
                var header = FolderManager.GetVideoHeader(Path.Combine(path, GlobalProcess.FolderPath(date)), beginTime, endTime);
                if (header != null && header.Type == DataType.SysHead)
                {
                    long length = getLength(path, dates, beginTime, endTime, StreamPacket.Encode(header).Length + 4);
                    return(new VideoBasePacket(header.Buffer, header.Time, length));
                }
            }
            return(null);
        }