Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

demux: add support for XSPF playlist files #8513

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Gobbel2000
Copy link

This adds support for the playlist format XSPF (website). It is used by various music players, maybe most notably it is the default for exporting playlists in VLC.

As XSPF is an XML format, I used the libxml2 library in implementation. This would add a new dependency, although libxml2 is already a dependency of ffmpeg and probably present on most systems. I have added an appropriate entry to the wscript, mostly so that it compiles. I have no experience with WAF, so it is very probable that this part needs to be changed in order to comply with best practices.

Line 227 assumes that p->real_stream->path is always set. Is that the case? If not an alternative way would be to load the entire file into memory and then use xmlParseMemory() instead.

@Gobbel2000 Gobbel2000 force-pushed the xspf branch 2 times, most recently from c20569c to bc0b481 Compare January 27, 2021 23:25
@@ -21,6 +21,8 @@
#include <dirent.h>

#include <libavutil/common.h>
#include <libxml/parser.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#if HAVE_LIBXML2

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I've added a few #if's and it works as expected now with --disable-libxml2.

This requires libxml2 as a new dependency
@Gobbel2000
Copy link
Author

The short answer is no, I don't know whether libxml2 is the best option. This is the first time I've used an XML library for C and I basically looked for what is most commonly used and is easy enough to figure out, counting on the wisdom of the crowd. It does seem to control at least some parts in a global state, the way I suppressed the error outputs would be an example. I'll look a bit into what problems or security issues there might be. If you know a better alternative or I find something then I wouldn't be opposed to changing to a different library.

@jeeb
Copy link
Member

jeeb commented May 8, 2021

I think around 5-10 or so years ago libxml2 had various issues due to trusting the input too much for its own good by default, but according to one of those people I know who looks up issues, apparently at this point it's not really that interesting as a target.

The main thing I would probably consider is whether one prefers the API of libxml2 or libexpat, and how much emphasis their documentation puts on using streaming parsing (as opposed to doing it in one big lump o' memory) as well as handling things securely.

Their CVE counts for recent years can be seen @
http://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=libxml2
http://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=expat

Expat has quite a bit less of CVEs in general, but one has to consider the proliferation of both libraries, and how much that affects things (more exposure means things get more poked, etc). Fortunately enough I have not yet had to dwell into this hornet's nest myself, so API wise I have not yet ventured into which seems like the less bad alternative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants