#define MS_SAFE_UNREF(src) {if (src) { gst_object_unref(GST_OBJECT(src)); src = NULL; } }
#define MS_TABLE_SAFE_UNREF(src) {if (src) { g_hash_table_unref(src); src = NULL; } }
+#define MS_TIME_NONE ((int)-1)
+
/* Ini Utils */
#define MEDIA_STREAMER_INI_DEFAULT_PATH "/usr/etc/media_streamer.ini"
#define MEDIA_STREAMER_INI_MAX_STRLEN 100
ms_retvm_if(ms_streamer->is_seeking, MEDIA_STREAMER_ERROR_INVALID_STATE, "Media streamer is seeking");
int ret = MEDIA_STREAMER_ERROR_NONE;
+ int duration = MS_TIME_NONE;
+
g_mutex_lock(&ms_streamer->mutex_lock);
- ms_streamer->seek_done_cb.callback = callback;
- ms_streamer->seek_done_cb.user_data = user_data;
+ /* if query duration failed or returns duration value MS_TIME_NONE,
+ * we suppose that pipeline does not support seek. */
+ ret = __ms_get_duration(ms_streamer, &duration);
+ if (ret == MEDIA_STREAMER_ERROR_NONE && duration != MS_TIME_NONE) {
+ ms_streamer->seek_done_cb.callback = callback;
+ ms_streamer->seek_done_cb.user_data = user_data;
- ret = __ms_streamer_seek(streamer, time, accurate);
+ ret = __ms_streamer_seek(streamer, time, accurate);
+ } else
+ ret = MEDIA_STREAMER_ERROR_NOT_SUPPORTED;
g_mutex_unlock(&ms_streamer->mutex_lock);
#include "media_streamer_node.h"
#include "media_streamer_gst.h"
+#define GST_TIME_TO_MSEC(t) (t == GST_CLOCK_TIME_NONE ? t : (int)(((GstClockTime)(t)) / GST_MSECOND))
+
int __ms_state_change(media_streamer_s * ms_streamer, media_streamer_state_e state)
{
int ret = MEDIA_STREAMER_ERROR_NONE;
ms_retvm_if(ms_streamer == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "Handle is NULL");
ms_retvm_if(time == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "Return value is NULL");
- gint64 current = -1;
+ gint64 current = GST_CLOCK_TIME_NONE;
if (!gst_element_query_position(ms_streamer->pipeline, GST_FORMAT_TIME, ¤t)) {
ms_error("Could not query current position.");
return MEDIA_STREAMER_ERROR_INVALID_OPERATION;
} else {
- *time = (int)(((GstClockTime) (current)) / GST_MSECOND);
+ *time = GST_TIME_TO_MSEC(current);
ms_info("Media streamer queried position at [%d] msec successfully.", *time);
}
ms_retvm_if(ms_streamer == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "Handle is NULL");
ms_retvm_if(time == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "Return value is NULL");
- gint64 duration = -1;
+ gint64 duration = GST_CLOCK_TIME_NONE;
if (!gst_element_query_duration(ms_streamer->pipeline, GST_FORMAT_TIME, &duration)) {
ms_error("Could not query current duration.");
return MEDIA_STREAMER_ERROR_INVALID_OPERATION;
} else {
- *time = (int)(((GstClockTime)(duration)) / GST_MSECOND);
+ *time = GST_TIME_TO_MSEC(duration);
ms_info("Media streamer queried duration [%d] msec successfully.", *time);
}