Exemplo n.º 1
0
        // Dispose
        protected override void Dispose(bool disposing)
        {
            base.Dispose(true);

            // stop encoder
            if (vsEncoder != null)
            {
                vsEncoder.Dispose();
                vsEncoder = null;
            }
        }
Exemplo n.º 2
0
        // ---------------------------------------------------------------
        // stop encoder
        public override void StopRecord()
        {
            if (vsEncoder != null && vsEncoder.Recording)
            {
                // stop timer
                timer.Stop();
                stimer.Stop();

                try
                {
                    // stop encoder
                    vsEncoder.StopRecord();

                    // already write and can be accessed by another?
                    // convert avi file to wmv
                    VsEncode vsEnc = new VsEncode(rawName, aviName);
                    EncodeOut(this, new VsEncodeEventArgs(vsEnc));
                    vsEnc.Dispose(); vsEnc = null;

                    // send data to database server
                    DataAlert();
                }
                catch (Exception err)
                {
                    // error log
                    logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);;

                    // if can't stop
                    // try to free memory
                    if (vsEncoder != null)
                    {
                        vsEncoder.Dispose();
                        vsEncoder = null;
                    }

                    // and create new encoder
                    if (vsEncoder == null)
                    {
                        try
                        {
                            vsEncoder = new AviEncoder();
                        }
                        catch (Exception err1)
                        {
                            if (vsEncoder != null)
                            {
                                vsEncoder.Dispose();
                                vsEncoder = null;
                            }
                            logger.Log(LogLevel.Error, err1.Message + " " + err1.Source + " " + err1.StackTrace);;
                        }
                    }
                }

                // start timer
                timer.Start();
            }
        }
Exemplo n.º 3
0
        protected override void Dispose(bool disposing)
        {
            // stop timer
            timer.Stop();
            stimer.Stop();

            // stop convertor
            if (vsConvert != null)
            {
                vsConvert.Dispose();
                vsConvert = null;
            }

            // stop encoder
            if (vsEncoder != null)
            {
                vsEncoder.Dispose();
                vsEncoder = null;
            }

            base.Dispose(true);
        }
Exemplo n.º 4
0
        // ---------------------------------------------------------------
        // create new viddo file
        public override void StartRecord()
        {
            if (vsEncoder == null)
            {
                try
                {
                    vsEncoder = new AviEncoder();
                }
                catch (Exception err)
                {
                    if (vsEncoder != null)
                    {
                        vsEncoder.Dispose();
                        vsEncoder = null;
                    }
                    logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);;
                }
            }

            if (vsEncoder != null && !vsEncoder.Recording)
            {
                // check & create directory
                process_DirName();

                try
                {
                    // create new file
                    vsEncoder.StartRecord(rawName, (int)(1000 / syncTimer), width, height);

                    // initial parameters
                    timeMaxLength = 0;
                    thumbCount    = 0;
                    thumbSave     = false;
                    stimer.Start();
                }
                catch (Exception err)
                {
                    // error log
                    logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);;

                    // stop encoder
                    StopRecord(false);
                }
            }
        }