private void ChannelInformation_Load(object sender, EventArgs e) { _radioButtonDefaultPreset = radioButtonDefaultPreset.Text; if (!MultipleSelection) // one channel { labelChannelName.Text += MyChannel.Name; DGChannel.ColumnCount = 2; // channel info DGChannel.Columns[0].DefaultCellStyle.BackColor = Color.Gainsboro; DGChannel.Rows.Add(AMSExplorer.Properties.Resources.AssetInformation_AssetInformation_Load_Name, MyChannel.Name); DGChannel.Rows.Add("Id", MyChannel.Id); DGChannel.Rows.Add(AMSExplorer.Properties.Resources.AssetInformation_AssetInformation_Load_State, (ChannelState)MyChannel.State); DGChannel.Rows.Add(AMSExplorer.Properties.Resources.AssetInformation_AssetInformation_Load_Created, ((DateTime)MyChannel.Created).ToLocalTime().ToString("G")); DGChannel.Rows.Add(AMSExplorer.Properties.Resources.AssetInformation_AssetInformation_Load_LastModified, ((DateTime)MyChannel.LastModified).ToLocalTime().ToString("G")); DGChannel.Rows.Add(AMSExplorer.Properties.Resources.ChannelInformation_ChannelInformation_Load_Description, MyChannel.Description); DGChannel.Rows.Add(AMSExplorer.Properties.Resources.ChannelInformation_ChannelInformation_Load_InputProtocol, MyChannel.Input.StreamingProtocol); DGChannel.Rows.Add(AMSExplorer.Properties.Resources.ChannelInformation_ChannelInformation_Load_EncodingType, MyChannel.EncodingType); if (MyChannel.Encoding != null) { DGChannel.Rows.Add(AMSExplorer.Properties.Resources.ChannelInformation_ChannelInformation_Load_EncodingSystemPreset, MyChannel.Encoding.SystemPreset); DGChannel.Rows.Add(AMSExplorer.Properties.Resources.ChannelInformation_ChannelInformation_Load_EncodingVideoStreamsCount, MyChannel.Encoding.VideoStreams.Count); DGChannel.Rows.Add(AMSExplorer.Properties.Resources.ChannelInformation_ChannelInformation_Load_EncodingAudioStreamsCount, MyChannel.Encoding.AudioStreams.Count); DGChannel.Rows.Add(AMSExplorer.Properties.Resources.ChannelInformation_ChannelInformation_Load_EncodingAdMarkerSource, (AdMarkerSource)MyChannel.Encoding.AdMarkerSource); if (MyChannel.Slate != null) { DGChannel.Rows.Add(AMSExplorer.Properties.Resources.ChannelInformation_ChannelInformation_Load_DefaultSlateAssetId, MyChannel.Slate.DefaultSlateAssetId); DGChannel.Rows.Add(AMSExplorer.Properties.Resources.ChannelInformation_ChannelInformation_Load_AutomaticSlateInsertionOnADSignal, MyChannel.Slate.InsertSlateOnAdMarker); } else { DGChannel.Rows.Add(AMSExplorer.Properties.Resources.ChannelInformation_ChannelInformation_Load_SlateSettings, AMSExplorer.Properties.Resources.ChannelInformation_ChannelInformation_Load_None); } } if (MyChannel.Input.KeyFrameInterval != null) { DGChannel.Rows.Add(AMSExplorer.Properties.Resources.ChannelInformation_ChannelInformation_Load_InputKeyFrameIntervalS, ((TimeSpan)MyChannel.Input.KeyFrameInterval).TotalSeconds); checkBoxKeyFrameIntDefined.Checked = true; textBoxKeyFrame.Text = ((TimeSpan)MyChannel.Input.KeyFrameInterval).TotalSeconds.ToString(); } string[] stringnameurl = new string[] { AMSExplorer.Properties.Resources.ChannelInformation_ChannelInformation_Load_Primary, AMSExplorer.Properties.Resources.ChannelInformation_ChannelInformation_Load_Secondary }; int i = 0; foreach (var endpoint in MyChannel.Input.Endpoints) { DGChannel.Rows.Add(string.Format(AMSExplorer.Properties.Resources.ChannelInformation_ChannelInformation_Load_0InputURL1, MyChannel.Input.Endpoints.Count == 2 ? stringnameurl[i] : "", endpoint.Protocol), endpoint.Url); if (MyChannel.Input.StreamingProtocol == StreamingProtocol.FragmentedMP4) { DGChannel.Rows.Add(string.Format(AMSExplorer.Properties.Resources.ChannelInformation_ChannelInformation_Load_0InputURL1SSL, MyChannel.Input.Endpoints.Count == 2 ? stringnameurl[i] : "", endpoint.Protocol), endpoint.Url.ToString().Replace("http://", "https://")); } i++; } if (MyChannel.Preview != null) { foreach (var endpoint in MyChannel.Preview.Endpoints) { DGChannel.Rows.Add(string.Format(AMSExplorer.Properties.Resources.ChannelInformation_ChannelInformation_Load_PreviewURL0, endpoint.Protocol), endpoint.Url); } } if (MyChannel.Output != null) { if (MyChannel.Output.Hls != null) { if (MyChannel.Output.Hls.FragmentsPerSegment != null) { DGChannel.Rows.Add(AMSExplorer.Properties.Resources.ChannelInformation_ChannelInformation_Load_OutputHLSFragmentsPerSegment, MyChannel.Output.Hls.FragmentsPerSegment); checkBoxHLSFragPerSeg.Checked = true; numericUpDownHLSFragPerSeg.Value = (int)MyChannel.Output.Hls.FragmentsPerSegment; } } } } else // multiselect { labelChannelName.Text = AMSExplorer.Properties.Resources.ChannelInformation_ChannelInformation_Load_MultipleChannelsHaveBeenSelected; tabControl1.TabPages.Remove(tabPageChannelInfo); // no channel info page tabControl1.TabPages.Remove(tabPagePreview); // no channel info page if (MyChannel.Input.KeyFrameInterval != null) { checkBoxKeyFrameIntDefined.Checked = true; textBoxKeyFrame.Text = ((TimeSpan)MyChannel.Input.KeyFrameInterval).TotalSeconds.ToString(); } if (MyChannel.Output != null) { if (MyChannel.Output.Hls != null) { if (MyChannel.Output.Hls.FragmentsPerSegment != null) { checkBoxHLSFragPerSeg.Checked = true; numericUpDownHLSFragPerSeg.Value = (int)MyChannel.Output.Hls.FragmentsPerSegment; } } } } // comon code - multiselect or only one channel selected // Encoding Settings if (MyChannel.EncodingType != ChannelEncodingType.None) { // default encoding profile name var profileliveselected = AMSEXPlorerLiveProfile.Profiles.Where(p => p.Type == MyChannel.EncodingType).FirstOrDefault(); if (profileliveselected != null) { defaultEncodingPreset = profileliveselected.Name; radioButtonDefaultPreset.Text = string.Format(_radioButtonDefaultPreset, defaultEncodingPreset); } if (MyChannel.Encoding != null && MyChannel.Encoding.SystemPreset != null) { if (MyChannel.Encoding.SystemPreset == defaultEncodingPreset) { radioButtonDefaultPreset.Checked = true; } else { radioButtonCustomPreset.Checked = true; textBoxCustomPreset.Text = MyChannel.Encoding.SystemPreset; } } if (MyChannel.State != ChannelState.Stopped) { groupBoxEncoding.Enabled = false; // encoding settings cannot be edited groupBoxVideoStream.Enabled = false; labelChannelMustBeStopped.Visible = true; labelIndexesChannelMustBeStopped.Visible = true; panelStreamIndexes.Enabled = false; // encoding settings cannot be edited } if (MyChannel.Input.StreamingProtocol != StreamingProtocol.RTPMPEG2TS) { tabControl1.TabPages.Remove(tabPageIndexes); // no rtp channel, no indexes groupBoxVideoStream.Visible = false; } else { numericUpDownVideoStreamIndex.Value = MyChannel.Encoding.VideoStreams != null && MyChannel.Encoding.VideoStreams.FirstOrDefault() != null? MyChannel.Encoding.VideoStreams.FirstOrDefault().Index : 0; Item myitem = new Item("Undefined", "und"); comboBoxAudioLanguageMain.Items.Add(myitem); comboBoxAudioLanguageAddition.Items.Add(myitem); comboBoxAudioLanguageAddition.SelectedItem = myitem; foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.NeutralCultures).OrderBy(c => c.DisplayName)) { myitem = new Item(ci.DisplayName, ci.ThreeLetterISOLanguageName); comboBoxAudioLanguageMain.Items.Add(myitem); comboBoxAudioLanguageAddition.Items.Add(myitem); if (MyChannel.Encoding.AudioStreams.Count > 0 && MyChannel.Encoding.AudioStreams[0].Language == ci.ThreeLetterISOLanguageName) { comboBoxAudioLanguageMain.SelectedItem = myitem; } } if (MyChannel.Encoding.AudioStreams != null && MyChannel.Encoding.AudioStreams.Count > 0) { if (comboBoxAudioLanguageMain.SelectedItem == null) // code which is not in culture list ! { myitem = new Item(MyChannel.Encoding.AudioStreams[0].Language, MyChannel.Encoding.AudioStreams[0].Language); comboBoxAudioLanguageMain.Items.Add(myitem); comboBoxAudioLanguageMain.SelectedItem = myitem; } defaultAudioStreamCode = MyChannel.Encoding.AudioStreams[0].Language; // in order to keep the initial code if needed numericUpDownAudioIndexMain.Value = MyChannel.Encoding.AudioStreams[0].Index; if (MyChannel.Encoding.AudioStreams.Count > 1) { int index = 0; foreach (var audiostream in MyChannel.Encoding.AudioStreams) { if (index > 0) { var language = CultureInfo.GetCultures(CultureTypes.NeutralCultures).Where(c => c.ThreeLetterISOLanguageName == audiostream.Language).FirstOrDefault(); audiostreams.Add(new ExplorerAudioStream() { Language = language != null ? language.DisplayName : audiostream.Language, Index = audiostream.Index, Code = audiostream.Language } ); } index++; } } // let set the next possible index List <int> audioindex = new List <int>() { MyChannel.Encoding.AudioStreams[0].Index }; audioindex.AddRange(MyChannel.Encoding.AudioStreams.Select(a => a.Index).ToList()); int indexAvailable = 0; while (true) { if (!audioindex.Contains(indexAvailable)) { break; } indexAvailable++; } numericUpDownAudioIndexAddition.Value = indexAvailable; } else // no audiostream list ! { defaultAudioStreamCode = null; numericUpDownAudioIndexMain.Value = 0; myitem = new Item("<null>", null); comboBoxAudioLanguageMain.Items.Add(myitem); comboBoxAudioLanguageMain.SelectedItem = myitem; } dataGridViewAudioStreams.DataSource = audiostreams; dataGridViewAudioStreams.DataError += new DataGridViewDataErrorEventHandler(dataGridView_DataError); } UpdateProfileGrids(); } else { tabControl1.TabPages.Remove(tabPageEncoding); // no encoding channel tabControl1.TabPages.Remove(tabPageIndexes); // no encoding channel, no indexes } if (MyChannel.Input.AccessControl != null) { if (MyChannel.Input.AccessControl.IPAllowList != null) { checkBoxInputSet.Checked = true; foreach (var endpoint in MyChannel.Input.AccessControl.IPAllowList) { InputEndpointSettingList.Add(endpoint); } } } dataGridViewInputIP.DataSource = InputEndpointSettingList; dataGridViewInputIP.DataError += new DataGridViewDataErrorEventHandler(dataGridView_DataError); if (MyChannel.Preview != null && MyChannel.Preview.AccessControl != null && MyChannel.Preview.AccessControl.IPAllowList != null) { checkBoxPreviewSet.Checked = true; foreach (var endpoint in MyChannel.Preview.AccessControl.IPAllowList) { PreviewEndpointSettingList.Add(endpoint); } } dataGridViewPreviewIP.DataSource = PreviewEndpointSettingList; dataGridViewPreviewIP.DataError += new DataGridViewDataErrorEventHandler(dataGridView_DataError); if (MyChannel.CrossSiteAccessPolicies != null) { if (MyChannel.CrossSiteAccessPolicies.ClientAccessPolicy != null) { checkBoxclientpolicy.Checked = true; textBoxClientPolicy.Text = MyChannel.CrossSiteAccessPolicies.ClientAccessPolicy; } if (MyChannel.CrossSiteAccessPolicies.CrossDomainPolicy != null) { checkBoxcrossdomains.Checked = true; textBoxCrossDomPolicy.Text = MyChannel.CrossSiteAccessPolicies.CrossDomainPolicy; } } textboxchannedesc.Text = MyChannel.Description; // Channel is not stopped or running. We cannot update settings if (MyChannel.State != ChannelState.Stopped && MyChannel.State != ChannelState.Running) { labelChannelStoppedOrStartedSettings.Visible = true; buttonUpdateClose.Enabled = false; } // let's track when user edit a setting Modifications = new ExplorerChannelModifications { Description = false, AudioStreams = false, ClientAccessPolicy = false, CrossDomainPolicy = false, HLSFragPerSegment = false, InputIPAllowList = false, KeyFrameInterval = false, PreviewIPAllowList = false, SystemPreset = false, VideoStreams = false, }; }
private void ChannelInformation_Load(object sender, EventArgs e) { if (!MultipleSelection) // one channel { labelChannelName.Text += MyChannel.Name; DGChannel.ColumnCount = 2; // channel info DGChannel.Columns[0].DefaultCellStyle.BackColor = Color.Gainsboro; DGChannel.Rows.Add("Name", MyChannel.Name); DGChannel.Rows.Add("Id", MyChannel.Id); DGChannel.Rows.Add("State", (ChannelState)MyChannel.State); DGChannel.Rows.Add("Created", ((DateTime)MyChannel.Created).ToLocalTime().ToString("G")); DGChannel.Rows.Add("Last Modified", ((DateTime)MyChannel.LastModified).ToLocalTime().ToString("G")); DGChannel.Rows.Add("Description", MyChannel.Description); DGChannel.Rows.Add("Input protocol", MyChannel.Input.StreamingProtocol); DGChannel.Rows.Add("Encoding Type", MyChannel.EncodingType); if (MyChannel.Encoding != null) { DGChannel.Rows.Add("Encoding System Preset", MyChannel.Encoding.SystemPreset); DGChannel.Rows.Add("Encoding IgnoreCEA708", MyChannel.Encoding.IgnoreCea708ClosedCaptions); DGChannel.Rows.Add("Encoding Video Streams Count", MyChannel.Encoding.VideoStreams.Count); DGChannel.Rows.Add("Encoding Audio Streams Count", MyChannel.Encoding.AudioStreams.Count); DGChannel.Rows.Add("Encoding Ad Marker Source", (AdMarkerSource)MyChannel.Encoding.AdMarkerSource); if (MyChannel.Slate != null) { DGChannel.Rows.Add("Default Slate Asset Id", MyChannel.Slate.DefaultSlateAssetId); DGChannel.Rows.Add("Automatic Slate Insertion on AD signal", MyChannel.Slate.InsertSlateOnAdMarker); } else { DGChannel.Rows.Add("Slate settings", "(none)"); } } if (MyChannel.Input.KeyFrameInterval != null) { DGChannel.Rows.Add("Input KeyFrameInterval (s)", ((TimeSpan)MyChannel.Input.KeyFrameInterval).TotalSeconds); checkBoxKeyFrameIntDefined.Checked = true; textBoxKeyFrame.Text = ((TimeSpan)MyChannel.Input.KeyFrameInterval).TotalSeconds.ToString(); } string[] stringnameurl = new string[] { "Primary ", "Secondary " }; int i = 0; foreach (var endpoint in MyChannel.Input.Endpoints) { DGChannel.Rows.Add(string.Format("{0}Input URL ({1})", MyChannel.Input.Endpoints.Count == 2 ? stringnameurl[i] : "", endpoint.Protocol), endpoint.Url); if (MyChannel.Input.StreamingProtocol == StreamingProtocol.FragmentedMP4) { DGChannel.Rows.Add(string.Format("{0}Input URL ({1}, SSL)", MyChannel.Input.Endpoints.Count == 2 ? stringnameurl[i] : "", endpoint.Protocol), endpoint.Url.ToString().Replace("http://", "https://")); } i++; } foreach (var endpoint in MyChannel.Preview.Endpoints) { DGChannel.Rows.Add(string.Format("Preview URL ({0})", endpoint.Protocol), endpoint.Url); } if (MyChannel.Output != null) { if (MyChannel.Output.Hls != null) { if (MyChannel.Output.Hls.FragmentsPerSegment != null) { DGChannel.Rows.Add("Output HLS Fragments per segment", MyChannel.Output.Hls.FragmentsPerSegment); checkBoxHLSFragPerSeg.Checked = true; numericUpDownHLSFragPerSeg.Value = (int)MyChannel.Output.Hls.FragmentsPerSegment; } } } } else // multiselect { labelChannelName.Text = "(multiple channels have been selected)"; tabControl1.TabPages.Remove(tabPageChannelInfo); // no channel info page tabControl1.TabPages.Remove(tabPagePreview); // no channel info page if (MyChannel.Input.KeyFrameInterval != null) { checkBoxKeyFrameIntDefined.Checked = true; textBoxKeyFrame.Text = ((TimeSpan)MyChannel.Input.KeyFrameInterval).TotalSeconds.ToString(); } if (MyChannel.Output != null) { if (MyChannel.Output.Hls != null) { if (MyChannel.Output.Hls.FragmentsPerSegment != null) { checkBoxHLSFragPerSeg.Checked = true; numericUpDownHLSFragPerSeg.Value = (int)MyChannel.Output.Hls.FragmentsPerSegment; } } } } // comon code - multiselect or only one channel selected // Encoding Settings if (MyChannel.EncodingType != ChannelEncodingType.None) { // default encoding profile name var profileliveselected = AMSEXPlorerLiveProfile.Profiles.Where(p => p.Type == MyChannel.EncodingType).FirstOrDefault(); if (profileliveselected != null) { defaultEncodingPreset = profileliveselected.Name; radioButtonDefaultPreset.Text = string.Format((radioButtonDefaultPreset.Tag as string), defaultEncodingPreset); } if (MyChannel.Encoding != null && MyChannel.Encoding.SystemPreset != null) { if (MyChannel.Encoding.SystemPreset == defaultEncodingPreset) { radioButtonDefaultPreset.Checked = true; } else { radioButtonCustomPreset.Checked = true; textBoxCustomPreset.Text = MyChannel.Encoding.SystemPreset; } } if (MyChannel.State != ChannelState.Stopped) { groupBoxEncoding.Enabled = false; // encoding settings cannot be edited groupBoxVideoStream.Enabled = false; labelChannelMustBeStopped.Visible = true; labelIndexesChannelMustBeStopped.Visible = true; panelStreamIndexes.Enabled = false; // encoding settings cannot be edited } if (MyChannel.Input.StreamingProtocol != StreamingProtocol.RTPMPEG2TS) { tabControl1.TabPages.Remove(tabPageIndexes); // no rtp channel, no indexes groupBoxVideoStream.Visible = false; } else { numericUpDownVideoStreamIndex.Value = MyChannel.Encoding.VideoStreams != null && MyChannel.Encoding.VideoStreams.FirstOrDefault() != null ? MyChannel.Encoding.VideoStreams.FirstOrDefault().Index : 0; Item myitem = new Item("Undefined", "und"); comboBoxAudioLanguageMain.Items.Add(myitem); comboBoxAudioLanguageAddition.Items.Add(myitem); comboBoxAudioLanguageAddition.SelectedItem = myitem; foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.NeutralCultures).OrderBy(c => c.DisplayName)) { myitem = new Item(ci.DisplayName, ci.ThreeLetterISOLanguageName); comboBoxAudioLanguageMain.Items.Add(myitem); comboBoxAudioLanguageAddition.Items.Add(myitem); if (MyChannel.Encoding.AudioStreams.Count > 0 && MyChannel.Encoding.AudioStreams[0].Language == ci.ThreeLetterISOLanguageName) { comboBoxAudioLanguageMain.SelectedItem = myitem; } } if (MyChannel.Encoding.AudioStreams != null && MyChannel.Encoding.AudioStreams.Count > 0) { if (comboBoxAudioLanguageMain.SelectedItem == null) // code which is not in culture list ! { myitem = new Item(MyChannel.Encoding.AudioStreams[0].Language, MyChannel.Encoding.AudioStreams[0].Language); comboBoxAudioLanguageMain.Items.Add(myitem); comboBoxAudioLanguageMain.SelectedItem = myitem; } defaultAudioStreamCode = MyChannel.Encoding.AudioStreams[0].Language; // in order to keep the initial code if needed numericUpDownAudioIndexMain.Value = MyChannel.Encoding.AudioStreams[0].Index; if (MyChannel.Encoding.AudioStreams.Count > 1) { int index = 0; foreach (var audiostream in MyChannel.Encoding.AudioStreams) { if (index > 0) { var language = CultureInfo.GetCultures(CultureTypes.NeutralCultures).Where(c => c.ThreeLetterISOLanguageName == audiostream.Language).FirstOrDefault(); audiostreams.Add(new ExplorerAudioStream() { Language = language != null ? language.DisplayName : audiostream.Language, Index = audiostream.Index, Code = audiostream.Language } ); } index++; } } // let set the next possible index List<int> audioindex = new List<int>() { MyChannel.Encoding.AudioStreams[0].Index }; audioindex.AddRange(MyChannel.Encoding.AudioStreams.Select(a => a.Index).ToList()); int indexAvailable = 0; while (true) { if (!audioindex.Contains(indexAvailable)) { break; } indexAvailable++; } numericUpDownAudioIndexAddition.Value = indexAvailable; } else // no audiostream list ! { defaultAudioStreamCode = null; numericUpDownAudioIndexMain.Value = 0; myitem = new Item("<null>", null); comboBoxAudioLanguageMain.Items.Add(myitem); comboBoxAudioLanguageMain.SelectedItem = myitem; } dataGridViewAudioStreams.DataSource = audiostreams; dataGridViewAudioStreams.DataError += new DataGridViewDataErrorEventHandler(dataGridView_DataError); } UpdateProfileGrids(); } else { tabControl1.TabPages.Remove(tabPageEncoding); // no encoding channel tabControl1.TabPages.Remove(tabPageIndexes); // no encoding channel, no indexes } if (MyChannel.Input.AccessControl != null) { if (MyChannel.Input.AccessControl.IPAllowList != null) { checkBoxInputSet.Checked = true; foreach (var endpoint in MyChannel.Input.AccessControl.IPAllowList) { InputEndpointSettingList.Add(endpoint); } } } dataGridViewInputIP.DataSource = InputEndpointSettingList; dataGridViewInputIP.DataError += new DataGridViewDataErrorEventHandler(dataGridView_DataError); if (MyChannel.Preview.AccessControl != null) { if (MyChannel.Preview.AccessControl.IPAllowList != null) { checkBoxPreviewSet.Checked = true; foreach (var endpoint in MyChannel.Preview.AccessControl.IPAllowList) { PreviewEndpointSettingList.Add(endpoint); } } } dataGridViewPreviewIP.DataSource = PreviewEndpointSettingList; dataGridViewPreviewIP.DataError += new DataGridViewDataErrorEventHandler(dataGridView_DataError); if (MyChannel.CrossSiteAccessPolicies != null) { if (MyChannel.CrossSiteAccessPolicies.ClientAccessPolicy != null) { checkBoxclientpolicy.Checked = true; textBoxClientPolicy.Text = MyChannel.CrossSiteAccessPolicies.ClientAccessPolicy; } if (MyChannel.CrossSiteAccessPolicies.CrossDomainPolicy != null) { checkBoxcrossdomains.Checked = true; textBoxCrossDomPolicy.Text = MyChannel.CrossSiteAccessPolicies.CrossDomainPolicy; } } textboxchannedesc.Text = MyChannel.Description; // Channel is not stopped or running. We cannot update settings if (MyChannel.State != ChannelState.Stopped && MyChannel.State != ChannelState.Running) { labelChannelStoppedOrStartedSettings.Visible = true; buttonUpdateClose.Enabled = false; } // let's track when user edit a setting Modifications = new ExplorerChannelModifications { Description = false, AudioStreams = false, ClientAccessPolicy = false, CrossDomainPolicy = false, HLSFragPerSegment = false, InputIPAllowList = false, KeyFrameInterval = false, PreviewIPAllowList = false, SystemPreset = false, VideoStreams = false }; }