Beispiel #1
0
        /// <summary>
        /// Opens the stream.
        /// </summary>
        /// <param name="hostAddress">The host address.</param>
        /// <param name="hostPort">The host port.</param>
        /// <returns>Succeeded or failed.</returns>
        private bool OpenStream(string hostAddress, int hostPort)
        {
            if (rtspClient == null)
            {
                rtspClient = new RtspClient();

                HookClientEvents();
            }

            this.lblCurrentState.Text = "Try to connect the server...";
            this.Refresh();

            bool result = rtspClient.ConnectServer(hostAddress, hostPort);

            if (!result)
            {
                MessageBox.Show(string.Format("Could not connect the server[{0}:{1}]!", hostAddress, hostPort.ToString()), "Information",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);

                Utils.OutputMessage(false, MsgLevel.Error, "ClientForm -- OpenStream", "Could not connect the server!");

                return(false);
            }

            result = rtspClient.OpenStream(fileNameOrUrl, filePath);
            if (!result)
            {
                Utils.OutputMessage(false, MsgLevel.Error, "ClientForm -- OpenStream", "Could not open the stream!");

                rtspClient.DisconnectServer();

                return(false);
            }

            duration = rtspClient.Duration;

            Utils.OutputMessage(false, MsgLevel.Debug, "ClientForm -- OpenStream", "Open the stream successfully.");

            return(true);
        }