diff --git a/libavformat/avio.c b/libavformat/avio.c
index 48399d081f7df1d85b91815f0560e1e78b27b0b3..e79c8fcbfdb50296dba40539d3e6dbb6541d1e0e 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -184,7 +184,7 @@ int url_read_complete(URLContext *h, unsigned char *buf, int size)
     return len;
 }
 
-int url_write(URLContext *h, unsigned char *buf, int size)
+int url_write(URLContext *h, const unsigned char *buf, int size)
 {
     int ret;
     if (!(h->flags & (URL_WRONLY | URL_RDWR)))
diff --git a/libavformat/avio.h b/libavformat/avio.h
index 9ffe93567533284d84137160b9042328ce2474cc..2b15e8d76be71b71925e576b95658ca03d7628c0 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -112,7 +112,7 @@ int url_read(URLContext *h, unsigned char *buf, int size);
  * certain there was either an error or the end of file was reached.
  */
 int url_read_complete(URLContext *h, unsigned char *buf, int size);
-int url_write(URLContext *h, unsigned char *buf, int size);
+int url_write(URLContext *h, const unsigned char *buf, int size);
 
 /**
  * Changes the position that will be used by the next read/write
@@ -224,7 +224,7 @@ typedef struct URLProtocol {
     const char *name;
     int (*url_open)(URLContext *h, const char *url, int flags);
     int (*url_read)(URLContext *h, unsigned char *buf, int size);
-    int (*url_write)(URLContext *h, unsigned char *buf, int size);
+    int (*url_write)(URLContext *h, const unsigned char *buf, int size);
     int64_t (*url_seek)(URLContext *h, int64_t pos, int whence);
     int (*url_close)(URLContext *h);
     struct URLProtocol *next;
diff --git a/libavformat/file.c b/libavformat/file.c
index 8873d5fcafe8ba61d826400bb1ee3fb7b245487f..d6ba1fa36281be30404b7ab8d9d98bd2eafe4bf1 100644
--- a/libavformat/file.c
+++ b/libavformat/file.c
@@ -64,7 +64,7 @@ static int file_read(URLContext *h, unsigned char *buf, int size)
     return read(fd, buf, size);
 }
 
-static int file_write(URLContext *h, unsigned char *buf, int size)
+static int file_write(URLContext *h, const unsigned char *buf, int size)
 {
     int fd = (intptr_t) h->priv_data;
     return write(fd, buf, size);
diff --git a/libavformat/gopher.c b/libavformat/gopher.c
index f5bb4a371854e92f8c1ff9e05289f19e9813e8a4..13f3a5f9e1d6ccc33fefa3d6f27ff1f26d13cc31 100644
--- a/libavformat/gopher.c
+++ b/libavformat/gopher.c
@@ -31,7 +31,7 @@ typedef struct {
     URLContext *hd;
 } GopherContext;
 
-static int gopher_write(URLContext *h, uint8_t *buf, int size)
+static int gopher_write(URLContext *h, const uint8_t *buf, int size)
 {
     GopherContext *s = h->priv_data;
     return url_write(s->hd, buf, size);
diff --git a/libavformat/http.c b/libavformat/http.c
index e697578486bd02a50584fcfb3c7b5d163df3a45f..56f8021025fcfb08bc678a4e4788e6d7d034aea4 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -49,7 +49,7 @@ typedef struct {
 
 static int http_connect(URLContext *h, const char *path, const char *hoststr,
                         const char *auth, int *new_location);
-static int http_write(URLContext *h, uint8_t *buf, int size);
+static int http_write(URLContext *h, const uint8_t *buf, int size);
 
 
 /* return non zero if error */
@@ -358,7 +358,7 @@ static int http_read(URLContext *h, uint8_t *buf, int size)
 }
 
 /* used only when posting data */
-static int http_write(URLContext *h, uint8_t *buf, int size)
+static int http_write(URLContext *h, const uint8_t *buf, int size)
 {
     char temp[11];  /* 32-bit hex + CRLF + nul */
     int ret;
diff --git a/libavformat/librtmp.c b/libavformat/librtmp.c
index d765102f1b8865fe550ee3c7383db4b00c9b998e..dd7640aaebaf94315ba153835d3daa66ea77bb81 100644
--- a/libavformat/librtmp.c
+++ b/libavformat/librtmp.c
@@ -109,7 +109,7 @@ fail:
     return rc;
 }
 
-static int rtmp_write(URLContext *s, uint8_t *buf, int size)
+static int rtmp_write(URLContext *s, const uint8_t *buf, int size)
 {
     RTMP *r = s->priv_data;
 
diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index 7d858ccc6a5e01119e3a32a5835c029b91a1cd85..1f572320fa26dba34befda19820ad8fc6252b097 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -922,7 +922,7 @@ static int rtmp_read(URLContext *s, uint8_t *buf, int size)
     return orig_size;
 }
 
-static int rtmp_write(URLContext *h, uint8_t *buf, int size)
+static int rtmp_write(URLContext *h, const uint8_t *buf, int size)
 {
     RTMPContext *rt = h->priv_data;
     int size_temp = size;
diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c
index 754908cc0b1450cc1306e1062767af8bdee2fd33..bbcf0d91c38af5a40f44000a13e9bc733b448943 100644
--- a/libavformat/rtpproto.c
+++ b/libavformat/rtpproto.c
@@ -279,7 +279,7 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size)
     return len;
 }
 
-static int rtp_write(URLContext *h, uint8_t *buf, int size)
+static int rtp_write(URLContext *h, const uint8_t *buf, int size)
 {
     RTPContext *s = h->priv_data;
     int ret;
diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index 79cabdfe903debf660479813334a1b4612520a9f..fb6dec798f28371c578c650a1a7cdc0e441c7d83 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -154,7 +154,7 @@ static int tcp_read(URLContext *h, uint8_t *buf, int size)
     }
 }
 
-static int tcp_write(URLContext *h, uint8_t *buf, int size)
+static int tcp_write(URLContext *h, const uint8_t *buf, int size)
 {
     TCPContext *s = h->priv_data;
     int ret, size1, fd_max, len;
diff --git a/libavformat/udp.c b/libavformat/udp.c
index a11f4c37d80a7f8deefdc8a0a858c1f3403a9556..0ec24cd4e55d7adda7fe8bbe2c1b3ac77afbf485 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -456,7 +456,7 @@ static int udp_read(URLContext *h, uint8_t *buf, int size)
     return len;
 }
 
-static int udp_write(URLContext *h, uint8_t *buf, int size)
+static int udp_write(URLContext *h, const uint8_t *buf, int size)
 {
     UDPContext *s = h->priv_data;
     int ret;