示例#1
0
        public bool LogActivity(int Timeout, int FromStep, int ToStep, IAsyncResult Result)
        {
            InStep = false;
            DateTime Till = DateTime.Now.AddSeconds(Timeout / 1000);
            OMSDIO   ini  = new OMSDIO(omsdFileName);

            while ((ini.GetCurrentStep() < FromStep) && (DateTime.Now < Till))
            {
                System.Threading.Thread.Sleep(100);
            }
            ;

            EventConsumer.FireBeginStep(StepNames[FromStep]);
            InStep = true;

            int LogStep = FromStep;
            int MessID  = ini.GetMessageOfs(LogStep);

            while ((!Result.IsCompleted) && (DateTime.Now < Till))
            {
                RollActivityPart(ref ini, ref MessID, ref LogStep, ToStep);
            }
            if (Result.IsCompleted && (ToStep <= ini.GetCurrentStep()))
            {
                while (LogStep <= ToStep)
                {
                    if (!RollActivityPart(ref ini, ref MessID, ref LogStep, ToStep))
                    {
                        break;
                    }
                }
            }
            return(LogStep >= ToStep);
        }
示例#2
0
        bool RollActivityPart(ref OMSDIO ini, ref int MessID, ref int LogStep, int ToStep)
        {
            if (LogStep > ToStep)
            {
                return(false);
            }

            if (MessID <= ini.GetMessageCount())
            {
                string s = ini.GetMessage(MessID);
                if (!string.IsNullOrEmpty(s))
                {
                    EventConsumer.FireLogStepEvent(s);
                }
                MessID++;
                int MC = ini.GetMessageOfs(LogStep + 1);
                if ((MC > 0) && (MessID >= MC))
                {
                    if ((ini.GetFailBits() & (1 << LogStep)) == 0)
                    //if ((ini.GetPassBits() & (1 << LogStep)) != 0)
                    {
                        EventConsumer.FireStepPassed();
                        InStep = false;
                    }
                    else
                    {
                        string ErrorLine;
                        GetErrorDescription(out ErrorLine);
                        throw new VideoException(ErrorLine);
                    }

                    do
                    {   // bypassing steps
                        LogStep++;
                        MC = ini.GetMessageOfs(LogStep);
                        System.Threading.Thread.Sleep(1);
                    }while ((MC > 0) && (MessID >= MC));
                    LogStep--;

                    if (LogStep <= ToStep)
                    {
                        EventConsumer.FireBeginStep(StepNames[LogStep]);
                        InStep = true;
                    }
                }
                return(true);
            }
            else
            {
                System.Threading.Thread.Sleep(100);
                return(false);
            }
        }
示例#3
0
        private void LogOutput(ref int MsgFrom, OMSDIO Ini, int LogStep)
        {
            int MsgTo = Ini.GetMessageOfs(LogStep + 1);

            if ((MsgTo == 0) || (MsgTo < MsgFrom))
            {
                MsgTo = Ini.GetMessageCount() + 1;
            }
            while (MsgFrom < MsgTo)
            {
                string s = Ini.GetMessage(MsgFrom++);
                if (!string.IsNullOrEmpty(s))
                {
                    EventConsumer.FireLogStepEvent(s);
                }
            }
        }
示例#4
0
        private bool GetErrorDescription(out string Error)
        {
            Error = "Internal error";
            OMSDIO ini      = new OMSDIO(FileName);
            int    FailStep = ini.GetCurrentStep();

            if (FailStep != 0)
            {
                int FailBits = ini.GetFailBits();
                for (FailStep = 0; ((FailBits & (1 << FailStep)) == 0) && (FailStep < 12); FailStep++)
                {
                }
                ;
                if (FailStep >= 12)
                {
                    return(false);
                }
            }
            switch (FailStep)
            {
            case 0:
                Error = "RTSP filter not found, please check your installation";
                break;

            case 1:
                Error = "RTSP filter internal error, initialization failed";
                break;

            case 2:
                Error = "OPTIONS command error, please check your connection";
                break;

            case 3:
                Error = "OPTIONS validation error";    //, OPTIONS = [" + ini.GetMessage(ini.GetMessageOfs(4) - 2) + "]";
                break;

            case 4:
                Error = "DESCRIBE command error, please check your connection";
                break;

            case 5:
                Error = "No known media sources found";
                break;

            case 6:
                Error = "SETUP command error";
                break;

            case 7:
                Error = "PLAY command error";
                break;

            case 8:
                Error = "No media frames within timeout, please check your connection";
                break;

            case 9:
                Error = "RTSP filter internal error - race conditions";
                break;

            case 10:
                Error = "TEARDOWN command error";
                break;

            case 11:
                Error = "RTSP filter internal error - finalization failed";
                break;
                //default :
                //Error = "ddd";
                //break;
            }
            return(true);
        }
