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;
        }
Esempio n. 2
0
        private void UpdateStatus()
        {
            while (!this.shutDown)
            {
                Channel latestChannel = channels[0];
                foreach (Channel channel in channels)
                {
                    AmcpResponse channelInfo = (new AmcpRequest(client, "INFO", channel)).GetResponse();
                    XmlDocument  status      = new XmlDocument();
                    status.LoadXml(channelInfo.Content);
                    XmlNodeList consumerNodes = status.GetElementsByTagName("consumer");
                    if (consumerNodes.Count > 0)
                    {
                        XmlNode consumerNode = consumerNodes[0];
                        foreach (XmlNode node in consumerNode.ChildNodes)
                        {
                            if (node.LocalName == "recording-head")
                            {
                                if (channel.Consumer != null)
                                {
                                    channel.Consumer.recordingHead = ulong.Parse(node.InnerText);
                                    if (latestChannel.Consumer.recordingHead > channel.Consumer.recordingHead)
                                    {
                                        latestChannel = channel;
                                    }
                                }
                            }
                        }
                    }
                    XmlNodeList foregroundProducerNodes = status.GetElementsByTagName("foreground");
                    if (foregroundProducerNodes.Count > 0)
                    {
                        foreach (XmlNode producerNode in foregroundProducerNodes[0].ChildNodes)
                        {
                            foreach (XmlNode node in producerNode.ChildNodes)
                            {
                                if (node.LocalName == "play-head")
                                {
                                    if (channel.Producer != null)
                                    {
                                        try
                                        {
                                            channel.Producer.playbackHead = ulong.Parse(node.InnerText);
                                        }
                                        catch (ArgumentOutOfRangeException aoore)
                                        {
                                        }
                                    }
                                }
                            }
                        }
                    }
                    XmlNodeList backgroundProducerNodes = status.GetElementsByTagName("background");
                    if (backgroundProducerNodes.Count > 0)
                    {
                        foreach (XmlNode producerNode in backgroundProducerNodes[0].ChildNodes)
                        {
                            foreach (XmlNode node in producerNode.ChildNodes)
                            {
                                if (node.LocalName == "type")
                                {
                                    if (node.InnerText == "empty-producer")
                                    {
                                        channel.hasNext = false;
                                    }
                                    else
                                    {
                                        channel.hasNext = true;
                                    }
                                }
                            }
                        }
                    }
                }

                foreach (Channel channel in channels)
                {
                    if (channel.Consumer != null)
                    {
                        channel.Consumer.Offset = (int)channel.Consumer.recordingHead - (int)latestChannel.Consumer.recordingHead;
                    }
                }

                if (latestChannel.Consumer != null)
                {
                    currentFrameInput = latestChannel.Consumer.recordingHead;
                }
                else
                {
                    currentFrameInput = 0;
                }

                Thread.Sleep(100);
            }
        }