/* Private functions definition */
+/**
+ * @brief Gets the play position of Media streamer element.
+ *
+ * @since_tizen 3.0
+ */
+int __ms_get_position(media_streamer_s *ms_streamer, int *time);
+
/**
* @brief Seeks Media streamer element to the pointed position.
*
g_mutex_lock(&ms_streamer->mutex_lock);
- ret = __ms_state_change(ms_streamer, MEDIA_STREAMER_STATE_PAUSED);
- /* TODO: do seek to 0 position. */
+ ret = __ms_streamer_seek(streamer, 0, FALSE);
+
+ if (ret != MEDIA_STREAMER_ERROR_NONE)
+ ms_error("Error while putting media streamer to zero playing position");
+ else
+ ret = __ms_state_change(ms_streamer, MEDIA_STREAMER_STATE_PAUSED);
g_mutex_unlock(&ms_streamer->mutex_lock);
media_streamer_s *ms_streamer = (media_streamer_s *) streamer;
ms_retvm_if(ms_streamer == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "Handle is NULL");
- return MEDIA_STREAMER_ERROR_NONE;
+ ms_retvm_if(ms_streamer->state < MEDIA_STREAMER_STATE_READY || ms_streamer->state > MEDIA_STREAMER_STATE_PAUSED, MEDIA_STREAMER_ERROR_INVALID_STATE, "The media streamer state is not in the appropriate state");
+
+ int ret = MEDIA_STREAMER_ERROR_NONE;
+ g_mutex_lock(&ms_streamer->mutex_lock);
+
+ ret = __ms_get_position(streamer, time);
+
+ g_mutex_unlock(&ms_streamer->mutex_lock);
+
+ return ret;
}
int media_streamer_node_push_packet(media_streamer_node_h src, media_packet_h packet)
while (GST_ITERATOR_OK == gst_iterator_next(sink_pad_iterator, &sink_pad_value)) {
GstPad *sink_pad = (GstPad *) g_value_get_object(&sink_pad_value);
- /* Check if sink pad of found element is unlinked */
+ /* If sink pad of found element is unlinked, */
+ /* next mediastreamer element is found unlinked element. */
if (!gst_pad_is_linked(sink_pad)) {
unlinked_sink_pad_found = TRUE;
linked_sink_element = NULL;
} else {
- /* Check if src pad of previous element is linked to sink pad of found element */
- src_pad_iterator = gst_element_iterate_src_pads(previous_elem);
- while (GST_ITERATOR_OK == gst_iterator_next(src_pad_iterator, &src_pad_value)) {
- GstPad *src_pad = (GstPad *) g_value_get_object(&src_pad_value);
- if (src_pad == gst_pad_get_peer(sink_pad))
- linked_sink_element = found_element;
+ if (previous_elem) {
+
+ /* If previous element is set, */
+ /* check if src pad of previous element is linked to sink pad of found element */
+ src_pad_iterator = gst_element_iterate_src_pads(previous_elem);
+ while (GST_ITERATOR_OK == gst_iterator_next(src_pad_iterator, &src_pad_value)) {
+ GstPad *src_pad = (GstPad *) g_value_get_object(&src_pad_value);
+
+ /* If pads are linked to each other, */
+ /* Next mediastreamer element will be found linked element */
+ GstPad *peer_pad = gst_pad_get_peer(sink_pad);
+ if (src_pad == peer_pad)
+ linked_sink_element = found_element;
+ MS_SAFE_UNREF(peer_pad);
+ g_value_reset(&src_pad_value);
+ }
+ g_value_unset(&src_pad_value);
+ gst_iterator_free(src_pad_iterator);
+ } else {
- g_value_reset(&src_pad_value);
+ /* Previous element is not set. */
+ /* Next mediastreamer element will be found linked element */
+ linked_sink_element = found_element;
}
- g_value_unset(&src_pad_value);
- gst_iterator_free(src_pad_iterator);
}
g_value_reset(&sink_pad_value);
}
g_value_unset(&sink_pad_value);
gst_iterator_free(sink_pad_iterator);
- /* Check if found element has unlinked sink pad, then return the found element */
if (unlinked_sink_pad_found) {
if (bin_name == NULL || g_strrstr(GST_ELEMENT_NAME(found_element), bin_name)) {
found = TRUE;
g_value_reset(&element_value);
}
- /* If found element is of the needed class but has been linked previously by user,
- we return this found element for further connection */
+ /* If found element is of the needed plugin class but has been linked previously by user, */
+ /* we return this found element for further connection */
if (linked_sink_element && (bin_name == NULL || g_strrstr(GST_ELEMENT_NAME(linked_sink_element), bin_name))) {
found_element = linked_sink_element;
found = TRUE;
parent_element = (GstElement *) gst_element_get_parent(previous_element);
- /*Look for node created by user */
+ /* Look for node created by user */
if (next_elem_klass_name)
found_element = __ms_bin_find_element_by_klass(parent_element, previous_element, next_elem_klass_name, next_elem_bin_name);
MS_SAFE_UNREF(src_pad);
}
- /*Add created element */
+ /* Add created element */
if (found_element) {
if (__ms_bin_add_element(parent_element, found_element, FALSE)) {
gst_element_sync_state_with_parent(found_element);
return __ms_pipeline_create(ms_streamer);
}
-int __ms_streamer_seek(media_streamer_s * ms_streamer, int g_time, bool flag)
+int __ms_get_position(media_streamer_s *ms_streamer, int *time)
+{
+ ms_retvm_if(ms_streamer == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "Handle is NULL");
+
+ gint64 current = -1;
+
+ 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);
+ ms_info("Media streamer queried position at [%d] msec successfully.", *time);
+ }
+
+ return MEDIA_STREAMER_ERROR_NONE;
+}
+
+int __ms_streamer_seek(media_streamer_s *ms_streamer, int g_time, bool flag)
{
ms_retvm_if(ms_streamer == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "Handle is NULL");
ms_streamer->is_seeking = TRUE;
}
- ms_info("Media streamer pipeline seeked successfully.");
+ ms_info("Media streamer pipeline seeked successfully to [%d] position", g_time);
return MEDIA_STREAMER_ERROR_NONE;
}
#define DEFAULT_SEEK_POS 0
#define MSEC_MULTIPLIER 1000
-
#define VIDEO_PORT 5000
#define AUDIO_PORT 6000
static void streamer_seek_cb(void *user_data)
{
g_print("Media Streamer seeked to required position \n");
+
+ int current_time = 0;
+
+ media_streamer_get_play_position(current_media_streamer, ¤t_time);
+
+ g_print("Current play position [%02d:%02d:%03d] \n", current_time/(1000*60),
+ (current_time/1000)%60, current_time%1000);
}
static void _create(media_streamer_h *streamer)
media_streamer_node_add(current_media_streamer, video_sink);
/*====================Linking Video Client=========================== */
- media_streamer_node_link(video_depay, "src", video_dec, "sink");
- media_streamer_node_link(video_dec, "src", video_conv, "sink");
- media_streamer_node_link(video_conv, "src", video_sink, "sink");
+ media_streamer_node_link(video_depay, "src", video_dec, "sink");
+ media_streamer_node_link(video_dec, "src", video_conv, "sink");
+ media_streamer_node_link(video_conv, "src", video_sink, "sink");
g_print("== success client video part \n");
}
static int count = 0;
- /* Try send only 10 packets*/
+ /* Try send only 10 packets */
if (status == MEDIA_STREAMER_CUSTOM_BUFFER_UNDERRUN && count < 10) {
g_print("Buffer status cb got underflow\n");
g_print("----------------------------------------------------\n");
g_print("\n");
g_print("Please select Playing Scenario mode\n");
- g_print("By default will be used [%d] mode\n", g_scenario_mode);
+ g_print("By default will be used [%d] mode\n", g_scenario_mode);
g_print("1. VideoFile playing \n");
g_print("2. VideoFile + SubtitleFile playing \n");
g_print("3. HTTP Source playing \n");
g_sub_menu_state = SUBMENU_STATE_UNKNOWN;
}
-
void _interpret_scenario_menu(char *cmd)
{
int len = strlen(cmd);
g_sub_menu_state = SUBMENU_STATE_GETTING_VIDEOFILE_URI;
} else if (g_menu_preset == PRESET_RTP_CLIENT) {
create_formats();
- media_streamer_node_h rtp_bin = _create_rtp(VIDEO_PORT, AUDIO_PORT, TRUE);
+ _create_rtp(VIDEO_PORT, AUDIO_PORT, TRUE);
g_sub_menu_state = SUBMENU_STATE_UNKNOWN;
}
}
}
} else {
if (g_scenario_mode == SCENARIO_MODE_FILE_STREAM_VIDEO_AUDIO) {
- media_streamer_node_h rtp_bin = NULL;
create_formats();
_create_file_streaming();
_create_rtp(VIDEO_PORT, AUDIO_PORT, FALSE);