check invalid parameter to return error immediately 00/187000/3
authornam <just.nam@samsung.com>
Fri, 17 Aug 2018 05:48:50 +0000 (14:48 +0900)
committernam <just.nam@samsung.com>
Mon, 20 Aug 2018 06:16:10 +0000 (15:16 +0900)
Change-Id: I9ae33eeaefed6e68118b34a97f4852f436af4cc8

src/player.c

index d5ef753..765690c 100644 (file)
@@ -44,7 +44,9 @@
 #define PLAYER_FEATURE_SOUND_STREAM      "http://tizen.org/feature/multimedia.player.stream_info"
 #define PLAYER_FEATURE_OPENGL            "http://tizen.org/feature/opengles.version.2_0"
 #define PLAYER_FEATURE_SPHERICAL_VIDEO   "http://tizen.org/feature/multimedia.player.spherical_video"
-
+#ifndef M_PI
+#define M_PI  3.14159265358979323846
+#endif
 typedef enum {
        TIZEN_PROFILE_UNKNOWN = 0,
        TIZEN_PROFILE_MOBILE = 0x1,
@@ -3124,10 +3126,10 @@ int player_set_playback_rate(player_h player, float rate)
        char *ret_buf = NULL;
 
        LOGD("ENTER");
-
-       PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_DOUBLE, "rate", (double)rate);
-       g_free(ret_buf);
-
+       if (rate != 0) {
+               PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_DOUBLE, "rate", (double)rate);
+               g_free(ret_buf);
+       }
        LOGD("LEAVE 0x%X", ret);
        return ret;
 }
@@ -3135,6 +3137,8 @@ int player_set_playback_rate(player_h player, float rate)
 int player_set_display_rotation(player_h player, player_display_rotation_e rotation)
 {
        PLAYER_INSTANCE_CHECK(player);
+       PLAYER_CHECK_CONDITION(PLAYER_DISPLAY_ROTATION_NONE <= rotation && rotation <= PLAYER_DISPLAY_ROTATION_270, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
+
        int ret = PLAYER_ERROR_NONE;
        muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY_ROTATION;
        player_cli_s *pc = (player_cli_s *) player;
@@ -4449,8 +4453,11 @@ int player_set_media_stream_info(player_h player, player_stream_type_e type, med
 
 int player_set_media_stream_buffer_max_size(player_h player, player_stream_type_e type, unsigned long long max_size)
 {
-       int ret = PLAYER_ERROR_NONE;
        PLAYER_INSTANCE_CHECK(player);
+       PLAYER_CHECK_CONDITION(PLAYER_STREAM_TYPE_DEFAULT <= type && type <= PLAYER_STREAM_TYPE_TEXT, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
+       PLAYER_CHECK_CONDITION(max_size > 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
+
+       int ret = PLAYER_ERROR_NONE;
        player_cli_s *pc = (player_cli_s *) player;
        muse_player_api_e api = MUSE_PLAYER_API_SET_MEDIA_STREAM_BUFFER_MAX_SIZE;
        char *ret_buf = NULL;
@@ -4488,8 +4495,10 @@ int player_get_media_stream_buffer_max_size(player_h player, player_stream_type_
 
 int player_set_media_stream_buffer_min_threshold(player_h player, player_stream_type_e type, unsigned int percent)
 {
-       int ret = PLAYER_ERROR_NONE;
        PLAYER_INSTANCE_CHECK(player);
+       PLAYER_CHECK_CONDITION(PLAYER_STREAM_TYPE_DEFAULT <= type && type <= PLAYER_STREAM_TYPE_TEXT, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
+
+       int ret = PLAYER_ERROR_NONE;
        player_cli_s *pc = (player_cli_s *) player;
        muse_player_api_e api = MUSE_PLAYER_API_SET_MEDIA_STREAM_BUFFER_MIN_THRESHOLD;
        char *ret_buf = NULL;
@@ -4922,6 +4931,9 @@ int player_360_set_direction_of_view(player_h player, float yaw, float pitch)
        PLAYER_FEATURE_CHECK(PLAYER_FEATURE_SPHERICAL_VIDEO);
 
        PLAYER_INSTANCE_CHECK(player);
+       PLAYER_CHECK_CONDITION(yaw >= (float)-M_PI && yaw <= (float)M_PI, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
+       PLAYER_CHECK_CONDITION(pitch >= (float)-M_PI/2 && pitch <= (float)M_PI/2, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
+
        int ret = PLAYER_ERROR_NONE;
        muse_player_api_e api = MUSE_PLAYER_API_360_SET_DIRECTION_OF_VIEW;
        player_cli_s *pc = (player_cli_s *) player;
@@ -4984,6 +4996,8 @@ int player_360_set_zoom(player_h player, float level)
        PLAYER_FEATURE_CHECK(PLAYER_FEATURE_SPHERICAL_VIDEO);
 
        PLAYER_INSTANCE_CHECK(player);
+       PLAYER_CHECK_CONDITION(level >= 1.0 && level <= 10.0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
+
        int ret = PLAYER_ERROR_NONE;
        muse_player_api_e api = MUSE_PLAYER_API_360_SET_ZOOM;
        player_cli_s *pc = (player_cli_s *) player;
@@ -5037,6 +5051,9 @@ int player_360_set_field_of_view(player_h player, int horizontal_degrees, int ve
        PLAYER_FEATURE_CHECK(PLAYER_FEATURE_SPHERICAL_VIDEO);
 
        PLAYER_INSTANCE_CHECK(player);
+       PLAYER_CHECK_CONDITION(horizontal_degrees >= 1 && horizontal_degrees <= 360, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
+       PLAYER_CHECK_CONDITION(vertical_degrees >= 1 && vertical_degrees <= 180, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
+
        int ret = PLAYER_ERROR_NONE;
        muse_player_api_e api = MUSE_PLAYER_API_360_SET_FIELD_OF_VIEW;
        player_cli_s *pc = (player_cli_s *) player;
@@ -5098,6 +5115,10 @@ int player_360_set_zoom_with_field_of_view(player_h player, float level, int hor
        PLAYER_FEATURE_CHECK(PLAYER_FEATURE_SPHERICAL_VIDEO);
 
        PLAYER_INSTANCE_CHECK(player);
+       PLAYER_CHECK_CONDITION(horizontal_degrees >= 1 && horizontal_degrees <= 360, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
+       PLAYER_CHECK_CONDITION(vertical_degrees >= 1 && vertical_degrees <= 180, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
+       PLAYER_CHECK_CONDITION(level >= 1.0 && level <= 10.0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
+
        int ret = PLAYER_ERROR_NONE;
        muse_player_api_e api = MUSE_PLAYER_API_360_SET_ZOOM_WITH_FIELD_OF_VIEW;
        player_cli_s *pc = (player_cli_s *) player;