mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
for #738, use reader and seeker for mp4 demuxer to seek for general mp4(ftyp-mdat-moov).
This commit is contained in:
parent
bbee16e4db
commit
9d21a8bb33
16 changed files with 237 additions and 101 deletions
|
@ -117,7 +117,7 @@ bool SrsFileWriter::is_open()
|
|||
return fd > 0;
|
||||
}
|
||||
|
||||
void SrsFileWriter::lseek(int64_t offset)
|
||||
void SrsFileWriter::seek2(int64_t offset)
|
||||
{
|
||||
::lseek(fd, (off_t)offset, SEEK_SET);
|
||||
}
|
||||
|
@ -167,6 +167,19 @@ int SrsFileWriter::writev(const iovec* iov, int iovcnt, ssize_t* pnwrite)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int SrsFileWriter::lseek(off_t offset, int whence, off_t* seeked)
|
||||
{
|
||||
off_t sk = ::lseek(fd, offset, whence);
|
||||
if (sk < 0) {
|
||||
return ERROR_SYSTEM_FILE_SEEK;
|
||||
}
|
||||
|
||||
if (seeked) {
|
||||
*seeked = sk;
|
||||
}
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
SrsFileReader::SrsFileReader()
|
||||
{
|
||||
fd = -1;
|
||||
|
@ -231,7 +244,7 @@ void SrsFileReader::skip(int64_t size)
|
|||
::lseek(fd, (off_t)size, SEEK_CUR);
|
||||
}
|
||||
|
||||
int64_t SrsFileReader::lseek(int64_t offset)
|
||||
int64_t SrsFileReader::seek2(int64_t offset)
|
||||
{
|
||||
return (int64_t)::lseek(fd, (off_t)offset, SEEK_SET);
|
||||
}
|
||||
|
@ -268,3 +281,16 @@ int SrsFileReader::read(void* buf, size_t count, ssize_t* pnread)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int SrsFileReader::lseek(off_t offset, int whence, off_t* seeked)
|
||||
{
|
||||
off_t sk = ::lseek(fd, offset, whence);
|
||||
if (sk < 0) {
|
||||
return ERROR_SYSTEM_FILE_SEEK;
|
||||
}
|
||||
|
||||
if (seeked) {
|
||||
*seeked = sk;
|
||||
}
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue