Re-use h264 keyframes
This commit is contained in:
@ -47,16 +47,28 @@ typedef struct {
|
||||
bool requested_key_frame;
|
||||
} http_video_status_t;
|
||||
|
||||
bool h264_is_key_frame(buffer_t *buf)
|
||||
{
|
||||
unsigned char *data = buf->start;
|
||||
device_t *camera = buf->buf_list->device;
|
||||
|
||||
if (buf->v4l2_buffer.flags & V4L2_BUF_FLAG_KEYFRAME) {
|
||||
E_LOG_DEBUG(buf, "Got key frame (from V4L2)!");
|
||||
return true;
|
||||
} else if (buf->used >= 5 && (data[4] & 0x1F) == 0x07) {
|
||||
E_LOG_DEBUG(buf, "Got key frame (from buffer)!");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int http_video_buf_part(buffer_lock_t *buf_lock, buffer_t *buf, int frame, http_video_status_t *status)
|
||||
{
|
||||
unsigned char *data = buf->start;
|
||||
|
||||
if (buf->v4l2_buffer.flags & V4L2_BUF_FLAG_KEYFRAME) {
|
||||
status->had_key_frame = true;
|
||||
E_LOG_DEBUG(buf, "Got key frame (from V4L2)!");
|
||||
} else if (buf->used >= 5 && (data[4] & 0x1F) == 0x07) {
|
||||
status->had_key_frame = true;
|
||||
E_LOG_DEBUG(buf, "Got key frame (from buffer)!");
|
||||
if (!status->had_key_frame) {
|
||||
status->had_key_frame = h264_is_key_frame(buf);
|
||||
}
|
||||
|
||||
if (!status->had_key_frame) {
|
||||
|
Reference in New Issue
Block a user