diff --git a/Plugins/FFMPEG/FFMPEGDecoder.m b/Plugins/FFMPEG/FFMPEGDecoder.m index 584eed4f5..711981606 100644 --- a/Plugins/FFMPEG/FFMPEGDecoder.m +++ b/Plugins/FFMPEG/FFMPEGDecoder.m @@ -157,6 +157,9 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op) framesRead = 0; endOfStream = NO; + if ( totalFrames < 0 ) + totalFrames = 0; + seekable = [s seekable]; return YES; @@ -180,7 +183,7 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op) - (int)readAudio:(void *)buf frames:(UInt32)frames { - if ( framesRead >= totalFrames ) + if ( totalFrames && framesRead >= totalFrames ) return 0; int frameSize = channels * (bitsPerSample / 8); @@ -292,7 +295,7 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op) } int framesReadNow = bytesRead / frameSize; - if ( framesRead + framesReadNow > totalFrames ) + if ( totalFrames && ( framesRead + framesReadNow > totalFrames ) ) framesReadNow = totalFrames - framesRead; framesRead += framesReadNow; @@ -302,6 +305,9 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op) - (long)seek:(long)frame { + if ( !totalFrames ) + return -1; + if (frame >= totalFrames) { framesRead = totalFrames; diff --git a/Plugins/FFMPEG/FFMPEGFileProtocols.m b/Plugins/FFMPEG/FFMPEGFileProtocols.m index e71016c64..396844c4c 100644 --- a/Plugins/FFMPEG/FFMPEGFileProtocols.m +++ b/Plugins/FFMPEG/FFMPEGFileProtocols.m @@ -90,6 +90,13 @@ static int file_open(URLContext *h, const char *filename, int flags) return 0; } +static int http_open(URLContext *h, const char *filename, int flags) +{ + int rval = file_open( h, filename, flags ); + h->is_streamed = 1; + return rval; +} + /* XXX: use llseek */ static int64_t file_seek(URLContext *h, int64_t pos, int whence) { @@ -97,6 +104,11 @@ static int64_t file_seek(URLContext *h, int64_t pos, int whence) return [c->fd seek:pos whence:whence] ? [c->fd tell] : -1; } +static int64_t http_seek(URLContext *h, int64_t pos, int whence) +{ + return -1; +} + static int file_close(URLContext *h) { FileContext *c = h->priv_data; @@ -117,9 +129,9 @@ URLProtocol ff_file_protocol = { URLProtocol ff_http_protocol = { .name = "http", - .url_open = file_open, + .url_open = http_open, .url_read = file_read, - .url_seek = file_seek, + .url_seek = http_seek, .url_close = file_close, .url_check = file_check, .priv_data_size = sizeof(FileContext),