Commit facd5e5b authored by Lori Anderson's avatar Lori Anderson

Added the "seek_percent" cmd line arg to test a byte seek which is based on...

Added the "seek_percent" cmd line arg to test a byte seek which is based on the duration of the content.
parent a144690a
......@@ -50,6 +50,7 @@ static gboolean g_handle_buffering = FALSE;
static gboolean g_use_dtcp = FALSE;
static gboolean g_format_bytes = FALSE;
static gint g_seek_secs = 0;
static gint g_seek_percent = 0;
static gboolean g_zero_position = FALSE;
static gboolean g_positions = FALSE;
......@@ -117,6 +118,7 @@ static gboolean perform_test_query(CustomData* data, gint64* position, GstFormat
static gboolean perform_test_seek(CustomData* data, gint64 position, GstFormat format, gfloat rate);
static gboolean perform_test_states(CustomData* data);
static gboolean perform_test_playspeeds(CustomData* data);
static gboolean perform_test_seek_byte_percent(CustomData* data);
static gboolean set_pipeline_state(GstElement* pipeline, GstState desired_state, gint timeoutSecs);
static gboolean set_new_uri(CustomData* data);
......@@ -541,6 +543,18 @@ static gboolean process_cmd_line_args(int argc, char *argv[])
g_print("Set requested seek secs to %d\n", g_seek_secs);
}
}
else if (strstr(argv[i], "seek_percent=") != NULL)
{
if (sscanf(argv[i], "seek_percent=%d", &g_seek_percent) != 1)
{
g_printerr("Invalid seek percent arg specified: %s\n", argv[i]);
return FALSE;
}
else
{
g_print("Set requested seek percent to %d\n", g_seek_percent);
}
}
else
{
g_printerr("Invalid option: %s\n", argv[i]);
......@@ -561,6 +575,7 @@ static gboolean process_cmd_line_args(int argc, char *argv[])
g_printerr("\t position \t\t test positioning of seeks\n");
g_printerr("\t rate=y \t\t where y is desired rate\n");
g_printerr("\t rrid=i \t\t where i is cds recording id\n");
g_printerr("\t seek_percent \t\t perform byte based seek to specified percent of total byte size\n");
g_printerr("\t seek_secs \t\t perform seek to specified seconds\n");
g_printerr("\t simple \t\t create simple pipeline rather than playbin\n");
g_printerr("\t states \t\t test state changes\n");
......@@ -1425,6 +1440,10 @@ static void perform_test(CustomData* data)
g_usleep(g_wait_secs * 1000000L);
perform_test_seek(data, g_seek_secs*GST_SECOND, GST_FORMAT_TIME, 1);
}
else if (g_seek_percent != 0)
{
perform_test_seek_byte_percent(data);
}
// Wait until error or EOS
bus = gst_element_get_bus (data->pipeline);
......@@ -1693,6 +1712,35 @@ static gboolean perform_test_seek(CustomData* data, gint64 start_position, GstFo
return TRUE;
}
static gboolean perform_test_seek_byte_percent(CustomData* data)
{
gint64 total_bytes;
guint64 position;
gfloat percent;
g_print("%s - Seek to byte percent: %d\n", __FUNCTION__, g_seek_percent);
g_usleep(g_wait_secs * 1000000L);
if (!gst_element_query_duration (data->pipeline, GST_FORMAT_BYTES, &total_bytes))
{
g_printerr ("Could not query current duration.\n");
return FALSE;
}
else
{
g_print("%s - Got total bytes: %" G_GINT64_FORMAT " \n", __FUNCTION__, total_bytes);
}
// Calculate byte for percent requested
percent = g_seek_percent / 100.0;
position = (guint64)(percent * total_bytes);
g_print("%s - Byte position is %" G_GUINT64_FORMAT " based on %d percent\n",
__FUNCTION__, position, g_seek_percent);
return perform_test_seek(data, position, GST_FORMAT_BYTES, 1);
}
static gboolean perform_test_playspeeds(CustomData* data)
{
GIOChannel *io_stdin;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment