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
|
@ -131,7 +131,7 @@ void MockSrsFileReader::skip(int64_t _size)
|
|||
offset += _size;
|
||||
}
|
||||
|
||||
int64_t MockSrsFileReader::lseek(int64_t _offset)
|
||||
int64_t MockSrsFileReader::seek2(int64_t _offset)
|
||||
{
|
||||
offset = (int)_offset;
|
||||
return offset;
|
||||
|
@ -163,6 +163,12 @@ int MockSrsFileReader::read(void* buf, size_t count, ssize_t* pnread)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int MockSrsFileReader::lseek(off_t _offset, int /*whence*/, off_t* /*seeked*/)
|
||||
{
|
||||
offset = (int)_offset;
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
void MockSrsFileReader::mock_append_data(const char* _data, int _size)
|
||||
{
|
||||
int s = srs_min(MAX_MOCK_DATA_SIZE - offset, _size);
|
||||
|
@ -952,10 +958,10 @@ VOID TEST(KernelFlvTest, FlvVSDecoderSeek)
|
|||
fs.mock_append_data(tag_header, 11);
|
||||
EXPECT_TRUE(11 == fs.offset);
|
||||
|
||||
EXPECT_TRUE(ERROR_SUCCESS == dec.lseek(0));
|
||||
EXPECT_TRUE(ERROR_SUCCESS == dec.seek2(0));
|
||||
EXPECT_TRUE(0 == fs.offset);
|
||||
|
||||
EXPECT_TRUE(ERROR_SUCCESS == dec.lseek(5));
|
||||
EXPECT_TRUE(ERROR_SUCCESS == dec.seek2(5));
|
||||
EXPECT_TRUE(5 == fs.offset);
|
||||
}
|
||||
|
||||
|
|
|
@ -81,10 +81,11 @@ public:
|
|||
virtual bool is_open();
|
||||
virtual int64_t tellg();
|
||||
virtual void skip(int64_t size);
|
||||
virtual int64_t lseek(int64_t offset);
|
||||
virtual int64_t seek2(int64_t offset);
|
||||
virtual int64_t filesize();
|
||||
public:
|
||||
virtual int read(void* buf, size_t count, ssize_t* pnread);
|
||||
virtual int lseek(off_t offset, int whence, off_t* seeked);
|
||||
// for mock
|
||||
public:
|
||||
// append data to current offset, modify the offset and size.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue