[FFmpeg-devel] [patch]MMS protocol over TCP
zhentan feng
spyfeng
Wed Mar 24 16:30:14 CET 2010
Hi
On Wed, Mar 24, 2010 at 10:41 PM, Michael Niedermayer <michaelni at gmx.at>wrote:
> On Wed, Mar 24, 2010 at 10:33:01PM +0800, zhentan feng wrote:
> > Hi
> >
> > On Wed, Mar 24, 2010 at 1:19 AM, Ronald S. Bultje <rsbultje at gmail.com
> >wrote:
> >
> > > Hi,
> > >
> > > On Tue, Mar 23, 2010 at 12:56 PM, zhentan feng <spyfeng at gmail.com>
> wrote:
> > > > I implement MMS protocol over TCP based on other developers' patch.
> > > > The patch is against the latest svn trunk and attached below.
> > > > thanks Ronald's great help.
> > > [..]
> > > > Index: libavformat/asfenc.c
> > > > ===================================================================
> > > > --- libavformat/asfenc.c (revision 22644)
> > > > +++ libavformat/asfenc.c (working copy)
> > > > @@ -203,7 +203,7 @@
> > > > put_buffer(s, *g, sizeof(*g));
> > > > }
> > > >
> > > > -static int put_str16_nolen(ByteIOContext *s, const char *tag)
> > > > +int ff_put_str16_nolen(ByteIOContext *s, const char *tag)
> > > > {
> > > > const uint8_t *q = tag;
> > > > int ret = 0;
> > > > @@ -228,7 +228,7 @@
> > > > if (url_open_dyn_buf(&dyn_buf) < 0)
> > > > return;
> > > >
> > > > - put_str16_nolen(dyn_buf, tag);
> > > > + ff_put_str16_nolen(dyn_buf, tag);
> > > > len = url_close_dyn_buf(dyn_buf, &pb);
> > > > put_le16(s, len);
> > > > put_buffer(s, pb, len);
> > > > @@ -361,7 +361,7 @@
> > > > hpos = put_header(pb, &ff_asf_comment_header);
> > > >
> > > > for (n = 0; n < FF_ARRAY_ELEMS(tags); n++) {
> > > > - len = tags[n] ? put_str16_nolen(dyn_buf, tags[n]->value)
> :
> > > 0;
> > > > + len = tags[n] ? ff_put_str16_nolen(dyn_buf,
> tags[n]->value)
> > > : 0;
> > > > put_le16(pb, len);
> > > > }
> > > > len = url_close_dyn_buf(dyn_buf, &buf);
> > > > @@ -489,7 +489,7 @@
> > > > if ( url_open_dyn_buf(&dyn_buf) < 0)
> > > > return AVERROR(ENOMEM);
> > > >
> > > > - put_str16_nolen(dyn_buf, desc);
> > > > + ff_put_str16_nolen(dyn_buf, desc);
> > > > len = url_close_dyn_buf(dyn_buf, &buf);
> > > > put_le16(pb, len / 2); // "number of characters" = length in
> > > bytes / 2
> > > >
> > > > Index: libavformat/asf.h
> > > > ===================================================================
> > > > --- libavformat/asf.h (revision 22644)
> > > > +++ libavformat/asf.h (working copy)
> > > > @@ -230,4 +230,5 @@
> > > >
> > > > extern AVInputFormat asf_demuxer;
> > > >
> > > > +extern int ff_put_str16_nolen(ByteIOContext *s, const char *tag);
> > > > #endif /* AVFORMAT_ASF_H */
> > >
> > > An alternative here is to move this function to asf.h as an inline
> > > function, so there's no odd interdependencies.
> > >
> > > I modified it as inline function.
> > see attached patch.
> >
> [...]
> > Index: libavformat/asf.h
> > ===================================================================
> > --- libavformat/asf.h (revision 22644)
> > +++ libavformat/asf.h (working copy)
> > @@ -230,4 +230,20 @@
> >
> > extern AVInputFormat asf_demuxer;
> >
> > +static inline int ff_put_str16_nolen(ByteIOContext *s, const char *tag)
> > +{
> > + const uint8_t *q = tag;
> > + int ret = 0;
> > +
> > + while (*q) {
> > + uint32_t ch;
> > + uint16_t tmp;
> > +
> > + GET_UTF8(ch, *q++, break;)
> > + PUT_UTF16(ch, tmp, put_le16(s, tmp);ret += 2;)
> > + }
> > + put_le16(s, 0);
> > + ret += 2;
> > + return ret;
> > +}
> > #endif /* AVFORMAT_ASF_H */
>
> code duplication (in each object including this and using the function)
> iam against this, declare the proper dependancies or if you have to move
> this to a (maybe new) C file.
> [...]
yes you are right. It's a awkward way.
then, how about moving it libavformat/utils.c and declare it in internal.h?
zhentan
--
Best wishes~
More information about the ffmpeg-devel
mailing list