|
|
|
@ -30,10 +30,11 @@ std::list< std::pair<unsigned char*,size_t> > H264_V4L2DeviceSource::splitFrames
|
|
|
|
|
|
|
|
|
|
size_t bufSize = frameSize;
|
|
|
|
|
size_t size = 0;
|
|
|
|
|
unsigned char* buffer = this->extractFrame(frame, bufSize, size);
|
|
|
|
|
int frameType = 0;
|
|
|
|
|
unsigned char* buffer = this->extractFrame(frame, bufSize, size, frameType);
|
|
|
|
|
while (buffer != NULL)
|
|
|
|
|
{
|
|
|
|
|
switch (m_frameType&0x1F)
|
|
|
|
|
switch (frameType&0x1F)
|
|
|
|
|
{
|
|
|
|
|
case 7: LOG(INFO) << "SPS size:" << size << " bufSize:" << bufSize; m_sps.assign((char*)buffer,size); break;
|
|
|
|
|
case 8: LOG(INFO) << "PPS size:" << size << " bufSize:" << bufSize; m_pps.assign((char*)buffer,size); break;
|
|
|
|
@ -66,7 +67,7 @@ std::list< std::pair<unsigned char*,size_t> > H264_V4L2DeviceSource::splitFrames
|
|
|
|
|
}
|
|
|
|
|
frameList.push_back(std::pair<unsigned char*,size_t>(buffer, size));
|
|
|
|
|
|
|
|
|
|
buffer = this->extractFrame(&buffer[size], bufSize, size);
|
|
|
|
|
buffer = this->extractFrame(&buffer[size], bufSize, size, frameType);
|
|
|
|
|
}
|
|
|
|
|
return frameList;
|
|
|
|
|
}
|
|
|
|
@ -78,10 +79,11 @@ std::list< std::pair<unsigned char*,size_t> > H265_V4L2DeviceSource::splitFrames
|
|
|
|
|
|
|
|
|
|
size_t bufSize = frameSize;
|
|
|
|
|
size_t size = 0;
|
|
|
|
|
unsigned char* buffer = this->extractFrame(frame, bufSize, size);
|
|
|
|
|
int frameType = 0;
|
|
|
|
|
unsigned char* buffer = this->extractFrame(frame, bufSize, size, frameType);
|
|
|
|
|
while (buffer != NULL)
|
|
|
|
|
{
|
|
|
|
|
switch ((m_frameType&0x7E)>>1)
|
|
|
|
|
switch ((frameType&0x7E)>>1)
|
|
|
|
|
{
|
|
|
|
|
case 32: LOG(INFO) << "VPS size:" << size << " bufSize:" << bufSize; m_vps.assign((char*)buffer,size); break;
|
|
|
|
|
case 33: LOG(INFO) << "SPS size:" << size << " bufSize:" << bufSize; m_sps.assign((char*)buffer,size); break;
|
|
|
|
@ -116,18 +118,18 @@ std::list< std::pair<unsigned char*,size_t> > H265_V4L2DeviceSource::splitFrames
|
|
|
|
|
}
|
|
|
|
|
frameList.push_back(std::pair<unsigned char*,size_t>(buffer, size));
|
|
|
|
|
|
|
|
|
|
buffer = this->extractFrame(&buffer[size], bufSize, size);
|
|
|
|
|
buffer = this->extractFrame(&buffer[size], bufSize, size, frameType);
|
|
|
|
|
}
|
|
|
|
|
return frameList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// extract a frame
|
|
|
|
|
unsigned char* H26X_V4L2DeviceSource::extractFrame(unsigned char* frame, size_t& size, size_t& outsize)
|
|
|
|
|
unsigned char* H26X_V4L2DeviceSource::extractFrame(unsigned char* frame, size_t& size, size_t& outsize, int& frameType)
|
|
|
|
|
{
|
|
|
|
|
unsigned char * outFrame = NULL;
|
|
|
|
|
outsize = 0;
|
|
|
|
|
unsigned int markerlength = 0;
|
|
|
|
|
m_frameType = 0;
|
|
|
|
|
frameType = 0;
|
|
|
|
|
|
|
|
|
|
unsigned char *startFrame = (unsigned char*)memmem(frame,size,H264marker,sizeof(H264marker));
|
|
|
|
|
if (startFrame != NULL) {
|
|
|
|
@ -139,7 +141,7 @@ unsigned char* H26X_V4L2DeviceSource::extractFrame(unsigned char* frame, size_t
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (startFrame != NULL) {
|
|
|
|
|
m_frameType = startFrame[markerlength];
|
|
|
|
|
frameType = startFrame[markerlength];
|
|
|
|
|
|
|
|
|
|
int remainingSize = size-(startFrame-frame+markerlength);
|
|
|
|
|
unsigned char *endFrame = (unsigned char*)memmem(&startFrame[markerlength], remainingSize, H264marker, sizeof(H264marker));
|
|
|
|
|