[FFmpeg-soc] [soc]: r4505 - in rtmp: rtmpdec.c rtmppkt.c rtmppkt.h

kostya subversion at mplayerhq.hu
Tue Jun 23 20:01:45 CEST 2009


Author: kostya
Date: Tue Jun 23 20:01:44 2009
New Revision: 4505

Log:
Format->protocol transition: do not use AVFormatContext in RTMP packet
reading/writing.

Modified:
   rtmp/rtmpdec.c
   rtmp/rtmppkt.c
   rtmp/rtmppkt.h

Modified: rtmp/rtmpdec.c
==============================================================================
--- rtmp/rtmpdec.c	Tue Jun 23 19:55:11 2009	(r4504)
+++ rtmp/rtmpdec.c	Tue Jun 23 20:01:44 2009	(r4505)
@@ -123,7 +123,7 @@ static void gen_connect(AVFormatContext 
 
     pkt.data_size = p - pkt.data;
 
-    rtmp_packet_write(s, rt->rtmp_hd, &pkt, rt->chunk_size, rt->prev_pkt[1]);
+    rtmp_packet_write(rt->rtmp_hd, &pkt, rt->chunk_size, rt->prev_pkt[1]);
 }
 
 static void gen_create_stream(AVFormatContext *s, RTMPContext *rt)
@@ -141,7 +141,7 @@ static void gen_create_stream(AVFormatCo
     rtmp_amf_write_tag(&p, AMF_NUMBER, &num);
     rtmp_amf_write_tag(&p, AMF_NULL, NULL);
 
-    rtmp_packet_write(s, rt->rtmp_hd, &pkt, rt->chunk_size, rt->prev_pkt[1]);
+    rtmp_packet_write(rt->rtmp_hd, &pkt, rt->chunk_size, rt->prev_pkt[1]);
     rtmp_packet_destroy(&pkt);
 }
 
