[Bug 764055] gst_event_new_seek

GStreamer (GNOME Bugzilla) bugzilla at gnome.org
Thu Mar 24 03:48:47 UTC 2016


https://bugzilla.gnome.org/show_bug.cgi?id=764055

--- Comment #8 from ShengyiLiu <liushengyi2012 at 163.com> ---
 I only add the code to the demo
(https://cgit.freedesktop.org/~slomo/gst-sdk-tutorials/tree/gst-sdk/tutorials/android-tutorial-5).

/* Send seek event to change rate */
static void gst_set_rate (JNIEnv* env,jobject thiz, jdouble rate) {
    gint64 position;
    GstEvent *seek_event;

    CustomData *data = GET_CUSTOM_DATA (env, thiz, custom_data_field_id);
    if (!data)
        return ;

    /* Obtain the current position, needed for the seek event */
    if (!gst_element_query_position (data->pipeline, GST_FORMAT_TIME,
&position)) {
        LOG_ERROR("Unable to retrieve current position.\n");
        return;
    }

    gint desired_position=position/GST_MSECOND;
    LOG_INFO("send_seek_event position:%d\n",desired_position);

    /* Create the seek event */
    if (rate> 0) {
        seek_event = gst_event_new_seek (rate, GST_FORMAT_TIME,
GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
                                         GST_SEEK_TYPE_SET, position,
GST_SEEK_TYPE_SET, -1);
    } else {
        seek_event = gst_event_new_seek (rate, GST_FORMAT_TIME,
GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
                GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_SET, position);
    }

    if (data->video_sink == NULL) {
        g_object_get (data->pipeline, "video-sink", &data->video_sink, NULL);
    }

    /* Send the event */
    gst_element_send_event (data->video_sink, seek_event);

    LOG_INFO("send_seek_event rate:%f\n",rate);
}

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.


More information about the gstreamer-bugs mailing list