Ejemplo n.º 1
0
 public override string ToString()
 {
     if (URI.Contains(",") || URI.Contains(";"))
     {
         return(@$ "" "{URI}" ", {StatusCode}");
     }
     return($"{URI}, {StatusCode}");
 }
Ejemplo n.º 2
0
        public void Search(string InputString, bool ControlKeyDown)
        {
            Init(); //Added 1/27/2022 so that ini file can be edited without restarting program
            history.Add(InputString, ControlKeyDown);

            if (InputString.Contains(".") && !InputString.Contains(" "))
            {
                RunBrowser(httpDirect(InputString)); //send the string directly to the browser
                return;
            }
            else if (ControlKeyDown)
            {
                RunBrowser(httpExpand(InputString)); //this adds .com and sends to browser
                return;
            }

            string URI;
            int    IndexOfSpace = InputString.IndexOf(' ');

            if (IndexOfSpace < 0) //check for single token input
            {
                /*
                 * Single token here
                 * If it's in the search dictionary, just go to that domain.
                 * Else google the token
                 */
                URI = SearchDic.ContainsKey(InputString)
                    ? SearchDic[InputString].Site
                    : SearchDic["gg"].ReplaceDollar(InputString);
            }
            else
            {
                //token has a space in it
                string key = InputString.Substring(0, IndexOfSpace); //key is first token

                /*
                 * If it's in the search dictionary, create target and parm
                 * param is always the parameter.
                 * target is only set if it's an internal program, else empty string
                 */
                URI = SearchDic.ContainsKey(key)
                    ? SearchDic[key].ReplaceDollar(InputString.Substring(IndexOfSpace + 1))
                    : SearchDic["gg"].ReplaceDollar(InputString);
            }

            if (URI.Contains("http"))
            {
                RunBrowser(URI);
            }
            else
            {
                Process.Start(GetTarget(URI), GetParm(URI));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// convert list of URIs to simple string list
        /// </summary>
        /// <param name="URIs">list of URIs </param>
        /// <returns>list of simple strings </returns>
        public static List <string> URIToSimpleString(List <string> URIs)
        {
            List <string> toreturn = new List <string>();

            foreach (string URI in URIs)
            {
                if (URI.Contains("#"))
                {
                    toreturn.Add(URI.Split('#')[1]);
                }
                else
                {
                    toreturn.Add(Regex.Match(URI, @"[^/]*$", RegexOptions.IgnoreCase).Groups[0].Value);
                }
            }

            return(toreturn);
        }
Ejemplo n.º 4
0
        private bool PlayVideo()
        {
            Media.StreamSetup streamSetup;
            string            msg, returnString, errorMessage = "";
            string            URI, soapFault;

            stopPlayer();
            Cursor.Current = Cursors.WaitCursor;

            btn_LiveVideo.Text = "Connecting";
            btn_LiveVideo.Update();

            // get the URI for the selected profile
            if (VideoProfiles == null)
            {
                btn_LiveVideo.Text = "Connect";
                return(false);
            }


            // if the selected index is greater then the known profiles length return
            if (cb_VideoStreams.SelectedIndex > VideoProfiles.Length)
            {
                btn_LiveVideo.Text = "Connect";
                return(false);
            }

            if ((Parameters.Media_ServiceAddress == "") && !(PollMediaConfigurationAddress(true)))
            {
                System.Windows.Forms.MessageBox.Show("Unable to retrieve Media Service Address.  Unable to view video stream.", "Error", MessageBoxButtons.OK);
                btn_LiveVideo.Text = "Connect";
                return(false);
            }

            // configure the video stream

            SetVideoProfileType(VideoProfiles[cb_VideoStreams.SelectedIndex].VideoEncoderConfiguration.Encoding, VideoProfiles[cb_VideoStreams.SelectedIndex].VideoEncoderConfiguration);


            // if the user wishes to see the video stream from the selected profile set it up

            streamSetup           = new Media.StreamSetup();
            streamSetup.Stream    = new Media.StreamType();
            streamSetup.Transport = new Media.Transport();

            streamSetup.Transport.Protocol = Media.TransportProtocol.UDP;
            streamSetup.Stream             = Media.StreamType.RTPUnicast;

            msg = TestMessage.Build_Media_GetStreamUriRequest(VideoProfiles[cb_VideoStreams.SelectedIndex].token, streamSetup);


            try
            {
                returnString = NetworkInterface.POST_Message(Parameters.TestTimeout, Parameters.Media_ServiceAddress, msg, Parameters.UserName, Parameters.Password);

                if (TestMessage.Check_SoapFault(returnString, out soapFault))
                {
                    MessageBox.Show("SOAP Fault, unable to connect." + Environment.NewLine + Environment.NewLine + soapFault, "Error", MessageBoxButtons.OK);
                    btn_LiveVideo.Text = "Connect";
                    return(false);
                }

                Media.GetStreamUriResponse GSR = (Media.GetStreamUriResponse)TestMessage.Parse_SoapMessage(returnString, typeof(Media.GetStreamUriResponse));

                if (GSR.MediaUri == null)
                {
                    MessageBox.Show("Unable to connect, Get Stream URI Response MediaUri is NULL" + Environment.NewLine + Environment.NewLine + soapFault, "Error", MessageBoxButtons.OK);
                    btn_LiveVideo.Text = "Connect";
                    return(false);
                }

                if (GSR.MediaUri.Uri == null)
                {
                    MessageBox.Show("Unable to connect, Get Stream URI Response does not contain a Media URI" + Environment.NewLine + Environment.NewLine + soapFault, "Error", MessageBoxButtons.OK);
                    btn_LiveVideo.Text = "Connect";
                    return(false);
                }

                URI = GSR.MediaUri.Uri;

                if (URI.Contains("&line=0"))
                {
                    URI = URI.Replace("&line=0", "");
                }

                //sc_VideoStream.StreamUri = URI;
                //sc_VideoStream.Play();

                OpenVideoStream(URI);
            }
            catch (Exception err)
            {
                errorMessage       = err.Message;
                btn_LiveVideo.Text = "Connect";
            }

            if (errorMessage != "")
            {
                MessageBox.Show("Unable to connect - " + errorMessage, "Error", MessageBoxButtons.OK);
                btn_LiveVideo.Text = "Connect";
            }
            Cursor.Current     = Cursors.Default;
            btn_LiveVideo.Text = "Stop";
            return(true);
        }