add isKeyframe method

pull/330/head
Michel Promonet 6 months ago
parent 0b4247c538
commit bfdd34d45b

@ -29,4 +29,5 @@ class H264_V4L2DeviceSource : public H26X_V4L2DeviceSource
// overide V4L2DeviceSource
virtual std::list< std::pair<unsigned char*,size_t> > splitFrames(unsigned char* frame, unsigned frameSize);
virtual std::list< std::string > getInitFrames();
virtual bool isKeyFrame(const char*, int);
};

@ -29,6 +29,7 @@ class H265_V4L2DeviceSource : public H26X_V4L2DeviceSource
// overide V4L2DeviceSource
virtual std::list< std::pair<unsigned char*,size_t> > splitFrames(unsigned char* frame, unsigned frameSize);
virtual std::list< std::string > getInitFrames();
virtual bool isKeyFrame(const char*, int);
protected:
std::string m_vps;

@ -80,6 +80,7 @@ class V4L2DeviceSource: public FramedSource
DeviceInterface* getDevice() { return m_device; }
void postFrame(char * frame, int frameSize, const timeval &ref);
virtual std::list< std::string > getInitFrames() { return std::list< std::string >(); }
virtual bool isKeyFrame(const char*, int) { return false; }
protected:

@ -78,3 +78,13 @@ std::list< std::string > H264_V4L2DeviceSource::getInitFrames() {
frameList.push_back(this->getFrameWithMarker(m_pps));
return frameList;
}
bool H264_V4L2DeviceSource::isKeyFrame(const char* buffer, int size) {
bool res = false;
if (size > 4)
{
int frameType = buffer[4]&0x1F;
res = (frameType == 5);
}
return res;
}

@ -76,3 +76,13 @@ std::list< std::string > H265_V4L2DeviceSource::getInitFrames() {
frameList.push_back(this->getFrameWithMarker(m_pps));
return frameList;
}
bool H265_V4L2DeviceSource::isKeyFrame(const char* buffer, int size) {
bool res = false;
if (size > 4)
{
int frameType = (buffer[4]&0x7E)>>1;
res = (frameType == 19 || frameType == 20);
}
return res;
}
Loading…
Cancel
Save