Example #1
0
        public frmUNIcastStreamer()
        {
            InitializeComponent();

            // Clear sample texts
            lblSubject.Text = String.Empty;
            lblLecturer.Text = String.Empty;
            lblDate.Text = String.Empty;

            // Fix screen position bug
            this.StartPosition = FormStartPosition.CenterScreen;

            // Load settings
            IniFile ini = new IniFile(Path.Combine(Environment.CurrentDirectory, IniFile));
            string str = ini.IniReadValue(Section, KeyStream);
            if (!Address.TryParse(str, out streamAddress))
            {
                streamAddress = DefaultStreamAddress;
                ini.IniWriteValue(Section, KeyStream, streamAddress.ToString());
            }
            str = ini.IniReadValue(Section, KeyMessage);
            if (!Address.TryParse(str, out messageAddress))
            {
                messageAddress = DefaultMessageAddress;
                ini.IniWriteValue(Section, KeyMessage, messageAddress.ToString());
            }

            // Load DeckLink API
            Thread deckLinkStreamerThread = new Thread(() =>
            {
                deckLinkStreamer = new DeckLinkStreamer();

                // Set callback
                deckLinkStreamer.SetCallback(this);

                // Initialise API
                if (!deckLinkStreamer.TryInitializeAPI())
                {
                    deckLinkStreamer.SetCallback(null);
                    MessageBox.Show(strings.errorDeckLinkDriver, strings.error);
                    Environment.Exit(1);
                }

                deckLinkAPIVersion = deckLinkStreamer.DeckLinkAPIVersion;
                lblDeckLinkVersion.InvokeIfRequired(c => c.Text = deckLinkAPIVersion);
            });
            deckLinkStreamerThread.SetApartmentState(ApartmentState.MTA);
            deckLinkStreamerThread.IsBackground = true;
            deckLinkStreamerThread.Start();

            // Initialise variables, load settings
            duration = new TimeSpan(1, 30, 00);
            timeMode = 0;
            timer = new System.Windows.Forms.Timer();
            timer.Tick += timer_Tick;

            tabControl.SelectedIndex = 0;

            progressRing.ProgressPercentage = 0;

            isStreaming = false;

            streamServer = new MulticastServer(streamAddress.IP, streamAddress.Port, TTL);
            messageServer = new MulticastServer(messageAddress.IP, messageAddress.Port, TTL);
            Thread inputMonitorThread = new Thread(() =>
            {
                inputMonitor = new InputMonitor();
                inputMonitor.InputPositionReceived += inputMonitor_InputPositionReceived;
                inputMonitor.Start();
            });
            inputMonitorThread.IsBackground = true;
            inputMonitorThread.Start();

            ffmpeg = new FFmpeg();
            if (ffmpeg.isAvailable)
            {
                //ffmpeg.OnLogDataReceived += ffmpeg_LogDataReceived;
                ffmpegVersion = ffmpeg.GetVersion();
                lblFFmpegVersion.Text = ffmpegVersion;
            }

            pipeHandler = new PipeHandler();
            pipeHandler.ClientConnected += pipeHandler_ClientConnected;
            pipeHandler.ClientDisconnected += pipeHandler_ClientDisconnected;
            //else
            //{
            //    MessageBox.Show(strings.errorFFmpeg, strings.error);
            //    Environment.Exit(1);
            //}

            //performanceMonitor = new PerformanceMonitor(new string[] { "ffmpeg", "BMDStreamingServer", Process.GetCurrentProcess().ProcessName });
            //performanceMonitor.PerfValuesReceived += performanceMonitor_PerfValuesReceived;
            //performanceMonitor.StartMonitoring();

            lblVersion.Text += Application.ProductVersion;

            progressRing.Enabled = true;

            messenger = new frmMessenger();
        }
Example #2
0
 void ffmpeg_LogDataReceived(object sender, FFmpeg.LogDataEventArgs e)
 {
     lblStatsFrame.InvokeIfRequired(c => c.Text = e.frame.ToString());
     lblStatsFps.InvokeIfRequired(c => c.Text = e.fps.ToString());
     lblStatsSize.InvokeIfRequired(c => c.Text = e.size.ToString("N0"));
     lblStatsTime.InvokeIfRequired(c => c.Text = String.Format("{0:hh\\:mm\\:ss\\.ff}", e.time));
     lblStatsBitrate.InvokeIfRequired(c => c.Text = e.bitrate.ToString("N1"));
 }