Esempio n. 1
0
        static void Main(string[] args)
        {
            RtpParticipant part = new RtpParticipant("*****@*****.**", "SENDER");

            RtpSession session = new RtpSession(ip, part, true, true);
            session.PacketTransform = new EncryptionTransform("You are a big freak!");
            //session.PacketTransform = new XorTransform();


            RtpSender sender = session.CreateRtpSender("My sender", PayloadType.Test, null);

            Stream fs = File.OpenRead("data.txt");
            int length = (int)fs.Length;
            Console.Out.WriteLine("Opening file of length: " + length);

            byte[] buffer = new byte[length];

            int bytesRead = 0;
            while (bytesRead < length)
            {
                bytesRead += fs.Read(buffer, bytesRead, Math.Min(16384, (length - bytesRead)));
            }

            for (int i = 0; i < 5; i++)
            {
                Console.Out.WriteLine("Sending buffer to address: " + ip);

                sender.Send(buffer);

                Thread.Sleep(1000);
            }

        }
Esempio n. 2
0
 public RTPReceiveConnection(IPEndPoint ip, NetworkArchiver na)
 {
     RtpEvents.RtpStreamAdded += new MSR.LST.Net.Rtp.RtpEvents.RtpStreamAddedEventHandler(this.handleRtpStreamAdded);
     RtpEvents.RtpStreamRemoved += new MSR.LST.Net.Rtp.RtpEvents.RtpStreamRemovedEventHandler(this.handleRtpStreamRemoved);
     this.m_Participant = new RtpParticipant("Recorder", "Recorder");
     this.m_Session = new RtpSession(ip, this.m_Participant, true, true);
     this.m_archiver = na;
 }
Esempio n. 3
0
        public RTPMessageSender(IPEndPoint ep, PresenterModel model, ClassroomModel classroom)
        {
            this.m_Model = model;
            this.m_Classroom = classroom;

            this.m_RtpLocalParticipant = new RtpLocalParticipant(this.m_Model.Participant);

            using(Synchronizer.Lock(this)) {
                // Register the stream event listeners first, since otherwise there would be a chance
                // that streams could be added between creating the RtpSession (which connects immediately).
                this.m_ParticipantManager = new ParticipantManager(this);

                this.m_RtpSession = new RtpSession(ep, this.m_RtpLocalParticipant, true, true);

                // TODO: Choose a meaningful value for the RtpSender name.
                ushort fec;
                short interpacketdelay;
                using (Synchronizer.Lock(model.SyncRoot)) {
                    using (Synchronizer.Lock(model.ViewerState.SyncRoot)) {
                        fec = (ushort)model.ViewerState.ForwardErrorCorrection;
                        interpacketdelay = (short)model.ViewerState.InterPacketDelay;
                    }
                }
                if( fec == 0 )
                    this.m_RtpSender = this.m_RtpSession.CreateRtpSender( "Classroom Presenter", PayloadType.dynamicPresentation, null );
                else
                    this.m_RtpSender = this.m_RtpSession.CreateRtpSenderFec( "Classroom Presenter", PayloadType.dynamicPresentation, null, 0, fec );
                this.m_RtpSender.DelayBetweenPackets = interpacketdelay;

                // Initialize the message chunking utilities.
                this.m_Encoder = new Chunk.ChunkEncoder();
                // TODO: Make the buffer size dynamic, ie., grow if we send a single very large message.
                // Make the buffer store up to 5MB worth of data.
                this.m_FrameBuffer = new FrameBuffer(5 * 1024 * 1024 / this.m_Encoder.MaximumChunkSize);

                // Create the NackManager which is responsible for sending NACKs on behalf of
                // our set of RTPMessageReceivers.
                this.m_NackManager = new RTPNackManager(this, this.m_Classroom);
            }

            // Create network services outside of the "lock(this)" so they can lock their own objects
            // without worrying about locking order.

            // Create the PresenterNetworkService which will watch for changes to the model and send messages.
            this.m_PresenterNetworkService = new PresenterNetworkService(this, this.m_Model);

            // Create the StudentSubmissionsNetworkService which will watch for requests to submit and send messages.
            this.m_StudentSubmissionNetworkService = new StudentSubmissionNetworkService(this, this.m_Model);

            // Create the SynchronizationNetworkService which will watch for all synchronization messages.
            this.m_SynchronizationNetworkService = new SynchronizationNetworkService( this, this.m_Model );

            // Create the ScriptingNetworkService which will watch for all scripting messages.
            this.m_ScriptingNetworkService = new ScriptingNetworkService( this, this.m_Model );

            // Create the BeaconService which will broadcast periodic information about the presentation.
            this.m_BeaconService = new Beacons.DefaultBeaconService(this, this.m_Model);
        }
Esempio n. 4
0
        public SimpleTest()
        {
            // Create participant
            RtpParticipant rtpParticipant = null;
            //rtpParticipant.SetTool(true);

            // Create session with Participant and Rtp data
            rtpSession = new RtpSession(new IPEndPoint(IPAddress.Parse(addr), rtpPort),
                rtpParticipant, false, true);
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            RtpEvents.RtpStreamAdded += new RtpEvents.RtpStreamAddedEventHandler(OnNewRtpStream);


            RtpParticipant part = new RtpParticipant("*****@*****.**", "Receiver");

            session = new RtpSession(ip, part, true, true);
            //session.PacketTransform = new XorTransform();
            session.PacketTransform = new EncryptionTransform("You are a big freak!");

            // make sure this thing doesn't terminate
            while (true)
            {
                Thread.Sleep(10000);
            }
        }
Esempio n. 6
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("Playing back stream: "+streamID+"; payload: "+streamPayload+"; name: "+ (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];
        }
Esempio n. 7
0
        private void InitializeNetwork()
        {
            RtpEvents.ReceiverReport            += new RtpEvents.ReceiverReportEventHandler(RtpReceiverReport);
            RtpEvents.DuplicateCNameDetected    += new RtpEvents.DuplicateCNameDetectedEventHandler(DuplicateCNameDetected);

            // Create participant
            rtpParticipant = new RtpParticipant(cName, name);
            rtpParticipant.SetTool(true);

            // Create session with Participant and Rtp data
            rtpSession = new RtpSession(new IPEndPoint(IPAddress.Parse(ipAddress), port), rtpParticipant, true, true);

            // Create RtpSender
            rtpSender = rtpSession.CreateRtpSender(HostName, PayloadType.PipecleanerSignal, null, null);
        }
Esempio n. 8
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;
            }
        }
Esempio n. 9
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;
        }
