2004-04-01 11:48:27 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* Copyright (C) <2003> David Schleef <ds@schleef.org>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-04 00:07:18 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2004-04-01 11:48:27 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file was (probably) generated from gstnavseek.c,
|
|
|
|
* gstnavseek.c,v 1.7 2003/11/08 02:48:59 dschleef Exp
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2021-02-15 13:55:15 +00:00
|
|
|
#include "gstdebugutilselements.h"
|
2005-10-05 11:38:29 +00:00
|
|
|
#include "gstnavseek.h"
|
2004-04-01 11:48:27 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
2015-04-27 10:22:11 +00:00
|
|
|
PROP_0,
|
2020-10-29 13:54:16 +00:00
|
|
|
PROP_SEEKOFFSET,
|
|
|
|
PROP_HOLD_EOS,
|
2004-04-01 11:48:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
GstStaticPadTemplate navseek_src_template = GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS_ANY);
|
|
|
|
|
|
|
|
GstStaticPadTemplate navseek_sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS_ANY);
|
|
|
|
|
2011-07-22 19:19:45 +00:00
|
|
|
static gboolean gst_navseek_sink_event (GstBaseTransform * trans,
|
|
|
|
GstEvent * event);
|
2005-10-05 11:38:29 +00:00
|
|
|
static GstFlowReturn gst_navseek_transform_ip (GstBaseTransform * basetrans,
|
|
|
|
GstBuffer * buf);
|
2011-07-22 19:19:45 +00:00
|
|
|
static gboolean gst_navseek_src_event (GstBaseTransform * trans,
|
|
|
|
GstEvent * event);
|
2005-10-05 11:38:29 +00:00
|
|
|
static gboolean gst_navseek_stop (GstBaseTransform * trans);
|
|
|
|
static gboolean gst_navseek_start (GstBaseTransform * trans);
|
|
|
|
|
2004-04-01 11:48:27 +00:00
|
|
|
static void gst_navseek_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_navseek_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
|
|
|
|
2010-03-17 17:23:00 +00:00
|
|
|
GType gst_navseek_get_type (void);
|
2011-06-07 10:06:08 +00:00
|
|
|
#define gst_navseek_parent_class parent_class
|
|
|
|
G_DEFINE_TYPE (GstNavSeek, gst_navseek, GST_TYPE_BASE_TRANSFORM);
|
2021-02-15 13:55:15 +00:00
|
|
|
GST_ELEMENT_REGISTER_DEFINE (navseek, "navseek",
|
|
|
|
GST_RANK_NONE, gst_navseek_get_type ());
|
2004-04-01 11:48:27 +00:00
|
|
|
|
|
|
|
static void
|
2005-10-05 11:38:29 +00:00
|
|
|
gst_navseek_class_init (GstNavSeekClass * klass)
|
2004-04-01 11:48:27 +00:00
|
|
|
{
|
2005-10-05 11:38:29 +00:00
|
|
|
GstBaseTransformClass *gstbasetrans_class;
|
2011-06-07 10:06:08 +00:00
|
|
|
GstElementClass *element_class;
|
2004-04-01 11:48:27 +00:00
|
|
|
GObjectClass *gobject_class;
|
|
|
|
|
2005-10-05 11:38:29 +00:00
|
|
|
gobject_class = G_OBJECT_CLASS (klass);
|
2011-06-07 10:06:08 +00:00
|
|
|
element_class = GST_ELEMENT_CLASS (klass);
|
2005-10-05 11:38:29 +00:00
|
|
|
gstbasetrans_class = GST_BASE_TRANSFORM_CLASS (klass);
|
|
|
|
|
|
|
|
gobject_class->set_property = gst_navseek_set_property;
|
|
|
|
gobject_class->get_property = gst_navseek_get_property;
|
2004-04-01 11:48:27 +00:00
|
|
|
|
2005-10-05 11:38:29 +00:00
|
|
|
g_object_class_install_property (gobject_class,
|
2015-04-27 10:22:11 +00:00
|
|
|
PROP_SEEKOFFSET, g_param_spec_double ("seek-offset", "Seek Offset",
|
2004-04-01 11:48:27 +00:00
|
|
|
"Time in seconds to seek by", 0.0, G_MAXDOUBLE, 5.0,
|
2010-10-13 14:21:23 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2020-10-29 13:54:16 +00:00
|
|
|
/**
|
|
|
|
* navseek:hold-eos:
|
|
|
|
*
|
|
|
|
* Hold eos until the next 'Return' keystroke.
|
|
|
|
*
|
|
|
|
* Since: 1.20
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_HOLD_EOS, g_param_spec_boolean ("hold-eos", "Hold EOS",
|
|
|
|
"Hold eos until the next 'Return' keystroke", FALSE,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2004-04-01 11:48:27 +00:00
|
|
|
|
2016-03-04 01:30:12 +00:00
|
|
|
gst_element_class_add_static_pad_template (element_class,
|
|
|
|
&navseek_sink_template);
|
|
|
|
gst_element_class_add_static_pad_template (element_class,
|
|
|
|
&navseek_src_template);
|
2011-06-07 10:06:08 +00:00
|
|
|
|
2012-04-09 23:51:41 +00:00
|
|
|
gst_element_class_set_static_metadata (element_class,
|
2011-06-07 10:06:08 +00:00
|
|
|
"Seek based on left-right arrows", "Filter/Video",
|
|
|
|
"Seek based on navigation keys left-right",
|
|
|
|
"Jan Schmidt <thaytan@mad.scientist.com>");
|
|
|
|
|
2011-07-22 19:19:45 +00:00
|
|
|
gstbasetrans_class->src_event = GST_DEBUG_FUNCPTR (gst_navseek_src_event);
|
|
|
|
gstbasetrans_class->sink_event = GST_DEBUG_FUNCPTR (gst_navseek_sink_event);
|
2005-10-05 11:38:29 +00:00
|
|
|
gstbasetrans_class->transform_ip =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_navseek_transform_ip);
|
|
|
|
gstbasetrans_class->start = GST_DEBUG_FUNCPTR (gst_navseek_start);
|
|
|
|
gstbasetrans_class->stop = GST_DEBUG_FUNCPTR (gst_navseek_stop);
|
2004-04-01 11:48:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-06-07 10:06:08 +00:00
|
|
|
gst_navseek_init (GstNavSeek * navseek)
|
2004-04-01 11:48:27 +00:00
|
|
|
{
|
2005-10-05 11:38:29 +00:00
|
|
|
gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (navseek), TRUE);
|
2004-06-18 22:32:44 +00:00
|
|
|
|
2004-04-01 11:48:27 +00:00
|
|
|
navseek->seek_offset = 5.0;
|
2004-06-18 22:32:44 +00:00
|
|
|
navseek->loop = FALSE;
|
2020-10-29 13:54:16 +00:00
|
|
|
navseek->hold_eos = FALSE;
|
|
|
|
navseek->eos = NULL;
|
2004-06-18 22:32:44 +00:00
|
|
|
navseek->grab_seg_start = FALSE;
|
|
|
|
navseek->grab_seg_end = FALSE;
|
|
|
|
navseek->segment_start = GST_CLOCK_TIME_NONE;
|
|
|
|
navseek->segment_end = GST_CLOCK_TIME_NONE;
|
2004-04-01 11:48:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_navseek_seek (GstNavSeek * navseek, gint64 offset)
|
|
|
|
{
|
2005-10-05 11:38:29 +00:00
|
|
|
gboolean ret;
|
|
|
|
GstPad *peer_pad;
|
|
|
|
gint64 peer_value;
|
2004-04-01 11:48:27 +00:00
|
|
|
|
2005-10-05 11:38:29 +00:00
|
|
|
/* Query for the current time then attempt to set to time + offset */
|
|
|
|
peer_pad = gst_pad_get_peer (GST_BASE_TRANSFORM (navseek)->sinkpad);
|
2011-07-28 09:54:38 +00:00
|
|
|
ret = gst_pad_query_position (peer_pad, GST_FORMAT_TIME, &peer_value);
|
2005-10-05 11:38:29 +00:00
|
|
|
|
2011-07-28 09:54:38 +00:00
|
|
|
if (ret) {
|
2005-10-05 11:38:29 +00:00
|
|
|
GstEvent *event;
|
2004-04-01 11:48:27 +00:00
|
|
|
|
|
|
|
peer_value += offset;
|
|
|
|
if (peer_value < 0)
|
|
|
|
peer_value = 0;
|
|
|
|
|
2005-10-05 11:38:29 +00:00
|
|
|
event = gst_event_new_seek (1.0, GST_FORMAT_TIME,
|
|
|
|
GST_SEEK_FLAG_ACCURATE | GST_SEEK_FLAG_FLUSH,
|
|
|
|
GST_SEEK_TYPE_SET, peer_value, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
|
|
|
|
|
|
|
|
gst_pad_send_event (peer_pad, event);
|
2004-04-01 11:48:27 +00:00
|
|
|
}
|
2005-10-05 11:38:29 +00:00
|
|
|
|
|
|
|
gst_object_unref (peer_pad);
|
2004-04-01 11:48:27 +00:00
|
|
|
}
|
|
|
|
|
2010-03-26 12:51:58 +00:00
|
|
|
static void
|
|
|
|
gst_navseek_change_playback_rate (GstNavSeek * navseek, gdouble rate)
|
|
|
|
{
|
|
|
|
gboolean ret;
|
|
|
|
GstPad *peer_pad;
|
|
|
|
gint64 current_position;
|
|
|
|
|
|
|
|
peer_pad = gst_pad_get_peer (GST_BASE_TRANSFORM (navseek)->sinkpad);
|
2011-07-28 09:54:38 +00:00
|
|
|
ret = gst_pad_query_position (peer_pad, GST_FORMAT_TIME, ¤t_position);
|
2010-03-26 12:51:58 +00:00
|
|
|
|
2011-07-28 09:54:38 +00:00
|
|
|
if (ret) {
|
2010-03-26 12:51:58 +00:00
|
|
|
GstEvent *event;
|
|
|
|
gint64 start;
|
|
|
|
gint64 stop;
|
|
|
|
|
|
|
|
if (rate > 0.0) {
|
|
|
|
start = current_position;
|
|
|
|
stop = -1;
|
|
|
|
} else {
|
|
|
|
/* negative rate: we play from stop to start */
|
|
|
|
start = 0;
|
|
|
|
stop = current_position;
|
|
|
|
}
|
|
|
|
|
|
|
|
event = gst_event_new_seek (rate, GST_FORMAT_TIME,
|
|
|
|
GST_SEEK_FLAG_ACCURATE | GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SKIP,
|
|
|
|
GST_SEEK_TYPE_SET, start, GST_SEEK_TYPE_SET, stop);
|
|
|
|
|
|
|
|
gst_pad_send_event (peer_pad, event);
|
|
|
|
}
|
2014-08-08 10:44:09 +00:00
|
|
|
gst_object_unref (peer_pad);
|
2010-03-26 12:51:58 +00:00
|
|
|
}
|
|
|
|
|
2004-06-18 22:32:44 +00:00
|
|
|
static void
|
|
|
|
gst_navseek_segseek (GstNavSeek * navseek)
|
|
|
|
{
|
|
|
|
GstEvent *event;
|
2005-10-05 11:38:29 +00:00
|
|
|
GstPad *peer_pad;
|
2004-06-18 22:32:44 +00:00
|
|
|
|
|
|
|
if ((navseek->segment_start == GST_CLOCK_TIME_NONE) ||
|
|
|
|
(navseek->segment_end == GST_CLOCK_TIME_NONE) ||
|
2005-10-05 11:38:29 +00:00
|
|
|
(!GST_PAD_IS_LINKED (GST_BASE_TRANSFORM (navseek)->sinkpad))) {
|
2004-06-18 22:32:44 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (navseek->loop) {
|
|
|
|
event =
|
2005-10-05 11:38:29 +00:00
|
|
|
gst_event_new_seek (1.0, GST_FORMAT_TIME,
|
|
|
|
GST_SEEK_FLAG_ACCURATE | GST_SEEK_FLAG_SEGMENT,
|
|
|
|
GST_SEEK_TYPE_SET, navseek->segment_start, GST_SEEK_TYPE_SET,
|
|
|
|
navseek->segment_end);
|
2004-06-18 22:32:44 +00:00
|
|
|
} else {
|
|
|
|
event =
|
2005-10-05 11:38:29 +00:00
|
|
|
gst_event_new_seek (1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_ACCURATE,
|
|
|
|
GST_SEEK_TYPE_SET, navseek->segment_start, GST_SEEK_TYPE_SET,
|
|
|
|
navseek->segment_end);
|
2004-06-18 22:32:44 +00:00
|
|
|
}
|
|
|
|
|
2005-10-05 11:38:29 +00:00
|
|
|
peer_pad = gst_pad_get_peer (GST_BASE_TRANSFORM (navseek)->sinkpad);
|
|
|
|
gst_pad_send_event (peer_pad, event);
|
|
|
|
gst_object_unref (peer_pad);
|
2004-06-18 22:32:44 +00:00
|
|
|
}
|
|
|
|
|
2011-09-14 15:37:12 +00:00
|
|
|
static void
|
|
|
|
gst_navseek_toggle_play_pause (GstNavSeek * navseek)
|
|
|
|
{
|
|
|
|
GstStateChangeReturn sret;
|
|
|
|
GstState current, pending, state;
|
|
|
|
|
|
|
|
sret = gst_element_get_state (GST_ELEMENT (navseek), ¤t, &pending, 0);
|
|
|
|
if (sret == GST_STATE_CHANGE_FAILURE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
state = (pending != GST_STATE_VOID_PENDING) ? pending : current;
|
|
|
|
|
|
|
|
gst_element_post_message (GST_ELEMENT (navseek),
|
|
|
|
gst_message_new_request_state (GST_OBJECT (navseek),
|
|
|
|
(state == GST_STATE_PLAYING) ? GST_STATE_PAUSED : GST_STATE_PLAYING));
|
|
|
|
}
|
|
|
|
|
2004-04-01 11:48:27 +00:00
|
|
|
static gboolean
|
2011-07-22 19:19:45 +00:00
|
|
|
gst_navseek_src_event (GstBaseTransform * trans, GstEvent * event)
|
2004-04-01 11:48:27 +00:00
|
|
|
{
|
|
|
|
GstNavSeek *navseek;
|
2005-10-05 11:38:29 +00:00
|
|
|
gboolean ret = TRUE;
|
2004-04-01 11:48:27 +00:00
|
|
|
|
2011-07-22 19:19:45 +00:00
|
|
|
navseek = GST_NAVSEEK (trans);
|
2004-04-01 11:48:27 +00:00
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_NAVIGATION:
|
|
|
|
{
|
2011-07-22 19:19:45 +00:00
|
|
|
/* Check for a keyup and convert left/right to a seek event */
|
2005-10-05 11:38:29 +00:00
|
|
|
const GstStructure *structure;
|
2004-04-01 11:48:27 +00:00
|
|
|
const gchar *event_type;
|
|
|
|
|
2005-10-05 11:38:29 +00:00
|
|
|
structure = gst_event_get_structure (event);
|
|
|
|
g_return_val_if_fail (structure != NULL, FALSE);
|
2004-04-01 11:48:27 +00:00
|
|
|
|
2005-10-05 11:38:29 +00:00
|
|
|
event_type = gst_structure_get_string (structure, "event");
|
|
|
|
g_return_val_if_fail (event_type != NULL, FALSE);
|
2004-04-01 11:48:27 +00:00
|
|
|
|
|
|
|
if (strcmp (event_type, "key-press") == 0) {
|
2005-10-05 11:38:29 +00:00
|
|
|
const gchar *key;
|
|
|
|
|
|
|
|
key = gst_structure_get_string (structure, "key");
|
|
|
|
g_return_val_if_fail (key != NULL, FALSE);
|
2004-04-01 11:48:27 +00:00
|
|
|
|
|
|
|
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);
|
2004-06-18 22:32:44 +00:00
|
|
|
} 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);
|
2010-03-26 12:51:58 +00:00
|
|
|
} 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);
|
2011-09-14 15:37:12 +00:00
|
|
|
} else if (strcmp (key, "space") == 0) {
|
|
|
|
gst_navseek_toggle_play_pause (navseek);
|
2020-10-29 13:54:16 +00:00
|
|
|
} else if (strcmp (key, "Return") == 0) {
|
|
|
|
if (navseek->eos) {
|
|
|
|
gst_pad_push_event (GST_BASE_TRANSFORM (navseek)->srcpad,
|
|
|
|
navseek->eos);
|
|
|
|
navseek->eos = NULL;
|
|
|
|
}
|
2004-04-01 11:48:27 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gst_event_unref (event);
|
|
|
|
event = NULL;
|
|
|
|
break;
|
2011-07-22 19:19:45 +00:00
|
|
|
}
|
2004-04-01 11:48:27 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2005-10-05 11:38:29 +00:00
|
|
|
|
2011-07-22 19:19:45 +00:00
|
|
|
if (event)
|
|
|
|
ret = GST_BASE_TRANSFORM_CLASS (parent_class)->src_event (trans, event);
|
2005-10-05 11:38:29 +00:00
|
|
|
|
|
|
|
return ret;
|
2004-04-01 11:48:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_navseek_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2005-10-05 11:38:29 +00:00
|
|
|
GstNavSeek *navseek = GST_NAVSEEK (object);
|
2004-04-01 11:48:27 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
2015-04-27 10:22:11 +00:00
|
|
|
case PROP_SEEKOFFSET:
|
2005-11-21 16:36:05 +00:00
|
|
|
GST_OBJECT_LOCK (navseek);
|
2005-10-05 11:38:29 +00:00
|
|
|
navseek->seek_offset = g_value_get_double (value);
|
2005-11-21 16:36:05 +00:00
|
|
|
GST_OBJECT_UNLOCK (navseek);
|
2004-04-01 11:48:27 +00:00
|
|
|
break;
|
2020-10-29 13:54:16 +00:00
|
|
|
case PROP_HOLD_EOS:
|
|
|
|
GST_OBJECT_LOCK (navseek);
|
|
|
|
navseek->hold_eos = g_value_get_boolean (value);
|
|
|
|
GST_OBJECT_UNLOCK (navseek);
|
|
|
|
break;
|
2004-04-01 11:48:27 +00:00
|
|
|
default:
|
2005-10-05 11:38:29 +00:00
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
2004-04-01 11:48:27 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_navseek_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2005-10-05 11:38:29 +00:00
|
|
|
GstNavSeek *navseek = GST_NAVSEEK (object);
|
2004-04-01 11:48:27 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
2015-04-27 10:22:11 +00:00
|
|
|
case PROP_SEEKOFFSET:
|
2005-11-21 16:36:05 +00:00
|
|
|
GST_OBJECT_LOCK (navseek);
|
2005-10-05 11:38:29 +00:00
|
|
|
g_value_set_double (value, navseek->seek_offset);
|
2005-11-21 16:36:05 +00:00
|
|
|
GST_OBJECT_UNLOCK (navseek);
|
2004-04-01 11:48:27 +00:00
|
|
|
break;
|
2020-10-29 13:54:16 +00:00
|
|
|
case PROP_HOLD_EOS:
|
|
|
|
GST_OBJECT_LOCK (navseek);
|
|
|
|
g_value_set_boolean (value, navseek->hold_eos);
|
|
|
|
GST_OBJECT_UNLOCK (navseek);
|
|
|
|
break;
|
2004-04-01 11:48:27 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-10-05 11:38:29 +00:00
|
|
|
static gboolean
|
2011-07-22 19:19:45 +00:00
|
|
|
gst_navseek_sink_event (GstBaseTransform * trans, GstEvent * event)
|
2004-04-01 11:48:27 +00:00
|
|
|
{
|
2005-10-05 11:38:29 +00:00
|
|
|
GstNavSeek *navseek = GST_NAVSEEK (trans);
|
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_EOS:
|
2005-11-21 16:36:05 +00:00
|
|
|
GST_OBJECT_LOCK (navseek);
|
2005-10-05 11:38:29 +00:00
|
|
|
if (navseek->loop)
|
|
|
|
gst_navseek_segseek (navseek);
|
2020-10-29 13:54:16 +00:00
|
|
|
if (navseek->hold_eos)
|
|
|
|
navseek->eos = event;
|
2005-11-21 16:36:05 +00:00
|
|
|
GST_OBJECT_UNLOCK (navseek);
|
2020-10-29 13:54:16 +00:00
|
|
|
if (navseek->eos)
|
|
|
|
return TRUE;
|
2005-10-05 11:38:29 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2011-07-22 19:19:45 +00:00
|
|
|
return GST_BASE_TRANSFORM_CLASS (parent_class)->sink_event (trans, event);
|
2005-10-05 11:38:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_navseek_transform_ip (GstBaseTransform * basetrans, GstBuffer * buf)
|
|
|
|
{
|
|
|
|
GstNavSeek *navseek = GST_NAVSEEK (basetrans);
|
2004-04-01 11:48:27 +00:00
|
|
|
|
2005-11-21 16:36:05 +00:00
|
|
|
GST_OBJECT_LOCK (navseek);
|
2004-06-18 22:32:44 +00:00
|
|
|
|
2005-10-05 11:38:29 +00:00
|
|
|
if (GST_BUFFER_TIMESTAMP_IS_VALID (buf)) {
|
2004-06-18 22:32:44 +00:00
|
|
|
if (navseek->grab_seg_start) {
|
2005-10-05 11:38:29 +00:00
|
|
|
navseek->segment_start = GST_BUFFER_TIMESTAMP (buf);
|
2004-06-18 22:32:44 +00:00
|
|
|
navseek->segment_end = GST_CLOCK_TIME_NONE;
|
|
|
|
navseek->grab_seg_start = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (navseek->grab_seg_end) {
|
2005-10-05 11:38:29 +00:00
|
|
|
navseek->segment_end = GST_BUFFER_TIMESTAMP (buf);
|
2004-06-18 22:32:44 +00:00
|
|
|
navseek->grab_seg_end = FALSE;
|
|
|
|
gst_navseek_segseek (navseek);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-21 16:36:05 +00:00
|
|
|
GST_OBJECT_UNLOCK (navseek);
|
2005-10-05 11:38:29 +00:00
|
|
|
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_navseek_start (GstBaseTransform * trans)
|
|
|
|
{
|
|
|
|
/* anything we should be doing here? */
|
|
|
|
return TRUE;
|
|
|
|
}
|
2004-06-18 22:32:44 +00:00
|
|
|
|
2005-10-05 11:38:29 +00:00
|
|
|
static gboolean
|
|
|
|
gst_navseek_stop (GstBaseTransform * trans)
|
|
|
|
{
|
2020-10-29 13:54:16 +00:00
|
|
|
GstNavSeek *navseek = GST_NAVSEEK (trans);
|
|
|
|
|
|
|
|
if (navseek->eos) {
|
|
|
|
gst_event_unref (navseek->eos);
|
|
|
|
navseek->eos = NULL;
|
|
|
|
}
|
2005-10-05 11:38:29 +00:00
|
|
|
return TRUE;
|
2004-04-01 11:48:27 +00:00
|
|
|
}
|