// public static bool StartRecording(string sFileName) { //stoprecording does everything neccessary VideoCaptureController.StopRecording(); // capture = new Capture(filters.VideoInputDevices[0], null); //capture.FrameSize = new System.Drawing.Size(360, 288); capture.CaptureComplete += new EventHandler(OnCaptureComplete); capture.Filename = sFileName; try { capture.Start(); } catch (ArgumentException) { Console.WriteLine("Videokabeli dakavebulia. Gtxovt scadot tavidan!"); capture.Dispose(); return(false); } sCurrentRecordingFileName = sFileName; Console.WriteLine("new capture {0}", sFileName); return(true); }
private void btn_stop_Click(object sender, EventArgs e) { VideoCaptureController.StopRecording(); fDilasAvtomaturiChacera = false; }
void Application_ApplicationExit(object sender, EventArgs e) { VideoCaptureController.StopRecording(); sqlConn.Close(); }
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); // }