static media_bridge_module_name_table g_media_bridge_module_name_table[MEDIA_BRIDGE_MODULE_NUM] = {
- /* MEDIA_BRIDGE_MODULE_CAMERA */
- {PATH_LIBDIR"/libcapi-media-camera.so.0",
+ [MEDIA_BRIDGE_MODULE_CAMERA] = {
+ PATH_LIBDIR"/libcapi-media-camera.so.0",
"camera_media_bridge_set_bridge",
"camera_media_bridge_unset_bridge",
NULL},
- /* MEDIA_BRIDGE_MODULE_PLAYER */
- {PATH_LIBDIR"/libcapi-media-player.so.0",
+ [MEDIA_BRIDGE_MODULE_PLAYER] = {
+ PATH_LIBDIR"/libcapi-media-player.so.0",
NULL,
NULL,
NULL},
- /* MEDIA_BRIDGE_MODULE_VISION */
- {PATH_LIBDIR"/libmv_common.so",
+ [MEDIA_BRIDGE_MODULE_VISION] = {
+ PATH_LIBDIR"/libmv_common.so",
NULL,
NULL,
NULL},
- /* MEDIA_BRIDGE_MODULE_CODEC */
- {PATH_LIBDIR"/libcapi-media-codec.so.0",
+ [MEDIA_BRIDGE_MODULE_CODEC] = {
+ PATH_LIBDIR"/libcapi-media-codec.so.0",
NULL,
NULL,
NULL},
- /* MEDIA_BRIDGE_MODULE_WEBRTC */
- {PATH_LIBDIR"/libcapi-media-webrtc.so.0",
+ [MEDIA_BRIDGE_MODULE_WEBRTC] = {
+ PATH_LIBDIR"/libcapi-media-webrtc.so.0",
NULL,
NULL,
"webrtc_media_bridge_push_packet"}
}
-static gpointer __media_bridge_push_packet_func(gpointer data)
+static gpointer __media_bridge_push_packet_thread_func(gpointer data)
{
int id = 0;
- int push_count = 0;
int ret = 0;
+ unsigned int pushed_count = 0;
media_bridge_s *handle = (media_bridge_s *)data;
media_packet_h packet = NULL;
media_bridge_sink_s *sink = NULL;
g_mutex_unlock(&handle->lock);
- LOGD("[%p] push packet[%p] to sink[count:%d]", handle, packet, handle->sink_count);
+ LOGD("[%p] push packet[%p] to sink[count:%u]", handle, packet, handle->sink_count);
- push_count = 0;
+ pushed_count = 0;
for (id = 0 ; id < MEDIA_BRIDGE_SINK_MAX ; id++) {
sink = &handle->sink[id];
continue;
}
- push_count++;
+ pushed_count++;
}
media_packet_unref(packet);
packet = NULL;
- if (handle->sink_count != push_count)
- LOGW("something wrong[sink count:%d vs push count:%d]", handle->sink_count, push_count);
+ if (handle->sink_count != pushed_count)
+ LOGW("something wrong[sink count:%u vs pushed count:%u]", handle->sink_count, pushed_count);
g_mutex_lock(&handle->lock);
}
g_cond_init(&new_handle->cond);
new_handle->push_packet_thread = g_thread_try_new("media_bridge_push_packet_thread",
- __media_bridge_push_packet_func, (gpointer)new_handle, NULL);
+ __media_bridge_push_packet_thread_func, (gpointer)new_handle, NULL);
if (!new_handle->push_packet_thread) {
LOGE("push_packet_thread failed");
goto _CREATE_FAILED;
void *dl_handle = NULL;
module_media_bridge_set_bridge_func set_bridge_func = NULL;
module_media_bridge_unset_bridge_func unset_bridge_func = NULL;
- const char *library_path = NULL;
- const char *set_bridge = NULL;
- const char *unset_bridge = NULL;
+ media_bridge_module_name_table *table_p = NULL;
MEDIA_BRIDGE_NULL_CHECK(handle);
MEDIA_BRIDGE_NULL_CHECK(module_handle);
goto _SET_SOURCE_OUT;
}
- library_path = g_media_bridge_module_name_table[module].library_path;
- set_bridge = g_media_bridge_module_name_table[module].set_bridge;
- unset_bridge = g_media_bridge_module_name_table[module].unset_bridge;
-
- if (!library_path || !set_bridge || !unset_bridge) {
+ table_p = &g_media_bridge_module_name_table[module];
+ if (!table_p->library_path || !table_p->set_bridge || !table_p->unset_bridge) {
LOGE("module[%d] is not supported[%s,%s,%s] for source",
- module, library_path, set_bridge, unset_bridge);
+ module, table_p->library_path, table_p->set_bridge, table_p->unset_bridge);
ret = MEDIA_BRIDGE_ERROR_NOT_SUPPORTED;
goto _SET_SOURCE_OUT;
}
- LOGI("open[%s]", library_path);
+ LOGI("open[%s]", table_p->library_path);
- dl_handle = dlopen(library_path, RTLD_NOW);
+ dl_handle = dlopen(table_p->library_path, RTLD_NOW);
if (!dl_handle) {
- LOGE("open[%s] failed[errno:%d]", library_path, errno);
+ LOGE("open[%s] failed[errno:%d]", table_p->library_path, errno);
ret = MEDIA_BRIDGE_ERROR_INVALID_OPERATION;
goto _SET_SOURCE_OUT;
}
- set_bridge_func = dlsym(dl_handle, set_bridge);
- unset_bridge_func = dlsym(dl_handle, unset_bridge);
+ set_bridge_func = dlsym(dl_handle, table_p->set_bridge);
+ unset_bridge_func = dlsym(dl_handle, table_p->unset_bridge);
if (!set_bridge_func || !unset_bridge_func) {
LOGE("module[%d] symbol[%s,%s] failed[%s]",
- module, set_bridge, unset_bridge, dlerror());
+ module, table_p->set_bridge, table_p->unset_bridge, dlerror());
ret = MEDIA_BRIDGE_ERROR_INVALID_OPERATION;
goto _SET_SOURCE_OUT;
}
media_bridge_s *handle = (media_bridge_s *)bridge;
media_bridge_sink_s *sink = NULL;
module_media_bridge_push_packet_func push_packet_func = NULL;
- const char *library_path = NULL;
- const char *push_packet = NULL;
+ media_bridge_module_name_table *table_p = NULL;
MEDIA_BRIDGE_NULL_CHECK(handle);
MEDIA_BRIDGE_NULL_CHECK(module_handle);
goto _ADD_SINK_OUT;
}
- library_path = g_media_bridge_module_name_table[module].library_path;
- push_packet = g_media_bridge_module_name_table[module].push_packet;
-
- if (!library_path || !push_packet) {
- LOGE("module[%d] is not supported[%s,%s] for sink", module, library_path, push_packet);
+ table_p = &g_media_bridge_module_name_table[module];
+ if (!table_p->library_path || !table_p->push_packet) {
+ LOGE("module[%d] is not supported[%s,%s] for sink", module, table_p->library_path, table_p->push_packet);
ret = MEDIA_BRIDGE_ERROR_NOT_SUPPORTED;
goto _ADD_SINK_OUT;
}
- LOGI("open[%s]", library_path);
+ LOGI("open[%s]", table_p->library_path);
- dl_handle = dlopen(library_path, RTLD_NOW);
+ dl_handle = dlopen(table_p->library_path, RTLD_NOW);
if (!dl_handle) {
- LOGE("open[%s] failed[errno:%d]", library_path, errno);
+ LOGE("open[%s] failed[errno:%d]", table_p->library_path, errno);
ret = MEDIA_BRIDGE_ERROR_INVALID_OPERATION;
goto _ADD_SINK_OUT;
}
- push_packet_func = dlsym(dl_handle, push_packet);
+ push_packet_func = dlsym(dl_handle, table_p->push_packet);
if (!push_packet_func) {
- LOGE("module[%d] symbol[%s] failed[%s]", module, push_packet, dlerror());
+ LOGE("module[%d] symbol[%s] failed[%s]", module, table_p->push_packet, dlerror());
ret = MEDIA_BRIDGE_ERROR_INVALID_OPERATION;
goto _ADD_SINK_OUT;
}
*sink_id = id;
- LOGI("[%p] sink added[module:%d,%p, id:%d] count[%d]",
+ LOGI("[%p] sink added[module:%d,%p, id:%d] count[%u]",
handle, module, module_handle, id, handle->sink_count);
_ADD_SINK_OUT:
handle->sink_count--;
- LOGI("[%p] sink removed[id:%d,count:%d]", sink_id, handle->sink_count);
+ LOGI("[%p] sink removed[id:%d,count:%u]", sink_id, handle->sink_count);
_REMOVE_SINK_OUT:
g_mutex_unlock(&handle->lock);
return MEDIA_BRIDGE_ERROR_INVALID_STATE;
}
- if (handle->sink_count < 1) {
+ if (handle->sink_count == 0) {
LOGE("no sink is added");
g_mutex_unlock(&handle->lock);
return MEDIA_BRIDGE_ERROR_INVALID_OPERATION;
goto _PUSH_PACKET_OUT;
}
- if (handle->sink_count < 1) {
+ if (handle->sink_count == 0) {
LOGW("no sink is added");
goto _PUSH_PACKET_OUT;
}