break;
}
} else {
- if (resolution_count == VIRTUAL_CAMERA_RES_MAX)
+ if (resolution_count < VIRTUAL_CAMERA_RES_MAX) {
+ v4l2_frame.discrete.width = g_virtual_camera_res[resolution_count].width;
+ v4l2_frame.discrete.height = g_virtual_camera_res[resolution_count].height;
+ v4l2_frame.type = V4L2_FRMSIZE_TYPE_DISCRETE;
+ } else {
break;
-
- v4l2_frame.discrete.width = g_virtual_camera_res[resolution_count].width;
- v4l2_frame.discrete.height = g_virtual_camera_res[resolution_count].height;
- v4l2_frame.type = V4L2_FRMSIZE_TYPE_DISCRETE;
+ }
}
if (resolution_count + 1 >= RESOLUTION_COUNT_MAX) {
static int __camera_get_device_info_list(void)
{
- int i = 0;
+ size_t i = 0;
int ret = CAMERA_ERROR_NONE;
int device_count = 0;
int device_fd = CAMERA_HAL_INITIAL_FD;
LOGD("device node count : %zu", glob_buf.gl_pathc);
for (i = 0 ; i < glob_buf.gl_pathc ; i++) {
- LOGD("[%d] check device [%s]", i, glob_buf.gl_pathv[i]);
+ LOGD("[%zu] check device [%s]", i, glob_buf.gl_pathv[i]);
device_fd = open(glob_buf.gl_pathv[i], O_RDWR);
if (device_fd < 0) {
}
+static gboolean __camera_h264_is_delta_frame(guint8 *data, uint32_t size)
+{
+ uint32_t offset = 0;
+ uint32_t zero_count = 0;
+ uint32_t nal_unit_type = 0;
+
+ if (!data) {
+ LOGW("NULL data");
+ return FALSE;
+ }
+
+CHECK_AGAIN:
+ zero_count = 0;
+ while (offset < size) {
+ if (data[offset] == 0x0) {
+ zero_count++;
+ } else if (data[offset] == 0x1) {
+ if (zero_count == 2 || zero_count == 3) {
+ /* break to check NAL unit type */
+ offset++;
+ break;
+ }
+ zero_count = 0;
+ } else {
+ zero_count = 0;
+ }
+
+ offset++;
+ }
+
+ if (offset >= size) {
+ LOGD("invalid offset[%u], size[%u]", offset, size);
+ return FALSE;
+ }
+
+ nal_unit_type = data[offset] & 0x1F;
+ offset++;
+
+ switch (nal_unit_type) {
+ case 1:
+ LOGD("non-IDR picture");
+ return TRUE;
+ case 5:
+ LOGD("IDR picture");
+ return FALSE;
+ case 7:
+ LOGD("SPS(Sequence Parameter Set)");
+ goto CHECK_AGAIN;
+ case 8:
+ LOGD("PPS(Picture Parameter Set)");
+ goto CHECK_AGAIN;
+ default:
+ LOGD("unhandled NAL unit type[%u]", nal_unit_type);
+ return FALSE;
+ }
+}
+
+
static void *__camera_buffer_handler_func(gpointer data)
{
int error = CAMERA_ERROR_NONE;
int index = 0;
hal_camera_handle *handle = (hal_camera_handle *)data;
uint32_t bytesused = 0;
+ camera_metadata_s meta;
if (!handle) {
LOGE("NULL handle for buffer handler");
break;
}
+ memset(&meta, 0x0, sizeof(camera_metadata_s));
+
+ if (handle->preview_format.stream_format == CAMERA_PIXEL_FORMAT_H264)
+ meta.is_delta_frame = __camera_h264_is_delta_frame((guint8 *)handle->camera_buffers[index].planes[0].data, bytesused);
+
handle->buffer_dequeued_count++;
handle->camera_buffers[index].planes[0].bytesused = bytesused;
g_mutex_unlock(&handle->buffer_lock);
if (handle->preview_cb) {
- handle->preview_cb(&handle->camera_buffers[index], NULL, handle->preview_cb_data);
+ handle->preview_cb(&handle->camera_buffers[index], &meta, handle->preview_cb_data);
} else {
LOGW("preview callback is NULL");
camera_v4l2_release_preview_buffer((void *)handle, index);