13 #define BUFFER_SIZE 128*(1<<10)
29 #if (LIBAVCODEC_VERSION_MAJOR >= 52) || (LIBAVCODEC_VERSION_INT >= ( ( 51<<16)+(49<<8)+0 ) ) || defined (__amd64__) \
30 || defined (_M_AMD64) || defined (__x86_64) || defined (__x86_64__)
31 typedef int64_t offset_t;
37 using namespace VSFileSystem;
39 extern "C" int _url_open( URLContext *h,
const char *filename,
int flags )
41 if (strncmp( filename,
"vsfile:", 7 ) != 0)
44 const char *type = strchr( filename+7,
'|' );
45 std::string path( filename+7, type ? type-filename-7 : strlen( filename+7 ) );
58 extern "C" int _url_close( URLContext *h )
60 delete (
VSFile*) (h->priv_data);
64 extern "C" int _url_read( URLContext *h,
unsigned char *buf,
int size )
66 return ( (
VSFile*) (h->priv_data) )->
Read( buf, size );
71 extern "C" int _url_write( URLContext *h,
72 #
if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52, 67, 0)
75 unsigned char *buf,
int size )
81 extern "C" offset_t _url_seek( URLContext *h, offset_t pos,
int whence )
83 if (whence != AVSEEK_SIZE) {
84 ( (
VSFile*) (h->priv_data) )->
GoTo(
long(pos) );
85 return ( (
VSFile*) (h->priv_data) )->GetPosition();
87 return ( (
VSFile*) (h->priv_data) )->Size();
91 struct URLProtocol vsFileProtocol = {
99 #if (LIBAVCODEC_VERSION_MAJOR >= 53)
100 NULL, NULL, NULL, NULL,
112 static bool initted =
false;
116 #if (LIBAVFORMAT_VERSION_MAJOR >= 53)
117 av_register_protocol2( &vsFileProtocol,
sizeof(vsFileProtocol) );
119 register_protocol( &vsFileProtocol );
126 #if (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR == 47 && LIBAVCODEC_VERSION_MICRO == 0)
128 void av_free_packet( AVPacket *pkt )
131 if (pkt->destruct) pkt->destruct( pkt );