[FFmpeg-devel] [PATCH] RTMP client support for lavf

Diego Biurrun diego
Tue Jul 21 10:23:33 CEST 2009


On Tue, Jul 21, 2009 at 11:04:09AM +0300, Kostya wrote:
> 
> --- libavformat/rtmpproto.c	(revision 0)
> +++ libavformat/rtmpproto.c	(revision 0)
> @@ -0,0 +1,630 @@
> +static void gen_play(URLContext *s, RTMPContext *rt)
> +{
> +    RTMPPacket pkt;
> +    uint8_t *p;
> +
> +    //av_log(s, AV_LOG_DEBUG, "Sending play command for '%s'\n", rt->playpath);
> +    ff_rtmp_packet_create(&pkt, RTMP_VIDEO_CHANNEL, RTMP_PT_INVOKE, 0,
> +                       29 + strlen(rt->playpath));

indentation

> --- libavformat/rtmppkt.c	(revision 0)
> +++ libavformat/rtmppkt.c	(revision 0)
> @@ -0,0 +1,261 @@
> +int ff_rtmp_packet_read(URLContext *h, RTMPPacket *p,
> +                     int chunk_size, RTMPPacket *prev_pkt)

indentation

> +    if (url_read(h, &hdr, 1) != 1) {
> +        return AVERROR(EIO);
> +    }

pointless {}

> +    if (hdr == RTMP_PS_ONEBYTE) {
> +        //todo
> +        return -1;
> +    } else {
> +        if (url_read_complete(h, buf, 3) != 3) {
> +            return AVERROR(EIO);
> +        }

ditto

> +        timestamp = AV_RB24(buf);
> +        if (hdr != RTMP_PS_FOURBYTES) {
> +            if (url_read_complete(h, buf, 3) != 3) {
> +                return AVERROR(EIO);
> +            }

ditto

> +            data_size = AV_RB24(buf);
> +            if (url_read_complete(h, &type, 1) != 1) {
> +                return AVERROR(EIO);
> +            }

ditto

> +            if (hdr == RTMP_PS_TWELVEBYTES) {
> +                if (url_read_complete(h, buf, 4) != 4) {
> +                    return AVERROR(EIO);
> +                }

ditto

> +    while (data_size > 0) {
> +        int toread = FFMIN(data_size, chunk_size);
> +        int r;
> +        if ((r = url_read_complete(h, p->data + offset, toread)) != toread) {
> +            ff_rtmp_packet_destroy(p);
> +            return AVERROR(EIO);
> +        }
> +        data_size -= chunk_size;
> +        offset    += chunk_size;
> +        if (data_size > 0) {
> +            url_read_complete(h, &t, 1); //marker
> +            if (t != (0xC0 + channel_id)) {
> +                return -1;
> +            }

ditto

> +int ff_rtmp_packet_write(URLContext *h, RTMPPacket *pkt,
> +                      int chunk_size, RTMPPacket *prev_pkt)

indentation

> --- libavformat/rtmppkt.h	(revision 0)
> +++ libavformat/rtmppkt.h	(revision 0)
> @@ -0,0 +1,210 @@
> +
> +int ff_rtmp_packet_create(RTMPPacket *pkt, int channel_id, RTMPPacketType type,
> +                          int timestamp, int size);

nit: long line


You don't employ an editor that does the right thing (TM) when you hit
the tab key?

Diego



More information about the ffmpeg-devel mailing list