--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "webrtc.h"
+#include "webrtc_private.h"
+
+#define WEBRTC_INI_PATH "/etc/multimedia/mmfw_webrtc.ini"
+#define DEFAULT_GENERATE_DOT TRUE
+#define DEFAULT_DOT_PATH "/tmp"
+
+#define INI_ITEM_GENERAL_DOT_PATH "general:dot path"
+#define INI_ITEM_GENERAL_DOT_GENERATE "general:generate dot"
+#define INI_ITEM_GENERAL_GST_ARGS "general:gstreamer arguments"
+#define INI_ITEM_GENERAL_GST_EXCLUDED_ELEMENTS "general:gstreamer excluded elements"
+
+static const char* __get_delimiter(const char *ini_path)
+{
+ const char *delimiter = ",";
+
+ if (g_strcmp0(ini_path, INI_ITEM_GENERAL_GST_ARGS) == 0)
+ delimiter = "|";
+
+ return delimiter;
+}
+
+static void __ini_read_list(dictionary *dict, const char *ini_path, gchar ***list)
+{
+ const char *str;
+ gchar *strtmp = NULL;
+
+ RET_IF(dict == NULL, "dict is NULL");
+ RET_IF(ini_path == NULL, "ini_path is NULL");
+ RET_IF(list == NULL, "list is NULL");
+
+ str = iniparser_getstring(dict, ini_path, NULL);
+ if (str && strlen(str) > 0) {
+ strtmp = g_strdup(str);
+ g_strstrip(strtmp);
+ *list = g_strsplit(strtmp, __get_delimiter(ini_path), 10);
+ }
+
+ LOG_DEBUG("[%s] %s", ini_path, strtmp ? strtmp : "none");
+
+ g_free(strtmp);
+}
+
+int _load_ini(webrtc_s *webrtc)
+{
+ const char *dot_path;
+
+ RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
+
+ memset(&webrtc->ini, 0, sizeof(webrtc_ini_s));
+
+ webrtc->ini.dict = iniparser_load(WEBRTC_INI_PATH);
+ if (!webrtc->ini.dict)
+ LOG_WARNING("could not open ini[%s], use default values", WEBRTC_INI_PATH);
+
+ webrtc->ini.generate_dot = iniparser_getboolean(webrtc->ini.dict, INI_ITEM_GENERAL_DOT_GENERATE, DEFAULT_GENERATE_DOT);
+
+ dot_path = iniparser_getstring(webrtc->ini.dict, INI_ITEM_GENERAL_DOT_PATH, DEFAULT_DOT_PATH);
+ if (webrtc->ini.generate_dot) {
+ LOG_INFO("dot file will be stored in [%s]", dot_path);
+ g_setenv("GST_DEBUG_DUMP_DOT_DIR", dot_path, FALSE);
+ }
+
+ __ini_read_list(webrtc->ini.dict, INI_ITEM_GENERAL_GST_ARGS, &webrtc->ini.gst_args);
+
+ __ini_read_list(webrtc->ini.dict, INI_ITEM_GENERAL_GST_EXCLUDED_ELEMENTS, &webrtc->ini.gst_excluded_elements);
+
+ return WEBRTC_ERROR_NONE;
+}
+
+void _unload_ini(webrtc_s *webrtc)
+{
+ RET_IF(webrtc == NULL, "webrtc is NULL");
+ RET_IF(webrtc->ini.dict == NULL, "ini.dict is NULL");
+
+ g_strfreev(webrtc->ini.gst_args);
+ webrtc->ini.gst_args = NULL;
+
+ g_strfreev(webrtc->ini.gst_excluded_elements);
+ webrtc->ini.gst_excluded_elements = NULL;
+
+ iniparser_freedict(webrtc->ini.dict);
+ LOG_DEBUG("ini instance[%p] is freed", webrtc->ini.dict);
+ webrtc->ini.dict = NULL;
+}
#include "webrtc.h"
#include "webrtc_private.h"
-#define DEFAULT_DOT_FILE_NAME_PREFIX "webrtc"
-#define DEFAULT_DOT_DIRECTORY "/tmp"
+#define DEFAULT_DOT_FILE_NAME_PREFIX "webrtc"
static const char* __state_str[] = {
"IDLE",
return element;
}
-int _ini_load(webrtc_s *webrtc)
-{
- RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
-
- memset(&webrtc->ini, 0, sizeof(webrtc_ini_s));
-
- /* FIXME: load from ini file */
- /* set it TRUE temporarily until ini ready */
- webrtc->ini.generate_dot = TRUE;
-
- if (webrtc->ini.generate_dot) {
- /* FIXME: get path from ini */
- LOG_INFO("dot file will be stored in [%s]", DEFAULT_DOT_DIRECTORY);
- g_setenv("GST_DEBUG_DUMP_DOT_DIR", DEFAULT_DOT_DIRECTORY, FALSE);
- }
-
- return WEBRTC_ERROR_NONE;
-}
-
int _gst_init(webrtc_s *webrtc)
{
int i = 0;