static void Main2(string[] args) { // Process all Console.WriteLine(VCRProfiles.GetSources("Nexus").Count()); Console.WriteLine(VCRProfiles.GetSources("Nexus2").Count()); // Create the filter ChannelFilter filter = new ChannelFilter { Profile = "Nexus", ServiceType = FilterServiceTypes.Radio, Encryption = FilterEncryptionTypes.Free, Name = "^[AB]", NameMatching = FilterNameMatching.RegularExpression }; // Process foreach (Channel channel in VCRProfiles.GetSources(filter).ToChannels().OrderBy(c => c.UniqueName)) { Console.WriteLine("{0} {1} {2} {3}", channel.UniqueName, channel.Station, channel.Source.DisplayName, channel.Source.SelectionKey); } // Done Console.ReadLine(); }
/// <summary> /// Erstellt einen neuen Eintrag für die Programmzeitschrift. /// </summary> /// <param name="entry">Der originale Eintrag aus der Verwaltung.</param> /// <param name="profileName">Der Name des zugehörigen Geräteprofils.</param> /// <returns>Die gewünschte Beschreibung.</returns> public static GuideItem Create(ProgramGuideEntry entry, string profileName) { // Validate if (entry == null) { throw new ArgumentNullException("entry"); } // Default name of the station var source = VCRProfiles.FindSource(profileName, entry.Source); // Create return (new GuideItem { Identifier = string.Format("{0}:{1}:{2}", entry.StartTime.Ticks, profileName, SourceIdentifier.ToString(entry.Source).Replace(" ", "")), Station = (source == null) ? entry.StationName : source.GetUniqueName(), Duration = TimeSpan.FromSeconds(entry.Duration), Categories = entry.Categories.ToArray(), Ratings = entry.Ratings.ToArray(), Summary = entry.ShortDescription, Description = entry.Description, StartTime = entry.StartTime, Language = entry.Language, Name = entry.Name, }); }
/// <summary> /// Erstellt die interne Repräsentation eines Filters. /// </summary> /// <param name="filter">Die externe Darstellung des Filters.</param> /// <returns>Die gewünschte Repräsentation.</returns> public static GuideEntryFilter Translate(GuideFilter filter) { // None if (filter == null) { return(null); } // Lookup source by unique name var source = (filter.Source == null) ? null : VCRProfiles.FindSource(filter.ProfileName, filter.Source); // Process return (new GuideEntryFilter { Source = (source == null) ? null : source.Source, SourceEncryption = filter.SourceEncryption, ContentPattern = filter.ContentPattern, TitlePattern = filter.TitlePattern, ProfileName = filter.ProfileName, SourceType = filter.SourceType, PageIndex = filter.PageIndex, PageSize = filter.PageSize, Start = filter.Start, }); }
/// <summary> /// Wandelt eine Aufzeichnung in die Beschreibung eines Empfangsdatenstroms. /// </summary> /// <returns>Die passende Beschreibung.</returns> public ReceiveInformation ToReceiveInformation() { // Attach to the station and the profile var source = Source; var profile = VCRProfiles.FindProfile(source.ProfileName); // May want to disable the program guide var streams = Streams.Clone(); var disableProgramGuide = profile.ScanConfiguration.GetFilter(source.Source).DisableProgramGuide; if (disableProgramGuide) { streams.ProgramGuide = false; } // Create protocol structure return (new ReceiveInformation { HDTVFileBufferSize = VCRConfiguration.Current.HighDefinitionVideoBufferSize, SDTVFileBufferSize = VCRConfiguration.Current.StandardVideoBufferSize, AudioFileBufferSize = VCRConfiguration.Current.AudioBufferSize, UniqueIdentifier = ScheduleUniqueID.Value, SelectionKey = source.SelectionKey, RecordingPath = FileName, Streams = streams, }); }
/// <summary> /// Erstellt eine neue Beschreibung. /// </summary> /// <param name="guide">Die zugehörige Programmzeitschrift.</param> /// <returns>Die gewünschte Beschreibung.</returns> public static GuideInfo Create(ProgramGuideManager guide) { // Collectors var sources = new HashSet <SourceIdentifier>(); var stations = new HashSet <string>(); var first = default(DateTime? ); var last = default(DateTime? ); // Process foreach (var entry in guide.LeafEntries.Events) { // Start time var start = entry.StartTime; if (!first.HasValue) { first = start; } else if (start < first.Value) { first = start; } if (!last.HasValue) { last = start; } else if (start > last.Value) { last = start; } // Add the source name var source = entry.Source; var sourceInfo = VCRProfiles.FindSource(guide.ProfileName, source); if (sourceInfo != null) { if (sources.Add(source)) { stations.Add(sourceInfo.GetUniqueName()); } } } // Report return (new GuideInfo { SourceNames = stations.OrderBy(name => name).ToArray(), FirstStart = first, LastStart = last, }); }
static void Main6(string[] args) { // Attach to job manager VCRServer server = new VCRServer(new DirectoryInfo(@"C:\temp\VCR.NET 3.9 Alpha\Jobs")); JobManager jobs = server.JobManager; // Create EPG collection using (ZappingRequest request = ZappingRequest.CreateDefault("Nexus Scan", jobs)) if (null != request) { // Get the information FullInfo info0 = request.CreateFullInformation(); // Report Console.WriteLine(info0.Recording.JobType); // Start it request.BeginExecute(false); // Go to ZDF LiveModeStatus stat1 = request.SetSource(VCRProfiles.FindSource("Nexus Scan", "ZDF [ZDFvision]"), "localhost:5555"); // Report Console.WriteLine("ZDF on"); Console.ReadLine(); // Get status LiveModeStatus stat2 = request.CreateStatus(); // Go to PREMIERE LiveModeStatus stat3 = request.SetSource(VCRProfiles.FindSource("Nexus Scan", "PREMIERE DIREKT [PREMIERE]"), "localhost:5555"); // Report Console.WriteLine("PREMIERE on"); Console.ReadLine(); // Get status LiveModeStatus stat4 = request.CreateStatus(); // Stop it request.Stop(); // Get the information FullInfo info1 = request.CreateFullInformation(); } // Done Console.WriteLine("Done"); Console.ReadLine(); }
/// <summary> /// Erstellt eine neue Aktualisierung. /// </summary> /// <param name="state">Das zugehörige Geräteprofil.</param> /// <param name="recording">Daten der primären Aufzeichnung.</param> private ProgramGuideProxy(ProfileState state, VCRRecordingInfo recording) : base(state, recording) { // Reset fields if (VCRConfiguration.Current.EnableFreeSat) { m_extensions = EPGExtensions.FreeSatUK; } else { m_extensions = EPGExtensions.None; } // All sources we know about var allSources = new Dictionary <string, SourceSelection>(StringComparer.InvariantCultureIgnoreCase); // Load all sources of this profile foreach (var source in VCRProfiles.GetSources(ProfileName)) { // Remember by direct name allSources[source.DisplayName] = source; // allSources by unique name allSources[source.QualifiedName] = source; } // Fill in all foreach (var legacyName in VCRConfiguration.Current.ProgramGuideSources) { // Skip if empty if (string.IsNullOrEmpty(legacyName)) { continue; } // Locate SourceSelection realSource; if (allSources.TryGetValue(legacyName, out realSource)) { m_selected.Add(realSource.Source); } else { VCRServer.Log(LoggingLevel.Full, Properties.Resources.BadEPGStation, legacyName); } } }
/// <summary> /// Beendet den Suchlauf endgültig. /// </summary> protected override void OnStop() { // Remember the time of the last scan ProfileState.LastSourceUpdateTime = DateTime.UtcNow; // Log VCRServer.Log(LoggingLevel.Full, Properties.Resources.PSIReplace); // Finish ServerImplementation.EndRequest(Server.BeginEndScan(m_mergeSources)); // Report Tools.ExtendedLogging("Card Server has updated Profile {0} - VCR.NET will reload all Profiles now", ProfileName); // Time to refresh our lists VCRProfiles.Reset(); }
/// <summary> /// Aktiviert eine neue Quelle. /// </summary> /// <typeparam name="TStatus">Die Art der Zustandsinformation.</typeparam> /// <param name="source">Die gewünschte Quelle.</param> /// <param name="factory">Methode zum Erzeugen einer neuen Zustandsinformation.</param> /// <returns>Der neue Zustand der Übertragung.</returns> public TStatus SetSource <TStatus>(SourceIdentifier source, Func <string, ServerInformation, TStatus> factory) { // Update end time Stamp(); // Remap to real source var selection = VCRProfiles.FindSource(ProfileName, source); if (selection == null) { throw new ArgumentNullException("source"); } // Report Tools.ExtendedLogging("Will now zap to Source {0}", selection.Source); // Process and remember m_lastState = EnqueueActionAndWait(() => ServerImplementation.EndRequest(Server.BeginSetZappingSource(selection.SelectionKey, m_target))); // Report return(CreateStatus(factory)); }
static void Main3(string[] args) { // Attach to job manager VCRServer server = new VCRServer(new DirectoryInfo(@"C:\temp\VCR.NET 3.9 Alpha\Jobs")); JobManager jobs = server.JobManager; // Get the profile Profile nexus = VCRProfiles.FindProfile("Nexus"); // Find the next recording VCRRecordingInfo rec = jobs.FindNextJob(new DateTime(2009, 2, 19, 20, 0, 0), null, nexus); if (null != rec) { if (rec.StartsAt.HasValue) { using (RecordingRequest recording = jobs.CreateRecording(rec, rec.StartsAt.Value, nexus)) { // Get the information FullInfo info0 = recording.CreateFullInformation(); // Start it recording.BeginExecute(false); // Report Console.WriteLine("Recording..."); Console.ReadLine(); // Get the information FullInfo info1 = recording.CreateFullInformation(); } } } // Done Console.WriteLine("Done"); Console.ReadLine(); }
/// <summary> /// Prüft, ob eine Quelle gültig ist. /// </summary> /// <param name="source">Die Auswahl der Quelle oder <i>null</i>.</param> /// <returns>Gesetzt, wenn die Auswahl gültig ist.</returns> public static bool Validate(this SourceSelection source) => (VCRProfiles.FindSource(source) != null);
/// <summary> /// Wendet die Fiterbedingung an. /// </summary> /// <param name="entries">Eine Liste von Einträgen.</param> /// <returns>Die gefilterte Liste.</returns> public IEnumerable <ProgramGuideEntry> Filter(IEnumerable <ProgramGuideEntry> entries) { // Only use sources available to the target profile var entrySet = entries .Select(entry => new { e = entry, s = VCRProfiles.FindSource(ProfileName, entry.Source) }) .Where(entry => entry.s != null) .Select(entry => new { e = entry.e, s = (Station)entry.s.Source }); // Name of the station - best filter first if (Source != null) { // One source - no more filters entrySet = entrySet.Where(entry => Source.Equals(entry.e.Source)); } else { // Apply source type filter if (SourceType == GuideSourceFilter.Television) { entrySet = entrySet.Where(entry => entry.s.SourceType == SourceTypes.TV); } else if (SourceType == GuideSourceFilter.Radio) { entrySet = entrySet.Where(entry => entry.s.SourceType == SourceTypes.Radio); } // Apply encryption filter if (SourceEncryption == GuideEncryptionFilter.Free) { entrySet = entrySet.Where(entry => !entry.s.IsEncrypted); } else if (SourceEncryption == GuideEncryptionFilter.Encrypted) { entrySet = entrySet.Where(entry => entry.s.IsEncrypted); } } // Start time if (Start.HasValue) { // Later entrySet = entrySet.Where(entry => entry.e.StartTime >= Start.Value); } else { // Current var now = DateTime.UtcNow; // Still active entrySet = entrySet.Where(entry => entry.e.EndTime > now); } // Matcher on content Func <ProgramGuideEntry, bool> matchTitle = null; Func <ProgramGuideEntry, bool> matchContent = null; // Title if (!string.IsNullOrEmpty(TitlePattern)) { var title = TitlePattern.Substring(1); switch (TitlePattern[0]) { case '=': matchTitle = entry => (entry.Name ?? string.Empty).Equals(title, StringComparison.InvariantCultureIgnoreCase); break; case '*': matchTitle = entry => (entry.Name ?? string.Empty).IndexOf(title, StringComparison.InvariantCultureIgnoreCase) >= 0; break; } } // Both descriptions if (!string.IsNullOrEmpty(ContentPattern)) { var content = ContentPattern.Substring(1); switch (ContentPattern[0]) { case '=': matchContent = entry => (entry.Description ?? string.Empty).Equals(content, StringComparison.InvariantCultureIgnoreCase) || (entry.ShortDescription ?? string.Empty).Equals(content, StringComparison.InvariantCultureIgnoreCase); break; case '*': matchContent = entry => ((entry.Description ?? string.Empty).IndexOf(content, StringComparison.InvariantCultureIgnoreCase) >= 0) || ((entry.ShortDescription ?? string.Empty).IndexOf(content, StringComparison.InvariantCultureIgnoreCase) >= 0); break; } } // Apply content filter if (matchTitle != null) { if (matchContent != null) { entrySet = entrySet.Where(entry => matchTitle(entry.e) || matchContent(entry.e)); } else { entrySet = entrySet.Where(entry => matchTitle(entry.e)); } } else if (matchContent != null) { entrySet = entrySet.Where(entry => matchContent(entry.e)); } // Back mapping entries = entrySet.Select(entry => entry.e); // Caller will get it all if (PageSize < 1) { return(entries); } // Copy local var matches = entries.ToList(); // Sort in list to improve overall performance matches.Sort(Comparer); // Adjust extract - report one more if possible to indicate that there is more available return(matches.Skip(PageIndex * PageSize).Take(PageSize + 1)); }
/// <summary> /// Beendet die Sammlung endgültig. /// </summary> protected override void OnStop() { // At least we tried ProfileState.ProgramGuide.LastUpdateTime = DateTime.UtcNow; // Report Tools.ExtendedLogging("Converting Program Guide Entries from Card Server to VCR.NET Format"); // Create result var result = new ProgramGuideEntries(); // Fill it foreach (var item in Server.BeginEndEPGCollection().Result) { // Create event var epg = new ProgramGuideEntry { TransportIdentifier = item.Source.TransportStream, ShortDescription = item.ShortDescription, NetworkIdentifier = item.Source.Network, ServiceIdentifier = item.Source.Service, Description = item.Description, Duration = item.Duration, Language = item.Language, StartTime = item.Start, Name = item.Name }; // Finish if (item.Content != null) { epg.Categories.AddRange(item.Content.Select(c => c.ToString())); } if (item.Ratings != null) { epg.Ratings.AddRange(item.Ratings); } // Resolve var source = VCRProfiles.FindSource(ProfileName, item.Source); if (source == null) { // Load default epg.StationName = item.Source.ToString(); } else { // Attach to the station var station = (Station)source.Source; // Load names epg.StationName = station.Name; } // Add it result.Add(epg); } // Report ProfileState.ProgramGuide.UpdateGuide(result); }
static void Main1(string[] args) { // Attach to job manager VCRServer server = new VCRServer(new DirectoryInfo(@"C:\temp\VCR.NET 3.9 Alpha\Jobs")); JobManager jobs = server.JobManager; // Process all profiles foreach (Profile profile in VCRProfiles.Profiles) { // Report Console.WriteLine(profile.Name); // Start time DateTime start = DateTime.UtcNow; // Process a bit for (int i = 10; i-- > 0;) { // Helper data VCRRecordingInfo[] included; bool inComplete; // Find the recording FullInfo info = jobs.FindNextRecording(start, profile, out inComplete, out included); VCRRecordingInfo rec = info.Recording; VCRJob job = jobs[rec.JobUniqueID.Value]; VCRSchedule sched = job[rec.ScheduleUniqueID.Value]; // Report Console.WriteLine("\t{0} {1} {2} ({3}) {4} {5} {6} {7}", rec.StartsAt.Value.ToLocalTime(), rec.EndsAt.ToLocalTime().TimeOfDay, job.Name, sched.Name, inComplete, included.Length, rec.JobUniqueID, rec.ScheduleUniqueID); // Report foreach (VCRRecordingInfo include in included) { Console.WriteLine("\t\t{0} {1} {2} {3} {4}", include.Source.GetUniqueName(), include.StartsAt.Value.ToLocalTime(), include.EndsAt.ToLocalTime().TimeOfDay, include.JobUniqueID, include.ScheduleUniqueID); } // Report foreach (StreamInfo stream in info.Streams) { foreach (ScheduleInfo schedule in stream.Schedules) { Console.WriteLine("\t\t{0} {1} {2} {3}", schedule.JobUniqueID, schedule.ScheduleUniqueID, schedule.StartsAt.ToLocalTime(), schedule.EndsAt.ToLocalTime().TimeOfDay); } } // Advance start = rec.EndsAt; } // Helper data VCRRecordingInfo[] incDummy; bool dummyFlag; // Start timer Stopwatch timer = Stopwatch.StartNew(); // Measure for (int n = 0; ++n > 0;) { // Find the recording jobs.FindNextRecording(DateTime.UtcNow, profile, out dummyFlag, out incDummy); // Get the time TimeSpan delta = timer.Elapsed; if (delta.TotalSeconds >= 5) { // Report Console.WriteLine("{0}ms", delta.TotalMilliseconds / n); // Done break; } } } // Get the profile Profile nexus = VCRProfiles.FindProfile("Nexus"); // Find the next recording VCRRecordingInfo rec2 = jobs.FindNextJob(new DateTime(2009, 2, 19, 20, 0, 0), null, nexus); if (null != rec2) { if (rec2.StartsAt.HasValue) { using (RecordingRequest recording = jobs.CreateRecording(rec2, rec2.StartsAt.Value, nexus)) { // Get the information FullInfo info0 = recording.CreateFullInformation(); #if EXEC // Start it recording.BeginExecute(false); // Report Console.WriteLine("Recording..."); Console.ReadLine(); // Get the information FullInfo info1 = recording.CreateFullInformation(); #endif } } } // Done Console.WriteLine("Done"); Console.ReadLine(); }