1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2 -*- */
3 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
4 * <2000> Daniel Fischer <dan@f3c.com>
5 * <2004> Wim Taymans <wim@fluendo.com>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
28 #include <libavc1394/avc1394.h>
29 #include <libavc1394/avc1394_vcr.h>
30 #include <libavc1394/rom1394.h>
32 #include "gstdv1394src.h"
34 GST_DEBUG_CATEGORY_STATIC (dv1394src_debug);
35 #define GST_CAT_DEFAULT (dv1394src_debug)
37 #define PAL_FRAMESIZE 144000
38 #define PAL_FRAMERATE 25
40 #define NTSC_FRAMESIZE 120000
41 #define NTSC_FRAMERATE 30
43 /* Filter signals and args */
51 #define DEFAULT_PORT -1
52 #define DEFAULT_CHANNEL 63
53 #define DEFAULT_CONSECUTIVE 1
54 #define DEFAULT_SKIP 0
55 #define DEFAULT_DROP_INCOMPLETE TRUE
56 #define DEFAULT_USE_AVC TRUE
57 #define DEFAULT_GUID 0
71 static GstElementDetails gst_dv1394src_details =
72 GST_ELEMENT_DETAILS ("Firewire (1394) DV Source",
74 "Source for DV video data from firewire port",
75 "Erik Walthinsen <omega@temple-baptist.com>\n"
76 "Daniel Fischer <dan@f3c.com>\n" "Wim Taymans <wim@fluendo.com>");
78 static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
81 GST_STATIC_CAPS ("video/x-dv, "
82 "format = (string) { NTSC, PAL }, " "systemstream = (boolean) true")
85 static void gst_dv1394src_base_init (gpointer g_class);
86 static void gst_dv1394src_class_init (GstDV1394SrcClass * klass);
87 static void gst_dv1394src_init (GstDV1394Src * filter);
88 static void gst_dv1394src_dispose (GObject * obj);
90 static void gst_dv1394src_set_property (GObject * object, guint prop_id,
91 const GValue * value, GParamSpec * pspec);
92 static void gst_dv1394src_get_property (GObject * object, guint prop_id,
93 GValue * value, GParamSpec * pspec);
95 static GstElementStateReturn gst_dv1394src_change_state (GstElement * element);
97 static GstFlowReturn gst_dv1394src_create (GstPushSrc * psrc, GstBuffer ** buf);
100 static const GstEventMask *gst_dv1394src_get_event_mask (GstPad * pad);
102 static gboolean gst_dv1394src_event (GstPad * pad, GstEvent * event);
105 static const GstFormat *gst_dv1394src_get_formats (GstPad * pad);
107 static gboolean gst_dv1394src_convert (GstPad * pad,
108 GstFormat src_format, gint64 src_value,
109 GstFormat * dest_format, gint64 * dest_value);
111 static const GstQueryType *gst_dv1394src_get_query_types (GstPad * pad);
112 static gboolean gst_dv1394src_query (GstPad * pad, GstQuery * query);
114 static GstElementClass *parent_class = NULL;
116 static void gst_dv1394src_uri_handler_init (gpointer g_iface,
117 gpointer iface_data);
119 static guint gst_dv1394src_signals[LAST_SIGNAL] = { 0 };
122 gst_dv1394src_get_type (void)
124 static GType gst_dv1394src_type = 0;
126 if (!gst_dv1394src_type) {
127 static const GTypeInfo gst_dv1394src_info = {
128 sizeof (GstDV1394Src),
129 gst_dv1394src_base_init,
131 (GClassInitFunc) gst_dv1394src_class_init,
134 sizeof (GstDV1394Src),
136 (GInstanceInitFunc) gst_dv1394src_init,
138 static const GInterfaceInfo urihandler_info = {
139 gst_dv1394src_uri_handler_init,
145 g_type_register_static (GST_TYPE_PUSH_SRC, "DV1394Src",
146 &gst_dv1394src_info, 0);
148 g_type_add_interface_static (gst_dv1394src_type, GST_TYPE_URI_HANDLER,
151 GST_DEBUG_CATEGORY_INIT (dv1394src_debug, "dv1394src", 0,
152 "DV firewire source");
154 return gst_dv1394src_type;
158 gst_dv1394src_base_init (gpointer g_class)
160 GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
162 gst_element_class_add_pad_template (element_class,
163 gst_static_pad_template_get (&src_factory));
165 gst_element_class_set_details (element_class, &gst_dv1394src_details);
169 gst_dv1394src_class_init (GstDV1394SrcClass * klass)
171 GObjectClass *gobject_class;
172 GstElementClass *gstelement_class;
173 GstBaseSrcClass *gstbasesrc_class;
174 GstPushSrcClass *gstpushsrc_class;
176 gobject_class = (GObjectClass *) klass;
177 gstelement_class = (GstElementClass *) klass;
178 gstbasesrc_class = (GstBaseSrcClass *) klass;
179 gstpushsrc_class = (GstPushSrcClass *) klass;
181 parent_class = g_type_class_ref (GST_TYPE_PUSH_SRC);
183 gobject_class->set_property = gst_dv1394src_set_property;
184 gobject_class->get_property = gst_dv1394src_get_property;
185 gobject_class->dispose = gst_dv1394src_dispose;
187 gst_dv1394src_signals[SIGNAL_FRAME_DROPPED] =
188 g_signal_new ("frame-dropped", G_TYPE_FROM_CLASS (klass),
189 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstDV1394SrcClass, frame_dropped),
190 NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
192 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PORT,
193 g_param_spec_int ("port", "Port", "Port number (-1 automatic)",
194 -1, 16, DEFAULT_PORT, G_PARAM_READWRITE));
195 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_CHANNEL,
196 g_param_spec_int ("channel", "Channel", "Channel number for listening",
197 0, 64, DEFAULT_CHANNEL, G_PARAM_READWRITE));
198 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_CONSECUTIVE,
199 g_param_spec_int ("consecutive", "consecutive frames",
200 "send n consecutive frames after skipping", 1, G_MAXINT,
201 DEFAULT_CONSECUTIVE, G_PARAM_READWRITE));
202 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SKIP,
203 g_param_spec_int ("skip", "skip frames", "skip n frames",
204 0, G_MAXINT, DEFAULT_SKIP, G_PARAM_READWRITE));
205 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DROP_INCOMPLETE,
206 g_param_spec_boolean ("drop_incomplete", "drop_incomplete",
207 "drop incomplete frames", DEFAULT_DROP_INCOMPLETE,
209 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_USE_AVC,
210 g_param_spec_boolean ("use-avc", "Use AV/C", "Use AV/C VTR control",
211 DEFAULT_USE_AVC, G_PARAM_READWRITE));
212 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_GUID,
213 g_param_spec_uint64 ("guid", "GUID",
214 "select one of multiple DV devices by its GUID. use a hexadecimal "
215 "like 0xhhhhhhhhhhhhhhhh. (0 = no guid)", 0, G_MAXUINT64,
216 DEFAULT_GUID, G_PARAM_READWRITE));
218 gstelement_class->change_state = gst_dv1394src_change_state;
220 gstbasesrc_class->negotiate = NULL;
221 gstpushsrc_class->create = gst_dv1394src_create;
225 gst_dv1394src_init (GstDV1394Src * dv1394src)
227 GstPad *srcpad = GST_BASE_SRC_PAD (dv1394src);
229 gst_base_src_set_live (GST_BASE_SRC (dv1394src), TRUE);
230 gst_pad_use_fixed_caps (srcpad);
232 gst_pad_set_event_function (srcpad, gst_dv1394src_event);
233 gst_pad_set_query_function (srcpad, gst_dv1394src_query);
234 gst_pad_set_query_type_function (srcpad, gst_dv1394src_get_query_types);
237 gst_pad_set_event_mask_function (dv1394src->srcpad,
238 gst_dv1394src_get_event_mask);
239 gst_pad_set_convert_function (dv1394src->srcpad, gst_dv1394src_convert);
240 gst_pad_set_formats_function (dv1394src->srcpad, gst_dv1394src_get_formats);
243 dv1394src->dv_lock = g_mutex_new ();
244 dv1394src->port = DEFAULT_PORT;
245 dv1394src->channel = DEFAULT_CHANNEL;
247 dv1394src->consecutive = DEFAULT_CONSECUTIVE;
248 dv1394src->skip = DEFAULT_SKIP;
249 dv1394src->drop_incomplete = DEFAULT_DROP_INCOMPLETE;
250 dv1394src->use_avc = DEFAULT_USE_AVC;
251 dv1394src->guid = DEFAULT_GUID;
253 /* initialized when first header received */
254 dv1394src->frame_size = 0;
256 dv1394src->buf = NULL;
257 dv1394src->frame = NULL;
258 dv1394src->frame_sequence = 0;
262 gst_dv1394src_dispose (GObject * obj)
264 GstDV1394Src *dv1394src;
266 dv1394src = GST_DV1394SRC (obj);
268 G_OBJECT_CLASS (parent_class)->dispose (obj);
272 gst_dv1394src_set_property (GObject * object, guint prop_id,
273 const GValue * value, GParamSpec * pspec)
275 GstDV1394Src *filter = GST_DV1394SRC (object);
279 filter->port = g_value_get_int (value);
282 filter->channel = g_value_get_int (value);
285 filter->skip = g_value_get_int (value);
287 case ARG_CONSECUTIVE:
288 filter->consecutive = g_value_get_int (value);
290 case ARG_DROP_INCOMPLETE:
291 filter->drop_incomplete = g_value_get_boolean (value);
294 filter->use_avc = g_value_get_boolean (value);
297 filter->guid = g_value_get_uint64 (value);
305 gst_dv1394src_get_property (GObject * object, guint prop_id, GValue * value,
308 GstDV1394Src *filter = GST_DV1394SRC (object);
312 g_value_set_int (value, filter->port);
315 g_value_set_int (value, filter->channel);
318 g_value_set_int (value, filter->skip);
320 case ARG_CONSECUTIVE:
321 g_value_set_int (value, filter->consecutive);
323 case ARG_DROP_INCOMPLETE:
324 g_value_set_boolean (value, filter->drop_incomplete);
327 g_value_set_boolean (value, filter->use_avc);
330 g_value_set_uint64 (value, filter->guid);
333 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
339 gst_dv1394src_iso_receive (raw1394handle_t handle, int channel, size_t len,
342 GstDV1394Src *dv1394src = GST_DV1394SRC (raw1394_get_userdata (handle));
346 the following code taken from kino-0.51 (Dan Dennedy/Charles Yates)
348 unsigned char *p = (unsigned char *) &data[3];
349 int section_type = p[0] >> 5; /* section type is in bits 5 - 7 */
350 int dif_sequence = p[1] >> 4; /* dif sequence number is in bits 4 - 7 */
351 int dif_block = p[2];
353 /* if we are at the beginning of a frame,
354 we set buf=frame, and alloc a new buffer for frame
357 if (section_type == 0 && dif_sequence == 0) { // dif header
358 if (!dv1394src->negotiated) {
361 // figure format (NTSC/PAL)
364 dv1394src->frame_size = PAL_FRAMESIZE;
365 dv1394src->frame_rate = PAL_FRAMERATE;
366 GST_DEBUG ("PAL data");
367 caps = gst_caps_new_simple ("video/x-dv",
368 "format", G_TYPE_STRING, "PAL",
369 "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
372 dv1394src->frame_size = NTSC_FRAMESIZE;
373 dv1394src->frame_rate = NTSC_FRAMERATE;
375 ("NTSC data [untested] - please report success/failure to <dan@f3c.com>");
376 caps = gst_caps_new_simple ("video/x-dv",
377 "format", G_TYPE_STRING, "NTSC",
378 "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
380 gst_pad_set_caps (GST_BASE_SRC_PAD (dv1394src), caps);
381 gst_caps_unref (caps);
382 dv1394src->negotiated = TRUE;
384 // drop last frame when not complete
385 if (!dv1394src->drop_incomplete
386 || dv1394src->bytes_in_frame == dv1394src->frame_size) {
387 dv1394src->buf = dv1394src->frame;
389 GST_INFO_OBJECT (GST_ELEMENT (dv1394src), "incomplete frame dropped");
390 g_signal_emit (G_OBJECT (dv1394src),
391 gst_dv1394src_signals[SIGNAL_FRAME_DROPPED], 0);
392 if (dv1394src->frame) {
393 gst_buffer_unref (dv1394src->frame);
396 dv1394src->frame = NULL;
397 if ((dv1394src->frame_sequence + 1) % (dv1394src->skip +
398 dv1394src->consecutive) < dv1394src->consecutive) {
402 buf = gst_buffer_new_and_alloc (dv1394src->frame_size);
404 /* fill in default offset */
405 format = GST_FORMAT_DEFAULT;
406 gst_dv1394src_query (dv1394src->srcpad, GST_QUERY_POSITION, &format,
407 &GST_BUFFER_OFFSET (buf));
408 /* fill in timestamp */
409 format = GST_FORMAT_TIME;
410 gst_dv1394src_query (dv1394src->srcpad, GST_QUERY_POSITION, &format,
411 &GST_BUFFER_TIMESTAMP (buf));
412 /* fill in duration by converting one frame to time */
413 gst_dv1394src_convert (dv1394src->srcpad, GST_FORMAT_DEFAULT, 1,
414 &format, &GST_BUFFER_DURATION (buf));
417 dv1394src->frame = buf;
419 dv1394src->frame_sequence++;
420 dv1394src->bytes_in_frame = 0;
423 if (dv1394src->frame != NULL) {
424 guint8 *data = GST_BUFFER_DATA (dv1394src->frame);
426 switch (section_type) {
427 case 0: /* 1 Header block */
428 /* p[3] |= 0x80; // hack to force PAL data */
429 memcpy (data + dif_sequence * 150 * 80, p, 480);
432 case 1: /* 2 Subcode blocks */
433 memcpy (data + dif_sequence * 150 * 80 + (1 + dif_block) * 80, p,
437 case 2: /* 3 VAUX blocks */
438 memcpy (data + dif_sequence * 150 * 80 + (3 + dif_block) * 80, p,
442 case 3: /* 9 Audio blocks interleaved with video */
443 memcpy (data + dif_sequence * 150 * 80 + (6 + dif_block * 16) * 80, p,
447 case 4: /* 135 Video blocks interleaved with audio */
448 memcpy (data + dif_sequence * 150 * 80 + (7 + (dif_block / 15) +
449 dif_block) * 80, p, 480);
452 default: /* we can't handle any other data */
455 dv1394src->bytes_in_frame += 480;
463 gst_dv1394src_bus_reset (raw1394handle_t handle, unsigned int generation)
465 GST_INFO_OBJECT (GST_DV1394SRC (raw1394_get_userdata (handle)),
471 gst_dv1394src_create (GstPushSrc * psrc, GstBuffer ** buf)
473 GstDV1394Src *dv1394src = GST_DV1394SRC (psrc);
476 GST_DV_LOCK (dv1394src);
477 dv1394src->buf = NULL;
478 while (dv1394src->buf == NULL)
479 raw1394_loop_iterate (dv1394src->handle);
481 caps = gst_pad_get_caps (GST_BASE_SRC_PAD (psrc));
482 gst_buffer_set_caps (dv1394src->buf, caps);
483 gst_caps_unref (caps);
485 *buf = dv1394src->buf;
486 GST_DV_UNLOCK (dv1394src);
492 gst_dv1394src_discover_avc_node (GstDV1394Src * src)
496 int m = src->num_ports;
498 if (src->port >= 0) {
499 /* search on explicit port */
504 /* loop over all our ports */
505 for (; j < m && node == -1; j++) {
506 raw1394handle_t handle;
508 struct raw1394_portinfo pinf[16];
511 handle = raw1394_new_handle ();
513 g_warning ("raw1394 - failed to get handle: %s.\n", strerror (errno));
516 if ((n_ports = raw1394_get_port_info (handle, pinf, 16)) < 0) {
517 g_warning ("raw1394 - failed to get port info: %s.\n", strerror (errno));
521 /* tell raw1394 which host adapter to use */
522 if (raw1394_set_port (handle, j) < 0) {
523 g_warning ("raw1394 - failed to set set port: %s.\n", strerror (errno));
527 /* now loop over all the nodes */
528 for (i = 0; i < raw1394_get_nodecount (handle); i++) {
529 /* are we looking for an explicit GUID */
530 if (src->guid != 0) {
531 if (src->guid == rom1394_get_guid (handle, i)) {
537 rom1394_directory rom_dir;
539 /* select first AV/C Tape Reccorder Player node */
540 if (rom1394_get_directory (handle, i, &rom_dir) < 0) {
541 g_warning ("error reading config rom directory for node %d\n", i);
544 if ((rom1394_get_node_type (&rom_dir) == ROM1394_NODE_TYPE_AVC) &&
545 avc1394_check_subunit_type (handle, i, AVC1394_SUBUNIT_TYPE_VCR)) {
553 raw1394_destroy_handle (handle);
558 static GstElementStateReturn
559 gst_dv1394src_change_state (GstElement * element)
561 GstDV1394Src *dv1394src;
563 GstElementStateReturn ret;
565 dv1394src = GST_DV1394SRC (element);
566 transition = GST_STATE_TRANSITION (element);
568 switch (transition) {
569 case GST_STATE_NULL_TO_READY:
570 /* create a handle */
571 if ((dv1394src->handle = raw1394_new_handle ()) == NULL)
574 /* set this plugin as the user data */
575 raw1394_set_userdata (dv1394src->handle, dv1394src);
577 /* get number of ports */
578 if ((dv1394src->num_ports =
579 raw1394_get_port_info (dv1394src->handle, dv1394src->pinfo,
583 if (dv1394src->use_avc || dv1394src->port == -1) {
584 /* discover AVC and optionally the port */
585 dv1394src->avc_node = gst_dv1394src_discover_avc_node (dv1394src);
588 /* configure our port now */
589 if (raw1394_set_port (dv1394src->handle, dv1394src->port) < 0)
590 goto cannot_set_port;
592 /* set the callbacks */
593 raw1394_set_iso_handler (dv1394src->handle, dv1394src->channel,
594 gst_dv1394src_iso_receive);
595 raw1394_set_bus_reset_handler (dv1394src->handle,
596 gst_dv1394src_bus_reset);
598 GST_DEBUG_OBJECT (dv1394src, "successfully opened up 1394 connection");
600 case GST_STATE_PAUSED_TO_PLAYING:
601 if (raw1394_start_iso_rcv (dv1394src->handle, dv1394src->channel) < 0)
604 if (dv1394src->use_avc) {
606 if (!avc1394_vcr_is_recording (dv1394src->handle, dv1394src->avc_node)
607 && avc1394_vcr_is_playing (dv1394src->handle, dv1394src->avc_node)
608 != AVC1394_VCR_OPERAND_PLAY_FORWARD) {
609 avc1394_vcr_play (dv1394src->handle, dv1394src->avc_node);
617 /* if we haven't failed already, give the parent class a chance to ;-) */
618 ret = GST_ELEMENT_CLASS (parent_class)->change_state (element);
620 switch (transition) {
621 case GST_STATE_PLAYING_TO_PAUSED:
622 /* we need to lock here as the _create function has to be completed.
623 * The base source will not call the _create() function again. */
624 GST_DV_LOCK (dv1394src);
625 raw1394_stop_iso_rcv (dv1394src->handle, dv1394src->channel);
626 if (dv1394src->use_avc) {
628 if (!avc1394_vcr_is_recording (dv1394src->handle, dv1394src->avc_node)
629 && (avc1394_vcr_is_playing (dv1394src->handle, dv1394src->avc_node)
630 != AVC1394_VCR_OPERAND_PLAY_FORWARD_PAUSE)) {
631 avc1394_vcr_pause (dv1394src->handle, dv1394src->avc_node);
634 GST_DV_UNLOCK (dv1394src);
636 case GST_STATE_PAUSED_TO_READY:
637 dv1394src->negotiated = FALSE;
639 case GST_STATE_READY_TO_NULL:
640 if (dv1394src->use_avc) {
642 avc1394_vcr_stop (dv1394src->handle, dv1394src->avc_node);
644 raw1394_destroy_handle (dv1394src->handle);
654 GST_ELEMENT_ERROR (dv1394src, RESOURCE, NOT_FOUND, (NULL),
655 ("can't get raw1394 handle"));
656 return GST_STATE_FAILURE;
660 GST_ELEMENT_ERROR (dv1394src, RESOURCE, NOT_FOUND, (NULL),
661 ("no ports available for raw1394"));
662 return GST_STATE_FAILURE;
666 GST_ELEMENT_ERROR (dv1394src, RESOURCE, SETTINGS, (NULL),
667 ("can't set 1394 port %d", dv1394src->port));
668 return GST_STATE_FAILURE;
672 GST_ELEMENT_ERROR (dv1394src, RESOURCE, READ, (NULL),
673 ("can't start 1394 iso receive"));
674 return GST_STATE_FAILURE;
680 static const GstEventMask *
681 gst_dv1394src_get_event_mask (GstPad * pad)
683 static const GstEventMask masks[] = {
692 gst_dv1394src_event (GstPad * pad, GstEvent * event)
698 static const GstFormat *
699 gst_dv1394src_get_formats (GstPad * pad)
701 static GstFormat formats[] = {
713 gst_dv1394src_convert (GstPad * pad,
714 GstFormat src_format, gint64 src_value,
715 GstFormat * dest_format, gint64 * dest_value)
719 src = GST_DV1394SRC (gst_pad_get_parent (pad));
721 switch (src_format) {
722 case GST_FORMAT_TIME:
723 switch (*dest_format) {
724 case GST_FORMAT_BYTES:
725 src_value *= src->frame_size;
726 case GST_FORMAT_DEFAULT:
727 *dest_value = src_value * src->frame_rate / GST_SECOND;
733 case GST_FORMAT_BYTES:
734 src_value /= src->frame_size;
735 case GST_FORMAT_DEFAULT:
736 switch (*dest_format) {
737 case GST_FORMAT_BYTES:
738 *dest_value = src_value * src->frame_size;
740 case GST_FORMAT_TIME:
741 if (src->frame_rate != 0)
742 *dest_value = src_value * GST_SECOND / src->frame_rate;
754 gst_object_unref (src);
759 gst_object_unref (src);
764 static const GstQueryType *
765 gst_dv1394src_get_query_types (GstPad * pad)
767 static const GstQueryType src_query_types[] = {
773 return src_query_types;
777 gst_dv1394src_query (GstPad * pad, GstQuery * query)
782 src = GST_DV1394SRC (gst_pad_get_parent (pad));
784 switch (GST_QUERY_TYPE (query)) {
785 case GST_QUERY_POSITION:
790 gst_query_parse_position (query, &format, NULL, NULL);
792 /* bring our current frame to the requested format */
793 res = gst_pad_query_convert (pad,
794 GST_FORMAT_DEFAULT, src->frame_sequence, &format, ¤t);
796 gst_query_set_position (query, format, current, -1);
799 case GST_QUERY_CONVERT:
801 GstFormat src_fmt, dest_fmt;
802 gint64 src_val, dest_val;
804 gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, &dest_val);
806 gst_dv1394src_convert (pad, src_fmt, src_val, &dest_fmt,
809 gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val);
816 gst_object_unref (src);
821 gst_object_unref (src);
826 /*** GSTURIHANDLER INTERFACE *************************************************/
829 gst_dv1394src_uri_get_type (void)
834 gst_dv1394src_uri_get_protocols (void)
836 static gchar *protocols[] = { "dv", NULL };
841 gst_dv1394src_uri_get_uri (GstURIHandler * handler)
843 GstDV1394Src *gst_dv1394src = GST_DV1394SRC (handler);
845 return gst_dv1394src->uri;
849 gst_dv1394src_uri_set_uri (GstURIHandler * handler, const gchar * uri)
851 gchar *protocol, *location;
856 GstDV1394Src *gst_dv1394src = GST_DV1394SRC (handler);
858 protocol = gst_uri_get_protocol (uri);
859 if (strcmp (protocol, "dv") != 0) {
865 location = gst_uri_get_location (uri);
866 gst_dv1394src->port = strtol (location, NULL, 10);
873 gst_dv1394src_uri_handler_init (gpointer g_iface, gpointer iface_data)
875 GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
877 iface->get_type = gst_dv1394src_uri_get_type;
878 iface->get_protocols = gst_dv1394src_uri_get_protocols;
879 iface->get_uri = gst_dv1394src_uri_get_uri;
880 iface->set_uri = gst_dv1394src_uri_set_uri;