Esempio n. 1
0
        public void TestAuthentication()
        {
            var handler =
                CommandGenerator
                .CreateAutoCommandHandler <StreamingAuthenticationCommand, StreamingAuthenticationCommand>(
                    new[] { "Username", "Password" }, true);

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.Streaming, helper =>
            {
                var switcher = helper.SdkClient.SdkSwitcher as IBMDSwitcherStreamRTMP;
                Assert.NotNull(switcher);

                AtemState stateBefore = helper.Helper.BuildLibState();

                for (int i = 0; i < 5; i++)
                {
                    string target1 = Randomiser.String(64);
                    string target2 = Randomiser.String(64);
                    stateBefore.Streaming.Authentication.Username = target1;
                    stateBefore.Streaming.Authentication.Password = target2;

                    helper.SendAndWaitForChange(stateBefore, () => { switcher.SetAuthentication(target1, target2); });
                }
            });
        }
        private static void FillRandomData(CameraControlGetCommand cmd, params CameraControlDataType[] omitTypes)
        {
            cmd.Input     = (VideoSource)(Randomiser.RangeInt(20) + 50);
            cmd.Category  = Randomiser.RangeInt(10) + 20;
            cmd.Parameter = Randomiser.RangeInt(10) + 15;

            cmd.Type = Randomiser.EnumValue <CameraControlDataType>(omitTypes);
            switch (cmd.Type)
            {
            case CameraControlDataType.Bool:
                cmd.BoolData = Enumerable.Range(0, Randomiser.RangeInt(8, 8))     // TODO - higher has issues
                               .Select(i => Randomiser.Range(0, 10) >= 5)
                               .ToArray();
                break;

            case CameraControlDataType.SInt8:
                cmd.IntData = Enumerable.Range(0, Randomiser.RangeInt(1, 8))     // TODO - higher has issues
                              .Select(i => Randomiser.RangeInt(sbyte.MinValue, sbyte.MaxValue))
                              .ToArray();
                break;

            case CameraControlDataType.SInt16:
                cmd.IntData = Enumerable.Range(0, Randomiser.RangeInt(1, 4))
                              .Select(i => Randomiser.RangeInt(short.MinValue, short.MaxValue))
                              .ToArray();
                break;

            case CameraControlDataType.SInt32:
                cmd.IntData = Enumerable.Range(0, Randomiser.RangeInt(1, 2))
                              .Select(i => Randomiser.RangeInt(-500000, 500000))
                              .ToArray();
                break;

            case CameraControlDataType.SInt64:
                cmd.LongData = Enumerable.Range(0, 1)
                               .Select(i => (long)Randomiser.RangeInt(-5000000, 5000000))
                               .ToArray();
                break;

            case CameraControlDataType.String:
                cmd.StringData = Randomiser.String(32);
                break;

            case CameraControlDataType.Float:
                cmd.FloatData = Enumerable.Range(0, Randomiser.RangeInt(1, 4))
                                .Select(i => Randomiser.Range(0, 1))
                                .ToArray();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        public void TestFilename()
        {
            var handler = CommandGenerator.CreateAutoCommandHandler <RecordingSettingsSetCommand, RecordingSettingsGetCommand>("Filename");

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.Recording, helper =>
            {
                var switcher = helper.SdkClient.SdkSwitcher as IBMDSwitcherRecordAV;
                Assert.NotNull(switcher);

                AtemState stateBefore = helper.Helper.BuildLibState();

                for (int i = 0; i < 5; i++)
                {
                    string target = Randomiser.String(128);
                    stateBefore.Recording.Properties.Filename = target;

                    helper.SendAndWaitForChange(stateBefore, () => { switcher.SetFilename(target); });
                }
            });
        }
Esempio n. 4
0
        public void TestKey()
        {
            var handler = CommandGenerator.CreateAutoCommandHandler <StreamingServiceSetCommand, StreamingServiceGetCommand>("Key");

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.Streaming, helper =>
            {
                var switcher = helper.SdkClient.SdkSwitcher as IBMDSwitcherStreamRTMP;
                Assert.NotNull(switcher);

                AtemState stateBefore = helper.Helper.BuildLibState();

                for (int i = 0; i < 5; i++)
                {
                    string target = Randomiser.String(512);
                    stateBefore.Streaming.Settings.Key = target;

                    helper.SendAndWaitForChange(stateBefore, () => { switcher.SetKey(target); });
                }
            });
        }
        public void TestDiskName()
        {
            var handler = CommandGenerator.CreateAutoCommandHandler <RecordingStatusSetCommand, RecordingStatusGetCommand>("IsRecording", true);

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.Streaming, helper =>
            {
                var switcher = helper.SdkClient.SdkSwitcher as IBMDSwitcherStreamRTMP;
                Assert.NotNull(switcher);

                AtemState stateBefore = helper.Helper.BuildLibState();

                var cmd = InitDisk(helper, stateBefore);

                for (int i = 0; i < 10; i++)
                {
                    stateBefore.Recording.Disks[cmd.DiskId].VolumeName =
                        cmd.VolumeName = Randomiser.String(64);

                    helper.SendFromServerAndWaitForChange(stateBefore, cmd);
                }
            });
        }
        public void TestClipsInfo()
        {
            AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.HyperDecks, helper =>
            {
                ImmutableList <ICommand> allCommands = helper.Server.GetParsedDataDump();
                List <HyperDeckSettingsGetCommand> settingsCommands = allCommands.OfType <HyperDeckSettingsGetCommand>().ToList();

                foreach (IBMDSwitcherHyperDeck deck in GetHyperDecks(helper))
                {
                    deck.GetId(out long id);
                    HyperDeckSettingsGetCommand cmd = settingsCommands.Single(c => c.Id == id);

                    // Force it to be connected
                    AtemState stateBefore = helper.Helper.BuildLibState();
                    cmd.Status            = HyperDeckConnectionStatus.Connected;
                    stateBefore.Hyperdecks[(int)id].Settings.Status = HyperDeckConnectionStatus.Connected;
                    stateBefore.Hyperdecks[(int)id].Player.State    = HyperDeckPlayerState.Idle;
                    helper.SendFromServerAndWaitForChange(stateBefore, cmd);

                    stateBefore = helper.Helper.BuildLibState();
                    HyperdeckState hyperdeckState = stateBefore.Hyperdecks[(int)id];

                    for (int i = 0; i < 5; i++)
                    {
                        // Change the length
                        var newCmd = new HyperDeckClipCountCommand
                        {
                            Id        = (uint)id,
                            ClipCount = (uint)Randomiser.RangeInt(2, 5)
                        };
                        hyperdeckState.Clips = UpdaterUtil
                                               .CreateList(newCmd.ClipCount, o => new HyperdeckState.ClipState());

                        helper.SendFromServerAndWaitForChange(stateBefore, newCmd, -1, (sdkState, libState) =>
                        {
                            // Sdk likes to randomly give back some stale data, so lets focus on just the length
                            sdkState.Hyperdecks[(int)id].Clips = UpdaterUtil
                                                                 .CreateList((uint)sdkState.Hyperdecks[(int)id].Clips.Count,
                                                                             o => new HyperdeckState.ClipState());
                        });

                        // Now fill in some clip info
                        var infoCmd = new HyperDeckClipInfoCommand
                        {
                            HyperdeckId = (uint)id,
                            ClipId      = 1,
                            Name        = Randomiser.String(64),

                            TimelineStart = new HyperDeckTime
                            {
                                Hour   = (uint)Randomiser.RangeInt(2, 8),
                                Minute = (uint)Randomiser.RangeInt(2, 50),
                                Second = (uint)Randomiser.RangeInt(2, 50),
                                Frame  = (uint)Randomiser.RangeInt(2, 50),
                            },

                            TimelineEnd = new HyperDeckTime
                            {
                                Hour   = (uint)Randomiser.RangeInt(4, 18),
                                Minute = (uint)Randomiser.RangeInt(2, 50),
                                Second = (uint)Randomiser.RangeInt(2, 50),
                                Frame  = (uint)Randomiser.RangeInt(2, 50),
                            },

                            Duration = new HyperDeckTime
                            {
                                Hour   = (uint)Randomiser.RangeInt(10, 20),
                                Minute = (uint)Randomiser.RangeInt(2, 50),
                                Second = (uint)Randomiser.RangeInt(2, 50),
                                Frame  = (uint)Randomiser.RangeInt(2, 50),
                            },
                        };
                        hyperdeckState.Clips[(int)infoCmd.ClipId].Name          = infoCmd.Name;
                        hyperdeckState.Clips[(int)infoCmd.ClipId].Duration      = infoCmd.Duration;
                        hyperdeckState.Clips[(int)infoCmd.ClipId].TimelineStart = infoCmd.TimelineStart;
                        hyperdeckState.Clips[(int)infoCmd.ClipId].TimelineEnd   = infoCmd.TimelineEnd;

                        helper.SendFromServerAndWaitForChange(stateBefore, infoCmd);
                    }
                }
            });
        }