Ejemplo n.º 1
0
        private void AddEntry(ushort service, JMS.DVB.EPG.EventEntry entry)
        {
            // Create a new Entry
            EPG_Event_Entry newEventEntry = new EPG_Event_Entry();

            // check if this channel is known; only use the EPG data when the channel can be used
                newEventEntry.Service = service;
                newEventEntry.EndTime = entry.StartTime.ToLocalTime() + entry.Duration;
                //newEventEntry.EIT_Table = entry.Table;
                newEventEntry.EventIdentifier = entry.EventIdentifier;
                newEventEntry.FreeCA = entry.FreeCA;
                newEventEntry.StartTime = entry.StartTime.ToLocalTime();
                newEventEntry.Status = entry.Status;
                newEventEntry.EPG_Provider = EPGDataSource.EPGName;

                // Descriptors we can have
                JMS.DVB.EPG.Descriptors.ShortEvent shortEvent = null;

                // Extended events
                List<JMS.DVB.EPG.Descriptors.ExtendedEvent> exEvents = new List<JMS.DVB.EPG.Descriptors.ExtendedEvent>();

                // Check all descriptors
                foreach (JMS.DVB.EPG.Descriptor descr in entry.Descriptors)
                    if (descr.IsValid)
                    {
                        // Check type
                        if (null == shortEvent)
                        {
                            // Read
                            shortEvent = descr as JMS.DVB.EPG.Descriptors.ShortEvent;
                            // Done for now
                            if (null != shortEvent)
                            {
                                // add the data
                                newEventEntry.ShortDescription.Language = shortEvent.Language;
                                newEventEntry.ShortDescription.Name = shortEvent.Name;
                                newEventEntry.ShortDescription.Text = shortEvent.Text;
                                newEventEntry.ShortDescription.Tag = shortEvent.Tag;
                                continue;
                            }
                        }

                        // Test
                        JMS.DVB.EPG.Descriptors.ExtendedEvent exEvent = descr as JMS.DVB.EPG.Descriptors.ExtendedEvent;

                        // Register
                        if (null != exEvent)
                        {
                            EPG_ExtendedEvent extevent = new EPG_ExtendedEvent();

                            extevent.DescriptorNumber = exEvent.DescriptorNumber;
                            extevent.Language = exEvent.Language;
                            extevent.LastDescriptorNumber = exEvent.LastDescriptorNumber;
                            extevent.Name = exEvent.Name;
                            extevent.Tag = exEvent.Tag;
                            extevent.Text = exEvent.Text;

                            newEventEntry.Extended.Add(extevent);
                        }
                    }

                if (ChannelAndStationMapper.ServiceID2Name(service) != "")
                {
                    // first check if the event is currently running or in the future
                    if (newEventEntry.EndTime.Ticks > DateTime.Now.Ticks)
                    {
                        lock (EPG_Events.SyncRoot)
                        {
                            // add and check if it's already in
                            try
                            {
                                EPG_Events.Add(string.Format("{0}-{1}", service, entry.EventIdentifier), newEventEntry);

                                ConsoleOutputLogger.WriteLine("New Event " + newEventEntry.ShortDescription.Name + " on Channel " + ChannelAndStationMapper.ServiceID2Name(service) + " - " + entry.StartTime.ToLocalTime().ToString());

                            }
                            catch (Exception)
                            {
                                return;
                            }
                        }
                    }
                }
                else
                {
                    // this is an unknown channel...print it out for debugging reasons...
                    //ConsoleOutputLogger.WriteLine("*UNKNOWN* New Event " + newEventEntry.ShortDescription.Name+ "(" + newEventEntry.ShortDescription.Text + ") on unknown service ID" + service + " - " + entry.StartTime.ToLocalTime().ToString());
                }
        }
Ejemplo n.º 2
0
        private void SectionFound(JMS.DVB.EPG.Section section)
        {
            // Check
            if ((null == section) || !section.IsValid) return;

            // Convert
            JMS.DVB.EPG.Tables.EIT epgTable = section.Table as JMS.DVB.EPG.Tables.EIT;

            // Check it
            if ((null == epgTable) || !epgTable.IsValid) return;

            // Process all events
            foreach (JMS.DVB.EPG.EventEntry entry in epgTable.Entries)
                if (JMS.DVB.EPG.EventStatus.Running == entry.Status)
                    AddEntry(epgTable.ServiceIdentifier, entry);
        }
Ejemplo n.º 3
0
        private void AddEntry(ushort service, JMS.DVB.EPG.EventEntry entry)
        {
            // Create a new Entry
            EPG_Event_Entry newEventEntry = new EPG_Event_Entry();

            newEventEntry.Service = service;
            newEventEntry.EndTime = entry.StartTime.ToLocalTime()+entry.Duration;
            //newEventEntry.EIT_Table = entry.Table;
            newEventEntry.EventIdentifier = entry.EventIdentifier;
            newEventEntry.FreeCA = entry.FreeCA;
            newEventEntry.StartTime = entry.StartTime.ToLocalTime();
            newEventEntry.Status = entry.Status;
            newEventEntry.EPG_Provider = EPGDataSource.EPGName;

            // Descriptors we can have
            JMS.DVB.EPG.Descriptors.ShortEvent shortEvent = null;

            // Extended events
            List<JMS.DVB.EPG.Descriptors.ExtendedEvent> exEvents = new List<JMS.DVB.EPG.Descriptors.ExtendedEvent>();

            // Check all descriptors
            foreach (JMS.DVB.EPG.Descriptor descr in entry.Descriptors)
                if (descr.IsValid)
                {
                    // Check type
                    if (null == shortEvent)
                    {
                        // Read
                        shortEvent = descr as JMS.DVB.EPG.Descriptors.ShortEvent;
                        // Done for now
                        if (null != shortEvent)
                        {
                            // add the data
                            newEventEntry.ShortDescription.Language = shortEvent.Language;
                            newEventEntry.ShortDescription.Name = shortEvent.Name;
                            newEventEntry.ShortDescription.Text = shortEvent.Text;
                            newEventEntry.ShortDescription.Tag = shortEvent.Tag;

                            continue;
                        }
                    }

                    // Test
                    JMS.DVB.EPG.Descriptors.ExtendedEvent exEvent = descr as JMS.DVB.EPG.Descriptors.ExtendedEvent;

                    // Register
                    if (null != exEvent)
                    {
                        EPG_ExtendedEvent extevent = new EPG_ExtendedEvent();

                        extevent.DescriptorNumber = exEvent.DescriptorNumber;
                        extevent.Language = exEvent.Language;
                        extevent.LastDescriptorNumber = exEvent.LastDescriptorNumber;
                        extevent.Name = exEvent.Name;
                        extevent.Tag = exEvent.Tag;
                        extevent.Text = exEvent.Text;

                        newEventEntry.Extended.Add(extevent);
                    }
                }

            // first check if the event is currently running or in the future
            if (newEventEntry.EndTime.Ticks > DateTime.Now.Ticks)
            {
                lock (EPG_Events.SyncRoot)
                {
                    // add and check if it's already in
                    try
                    {
                        EPG_Events.Add(string.Format("{0}-{1}", service, entry.EventIdentifier), newEventEntry);

                        try
                        {
                            lock (ServiceIDtoStationNameMapper.Service2StationMapping.SyncRoot)
                            {
                                Station newStation = new Station();

                                newStation.Service = service;
                                newStation.StationName = service.ToString();

                                ServiceIDtoStationNameMapper.Service2StationMapping.Add(service, newStation);
                            }
                        }
                        catch (Exception)
                        {
                        }

                        Console.WriteLine("New Event " + newEventEntry.ShortDescription.Name + " on Channel " + ServiceIDtoStationNameMapper.MapService2StationName(service) + " - " + entry.StartTime.ToLocalTime().ToString());

                        {
                            #region XML
                            FileStream fs = new FileStream("blah.xml", FileMode.Create, FileAccess.Write);
                            try
                            {

                                List<EPG_Event_Entry> entries = new List<EPG_Event_Entry>(EPG_Events.Count);

                                foreach (object key in EPG_Events.Keys)
                                {
                                    entries.Add((EPG_Event_Entry)EPG_Events[key]);
                                }

                                XmlSerializer serializer = new XmlSerializer(typeof(List<EPG_Event_Entry>));
                                serializer.Serialize(fs, entries);
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e.Message);
                            }
                            finally
                            {
                                fs.Close();
                            }
                            #endregion
                            #region XML
                            fs = new FileStream("StationID.xml", FileMode.Create, FileAccess.Write);
                            try
                            {
                                List<Station> entries = new List<Station>(ServiceIDtoStationNameMapper.Service2StationMapping.Count);

                                foreach (object key in ServiceIDtoStationNameMapper.Service2StationMapping.Keys)
                                {
                                    entries.Add((Station)ServiceIDtoStationNameMapper.Service2StationMapping[key]);
                                }

                                XmlSerializer serializer = new XmlSerializer(typeof(List<Station>));
                                serializer.Serialize(fs, entries);
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e.Message);
                            }
                            finally
                            {
                                fs.Close();
                            }
                            #endregion
                        }

                    }
                    catch (Exception)
                    {
                        //Console.Write("-");
                        return;
                    }
                }
            }
        }