private void InitiateBufferFilesCopyProcess(Recording rec) { if (_tsBufferExtractorSetup == "A" && _snapshotBufferPosition == -2) { Log.Info("TsBufferExtractor: there is no program information, skip the ts buffer copy."); return; } string recordingFilename = rec.FileName; IUser u = _tvEvent.Card.User; long bufferId = 0; Int64 currentPosition = -1; var layer = new TvBusinessLayer(); Int64 maximumFileSize = Int64.Parse(layer.GetSetting("timeshiftMaxFileSize", "30").Value) * 1000 * 1000; int maxFiles = Convert.ToInt16(layer.GetSetting("timeshiftMaxFiles", "30").Value); List <string[]> itemlist = new List <string[]>(); if (RemoteControl.Instance.TimeShiftGetCurrentFilePosition(ref u, ref currentPosition, ref bufferId)) { string currentFile = RemoteControl.Instance.TimeShiftFileName(ref u) + bufferId.ToString() + ".ts"; if (_snapshotBufferPosition == -2) { _snapshotBufferId = bufferId + 1; Log.Debug("TsBufferExtractor: snapshotBufferPosition was overwritten, the new _snapshotBufferId {0}", _snapshotBufferId); } Log.Info("TsBufferExtractor: current TS Position {0}, TS bufferId {1}, snapshotBufferId {2}, recording file {3}", currentPosition, bufferId, _snapshotBufferId, recordingFilename); if (_snapshotBufferId < bufferId) { Log.Debug("TsBufferExtractor: snapshotBufferId {0}, bufferId {1}", _snapshotBufferId, bufferId); string nextFile; for (long i = _snapshotBufferId; i < bufferId; i++) { nextFile = RemoteControl.Instance.TimeShiftFileName(ref u) + i + ".ts"; Log.Debug("TsBufferExtractor: nextFile {0}", nextFile); itemlist.Add(new[] { nextFile, string.Format("{0}", maximumFileSize), recordingFilename }); } } else if (_snapshotBufferId > bufferId) { { string nextFile; for (long i = _snapshotBufferId; i <= maxFiles; i++) { nextFile = RemoteControl.Instance.TimeShiftFileName(ref u) + i + ".ts"; Log.Debug("TsBufferExtractor: nextFile {0}", nextFile); itemlist.Add(new[] { nextFile, string.Format("{0}", maximumFileSize), recordingFilename }); } if (1 < _bufferId) { for (long i = 1; i < _bufferId; i++) { nextFile = RemoteControl.Instance.TimeShiftFileName(ref u) + i + ".ts"; Log.Debug("TsBufferExtractor: nextFile {0}", nextFile); itemlist.Add(new[] { nextFile, string.Format("{0}", maximumFileSize), recordingFilename }); } } } } itemlist.Add(new[] { currentFile, string.Format("{0}", currentPosition), recordingFilename }); Log.Debug("TsBufferExtractor: currentFile {0}", currentFile); try { Schedule newSchedule = new Schedule(rec.IdChannel, rec.Title, rec.StartTime, DateTime.Now); newSchedule.PreRecordInterval = 0; newSchedule.PostRecordInterval = 0; newSchedule.Persist(); Copyer Copy = new Copyer(); Copy.CopyTimeShiftFile(itemlist, rec, newSchedule); } catch (Exception ex) { Log.Error("TsBufferExtractor.CopyTimeShiftFile exception : {0}", ex); } } _snapshotBufferPosition = -1; _snapshotBufferFile = string.Empty; _snapshotBufferId = 0; }
private void InitiateBufferFilesCopyProcess(Recording rec) { if (_tsBufferExtractorSetup == "A" && _snapshotBufferPosition == -2) { Log.Info("TsBufferExtractor: there is no program information, skip the ts buffer copy."); return; } string recordingFilename = rec.FileName; IUser u = _tvEvent.Card.User; long bufferId = 0; Int64 currentPosition = -1; var layer = new TvBusinessLayer(); Int64 maximumFileSize = Int64.Parse(layer.GetSetting("timeshiftMaxFileSize", "30").Value) * 1000 * 1000; int maxFiles = Convert.ToInt16(layer.GetSetting("timeshiftMaxFiles", "30").Value); List<string[]> itemlist = new List<string[]>(); if (RemoteControl.Instance.TimeShiftGetCurrentFilePosition(ref u, ref currentPosition, ref bufferId)) { string currentFile = RemoteControl.Instance.TimeShiftFileName(ref u) + bufferId.ToString() + ".ts"; if (_snapshotBufferPosition == -2) { _snapshotBufferId = bufferId + 1; Log.Debug("TsBufferExtractor: snapshotBufferPosition was overwritten, the new _snapshotBufferId {0}", _snapshotBufferId); } Log.Info("TsBufferExtractor: current TS Position {0}, TS bufferId {1}, snapshotBufferId {2}, recording file {3}", currentPosition, bufferId, _snapshotBufferId, recordingFilename); if (_snapshotBufferId < bufferId) { Log.Debug("TsBufferExtractor: snapshotBufferId {0}, bufferId {1}", _snapshotBufferId, bufferId); string nextFile; for (long i = _snapshotBufferId; i < bufferId; i++) { nextFile = RemoteControl.Instance.TimeShiftFileName(ref u) + i + ".ts"; Log.Debug("TsBufferExtractor: nextFile {0}", nextFile); itemlist.Add(new[] { nextFile, string.Format("{0}", maximumFileSize), recordingFilename }); } } else if (_snapshotBufferId > bufferId) { { string nextFile; for (long i = _snapshotBufferId; i <= maxFiles; i++) { nextFile = RemoteControl.Instance.TimeShiftFileName(ref u) + i + ".ts"; Log.Debug("TsBufferExtractor: nextFile {0}", nextFile); itemlist.Add(new[] { nextFile, string.Format("{0}", maximumFileSize), recordingFilename }); } if (1 < _bufferId) { for (long i = 1; i < _bufferId; i++) { nextFile = RemoteControl.Instance.TimeShiftFileName(ref u) + i + ".ts"; Log.Debug("TsBufferExtractor: nextFile {0}", nextFile); itemlist.Add(new[] { nextFile, string.Format("{0}", maximumFileSize), recordingFilename }); } } } } itemlist.Add(new[] { currentFile, string.Format("{0}", currentPosition), recordingFilename }); Log.Debug("TsBufferExtractor: currentFile {0}", currentFile); try { Schedule newSchedule = new Schedule(rec.IdChannel, rec.Title, rec.StartTime, DateTime.Now); newSchedule.PreRecordInterval = 0; newSchedule.PostRecordInterval = 0; newSchedule.Persist(); Copyer Copy = new Copyer(); Copy.CopyTimeShiftFile(itemlist, rec, newSchedule); } catch (Exception ex) { Log.Error("TsBufferExtractor.CopyTimeShiftFile exception : {0}", ex); } } _snapshotBufferPosition = -1; _snapshotBufferFile = string.Empty; _snapshotBufferId = 0; }