diff --git a/skyscraper8/DvbI/DvbIService.cs b/skyscraper8/DvbI/DvbIService.cs index 8a73ed5..fdd24a8 100644 --- a/skyscraper8/DvbI/DvbIService.cs +++ b/skyscraper8/DvbI/DvbIService.cs @@ -34,6 +34,9 @@ namespace skyscraper8.DvbI public string Region { get; internal set; } public string ServiceDescription { get; internal set; } + public string BannerURL { get; internal set; } + public string LinkedApplication { get; set; } + public override bool Equals(object? obj) { return obj is DvbIService service && diff --git a/skyscraper8/DvbI/DvbIUtils.cs b/skyscraper8/DvbI/DvbIUtils.cs index 1766056..445b631 100644 --- a/skyscraper8/DvbI/DvbIUtils.cs +++ b/skyscraper8/DvbI/DvbIUtils.cs @@ -139,6 +139,12 @@ namespace skyscraper8.DvbI case "urn:dvb:metadata:cs:HowRelatedCS:2021:1001.2": child.LogoURL = value; break; + case "urn:dvb:metadata:cs:HowRelatedCS:2021:1001.3": + child.BannerURL = value; + break; + case "urn:dvb:metadata:cs:LinkedApplicationCS:2019:1.1": + child.LinkedApplication = value; + break; default: throw new NotImplementedException(key); } diff --git a/skyscraper8/DvbNip/DvbNipReceiver.cs b/skyscraper8/DvbNip/DvbNipReceiver.cs index 119dde7..7af5d66 100644 --- a/skyscraper8/DvbNip/DvbNipReceiver.cs +++ b/skyscraper8/DvbNip/DvbNipReceiver.cs @@ -130,6 +130,7 @@ namespace skyscraper8.DvbNip string serviceListId = serviceListUrls[fluteListener.FileAssociation.ContentLocation]; Stream serviceListStream = fluteListener.ToStream(); byte[] serviceListByteArray = new byte[serviceListStream.Length]; + serviceListStream.Read(serviceListByteArray, 0, (int)serviceListStream.Length); ServiceListType serviceList = DvbIUtils.UnpackServiceList(serviceListByteArray); EventHandler.OnServiceList(CurrentCarrierInformation, serviceListId, serviceList); } @@ -158,9 +159,13 @@ namespace skyscraper8.DvbNip { switch (fluteListener.FileAssociation.ContentLocation) { + case "urn:dvb:metadata:cs:NativeIPMulticastTransportObjectTypeCS:2023:bootstrap": + MulticastGatewayConfigurationType multicastGatewayConfiguration2023 = DvbNipUtilities.UnpackMulticastGatewayConfiguration(fluteListener.ToStream()); + EventHandler?.OnMulticastGatewayConfiguration(CurrentCarrierInformation, multicastGatewayConfiguration2023); + return true; case "urn:dvb:metadata:cs:MulticastTransportObjectTypeCS:2021:gateway-configuration": - MulticastGatewayConfigurationType multicastGatewayConfiguration = DvbNipUtilities.UnpackMulticastGatewayConfiguration(fluteListener.ToStream()); - EventHandler?.OnMulticastGatewayConfiguration(CurrentCarrierInformation, multicastGatewayConfiguration); + MulticastGatewayConfigurationType multicastGatewayConfiguration2021 = DvbNipUtilities.UnpackMulticastGatewayConfiguration(fluteListener.ToStream()); + EventHandler?.OnMulticastGatewayConfiguration(CurrentCarrierInformation, multicastGatewayConfiguration2021); return true; case "urn:dvb:metadata:nativeip:PrivateDataSignalling": PrivateDataSignallingManifestType privateDataSignallingManifest = DvbNipUtilities.UnpackPrivateDataSignallingManifest(fluteListener.ToStream()); @@ -196,6 +201,10 @@ namespace skyscraper8.DvbNip ServiceInformationFileType serviceInformationFile = DvbNipUtilities.UnpackServiceInformationFile(fluteListener.ToStream()); EventHandler?.OnServiceInformationFile(CurrentCarrierInformation, serviceInformationFile); return true; + case "urn:dvb:metadata:nativeip:ServiceGuide": + //Unfortunately, the NIPServiceGuideManifest does not contain any useful information at all, which is why we ignore it. + //There doesn't seem to be a way to get the actual EIT XML from it. + return true; default: throw new NotImplementedException(fluteListener.FileAssociation.ContentLocation); } diff --git a/skyscraper8/Program.cs b/skyscraper8/Program.cs index f8d0efd..b590c45 100644 --- a/skyscraper8/Program.cs +++ b/skyscraper8/Program.cs @@ -63,6 +63,7 @@ namespace skyscraper5 SkyscraperContext skyscraperContext = new SkyscraperContext(new TsContext()); skyscraperContext.InitalizeFilterChain(); skyscraperContext.IngestFromStream(m3U8Stream); + return; } if (args[0].Equals("aactest")) diff --git a/skyscraper8/Skyscraper/Scraper/SkyscraperContext.cs b/skyscraper8/Skyscraper/Scraper/SkyscraperContext.cs index 718e7af..4149d25 100644 --- a/skyscraper8/Skyscraper/Scraper/SkyscraperContext.cs +++ b/skyscraper8/Skyscraper/Scraper/SkyscraperContext.cs @@ -2460,10 +2460,41 @@ namespace skyscraper5.Skyscraper.Scraper public void OnMulticastGatewayConfiguration(NipActualCarrierInformation carrier, MulticastGatewayConfigurationType multicastGatewayConfiguration) { - if (multicastGatewayConfiguration.MulticastSession == null) - return; + if (multicastGatewayConfiguration.MulticastSession != null) + { + foreach (MulticastSessionType multicastSession in multicastGatewayConfiguration.MulticastSession) + { + if (!ScraperStorage.DvbNipTestForMulticastSession(multicastSession)) + { + LogEvent(SkyscraperContextEvent.DvbNipMulticastSession, multicastSession.serviceIdentifier); + ScraperStorage.DvbNipInsertMulticastSession(multicastSession); + } + } + } - throw new NotImplementedException(); + if (multicastGatewayConfiguration.MulticastGatewayConfigurationTransportSession != null) + { + foreach (MulticastGatewayConfigurationTransportSessionType multicastGatewayConfigurationTransportSession in multicastGatewayConfiguration.MulticastGatewayConfigurationTransportSession) + { + if (multicastGatewayConfigurationTransportSession.EndpointAddress == null) + continue; + + MulticastEndpointAddressType endpointAddress = multicastGatewayConfigurationTransportSession.EndpointAddress[0]; + if (!ScraperStorage.DvbNipTestForMulticastGatewayConfigurationTransportSession(carrier, endpointAddress)) + { + string name = String.Format("{0} -> {1}:{2}, TSI = {3}", endpointAddress.NetworkSourceAddress, + endpointAddress.NetworkDestinationGroupAddress, endpointAddress.TransportDestinationPort, + endpointAddress.MediaTransportSessionIdentifier); + LogEvent(SkyscraperContextEvent.DvbNipMulticastGatewayConfigurationTransportSession, name); + ScraperStorage.DvbNipInsertMulticastGatewayConfigurationTransportSession(carrier, multicastGatewayConfigurationTransportSession); + } + } + } + + if (multicastGatewayConfiguration.MulticastGatewaySessionReporting != null) + { + throw new NotImplementedException(nameof(multicastGatewayConfiguration.MulticastGatewaySessionReporting)); + } } public void OnNipCarrierDetected(NipActualCarrierInformation currentCarrierInformation) @@ -2549,7 +2580,25 @@ namespace skyscraper5.Skyscraper.Scraper public void OnServiceList(NipActualCarrierInformation currentCarrierInformation, string serviceListId, ServiceListType serviceList) { - throw new NotImplementedException(); + List services = DvbIUtils.FlattenServiceList(serviceList).ToList(); + DvbIDataStorage dataStorage = ScraperStorage; + foreach (DvbIService service in services) + { + if (dataStorage.TestForDvbiService(service.Id)) + { + int versionInDb = dataStorage.GetDvbiServiceVersion(service.Id); + if (service.Version > versionInDb) + { + dataStorage.UpdateDvbiService(service); + } + } + else + { + logger.InfoFormat("New DVB-I Service: {0}", service.ServiceName); + dataStorage.InsertDvbiService(service); + dataStorage.AddDvbiServiceToServiceList(service.Id, serviceListId); + } + } } public void OnTimeOffsetFile(NipActualCarrierInformation currentCarrierInformation, TimeOffsetFileType timeOffsetFile) diff --git a/skyscraper8/Skyscraper/Scraper/SkyscraperContextEvent.cs b/skyscraper8/Skyscraper/Scraper/SkyscraperContextEvent.cs index bff2b8c..dbdaac3 100644 --- a/skyscraper8/Skyscraper/Scraper/SkyscraperContextEvent.cs +++ b/skyscraper8/Skyscraper/Scraper/SkyscraperContextEvent.cs @@ -78,6 +78,8 @@ FluteFileProgress, NipPrivateDataSpecifier, DvbNipNetwork, - DvbNipService + DvbNipService, + DvbNipMulticastSession, + DvbNipMulticastGatewayConfigurationTransportSession } } diff --git a/skyscraper8/Skyscraper/Scraper/Storage/Filesystem/FilesystemScraperStorage.cs b/skyscraper8/Skyscraper/Scraper/Storage/Filesystem/FilesystemScraperStorage.cs index 7af65f4..7bfadc5 100644 --- a/skyscraper8/Skyscraper/Scraper/Storage/Filesystem/FilesystemScraperStorage.cs +++ b/skyscraper8/Skyscraper/Scraper/Storage/Filesystem/FilesystemScraperStorage.cs @@ -1479,6 +1479,28 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.Filesystem throw new NotImplementedException(); } + public bool DvbNipTestForMulticastSession(MulticastSessionType multicastSession) + { + throw new NotImplementedException(); + } + + public void DvbNipInsertMulticastSession(MulticastSessionType multicastSession) + { + throw new NotImplementedException(); + } + + public bool DvbNipTestForMulticastGatewayConfigurationTransportSession(NipActualCarrierInformation carrier, + MulticastEndpointAddressType multicastEndpointAddressType) + { + throw new NotImplementedException(); + } + + public void DvbNipInsertMulticastGatewayConfigurationTransportSession(NipActualCarrierInformation carrier, + MulticastGatewayConfigurationTransportSessionType multicastGatewayConfigurationTransportSession) + { + throw new NotImplementedException(); + } + public DateTime GetLastDvbiServiceListEntryPointUpdateDate(long sourceHash) { throw new NotImplementedException(); diff --git a/skyscraper8/Skyscraper/Scraper/Storage/IScraperStorage.cs b/skyscraper8/Skyscraper/Scraper/Storage/IScraperStorage.cs index fc5d2dd..0404d72 100644 --- a/skyscraper8/Skyscraper/Scraper/Storage/IScraperStorage.cs +++ b/skyscraper8/Skyscraper/Scraper/Storage/IScraperStorage.cs @@ -190,5 +190,9 @@ namespace skyscraper5.Skyscraper.Scraper.Storage void DvbNipInsertNetwork(BroadcastNetworkType network); bool DvbNipTestForService(BroadcastMediaStreamType broadcastMediaStreamType); void DvbNipInsertService(BroadcastMediaStreamType broadcastMediaStreamType); + bool DvbNipTestForMulticastSession(MulticastSessionType multicastSession); + void DvbNipInsertMulticastSession(MulticastSessionType multicastSession); + bool DvbNipTestForMulticastGatewayConfigurationTransportSession(NipActualCarrierInformation carrier, MulticastEndpointAddressType multicastEndpointAddressType); + void DvbNipInsertMulticastGatewayConfigurationTransportSession(NipActualCarrierInformation carrier, MulticastGatewayConfigurationTransportSessionType multicastGatewayConfigurationTransportSession); } } diff --git a/skyscraper8/Skyscraper/Scraper/Storage/InMemory/InMemoryScraperStorage.cs b/skyscraper8/Skyscraper/Scraper/Storage/InMemory/InMemoryScraperStorage.cs index 9e565a7..1203e96 100644 --- a/skyscraper8/Skyscraper/Scraper/Storage/InMemory/InMemoryScraperStorage.cs +++ b/skyscraper8/Skyscraper/Scraper/Storage/InMemory/InMemoryScraperStorage.cs @@ -37,1041 +37,1105 @@ using System.Linq; using System.Net; using System.Net.NetworkInformation; using skyscraper8.Ietf.FLUTE; +using skyscraper8.Skyscraper.Scraper.Storage.Utilities; using Platform = skyscraper5.Dvb.SystemSoftwareUpdate.Model.Platform; namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory { internal class InMemoryScraperStorage : IScraperStroage - { - public InMemoryScraperStorage() - { - nitNetworks = new NitNetwork[ushort.MaxValue + 1]; - nitTransportStreams = new NitTransportStream[ushort.MaxValue + 1][]; - patEntries = new HashSet(); - pmtEntries = new ProgramMapping[ushort.MaxValue + 1][][]; - teletextPageCache = new Dictionary>(); - sdtServices = new SdtService[ushort.MaxValue + 1][][]; - batBouquets = new BatBouquet[ushort.MaxValue]; - batTransportStreams = new BatTransportStream[ushort.MaxValue + 1][]; - timeOffsets = new Tuple[ushort.MaxValue + 1][]; - tdtTimes = new DateTime[ushort.MaxValue + 1][]; - eitEvents = new HashSet(); - doItNowEvents = new List(); - caSystems = new List(); - updateHashes = new HashSet(); - updates = new List>(); - rdsTexts = new HashSet(); - ptyCodes = new PTY.ProgrammeTypeCodes[ushort.MaxValue][][]; - scte35SpliceCoordinates = new HashSet(); - compliances = new HashSet(); - stationIdentification = new string[ushort.MaxValue + 1][]; - aitApplicationCoordinates = new HashSet(); - rstCoordinates = new HashSet(); - ipMacNotificationCoordinates = new List(); - pluginToken = new InMemoryPluginToken(); - } + { + public InMemoryScraperStorage() + { + nitNetworks = new NitNetwork[ushort.MaxValue + 1]; + nitTransportStreams = new NitTransportStream[ushort.MaxValue + 1][]; + patEntries = new HashSet(); + pmtEntries = new ProgramMapping[ushort.MaxValue + 1][][]; + teletextPageCache = new Dictionary>(); + sdtServices = new SdtService[ushort.MaxValue + 1][][]; + batBouquets = new BatBouquet[ushort.MaxValue]; + batTransportStreams = new BatTransportStream[ushort.MaxValue + 1][]; + timeOffsets = new Tuple[ushort.MaxValue + 1][]; + tdtTimes = new DateTime[ushort.MaxValue + 1][]; + eitEvents = new HashSet(); + doItNowEvents = new List(); + caSystems = new List(); + updateHashes = new HashSet(); + updates = new List>(); + rdsTexts = new HashSet(); + ptyCodes = new PTY.ProgrammeTypeCodes[ushort.MaxValue][][]; + scte35SpliceCoordinates = new HashSet(); + compliances = new HashSet(); + stationIdentification = new string[ushort.MaxValue + 1][]; + aitApplicationCoordinates = new HashSet(); + rstCoordinates = new HashSet(); + ipMacNotificationCoordinates = new List(); + pluginToken = new InMemoryPluginToken(); + } - private NitNetwork[] nitNetworks; - private NitTransportStream[][] nitTransportStreams; - private HashSet patEntries; - private ProgramMapping[][][] pmtEntries; - private Dictionary> teletextPageCache; - private SdtService[][][] sdtServices; - private BatBouquet[] batBouquets; - private BatTransportStream[][] batTransportStreams; - private Tuple[][] timeOffsets; - private DateTime[][] tdtTimes; - private HashSet eitEvents; - private List doItNowEvents; - private List caSystems; - private HashSet updateHashes; - private List> updates; - private bool[][][] rdsDataPresent; - private string[][][] rdsProgrammeService; - private HashSet rdsTexts; - private PTY.ProgrammeTypeCodes[][][] ptyCodes; - private bool[][][] rdsTrafficInformationPreset; - private HashSet scte35SpliceCoordinates; - private HashSet compliances; - private string[][] stationIdentification; - private HashSet aitApplicationCoordinates; - private HashSet rstCoordinates; - private List ipMacNotificationCoordinates; - private DateTime[][][] t2MiTimestamps; - private InMemoryPluginToken pluginToken; + private NitNetwork[] nitNetworks; + private NitTransportStream[][] nitTransportStreams; + private HashSet patEntries; + private ProgramMapping[][][] pmtEntries; + private Dictionary> teletextPageCache; + private SdtService[][][] sdtServices; + private BatBouquet[] batBouquets; + private BatTransportStream[][] batTransportStreams; + private Tuple[][] timeOffsets; + private DateTime[][] tdtTimes; + private HashSet eitEvents; + private List doItNowEvents; + private List caSystems; + private HashSet updateHashes; + private List> updates; + private bool[][][] rdsDataPresent; + private string[][][] rdsProgrammeService; + private HashSet rdsTexts; + private PTY.ProgrammeTypeCodes[][][] ptyCodes; + private bool[][][] rdsTrafficInformationPreset; + private HashSet scte35SpliceCoordinates; + private HashSet compliances; + private string[][] stationIdentification; + private HashSet aitApplicationCoordinates; + private HashSet rstCoordinates; + private List ipMacNotificationCoordinates; + private DateTime[][][] t2MiTimestamps; + private InMemoryPluginToken pluginToken; - public bool TestForNitNetwork(NitNetwork nitNetwork) - { - return nitNetworks[nitNetwork.NetworkId] != null; - } + public bool TestForNitNetwork(NitNetwork nitNetwork) + { + return nitNetworks[nitNetwork.NetworkId] != null; + } - public void StoreNitNetwork(NitNetwork nitNetwork) - { - nitNetworks[nitNetwork.NetworkId] = nitNetwork; - } + public void StoreNitNetwork(NitNetwork nitNetwork) + { + nitNetworks[nitNetwork.NetworkId] = nitNetwork; + } - public bool UpdateNitNetwork(NitNetwork l) - { - bool result = false; - NitNetwork r = nitNetworks[l.NetworkId]; + public bool UpdateNitNetwork(NitNetwork l) + { + bool result = false; + NitNetwork r = nitNetworks[l.NetworkId]; - if (string.IsNullOrEmpty(r.Name) && !string.IsNullOrEmpty(l.Name)) - { - r.Name = l.Name; - result = true; - } + if (string.IsNullOrEmpty(r.Name) && !string.IsNullOrEmpty(l.Name)) + { + r.Name = l.Name; + result = true; + } - foreach (LinkageDescriptor lLinkage in l.Linkages) - { - if (!r.Linkages.Contains(lLinkage)) - { - r.Linkages.Add(lLinkage); - result = true; - } - } + foreach (LinkageDescriptor lLinkage in l.Linkages) + { + if (!r.Linkages.Contains(lLinkage)) + { + r.Linkages.Add(lLinkage); + result = true; + } + } - if (!r.PrivateDataSpecifierId.HasValue && l.PrivateDataSpecifierId.HasValue) - { - r.PrivateDataSpecifierId = l.PrivateDataSpecifierId; - result = true; - } + if (!r.PrivateDataSpecifierId.HasValue && l.PrivateDataSpecifierId.HasValue) + { + r.PrivateDataSpecifierId = l.PrivateDataSpecifierId; + result = true; + } - return result; - } + return result; + } - public bool TestForNitTransportStream(ushort networkId, NitTransportStream transportStream) - { - if (nitTransportStreams[transportStream.OriginalNetworkId] == null) - return false; + public bool TestForNitTransportStream(ushort networkId, NitTransportStream transportStream) + { + if (nitTransportStreams[transportStream.OriginalNetworkId] == null) + return false; - return nitTransportStreams[transportStream.OriginalNetworkId][transportStream.TransportStreamId] != null; - } + return nitTransportStreams[transportStream.OriginalNetworkId][transportStream.TransportStreamId] != null; + } - public void StoreNitTransportStream(ushort networkId, NitTransportStream transportStream) - { - if (nitTransportStreams[transportStream.OriginalNetworkId] == null) - nitTransportStreams[transportStream.OriginalNetworkId] = new NitTransportStream[ushort.MaxValue]; + public void StoreNitTransportStream(ushort networkId, NitTransportStream transportStream) + { + if (nitTransportStreams[transportStream.OriginalNetworkId] == null) + nitTransportStreams[transportStream.OriginalNetworkId] = new NitTransportStream[ushort.MaxValue]; - nitTransportStreams[transportStream.OriginalNetworkId][transportStream.TransportStreamId] = transportStream; - } + nitTransportStreams[transportStream.OriginalNetworkId][transportStream.TransportStreamId] = transportStream; + } - public bool UpdateNitTransportStream(ushort nid, NitTransportStream l) - { - NitTransportStream r = nitTransportStreams[l.OriginalNetworkId][l.TransportStreamId]; + public bool UpdateNitTransportStream(ushort nid, NitTransportStream l) + { + NitTransportStream r = nitTransportStreams[l.OriginalNetworkId][l.TransportStreamId]; - if (!r.Frequency.HasValue && l.Frequency.HasValue) - { - r.RollOff = l.RollOff; - r.S2 = l.S2; - r.Frequency = l.Frequency; - r.Polarization = l.Polarization; - r.SymbolRate = l.SymbolRate; - r.East = l.East; - r.FecInner = l.FecInner; - r.ModulationType = l.ModulationType; - r.OrbitalPosition = l.OrbitalPosition; - return true; - } + if (!r.Frequency.HasValue && l.Frequency.HasValue) + { + r.RollOff = l.RollOff; + r.S2 = l.S2; + r.Frequency = l.Frequency; + r.Polarization = l.Polarization; + r.SymbolRate = l.SymbolRate; + r.East = l.East; + r.FecInner = l.FecInner; + r.ModulationType = l.ModulationType; + r.OrbitalPosition = l.OrbitalPosition; + return true; + } - return false; - } + return false; + } - public bool StorePatEntry(int currentNetworkId, int currentTransportStreamId, int pmtPid, ushort programId) - { - InMemoryPatEntry inMemoryPatEntry = new InMemoryPatEntry(currentNetworkId, currentTransportStreamId, pmtPid, programId); - return patEntries.Add(inMemoryPatEntry); - } + public bool StorePatEntry(int currentNetworkId, int currentTransportStreamId, int pmtPid, ushort programId) + { + InMemoryPatEntry inMemoryPatEntry = + new InMemoryPatEntry(currentNetworkId, currentTransportStreamId, pmtPid, programId); + return patEntries.Add(inMemoryPatEntry); + } - public bool TestForPmtEvent(int currentNetworkId, int currentTransportStreamId, ProgramMapping result) - { - if (pmtEntries[currentNetworkId] == null) - return false; + public bool TestForPmtEvent(int currentNetworkId, int currentTransportStreamId, ProgramMapping result) + { + if (pmtEntries[currentNetworkId] == null) + return false; - if (pmtEntries[currentNetworkId][currentTransportStreamId] == null) - return false; + if (pmtEntries[currentNetworkId][currentTransportStreamId] == null) + return false; - return pmtEntries[currentNetworkId][currentTransportStreamId][result.ProgramNumber] != null; - } + return pmtEntries[currentNetworkId][currentTransportStreamId][result.ProgramNumber] != null; + } - public bool StorePmtEvent(int currentNetworkId, int currentTransportStreamId, ProgramMapping mapping) - { - if (pmtEntries[currentNetworkId] == null) - pmtEntries[currentNetworkId] = new ProgramMapping[ushort.MaxValue][]; + public bool StorePmtEvent(int currentNetworkId, int currentTransportStreamId, ProgramMapping mapping) + { + if (pmtEntries[currentNetworkId] == null) + pmtEntries[currentNetworkId] = new ProgramMapping[ushort.MaxValue][]; - if (pmtEntries[currentNetworkId][currentTransportStreamId] == null) - pmtEntries[currentNetworkId][currentTransportStreamId] = new ProgramMapping[ushort.MaxValue]; + if (pmtEntries[currentNetworkId][currentTransportStreamId] == null) + pmtEntries[currentNetworkId][currentTransportStreamId] = new ProgramMapping[ushort.MaxValue]; - bool result = pmtEntries[currentNetworkId][currentTransportStreamId][mapping.ProgramNumber] == null; - pmtEntries[currentNetworkId][currentTransportStreamId][mapping.ProgramNumber] = mapping; - return result; - } + bool result = pmtEntries[currentNetworkId][currentTransportStreamId][mapping.ProgramNumber] == null; + pmtEntries[currentNetworkId][currentTransportStreamId][mapping.ProgramNumber] = mapping; + return result; + } - public bool StoreTeletextPage(int networkId, int transportStreamId, ushort programNumber, TeletextMagazine magazine, DateTime timestamp) - { - return false; - } + public bool StoreTeletextPage(int networkId, int transportStreamId, ushort programNumber, + TeletextMagazine magazine, DateTime timestamp) + { + return false; + } - public bool TestForSdtService(ushort transportStreamId, ushort originalNetworkId, SdtService sdtService) - { - if (sdtServices[transportStreamId] == null) - return false; + public bool TestForSdtService(ushort transportStreamId, ushort originalNetworkId, SdtService sdtService) + { + if (sdtServices[transportStreamId] == null) + return false; - if (sdtServices[transportStreamId][originalNetworkId] == null) - return false; + if (sdtServices[transportStreamId][originalNetworkId] == null) + return false; - return sdtServices[transportStreamId][originalNetworkId][sdtService.ServiceId] != null; - } + return sdtServices[transportStreamId][originalNetworkId][sdtService.ServiceId] != null; + } - public bool TestForTeletextPage(int networkId, int transportStreamId, ushort programNumber, TeletextMagazine magazine, DateTime timestamp) - { - //No need to keep teletext pages in memory - return true; - } + public bool TestForTeletextPage(int networkId, int transportStreamId, ushort programNumber, + TeletextMagazine magazine, DateTime timestamp) + { + //No need to keep teletext pages in memory + return true; + } - public void MarkTeletextPageAsKnown(int networkId, int transportStreamId, ushort programNumber, TeletextMagazine magazine, DateTime timestamp) - { - //No need to keep teletext pages in memory - } + public void MarkTeletextPageAsKnown(int networkId, int transportStreamId, ushort programNumber, + TeletextMagazine magazine, DateTime timestamp) + { + //No need to keep teletext pages in memory + } - public bool UpdateSdtService(ushort transportStreamId, ushort originalNetworkId, SdtService l) - { - bool result = false; - SdtService r = sdtServices[transportStreamId][originalNetworkId][l.ServiceId]; - if (!string.IsNullOrEmpty(l.ServiceName) && string.IsNullOrEmpty(r.ServiceName)) - { - r.ServiceName = l.ServiceName; - r.ServiceProviderName = l.ServiceProviderName; - r.ServiceType = l.ServiceType; - result = true; - } + public bool UpdateSdtService(ushort transportStreamId, ushort originalNetworkId, SdtService l) + { + bool result = false; + SdtService r = sdtServices[transportStreamId][originalNetworkId][l.ServiceId]; + if (!string.IsNullOrEmpty(l.ServiceName) && string.IsNullOrEmpty(r.ServiceName)) + { + r.ServiceName = l.ServiceName; + r.ServiceProviderName = l.ServiceProviderName; + r.ServiceType = l.ServiceType; + result = true; + } - if (l.PrivateDataSpecifier.HasValue && !r.PrivateDataSpecifier.HasValue) - { - r.PrivateDataSpecifier = l.PrivateDataSpecifier; - result = true; - } + if (l.PrivateDataSpecifier.HasValue && !r.PrivateDataSpecifier.HasValue) + { + r.PrivateDataSpecifier = l.PrivateDataSpecifier; + result = true; + } - return false; - } + return false; + } - public void StoreSdtService(ushort transportStreamId, ushort originalNetworkId, SdtService sdtService) - { - if (sdtServices[transportStreamId] == null) - sdtServices[transportStreamId] = new SdtService[ushort.MaxValue + 1][]; + public void StoreSdtService(ushort transportStreamId, ushort originalNetworkId, SdtService sdtService) + { + if (sdtServices[transportStreamId] == null) + sdtServices[transportStreamId] = new SdtService[ushort.MaxValue + 1][]; - if (sdtServices[transportStreamId][originalNetworkId] == null) - sdtServices[transportStreamId][originalNetworkId] = new SdtService[ushort.MaxValue + 1]; + if (sdtServices[transportStreamId][originalNetworkId] == null) + sdtServices[transportStreamId][originalNetworkId] = new SdtService[ushort.MaxValue + 1]; - sdtServices[transportStreamId][originalNetworkId][sdtService.ServiceId] = sdtService; - } + sdtServices[transportStreamId][originalNetworkId][sdtService.ServiceId] = sdtService; + } - public bool TestForBatBouquet(BatBouquet batBouquet) - { - return batBouquets[batBouquet.BouquetId] != null; - } + public bool TestForBatBouquet(BatBouquet batBouquet) + { + return batBouquets[batBouquet.BouquetId] != null; + } - public bool UpdateBatBouquet(BatBouquet l) - { - bool result = false; - BatBouquet r = batBouquets[l.BouquetId]; - if (!string.IsNullOrEmpty(l.BouquetName) && string.IsNullOrEmpty(r.BouquetName)) - { - r.BouquetName = l.BouquetName; - result = true; - } + public bool UpdateBatBouquet(BatBouquet l) + { + bool result = false; + BatBouquet r = batBouquets[l.BouquetId]; + if (!string.IsNullOrEmpty(l.BouquetName) && string.IsNullOrEmpty(r.BouquetName)) + { + r.BouquetName = l.BouquetName; + result = true; + } - foreach (LinkageDescriptor linkageDescriptor in l.Linkages) - { - if (!r.Linkages.Contains(linkageDescriptor)) - { - r.Linkages.Add(linkageDescriptor); - result = true; - } - } + foreach (LinkageDescriptor linkageDescriptor in l.Linkages) + { + if (!r.Linkages.Contains(linkageDescriptor)) + { + r.Linkages.Add(linkageDescriptor); + result = true; + } + } - foreach (KeyValuePair country in l.CountryAvailabilityDictionary) - { - if (r.CountryAvailabilityDictionary.ContainsKey(country.Key)) - { - if (country.Value != r.CountryAvailabilityDictionary[country.Key]) - { - r.CountryAvailabilityDictionary[country.Key] = country.Value; - result = true; - continue; - } - } - else - { - r.CountryAvailabilityDictionary[country.Key] = country.Value; - result = true; - } - } + foreach (KeyValuePair country in l.CountryAvailabilityDictionary) + { + if (r.CountryAvailabilityDictionary.ContainsKey(country.Key)) + { + if (country.Value != r.CountryAvailabilityDictionary[country.Key]) + { + r.CountryAvailabilityDictionary[country.Key] = country.Value; + result = true; + continue; + } + } + else + { + r.CountryAvailabilityDictionary[country.Key] = country.Value; + result = true; + } + } - return result; - } + return result; + } - public void StoreBatBouquet(BatBouquet batBouquet) - { - batBouquets[batBouquet.BouquetId] = batBouquet; - } + public void StoreBatBouquet(BatBouquet batBouquet) + { + batBouquets[batBouquet.BouquetId] = batBouquet; + } - public bool TestForBatTransportStream(ushort batBouquetBouquetId, BatTransportStream child) - { - if (batTransportStreams[batBouquetBouquetId] == null) - return false; + public bool TestForBatTransportStream(ushort batBouquetBouquetId, BatTransportStream child) + { + if (batTransportStreams[batBouquetBouquetId] == null) + return false; - return batTransportStreams[batBouquetBouquetId][child.TransportStreamId] != null; - } + return batTransportStreams[batBouquetBouquetId][child.TransportStreamId] != null; + } - public bool UpdateBatTransportStream(ushort batBouquetBouquetId, BatTransportStream l) - { - if (l.ServiceList == null) - return false; + public bool UpdateBatTransportStream(ushort batBouquetBouquetId, BatTransportStream l) + { + if (l.ServiceList == null) + return false; - bool result = false; - BatTransportStream r = batTransportStreams[batBouquetBouquetId][l.TransportStreamId]; - foreach (ServiceListDescriptor.Service service in l.ServiceList) - { - if (r.ServiceList == null) - r.ServiceList = new List(); - if (!r.ServiceList.Contains(service)) - { - r.ServiceList.Add(service); - result = true; - } - } + bool result = false; + BatTransportStream r = batTransportStreams[batBouquetBouquetId][l.TransportStreamId]; + foreach (ServiceListDescriptor.Service service in l.ServiceList) + { + if (r.ServiceList == null) + r.ServiceList = new List(); + if (!r.ServiceList.Contains(service)) + { + r.ServiceList.Add(service); + result = true; + } + } - return result; - } + return result; + } - public void StoreBatTransportStream(ushort batBouquetBouquetId, BatTransportStream child) - { - if (batTransportStreams[batBouquetBouquetId] == null) - batTransportStreams[batBouquetBouquetId] = new BatTransportStream[ushort.MaxValue]; + public void StoreBatTransportStream(ushort batBouquetBouquetId, BatTransportStream child) + { + if (batTransportStreams[batBouquetBouquetId] == null) + batTransportStreams[batBouquetBouquetId] = new BatTransportStream[ushort.MaxValue]; - batTransportStreams[batBouquetBouquetId][child.TransportStreamId] = child; - } + batTransportStreams[batBouquetBouquetId][child.TransportStreamId] = child; + } - public bool UpdateTimeOffsetTable(int currentNetworkId, int currentTransportStreamId, DateTime newTime, LocalTimeOffsetDescriptor ltod) - { - if (timeOffsets[currentNetworkId] == null) - timeOffsets[currentNetworkId] = new Tuple[ushort.MaxValue]; + public bool UpdateTimeOffsetTable(int currentNetworkId, int currentTransportStreamId, DateTime newTime, + LocalTimeOffsetDescriptor ltod) + { + if (timeOffsets[currentNetworkId] == null) + timeOffsets[currentNetworkId] = new Tuple[ushort.MaxValue]; - if (timeOffsets[currentNetworkId][currentTransportStreamId] != null) - { - DateTime oldTime = timeOffsets[currentNetworkId][currentTransportStreamId].Item1; - if ((newTime - oldTime).TotalSeconds < 10) - return false; - } - timeOffsets[currentNetworkId][currentTransportStreamId] = new Tuple(newTime, ltod); - return true; - } + if (timeOffsets[currentNetworkId][currentTransportStreamId] != null) + { + DateTime oldTime = timeOffsets[currentNetworkId][currentTransportStreamId].Item1; + if ((newTime - oldTime).TotalSeconds < 10) + return false; + } - public bool UpdateTimeAndDate(int currentNetworkId, int currentTransportStreamId, DateTime newTime) - { - if (tdtTimes[currentNetworkId] == null) - tdtTimes[currentNetworkId] = new DateTime[ushort.MaxValue]; + timeOffsets[currentNetworkId][currentTransportStreamId] = + new Tuple(newTime, ltod); + return true; + } - if (tdtTimes[currentNetworkId][currentTransportStreamId] != DateTime.MinValue) - { - DateTime oldTime = tdtTimes[currentNetworkId][currentTransportStreamId]; - if ((newTime - oldTime).TotalSeconds < 10) - return false; - } + public bool UpdateTimeAndDate(int currentNetworkId, int currentTransportStreamId, DateTime newTime) + { + if (tdtTimes[currentNetworkId] == null) + tdtTimes[currentNetworkId] = new DateTime[ushort.MaxValue]; - tdtTimes[currentNetworkId][currentTransportStreamId] = newTime; - return true; - } + if (tdtTimes[currentNetworkId][currentTransportStreamId] != DateTime.MinValue) + { + DateTime oldTime = tdtTimes[currentNetworkId][currentTransportStreamId]; + if ((newTime - oldTime).TotalSeconds < 10) + return false; + } - public bool StoreEitEvent(EitEvent eitEvent) - { - return eitEvents.Add(eitEvent); - } + tdtTimes[currentNetworkId][currentTransportStreamId] = newTime; + return true; + } - public bool TestForAitApplication(ApplicationIdentifier aitApplicationApplicationIdentifier) - { - AitApplicationCoordinate aitCoordinate = new AitApplicationCoordinate(aitApplicationApplicationIdentifier.OrganisationId, aitApplicationApplicationIdentifier.ApplicationId); - return aitApplicationCoordinates.Contains(aitCoordinate); - } + public bool StoreEitEvent(EitEvent eitEvent) + { + return eitEvents.Add(eitEvent); + } - public void StoreAitApplication(AitApplication aitApplication) - { - AitApplicationCoordinate aitApplicationCoordinate = new AitApplicationCoordinate( - aitApplication.ApplicationIdentifier.OrganisationId, - aitApplication.ApplicationIdentifier.ApplicationId); + public bool TestForAitApplication(ApplicationIdentifier aitApplicationApplicationIdentifier) + { + AitApplicationCoordinate aitCoordinate = new AitApplicationCoordinate( + aitApplicationApplicationIdentifier.OrganisationId, aitApplicationApplicationIdentifier.ApplicationId); + return aitApplicationCoordinates.Contains(aitCoordinate); + } - aitApplicationCoordinate.PointingTo = aitApplication; - aitApplicationCoordinates.Add(aitApplicationCoordinate); - } + public void StoreAitApplication(AitApplication aitApplication) + { + AitApplicationCoordinate aitApplicationCoordinate = new AitApplicationCoordinate( + aitApplication.ApplicationIdentifier.OrganisationId, + aitApplication.ApplicationIdentifier.ApplicationId); - public bool ObjectCarouselFileArrival(VfsFile vfsFile, int transportStreamId, int networkId) - { - string outPath = String.Format("{0}{1}{2}{1}{3}{4}", networkId, Path.DirectorySeparatorChar, transportStreamId, vfsFile.SourcePid, vfsFile.ToString()); - FileInfo outFileInfo = new FileInfo(outPath); - if (outFileInfo.Exists) - return false; - EnsureDirectoryExists(outFileInfo.Directory); - File.WriteAllBytes(outFileInfo.FullName, vfsFile.FileContent); - return true; - } - - public bool TestForCaSystem(int currentNetworkId, int currentTransportStreamId, int caDescriptorCaPid) - { - InMemoryCaSystem find = caSystems.Find(x => x.CurrentNetworkId == currentNetworkId && x.CurrentTransportStreamId == currentTransportStreamId && x.CaPid == caDescriptorCaPid); - return find != null; - } + aitApplicationCoordinate.PointingTo = aitApplication; + aitApplicationCoordinates.Add(aitApplicationCoordinate); + } - public void StoreCaSystem(int currentNetworkId, int currentTransportStreamId, CaDescriptor caDescriptor) - { - InMemoryCaSystem caSystem = new InMemoryCaSystem(currentNetworkId, currentTransportStreamId,caDescriptor); - caSystems.Add(caSystem); - } + public bool ObjectCarouselFileArrival(VfsFile vfsFile, int transportStreamId, int networkId) + { + string outPath = String.Format("{0}{1}{2}{1}{3}{4}", networkId, Path.DirectorySeparatorChar, + transportStreamId, vfsFile.SourcePid, vfsFile.ToString()); + FileInfo outFileInfo = new FileInfo(outPath); + if (outFileInfo.Exists) + return false; + EnsureDirectoryExists(outFileInfo.Directory); + File.WriteAllBytes(outFileInfo.FullName, vfsFile.FileContent); + return true; + } - public bool TestForUpdateNotification(int hashCode, UpdateNotificationGroup common) - { - return updateHashes.Contains(hashCode); - } + public bool TestForCaSystem(int currentNetworkId, int currentTransportStreamId, int caDescriptorCaPid) + { + InMemoryCaSystem find = caSystems.Find(x => + x.CurrentNetworkId == currentNetworkId && x.CurrentTransportStreamId == currentTransportStreamId && + x.CaPid == caDescriptorCaPid); + return find != null; + } - public void StoreUpdateNotification(int hashCode, UpdateNotificationGroup common, Compatibility compatibility, Platform platform) - { - updateHashes.Add(hashCode); - updates.Add(new Tuple(hashCode, compatibility, platform)); - } - - public void DataCarouselModuleArrival(int currentNetworkId, int currentTransportStreamId, int elementaryPid, ushort moduleModuleId, byte moduleModuleVersion, Stream result) - { - string outPath = String.Format("{0}{1}{2}{1}{3}{1}{4}_{5}.bin", currentNetworkId, Path.DirectorySeparatorChar, currentTransportStreamId, elementaryPid, moduleModuleId, moduleModuleVersion); - FileInfo fi = new FileInfo(outPath); - if (fi.Exists) - return; - EnsureDirectoryExists(fi.Directory); - FileStream fileStream = fi.OpenWrite(); - result.CopyTo(fileStream); - fileStream.Close(); - fileStream.Dispose(); + public void StoreCaSystem(int currentNetworkId, int currentTransportStreamId, CaDescriptor caDescriptor) + { + InMemoryCaSystem caSystem = new InMemoryCaSystem(currentNetworkId, currentTransportStreamId, caDescriptor); + caSystems.Add(caSystem); + } - DsmCcModuleXmlMemory.GetInstance().MarkComplete(currentNetworkId, currentTransportStreamId, elementaryPid, moduleModuleId, moduleModuleVersion); + public bool TestForUpdateNotification(int hashCode, UpdateNotificationGroup common) + { + return updateHashes.Contains(hashCode); + } + + public void StoreUpdateNotification(int hashCode, UpdateNotificationGroup common, Compatibility compatibility, + Platform platform) + { + updateHashes.Add(hashCode); + updates.Add(new Tuple(hashCode, compatibility, platform)); + } + + public void DataCarouselModuleArrival(int currentNetworkId, int currentTransportStreamId, int elementaryPid, + ushort moduleModuleId, byte moduleModuleVersion, Stream result) + { + string outPath = String.Format("{0}{1}{2}{1}{3}{1}{4}_{5}.bin", currentNetworkId, + Path.DirectorySeparatorChar, currentTransportStreamId, elementaryPid, moduleModuleId, + moduleModuleVersion); + FileInfo fi = new FileInfo(outPath); + if (fi.Exists) + return; + EnsureDirectoryExists(fi.Directory); + FileStream fileStream = fi.OpenWrite(); + result.CopyTo(fileStream); + fileStream.Close(); + fileStream.Dispose(); + + DsmCcModuleXmlMemory.GetInstance().MarkComplete(currentNetworkId, currentTransportStreamId, elementaryPid, + moduleModuleId, moduleModuleVersion); } - public bool TestForKnownRdsData(int currentNetworkId, int currentTransportStreamId, int programNumber) - { - if (rdsDataPresent == null) - return false; + public bool TestForKnownRdsData(int currentNetworkId, int currentTransportStreamId, int programNumber) + { + if (rdsDataPresent == null) + return false; - if (rdsDataPresent[currentNetworkId] == null) - return false; + if (rdsDataPresent[currentNetworkId] == null) + return false; - if (rdsDataPresent[currentNetworkId][currentTransportStreamId] == null) - return false; + if (rdsDataPresent[currentNetworkId][currentTransportStreamId] == null) + return false; - return rdsDataPresent[currentNetworkId][currentTransportStreamId][programNumber]; - } + return rdsDataPresent[currentNetworkId][currentTransportStreamId][programNumber]; + } - public void EnableRdsCollection(int currentNetworkId, int currentTransportStreamId, int programNumber) - { - if (rdsDataPresent == null) - rdsDataPresent = new bool[ushort.MaxValue][][]; + public void EnableRdsCollection(int currentNetworkId, int currentTransportStreamId, int programNumber) + { + if (rdsDataPresent == null) + rdsDataPresent = new bool[ushort.MaxValue][][]; - if (rdsDataPresent[currentNetworkId] == null) - rdsDataPresent[currentNetworkId] = new bool[ushort.MaxValue][]; + if (rdsDataPresent[currentNetworkId] == null) + rdsDataPresent[currentNetworkId] = new bool[ushort.MaxValue][]; - if (rdsDataPresent[currentNetworkId][currentTransportStreamId] == null) - rdsDataPresent[currentNetworkId][currentTransportStreamId] = new bool[ushort.MaxValue]; + if (rdsDataPresent[currentNetworkId][currentTransportStreamId] == null) + rdsDataPresent[currentNetworkId][currentTransportStreamId] = new bool[ushort.MaxValue]; - rdsDataPresent[currentNetworkId][currentTransportStreamId][programNumber] = true; - } + rdsDataPresent[currentNetworkId][currentTransportStreamId][programNumber] = true; + } - public bool UpdateRdsProgrammeServiceName(int currentNetworkId, int currentTransportStreamId, int programNumber, string programmeService2) - { - if (rdsProgrammeService == null) - rdsProgrammeService = new string[ushort.MaxValue][][]; + public bool UpdateRdsProgrammeServiceName(int currentNetworkId, int currentTransportStreamId, int programNumber, + string programmeService2) + { + if (rdsProgrammeService == null) + rdsProgrammeService = new string[ushort.MaxValue][][]; - if (rdsProgrammeService[currentNetworkId] == null) - rdsProgrammeService[currentNetworkId] = new string[ushort.MaxValue][]; + if (rdsProgrammeService[currentNetworkId] == null) + rdsProgrammeService[currentNetworkId] = new string[ushort.MaxValue][]; - if (rdsProgrammeService[currentNetworkId][currentTransportStreamId] == null) - rdsProgrammeService[currentNetworkId][currentTransportStreamId] = new string[ushort.MaxValue]; + if (rdsProgrammeService[currentNetworkId][currentTransportStreamId] == null) + rdsProgrammeService[currentNetworkId][currentTransportStreamId] = new string[ushort.MaxValue]; - bool result = !string.Equals(programmeService2, rdsProgrammeService[currentNetworkId][currentTransportStreamId][programNumber]); - rdsProgrammeService[currentNetworkId][currentTransportStreamId][programNumber] = programmeService2; - return result; - } + bool result = !string.Equals(programmeService2, + rdsProgrammeService[currentNetworkId][currentTransportStreamId][programNumber]); + rdsProgrammeService[currentNetworkId][currentTransportStreamId][programNumber] = programmeService2; + return result; + } - public bool UpdateRdsRadioText(int currentNetworkId, int currentTransportStreamId, int programNumber, string text) - { - InMemoryRdsText child = new InMemoryRdsText(currentNetworkId, currentTransportStreamId, programNumber, text); - bool add = rdsTexts.Add(child); - return add; - } + public bool UpdateRdsRadioText(int currentNetworkId, int currentTransportStreamId, int programNumber, + string text) + { + InMemoryRdsText child = + new InMemoryRdsText(currentNetworkId, currentTransportStreamId, programNumber, text); + bool add = rdsTexts.Add(child); + return add; + } - public bool UpdateRdsPty(int currentNetworkId, int currentTransportStreamId, int programNumber, PTY.ProgrammeTypeCodes pty) - { - if (ptyCodes[currentNetworkId] == null) - ptyCodes[currentNetworkId] = new PTY.ProgrammeTypeCodes[ushort.MaxValue][]; + public bool UpdateRdsPty(int currentNetworkId, int currentTransportStreamId, int programNumber, + PTY.ProgrammeTypeCodes pty) + { + if (ptyCodes[currentNetworkId] == null) + ptyCodes[currentNetworkId] = new PTY.ProgrammeTypeCodes[ushort.MaxValue][]; - if (ptyCodes[currentNetworkId][currentTransportStreamId] == null) - ptyCodes[currentNetworkId][currentTransportStreamId] = new PTY.ProgrammeTypeCodes[ushort.MaxValue]; + if (ptyCodes[currentNetworkId][currentTransportStreamId] == null) + ptyCodes[currentNetworkId][currentTransportStreamId] = new PTY.ProgrammeTypeCodes[ushort.MaxValue]; - if (ptyCodes[currentNetworkId][currentTransportStreamId][programNumber] != pty) - { - ptyCodes[currentNetworkId][currentTransportStreamId][programNumber] = pty; - return true; - } + if (ptyCodes[currentNetworkId][currentTransportStreamId][programNumber] != pty) + { + ptyCodes[currentNetworkId][currentTransportStreamId][programNumber] = pty; + return true; + } - return false; - } + return false; + } - public bool MarkAsRdsTrafficInformationProgramme(int currentNetworkId, int currentTransportStreamId, int programNumber) - { - if (rdsTrafficInformationPreset == null) - rdsTrafficInformationPreset = new bool[ushort.MaxValue][][]; + public bool MarkAsRdsTrafficInformationProgramme(int currentNetworkId, int currentTransportStreamId, + int programNumber) + { + if (rdsTrafficInformationPreset == null) + rdsTrafficInformationPreset = new bool[ushort.MaxValue][][]; - if (rdsTrafficInformationPreset[currentNetworkId] == null) - rdsTrafficInformationPreset[currentNetworkId] = new bool[ushort.MaxValue][]; + if (rdsTrafficInformationPreset[currentNetworkId] == null) + rdsTrafficInformationPreset[currentNetworkId] = new bool[ushort.MaxValue][]; - if (rdsTrafficInformationPreset[currentNetworkId][currentTransportStreamId] == null) - rdsTrafficInformationPreset[currentNetworkId][currentTransportStreamId] = new bool[ushort.MaxValue]; + if (rdsTrafficInformationPreset[currentNetworkId][currentTransportStreamId] == null) + rdsTrafficInformationPreset[currentNetworkId][currentTransportStreamId] = new bool[ushort.MaxValue]; - if (!rdsTrafficInformationPreset[currentNetworkId][currentTransportStreamId][programNumber]) - { - rdsTrafficInformationPreset[currentNetworkId][currentTransportStreamId][programNumber] = true; - return true; - } - return false; - } + if (!rdsTrafficInformationPreset[currentNetworkId][currentTransportStreamId][programNumber]) + { + rdsTrafficInformationPreset[currentNetworkId][currentTransportStreamId][programNumber] = true; + return true; + } - public bool TestForScte35SpliceInsert(int currentNetworkId, int currentTransportStreamId, ushort programNumber, SpliceInsert spliceInsert) - { - Scte35SpliceCoordinate scte35sc = new Scte35SpliceCoordinate(currentNetworkId, currentTransportStreamId, programNumber, spliceInsert.SpliceEventId); - return scte35SpliceCoordinates.Contains(scte35sc); - } - - public void StoreScte35SpliceInsert(int currentNetworkId, int currentTransportStreamId, ushort programNumber, SpliceInsert spliceInsert) - { - Scte35SpliceCoordinate scte35sc = new Scte35SpliceCoordinate(currentNetworkId, currentTransportStreamId, programNumber, spliceInsert.SpliceEventId); - scte35SpliceCoordinates.Add(scte35sc); - } + return false; + } - public bool IsCompliant(int currentNetworkId, int currentTransportStreamId, string compliance) - { - ComplianceCoordiante cc = new ComplianceCoordiante(currentNetworkId, currentTransportStreamId, compliance); - return compliances.Contains(cc); - } + public bool TestForScte35SpliceInsert(int currentNetworkId, int currentTransportStreamId, ushort programNumber, + SpliceInsert spliceInsert) + { + Scte35SpliceCoordinate scte35sc = new Scte35SpliceCoordinate(currentNetworkId, currentTransportStreamId, + programNumber, spliceInsert.SpliceEventId); + return scte35SpliceCoordinates.Contains(scte35sc); + } - public void MarkAsCompliant(int currentNetworkId, int currentTransportStreamId, string compliance) - { - ComplianceCoordiante cc = new ComplianceCoordiante(currentNetworkId, currentTransportStreamId, compliance); - compliances.Add(cc); - } + public void StoreScte35SpliceInsert(int currentNetworkId, int currentTransportStreamId, ushort programNumber, + SpliceInsert spliceInsert) + { + Scte35SpliceCoordinate scte35sc = new Scte35SpliceCoordinate(currentNetworkId, currentTransportStreamId, + programNumber, spliceInsert.SpliceEventId); + scte35SpliceCoordinates.Add(scte35sc); + } - public bool SetStationIdentification(int currentNetworkId, int currentTransportStreamId, string newSi) - { - if (stationIdentification[currentNetworkId] == null) - stationIdentification[currentNetworkId] = new string[ushort.MaxValue]; + public bool IsCompliant(int currentNetworkId, int currentTransportStreamId, string compliance) + { + ComplianceCoordiante cc = new ComplianceCoordiante(currentNetworkId, currentTransportStreamId, compliance); + return compliances.Contains(cc); + } - bool result = !newSi.Equals(stationIdentification[currentNetworkId][currentTransportStreamId]); - stationIdentification[currentNetworkId][currentTransportStreamId] = newSi; - return result; - } - - public bool IsDsmCcModuleWanted(int currentNetworkId, int currentTransportStreamId, int elementaryPid, ushort moduleId, byte moduleVersion) - { - return DsmCcModuleXmlMemory.GetInstance().IsWanted(currentNetworkId, currentTransportStreamId,elementaryPid, moduleId, moduleVersion); - } + public void MarkAsCompliant(int currentNetworkId, int currentTransportStreamId, string compliance) + { + ComplianceCoordiante cc = new ComplianceCoordiante(currentNetworkId, currentTransportStreamId, compliance); + compliances.Add(cc); + } - public void StoreDsmCcDoItNowEvent(DateTime timestamp, int currentNetworkId, int currentTransportStreamId, int programNumber, StreamEventDescriptor descriptorListStreamEventDescriptor, int pid) - { + public bool SetStationIdentification(int currentNetworkId, int currentTransportStreamId, string newSi) + { + if (stationIdentification[currentNetworkId] == null) + stationIdentification[currentNetworkId] = new string[ushort.MaxValue]; - } + bool result = !newSi.Equals(stationIdentification[currentNetworkId][currentTransportStreamId]); + stationIdentification[currentNetworkId][currentTransportStreamId] = newSi; + return result; + } - public bool StoreRunningStatus(uint transportStreamId, uint originalNetworkId, uint serviceId, uint eventId, RunningStatus runningStatus, DateTime currentTime) - { - RstCoordinates rstCoordinates = new RstCoordinates(originalNetworkId, transportStreamId, serviceId, eventId, runningStatus, currentTime); - return this.rstCoordinates.Add(rstCoordinates); - } + public bool IsDsmCcModuleWanted(int currentNetworkId, int currentTransportStreamId, int elementaryPid, + ushort moduleId, byte moduleVersion) + { + return DsmCcModuleXmlMemory.GetInstance().IsWanted(currentNetworkId, currentTransportStreamId, + elementaryPid, moduleId, moduleVersion); + } - public void SetScte35TimeSignal(int currentNetworkId, int currentTransportStreamId, DateTime currentTime, ushort programNumber, TimeSignal timeSignal) - { + public void StoreDsmCcDoItNowEvent(DateTime timestamp, int currentNetworkId, int currentTransportStreamId, + int programNumber, StreamEventDescriptor descriptorListStreamEventDescriptor, int pid) + { - } + } - public bool TestForFramegrab(int currentNetworkId, int transportStreamId, ushort mappingProgramNumber, int mappingStreamElementaryPid) - { - FileInfo fi = new FileInfo(Path.Combine("screenshots", currentNetworkId.ToString(), transportStreamId.ToString(), String.Format("{0}.jpg", mappingProgramNumber))); - return fi.Exists; - } + public bool StoreRunningStatus(uint transportStreamId, uint originalNetworkId, uint serviceId, uint eventId, + RunningStatus runningStatus, DateTime currentTime) + { + RstCoordinates rstCoordinates = new RstCoordinates(originalNetworkId, transportStreamId, serviceId, eventId, + runningStatus, currentTime); + return this.rstCoordinates.Add(rstCoordinates); + } - public void StoreFramegrab(int currentNetworkId, int transportStreamId, ushort mappingProgramNumber, ushort pid, byte[] imageData) - { - FileInfo fi = new FileInfo(Path.Combine("screenshots", currentNetworkId.ToString(), transportStreamId.ToString(), String.Format("{0}.jpg", mappingProgramNumber))); - fi.Directory.EnsureExists(); - File.WriteAllBytes(fi.FullName, imageData); - } + public void SetScte35TimeSignal(int currentNetworkId, int currentTransportStreamId, DateTime currentTime, + ushort programNumber, TimeSignal timeSignal) + { - private HashSet _docsisUpstreamChannelCoordinates; - public bool TestForDocsisUpstreamChannel(PhysicalAddress mmmSource, uint mmmFrequency, int locationId) - { - if (_docsisUpstreamChannelCoordinates == null) - return false; + } - DocsisUpstreamChannelCoordinate coord = new DocsisUpstreamChannelCoordinate(mmmSource, mmmFrequency); - return _docsisUpstreamChannelCoordinates.Contains(coord); - } + public bool TestForFramegrab(int currentNetworkId, int transportStreamId, ushort mappingProgramNumber, + int mappingStreamElementaryPid) + { + FileInfo fi = new FileInfo(Path.Combine("screenshots", currentNetworkId.ToString(), + transportStreamId.ToString(), String.Format("{0}.jpg", mappingProgramNumber))); + return fi.Exists; + } - public void StoreDocsisUpstreamChannel(UpstreamChannelDescriptor mmm, int locationId) - { - if (!mmm.Frequency.HasValue) - return; + public void StoreFramegrab(int currentNetworkId, int transportStreamId, ushort mappingProgramNumber, ushort pid, + byte[] imageData) + { + FileInfo fi = new FileInfo(Path.Combine("screenshots", currentNetworkId.ToString(), + transportStreamId.ToString(), String.Format("{0}.jpg", mappingProgramNumber))); + fi.Directory.EnsureExists(); + File.WriteAllBytes(fi.FullName, imageData); + } - if (_docsisUpstreamChannelCoordinates == null) - _docsisUpstreamChannelCoordinates = new HashSet(); + private HashSet _docsisUpstreamChannelCoordinates; - DocsisUpstreamChannelCoordinate coord = new DocsisUpstreamChannelCoordinate(mmm.Source, mmm.Frequency.Value); - _docsisUpstreamChannelCoordinates.Add(coord); - } + public bool TestForDocsisUpstreamChannel(PhysicalAddress mmmSource, uint mmmFrequency, int locationId) + { + if (_docsisUpstreamChannelCoordinates == null) + return false; - private HashSet _docsisDownstreamChannelCoordinates; - public bool TestForDocsisDownstreamChannel(PhysicalAddress physicalAddress, MacDomainDescriptor.DownstreamActiveChannel downstreamActiveChannel, int locationId) - { - if (_docsisDownstreamChannelCoordinates == null) - return false; + DocsisUpstreamChannelCoordinate coord = new DocsisUpstreamChannelCoordinate(mmmSource, mmmFrequency); + return _docsisUpstreamChannelCoordinates.Contains(coord); + } - DocsisUpstreamChannelCoordinate coord = new DocsisUpstreamChannelCoordinate(physicalAddress, downstreamActiveChannel.Frequency.Value); - return _docsisDownstreamChannelCoordinates.Contains(coord); - } + public void StoreDocsisUpstreamChannel(UpstreamChannelDescriptor mmm, int locationId) + { + if (!mmm.Frequency.HasValue) + return; - public void StoreDocsisDownstreamChannel(PhysicalAddress physicalAddress, MacDomainDescriptor.DownstreamActiveChannel downstreamActiveChannel, int locationId) - { - if (_docsisDownstreamChannelCoordinates == null) - _docsisDownstreamChannelCoordinates = new HashSet(); + if (_docsisUpstreamChannelCoordinates == null) + _docsisUpstreamChannelCoordinates = new HashSet(); - DocsisUpstreamChannelCoordinate coord = new DocsisUpstreamChannelCoordinate(physicalAddress, downstreamActiveChannel.Frequency.Value); - _docsisDownstreamChannelCoordinates.Add(coord); - } + DocsisUpstreamChannelCoordinate + coord = new DocsisUpstreamChannelCoordinate(mmm.Source, mmm.Frequency.Value); + _docsisUpstreamChannelCoordinates.Add(coord); + } - private Dictionary cmtsIpAddresses; - public bool SetCmtsIp(PhysicalAddress arpHeaderSenderHardwareAddress, IPAddress arpHeaderSenderProtocolAddress) - { - if (cmtsIpAddresses == null) - cmtsIpAddresses = new Dictionary(); + private HashSet _docsisDownstreamChannelCoordinates; - if (cmtsIpAddresses.ContainsKey(arpHeaderSenderHardwareAddress)) - { - bool result = cmtsIpAddresses[arpHeaderSenderHardwareAddress].Equals(arpHeaderSenderProtocolAddress); - cmtsIpAddresses[arpHeaderSenderHardwareAddress] = arpHeaderSenderProtocolAddress; - return !result; - } - else - { - cmtsIpAddresses[arpHeaderSenderHardwareAddress] = arpHeaderSenderProtocolAddress; - return true; - } - } + public bool TestForDocsisDownstreamChannel(PhysicalAddress physicalAddress, + MacDomainDescriptor.DownstreamActiveChannel downstreamActiveChannel, int locationId) + { + if (_docsisDownstreamChannelCoordinates == null) + return false; - private DsmCcModuleBlacklist dsmCcBlacklist; - public bool IsDsmCcModuleBlacklisted(int currentNetworkId, int currentTransportStreamId, int elementaryPid, ushort moduleId, - byte moduleVersion) - { - if (dsmCcBlacklist == null) - { - FileInfo fi = new FileInfo("dsmcc_blacklist.csv"); - dsmCcBlacklist = new DsmCcModuleBlacklist(fi); - } + DocsisUpstreamChannelCoordinate coord = + new DocsisUpstreamChannelCoordinate(physicalAddress, downstreamActiveChannel.Frequency.Value); + return _docsisDownstreamChannelCoordinates.Contains(coord); + } - return dsmCcBlacklist.IsBlacklisted(currentNetworkId, currentTransportStreamId, elementaryPid, moduleId, moduleVersion); - } + public void StoreDocsisDownstreamChannel(PhysicalAddress physicalAddress, + MacDomainDescriptor.DownstreamActiveChannel downstreamActiveChannel, int locationId) + { + if (_docsisDownstreamChannelCoordinates == null) + _docsisDownstreamChannelCoordinates = new HashSet(); - public int? GetCurrentLocationId() - { - if (!File.Exists("docsis_location.txt")) - return 0; - else - { - string readAllText = File.ReadAllText("docsis_location.txt"); - return Int32.Parse(readAllText); - } - } + DocsisUpstreamChannelCoordinate coord = + new DocsisUpstreamChannelCoordinate(physicalAddress, downstreamActiveChannel.Frequency.Value); + _docsisDownstreamChannelCoordinates.Add(coord); + } - private Dictionary docsisParticipants; - public void StoreDocsisParticipant(PhysicalAddress pa, int currentLocation) - { - if (docsisParticipants == null) - docsisParticipants = new Dictionary(); - if (!docsisParticipants.ContainsKey(pa)) - docsisParticipants.Add(pa, currentLocation); - } - - public bool TestForIpMacNotification(IpMacNotification notification) - { - IpMacNotification ipMacNotification = ipMacNotificationCoordinates.Find(x => x.Equals(notification)); - return ipMacNotification != null; - } + private Dictionary cmtsIpAddresses; - public void StoreIpMacNotification(IpMacNotification notification) - { - ipMacNotificationCoordinates.Add(notification); - } + public bool SetCmtsIp(PhysicalAddress arpHeaderSenderHardwareAddress, IPAddress arpHeaderSenderProtocolAddress) + { + if (cmtsIpAddresses == null) + cmtsIpAddresses = new Dictionary(); - #region Ts File Collection Importer + if (cmtsIpAddresses.ContainsKey(arpHeaderSenderHardwareAddress)) + { + bool result = cmtsIpAddresses[arpHeaderSenderHardwareAddress].Equals(arpHeaderSenderProtocolAddress); + cmtsIpAddresses[arpHeaderSenderHardwareAddress] = arpHeaderSenderProtocolAddress; + return !result; + } + else + { + cmtsIpAddresses[arpHeaderSenderHardwareAddress] = arpHeaderSenderProtocolAddress; + return true; + } + } - private KnownTsMemory knownTss; + private DsmCcModuleBlacklist dsmCcBlacklist; - public void ImportMarkFileAsKnown(FileInfo fi, TimeSpan ts, int tstype) - { - if (knownTss == null) - knownTss = new KnownTsMemory("known_ts_filenames.json"); - knownTss.ImportMarkFileAsKnown(fi, ts, tstype); - } + public bool IsDsmCcModuleBlacklisted(int currentNetworkId, int currentTransportStreamId, int elementaryPid, + ushort moduleId, + byte moduleVersion) + { + if (dsmCcBlacklist == null) + { + FileInfo fi = new FileInfo("dsmcc_blacklist.csv"); + dsmCcBlacklist = new DsmCcModuleBlacklist(fi); + } - public bool ImportFileKnown(FileInfo fi) - { + return dsmCcBlacklist.IsBlacklisted(currentNetworkId, currentTransportStreamId, elementaryPid, moduleId, + moduleVersion); + } + + public int? GetCurrentLocationId() + { + if (!File.Exists("docsis_location.txt")) + return 0; + else + { + string readAllText = File.ReadAllText("docsis_location.txt"); + return Int32.Parse(readAllText); + } + } + + private Dictionary docsisParticipants; + + public void StoreDocsisParticipant(PhysicalAddress pa, int currentLocation) + { + if (docsisParticipants == null) + docsisParticipants = new Dictionary(); + if (!docsisParticipants.ContainsKey(pa)) + docsisParticipants.Add(pa, currentLocation); + } + + public bool TestForIpMacNotification(IpMacNotification notification) + { + IpMacNotification ipMacNotification = ipMacNotificationCoordinates.Find(x => x.Equals(notification)); + return ipMacNotification != null; + } + + public void StoreIpMacNotification(IpMacNotification notification) + { + ipMacNotificationCoordinates.Add(notification); + } + + #region Ts File Collection Importer + + private KnownTsMemory knownTss; + + public void ImportMarkFileAsKnown(FileInfo fi, TimeSpan ts, int tstype) + { + if (knownTss == null) + knownTss = new KnownTsMemory("known_ts_filenames.json"); + knownTss.ImportMarkFileAsKnown(fi, ts, tstype); + } + + public bool ImportFileKnown(FileInfo fi) + { if (knownTss == null) knownTss = new KnownTsMemory("known_ts_filenames.json"); return knownTss.ImportFileKnown(fi); } - #endregion - public DateTime T2MiGetTimestamp(int currentNetworkId, int currentTransportStreamId, int pid) - { - if (t2MiTimestamps == null) - return DateTime.MinValue; + #endregion - if (t2MiTimestamps[currentNetworkId] == null) - return DateTime.MinValue; - - if (t2MiTimestamps[currentNetworkId][currentTransportStreamId] == null) - return DateTime.MinValue; + public DateTime T2MiGetTimestamp(int currentNetworkId, int currentTransportStreamId, int pid) + { + if (t2MiTimestamps == null) + return DateTime.MinValue; - return t2MiTimestamps[currentNetworkId][currentTransportStreamId][pid]; - } + if (t2MiTimestamps[currentNetworkId] == null) + return DateTime.MinValue; - public void T2MiSetTimestamp(int currentNetworkId, int currentTransportStreamId, int pid, DateTime resolveTime) - { - if (t2MiTimestamps == null) - t2MiTimestamps = new DateTime[ushort.MaxValue][][]; + if (t2MiTimestamps[currentNetworkId][currentTransportStreamId] == null) + return DateTime.MinValue; - if (t2MiTimestamps[currentNetworkId] == null) - t2MiTimestamps[currentNetworkId] = new DateTime[ushort.MaxValue][]; + return t2MiTimestamps[currentNetworkId][currentTransportStreamId][pid]; + } - if (t2MiTimestamps[currentNetworkId][currentTransportStreamId] == null) - t2MiTimestamps[currentNetworkId][currentTransportStreamId] = new DateTime[0x1fff]; + public void T2MiSetTimestamp(int currentNetworkId, int currentTransportStreamId, int pid, DateTime resolveTime) + { + if (t2MiTimestamps == null) + t2MiTimestamps = new DateTime[ushort.MaxValue][][]; - t2MiTimestamps[currentNetworkId][currentTransportStreamId][pid] = resolveTime; - } + if (t2MiTimestamps[currentNetworkId] == null) + t2MiTimestamps[currentNetworkId] = new DateTime[ushort.MaxValue][]; - public bool TestForRelatedContent(EitEvent lEvent, RctLinkInfo rctLinkInfo) - { - throw new NotImplementedException(); - } + if (t2MiTimestamps[currentNetworkId][currentTransportStreamId] == null) + t2MiTimestamps[currentNetworkId][currentTransportStreamId] = new DateTime[0x1fff]; - public void SetRelatedContent(EitEvent lEvent, RctLinkInfo rctLinkInfo) - { - throw new NotImplementedException(); - } + t2MiTimestamps[currentNetworkId][currentTransportStreamId][pid] = resolveTime; + } - private List satellitePositions; - public List UiSatellitesListAll() - { - if (satellitePositions == null) - satellitePositions = new List(); - return satellitePositions.ToList(); - } + public bool TestForRelatedContent(EitEvent lEvent, RctLinkInfo rctLinkInfo) + { + throw new NotImplementedException(); + } - public void UiSatellitesAdd(SatellitePosition newPosition) - { - if (satellitePositions == null) - satellitePositions = new List(); - satellitePositions.Add(newPosition); - } + public void SetRelatedContent(EitEvent lEvent, RctLinkInfo rctLinkInfo) + { + throw new NotImplementedException(); + } - public void UiSatellitesDelete(SatellitePosition satellitePosition) - { - satellitePositions.RemoveAll(x => x.Checksum == satellitePosition.Checksum); - } + private List satellitePositions; - private List uiTuners; - public bool UiTunerTestFor(TunerMetadata tuner) - { - if (uiTuners == null) - return false; + public List UiSatellitesListAll() + { + if (satellitePositions == null) + satellitePositions = new List(); + return satellitePositions.ToList(); + } - return uiTuners.Exists(x => x.MacAddress.Equals(tuner.MacAddress)); - } + public void UiSatellitesAdd(SatellitePosition newPosition) + { + if (satellitePositions == null) + satellitePositions = new List(); + satellitePositions.Add(newPosition); + } - public void UiTunerUpdate(TunerMetadata tuner) - { - TunerMetadata copy = uiTuners.Find(x => x.MacAddress.Equals(tuner.MacAddress)); - copy.DiseqcType = tuner.DiseqcType; - copy.Satellites[0] = tuner.Satellites[0]; - copy.Satellites[1] = tuner.Satellites[1]; - copy.Satellites[2] = tuner.Satellites[2]; - copy.Satellites[3] = tuner.Satellites[3]; - } + public void UiSatellitesDelete(SatellitePosition satellitePosition) + { + satellitePositions.RemoveAll(x => x.Checksum == satellitePosition.Checksum); + } - public void UiTunerInsert(TunerMetadata tuner) - { - TunerMetadata copy = new TunerMetadata(tuner.Index, tuner.Name, tuner.Type); - copy.DiseqcType = tuner.DiseqcType; - copy.MacAddress = new PhysicalAddress(tuner.MacAddress.GetAddressBytes()); - copy.Satellites = new int[4]; - copy.Satellites[0] = tuner.Satellites[0]; - copy.Satellites[1] = tuner.Satellites[1]; - copy.Satellites[2] = tuner.Satellites[2]; - copy.Satellites[3] = tuner.Satellites[3]; - copy.Caps = tuner.Caps; - uiTuners.Add(copy); - } + private List uiTuners; - public void UiTunerGetConfiguration(TunerMetadata foundTuner) - { - TunerMetadata copy = uiTuners.Find(x => x.MacAddress.Equals(foundTuner.MacAddress)); - foundTuner.DiseqcType = copy.DiseqcType; - foundTuner.Satellites = new int[4]; - foundTuner.Satellites[0] = copy.Satellites[0]; - foundTuner.Satellites[1] = copy.Satellites[1]; - foundTuner.Satellites[2] = copy.Satellites[2]; - foundTuner.Satellites[3] = copy.Satellites[3]; - } + public bool UiTunerTestFor(TunerMetadata tuner) + { + if (uiTuners == null) + return false; - private void EnsureDirectoryExists(DirectoryInfo di) - { - if (di.Exists) - return; - EnsureDirectoryExists(di.Parent); - di.Create(); - } + return uiTuners.Exists(x => x.MacAddress.Equals(tuner.MacAddress)); + } - public HeadlessJob GetQueuedJob() - { - throw new NotImplementedException(); - } + public void UiTunerUpdate(TunerMetadata tuner) + { + TunerMetadata copy = uiTuners.Find(x => x.MacAddress.Equals(tuner.MacAddress)); + copy.DiseqcType = tuner.DiseqcType; + copy.Satellites[0] = tuner.Satellites[0]; + copy.Satellites[1] = tuner.Satellites[1]; + copy.Satellites[2] = tuner.Satellites[2]; + copy.Satellites[3] = tuner.Satellites[3]; + } - public void SetQueuedJobComplete(HeadlessJob headlessJob) - { - throw new NotImplementedException(); - } + public void UiTunerInsert(TunerMetadata tuner) + { + TunerMetadata copy = new TunerMetadata(tuner.Index, tuner.Name, tuner.Type); + copy.DiseqcType = tuner.DiseqcType; + copy.MacAddress = new PhysicalAddress(tuner.MacAddress.GetAddressBytes()); + copy.Satellites = new int[4]; + copy.Satellites[0] = tuner.Satellites[0]; + copy.Satellites[1] = tuner.Satellites[1]; + copy.Satellites[2] = tuner.Satellites[2]; + copy.Satellites[3] = tuner.Satellites[3]; + copy.Caps = tuner.Caps; + uiTuners.Add(copy); + } - public void WaitForCompletion() - { - //We're doing in-memory operations, so we'll won't have to wait for anything. - } + public void UiTunerGetConfiguration(TunerMetadata foundTuner) + { + TunerMetadata copy = uiTuners.Find(x => x.MacAddress.Equals(foundTuner.MacAddress)); + foundTuner.DiseqcType = copy.DiseqcType; + foundTuner.Satellites = new int[4]; + foundTuner.Satellites[0] = copy.Satellites[0]; + foundTuner.Satellites[1] = copy.Satellites[1]; + foundTuner.Satellites[2] = copy.Satellites[2]; + foundTuner.Satellites[3] = copy.Satellites[3]; + } - public void UiSetVersion(int version) - { - //Since we're working solely in memory, we won't need to remember this. - } + private void EnsureDirectoryExists(DirectoryInfo di) + { + if (di.Exists) + return; + EnsureDirectoryExists(di.Parent); + di.Create(); + } - public bool T2MiTestForTransmitter(int? currentNetworkId, int? currentTransportStreamId, int relatedPid, ushort txIdentifier) - { - throw new NotImplementedException(); - } + public HeadlessJob GetQueuedJob() + { + throw new NotImplementedException(); + } - public void T2MiRememberTransmitter(int? currentNetworkId, int? currentTransportStreamId, int relatedPid, ushort txIdentifier) - { - throw new NotImplementedException(); - } + public void SetQueuedJobComplete(HeadlessJob headlessJob) + { + throw new NotImplementedException(); + } - public void T2MiSetTransmitterTimeOffset(int? currentNetworkId, int? currentTransportStreamId, int relatedPid, ushort txIdentifier, ushort timeOffset) - { - throw new NotImplementedException(); - } + public void WaitForCompletion() + { + //We're doing in-memory operations, so we'll won't have to wait for anything. + } - private List _lnbTypes; - public List UiLnbTypesListAll() - { - if (_lnbTypes == null) - _lnbTypes = new List(); - return _lnbTypes; - } + public void UiSetVersion(int version) + { + //Since we're working solely in memory, we won't need to remember this. + } - public void UiLnbTypesAdd(LnbType defaultLnbType) - { + public bool T2MiTestForTransmitter(int? currentNetworkId, int? currentTransportStreamId, int relatedPid, + ushort txIdentifier) + { + throw new NotImplementedException(); + } + + public void T2MiRememberTransmitter(int? currentNetworkId, int? currentTransportStreamId, int relatedPid, + ushort txIdentifier) + { + throw new NotImplementedException(); + } + + public void T2MiSetTransmitterTimeOffset(int? currentNetworkId, int? currentTransportStreamId, int relatedPid, + ushort txIdentifier, ushort timeOffset) + { + throw new NotImplementedException(); + } + + private List _lnbTypes; + + public List UiLnbTypesListAll() + { + if (_lnbTypes == null) + _lnbTypes = new List(); + return _lnbTypes; + } + + public void UiLnbTypesAdd(LnbType defaultLnbType) + { if (_lnbTypes == null) _lnbTypes = new List(); if (!_lnbTypes.Contains(defaultLnbType)) _lnbTypes.Add(defaultLnbType); - } + } - private List _dishTypes; - public List UiDishTypesListAll() - { - if (_dishTypes == null) - _dishTypes = new List(); - return _dishTypes; + private List _dishTypes; - } + public List UiDishTypesListAll() + { + if (_dishTypes == null) + _dishTypes = new List(); + return _dishTypes; - public void UiDishTypesAdd(DishType defaultDishType) - { - if (_dishTypes == null) - _dishTypes = new List(); - if (!_dishTypes.Contains(defaultDishType)) - _dishTypes.Add(defaultDishType); - } + } - public object[] GetPluginConnector() - { - return new object[] { pluginToken }; - } + public void UiDishTypesAdd(DishType defaultDishType) + { + if (_dishTypes == null) + _dishTypes = new List(); + if (!_dishTypes.Contains(defaultDishType)) + _dishTypes.Add(defaultDishType); + } - public void Ping() - { - - } + public object[] GetPluginConnector() + { + return new object[] { pluginToken }; + } - public IEnumerable> SelectAllPmt() - { - for (int x = 0; x < pmtEntries.Length; x++) - { - if (pmtEntries[x] == null) - continue; + public void Ping() + { - for (int y = 0; y < pmtEntries[x].Length; y++) - { - if (pmtEntries[x][y] == null) - continue; + } - for (int z = 0; z < pmtEntries[x][y].Length; z++) - { - if (pmtEntries[x][y][z] == null) - continue; + public IEnumerable> SelectAllPmt() + { + for (int x = 0; x < pmtEntries.Length; x++) + { + if (pmtEntries[x] == null) + continue; - yield return new Tuple(y, x, pmtEntries[x][y][z]); - } - } - } + for (int y = 0; y < pmtEntries[x].Length; y++) + { + if (pmtEntries[x][y] == null) + continue; - yield break; - } + for (int z = 0; z < pmtEntries[x][y].Length; z++) + { + if (pmtEntries[x][y][z] == null) + continue; - public SdtService SelectSdtById(int x, int y, ushort programMappingProgramNumber) - { - if (sdtServices[y] == null) - return null; + yield return new Tuple(y, x, pmtEntries[x][y][z]); + } + } + } - if (sdtServices[y][x] == null) - return null; + yield break; + } - return sdtServices[y][x][programMappingProgramNumber]; - } + public SdtService SelectSdtById(int x, int y, ushort programMappingProgramNumber) + { + if (sdtServices[y] == null) + return null; - public IEnumerable> SelectAllSdt() - { - for (int x = 0; x < sdtServices.Length; x++) - { - if (sdtServices[x] == null) - continue; + if (sdtServices[y][x] == null) + return null; - for (int y = 0; y < sdtServices[x].Length; y++) - { - if (sdtServices[x][y] == null) - continue; + return sdtServices[y][x][programMappingProgramNumber]; + } - for (int z = 0; z < sdtServices[x][y].Length; z++) - { - if (sdtServices[x][y][z] != null) - { - yield return new Tuple(x, y, sdtServices[x][y][z]); - } - } - } - } + public IEnumerable> SelectAllSdt() + { + for (int x = 0; x < sdtServices.Length; x++) + { + if (sdtServices[x] == null) + continue; - yield break; - } + for (int y = 0; y < sdtServices[x].Length; y++) + { + if (sdtServices[x][y] == null) + continue; - public void BeamsDisableAll() - { - throw new NotImplementedException(); - } + for (int z = 0; z < sdtServices[x][y].Length; z++) + { + if (sdtServices[x][y][z] != null) + { + yield return new Tuple(x, y, sdtServices[x][y][z]); + } + } + } + } - public void BeamsEnable(int id, float satpos, string name, DateTime processTimestamp) - { - throw new NotImplementedException(); - } + yield break; + } - public void BeamFootprintStore(int databasePointerId, DateTime databasePointerBeamsProcessTimestamp, string name, - string getPolygonString, string id) - { - throw new NotImplementedException(); - } + public void BeamsDisableAll() + { + throw new NotImplementedException(); + } - public bool TestForBeamFootprint(int databasePointerId, DateTime databasePointerBeamsProcessTimestamp, string name,string id) - { - throw new NotImplementedException(); - } + public void BeamsEnable(int id, float satpos, string name, DateTime processTimestamp) + { + throw new NotImplementedException(); + } - public void BeamsDisableSpecific(int databasePointerId, float databasePointerSatpos, string databasePointerName, - DateTime databasePointerBeamsProcessTimestamp) - { - throw new NotImplementedException(); - } + public void BeamFootprintStore(int databasePointerId, DateTime databasePointerBeamsProcessTimestamp, + string name, + string getPolygonString, string id) + { + throw new NotImplementedException(); + } - public IEnumerable BeamsSelectEnabled() - { - throw new NotImplementedException(); - } + public bool TestForBeamFootprint(int databasePointerId, DateTime databasePointerBeamsProcessTimestamp, + string name, string id) + { + throw new NotImplementedException(); + } - public List BeamsSelectFootprints(int satelliteBeamId, DateTime satelliteBeamProcessTimestamp) - { - throw new NotImplementedException(); - } + public void BeamsDisableSpecific(int databasePointerId, float databasePointerSatpos, string databasePointerName, + DateTime databasePointerBeamsProcessTimestamp) + { + throw new NotImplementedException(); + } - private HashSet jobs; - public void InsertBlindscanJob(DbBlindscanJob jobInDb) - { - if (jobs == null) - jobs = new HashSet(); + public IEnumerable BeamsSelectEnabled() + { + throw new NotImplementedException(); + } - DbBlindscanJobContainer jobContainer = new DbBlindscanJobContainer(jobInDb); - jobs.Add(jobContainer); - } + public List BeamsSelectFootprints(int satelliteBeamId, + DateTime satelliteBeamProcessTimestamp) + { + throw new NotImplementedException(); + } - public void UpdateJobState(DbBlindscanJob jobInDb) - { + private HashSet jobs; - } + public void InsertBlindscanJob(DbBlindscanJob jobInDb) + { + if (jobs == null) + jobs = new HashSet(); + + DbBlindscanJobContainer jobContainer = new DbBlindscanJobContainer(jobInDb); + jobs.Add(jobContainer); + } + + public void UpdateJobState(DbBlindscanJob jobInDb) + { + + } - public void InsertSearchResult(DbBlindscanJob jobInDb, bool satellite, SearchResult searchResult, int polarityIndex, - SearchResult2 searchResult2) - { + public void InsertSearchResult(DbBlindscanJob jobInDb, bool satellite, SearchResult searchResult, + int polarityIndex, + SearchResult2 searchResult2) + { DbBlindscanJobContainer dbBlindscanJobContainer = jobs.First(x => x.JobGuid.Equals(jobInDb.JobGuid)); - if (dbBlindscanJobContainer == null) - throw new Exception("Failed to find the job."); + if (dbBlindscanJobContainer == null) + throw new Exception("Failed to find the job."); - dbBlindscanJobContainer.AddSearchResult(satellite, searchResult, polarityIndex, searchResult2); - } + dbBlindscanJobContainer.AddSearchResult(satellite, searchResult, polarityIndex, searchResult2); + } - public void UpdateTransponderState(DbBlindscanJob jobInDb, bool satellite, SearchResult searchResult, - BlindscanResultState blindscanResultState, SearchResult2 searchResult2) - { + public void UpdateTransponderState(DbBlindscanJob jobInDb, bool satellite, SearchResult searchResult, + BlindscanResultState blindscanResultState, SearchResult2 searchResult2) + { - } + } - public void InsertTransponderService(DbBlindscanJob jobInDb, bool resultSatellite, SearchResult resultSr1, - SearchResult2 resultSr2, HumanReadableService humanReadableService) - { + public void InsertTransponderService(DbBlindscanJob jobInDb, bool resultSatellite, SearchResult resultSr1, + SearchResult2 resultSr2, HumanReadableService humanReadableService) + { DbBlindscanJobContainer jobContainer = jobs.First(x => x.JobGuid.Equals(jobInDb.JobGuid)); if (jobContainer == null) throw new Exception("Failed to find the job."); - DbBlindscanJobContainer.SearchResultContainer searchResultContainer = jobContainer.GetSearchResult(resultSatellite, resultSr1, resultSr2); - if (searchResultContainer == null) - throw new Exception("Failed to find the search result."); - searchResultContainer.AddService(humanReadableService); + DbBlindscanJobContainer.SearchResultContainer searchResultContainer = + jobContainer.GetSearchResult(resultSatellite, resultSr1, resultSr2); + if (searchResultContainer == null) + throw new Exception("Failed to find the search result."); + searchResultContainer.AddService(humanReadableService); } public bool TestForIncompleteJob() - { - return false; - } + { + return false; + } - public DbBlindscanJob GetPastBlindscanJob(long offset) - { - throw new NotImplementedException(); - } + public DbBlindscanJob GetPastBlindscanJob(long offset) + { + throw new NotImplementedException(); + } public void DeleteBlindscanJob(Guid guid) { @@ -1108,7 +1172,8 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory throw new NotImplementedException(); } - public void StoreTerminalBurstTimePlan(ushort interactiveNetworkId, uint gtoupId, uint superframeCount, uint frameNumber, Tbtp.TbtpFrame.BtpEntity btp) + public void StoreTerminalBurstTimePlan(ushort interactiveNetworkId, uint gtoupId, uint superframeCount, + uint frameNumber, Tbtp.TbtpFrame.BtpEntity btp) { throw new NotImplementedException(); } @@ -1218,7 +1283,8 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory throw new NotImplementedException(); } - public bool NetworkLayerInfoTim(PhysicalAddress mac, _0xa0_NetworkLayerInfoDescriptor nlid, DateTime timestamped) + public bool NetworkLayerInfoTim(PhysicalAddress mac, _0xa0_NetworkLayerInfoDescriptor nlid, + DateTime timestamped) { throw new NotImplementedException(); } @@ -1235,10 +1301,10 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory public long DnsCountA() { - if (dnsRecords == null) - return 0; + if (dnsRecords == null) + return 0; - return dnsRecords.Count(x => x.RecordType.Item1 == 1); + return dnsRecords.Count(x => x.RecordType.Item1 == 1); } public string DnsIpToName(IPAddress source) @@ -1251,47 +1317,50 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory throw new NotImplementedException(); } - private HashSet dnsRecords; + private HashSet dnsRecords; + public void RememberDnsRecord(DnsRecord record) { - if (dnsRecords == null) - dnsRecords = new HashSet(); + if (dnsRecords == null) + dnsRecords = new HashSet(); - dnsRecords.Add(record); + dnsRecords.Add(record); } - private SgtList[] sgtLists; + private SgtList[] sgtLists; + public bool TestForSgtList(SgtList list) { - if (sgtLists == null) - return false; + if (sgtLists == null) + return false; - return sgtLists[list.ServiceListId] != null; + return sgtLists[list.ServiceListId] != null; } public void InsertSgtList(SgtList list) { - if (sgtLists == null) - sgtLists = new SgtList[ushort.MaxValue]; + if (sgtLists == null) + sgtLists = new SgtList[ushort.MaxValue]; - sgtLists[list.ServiceListId] = list; + sgtLists[list.ServiceListId] = list; } - private HashSet sgtServices; + private HashSet sgtServices; + public bool TestForSgtService(SgtService child) { - if (sgtServices == null) - return false; + if (sgtServices == null) + return false; - return sgtServices.Contains(child); + return sgtServices.Contains(child); } public void InsertSgtService(SgtService child) { - if (sgtServices == null) - sgtServices = new HashSet(); + if (sgtServices == null) + sgtServices = new HashSet(); - sgtServices.Add(child); + sgtServices.Add(child); } public bool DvbNipTestForFile(string announcedFileContentLocation) @@ -1305,7 +1374,7 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory { string filename = DvbNipUtilities.MakeFilename(listener.FileAssociation.ContentLocation); FileInfo fi = new FileInfo(filename); - fi.Directory.EnsureExists(); + fi.Directory.EnsureExists(); FileStream outStream = fi.OpenWrite(); Stream inStream = listener.ToStream(); inStream.CopyTo(outStream); @@ -1320,7 +1389,7 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory { public class NipSubPds { - public DateTime VersionUpdate { get; set; } + public DateTime VersionUpdate { get; set; } public List PrivateDataSessions { get; set; } public NipSubPds(DateTime versionUpdate, List privateDataSessions) @@ -1334,7 +1403,9 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory } private Dictionary _nipPrivateDataSpecifiers; - public bool DvbNipPrivateDataSpecifier(NipActualCarrierInformation currentCarrierInformation, DateTime versionUpdate, uint privateDataSpecifier, List privateDataSessions) + + public bool DvbNipPrivateDataSpecifier(NipActualCarrierInformation currentCarrierInformation, + DateTime versionUpdate, uint privateDataSpecifier, List privateDataSessions) { if (_nipPrivateDataSpecifiers == null) _nipPrivateDataSpecifiers = new Dictionary(); @@ -1361,7 +1432,7 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory oldPds.subs.Add(privateDataSpecifier, new NipPds.NipSubPds(versionUpdate, privateDataSessions)); return true; } - + } else { @@ -1373,6 +1444,7 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory } private BroadcastNetworkType[] nipBroadcastNetworkTypes; + public bool DvbNipTestForNetwork(BroadcastNetworkType network) { if (nipBroadcastNetworkTypes == null) @@ -1409,7 +1481,8 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory protected bool Equals(NipServiceCoordinate other) { - return ServiceId == other.ServiceId && LinkId == other.LinkId && CarrierId == other.CarrierId && NetworkId == other.NetworkId; + return ServiceId == other.ServiceId && LinkId == other.LinkId && CarrierId == other.CarrierId && + NetworkId == other.NetworkId; } public override bool Equals(object? obj) @@ -1427,6 +1500,7 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory } private Dictionary _dvbNipServices; + public bool DvbNipTestForService(BroadcastMediaStreamType broadcastMediaStreamType) { if (_dvbNipServices == null) @@ -1445,14 +1519,60 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory _dvbNipServices.Add(coords, broadcastMediaStreamType); } + private Dictionary _dvbNipMulticastSessions; + + public bool DvbNipTestForMulticastSession(MulticastSessionType multicastSession) + { + if (_dvbNipMulticastSessions == null) + return false; + + return _dvbNipMulticastSessions.ContainsKey(multicastSession.serviceIdentifier); + } + + public void DvbNipInsertMulticastSession(MulticastSessionType multicastSession) + { + if (_dvbNipMulticastSessions == null) + _dvbNipMulticastSessions = new Dictionary(); + + _dvbNipMulticastSessions[multicastSession.serviceIdentifier] = multicastSession; + } + + private Dictionary _nipMulticastGatewayConfigurationTransportSessions; + + public bool DvbNipTestForMulticastGatewayConfigurationTransportSession(NipActualCarrierInformation carrier, + MulticastEndpointAddressType multicastEndpointAddressType) + { + if (_nipMulticastGatewayConfigurationTransportSessions == null) + return false; + + DatabaseKeyNipMulticastGatewayConfigurationTransportSession key = + new DatabaseKeyNipMulticastGatewayConfigurationTransportSession(carrier, multicastEndpointAddressType); + return _nipMulticastGatewayConfigurationTransportSessions.ContainsKey(key); + } + + public void DvbNipInsertMulticastGatewayConfigurationTransportSession(NipActualCarrierInformation carrier, + MulticastGatewayConfigurationTransportSessionType multicastGatewayConfigurationTransportSession) + { + if (_nipMulticastGatewayConfigurationTransportSessions == null) + _nipMulticastGatewayConfigurationTransportSessions = + new Dictionary(); + + DatabaseKeyNipMulticastGatewayConfigurationTransportSession key = + new DatabaseKeyNipMulticastGatewayConfigurationTransportSession(carrier, + multicastGatewayConfigurationTransportSession.EndpointAddress[0]); + _nipMulticastGatewayConfigurationTransportSessions.Add(key, multicastGatewayConfigurationTransportSession); + } + public void InsertDvbiServiceListEntryPoint(long sourceHash) { - if (_dvbiServiceListEntryPointsCoordinates == null) - _dvbiServiceListEntryPointsCoordinates = new HashSet(); + if (_dvbiServiceListEntryPointsCoordinates == null) + _dvbiServiceListEntryPointsCoordinates = new HashSet(); - DvbiServiceListEntryPointsCoordinate coordinate = new DvbiServiceListEntryPointsCoordinate(); - coordinate.Hash = sourceHash; - _dvbiServiceListEntryPointsCoordinates.Add(coordinate); + DvbiServiceListEntryPointsCoordinate coordinate = new DvbiServiceListEntryPointsCoordinate(); + coordinate.Hash = sourceHash; + _dvbiServiceListEntryPointsCoordinates.Add(coordinate); } public bool TestForServiceListEntryPoints(long sourceHash) @@ -1462,10 +1582,10 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory public void InsertDvbiServiceList(DvbiServiceList serviceList) { - if (_dvbiServiceLists == null) - _dvbiServiceLists = new Dictionary(); + if (_dvbiServiceLists == null) + _dvbiServiceLists = new Dictionary(); - _dvbiServiceLists.Add(serviceList.Id, serviceList); + _dvbiServiceLists.Add(serviceList.Id, serviceList); } public bool TestForDvbiServiceList(string id) @@ -1486,7 +1606,7 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory public override bool Equals(object? obj) { return obj is DvbiServiceListEntryPointsCoordinate coordinate && - Hash == coordinate.Hash; + Hash == coordinate.Hash; } public override int GetHashCode() @@ -1494,43 +1614,46 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory return HashCode.Combine(Hash); } } + private HashSet _dvbiServiceListEntryPointsCoordinates; public void UpdateDvbiServiceListEntryPointUpdateDate(long v, DateTime currentTime) { - foreach(DvbiServiceListEntryPointsCoordinate coord in _dvbiServiceListEntryPointsCoordinates) - { - if (coord.Hash == v) - { - coord.LastUpdate = currentTime; - return; - } - } + foreach (DvbiServiceListEntryPointsCoordinate coord in _dvbiServiceListEntryPointsCoordinates) + { + if (coord.Hash == v) + { + coord.LastUpdate = currentTime; + return; + } + } } public bool TestForDvbiServiceListEntryPoints(long sourceHash) { - if (_dvbiServiceListEntryPointsCoordinates == null) - return false; + if (_dvbiServiceListEntryPointsCoordinates == null) + return false; foreach (DvbiServiceListEntryPointsCoordinate coord in _dvbiServiceListEntryPointsCoordinates) { if (coord.Hash == sourceHash) { - return true; + return true; } } - return false; + + return false; } - private Dictionary _dvbiServiceListLastChecked; + private Dictionary _dvbiServiceListLastChecked; + public void UpdateDvbiServiceListLastCheckedDate(string id, DateTime currentTime) { - if (_dvbiServiceListLastChecked == null) - _dvbiServiceListLastChecked = new Dictionary(); + if (_dvbiServiceListLastChecked == null) + _dvbiServiceListLastChecked = new Dictionary(); - _dvbiServiceListLastChecked[id] = currentTime; + _dvbiServiceListLastChecked[id] = currentTime; } public DateTime GetLastDvbiServiceListEntryPointUpdateDate(long sourceHash) @@ -1539,10 +1662,11 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory { if (coord.Hash == sourceHash) { - return coord.LastUpdate; + return coord.LastUpdate; } } - return DateTime.MinValue; + + return DateTime.MinValue; } public DateTime GetDvbiServiceListLastUpdateDate(string id) @@ -1550,65 +1674,68 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory throw new NotImplementedException(); } - private Dictionary> _dvbiServiceListEntryPointToServiceListMapping; + private Dictionary> _dvbiServiceListEntryPointToServiceListMapping; + public void AddDvbiServiceListToServiceListEntryPoint(DvbiServiceList serviceList, long sourceHash) { - if (_dvbiServiceListEntryPointToServiceListMapping == null) - _dvbiServiceListEntryPointToServiceListMapping = new Dictionary>(); + if (_dvbiServiceListEntryPointToServiceListMapping == null) + _dvbiServiceListEntryPointToServiceListMapping = new Dictionary>(); - if (!_dvbiServiceListEntryPointToServiceListMapping.ContainsKey(sourceHash)) - _dvbiServiceListEntryPointToServiceListMapping.Add(sourceHash, new List()); + if (!_dvbiServiceListEntryPointToServiceListMapping.ContainsKey(sourceHash)) + _dvbiServiceListEntryPointToServiceListMapping.Add(sourceHash, new List()); - if (!_dvbiServiceListEntryPointToServiceListMapping[sourceHash].Contains(serviceList.Id)) - _dvbiServiceListEntryPointToServiceListMapping[sourceHash].Add(serviceList.Id); + if (!_dvbiServiceListEntryPointToServiceListMapping[sourceHash].Contains(serviceList.Id)) + _dvbiServiceListEntryPointToServiceListMapping[sourceHash].Add(serviceList.Id); } - private Dictionary> _dvbiServiceToServiceListMapping; + private Dictionary> _dvbiServiceToServiceListMapping; + public void AddDvbiServiceToServiceList(string id, string serviceListId) { - if (_dvbiServiceToServiceListMapping == null) - _dvbiServiceToServiceListMapping = new Dictionary>(); + if (_dvbiServiceToServiceListMapping == null) + _dvbiServiceToServiceListMapping = new Dictionary>(); - if (!_dvbiServiceToServiceListMapping.ContainsKey(serviceListId)) - _dvbiServiceToServiceListMapping.Add(serviceListId, new List()); + if (!_dvbiServiceToServiceListMapping.ContainsKey(serviceListId)) + _dvbiServiceToServiceListMapping.Add(serviceListId, new List()); - if (!_dvbiServiceToServiceListMapping[serviceListId].Contains(id)) - _dvbiServiceToServiceListMapping [serviceListId].Add(id); + if (!_dvbiServiceToServiceListMapping[serviceListId].Contains(id)) + _dvbiServiceToServiceListMapping[serviceListId].Add(id); } public int GetDvbiServiceVersion(string id) { - foreach(DvbIService service in _dvbiServices) - { - if (service.Id.Equals(id)) - { - return service.Version; - } - } - return -1; + foreach (DvbIService service in _dvbiServices) + { + if (service.Id.Equals(id)) + { + return service.Version; + } + } + + return -1; } - private HashSet _dvbiServices; + private HashSet _dvbiServices; + public bool TestForDvbiService(string id) { - if (_dvbiServices == null) - return false; + if (_dvbiServices == null) + return false; - return _dvbiServices.Any(x => x.Id.Equals(id)); + return _dvbiServices.Any(x => x.Id.Equals(id)); } public void InsertDvbiService(DvbIService service) { - if (_dvbiServices == null) - _dvbiServices = new HashSet(); + if (_dvbiServices == null) + _dvbiServices = new HashSet(); - _dvbiServices.Add(service); + _dvbiServices.Add(service); } public void UpdateDvbiService(DvbIService service) { throw new NotImplementedException(); } - } } diff --git a/skyscraper8/Skyscraper/Scraper/Storage/Split/ObjectStorage.cs b/skyscraper8/Skyscraper/Scraper/Storage/Split/ObjectStorage.cs index f1605e7..fa58c6d 100644 --- a/skyscraper8/Skyscraper/Scraper/Storage/Split/ObjectStorage.cs +++ b/skyscraper8/Skyscraper/Scraper/Storage/Split/ObjectStorage.cs @@ -30,5 +30,9 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.Split void DvbNipInsertNetwork(BroadcastNetworkType network); bool DvbNipTestForService(BroadcastMediaStreamType broadcastMediaStreamType); void DvbNipInsertService(BroadcastMediaStreamType broadcastMediaStreamType); + bool DvbNipTestForMulticastSession(MulticastSessionType multicastSession); + void DvbNipInsertMulticastSession(MulticastSessionType multicastSession); + bool DvbNipTestForMulticastGatewayConfigurationTransportSession(NipActualCarrierInformation carrier, MulticastEndpointAddressType multicastEndpointAddressType); + void DvbNipInsertMulticastGatewayConfigurationTransportSession(NipActualCarrierInformation carrier, MulticastGatewayConfigurationTransportSessionType multicastGatewayConfigurationTransportSession); } } diff --git a/skyscraper8/Skyscraper/Scraper/Storage/Split/SplitScraperStorage.cs b/skyscraper8/Skyscraper/Scraper/Storage/Split/SplitScraperStorage.cs index 58ef682..e8a38df 100644 --- a/skyscraper8/Skyscraper/Scraper/Storage/Split/SplitScraperStorage.cs +++ b/skyscraper8/Skyscraper/Scraper/Storage/Split/SplitScraperStorage.cs @@ -933,6 +933,31 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.Split objectStorage.DvbNipInsertService(broadcastMediaStreamType); } + [DebuggerStepThrough] + public bool DvbNipTestForMulticastSession(MulticastSessionType multicastSession) + { + return objectStorage.DvbNipTestForMulticastSession(multicastSession); + } + + [DebuggerStepThrough] + public void DvbNipInsertMulticastSession(MulticastSessionType multicastSession) + { + objectStorage.DvbNipInsertMulticastSession(multicastSession); + } + + [DebuggerStepThrough] + public bool DvbNipTestForMulticastGatewayConfigurationTransportSession(NipActualCarrierInformation carrier, + MulticastEndpointAddressType multicastEndpointAddressType) + { + return objectStorage.DvbNipTestForMulticastGatewayConfigurationTransportSession(carrier, multicastEndpointAddressType); + } + + [DebuggerStepThrough] + public void DvbNipInsertMulticastGatewayConfigurationTransportSession(NipActualCarrierInformation carrier, MulticastGatewayConfigurationTransportSessionType multicastGatewayConfigurationTransportSession) + { + objectStorage.DvbNipInsertMulticastGatewayConfigurationTransportSession(carrier, multicastGatewayConfigurationTransportSession); + } + [DebuggerStepThrough] public void InsertDvbiServiceListEntryPoint(long sourceHash) { diff --git a/skyscraper8/Skyscraper/Scraper/Storage/Utilities/DatabaseKeyNipMulticastGatewayConfigurationTransportSession.cs b/skyscraper8/Skyscraper/Scraper/Storage/Utilities/DatabaseKeyNipMulticastGatewayConfigurationTransportSession.cs new file mode 100644 index 0000000..7b9099b --- /dev/null +++ b/skyscraper8/Skyscraper/Scraper/Storage/Utilities/DatabaseKeyNipMulticastGatewayConfigurationTransportSession.cs @@ -0,0 +1,60 @@ +using skyscraper8.DvbNip; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace skyscraper8.Skyscraper.Scraper.Storage.Utilities +{ + public class DatabaseKeyNipMulticastGatewayConfigurationTransportSession + { + + public DatabaseKeyNipMulticastGatewayConfigurationTransportSession(NipActualCarrierInformation carrier, MulticastEndpointAddressType address) + { + this.CarrierId = carrier.NipCarrierId; + this.LinkId = carrier.NipLinkId; + this.NetworkId = carrier.NipNetworkId; + this.ServiceId = carrier.NipServiceId; + this.SourceAddress = IPAddress.Parse(address.NetworkSourceAddress); + this.DestinationAddress = IPAddress.Parse(address.NetworkDestinationGroupAddress); + this.DestinationPort = ushort.Parse(address.TransportDestinationPort); + this.TSI = long.Parse(address.MediaTransportSessionIdentifier); + } + + public long TSI { get; set; } + + public ushort DestinationPort { get; set; } + + public IPAddress DestinationAddress { get; set; } + + public IPAddress SourceAddress { get; set; } + + public ushort ServiceId { get; set; } + + public ushort NetworkId { get; set; } + + public ushort LinkId { get; set; } + + public ushort CarrierId { get; set; } + + protected bool Equals(DatabaseKeyNipMulticastGatewayConfigurationTransportSession other) + { + return TSI == other.TSI && DestinationPort == other.DestinationPort && DestinationAddress.Equals(other.DestinationAddress) && SourceAddress.Equals(other.SourceAddress) && ServiceId == other.ServiceId && NetworkId == other.NetworkId && LinkId == other.LinkId && CarrierId == other.CarrierId; + } + + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((DatabaseKeyNipMulticastGatewayConfigurationTransportSession)obj); + } + + public override int GetHashCode() + { + return HashCode.Combine(TSI, DestinationPort, DestinationAddress, SourceAddress, ServiceId, NetworkId, LinkId, CarrierId); + } + } +}