#endif
#define VISION_SOURCE_DEVICE_ID 3
+#define VISION_SOURCE_CAPS_ID 0
#define __max(a, b) (((a) > (b)) ? (a) : (b))
#define __min(a, b) (((a) < (b)) ? (a) : (b))
printf("_vision_source_cb: %lld ms\n", static_cast<long long int>(app->stopWatch.elapsedTime().count()));
char *plane_data_ptr;
- int stride_w, height, width;
+ int height, width;
media_format_h fmt;
media_packet_get_format(packet, &fmt);
media_format_get_video_info(fmt, nullptr, &width, &height, nullptr, nullptr);
media_format_unref(fmt);
- media_packet_get_video_stride_width(packet, 0, &stride_w);
- media_packet_get_video_plane_data_ptr(packet, 0, (void **) (&plane_data_ptr));
+ media_packet_get_buffer_data_ptr(packet, (void **) (&plane_data_ptr));
- for (int h = 0; h < height; h++) {
- memcpy(app->buffer + width * h, plane_data_ptr + stride_w * h, width);
- }
+ memcpy(app->buffer, plane_data_ptr, width * height);
mv_source_fill_by_buffer(app->mv_source, app->buffer, app->imgWidth * app->imgHeight, app->imgWidth, app->imgHeight,
MEDIA_VISION_COLORSPACE_Y800);
- media_packet_unref(packet);
if (isAsync)
mv_3d_run_async(app->mv3d_handle, app->mv_source, nullptr, nullptr);
int ret = MEDIA_VISION_ERROR_NONE;
printf("enter main\n");
- vision_source_format_s format { .pixel_format = VISION_SOURCE_PIXEL_FORMAT_NV12,
- .resolution = { static_cast<unsigned int>(camWidth << 1),
- static_cast<unsigned int>(camHeight) },
- .fps = 10,
- .quality = 0,
- .bitrate = 0 };
-
// mediavision
// engine_config
ret = mv_create_engine_config(&engine_config);
goto _err;
}
- // vision-source
ret = vision_source_init(&vision_source_handle);
if (ret != VISION_SOURCE_ERROR_NONE) {
goto _err;
}
+ const vision_source_device_info_s *dev_list;
+ int dev_cnt;
+
+ ret = vision_source_list_devices(vision_source_handle, &dev_list, &dev_cnt);
+ if (ret != VISION_SOURCE_ERROR_NONE) {
+ goto _err;
+ }
+
ret = vision_source_open_device(vision_source_handle, VISION_SOURCE_DEVICE_ID);
if (ret != VISION_SOURCE_ERROR_NONE) {
goto _err;
}
+ const media_format_h *fmt_list;
+ int fmt_count;
+
+ ret = vision_source_list_device_caps(vision_source_handle, VISION_SOURCE_CAPS_ID, &fmt_list, &fmt_count);
+ if (ret != VISION_SOURCE_ERROR_NONE) {
+ goto _err;
+ }
+
loop = g_main_loop_new(NULL, false);
- ret = vision_source_set_stream_format(vision_source_handle, &format);
+
+ ret = vision_source_set_stream_format(vision_source_handle, fmt_list[VISION_SOURCE_CAPS_ID]);
if (ret != VISION_SOURCE_ERROR_NONE) {
goto _err;
}
- vision_source_start_stream(vision_source_handle, _vision_source_cb, &app);
+ vision_source_set_stream_cb(vision_source_handle, _vision_source_cb, &app);
+ vision_source_start_stream(vision_source_handle);
printf("starting...\n");
g_main_loop_run(loop);
printf("stop\n");