private void ConnectButton_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor; // Connecting can take some time

            IPAddress[] addresses      = Dns.GetHostAddresses(ServerAddressComboBox.Text);
            IPAddress   selectedAdress = null;

            foreach (IPAddress address in addresses)
            {
                if (address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                {
                    selectedAdress = address;
                }
            }

            if (selectedAdress != null)
            {
                try
                {
                    client = new AmcpClient(new IPEndPoint(selectedAdress, 5250));
                    AmcpRequest  request  = new AmcpRequest(client, "VERSION", 0, 0);
                    AmcpResponse response = request.GetResponse();
                    StatusLabel.Text = "Connected to: " + client.ServerEndPoint.ToString() + ", server version: " + response.Content;

                    string[] ingestDevices = Properties.Settings.Default.IngestDecklinkDevices.Split(',');

                    server = new Server(client, ingestDevices, true);

                    StatusUpdate.Enabled = true;
                    currentPGMChannel    = server.Channels[0];

                    PlaybackName.Text = "IN" + server.Channels[0].Id;
                    (new AmcpRequest(client, "PLAY", 5, 100, "MULTIVIEW\\\\CM" + 1)).GetResponse();
                }
                catch (SocketException se)
                {
                    MessageBox.Show(se.Message, "Network error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            this.Cursor = this.DefaultCursor;
        }
Beispiel #2
0
        public Server(AmcpClient Client, String[] IngestDecklinkDevices, Boolean ChannelGrid = false)
        {
            this.RecordingHeadPositionUpdated   += new OscMessageEvent(Server_RecordingHeadPositionUpdated);
            this.PlayHeadPositionUpdated        += new OscMessageEvent(Server_PlayHeadPositionUpdated);
            this.VirtualPlayHeadPositionUpdated += new OscMessageEvent(Server_VirtualPlayHeadPositionUpdated);

            client = Client;

            channels = new List <Channel>();

            channels.Add(new Channel(1));
            channels.Add(new Channel(2));
            channels.Add(new Channel(3));

            string Channel1FileName = CurrentTimeDate() + "-IN1";
            string Channel2FileName = CurrentTimeDate() + "-IN2";
            string Channel3FileName = CurrentTimeDate() + "-IN3";

            foreach (string Input in IngestDecklinkDevices)
            {
                (new AmcpRequest(client, "PLAY", channels[0], "DECKLINK", Input)).GetResponse();
            }

            (new AmcpRequest(client, "ADD", channels[0], "REPLAY", Channel1FileName)).GetResponse();
            channels[0].Consumer = new ReplayConsumer(Channel1FileName);

            (new AmcpRequest(client, "ADD", channels[1], "REPLAY", Channel2FileName)).GetResponse();
            channels[1].Consumer = new ReplayConsumer(Channel2FileName);

            (new AmcpRequest(client, "ADD", channels[2], "REPLAY", Channel3FileName)).GetResponse();
            channels[2].Consumer = new ReplayConsumer(Channel3FileName);

            channels.Add(new Channel(4));

            Thread.Sleep(250);
            (new AmcpRequest(client, "PLAY", channels[3], Channel1FileName)).GetResponse();

            channels[3].Producer = new ReplayProducer();

            try
            {
                oscListener = new OscListener(6250);
                oscListener.Attach("/channel/1/output/file/frame", RecordingHeadPositionUpdated);
                oscListener.Attach("/channel/2/output/file/frame", RecordingHeadPositionUpdated);
                oscListener.Attach("/channel/3/output/file/frame", RecordingHeadPositionUpdated);


                oscListener.Attach("/channel/4/stage/layer/0/file/frame", PlayHeadPositionUpdated);
                oscListener.Attach("/channel/4/stage/layer/0/file/vframe", VirtualPlayHeadPositionUpdated);
                oscListener.Connect();
            }
            catch (Exception ioe)
            {
                Console.Error.WriteLine(ioe.ToString());
            }


            if (ChannelGrid)
            {
                (new AmcpRequest(client, "CHANNEL_GRID", 0)).NoResponseRequest();
                Thread.Sleep(1000);
                (new AmcpRequest(client, "MIXER", 5, "GRID", "2", "2")).GetResponse();
            }
        }