public StreamMgr(String cname, String name, DateTime start, DateTime end, bool compressed, PayloadType payload) { streamProfileData = null; cancel = false; this.compressed = compressed; lastFSP = -1; currentFSPGuid = Guid.Empty; this.cname = cname; this.name = name; this.payload = payload; //Look behind to make sure we get a key frame before the requested start time. //Otherwise we may have several seconds of missing video frames at the beginning of the segment. //PRI2: make the lookbehind customizable. //PRI2: audio surely doesn't need as much lookbehind? If any? startTime = start.Ticks; lookBehindStart = startTime; if (!compressed) { lookBehindStart -= Constants.TicksPerSec * 10; } //Get the relevant stream_id's and create DBStreamPlayers for each. streams = DatabaseUtility.GetStreams(payload, cname, name, startTime, end.Ticks); streamPlayers = new DBStreamPlayer[streams.Length]; for (int i = 0; i < streams.Length; i++) { streamPlayers[i] = new DBStreamPlayer(streams[i], lookBehindStart, end.Ticks, payload); } }
/// <summary> /// Thread proc to examine presentation data to find referenced slide decks. /// </summary> private void AnalyzeThread() { decks.Clear(); this.unnamedDecks = new Hashtable(); BufferChunk frame; long timestamp; progressTracker = new ProgressTracker(1); progressTracker.CustomMessage = "Initializing"; progressTracker.CurrentValue = 0; progressTracker.EndValue = 100; //dummy value to start with. progressTracker.OnShowProgress += new ProgressTracker.showProgressCallback(OnShowProgress); progressTracker.Start(); //Note: there would be multiple streams here if the presenter left the venue and rejoined during the segment. // This is in the context of a single segment, so we can assume one cname, and no overlapping streams. int[] streams = DatabaseUtility.GetStreams(payload, cname, null, dtstart.Ticks, dtend.Ticks); if (streams == null) { progressTracker.Stop(); progressTracker = null; this.OnAnalyzeCompleted(); return; } DBStreamPlayer[] streamPlayers = new DBStreamPlayer[streams.Length]; double totalDuration = 0; for (int i = 0; i < streams.Length; i++) { streamPlayers[i] = new DBStreamPlayer(streams[i], dtstart.Ticks, dtend.Ticks, this.payload); totalDuration += ((TimeSpan)(streamPlayers[i].End - streamPlayers[i].Start)).TotalSeconds; } progressTracker.EndValue = (int)totalDuration; progressTracker.CustomMessage = "Analyzing"; int framecount = 0; for (int i = 0; i < streamPlayers.Length; i++) { if (stopAnalyze) { break; } while ((streamPlayers[i].GetNextFrame(out frame, out timestamp))) { if (stopAnalyze) { break; } ProcessFrame(frame); progressTracker.CurrentValue = (int)(((TimeSpan)(new DateTime(timestamp) - streamPlayers[0].Start)).TotalSeconds); framecount++; } } if ((!stopAnalyze) && (this.OnAnalyzeCompleted != null)) { mergeUnnamedDecks(); progressTracker.Stop(); progressTracker = null; this.OnAnalyzeCompleted(); } }
private void lookupThreadProc() { working.Reset(); if (!DatabaseUtility.CheckConnectivity()) { done = true; sqlConnectError = true; working.Set(); return; } Conference[] confs = DatabaseUtility.GetConferences(); this.conferenceData = new ArrayList(); participantCount = DatabaseUtility.CountParticipants(); if (participantCount < 1) { done = true; sqlConnectError = false; working.Set(); return; } currentParticipant = 0; foreach (Conference c in confs) { if (stopNow) { break; } ConferenceWrapper cw = new ConferenceWrapper(); cw.Conference = c; cw.Description = "Conference: " + c.Start.ToString() + " - " + c.Description; cw.Participants = new ArrayList(); Participant[] participants = DatabaseUtility.GetParticipants(c.ConferenceID); foreach (Participant part in participants) { if (stopNow) { break; } ParticipantWrapper pw = new ParticipantWrapper(); pw.Description = "Participant: " + part.CName; pw.Participant = part; pw.StreamGrouper = new StreamGrouper(part.CName); //Here is the slow part: Stream[] streams = DatabaseUtility.GetStreams(part.ParticipantID); currentParticipant++; if (streams == null) { continue; } foreach (Stream str in streams) { pw.StreamGrouper.AddStream(str); } //Only show the participants that sent some supported data if (pw.StreamGrouper.GroupCount > 0) { cw.Participants.Add(pw); } } conferenceData.Add(cw); } done = true; working.Set(); }
public SlideStreamMgr(ArchiveTranscoderJob job, ArchiveTranscoderJobSegment segment, LogMgr logMgr, double fps, int width, int height) { this.job = job; this.segment = segment; this.logMgr = logMgr; if (width > 0 && height > 0) { this.outputWidth = width; this.outputHeight = height; } this.ticksBetweenFrames = (long)((double)Constants.TicksPerSec / fps); uncompressedMT = getUncompressedMT(this.outputWidth, this.outputHeight, fps); cancel = false; initialized = false; pptInstalled = Utility.CheckPptIsInstalled(); if ((!DateTime.TryParse(segment.StartTime, out start)) || (!DateTime.TryParse(segment.EndTime, out end))) { throw(new System.Exception("Failed to parse start/end time")); } this.nextFrameTime = start.Ticks; format = Utility.StringToPresenterWireFormatType(segment.PresentationDescriptor.PresentationFormat); payload = Utility.formatToPayload(format); cname = segment.PresentationDescriptor.PresentationCname; slideImageMgr = new SlideImageMgr(format, this.outputWidth, this.outputHeight); //Get the start time for the entire conference and use that to get streams. long confStart = DatabaseUtility.GetConferenceStartTime(payload, cname, start.Ticks, end.Ticks); if (confStart <= 0) { logMgr.WriteLine("Warning: No conference exists in the database that matches this presentation: " + cname + " with PresentationFormat " + format.ToString()); logMgr.ErrorLevel = 7; confStart = start.Ticks; } //Get the relevant stream_id's and create DBStreamPlayers for each. streamIDs = DatabaseUtility.GetStreams(payload, segment.PresentationDescriptor.PresentationCname, null, confStart, end.Ticks); DateTime sdt = new DateTime(confStart); Debug.WriteLine("***Conference start: " + sdt.ToString() + " end: " + end.ToString()); if ((streamIDs == null) || (streamIDs.Length == 0)) { Debug.WriteLine("No presentation data found."); logMgr.WriteLine("Warning: No presentation data was found for the given time range for " + cname + " with PresentationFormat " + format.ToString()); logMgr.ErrorLevel = 7; streamPlayers = null; return; } streamPlayers = new DBStreamPlayer[streamIDs.Length]; for (int i = 0; i < streamIDs.Length; i++) { streamPlayers[i] = new DBStreamPlayer(streamIDs[i], confStart, end.Ticks, payload); } lookBehindDuration = 0; if (streamPlayers[0].Start < start) { lookBehindDuration = ((TimeSpan)(start - streamPlayers[0].Start)).TotalSeconds; } }