예제 #1
0
        public void TestAttachments()
        {
            var mkvPath = GenerateTempMkvFilePath();

            var config = new DeviceConfiguration
            {
                CameraFps       = FrameRate.Fifteen,
                ColorFormat     = ImageFormat.ColorNV12,
                ColorResolution = ColorResolution.R720p,
                DepthMode       = DepthMode.NarrowView2x2Binned,
            };

            var deviceTimestamp0 = Microseconds64.FromMilliseconds(1.0);
            var deviceTimestamp1 = Microseconds64.FromMilliseconds(7.7);

            var attachment1Name = "\ud182\ud0b5\ud181\ud182 \ud0ba\ud0be\ud0b4\ud0b8\ud180\ud0be\ud0b2\ud0ba\ud0b8";
            var attachment1Data = new byte[] { 1, 255, 0, 8, 7, 254, 128, 3, 127, 65, 179 };

            var attachment2Name = "another_attachment.file";
            var attachment2Data = new byte[] { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250 };

            using (var recorder = new Recorder(mkvPath, null, config))
            {
                recorder.AddAttachment(attachment1Name, attachment1Data);
                recorder.AddAttachment(attachment2Name, attachment2Data);

                recorder.WriteHeader();

                WriteTestCaptures(recorder, deviceTimestamp0, deviceTimestamp1);
            }

            using (var playback = new Playback(mkvPath))
            {
                Assert.IsTrue(playback.TryGetAttachment(attachment1Name, out var data1));
                AssertAreEqual(attachment1Data, data1);

                Assert.IsTrue(playback.TryGetAttachment(attachment2Name, out var data2));
                AssertAreEqual(attachment2Data, data2);

                Assert.IsFalse(playback.TryGetAttachment("some_unknown_attachment_name", out var tmp));
                Assert.IsNull(tmp);
            }

            File.Delete(mkvPath);
        }