Beispiel #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:VRCapture.VRCaptureMerger"/> class.
 /// </summary>
 /// <param name="video">Video.</param>
 /// <param name="audio">Audio.</param>
 public VRCaptureMerger(VRCaptureVideo video, VRCaptureAudio audio)
 {
     captureVideo = video;
     captureAudio = audio;
 }
Beispiel #2
0
        /// <summary>
        /// Initialize the attributes of the capture session and and start capturing.
        /// </summary>
        /// <returns>
        /// The status of the capturing session. This may be Success or a failure code.
        /// See StatusCode for more information.
        /// </returns>
        public StatusCode StartCapture()
        {
            // Check if can begin capture session.
            if (vrCaptureVideos.Length < 1 && vrCaptureAudio == null)
            {
                Debug.LogError(
                    "VRCapture: StartCapture called but no attached " +
                    "cameras and audio listener were found!"
                    );
                sessionStatus = StatusCode.CaptureNotFound;
                return(sessionStatus);
            }
            if (IsProcessing())
            {
                Debug.LogWarning(
                    "VRCapture: StartCapture called before, and " +
                    "capture still processing!"
                    );
                return(sessionStatus);
            }
            if (mergeThread != null && mergeThread.IsAlive)
            {
                Debug.LogWarning(
                    "VRCapture: StartCapture called before, and " +
                    "mergeThread still running!"
                    );
                return(sessionStatus);
            }
            if (gcThread != null && gcThread.IsAlive)
            {
                Debug.LogWarning(
                    "VRCapture: StartCapture called before, and " +
                    "gcThread still running!"
                    );
                return(sessionStatus);
            }
            if (!File.Exists(VRCaptureUtils.FFmpegPath))
            {
                Debug.LogError(
                    "VRCapture: FFmpeg not found, please fix this " +
                    "before capture!"
                    );
                sessionStatus = StatusCode.FFmpegNotFound;
                return(sessionStatus);
            }

            if (!Directory.Exists(VRCaptureUtils.SaveFolder))
            {
                Directory.CreateDirectory(VRCaptureUtils.SaveFolder);
            }

            // Reset sessionStatus.
            sessionStatus = StatusCode.Success;
            isInterrupted = false;
            // Loop through each of the video capture objects, initialize them
            // and start them recording.
            captureRequiredCount = 0;
            for (int i = 0; i < vrCaptureVideos.Length; i++)
            {
                VRCaptureVideo vrCaptureVideo = vrCaptureVideos[i];
                if (vrCaptureVideo == null || !vrCaptureVideo.isEnabled)
                {
                    continue;
                }
                captureRequiredCount++;
                vrCaptureVideo.Index = i;
                vrCaptureVideo.StartCapture();
                vrCaptureVideo.RegisterCaptureCompleteDelegate(
                    HandleVideoCaptureComplete);
            }

            // Check if capture audio.
            if (vrCaptureAudio != null && vrCaptureAudio.isEnabled)
            {
                vrCaptureAudio.StartCapture();
                vrCaptureAudio.RegisterCaptureCompleteDelegate(
                    HandleAudioCaptureComplete);
            }
            captureFinishCount = 0;

            // Start gc thread.
            //gcThread = new Thread(GCThreadFunction);
            //gcThread.Priority = System.Threading.ThreadPriority.Lowest;
            //gcThread.IsBackground = true;
            //gcThread.Start();

            sessionStatus = StatusCode.Success;
            return(sessionStatus);
        }