[FFmpeg-devel] [PATCH] http: add support for reading streamcast metadata
wm4
nfxjfg at googlemail.com
Thu Jun 27 18:52:39 CEST 2013
On Thu, 27 Jun 2013 15:14:58 +0200
Stefano Sabatini <stefasab at gmail.com> wrote:
Thanks for reviewing.
> > @@ -375,6 +385,16 @@ static int process_line(URLContext *h, char
> > *line, int line_count, snprintf(s->cookies, str_size, "%s\n%s",
> > tmp, p); av_free(tmp);
> > }
> > + } else if (!av_strcasecmp (tag, "Icy-MetaInt")) {
> > + s->icy_metaint = strtoll(p, NULL, 10);
> > + } else if (!av_strncasecmp(tag, "Icy-", 4)) {
> > + AVBPrint bp;
> > + av_bprint_init(&bp, 1, -1);
> > + if (s->icy_meta_header)
> > + av_bprintf(&bp, "%s", s->icy_meta_header);
> > + av_bprintf(&bp, "%s: %s\n", tag, p);
> > + av_freep(&s->icy_meta_header);
> > + av_bprint_finalize(&bp, &s->icy_meta_header);
>
> Nit++: probably easier if you first free, then fill the new value but
> maybe it's just me
No, I actually need the old value before that, because all header lines
starting with icy- are concatenated.
> > + if (s->icy_metaint > 0) {
> > + int remaining = s->icy_metaint - s->icy_data_read;
> > + if (!remaining) {
> > + char data[4096];
> > + char *buf;
> > + int n;
> > + int ch = http_getc(s);
> > + if (ch < 0)
> > + return ch;
> > + if (ch > 0) {
> > + ch *= 16;
> > + for (n = 0; n < ch; n++)
> > + data[n] = http_getc(s);
> > + buf = av_mallocz(ch + 1);
> > + if (buf)
> > + memcpy(buf, data, ch);
> > + av_freep(&s->icy_meta_packet);
> > + s->icy_meta_packet = buf;
> > + }
> > + s->icy_data_read = 0;
> > + remaining = s->icy_metaint;
> > + }
> > + size = FFMIN(size, remaining);
> > + }
>
> I can't really comment about this part. Can you add some generic
> comments to explain what it's doing?
Tried to do so. Note that I call http_getc() in a loop. This is a bit
dumb, but saves me from dealing with the buffer management code that is
in http.c.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-http-add-support-for-reading-streamcast-metadata.patch
Type: text/x-patch
Size: 7599 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130627/5f628852/attachment.bin>
More information about the ffmpeg-devel
mailing list