Gathered common code for WFD Source and sink (attr and ini related code only) 75/24975/1
authorAndrey Shelest <a.shelest@samsung.com>
Thu, 24 Jul 2014 13:44:05 +0000 (16:44 +0300)
committerAndrey Shelest <a.shelest@samsung.com>
Thu, 24 Jul 2014 13:48:39 +0000 (16:48 +0300)
Change-Id: Ia818547f48c517b95513f5759031cfd2506483a6

12 files changed:
Makefile.am
common/Makefile.am [new file with mode: 0644]
common/include/mm_wfd_attrs.h [new file with mode: 0755]
common/include/mm_wfd_ini.h [new file with mode: 0644]
common/mm_wfd_attrs.c [new file with mode: 0755]
common/mm_wfd_ini.c [new file with mode: 0755]
configure.ac
src/Makefile.am
src/include/mm_wfd_attrs.h [deleted file]
src/include/mm_wfd_ini.h [deleted file]
src/mm_wfd_attrs.c [deleted file]
src/mm_wfd_ini.c [deleted file]

index 738333bd21d5d538a698d385bc8ba9caec93f0ea..63b365d5c30527d62e2f796c6bc3fa2bca7e02b4 100755 (executable)
@@ -1,5 +1,5 @@
 ACLOCAL_AMFLAGS='-I m4'
-SUBDIRS = src test proxy server
+SUBDIRS = common src test proxy server
 
 pcfiles = mm-wfd.pc
 pkgconfigdir = $(libdir)/pkgconfig
