public void StopPlaying()
        {
            if (playing == false)
            {
                return;
            }

            if (avPlayer != null)
            {
                avPlayer.Stop();
                avPlayer = null;
            }

            if (otherPlayer != null)
            {
                otherPlayer.Stop();
                otherPlayer = null;
            }

            if (this.perfCounter != null)
            {
                perfCounter.Dispose();
            }

            lock (this)
            {
                if (rtpSession != null)
                {
                    rtpSession.Dispose();
                    rtpSession = null;
                }

                playing = false;
            }
        }
Exemplo n.º 2
0
        public void Play( IPEndPoint venue, int[] streams, bool receiveData )
        {
            if( this.playing )
                throw new InvalidOperationException("ConferencePlayer::Play called when the player is already playing.");
            if( streams == null )
                throw new ArgumentNullException("streams cannot be null");

            venueIPE = venue;

            // Create an RtpSession
            RtpParticipant me = new RtpParticipant(Constants.PersistenceCName, Constants.PersistenceName + " (Playing)");
            rtpSession = new RtpSession(venue, me, true, receiveData);

            // Hook the static stream-ended event
            StreamPlayer.EndOfStreamReached += new EventHandler(EndOfStreamReached);

            // Create a new perf counter for this ConferencePlayer instance
            this.perfCounter = new ConferencePlayerPC(venue.ToString());

            // Keep track of the streamPlayers
            ArrayList avStreams = new ArrayList();
            ArrayList otherStreams = new ArrayList();

            // Find the first stored ticks of all the streams while creating them...
            this.firstStoredTick = long.MaxValue;

            // Create all of our StreamPlayers (one per stream...)
            for ( int i = 0; i < streams.Length; i++)
            {
                StreamPlayer newStream = null;

                try
                {
                    newStream = new StreamPlayer(rtpSession, streams[i], perfCounter);
                }
                catch( Exception ex )
                {
                    eventLog.WriteEntry(String.Format("Stream with bad data reached.  Continuing playback of all other streams."
                        + "  Stream ID: {0}.  Exception: \n {1}", streams[i], ex.ToString()),
                        EventLogEntryType.Warning, ArchiveServiceEventLog.ID.BadStreamInDB);
                }

                if( newStream != null )
                {
                    perfCounter.AddInstanceForCollection( newStream );

                    if( newStream.FirstStreamsTicks < this.firstStoredTick )
                        this.firstStoredTick = newStream.FirstStreamsTicks;

                    // Add the new StreamPlayer to the right collection
                    // Pri3: Consider other methods here.  Maybe a smarter detection of large frame sizes,
                    //  or initializing the stream so it has enough packets ahead of time?
                    if( newStream.Payload == PayloadType.dynamicAudio || newStream.Payload == PayloadType.dynamicVideo )
                        avStreams.Add(newStream);
                    else // RTDocs stream or other large-payload stream, most likely
                        otherStreams.Add(newStream);
                }
            }

            // Start the StreamsGroupPlayers
            // Pri2: Change this to be compatable with use of the "playback speed" feature.
            long startTime = DateTime.Now.Ticks + 1500*Constants.TicksPerMs; // we'll start in 1.5 seconds (for init time)

            // Create the StreamsGroupPlayer(s)
            avPlayer = new StreamsGroupPlayer(avStreams, this.firstStoredTick, startTime);
            otherPlayer = new StreamsGroupPlayer(otherStreams, this.firstStoredTick, startTime);

            this.playing = true;
        }
Exemplo n.º 3
0
        public void StopPlaying()
        {
            if( playing == false )
                return;

            if( avPlayer != null )
            {
                avPlayer.Stop();
                avPlayer = null;
            }

            if( otherPlayer != null )
            {
                otherPlayer.Stop();
                otherPlayer = null;
            }

            if( this.perfCounter != null )
            {
                perfCounter.Dispose();
            }

            lock(this)
            {
                if( rtpSession != null )
                {
                    rtpSession.Dispose();
                    rtpSession = null;
                }

                playing = false;
            }
        }
        public void Play(IPEndPoint venue, int[] streams, bool receiveData)
        {
            if (this.playing)
            {
                throw new InvalidOperationException(Strings.PlayerAlreadyPlayingError);
            }
            if (streams == null)
            {
                throw new ArgumentNullException(Strings.StreamsCannotBeNull);
            }

            venueIPE = venue;

            // Create an RtpSession
            RtpParticipant me = new RtpParticipant(Constants.PersistenceCName,
                                                   string.Format(CultureInfo.CurrentCulture, Strings.Playing, Constants.PersistenceName));

            rtpSession = new RtpSession(venue, me, true, receiveData);

            // andrew: connect to diagnostic server
            rtpSession.VenueName = "Archived: " + venue.ToString();

            // Hook the static stream-ended event
            StreamPlayer.EndOfStreamReached += new EventHandler(EndOfStreamReached);

            // Create a new perf counter for this ConferencePlayer instance
            this.perfCounter = new ConferencePlayerPC(venue.ToString());

            // Keep track of the streamPlayers
            ArrayList avStreams    = new ArrayList();
            ArrayList otherStreams = new ArrayList();

            // Find the first stored ticks of all the streams while creating them...
            this.firstStoredTick = long.MaxValue;

            // Create all of our StreamPlayers (one per stream...)
            for (int i = 0; i < streams.Length; i++)
            {
                StreamPlayer newStream = null;

                try
                {
                    newStream = new StreamPlayer(rtpSession, streams[i], perfCounter);
                }
                catch (Exception ex)
                {
                    eventLog.WriteEntry(String.Format(CultureInfo.CurrentCulture, Strings.StreamWithBadDataReached,
                                                      streams[i], ex.ToString()), EventLogEntryType.Warning,
                                        ArchiveServiceEventLog.ID.BadStreamInDB);
                }

                if (newStream != null)
                {
                    perfCounter.AddInstanceForCollection(newStream);

                    if (newStream.FirstStreamsTicks < this.firstStoredTick)
                    {
                        this.firstStoredTick = newStream.FirstStreamsTicks;
                    }

                    // Add the new StreamPlayer to the right collection
                    // Pri3: Consider other methods here.  Maybe a smarter detection of large frame sizes,
                    //  or initializing the stream so it has enough packets ahead of time?
                    if (newStream.Payload == PayloadType.dynamicAudio || newStream.Payload == PayloadType.dynamicVideo)
                    {
                        avStreams.Add(newStream);
                    }
                    else // RTDocs stream or other large-payload stream, most likely
                    {
                        otherStreams.Add(newStream);
                    }
                }
            }

            // Start the StreamsGroupPlayers
            // Pri2: Change this to be compatable with use of the "playback speed" feature.
            long startTime = DateTime.Now.Ticks + 1500 * Constants.TicksPerMs; // we'll start in 1.5 seconds (for init time)

            // Create the StreamsGroupPlayer(s)
            avPlayer    = new StreamsGroupPlayer(avStreams, this.firstStoredTick, startTime);
            otherPlayer = new StreamsGroupPlayer(otherStreams, this.firstStoredTick, startTime);

            this.playing = true;
        }