コード例 #1
0
 public override bool AbortRecording(string schedulerBaseUrl, UpcomingProgram recordingProgram)
 {
     Log("{0} - Abort recording {1}", this.Name, recordingProgram.CreateProgramTitle());
     if (!_recordingThreads.StopThreadAsync(recordingProgram))
     {
         Log(TraceEventType.Warning, "{0} - Recording {1} not found, failed to abort", this.Name, recordingProgram.CreateProgramTitle());
         return(false);
     }
     return(true);
 }
コード例 #2
0
ファイル: UpcomingBase.cs プロジェクト: rob-opsi/ARGUS-TV
        private GUIListItem CreateListItem(UpcomingProgram upcomingProgram, UpcomingRecording recording, ScheduleSummary schedule)
        {
            GUIListItem item = new GUIListItem();

            if (schedule != null)
            {
                //create list with schedules
                item.Label    = schedule.Name;
                item.IsFolder = true;
                Utils.SetDefaultIcons(item);
                item.PinImage = Utility.GetLogoForSchedule(schedule.ScheduleType, schedule.IsOneTime, schedule.IsActive);
                item.TVTag    = schedule;
                item.IsPlayed = !schedule.IsActive;
            }
            else
            {
                //create list with Upcoming Programs
                string title = upcomingProgram.CreateProgramTitle();
                item.Label = title;
                string logoImagePath = Utility.GetLogoImage(upcomingProgram.Channel);
                if (!Utils.FileExistsInCache(logoImagePath))
                {
                    item.Label    = String.Format("[{0}] {1}", upcomingProgram.Channel.DisplayName, title);
                    logoImagePath = "defaultVideoBig.png";
                }
                item.PinImage = Utility.GetIconImageFileName(_currentProgramType, upcomingProgram.IsPartOfSeries,
                                                             upcomingProgram.CancellationReason, recording);
                item.TVTag          = upcomingProgram;
                item.ThumbnailImage = logoImagePath;
                item.IconImageBig   = logoImagePath;
                item.IconImage      = logoImagePath;
                item.Label2         = String.Format("{0} {1} - {2}", Utility.GetShortDayDateString(upcomingProgram.StartTime),
                                                    upcomingProgram.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat),
                                                    upcomingProgram.StopTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));
                item.IsPlayed = upcomingProgram.IsCancelled;
            }
            return(item);
        }
コード例 #3
0
ファイル: FileUtility.cs プロジェクト: twemperor/ARGUS-TV
 public static string BuildRecordingBaseFileName(string recordingsPath, UpcomingProgram program)
 {
     StringBuilder filePath = new StringBuilder();
     if (recordingsPath != null)
     {
         filePath.Append(recordingsPath);
         if (filePath[filePath.Length - 1] != Path.DirectorySeparatorChar)
         {
             filePath.Append(Path.DirectorySeparatorChar);
         }
         filePath.Append(MakeValidFileName(program.Title)).Append(Path.DirectorySeparatorChar);
     }
     string programTitle = program.CreateProgramTitle();
     if (programTitle.Length > 80)
     {
         programTitle = programTitle.Substring(0, 80);
     }
     filePath.Append(MakeValidFileName(programTitle));
     filePath.Append("_");
     filePath.AppendFormat(MakeValidFileName(program.Channel.DisplayName));
     filePath.Append("_");
     filePath.AppendFormat(CultureInfo.InvariantCulture, @"{0:yyyy-MM-dd_HH-mm}", program.StartTime);
     return filePath.ToString();
 }
