[EPG] - Will EPG data be updated while watching TV?

Discussion in 'Improvement Suggestions' started by Snoopy87, July 16, 2013.

  1. Snoopy87

    Snoopy87 Portal Pro

    Joined:
    August 12, 2012
    Messages:
    468
    Likes Received:
    123
    Gender:
    Male
    Ratings:
    +166 / 10
    Home Country:
    Germany Germany
    Show System Specs
    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 (Text):
    1. public override int OnEpgReceived()
    2.     {
    3.       try
    4.       {
    5.         //is epg grabbing in progress?
    6.         /*if (_state == EpgState.Idle)
    7.         {
    8.           Log.Epg("Epg: card:{0} OnEpgReceived while idle", _user.CardId);
    9.           return 0;
    10.         }*/
    11.         //is epg grabber already updating the database?
    12.  
    13.         if (_state == EpgState.Updating)
    14.         {
    15.           Log.Epg("Epg: card:{0} OnEpgReceived while updating", _user.CardId);
    16.           return 0;
    17.         }
    18.  
    19.         //is the card still idle?
    20.         if (IsCardIdle(_user) == false)
    21.         {
    22.           Log.Epg("Epg: card:{0} OnEpgReceived but card is not idle", _user.CardId);
    23.           _state = EpgState.Idle;
    24.           _tvController.StopGrabbingEpg(_user);
    25.           _user.CardId = -1;
    26.           _currentTransponder.InUse = false;
    27.           return 0;
    28.         }
    29.  
    30.         List<EpgChannel> epg = _tvController.Epg(_user.CardId) ?? new List<EpgChannel>();
    31.         //did we receive epg info?
    32.         if (epg.Count == 0)
    33.         {
    34.           //no epg found for this transponder
    35.           Log.Epg("Epg: card:{0} no epg found", _user.CardId);
    36.           _currentTransponder.InUse = false;
    37.           _currentTransponder.OnTimeOut();
    38.  
    39.           _state = EpgState.Idle;
    40.           _tvController.StopGrabbingEpg(_user);
    41.           _tvController.PauseCard(_user);
    42.           _user.CardId = -1;
    43.           _currentTransponder.InUse = false;
    44.           return 0;
    45.         }
    46.  
    47.         //create worker thread to update the database
    48.         Log.Epg("Epg: card:{0} received epg for {1} channels", _user.CardId, epg.Count);
    49.         _state = EpgState.Updating;
    50.         _epg = epg;
    51.         Thread workerThread = new Thread(UpdateDatabaseThread);
    52.         workerThread.IsBackground = true;
    53.         workerThread.Name = "EPG Update thread";
    54.         workerThread.Start();
    55.       }
    56.       catch (Exception ex)
    57.       {
    58.         Log.Write(ex);
    59.       }
    60.       return 0;
    61.     }
    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: July 16, 2013
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. Django.edwards

    Django.edwards Portal Pro

    Joined:
    October 22, 2009
    Messages:
    457
    Likes Received:
    47
    Gender:
    Male
    Location:
    Eupen
    Ratings:
    +55 / 0
    Home Country:
    Belgium Belgium
    Show System Specs
    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.
     
    • Like Like x 1
  4. Snoopy87

    Snoopy87 Portal Pro

    Joined:
    August 12, 2012
    Messages:
    468
    Likes Received:
    123
    Gender:
    Male
    Ratings:
    +166 / 10
    Home Country:
    Germany Germany
    Show System Specs
    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.
     
  5. Django.edwards

    Django.edwards Portal Pro

    Joined:
    October 22, 2009
    Messages:
    457
    Likes Received:
    47
    Gender:
    Male
    Location:
    Eupen
    Ratings:
    +55 / 0
    Home Country:
    Belgium Belgium
    Show System Specs
    Sorry no idea, I'm not a developer. :whistle:
     
  6. tourettes
    • Premium Supporter

    tourettes Retired Team Member

    Joined:
    January 7, 2005
    Messages:
    17,301
    Likes Received:
    4,595
    Ratings:
    +4,810 / 3
    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
     
  7. Snoopy87

    Snoopy87 Portal Pro

    Joined:
    August 12, 2012
    Messages:
    468
    Likes Received:
    123
    Gender:
    Male
    Ratings:
    +166 / 10
    Home Country:
    Germany Germany
    Show System Specs
    @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 (Text):
    1. _timeshiftingEpgGrabberEnabled = (layer.GetSetting("timeshiftingEpgGrabberEnabled", "no").Value == "yes");
    _timeshiftingEpgGrabberEnabled will only be used here (TimeShifterBase.cs):

    Code (Text):
    1. protected void StartTimeShiftingEPGgrabber(IUser user)
    2.     {
    3.       if (_timeshiftingEpgGrabberEnabled)
    4.       {
    5.         Channel channel = Channel.Retrieve(user.IdChannel);
    6.         if (channel.GrabEpg)
    7.         {
    8.           _cardHandler.Card.GrabEpg();
    9.         }
    10.         else
    11.         {
    12.           Log.Info("TimeshiftingEPG: channel {0} is not configured for grabbing epg",
    13.                   channel.DisplayName);
    14.         }
    15.       }
    16.     }
    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: July 17, 2013
  8. mm1352000
    • Team MediaPortal

    mm1352000 Development Group

    Joined:
    September 1, 2008
    Messages:
    21,527
    Likes Received:
    4,738
    Ratings:
    +8,205 / 17
    Home Country:
    New Zealand New Zealand
    Sure... but honestly, this problem would have been reported long ago if it were not working. ;)

    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.
     
    • Like Like x 1
  9. Snoopy87

    Snoopy87 Portal Pro

    Joined:
    August 12, 2012
    Messages:
    468
    Likes Received:
    123
    Gender:
    Male
    Ratings:
    +166 / 10
    Home Country:
    Germany Germany
    Show System Specs
    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: July 17, 2013
    • Agree Agree x 3
Loading...

Users Viewing Thread (Users: 0, Guests: 0)

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice
  • About The Project

    The vision of the MediaPortal project is to create a free open source media centre application, which supports all advanced media centre functions, and is accessible to all Windows users.

    In reaching this goal we are working every day to make sure our software is one of the best.

             

  • Support MediaPortal!

    The team works very hard to make sure the community is running the best HTPC-software. We give away MediaPortal for free but hosting and software is not for us.

    Care to support our work with a few bucks? We'd really appreciate it!