// wizardPageChannelNumber private void InitChannelNumberingRecursedTree(ChannelFolder channelFolder) { foreach (Channel channel in channelFolder.ChannelList) { ListViewItem lvi = new ListViewItem(channel.Name); lvi.IndentCount = currentChannelIndentation; lvi.Tag = channel; mapChannelsIndentation[lvi] = currentChannelIndentation; if (channel is ChannelTV) { ChannelTV channelTV = channel as ChannelTV; lvi.SubItems.Add(channelTV.ChannelNumber.ToString()); maxChannelNumber = Math.Max(maxChannelNumber, channelTV.ChannelNumber); lvi.ImageKey = (MainForm.imageListLogoTV.Images.ContainsKey(channelTV.Logo) ? channelTV.Logo : "LogoTVDefault"); this.listViewChannelNumbering.Items.Add(lvi); } else if (channel is ChannelFolder) { this.listViewChannelNumbering.Items.Add(lvi); lvi.ImageKey = "FolderClosed"; currentChannelIndentation++; InitChannelNumberingRecursedTree(channel as ChannelFolder); currentChannelIndentation--; } } }
private void treeViewChannel_DoubleClick(object sender, EventArgs e) { if (this.treeViewChannel.SelectedNode != null && this.treeViewChannel.SelectedNode.Tag is ChannelTV) { ChannelTV channel = this.treeViewChannel.SelectedNode.Tag as ChannelTV; MainForm.TuneChannelGUI((Channel)channel); } }
private void rebuildTheGraphAndTuneToolStripMenuItem_Click(object sender, EventArgs e) { if (this.treeViewChannel.SelectedNode != null && this.treeViewChannel.SelectedNode.Tag is ChannelTV) { ChannelTV channel = this.treeViewChannel.SelectedNode.Tag as ChannelTV; MainForm.TuneChannelGUI((Channel)channel, true); } }
private void switchOnToolStripMenuItem_Click(object sender, EventArgs e) { if (this.treeViewChannel.SelectedNode != null && this.treeViewChannel.SelectedNode.Tag is ChannelTV) { ChannelTV channel = this.treeViewChannel.SelectedNode.Tag as ChannelTV; MainForm.TuneChannelGUI((Channel)channel); } }
void channelToolStripMenuItem_Click(object sender, EventArgs e) { ToolStripMenuItem toolStripMenuItem = sender as ToolStripMenuItem; if (toolStripMenuItem.Tag is ChannelTV) { ChannelTV channel = toolStripMenuItem.Tag as ChannelTV; this.propertyGridChannel.SelectedObject = channel; } }
private void UpdateChannelNumbering() { foreach (ListViewItem lvi in listViewChannelNumbering.Items) { if (lvi.Tag is ChannelTV) { ChannelTV channelTV = lvi.Tag as ChannelTV; channelTV.ChannelNumber = short.Parse(lvi.SubItems[1].Text); } } MainForm.UpdateChannelNumber(); }
public virtual bool NeedToRebuildTheGraph(Channel newChannel) { if (!(newChannel is ChannelTV) || !(this.currentChannel is ChannelTV)) { return(true); } ChannelTV channelNew = newChannel as ChannelTV; ChannelTV channelCurrent = this.currentChannel as ChannelTV; return(channelCurrent.NeedToRebuildTheGraph(channelNew)); }
private void CopyChannelToDestinationFolder() { if (radioButtonAddThisChannel.Checked) { ChannelFolder channelFolder = textBoxFolderDestinationName.Tag as ChannelFolder; if (channelFolder != null) { ChannelTV channelTV = this.propertyGridChannel.SelectedObject as ChannelTV; if (channelTV != null) { MainForm.panelChannel.AddChannelToFavorite(channelFolder, new Channel[] { channelTV }); } } } else if (radioButtonScanFrequency.Checked) { ChannelFolder channelFolder = textBoxFolderDestinationName.Tag as ChannelFolder; if (channelFolder != null) { List <Channel> al = new List <Channel>(); foreach (ListViewItem lvi in this.listViewScanResult.SelectedItems) { al.Add((lvi.Tag as Channel).MakeCopy()); } if (al.Count > 0) { al.Sort(delegate(Channel x, Channel y) { short xOrder = short.MaxValue, yOrder = short.MaxValue; if (x is ChannelTV) { xOrder = (x as ChannelTV).ChannelNumber; if (xOrder <= 0) { xOrder = short.MaxValue - 1; } } if (y is ChannelTV) { yOrder = (y as ChannelTV).ChannelNumber; if (yOrder <= 0) { yOrder = short.MaxValue - 1; } } return(xOrder.CompareTo(yOrder)); }); MainForm.panelChannel.AddChannelToFavorite(channelFolder, (Channel[])al.ToArray()); } } } MainForm.UpdateChannelNumber(); }
// wizardPageScanner private void InitializeWizardPageScanner() { ChannelTV channelTV = this.propertyGridChannel.SelectedObject as ChannelTV; if (channelTV != null) { switch (channelTV.TunerType) { case TunerType.DVBT: this.currentFrequencies = TransponderReader.GetFrequencies(TunerType.DVBT); break; case TunerType.DVBC: this.currentFrequencies = TransponderReader.GetFrequencies(TunerType.DVBC); break; case TunerType.DVBS: this.currentFrequencies = TransponderReader.GetFrequencies(TunerType.DVBS); break; case TunerType.Analogic: this.currentFrequencies = TransponderReader.GetFrequencies(TunerType.Analogic); break; } if (this.currentFrequencies != null) { this.comboBoxScanCountry.Items.Clear(); if (this.currentFrequencies != null) { foreach (string country in this.currentFrequencies.Keys) { this.comboBoxScanCountry.Items.Add(country); } } if (this.comboBoxScanCountry.Items.Count > 0) { this.comboBoxScanCountry.SelectedIndex = 0; } this.tabControlScanner.Enabled = true; } else { this.comboBoxScanCountry.Items.Clear(); this.comboBoxScanRegion.Items.Clear(); this.tabControlScanner.Enabled = false; } } }
private bool ScanProbeFrequency(ChannelTV currentChannelTV, bool needRebuild) { this.propertyGridChannel.SelectedObject = currentChannelTV; Application.DoEvents(); MainForm.videoControl.BackColor = Color.Transparent; try { MainForm.TuneChannel(currentChannelTV, needRebuild); needRebuild = false; textBoxScanStatus.Text = Properties.Resources.Scanning; if (currentChannelTV is ChannelDVB) { textBoxScanFrequency.Text = string.Format(Properties.Resources.ScanningFrequency, (currentChannelTV as ChannelDVB).Frequency); } else if (currentChannelTV is ChannelAnalogic) { textBoxScanFrequency.Text = string.Format(Properties.Resources.ScanningChannel, (currentChannelTV as ChannelAnalogic).Channel); } } catch (Exception ex) { Trace.WriteLineIf(MainForm.trace.TraceError, ex.ToString()); textBoxScanStatus.Text = Properties.Resources.Error + " " + ex.Message; textBoxScanFrequency.Text = Properties.Resources.ScanningError; MainForm.videoControl.BackColor = MainForm.Settings.VideoBackgroundColor; } if (currentChannelTV is ChannelDVB) { if (MainForm.GraphBuilder is IBDA) { IBDA graphBuilderBDA = MainForm.GraphBuilder as IBDA; bool locked, present; int strength, quality; System.Threading.Thread.Sleep(500); if ((graphBuilderBDA as ITV).GetSignalStatistics(out locked, out present, out strength, out quality)) { if (locked && present) { IMpeg2Data mpeg2Data = graphBuilderBDA.SectionsAndTables as IMpeg2Data; short originalNetworkId = -1; Hashtable serviceNameByServiceId = new Hashtable(); // Hervé Stalin : Ajout d'une hashtable pour le services_type d'un service Hashtable serviceTypeByServiceID = new Hashtable(); PSISection[] psiSdts = PSISection.GetPSITable((int)PIDS.SDT, (int)TABLE_IDS.SDT_ACTUAL, mpeg2Data); for (int i = 0; i < psiSdts.Length; i++) { PSISection psiSdt = psiSdts[i]; if (psiSdt != null && psiSdt is PSISDT) { PSISDT sdt = (PSISDT)psiSdt; Trace.WriteLineIf(MainForm.trace.TraceVerbose, "PSI Table " + i + "/" + psiSdts.Length + "\r\n"); Trace.WriteLineIf(MainForm.trace.TraceVerbose, sdt.ToString()); originalNetworkId = (short)sdt.OriginalNetworkId; foreach (PSISDT.Data service in sdt.Services) { serviceNameByServiceId[service.ServiceId] = service.GetServiceName(); //Hervé Stalin : remplissage du hashtable du service_type serviceTypeByServiceID[service.ServiceId] = service.GetServiceType(); } } } //Hervé Stalin : Code pode pour créér un hashtable de lcn Hashtable logicalChannelNumberByServiceId = new Hashtable(); PSISection[] psiNits = PSISection.GetPSITable((int)PIDS.NIT, (int)TABLE_IDS.NIT_ACTUAL, mpeg2Data); for (int i = 0; i < psiNits.Length; i++) { PSISection psinit = psiNits[i]; if (psinit != null && psinit is PSINIT) { PSINIT nit = (PSINIT)psinit; Trace.WriteLineIf(MainForm.trace.TraceVerbose, "PSI Table " + i + "/" + psiNits.Length + "\r\n"); Trace.WriteLineIf(MainForm.trace.TraceVerbose, nit.ToString()); foreach (PSINIT.Data data in nit.Streams) { foreach (PSIDescriptor psiDescriptorData in data.Descriptors) { if (psiDescriptorData.DescriptorTag == DESCRIPTOR_TAGS.DESCR_LOGICAL_CHANNEL) { PSIDescriptorLogicalChannel psiDescriptorLogicalChannel = (PSIDescriptorLogicalChannel)psiDescriptorData; foreach (PSIDescriptorLogicalChannel.ChannelNumber f in psiDescriptorLogicalChannel.LogicalChannelNumbers) { logicalChannelNumberByServiceId[f.ServiceID] = f.LogicalChannelNumber; } } } } } } PSISection[] psis = PSISection.GetPSITable((int)PIDS.PAT, (int)TABLE_IDS.PAT, mpeg2Data); for (int i = 0; i < psis.Length; i++) { PSISection psi = psis[i]; if (psi != null && psi is PSIPAT) { PSIPAT pat = (PSIPAT)psi; Trace.WriteLineIf(MainForm.trace.TraceVerbose, "PSI Table " + i + "/" + psis.Length + "\r\n"); Trace.WriteLineIf(MainForm.trace.TraceVerbose, pat.ToString()); ChannelDVB newTemplateChannelDVB = (MainForm.GraphBuilder as ITV).CurrentChannel.MakeCopy() as ChannelDVB; newTemplateChannelDVB.ONID = originalNetworkId; newTemplateChannelDVB.TSID = pat.TransportStreamId; foreach (PSIPAT.Data program in pat.ProgramIds) { if (!program.IsNetworkPID) // Hervé Stalin : est encore utile ? { //Hervé Stalin: discrimination par le service type SERVICE_TYPES st; try { st = (SERVICE_TYPES)serviceTypeByServiceID[program.ProgramNumber]; } catch { st = SERVICE_TYPES.DIGITAL_TELEVISION_SERVICE; // bypass en cas de probleme de parsing (mauvaise réception dans mon cas) } if (st == SERVICE_TYPES.DIGITAL_TELEVISION_SERVICE || // TV SD MPEG2 st == SERVICE_TYPES.ADVANCE_CODEC_HD_DIGITAL_SERVICE || // TV HD H264 st == SERVICE_TYPES.ADVANCE_CODEC_SD_DIGITAL_SERVICE || // TV SD H264 st == SERVICE_TYPES.MPEG2_HD_DIGITAL_TELEVISION_SERVICE || // TV HD MPEG2 st == SERVICE_TYPES.DIGITAL_RADIO_SOUND_SERVICE || // Radio MP2 st == SERVICE_TYPES.ADVANCED_CODEC_DIGITAL_RADIO_SOUND_SERVICE || // Radio AC3/E-AC3/AAC st == SERVICE_TYPES.MOSAIC_SERVICE || // Mosaic MPEG2 st == SERVICE_TYPES.ADVANCED_CODEC_MOSAIC_SERVICE) // Mosaic H264 { ChannelDVB newChannelDVB = newTemplateChannelDVB.MakeCopy() as ChannelDVB; newChannelDVB.SID = program.ProgramNumber; newChannelDVB.Name = (string)serviceNameByServiceId[program.ProgramNumber]; //Hervé Stalin: ajout du LCN newChannelDVB.ChannelNumber = Convert.ToInt16(logicalChannelNumberByServiceId[program.ProgramNumber]); if (newChannelDVB.Name == null) { newChannelDVB.Name = Properties.Resources.NoName; } UpdateDVBChannelPids(mpeg2Data, program.Pid, newChannelDVB); ListViewItem lvi = new ListViewItem(newChannelDVB.Name, "LogoTVDefault"); lvi.SubItems.Add(newChannelDVB.Frequency.ToString()); lvi.SubItems.Add(newChannelDVB.ChannelNumber.ToString()); lvi.Tag = newChannelDVB; //this.listViewScanResult.SmallImageList = MainForm.imageListLogoTV; this.listViewScanResult.Items.Add(lvi); this.buttonScanClear.Enabled = true; try { var extensions = new HashSet <string>(StringComparer.OrdinalIgnoreCase) { ".gif", ".png", ".jpg", ".jpeg", ".bmp" }; //var files = Directory.EnumerateFiles(@".\Logos\", "*"); var files = Directory.GetFiles(@".\Logos\", "*"); foreach (var logo in files) { string extension = Path.GetExtension(logo).ToLowerInvariant(); if (extensions.Contains(extension)) { string filename = Path.GetFileNameWithoutExtension(logo).ToLowerInvariant(); if (newChannelDVB.Name.ToLowerInvariant().IndexOf(filename) != -1) { newChannelDVB.Logo = logo; //MainForm.panelChannel.AdjustTVLogo(newChannelDVB); if (MainForm.imageListLogoTV.Images.ContainsKey(logo)) { lvi.ImageKey = logo; } else { try { string path = FileUtils.GetAbsolutePath(logo); if (File.Exists(path)) { Bitmap bitmap = new Bitmap(path); //if (!Bitmap.IsAlphaPixelFormat(bitmap.PixelFormat)) // bitmap.MakeTransparent(Color.White); Image thumbnail = Utils.ResizeImage(bitmap, 16, 16, false); MainForm.imageListLogoTV.Images.Add(logo, thumbnail); lvi.ImageKey = logo; thumbnail.Dispose(); bitmap.Dispose(); break; } } catch (ArgumentException) { } } } } } } catch (Exception) { } //PSISection[] psis2 = PSISection.GetPSITable(program.Pid, (int)TABLE_IDS.PMT, mpeg2Data); //for (int i2 = 0; i2 < psis2.Length; i2++) //{ // PSISection psi2 = psis2[i2]; // if (psi2 != null && psi2 is PSIPMT) // { // PSIPMT pmt = (PSIPMT)psi2; // Trace.WriteLineIf(trace.TraceVerbose, "PSI Table " + i2 + "/" + psis2.Length + "\r\n"); // Trace.WriteLineIf(trace.TraceVerbose, pmt.ToString()); // } //} } } } Application.DoEvents(); } } } } } } else if (currentChannelTV is ChannelAnalogic) { GraphBuilderWDM graphBuilderWDM = MainForm.GraphBuilder as GraphBuilderWDM; if (graphBuilderWDM.CurrentChannel != null) { bool locked, present; int strength, quality; if (graphBuilderWDM.GetSignalStatistics(out locked, out present, out strength, out quality)) { if (locked && present) { ChannelAnalogic newChannel = graphBuilderWDM.CurrentChannel.MakeCopy() as ChannelAnalogic; newChannel.Name = Properties.Resources.NewChannelName + " " + newChannel.Channel.ToString(); ListViewItem lvi = new ListViewItem(newChannel.Name, "LogoTVDefault"); lvi.SubItems.Add(newChannel.Channel.ToString()); lvi.Tag = newChannel; this.listViewScanResult.Items.Add(lvi); this.buttonScanClear.Enabled = true; } } } } return(needRebuild); }
private void buttonScanChannels_Click(object sender, EventArgs e) { if (this.propertyGridChannel.SelectedObject != null && this.propertyGridChannel.SelectedObject is ChannelTV) { MainForm.ClearGraph(); this.continueScanning = true; this.buttonScanChannels.Enabled = false; this.buttonScanStop.Enabled = true; ChannelTV templateChannelTV = this.propertyGridChannel.SelectedObject as ChannelTV; ChannelTV currentChannelTV; bool needRebuild = true; if (templateChannelTV is ChannelDVB) { if (this.tabControlScanner.SelectedTab == this.tabPageScanPredefined) { List <string> region; if (this.currentCountries.TryGetValue((string)this.comboBoxScanRegion.SelectedItem, out region)) { foreach (string currentFrequency in region) { if (!continueScanning) { break; } currentChannelTV = templateChannelTV.MakeCopy() as ChannelTV; TransponderReader.PopulateChannelWithTransponderSettings(ref currentChannelTV, currentFrequency); needRebuild = ScanProbeFrequency(currentChannelTV, needRebuild); } } } else if (this.tabControlScanner.SelectedTab == this.tabPageScanManual) { int startFrequency = int.Parse(this.textBoxScanStartFrequency.Text); int stopFrequency = int.Parse(this.textBoxScanStopFrequency.Text); int bandwidth = int.Parse(this.textBoxScanBandwidth.Text); int currentFrequency = startFrequency; while (currentFrequency <= stopFrequency && continueScanning) { currentChannelTV = templateChannelTV.MakeCopy() as ChannelTV; (currentChannelTV as ChannelDVB).Frequency = currentFrequency; currentFrequency += bandwidth; needRebuild = ScanProbeFrequency(currentChannelTV, needRebuild); } } } else if (templateChannelTV is ChannelAnalogic) { int startChannelNumber = 0; // int.Parse(this.textBoxScanStartFrequency.Text); int stopChannelNumber = 100; // int.Parse(this.textBoxScanStopFrequency.Text); int currentChannelNumber = startChannelNumber; while (currentChannelNumber <= stopChannelNumber && continueScanning) { currentChannelTV = templateChannelTV.MakeCopy() as ChannelTV; (currentChannelTV as ChannelAnalogic).Channel = currentChannelNumber; currentChannelNumber++; needRebuild = ScanProbeFrequency(currentChannelTV, needRebuild); } } this.buttonScanChannels.Enabled = true; this.buttonScanStop.Enabled = false; } else { MessageBox.Show(Properties.Resources.WizardYouMustCreateChannelTemplate); } }
public FrequencyEditorForm(ChannelTV channel) { InitializeComponent(); this.channel = channel; }
public static void PopulateChannelWithTransponderSettings(ref ChannelTV channel, string frequency) { string[] fields = frequency.Split(new char[] { ',' }); if (channel is ChannelDVBT) { //Channelname,Frequency(KHz),Inversion(0,1),0,Bandwidth (7MHz=1, 8MHz=2) //C05,177.500,0,0,1 ChannelDVBT channelDVBT = channel as ChannelDVBT; channelDVBT.Frequency = int.Parse(fields[1].Trim().Replace(".", "")); channelDVBT.Bandwidth = (fields[4].Trim() == "1" ? 7 : 8); } else if (channel is ChannelDVBC) { //Frequency(KHz), Symbolrate(Ks/s), QAM //50500,6900,0 //57500,6900,64 ChannelDVBC channelDVBC = channel as ChannelDVBC; channelDVBC.Frequency = int.Parse(fields[0].Trim().Replace(".", "")); channelDVBC.SymbolRate = int.Parse(fields[1].Trim()); int modulation = int.Parse(fields[2].Trim()); switch (modulation) { case 0: channelDVBC.Modulation = DirectShowLib.BDA.ModulationType.ModNotSet; break; case 16: channelDVBC.Modulation = DirectShowLib.BDA.ModulationType.Mod16Qam; break; case 32: channelDVBC.Modulation = DirectShowLib.BDA.ModulationType.Mod32Qam; break; case 64: channelDVBC.Modulation = DirectShowLib.BDA.ModulationType.Mod64Qam; break; case 80: channelDVBC.Modulation = DirectShowLib.BDA.ModulationType.Mod80Qam; break; case 96: channelDVBC.Modulation = DirectShowLib.BDA.ModulationType.Mod96Qam; break; case 112: channelDVBC.Modulation = DirectShowLib.BDA.ModulationType.Mod112Qam; break; case 128: channelDVBC.Modulation = DirectShowLib.BDA.ModulationType.Mod128Qam; break; case 160: channelDVBC.Modulation = DirectShowLib.BDA.ModulationType.Mod160Qam; break; case 192: channelDVBC.Modulation = DirectShowLib.BDA.ModulationType.Mod192Qam; break; case 224: channelDVBC.Modulation = DirectShowLib.BDA.ModulationType.Mod224Qam; break; case 256: channelDVBC.Modulation = DirectShowLib.BDA.ModulationType.Mod256Qam; break; case 320: channelDVBC.Modulation = DirectShowLib.BDA.ModulationType.Mod320Qam; break; case 384: channelDVBC.Modulation = DirectShowLib.BDA.ModulationType.Mod384Qam; break; case 448: channelDVBC.Modulation = DirectShowLib.BDA.ModulationType.Mod448Qam; break; case 512: channelDVBC.Modulation = DirectShowLib.BDA.ModulationType.Mod512Qam; break; case 640: channelDVBC.Modulation = DirectShowLib.BDA.ModulationType.Mod640Qam; break; case 768: channelDVBC.Modulation = DirectShowLib.BDA.ModulationType.Mod768Qam; break; case 896: channelDVBC.Modulation = DirectShowLib.BDA.ModulationType.Mod896Qam; break; case 1024: channelDVBC.Modulation = DirectShowLib.BDA.ModulationType.Mod1024Qam; break; } } else if (channel is ChannelDVBS) { //Frequecny,polarisation,symbol rate,FEC //11016,H, 6284,78 ChannelDVBS channelDVBS = channel as ChannelDVBS; channelDVBS.Frequency = int.Parse(fields[0].Trim().Replace(".", "")); string polarisation = fields[1].Trim(); if (polarisation == "H") { channelDVBS.SignalPolarisation = DirectShowLib.BDA.Polarisation.LinearH; } else if (polarisation == "V") { channelDVBS.SignalPolarisation = DirectShowLib.BDA.Polarisation.LinearV; } else if (polarisation == "L") { channelDVBS.SignalPolarisation = DirectShowLib.BDA.Polarisation.CircularL; } else if (polarisation == "R") { channelDVBS.SignalPolarisation = DirectShowLib.BDA.Polarisation.CircularR; } channelDVBS.SymbolRate = int.Parse(fields[2].Trim()); } }