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

Michael Niedermayer michaelni
Tue Feb 17 16:36:25 CET 2009


On Tue, Feb 17, 2009 at 04:20:35PM +0100, Aurelien Jacobs wrote:
> On Tue, 17 Feb 2009 14:00:23 +0100
> Michael Niedermayer <michaelni at gmx.at> wrote:
> 
> > On Tue, Feb 17, 2009 at 12:52:21PM +0100, Aurelien Jacobs wrote:
> > > On Tue, 17 Feb 2009 01:42:37 +0100
> > > Michael Niedermayer <michaelni at gmx.at> wrote:
> > > 
> > > > 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));
> > > 
> > > This is not exactly as simple, because:
> > >  - av_metadata_get() don't return a char*
> > >  - av_metadata_get() can return NULL
> > > So this would looks more like:
> > >   for(i=0; i<FF_ARRAY_ELEMS(meta); i++) {
> > >      AVMetadataTag *tag = av_metadata_get(ctx->metadata, meta[i],NULL,0);
> > >      put_str(s, tag ? tag->value : "");
> > >   }
> > 
> > put_str(s, av_metadata_get(ctx->metadata, meta[i],NULL,0)->value);
> > with a less picky put_str() could be used. Iam not saying i
> > suggest that just that it can be done.
> 
> No it can't. av_metadata_get() can return NULL, so av_metadata_get()->value
> will segfault.

NULL->value will be NULL+4 or NULL+8, that can be checked for
not pretty and not strictly correct but it would work reliably in reality


> 
> > > But even with this, we are still left we the size calculation above.
> > 
> > sizepos= url_ftell();
> > for()
> >     ...
> > put_be32_at(url_ftell() - sizepos, sizepos);
> > 
> > is one way, again not saying i suggest it just showing that it can be done
> 
> I generally tend to avoid seeking, so I didn't even thought about this.
> I would indeed work.

theres a buffer so its not a real seek unless your metadata is
unrealistically large 

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No snowflake in an avalanche ever feels responsible. -- Voltaire
-------------- 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/07887022/attachment.pgp>



More information about the ffmpeg-devel mailing list