Seek With Alaw pipeline
Anuroop Jesu
jesuas at gmail.com
Wed Apr 20 08:24:41 PDT 2011
Hi,
Does any one tried the seek on alaw pipeline.
I could able to record and playback the alaw file but seek forward and
backward on the
pipeline is failing.
Below is the code for seek which works perfectly fine for the mp3 playback
pipeline.
static void seekMediaTime (int ff, int time_seconds)
{
gint64 start_pos, stop_pos, rate;
gint64 start_flag, stop_flag;
gint64 pos, len, tmp = 0;
gint64 timeFf = FF_SPEED_BASE;
GstFormat fmt = GST_FORMAT_TIME;
/* If media is not playing */
if (recordEng.recStatus != REC_PAUSE)
return;
gst_element_query_duration (recordEng.recPipeline, &fmt, &len);
gst_element_query_position (recordEng.recPipeline, &fmt, &pos);
if (ff == 0)
{
timeFf = ((gint64)FF_SPEED_BASE * time_seconds);
if ((len <= (pos + timeFf)) || (len == pos))
timeFf = 0;
else
tmp = pos + timeFf;
printf ("FORWARDWORD BY:%llu\r\n",timeFf);
}
else
{
timeFf = ((gint64)FF_SPEED_BASE * time_seconds);
if ((pos <= timeFf) || (len == pos))
timeFf = 0;
else
tmp = (pos - timeFf);
printf ("BACKWORD BY:%llu\r\n",timeFf);
}
g_print ("Current Pos Time: %llu %llu\r\n",pos,len);
g_print ("Set Pos Time: %llu\r\n",tmp);
timeFf = tmp;
rate = 1.0;
start_pos = timeFf;
start_flag = GST_SEEK_TYPE_SET;
stop_flag = GST_SEEK_TYPE_NONE;
stop_pos = GST_CLOCK_TIME_NONE;
if (recordEng.recStatus == REC_PLAYING)
gst_element_set_state(GST_ELEMENT(recordEng.recPipeline),
GST_STATE_PAUSED);
if (!gst_element_seek (recordEng.recPipeline, rate,
GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH,
start_flag, start_pos,
stop_flag, stop_pos))
{
g_print ("Seek failed!\r\n");
}
else
{
g_print ("Time: %" GST_TIME_FORMAT " / %"
GST_TIME_FORMAT "\r\n",
GST_TIME_ARGS (pos), GST_TIME_ARGS (len));
/* We will wait til it is running or failed */
if (gst_element_get_state (recordEng.recPipeline,
NULL, NULL, -1) == GST_STATE_CHANGE_FAILURE)
{
g_print ("Failed to go into PLAYING state\r\n");
}
}
if (recordEng.recStatus == REC_PLAYING)
gst_element_set_state(GST_ELEMENT(recordEng.recPipeline),
GST_STATE_PLAYING);
}
With Warm Regards
Jesu Anuroop Suresh
"Any intelligent fool can make things bigger, more complex, and more
violent. It takes a touch of genius -- and a lot of courage -- to move in
the opposite direction."
"Anyone who has never made a mistake has never tried anything new."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20110420/631be667/attachment.htm>
More information about the gstreamer-devel
mailing list