void capturing() { while (!quitCaptureThread_) { controlAndMeasureFPS(); var monitor = NativeRecorder.GetMonitor(monitorNumber_); // todo: if (monitor == null) { Debug.LogErrorFormat("Failed to get monitor ({0}) informaiton", monitorNumber_); continue; } var frame = new NativeRecorder.Frame(); int res = NativeRecorder.CaptureDesktopFrame(monitor.Rect, frame); if (res == (int)APIResult.Fatal) { Debug.LogErrorFormat("Fatal error occurred when capturing desktop frame"); break; } else if (res != 0) { Debug.LogErrorFormat("Failed to capture desktop frame"); continue; } long ms = recordingTimer_.ElapsedMilliseconds; framesToEncode_.Enqueue(new Frame(frame.Data, frame.Width, frame.Height, ms)); } }
public void StartRecording(RecordingParameters parameters) { if (state_ != State.Running) { var param = parameters as RecordingParameters; var monitor = NativeRecorder.GetMonitor(param.Monitor); if (monitor == null || monitor.Width <= 0 || monitor.Height <= 0) { Debug.LogErrorFormat("Failed to get monitor ({0}) informaiton", param.Monitor); return; } monitorNumber_ = param.Monitor; int res = NativeRecorder.StartRecording(monitor.Width, monitor.Height, param.RecordLength, param.Fps, param.Quality); state_ = State.Running; recordingTimer_.Reset(); // need? recordingTimer_.Start(); fps_ = param.Fps; msList.Clear(); msList.Enqueue(recordingTimer_.ElapsedMilliseconds); startFrameCaptureThread(); startFrameEncodeThread(); Debug.Log("StartRecording: result=" + (APIResult)res); } }
string[] monitorLabels() { int count = NativeRecorder.GetMonitorCount(); List <string> texts = new List <string>(); for (int i = 0; i < count; i++) { var monitor = NativeRecorder.GetMonitor(i); if (monitor != null) { string t = string.Format( "Monitor{0} ({1}x{2}{3})", (i + 1), monitor.Width, monitor.Height, monitor.IsPrimary ? ", PRIMARY" : ""); texts.Add(t); } } return(texts.ToArray()); }