| ... | ... |
@@ -188,6 +188,10 @@ int url_read_complete(URLContext *h, unsigned char *buf, int size) |
| 188 | 188 |
{
|
| 189 | 189 |
return ffurl_read_complete(h, buf, size); |
| 190 | 190 |
} |
| 191 |
+int url_write(URLContext *h, const unsigned char *buf, int size) |
|
| 192 |
+{
|
|
| 193 |
+ return ffurl_write(h, buf, size); |
|
| 194 |
+} |
|
| 191 | 195 |
#endif |
| 192 | 196 |
|
| 193 | 197 |
#define URL_SCHEME_CHARS \ |
| ... | ... |
@@ -280,7 +284,7 @@ int ffurl_read_complete(URLContext *h, unsigned char *buf, int size) |
| 280 | 280 |
return retry_transfer_wrapper(h, buf, size, size, h->prot->url_read); |
| 281 | 281 |
} |
| 282 | 282 |
|
| 283 |
-int url_write(URLContext *h, const unsigned char *buf, int size) |
|
| 283 |
+int ffurl_write(URLContext *h, const unsigned char *buf, int size) |
|
| 284 | 284 |
{
|
| 285 | 285 |
if (!(h->flags & (URL_WRONLY | URL_RDWR))) |
| 286 | 286 |
return AVERROR(EIO); |
| ... | ... |
@@ -107,17 +107,10 @@ attribute_deprecated int url_connect(URLContext *h); |
| 107 | 107 |
attribute_deprecated int url_open(URLContext **h, const char *url, int flags); |
| 108 | 108 |
attribute_deprecated int url_read(URLContext *h, unsigned char *buf, int size); |
| 109 | 109 |
attribute_deprecated int url_read_complete(URLContext *h, unsigned char *buf, int size); |
| 110 |
+attribute_deprecated int url_write(URLContext *h, const unsigned char *buf, int size); |
|
| 110 | 111 |
#endif |
| 111 | 112 |
|
| 112 | 113 |
/** |
| 113 |
- * Write size bytes from buf to the resource accessed by h. |
|
| 114 |
- * |
|
| 115 |
- * @return the number of bytes actually written, or a negative value |
|
| 116 |
- * corresponding to an AVERROR code in case of failure |
|
| 117 |
- */ |
|
| 118 |
-int url_write(URLContext *h, const unsigned char *buf, int size); |
|
| 119 |
- |
|
| 120 |
-/** |
|
| 121 | 114 |
* Passing this as the "whence" parameter to a seek function causes it to |
| 122 | 115 |
* return the filesize without seeking anywhere. Supporting this is optional. |
| 123 | 116 |
* If it is not supported then the seek function will return <0. |
| ... | ... |
@@ -846,7 +846,7 @@ int ffio_fdopen(AVIOContext **s, URLContext *h) |
| 846 | 846 |
|
| 847 | 847 |
if (ffio_init_context(*s, buffer, buffer_size, |
| 848 | 848 |
(h->flags & URL_WRONLY || h->flags & URL_RDWR), h, |
| 849 |
- ffurl_read, url_write, url_seek) < 0) {
|
|
| 849 |
+ ffurl_read, ffurl_write, url_seek) < 0) {
|
|
| 850 | 850 |
av_free(buffer); |
| 851 | 851 |
av_freep(s); |
| 852 | 852 |
return AVERROR(EIO); |
| ... | ... |
@@ -35,7 +35,7 @@ typedef struct {
|
| 35 | 35 |
static int gopher_write(URLContext *h, const uint8_t *buf, int size) |
| 36 | 36 |
{
|
| 37 | 37 |
GopherContext *s = h->priv_data; |
| 38 |
- return url_write(s->hd, buf, size); |
|
| 38 |
+ return ffurl_write(s->hd, buf, size); |
|
| 39 | 39 |
} |
| 40 | 40 |
|
| 41 | 41 |
static int gopher_connect(URLContext *h, const char *path) |
| ... | ... |
@@ -333,7 +333,7 @@ static int http_connect(URLContext *h, const char *path, const char *hoststr, |
| 333 | 333 |
authstr ? authstr : ""); |
| 334 | 334 |
|
| 335 | 335 |
av_freep(&authstr); |
| 336 |
- if (url_write(s->hd, s->buffer, strlen(s->buffer)) < 0) |
|
| 336 |
+ if (ffurl_write(s->hd, s->buffer, strlen(s->buffer)) < 0) |
|
| 337 | 337 |
return AVERROR(EIO); |
| 338 | 338 |
|
| 339 | 339 |
/* init input buffer */ |
| ... | ... |
@@ -427,7 +427,7 @@ static int http_write(URLContext *h, const uint8_t *buf, int size) |
| 427 | 427 |
|
| 428 | 428 |
if (s->chunksize == -1) {
|
| 429 | 429 |
/* non-chunked data is sent without any special encoding */ |
| 430 |
- return url_write(s->hd, buf, size); |
|
| 430 |
+ return ffurl_write(s->hd, buf, size); |
|
| 431 | 431 |
} |
| 432 | 432 |
|
| 433 | 433 |
/* silently ignore zero-size data since chunk encoding that would |
| ... | ... |
@@ -436,9 +436,9 @@ static int http_write(URLContext *h, const uint8_t *buf, int size) |
| 436 | 436 |
/* upload data using chunked encoding */ |
| 437 | 437 |
snprintf(temp, sizeof(temp), "%x\r\n", size); |
| 438 | 438 |
|
| 439 |
- if ((ret = url_write(s->hd, temp, strlen(temp))) < 0 || |
|
| 440 |
- (ret = url_write(s->hd, buf, size)) < 0 || |
|
| 441 |
- (ret = url_write(s->hd, crlf, sizeof(crlf) - 1)) < 0) |
|
| 439 |
+ if ((ret = ffurl_write(s->hd, temp, strlen(temp))) < 0 || |
|
| 440 |
+ (ret = ffurl_write(s->hd, buf, size)) < 0 || |
|
| 441 |
+ (ret = ffurl_write(s->hd, crlf, sizeof(crlf) - 1)) < 0) |
|
| 442 | 442 |
return ret; |
| 443 | 443 |
} |
| 444 | 444 |
return size; |
| ... | ... |
@@ -452,7 +452,7 @@ static int http_close(URLContext *h) |
| 452 | 452 |
|
| 453 | 453 |
/* signal end of chunked encoding if used */ |
| 454 | 454 |
if ((h->flags & URL_WRONLY) && s->chunksize != -1) {
|
| 455 |
- ret = url_write(s->hd, footer, sizeof(footer) - 1); |
|
| 455 |
+ ret = ffurl_write(s->hd, footer, sizeof(footer) - 1); |
|
| 456 | 456 |
ret = ret > 0 ? 0 : ret; |
| 457 | 457 |
} |
| 458 | 458 |
|
| ... | ... |
@@ -68,7 +68,7 @@ static int md5_close(URLContext *h) |
| 68 | 68 |
err = ffurl_open(&out, filename, URL_WRONLY); |
| 69 | 69 |
if (err) |
| 70 | 70 |
return err; |
| 71 |
- err = url_write(out, buf, i*2+1); |
|
| 71 |
+ err = ffurl_write(out, buf, i*2+1); |
|
| 72 | 72 |
url_close(out); |
| 73 | 73 |
} else {
|
| 74 | 74 |
if (fwrite(buf, 1, i*2+1, stdout) < i*2+1) |
| ... | ... |
@@ -139,7 +139,7 @@ static int send_command_packet(MMSTContext *mmst) |
| 139 | 139 |
memset(mms->write_out_ptr, 0, exact_length - len); |
| 140 | 140 |
|
| 141 | 141 |
// write it out. |
| 142 |
- write_result= url_write(mms->mms_hd, mms->out_buffer, exact_length); |
|
| 142 |
+ write_result= ffurl_write(mms->mms_hd, mms->out_buffer, exact_length); |
|
| 143 | 143 |
if(write_result != exact_length) {
|
| 144 | 144 |
av_log(NULL, AV_LOG_ERROR, |
| 145 | 145 |
"Failed to write data of length %d: %d (%s)\n", |
| ... | ... |
@@ -215,15 +215,15 @@ int ff_rtmp_packet_write(URLContext *h, RTMPPacket *pkt, |
| 215 | 215 |
} |
| 216 | 216 |
prev_pkt[pkt->channel_id].extra = pkt->extra; |
| 217 | 217 |
|
| 218 |
- url_write(h, pkt_hdr, p-pkt_hdr); |
|
| 218 |
+ ffurl_write(h, pkt_hdr, p-pkt_hdr); |
|
| 219 | 219 |
size = p - pkt_hdr + pkt->data_size; |
| 220 | 220 |
while (off < pkt->data_size) {
|
| 221 | 221 |
int towrite = FFMIN(chunk_size, pkt->data_size - off); |
| 222 |
- url_write(h, pkt->data + off, towrite); |
|
| 222 |
+ ffurl_write(h, pkt->data + off, towrite); |
|
| 223 | 223 |
off += towrite; |
| 224 | 224 |
if (off < pkt->data_size) {
|
| 225 | 225 |
uint8_t marker = 0xC0 | pkt->channel_id; |
| 226 |
- url_write(h, &marker, 1); |
|
| 226 |
+ ffurl_write(h, &marker, 1); |
|
| 227 | 227 |
size++; |
| 228 | 228 |
} |
| 229 | 229 |
} |
| ... | ... |
@@ -486,7 +486,7 @@ static int rtmp_handshake(URLContext *s, RTMPContext *rt) |
| 486 | 486 |
tosend[i] = av_lfg_get(&rnd) >> 24; |
| 487 | 487 |
client_pos = rtmp_handshake_imprint_with_digest(tosend + 1); |
| 488 | 488 |
|
| 489 |
- url_write(rt->stream, tosend, RTMP_HANDSHAKE_PACKET_SIZE + 1); |
|
| 489 |
+ ffurl_write(rt->stream, tosend, RTMP_HANDSHAKE_PACKET_SIZE + 1); |
|
| 490 | 490 |
i = ffurl_read_complete(rt->stream, serverdata, RTMP_HANDSHAKE_PACKET_SIZE + 1); |
| 491 | 491 |
if (i != RTMP_HANDSHAKE_PACKET_SIZE + 1) {
|
| 492 | 492 |
av_log(LOG_CONTEXT, AV_LOG_ERROR, "Cannot read RTMP handshake response\n"); |
| ... | ... |
@@ -532,9 +532,9 @@ static int rtmp_handshake(URLContext *s, RTMPContext *rt) |
| 532 | 532 |
tosend + RTMP_HANDSHAKE_PACKET_SIZE - 32); |
| 533 | 533 |
|
| 534 | 534 |
// write reply back to the server |
| 535 |
- url_write(rt->stream, tosend, RTMP_HANDSHAKE_PACKET_SIZE); |
|
| 535 |
+ ffurl_write(rt->stream, tosend, RTMP_HANDSHAKE_PACKET_SIZE); |
|
| 536 | 536 |
} else {
|
| 537 |
- url_write(rt->stream, serverdata+1, RTMP_HANDSHAKE_PACKET_SIZE); |
|
| 537 |
+ ffurl_write(rt->stream, serverdata+1, RTMP_HANDSHAKE_PACKET_SIZE); |
|
| 538 | 538 |
} |
| 539 | 539 |
|
| 540 | 540 |
return 0; |
| ... | ... |
@@ -25,6 +25,7 @@ |
| 25 | 25 |
#include "libavcodec/get_bits.h" |
| 26 | 26 |
#include "avformat.h" |
| 27 | 27 |
#include "mpegts.h" |
| 28 |
+#include "url.h" |
|
| 28 | 29 |
|
| 29 | 30 |
#include <unistd.h> |
| 30 | 31 |
#include <strings.h> |
| ... | ... |
@@ -325,8 +326,8 @@ int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count) |
| 325 | 325 |
if ((len > 0) && buf) {
|
| 326 | 326 |
int result; |
| 327 | 327 |
av_dlog(s->ic, "sending %d bytes of RR\n", len); |
| 328 |
- result= url_write(s->rtp_ctx, buf, len); |
|
| 329 |
- av_dlog(s->ic, "result from url_write: %d\n", result); |
|
| 328 |
+ result= ffurl_write(s->rtp_ctx, buf, len); |
|
| 329 |
+ av_dlog(s->ic, "result from ffurl_write: %d\n", result); |
|
| 330 | 330 |
av_free(buf); |
| 331 | 331 |
} |
| 332 | 332 |
return 0; |
| ... | ... |
@@ -351,7 +352,7 @@ void rtp_send_punch_packets(URLContext* rtp_handle) |
| 351 | 351 |
avio_flush(pb); |
| 352 | 352 |
len = avio_close_dyn_buf(pb, &buf); |
| 353 | 353 |
if ((len > 0) && buf) |
| 354 |
- url_write(rtp_handle, buf, len); |
|
| 354 |
+ ffurl_write(rtp_handle, buf, len); |
|
| 355 | 355 |
av_free(buf); |
| 356 | 356 |
|
| 357 | 357 |
/* Send a minimal RTCP RR */ |
| ... | ... |
@@ -366,7 +367,7 @@ void rtp_send_punch_packets(URLContext* rtp_handle) |
| 366 | 366 |
avio_flush(pb); |
| 367 | 367 |
len = avio_close_dyn_buf(pb, &buf); |
| 368 | 368 |
if ((len > 0) && buf) |
| 369 |
- url_write(rtp_handle, buf, len); |
|
| 369 |
+ ffurl_write(rtp_handle, buf, len); |
|
| 370 | 370 |
av_free(buf); |
| 371 | 371 |
} |
| 372 | 372 |
|
| ... | ... |
@@ -983,14 +983,14 @@ static int ff_rtsp_send_cmd_with_content_async(AVFormatContext *s, |
| 983 | 983 |
|
| 984 | 984 |
av_dlog(s, "Sending:\n%s--\n", buf); |
| 985 | 985 |
|
| 986 |
- url_write(rt->rtsp_hd_out, out_buf, strlen(out_buf)); |
|
| 986 |
+ ffurl_write(rt->rtsp_hd_out, out_buf, strlen(out_buf)); |
|
| 987 | 987 |
if (send_content_length > 0 && send_content) {
|
| 988 | 988 |
if (rt->control_transport == RTSP_MODE_TUNNEL) {
|
| 989 | 989 |
av_log(s, AV_LOG_ERROR, "tunneling of RTSP requests " |
| 990 | 990 |
"with content data not supported\n"); |
| 991 | 991 |
return AVERROR_PATCHWELCOME; |
| 992 | 992 |
} |
| 993 |
- url_write(rt->rtsp_hd_out, send_content, send_content_length); |
|
| 993 |
+ ffurl_write(rt->rtsp_hd_out, send_content, send_content_length); |
|
| 994 | 994 |
} |
| 995 | 995 |
rt->last_cmd_time = av_gettime(); |
| 996 | 996 |
|
| ... | ... |
@@ -32,6 +32,7 @@ |
| 32 | 32 |
#include "avio_internal.h" |
| 33 | 33 |
#include "libavutil/intreadwrite.h" |
| 34 | 34 |
#include "libavutil/avstring.h" |
| 35 |
+#include "url.h" |
|
| 35 | 36 |
|
| 36 | 37 |
#define SDP_MAX_SIZE 16384 |
| 37 | 38 |
|
| ... | ... |
@@ -158,7 +159,7 @@ static int tcp_write_packet(AVFormatContext *s, RTSPStream *rtsp_st) |
| 158 | 158 |
interleave_header[0] = '$'; |
| 159 | 159 |
interleave_header[1] = id; |
| 160 | 160 |
AV_WB16(interleave_header + 2, packet_len); |
| 161 |
- url_write(rt->rtsp_hd_out, interleaved_packet, 4 + packet_len); |
|
| 161 |
+ ffurl_write(rt->rtsp_hd_out, interleaved_packet, 4 + packet_len); |
|
| 162 | 162 |
ptr += packet_len; |
| 163 | 163 |
size -= packet_len; |
| 164 | 164 |
} |
| ... | ... |
@@ -54,7 +54,7 @@ static int sap_write_close(AVFormatContext *s) |
| 54 | 54 |
|
| 55 | 55 |
if (sap->last_time && sap->ann && sap->ann_fd) {
|
| 56 | 56 |
sap->ann[0] |= 4; /* Session deletion*/ |
| 57 |
- url_write(sap->ann_fd, sap->ann, sap->ann_size); |
|
| 57 |
+ ffurl_write(sap->ann_fd, sap->ann, sap->ann_size); |
|
| 58 | 58 |
} |
| 59 | 59 |
|
| 60 | 60 |
av_freep(&sap->ann); |
| ... | ... |
@@ -239,7 +239,7 @@ static int sap_write_packet(AVFormatContext *s, AVPacket *pkt) |
| 239 | 239 |
int64_t now = av_gettime(); |
| 240 | 240 |
|
| 241 | 241 |
if (!sap->last_time || now - sap->last_time > 5000000) {
|
| 242 |
- int ret = url_write(sap->ann_fd, sap->ann, sap->ann_size); |
|
| 242 |
+ int ret = ffurl_write(sap->ann_fd, sap->ann, sap->ann_size); |
|
| 243 | 243 |
/* Don't abort even if we get "Destination unreachable" */ |
| 244 | 244 |
if (ret < 0 && ret != AVERROR(ECONNREFUSED)) |
| 245 | 245 |
return ret; |
| ... | ... |
@@ -78,4 +78,12 @@ int ffurl_read(URLContext *h, unsigned char *buf, int size); |
| 78 | 78 |
*/ |
| 79 | 79 |
int ffurl_read_complete(URLContext *h, unsigned char *buf, int size); |
| 80 | 80 |
|
| 81 |
+/** |
|
| 82 |
+ * Write size bytes from buf to the resource accessed by h. |
|
| 83 |
+ * |
|
| 84 |
+ * @return the number of bytes actually written, or a negative value |
|
| 85 |
+ * corresponding to an AVERROR code in case of failure |
|
| 86 |
+ */ |
|
| 87 |
+int ffurl_write(URLContext *h, const unsigned char *buf, int size); |
|
| 88 |
+ |
|
| 81 | 89 |
#endif //AVFORMAT_URL_H |