Mercurial > libavformat.hg
comparison http.c @ 6162:4c0017a87855 libavformat
Allocate the HTTPContext through URLProtocol.priv_data_size
author | mstorsjo |
---|---|
date | Tue, 22 Jun 2010 14:12:34 +0000 |
parents | 85710c0ef275 |
children | 2e0ee73855cd |
comparison
equal
deleted
inserted
replaced
6161:f7090c70ed34 | 6162:4c0017a87855 |
---|---|
145 return AVERROR(EIO); | 145 return AVERROR(EIO); |
146 } | 146 } |
147 | 147 |
148 static int http_open(URLContext *h, const char *uri, int flags) | 148 static int http_open(URLContext *h, const char *uri, int flags) |
149 { | 149 { |
150 HTTPContext *s; | 150 HTTPContext *s = h->priv_data; |
151 | 151 |
152 h->is_streamed = 1; | 152 h->is_streamed = 1; |
153 | 153 |
154 s = av_malloc(sizeof(HTTPContext)); | |
155 if (!s) { | |
156 return AVERROR(ENOMEM); | |
157 } | |
158 h->priv_data = s; | |
159 s->filesize = -1; | 154 s->filesize = -1; |
160 s->chunksize = 0; /* Default to chunked POSTs */ | 155 s->chunksize = 0; /* Default to chunked POSTs */ |
161 s->off = 0; | |
162 s->init = 0; | |
163 s->hd = NULL; | |
164 *s->headers = '\0'; | |
165 memset(&s->auth_state, 0, sizeof(s->auth_state)); | |
166 av_strlcpy(s->location, uri, URL_SIZE); | 156 av_strlcpy(s->location, uri, URL_SIZE); |
167 | 157 |
168 return 0; | 158 return 0; |
169 } | 159 } |
170 static int http_getc(HTTPContext *s) | 160 static int http_getc(HTTPContext *s) |
467 ret = ret > 0 ? 0 : ret; | 457 ret = ret > 0 ? 0 : ret; |
468 } | 458 } |
469 | 459 |
470 if (s->hd) | 460 if (s->hd) |
471 url_close(s->hd); | 461 url_close(s->hd); |
472 av_free(s); | |
473 return ret; | 462 return ret; |
474 } | 463 } |
475 | 464 |
476 static int64_t http_seek(URLContext *h, int64_t off, int whence) | 465 static int64_t http_seek(URLContext *h, int64_t off, int whence) |
477 { | 466 { |
530 http_read, | 519 http_read, |
531 http_write, | 520 http_write, |
532 http_seek, | 521 http_seek, |
533 http_close, | 522 http_close, |
534 .url_get_file_handle = http_get_file_handle, | 523 .url_get_file_handle = http_get_file_handle, |
524 .priv_data_size = sizeof(HTTPContext), | |
535 }; | 525 }; |