diff --git a/common/Makefile.am b/common/Makefile.am
new file mode 100644 (file)
index 0000000..f3dff63
--- /dev/null
@@ -0,0 +1,16 @@
+lib_LTLIBRARIES = libwfdcommon.la
+
+includelibwfdcommondir = $(includedir)/mmf
+
+libwfdcommon_la_SOURCES = mm_wfd_attrs.c mm_wfd_ini.c
+
+libwfdcommon_la_CFLAGS =  -I$(srcdir)/include \
+               -I$(top_builddir)/src/include \
+               $(GST_CFLAGS) \
+        $(GLIB_CFLAGS) \
+        $(MMCOMMON_CFLAGS) \
+               $(MMTA_CFLAGS)
+
+libwfdcommon_la_LIBADD = $(GLIB_LIBS) \
+        $(MMCOMMON_LIBS) \
+        $(INIPARSER_LIBS)
\ No newline at end of file
diff --git a/common/include/mm_wfd_attrs.h b/common/include/mm_wfd_attrs.h
new file mode 100755 (executable)
index 0000000..cb78fb8
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * libmm-wfd
+ *
+ * Copyright (c) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, ByungWook Jang <bw.jang@samsung.com>,
+ * Manoj Kumar K <manojkumar.k@samsung.com>, Hyunil Park <hyunil46.park@samsung.com>
+ *
+ * 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.
+ *
+ */
+
+#ifndef __MM_WFD_ATTRS_H__
+#define        __MM_WFD_ATTRS_H__
+
+
+#include <mm_attrs_private.h>
+#include <mm_attrs.h>
+#include <mm_wfd_priv.h>
+#include <mm_wfd.h>
+
+/* general */
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(arr)                (sizeof(arr) / sizeof((arr)[0]))
+#endif
+#define MMWFD_MAX_INT  (2147483647)
+
+MMHandleType _mmwfd_construct_attribute(MMHandleType hwfd);
+void  _mmwfd_deconstruct_attribute( MMHandleType hwfd);
+int _mmwfd_set_attribute(MMHandleType hwfd,  char **err_atr_name, const char *attribute_name, va_list args_list);
+int _mmwfd_get_attributes_info(MMHandleType handle,  const char *attribute_name, MMWfdAttrsInfo *dst_info);
+int _mmwfd_get_attribute(MMHandleType handle,  char **err_attr_name, const char *attribute_name, va_list args_list);
+#endif /* __MM_WFD_ATTRS_H__ */
+
+
+
+
diff --git a/common/include/mm_wfd_ini.h b/common/include/mm_wfd_ini.h
new file mode 100644 (file)
index 0000000..f66e06b
--- /dev/null
@@ -0,0 +1,175 @@
+/*
+ * libmm-wfd
+ *
+ * Copyright (c) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, ByungWook Jang <bw.jang@samsung.com>,
+ * Manoj Kumar K <manojkumar.k@samsung.com>, Hyunil Park <hyunil46.park@samsung.com>
+ *
+ * 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.
+ *
+ */
+
+#ifndef __MM_WFD_INI_H__
+#define __MM_WFD_INI_H__
+
+#include <glib.h>
+#include <rtsp-client.h>
+
+#ifdef __cplusplus
+  extern "C" {
+#endif
+
+
+#define MM_WFD_INI_DEFAULT_PATH        "/usr/etc/mmfw_wfd.ini"
+
+#define WFD_INI() mm_wfd_ini_get_structure()
+
+#define WFD_INI_MAX_STRLEN     80
+
+/* NOTE : MMPlayer has no initalizing API for library itself
+ * so we cannot decide when those ini values to be released.
+ * this is the reason of all string items are static array.
+ * make it do with malloc when MMPlayerInitialize() API created
+ * before that time, we should be careful with size limitation
+ * of each string item.
+ */
+
+/* @ mark means the item has tested */
+typedef struct __mm_wfd_ini
+{
+  /* general */
+  WFD_INI_VSRC_ELEMENT videosrc_element;
+  gint session_mode;
+  WFD_INI_VSINK_ELEMENT videosink_element; // @
+  gchar name_of_video_converter[WFD_INI_MAX_STRLEN];
+  gboolean skip_rescan; // @
+  gboolean generate_dot; // @
+  gboolean provide_clock; // @
+  gint live_state_change_timeout; // @
+  gint localplayback_state_change_timeout; // @
+  gint delay_before_repeat;
+  gint eos_delay; // @
+  gint videobitrate;
+  gint mtu_size;
+
+  gchar gst_param[5][256]; // @
+  gchar exclude_element_keyword[10][WFD_INI_MAX_STRLEN];
+  gboolean async_start;
+  gboolean disable_segtrap;
+  gchar infile[256]; // @
+
+  /* hw accelation */
+  gboolean use_video_hw_accel; // @
+} mm_wfd_ini_t;
+
+/* default values if each values are not specified in inifile */
+/* general */
+#define DEFAULT_SKIP_RESCAN                            TRUE
+#define DEFAULT_GENERATE_DOT                           FALSE
+#define DEFAULT_PROVIDE_CLOCK                          TRUE
+#define DEFAULT_DELAY_BEFORE_REPEAT                    50 /* msec */
+#define DEFAULT_EOS_DELAY                              150 /* msec */
+#define DEFAULT_VIDEOSINK                              WFD_INI_VSINK_XVIMAGESINK
+#define DEFAULT_VIDEOSRC                               WFD_INI_VSRC_XVIMAGESRC
+#define DEFAULT_VIDEO_BITRATE                          3072000 /* bps */
+#define DEFAULT_MTU_SIZE        1400 /* bytes */
+#define DEFAULT_SESSION_MODE                           0
+#define DEFAULT_GST_PARAM                              ""
+#define DEFAULT_EXCLUDE_KEYWORD                                ""
+#define DEFAULT_ASYNC_START                            TRUE
+#define DEFAULT_DISABLE_SEGTRAP                                TRUE
+#define DEFAULT_VIDEO_CONVERTER                                ""
+#define DEFAULT_LIVE_STATE_CHANGE_TIMEOUT              30 /* sec */
+#define DEFAULT_LOCALPLAYBACK_STATE_CHANGE_TIMEOUT     10 /* sec */
+/* hw accel */
+#define DEFAULT_USE_VIDEO_HW_ACCEL     FALSE
+#define DEFAULT_INPUT_FILE ""
+
+/* NOTE : following content should be same with above default values */
+/* FIXIT : need smarter way to generate default ini file. */
+/* FIXIT : finally, it should be an external file */
+#define MM_WFD_DEFAULT_INI \
+" \
+[general] \n\
+\n\
+; set default video source element\n\
+; 0: xvimagesrc, 1: filesrc, 2: camerasrc, 3: videotestsrc\n\
+videosrc element = 0 \n\
+\n\
+; sending video only mirroring mode\n\
+; 0: audio-video-muxed sending, 1:video-only, 2:audio-only, 3:audio-video-saperate\n\
+session_mode = 0 \n\
+disable segtrap = yes ; same effect with --gst-disable-segtrap \n\
+\n\
+; set default video sink when video is rendered on the WFD source as well\n\
+; 0:v4l2sink, 1:ximagesink, 2:xvimagesink, 3:fakesink 4:evasimagesink 5:glimagesink\n\
+videosink element = 2 \n\
+\n\
+videobitrate value = 6144000 \n\
+\n\
+mtu_size value = 1400 \n\
+\n\
+video converter element = \n\
+\n\
+; if yes. gstreamer will not update registry \n\
+skip rescan = yes \n\
+\n\
+delay before repeat = 50 ; msec\n\
+\n\
+; comma separated list of tocken which elemnts has it in its name will not be used \n\
+element exclude keyword = \n\
+\n\
+async start = yes \n\
+\n\
+; parameters for initializing gstreamer \n\
+gstparam1 = \n\
+gstparam2 = \n\
+gstparam3 = \n\
+gstparam4 = \n\
+gstparam5 = \n\
+\n\
+; generating dot file representing pipeline state \n\
+generate dot = no \n\
+\n\
+; parameter for clock provide in audiosink \n\
+provide clock = yes \n\
+\n\
+; allowed timeout for changing pipeline state \n\
+live state change timeout = 30 ; sec \n\
+localplayback state change timeout = 4 ; sec \n\
+\n\
+; delay in msec for sending EOS \n\
+eos delay = 150 ; msec \n\
+\n\
+\n\
+[hw accelation] \n\
+use video hw accel = yes \n\
+\n\
+\n\
+\n\
+"
+
+int
+mm_wfd_ini_load(void);
+
+mm_wfd_ini_t*
+mm_wfd_ini_get_structure(void);
+
+
+#ifdef __cplusplus
+  }
+#endif
+
+#endif
+
diff --git a/common/mm_wfd_attrs.c b/common/mm_wfd_attrs.c
new file mode 100755 (executable)
index 0000000..d0f25f3
--- /dev/null
@@ -0,0 +1,320 @@
+/*
+ * libmm-wfd
+ *
+ * Copyright (c) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, ByungWook Jang <bw.jang@samsung.com>,
+ * Manoj Kumar K <manojkumar.k@samsung.com>, Hyunil Park <hyunil46.park@samsung.com>
+ *
+ * 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 "mm_wfd_attrs.h"
+
+typedef struct{
+       char *name;
+       int value_type;
+       int flags;                              // r, w
+       void *default_value;
+       int valid_type;                 // validity type
+       int value_min;                  //<- set validity value range
+       int value_max;          //->
+}MMWfdAttrsSpec;
+
+static gboolean __mmwfd_apply_attribute(MMHandleType handle, const char *attribute_name);
+
+MMHandleType
+_mmwfd_construct_attribute(MMHandleType handle)
+{
+       int idx = 0;
+       MMHandleType attrs = 0;
+       int num_of_attrs = 0;
+       mmf_attrs_construct_info_t *base = NULL;
+
+       debug_fenter();
+
+       return_val_if_fail(handle, (MMHandleType)NULL);
+
+       MMWfdAttrsSpec wfd_attrs[] =
+       {
+               {
+                       "server_ip",
+                       MM_ATTRS_TYPE_STRING,
+                       MM_ATTRS_FLAG_RW,
+                       (void *)"127.0.0.1",
+                       MM_ATTRS_VALID_TYPE_NONE,
+                       0,
+                       0
+               },
+
+               {
+                       "server_port",
+                       MM_ATTRS_TYPE_STRING,
+                       MM_ATTRS_FLAG_RW,
+                       (void *)"8554",
+                       MM_ATTRS_VALID_TYPE_NONE,
+                       0,
+                       0
+               },
+
+               {
+                       "max_client_count",
+                       MM_ATTRS_TYPE_INT,
+                       MM_ATTRS_FLAG_RW,
+                       (void *)1,
+                       MM_ATTRS_VALID_TYPE_INT_RANGE,
+                       0,
+                       10
+               },
+
+       };
+
+       num_of_attrs = ARRAY_SIZE(wfd_attrs);
+
+       base = (mmf_attrs_construct_info_t* )malloc(num_of_attrs * sizeof(mmf_attrs_construct_info_t));
+
+       if ( !base )
+       {
+               debug_error("Cannot create mmwfd attribute\n");
+               goto ERROR;
+       }
+
+       /* initialize values of attributes */
+       for ( idx = 0; idx < num_of_attrs; idx++ )
+       {
+               base[idx].name = wfd_attrs[idx].name;
+               base[idx].value_type = wfd_attrs[idx].value_type;
+               base[idx].flags = wfd_attrs[idx].flags;
+               base[idx].default_value = wfd_attrs[idx].default_value;
+       }
+
+       attrs = mmf_attrs_new_from_data(
+                                       "mmwfd_attrs",
+                                       base,
+                                       num_of_attrs,
+                                       NULL,
+                                       NULL);
+
+       MMWFD_FREEIF(base);
+
+       if ( !attrs )
+       {
+               debug_error("Cannot create mmwfd attribute\n");
+               goto ERROR;
+       }
+
+       /* set validity type and range */
+       for ( idx = 0; idx < num_of_attrs; idx++ )
+       {
+               switch ( wfd_attrs[idx].valid_type)
+               {
+                       case MM_ATTRS_VALID_TYPE_INT_RANGE:
+                       {
+                               mmf_attrs_set_valid_type (attrs, idx, MM_ATTRS_VALID_TYPE_INT_RANGE);
+                               mmf_attrs_set_valid_range (attrs, idx,
+                                               wfd_attrs[idx].value_min,
+                                               wfd_attrs[idx].value_max,
+                                               (int)wfd_attrs[idx].default_value);
+                       }
+                       break;
+
+                       case MM_ATTRS_VALID_TYPE_INT_ARRAY:
+                       case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
+                       case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
+                       default:
+                       break;
+               }
+       }
+
+       debug_fleave();
+
+       return attrs;
+
+ERROR:
+       _mmwfd_deconstruct_attribute(handle);
+
+       return (MMHandleType)NULL;
+}
+
+void
+_mmwfd_deconstruct_attribute(MMHandleType handle) // @
+{
+       debug_fenter();
+
+       mm_wfd_t* wfd = (mm_wfd_t*)handle;
+
+       return_if_fail( wfd );
+
+       if (wfd->attrs)
+       {
+               mmf_attrs_free (wfd->attrs);
+               wfd->attrs = 0;
+       }
+
+       debug_fleave();
+}
+
+
+int
+_mmwfd_get_attribute(MMHandleType handle,  char **err_attr_name, const char *attribute_name, va_list args_list)
+{
+       int result = MM_ERROR_NONE;
+       MMHandleType attrs = 0;
+
+       debug_fenter();
+
+       /* NOTE : Don't need to check err_attr_name because it can be set NULL */
+       /* if it's not want to know it. */
+       return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
+       return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
+
+       attrs = MMWFD_GET_ATTRS(handle);
+
+       return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT);
+
+       result = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, args_list);
+
+       if ( result != MM_ERROR_NONE)
+               debug_error("failed to get %s attribute\n", attribute_name);
+
+       debug_fleave();
+
+       return result;
+}
+
+int
+_mmwfd_set_attribute(MMHandleType handle,  char **err_attr_name, const char *attribute_name, va_list args_list)
+{
+       int result = MM_ERROR_NONE;
+       MMHandleType attrs = 0;
+
+       debug_fenter();
+
+       /* NOTE : Don't need to check err_attr_name because it can be set NULL */
+       /* if it's not want to know it. */
+       return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
+       return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
+
+       attrs = MMWFD_GET_ATTRS(handle);
+
+       return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT);
+
+       /* set attributes and commit them */
+       result = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, args_list);
+
+       if ( result != MM_ERROR_NONE)
+       {
+               debug_error("failed to set %s attribute\n", attribute_name);
+               return result;
+       }
+
+       __mmwfd_apply_attribute(handle, attribute_name);
+
+       debug_fleave();
+
+       return result;
+}
+
+
+static gboolean
+__mmwfd_apply_attribute(MMHandleType handle, const char *attribute_name)
+{
+       MMHandleType attrs = 0;
+       mm_wfd_t* wfd = 0;
+
+       debug_fenter();
+
+       return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
+       return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
+
+       attrs = MMWFD_GET_ATTRS(handle);;
+
+       return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT);
+
+       wfd = (mm_wfd_t*)handle;
+
+       // TODO: This function is not useful at this moment
+
+       debug_fleave();
+
+       return TRUE;
+}
+
+int
+_mmwfd_get_attributes_info(MMHandleType handle,  const char *attribute_name, MMWfdAttrsInfo *dst_info)
+{
+       int result = MM_ERROR_NONE;
+       MMHandleType attrs = 0;
+       MMAttrsInfo src_info = {0, };
+
+       debug_fenter();
+
+       return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
+       return_val_if_fail(dst_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
+       return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
+
+       attrs = MMWFD_GET_ATTRS(handle);
+
+       return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT);
+
+       result = mm_attrs_get_info_by_name(attrs, attribute_name, &src_info);
+
+       if ( result != MM_ERROR_NONE)
+       {
+               debug_error("failed to get attribute info\n");
+               return result;
+       }
+
+       memset(dst_info, 0x00, sizeof(MMWfdAttrsInfo));
+
+       dst_info->type = src_info.type;
+       dst_info->flag = src_info.flag;
+       dst_info->validity_type= src_info.validity_type;
+
+       switch(src_info.validity_type)
+       {
+               case MM_ATTRS_VALID_TYPE_INT_ARRAY:
+                       dst_info->int_array.array = src_info.int_array.array;
+                       dst_info->int_array.count = src_info.int_array.count;
+                       dst_info->int_array.d_val = src_info.int_array.dval;
+               break;
+
+               case MM_ATTRS_VALID_TYPE_INT_RANGE:
+                       dst_info->int_range.min = src_info.int_range.min;
+                       dst_info->int_range.max = src_info.int_range.max;
+                       dst_info->int_range.d_val = src_info.int_range.dval;
+               break;
+
+               case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
+                       dst_info->double_array.array = src_info.double_array.array;
+                       dst_info->double_array.count = src_info.double_array.count;
+                       dst_info->double_array.d_val = src_info.double_array.dval;
+               break;
+
+               case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
+                       dst_info->double_range.min = src_info.double_range.min;
+                       dst_info->double_range.max = src_info.double_range.max;
+                       dst_info->double_range.d_val = src_info.double_range.dval;
+               break;
+
+               default:
+               break;
+       }
+
+       debug_fleave();
+
+       return result;
+}
+
+
diff --git a/common/mm_wfd_ini.c b/common/mm_wfd_ini.c
new file mode 100755 (executable)
index 0000000..a7cf47d
--- /dev/null
@@ -0,0 +1,301 @@
+/*
+ * libmm-wfd
+ *
+ * Copyright (c) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, ByungWook Jang <bw.jang@samsung.com>,
+ * Manoj Kumar K <manojkumar.k@samsung.com>, Hyunil Park <hyunil46.park@samsung.com>
+ *
+ * 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.
+ *
+ */
+
+#ifndef __MM_WFD_INI_C__
+#define __MM_WFD_INI_C__ // TODO: why macro is needed ??
+
+#include <glib.h>
+#include <stdlib.h>
+#include "iniparser.h"
+#include <mm_wfd_ini.h>
+#include "mm_debug.h"
+#include <mm_error.h>
+#include <glib/gstdio.h>
+
+/* global variables here */
+static mm_wfd_ini_t g_wfd_ini;
+static void __mm_wfd_ini_check_ini_status(void);
+static void    __get_string_list(gchar** out_list, gchar* str);
+
+/* macro */
+#define MMWFD_INI_GET_STRING( x_item, x_ini, x_default ) \
+do \
+{ \
+  gchar* str = iniparser_getstring(dict, x_ini, x_default); \
+ \
+  if ( str &&  \
+    ( strlen( str ) > 1 ) && \
+    ( strlen( str ) < WFD_INI_MAX_STRLEN ) ) \
+  { \
+    strcpy ( x_item, str ); \
+  } \
+  else \
+  { \
+    strcpy ( x_item, x_default ); \
+  } \
+}while(0)
+
+int
+mm_wfd_ini_load(void)
+{
+  static gboolean loaded = FALSE;
+  dictionary * dict = NULL;
+  gint idx = 0;
+
+  if ( loaded )
+  return MM_ERROR_NONE;
+
+  dict = NULL;
+
+  /* disabling ini parsing for launching */
+  #if 1 //debianize
+  /* get wfd ini status because system will be crashed
+  * if ini file is corrupted.
+  */
+  /* FIXIT : the api actually deleting illregular ini. but the function name said it's just checking. */
+  __mm_wfd_ini_check_ini_status();
+
+  /* first, try to load existing ini file */
+  dict = iniparser_load(MM_WFD_INI_DEFAULT_PATH);
+
+  /* if no file exists. create one with set of default values */
+  if ( !dict )
+  {
+#if 0
+    debug_log("No inifile found. wfd will create default inifile.\n");
+    if ( FALSE == __generate_default_ini() )
+    {
+      debug_warning("Creating default inifile failed. Player will use default values.\n");
+    }
+    else
+    {
+      /* load default ini */
+      dict = iniparser_load(MM_WFD_INI_DEFAULT_PATH);
+    }
+#else
+    debug_log("No inifile found. \n");
+
+    return MM_ERROR_FILE_NOT_FOUND;
+#endif
+  }
+#endif
+
+  /* get ini values */
+  memset( &g_wfd_ini, 0, sizeof(mm_wfd_ini_t) );
+
+  if ( dict ) /* if dict is available */
+  {
+    /* general */
+    g_wfd_ini.videosrc_element = iniparser_getint(dict, "general:videosrc element", DEFAULT_VIDEOSRC);
+    g_wfd_ini.session_mode = iniparser_getint(dict, "general:session_mode", DEFAULT_SESSION_MODE);
+    g_wfd_ini.videosink_element = iniparser_getint(dict, "general:videosink element", DEFAULT_VIDEOSINK);
+    g_wfd_ini.disable_segtrap = iniparser_getboolean(dict, "general:disable segtrap", DEFAULT_DISABLE_SEGTRAP);
+    g_wfd_ini.skip_rescan = iniparser_getboolean(dict, "general:skip rescan", DEFAULT_SKIP_RESCAN);
+    g_wfd_ini.videosink_element = iniparser_getint(dict, "general:videosink element", DEFAULT_VIDEOSINK);
+    g_wfd_ini.videobitrate = iniparser_getint(dict, "general:videobitrate value", DEFAULT_VIDEO_BITRATE);
+    g_wfd_ini.mtu_size = iniparser_getint(dict, "general:mtu_size value", DEFAULT_MTU_SIZE);
+    g_wfd_ini.generate_dot = iniparser_getboolean(dict, "general:generate dot", DEFAULT_GENERATE_DOT);
+    g_wfd_ini.provide_clock= iniparser_getboolean(dict, "general:provide clock", DEFAULT_PROVIDE_CLOCK);
+    g_wfd_ini.live_state_change_timeout = iniparser_getint(dict, "general:live state change timeout", DEFAULT_LIVE_STATE_CHANGE_TIMEOUT);
+    g_wfd_ini.localplayback_state_change_timeout = iniparser_getint(dict, "general:localplayback state change timeout", DEFAULT_LOCALPLAYBACK_STATE_CHANGE_TIMEOUT);
+    g_wfd_ini.eos_delay = iniparser_getint(dict, "general:eos delay", DEFAULT_EOS_DELAY);
+    g_wfd_ini.async_start = iniparser_getboolean(dict, "general:async start", DEFAULT_ASYNC_START);
+
+    g_wfd_ini.delay_before_repeat = iniparser_getint(dict, "general:delay before repeat", DEFAULT_DELAY_BEFORE_REPEAT);
+
+    MMWFD_INI_GET_STRING( g_wfd_ini.name_of_video_converter, "general:video converter element", DEFAULT_VIDEO_CONVERTER );
+
+    __get_string_list( (gchar**) g_wfd_ini.exclude_element_keyword,
+      iniparser_getstring(dict, "general:element exclude keyword", DEFAULT_EXCLUDE_KEYWORD));
+
+    MMWFD_INI_GET_STRING( g_wfd_ini.gst_param[0], "general:gstparam1", DEFAULT_GST_PARAM );
+    MMWFD_INI_GET_STRING( g_wfd_ini.gst_param[1], "general:gstparam2", DEFAULT_GST_PARAM );
+    MMWFD_INI_GET_STRING( g_wfd_ini.gst_param[2], "general:gstparam3", DEFAULT_GST_PARAM );
+    MMWFD_INI_GET_STRING( g_wfd_ini.gst_param[3], "general:gstparam4", DEFAULT_GST_PARAM );
+    MMWFD_INI_GET_STRING( g_wfd_ini.gst_param[4], "general:gstparam5", DEFAULT_GST_PARAM );
+
+    MMWFD_INI_GET_STRING( g_wfd_ini.infile, "general:input file", DEFAULT_INPUT_FILE );
+
+    /* hw accelation */
+    g_wfd_ini.use_video_hw_accel = iniparser_getboolean(dict, "hw accelation:use video hw accel", DEFAULT_USE_VIDEO_HW_ACCEL);
+  }
+  else /* if dict is not available just fill the structure with default value */
+  {
+    debug_warning("failed to load ini. using hardcoded default\n");
+
+    /* general */
+    g_wfd_ini.videosrc_element = DEFAULT_VIDEOSRC;
+    g_wfd_ini.session_mode = DEFAULT_SESSION_MODE;
+    g_wfd_ini.disable_segtrap = DEFAULT_DISABLE_SEGTRAP;
+    g_wfd_ini.skip_rescan = DEFAULT_SKIP_RESCAN;
+    g_wfd_ini.videosink_element = DEFAULT_VIDEOSINK;
+    g_wfd_ini.videobitrate = DEFAULT_VIDEO_BITRATE;
+    g_wfd_ini.mtu_size = DEFAULT_MTU_SIZE;
+    g_wfd_ini.generate_dot = DEFAULT_GENERATE_DOT;
+    g_wfd_ini.provide_clock= DEFAULT_PROVIDE_CLOCK;
+    g_wfd_ini.live_state_change_timeout = DEFAULT_LIVE_STATE_CHANGE_TIMEOUT;
+    g_wfd_ini.localplayback_state_change_timeout = DEFAULT_LOCALPLAYBACK_STATE_CHANGE_TIMEOUT;
+    g_wfd_ini.eos_delay = DEFAULT_EOS_DELAY;
+    g_wfd_ini.async_start = DEFAULT_ASYNC_START;
+    g_wfd_ini.delay_before_repeat = DEFAULT_DELAY_BEFORE_REPEAT;
+
+    strcpy( g_wfd_ini.name_of_video_converter, DEFAULT_VIDEO_CONVERTER);
+
+    {
+      __get_string_list( (gchar**) g_wfd_ini.exclude_element_keyword, DEFAULT_EXCLUDE_KEYWORD);
+    }
+
+
+    strcpy( g_wfd_ini.gst_param[0], DEFAULT_GST_PARAM );
+    strcpy( g_wfd_ini.gst_param[1], DEFAULT_GST_PARAM );
+    strcpy( g_wfd_ini.gst_param[2], DEFAULT_GST_PARAM );
+    strcpy( g_wfd_ini.gst_param[3], DEFAULT_GST_PARAM );
+    strcpy( g_wfd_ini.gst_param[4], DEFAULT_GST_PARAM );
+
+    strcpy( g_wfd_ini.infile, DEFAULT_INPUT_FILE );
+
+    /* hw accelation */
+    g_wfd_ini.use_video_hw_accel = DEFAULT_USE_VIDEO_HW_ACCEL;
+
+  }
+
+  /* free dict as we got our own structure */
+  iniparser_freedict (dict);
+
+  loaded = TRUE;
+
+  /* The simulator uses a separate ini file. */
+  //__mm_wfd_ini_force_setting();
+
+
+  /* dump structure */
+  debug_log("wfd settings -----------------------------------\n");
+
+  /* general */
+  debug_log("videosrc element : %d\n", g_wfd_ini.videosrc_element);
+  debug_log("session mode in mirroring : %d\n", g_wfd_ini.session_mode);
+  debug_log("disable_segtrap : %d\n", g_wfd_ini.disable_segtrap);
+  debug_log("skip rescan : %d\n", g_wfd_ini.skip_rescan);
+  debug_log("videosink element(0:v4l2sink, 1:ximagesink, 2:xvimagesink, 3:fakesink) : %d\n", g_wfd_ini.videosink_element);
+  debug_log("video_bitrate : %d\n", g_wfd_ini.videobitrate);
+  debug_log("mtu_size : %d\n", g_wfd_ini.mtu_size);
+  debug_log("generate_dot : %d\n", g_wfd_ini.generate_dot);
+  debug_log("provide_clock : %d\n", g_wfd_ini.provide_clock);
+  debug_log("live_state_change_timeout(sec) : %d\n", g_wfd_ini.live_state_change_timeout);
+  debug_log("localplayback_state_change_timeout(sec) : %d\n", g_wfd_ini.localplayback_state_change_timeout);
+  debug_log("eos_delay(msec) : %d\n", g_wfd_ini.eos_delay);
+  debug_log("delay_before_repeat(msec) : %d\n", g_wfd_ini.delay_before_repeat);
+  debug_log("name_of_video_converter : %s\n", g_wfd_ini.name_of_video_converter);
+  debug_log("async_start : %d\n", g_wfd_ini.async_start);
+
+  debug_log("gst_param1 : %s\n", g_wfd_ini.gst_param[0]);
+  debug_log("gst_param2 : %s\n", g_wfd_ini.gst_param[1]);
+  debug_log("gst_param3 : %s\n", g_wfd_ini.gst_param[2]);
+  debug_log("gst_param4 : %s\n", g_wfd_ini.gst_param[3]);
+  debug_log("gst_param5 : %s\n", g_wfd_ini.gst_param[4]);
+
+  debug_log("input file : %s\n", g_wfd_ini.infile);
+
+  for ( idx = 0; g_wfd_ini.exclude_element_keyword[idx][0] != '\0'; idx++ )
+  {
+       debug_log("exclude_element_keyword [%d] : %s\n", idx, g_wfd_ini.exclude_element_keyword[idx]);
+  }
+
+  /* hw accel */
+  debug_log("use_video_hw_accel : %d\n", g_wfd_ini.use_video_hw_accel);
+  
+  debug_log("---------------------------------------------------\n");
+
+  return MM_ERROR_NONE;
+}
+
+
+static
+void __mm_wfd_ini_check_ini_status(void)
+{
+  struct stat ini_buff;
+  
+  if ( g_stat(MM_WFD_INI_DEFAULT_PATH, &ini_buff) < 0 )
+  {
+    debug_warning("failed to get wfd ini status\n");
+  }
+  else
+  {
+    if ( ini_buff.st_size < 5 )
+    {
+      debug_warning("wfd.ini file size=%d, Corrupted! So, Removed\n", (int)ini_buff.st_size);
+      g_remove( MM_WFD_INI_DEFAULT_PATH );
+    }
+  }
+}
+
+
+mm_wfd_ini_t*
+mm_wfd_ini_get_structure(void)
+{
+  return &g_wfd_ini;
+}
+
+
+static
+void __get_string_list(gchar** out_list, gchar* str)
+{
+  gchar** list = NULL;
+  gchar** walk = NULL;
+  gint i = 0;
+  gchar* strtmp = NULL;
+
+  if ( ! str )
+  return;
+
+  if ( strlen( str ) < 1 )
+    return;
+
+  strtmp = g_strdup (str);
+
+  /* trimming. it works inplace */
+  g_strstrip( strtmp );
+
+  /* split */
+  list = g_strsplit( strtmp, ",", 10 );
+
+  g_return_if_fail ( list != NULL );
+
+  /* copy list */
+  for( walk = list; *walk; walk++ )
+  {
+    strncpy( g_wfd_ini.exclude_element_keyword[i], *walk, (WFD_INI_MAX_STRLEN - 1) );
+    g_strstrip( g_wfd_ini.exclude_element_keyword[i] );
+    g_wfd_ini.exclude_element_keyword[i][WFD_INI_MAX_STRLEN - 1] = '\0';
+    i++;
+  }
+
+  /* mark last item to NULL */
+  g_wfd_ini.exclude_element_keyword[i][0] = '\0';
+
+  g_strfreev( list );
+  if (strtmp)
+  g_free (strtmp);
+}
+
+#endif
+
index 96063dfe6486c9e82ccc5cad5fe5e2a6e99b0ad6..2463d07c9aacf5a385dfbaf1487b3741a099187e 100755 (executable)
@@ -124,6 +124,7 @@ AC_ARG_ENABLE(sdk, AC_HELP_STRING([--enable-sdk], [sdk build]),
 AM_CONDITIONAL([IS_SDK], [test "x$IS_SDK" = "xyes"])
 
 AC_CONFIG_FILES([Makefile
+                common/Makefile
                 src/Makefile
                 test/Makefile
                 server/Makefile
index 1196bdec7192f6ffd39211a7bad4cce559546799..7b6bc4edca3808fb5d4d07e7213da5482d8691db 100755 (executable)
@@ -36,26 +36,24 @@ includelibmmfwfddir = $(includedir)/mmf
 includelibmmfwfd_HEADERS = include/mm_wfd.h
 
 libmmfwfd_la_SOURCES = mm_wfd.c \
-               mm_wfd_priv.c \
-               mm_wfd_ini.c \
-               mm_wfd_attrs.c
+               mm_wfd_priv.c
 
 libmmfwfd_la_CFLAGS =  -I$(srcdir)/include \
                          $(MMCOMMON_CFLAGS) \
                          $(MMTA_CFLAGS) \
-                         $(GST_CFLAGS)
+                         $(GST_CFLAGS) \
+                         -I$(top_builddir)/common/include
 
 libmmfwfd_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
 
-noinst_HEADERS = include/mm_wfd_ini.h \
-                include/mm_wfd_priv.h \
-                include/mm_wfd_attrs.h
+noinst_HEADERS = include/mm_wfd_priv.h
                 
 libmmfwfd_la_LIBADD = $(GST_LIBS) \
                $(MMTA_LIBS) \
                $(MMCOMMON_LIBS) \
                $(GST_APP_LIBS) \
     -lmmfwfd_rtsp_server \
+               $(top_builddir)/common/libwfdcommon.la \
                $(INIPARSER_LIBS)
 
 libmmfwfd_la_CFLAGS += $(MMLOG_CFLAGS) -DMMF_LOG_OWNER=0x02000000 -DMMF_DEBUG_PREFIX=\"MMF-WFD\" -D_INTERNAL_SESSION_MANAGER_
diff --git a/src/include/mm_wfd_attrs.h b/src/include/mm_wfd_attrs.h
deleted file mode 100755 (executable)
index cb78fb8..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * libmm-wfd
- *
- * Copyright (c) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, ByungWook Jang <bw.jang@samsung.com>,
- * Manoj Kumar K <manojkumar.k@samsung.com>, Hyunil Park <hyunil46.park@samsung.com>
- *
- * 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.
- *
- */
-
-#ifndef __MM_WFD_ATTRS_H__
-#define        __MM_WFD_ATTRS_H__
-
-
-#include <mm_attrs_private.h>
-#include <mm_attrs.h>
-#include <mm_wfd_priv.h>
-#include <mm_wfd.h>
-
-/* general */
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(arr)                (sizeof(arr) / sizeof((arr)[0]))
-#endif
-#define MMWFD_MAX_INT  (2147483647)
-
-MMHandleType _mmwfd_construct_attribute(MMHandleType hwfd);
-void  _mmwfd_deconstruct_attribute( MMHandleType hwfd);
-int _mmwfd_set_attribute(MMHandleType hwfd,  char **err_atr_name, const char *attribute_name, va_list args_list);
-int _mmwfd_get_attributes_info(MMHandleType handle,  const char *attribute_name, MMWfdAttrsInfo *dst_info);
-int _mmwfd_get_attribute(MMHandleType handle,  char **err_attr_name, const char *attribute_name, va_list args_list);
-#endif /* __MM_WFD_ATTRS_H__ */
-
-
-
-
diff --git a/src/include/mm_wfd_ini.h b/src/include/mm_wfd_ini.h
deleted file mode 100644 (file)
index f66e06b..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * libmm-wfd
- *
- * Copyright (c) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, ByungWook Jang <bw.jang@samsung.com>,
- * Manoj Kumar K <manojkumar.k@samsung.com>, Hyunil Park <hyunil46.park@samsung.com>
- *
- * 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.
- *
- */
-
-#ifndef __MM_WFD_INI_H__
-#define __MM_WFD_INI_H__
-
-#include <glib.h>
-#include <rtsp-client.h>
-
-#ifdef __cplusplus
-  extern "C" {
-#endif
-
-
-#define MM_WFD_INI_DEFAULT_PATH        "/usr/etc/mmfw_wfd.ini"
-
-#define WFD_INI() mm_wfd_ini_get_structure()
-
-#define WFD_INI_MAX_STRLEN     80
-
-/* NOTE : MMPlayer has no initalizing API for library itself
- * so we cannot decide when those ini values to be released.
- * this is the reason of all string items are static array.
- * make it do with malloc when MMPlayerInitialize() API created
- * before that time, we should be careful with size limitation
- * of each string item.
- */
-
-/* @ mark means the item has tested */
-typedef struct __mm_wfd_ini
-{
-  /* general */
-  WFD_INI_VSRC_ELEMENT videosrc_element;
-  gint session_mode;
-  WFD_INI_VSINK_ELEMENT videosink_element; // @
-  gchar name_of_video_converter[WFD_INI_MAX_STRLEN];
-  gboolean skip_rescan; // @
-  gboolean generate_dot; // @
-  gboolean provide_clock; // @
-  gint live_state_change_timeout; // @
-  gint localplayback_state_change_timeout; // @
-  gint delay_before_repeat;
-  gint eos_delay; // @
-  gint videobitrate;
-  gint mtu_size;
-
-  gchar gst_param[5][256]; // @
-  gchar exclude_element_keyword[10][WFD_INI_MAX_STRLEN];
-  gboolean async_start;
-  gboolean disable_segtrap;
-  gchar infile[256]; // @
-
-  /* hw accelation */
-  gboolean use_video_hw_accel; // @
-} mm_wfd_ini_t;
-
-/* default values if each values are not specified in inifile */
-/* general */
-#define DEFAULT_SKIP_RESCAN                            TRUE
-#define DEFAULT_GENERATE_DOT                           FALSE
-#define DEFAULT_PROVIDE_CLOCK                          TRUE
-#define DEFAULT_DELAY_BEFORE_REPEAT                    50 /* msec */
-#define DEFAULT_EOS_DELAY                              150 /* msec */
-#define DEFAULT_VIDEOSINK                              WFD_INI_VSINK_XVIMAGESINK
-#define DEFAULT_VIDEOSRC                               WFD_INI_VSRC_XVIMAGESRC
-#define DEFAULT_VIDEO_BITRATE                          3072000 /* bps */
-#define DEFAULT_MTU_SIZE        1400 /* bytes */
-#define DEFAULT_SESSION_MODE                           0
-#define DEFAULT_GST_PARAM                              ""
-#define DEFAULT_EXCLUDE_KEYWORD                                ""
-#define DEFAULT_ASYNC_START                            TRUE
-#define DEFAULT_DISABLE_SEGTRAP                                TRUE
-#define DEFAULT_VIDEO_CONVERTER                                ""
-#define DEFAULT_LIVE_STATE_CHANGE_TIMEOUT              30 /* sec */
-#define DEFAULT_LOCALPLAYBACK_STATE_CHANGE_TIMEOUT     10 /* sec */
-/* hw accel */
-#define DEFAULT_USE_VIDEO_HW_ACCEL     FALSE
-#define DEFAULT_INPUT_FILE ""
-
-/* NOTE : following content should be same with above default values */
-/* FIXIT : need smarter way to generate default ini file. */
-/* FIXIT : finally, it should be an external file */
-#define MM_WFD_DEFAULT_INI \
-" \
-[general] \n\
-\n\
-; set default video source element\n\
-; 0: xvimagesrc, 1: filesrc, 2: camerasrc, 3: videotestsrc\n\
-videosrc element = 0 \n\
-\n\
-; sending video only mirroring mode\n\
-; 0: audio-video-muxed sending, 1:video-only, 2:audio-only, 3:audio-video-saperate\n\
-session_mode = 0 \n\
-disable segtrap = yes ; same effect with --gst-disable-segtrap \n\
-\n\
-; set default video sink when video is rendered on the WFD source as well\n\
-; 0:v4l2sink, 1:ximagesink, 2:xvimagesink, 3:fakesink 4:evasimagesink 5:glimagesink\n\
-videosink element = 2 \n\
-\n\
-videobitrate value = 6144000 \n\
-\n\
-mtu_size value = 1400 \n\
-\n\
-video converter element = \n\
-\n\
-; if yes. gstreamer will not update registry \n\
-skip rescan = yes \n\
-\n\
-delay before repeat = 50 ; msec\n\
-\n\
-; comma separated list of tocken which elemnts has it in its name will not be used \n\
-element exclude keyword = \n\
-\n\
-async start = yes \n\
-\n\
-; parameters for initializing gstreamer \n\
-gstparam1 = \n\
-gstparam2 = \n\
-gstparam3 = \n\
-gstparam4 = \n\
-gstparam5 = \n\
-\n\
-; generating dot file representing pipeline state \n\
-generate dot = no \n\
-\n\
-; parameter for clock provide in audiosink \n\
-provide clock = yes \n\
-\n\
-; allowed timeout for changing pipeline state \n\
-live state change timeout = 30 ; sec \n\
-localplayback state change timeout = 4 ; sec \n\
-\n\
-; delay in msec for sending EOS \n\
-eos delay = 150 ; msec \n\
-\n\
-\n\
-[hw accelation] \n\
-use video hw accel = yes \n\
-\n\
-\n\
-\n\
-"
-
-int
-mm_wfd_ini_load(void);
-
-mm_wfd_ini_t*
-mm_wfd_ini_get_structure(void);
-
-
-#ifdef __cplusplus
-  }
-#endif
-
-#endif
-
diff --git a/src/mm_wfd_attrs.c b/src/mm_wfd_attrs.c
deleted file mode 100755 (executable)
index d0f25f3..0000000
+++ /dev/null
@@ -1,320 +0,0 @@
-/*
- * libmm-wfd
- *
- * Copyright (c) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, ByungWook Jang <bw.jang@samsung.com>,
- * Manoj Kumar K <manojkumar.k@samsung.com>, Hyunil Park <hyunil46.park@samsung.com>
- *
- * 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 "mm_wfd_attrs.h"
-
-typedef struct{
-       char *name;
-       int value_type;
-       int flags;                              // r, w
-       void *default_value;
-       int valid_type;                 // validity type
-       int value_min;                  //<- set validity value range
-       int value_max;          //->
-}MMWfdAttrsSpec;
-
-static gboolean __mmwfd_apply_attribute(MMHandleType handle, const char *attribute_name);
-
-MMHandleType
-_mmwfd_construct_attribute(MMHandleType handle)
-{
-       int idx = 0;
-       MMHandleType attrs = 0;
-       int num_of_attrs = 0;
-       mmf_attrs_construct_info_t *base = NULL;
-
-       debug_fenter();
-
-       return_val_if_fail(handle, (MMHandleType)NULL);
-
-       MMWfdAttrsSpec wfd_attrs[] =
-       {
-               {
-                       "server_ip",
-                       MM_ATTRS_TYPE_STRING,
-                       MM_ATTRS_FLAG_RW,
-                       (void *)"127.0.0.1",
-                       MM_ATTRS_VALID_TYPE_NONE,
-                       0,
-                       0
-               },
-
-               {
-                       "server_port",
-                       MM_ATTRS_TYPE_STRING,
-                       MM_ATTRS_FLAG_RW,
-                       (void *)"8554",
-                       MM_ATTRS_VALID_TYPE_NONE,
-                       0,
-                       0
-               },
-
-               {
-                       "max_client_count",
-                       MM_ATTRS_TYPE_INT,
-                       MM_ATTRS_FLAG_RW,
-                       (void *)1,
-                       MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       0,
-                       10
-               },
-
-       };
-
-       num_of_attrs = ARRAY_SIZE(wfd_attrs);
-
-       base = (mmf_attrs_construct_info_t* )malloc(num_of_attrs * sizeof(mmf_attrs_construct_info_t));
-
-       if ( !base )
-       {
-               debug_error("Cannot create mmwfd attribute\n");
-               goto ERROR;
-       }
-
-       /* initialize values of attributes */
-       for ( idx = 0; idx < num_of_attrs; idx++ )
-       {
-               base[idx].name = wfd_attrs[idx].name;
-               base[idx].value_type = wfd_attrs[idx].value_type;
-               base[idx].flags = wfd_attrs[idx].flags;
-               base[idx].default_value = wfd_attrs[idx].default_value;
-       }
-
-       attrs = mmf_attrs_new_from_data(
-                                       "mmwfd_attrs",
-                                       base,
-                                       num_of_attrs,
-                                       NULL,
-                                       NULL);
-
-       MMWFD_FREEIF(base);
-
-       if ( !attrs )
-       {
-               debug_error("Cannot create mmwfd attribute\n");
-               goto ERROR;
-       }
-
-       /* set validity type and range */
-       for ( idx = 0; idx < num_of_attrs; idx++ )
-       {
-               switch ( wfd_attrs[idx].valid_type)
-               {
-                       case MM_ATTRS_VALID_TYPE_INT_RANGE:
-                       {
-                               mmf_attrs_set_valid_type (attrs, idx, MM_ATTRS_VALID_TYPE_INT_RANGE);
-                               mmf_attrs_set_valid_range (attrs, idx,
-                                               wfd_attrs[idx].value_min,
-                                               wfd_attrs[idx].value_max,
-                                               (int)wfd_attrs[idx].default_value);
-                       }
-                       break;
-
-                       case MM_ATTRS_VALID_TYPE_INT_ARRAY:
-                       case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
-                       case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
-                       default:
-                       break;
-               }
-       }
-
-       debug_fleave();
-
-       return attrs;
-
-ERROR:
-       _mmwfd_deconstruct_attribute(handle);
-
-       return (MMHandleType)NULL;
-}
-
-void
-_mmwfd_deconstruct_attribute(MMHandleType handle) // @
-{
-       debug_fenter();
-
-       mm_wfd_t* wfd = (mm_wfd_t*)handle;
-
-       return_if_fail( wfd );
-
-       if (wfd->attrs)
-       {
-               mmf_attrs_free (wfd->attrs);
-               wfd->attrs = 0;
-       }
-
-       debug_fleave();
-}
-
-
-int
-_mmwfd_get_attribute(MMHandleType handle,  char **err_attr_name, const char *attribute_name, va_list args_list)
-{
-       int result = MM_ERROR_NONE;
-       MMHandleType attrs = 0;
-
-       debug_fenter();
-
-       /* NOTE : Don't need to check err_attr_name because it can be set NULL */
-       /* if it's not want to know it. */
-       return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
-       return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
-
-       attrs = MMWFD_GET_ATTRS(handle);
-
-       return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT);
-
-       result = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, args_list);
-
-       if ( result != MM_ERROR_NONE)
-               debug_error("failed to get %s attribute\n", attribute_name);
-
-       debug_fleave();
-
-       return result;
-}
-
-int
-_mmwfd_set_attribute(MMHandleType handle,  char **err_attr_name, const char *attribute_name, va_list args_list)
-{
-       int result = MM_ERROR_NONE;
-       MMHandleType attrs = 0;
-
-       debug_fenter();
-
-       /* NOTE : Don't need to check err_attr_name because it can be set NULL */
-       /* if it's not want to know it. */
-       return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
-       return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
-
-       attrs = MMWFD_GET_ATTRS(handle);
-
-       return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT);
-
-       /* set attributes and commit them */
-       result = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, args_list);
-
-       if ( result != MM_ERROR_NONE)
-       {
-               debug_error("failed to set %s attribute\n", attribute_name);
-               return result;
-       }
-
-       __mmwfd_apply_attribute(handle, attribute_name);
-
-       debug_fleave();
-
-       return result;
-}
-
-
-static gboolean
-__mmwfd_apply_attribute(MMHandleType handle, const char *attribute_name)
-{
-       MMHandleType attrs = 0;
-       mm_wfd_t* wfd = 0;
-
-       debug_fenter();
-
-       return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
-       return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
-
-       attrs = MMWFD_GET_ATTRS(handle);;
-
-       return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT);
-
-       wfd = (mm_wfd_t*)handle;
-
-       // TODO: This function is not useful at this moment
-
-       debug_fleave();
-
-       return TRUE;
-}
-
-int
-_mmwfd_get_attributes_info(MMHandleType handle,  const char *attribute_name, MMWfdAttrsInfo *dst_info)
-{
-       int result = MM_ERROR_NONE;
-       MMHandleType attrs = 0;
-       MMAttrsInfo src_info = {0, };
-
-       debug_fenter();
-
-       return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
-       return_val_if_fail(dst_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
-       return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
-
-       attrs = MMWFD_GET_ATTRS(handle);
-
-       return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT);
-
-       result = mm_attrs_get_info_by_name(attrs, attribute_name, &src_info);
-
-       if ( result != MM_ERROR_NONE)
-       {
-               debug_error("failed to get attribute info\n");
-               return result;
-       }
-
-       memset(dst_info, 0x00, sizeof(MMWfdAttrsInfo));
-
-       dst_info->type = src_info.type;
-       dst_info->flag = src_info.flag;
-       dst_info->validity_type= src_info.validity_type;
-
-       switch(src_info.validity_type)
-       {
-               case MM_ATTRS_VALID_TYPE_INT_ARRAY:
-                       dst_info->int_array.array = src_info.int_array.array;
-                       dst_info->int_array.count = src_info.int_array.count;
-                       dst_info->int_array.d_val = src_info.int_array.dval;
-               break;
-
-               case MM_ATTRS_VALID_TYPE_INT_RANGE:
-                       dst_info->int_range.min = src_info.int_range.min;
-                       dst_info->int_range.max = src_info.int_range.max;
-                       dst_info->int_range.d_val = src_info.int_range.dval;
-               break;
-
-               case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
-                       dst_info->double_array.array = src_info.double_array.array;
-                       dst_info->double_array.count = src_info.double_array.count;
-                       dst_info->double_array.d_val = src_info.double_array.dval;
-               break;
-
-               case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
-                       dst_info->double_range.min = src_info.double_range.min;
-                       dst_info->double_range.max = src_info.double_range.max;
-                       dst_info->double_range.d_val = src_info.double_range.dval;
-               break;
-
-               default:
-               break;
-       }
-
-       debug_fleave();
-
-       return result;
-}
-
-
diff --git a/src/mm_wfd_ini.c b/src/mm_wfd_ini.c
deleted file mode 100755 (executable)
index a7cf47d..0000000
+++ /dev/null
@@ -1,301 +0,0 @@
-/*
- * libmm-wfd
- *
- * Copyright (c) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, ByungWook Jang <bw.jang@samsung.com>,
- * Manoj Kumar K <manojkumar.k@samsung.com>, Hyunil Park <hyunil46.park@samsung.com>
- *
- * 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.
- *
- */
-
-#ifndef __MM_WFD_INI_C__
-#define __MM_WFD_INI_C__ // TODO: why macro is needed ??
-
-#include <glib.h>
-#include <stdlib.h>
-#include "iniparser.h"
-#include <mm_wfd_ini.h>
-#include "mm_debug.h"
-#include <mm_error.h>
-#include <glib/gstdio.h>
-
-/* global variables here */
-static mm_wfd_ini_t g_wfd_ini;
-static void __mm_wfd_ini_check_ini_status(void);
-static void    __get_string_list(gchar** out_list, gchar* str);
-
-/* macro */
-#define MMWFD_INI_GET_STRING( x_item, x_ini, x_default ) \
-do \
-{ \
-  gchar* str = iniparser_getstring(dict, x_ini, x_default); \
- \
-  if ( str &&  \
-    ( strlen( str ) > 1 ) && \
-    ( strlen( str ) < WFD_INI_MAX_STRLEN ) ) \
-  { \
-    strcpy ( x_item, str ); \
-  } \
-  else \
-  { \
-    strcpy ( x_item, x_default ); \
-  } \
-}while(0)
-
-int
-mm_wfd_ini_load(void)
-{
-  static gboolean loaded = FALSE;
-  dictionary * dict = NULL;
-  gint idx = 0;
-
-  if ( loaded )
-  return MM_ERROR_NONE;
-
-  dict = NULL;
-
-  /* disabling ini parsing for launching */
-  #if 1 //debianize
-  /* get wfd ini status because system will be crashed
-  * if ini file is corrupted.
-  */
-  /* FIXIT : the api actually deleting illregular ini. but the function name said it's just checking. */
-  __mm_wfd_ini_check_ini_status();
-
-  /* first, try to load existing ini file */
-  dict = iniparser_load(MM_WFD_INI_DEFAULT_PATH);
-
-  /* if no file exists. create one with set of default values */
-  if ( !dict )
-  {
-#if 0
-    debug_log("No inifile found. wfd will create default inifile.\n");
-    if ( FALSE == __generate_default_ini() )
-    {
-      debug_warning("Creating default inifile failed. Player will use default values.\n");
-    }
-    else
-    {
-      /* load default ini */
-      dict = iniparser_load(MM_WFD_INI_DEFAULT_PATH);
-    }
-#else
-    debug_log("No inifile found. \n");
-
-    return MM_ERROR_FILE_NOT_FOUND;
-#endif
-  }
-#endif
-
-  /* get ini values */
-  memset( &g_wfd_ini, 0, sizeof(mm_wfd_ini_t) );
-
-  if ( dict ) /* if dict is available */
-  {
-    /* general */
-    g_wfd_ini.videosrc_element = iniparser_getint(dict, "general:videosrc element", DEFAULT_VIDEOSRC);
-    g_wfd_ini.session_mode = iniparser_getint(dict, "general:session_mode", DEFAULT_SESSION_MODE);
-    g_wfd_ini.videosink_element = iniparser_getint(dict, "general:videosink element", DEFAULT_VIDEOSINK);
-    g_wfd_ini.disable_segtrap = iniparser_getboolean(dict, "general:disable segtrap", DEFAULT_DISABLE_SEGTRAP);
-    g_wfd_ini.skip_rescan = iniparser_getboolean(dict, "general:skip rescan", DEFAULT_SKIP_RESCAN);
-    g_wfd_ini.videosink_element = iniparser_getint(dict, "general:videosink element", DEFAULT_VIDEOSINK);
-    g_wfd_ini.videobitrate = iniparser_getint(dict, "general:videobitrate value", DEFAULT_VIDEO_BITRATE);
-    g_wfd_ini.mtu_size = iniparser_getint(dict, "general:mtu_size value", DEFAULT_MTU_SIZE);
-    g_wfd_ini.generate_dot = iniparser_getboolean(dict, "general:generate dot", DEFAULT_GENERATE_DOT);
-    g_wfd_ini.provide_clock= iniparser_getboolean(dict, "general:provide clock", DEFAULT_PROVIDE_CLOCK);
-    g_wfd_ini.live_state_change_timeout = iniparser_getint(dict, "general:live state change timeout", DEFAULT_LIVE_STATE_CHANGE_TIMEOUT);
-    g_wfd_ini.localplayback_state_change_timeout = iniparser_getint(dict, "general:localplayback state change timeout", DEFAULT_LOCALPLAYBACK_STATE_CHANGE_TIMEOUT);
-    g_wfd_ini.eos_delay = iniparser_getint(dict, "general:eos delay", DEFAULT_EOS_DELAY);
-    g_wfd_ini.async_start = iniparser_getboolean(dict, "general:async start", DEFAULT_ASYNC_START);
-
-    g_wfd_ini.delay_before_repeat = iniparser_getint(dict, "general:delay before repeat", DEFAULT_DELAY_BEFORE_REPEAT);
-
-    MMWFD_INI_GET_STRING( g_wfd_ini.name_of_video_converter, "general:video converter element", DEFAULT_VIDEO_CONVERTER );
-
-    __get_string_list( (gchar**) g_wfd_ini.exclude_element_keyword,
-      iniparser_getstring(dict, "general:element exclude keyword", DEFAULT_EXCLUDE_KEYWORD));
-
-    MMWFD_INI_GET_STRING( g_wfd_ini.gst_param[0], "general:gstparam1", DEFAULT_GST_PARAM );
-    MMWFD_INI_GET_STRING( g_wfd_ini.gst_param[1], "general:gstparam2", DEFAULT_GST_PARAM );
-    MMWFD_INI_GET_STRING( g_wfd_ini.gst_param[2], "general:gstparam3", DEFAULT_GST_PARAM );
-    MMWFD_INI_GET_STRING( g_wfd_ini.gst_param[3], "general:gstparam4", DEFAULT_GST_PARAM );
-    MMWFD_INI_GET_STRING( g_wfd_ini.gst_param[4], "general:gstparam5", DEFAULT_GST_PARAM );
-
-    MMWFD_INI_GET_STRING( g_wfd_ini.infile, "general:input file", DEFAULT_INPUT_FILE );
-
-    /* hw accelation */
-    g_wfd_ini.use_video_hw_accel = iniparser_getboolean(dict, "hw accelation:use video hw accel", DEFAULT_USE_VIDEO_HW_ACCEL);
-  }
-  else /* if dict is not available just fill the structure with default value */
-  {
-    debug_warning("failed to load ini. using hardcoded default\n");
-
-    /* general */
-    g_wfd_ini.videosrc_element = DEFAULT_VIDEOSRC;
-    g_wfd_ini.session_mode = DEFAULT_SESSION_MODE;
-    g_wfd_ini.disable_segtrap = DEFAULT_DISABLE_SEGTRAP;
-    g_wfd_ini.skip_rescan = DEFAULT_SKIP_RESCAN;
-    g_wfd_ini.videosink_element = DEFAULT_VIDEOSINK;
-    g_wfd_ini.videobitrate = DEFAULT_VIDEO_BITRATE;
-    g_wfd_ini.mtu_size = DEFAULT_MTU_SIZE;
-    g_wfd_ini.generate_dot = DEFAULT_GENERATE_DOT;
-    g_wfd_ini.provide_clock= DEFAULT_PROVIDE_CLOCK;
-    g_wfd_ini.live_state_change_timeout = DEFAULT_LIVE_STATE_CHANGE_TIMEOUT;
-    g_wfd_ini.localplayback_state_change_timeout = DEFAULT_LOCALPLAYBACK_STATE_CHANGE_TIMEOUT;
-    g_wfd_ini.eos_delay = DEFAULT_EOS_DELAY;
-    g_wfd_ini.async_start = DEFAULT_ASYNC_START;
-    g_wfd_ini.delay_before_repeat = DEFAULT_DELAY_BEFORE_REPEAT;
-
-    strcpy( g_wfd_ini.name_of_video_converter, DEFAULT_VIDEO_CONVERTER);
-
-    {
-      __get_string_list( (gchar**) g_wfd_ini.exclude_element_keyword, DEFAULT_EXCLUDE_KEYWORD);
-    }
-
-
-    strcpy( g_wfd_ini.gst_param[0], DEFAULT_GST_PARAM );
-    strcpy( g_wfd_ini.gst_param[1], DEFAULT_GST_PARAM );
-    strcpy( g_wfd_ini.gst_param[2], DEFAULT_GST_PARAM );
-    strcpy( g_wfd_ini.gst_param[3], DEFAULT_GST_PARAM );
-    strcpy( g_wfd_ini.gst_param[4], DEFAULT_GST_PARAM );
-
-    strcpy( g_wfd_ini.infile, DEFAULT_INPUT_FILE );
-
-    /* hw accelation */
-    g_wfd_ini.use_video_hw_accel = DEFAULT_USE_VIDEO_HW_ACCEL;
-
-  }
-
-  /* free dict as we got our own structure */
-  iniparser_freedict (dict);
-
-  loaded = TRUE;
-
-  /* The simulator uses a separate ini file. */
-  //__mm_wfd_ini_force_setting();
-
-
-  /* dump structure */
-  debug_log("wfd settings -----------------------------------\n");
-
-  /* general */
-  debug_log("videosrc element : %d\n", g_wfd_ini.videosrc_element);
-  debug_log("session mode in mirroring : %d\n", g_wfd_ini.session_mode);
-  debug_log("disable_segtrap : %d\n", g_wfd_ini.disable_segtrap);
-  debug_log("skip rescan : %d\n", g_wfd_ini.skip_rescan);
-  debug_log("videosink element(0:v4l2sink, 1:ximagesink, 2:xvimagesink, 3:fakesink) : %d\n", g_wfd_ini.videosink_element);
-  debug_log("video_bitrate : %d\n", g_wfd_ini.videobitrate);
-  debug_log("mtu_size : %d\n", g_wfd_ini.mtu_size);
-  debug_log("generate_dot : %d\n", g_wfd_ini.generate_dot);
-  debug_log("provide_clock : %d\n", g_wfd_ini.provide_clock);
-  debug_log("live_state_change_timeout(sec) : %d\n", g_wfd_ini.live_state_change_timeout);
-  debug_log("localplayback_state_change_timeout(sec) : %d\n", g_wfd_ini.localplayback_state_change_timeout);
-  debug_log("eos_delay(msec) : %d\n", g_wfd_ini.eos_delay);
-  debug_log("delay_before_repeat(msec) : %d\n", g_wfd_ini.delay_before_repeat);
-  debug_log("name_of_video_converter : %s\n", g_wfd_ini.name_of_video_converter);
-  debug_log("async_start : %d\n", g_wfd_ini.async_start);
-
-  debug_log("gst_param1 : %s\n", g_wfd_ini.gst_param[0]);
-  debug_log("gst_param2 : %s\n", g_wfd_ini.gst_param[1]);
-  debug_log("gst_param3 : %s\n", g_wfd_ini.gst_param[2]);
-  debug_log("gst_param4 : %s\n", g_wfd_ini.gst_param[3]);
-  debug_log("gst_param5 : %s\n", g_wfd_ini.gst_param[4]);
-
-  debug_log("input file : %s\n", g_wfd_ini.infile);
-
-  for ( idx = 0; g_wfd_ini.exclude_element_keyword[idx][0] != '\0'; idx++ )
-  {
-       debug_log("exclude_element_keyword [%d] : %s\n", idx, g_wfd_ini.exclude_element_keyword[idx]);
-  }
-
-  /* hw accel */
-  debug_log("use_video_hw_accel : %d\n", g_wfd_ini.use_video_hw_accel);
-  
-  debug_log("---------------------------------------------------\n");
-
-  return MM_ERROR_NONE;
-}
-
-
-static
-void __mm_wfd_ini_check_ini_status(void)
-{
-  struct stat ini_buff;
-  
-  if ( g_stat(MM_WFD_INI_DEFAULT_PATH, &ini_buff) < 0 )
-  {
-    debug_warning("failed to get wfd ini status\n");
-  }
-  else
-  {
-    if ( ini_buff.st_size < 5 )
-    {
-      debug_warning("wfd.ini file size=%d, Corrupted! So, Removed\n", (int)ini_buff.st_size);
-      g_remove( MM_WFD_INI_DEFAULT_PATH );
-    }
-  }
-}
-
-
-mm_wfd_ini_t*
-mm_wfd_ini_get_structure(void)
-{
-  return &g_wfd_ini;
-}
-
-
-static
-void __get_string_list(gchar** out_list, gchar* str)
-{
-  gchar** list = NULL;
-  gchar** walk = NULL;
-  gint i = 0;
-  gchar* strtmp = NULL;
-
-  if ( ! str )
-  return;
-
-  if ( strlen( str ) < 1 )
-    return;
-
-  strtmp = g_strdup (str);
-
-  /* trimming. it works inplace */
-  g_strstrip( strtmp );
-
-  /* split */
-  list = g_strsplit( strtmp, ",", 10 );
-
-  g_return_if_fail ( list != NULL );
-
-  /* copy list */
-  for( walk = list; *walk; walk++ )
-  {
-    strncpy( g_wfd_ini.exclude_element_keyword[i], *walk, (WFD_INI_MAX_STRLEN - 1) );
-    g_strstrip( g_wfd_ini.exclude_element_keyword[i] );
-    g_wfd_ini.exclude_element_keyword[i][WFD_INI_MAX_STRLEN - 1] = '\0';
-    i++;
-  }
-
-  /* mark last item to NULL */
-  g_wfd_ini.exclude_element_keyword[i][0] = '\0';
-
-  g_strfreev( list );
-  if (strtmp)
-  g_free (strtmp);
-}
-
-#endif
-