MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / http_seek

Function http_seek

libavformat/http.c:404–438  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

402}
403
404static int64_t http_seek(URLContext *h, int64_t off, int whence)
405{
406 HTTPContext *s = h->priv_data;
407 URLContext *old_hd = s->hd;
408 int64_t old_off = s->off;
409 uint8_t old_buf[BUFFER_SIZE];
410 int old_buf_size;
411
412 if (whence == AVSEEK_SIZE)
413 return s->filesize;
414 else if ((s->filesize == -1 && whence == SEEK_END) || h->is_streamed)
415 return -1;
416
417 /* we save the old context in case the seek fails */
418 old_buf_size = s->buf_end - s->buf_ptr;
419 memcpy(old_buf, s->buf_ptr, old_buf_size);
420 s->hd = NULL;
421 if (whence == SEEK_CUR)
422 off += s->off;
423 else if (whence == SEEK_END)
424 off += s->filesize;
425 s->off = off;
426
427 /* if it fails, continue on old connection */
428 if (http_open_cnx(h) < 0) {
429 memcpy(s->buffer, old_buf, old_buf_size);
430 s->buf_ptr = s->buffer;
431 s->buf_end = s->buffer + old_buf_size;
432 s->hd = old_hd;
433 s->off = old_off;
434 return -1;
435 }
436 url_close(old_hd);
437 return off;
438}
439
440static int
441http_get_file_handle(URLContext *h)

Callers

nothing calls this directly

Calls 2

http_open_cnxFunction · 0.85
url_closeFunction · 0.85

Tested by

no test coverage detected