Example #1
0
        public void ReloadVideoTasks()
        {
            ConfigurationManager.RefreshSection("appSettings");

            var appSettings = ConfigurationManager.AppSettings;
            var allKeys     = appSettings.AllKeys;

            if (allKeys.Contains("VideoPublishTasks"))
            {
                m_VideoOutputTaskGroup = JsonConvert.DeserializeObject <VideoOutputTaskGroup>(appSettings["VideoPublishTasks"].ToString());
            }

            olvVideoTasks.SetObjects(m_VideoOutputTaskGroup.Tasks);
            olvVideoTasks.Refresh();
        }
Example #2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            rbtnFromDevice.Checked    = false;
            cbbCams.Enabled           = false;
            cbbMics.Enabled           = false;
            rbtnFromUrl.Checked       = true;
            edtVideoUrlSource.Enabled = true;
            edtAudioUrlSource.Enabled = true;

            btnStart.Enabled = true;
            btnStop.Enabled  = true;

            bool needAudio = false;

            var appSettings = ConfigurationManager.AppSettings;
            var allKeys     = appSettings.AllKeys;

            if (allKeys.Contains("EncoderAAC"))
            {
                m_EncoderAAC = appSettings["EncoderAAC"];
            }

            if (allKeys.Contains("MaxRecvIdleSeconds"))
            {
                int maxIdleTime = 0;
                if (Int32.TryParse(appSettings["MaxRecvIdleSeconds"].ToString(), out maxIdleTime))
                {
                    m_MaxRecvIdleSeconds = maxIdleTime > 0 ? maxIdleTime : 0;
                }
            }

            int interval = 0;

            if (allKeys.Contains("AutoRestartInterval"))
            {
                int.TryParse(appSettings["AutoRestartInterval"], out interval);
            }
            if (interval > 0)
            {
                timerRestartVideo.Interval = 1000 * interval;
                timerRestartAudio.Interval = 1000 * interval;
                ckbAutoRestart.Checked     = true;
                ckbAutoRestart.Enabled     = true;

                if (interval <= 1)
                {
                    lblRestartInterval.Text = "(restart in 1 second once stopped)";
                }
                else
                {
                    lblRestartInterval.Text = "(restart in " + interval + " seconds once stopped)";
                }
            }
            else
            {
                timerRestartVideo.Interval = 100;
                timerRestartAudio.Interval = 100;
                ckbAutoRestart.Checked     = false;
                ckbAutoRestart.Enabled     = false;

                lblRestartInterval.Text = "(disabled)";
            }

            if (allKeys.Contains("VideoDeviceParam"))
            {
                edtVideoOption.Text = appSettings["VideoDeviceParam"];
            }
            if (allKeys.Contains("AudioDeviceParam"))
            {
                edtAudioOption.Text = appSettings["AudioDeviceParam"];
            }

            if (allKeys.Contains("VideoDeviceName"))
            {
                m_DefaultVideoDeviceName = appSettings["VideoDeviceName"];
            }
            if (allKeys.Contains("AudioDeviceName"))
            {
                m_DefaultAudioDeviceName = appSettings["AudioDeviceName"];
            }

            if (allKeys.Contains("VideoPublishTasks"))
            {
                m_VideoOutputTaskGroup = JsonConvert.DeserializeObject <VideoOutputTaskGroup>(appSettings["VideoPublishTasks"].ToString());
            }

            if (allKeys.Contains("AudioPublishTasks"))
            {
                m_AudioOutputTaskGroup = JsonConvert.DeserializeObject <AudioOutputTaskGroup>(appSettings["AudioPublishTasks"].ToString());
            }

            if (allKeys.Contains("VideoUrlSource"))
            {
                edtVideoUrlSource.Text = appSettings["VideoUrlSource"];
            }
            if (allKeys.Contains("AudioUrlSource"))
            {
                edtAudioUrlSource.Text = appSettings["AudioUrlSource"];
            }

            if (allKeys.Contains("EnableAudio"))
            {
                needAudio = Convert.ToBoolean(appSettings["EnableAudio"]);
            }

            needAudio = true; // always enable audio ...

            cbbMics.Visible     = needAudio;
            gbAudioTask.Enabled = needAudio;

            if (!needAudio)
            {
                cbbCams.Width             = edtVideoUrlSource.Width;
                edtAudioUrlSource.Text    = "";
                edtAudioUrlSource.Enabled = false;
                edtAudioUrlSource.Visible = false;
            }

            olvVideoTasks.SetObjects(m_VideoOutputTaskGroup.Tasks);
            olvAudioTasks.SetObjects(m_AudioOutputTaskGroup.Tasks);

            notifyIconMain.Icon = notifyIconStop.Icon;
            notifyIconMain.Text = this.Text + " (" + notifyIconStop.Text + ")";

            if (m_DefaultVideoDeviceName.Length > 0 || m_DefaultAudioDeviceName.Length > 0)
            {
                gbAction.Enabled      = false;
                gbMediaSource.Enabled = false;
                timerAutoSet.Enabled  = true;
            }
            else
            {
                gbAction.Enabled      = true;
                gbMediaSource.Enabled = true;
                timerAutoSet.Enabled  = false;
            }

            m_UpdatedUI4Start = true;
        }