Example #1
0
        // Set up the TCP connection with the server and open a UDP socket
        public void SetupClicked(string _videoName)
        {
            // Initialize the rtsp sequence number
            rtspModel.ResetSequenceNumber();
            rtspModel.UpdateSequenceNumber();

            // Initialize the video file name
            videoName = _videoName;

            // Create an rtp model
            rtpModel = new RtpModel();

            // Signal the rtp model to create a local udp socket and get the server udp port number
            serverUdpPort = rtpModel.CreateUDPSocket(serverIP);

            try
            {
                // Send a setup request to the server
                rtspModel.Setup(serverIP.ToString(), serverTcpPort, serverUdpPort, videoName);

                // Receive the reply message from the server
                string message = rtspModel.ReceiveReply();

                // Extract the session number from the reply message
                int sessionID = ExtractSessionID(message);

                // Set the session ID number in the rtsp model
                rtspModel.SetSessionID(sessionID);

                // Update the view to display the correct buttons
                view.DisplayPlay();

                // Update the view to display the server response
                view.UpdateServerResponsesTextBox(message);

                // Update the view to display the name of the video file
                view.UpdateInfoTextBox(videoName);

                // Initialize the timer
                timer           = new System.Timers.Timer();
                timer.AutoReset = false;
                timer.Interval  = 50;
                timer.Elapsed  += timer_Elapsed;
            }
            catch (Exception e)
            {
                MessageBox.Show("An error has occured. The server has likely been terminated, and the connection has been closed.");

                // The server no longer exists
                // Reset the view
                view.Reset();

                // Close the RTSP connection
                rtspModel.CloseTcpSocket();
            }
        }
Example #2
0
        public UsedPortDialog(RtpModel _rtpModel, List <int> _usedPorts)
        {
            InitializeComponent();

            usedPorts = _usedPorts;
            rtpModel  = _rtpModel;

            // Load the ports that have already been used
            foreach (int i in usedPorts)
            {
                textBox1.AppendText(i.ToString());
            }
        }