Fixed HTTP streaming FFMPEG supported formats

CQTexperiment
Chris Moeller 2014-07-04 01:07:55 -07:00
parent 3d26315db9
commit 75c565da0d
2 changed files with 22 additions and 4 deletions

View File

@ -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;

View File

@ -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),