示例#5
0
        private bool GetErrorDescription(out string Error)
        {
            Error = "Internal error";
            OMSDIO ini      = new OMSDIO(FileName);
            int    FailStep = ini.GetCurrentStep();

            if (FailStep != 0)
            {
                int FailBits = ini.GetFailBits();
                for (FailStep = 0; ((FailBits & (1 << FailStep)) == 0) && (FailStep < step_End); FailStep++)
                {
                }
                ;
                if (FailStep >= step_End)
                {
                    return(false);
                }
            }
            switch (FailStep)
            {
            case step_Constructed:
                Error = "RTSP filter not found, please check your installation";
                break;

            case step_InitEnvironment:
                Error = "RTSP filter internal error, initialization failed";
                break;

            case step_OPTIONS:
                Error = "OPTIONS command error, please check your connection";
                break;

            case step_CheckOptions:
                Error = "OPTIONS validation error";    //, OPTIONS = [" + ini.GetMessage(ini.GetMessageOfs(4) - 2) + "]";
                break;

            case step_DESCRIBE:
                Error = "DESCRIBE command error, please check your connection";
                break;

            case step_OpenStream:
                Error = "No known media sources found";
                break;

            case step_SETUP:
                Error = "SETUP command error";
                break;

            case step_PLAY:
                Error = "PLAY command error";
                break;

            case step_WaitStream:
                Error = "No media frames within timeout, please check your connection";
                break;

            case step_PAUSE:
                Error = "PAUSE command error";
                break;

            case step_StopThread:
                Error = "RTSP filter internal error - race conditions";
                break;

            case step_TEARDOWN:
                Error = "TEARDOWN command error";
                break;

            case step_HaltEnvironment:
                Error = "RTSP filter internal error - finalization failed";
                break;
                //default :
                //Error = "ddd";
                //break;
            }
            return(true);
        }
示例#6
0
        private void DoCommand(
            bool condition, Action commandAction, int stepFrom, int stepTo,
            Action successAction, ContainerState successState, int stepToSetState)
        {
            if (!condition)
            {
                return;
            }
            if ((TestControl == null) || (MediaControl == null))
            {
                throw new VideoException("Internal error in AV engine");
            }
            Exception ex            = null;
            Action    CommandAction = new Action(() =>
            {
                try
                {
                    commandAction();
                }
                catch (Exception e)
                {
                    ex = e;
                }
            });

            OMSDIO ini = new OMSDIO(omsdFileName);

            ini.WriteString("Test State", "StepEnded", "0");
            int MsgFirst = ini.GetMessageCount() + 1;

            int StepEnded = 0;
            int LogStep   = stepFrom;
            int StepState = 0;
            int MsgCurr   = ini.GetMessageCount() + 1;

            IAsyncResult Result = CommandAction.BeginInvoke(null, null);

            try
            {
                DateTime Till = DateTime.Now.AddSeconds(Timeout / 1000);
                if (EventConsumer != null)
                {
                    EventConsumer.FireBeginStep(StepNames[LogStep]);

                    while (StepState != stepTo && LogStep <= stepTo && DateTime.Now < Till)
                    {
                        StepState = ini.ReadInt("Test State", "StepEnded", 0);
                        StepEnded = Math.Min(Math.Abs(StepState), stepTo);
                        // pass steps which has been ended till this moment
                        while (LogStep < StepEnded)
                        {
                            LogOutput(ref MsgCurr, ini, LogStep);

                            EventConsumer.FireStepPassed();
                            EventConsumer.FireBeginStep(StepNames[++LogStep]);
                        }
                        // check if step is ended
                        if (StepEnded != LogStep)
                        {
                            System.Threading.Thread.Sleep(100);
                            // output current messages from this step
                            LogOutput(ref MsgCurr, ini, LogStep);
                            continue;
                        }
                        // output remaining messages from this step
                        LogOutput(ref MsgCurr, ini, LogStep);

                        // step passed
                        if (StepState > 0)
                        {
                            EventConsumer.FireStepPassed();
                        }
                        // step failed
                        if (StepState < 0)
                        {
                            string ErrorLine;
                            GetErrorDescription(out ErrorLine);
                            throw new VideoException(ErrorLine);
                        }
                        // begin next step
                        if (LogStep < stepTo)
                        {
                            EventConsumer.FireBeginStep(StepNames[++LogStep]);
                        }
                    }
                }
                else
                {
                    Result.AsyncWaitHandle.WaitOne(Timeout);
                }
                if (!Result.IsCompleted)
                {   // timeout, no exception in stack
                    throw new VideoException("Connection Timeout");
                }
                if (ex != null)
                {   // action ends with exception
                    if (!InStep && (EventConsumer != null))
                    {
                        EventConsumer.FireBeginStep("Verifying connection state");
                    }
                    throw ex;
                }
            }
            catch (Exception exp)
            {
                if (StepEnded > stepToSetState || (StepEnded == stepToSetState && StepState > 0))
                {
                    State = successState;
                }
                if (exp.Message == "Error HRESULT E_FAIL has been returned from a call to a COM component.")
                {
                    throw new Exception("Operation failed");
                }
                else
                {
                    throw exp;
                }
            }

            successAction();
            State = successState;
        }