2002-03-20 21:45:03 +00:00
|
|
|
|
/* GStreamer
|
2001-12-23 16:42:33 +00:00
|
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
2003-01-06 15:07:21 +00:00
|
|
|
|
* <2000> Daniel Fischer <dan@f3c.com>
|
2001-12-23 16:42:33 +00:00
|
|
|
|
*
|
|
|
|
|
* 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
|
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
|
*/
|
|
|
|
|
|
2003-11-06 23:36:33 +00:00
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include "config.h"
|
|
|
|
|
#endif
|
2001-12-23 16:42:33 +00:00
|
|
|
|
#include <gst/gst.h>
|
2003-01-06 15:07:21 +00:00
|
|
|
|
#include <string.h>
|
2001-12-23 16:42:33 +00:00
|
|
|
|
#include "gstdv1394src.h"
|
|
|
|
|
|
2003-01-06 15:07:21 +00:00
|
|
|
|
#define N_BUFFERS_IN_POOL 3
|
|
|
|
|
|
|
|
|
|
#define PAL_FRAMESIZE 144000
|
|
|
|
|
#define NTSC_FRAMESIZE 120000
|
2001-12-23 16:42:33 +00:00
|
|
|
|
|
|
|
|
|
/* Filter signals and args */
|
2004-03-14 22:34:33 +00:00
|
|
|
|
enum
|
|
|
|
|
{
|
2001-12-23 16:42:33 +00:00
|
|
|
|
/* FILL ME */
|
|
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
|
enum
|
|
|
|
|
{
|
2003-01-06 15:07:21 +00:00
|
|
|
|
ARG_0,
|
|
|
|
|
ARG_CONSECUTIVE,
|
|
|
|
|
ARG_SKIP,
|
2004-05-21 23:28:57 +00:00
|
|
|
|
ARG_DROP_INCOMPLETE
|
2001-12-23 16:42:33 +00:00
|
|
|
|
};
|
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
|
static GstElementDetails gst_dv1394src_details =
|
|
|
|
|
GST_ELEMENT_DETAILS ("Firewire (1394) DV Source",
|
|
|
|
|
"Source/Video",
|
|
|
|
|
"Source for DV video data from firewire port",
|
|
|
|
|
"Erik Walthinsen <omega@temple-baptist.com>\n"
|
|
|
|
|
"Daniel Fischer <dan@f3c.com>");
|
2003-11-02 03:08:13 +00:00
|
|
|
|
|
2002-11-15 19:21:58 +00:00
|
|
|
|
#if 0
|
2004-03-14 22:34:33 +00:00
|
|
|
|
static GstPadTemplate *
|
2001-12-23 16:42:33 +00:00
|
|
|
|
gst_dv1394src_factory (void)
|
|
|
|
|
{
|
|
|
|
|
static GstPadTemplate *template = NULL;
|
|
|
|
|
|
|
|
|
|
if (!template) {
|
2004-03-14 22:34:33 +00:00
|
|
|
|
template = gst_pad_template_new ("src",
|
2004-03-15 19:32:27 +00:00
|
|
|
|
GST_PAD_SRC,
|
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
|
GST_STATIC_CAPS ("dv1394src",
|
2004-05-07 16:17:25 +00:00
|
|
|
|
"video/x-dv",
|
2004-03-15 19:32:27 +00:00
|
|
|
|
gst_props_new ("format", GST_PROPS_LIST (G_TYPE_STRING ("NTSC"),
|
|
|
|
|
G_TYPE_STRING ("PAL")
|
|
|
|
|
), NULL)
|
|
|
|
|
), NULL);
|
2001-12-23 16:42:33 +00:00
|
|
|
|
}
|
|
|
|
|
return template;
|
|
|
|
|
}
|
2002-11-15 19:21:58 +00:00
|
|
|
|
#endif
|
2001-12-23 16:42:33 +00:00
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
|
static void gst_dv1394src_base_init (gpointer g_class);
|
|
|
|
|
static void gst_dv1394src_class_init (GstDV1394SrcClass * klass);
|
|
|
|
|
static void gst_dv1394src_init (GstDV1394Src * filter);
|
2001-12-23 16:42:33 +00:00
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
|
static void gst_dv1394src_set_property (GObject * object, guint prop_id,
|
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
|
static void gst_dv1394src_get_property (GObject * object, guint prop_id,
|
|
|
|
|
GValue * value, GParamSpec * pspec);
|
2001-12-23 16:42:33 +00:00
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
|
static GstElementStateReturn gst_dv1394src_change_state (GstElement * element);
|
2001-12-23 16:42:33 +00:00
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
|
static GstData *gst_dv1394src_get (GstPad * pad);
|
2001-12-23 16:42:33 +00:00
|
|
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
2002-03-19 04:10:05 +00:00
|
|
|
|
/*static guint gst_filter_signals[LAST_SIGNAL] = { 0 }; */
|
2001-12-23 16:42:33 +00:00
|
|
|
|
|
|
|
|
|
GType
|
2004-03-14 22:34:33 +00:00
|
|
|
|
gst_dv1394src_get_type (void)
|
|
|
|
|
{
|
2001-12-23 16:42:33 +00:00
|
|
|
|
static GType gst_dv1394src_type = 0;
|
|
|
|
|
|
|
|
|
|
if (!gst_dv1394src_type) {
|
|
|
|
|
static const GTypeInfo gst_dv1394src_info = {
|
2004-03-14 22:34:33 +00:00
|
|
|
|
sizeof (GstDV1394Src),
|
2003-11-02 03:08:13 +00:00
|
|
|
|
gst_dv1394src_base_init,
|
2001-12-23 16:42:33 +00:00
|
|
|
|
NULL,
|
2004-03-14 22:34:33 +00:00
|
|
|
|
(GClassInitFunc) gst_dv1394src_class_init,
|
2001-12-23 16:42:33 +00:00
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
2004-03-14 22:34:33 +00:00
|
|
|
|
sizeof (GstDV1394Src),
|
2001-12-23 16:42:33 +00:00
|
|
|
|
0,
|
2004-03-14 22:34:33 +00:00
|
|
|
|
(GInstanceInitFunc) gst_dv1394src_init,
|
2001-12-23 16:42:33 +00:00
|
|
|
|
};
|
2004-03-15 19:32:27 +00:00
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
|
gst_dv1394src_type =
|
2004-03-15 19:32:27 +00:00
|
|
|
|
g_type_register_static (GST_TYPE_ELEMENT, "DV1394Src",
|
|
|
|
|
&gst_dv1394src_info, 0);
|
2001-12-23 16:42:33 +00:00
|
|
|
|
}
|
|
|
|
|
return gst_dv1394src_type;
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-02 03:08:13 +00:00
|
|
|
|
static void
|
|
|
|
|
gst_dv1394src_base_init (gpointer g_class)
|
|
|
|
|
{
|
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
|
|
|
|
|
|
|
|
|
gst_element_class_set_details (element_class, &gst_dv1394src_details);
|
|
|
|
|
}
|
|
|
|
|
|
2001-12-23 16:42:33 +00:00
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
|
gst_dv1394src_class_init (GstDV1394SrcClass * klass)
|
2001-12-23 16:42:33 +00:00
|
|
|
|
{
|
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2001-12-23 16:42:33 +00:00
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_CONSECUTIVE,
|
|
|
|
|
g_param_spec_int ("consecutive", "consecutive frames",
|
2004-03-15 19:32:27 +00:00
|
|
|
|
"send n consecutive frames after skipping", 1, G_MAXINT, 1,
|
|
|
|
|
G_PARAM_READWRITE));
|
2004-03-14 22:34:33 +00:00
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SKIP,
|
|
|
|
|
g_param_spec_int ("skip", "skip frames", "skip n frames", 0, G_MAXINT, 1,
|
2004-03-15 19:32:27 +00:00
|
|
|
|
G_PARAM_READWRITE));
|
2004-03-14 22:34:33 +00:00
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DROP_INCOMPLETE,
|
|
|
|
|
g_param_spec_boolean ("drop_incomplete", "drop_incomplete",
|
2004-03-15 19:32:27 +00:00
|
|
|
|
"drop incomplete frames", TRUE, G_PARAM_READWRITE));
|
2003-01-06 15:07:21 +00:00
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
|
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
2001-12-23 16:42:33 +00:00
|
|
|
|
|
|
|
|
|
gobject_class->set_property = gst_dv1394src_set_property;
|
|
|
|
|
gobject_class->get_property = gst_dv1394src_get_property;
|
|
|
|
|
|
|
|
|
|
gstelement_class->change_state = gst_dv1394src_change_state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
|
gst_dv1394src_init (GstDV1394Src * dv1394src)
|
2001-12-23 16:42:33 +00:00
|
|
|
|
{
|
|
|
|
|
dv1394src->srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
|
|
|
|
gst_pad_set_get_function (dv1394src->srcpad, gst_dv1394src_get);
|
2004-05-07 16:17:25 +00:00
|
|
|
|
gst_pad_use_explicit_caps (dv1394src->srcpad);
|
2001-12-23 16:42:33 +00:00
|
|
|
|
gst_element_add_pad (GST_ELEMENT (dv1394src), dv1394src->srcpad);
|
|
|
|
|
|
|
|
|
|
dv1394src->card = 0;
|
|
|
|
|
dv1394src->port = 0;
|
|
|
|
|
dv1394src->channel = 63;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
2003-01-06 15:07:21 +00:00
|
|
|
|
dv1394src->consecutive = 1;
|
|
|
|
|
dv1394src->skip = 0;
|
|
|
|
|
dv1394src->drop_incomplete = TRUE;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
2003-01-06 15:07:21 +00:00
|
|
|
|
/* initialized when first header received */
|
2004-03-14 22:34:33 +00:00
|
|
|
|
dv1394src->frameSize = 0;
|
|
|
|
|
|
2003-01-06 15:07:21 +00:00
|
|
|
|
dv1394src->buf = NULL;
|
|
|
|
|
dv1394src->frame = NULL;
|
|
|
|
|
dv1394src->frameSequence = 0;
|
2001-12-23 16:42:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
|
gst_dv1394src_set_property (GObject * object, guint prop_id,
|
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
2001-12-23 16:42:33 +00:00
|
|
|
|
{
|
|
|
|
|
GstDV1394Src *filter;
|
|
|
|
|
|
|
|
|
|
/* it's not null if we got it, but it might not be ours */
|
2004-03-14 22:34:33 +00:00
|
|
|
|
g_return_if_fail (GST_IS_DV1394SRC (object));
|
|
|
|
|
filter = GST_DV1394SRC (object);
|
2001-12-23 16:42:33 +00:00
|
|
|
|
|
|
|
|
|
switch (prop_id) {
|
2003-01-06 15:07:21 +00:00
|
|
|
|
case ARG_SKIP:
|
2004-03-14 22:34:33 +00:00
|
|
|
|
filter->skip = g_value_get_int (value);
|
|
|
|
|
break;
|
2003-01-06 15:07:21 +00:00
|
|
|
|
case ARG_CONSECUTIVE:
|
2004-03-14 22:34:33 +00:00
|
|
|
|
filter->consecutive = g_value_get_int (value);
|
|
|
|
|
break;
|
2003-01-06 15:07:21 +00:00
|
|
|
|
case ARG_DROP_INCOMPLETE:
|
2004-03-14 22:34:33 +00:00
|
|
|
|
filter->drop_incomplete = g_value_get_boolean (value);
|
|
|
|
|
break;
|
2001-12-23 16:42:33 +00:00
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
|
gst_dv1394src_get_property (GObject * object, guint prop_id, GValue * value,
|
|
|
|
|
GParamSpec * pspec)
|
2001-12-23 16:42:33 +00:00
|
|
|
|
{
|
|
|
|
|
GstDV1394Src *filter;
|
|
|
|
|
|
|
|
|
|
/* it's not null if we got it, but it might not be ours */
|
2004-03-14 22:34:33 +00:00
|
|
|
|
g_return_if_fail (GST_IS_DV1394SRC (object));
|
|
|
|
|
filter = GST_DV1394SRC (object);
|
2001-12-23 16:42:33 +00:00
|
|
|
|
|
|
|
|
|
switch (prop_id) {
|
2003-01-06 15:07:21 +00:00
|
|
|
|
case ARG_SKIP:
|
2004-03-14 22:34:33 +00:00
|
|
|
|
g_value_set_int (value, filter->skip);
|
|
|
|
|
break;
|
2003-01-06 15:07:21 +00:00
|
|
|
|
case ARG_CONSECUTIVE:
|
2004-03-14 22:34:33 +00:00
|
|
|
|
g_value_set_int (value, filter->consecutive);
|
|
|
|
|
break;
|
2003-01-06 15:07:21 +00:00
|
|
|
|
case ARG_DROP_INCOMPLETE:
|
2004-03-14 22:34:33 +00:00
|
|
|
|
g_value_set_boolean (value, filter->drop_incomplete);
|
|
|
|
|
break;
|
2001-12-23 16:42:33 +00:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
|
static int
|
|
|
|
|
gst_dv1394src_iso_receive (raw1394handle_t handle, int channel, size_t len,
|
|
|
|
|
quadlet_t * data)
|
|
|
|
|
{
|
|
|
|
|
GstDV1394Src *dv1394src = GST_DV1394SRC (raw1394_get_userdata (handle));
|
2001-12-23 16:42:33 +00:00
|
|
|
|
|
|
|
|
|
if (len > 16) {
|
2004-03-14 22:34:33 +00:00
|
|
|
|
/*
|
|
|
|
|
the following code taken from kino-0.51 (Dan Dennedy/Charles Yates)
|
|
|
|
|
*/
|
|
|
|
|
unsigned char *p = (unsigned char *) &data[3];
|
2004-03-15 19:32:27 +00:00
|
|
|
|
int section_type = p[0] >> 5; /* section type is in bits 5 - 7 */
|
|
|
|
|
int dif_sequence = p[1] >> 4; /* dif sequence number is in bits 4 - 7 */
|
2004-03-14 22:34:33 +00:00
|
|
|
|
int dif_block = p[2];
|
|
|
|
|
|
|
|
|
|
/* if we are at the beginning of a frame,
|
|
|
|
|
we set buf=frame, and alloc a new buffer for frame
|
|
|
|
|
*/
|
|
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
|
if (section_type == 0 && dif_sequence == 0) { // dif header
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
|
|
if (!dv1394src->negotiated) {
|
2004-03-15 19:32:27 +00:00
|
|
|
|
// figure format (NTSC/PAL)
|
|
|
|
|
if (p[3] & 0x80) {
|
|
|
|
|
// PAL
|
|
|
|
|
dv1394src->frameSize = PAL_FRAMESIZE;
|
|
|
|
|
GST_DEBUG ("PAL data");
|
2004-05-07 16:17:25 +00:00
|
|
|
|
if (!gst_pad_set_explicit_caps (dv1394src->srcpad,
|
|
|
|
|
gst_caps_new_simple ("video/x-dv",
|
|
|
|
|
"format", G_TYPE_STRING, "PAL", NULL))) {
|
2004-03-15 19:32:27 +00:00
|
|
|
|
GST_ELEMENT_ERROR (dv1394src, CORE, NEGOTIATION, (NULL),
|
|
|
|
|
("Could not set source caps for PAL"));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// NTSC (untested)
|
|
|
|
|
dv1394src->frameSize = NTSC_FRAMESIZE;
|
|
|
|
|
GST_DEBUG
|
|
|
|
|
("NTSC data [untested] - please report success/failure to <dan@f3c.com>");
|
2004-05-07 16:17:25 +00:00
|
|
|
|
if (!gst_pad_set_explicit_caps (dv1394src->srcpad,
|
|
|
|
|
gst_caps_new_simple ("video/x-dv", "format", G_TYPE_STRING,
|
|
|
|
|
"NTSC", NULL))) {
|
2004-03-15 19:32:27 +00:00
|
|
|
|
GST_ELEMENT_ERROR (dv1394src, CORE, NEGOTIATION, (NULL),
|
|
|
|
|
("Could not set source caps for NTSC"));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
dv1394src->negotiated = TRUE;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
}
|
|
|
|
|
// drop last frame when not complete
|
|
|
|
|
if (!dv1394src->drop_incomplete
|
2004-03-15 19:32:27 +00:00
|
|
|
|
|| dv1394src->bytesInFrame == dv1394src->frameSize) {
|
|
|
|
|
dv1394src->buf = dv1394src->frame;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
} else {
|
2004-03-15 19:32:27 +00:00
|
|
|
|
GST_INFO_OBJECT (GST_ELEMENT (dv1394src), "incomplete frame dropped");
|
2004-03-14 22:34:33 +00:00
|
|
|
|
}
|
|
|
|
|
dv1394src->frame = NULL;
|
|
|
|
|
|
|
|
|
|
dv1394src->frameSequence++;
|
|
|
|
|
|
|
|
|
|
if (dv1394src->frameSequence % (dv1394src->skip +
|
2004-03-15 19:32:27 +00:00
|
|
|
|
dv1394src->consecutive) < dv1394src->consecutive) {
|
|
|
|
|
dv1394src->frame = gst_buffer_new_and_alloc (dv1394src->frameSize);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
}
|
|
|
|
|
dv1394src->bytesInFrame = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dv1394src->frame != NULL) {
|
|
|
|
|
void *data = GST_BUFFER_DATA (dv1394src->frame);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (section_type) {
|
2004-03-15 19:32:27 +00:00
|
|
|
|
case 0: /* 1 Header block */
|
|
|
|
|
/* p[3] |= 0x80; // hack to force PAL data */
|
|
|
|
|
memcpy (data + dif_sequence * 150 * 80, p, 480);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 1: /* 2 Subcode blocks */
|
|
|
|
|
memcpy (data + dif_sequence * 150 * 80 + (1 + dif_block) * 80, p,
|
|
|
|
|
480);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 2: /* 3 VAUX blocks */
|
|
|
|
|
memcpy (data + dif_sequence * 150 * 80 + (3 + dif_block) * 80, p,
|
|
|
|
|
480);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 3: /* 9 Audio blocks interleaved with video */
|
|
|
|
|
memcpy (data + dif_sequence * 150 * 80 + (6 + dif_block * 16) * 80, p,
|
|
|
|
|
480);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 4: /* 135 Video blocks interleaved with audio */
|
|
|
|
|
memcpy (data + dif_sequence * 150 * 80 + (7 + (dif_block / 15) +
|
|
|
|
|
dif_block) * 80, p, 480);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default: /* we can<61>t handle any other data */
|
|
|
|
|
break;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
}
|
|
|
|
|
dv1394src->bytesInFrame += 480;
|
|
|
|
|
}
|
2001-12-23 16:42:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
|
static int
|
|
|
|
|
gst_dv1394src_bus_reset (raw1394handle_t handle, unsigned int generation)
|
|
|
|
|
{
|
|
|
|
|
GST_INFO_OBJECT (GST_DV1394SRC (raw1394_get_userdata (handle)),
|
|
|
|
|
"have bus reset");
|
2001-12-23 16:42:33 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-08 16:08:18 +00:00
|
|
|
|
static GstData *
|
2004-03-14 22:34:33 +00:00
|
|
|
|
gst_dv1394src_get (GstPad * pad)
|
2001-12-23 16:42:33 +00:00
|
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
|
GstDV1394Src *dv1394src = GST_DV1394SRC (GST_PAD_PARENT (pad));
|
2001-12-23 16:42:33 +00:00
|
|
|
|
|
|
|
|
|
dv1394src->buf = NULL;
|
|
|
|
|
while (dv1394src->buf == NULL)
|
2004-03-14 22:34:33 +00:00
|
|
|
|
raw1394_loop_iterate (dv1394src->handle);
|
2001-12-23 16:42:33 +00:00
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
|
return GST_DATA (dv1394src->buf);
|
|
|
|
|
}
|
2001-12-23 16:42:33 +00:00
|
|
|
|
|
|
|
|
|
static GstElementStateReturn
|
2004-03-14 22:34:33 +00:00
|
|
|
|
gst_dv1394src_change_state (GstElement * element)
|
2001-12-23 16:42:33 +00:00
|
|
|
|
{
|
|
|
|
|
GstDV1394Src *dv1394src;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_DV1394SRC (element), GST_STATE_FAILURE);
|
|
|
|
|
dv1394src = GST_DV1394SRC (element);
|
|
|
|
|
|
|
|
|
|
switch (GST_STATE_TRANSITION (element)) {
|
|
|
|
|
case GST_STATE_NULL_TO_READY:
|
2004-03-14 22:34:33 +00:00
|
|
|
|
if ((dv1394src->handle = raw1394_new_handle ()) == NULL) {
|
2004-03-15 19:32:27 +00:00
|
|
|
|
GST_INFO_OBJECT (dv1394src, "can't get raw1394 handle");
|
|
|
|
|
return GST_STATE_FAILURE;
|
2001-12-23 16:42:33 +00:00
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
raw1394_set_userdata (dv1394src->handle, dv1394src);
|
|
|
|
|
dv1394src->numcards =
|
2004-03-15 19:32:27 +00:00
|
|
|
|
raw1394_get_port_info (dv1394src->handle, dv1394src->pinfo, 16);
|
2001-12-23 16:42:33 +00:00
|
|
|
|
if (dv1394src->numcards == 0) {
|
2004-03-15 19:32:27 +00:00
|
|
|
|
GST_INFO_OBJECT (dv1394src, "no cards available for raw1394");
|
|
|
|
|
return GST_STATE_FAILURE;
|
2001-12-23 16:42:33 +00:00
|
|
|
|
}
|
|
|
|
|
if (dv1394src->pinfo[dv1394src->card].nodes <= 1) {
|
2004-03-15 19:32:27 +00:00
|
|
|
|
GST_INFO_OBJECT (dv1394src, "there are no nodes on the 1394 bus");
|
|
|
|
|
return GST_STATE_FAILURE;
|
2001-12-23 16:42:33 +00:00
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
if (raw1394_set_port (dv1394src->handle, dv1394src->port) < 0) {
|
2004-03-15 19:32:27 +00:00
|
|
|
|
GST_INFO_OBJECT (dv1394src, "can't set 1394 port %d", dv1394src->port);
|
|
|
|
|
return GST_STATE_FAILURE;
|
2001-12-23 16:42:33 +00:00
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
raw1394_set_iso_handler (dv1394src->handle, dv1394src->channel,
|
2004-03-15 19:32:27 +00:00
|
|
|
|
gst_dv1394src_iso_receive);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
raw1394_set_bus_reset_handler (dv1394src->handle,
|
2004-03-15 19:32:27 +00:00
|
|
|
|
gst_dv1394src_bus_reset);
|
2001-12-23 16:42:33 +00:00
|
|
|
|
dv1394src->started = FALSE;
|
2003-06-29 19:46:12 +00:00
|
|
|
|
GST_DEBUG ("successfully opened up 1394 connection");
|
2001-12-23 16:42:33 +00:00
|
|
|
|
break;
|
|
|
|
|
case GST_STATE_PAUSED_TO_PLAYING:
|
2004-03-14 22:34:33 +00:00
|
|
|
|
if (raw1394_start_iso_rcv (dv1394src->handle, dv1394src->channel) < 0) {
|
2004-03-15 19:32:27 +00:00
|
|
|
|
GST_INFO_OBJECT (dv1394src, "can't start 1394 iso receive");
|
|
|
|
|
return GST_STATE_FAILURE;
|
2001-12-23 16:42:33 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case GST_STATE_PLAYING_TO_PAUSED:
|
2004-03-14 22:34:33 +00:00
|
|
|
|
raw1394_stop_iso_rcv (dv1394src->handle, dv1394src->channel);
|
2001-12-23 16:42:33 +00:00
|
|
|
|
break;
|
|
|
|
|
case GST_STATE_READY_TO_NULL:
|
2004-03-14 22:34:33 +00:00
|
|
|
|
raw1394_destroy_handle (dv1394src->handle);
|
2001-12-23 16:42:33 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
|
/* if we haven't failed already, give the parent class a chance to ;-) */
|
2001-12-23 16:42:33 +00:00
|
|
|
|
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
|
|
|
|
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
|
|
|
|
|
|
|
|
|
return GST_STATE_SUCCESS;
|
|
|
|
|
}
|