Incomplete Rar Support

  Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
gattan007 Offline
Junior Member
Posts: 1
Joined: Jun 2012
Reputation: 0
Post: #1
I'm one of those people who likes to start watching something as I download it, and not wait for the entire video to be completed. This is something that I could do with mplayer on my xbox version of xbmc, but having recently switched to a HTPC I was sad to see that this no longer worked. Looking through the forums here and elsewhere, it looks like I'm not alone in wishing that this functionality still existed. After digging around the code a little, I found a way to get back the functionality as it used to exist. This modification allows incomplete rar sets to be played (but you can't fastforward or rewind) and doesn't break any of the functionality in completed rar sets. Based on my admittedly limited testing, this seems to work just fine. I didn't feel like figuring out how to get an account working so I could submit the code via git, but maybe someone here can get this worked into the code base. Also, this probably isn't the most efficient way to go about adding this functionality, but its a working starting point for anyone who is interested.

In FileRar.cpp (xbmc Eden) this block of code:
Code:
// perform 'noidx' check
      CFileInfo* pFile = g_RarManager.GetFileInRar(m_strRarPath,m_strPathInRar);
      if (pFile)
      {
        if (pFile->m_iIsSeekable == -1)
        {
          if (Seek(-1,SEEK_END) == -1)
          {
            m_bSeekable = false;
            pFile->m_iIsSeekable = 0;
          }
        }
        else
          m_bSeekable = (pFile->m_iIsSeekable == 1);
      }
      return true;

should be replaced with this:
Code:
// perform 'noidx' check
      if (Seek(-1,SEEK_END) == -1)
      {
        m_bSeekable = false;
      }
      //The Seek() call leaves things in the wrong state
      //This is an easy (but not efficient) way to get things back as they should be
      CleanUp();
      OpenInArchive();
      return true;

Based on my testing, the call to g_RarManager.GetFileInRar() always returns NULL, even though the file exists in the rar and regardless of whether the rar set is complete. This change finds out if the file is seekable using a different method (just call Seek). The call to Seek either leaves you at the end of the file (wrong place), or returns an error (leaving the file a bad state). The calls to CleanUp() and OpenInArchive() put things back how they were before the call to Seek() in either case. The return values aren't checked because both of these functions had to be successful immediately prior to this in order to get to this point, but it would be better if the return values were checked here as well. I hope someone finds this useful, but if not at least I have it working for my own use Big Grin. Thanks.
find quote
Popeye Offline
Posting Freak
Posts: 874
Joined: Aug 2009
Reputation: 25
Location: Sweden
Post: #2
There is a closed trac ticket about the same thing, http://trac.xbmc.org/ticket/6888

sverigesradio | Pneumatic | SABnzbd | XBMC that just works - openelec
find quote
darwin Offline
Senior Member
Posts: 114
Joined: Feb 2009
Reputation: 0
Post: #3
Four years later, as the submitter of the above ticket, I still really want this feature. Any chance a developer could comment on the above patch methodology? I would be willing to try to this sort of functionality into a merge request in order to be able to do this again like on the xbox.. Smile

=darwin
find quote
jmarshall Offline
Team-XBMC Developer
Posts: 24,520
Joined: Oct 2003
Reputation: 138
Post: #4
The BEST way to sort this functionality is to get it into libarchive, as there's a patch to get libarchive to replace rar. This gives a completely free, clean implementation of reading in rar files.

With that said, a PR with your fix would at least get someone to review it.

Cheers,
Jonathan

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


[Image: badge.gif]
find quote