mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
HLS: Ignore empty NALU to avoid error. v5.0.170
This commit is contained in:
parent
08147f81bf
commit
939f6b484b
8 changed files with 116 additions and 3 deletions
|
@ -17,6 +17,9 @@
|
|||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#ifdef SRS_SRT
|
||||
#include <srs_app_srt_server.hpp>
|
||||
#endif
|
||||
|
@ -208,3 +211,39 @@ VOID TEST(SampleTest, ContextTest)
|
|||
cache[0] = cid;
|
||||
}
|
||||
|
||||
MockProtectedBuffer::MockProtectedBuffer() : size_(0), data_(NULL), raw_memory_(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
MockProtectedBuffer::~MockProtectedBuffer()
|
||||
{
|
||||
if (size_ && raw_memory_) {
|
||||
long page_size = sysconf(_SC_PAGESIZE);
|
||||
munmap(raw_memory_, page_size * 2);
|
||||
}
|
||||
}
|
||||
|
||||
int MockProtectedBuffer::alloc(int size)
|
||||
{
|
||||
srs_assert(!raw_memory_);
|
||||
|
||||
long page_size = sysconf(_SC_PAGESIZE);
|
||||
if (size >= page_size) return -1;
|
||||
|
||||
char* data = (char*)mmap(NULL, page_size * 2, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
|
||||
if (data == MAP_FAILED) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
size_ = size;
|
||||
raw_memory_ = data;
|
||||
data_ = data + page_size - size;
|
||||
|
||||
int r0 = mprotect(data + page_size, page_size, PROT_NONE);
|
||||
if (r0 < 0) {
|
||||
return r0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue