Ejemplo n.º 1
0
int discoverAVC( int* port, octlet_t guid )
{
	rom1394_directory rom_dir;
	raw1394handle_t handle;
	int device = -1;
	int i, j = 0;
	int m = raw1394_get_num_ports();

	if ( *port >= 0 )
	{
		/* search on explicit port */
		j = *port;
		m = *port + 1;
	}

	for ( ; j < m && device == -1; j++ )
	{
		handle = raw1394_open( j );
		for ( i = 0; i < raw1394_get_nodecount( handle ); ++i )
		{
			if ( guid != 0 )
			{
				/* select explicitly by GUID */
				if ( guid == rom1394_get_guid( handle, i ) )
				{
					device = i;
					*port = j;
					break;
				}
			}
			else
			{
				/* select first AV/C Tape Reccorder Player node */
				if ( rom1394_get_directory( handle, i, &rom_dir ) < 0 )
				{
					fprintf( stderr, "error reading config rom directory for node %d\n", i );
					continue;
				}
				if ( ( rom1394_get_node_type( &rom_dir ) == ROM1394_NODE_TYPE_AVC ) &&
				        avc1394_check_subunit_type( handle, i, AVC1394_SUBUNIT_TYPE_VCR ) )
				{
					device = i;
					*port = j;
					break;
				}
			}
		}
		raw1394_close( handle );
	}

	return device;
}
Ejemplo n.º 2
0
static GValueArray *
gst_1394_get_guid_array (void)
{
  GValueArray *result = NULL;
  raw1394handle_t handle = NULL;
  int num_ports = 0;
  int port = 0;
  int num_nodes = 0;
  int node = 0;
  rom1394_directory directory;
  GValue value = { 0, };

  handle = raw1394_new_handle ();

  if (handle == NULL)
    return NULL;

  num_ports = raw1394_get_port_info (handle, NULL, 0);
  for (port = 0; port < num_ports; port++) {
    if (raw1394_set_port (handle, port) >= 0) {
      num_nodes = raw1394_get_nodecount (handle);
      for (node = 0; node < num_nodes; node++) {
        rom1394_get_directory (handle, node, &directory);
        if (rom1394_get_node_type (&directory) == ROM1394_NODE_TYPE_AVC &&
            avc1394_check_subunit_type (handle, node,
                AVC1394_SUBUNIT_TYPE_VCR)) {
          if (result == NULL)
            result = g_value_array_new (3);     /* looks like a sensible default */
          g_value_init (&value, G_TYPE_UINT64);
          g_value_set_uint64 (&value, rom1394_get_guid (handle, node));
          g_value_array_append (result, &value);
          g_value_unset (&value);
        }
      }
    }
  }

  return result;
}
Ejemplo n.º 3
0
void AVC1394Control::initialize()
{
	int i;

	current_command = COMMAND_NONE;
	device = -1;

	device_lock = new Mutex("AVC1394Control::device_lock");

#ifdef RAW1394_V_0_8
	handle = raw1394_get_handle();
#else
	handle = raw1394_new_handle();
#endif
//printf("AVC1394Control::initialize(): 1\n");
	if(!handle)
	{
//printf("AVC1394Control::initialize(): 2\n");
		if(!errno)
		{
//printf("AVC1394Control::initialize(): 3\n");
			fprintf(stderr, "AVC1394Control::initialize(): Not Compatable!\n");
		} 
		else 
		{
//printf("AVC1394Control::initialize(): 4\n");
			fprintf(stderr, "AVC1394Control::initialize(): couldn't get handle\n");
		}
		return;
	}

	if(raw1394_set_port(handle, 0) < 0) {
//printf("AVC1394Control::initialize(): 5\n");
		perror("AVC1394Control::initialize(): couldn't set port");
//		raw1394_destroy_handle(handle);
		return;
	}

	for(i = 0; i < raw1394_get_nodecount(handle); i++)
	{
		if(rom1394_get_directory(handle, i, &rom_dir) < 0)
		{
//printf("AVC1394Control::initialize(): 6\n");
			fprintf(stderr, "AVC1394Control::initialize(): node %d\n", i);
//			raw1394_destroy_handle(handle);
			return;
		}
		
		if((rom1394_get_node_type(&rom_dir) == ROM1394_NODE_TYPE_AVC) &&
			avc1394_check_subunit_type(handle, i, AVC1394_SUBUNIT_TYPE_VCR))
		{
//printf("AVC1394Control::initialize(): 7\n");
			device = i;
			break;
		}
	}

	if(device == -1)
	{
//printf("AVC1394Control::initialize(): 8\n");
		fprintf(stderr, "AVC1394Control::initialize(): No AV/C Devices\n");
//		raw1394_destroy_handle(handle);
		return;
	}

}
static int
gst_hdv1394src_discover_avc_node (GstHDV1394Src * src)
{
    int node = -1;
    int i, j = 0;
    int m = src->num_ports;

    if (src->port >= 0) {
        /* search on explicit port */
        j = src->port;
        m = j + 1;
    }

    /* loop over all our ports */
    for (; j < m && node == -1; j++) {
        raw1394handle_t handle;
        struct raw1394_portinfo pinf[16];

        /* open the port */
        handle = raw1394_new_handle ();
        if (!handle) {
            GST_WARNING ("raw1394 - failed to get handle: %s.\n", strerror (errno));
            continue;
        }
        if (raw1394_get_port_info (handle, pinf, 16) < 0) {
            GST_WARNING ("raw1394 - failed to get port info: %s.\n",
                         strerror (errno));
            goto next;
        }

        /* tell raw1394 which host adapter to use */
        if (raw1394_set_port (handle, j) < 0) {
            GST_WARNING ("raw1394 - failed to set set port: %s.\n", strerror (errno));
            goto next;
        }

        /* now loop over all the nodes */
        for (i = 0; i < raw1394_get_nodecount (handle); i++) {
            /* are we looking for an explicit GUID ? */
            if (src->guid != 0) {
                if (src->guid == rom1394_get_guid (handle, i)) {
                    node = i;
                    src->port = j;
                    g_free (src->uri);
                    src->uri = g_strdup_printf ("dv://%d", src->port);
                    break;
                }
            } else {
                rom1394_directory rom_dir;

                /* select first AV/C Tape Recorder Player node */
                if (rom1394_get_directory (handle, i, &rom_dir) < 0) {
                    GST_WARNING ("error reading config rom directory for node %d\n", i);
                    continue;
                }
                if ((rom1394_get_node_type (&rom_dir) == ROM1394_NODE_TYPE_AVC) &&
                        avc1394_check_subunit_type (handle, i, AVC1394_SUBUNIT_TYPE_VCR)) {
                    node = i;
                    src->port = j;
                    src->guid = rom1394_get_guid (handle, i);
                    g_free (src->uri);
                    src->uri = g_strdup_printf ("dv://%d", src->port);
                    g_free (src->device_name);
                    src->device_name = g_strdup (rom_dir.label);
                    break;
                }
                rom1394_free_directory (&rom_dir);
            }
        }
next:
        raw1394_destroy_handle (handle);
    }
    return node;
}