[FFmpeg-soc] [soc]: r4651 - concat/libavformat/xspf.c
gkovacs
subversion at mplayerhq.hu
Tue Jul 7 04:32:56 CEST 2009
Author: gkovacs
Date: Tue Jul 7 04:32:55 2009
New Revision: 4651
Log:
reimplemented xspf without datanode
Modified:
concat/libavformat/xspf.c
Modified: concat/libavformat/xspf.c
==============================================================================
--- concat/libavformat/xspf.c Tue Jul 7 04:21:29 2009 (r4650)
+++ concat/libavformat/xspf.c Tue Jul 7 04:32:55 2009 (r4651)
@@ -20,7 +20,6 @@
*/
#include "concatgen.h"
-#include "datanode.h"
/* The ffmpeg codecs we support, and the IDs they have in the file */
static const AVCodecTag codec_xspf_tags[] = {
@@ -41,18 +40,57 @@ static int xspf_probe(AVProbeData *p)
return 0;
}
-static int xspf_list_files(ByteIOContext *s, PlaylistContext *ctx)
+static int xspf_list_files(ByteIOContext *b, PlaylistContext *ctx)
{
- int i;
+ int i, j, c;
+ unsigned int buflen;
+ char state;
char **flist;
- StringList *l;
- DataNode *d;
- l = ff_stringlist_alloc();
- d = ff_datanode_tree_from_xml(s);
- ff_datanode_visualize(d);
- ff_datanode_filter_values_by_name(d, l, "location");
- ff_stringlist_print(l);
- ff_stringlist_export(l, &flist, &(ctx->pelist_size));
+ char buf[1024];
+ char s[5];
+ char t[] = "<location>";
+ state = flist = buflen = i = j = 0;
+ while ((c = url_fgetc(b))) {
+ if (c == EOF)
+ break;
+ if (state == 0) {
+ s[0] = s[1];
+ s[1] = s[2];
+ s[2] = s[3];
+ s[3] = s[4];
+ s[4] = s[5];
+ s[5] = s[6];
+ s[6] = s[7];
+ s[7] = s[8];
+ s[8] = s[9];
+ s[9] = c;
+ if (s[0] == t[0] && s[1] == t[1] && s[2] == t[2] && s[3] == t[3] && s[4] == t[4] &&
+ s[5] == t[5] && s[6] == t[6] && s[7] == t[7] && s[8] == t[8] && s[9] == t[9])
+ state = 1;
+ }
+ else {
+ if (c == '<') {
+ termfn:
+ buf[i++] = 0;
+ flist = av_fast_realloc(flist, &buflen, sizeof(*flist) * (j+2));
+ flist[j] = av_malloc(i);
+ av_strlcpy(flist[j++], buf, i);
+ i = 0;
+ state = 0;
+ s[sizeof(s)-1] = c;
+ continue;
+ }
+ else {
+ buf[i++] = c;
+ if (i >= sizeof(buf)-1)
+ goto termfn;
+ }
+ }
+ }
+ if (!flist) // no files have been found
+ return AVERROR_EOF;
+ flist[j] = 0;
+ ctx->pelist_size = j;
ff_playlist_relative_paths(flist, ctx->workingdir);
ctx->pelist = av_malloc(ctx->pelist_size * sizeof(*(ctx->pelist)));
memset(ctx->pelist, 0, ctx->pelist_size * sizeof(*(ctx->pelist)));
@@ -69,7 +107,10 @@ static int xspf_read_header(AVFormatCont
{
int i;
PlaylistContext *ctx = ff_playlist_alloc_context(s->filename);
- xspf_list_files(s->pb, ctx);
+ if (xspf_list_files(s->pb, ctx)) {
+ fprintf(stderr, "no playlist items found in %s\n", s->filename);
+ return AVERROR_EOF;
+ }
s->priv_data = ctx;
for (i = 0; i < ctx->pe_curidxs_size; ++i) {
ff_playlist_populate_context(ctx, s, i);
More information about the FFmpeg-soc
mailing list