public void StartRecordingAsync(string filename, VideoCapture.OnStartedRecordingVideoCallback onStartedRecordingVideoCallback)
        {
            if (this.m_NativePtr == IntPtr.Zero)
            {
                throw new InvalidOperationException("You must create a Video Capture Object before recording video.");
            }
            if (onStartedRecordingVideoCallback == null)
            {
                throw new ArgumentNullException("onStartedRecordingVideoCallback");
            }
            if (string.IsNullOrEmpty(filename))
            {
                throw new ArgumentNullException("filename");
            }
            filename = filename.Replace("/", "\\");
            string directoryName = Path.GetDirectoryName(filename);

            if (!string.IsNullOrEmpty(directoryName) && !Directory.Exists(directoryName))
            {
                throw new ArgumentException("The specified directory does not exist.", "filename");
            }
            FileInfo fileInfo = new FileInfo(filename);

            if (fileInfo.Exists && fileInfo.IsReadOnly)
            {
                throw new ArgumentException("Cannot write to the file because it is read-only.", "filename");
            }
            this.StartRecordingVideoToDisk_Internal(this.m_NativePtr, filename, onStartedRecordingVideoCallback);
        }
Exemple #2
0
        public void StartRecordingAsync(string filename, VideoCapture.OnStartedRecordingVideoCallback onStartedRecordingVideoCallback)
        {
            bool flag = onStartedRecordingVideoCallback == null;

            if (flag)
            {
                throw new ArgumentNullException("onStartedRecordingVideoCallback");
            }
            bool flag2 = string.IsNullOrEmpty(filename);

            if (flag2)
            {
                throw new ArgumentNullException("filename");
            }
            string directoryName = Path.GetDirectoryName(filename);
            bool   flag3         = !string.IsNullOrEmpty(directoryName) && !System.IO.Directory.Exists(directoryName);

            if (flag3)
            {
                throw new ArgumentException("The specified directory does not exist.", "filename");
            }
            FileInfo fileInfo = new FileInfo(filename);
            bool     flag4    = fileInfo.Exists && fileInfo.IsReadOnly;

            if (flag4)
            {
                throw new ArgumentException("Cannot write to the file because it is read-only.", "filename");
            }
            this.StartRecordingVideoToDisk_Internal(fileInfo.FullName, onStartedRecordingVideoCallback);
        }
 private extern void StartRecordingVideoToDisk_Internal(IntPtr videoCaptureObj, string filename, VideoCapture.OnStartedRecordingVideoCallback onStartedRecordingVideoCallback);
 private static void InvokeOnStartedRecordingVideoToDiskDelegate(VideoCapture.OnStartedRecordingVideoCallback callback, long hResult)
 {
     callback(VideoCapture.MakeCaptureResult(hResult));
 }