Exemple #1
0
 private void RecorderController_Load(object sender, EventArgs e)
 {
     ////VideoCaptureController capturer = new VideoCaptureController();
     //
     System.Timers.Timer timerResetCheckOrNot = new System.Timers.Timer(3000);
     timerResetCheckOrNot.Elapsed += delegate(object senderTimer, ElapsedEventArgs eTimer)
     {
         string   sAxaliGadacemisSaxeli;
         DateTime dtAxaliGadacemisDackebisDro;
         if (true == nextCSVResult(out sAxaliGadacemisSaxeli, out dtAxaliGadacemisDackebisDro))
         {
             //
             string sGadacemaName = (0 < sAxaliGadacemisSaxeli.IndexOf("_"))
                 ? sAxaliGadacemisSaxeli.Substring(0, sAxaliGadacemisSaxeli.IndexOf("_"))
                                    //:"undefined";
                 : sAxaliGadacemisSaxeli.Substring(0, sAxaliGadacemisSaxeli.LastIndexOf(".")).Replace(" ", "");
             //call capture
             VideoCaptureController.StartRecording(sPrepareAndReturnFileDestination(sGadacemaName, dtAxaliGadacemisDackebisDro));
             //
         }
         else
         {
             //Console.WriteLine("don't stop capturing");
         }
     };
     timerResetCheckOrNot.Start();
     //
 }
Exemple #2
0
 private void btnStopAndStart_Click(object sender, EventArgs e)
 {
     if (0 < txtNextGadacemaName.Text.Length)
     {
         VideoCaptureController.StartRecording(sPrepareAndReturnFileDestination(txtNextGadacemaName.Text, DateTime.Now));
     }
 }
