[EPG] Will EPG data be updated while watching TV? (1 Viewer)

Snoopy87

Portal Pro
August 12, 2012
470
167
Home Country
Germany Germany
Hi,

I always wondered why EPG data is very often not updated and why I very often have no epg info on many channels.

Today I looked in the code and saw this code (EpgCard.cs):

Code:
public override int OnEpgReceived()
	{
	  try
	  {
		//is epg grabbing in progress?
		/*if (_state == EpgState.Idle)
		{
		  Log.Epg("Epg: card:{0} OnEpgReceived while idle", _user.CardId);
		  return 0;
		}*/
		//is epg grabber already updating the database?
 
		if (_state == EpgState.Updating)
		{
		  Log.Epg("Epg: card:{0} OnEpgReceived while updating", _user.CardId);
		  return 0;
		}
 
		//is the card still idle?
		if (IsCardIdle(_user) == false)
		{
		  Log.Epg("Epg: card:{0} OnEpgReceived but card is not idle", _user.CardId);
		  _state = EpgState.Idle;
		  _tvController.StopGrabbingEpg(_user);
		  _user.CardId = -1;
		  _currentTransponder.InUse = false;
		  return 0;
		}
 
		List<EpgChannel> epg = _tvController.Epg(_user.CardId) ?? new List<EpgChannel>();
		//did we receive epg info?
		if (epg.Count == 0)
		{
		  //no epg found for this transponder
		  Log.Epg("Epg: card:{0} no epg found", _user.CardId);
		  _currentTransponder.InUse = false;
		  _currentTransponder.OnTimeOut();
 
		  _state = EpgState.Idle;
		  _tvController.StopGrabbingEpg(_user);
		  _tvController.PauseCard(_user);
		  _user.CardId = -1;
		  _currentTransponder.InUse = false;
		  return 0;
		}
 
		//create worker thread to update the database
		Log.Epg("Epg: card:{0} received epg for {1} channels", _user.CardId, epg.Count);
		_state = EpgState.Updating;
		_epg = epg;
		Thread workerThread = new Thread(UpdateDatabaseThread);
		workerThread.IsBackground = true;
		workerThread.Name = "EPG Update thread";
		workerThread.Start();
	  }
	  catch (Exception ex)
	  {
		Log.Write(ex);
	  }
	  return 0;
	}

So, if EPG Grabber is already updating some data, the new received EPG data will not be stored.
Also, if the TV Card is NOT in idle state, the method returns.

So is it true, that the EPG data will only be stored, if my tv card is in idle state? That will mean, the EPG is not stored while watching a channel? Is there any reason for this behaviour? In my opinion it makes more sense to store the EPG which will be received on the channel I'm watching, because this is the normal and expected behaviour of any set top box / tv / dvb software. If I always watch TV with my HTPC, so that my TV card is never in idle mode, EPG data will never be stored?

Or do I understand something completly wrong? :-(

Best regards,
Sascha
 
Last edited:

Django.edwards

Portal Pro
October 22, 2009
457
54
Eupen
Home Country
Belgium Belgium
If you have the Option "grab epg while timeshifting" ticked, then the epg will be grabbed in the first minutes you Switch to the channel. You can observe this if you take a look at the "Manual" section in the tvserver config.
 

Snoopy87

Portal Pro
August 12, 2012
470
167
Home Country
Germany Germany
Ok, thanks.

Where do I find this code for? Is there another method which will be called in the case of "grab epg while timeshifting", because in the above code I can't see where the method does not return in this case.
 

tourettes

Retired Team Member
  • Premium Supporter
  • January 7, 2005
    17,301
    4,800
    No clue where the code resides but that pasted code is probably missing synchronisation for the state object. At least I would assume the state is used by multiple threads.

    @gibman
     

    Snoopy87

    Portal Pro
    August 12, 2012
    470
    167
    Home Country
    Germany Germany
    @Sebastiii: Could some developer look at this? I tooked a deeper look in this, and it seems to me, that EPG is not stored while watching TV, because it is only stored if the TV card is in idle state (which it is not, if you watch tv). Also the setting that EPG should be stored while timeshifting has no effect on this in my opinion.

    This could be found in TimeShifter.cs:

    Code:
    _timeshiftingEpgGrabberEnabled = (layer.GetSetting("timeshiftingEpgGrabberEnabled", "no").Value == "yes");

    _timeshiftingEpgGrabberEnabled will only be used here (TimeShifterBase.cs):

    Code:
    protected void StartTimeShiftingEPGgrabber(IUser user)
    	{
    	  if (_timeshiftingEpgGrabberEnabled)
    	  {
    		Channel channel = Channel.Retrieve(user.IdChannel);
    		if (channel.GrabEpg)
    		{
    		  _cardHandler.Card.GrabEpg();
    		}
    		else
    		{
    		  Log.Info("TimeshiftingEPG: channel {0} is not configured for grabbing epg",
    				  channel.DisplayName);
    		}
    	  }
    	}

    Because of Interfaces, etc. I was unable to follow the code more deeper, but I think at the end GrabEpg() will run OnEpgReceived() (posted in the first post) and as said then EPG data will not be stored, because TV card is not idling.
     
    Last edited:

    mm1352000

    Retired Team Member
  • Premium Supporter
  • September 1, 2008
    21,577
    8,224
    Home Country
    New Zealand New Zealand
    Could some developer look at this?
    Sure... but honestly, this problem would have been reported long ago if it were not working. ;)

    Where do I find this code for? Is there another method which will be called in the case of "grab epg while timeshifting", because in the above code I can't see where the method does not return in this case.

    OnEpgReceived() in TimeShiftingEPGGraber.cs (in the TV library).
    https://github.com/MediaPortal/Medi...TVLibrary/TVLibrary/TimeShiftingEPGGrabber.cs

    You're looking at the code for the idle EPG grabber only.
     

    Snoopy87

    Portal Pro
    August 12, 2012
    470
    167
    Home Country
    Germany Germany
    Thanks! I didn't know that, I only looked in the TV Service. Thanks! :)

    It's not easy to understand the whole code, if you are just starting with developing for MediaPortal, because it's a very huge project with a lot of code :)
     
    Last edited:

    Users who are viewing this thread

    Top Bottom