Add inline function to get number from string 02/239502/3
authorSangchul Lee <sc11.lee@samsung.com>
Mon, 27 Jul 2020 07:18:21 +0000 (16:18 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Mon, 27 Jul 2020 07:43:37 +0000 (16:43 +0900)
[Version] 0.1.103
[Issue Type] Refactoring

Change-Id: I0c64a5e655106f0e5de0f48b7e81b60c67da1b33
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
include/media_streamer_util.h
packaging/capi-media-streamer.spec
src/media_streamer_gst.c
src/media_streamer_node.c

index 0eaa0f5..196b4b2 100644 (file)
@@ -258,6 +258,11 @@ typedef struct _media_streamer_wl_info_s {
                        type = NULL; \
        } while (0)
 
+inline int ms_get_number_from_string(const char *string)
+{
+       return (int)strtol(string, NULL, 10);
+}
+
 /**
  * @brief Loads media streamer settings from ini file.
  *        The default values will be used if error has occurred.
index 81f7312..b48779a 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-streamer
 Summary:    A Media Streamer API
-Version:    0.1.102
+Version:    0.1.103
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 25a52dc..971c6b1 100644 (file)
@@ -848,7 +848,7 @@ static void __decodebin_nomore_pads_cb(GstElement *decodebin, gpointer user_data
                } else {
                        /* It`s server part of Streaming Scenario*/
                        media_streamer_node_get_param(rtp_node, MEDIA_STREAMER_PARAM_VIDEO_OUT_PORT, &param_value);
-                       if (param_value && (strtol(param_value, NULL, 10) > 0))
+                       if (param_value && ms_get_number_from_string(param_value) > 0)
                                sink_bin_type = MEDIA_STREAMER_SINK_BIN_RTP_SERVER;
 
                        MS_SAFE_FREE(param_value);
index 624cf0e..1308cce 100644 (file)
@@ -315,7 +315,7 @@ static int __ms_param_value_set(GValue *value, param_data_type_e type, const cha
        case PARAM_DATA_TYPE_NUMBER:
                g_value_unset(value);
                g_value_init(value, G_TYPE_INT);
-               g_value_set_int(value, (int)strtol(param_value, NULL, 10));
+               g_value_set_int(value, ms_get_number_from_string(param_value));
                break;
 
        case PARAM_DATA_TYPE_BOOL:
@@ -340,7 +340,7 @@ static int __ms_param_value_set(GValue *value, param_data_type_e type, const cha
        case PARAM_DATA_TYPE_ENUM:
                g_value_unset(value);
                g_value_init(value, G_TYPE_ENUM);
-               g_value_set_enum(value, (int)strtol(param_value, NULL, 10));
+               g_value_set_enum(value, ms_get_number_from_string(param_value));
                break;
 
        case PARAM_DATA_TYPE_POINTER:
@@ -1990,7 +1990,7 @@ int ms_node_set_param_value(media_streamer_node_s *node, param_s *param, const c
 
        switch (param->prop_enum) {
        case PROP_NAME_CAMERA_ID: {
-               int camera_id = (int)strtol(param_value, NULL, 10);
+               int camera_id = ms_get_number_from_string(param_value);
                ms_retvm_if(camera_id == -1, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "Invalid %s value", param->param_name);
                g_object_set(node->gst_element, param->prop_name, camera_id, NULL);
                break;
@@ -2003,7 +2003,7 @@ int ms_node_set_param_value(media_streamer_node_s *node, param_s *param, const c
        case PROP_NAME_ROTATE:
        case PROP_NAME_FLIP:
        case PROP_NAME_DISPLAY_GEOMETRY_METHOD:
-               g_object_set(node->gst_element, param->prop_name, (int)strtol(param_value, NULL, 10), NULL);
+               g_object_set(node->gst_element, param->prop_name, ms_get_number_from_string(param_value), NULL);
                break;
 
        case PROP_NAME_IS_LIVE: