[WiP] Timeshifting in a single looping .ts file (1 Viewer)

dvdfreak

Portal Pro
June 13, 2006
979
178
Belgium Belgium
I want to propose a new .tshift format, similar to the existing .tsbuffer format, but with one big difference: timeshifting takes place in a single .ts file instead of a list of (by default) four files.

The format of this .tshift file is the following:

  1. First 8 bytes: 64-bit pointer to the current live-position (where the server is writing)
  2. Next 4 bytes: a 32-bit integer counting the number of times the file has looped/wrapped (starting at 0)
  3. Rest of the file: a Unicode filepath to the .ts file used (zero terminated, any path is ignored, file is in the same directory as the .tshift file)
As you can see: simple and straightforward.

The server writes to the .ts file and keeps the .tshift file up to date with the current position and wrapped-counter. When the server reaches the end of the file, the counter is incremented and the writing continues at the start of the same file.

What I'd like to upload first is the required patches to TsReader.ax and MediaPortal itself, so handle the client-side of this new format.

Note that the only reason I had to patch MP itself is to simply make sure .tshift files were recognized as live TV files and properly forwarded to tsreader. All the real logic is in tsreader itself.

Also note that there's still a small zapping issue, but we're look at that... Disaster123 is looking at the tswriter side of things, which he can add to this thread too I guess :)

Finally, what I uploaded does NOT work stand-alone yet. I have an internal For The Record build that writes out the new .tshift format, and disaster123 is working on tswriter...
 

Attachments

disaster123

MP Donator
  • Premium Supporter
  • May 14, 2008
    3,546
    432
    Germany Germany
    Country flag
    AW: Timeshifting in a single looping .ts file

    I will post the tswriter / tvserver patches tonight. ATM I'm busy with family stuff.
     

    tourettes

    Retired Team Member
  • Premium Supporter
  • January 7, 2005
    17,301
    4,800
    Please provide the source code changes as patch files. It will be much easier to work with those (and it is one of the requrement :)).

    Also mpfilewriter needs to be parched as well.
     

    miroslav22

    Development Group Member
  • Premium Supporter
  • September 4, 2009
    703
    460
    Warwick
    United Kingdom United Kingdom
    Country flag
    Re: AW: Timeshifting in a single looping .ts file

    I would think it will be ok. I don't think there's been any other major changes in tsreader from 1.1.2 -> 1.2.0 Alpha

    Edit: sorry no ignore me, another version will have to be compiled as there's more changes than just in tsreader
     

    disaster123

    MP Donator
  • Premium Supporter
  • May 14, 2008
    3,546
    432
    Germany Germany
    Country flag
    AW: Timeshifting in a single looping .ts file

    At least the tvserver patched will only work with SVN. So no 1.1.2 support here.

    tourettes
    Should the patch then include miroslav patch or should it work? It won't work without.
     

    FreakyJ

    Development Group
  • Team MediaPortal
  • July 25, 2010
    4,024
    1,420
    Germany Germany
    Country flag
    AW: Timeshifting in a single looping .ts file

    Just one question: Can you say something about the behavior with very big files? The reason is that I have a very long timeshifting period.

    Details:
    Minimum: 6 files
    Maximum: 30 files
    filesize: 600MB

    the result: ~18GB (600MB*30files) for paused live Tv and ~ 3,6GB (600MB * 6files) for normal live Tv.
    The normal live Tv should be no problem, but a file of 18GB will maybe...
    I'm using NTFS so the file size itself shouldn't be a problem (NTFS.com NTFS vs FAT32 FAT64 exFAT FAT. Comparing. Performance.), I'm more worried about things like the time which is needed to open the file or to preallocate the file.

    Another point is how you manage the current difference between "watching live Tv" and "paused live Tv" (see "Minumum" & "Maximum" in the wiki: Timeshifting - MediaPortal Wiki)

    Maybe you could give me some details on the points mentioned above, would be very kind of you =)
     

    miroslav22

    Development Group Member
  • Premium Supporter
  • September 4, 2009
    703
    460
    Warwick
    United Kingdom United Kingdom
    Country flag
    Hi,

    When a file is pre-allocated nothing is actually written to it, the space is only reserved on the disk. This is generally pretty quick even for a very large file.

    The drawback of a single file is you lose the flexibility of being able to leave it paused for a longer duration then the file length.
     

    SilentException

    Retired Team Member
  • Premium Supporter
  • October 27, 2008
    2,617
    1,130
    Rijeka, Croatia
    Croatia Croatia
    Country flag
    If I understand this correctly, currently if maximum files is reached, we loose live data instead of old data. So for example if we paused live TV on a movie and wen't away for quite some time, when we resumed, movie would resume up to the point where we started to loose live data. I don't know how important this feature is or even if it's a bug or feature but you should keep this in mind while working on single looping ts file :)
     

    FreakyJ

    Development Group
  • Team MediaPortal
  • July 25, 2010
    4,024
    1,420
    Germany Germany
    Country flag
    AW: Timeshifting in a single looping .ts file

    SilentException
    You are right =) And due to my opinion it is a feature rather than a bug^^ Because if I pause Live Tv I *want* to watch it later on and don't care about the live program 5 hours after this point...

    And you can get another error, an short example:

    Situation:
    - The size of your timeshift buffer is big enough for 3 hours
    - you pause your live tv
    - you are away for > 3 hours (maybe 4^^)

    Now (4 hours after pauseing live tv) you press play again, what would be the behavior of MP in this situation with a single timeshift buffer file?
    My expected behavior would be that MP continuous at the old position (like it is now).
    Another one would be to jump to the latest available point (not so nice, because I had a reason to pause live tv => want to watch it later)

    The result is that you have to stop timeshifting if live tv is paused & the buffer full :p
     

    Users Who Are Viewing This Thread (Users: 0, Guests: 1)

    Top Bottom