Fixed HTTP streaming FFMPEG supported formats
This commit is contained in:
parent
3d26315db9
commit
75c565da0d
2 changed files with 22 additions and 4 deletions
|
@ -157,6 +157,9 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op)
|
||||||
framesRead = 0;
|
framesRead = 0;
|
||||||
endOfStream = NO;
|
endOfStream = NO;
|
||||||
|
|
||||||
|
if ( totalFrames < 0 )
|
||||||
|
totalFrames = 0;
|
||||||
|
|
||||||
seekable = [s seekable];
|
seekable = [s seekable];
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
|
@ -180,7 +183,7 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op)
|
||||||
|
|
||||||
- (int)readAudio:(void *)buf frames:(UInt32)frames
|
- (int)readAudio:(void *)buf frames:(UInt32)frames
|
||||||
{
|
{
|
||||||
if ( framesRead >= totalFrames )
|
if ( totalFrames && framesRead >= totalFrames )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int frameSize = channels * (bitsPerSample / 8);
|
int frameSize = channels * (bitsPerSample / 8);
|
||||||
|
@ -292,7 +295,7 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op)
|
||||||
}
|
}
|
||||||
|
|
||||||
int framesReadNow = bytesRead / frameSize;
|
int framesReadNow = bytesRead / frameSize;
|
||||||
if ( framesRead + framesReadNow > totalFrames )
|
if ( totalFrames && ( framesRead + framesReadNow > totalFrames ) )
|
||||||
framesReadNow = totalFrames - framesRead;
|
framesReadNow = totalFrames - framesRead;
|
||||||
|
|
||||||
framesRead += framesReadNow;
|
framesRead += framesReadNow;
|
||||||
|
@ -302,6 +305,9 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op)
|
||||||
|
|
||||||
- (long)seek:(long)frame
|
- (long)seek:(long)frame
|
||||||
{
|
{
|
||||||
|
if ( !totalFrames )
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (frame >= totalFrames)
|
if (frame >= totalFrames)
|
||||||
{
|
{
|
||||||
framesRead = totalFrames;
|
framesRead = totalFrames;
|
||||||
|
|
|
@ -90,6 +90,13 @@ static int file_open(URLContext *h, const char *filename, int flags)
|
||||||
return 0;
|
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 */
|
/* XXX: use llseek */
|
||||||
static int64_t file_seek(URLContext *h, int64_t pos, int whence)
|
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;
|
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)
|
static int file_close(URLContext *h)
|
||||||
{
|
{
|
||||||
FileContext *c = h->priv_data;
|
FileContext *c = h->priv_data;
|
||||||
|
@ -117,9 +129,9 @@ URLProtocol ff_file_protocol = {
|
||||||
|
|
||||||
URLProtocol ff_http_protocol = {
|
URLProtocol ff_http_protocol = {
|
||||||
.name = "http",
|
.name = "http",
|
||||||
.url_open = file_open,
|
.url_open = http_open,
|
||||||
.url_read = file_read,
|
.url_read = file_read,
|
||||||
.url_seek = file_seek,
|
.url_seek = http_seek,
|
||||||
.url_close = file_close,
|
.url_close = file_close,
|
||||||
.url_check = file_check,
|
.url_check = file_check,
|
||||||
.priv_data_size = sizeof(FileContext),
|
.priv_data_size = sizeof(FileContext),
|
||||||
|
|
Loading…
Reference in a new issue