webrtc_callbacks_s message_cb;
} webrtc_signaling_client_s;
-int _load_ini(webrtc_s *webrtc);
+void _load_ini(webrtc_s *webrtc);
void _unload_ini(webrtc_s *webrtc);
ini_item_media_source_s* _ini_get_source_by_type(webrtc_ini_s *ini, int type);
bool _is_resource_required(webrtc_ini_s *ini);
Name: capi-media-webrtc
Summary: A WebRTC library in Tizen Native API
-Version: 0.2.155
+Version: 0.2.156
Release: 0
Group: Multimedia/API
License: Apache-2.0
int webrtc_create(webrtc_h *webrtc)
{
-#ifndef TIZEN_TV
int ret = WEBRTC_ERROR_NONE;
-#endif
+ g_autoptr(GMutexLocker) locker = NULL;
webrtc_s *_webrtc = NULL;
RET_ERR_IF_NETWORK_FEATURES_ARE_NOT_SUPPORTED();
_webrtc = g_new0(webrtc_s, 1);
g_mutex_init(&_webrtc->mutex);
- g_mutex_lock(&_webrtc->mutex);
+ locker = g_mutex_locker_new(&_webrtc->mutex);
g_mutex_init(&_webrtc->desc_mutex);
g_cond_init(&_webrtc->desc_cond);
_load_ini(_webrtc);
if (_is_resource_required(&_webrtc->ini)) {
#ifndef TIZEN_TV
- ret = _create_resource_manager(_webrtc);
- if (ret != WEBRTC_ERROR_NONE) {
- LOG_ERROR("failed to create resource manager");
- _unload_ini(_webrtc);
- g_mutex_unlock(&_webrtc->mutex);
- g_free(_webrtc);
- return ret;
- }
+ if ((ret = _create_resource_manager(_webrtc)) != WEBRTC_ERROR_NONE)
+ goto error;
#else
LOG_WARNING("no resource manager integration yet");
#endif
}
- _gst_init(_webrtc);
- _gst_build_pipeline(_webrtc);
+
+ if ((ret = _gst_init(_webrtc)) != WEBRTC_ERROR_NONE)
+ goto error;
+
+ if ((ret = _gst_build_pipeline(_webrtc)) != WEBRTC_ERROR_NONE)
+ goto error;
+
_init_data_channels(_webrtc);
_webrtc->pend_state = WEBRTC_STATE_IDLE;
LOG_INFO("webrtc[%p] is created", *webrtc);
- g_mutex_unlock(&_webrtc->mutex);
-
return WEBRTC_ERROR_NONE;
+
+error:
+ _unload_ini(_webrtc);
+ g_free(_webrtc);
+
+ return ret;
}
int webrtc_destroy(webrtc_h webrtc)
is_default ? DEFAULT_FEC_PERCENTAGE : ini->media_source.fec_percentage);
}
-int _load_ini(webrtc_s *webrtc)
+void _load_ini(webrtc_s *webrtc)
{
webrtc_ini_s *ini;
int i = 0;
- RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
+ RET_IF(webrtc == NULL, "webrtc is NULL");
memset(&webrtc->ini, 0, sizeof(webrtc_ini_s));
ini = &webrtc->ini;
__apply_vpxenc_params_setting(ini, &ini->vpxenc_params, INI_CATEGORY_VPXENC_PARAMS);
__dump_ini(ini);
-
- return WEBRTC_ERROR_NONE;
}
ini_item_media_source_s* _ini_get_source_by_type(webrtc_ini_s *ini, int type)
g_strfreev(webrtc->ini.general.gst_excluded_elements);
webrtc->ini.general.gst_excluded_elements = NULL;
- iniparser_freedict(webrtc->ini.dict);
- LOG_DEBUG("ini instance[%p] is freed", webrtc->ini.dict);
- webrtc->ini.dict = NULL;
+ if (webrtc->ini.dict) {
+ iniparser_freedict(webrtc->ini.dict);
+ LOG_DEBUG("ini instance[%p] is freed", webrtc->ini.dict);
+ webrtc->ini.dict = NULL;
+ }
}
if (mm_resource_manager_create(MM_RESOURCE_MANAGER_APP_CLASS_MEDIA,
__resource_release_cb, webrtc,
&webrtc->resource.mgr) != MM_RESOURCE_MANAGER_ERROR_NONE) {
- LOG_ERROR("Failed to init resource manager for media");
+ LOG_ERROR("failed to init resource manager for media");
return WEBRTC_ERROR_RESOURCE_FAILED;
}