public void TestClipFrameUpload() { UploadJobWorker worker = null; AtemMockServerWrapper.Each(_output, _pool, (a, b) => worker?.HandleCommand(a, b), DeviceTestCases.MediaPlayerClips, helper => { helper.DisposeSdkClient = true; IBMDSwitcherMediaPool pool = GetMediaPool(helper); for (int i = 0; i < 3; i++) { AtemState stateBefore = helper.Helper.BuildLibState(); Tuple <uint, uint> resolution = stateBefore.Settings.VideoMode.GetResolution().GetSize(); uint index = Randomiser.RangeInt((uint)stateBefore.MediaPool.Clips.Count); uint frameIndex = Randomiser.RangeInt(stateBefore.MediaPool.Clips[(int)index].MaxFrames); IBMDSwitcherClip clip = GetClip(helper, index); worker = new UploadJobWorker(resolution.Item1 * resolution.Item2 * 4, _output, index + 1, frameIndex, DataTransferUploadRequestCommand.TransferMode.Write); var cb = new LockCallback(); helper.SendAndWaitForChange(stateBefore, () => { clip.Lock(cb); }); Assert.True(cb.Wait.WaitOne(2000)); pool.CreateFrame(_BMDSwitcherPixelFormat.bmdSwitcherPixelFormat10BitYUVA, resolution.Item1, resolution.Item2, out IBMDSwitcherFrame frame); byte[] bytes = MediaPoolUtil.SolidColour(resolution.Item1 * resolution.Item2, 100, 0, 0, 255); MediaPoolUtil.FillSdkFrame(frame, bytes); var clipState = stateBefore.MediaPool.Clips[(int)index]; clipState.Frames[(int)frameIndex].IsUsed = true; //clipState.Audio.Name = name; var uploadCb = new TransferCallback(); clip.AddCallback(uploadCb); clip.UploadFrame(frameIndex, frame); helper.HandleUntil(uploadCb.Wait, 5000); Assert.True(uploadCb.Wait.WaitOne(500)); Assert.Equal(_BMDSwitcherMediaPoolEventType.bmdSwitcherMediaPoolEventTypeTransferCompleted, uploadCb.Result); Assert.Equal(BitConverter.ToString(bytes), BitConverter.ToString(worker.Buffer)); helper.SendAndWaitForChange(stateBefore, () => { clip.Unlock(cb); }); } }); }