[Approved] - Fix for TsReader problems with TS files with PCR rollover

Discussion in 'Archive' started by asselin, June 29, 2011.

    • Premium Supporter

    asselin MP Donator

    Continuing this from the thread I started over here: http://forum.team-mediaportal.com/m...ies-when-dealing-ts-files-pcr-rollover-97975/.

    TsReader has 2 bugs in it when dealing with TS files that have PCR rollover:
    1. When you start playback, MediaPortal freezes, HDD light goes solid, and after a while (could be minutes), the file starts playing back.
    2. While playing, if you try to skip forward or backward, the HDD light goes solid again, and then after a while, the recording restarts from the beginning.

    Problem #1 is a bug in TsDuration. It calculates the duration of the TS file by looking for the max PCR in the TS file before the rollover happens, and does this by a sequential (!) backwards (!!) file search. All that is unnecessary-- the code should just use a constant value (the MAX possible PCR of all binary 1s) as the value. The patch to TsDuration{.cpp,.h} below fixes this.

    Problem #2 is a bug in TsFileSeek. Here, there's a section of code specifically for scanning a TS file with PCR rollover in it, and there's an if() statement where the logic is backwards. Fixing the if() fixes the problem, but beyond that, there's a whole other algorithm in it to deal with skipping around in TS files with PCR rollover that is unnecessary. The standard binary search algorithm works just fine, and is in fact faster. The patch to TsFileSeek below fixes both of these.

    This is my first patch submission for MediaPortal, so if there are some rules (written or unwritten) that I haven't followed for patch submission, please let me know, and I'd be happy to work on the patches to get them into proper shape for inclusion.

    Thanks...

    Attached Files:

    • Like Like x 6
    • Team MediaPortal

    Owlsroost Development Group

    System Specs
    I keep getting "The patch seems outdated!" error messages from TortoiseSVN when I try to apply some of the patch files - is anyone else seeing this ?

    Tony
    • Premium Supporter

    asselin Thread Starter MP Donator

    I'm at work and don't have access to my dev PC right now, but I'll take a look at it tonight. I manually trimmed down the patch files before submitting because there were quite a few lines of just whitespace differences; I probably messed something up. Sorry for the wasted time-- I'll be more careful before submitting next time. :oops:
    • Team MediaPortal

    Owlsroost Development Group

    System Specs
    No problem :) - I think you have to leave the .patch files untouched after generation (it was mis-matched whitespace-only lines generating the error message, as far as I can tell)

    Tony
    • Premium Supporter

    disaster123 MP Donator

    AW: Fix for TsReader problems with TS files with PCR rollover

    For me this results in non working seeking for live TV.
    • Premium Supporter

    asselin Thread Starter MP Donator

    OK, take 2, being more careful this time not to introduce stupid mistakes :oops: (sorry disaster123) and not edit patches after SVN creates them.

    Thanks...

    Attached Files:

    • Like Like x 1
    • Premium Supporter

    disaster123 MP Donator

    AW: Fix for TsReader problems with TS files with PCR rollover

    So seeking should work niw on LiveTV even when the ts buffer rollover happens?
    • Premium Supporter

    asselin Thread Starter MP Donator

    disaster123,

    From what tourettes explained to me on the other thread, PCR rollover should never occur when playing TS files recorded with MediaPortal because TsWriter modifies the PCR it writes into the TS file.

    There was a silly bug in the original patch I submitted that completely broke seek in all cases. I fixed that in the patch I just submitted.

    So in short, yes, this should work for you. If it doesn't, can you post the TsReader.log file?

    Thanks...
    • Team MediaPortal

    tourettes Development Group

    True. TsWriter will produce TS buffer files that start always from the 0 PCR value. So it will take 26+ hours to reach the PCR rollover in timeshifting buffer. It is highly likely that the 26+ hour mark is having similar issues as asselin has seen in the local TS files. It is even possible that asselin's fix allows more than 26+ hours of continuous live tv watching (as long as the buffer timespan itself is not bigger than 26+ hours).
    • Premium Supporter

    disaster123 MP Donator

    AW: Fix for TsReader problems with TS files with PCR rollover

    OK will try again. Could it be that the Streamingserver component needs the same patch?
    • Like Like x 1

Share This Page

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

Running the latest version?

V1.3.0 FINAL - released March 2013
Releasenews | Download
Changelog
 | Requirements
HTPC
Team-MediaPortal
 
About
Contact |  Press
Partners