Exemplo n.º 1
0
    /// <summary>
    /// Thread to record the ARCore session.
    /// </summary>
    /// <returns>An event of WaitForSeconds or null.</returns>
    private IEnumerator Record()
    {
        Extensions.Session.enabled = false;

        // It can take up to 10s until AR Foundation unlocked session native pointer.
        // Before that, the session handle returns IntPtr.Zero and fails StartRecording().
        RecordingResult result = RecordingResult.SessionNotReady;

        _recordingConfig.Mp4DatasetFilepath = _filenameToSave;

        yield return(new WaitWhile(() =>
        {
            result = _recordingManager.StartRecording(_recordingConfig);
            return result == RecordingResult.SessionNotReady;
        }));

        if (result != RecordingResult.OK)
        {
            Extensions.Session.enabled = true;
            _status = RecorderStatus.Stopped;
            yield break;
        }

        ResetScenes();
        yield return(null);

        Extensions.Session.enabled = true;
        _status = RecorderStatus.Recording;
        _timeWhenRecorderStarts = Time.time;
        RecordingTimerText.gameObject.SetActive(true);
    }
Exemplo n.º 2
0
        // Schedule Recordings
        /// <summary>
        /// Schedule a recording - this examines the request and populates Service ID, etc.
        /// The MCDATA.Schedule... method should never be called directly outside this method
        /// </summary>
        public static RecordingResult ScheduleRecording(RecordingRequest rr)
        {
            // Populate defaults, e.g. quality, if not set
            PopulateDefaultsIfUnset(ref rr);

            RecordingResult failedResult = new RecordingResult();

            failedResult.Completed = false;

            if (rr.RequestType != RecordingRequestType.Manual)  // manual recordings already have a service ID specified
            {
                if (rr.TVProgrammeID < 1)
                {
                    failedResult.ErrorMessage = "No TV Programme ID was specified.";
                    return(failedResult);
                }

                // Populate the Service ID if not already populated
                TVProgramme tvp = mcData.GetTVProgramme(rr.TVProgrammeID.ToString());
                if (tvp == null)
                {
                    failedResult.ErrorMessage = "No TV Programme with the specified ID could be found.";
                    return(failedResult);
                }

                rr.ServiceID = long.Parse(tvp.ServiceID);  // could fail
            }

            // Get the channel ID from the service ID
            TVService tvs = TVServiceWithIDOrNull(rr.ServiceID.ToString());

            if (tvs == null)
            {
                failedResult.ErrorMessage = "No TV Channel with the retrieved ID could be found.";
                return(failedResult);
            }
            rr.MCChannelID = tvs.MCChannelID;


            // ************** SCHEDULE THE RECORDING ************************
            RPRequest       generatedRequest;
            RecordingResult earlyRecResult;

            if (!mcData.ScheduleRecording(rr, out generatedRequest, out earlyRecResult))
            {
                bool debug2 = (Settings.Default.DebugAdvanced);
                Functions.WriteLineToLogFileIfSetting(debug2, "Failed already - return the early result");
                return(earlyRecResult);
            }


            RecordingResult recResult = mcData.DetermineRecordingResultForRequest(generatedRequest);
            bool            debug     = (Settings.Default.DebugAdvanced);

            Functions.WriteLineToLogFileIfSetting(debug, "recResult.Success=" + recResult.Success);

            // Success?
            if (recResult.Success)
            {
                // Wait a moment so Scheduler can catch up and associate our request with our recordings...
                System.Threading.Thread.Sleep(600);

                Functions.WriteLineToLogFileIfSetting(debug, "// Now refresh and get the generated recordings...");
                EPGManager.ReloadAllRecordings();

                try
                {
                    RPRequest req = recResult.GeneratedRecordingsBlob.RPRequests[0];
                    Functions.WriteLineToLogFileIfSetting(debug, "req.Title=" + req.Title);

                    // Add recordings
                    recResult.GeneratedRecordingsBlob.RPRecordings = req.Recordings();
                    Functions.WriteLineToLogFileIfSetting(debug, "recordings added");

                    // Add programs linked to these recordings
                    foreach (RPRecording rec in recResult.GeneratedRecordingsBlob.RPRecordings)
                    {
                        TVProgramme tvp = rec.TVProgramme();
                        if (tvp != null)
                        {
                            recResult.GeneratedRecordingsBlob.TVProgrammes.Add(tvp);
                            Functions.WriteLineToLogFileIfSetting(debug, tvp.Filename + " added");
                        }
                    }
                }
                catch (Exception ex)
                {
                    Functions.WriteLineToLogFile("ScheduleRecording(): Error retrieving recordings:");
                    Functions.WriteExceptionToLogFile(ex);
                    recResult.Success      = false;
                    recResult.ErrorMessage = "Exception occured while retrieving recordings - the recording may have been scheduled.";
                }
            }

            return(recResult);
        }