diff rtsp.c @ 5004:84a7b7a2f252 libavformat

Move function for reading whole specified amount of data from RTSP demuxer into more common place.
author kostya
date Thu, 04 Jun 2009 06:25:53 +0000
parents 0b15fbb456f4
children 43d99d0e12e0
line wrap: on
line diff
--- a/rtsp.c	Wed Jun 03 23:34:35 2009 +0000
+++ b/rtsp.c	Thu Jun 04 06:25:53 2009 +0000
@@ -703,20 +703,6 @@
     }
 }
 
-static int url_readbuf(URLContext *h, unsigned char *buf, int size)
-{
-    int ret, len;
-
-    len = 0;
-    while (len < size) {
-        ret = url_read(h, buf+len, size-len);
-        if (ret < 1)
-            return ret;
-        len += ret;
-    }
-    return len;
-}
-
 /* skip a RTP/TCP interleaved packet */
 static void rtsp_skip_packet(AVFormatContext *s)
 {
@@ -724,7 +710,7 @@
     int ret, len, len1;
     uint8_t buf[1024];
 
-    ret = url_readbuf(rt->rtsp_hd, buf, 3);
+    ret = url_read_complete(rt->rtsp_hd, buf, 3);
     if (ret != 3)
         return;
     len = AV_RB16(buf + 1);
@@ -736,7 +722,7 @@
         len1 = len;
         if (len1 > sizeof(buf))
             len1 = sizeof(buf);
-        ret = url_readbuf(rt->rtsp_hd, buf, len1);
+        ret = url_read_complete(rt->rtsp_hd, buf, len1);
         if (ret != len1)
             return;
         len -= len1;
@@ -782,7 +768,7 @@
     for(;;) {
         q = buf;
         for(;;) {
-            ret = url_readbuf(rt->rtsp_hd, &ch, 1);
+            ret = url_read_complete(rt->rtsp_hd, &ch, 1);
 #ifdef DEBUG_RTP_TCP
             dprintf(s, "ret=%d c=%02x [%c]\n", ret, ch, ch);
 #endif
@@ -829,7 +815,7 @@
     if (content_length > 0) {
         /* leave some room for a trailing '\0' (useful for simple parsing) */
         content = av_malloc(content_length + 1);
-        (void)url_readbuf(rt->rtsp_hd, content, content_length);
+        (void)url_read_complete(rt->rtsp_hd, content, content_length);
         content[content_length] = '\0';
     }
     if (content_ptr)
@@ -1329,7 +1315,7 @@
             break;
         /* XXX: parse message */
     }
-    ret = url_readbuf(rt->rtsp_hd, buf, 3);
+    ret = url_read_complete(rt->rtsp_hd, buf, 3);
     if (ret != 3)
         return -1;
     id = buf[0];
@@ -1340,7 +1326,7 @@
     if (len > buf_size || len < 12)
         goto redo;
     /* get the data */
-    ret = url_readbuf(rt->rtsp_hd, buf, len);
+    ret = url_read_complete(rt->rtsp_hd, buf, len);
     if (ret != len)
         return -1;
     if (rt->transport == RTSP_TRANSPORT_RDT &&