comparison aviobuf.c @ 2598:fc7f8ee4700b libavformat

Add functionality to set the direction of a ByteIOContext buffer. Patch by Bj«Órn Axelsson bjorn axelsson intinor se Original thread: [FFmpeg-devel] [PATCH] MMS protocol support patch 1 Date: 09/19/2007 05:51 PM
author benoit
date Thu, 11 Oct 2007 14:57:47 +0000
parents 8389e57c7c3a
children 153d6efc05b8
comparison
equal deleted inserted replaced
2597:eb7808a9d361 2598:fc7f8ee4700b
36 offset_t (*seek)(void *opaque, offset_t offset, int whence)) 36 offset_t (*seek)(void *opaque, offset_t offset, int whence))
37 { 37 {
38 s->buffer = buffer; 38 s->buffer = buffer;
39 s->buffer_size = buffer_size; 39 s->buffer_size = buffer_size;
40 s->buf_ptr = buffer; 40 s->buf_ptr = buffer;
41 s->write_flag = write_flag; 41 url_resetbuf(s, write_flag ? URL_WRONLY : URL_RDONLY);
42 if (!s->write_flag)
43 s->buf_end = buffer;
44 else
45 s->buf_end = buffer + buffer_size;
46 s->opaque = opaque; 42 s->opaque = opaque;
47 s->write_packet = write_packet; 43 s->write_packet = write_packet;
48 s->read_packet = read_packet; 44 s->read_packet = read_packet;
49 s->seek = seek; 45 s->seek = seek;
50 s->pos = 0; 46 s->pos = 0;
532 528
533 av_free(s->buffer); 529 av_free(s->buffer);
534 s->buffer = buffer; 530 s->buffer = buffer;
535 s->buffer_size = buf_size; 531 s->buffer_size = buf_size;
536 s->buf_ptr = buffer; 532 s->buf_ptr = buffer;
537 if (!s->write_flag) 533 url_resetbuf(s, s->write_flag ? URL_WRONLY : URL_RDONLY);
538 s->buf_end = buffer; 534 return 0;
539 else 535 }
540 s->buf_end = buffer + buf_size; 536
537 int url_resetbuf(ByteIOContext *s, int flags)
538 {
539 URLContext *h = s->opaque;
540 if ((flags & URL_RDWR) || (h && h->flags != flags && !h->flags & URL_RDWR))
541 return AVERROR(EINVAL);
542
543 if (flags & URL_WRONLY) {
544 s->buf_end = s->buffer + s->buffer_size;
545 s->write_flag = 1;
546 } else {
547 s->buf_end = s->buffer;
548 s->write_flag = 0;
549 }
541 return 0; 550 return 0;
542 } 551 }
543 552
544 int url_fopen(ByteIOContext *s, const char *filename, int flags) 553 int url_fopen(ByteIOContext *s, const char *filename, int flags)
545 { 554 {