|
MythTV
0.26-pre
|
00001 #include "avfringbuffer.h" 00002 00003 static int AVF_Open(URLContext *h, const char *filename, int flags) 00004 { 00005 (void)filename; 00006 (void)flags; 00007 00008 h->priv_data = NULL; 00009 return 0; 00010 } 00011 00012 static int AVF_Read(URLContext *h, uint8_t *buf, int buf_size) 00013 { 00014 AVFRingBuffer *avfr = (AVFRingBuffer *)h->priv_data; 00015 00016 if (!avfr) 00017 return 0; 00018 00019 return avfr->GetRingBuffer()->Read(buf, buf_size); 00020 } 00021 00022 static int AVF_Write(URLContext *h, const uint8_t *buf, int buf_size) 00023 { 00024 AVFRingBuffer *avfr = (AVFRingBuffer *)h->priv_data; 00025 00026 if (!avfr) 00027 return 0; 00028 00029 return avfr->GetRingBuffer()->Write(buf, buf_size); 00030 } 00031 00032 static int64_t AVF_Seek(URLContext *h, int64_t offset, int whence) 00033 { 00034 AVFRingBuffer *avfr = (AVFRingBuffer *)h->priv_data; 00035 00036 if (!avfr) 00037 return 0; 00038 00039 if (whence == AVSEEK_SIZE) 00040 return avfr->GetRingBuffer()->GetRealFileSize(); 00041 00042 if (whence == SEEK_END) 00043 return avfr->GetRingBuffer()->GetRealFileSize() + offset; 00044 00045 return avfr->GetRingBuffer()->Seek(offset, whence); 00046 } 00047 00048 static int AVF_Close(URLContext *h) 00049 { 00050 (void)h; 00051 return 0; 00052 } 00053 00054 URLProtocol AVF_RingBuffer_Protocol = { 00055 "rbuffer", 00056 AVF_Open, 00057 NULL, // open2 00058 AVF_Read, 00059 AVF_Write, 00060 AVF_Seek, 00061 AVF_Close, 00062 NULL, // next 00063 NULL, // read_pause 00064 NULL, // read_seek 00065 NULL, // get_file_handle 00066 0, // priv_data_size 00067 NULL, // priv_data_class 00068 URL_PROTOCOL_FLAG_NETWORK, // flags 00069 NULL // url_check 00070 }; 00071 00072 int AVF_Write_Packet(void *opaque, uint8_t *buf, int buf_size) 00073 { 00074 if (!opaque) 00075 return 0; 00076 00077 return ffurl_write((URLContext *)opaque, buf, buf_size); 00078 } 00079 00080 int AVF_Read_Packet(void *opaque, uint8_t *buf, int buf_size) 00081 { 00082 if (!opaque) 00083 return 0; 00084 00085 return ffurl_read((URLContext *)opaque, buf, buf_size); 00086 } 00087 00088 int64_t AVF_Seek_Packet(void *opaque, int64_t offset, int whence) 00089 { 00090 if (!opaque) 00091 return 0; 00092 00093 return ffurl_seek((URLContext *)opaque, offset, whence); 00094 } 00095 00096 /* vim: set expandtab tabstop=4 shiftwidth=4: */
1.7.6.1