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);
            }
        }
示例#2
0
        public static void VerifyStream(int streamId, DateTime startTime, DateTime endTime)
        {
            DBStreamPlayer streamPlayer = new DBStreamPlayer(streamId, startTime.Ticks, endTime.Ticks, PayloadType.dynamicVideo);

            Console.WriteLine("VerifyStream: streamID=" + streamId.ToString() +
                              "; Start=" + startTime.ToString() + "; End=" + endTime.ToString());
            verifyStream(streamPlayer);
        }
示例#3
0
        /// <summary>
        /// Read from a stream and attempt to find various issues.
        /// </summary>
        /// <param name="streamId"></param>
        /// <param name="durationSeconds"></param>
        public static void VerifyStream(int streamId, int durationSeconds)
        {
            DBStreamPlayer streamPlayer = new DBStreamPlayer(streamId, (long)durationSeconds * (long)Constants.TicksPerSec, PayloadType.dynamicVideo);

            Console.WriteLine("VerifyStream: streamID=" + streamId.ToString() +
                              "; requested duration Ticks=" + ((long)durationSeconds * (long)Constants.TicksPerSec).ToString());
            verifyStream(streamPlayer);
        }
示例#4
0
        private static void verifyStream(DBStreamPlayer streamPlayer)
        {
            BufferChunk frame;
            long        streamTime;
            BufferChunk sample;
            bool        keyframe;
            long        refTime        = 0;
            long        lastStreamTime = 0;
            long        timediff       = 0;
            DateTime    dt;

            while (streamPlayer.GetNextFrame(out frame, out streamTime))
            {
                try {
                    sample = ProfileUtility.FrameToSample(frame, out keyframe);
                }
                catch (Exception ex) {
                    dt = new DateTime(streamTime);
                    Console.WriteLine("FrameToSample failed at: " + dt.ToString() + "; Sampletime=" + streamTime.ToString());
                    Console.WriteLine(ex.ToString());
                    continue;
                }
                if (refTime == 0)
                {
                    refTime = streamTime;
                }


                timediff = streamTime - lastStreamTime;

                // Look for large intervals
                //if (timediff > 500000L) {
                //    dt = new DateTime(streamTime);
                //    Console.WriteLine("Sample: " + dt.ToString() + "; Sampletime=" + streamTime.ToString() + "; length=" + sample.Length.ToString() + ";interval=" + timediff.ToString());
                //}
                // Look for large samples
                //if (sample.Length > 90000) {
                //    dt = new DateTime(streamTime);
                //    Console.WriteLine("Sample: " + dt.ToString() + "; Sampletime=" + streamTime.ToString() + "; length=" + sample.Length.ToString() + ";interval=" + timediff.ToString());
                //}
                // Look for small samples
                //if (sample.Length < 300) {
                //    dt = new DateTime(streamTime);
                //    Console.WriteLine("Sample: " + dt.ToString() + "; Sampletime=" + streamTime.ToString() + "; length=" + sample.Length.ToString() + ";interval=" + timediff.ToString());
                //}

                lastStreamTime = streamTime;
            }

            DateTime dt1 = new DateTime(refTime);
            DateTime dt2 = new DateTime(lastStreamTime);

            Console.WriteLine("Started at " + dt1.ToString() + "; Ended at " + dt2.ToString() + " (" + lastStreamTime.ToString() + " ticks)" +
                              " after duration ticks =" + (lastStreamTime - refTime).ToString());
        }
示例#5
0
        private static void verifyStream(DBStreamPlayer streamPlayer)
        {
            BufferChunk frame;
            long        streamTime;
            BufferChunk sample;
            bool        keyframe;
            long        refTime        = 0;
            long        lastStreamTime = 0;

            while (streamPlayer.GetNextFrame(out frame, out streamTime))
            {
                try {
                    sample = ProfileUtility.FrameToSample(frame, out keyframe);
                }
                catch (Exception ex) {
                    DateTime dt = new DateTime(streamTime);
                    Console.WriteLine("FrameToSample failed at: " + dt.ToString() + "; Sampletime=" + streamTime.ToString());
                    Console.WriteLine(ex.ToString());
                    continue;
                }
                if (refTime == 0)
                {
                    refTime = streamTime;
                }
                //DateTime dt = new DateTime(streamTime);
                //Console.WriteLine("Sample: " + dt.ToString() + "; Sampletime=" + streamTime.ToString() + "; length=" + sample.Length.ToString());                    Console.WriteLine(ex.ToString());

                lastStreamTime = streamTime;
            }

            DateTime dt1 = new DateTime(refTime);
            DateTime dt2 = new DateTime(lastStreamTime);

            Console.WriteLine("Started at " + dt1.ToString() + "; Ended at " + dt2.ToString() + " (" + lastStreamTime.ToString() + " ticks)" +
                              " after duration ticks =" + (lastStreamTime - refTime).ToString());
        }
        /// <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();
            }
        }
        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;
            }
        }