コード例 #1
0
        private void btReadAll_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string data = null;
                tbData.Text = null;
                string path = tbPath.Text;
                if (!new DirectoryInfo(path).Exists)
                {
                    throw new InvalidDataException("无效的视频路径");
                }
                var packets = FolderManager.GetIndexesPackets(path);
                foreach (var packet in packets)
                {
                    writeLine(string.Format(packet.BeginTime.TimeOfDay + " - " + packet.EndTime.TimeOfDay + " " + packet.StartIndex), ref data);
                    var streams = FolderManager.GetVideoStreamsPacket(path, packet.BeginTime);

                    foreach (var stream in streams.VideoStreams)
                    {
                        writeLine($"{stream.Time.TimeOfDay}\t{stream.Buffer.Length}\t{BitConverter.ToString(stream.Buffer.Take(20).ToArray())}", ref data);
                    }
                }
                tbData.Text = data;
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(ex.Message);
            }
        }
コード例 #2
0
        public void TestDownloadRecorder()
        {
            string path = "D:\\读写测试\\TestDownloadRecorder";

            StreamPacket[] sPackets = Recorder(path);

            VideoStreamsPacket packet = FolderManager.GetVideoStreamsPacket(path, sPackets.First(_ => _.Type == DataType.StreamDataKey).Time.AddSeconds(1));

            Assert.AreEqual(sPackets.First(_ => _.Type == DataType.StreamDataKey).Time, packet.TimePeriod.BeginTime);
            Assert.AreEqual(sPackets.Last().Time.AddSeconds(1), packet.TimePeriod.EndTime);
            Assert.AreEqual(5, packet.VideoStreams.Length);
            for (int i = 0; i < packet.VideoStreams.Length; i++)
            {
                assertAreEqual(sPackets[i + 2], packet.VideoStreams[i]);
            }
            FolderManager.DeleteDirectoryInfo(path);
        }
コード例 #3
0
 private void check(VideoPackageRecorder recorder, bool isInitedVideoBase, bool isDownloaded, int seconds, int length)
 {
     Assert.AreEqual(isInitedVideoBase, recorder.IsInitedVideoBase);
     Assert.AreEqual(isDownloaded, recorder.IsDownloaded);
     Assert.AreEqual(seconds * 100.0 / 120, recorder.Percent);
     TimePeriodPacket[] tpps = recorder.GetDownloadedTimePeriods();
     Assert.AreEqual(length, tpps.Length);
     if (length > 0)
     {
         Assert.AreEqual(begin, tpps[0].BeginTime);
         Assert.AreEqual(begin.AddSeconds(seconds), tpps[0].EndTime);
     }
     if (seconds > 0)
     {
         Assert.IsNotNull(FolderManager.GetVideoStreamsPacket(path, begin.AddSeconds(seconds - 1)));
     }
     if (seconds < 120)
     {
         Assert.AreEqual(begin.AddSeconds(seconds), recorder.ProbeTime);
     }
 }
コード例 #4
0
        /// <summary>获取某通道视频在某时间点对应的视频数据包</summary>
        public static VideoStreamsPacket GetVideoPacket(string videoId, int streamId, DateTime time)
        {
            string path = getPath(videoId, streamId, time);

            return(FolderManager.GetVideoStreamsPacket(path, time));
        }
コード例 #5
0
 public VideoStreamsPacket GetVideoStreamsPacket(DateTime time)
 {
     return(FolderManager.GetVideoStreamsPacket(_path, time));
 }