Пример #1
0
        /// <summary>
        /// get details of the stream...raw data and start tiume etc
        /// set up the stream senders associated with us. we have n, one active and the rest acting as buffers
        /// </summary>
        public StreamPlayer(RtpSession session, int newStreamID, ConferencePlayerPC cppc)
        {
            int maxFrameSize, maxFrameCount, maxBufferSize;

            // This occasionally throws due to bad data.  Let ConferencePlayer handle it.
            DBHelper.GetStreamStatistics(newStreamID, out this.firstStreamTicks, out maxFrameSize, out maxFrameCount, out maxBufferSize);

            streamID        = newStreamID;
            totalFramesSent = 0;
            totalBytesSent  = 0;
            totalLateness   = 0;
            buffers         = new BufferPlayer[Constants.BuffersPerStream];
            perfCounter     = cppc;

            string payload;

            DBHelper.GetStreamAndParticipantDetails(streamID, out name, out payload, out cname, out privExtns);
            streamPayload = (PayloadType)Enum.Parse(typeof(PayloadType), payload, true);

            // for delayed buffers (late joiners), we create the rtpSender later
            this.rtpSession = session;

            Trace.WriteLine(string.Format(CultureInfo.CurrentCulture,
                                          "Playing back stream: {0}; payload: {1}; name: {2} : {3}", streamID, streamPayload, cname, name));

            // buffer n buffers worth of data
            long startingTick = this.firstStreamTicks;

            for (int i = 0; i < buffers.Length; i++)
            {
                buffers[i] = new BufferPlayer(streamID, maxFrameSize, maxFrameCount, maxBufferSize);
                buffers[i].Populate(startingTick);
                startingTick = buffers[i].LastTick + 1;

                perfCounter.AddInstanceForCollection(buffers[i]);
            }

            // first stream is initially active
            activeBufferIndex = 0;
            activeBuffer      = buffers[activeBufferIndex];
        }