Exemple #3
0
        private void RecorderController_Load(object sender, EventArgs e)
        {
            //test each codec recording
            //VideoCaptureController.SaveTestCodecFiles(); return;
            //
            Application.ApplicationExit += new EventHandler(Application_ApplicationExit);
            ////VideoCaptureController capturer = new VideoCaptureController();
            //
            System.Timers.Timer timerResetCheckOrNot = new System.Timers.Timer(3500);
            string sLastDatabaseOrCSVGadacemaName    = "";

            timerResetCheckOrNot.Elapsed += delegate(object senderTimer, ElapsedEventArgs eTimer)
            {
                if ((DateTime.Now.Hour >= 3) && (DateTime.Now.Hour < 7))
                {
                    //don't record between 03:00 AM and 07:00 AM
                    VideoCaptureController.StopRecording();
                    return;
                }
                string   sAxaliGadacemisSaxeli;
                DateTime dtAxaliGadacemisDackebisDro;
                DateTime dtAxaliGadacemisDamtavrebisDro = DateTime.Now;//assign dummy
                if (true == nextCSVResult(out sAxaliGadacemisSaxeli, out dtAxaliGadacemisDackebisDro) &&
                    false == (dtAxaliGadacemisDackebisDro.Hour < 4 && DateTime.Now.Hour >= 7) &&//dont record last night's shows when now is morning
                    false == fMidisDatabasedanChacera)
                {
                    //
                    string sGadacemaName = (0 < sAxaliGadacemisSaxeli.IndexOf("_"))
                        ? sAxaliGadacemisSaxeli.Substring(0, sAxaliGadacemisSaxeli.IndexOf("_"))
                                           //:"undefined";
                        : (0 < sAxaliGadacemisSaxeli.IndexOf("."))
                            ? sAxaliGadacemisSaxeli.Substring(0, sAxaliGadacemisSaxeli.LastIndexOf("."))
                            : sAxaliGadacemisSaxeli;
                    ChangeParamIfInDBIsGadacemaOnlyForName(ref sGadacemaName);
                    sLastDatabaseOrCSVGadacemaName = sGadacemaName;
                    //call capture
                    VideoCaptureController.StartRecording(sPrepareAndReturnFileDestination(sGadacemaName, dtAxaliGadacemisDackebisDro));
                    //
                    fDilasAvtomaturiChacera  = false;
                    fMidisDatabasedanChacera = false;
                    //
                }
                else if (true == isThereGadacemebiForNow(sGadacemisSaxeliLastTime, out sAxaliGadacemisSaxeli, out dtAxaliGadacemisDackebisDro, out dtAxaliGadacemisDamtavrebisDro) &&
                         sLastDatabaseOrCSVGadacemaName != sAxaliGadacemisSaxeli)
                {
                    //
                    //string sGadacemaName = (0 < sAxaliGadacemisSaxeli.IndexOf("_"))
                    //    ? sAxaliGadacemisSaxeli.Substring(0, sAxaliGadacemisSaxeli.IndexOf("_"))
                    //    //:"undefined";
                    //    : sAxaliGadacemisSaxeli.Substring(0, sAxaliGadacemisSaxeli.LastIndexOf(".")).Replace(" ", "");
                    string sGadacemaName = sAxaliGadacemisSaxeli;
                    sLastDatabaseOrCSVGadacemaName = sGadacemaName;
                    //call capture
                    VideoCaptureController.StartRecording(sPrepareAndReturnFileDestination(sGadacemaName, dtAxaliGadacemisDackebisDro));
                    //
                    fDilasAvtomaturiChacera  = false;
                    fMidisDatabasedanChacera = true;
                    //
                }
                else
                {
                    //tu am cutas vicert database-dan da dro gauvida, gavacherot
                    if (true == fMidisDatabasedanChacera && DateTime.Now >= dtAxaliGadacemisDamtavrebisDro)
                    {
                        VideoCaptureController.StopRecording();
                        fDilasAvtomaturiChacera  = false;
                        fMidisDatabasedanChacera = false;
                    }
                    else
                    {
                        //yoveltvis ganaaxlos chacera, roca naxavs ro gacherebulia
                        if (false == (true == fMidisDatabasedanChacera && DateTime.Now < dtAxaliGadacemisDamtavrebisDro))
                        {
                            //if it's between 7:00AM and 8:00AM and the program has already started automated recording
                            if (VideoCaptureController.fIsRecording())
                            {
                                //TODO: or predict memory scarciness with MemoryFailPoint Class
                                try
                                {
                                    MemoryFailPoint mfp = new MemoryFailPoint(500);
                                }
                                catch (InsufficientMemoryException)
                                {
                                    //VideoCaptureController.StartRecording(sPrepareAndReturnFileDestination(sLastDatabaseOrCSVGadacemaName, DateTime.Now));
                                }
                                //
                                if (GetFreeMemory() < 500)
                                {
                                    Console.WriteLine("Low Memory: {0} Megabytes. Restarting recording. ", GetFreeMemory());
                                    VideoCaptureController.StartRecording(sPrepareAndReturnFileDestination(sLastDatabaseOrCSVGadacemaName, DateTime.Now));
                                    dtAxaliGadacemisDackebisDro = DateTime.Now;
                                }
                                else
                                {
                                    //tu dilit avtomaturi chaceraa chartuli da ert saatze metia chacerili, gackvitos chacera da tavidan daickos
                                    if (
                                        (true == fDilasAvtomaturiChacera) && DateTime.Now.Subtract(dtLastAvtomaturiChacerisDro).Minutes > 30
                                        ||
                                        /////////////////////////// !!!!!!!!!!!: always split to 30 minute files instead of only at morning
                                        DateTime.Now.Subtract(dtAxaliGadacemisDackebisDro).Minutes > 30
                                        )
                                    {
                                        //stop & start recording
                                        VideoCaptureController.StartRecording(sPrepareAndReturnFileDestination("autorecording", DateTime.Now));
                                        dtAxaliGadacemisDackebisDro = DateTime.Now;
                                        fDilasAvtomaturiChacera     = true;
                                        fMidisDatabasedanChacera    = false;
                                        dtLastAvtomaturiChacerisDro = DateTime.Now;
                                        Console.WriteLine("Avtomaturma chaceram daimaxsovra ertsaatiani faili da agrdzelebs shemdegis chaceras.");
                                    }
                                }
                            }
                            //AXALI: roca gacherebulia da csv/db-shi axali chanaceri ar aris
                            else
                            {
                                //stop & start recording
                                VideoCaptureController.StartRecording(sPrepareAndReturnFileDestination("autorecording", DateTime.Now));
                                dtAxaliGadacemisDackebisDro = DateTime.Now;
                                fDilasAvtomaturiChacera     = true;
                                fMidisDatabasedanChacera    = false;
                                dtLastAvtomaturiChacerisDro = DateTime.Now;
                                Console.WriteLine("Vrtavt chaceras avtomaturad. ");
                            }
                            //
                        }
                        else
                        {
                            Console.WriteLine("{0}, ar vicert avtomaturad imitom rom bazidan midis chacera. ", DateTime.Now);
                        }
                    }
                }
            };
            timerResetCheckOrNot.Start();
            //
            sqlConn.Open();
            //
            txtPathToCSV.Text = File.ReadAllText(VideoCaptureController.sFileContainingInfoAboutCSVFilePath);
            //
        }