コード例 #4
0
        protected override void Run()
        {
            var callbackProxy = new RecorderCallbackProxy(_schedulerBaseUrl);

            try
            {
                SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS | EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_AWAYMODE_REQUIRED);

                if (this.StopTimeUtc <= DateTime.UtcNow || _startTimeUtc >= this.StopTimeUtc)
                {
                    CallStartRecordingFailed(callbackProxy, String.Format(CultureInfo.InvariantCulture,
                                                                          "Recording of {0} at {1} for {2} has invalid timing parameters.",
                                                                          _channelAllocation.ChannelName, _startTimeUtc.ToLocalTime().ToShortTimeString(), this.StopTimeUtc.Subtract(_startTimeUtc)));
                    return;
                }

                if (_waitForThreadToComplete != null)
                {
                    _waitForThreadToComplete.Join();
                }

                bool aborted = false;
                _usedSuggestedBaseFileName = !_okToRenameRecordedFiles;

                // First of all make sure the recorder is tuned to the correct channel.
                string errorMessage = null;
                if (!OnPrepareRecording(callbackProxy, ref errorMessage))
                {
                    CallStartRecordingFailed(callbackProxy, errorMessage);
                    OnError();
                    aborted = true;
                }

                DateTime actualStartTimeUtc = DateTime.MaxValue;

                if (!aborted)
                {
                    // Now wait for the actual start-time
                    try
                    {
                        TimeSpan delay = _startTimeUtc.AddSeconds(-1) - DateTime.UtcNow;
                        if (delay.TotalMilliseconds > 0)
                        {
                            aborted = this.StopThreadEvent.WaitOne((int)delay.TotalMilliseconds, false);
                        }
                        if (!aborted)
                        {
                            errorMessage           = null;
                            this.RecordingFileName = OnStartRecording(callbackProxy, ref errorMessage);
                            if (String.IsNullOrEmpty(this.RecordingFileName))
                            {
                                CallStartRecordingFailed(callbackProxy, errorMessage);
                                OnError();
                                aborted = true;
                            }
                            else
                            {
                                this.ActualRecordingFileName = ShareExplorer.TryConvertUncToLocal(this.RecordingFileName);
                                actualStartTimeUtc           = DateTime.UtcNow;
                                CallAddNewRecording(callbackProxy, actualStartTimeUtc);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        CallStartRecordingFailed(callbackProxy, e.Message);
                        OnError();
                        aborted = true;
                    }
                }

                if (!aborted)
                {
                    TimeSpan?checkerInterval = this.FileSizeCheckerInterval;
                    if (!checkerInterval.HasValue)
                    {
                        checkerInterval = TimeSpan.MaxValue;
                    }
                    _fileSizeChecker = new FileSizeChecker(this.ActualRecordingFileName, checkerInterval.Value);

                    while (!aborted && DateTime.UtcNow < this.StopTimeUtc)
                    {
                        TimeSpan interval  = this.CheckRecordingActiveInterval;
                        TimeSpan timeToEnd = this.StopTimeUtc.AddMilliseconds(1) - DateTime.UtcNow;
                        if (timeToEnd < interval)
                        {
                            interval = timeToEnd;
                        }

                        aborted = this.StopThreadEvent.WaitOne(interval, false);
                    }

                    if (aborted)
                    {
                        WriteLog(TraceEventType.Warning, "RecordingThread [{0}]: Aborted", _recordingProgram.CreateProgramTitle());
                    }

                    if (!OnStopRecording(callbackProxy, aborted))
                    {
                        WriteLog(TraceEventType.Error, "RecordingThread [{0}]: Failed to stop recording", _recordingProgram.CreateProgramTitle());
                        try
                        {
                            callbackProxy.LogMessage(this.RecorderId, LogSeverity.Error, "Failed to stop recording " + _recordingProgram.CreateProgramTitle());
                        }
                        catch { }
                    }

                    CallEndRecording(callbackProxy, actualStartTimeUtc, DateTime.UtcNow);
                }
            }
            catch (Exception ex)
            {
                WriteLog(TraceEventType.Error, "RecordingThread [{0}]: {1}", _recordingProgram.CreateProgramTitle(), ex.Message);
                try
                {
                    callbackProxy.LogMessage(this.RecorderId, LogSeverity.Error, "Exception: " + ex.Message);
                }
                catch { }
                OnError();
            }
            finally
            {
                SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS);
            }

            OnThreadEnding();
        }
コード例 #5
0
        public override bool ValidateAndUpdateRecording(CardChannelAllocation channelAllocation, UpcomingProgram recordingProgram, DateTime stopTimeUtc)
        {
            bool threadNotFound;
            bool result = _recordingThreads.ValidateAndUpdateRecording(recordingProgram, stopTimeUtc, out threadNotFound);

            if (threadNotFound)
            {
                Log(TraceEventType.Warning, "{0} - ValidateAndUpdateRecording called on unknown recording {1}", this.Name, recordingProgram.CreateProgramTitle());
            }
            return(result);
        }
コード例 #6
0
        public override bool StartRecording(string serverHostName, int tcpPort, CardChannelAllocation channelAllocation,
                                            DateTime startTimeUtc, DateTime stopTimeUtc, UpcomingProgram recordingProgram, string suggestedBaseFileName)
        {
            bool result = false;

            TvDatabase.Card recordOnCard = GetCardByCardId(channelAllocation.CardId);
            if (recordOnCard != null)
            {
                TvDatabase.Channel channel = GetLinkedMediaPortalChannel(channelAllocation.ChannelType,
                                                                         channelAllocation.ChannelId, channelAllocation.ChannelName);
                if (channel != null)
                {
                    result = this.RecordingThreads.StartNewThread(new RecordingThread(this.RecorderTunerId,
                                                                                      serverHostName, tcpPort, channelAllocation, startTimeUtc, stopTimeUtc,
                                                                                      recordingProgram, suggestedBaseFileName, recordOnCard, channel));
                    if (!result)
                    {
                        Log(TraceEventType.Error, "{0} - Already recording {1}", this.Name, recordingProgram.CreateProgramTitle());
                    }
                }
                else
                {
                    Log(TraceEventType.Error, "{0} - Channel {1} not found", this.Name, channelAllocation.ChannelName);
                }
            }
            else
            {
                Log(TraceEventType.Error, "{0} - Card {1} not found", this.Name, channelAllocation.CardId);
            }

            return(result);
        }
コード例 #7
0
ファイル: ProcessUtility.cs プロジェクト: twemperor/ARGUS-TV
        public static string CreateConflictingProgramsToolTip(UpcomingOrActiveProgramsList upcomingRecordings, List <Guid> programIds,
                                                              string conflictsText, string noCardFoundText)
        {
            StringBuilder toolTip = new StringBuilder();

            foreach (Guid programId in programIds)
            {
                if (toolTip.Length > 0)
                {
                    toolTip.AppendLine();
                }
                else
                {
                    toolTip.AppendLine(conflictsText);
                }
                UpcomingProgram upcomingProgram = upcomingRecordings.FindProgramById(programId);
                if (upcomingProgram != null)
                {
                    toolTip.AppendFormat("● {0} {1:g}-{2:t} {3}", upcomingProgram.Channel.DisplayName,
                                         upcomingProgram.StartTime, upcomingProgram.StopTime, upcomingProgram.CreateProgramTitle());
                }
                else
                {
                    toolTip.Append("● ?");
                }
            }
            if (toolTip.Length == 0)
            {
                toolTip.Append(noCardFoundText);
            }
            return(toolTip.ToString());
        }
コード例 #8
0
ファイル: Utility.cs プロジェクト: twemperor/ARGUS-TV
 public static string BuildRecordingBaseFilePath(string format, UpcomingRecording upcomingRecording, string scheduleName, int? episodeNumber, int? seriesNumber)
 {
     UpcomingProgram upcoming = upcomingRecording.Program;
     return BuildRecordingBaseFilePath(format, upcoming.Channel.DisplayName, upcoming.Channel.ChannelType, scheduleName, upcoming.Title, upcoming.CreateProgramTitle(),
         upcoming.SubTitle, upcoming.EpisodeNumberDisplay, episodeNumber, seriesNumber, upcoming.StartTime, upcoming.Category);
 }