1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

avio: make url_read() internal.

This commit is contained in:
Anton Khirnov 2011-03-31 16:31:43 +02:00
parent 0589da0aa5
commit bc371aca46
11 changed files with 29 additions and 23 deletions

View File

@ -241,7 +241,7 @@ static int applehttp_read(URLContext *h, uint8_t *buf, int size)
start:
if (s->seg_hd) {
ret = url_read(s->seg_hd, buf, size);
ret = ffurl_read(s->seg_hd, buf, size);
if (ret > 0)
return ret;
}

View File

@ -180,6 +180,10 @@ int url_open(URLContext **puc, const char *filename, int flags)
{
return ffurl_open(puc, filename, flags);
}
int url_read(URLContext *h, unsigned char *buf, int size)
{
return ffurl_read(h, buf, size);
}
#endif
#define URL_SCHEME_CHARS \
@ -258,7 +262,7 @@ static inline int retry_transfer_wrapper(URLContext *h, unsigned char *buf, int
return len;
}
int url_read(URLContext *h, unsigned char *buf, int size)
int ffurl_read(URLContext *h, unsigned char *buf, int size)
{
if (h->flags & URL_WRONLY)
return AVERROR(EIO);

View File

@ -105,19 +105,9 @@ attribute_deprecated int url_open_protocol (URLContext **puc, struct URLProtocol
attribute_deprecated int url_alloc(URLContext **h, const char *url, int flags);
attribute_deprecated int url_connect(URLContext *h);
attribute_deprecated int url_open(URLContext **h, const char *url, int flags);
attribute_deprecated int url_read(URLContext *h, unsigned char *buf, int size);
#endif
/**
* Read up to size bytes from the resource accessed by h, and store
* the read bytes in buf.
*
* @return The number of bytes actually read, or a negative value
* corresponding to an AVERROR code in case of error. A value of zero
* indicates that it is not possible to read more from the accessed
* resource (except if the value of the size argument is also zero).
*/
int url_read(URLContext *h, unsigned char *buf, int size);
/**
* Read as many bytes as possible (up to size), calling the
* read function multiple times if necessary.

View File

@ -846,7 +846,7 @@ int ffio_fdopen(AVIOContext **s, URLContext *h)
if (ffio_init_context(*s, buffer, buffer_size,
(h->flags & URL_WRONLY || h->flags & URL_RDWR), h,
url_read, url_write, url_seek) < 0) {
ffurl_read, url_write, url_seek) < 0) {
av_free(buffer);
av_freep(s);
return AVERROR(EIO);

View File

@ -136,7 +136,7 @@ static int concat_read(URLContext *h, unsigned char *buf, int size)
size_t i = data->current;
while (size > 0) {
result = url_read(nodes[i].uc, buf, size);
result = ffurl_read(nodes[i].uc, buf, size);
if (result < 0)
return total ? total : result;
if (!result)

View File

@ -115,7 +115,7 @@ static int gopher_open(URLContext *h, const char *uri, int flags)
static int gopher_read(URLContext *h, uint8_t *buf, int size)
{
GopherContext *s = h->priv_data;
int len = url_read(s->hd, buf, size);
int len = ffurl_read(s->hd, buf, size);
return len;
}

View File

@ -171,7 +171,7 @@ static int http_getc(HTTPContext *s)
{
int len;
if (s->buf_ptr >= s->buf_end) {
len = url_read(s->hd, s->buffer, BUFFER_SIZE);
len = ffurl_read(s->hd, s->buffer, BUFFER_SIZE);
if (len < 0) {
return AVERROR(EIO);
} else if (len == 0) {
@ -407,7 +407,7 @@ static int http_read(URLContext *h, uint8_t *buf, int size)
} else {
if (!s->willclose && s->filesize >= 0 && s->off >= s->filesize)
return AVERROR_EOF;
len = url_read(s->hd, buf, size);
len = ffurl_read(s->hd, buf, size);
}
if (len > 0) {
s->off += len;

View File

@ -25,6 +25,7 @@
#include "rtmppkt.h"
#include "flv.h"
#include "url.h"
void ff_amf_write_bool(uint8_t **dst, int val)
{
@ -78,7 +79,7 @@ int ff_rtmp_packet_read(URLContext *h, RTMPPacket *p,
enum RTMPPacketType type;
int size = 0;
if (url_read(h, &hdr, 1) != 1)
if (ffurl_read(h, &hdr, 1) != 1)
return AVERROR(EIO);
size++;
channel_id = hdr & 0x3F;

View File

@ -1594,7 +1594,7 @@ static int udp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st,
rtsp_st = rt->rtsp_streams[i];
if (rtsp_st->rtp_handle) {
if (p[j].revents & POLLIN || p[j+1].revents & POLLIN) {
ret = url_read(rtsp_st->rtp_handle, buf, buf_size);
ret = ffurl_read(rtsp_st->rtp_handle, buf, buf_size);
if (ret > 0) {
*prtsp_st = rtsp_st;
return ret;
@ -1868,7 +1868,7 @@ static int rtp_read_header(AVFormatContext *s,
goto fail;
while (1) {
ret = url_read(in, recvbuf, sizeof(recvbuf));
ret = ffurl_read(in, recvbuf, sizeof(recvbuf));
if (ret == AVERROR(EAGAIN))
continue;
if (ret < 0)

View File

@ -93,7 +93,7 @@ static int sap_read_header(AVFormatContext *s,
int addr_type, auth_len;
int pos;
ret = url_read(sap->ann_fd, recvbuf, sizeof(recvbuf) - 1);
ret = ffurl_read(sap->ann_fd, recvbuf, sizeof(recvbuf) - 1);
if (ret == AVERROR(EAGAIN))
continue;
if (ret < 0)
@ -195,7 +195,7 @@ static int sap_fetch_packet(AVFormatContext *s, AVPacket *pkt)
n = poll(&p, 1, 0);
if (n <= 0 || !(p.revents & POLLIN))
break;
ret = url_read(sap->ann_fd, recvbuf, sizeof(recvbuf));
ret = ffurl_read(sap->ann_fd, recvbuf, sizeof(recvbuf));
if (ret >= 8) {
uint16_t hash = AV_RB16(&recvbuf[2]);
/* Should ideally check the source IP address, too */

View File

@ -58,4 +58,15 @@ int ffurl_connect(URLContext *h);
*/
int ffurl_open(URLContext **h, const char *url, int flags);
/**
* Read up to size bytes from the resource accessed by h, and store
* the read bytes in buf.
*
* @return The number of bytes actually read, or a negative value
* corresponding to an AVERROR code in case of error. A value of zero
* indicates that it is not possible to read more from the accessed
* resource (except if the value of the size argument is also zero).
*/
int ffurl_read(URLContext *h, unsigned char *buf, int size);
#endif //AVFORMAT_URL_H