Discussion:
[vlc-devel] How to make relative paths in local xspf playlists work?
Michael A. Puls II
2009-07-30 13:24:44 UTC
Permalink
In
<https://trac.videolan.org/vlc/browser/modules/demux/playlist/xspf.c#L90>,
p_demux->p_sys->psz_base should be initialized to a URI (file: or http:
for example) representing the directory the xspf file is in.

Then, for the xml:base case at
<https://trac.videolan.org/vlc/browser/modules/demux/playlist/xspf.c#L213>,
right before: p_demux->p_sys->psz_base = strdup( psz_value );,
free(p_demux->p_sys->psz_base); could be added if needed.

I think that would solve the "psz_base should default to the XSPF resource
location" problem mentioned at
<https://trac.videolan.org/vlc/browser/modules/demux/playlist/xspf.c#L562>,
which will make relative paths in local xspf files work.

Or, maybe only do that "if missing (not the current working directory)."

However, how do you get the path to the xspf file (as an absolute URI) so
that you can do:

"file:///c:/documents%20and%20settings/user/desktop/file.xspf" ->
"file:///c:/documents%20and%20settings/user/desktop/" to get the base path.

Thanks
--
Michael
Rafaël Carré
2009-07-30 13:29:36 UTC
Permalink
On Thu, 30 Jul 2009 09:24:44 -0400
Post by Michael A. Puls II
However, how do you get the path to the xspf file (as an absolute
"file:///c:/documents%20and%20settings/user/desktop/file.xspf" ->
"file:///c:/documents%20and%20settings/user/desktop/" to get the base path.
Have a look at include/vlc_demux.h , especially struct demux_t ->
psz_path
--
Rafa?l Carr?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20090730/2652e054/attachment.pgp>
Rémi Denis-Courmont
2009-07-30 14:33:24 UTC
Permalink
Post by Michael A. Puls II
I think that would solve the "psz_base should default to the XSPF resource
location" problem mentioned at
<https://trac.videolan.org/vlc/browser/modules/demux/playlist/xspf.c#L562>,
which will make relative paths in local xspf files work.
Not really. Sure, you can get the base URL from the demux_t.psz_path, but you
still need to implement the algorithm to resolve an absolute URI from a base
absolute URI and a relative URI... gcc is not going to do it for us.
--
R?mi Denis-Courmont
http://www.remlab.net/
Michael A. Puls II
2009-07-30 16:06:34 UTC
Permalink
On Thu, 30 Jul 2009 10:33:24 -0400, R?mi <Denis-Courmont"
Post by Rémi Denis-Courmont
Post by Michael A. Puls II
I think that would solve the "psz_base should default to the XSPF resource
location" problem mentioned at
<https://trac.videolan.org/vlc/browser/modules/demux/playlist/xspf.c#L562>,
which will make relative paths in local xspf files work.
Not really. Sure, you can get the base URL from the demux_t.psz_path, but you
still need to implement the algorithm to resolve an absolute URI from a base
absolute URI and a relative URI... gcc is not going to do it for us.
Thanks

So, you're saying the full deal is needed like URI parser does it?
<http://uriparser.sourceforge.net/doc/html/#filenames>
<http://uriparser.sourceforge.net/doc/html/>

However, my original thinking was that for dragging and dropping .xspf
files onto vlc or using file -> open -> file.xspf, you'd always get an
absolute path to work with. And, the same would apply for "vlc.exe"
"absolute path to local playlist.xspf".

"vlc.exe" "relative path to local .xspf file" just still wouldn't work for
relative location paths in the file, but things would perhaps be improved
for *some* of the situations.

Right now, I just workaround this by doing:

<playlist xml:base="absolute URI to directory the playlist is in">

and changing that if I move the playlist.

I have an idea of how things should fully work though. I can use Firefox
to simulate it.

1. Load an xspf file with XHR.

2. Get the textContent of a <location> element.

3. Create an HTMLAnchorElement (with the xspf xml doc as the
ownerDocument).

4. Set the anchor element's href to the textContent of the <location>
element.

5. Append the anchor element to the <location> element.

6. Get the href property of the appended anchor element.

7. Remove the anchor element from the <location> element (as it's not
needed any more)

The keys there are:

#4 will resolve the URI (absolute or not or expansions etc.) to an
absolute URI based on the xspf file's path.

#5 will update the resolution to honor all the xml:base attributes in the
xspf xml document that apply to the <location> element

In short, you end up with absolute URI paths to the files all resolved and
normalized nicely. Of course, Firefox has a really nice XML parser with a
nice URI resolver/normalizer.
--
Michael
Loading...