[FFmpeg-devel] [PATCH] use new metadata API in realmedia

Michael Niedermayer michaelni
Tue Feb 17 01:42:37 CET 2009


On Tue, Feb 17, 2009 at 01:15:04AM +0100, Aurelien Jacobs wrote:
> Hi,
> 
> Attached patch converts rm muxer and demuxer to the new metadata API.
> 
> Aurel
> Index: libavformat/rmenc.c
> ===================================================================
> --- libavformat/rmenc.c	(revision 17387)
> +++ libavformat/rmenc.c	(working copy)
> @@ -70,7 +70,18 @@
>      const char *desc, *mimetype;
>      int nb_packets, packet_total_size, packet_max_size, size, packet_avg_size, i;
>      int bit_rate, v, duration, flags, data_pos;
> +    const char *title, *author, *copyright, *comment;
> +    AVMetadataTag *tag;
>  
> +    tag = av_metadata_get(ctx->metadata, "title"    , NULL, 0);
> +    title     = tag ? tag->value : "";
> +    tag = av_metadata_get(ctx->metadata, "author"   , NULL, 0);
> +    author    = tag ? tag->value : "";
> +    tag = av_metadata_get(ctx->metadata, "copyright", NULL, 0);
> +    copyright = tag ? tag->value : "";
> +    tag = av_metadata_get(ctx->metadata, "comment"  , NULL, 0);
> +    comment   = tag ? tag->value : "";
> +
>      start_ptr = s->buf_ptr;
>  
>      put_tag(s, ".RMF");
> @@ -123,14 +134,14 @@
>      /* comments */
>  
>      put_tag(s,"CONT");
> -    size = strlen(ctx->title) + strlen(ctx->author) + strlen(ctx->copyright) +
> -        strlen(ctx->comment) + 4 * 2 + 10;
> +    size = strlen(title) + strlen(author) + strlen(copyright) +
> +        strlen(comment) + 4 * 2 + 10;
>      put_be32(s,size);
>      put_be16(s,0);
> -    put_str(s, ctx->title);
> -    put_str(s, ctx->author);
> -    put_str(s, ctx->copyright);
> -    put_str(s, ctx->comment);
> +    put_str(s, title);
> +    put_str(s, author);
> +    put_str(s, copyright);
> +    put_str(s, comment);

for(i=0; i<FF_ARRAY_ELEMS(meta); i++)
    put_str(s, av_metadata_get(ctx->metadata, meta[i], NULL, 0));



>  
>      for(i=0;i<ctx->nb_streams;i++) {
>          int codec_data_size;
> Index: libavformat/rmdec.c
> ===================================================================
> --- libavformat/rmdec.c	(revision 17387)
> +++ libavformat/rmdec.c	(working copy)
> @@ -72,6 +72,13 @@
>      get_strl(pb, buf, buf_size, get_byte(pb));
>  }
>  
> +static void get_tag(AVFormatContext *s, int len, const char *name)
> +{
> +    char buf[1024];
> +    get_strl(s->pb, buf, sizeof(buf), len);
> +    av_metadata_set(&s->metadata, name, buf);
> +}
> +
>  RMStream *ff_rm_alloc_rmstream (void)
>  {
>      RMStream *rms = av_mallocz(sizeof(RMStream));
> @@ -95,10 +102,10 @@
>      if (((version >> 16) & 0xff) == 3) {
>          int64_t startpos = url_ftell(pb);
>          url_fskip(pb, 14);
> -        get_str8(pb, s->title, sizeof(s->title));
> -        get_str8(pb, s->author, sizeof(s->author));
> -        get_str8(pb, s->copyright, sizeof(s->copyright));
> -        get_str8(pb, s->comment, sizeof(s->comment));
> +        get_tag(s, get_byte(pb), "title");
> +        get_tag(s, get_byte(pb), "author");
> +        get_tag(s, get_byte(pb), "copyright");
> +        get_tag(s, get_byte(pb), "comment");

for()
    get_tag(s, ...meta_tag_name_whatever[i]);

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In fact, the RIAA has been known to suggest that students drop out
of college or go to community college in order to be able to afford
settlements. -- The RIAA
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090217/58e33157/attachment.pgp>



More information about the ffmpeg-devel mailing list