public static string Teardown(PLAY play_frame,SETUP setup_frame)
 {
     var command = "TEARDOWN " + play_frame.Url.AbsoluteUri + RTSP_CONSTANTS.RTSP_VERSION + Environment.NewLine
         + "Session:" + setup_frame.Session + Environment.NewLine
         + "CSeq: " + RTSP_CONSTANTS.Cseq++ + Environment.NewLine;
     return command;
 }
        public static string Teardown(PLAY play_frame, SETUP setup_frame)
        {
            var command = "TEARDOWN " + play_frame.Url.AbsoluteUri + RTSP_CONSTANTS.RTSP_VERSION + Environment.NewLine
                          + "Session:" + setup_frame.Session + Environment.NewLine
                          + "CSeq: " + RTSP_CONSTANTS.Cseq++ + Environment.NewLine;

            return(command);
        }
        //Completed event args go here
        void RTSP_Socket_EvntArgs_Completed(object sender, SocketAsyncEventArgs e)
        {
            switch (e.LastOperation)
            {
            case SocketAsyncOperation.Connect:
                SendMessage(RTSP_COMMANDS.Describe(YoutubeSource.Source));
                break;

            case SocketAsyncOperation.Send:
                ReceiveMessage();
                break;

            case SocketAsyncOperation.Receive:
                var message         = Encoding.UTF8.GetString(e.Buffer, 0, e.BytesTransferred);
                var Messsage_Status = message.Substring(0, 15);
                if (!Messsage_Status.Contains(RTSP_CONSTANTS.STATUS_OK))
                {
                    throw new WebException(message);
                }
                switch (CurrentCommand)
                {
                case COMMAND.DESCRIBE:
                    DescribeFrame  = new DESCRIBE(message);
                    CurrentCommand = COMMAND.SETUP;
                    SendMessage(RTSP_COMMANDS.Setup(DescribeFrame, UDP_PORT, 0));
                    break;

                case COMMAND.SETUP:
                    SetupFrame     = new SETUP(message);
                    CurrentCommand = COMMAND.PLAY;
                    SendMessage(RTSP_COMMANDS.Play(SetupFrame, DescribeFrame, 0));
                    break;

                case COMMAND.PLAY:
                    PlayFrame = new PLAY(message);

                    iso = IsolatedStorageFile.GetUserStoreForApplication();
                    isf = new IsolatedStorageFileStream("track.aac", System.IO.FileMode.Create, iso);
                    isf.Close();
                    Udp_Socket_EvntArgs.RemoteEndPoint = new IPEndPoint(IPAddress.Any, SetupFrame.Server_RTP_Port);
                    Udp_Socket_EvntArgs.SetBuffer(new byte[MAX_BUFFER_SIZE], 0, MAX_BUFFER_SIZE);
                    UDP_SOCKET.ReceiveFromAsync(Udp_Socket_EvntArgs);
                    break;

                case COMMAND.PAUSE:
                    break;

                case COMMAND.TEARDOWN:
                    SendMessage(RTSP_COMMANDS.Teardown(PlayFrame, SetupFrame));
                    break;
                }
                break;
            }
        }