Exemplo n.º 1
0
 public void TestRandomStillDownload()
 {
     DoDownload(1, 180000, (width, height) =>
     {
         var bytes = MediaPoolUtil.RandomFrame(width * height);
         return(Tuple.Create(bytes, FrameEncodingUtil.EncodeRLE(bytes)));
     });
 }
Exemplo n.º 2
0
 public void TestBlankStillDownload()
 {
     DoDownload(3, 3000, (width, height) =>
     {
         var bytes = MediaPoolUtil.SolidColour(width * height,
                                               (byte)Randomiser.Range(50, 200), (byte)Randomiser.Range(50, 200),
                                               (byte)Randomiser.Range(50, 200), (byte)Randomiser.Range(50, 200));
         return(Tuple.Create(bytes, FrameEncodingUtil.EncodeRLE(bytes)));
     });
 }
Exemplo n.º 3
0
        public void TestClipFrameDownload()
        {
            DownloadJobWorker 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);

                    {
                        var frameState    = stateBefore.MediaPool.Clips[(int)index].Frames[(int)frameIndex];
                        frameState.IsUsed = true;
                        frameState.Hash   = new byte[16];
                        helper.SendFromServerAndWaitForChange(stateBefore, new MediaPoolFrameDescriptionCommand
                        {
                            Bank     = (MediaPoolFileType)index + 1,
                            Filename = "",
                            Index    = frameIndex,
                            IsUsed   = true
                        });
                    }
                    stateBefore = helper.Helper.BuildLibState();

                    byte[] bytes = new byte[resolution.Item1 * resolution.Item2 * 4];
                    worker       = new DownloadJobWorker(_output, index + 1, frameIndex, FrameEncodingUtil.EncodeRLE(bytes));

                    var cb = new LockCallback();
                    helper.SendAndWaitForChange(stateBefore, () => { clip.Lock(cb); });
                    Assert.True(cb.Wait.WaitOne(2000));

                    var downloadCb = new TransferCallback();
                    clip.AddCallback(downloadCb);
                    clip.DownloadFrame(frameIndex);

                    helper.HandleUntil(downloadCb.Wait, 5000);
                    Assert.True(downloadCb.Wait.WaitOne(500));

                    Assert.Equal(_BMDSwitcherMediaPoolEventType.bmdSwitcherMediaPoolEventTypeTransferCompleted,
                                 downloadCb.Result);
                    Assert.NotNull(downloadCb.Frame);
                    Assert.Null(downloadCb.Audio);

                    byte[] sdkBytes = MediaPoolUtil.GetSdkFrameBytes(downloadCb.Frame);
                    Assert.Equal(BitConverter.ToString(bytes), BitConverter.ToString(sdkBytes));

                    helper.SendAndWaitForChange(stateBefore, () =>
                    {
                        clip.Unlock(cb);
                    });
                }
            });
        }