Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/Mediaportal/MP1-5111-Parallel_D…
Browse files Browse the repository at this point in the history
…VB_EPG' into MP_1.30_Pre_Release_Test3
  • Loading branch information
andrewjswan committed Apr 27, 2022
2 parents 3270705 + 8ed244c commit 623f4a4
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 46 deletions.
82 changes: 48 additions & 34 deletions TvEngine3/TVLibrary/SetupTv/Sections/Epg.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions TvEngine3/TVLibrary/SetupTv/Sections/Epg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

using System;
using System.Collections.Specialized;
using System.Collections.Generic;
using TvLibrary.Interfaces;
using TvDatabase;
using System.IO;
using TvLibrary;
Expand All @@ -29,6 +31,7 @@ namespace SetupTv.Sections
public partial class Epg : SectionSettings
{
private string crcSettingsFile = DebugSettings.SettingPath("DisableCRCCheck");
private readonly Dictionary<string, CardType> cardTypes = new Dictionary<string, CardType>();

public Epg()
: this("DVB EPG") {}
Expand All @@ -48,6 +51,33 @@ public override void OnSectionActivated()
checkBoxAlwaysUpdate.Checked = (layer.GetSetting("generalEPGAlwaysReplace", "no").Value == "yes");
checkboxSameTransponder.Checked = (layer.GetSetting("generalGrapOnlyForSameTransponder", "no").Value == "yes");

checkBoxUseAllAvailableTuners.Checked = (layer.GetSetting("UseAllAvailableTunersForEPG", "no").Value == "yes");
IList<Card> cards = Card.ListAllEnabled();
string cardType = "";
int nbAvailableCards = 0;
foreach (Card card in cards)
{
cardTypes[card.DevicePath] = TvControl.RemoteControl.Instance.Type(card.IdCard);
if (cardTypes.ContainsKey(card.DevicePath))
{
cardType = cardTypes[card.DevicePath].ToString();
}
// Don't take Analog, nor RadioWebStream nor DvbIP
if (cardType == "Atsc" || cardType == "DvbC" || cardType == "DvbS" || cardType == "DvbT")
{
nbAvailableCards++;
}
}
// At least 2 cards otherwise, AllAvailableTunersForEPG is useless
if (nbAvailableCards < 2 )
{
checkBoxUseAllAvailableTuners.Visible = false;
}
else
{
checkBoxUseAllAvailableTuners.Visible = true;
}

checkBoxEnableEPGWhileIdle.Checked = (layer.GetSetting("idleEPGGrabberEnabled", "yes").Value == "yes");
checkBoxEnableCRCCheck.Checked = !DebugSettings.DisableCRCCheck;
numericUpDownEpgTimeOut.Value = Convert.ToDecimal(layer.GetSetting("timeoutEPG", "10").Value);
Expand Down Expand Up @@ -77,6 +107,10 @@ public override void OnSectionDeActivated()
s.Value = checkboxSameTransponder.Checked ? "yes" : "no";
s.Persist();

s = layer.GetSetting("UseAllAvailableTunersForEPG", "no");
s.Value = checkBoxUseAllAvailableTuners.Checked ? "yes" : "no";
s.Persist();

DebugSettings.DisableCRCCheck = !checkBoxEnableCRCCheck.Checked;

s = layer.GetSetting("idleEPGGrabberEnabled", "yes");
Expand Down
4 changes: 2 additions & 2 deletions TvEngine3/TVLibrary/SetupTv/Sections/Epg.resx
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
12 changes: 6 additions & 6 deletions TvEngine3/TVLibrary/TvService/Epg/EpgCard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -385,12 +385,12 @@ private bool GrabEpgForChannel(Channel channel, IChannel tuning, Card card)
Log.Error("Epg: invalid user");
return false;
}
//remove following check to enable multi-card epg grabbing (still beta)
if (_tvController.AllCardsIdle == false)
{
Log.Epg("Epg: card:{0} cards are not idle", Card.IdCard);
return false;
}
// 5111: remove following check to enable multi-card epg grabbing (Parallel EPG)
// if (_tvController.AllCardsIdle == false)
// {
// Log.Epg("Epg: card:{0} cards are not idle", Card.IdCard);
// return false;
// }

TvResult result = TvResult.UnknownError;
//handle ATSC
Expand Down
35 changes: 31 additions & 4 deletions TvEngine3/TVLibrary/TvService/Epg/EpgGrabber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

namespace TvService
{
public class EpgCardPriorityComparer : IComparer<EpgCard>
public class EpgCardPriorityComparerHighest : IComparer<EpgCard>
{
// Highest priority first
public int Compare(EpgCard x, EpgCard y)
Expand All @@ -41,6 +41,19 @@ public int Compare(EpgCard x, EpgCard y)
}
}

public class EpgCardPriorityComparerLowest : IComparer<EpgCard>
{
// Lowest priority first
public int Compare(EpgCard x, EpgCard y)
{
if (x.Card.Priority < y.Card.Priority)
return -1;
if (x.Card.Priority == y.Card.Priority)
return 0;
return 1;
}
}

/// <summary>
/// Class which will continously grab the epg for all channels
/// Epg is grabbed when:
Expand All @@ -58,6 +71,7 @@ public class EpgGrabber : IDisposable
private bool _disposed;
private bool _isRunning;
private bool _reEntrant;
private bool _UseAllAvailableTunersForEPG;
private readonly TVController _tvController;
private List<EpgCard> _epgCards;

Expand Down Expand Up @@ -164,7 +178,18 @@ public void Start(double timerInterval)
EpgCard epgCard = new EpgCard(_tvController, card);
_epgCards.Add(epgCard);
}
_epgCards.Sort(new EpgCardPriorityComparer());

if (layer.GetSetting("UseAllAvailableTunersForEPG", "yes").Value != "yes")
{
_epgCards.Sort(new EpgCardPriorityComparerHighest());
_UseAllAvailableTunersForEPG = false;
}
else
{
_epgCards.Sort(new EpgCardPriorityComparerLowest());
_UseAllAvailableTunersForEPG = true;
}

_epgTimer.Interval = timerInterval;
_epgTimer.Enabled = true;
}
Expand Down Expand Up @@ -246,7 +271,8 @@ private void _epgTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
}
catch (InvalidOperationException) {}

if (_tvController.AllCardsIdle == false)
// Grab when all cards idle only when grab on highest priority card
if (_tvController.AllCardsIdle == false && _UseAllAvailableTunersForEPG == false)
return;
foreach (EpgCard card in _epgCards)
{
Expand All @@ -255,7 +281,8 @@ private void _epgTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
return;
if (card.IsGrabbing)
continue;
if (_tvController.AllCardsIdle == false)
// Grab when all cards idle only when grab on highest priority card
if (_tvController.AllCardsIdle == false && _UseAllAvailableTunersForEPG == false)
return;
GrabEpgOnCard(card);
}
Expand Down

0 comments on commit 623f4a4

Please sign in to comment.