@@ -165,7 +165,7 @@ static void gen_play(AVFormatContext *s,
     num = 0.0;
     rtmp_amf_write_tag(&p, AMF_NUMBER, &num);
 
-    rtmp_packet_write(s, rt->rtmp_hd, &pkt, rt->chunk_size, rt->prev_pkt[1]);
+    rtmp_packet_write(rt->rtmp_hd, &pkt, rt->chunk_size, rt->prev_pkt[1]);
     rtmp_packet_destroy(&pkt);
 
     // set client buffer time disguised in ping packet
@@ -176,7 +176,7 @@ static void gen_play(AVFormatContext *s,
     bytestream_put_be32(&p, 1);
     bytestream_put_be32(&p, 256); //TODO: what is a good value here?
 
-    rtmp_packet_write(s, rt->rtmp_hd, &pkt, rt->chunk_size, rt->prev_pkt[1]);
+    rtmp_packet_write(rt->rtmp_hd, &pkt, rt->chunk_size, rt->prev_pkt[1]);
     rtmp_packet_destroy(&pkt);
 }
 
@@ -189,7 +189,7 @@ static void gen_pong(AVFormatContext *s,
     p = pkt.data;
     bytestream_put_be16(&p, 7);
     bytestream_put_be32(&p, AV_RB32(ppkt->data+2) + 1);
-    rtmp_packet_write(s, rt->rtmp_hd, &pkt, rt->chunk_size, rt->prev_pkt[1]);
+    rtmp_packet_write(rt->rtmp_hd, &pkt, rt->chunk_size, rt->prev_pkt[1]);
     rtmp_packet_destroy(&pkt);
 }
 
@@ -481,7 +481,7 @@ static int rtmp_read_packet(AVFormatCont
     while (url_ftell(&rt->pb) == rt->flv_size) {
         RTMPPacket rpkt;
         int has_data = 0;
-        if ((ret = rtmp_packet_read(s, rt->rtmp_hd, &rpkt,
+        if ((ret = rtmp_packet_read(rt->rtmp_hd, &rpkt,
                                     rt->chunk_size, rt->prev_pkt[0])) != 0) {
             if (ret > 0) {
                 nanosleep(&ts, NULL);

Modified: rtmp/rtmppkt.c
==============================================================================
--- rtmp/rtmppkt.c	Tue Jun 23 19:55:11 2009	(r4504)
+++ rtmp/rtmppkt.c	Tue Jun 23 20:01:44 2009	(r4505)
@@ -68,7 +68,7 @@ void rtmp_amf_write_tag(uint8_t **dst, A
     }
 }
 
-int rtmp_packet_read(AVFormatContext *ctx, URLContext *h, RTMPPacket *p,
+int rtmp_packet_read(URLContext *h, RTMPPacket *p,
                      int chunk_size, RTMPPacket *prev_pkt)
 {
     uint8_t hdr, t, buf[16];
@@ -76,35 +76,29 @@ int rtmp_packet_read(AVFormatContext *ct
     uint8_t type;
 
     if (url_read(h, &hdr, 1) != 1) {
-        av_log(ctx, AV_LOG_ERROR, "Cannot read packet header\n");
         return -1;
     }
     stream_id = hdr & 0x3F;
 
     hdr >>= 6;
     if (hdr == RTMP_PS_ONEBYTE) {
-        av_log(ctx, AV_LOG_ERROR, "Onebyte header!\n\n\n");
         //todo
         return -1;
     } else {
         if (url_read_complete(h, buf, 3) != 3) {
-            av_log(ctx, AV_LOG_ERROR, "reading timestamp failed\n");
             return -1;
         }
         timestamp = AV_RB24(buf);
         if (hdr != RTMP_PS_FOURBYTES) {
             if (url_read_complete(h, buf, 3) != 3) {
-                av_log(ctx, AV_LOG_ERROR, "reading size failed\n");
                 return -1;
             }
             data_size = AV_RB24(buf);
             if (url_read_complete(h, &type, 1) != 1) {
-                av_log(ctx, AV_LOG_ERROR, "reading type failed\n");
                 return -1;
             }
             if (hdr == RTMP_PS_TWELVEBYTES) {
                 if (url_read(h, buf, 4) != 4) {
-                    av_log(ctx, AV_LOG_ERROR, "reading timestamp2 failed\n");
                     return -1;
                 }
                 extra = AV_RL32(buf);
@@ -129,7 +123,6 @@ int rtmp_packet_read(AVFormatContext *ct
         int toread = FFMIN(data_size, chunk_size);
         int r;
         if ((r = url_read_complete(h, p->data + offset, toread)) != toread) {
-            av_log(ctx, AV_LOG_ERROR, "Need %d read %d\n", toread, r);
             rtmp_packet_destroy(p);
             return -1;
         }
@@ -138,8 +131,6 @@ int rtmp_packet_read(AVFormatContext *ct
         if (data_size > 0) {
             url_read_complete(h, &t, 1); //marker
             if (t != (0xC0 + stream_id)) {
-                av_log(ctx, AV_LOG_ERROR, "Expected marker %02X, got %02X\n",
-                       t, 0xC0 + stream_id);
                 return -1;
             }
         }
@@ -147,7 +138,7 @@ int rtmp_packet_read(AVFormatContext *ct
     return 0;
 }
 
-int rtmp_packet_write(AVFormatContext *ctx, URLContext *h, RTMPPacket *pkt,
+int rtmp_packet_write(URLContext *h, RTMPPacket *pkt,
                       int chunk_size, RTMPPacket *prev_pkt)
 {
     uint8_t pkt_hdr[16], *p = pkt_hdr;
@@ -264,7 +255,7 @@ static void parse_amf(const uint8_t *dat
     }
 }
 
-void rtmp_packet_inspect(AVFormatContext *ctx, RTMPPacket *pkt)
+void rtmp_packet_inspect(RTMPPacket *pkt)
 {
     av_log(NULL,0,"Packet on ");
     switch (pkt->stream_id) {

Modified: rtmp/rtmppkt.h
==============================================================================
--- rtmp/rtmppkt.h	Tue Jun 23 19:55:11 2009	(r4504)
+++ rtmp/rtmppkt.h	Tue Jun 23 20:01:44 2009	(r4505)
@@ -111,16 +111,16 @@ int rtmp_packet_create(RTMPPacket *pkt, 
 
 void rtmp_packet_destroy(RTMPPacket *pkt);
 
-int rtmp_packet_read(AVFormatContext *ctx, URLContext *h, RTMPPacket *p,
+int rtmp_packet_read(URLContext *h, RTMPPacket *p,
                      int chunk_size, RTMPPacket *prev_pkt);
 
-int rtmp_packet_write(AVFormatContext *ctx, URLContext *h, RTMPPacket *p,
+int rtmp_packet_write(URLContext *h, RTMPPacket *p,
                       int chunk_size, RTMPPacket *prev_pkt);
 
 int rtmp_amf_tag_size(int type, const void *data);
 
 void rtmp_amf_write_tag(uint8_t **dst, AMFType type, const void *data);
 
-void rtmp_packet_inspect(AVFormatContext *ctx, RTMPPacket *pkt);
+void rtmp_packet_inspect(RTMPPacket *pkt);
 
 #endif /* AVFORMAT_RTMPPKT_H */


More information about the FFmpeg-soc mailing list