00001 #include "avfringbuffer.h"
00002
00003 int AVF_Open(URLContext *h, const char *filename, int flags)
00004 {
00005 (void)h;
00006 (void)filename;
00007 (void)flags;
00008 return 0;
00009 }
00010
00011 int AVF_Read(URLContext *h, uint8_t *buf, int buf_size)
00012 {
00013 AVFRingBuffer *avfr = (AVFRingBuffer *)h->priv_data;
00014
00015 return avfr->GetRingBuffer()->Read(buf, buf_size);
00016 }
00017
00018 int AVF_Write(URLContext *h, uint8_t *buf, int buf_size)
00019 {
00020 AVFRingBuffer *avfr = (AVFRingBuffer *)h->priv_data;
00021
00022 return avfr->GetRingBuffer()->Write(buf, buf_size);
00023 }
00024
00025 offset_t AVF_Seek(URLContext *h, offset_t offset, int whence)
00026 {
00027 AVFRingBuffer *avfr = (AVFRingBuffer *)h->priv_data;
00028
00029 if (whence == AVSEEK_SIZE)
00030 return avfr->GetRingBuffer()->GetRealFileSize();
00031
00032 if (whence == SEEK_END)
00033 return avfr->GetRingBuffer()->GetRealFileSize() + offset;
00034
00035 return avfr->GetRingBuffer()->Seek(offset, whence);
00036 }
00037
00038 int AVF_Close(URLContext *h)
00039 {
00040 (void)h;
00041 return 0;
00042 }
00043
00044 URLProtocol AVF_RingBuffer_Protocol = {
00045 "rbuffer",
00046 AVF_Open,
00047 AVF_Read,
00048 AVF_Write,
00049 AVF_Seek,
00050 AVF_Close,
00051 NULL
00052 };
00053
00054 int AVF_Write_Packet(void *opaque, uint8_t *buf, int buf_size)
00055 {
00056 URLContext *h = (URLContext *)opaque;
00057 return url_write(h, buf, buf_size);
00058 }
00059
00060 int AVF_Read_Packet(void *opaque, uint8_t *buf, int buf_size)
00061 {
00062 URLContext *h = (URLContext *)opaque;
00063 return url_read(h, buf, buf_size);
00064 }
00065
00066 offset_t AVF_Seek_Packet(void *opaque, int64_t offset, int whence)
00067 {
00068 URLContext *h = (URLContext *)opaque;
00069 return url_seek(h, offset, whence);
00070 }
00071
00072