/* make media packet with below cases.
* 1. media_packet_preview_cb is set
* 2. EVAS display rendering
+ * 3. media bridge is set
*/
if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] ||
- CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
+ cb_info->is_evas_render ||
+ cb_info->bridge) {
ret = __camera_media_packet_data_create(ret_fd, tfd, num_buffer_fd, bo, buffer_bo, data_bo, &mp_data);
if (ret != CAMERA_ERROR_NONE) {
CAM_LOG_ERROR("__camera_media_packet_data_create failed[0x%x]", ret);
}
/* 2. call evas renderer */
- if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
+ if (cb_info->is_evas_render) {
if (cb_info->run_evas_render) {
media_packet_ref(pkt);
ret = mm_display_interface_evas_render(cb_info->dp_interface, pkt);
}
}
+ /* 3. media bridge */
+ g_mutex_lock(&cb_info->bridge_lock);
+
+ if (cb_info->bridge) {
+ media_packet_ref(pkt);
+ ret = media_bridge_push_packet(cb_info->bridge, pkt);
+ if (ret != MEDIA_BRIDGE_ERROR_NONE) {
+ CAM_LOG_ERROR("push packet to bridge failed[0x%x]", ret);
+ media_packet_unref(pkt);
+ }
+ }
+
+ g_mutex_unlock(&cb_info->bridge_lock);
+
_PREVIEW_CB_HANDLER_DONE:
/* send PREVIEW_CB_RETURN message if zero copy buffer is used(num_buffer_fd is bigger than 0)
and preview callback(normal or media packet) is set. */
g_mutex_init(&cb_info->fd_lock);
g_mutex_init(&cb_info->mp_data_mutex);
+ g_mutex_init(&cb_info->bridge_lock);
for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
g_mutex_init(&cb_info->user_cb_mutex[i]);
}
cb_info->fd = sockfd;
- cb_info->preview_cb_flag = 0;
/* message receive thread */
g_atomic_int_set(&cb_info->msg_recv_running, 1);
g_mutex_clear(&cb_info->fd_lock);
g_mutex_clear(&cb_info->mp_data_mutex);
+ g_mutex_clear(&cb_info->bridge_lock);
for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
g_mutex_clear(&cb_info->api_mutex[i]);
g_mutex_clear(&cb_info->fd_lock);
g_mutex_clear(&cb_info->mp_data_mutex);
+ g_mutex_clear(&cb_info->bridge_lock);
for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
g_mutex_clear(&cb_info->api_mutex[i]);
cb_info->dp_interface = NULL;
}
- cb_info->preview_cb_flag = 0;
-
g_free(cb_info);
}
CAM_LOG_INFO("start");
- if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
+ if (!pc->cb_info->is_evas_render) {
CAM_LOG_ERROR("EVAS surface is not set");
return CAMERA_ERROR_NONE;
}
CAM_LOG_INFO("stop - keep screen %d", keep_screen);
- if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
+ if (!pc->cb_info->is_evas_render) {
CAM_LOG_ERROR("EVAS surface is not set");
return CAMERA_ERROR_NONE;
}
pc->cb_info->user_cb[i] = NULL;
pc->cb_info->user_data[i] = NULL;
}
- UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
}
return ret;
_camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
}
- if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
+ if (ret == CAMERA_ERROR_NONE && pc->cb_info->is_evas_render) {
ret = _camera_start_evas_rendering(camera);
if (ret != CAMERA_ERROR_NONE) {
CAM_LOG_ERROR("stop preview because of error");
CAM_LOG_INFO("Enter");
//LCOV_EXCL_START
- if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
+ if (pc->cb_info->is_evas_render) {
ret = camera_get_state(camera, ¤t_state);
if (ret != CAMERA_ERROR_NONE) {
CAM_LOG_ERROR("failed to get current state 0x%x", ret);
_camera_msg_send_param1(api, cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
- if (ret == CAMERA_ERROR_NONE) {
- if (type == MM_DISPLAY_TYPE_EVAS)
- SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
- }
+ if (ret == CAMERA_ERROR_NONE)
+ cb_info->is_evas_render = (type == MM_DISPLAY_TYPE_EVAS) ? TRUE : FALSE;
return ret;
}
return CAMERA_ERROR_INVALID_PARAMETER;
}
- if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
+ if (pc->cb_info->is_evas_render) {
ret = camera_get_state(camera, ¤t_state);
if (ret != CAMERA_ERROR_NONE) {
CAM_LOG_ERROR("failed to get current state 0x%x", ret);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
+ if (pc->cb_info->is_evas_render) {
ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
if (ret != MM_ERROR_NONE) {
CAM_LOG_ERROR("failed to set rotation for evas surface 0x%x", ret);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
+ if (pc->cb_info->is_evas_render) {
ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
if (ret != MM_ERROR_NONE) {
CAM_LOG_ERROR("failed to set flip for evas surface 0x%x", ret);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
+ if (pc->cb_info->is_evas_render) {
ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
if (ret != MM_ERROR_NONE) {
CAM_LOG_ERROR("failed to set visible for evas surface 0x%x", ret);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
+ if (pc->cb_info->is_evas_render) {
ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
if (ret != MM_ERROR_NONE) {
CAM_LOG_ERROR("failed to set geometry for evas surface 0x%x", ret);
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
-
- SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
}
CAM_LOG_INFO("ret : 0x%x", ret);
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
-
- UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
}
CAM_LOG_INFO("ret : 0x%x", ret);
CAM_LOG_INFO("Enter");
- if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
+ if (pc->cb_info->is_evas_render) {
ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
if (ret != MM_ERROR_NONE) {
CAM_LOG_ERROR("mm_evas_renderer_set_roi_area error 0x%x", ret);
}
+int camera_media_bridge_set_bridge(camera_h camera, media_bridge_h bridge)
+{
+ int ret = CAMERA_ERROR_NONE;
+ camera_cli_s *pc = (camera_cli_s *)camera;
+ muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_BRIDGE;
+
+ if (!pc || !pc->cb_info) {
+ CAM_LOG_ERROR("NULL handle");
+ return CAMERA_ERROR_INVALID_PARAMETER;
+ }
+
+ g_mutex_lock(&pc->cb_info->bridge_lock);
+
+ if (pc->cb_info->bridge) {
+ CAM_LOG_ERROR("media bridge[%p] is already set", pc->cb_info->bridge);
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ goto _SET_MEDIA_BRIDGE_DONE;
+ }
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+ if (ret != CAMERA_ERROR_NONE) {
+ CAM_LOG_ERROR("set media bridge failed[0x%x]", ret);
+ goto _SET_MEDIA_BRIDGE_DONE;
+ }
+
+ pc->cb_info->bridge = bridge;
+
+ CAM_LOG_INFO("[%p] set media bridge[%p]", camera, bridge);
+
+_SET_MEDIA_BRIDGE_DONE:
+ g_mutex_unlock(&pc->cb_info->bridge_lock);
+
+ return ret;
+}
+
+
+int camera_media_bridge_unset_bridge(camera_h camera)
+{
+ int ret = CAMERA_ERROR_NONE;
+ camera_cli_s *pc = (camera_cli_s *)camera;
+ muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_BRIDGE;
+
+ if (!pc || !pc->cb_info) {
+ CAM_LOG_ERROR("NULL handle");
+ return CAMERA_ERROR_INVALID_PARAMETER;
+ }
+
+ g_mutex_lock(&pc->cb_info->bridge_lock);
+
+ if (!pc->cb_info->bridge) {
+ CAM_LOG_ERROR("no media bridge");
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ goto _UNSET_MEDIA_BRIDGE_DONE;
+ }
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+ if (ret != CAMERA_ERROR_NONE) {
+ CAM_LOG_ERROR("unset media bridge failed[0x%x]", ret);
+ goto _UNSET_MEDIA_BRIDGE_DONE;
+ }
+
+ CAM_LOG_INFO("[%p] unset media bridge[%p]", camera, pc->cb_info->bridge);
+
+ pc->cb_info->bridge = NULL;
+
+_UNSET_MEDIA_BRIDGE_DONE:
+ g_mutex_unlock(&pc->cb_info->bridge_lock);
+
+ return ret;
+}
+
+
int _camera_get_log_level(void)
{
return g_camera_log_level;
#include <Elementary.h>
#include <appcore-efl.h>
#include <tbm_surface.h>
+#include <media_bridge_internal.h>
/*-----------------------------------------------------------------------
| GLOBAL VARIABLE DEFINITIONS: |
static struct timeval current_time;
static struct timeval result_time;
+static media_bridge_h bridge;
+
/*-----------------------------------------------------------------------
| GLOBAL CONSTANT DEFINITIONS: |
-----------------------------------------------------------------------*/
int camcordertest_set_attr_int(const char* attr_subcategory, int value);
+static void __release_media_bridge()
+{
+ if (bridge) {
+ media_bridge_unset_source(bridge); /* not mandatory, it will be done in media_bridge_destroy() */
+ media_bridge_destroy(bridge);
+ bridge = NULL;
+ }
+}
+
static inline void flush_stdin()
{
int ch;
g_print("\t 'K' Video-stabilization \n");
g_print("\t 'u' Touch AF area \n");
g_print("\t 'n' Set file path to write captured image\n");
+ g_print("\t 'm' Set media bridge\n");
g_print("\t 'b' back\n");
g_print("\t=======================================\n");
break;
camera_unset_media_packet_preview_cb(hcamcorder->camera);
break;
case 'b': /* back */
+ __release_media_bridge();
+
camera_stop_preview(hcamcorder->camera);
camera_destroy(hcamcorder->camera);
hcamcorder->camera = NULL;
int width = 0;
int height = 0;
int result = 0;
+ int set_bridge = 0;
switch (buf) {
/* Camera setting */
g_print("\nset file path failed\n");
}
break;
+ case 'm': /* media bridge */
+ g_print("* Media Bridge !\n");
+ g_print("\tSet[1] or Unset[Others] :");
+ err = scanf("%d", &set_bridge);
+ flush_stdin();
+ if (set_bridge == 1) {
+ __release_media_bridge();
+
+ err = media_bridge_create(&bridge);
+ err |= media_bridge_set_source(bridge, MEDIA_BRIDGE_MODULE_CAMERA, hcamcorder->camera);
+ } else {
+ __release_media_bridge();
+ }
+ if (err != 0)
+ g_print("Failed to set/unset[%d] media bridge[%x]\n", set_bridge, err);
+ else
+ g_print("Succeed to set/unset[%d] media bridge\n", set_bridge);
+ break;
case 'b': /* back */
hcamcorder->menu_state = MENU_STATE_MAIN;
break;