[0.6.128] refactoring about set position 21/187721/3 accepted/tizen/unified/20180830.060824 submit/tizen/20180829.053131
authorEunhae Choi <eunhae1.choi@samsung.com>
Tue, 28 Aug 2018 05:15:43 +0000 (14:15 +0900)
committereunhae choi <eunhae1.choi@samsung.com>
Wed, 29 Aug 2018 04:24:48 +0000 (04:24 +0000)
- improve the cyclomatic complexity of _set_position function
- remove format related code in set/get position (dead code)

Change-Id: I116600d8f8f03e4876e0269607398c4b7d5480db

packaging/libmm-player.spec
src/include/mm_player.h
src/include/mm_player_gst.h
src/include/mm_player_priv.h
src/mm_player.c
src/mm_player_gst.c
src/mm_player_priv.c

index 9f01b14..b8f430c 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-player
 Summary:    Multimedia Framework Player Library
-Version:    0.6.127
+Version:    0.6.128
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index b6545ca..5ee8484 100644 (file)
@@ -283,7 +283,6 @@ typedef enum {
 
 /**
  * Enumerations of position formats.
- * Used while invoking mm_player_get_position/mm_player_set_position APIs
  */
 typedef enum {
        MM_PLAYER_POS_FORMAT_TIME,                      /**< Format for time based */
@@ -836,14 +835,13 @@ int mm_player_resume(MMHandleType player);
  * So, it can be seeked to requested position. \n
  *
  * @param      player          [in]    Handle of player
- * @param      format          [in]    Format of position.
  * @param      pos                     [in]    Position for playback
  *
  * @return     This function returns zero on success, or negative value with error code.
- * @see                MMPlayerPosFormatType, mm_player_get_position
+ * @see                mm_player_get_position
  * @remark  the unit of time-based format is millisecond and other case is percent.
  */
-int mm_player_set_position(MMHandleType player, MMPlayerPosFormatType format, int64_t pos);
+int mm_player_set_position(MMHandleType player, int64_t pos);
 
 /**
  * This function is to get current position of playback content.
@@ -853,10 +851,10 @@ int mm_player_set_position(MMHandleType player, MMPlayerPosFormatType format, in
  * @param    pos        [out] contains current position on success or zero in case of failure.
  *
  * @return     This function returns zero on success, or negative value with errors
- * @see                MMPlayerPosFormatType, mm_player_set_position
+ * @see                mm_player_set_position
  * @remark  the unit of time-based format is millisecond and other case is percent.
  */
-int mm_player_get_position(MMHandleType player, MMPlayerPosFormatType format, int64_t *pos);
+int mm_player_get_position(MMHandleType player, int64_t *pos);
 
 /**
  * This function is to get the content time duration.
index a95876b..7e54b7e 100644 (file)
@@ -54,8 +54,8 @@ gboolean __mmplayer_gst_send_event_to_sink(mm_player_t* player, GstEvent* event)
 gboolean __mmplayer_gst_seek(mm_player_t* player, GstElement * element, gdouble rate,
                        GstFormat format, GstSeekFlags flags, GstSeekType cur_type,
                        gint64 cur, GstSeekType stop_type, gint64 stop);
-int __mmplayer_gst_set_position(mm_player_t* player, int format, gint64 position, gboolean internal_called);
-int __mmplayer_gst_get_position(mm_player_t* player, int format, gint64* position);
+int __mmplayer_gst_set_position(mm_player_t* player, gint64 position, gboolean internal_called);
+int __mmplayer_gst_get_position(mm_player_t* player, gint64* position);
 int __mmplayer_gst_get_buffer_position(mm_player_t* player, int format, unsigned long* start_pos, unsigned long* stop_pos);
 int __mmplayer_gst_build_es_pipeline(mm_player_t* player);
 int __mmplayer_gst_build_pd_pipeline(mm_player_t* player);
index 6f48c8b..54299e6 100644 (file)
@@ -438,7 +438,6 @@ typedef struct {
 
 typedef struct {
        bool is_pending;
-       MMPlayerPosFormatType format;
        gint64 pos;
 } MMPlayerPendingSeek;
 
@@ -896,8 +895,8 @@ int _mmplayer_stop(MMHandleType hplayer);
 int _mmplayer_pause(MMHandleType hplayer);
 int _mmplayer_abort_pause(MMHandleType hplayer);
 int _mmplayer_resume(MMHandleType hplayer);
-int _mmplayer_set_position(MMHandleType hplayer, int format, gint64 pos);
-int _mmplayer_get_position(MMHandleType hplayer, int format, gint64 *pos);
+int _mmplayer_set_position(MMHandleType hplayer, gint64 pos);
+int _mmplayer_get_position(MMHandleType hplayer, gint64 *pos);
 int _mmplayer_get_duration(MMHandleType hplayer, gint64 *duration);
 int _mmplayer_adjust_subtitle_postion(MMHandleType hplayer, int format,  int pos);
 int _mmplayer_set_playspeed(MMHandleType hplayer, float rate, bool streaming);
index 74d87c5..6cbea96 100644 (file)
@@ -423,41 +423,31 @@ int mm_player_set_play_speed(MMHandleType player, float rate, bool streaming)
        return result;
 }
 
-int mm_player_set_position(MMHandleType player, MMPlayerPosFormatType format, int64_t pos)
+int mm_player_set_position(MMHandleType player, int64_t pos)
 {
        int result = MM_ERROR_NONE;
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
-       if (format >= MM_PLAYER_POS_FORMAT_NUM) {
-               LOGE("wrong format\n");
-               return MM_ERROR_COMMON_INVALID_ARGUMENT;
-       }
-
        MMPLAYER_CMD_LOCK(player);
 
-       result = _mmplayer_set_position(player, format, pos);
+       result = _mmplayer_set_position(player, pos);
 
        MMPLAYER_CMD_UNLOCK(player);
 
        return result;
 }
 
-int mm_player_get_position(MMHandleType player, MMPlayerPosFormatType format, int64_t *pos)
+int mm_player_get_position(MMHandleType player, int64_t *pos)
 {
        int result = MM_ERROR_NONE;
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
        MMPLAYER_RETURN_VAL_IF_FAIL(pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
 
-       if (format >= MM_PLAYER_POS_FORMAT_NUM) {
-               LOGE("wrong format\n");
-               return MM_ERROR_COMMON_INVALID_ARGUMENT;
-       }
-
        MMPLAYER_CMD_LOCK(player);
 
-       result = _mmplayer_get_position(player, (int)format, pos);
+       result = _mmplayer_get_position(player, pos);
 
        MMPLAYER_CMD_UNLOCK(player);
 
index afe38d4..9ef2f12 100644 (file)
@@ -1023,7 +1023,7 @@ __mmplayer_update_buffer_setting(mm_player_t *player, GstMessage *buffering_msg)
 
        MMPLAYER_RETURN_IF_FAIL(player && player->pipeline && player->pipeline->mainbin);
 
-       __mmplayer_gst_get_position(player, MM_PLAYER_POS_FORMAT_TIME, &pos_nsec);      /* to update player->last_position */
+       __mmplayer_gst_get_position(player, &pos_nsec); /* to update player->last_position */
 
        attrs = MMPLAYER_GET_ATTRS(player);
        if (!attrs) {
@@ -1235,7 +1235,7 @@ __mmplayer_eos_timer_cb(gpointer u_data)
 
        if (count == -1) {
                gint ret_value = 0;
-               ret_value = __mmplayer_gst_set_position(player, MM_PLAYER_POS_FORMAT_TIME, 0, TRUE);
+               ret_value = __mmplayer_gst_set_position(player, 0, TRUE);
                if (ret_value != MM_ERROR_NONE)
                        LOGE("seeking to 0 failed in repeat play");
        } else {
@@ -1308,7 +1308,7 @@ static int __mmplayer_gst_pending_seek(mm_player_t* player)
 
        LOGD("trying to play from(%"G_GINT64_FORMAT") pending position\n", player->pending_seek.pos);
 
-       ret = __mmplayer_gst_set_position(player, player->pending_seek.format, player->pending_seek.pos, FALSE);
+       ret = __mmplayer_gst_set_position(player, player->pending_seek.pos, FALSE);
 
        if (MM_ERROR_NONE != ret)
                LOGE("failed to seek pending postion. just keep staying current position.\n");
@@ -1678,7 +1678,7 @@ __mmplayer_gst_handle_state_message(mm_player_t* player, GstMessage *msg)
                        int retVal = MM_ERROR_NONE;
                        LOGD("trying to play from (%"G_GINT64_FORMAT") pending position", player->pending_seek.pos);
 
-                       retVal = __mmplayer_gst_set_position(player, player->pending_seek.format, player->pending_seek.pos, TRUE);
+                       retVal = __mmplayer_gst_set_position(player, player->pending_seek.pos, TRUE);
 
                        if (MM_ERROR_NONE != retVal)
                                LOGE("failed to seek pending postion. just keep staying current position.");
@@ -2947,6 +2947,77 @@ static gpointer __mmplayer_gst_bus_msg_thread(gpointer data)
        return NULL;
 }
 
+static int
+__mmplayer_gst_check_duration(mm_player_t* player, gint64 position)
+{
+       gint64 dur_nsec = 0;
+
+       MMPLAYER_FENTER();
+       MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline, MM_ERROR_PLAYER_NOT_INITIALIZED);
+
+       if (MMPLAYER_IS_MS_BUFF_SRC(player))
+               return MM_ERROR_NONE;
+
+       /* NOTE : duration cannot be zero except live streaming.
+        *              Since some element could have some timing problemn with quering duration, try again.
+        */
+       if (player->duration == 0) {
+               if (!gst_element_query_duration(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_FORMAT_TIME, &dur_nsec)) {
+                       /* For RTSP Streaming , duration is not returned in READY state. So seek to the previous position does not work properly.
+                        * Added a patch to postpone the actual seek when state changes to PLAY. Sending a fake SEEK_COMPLETED event to finish the current request. */
+                       if ((MMPLAYER_IS_RTSP_STREAMING(player)) &&
+                               (__mmplayer_get_stream_service_type(player) == STREAMING_SERVICE_VOD)) {
+                               player->pending_seek.is_pending = TRUE;
+                               player->pending_seek.pos = position;
+                               player->seek_state = MMPLAYER_SEEK_NONE;
+                               MMPLAYER_POST_MSG(player, MM_MESSAGE_SEEK_COMPLETED, NULL);
+                               return MM_ERROR_PLAYER_NO_OP;
+                       } else {
+                               player->seek_state = MMPLAYER_SEEK_NONE;
+                               return MM_ERROR_PLAYER_SEEK;
+                       }
+               }
+               player->duration = dur_nsec;
+       }
+
+       if (player->duration > 0 && player->duration < position) {
+               LOGE("invalid pos %"G_GINT64_FORMAT", dur: %"G_GINT64_FORMAT, position, player->duration);
+               return MM_ERROR_INVALID_ARGUMENT;
+       }
+
+       MMPLAYER_FLEAVE();
+       return MM_ERROR_NONE;
+}
+
+static gboolean
+__mmplayer_gst_check_seekable(mm_player_t* player)
+{
+       GstQuery *query = NULL;
+       gboolean seekable = FALSE;
+
+       if (MMPLAYER_IS_MS_BUFF_SRC(player)) {
+               return TRUE;
+       }
+
+       query = gst_query_new_seeking(GST_FORMAT_TIME);
+       if (gst_element_query(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, query)) {
+               gst_query_parse_seeking(query, NULL, &seekable, NULL, NULL);
+               gst_query_unref(query);
+
+               if (!seekable) {
+                       LOGW("non-seekable content");
+                       player->seek_state = MMPLAYER_SEEK_NONE;
+                       return FALSE;
+               }
+       } else {
+               LOGW("failed to get seeking query");
+               gst_query_unref(query); /* keep seeking operation */
+       }
+
+       return TRUE;
+}
+
+
 #if 0
 #endif
 
@@ -3394,11 +3465,10 @@ __mmplayer_gst_seek(mm_player_t* player, GstElement * element, gdouble rate,
 }
 
 int
-__mmplayer_gst_set_position(mm_player_t* player, int format, gint64 position, gboolean internal_called)
+__mmplayer_gst_set_position(mm_player_t* player, gint64 position, gboolean internal_called)
 {
-       gint64 dur_nsec = 0;
+       int ret = MM_ERROR_NONE;
        gint64 pos_nsec = 0;
-       gboolean ret = TRUE;
        gboolean accurated = FALSE;
        GstSeekFlags seek_flags = GST_SEEK_FLAG_FLUSH;
 
@@ -3410,173 +3480,77 @@ __mmplayer_gst_set_position(mm_player_t* player, int format, gint64 position, gb
                && MMPLAYER_CURRENT_STATE(player) != MM_PLAYER_STATE_PAUSED)
                goto PENDING;
 
-       if (!MMPLAYER_IS_MS_BUFF_SRC(player)) {
-               /* check duration */
-               /* NOTE : duration cannot be zero except live streaming.
-                *              Since some element could have some timing problemn with quering duration, try again.
-                */
-               if (player->duration == 0) {
-                       if (!gst_element_query_duration(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_FORMAT_TIME, &dur_nsec)) {
-                               /* For RTSP Streaming , duration is not returned in READY state. So seek to the previous position does not work properly.
-                                * Added a patch to postpone the actual seek when state changes to PLAY. Sending a fake SEEK_COMPLETED event to finish the current request. */
-                               if ((MMPLAYER_IS_RTSP_STREAMING(player)) && (__mmplayer_get_stream_service_type(player) == STREAMING_SERVICE_VOD)) {
-                                       player->pending_seek.is_pending = TRUE;
-                                       player->pending_seek.format = format;
-                                       player->pending_seek.pos = position;
-                                       player->seek_state = MMPLAYER_SEEK_NONE;
-                                       MMPLAYER_POST_MSG(player, MM_MESSAGE_SEEK_COMPLETED, NULL);
-                                       return MM_ERROR_NONE;
-                               } else {
-                                       goto SEEK_ERROR;
-                               }
-                       }
-                       player->duration = dur_nsec;
-               }
+       ret = __mmplayer_gst_check_duration(player, position);
+       if (ret != MM_ERROR_NONE) {
+               LOGE("failed to check duration 0x%X", ret);
+               return (ret == MM_ERROR_PLAYER_NO_OP) ? (MM_ERROR_NONE) : (ret);
        }
-       LOGD("playback rate: %f\n", player->playback_rate);
-
-       mm_attrs_get_int_by_name(player->attrs, "accurate_seek", &accurated);
-       if (accurated)
-               seek_flags |= GST_SEEK_FLAG_ACCURATE;
-       else
-               seek_flags |= GST_SEEK_FLAG_KEY_UNIT;
 
-       /* do seek */
-       switch (format) {
-       case MM_PLAYER_POS_FORMAT_TIME:
-       {
-               if (!MMPLAYER_IS_MS_BUFF_SRC(player)) {
-                       GstQuery *query = NULL;
-                       gboolean seekable = FALSE;
-
-                       /* check position is valid or not */
-                       if (position > player->duration)
-                               goto INVALID_ARGS;
-
-                       query = gst_query_new_seeking(GST_FORMAT_TIME);
-                       if (gst_element_query(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, query)) {
-                               gst_query_parse_seeking(query, NULL, &seekable, NULL, NULL);
-                               gst_query_unref(query);
-
-                               if (!seekable) {
-                                       LOGW("non-seekable content");
-                                       player->seek_state = MMPLAYER_SEEK_NONE;
-                                       return MM_ERROR_PLAYER_NO_OP;
-                               }
-                       } else {
-                               LOGW("failed to get seeking query");
-                               gst_query_unref(query); /* keep seeking operation */
-                       }
-
-                       LOGD("seeking to(%"G_GINT64_FORMAT") nsec, duration is %"G_GINT64_FORMAT" nsec\n", position, player->duration);
-
-                       /* For rtspsrc stack , npt-start value coming from server is used for finding the current position.
-                          But when a rtsp clip (especially from Youtube Desktop View) is paused and kept for sometime,npt-start is still increasing.
-                          This causes problem is position calculation during normal pause resume scenarios also.
-                          Currently during seek , we are sending the current position to rtspsrc module for position saving for later use. */
-                       if ((MMPLAYER_IS_RTSP_STREAMING(player)) &&
-                               (__mmplayer_get_stream_service_type(player) == STREAMING_SERVICE_VOD)) {
-                               if (!gst_element_query_position(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_FORMAT_TIME, &pos_nsec))
-                                       LOGW("getting current position failed in seek\n");
-
-                               player->last_position = pos_nsec;
-                               g_object_set(player->pipeline->mainbin[MMPLAYER_M_SRC].gst, "resume-position", player->last_position, NULL);
-                       }
-
-                       if (player->seek_state != MMPLAYER_SEEK_NONE) {
-                               LOGD("not completed seek");
-                               return MM_ERROR_PLAYER_DOING_SEEK;
-                       }
-               }
-
-               if (!internal_called)
-                       player->seek_state = MMPLAYER_SEEK_IN_PROGRESS;
-
-               if ((MMPLAYER_IS_HTTP_STREAMING(player)) && (!player->videodec_linked)) {
-                       gint64 cur_time = 0;
-
-                       /* get current position */
-                       gst_element_query_position(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_FORMAT_TIME, &cur_time);
-
-                       /* flush */
-                       GstEvent *event = gst_event_new_seek(1.0,
-                                                       GST_FORMAT_TIME,
-                                                       (GstSeekFlags)GST_SEEK_FLAG_FLUSH,
-                                                       GST_SEEK_TYPE_SET, cur_time,
-                                                       GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
-                       if (event)
-                               __mmplayer_gst_send_event_to_sink(player, event);
-
-                       if (!MMPLAYER_IS_RTSP_STREAMING(player))
-                               __mmplayer_gst_pause(player, FALSE);
-               }
+       if (!__mmplayer_gst_check_seekable(player))
+               return MM_ERROR_PLAYER_NO_OP;
 
-               pos_nsec = position;
+       LOGD("seeking to(%"G_GINT64_FORMAT") nsec, rate: %f, dur: %"G_GINT64_FORMAT" nsec",
+                               position, player->playback_rate, player->duration);
 
-               /* rtsp streaming case, there is no sink after READY TO PAUSE state(no preroll state change).
-                       that's why set position through property. */
-               if ((MMPLAYER_IS_RTSP_STREAMING(player)) &&
-                       (MMPLAYER_CURRENT_STATE(player) == MM_PLAYER_STATE_PAUSED) &&
-                       (MMPLAYER_PREV_STATE(player) == MM_PLAYER_STATE_READY) &&
-                       (!player->videodec_linked) && (!player->audiodec_linked)) {
+       /* For rtspsrc stack , npt-start value coming from server is used for finding the current position.
+          But when a rtsp clip (especially from Youtube Desktop View) is paused and kept for sometime,npt-start is still increasing.
+          This causes problem is position calculation during normal pause resume scenarios also.
+          Currently during seek , we are sending the current position to rtspsrc module for position saving for later use. */
+       if ((MMPLAYER_IS_RTSP_STREAMING(player)) &&
+               (__mmplayer_get_stream_service_type(player) == STREAMING_SERVICE_VOD)) {
+               if (!gst_element_query_position(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_FORMAT_TIME, &pos_nsec))
+                       LOGW("getting current position failed in seek");
 
-                       g_object_set(player->pipeline->mainbin[MMPLAYER_M_SRC].gst, "pending-start-position", pos_nsec, NULL);
-                       LOGD("[%s] set position =%"GST_TIME_FORMAT,
-                                       GST_ELEMENT_NAME(player->pipeline->mainbin[MMPLAYER_M_SRC].gst), GST_TIME_ARGS(pos_nsec));
-                       player->seek_state = MMPLAYER_SEEK_NONE;
-                       MMPLAYER_POST_MSG(player, MM_MESSAGE_SEEK_COMPLETED, NULL);
-               } else {
-                       ret = __mmplayer_gst_seek(player, player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, player->playback_rate,
-                                                       GST_FORMAT_TIME, seek_flags,
-                                                       GST_SEEK_TYPE_SET, pos_nsec, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
-               }
+               player->last_position = pos_nsec;
+               g_object_set(player->pipeline->mainbin[MMPLAYER_M_SRC].gst, "resume-position", player->last_position, NULL);
+       }
 
-               if (!ret) {
-                       LOGE("failed to set position.");
-                       goto SEEK_ERROR;
-               }
+       if (player->seek_state != MMPLAYER_SEEK_NONE) {
+               LOGD("not completed seek");
+               return MM_ERROR_PLAYER_DOING_SEEK;
        }
-       break;
 
-       case MM_PLAYER_POS_FORMAT_PERCENT:
-       {
-               LOGD("seeking to %"G_GINT64_FORMAT"%%", position);
+       if (!internal_called)
+               player->seek_state = MMPLAYER_SEEK_IN_PROGRESS;
 
-               if (player->seek_state != MMPLAYER_SEEK_NONE) {
-                       LOGD("not completed seek");
-                       return MM_ERROR_PLAYER_DOING_SEEK;
-               }
+       /* rtsp streaming case, there is no sink after READY TO PAUSE state(no preroll state change).
+               that's why set position through property. */
+       if ((MMPLAYER_IS_RTSP_STREAMING(player)) &&
+               (MMPLAYER_CURRENT_STATE(player) == MM_PLAYER_STATE_PAUSED) &&
+               (MMPLAYER_PREV_STATE(player) == MM_PLAYER_STATE_READY) &&
+               (!player->videodec_linked) && (!player->audiodec_linked)) {
 
-               if (!internal_called)
-                       player->seek_state = MMPLAYER_SEEK_IN_PROGRESS;
+               LOGD("[%s] set position =%"GST_TIME_FORMAT,
+                               GST_ELEMENT_NAME(player->pipeline->mainbin[MMPLAYER_M_SRC].gst), GST_TIME_ARGS(position));
 
-               /* FIXIT : why don't we use 'GST_FORMAT_PERCENT' */
-               pos_nsec = (gint64)((position * player->duration) / 100);
-               ret = __mmplayer_gst_seek(player, player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, player->playback_rate,
+               g_object_set(player->pipeline->mainbin[MMPLAYER_M_SRC].gst, "pending-start-position", position, NULL);
+               player->seek_state = MMPLAYER_SEEK_NONE;
+               MMPLAYER_POST_MSG(player, MM_MESSAGE_SEEK_COMPLETED, NULL);
+       } else {
+               mm_attrs_get_int_by_name(player->attrs, "accurate_seek", &accurated);
+               if (accurated)
+                       seek_flags |= GST_SEEK_FLAG_ACCURATE;
+               else
+                       seek_flags |= GST_SEEK_FLAG_KEY_UNIT;
+
+               if (!__mmplayer_gst_seek(player, player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, player->playback_rate,
                                                GST_FORMAT_TIME, seek_flags,
-                                               GST_SEEK_TYPE_SET, pos_nsec, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
-               if (!ret) {
-                       LOGE("failed to set position. pos[%"G_GINT64_FORMAT"] dur[%"G_GINT64_FORMAT"] ", pos_nsec, player->duration);
+                                               GST_SEEK_TYPE_SET, position, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE)) {
+                       LOGE("failed to set position");
                        goto SEEK_ERROR;
                }
        }
-       break;
-
-       default:
-               goto INVALID_ARGS;
-       }
 
        /* NOTE : store last seeking point to overcome some bad operation
          *     (returning zero when getting current position) of some elements
          */
-       player->last_position = pos_nsec;
+       player->last_position = position;
 
        /* MSL should guarante playback rate when seek is selected during trick play of fast forward. */
        if (player->playback_rate > 1.0)
                _mmplayer_set_playspeed((MMHandleType)player, player->playback_rate, FALSE);
 
-       if ((!internal_called) &&
-           (player->streamer) && (player->streamer->buffering_state & MM_PLAYER_BUFFERING_IN_PROGRESS)) {
+       if ((player->streamer) && (player->streamer->buffering_state & MM_PLAYER_BUFFERING_IN_PROGRESS)) {
                LOGD("buffering should be reset after seeking");
                player->streamer->buffering_state = MM_PLAYER_BUFFERING_ABORT;
                player->streamer->buffering_percent = 100; /* after seeking, new per can be non-zero. */
@@ -3587,27 +3561,22 @@ __mmplayer_gst_set_position(mm_player_t* player, int format, gint64 position, gb
 
 PENDING:
        player->pending_seek.is_pending = TRUE;
-       player->pending_seek.format = format;
        player->pending_seek.pos = position;
 
-       LOGW("player current-state : %s, pending-state : %s, just preserve pending position(%"G_GINT64_FORMAT").\n",
+       LOGW("player current-state : %s, pending-state : %s, just preserve pending position(%"G_GINT64_FORMAT")",
                MMPLAYER_STATE_GET_NAME(MMPLAYER_CURRENT_STATE(player)),
                MMPLAYER_STATE_GET_NAME(MMPLAYER_PENDING_STATE(player)),
                player->pending_seek.pos);
 
        return MM_ERROR_NONE;
 
-INVALID_ARGS:
-       LOGE("invalid arguments, position: %"G_GINT64_FORMAT" dur : %"G_GINT64_FORMAT" format : %d \n", position, player->duration, format);
-       return MM_ERROR_INVALID_ARGUMENT;
-
 SEEK_ERROR:
        player->seek_state = MMPLAYER_SEEK_NONE;
        return MM_ERROR_PLAYER_SEEK;
 }
 
 int
-__mmplayer_gst_get_position(mm_player_t* player, int format, gint64* position)
+__mmplayer_gst_get_position(mm_player_t* player, gint64* position)
 {
 #define TRICKPLAY_OFFSET GST_MSECOND
 
@@ -3652,25 +3621,7 @@ __mmplayer_gst_get_position(mm_player_t* player, int format, gint64* position)
                player->last_position = pos_nsec;
        }
 
-       switch (format) {
-       case MM_PLAYER_POS_FORMAT_TIME:
-               *position = pos_nsec;
-               break;
-
-       case MM_PLAYER_POS_FORMAT_PERCENT:
-       {
-               if (player->duration <= 0) {
-                       LOGD("duration is [%"G_GINT64_FORMAT"], so returning position 0\n", player->duration);
-                       *position = 0;
-               } else {
-                       LOGD("position is [%"G_GINT64_FORMAT"] nsec , duration is [%"G_GINT64_FORMAT"] nsec", pos_nsec, player->duration);
-                       *position = (gint64)(pos_nsec * 100 / player->duration);
-               }
-               break;
-       }
-       default:
-               return MM_ERROR_PLAYER_INTERNAL;
-       }
+       *position = pos_nsec;
 
        return MM_ERROR_NONE;
 }
@@ -3703,22 +3654,22 @@ int __mmplayer_gst_get_buffer_position(mm_player_t* player, int format, unsigned
 
        if (!MMPLAYER_IS_HTTP_STREAMING(player)) {
                /* and rtsp is not ready yet. */
-               LOGW("it's only used for http streaming case.\n");
+               LOGW("it's only used for http streaming case");
                return MM_ERROR_PLAYER_NO_OP;
        }
 
        if (format != MM_PLAYER_POS_FORMAT_PERCENT) {
-               LOGW("Time format is not supported yet.\n");
+               LOGW("Time format is not supported yet");
                return MM_ERROR_INVALID_ARGUMENT;
        }
 
        if (content_size_time <= 0 || content_size_bytes <= 0) {
-               LOGW("there is no content size.");
+               LOGW("there is no content size");
                return MM_ERROR_NONE;
        }
 
-       if (__mmplayer_gst_get_position(player, MM_PLAYER_POS_FORMAT_TIME, &position) != MM_ERROR_NONE) {
-               LOGW("fail to get current position.");
+       if (__mmplayer_gst_get_position(player, &position) != MM_ERROR_NONE) {
+               LOGW("fail to get current position");
                return MM_ERROR_NONE;
        }
 
@@ -3802,7 +3753,7 @@ int __mmplayer_gst_get_buffer_position(mm_player_t* player, int format, unsigned
        *start_pos = CHECK_PERCENT_VALUE(start_per, 0, 100);
        *stop_pos = CHECK_PERCENT_VALUE(stop_per, *start_pos, 100);
 
-       LOGD("buffered info: %"G_GINT64_FORMAT" bytes, %d sec, per %lu~%lu\n",
+       LOGD("buffered info: %"G_GINT64_FORMAT" bytes, %d sec, per %lu~%lu",
                buffered_total, buffered_sec, *start_pos, *stop_pos);
 
        return MM_ERROR_NONE;
index 2e5b177..4c77459 100644 (file)
@@ -5353,7 +5353,7 @@ __resource_release_cb(mm_resource_manager_h rm, mm_resource_manager_res_h res,
                player->interrupted_by_resource = TRUE;
 
                /* get last play position */
-               if (_mmplayer_get_position((MMHandleType)player, MM_PLAYER_POS_FORMAT_TIME, &pos) != MM_ERROR_NONE) {
+               if (_mmplayer_get_position((MMHandleType)player, &pos) != MM_ERROR_NONE) {
                        LOGW("failed to get play position.");
                } else {
                        msg.union_type = MM_MSG_UNION_TIME;
@@ -6676,7 +6676,7 @@ _mmplayer_set_playspeed(MMHandleType hplayer, float rate, bool streaming)
 }
 
 int
-_mmplayer_set_position(MMHandleType hplayer, int format, gint64 position)
+_mmplayer_set_position(MMHandleType hplayer, gint64 position)
 {
        mm_player_t* player = (mm_player_t*)hplayer;
        int ret = MM_ERROR_NONE;
@@ -6688,7 +6688,7 @@ _mmplayer_set_position(MMHandleType hplayer, int format, gint64 position)
        /* check pipline building state */
        __mmplayer_check_pipeline(player);
 
-       ret = __mmplayer_gst_set_position(player, format, position, FALSE);
+       ret = __mmplayer_gst_set_position(player, position, FALSE);
 
        MMPLAYER_FLEAVE();
 
@@ -6696,14 +6696,14 @@ _mmplayer_set_position(MMHandleType hplayer, int format, gint64 position)
 }
 
 int
-_mmplayer_get_position(MMHandleType hplayer, int format, gint64 *position)
+_mmplayer_get_position(MMHandleType hplayer, gint64 *position)
 {
        mm_player_t* player = (mm_player_t*)hplayer;
        int ret = MM_ERROR_NONE;
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
-       ret = __mmplayer_gst_get_position(player, format, position);
+       ret = __mmplayer_gst_get_position(player, position);
 
        return ret;
 }
@@ -7413,7 +7413,6 @@ __mmplayer_initialize_next_play(mm_player_t *player)
        player->not_supported_codec = MISSING_PLUGIN_NONE;
        player->can_support_codec = FOUND_PLUGIN_NONE;
        player->pending_seek.is_pending = FALSE;
-       player->pending_seek.format = MM_PLAYER_POS_FORMAT_TIME;
        player->pending_seek.pos = 0;
        player->msg_posted = FALSE;
        player->has_many_types = FALSE;
@@ -8452,7 +8451,6 @@ __mmplayer_release_misc(mm_player_t* player)
        player->not_supported_codec = MISSING_PLUGIN_NONE;
        player->can_support_codec = FOUND_PLUGIN_NONE;
        player->pending_seek.is_pending = FALSE;
-       player->pending_seek.format = MM_PLAYER_POS_FORMAT_TIME;
        player->pending_seek.pos = 0;
        player->msg_posted = FALSE;
        player->has_many_types = FALSE;
@@ -9159,17 +9157,11 @@ __mmplayer_do_change_videosink(mm_player_t* player, const int dec_index, const c
                gint64 position = 0;
 
                LOGD("do get/set position for new videosink plugin");
-               if (__mmplayer_gst_get_position(player, MM_PLAYER_POS_FORMAT_TIME, &position)) {
+               if (__mmplayer_gst_get_position(player, &position)) {
                        LOGE("failed to get position");
                        return MM_ERROR_PLAYER_INTERNAL;
                }
-#ifdef SINKCHANGE_WITH_ACCURATE_SEEK
-               /* accurate seek */
-               if (__mmplayer_gst_set_position(player, MM_PLAYER_POS_FORMAT_TIME, position, TRUE)) {
-                       LOGE("failed to set position");
-                       return MM_ERROR_PLAYER_INTERNAL;
-               }
-#else
+
                /* key unit seek */
                ret = __mmplayer_gst_seek(player, player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, 1.0,
                                GST_FORMAT_TIME, (GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT),
@@ -9179,7 +9171,6 @@ __mmplayer_do_change_videosink(mm_player_t* player, const int dec_index, const c
                        LOGE("failed to set position");
                        return MM_ERROR_PLAYER_INTERNAL;
                }
-#endif
        }
 
        if (src_pad_dec)