From: <do...@us...> - 2009-01-15 16:10:58
|
Revision: 2510 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=2510&view=rev Author: dot-i Date: 2009-01-15 16:10:32 +0000 (Thu, 15 Jan 2009) Log Message: ----------- Updated to version 1.3.2 of For The Record. Modified Paths: -------------- trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/MediaPortalRecorderTunerService.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/RecordingThread.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/SetupForm.Designer.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/SetupForm.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/SetupForm.resx trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/ChannelNavigator.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/ForTheRecordHome.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/SetupForm.Designer.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/SetupForm.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TvGuideBase.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TvRecorded.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/EditSchedule/EditScheduleController.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/EditSchedule/EditScheduleModel.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/RecorderTunersCache.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/ScheduleNamesCache.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/TvGuide/TvGuideController.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/UpcomingOrActiveProgramsList.cs Added Paths: ----------- trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/skin/BlueTwo wide/4TR_TvGuideSearch.xml Modified: trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/MediaPortalRecorderTunerService.cs =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/MediaPortalRecorderTunerService.cs 2009-01-15 08:29:58 UTC (rev 2509) +++ trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/MediaPortalRecorderTunerService.cs 2009-01-15 16:10:32 UTC (rev 2510) @@ -143,7 +143,8 @@ return null; } - public override bool StartRecording(string tvSchedulerHostName, int tvSchedulerTcpPort, CardChannelAllocation channelAllocation, DateTime startTime, DateTime stopTime, UpcomingProgram recordingProgram) + public override bool StartRecording(string tvSchedulerHostName, int tvSchedulerTcpPort, CardChannelAllocation channelAllocation, + DateTime startTime, DateTime stopTime, UpcomingProgram recordingProgram, string suggestedBaseFileName) { bool result = false; @@ -157,7 +158,7 @@ { result = this.RecordingThreads.StartNewThread(new RecordingThread(this.RecorderTunerId, tvSchedulerHostName, tvSchedulerTcpPort, channelAllocation, startTime, stopTime, - recordingProgram, recordOnCard, channel)); + recordingProgram, suggestedBaseFileName, recordOnCard, channel)); if (!result) { Log(TraceEventType.Error, "{0} - Already recording {1}", this.Name, recordingProgram.CreateProgramTitle()); @@ -188,6 +189,10 @@ string uncRecordingFolder = Common.ShareExplorer.GetUncPathForLocalPath(card.RecordingFolder); shares.Add(String.IsNullOrEmpty(uncRecordingFolder) ? card.RecordingFolder : uncRecordingFolder); } + else + { + shares.Add(String.Empty); + } } return shares.ToArray(); @@ -224,27 +229,29 @@ } } } - - if (liveTvStream != null) + else { - StopLiveTvStream(liveTvStream); - liveTvStream = null; - } + if (liveTvStream != null) + { + StopLiveTvStream(liveTvStream); + liveTvStream = null; + } - foreach (Card card in availableCards) - { - if (CardFreeOrUsingSameTransponder(card.IdCard, channel, null)) + foreach (Card card in availableCards) { - string userName = String.Format(CultureInfo.InvariantCulture, "{0}{1}", _ftrLiveUserName, Guid.NewGuid()); + if (CardFreeOrUsingSameTransponder(card.IdCard, channel, null)) + { + string userName = String.Format(CultureInfo.InvariantCulture, "{0}{1}", _ftrLiveUserName, Guid.NewGuid()); - User tve3User = new User(userName, true, card.IdCard); - tve3User.IdChannel = channel.IdChannel; - tve3User.SubChannel = -1; + User tve3User = new User(userName, true, card.IdCard); + tve3User.IdChannel = channel.IdChannel; + tve3User.SubChannel = -1; - LiveTvResult result = StartTimeShifting(card, channel, ref tve3User, ref liveTvStream); - if (result != LiveTvResult.NoFreeCardFound) - { - return result; + LiveTvResult result = StartTimeShifting(card, channel, ref tve3User, ref liveTvStream); + if (result != LiveTvResult.NoFreeCardFound) + { + return result; + } } } } @@ -285,19 +292,22 @@ { if (TvServerPlugin.TvController.Tune(ref tve3User, tuningChannel, channel.IdChannel) == TvResult.Succeeded) { - string fileName = Path.Combine(card.TimeShiftFolder, - String.Format(CultureInfo.InvariantCulture, @"live{0}-{1}.ts", tve3User.CardId, tve3User.SubChannel)); + string timeshiftFileName = Path.Combine(card.TimeShiftFolder, + String.Format(CultureInfo.InvariantCulture, @"live{0}-{1}", tve3User.CardId, tve3User.SubChannel)); - switch (TvServerPlugin.TvController.StartTimeShifting(ref tve3User, ref fileName)) + switch (TvServerPlugin.TvController.StartTimeShifting(ref tve3User, ref timeshiftFileName)) { case TvResult.Succeeded: if (liveTvStream == null) { + string rtspUrl = TvServerPlugin.TvController.GetStreamingUrl(tve3User); + string tsBufferFile = GetTsBufferFile(tve3User); lock (_tvStreamsLock) { - liveTvStream = new LiveTvStream(TvServerPlugin.TvController.GetStreamingUrl(tve3User)); - _tvStreams.Add(liveTvStream.RtspUrl, liveTvStream); - _tvStreamUsers.Add(liveTvStream.RtspUrl, tve3User); + liveTvStream = new LiveTvStream(rtspUrl); + liveTvStream.TimeshiftFile = tsBufferFile; + _tvStreams[liveTvStream.RtspUrl] = liveTvStream; + _tvStreamUsers[liveTvStream.RtspUrl] = tve3User; } } return LiveTvResult.Succeeded; @@ -339,6 +349,7 @@ _tvStreams.Remove(liveTvStream.RtspUrl); _tvStreamUsers.Remove(liveTvStream.RtspUrl); } + CleanUpTimeshiftingFiles(liveTvStream.TimeshiftFile); } catch (Exception ex) { @@ -347,6 +358,23 @@ } } + private void CleanUpTimeshiftingFiles(string timeshiftFile) + { + try + { + DirectoryInfo dirInfo = new DirectoryInfo(Path.GetDirectoryName(timeshiftFile)); + foreach (FileInfo fileInfo in dirInfo.GetFiles(Path.GetFileName(timeshiftFile) + "*")) + { + try { File.Delete(fileInfo.FullName); } + catch { } + } + } + catch + { + Log(TraceEventType.Error, "Failed to clean up timeshifting files for '{0}'", timeshiftFile); + } + } + public override LiveTvStream[] GetLiveTvStreams() { List<LiveTvStream> liveTvStreams = new List<LiveTvStream>(); @@ -359,7 +387,7 @@ cards.Sort(delegate(Card c1, Card c2) { return c1.Priority.CompareTo(c2.Priority); }); // Get the list of live streams from TV Server - Dictionary<string, User> mpStreams = new Dictionary<string, User>(); + Dictionary<string, User> mpStreamUsers = new Dictionary<string, User>(); foreach (Card card in cards) { User[] cardUsers = TvServerPlugin.TvController.GetUsersForCard(card.IdCard); @@ -372,7 +400,7 @@ User tve3User = user; if (TvServerPlugin.TvController.IsTimeShifting(ref tve3User)) { - mpStreams.Add(TvServerPlugin.TvController.GetStreamingUrl(tve3User), tve3User); + mpStreamUsers.Add(TvServerPlugin.TvController.GetStreamingUrl(tve3User), tve3User); } } } @@ -384,7 +412,7 @@ foreach (LiveTvStream tvStream in _tvStreams.Values) { - if (mpStreams.ContainsKey(tvStream.RtspUrl)) + if (mpStreamUsers.ContainsKey(tvStream.RtspUrl)) { liveTvStreams.Add(tvStream); } @@ -398,15 +426,16 @@ foreach(string keyToRemove in keysToRemove) { _tvStreams.Remove(keyToRemove); + _tvStreamUsers.Remove(keyToRemove); } // Check if there are any live streams within MP that we don't know about. // If so, stop those streams (they may be left-overs from client crashes). - foreach (string rtspUrl in mpStreams.Keys) + foreach (string rtspUrl in mpStreamUsers.Keys) { if (!_tvStreams.ContainsKey(rtspUrl)) { - User tve3User = mpStreams[rtspUrl]; + User tve3User = mpStreamUsers[rtspUrl]; TvServerPlugin.TvController.StopTimeShifting(ref tve3User, TvStoppedReason.KickedByAdmin); } } @@ -444,6 +473,17 @@ #region Private Methods + private static string GetTsBufferFile(User tve3User) + { + string tsBufferFile = TvServerPlugin.TvController.TimeShiftFileName(ref tve3User); + string uncTimeshiftFolder = Common.ShareExplorer.GetUncPathForLocalPath(Path.GetDirectoryName(tsBufferFile)); + if (!String.IsNullOrEmpty(uncTimeshiftFolder)) + { + return Path.Combine(uncTimeshiftFolder, Path.GetFileName(tsBufferFile)); + } + return null; + } + private List<Card> GetCardsForChannel(ChannelLinks channelLinks, Guid tvChannelId, string tvChannelName, out Channel channel) { List<Card> availableCards = new List<Card>(); Modified: trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/RecordingThread.cs =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/RecordingThread.cs 2009-01-15 08:29:58 UTC (rev 2509) +++ trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/RecordingThread.cs 2009-01-15 16:10:32 UTC (rev 2510) @@ -43,13 +43,15 @@ { private static object _startRecordingLock = new object(); + private string _suggestedBaseFileName; private Card _recordOnCard; private Channel _channel; public RecordingThread(Guid recorderTunerId, string tvSchedulerHostName, int tvSchedulerTcpPort, CardChannelAllocation channelAllocation, - DateTime startTime, DateTime stopTime, UpcomingProgram recordingProgram, Card recordOnCard, Channel channel) + DateTime startTime, DateTime stopTime, UpcomingProgram recordingProgram, string suggestedBaseFileName, Card recordOnCard, Channel channel) : base(recorderTunerId, tvSchedulerHostName, tvSchedulerTcpPort, channelAllocation, startTime, stopTime, recordingProgram, true) { + _suggestedBaseFileName = suggestedBaseFileName; _recordOnCard = recordOnCard; _channel = channel; } @@ -60,7 +62,7 @@ { get { - return new TimeSpan(0, 2, 0); + return new TimeSpan(0, 3, 0); } } @@ -81,12 +83,26 @@ protected override string OnStartRecording(RecorderTunerCallbackServiceAgent callbackAgent, ref string errorMessage) { - string fileName = Path.Combine(_recordOnCard.RecordingFolder, - Common.Utility.BuildRecordingBaseFileName(null, this.RecordingProgram)); + string baseFileName = _suggestedBaseFileName; + if (String.IsNullOrEmpty(baseFileName)) + { + baseFileName = Common.Utility.BuildRecordingBaseFileName(null, this.RecordingProgram); + } + else + { + this.UsedSuggestedBaseFileName = true; + } + + string fileName = Path.Combine(_recordOnCard.RecordingFolder, baseFileName); string extension = (_recordOnCard.RecordingFormat == 0) ? ".ts" : ".mpg"; _tve3RecordingFileName = Common.Utility.GetFreeFileName(fileName, extension); + string tve3RecordingDirectory = Path.GetDirectoryName(_tve3RecordingFileName); + if (!Directory.Exists(tve3RecordingDirectory)) + { + Directory.CreateDirectory(tve3RecordingDirectory); + } - string uncRecordingFolder = Common.ShareExplorer.GetUncPathForLocalPath(Path.GetDirectoryName(_tve3RecordingFileName)); + string uncRecordingFolder = Common.ShareExplorer.GetUncPathForLocalPath(tve3RecordingDirectory); if (String.IsNullOrEmpty(uncRecordingFolder)) { errorMessage = "Failed to convert '" + Path.GetDirectoryName(_tve3RecordingFileName) + "' to UNC path, please add required share"; Modified: trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/SetupForm.Designer.cs =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/SetupForm.Designer.cs 2009-01-15 08:29:58 UTC (rev 2509) +++ trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/SetupForm.Designer.cs 2009-01-15 16:10:32 UTC (rev 2510) @@ -35,6 +35,8 @@ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SetupForm)); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); this._tvSchedulerGroupBox = new System.Windows.Forms.GroupBox(); this._connectButton = new System.Windows.Forms.Button(); this._portNumericUpDown = new System.Windows.Forms.NumericUpDown(); @@ -54,13 +56,13 @@ this._channelItemsBindingSource = new System.Windows.Forms.BindingSource(this.components); this._notConnectedPanel = new System.Windows.Forms.Panel(); this._notConnectedLabel = new System.Windows.Forms.Label(); - this._generalGroupBox = new System.Windows.Forms.GroupBox(); + this._uncRecordingGroupBox = new System.Windows.Forms.GroupBox(); this._createUncShareButton = new System.Windows.Forms.Button(); - this._refreshUncButton = new System.Windows.Forms.Button(); this._uncPathsDataGridView = new System.Windows.Forms.DataGridView(); this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this._uncPathsBindingSource = new System.Windows.Forms.BindingSource(this.components); + this._refreshUncButton = new System.Windows.Forms.Button(); this._syncInfoLabel = new System.Windows.Forms.Label(); this._hoursLabel = new System.Windows.Forms.Label(); this._allProgramsHoursNumericUpDown = new System.Windows.Forms.NumericUpDown(); @@ -72,6 +74,13 @@ this._configTabPage = new System.Windows.Forms.TabPage(); this._powerGroupBox = new System.Windows.Forms.GroupBox(); this._restartOnResumeCheckBox = new System.Windows.Forms.CheckBox(); + this._uncPathsTabPage = new System.Windows.Forms.TabPage(); + this._uncTimeshiftGroupBox = new System.Windows.Forms.GroupBox(); + this._createTimeshiftingShareButton = new System.Windows.Forms.Button(); + this._uncTimeshiftingDataGridView = new System.Windows.Forms.DataGridView(); + this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this._uncTimeshiftingBindingSource = new System.Windows.Forms.BindingSource(this.components); this._channelsTabPage = new System.Windows.Forms.TabPage(); this._tvSchedulerGroupBox.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this._portNumericUpDown)).BeginInit(); @@ -81,7 +90,7 @@ ((System.ComponentModel.ISupportInitialize)(this._channelsDataGridView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this._channelItemsBindingSource)).BeginInit(); this._notConnectedPanel.SuspendLayout(); - this._generalGroupBox.SuspendLayout(); + this._uncRecordingGroupBox.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this._uncPathsDataGridView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this._uncPathsBindingSource)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this._allProgramsHoursNumericUpDown)).BeginInit(); @@ -89,6 +98,10 @@ this._tabControl.SuspendLayout(); this._configTabPage.SuspendLayout(); this._powerGroupBox.SuspendLayout(); + this._uncPathsTabPage.SuspendLayout(); + this._uncTimeshiftGroupBox.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this._uncTimeshiftingDataGridView)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this._uncTimeshiftingBindingSource)).BeginInit(); this._channelsTabPage.SuspendLayout(); this.SuspendLayout(); // @@ -315,25 +328,23 @@ this._notConnectedLabel.TabIndex = 0; this._notConnectedLabel.Text = "Not connected to For The Record, check server settings in Configuration."; // - // _generalGroupBox + // _uncRecordingGroupBox // - this._generalGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) + this._uncRecordingGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this._generalGroupBox.Controls.Add(this._createUncShareButton); - this._generalGroupBox.Controls.Add(this._refreshUncButton); - this._generalGroupBox.Controls.Add(this._uncPathsDataGridView); - this._generalGroupBox.Location = new System.Drawing.Point(6, 86); - this._generalGroupBox.Name = "_generalGroupBox"; - this._generalGroupBox.Size = new System.Drawing.Size(580, 128); - this._generalGroupBox.TabIndex = 1; - this._generalGroupBox.TabStop = false; - this._generalGroupBox.Text = "UNC Recording Paths"; + this._uncRecordingGroupBox.Controls.Add(this._createUncShareButton); + this._uncRecordingGroupBox.Controls.Add(this._uncPathsDataGridView); + this._uncRecordingGroupBox.Location = new System.Drawing.Point(6, 6); + this._uncRecordingGroupBox.Name = "_uncRecordingGroupBox"; + this._uncRecordingGroupBox.Size = new System.Drawing.Size(580, 152); + this._uncRecordingGroupBox.TabIndex = 1; + this._uncRecordingGroupBox.TabStop = false; + this._uncRecordingGroupBox.Text = "UNC Recording Paths"; // // _createUncShareButton // this._createUncShareButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this._createUncShareButton.Location = new System.Drawing.Point(6, 99); + this._createUncShareButton.Location = new System.Drawing.Point(6, 123); this._createUncShareButton.Name = "_createUncShareButton"; this._createUncShareButton.Size = new System.Drawing.Size(100, 23); this._createUncShareButton.TabIndex = 11; @@ -341,17 +352,6 @@ this._createUncShareButton.UseVisualStyleBackColor = true; this._createUncShareButton.Click += new System.EventHandler(this._createUncShareButton_Click); // - // _refreshUncButton - // - this._refreshUncButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this._refreshUncButton.Location = new System.Drawing.Point(499, 99); - this._refreshUncButton.Name = "_refreshUncButton"; - this._refreshUncButton.Size = new System.Drawing.Size(75, 23); - this._refreshUncButton.TabIndex = 12; - this._refreshUncButton.Text = "Refresh"; - this._refreshUncButton.UseVisualStyleBackColor = true; - this._refreshUncButton.Click += new System.EventHandler(this._refreshUncButton_Click); - // // _uncPathsDataGridView // this._uncPathsDataGridView.AllowUserToAddRows = false; @@ -385,7 +385,7 @@ dataGridViewCellStyle4.SelectionForeColor = System.Drawing.Color.Black; this._uncPathsDataGridView.RowsDefaultCellStyle = dataGridViewCellStyle4; this._uncPathsDataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this._uncPathsDataGridView.Size = new System.Drawing.Size(568, 76); + this._uncPathsDataGridView.Size = new System.Drawing.Size(568, 100); this._uncPathsDataGridView.StandardTab = true; this._uncPathsDataGridView.TabIndex = 10; this._uncPathsDataGridView.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this._uncPathsDataGridView_CellFormatting); @@ -409,6 +409,17 @@ this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2"; this.dataGridViewTextBoxColumn2.ReadOnly = true; // + // _refreshUncButton + // + this._refreshUncButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this._refreshUncButton.Location = new System.Drawing.Point(511, 322); + this._refreshUncButton.Name = "_refreshUncButton"; + this._refreshUncButton.Size = new System.Drawing.Size(75, 23); + this._refreshUncButton.TabIndex = 12; + this._refreshUncButton.Text = "Refresh"; + this._refreshUncButton.UseVisualStyleBackColor = true; + this._refreshUncButton.Click += new System.EventHandler(this._refreshUncButton_Click); + // // _syncInfoLabel // this._syncInfoLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0))); @@ -472,7 +483,7 @@ // // _epgGroupBox // - this._epgGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + this._epgGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this._epgGroupBox.Controls.Add(this._epgAutoCreateChannelsCheckBox); this._epgGroupBox.Controls.Add(this._allProgramsEveryLabel); @@ -480,7 +491,7 @@ this._epgGroupBox.Controls.Add(this._hoursLabel); this._epgGroupBox.Controls.Add(this._syncTve3EpgcheckBox); this._epgGroupBox.Controls.Add(this._syncInfoLabel); - this._epgGroupBox.Location = new System.Drawing.Point(6, 266); + this._epgGroupBox.Location = new System.Drawing.Point(6, 138); this._epgGroupBox.Name = "_epgGroupBox"; this._epgGroupBox.Size = new System.Drawing.Size(580, 106); this._epgGroupBox.TabIndex = 2; @@ -500,6 +511,7 @@ // _tabControl // this._tabControl.Controls.Add(this._configTabPage); + this._tabControl.Controls.Add(this._uncPathsTabPage); this._tabControl.Controls.Add(this._channelsTabPage); this._tabControl.Dock = System.Windows.Forms.DockStyle.Fill; this._tabControl.Location = new System.Drawing.Point(0, 0); @@ -513,7 +525,6 @@ // this._configTabPage.Controls.Add(this._powerGroupBox); this._configTabPage.Controls.Add(this._tvSchedulerGroupBox); - this._configTabPage.Controls.Add(this._generalGroupBox); this._configTabPage.Controls.Add(this._epgGroupBox); this._configTabPage.Location = new System.Drawing.Point(4, 22); this._configTabPage.Name = "_configTabPage"; @@ -525,9 +536,10 @@ // // _powerGroupBox // - this._powerGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this._powerGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this._powerGroupBox.Controls.Add(this._restartOnResumeCheckBox); - this._powerGroupBox.Location = new System.Drawing.Point(6, 218); + this._powerGroupBox.Location = new System.Drawing.Point(6, 88); this._powerGroupBox.Name = "_powerGroupBox"; this._powerGroupBox.Size = new System.Drawing.Size(580, 44); this._powerGroupBox.TabIndex = 3; @@ -544,6 +556,99 @@ this._restartOnResumeCheckBox.Text = "Re-initialize TV Server when the system resumes from standby"; this._restartOnResumeCheckBox.UseVisualStyleBackColor = true; // + // _uncPathsTabPage + // + this._uncPathsTabPage.Controls.Add(this._uncTimeshiftGroupBox); + this._uncPathsTabPage.Controls.Add(this._refreshUncButton); + this._uncPathsTabPage.Controls.Add(this._uncRecordingGroupBox); + this._uncPathsTabPage.Location = new System.Drawing.Point(4, 22); + this._uncPathsTabPage.Name = "_uncPathsTabPage"; + this._uncPathsTabPage.Size = new System.Drawing.Size(592, 374); + this._uncPathsTabPage.TabIndex = 2; + this._uncPathsTabPage.Text = "UNC Paths"; + this._uncPathsTabPage.UseVisualStyleBackColor = true; + // + // _uncTimeshiftGroupBox + // + this._uncTimeshiftGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this._uncTimeshiftGroupBox.Controls.Add(this._createTimeshiftingShareButton); + this._uncTimeshiftGroupBox.Controls.Add(this._uncTimeshiftingDataGridView); + this._uncTimeshiftGroupBox.Location = new System.Drawing.Point(6, 164); + this._uncTimeshiftGroupBox.Name = "_uncTimeshiftGroupBox"; + this._uncTimeshiftGroupBox.Size = new System.Drawing.Size(580, 152); + this._uncTimeshiftGroupBox.TabIndex = 13; + this._uncTimeshiftGroupBox.TabStop = false; + this._uncTimeshiftGroupBox.Text = "UNC Timeshift Paths"; + // + // _createTimeshiftingShareButton + // + this._createTimeshiftingShareButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this._createTimeshiftingShareButton.Location = new System.Drawing.Point(6, 123); + this._createTimeshiftingShareButton.Name = "_createTimeshiftingShareButton"; + this._createTimeshiftingShareButton.Size = new System.Drawing.Size(100, 23); + this._createTimeshiftingShareButton.TabIndex = 11; + this._createTimeshiftingShareButton.Text = "Create Share"; + this._createTimeshiftingShareButton.UseVisualStyleBackColor = true; + this._createTimeshiftingShareButton.Click += new System.EventHandler(this._createTimeshiftingShareButton_Click); + // + // _uncTimeshiftingDataGridView + // + this._uncTimeshiftingDataGridView.AllowUserToAddRows = false; + this._uncTimeshiftingDataGridView.AllowUserToDeleteRows = false; + this._uncTimeshiftingDataGridView.AllowUserToResizeRows = false; + dataGridViewCellStyle5.BackColor = System.Drawing.Color.WhiteSmoke; + dataGridViewCellStyle5.ForeColor = System.Drawing.Color.Black; + dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.Silver; + dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.Black; + this._uncTimeshiftingDataGridView.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5; + this._uncTimeshiftingDataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this._uncTimeshiftingDataGridView.AutoGenerateColumns = false; + this._uncTimeshiftingDataGridView.BackgroundColor = System.Drawing.Color.White; + this._uncTimeshiftingDataGridView.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; + this._uncTimeshiftingDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; + this._uncTimeshiftingDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.dataGridViewTextBoxColumn3, + this.dataGridViewTextBoxColumn4}); + this._uncTimeshiftingDataGridView.DataSource = this._uncTimeshiftingBindingSource; + this._uncTimeshiftingDataGridView.GridColor = System.Drawing.Color.White; + this._uncTimeshiftingDataGridView.Location = new System.Drawing.Point(6, 19); + this._uncTimeshiftingDataGridView.MultiSelect = false; + this._uncTimeshiftingDataGridView.Name = "_uncTimeshiftingDataGridView"; + this._uncTimeshiftingDataGridView.ReadOnly = true; + this._uncTimeshiftingDataGridView.RowHeadersVisible = false; + dataGridViewCellStyle6.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle6.ForeColor = System.Drawing.Color.Black; + dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.Silver; + dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.Black; + this._uncTimeshiftingDataGridView.RowsDefaultCellStyle = dataGridViewCellStyle6; + this._uncTimeshiftingDataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this._uncTimeshiftingDataGridView.Size = new System.Drawing.Size(568, 100); + this._uncTimeshiftingDataGridView.StandardTab = true; + this._uncTimeshiftingDataGridView.TabIndex = 10; + this._uncTimeshiftingDataGridView.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this._uncPathsDataGridView_CellFormatting); + this._uncTimeshiftingDataGridView.SelectionChanged += new System.EventHandler(this._uncTimeshiftingDataGridView_SelectionChanged); + // + // dataGridViewTextBoxColumn3 + // + this.dataGridViewTextBoxColumn3.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.dataGridViewTextBoxColumn3.DataPropertyName = "CardName"; + this.dataGridViewTextBoxColumn3.FillWeight = 30F; + this.dataGridViewTextBoxColumn3.HeaderText = "Card"; + this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3"; + this.dataGridViewTextBoxColumn3.ReadOnly = true; + // + // dataGridViewTextBoxColumn4 + // + this.dataGridViewTextBoxColumn4.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.dataGridViewTextBoxColumn4.DataPropertyName = "Message"; + this.dataGridViewTextBoxColumn4.FillWeight = 70F; + this.dataGridViewTextBoxColumn4.HeaderText = "Path"; + this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4"; + this.dataGridViewTextBoxColumn4.ReadOnly = true; + // // _channelsTabPage // this._channelsTabPage.Controls.Add(this._channelMappingGroupBox); @@ -570,7 +675,7 @@ ((System.ComponentModel.ISupportInitialize)(this._channelItemsBindingSource)).EndInit(); this._notConnectedPanel.ResumeLayout(false); this._notConnectedPanel.PerformLayout(); - this._generalGroupBox.ResumeLayout(false); + this._uncRecordingGroupBox.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this._uncPathsDataGridView)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this._uncPathsBindingSource)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this._allProgramsHoursNumericUpDown)).EndInit(); @@ -580,6 +685,10 @@ this._configTabPage.ResumeLayout(false); this._powerGroupBox.ResumeLayout(false); this._powerGroupBox.PerformLayout(); + this._uncPathsTabPage.ResumeLayout(false); + this._uncTimeshiftGroupBox.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this._uncTimeshiftingDataGridView)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this._uncTimeshiftingBindingSource)).EndInit(); this._channelsTabPage.ResumeLayout(false); this.ResumeLayout(false); @@ -599,7 +708,7 @@ private System.Windows.Forms.Panel _channelsPanel; private System.Windows.Forms.Label _notConnectedLabel; private System.Windows.Forms.BindingSource _channelItemsBindingSource; - private System.Windows.Forms.GroupBox _generalGroupBox; + private System.Windows.Forms.GroupBox _uncRecordingGroupBox; private System.Windows.Forms.Label _hoursLabel; private System.Windows.Forms.NumericUpDown _allProgramsHoursNumericUpDown; private System.Windows.Forms.Label _allProgramsEveryLabel; @@ -625,5 +734,12 @@ private System.Windows.Forms.GroupBox _powerGroupBox; private System.Windows.Forms.CheckBox _restartOnResumeCheckBox; private System.Windows.Forms.Button _linkChannelButton; + private System.Windows.Forms.TabPage _uncPathsTabPage; + private System.Windows.Forms.GroupBox _uncTimeshiftGroupBox; + private System.Windows.Forms.Button _createTimeshiftingShareButton; + private System.Windows.Forms.DataGridView _uncTimeshiftingDataGridView; + private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn3; + private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn4; + private System.Windows.Forms.BindingSource _uncTimeshiftingBindingSource; } } Modified: trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/SetupForm.cs =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/SetupForm.cs 2009-01-15 08:29:58 UTC (rev 2509) +++ trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/SetupForm.cs 2009-01-15 16:10:32 UTC (rev 2510) @@ -239,44 +239,23 @@ { bool anyError = false; - IList mediaPortalCards = Card.ListAll(); - List<UncPathItem> pathItems = new List<UncPathItem>(); + List<UncPathItem> tsPathItems = new List<UncPathItem>(); + List<Card> mediaPortalCards = Utility.GetAllCards(); foreach (Card card in mediaPortalCards) { - if (card.Enabled - && !card.DevicePath.Equals("(builtin)", StringComparison.CurrentCultureIgnoreCase) - && !String.IsNullOrEmpty(card.RecordingFolder)) - { - bool hasError = true; - string message; - - string recordingPath = card.RecordingFolder; - string uncPath = ShareExplorer.GetUncPathForLocalPath(recordingPath); - if (!String.IsNullOrEmpty(uncPath)) - { - message = uncPath; - recordingPath = uncPath; - hasError = false; - } - else - { - message = card.RecordingFolder; - hasError = true; - } - - anyError = anyError | hasError; - pathItems.Add(new UncPathItem(card.Name, recordingPath, message, hasError)); - } + anyError = anyError | AddUncPathItem(pathItems, card.Name, card.RecordingFolder); + anyError = anyError | AddUncPathItem(tsPathItems, card.Name, card.TimeShiftFolder); } _uncPathsBindingSource.DataSource = pathItems; + _uncTimeshiftingBindingSource.DataSource = tsPathItems; EnableUncButtons(); if (anyError) { - MessageBox.Show(this, "You must set up a share with full permissions for" + Environment.NewLine + "the SYSTEM account for all recording folders!", null, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + MessageBox.Show(this, "You must set up a share with full permissions for the core" + Environment.NewLine + "services account for all recording folders!", null, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception ex) @@ -285,6 +264,29 @@ } } + private static bool AddUncPathItem(List<UncPathItem> pathItems, string name, string path) + { + bool hasError = true; + string message; + + string uncPath = ShareExplorer.GetUncPathForLocalPath(path); + if (!String.IsNullOrEmpty(uncPath)) + { + message = uncPath; + path = uncPath; + hasError = false; + } + else + { + message = path; + hasError = true; + } + + pathItems.Add(new UncPathItem(name, path, message, hasError)); + + return hasError; + } + private void LoadChannels() { try @@ -317,11 +319,12 @@ private void _uncPathsDataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { + DataGridView dataGridView = sender as DataGridView; if (e.ColumnIndex == 1 && e.RowIndex >= 0 && e.RowIndex < _uncPathsBindingSource.Count) { - UncPathItem linkItem = _uncPathsDataGridView.Rows[e.RowIndex].DataBoundItem as UncPathItem; + UncPathItem linkItem = dataGridView.Rows[e.RowIndex].DataBoundItem as UncPathItem; if (linkItem != null && linkItem.HasError) { @@ -351,16 +354,6 @@ } } - private void _uncPathsDataGridView_SelectionChanged(object sender, EventArgs e) - { - EnableUncButtons(); - } - - private void _refreshUncButton_Click(object sender, EventArgs e) - { - LoadUncPaths(); - } - private void EnableUncButtons() { if (_uncPathsDataGridView.SelectedRows.Count > 0) @@ -372,6 +365,15 @@ { _createUncShareButton.Enabled = false; } + if (_uncTimeshiftingDataGridView.SelectedRows.Count > 0) + { + UncPathItem linkItem = _uncTimeshiftingDataGridView.SelectedRows[0].DataBoundItem as UncPathItem; + _createTimeshiftingShareButton.Enabled = linkItem.HasError; + } + else + { + _createTimeshiftingShareButton.Enabled = false; + } } private void EnableChannelButtons() @@ -379,25 +381,21 @@ _linkChannelButton.Enabled = (_channelsDataGridView.SelectedRows.Count == 1); } - private void _createUncShareButton_Click(object sender, EventArgs e) + private void _syncTve3EpgcheckBox_CheckedChanged(object sender, EventArgs e) { - if (_uncPathsDataGridView.SelectedRows.Count > 0) - { - CreateShareForm form = new CreateShareForm(); - UncPathItem linkItem = _uncPathsDataGridView.SelectedRows[0].DataBoundItem as UncPathItem; - form.LocalPath = linkItem.RecordingPath; - if (form.ShowDialog(this) == DialogResult.OK) - { - LoadUncPaths(); - } - } + _epgAutoCreateChannelsCheckBox.Enabled = _syncTve3EpgcheckBox.Checked; } - private void _syncTve3EpgcheckBox_CheckedChanged(object sender, EventArgs e) + private void _refreshUncButton_Click(object sender, EventArgs e) { - _epgAutoCreateChannelsCheckBox.Enabled = _syncTve3EpgcheckBox.Checked; + LoadUncPaths(); } + private void _uncPathsDataGridView_SelectionChanged(object sender, EventArgs e) + { + EnableUncButtons(); + } + private void _channelsDataGridView_SelectionChanged(object sender, EventArgs e) { EnableChannelButtons(); @@ -459,5 +457,36 @@ rowColor = Color.DarkGreen; } } + + private void _uncTimeshiftingDataGridView_SelectionChanged(object sender, EventArgs e) + { + EnableUncButtons(); + } + + private void _createUncShareButton_Click(object sender, EventArgs e) + { + if (_uncPathsDataGridView.SelectedRows.Count > 0) + { + ShowCreateShareForm(_uncPathsDataGridView.SelectedRows[0].DataBoundItem as UncPathItem); + } + } + + private void _createTimeshiftingShareButton_Click(object sender, EventArgs e) + { + if (_uncTimeshiftingDataGridView.SelectedRows.Count > 0) + { + ShowCreateShareForm(_uncTimeshiftingDataGridView.SelectedRows[0].DataBoundItem as UncPathItem); + } + } + + private void ShowCreateShareForm(UncPathItem linkItem) + { + CreateShareForm form = new CreateShareForm(); + form.LocalPath = linkItem.RecordingPath; + if (form.ShowDialog(this) == DialogResult.OK) + { + LoadUncPaths(); + } + } } } Modified: trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/SetupForm.resx =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/SetupForm.resx 2009-01-15 08:29:58 UTC (rev 2509) +++ trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/SetupForm.resx 2009-01-15 16:10:32 UTC (rev 2510) @@ -138,4 +138,13 @@ <data name="_syncInfoLabel.Text" xml:space="preserve"> <value>Only turn this on when you do *not* use XMLTV guide data and want the DVB-EPG data collected by TV Server copied over to For The Record (not recommended)! Channels you want to be synced must be created in For The Record and shown as linked in Channels.</value> </data> + <metadata name="dataGridViewTextBoxColumn3.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="dataGridViewTextBoxColumn4.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="_uncTimeshiftingBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>413, 16</value> + </metadata> </root> \ No newline at end of file Modified: trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/ChannelNavigator.cs =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/ChannelNavigator.cs 2009-01-15 08:29:58 UTC (rev 2509) +++ trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/ChannelNavigator.cs 2009-01-15 16:10:32 UTC (rev 2510) @@ -26,6 +26,7 @@ using System; using System.Collections.Generic; using System.Text; +using System.Threading; using MediaPortal.Configuration; using MediaPortal.GUI.Library; @@ -554,6 +555,7 @@ #region Live TV private LiveTvStream _liveTvStream; + private LiveTvStream _pendingStopLiveTvStream; private void TuneLiveTv(TvChannel tvChannel) { @@ -565,77 +567,96 @@ if (currentAndNext != null) { LiveTvStream liveTvStream = _liveTvStream; - if (liveTvStream == null) + + if (liveTvStream != null) { - LiveTvResult result = this.TvControlAgent.TuneLiveTvStream(currentAndNext.TvChannel, ref liveTvStream); - if (result == LiveTvResult.Succeeded) + bool resumeGraph = true; + g_Player.PauseGraph(); + LiveTvResult firstResult = LiveTvResult.Succeeded; + LiveTvResult result = LiveTvResult.UnknownError; + try { - SetCurrentAndNext(currentAndNext); - _currentChannel = tvChannel; - _liveTvStream = liveTvStream; + string lastRtspUrl = liveTvStream.RtspUrl; + result = this.TvControlAgent.TuneLiveTvStream(currentAndNext.TvChannel, ref liveTvStream); + if (result == LiveTvResult.Succeeded) + { + SetCurrentAndNext(currentAndNext); + _currentChannel = tvChannel; - if (_currentProgram != null) - { - g_Player.currentTitle = _currentProgram.CreateProgramTitle(); - g_Player.currentDescription = Utility.GetComposedDescription(_currentProgram); + if (liveTvStream.RtspUrl != lastRtspUrl) + { + result = PlayLiveTv(liveTvStream); + } + else + { + string fileName; + int seekOffset; + GetPlayerFileNameAndOffset(liveTvStream, out fileName, out seekOffset); + g_Player.SeekAbsolute(g_Player.Duration + seekOffset); + } } else { - g_Player.currentTitle = String.Empty; - g_Player.currentDescription = String.Empty; - } + firstResult = result; + tvChannel = _currentChannel; - if (g_Player.Play(_liveTvStream.RtspUrl, g_Player.MediaType.TV)) - { - if (_autoFullScreen) + g_Player.ContinueGraph(); + resumeGraph = false; + SilentlyStopLiveTv(liveTvStream); + + liveTvStream = null; + result = this.TvControlAgent.TuneLiveTvStream(tvChannel, ref liveTvStream); + if (result == LiveTvResult.Succeeded) { - g_Player.ShowFullScreenWindow(); + result = PlayLiveTv(liveTvStream); + _currentChannel = tvChannel; } } } - else + catch { + result = LiveTvResult.UnknownError; + } + finally + { + if (resumeGraph) + { + g_Player.ContinueGraph(); + } + } + + if (result != LiveTvResult.Succeeded) + { + SilentlyStopLiveTv(liveTvStream); ShowLiveTvError(result); - _liveTvStream = null; } + else if (firstResult != LiveTvResult.Succeeded) + { + ShowLiveTvError(firstResult); + } } - else + + if (liveTvStream == null) { - g_Player.PauseGraph(); - bool resumePlayer = true; - - string lastRtspUrl = liveTvStream.RtspUrl; + StopPendingLiveTvStream(); LiveTvResult result = this.TvControlAgent.TuneLiveTvStream(currentAndNext.TvChannel, ref liveTvStream); if (result == LiveTvResult.Succeeded) { SetCurrentAndNext(currentAndNext); _currentChannel = tvChannel; - if (liveTvStream.RtspUrl != lastRtspUrl) + result = PlayLiveTv(liveTvStream); + if (result == LiveTvResult.Succeeded) { - if (g_Player.Play(liveTvStream.RtspUrl, g_Player.MediaType.TV)) + if (_autoFullScreen) { - g_Player.ContinueGraph(); - resumePlayer = false; - _liveTvStream = liveTvStream; + g_Player.ShowFullScreenWindow(); } - else - { - _liveTvStream = null; - } } } - - if (resumePlayer) + else { - g_Player.SeekAbsolute(g_Player.Duration + 10); - g_Player.ContinueGraph(); - } - - if (result != LiveTvResult.Succeeded) - { ShowLiveTvError(result); - _liveTvStream = null; } } } @@ -643,6 +664,47 @@ } } + private LiveTvResult PlayLiveTv(LiveTvStream liveTvStream) + { + LiveTvResult result = LiveTvResult.Succeeded; + + string fileName; + int seekOffset; + GetPlayerFileNameAndOffset(liveTvStream, out fileName, out seekOffset); + + if (g_Player.Play(fileName, g_Player.MediaType.TV)) + { + _liveTvStream = liveTvStream; + g_Player.SeekAbsolute(g_Player.Duration + seekOffset); + } + else + { + result = LiveTvResult.UnknownError; + } + + return result; + } + + private void SilentlyStopLiveTv(LiveTvStream liveTvStream) + { + _liveTvStream = null; + g_Player.Stop(); + _liveTvStream = liveTvStream; + StopLiveTv(); + } + + private static void GetPlayerFileNameAndOffset(LiveTvStream liveTvStream, out string fileName, out int seekOffset) + { + seekOffset = 10; + fileName = liveTvStream.RtspUrl; + if (ForTheRecordHome.AvoidRtspForLiveTv + && !String.IsNullOrEmpty(liveTvStream.TimeshiftFile)) + { + fileName = liveTvStream.TimeshiftFile; + seekOffset = 0; + } + } + private void SetCurrentAndNext(CurrentAndNextProgram currentAndNext) { _currentNextProgram = currentAndNext; @@ -662,6 +724,20 @@ } } } + if (g_Player.Playing + && g_Player.IsTV) + { + if (_currentProgram != null) + { + g_Player.currentTitle = _currentProgram.CreateProgramTitle(); + g_Player.currentDescription = Utility.GetComposedDescription(_currentProgram); + } + else + { + g_Player.currentTitle = String.Empty; + g_Player.currentDescription = String.Empty; + } + } } private void RefreshCurrentAndNext() @@ -676,8 +752,29 @@ } } + private Thread _asyncStopLiveTvThread; + private object _asyncStopLiveTvLock = new object(); + + public void AsyncStopLiveTv() + { + if (_liveTvStream != null) + { + lock (_asyncStopLiveTvLock) + { + _pendingStopLiveTvStream = _liveTvStream; + _liveTvStream = null; + _previousChannel = _currentChannel; + _asyncStopLiveTvThread = new Thread(new ThreadStart(AsyncStopLiveTvThreadMain)); + _asyncStopLiveTvThread.Start(); + } + } + _currentChannel = null; + _currentNextProgram = null; + } + public void StopLiveTv() { + StopPendingLiveTvStream(); if (_liveTvStream != null) { this.TvControlAgent.StopLiveTvStream(_liveTvStream); @@ -727,6 +824,29 @@ #region Private methods + private void AsyncStopLiveTvThreadMain() + { + while ((g_Player.Playing || GUIGraphicsContext.IsPlaying) + && g_Player.IsTV) + { + Thread.Sleep(100); + } + Thread.Sleep(500); + StopPendingLiveTvStream(); + } + + private void StopPendingLiveTvStream() + { + lock (_asyncStopLiveTvLock) + { + if (_pendingStopLiveTvStream != null) + { + this.TvControlAgent.StopLiveTvStream(_pendingStopLiveTvStream); + _pendingStopLiveTvStream = null; + } + } + } + private void RefreshChannelsInGroup() { using (TvSchedulerServiceAgent tvSchedulerAgent = new TvSchedulerServiceAgent())... [truncated message content] |