Esempio n. 10
0
        /// <summary>
        /// Join the Venue and start participating.  AutoSend default devices if AutoSend == true
        /// </summary>
        public static void JoinVenue(IVenue venue)
        {
            lock(venue)
            {
                if (Conference.ActiveVenue != null)
                {
                    throw new InvalidOperationException("Cannot join a venue when already joined to a venue.");
                }

                if (venue.VenueData.VenueType == VenueType.Invalid)
                {
                    throw new ArgumentException("Can not join a venue that is of type Invalid");
                }

                // (pfb) Why are we checking this here?  When would it happen?
                if (rtpSession == null)
                {
                    // Do this first, or else the locks in the eventHandlers will throw, due to null argument
                    Conference.activeVenue = venue;

                    HookRtpEvents();

                    #region Start the RtpSession
                    try
                    {
                        // Pri3: Add casting of a Participant to an RtpParticipant
                        Participant p = Conference.LocalParticipant;
                        RtpParticipant rp = new RtpParticipant(p.Identifier, p.Name);
                        rp.Email = p.Email;
                        rp.Location = Conference.Location;
                        rp.Phone = p.Phone;

                        if (Conference.ReflectorEnabled && MSR.LST.Net.Utility.IsMulticast(venue.EndPoint))
                        {
                            IPEndPoint refEP;
                            IPAddress reflectorIP;
                            int unicastPort;

                            // Resolve the reflector address
                            try
                            {
                                reflectorIP = System.Net.Dns.GetHostEntry(
                                    Conference.ReflectorAddress).AddressList[0];
                            }
                            catch(Exception e)
                            {
                                throw new Exception("Reflector address not found - "
                                    + Conference.ReflectorAddress, e);
                            }

                            // Send a join request to the reflector and receive the RTP unicast port back
                            regClient = new RegistrarClient(reflectorIP, Conference.ReflectorJoinPort);
                            try
                            {
                                unicastPort = regClient.join(venue.EndPoint.Address, venue.EndPoint.Port);
                            }
                            catch(Exception e)
                            {
                                throw new Exception("Reflector join request failed", e);
                            }

                            refEP = new IPEndPoint(reflectorIP, unicastPort);

                            rtpSession = new RtpSession(venue.EndPoint, rp, true, true, refEP);
                        }
                        else
                        {
                            rtpSession = new RtpSession(venue.EndPoint, rp, true, true);
                        }
                    }
                    catch (System.Net.Sockets.SocketException se)
                    {
                        eventLog.WriteEntry(se.ToString(), EventLogEntryType.Error, 99);
                        LeaveVenue();

                        if (se.ErrorCode == 10013)
                        {
                            throw new Exception("A security error occurred connecting to the network "
                                + "(WSAEACCES).  Common causes of this error are; no network "
                                + "connection can be found, a change to the .NET Framework or "
                                + "Winsock without a reboot, or recently disconnecting from a "
                                + "VPN session which leaves Winsock in an indeterminate state.  "
                                + "Check your network connectivity or reboot your computer and try "
                                + "again.");
                        }
                        else
                        {
                            throw;
                        }
                    }
                    catch (Exception e)
                    {
                        eventLog.WriteEntry(e.ToString(), EventLogEntryType.Error, 99);
                        LeaveVenue();
                        throw;
                    }

                    #endregion
                }
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Leave the Venue and do all the cleanup work.
        /// </summary>
        public static void LeaveVenue()
        {
            if( Conference.ActiveVenue == null )
                throw new InvalidOperationException("Cannot exit a venue when not in a venue!");

            lock(Conference.ActiveVenue)
            {
                // So nothing new is created from the network
                UnhookRtpEvents();

                // Clean up participants + owned capabilities
                foreach(Participant p in new ArrayList(participants.Values))
                {
                    // A dependency on the local participant dictates that we should always have the local participant
                    //   in the venue.
                    if( p != Conference.localParticipant )
                        RemoveParticipant(p);
                }

                Debug.Assert(participants.Count == 1);

                // Dispose remaining capabilities (channels)
                foreach(ICapability ic in new ArrayList(capabilities.Values))
                {
                    DisposeCapability(ic);
                }

                Debug.Assert(capabilities.Count == 0);
                Debug.Assert(capabilityViewers.Count == 0);
                Debug.Assert(capabilitySenders.Count == 0);

                // Clear collection of form positions
                capabilityForms.Clear();

                // Leave the network
                if (rtpSession != null)
                {
                    rtpSession.Dispose();
                    rtpSession = null;
                }

                // Send a leave request to the reflector if the reflector was enabled when joining
                // the venue. Do this after leaving the Session, so that BYE packets have been sent
                // through reflector
                if (Conference.ReflectorEnabled && regClient != null)
                {
                    regClient.leave();
                }

                Conference.activeVenue = null;
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Stops recording the current conference
        /// </summary>
        public void StopRecording()
        {
            if( stopTimer != null )
            {
                stopTimer.Dispose();
                stopTimer = null;
            }

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

            if( this.recording )
            {
                perfCounter.Dispose();

                // Stop all the streams
                foreach ( StreamRecorder sm in streams.Values)
                {
                    sm.StopListening();
                }

                streams = null;
                participants = null;

                // Stop the rtpSession
                RtpEvents.RtpParticipantAdded -= new RtpEvents.RtpParticipantAddedEventHandler(this.OnNewRtpParticipant);
                RtpEvents.RtpStreamAdded -= new RtpEvents.RtpStreamAddedEventHandler(this.OnNewRtpStream);
                RtpEvents.RtpStreamRemoved -= new RtpEvents.RtpStreamRemovedEventHandler(this.OnRtpStreamRemoved);

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

                DBHelper.RecordConferenceEndTime( conferenceID, System.DateTime.Now);

                this.recording = false;
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Starts recording a conference. Sets up the conference data and then records all streams received until told to stop.
        /// </summary>
        public void RecordConference( string conferenceDescription, string venueIdentifier, IPEndPoint venue )
        {
            if( conferenceDescription.Length >= Constants.MaxDBStringSize || venueIdentifier.Length >= Constants.MaxDBStringSize )
                throw new ArgumentException("String longer than accepted by database.");

            recording = true;
            venueIPE = venue;

            streams = new Hashtable(Constants.InitialStreams);
            participants = new Hashtable();

            conferenceID = DBHelper.CreateConference( conferenceDescription, venueIdentifier, DateTime.Now);

            // Store info about this conference to the instance, for debugging reference (mostly)
            this.conferenceDescription  = conferenceDescription;
            this.venueIdentifier = venueIdentifier;
            this.venue = venue;

            // Create our performance counter
            perfCounter = new ConferenceRecorderPC( venueIdentifier + " : " + conferenceDescription );

            // Set up RTCP properties
            RtpEvents.RtpParticipantAdded += new MSR.LST.Net.Rtp.RtpEvents.RtpParticipantAddedEventHandler(this.OnNewRtpParticipant);
            RtpEvents.RtpStreamAdded += new MSR.LST.Net.Rtp.RtpEvents.RtpStreamAddedEventHandler(this.OnNewRtpStream);
            RtpEvents.RtpStreamRemoved += new MSR.LST.Net.Rtp.RtpEvents.RtpStreamRemovedEventHandler(this.OnRtpStreamRemoved);

            // Start listening
            RtpParticipant rtpMe = new RtpParticipant(Constants.PersistenceCName, Constants.PersistenceName + " (RECORDING)");
            rtpSession = new RtpSession(venue, rtpMe, true, true);
        }
Esempio n. 14
0
 public void JoinRTPSession(bool receive)
 {
     if (receive)
     {
         RegisterRtpUserEvents();
         RegisterRtpStreamEvents();
     }
     rtpSession = new RtpSession(network.GetChannel(channel), new RtpParticipant(Environment.MachineName, Environment.MachineName), true, receive);
     rtpSender = rtpSession.CreateRtpSender("VOIP Listener", PayloadType.dynamicAudio, null);
 }
Esempio n. 15
0
        /// <summary>
        /// Leave the Venue and do all the cleanup work.
        /// </summary>
        public static void LeaveVenue()
        {
            if( Conference.ActiveVenue == null )
                throw new InvalidOperationException(Strings.CannotExitNotInVenue);

            lock(Conference.ActiveVenue)
            {
                StopDiagnosticMonitor();

                // So nothing new is created from the network
                UnhookRtpEvents();

                // Clean up participants + owned capabilities
                foreach(Participant p in new ArrayList(participants.Values))
                {
                    // A dependency on the local participant dictates that we should always have the local participant
                    //   in the venue.
                    if( p != Conference.localParticipant )
                        RemoveParticipant(p);
                }

                Debug.Assert(participants.Count == 1);

                // Dispose remaining capabilities (channels)
                foreach(ICapability ic in new ArrayList(capabilities.Values))
                {
                    DisposeCapability(ic);
                }

                Debug.Assert(capabilities.Count == 0);
                Debug.Assert(capabilityViewers.Count == 0);
                Debug.Assert(capabilitySenders.Count == 0);
                
                // Clear collection of form positions
                capabilityForms.Clear();

                // Leave the network
                if (rtpSession != null)
                {
                    rtpSession.Dispose();
                    rtpSession = null;
                }

                // andrew: termination of reflector sessions is now done in UdpListner.  This should happen
                // as a side-effect of disposing the RTP session.

                Conference.activeVenue = null;
            }

            originalWindowPositions.Clear();
            Utilities.SaveWindowPersistenceData(windowPersistenceData);
        }
Esempio n. 16
0
 private void LeaveRtpSession()
 {
     if(rtpSession != null)
     {
         // Clean up all outstanding objects owned by the RtpSession
         rtpSession.Dispose();
         rtpSession = null;
         rtpSender = null;
     }
 }
Esempio n. 17
0
 public RTPSendConnection(IPEndPoint ipe)
 {
     this.m_Participant = new RtpParticipant(Guid.NewGuid().ToString(), "Classroom Playback");
     this.m_Session = new RtpSession(ipe, this.m_Participant, true, false);
     this.m_Sender = this.m_Session.CreateRtpSenderFec("Classroom Presenter", PayloadType.dynamicPresentation, null, 0, 100);
     this.m_Queue = new SendingQueue(this);
 }
Esempio n. 18
0
 // CF2 Create participant, join session
 // CF3 Retrieve RtpSender
 private void JoinRtpSession(string name)
 {
     rtpSession = new RtpSession(ep, new RtpParticipant(name, name), true, true);
     rtpSender = rtpSession.CreateRtpSenderFec(name, PayloadType.Chat, null, 0, 200);
 }
Esempio n. 19
0
 internal static RtpSender CreateInstance(RtpSession rtpSession, string name, PayloadType pt, Hashtable priExns)
 {
     return CreateInstance(rtpSession, name, pt, priExns, 0);
 }
Esempio n. 20
0
        public RtpListener(IPEndPoint nextHopEP, IPEndPoint groupEP, RtpSession rtpSession)
        {
            this.rtpSession = rtpSession;
            this.nextHopEP = nextHopEP;
            this.groupEP = groupEP;

            returnBufferHandler = new ReturnBufferHandler(ReturnBuffer);
            getBufferHandler = new GetBufferHandler(GetBuffer);

            InitializeBufferPool();
            InitializePerformanceCounters();
            InitializeNetwork();
            InitializeThreads();
        }
Esempio n. 21
0
 public RtpListener(IPEndPoint nextHopEP, RtpSession rtpSession)
     : this(nextHopEP, nextHopEP, rtpSession)
 {
 }
Esempio n. 22
0
 private void DisposeRtpSession()
 {
     if (rtpSession != null)
     {
         rtpSession.Dispose();
         rtpSession = null;
         rtpSender = null;
     }
 }
 private void JoinRtpSession()
 {
     RtpParticipant participant = new RtpParticipant("Video" + pb1.Handle.ToInt32(), "Video");
     rtpSession = new RtpSession(ep, participant, true, true);
 }
Esempio n. 24
0
        public RtpListener(RtpSession rtpSession)
        {
            this.rtpSession = rtpSession;

            returnBufferHandler = new ReturnBufferHandler(ReturnBuffer);
            getBufferHandler = new GetBufferHandler(GetBuffer);

            InitializeBufferPool();
            InitializePerformanceCounters();
            InitializeNetwork();
            InitializeThreads();
        }
Esempio n. 25
0
        public void Dispose()
        {
            lock(classLock)
            {
                try
                {
                    disposed = true;

                    // Unhook events
                    RtpEvents.ReceiverReport            -= new RtpEvents.ReceiverReportEventHandler(RtpReceiverReport);
                    RtpEvents.DuplicateCNameDetected    -= new RtpEvents.DuplicateCNameDetectedEventHandler(DuplicateCNameDetected);

                    if(updateThread != null)
                    {
                        updateThread.Dispose();
                        updateThread = null;
                    }

                    if(rtpSession != null)
                    {
                        rtpSession.Dispose();
                        rtpSession = null;
                        rtpSender = null;
                    }
                }
                catch(Exception e)
                {
                    eventLog.WriteEntry("Error disposing ConnectivityDetector. \n" + e.ToString(),
                        EventLogEntryType.Error, 0);
                }
            }
        }
        // CF1
        private void LeaveRtpSession()
        {
            UnhookRtpEvents();

            if(rtpSession != null)
            {
                rtpSession.Dispose();
                rtpSession = null;
                rtpSender = null;
                rtpStream = null;
            }
        }
Esempio n. 27
0
 public HiddenSocketExceptionEventArgs( RtpSession session, System.Net.Sockets.SocketException ex )
 {
     Session = session;
     Exception = ex;
 }
Esempio n. 28
0
        /// <summary>
        /// Join the Venue and start participating.  AutoSend default devices if AutoSend == true
        /// The optional password is used generate a symmetric encryption key...
        /// </summary>
        public static void JoinVenue(IVenue venue,String password)
        {
            foreach (Participant p in participants.Values) {
                //If there was an active warning on the local particpant at the time of the 
                //previous venue leave, it needs to be cleaned up.
                p.ThroughputWarnings.Clear();
            }

            lock(venue)
            {
                if (Conference.ActiveVenue != null)
                {
                    throw new InvalidOperationException(Strings.AlreadyJoinedToVenue);
                }

                if (venue.VenueData.VenueType == VenueType.Invalid)
                {
                    throw new ArgumentException(Strings.InvalidVenueType);
                }

                // (pfb) Why are we checking this here?  When would it happen?
                if (rtpSession == null)
                {
                    // Do this first, or else the locks in the eventHandlers will throw, due to null argument
                    Conference.activeVenue = venue;
                    
                    HookRtpEvents();

                    #region Start the RtpSession
                    try
                    {
                        // Pri3: Add casting of a Participant to an RtpParticipant
                        Participant p = Conference.LocalParticipant;
                        RtpParticipant rp = new RtpParticipant(p.Identifier, p.Name);
                        rp.Email = p.Email;
                        rp.Location = Conference.Location;
                        rp.Phone = p.Phone;

                        if (Conference.ReflectorEnabled && MSR.LST.Net.Utility.IsMulticast(venue.EndPoint))
                        {
                            IPEndPoint refEP;
                            IPAddress reflectorIP;
                            
                            // Resolve the reflector address
                            try
                            {
                                reflectorIP = System.Net.Dns.GetHostEntry(
                                    Conference.ReflectorAddress).AddressList[0];
                            }
                            catch(Exception e)
                            {
                                //Starting with .Net 4, passing an IP address to GetHostEntry excepts.  We'll check
                                //here to see if the user entered an IP address before rethowing.
                                if (!IPAddress.TryParse(Conference.ReflectorAddress, out reflectorIP)) {
                                    throw new Exception(string.Format(CultureInfo.CurrentCulture,
                                        Strings.ReflectorAddressNotFound, Conference.ReflectorAddress), e);
                                }
                            }

                            // andrew: reflector registation is now done via UDP, and has been
                            // pushed down into UDPListener...

                            refEP = new IPEndPoint(reflectorIP, ReflectorRtpPort);

                            StartDiagnosticMonitor(venue.Name, venue.EndPoint);
                            
                            rtpSession = new RtpSession(venue.EndPoint, rp, true, true, refEP);
                            if (password != null)
                            {
                                PacketTransform xform = MakePacketTransform(password);
                                rtpSession.PacketTransform = xform;
                            }
                        } 
                        else
                        {
                            StartDiagnosticMonitor(venue.Name, venue.EndPoint);
                            
                            rtpSession = new RtpSession(venue.EndPoint, rp, true, true);
                            if (password != null)
                            {
                                PacketTransform xform = MakePacketTransform(password);
                                rtpSession.PacketTransform = xform;
                            }
                        }

                        // andrew: notify RTP of our venue name; this is for diagnostic purposes
                        rtpSession.VenueName = venue.Name;

                    }
                    catch (System.Net.Sockets.SocketException se)
                    {
                        eventLog.WriteEntry(se.ToString(), EventLogEntryType.Error, 99);
                        LeaveVenue();

                        if (se.ErrorCode == 10013)
                        {
                            throw new Exception(Strings.SecurityErrorOccurredConnecting);
                        }
                        else
                        {
                            throw;
                        }
                    }
                    catch (Exception e)
                    {
                        eventLog.WriteEntry(e.ToString(), EventLogEntryType.Error, 99);                        
                        LeaveVenue();
                        throw;
                    }

                    #endregion
                }
            }
        }