[FFmpeg-devel] [PATCH] RTSP-MS 14/15: ASF packet parsing

Michael Niedermayer michaelni
Tue Feb 3 13:38:17 CET 2009


On Tue, Jan 06, 2009 at 12:18:39AM -0500, Ronald S. Bultje wrote:
> Hi,
> 
> this patch implements parsing of ASF packets from RTSP packets.
> Nothing much to say about it. It's described on MSDN, so I didn't
> bother adding any explanation to the code about the data structure,
> especially since' we're reading no more than 4 bytes in this function
> anyway...
[....]
> +/**< return 0 on packet, no more left, 1 on packet, 1 on partial packet... */
> +static int
> +asfrtp_parse_packet (PayloadContext *asf, AVStream *st,
> +                     AVPacket *pkt, uint32_t *timestamp,
> +                     const uint8_t *buf, int len, int flags)
> +{
> +    ByteIOContext *gb = &asf->gb;
> +    int res, mflags, len_off;
> +    RTSPStream *rtsp_st = st->priv_data;
> +    AVFormatContext *s = rtsp_st->tx_ctx->ic;
> +    RTSPState *rt = s->priv_data;
> +

> +    if (!rt->asf_ctx)
> +        return -1;

can this happen?


> +
> +    if (len > 0) {
> +        if (len < 4)
> +            return -1;
> +

> +        av_freep(&asf->buffer);
> +        asf->buffer = av_malloc(len);
> +        memcpy(asf->buffer, buf, len);
> +
> +        init_put_byte(gb, asf->buffer, len, 0, NULL, NULL, NULL, NULL);
> +        mflags = get_byte(gb);
> +        if (mflags & 0x80)
> +            flags |= PKT_FLAG_KEY;

> +        len_off = (get_byte(gb)<<16)|(get_byte(gb)<<8)|get_byte(gb);

does this have defined behavior in C?


> +        if (mflags & 0x20) /* relative timestamp */
> +            url_fskip(gb, 4);
> +        if (mflags & 0x10) /* has duration */
> +            url_fskip(gb, 4);
> +        if (mflags & 0x8) /* has location ID */
> +            url_fskip(gb, 4);
> +
> +        if (!(mflags & 0x40) || len_off != len) {
> +            ff_log_missing_feature(s,
> +                "RTSP-MS packet concatenation and splitting", 1);
> +            return -1;
> +        }
> +
> +        gb->pos -= url_ftell(gb);
> +        gb->pos += rt->asf_gb_pos;
> +        res = ff_asf_get_packet(rt->asf_ctx, gb);
> +        rt->asf_gb_pos = url_ftell(gb);
> +        if (res < 0)
> +            return res;
> +    }
> +
> +    for (;;) {
> +        int i;
> +
> +        res = ff_asf_parse_packet(rt->asf_ctx, gb, pkt);
> +        rt->asf_gb_pos = url_ftell(gb);

> +        if (res != 0)

superflous != 0


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

Good people do not need laws to tell them to act responsibly, while bad
people will find a way around the laws. -- Plato
-------------- 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/20090203/ea61e430/attachment.pgp>



More information about the ffmpeg-devel mailing list