static gboolean gst_navseek_src_event (GstBaseTransform * trans, GstEvent * event) { GstNavSeek *navseek; gboolean ret = TRUE; navseek = GST_NAVSEEK (trans); switch (GST_EVENT_TYPE (event)) { case GST_EVENT_NAVIGATION: { /* Check for a keyup and convert left/right to a seek event */ const GstStructure *structure; const gchar *event_type; structure = gst_event_get_structure (event); g_return_val_if_fail (structure != NULL, FALSE); event_type = gst_structure_get_string (structure, "event"); g_return_val_if_fail (event_type != NULL, FALSE); if (strcmp (event_type, "key-press") == 0) { const gchar *key; key = gst_structure_get_string (structure, "key"); g_return_val_if_fail (key != NULL, FALSE); if (strcmp (key, "Left") == 0) { /* Seek backward by 5 secs */ gst_navseek_seek (navseek, -1.0 * navseek->seek_offset * GST_SECOND); } else if (strcmp (key, "Right") == 0) { /* Seek forward */ gst_navseek_seek (navseek, navseek->seek_offset * GST_SECOND); } else if (strcmp (key, "s") == 0) { /* Grab the next frame as the start frame of a segment */ navseek->grab_seg_start = TRUE; } else if (strcmp (key, "e") == 0) { /* Grab the next frame as the end frame of a segment */ navseek->grab_seg_end = TRUE; } else if (strcmp (key, "l") == 0) { /* Toggle the loop flag. If we have both start and end segment times send a seek */ navseek->loop = !navseek->loop; gst_navseek_segseek (navseek); } else if (strcmp (key, "f") == 0) { /* fast forward */ gst_navseek_change_playback_rate (navseek, 2.0); } else if (strcmp (key, "r") == 0) { /* rewind */ gst_navseek_change_playback_rate (navseek, -2.0); } else if (strcmp (key, "n") == 0) { /* normal speed */ gst_navseek_change_playback_rate (navseek, 1.0); } else if (strcmp (key, "space") == 0) { gst_navseek_toggle_play_pause (navseek); } } else { break; } gst_event_unref (event); event = NULL; break; } default: break; } if (event) ret = GST_BASE_TRANSFORM_CLASS (parent_class)->src_event (trans, event); return ret; }
static gboolean gst_navseek_handle_src_event (GstPad * pad, GstEvent * event) { GstNavSeek *navseek; gboolean ret = TRUE; navseek = GST_NAVSEEK (GST_PAD_PARENT (pad)); switch (GST_EVENT_TYPE (event)) { case GST_EVENT_NAVIGATION: /* Check for a keyup and convert left/right to a seek event */ { const GstStructure *structure; const gchar *event_type; structure = gst_event_get_structure (event); g_return_val_if_fail (structure != NULL, FALSE); event_type = gst_structure_get_string (structure, "event"); g_return_val_if_fail (event_type != NULL, FALSE); if (strcmp (event_type, "key-press") == 0) { const gchar *key; key = gst_structure_get_string (structure, "key"); g_return_val_if_fail (key != NULL, FALSE); if (strcmp (key, "Left") == 0) { /* Seek backward by 5 secs */ gst_navseek_seek (navseek, -1.0 * navseek->seek_offset * GST_SECOND); } else if (strcmp (key, "Right") == 0) { /* Seek forward */ gst_navseek_seek (navseek, navseek->seek_offset * GST_SECOND); } else if (strcmp (key, "s") == 0) { /* Grab the next frame as the start frame of a segment */ navseek->grab_seg_start = TRUE; } else if (strcmp (key, "e") == 0) { /* Grab the next frame as the end frame of a segment */ navseek->grab_seg_end = TRUE; } else if (strcmp (key, "l") == 0) { /* Toggle the loop flag. If we have both start and end segment times send a seek */ navseek->loop = !navseek->loop; gst_navseek_segseek (navseek); } } else { break; } gst_event_unref (event); event = NULL; } break; default: break; } if (event && GST_PAD_IS_LINKED (GST_BASE_TRANSFORM (navseek)->sinkpad)) { GstPad *peer_pad = gst_pad_get_peer (GST_BASE_TRANSFORM (navseek)->sinkpad); ret = gst_pad_send_event (peer_pad, event); gst_object_unref (peer_pad); } return ret; }