示例#1
0
        /// <summary>
        /// setup the initial buffers and write the basic stream data to the db
        /// </summary>
        /// <param name="participant">for this participant</param>
        /// <param name="stream">using this rtp stream</param>
        public StreamRecorder(int participantID, RtpStream stream, ConferenceRecorderPC conferencePerfCounter)
        {
            this.rtpStream   = stream;
            this.perfCounter = conferencePerfCounter;
            this.partID      = participantID;

            // We do *not* re-use existing streams if a stream goes away and comes back.  This decision was made
            //  becuase it causes the client not to see the Rtcp data die & come back during playback, though it
            //  did during recording.  This inconsistency was viewed to cause problems, and was removed.
            InitStream();

            buffers     = new BufferRecorder[Constants.MaxBuffers];
            bufferCount = Constants.InitialBuffers;

            for (int i = 0; i < bufferCount; i++)
            {
                buffers[i]             = new BufferRecorder(i, streamID);
                buffers[i].Overflowed += new EventHandler(this.OnOverflowException);

                perfCounter.AddInstanceForCollection(buffers[i]);
            }

            curBufIndex   = 0;
            currentBuffer = buffers[curBufIndex];

            rtpStream.FrameReceived += new MSR.LST.Net.Rtp.RtpStream.FrameReceivedEventHandler(FrameReceived);
        }
示例#2
0
        /// <summary>
        /// setup the initial buffers and write the basic stream data to the db
        /// </summary>
        /// <param name="participant">for this participant</param>
        /// <param name="stream">using this rtp stream</param>
        public StreamRecorder( int participantID, RtpStream stream, ConferenceRecorderPC conferencePerfCounter )
        {
            this.rtpStream = stream;
            this.perfCounter = conferencePerfCounter;
            this.partID = participantID;

            // We do *not* re-use existing streams if a stream goes away and comes back.  This decision was made
            //  becuase it causes the client not to see the Rtcp data die & come back during playback, though it
            //  did during recording.  This inconsistency was viewed to cause problems, and was removed.
            InitStream();

            buffers = new BufferRecorder[Constants.MaxBuffers];
            bufferCount = Constants.InitialBuffers;

            for ( int i = 0; i < bufferCount; i++)
            {
                buffers[i] = new BufferRecorder( i, streamID );
                buffers[i].Overflowed += new EventHandler(this.OnOverflowException);

                perfCounter.AddInstanceForCollection(buffers[i]);
            }

            curBufIndex = 0;
            currentBuffer = buffers[curBufIndex];

            rtpStream.FrameReceived += new MSR.LST.Net.Rtp.RtpStream.FrameReceivedEventHandler(FrameReceived);
        }
示例#3
0
        private bool IncrementBuffer()
        {
            // increment the buffer we use....
            int bufIndex = (curBufIndex + 1) % bufferCount;

            while (bufIndex != curBufIndex)
            {
                if (buffers[bufIndex].Available == true)
                {
                    curBufIndex   = bufIndex;
                    currentBuffer = buffers[curBufIndex];
                    return(true);
                }

                bufIndex = (bufIndex + 1) % bufferCount;
            }

            // no buffers available so grow...
            if (bufferCount < buffers.Length)
            {
                eventLog.WriteEntry("Growing buffers for stream " + streamID + " to " + (bufferCount + 1), EventLogEntryType.Warning,
                                    ArchiveServiceEventLog.ID.GrowingBuffers);

                bufIndex = bufferCount;
                bufferCount++;
                buffers[bufIndex]             = new BufferRecorder(bufIndex, streamID);
                buffers[bufIndex].Overflowed += new EventHandler(this.OnOverflowException);
                perfCounter.AddInstanceForCollection(buffers[bufIndex]);

                curBufIndex   = bufIndex;
                currentBuffer = buffers[curBufIndex];
                return(true);
            }
            else
            {
                // Uut of buffers logged in return.  Also, we return w/o having changed which buffer is the current
                //  one b/c we expect the next buffer to be the first one to become available.
                return(false);
            }
        }
示例#4
0
        /// <summary>
        /// we have a new stream - start recording
        /// </summary>
        /// <param name="SSRC">what's arrived</param>
        private void OnNewRtpStream(object sender, RtpEvents.RtpStreamEventArgs ea)
        {
            if (this.rtpSession != sender)
            {
                return;
            }

            RtpStream stream = ea.RtpStream;

            if (streams.ContainsKey(stream.SSRC))
            {
                return;
            }

            Trace.WriteLine("New stream found: " + stream.Properties.CName + ", " + stream.Properties.Name);

            if (participants[stream.Properties.CName] != null)
            {
                ParticipantWrapper participant = (ParticipantWrapper)participants[stream.Properties.CName];

                StreamRecorder sm = new StreamRecorder(participant.participantID, stream, perfCounter);
                streams[stream.SSRC] = sm;

                perfCounter.AddInstanceForCollection(sm);

                // Make sure we don't stop recording now
                if (this.stopTimer != null)
                {
                    stopTimer.Dispose();
                    stopTimer = null;
                }
            }
            else
            {
                eventLog.WriteEntry("Detected stream for unknown participant, ignoring.  CNAME: " +
                                    stream.Properties.CName, EventLogEntryType.Error, ArchiveServiceEventLog.ID.Error);
            }
        }
        /// <summary>
        /// we have a new stream - start recording
        /// </summary>
        /// <param name="SSRC">what's arrived</param>
        private void OnNewRtpStream(object sender, RtpEvents.RtpStreamEventArgs ea)
        {
            try {
                RtpStream stream = ea.RtpStream;

                eventLog.WriteEntry("OnNewRtpStream: " + stream.Properties.CName + " " +
                                    stream.PayloadType.ToString(),
                                    EventLogEntryType.Information, ArchiveServiceEventLog.ID.Information);

                if (this.rtpSession != sender)
                {
                    eventLog.WriteEntry("OnNewRtpStream: this.rtpSession and sender don't match.",
                                        EventLogEntryType.Information, ArchiveServiceEventLog.ID.Information);
                    if (this.rtpSession == null)
                    {
                        eventLog.WriteEntry("OnNewRtpStream: this.rtpSession is null.",
                                            EventLogEntryType.Information, ArchiveServiceEventLog.ID.Information);
                    }
                    if (sender == null)
                    {
                        eventLog.WriteEntry("OnNewRtpStream: sender is null.",
                                            EventLogEntryType.Information, ArchiveServiceEventLog.ID.Information);
                    }
                    //return;
                }


                if (streams.ContainsKey(stream.SSRC))
                {
                    eventLog.WriteEntry("OnNewRtpStream already in streams collection.",
                                        EventLogEntryType.Information, ArchiveServiceEventLog.ID.Information);
                    return;
                }

                //eventLog.WriteEntry(string.Format(CultureInfo.CurrentCulture, "  New stream found: {0}, {1}",
                //    stream.Properties.CName, stream.Properties.Name));

                if (participants[stream.Properties.CName] != null)
                {
                    ParticipantWrapper participant = (ParticipantWrapper)participants[stream.Properties.CName];

                    StreamRecorder sm = new StreamRecorder(participant.participantID, stream, perfCounter);
                    streams[stream.SSRC] = sm;

                    perfCounter.AddInstanceForCollection(sm);

                    // Make sure we don't stop recording now
                    if (this.stopTimer != null)
                    {
                        stopTimer.Dispose();
                        stopTimer = null;
                    }

                    eventLog.WriteEntry("OnNewRtpStream stream added complete.",
                                        EventLogEntryType.Information, ArchiveServiceEventLog.ID.Information);
                }
                else
                {
                    eventLog.WriteEntry(Strings.UnknownParticipantError + stream.Properties.CName,
                                        EventLogEntryType.Information, ArchiveServiceEventLog.ID.Information);
                }
            }
            catch (Exception e) {
                eventLog.WriteEntry("OnNewRtpStream exception: " + e.ToString(),
                                    EventLogEntryType.Warning, ArchiveServiceEventLog.ID.Warning);
            }
        }