mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 18:05:37 +00:00
ext/raw1394/gstdv1394src.c: Clean up for style before doing some hacking. The only change should be that the state ch...
Original commit message from CVS: 2005-10-07 Andy Wingo <wingo@pobox.com> * ext/raw1394/gstdv1394src.c: Clean up for style before doing some hacking. The only change should be that the state change stuff was put into basesrc's start() and stop() routines, which coalesces some steps.
This commit is contained in:
parent
76f35f988f
commit
19712f28f6
3 changed files with 129 additions and 238 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2005-10-07 Andy Wingo <wingo@pobox.com>
|
||||||
|
|
||||||
|
* ext/raw1394/gstdv1394src.c: Clean up for style before doing some
|
||||||
|
hacking. The only change should be that the state change stuff was
|
||||||
|
put into basesrc's start() and stop() routines, which coalesces
|
||||||
|
some steps.
|
||||||
|
|
||||||
2005-10-07 Tim-Philipp Müller <tim at centricular dot net>
|
2005-10-07 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
* configure.ac:
|
* configure.ac:
|
||||||
|
|
2
common
2
common
|
@ -1 +1 @@
|
||||||
Subproject commit fb4bd52a0a6e882bd8eb0ca836edd94d3fcaea42
|
Subproject commit eb0dd118a086dd4aa405d3871131839d81306245
|
|
@ -40,7 +40,6 @@ GST_DEBUG_CATEGORY_STATIC (dv1394src_debug);
|
||||||
#define NTSC_FRAMESIZE 120000
|
#define NTSC_FRAMESIZE 120000
|
||||||
#define NTSC_FRAMERATE 30
|
#define NTSC_FRAMERATE 30
|
||||||
|
|
||||||
/* Filter signals and args */
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
SIGNAL_FRAME_DROPPED,
|
SIGNAL_FRAME_DROPPED,
|
||||||
|
@ -58,14 +57,14 @@ enum
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
ARG_0,
|
PROP_0,
|
||||||
ARG_PORT,
|
PROP_PORT,
|
||||||
ARG_CHANNEL,
|
PROP_CHANNEL,
|
||||||
ARG_CONSECUTIVE,
|
PROP_CONSECUTIVE,
|
||||||
ARG_SKIP,
|
PROP_SKIP,
|
||||||
ARG_DROP_INCOMPLETE,
|
PROP_DROP_INCOMPLETE,
|
||||||
ARG_USE_AVC,
|
PROP_USE_AVC,
|
||||||
ARG_GUID
|
PROP_GUID
|
||||||
};
|
};
|
||||||
|
|
||||||
static GstElementDetails gst_dv1394src_details =
|
static GstElementDetails gst_dv1394src_details =
|
||||||
|
@ -82,29 +81,19 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
"format = (string) { NTSC, PAL }, " "systemstream = (boolean) true")
|
"format = (string) { NTSC, PAL }, " "systemstream = (boolean) true")
|
||||||
);
|
);
|
||||||
|
|
||||||
static void gst_dv1394src_base_init (gpointer g_class);
|
static void gst_dv1394src_uri_handler_init (gpointer g_iface,
|
||||||
static void gst_dv1394src_class_init (GstDV1394SrcClass * klass);
|
gpointer iface_data);
|
||||||
static void gst_dv1394src_init (GstDV1394Src * filter);
|
|
||||||
static void gst_dv1394src_dispose (GObject * obj);
|
|
||||||
|
|
||||||
static void gst_dv1394src_set_property (GObject * object, guint prop_id,
|
static void gst_dv1394src_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec);
|
const GValue * value, GParamSpec * pspec);
|
||||||
static void gst_dv1394src_get_property (GObject * object, guint prop_id,
|
static void gst_dv1394src_get_property (GObject * object, guint prop_id,
|
||||||
GValue * value, GParamSpec * pspec);
|
GValue * value, GParamSpec * pspec);
|
||||||
|
|
||||||
static GstStateChangeReturn gst_dv1394src_change_state (GstElement * element,
|
static gboolean gst_dv1394src_start (GstBaseSrc * bsrc);
|
||||||
GstStateChange transition);
|
static gboolean gst_dv1394src_stop (GstBaseSrc * bsrc);
|
||||||
|
|
||||||
static GstFlowReturn gst_dv1394src_create (GstPushSrc * psrc, GstBuffer ** buf);
|
static GstFlowReturn gst_dv1394src_create (GstPushSrc * psrc, GstBuffer ** buf);
|
||||||
|
|
||||||
#if 0
|
|
||||||
static const GstEventMask *gst_dv1394src_get_event_mask (GstPad * pad);
|
|
||||||
#endif
|
|
||||||
static gboolean gst_dv1394src_event (GstPad * pad, GstEvent * event);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
static const GstFormat *gst_dv1394src_get_formats (GstPad * pad);
|
|
||||||
#endif
|
|
||||||
static gboolean gst_dv1394src_convert (GstPad * pad,
|
static gboolean gst_dv1394src_convert (GstPad * pad,
|
||||||
GstFormat src_format, gint64 src_value,
|
GstFormat src_format, gint64 src_value,
|
||||||
GstFormat * dest_format, gint64 * dest_value);
|
GstFormat * dest_format, gint64 * dest_value);
|
||||||
|
@ -112,48 +101,26 @@ static gboolean gst_dv1394src_convert (GstPad * pad,
|
||||||
static const GstQueryType *gst_dv1394src_get_query_types (GstPad * pad);
|
static const GstQueryType *gst_dv1394src_get_query_types (GstPad * pad);
|
||||||
static gboolean gst_dv1394src_query (GstPad * pad, GstQuery * query);
|
static gboolean gst_dv1394src_query (GstPad * pad, GstQuery * query);
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
static void
|
||||||
|
_do_init (GType type)
|
||||||
|
{
|
||||||
|
static const GInterfaceInfo urihandler_info = {
|
||||||
|
gst_dv1394src_uri_handler_init,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
g_type_add_interface_static (type, GST_TYPE_URI_HANDLER, &urihandler_info);
|
||||||
|
|
||||||
|
GST_DEBUG_CATEGORY_INIT (dv1394src_debug, "dv1394src", 0,
|
||||||
|
"DV firewire source");
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_BOILERPLATE_FULL (GstDV1394Src, gst_dv1394src, GstPushSrc,
|
||||||
|
GST_TYPE_PUSH_SRC, _do_init);
|
||||||
|
|
||||||
static void gst_dv1394src_uri_handler_init (gpointer g_iface,
|
|
||||||
gpointer iface_data);
|
|
||||||
|
|
||||||
static guint gst_dv1394src_signals[LAST_SIGNAL] = { 0 };
|
static guint gst_dv1394src_signals[LAST_SIGNAL] = { 0 };
|
||||||
|
|
||||||
GType
|
|
||||||
gst_dv1394src_get_type (void)
|
|
||||||
{
|
|
||||||
static GType gst_dv1394src_type = 0;
|
|
||||||
|
|
||||||
if (!gst_dv1394src_type) {
|
|
||||||
static const GTypeInfo gst_dv1394src_info = {
|
|
||||||
sizeof (GstDV1394Src),
|
|
||||||
gst_dv1394src_base_init,
|
|
||||||
NULL,
|
|
||||||
(GClassInitFunc) gst_dv1394src_class_init,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
sizeof (GstDV1394Src),
|
|
||||||
0,
|
|
||||||
(GInstanceInitFunc) gst_dv1394src_init,
|
|
||||||
};
|
|
||||||
static const GInterfaceInfo urihandler_info = {
|
|
||||||
gst_dv1394src_uri_handler_init,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
};
|
|
||||||
|
|
||||||
gst_dv1394src_type =
|
|
||||||
g_type_register_static (GST_TYPE_PUSH_SRC, "DV1394Src",
|
|
||||||
&gst_dv1394src_info, 0);
|
|
||||||
|
|
||||||
g_type_add_interface_static (gst_dv1394src_type, GST_TYPE_URI_HANDLER,
|
|
||||||
&urihandler_info);
|
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_INIT (dv1394src_debug, "dv1394src", 0,
|
|
||||||
"DV firewire source");
|
|
||||||
}
|
|
||||||
return gst_dv1394src_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_dv1394src_base_init (gpointer g_class)
|
gst_dv1394src_base_init (gpointer g_class)
|
||||||
|
@ -170,77 +137,64 @@ static void
|
||||||
gst_dv1394src_class_init (GstDV1394SrcClass * klass)
|
gst_dv1394src_class_init (GstDV1394SrcClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class;
|
GObjectClass *gobject_class;
|
||||||
GstElementClass *gstelement_class;
|
|
||||||
GstBaseSrcClass *gstbasesrc_class;
|
GstBaseSrcClass *gstbasesrc_class;
|
||||||
GstPushSrcClass *gstpushsrc_class;
|
GstPushSrcClass *gstpushsrc_class;
|
||||||
|
|
||||||
gobject_class = (GObjectClass *) klass;
|
gobject_class = (GObjectClass *) klass;
|
||||||
gstelement_class = (GstElementClass *) klass;
|
|
||||||
gstbasesrc_class = (GstBaseSrcClass *) klass;
|
gstbasesrc_class = (GstBaseSrcClass *) klass;
|
||||||
gstpushsrc_class = (GstPushSrcClass *) klass;
|
gstpushsrc_class = (GstPushSrcClass *) klass;
|
||||||
|
|
||||||
parent_class = g_type_class_ref (GST_TYPE_PUSH_SRC);
|
|
||||||
|
|
||||||
gobject_class->set_property = gst_dv1394src_set_property;
|
gobject_class->set_property = gst_dv1394src_set_property;
|
||||||
gobject_class->get_property = gst_dv1394src_get_property;
|
gobject_class->get_property = gst_dv1394src_get_property;
|
||||||
gobject_class->dispose = gst_dv1394src_dispose;
|
|
||||||
|
|
||||||
gst_dv1394src_signals[SIGNAL_FRAME_DROPPED] =
|
gst_dv1394src_signals[SIGNAL_FRAME_DROPPED] =
|
||||||
g_signal_new ("frame-dropped", G_TYPE_FROM_CLASS (klass),
|
g_signal_new ("frame-dropped", G_TYPE_FROM_CLASS (klass),
|
||||||
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstDV1394SrcClass, frame_dropped),
|
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstDV1394SrcClass, frame_dropped),
|
||||||
NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
||||||
|
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PORT,
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_PORT,
|
||||||
g_param_spec_int ("port", "Port", "Port number (-1 automatic)",
|
g_param_spec_int ("port", "Port", "Port number (-1 automatic)",
|
||||||
-1, 16, DEFAULT_PORT, G_PARAM_READWRITE));
|
-1, 16, DEFAULT_PORT, G_PARAM_READWRITE));
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_CHANNEL,
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_CHANNEL,
|
||||||
g_param_spec_int ("channel", "Channel", "Channel number for listening",
|
g_param_spec_int ("channel", "Channel", "Channel number for listening",
|
||||||
0, 64, DEFAULT_CHANNEL, G_PARAM_READWRITE));
|
0, 64, DEFAULT_CHANNEL, G_PARAM_READWRITE));
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_CONSECUTIVE,
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_CONSECUTIVE,
|
||||||
g_param_spec_int ("consecutive", "consecutive frames",
|
g_param_spec_int ("consecutive", "consecutive frames",
|
||||||
"send n consecutive frames after skipping", 1, G_MAXINT,
|
"send n consecutive frames after skipping", 1, G_MAXINT,
|
||||||
DEFAULT_CONSECUTIVE, G_PARAM_READWRITE));
|
DEFAULT_CONSECUTIVE, G_PARAM_READWRITE));
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SKIP,
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SKIP,
|
||||||
g_param_spec_int ("skip", "skip frames", "skip n frames",
|
g_param_spec_int ("skip", "skip frames", "skip n frames",
|
||||||
0, G_MAXINT, DEFAULT_SKIP, G_PARAM_READWRITE));
|
0, G_MAXINT, DEFAULT_SKIP, G_PARAM_READWRITE));
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DROP_INCOMPLETE,
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_DROP_INCOMPLETE,
|
||||||
g_param_spec_boolean ("drop_incomplete", "drop_incomplete",
|
g_param_spec_boolean ("drop_incomplete", "drop_incomplete",
|
||||||
"drop incomplete frames", DEFAULT_DROP_INCOMPLETE,
|
"drop incomplete frames", DEFAULT_DROP_INCOMPLETE,
|
||||||
G_PARAM_READWRITE));
|
G_PARAM_READWRITE));
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_USE_AVC,
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_USE_AVC,
|
||||||
g_param_spec_boolean ("use-avc", "Use AV/C", "Use AV/C VTR control",
|
g_param_spec_boolean ("use-avc", "Use AV/C", "Use AV/C VTR control",
|
||||||
DEFAULT_USE_AVC, G_PARAM_READWRITE));
|
DEFAULT_USE_AVC, G_PARAM_READWRITE));
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_GUID,
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_GUID,
|
||||||
g_param_spec_uint64 ("guid", "GUID",
|
g_param_spec_uint64 ("guid", "GUID",
|
||||||
"select one of multiple DV devices by its GUID. use a hexadecimal "
|
"select one of multiple DV devices by its GUID. use a hexadecimal "
|
||||||
"like 0xhhhhhhhhhhhhhhhh. (0 = no guid)", 0, G_MAXUINT64,
|
"like 0xhhhhhhhhhhhhhhhh. (0 = no guid)", 0, G_MAXUINT64,
|
||||||
DEFAULT_GUID, G_PARAM_READWRITE));
|
DEFAULT_GUID, G_PARAM_READWRITE));
|
||||||
|
|
||||||
gstelement_class->change_state = gst_dv1394src_change_state;
|
|
||||||
|
|
||||||
gstbasesrc_class->negotiate = NULL;
|
gstbasesrc_class->negotiate = NULL;
|
||||||
|
gstbasesrc_class->start = gst_dv1394src_start;
|
||||||
|
gstbasesrc_class->stop = gst_dv1394src_stop;
|
||||||
gstpushsrc_class->create = gst_dv1394src_create;
|
gstpushsrc_class->create = gst_dv1394src_create;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_dv1394src_init (GstDV1394Src * dv1394src)
|
gst_dv1394src_init (GstDV1394Src * dv1394src, GstDV1394SrcClass * klass)
|
||||||
{
|
{
|
||||||
GstPad *srcpad = GST_BASE_SRC_PAD (dv1394src);
|
GstPad *srcpad = GST_BASE_SRC_PAD (dv1394src);
|
||||||
|
|
||||||
gst_base_src_set_live (GST_BASE_SRC (dv1394src), TRUE);
|
gst_base_src_set_live (GST_BASE_SRC (dv1394src), TRUE);
|
||||||
gst_pad_use_fixed_caps (srcpad);
|
gst_pad_use_fixed_caps (srcpad);
|
||||||
|
|
||||||
gst_pad_set_event_function (srcpad, gst_dv1394src_event);
|
|
||||||
gst_pad_set_query_function (srcpad, gst_dv1394src_query);
|
gst_pad_set_query_function (srcpad, gst_dv1394src_query);
|
||||||
gst_pad_set_query_type_function (srcpad, gst_dv1394src_get_query_types);
|
gst_pad_set_query_type_function (srcpad, gst_dv1394src_get_query_types);
|
||||||
|
|
||||||
#if 0
|
|
||||||
gst_pad_set_event_mask_function (dv1394src->srcpad,
|
|
||||||
gst_dv1394src_get_event_mask);
|
|
||||||
gst_pad_set_convert_function (dv1394src->srcpad, gst_dv1394src_convert);
|
|
||||||
gst_pad_set_formats_function (dv1394src->srcpad, gst_dv1394src_get_formats);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
dv1394src->dv_lock = g_mutex_new ();
|
dv1394src->dv_lock = g_mutex_new ();
|
||||||
dv1394src->port = DEFAULT_PORT;
|
dv1394src->port = DEFAULT_PORT;
|
||||||
dv1394src->channel = DEFAULT_CHANNEL;
|
dv1394src->channel = DEFAULT_CHANNEL;
|
||||||
|
@ -259,16 +213,6 @@ gst_dv1394src_init (GstDV1394Src * dv1394src)
|
||||||
dv1394src->frame_sequence = 0;
|
dv1394src->frame_sequence = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gst_dv1394src_dispose (GObject * obj)
|
|
||||||
{
|
|
||||||
GstDV1394Src *dv1394src;
|
|
||||||
|
|
||||||
dv1394src = GST_DV1394SRC (obj);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->dispose (obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_dv1394src_set_property (GObject * object, guint prop_id,
|
gst_dv1394src_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec)
|
const GValue * value, GParamSpec * pspec)
|
||||||
|
@ -276,25 +220,25 @@ gst_dv1394src_set_property (GObject * object, guint prop_id,
|
||||||
GstDV1394Src *filter = GST_DV1394SRC (object);
|
GstDV1394Src *filter = GST_DV1394SRC (object);
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case ARG_PORT:
|
case PROP_PORT:
|
||||||
filter->port = g_value_get_int (value);
|
filter->port = g_value_get_int (value);
|
||||||
break;
|
break;
|
||||||
case ARG_CHANNEL:
|
case PROP_CHANNEL:
|
||||||
filter->channel = g_value_get_int (value);
|
filter->channel = g_value_get_int (value);
|
||||||
break;
|
break;
|
||||||
case ARG_SKIP:
|
case PROP_SKIP:
|
||||||
filter->skip = g_value_get_int (value);
|
filter->skip = g_value_get_int (value);
|
||||||
break;
|
break;
|
||||||
case ARG_CONSECUTIVE:
|
case PROP_CONSECUTIVE:
|
||||||
filter->consecutive = g_value_get_int (value);
|
filter->consecutive = g_value_get_int (value);
|
||||||
break;
|
break;
|
||||||
case ARG_DROP_INCOMPLETE:
|
case PROP_DROP_INCOMPLETE:
|
||||||
filter->drop_incomplete = g_value_get_boolean (value);
|
filter->drop_incomplete = g_value_get_boolean (value);
|
||||||
break;
|
break;
|
||||||
case ARG_USE_AVC:
|
case PROP_USE_AVC:
|
||||||
filter->use_avc = g_value_get_boolean (value);
|
filter->use_avc = g_value_get_boolean (value);
|
||||||
break;
|
break;
|
||||||
case ARG_GUID:
|
case PROP_GUID:
|
||||||
filter->guid = g_value_get_uint64 (value);
|
filter->guid = g_value_get_uint64 (value);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -309,25 +253,25 @@ gst_dv1394src_get_property (GObject * object, guint prop_id, GValue * value,
|
||||||
GstDV1394Src *filter = GST_DV1394SRC (object);
|
GstDV1394Src *filter = GST_DV1394SRC (object);
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case ARG_PORT:
|
case PROP_PORT:
|
||||||
g_value_set_int (value, filter->port);
|
g_value_set_int (value, filter->port);
|
||||||
break;
|
break;
|
||||||
case ARG_CHANNEL:
|
case PROP_CHANNEL:
|
||||||
g_value_set_int (value, filter->channel);
|
g_value_set_int (value, filter->channel);
|
||||||
break;
|
break;
|
||||||
case ARG_SKIP:
|
case PROP_SKIP:
|
||||||
g_value_set_int (value, filter->skip);
|
g_value_set_int (value, filter->skip);
|
||||||
break;
|
break;
|
||||||
case ARG_CONSECUTIVE:
|
case PROP_CONSECUTIVE:
|
||||||
g_value_set_int (value, filter->consecutive);
|
g_value_set_int (value, filter->consecutive);
|
||||||
break;
|
break;
|
||||||
case ARG_DROP_INCOMPLETE:
|
case PROP_DROP_INCOMPLETE:
|
||||||
g_value_set_boolean (value, filter->drop_incomplete);
|
g_value_set_boolean (value, filter->drop_incomplete);
|
||||||
break;
|
break;
|
||||||
case ARG_USE_AVC:
|
case PROP_USE_AVC:
|
||||||
g_value_set_boolean (value, filter->use_avc);
|
g_value_set_boolean (value, filter->use_avc);
|
||||||
break;
|
break;
|
||||||
case ARG_GUID:
|
case PROP_GUID:
|
||||||
g_value_set_uint64 (value, filter->guid);
|
g_value_set_uint64 (value, filter->guid);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -399,23 +343,21 @@ gst_dv1394src_iso_receive (raw1394handle_t handle, int channel, size_t len,
|
||||||
dv1394src->frame = NULL;
|
dv1394src->frame = NULL;
|
||||||
if ((dv1394src->frame_sequence + 1) % (dv1394src->skip +
|
if ((dv1394src->frame_sequence + 1) % (dv1394src->skip +
|
||||||
dv1394src->consecutive) < dv1394src->consecutive) {
|
dv1394src->consecutive) < dv1394src->consecutive) {
|
||||||
//GstFormat format;
|
GstFormat format;
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
|
gint64 i64;
|
||||||
|
|
||||||
buf = gst_buffer_new_and_alloc (dv1394src->frame_size);
|
buf = gst_buffer_new_and_alloc (dv1394src->frame_size);
|
||||||
#if 0
|
|
||||||
/* fill in default offset */
|
/* fill in offset, duration, timestamp */
|
||||||
format = GST_FORMAT_DEFAULT;
|
GST_BUFFER_OFFSET (buf) = dv1394src->frame_sequence;
|
||||||
gst_dv1394src_query (dv1394src->srcpad, GST_QUERY_POSITION, &format,
|
|
||||||
&GST_BUFFER_OFFSET (buf));
|
|
||||||
/* fill in timestamp */
|
|
||||||
format = GST_FORMAT_TIME;
|
format = GST_FORMAT_TIME;
|
||||||
gst_dv1394src_query (dv1394src->srcpad, GST_QUERY_POSITION, &format,
|
gst_dv1394src_convert (GST_BASE_SRC_PAD (dv1394src), GST_FORMAT_DEFAULT,
|
||||||
&GST_BUFFER_TIMESTAMP (buf));
|
GST_BUFFER_OFFSET (buf), &format, &i64);
|
||||||
/* fill in duration by converting one frame to time */
|
GST_BUFFER_TIMESTAMP (buf) = i64;
|
||||||
gst_dv1394src_convert (dv1394src->srcpad, GST_FORMAT_DEFAULT, 1,
|
gst_dv1394src_convert (GST_BASE_SRC_PAD (dv1394src), GST_FORMAT_DEFAULT,
|
||||||
&format, &GST_BUFFER_DURATION (buf));
|
1, &format, &i64);
|
||||||
#endif
|
GST_BUFFER_DURATION (buf) = i64;
|
||||||
|
|
||||||
dv1394src->frame = buf;
|
dv1394src->frame = buf;
|
||||||
}
|
}
|
||||||
|
@ -558,157 +500,99 @@ gst_dv1394src_discover_avc_node (GstDV1394Src * src)
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstStateChangeReturn
|
static gboolean
|
||||||
gst_dv1394src_change_state (GstElement * element, GstStateChange transition)
|
gst_dv1394src_start (GstBaseSrc * bsrc)
|
||||||
{
|
{
|
||||||
GstDV1394Src *dv1394src;
|
GstDV1394Src *src = GST_DV1394SRC (bsrc);
|
||||||
GstStateChangeReturn ret;
|
|
||||||
|
|
||||||
dv1394src = GST_DV1394SRC (element);
|
src->handle = raw1394_new_handle ();
|
||||||
|
|
||||||
switch (transition) {
|
if (!src->handle)
|
||||||
case GST_STATE_CHANGE_NULL_TO_READY:
|
goto no_handle;
|
||||||
/* create a handle */
|
|
||||||
if ((dv1394src->handle = raw1394_new_handle ()) == NULL)
|
|
||||||
goto no_handle;
|
|
||||||
|
|
||||||
/* set this plugin as the user data */
|
raw1394_set_userdata (src->handle, src);
|
||||||
raw1394_set_userdata (dv1394src->handle, dv1394src);
|
|
||||||
|
|
||||||
/* get number of ports */
|
src->num_ports = raw1394_get_port_info (src->handle, src->pinfo, 16);
|
||||||
if ((dv1394src->num_ports =
|
|
||||||
raw1394_get_port_info (dv1394src->handle, dv1394src->pinfo,
|
|
||||||
16)) == 0)
|
|
||||||
goto no_ports;
|
|
||||||
|
|
||||||
if (dv1394src->use_avc || dv1394src->port == -1) {
|
if (src->num_ports == 0)
|
||||||
/* discover AVC and optionally the port */
|
goto no_ports;
|
||||||
dv1394src->avc_node = gst_dv1394src_discover_avc_node (dv1394src);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* configure our port now */
|
if (src->use_avc || src->port == -1)
|
||||||
if (raw1394_set_port (dv1394src->handle, dv1394src->port) < 0)
|
src->avc_node = gst_dv1394src_discover_avc_node (src);
|
||||||
goto cannot_set_port;
|
|
||||||
|
|
||||||
/* set the callbacks */
|
if (raw1394_set_port (src->handle, src->port) < 0)
|
||||||
raw1394_set_iso_handler (dv1394src->handle, dv1394src->channel,
|
goto cannot_set_port;
|
||||||
gst_dv1394src_iso_receive);
|
|
||||||
raw1394_set_bus_reset_handler (dv1394src->handle,
|
|
||||||
gst_dv1394src_bus_reset);
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (dv1394src, "successfully opened up 1394 connection");
|
raw1394_set_iso_handler (src->handle, src->channel,
|
||||||
break;
|
gst_dv1394src_iso_receive);
|
||||||
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
raw1394_set_bus_reset_handler (src->handle, gst_dv1394src_bus_reset);
|
||||||
if (raw1394_start_iso_rcv (dv1394src->handle, dv1394src->channel) < 0)
|
|
||||||
goto cannot_start;
|
|
||||||
|
|
||||||
if (dv1394src->use_avc) {
|
GST_DEBUG_OBJECT (src, "successfully opened up 1394 connection");
|
||||||
/* start the VCR */
|
|
||||||
if (!avc1394_vcr_is_recording (dv1394src->handle, dv1394src->avc_node)
|
if (raw1394_start_iso_rcv (src->handle, src->channel) < 0)
|
||||||
&& avc1394_vcr_is_playing (dv1394src->handle, dv1394src->avc_node)
|
goto cannot_start;
|
||||||
!= AVC1394_VCR_OPERAND_PLAY_FORWARD) {
|
|
||||||
avc1394_vcr_play (dv1394src->handle, dv1394src->avc_node);
|
if (src->use_avc) {
|
||||||
}
|
/* start the VCR */
|
||||||
}
|
if (!avc1394_vcr_is_recording (src->handle, src->avc_node)
|
||||||
break;
|
&& avc1394_vcr_is_playing (src->handle, src->avc_node)
|
||||||
default:
|
!= AVC1394_VCR_OPERAND_PLAY_FORWARD)
|
||||||
break;
|
avc1394_vcr_play (src->handle, src->avc_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if we haven't failed already, give the parent class a chance to ;-) */
|
return TRUE;
|
||||||
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
|
||||||
|
|
||||||
switch (transition) {
|
|
||||||
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
|
||||||
/* we need to lock here as the _create function has to be completed.
|
|
||||||
* The base source will not call the _create() function again. */
|
|
||||||
GST_DV_LOCK (dv1394src);
|
|
||||||
raw1394_stop_iso_rcv (dv1394src->handle, dv1394src->channel);
|
|
||||||
if (dv1394src->use_avc) {
|
|
||||||
/* pause the VCR */
|
|
||||||
if (!avc1394_vcr_is_recording (dv1394src->handle, dv1394src->avc_node)
|
|
||||||
&& (avc1394_vcr_is_playing (dv1394src->handle, dv1394src->avc_node)
|
|
||||||
!= AVC1394_VCR_OPERAND_PLAY_FORWARD_PAUSE)) {
|
|
||||||
avc1394_vcr_pause (dv1394src->handle, dv1394src->avc_node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
GST_DV_UNLOCK (dv1394src);
|
|
||||||
break;
|
|
||||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
|
||||||
dv1394src->negotiated = FALSE;
|
|
||||||
break;
|
|
||||||
case GST_STATE_CHANGE_READY_TO_NULL:
|
|
||||||
if (dv1394src->use_avc) {
|
|
||||||
/* stop the VCR */
|
|
||||||
avc1394_vcr_stop (dv1394src->handle, dv1394src->avc_node);
|
|
||||||
}
|
|
||||||
raw1394_destroy_handle (dv1394src->handle);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
no_handle:
|
no_handle:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (dv1394src, RESOURCE, NOT_FOUND, (NULL),
|
GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, (NULL),
|
||||||
("can't get raw1394 handle"));
|
("can't get raw1394 handle"));
|
||||||
return GST_STATE_CHANGE_FAILURE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
no_ports:
|
no_ports:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (dv1394src, RESOURCE, NOT_FOUND, (NULL),
|
GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, (NULL),
|
||||||
("no ports available for raw1394"));
|
("no ports available for raw1394"));
|
||||||
return GST_STATE_CHANGE_FAILURE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
cannot_set_port:
|
cannot_set_port:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (dv1394src, RESOURCE, SETTINGS, (NULL),
|
GST_ELEMENT_ERROR (src, RESOURCE, SETTINGS, (NULL),
|
||||||
("can't set 1394 port %d", dv1394src->port));
|
("can't set 1394 port %d", src->port));
|
||||||
return GST_STATE_CHANGE_FAILURE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
cannot_start:
|
cannot_start:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (dv1394src, RESOURCE, READ, (NULL),
|
GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
|
||||||
("can't start 1394 iso receive"));
|
("can't start 1394 iso receive"));
|
||||||
return GST_STATE_CHANGE_FAILURE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
static const GstEventMask *
|
|
||||||
gst_dv1394src_get_event_mask (GstPad * pad)
|
|
||||||
{
|
|
||||||
static const GstEventMask masks[] = {
|
|
||||||
{0,}
|
|
||||||
};
|
|
||||||
|
|
||||||
return masks;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_dv1394src_event (GstPad * pad, GstEvent * event)
|
gst_dv1394src_stop (GstBaseSrc * bsrc)
|
||||||
{
|
{
|
||||||
return FALSE;
|
GstDV1394Src *src = GST_DV1394SRC (bsrc);
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
GST_DV_LOCK (src);
|
||||||
static const GstFormat *
|
raw1394_stop_iso_rcv (src->handle, src->channel);
|
||||||
gst_dv1394src_get_formats (GstPad * pad)
|
if (src->use_avc) {
|
||||||
{
|
/* pause the VCR */
|
||||||
static GstFormat formats[] = {
|
if (!avc1394_vcr_is_recording (src->handle, src->avc_node)
|
||||||
GST_FORMAT_TIME,
|
&& (avc1394_vcr_is_playing (src->handle, src->avc_node)
|
||||||
GST_FORMAT_BYTES,
|
!= AVC1394_VCR_OPERAND_PLAY_FORWARD_PAUSE))
|
||||||
GST_FORMAT_DEFAULT,
|
avc1394_vcr_pause (src->handle, src->avc_node);
|
||||||
0
|
}
|
||||||
};
|
GST_DV_UNLOCK (src);
|
||||||
|
src->negotiated = FALSE;
|
||||||
|
|
||||||
return formats;
|
if (src->use_avc)
|
||||||
|
/* stop the VCR */
|
||||||
|
avc1394_vcr_stop (src->handle, src->avc_node);
|
||||||
|
|
||||||
|
raw1394_destroy_handle (src->handle);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_dv1394src_convert (GstPad * pad,
|
gst_dv1394src_convert (GstPad * pad,
|
||||||
|
|
Loading…
Reference in a new issue