add virtual camera

report us being a ptp class camera
This commit is contained in:
Marcus Meissner
2015-12-07 15:59:09 +01:00
parent d46dd69d7d
commit ead8d6c616
4 changed files with 102 additions and 1 deletions

View File

@@ -10,4 +10,4 @@ vusb_la_CPPFLAGS = \
vusb_la_DEPENDENCIES = $(iolib_dependencies)
vusb_la_LIBADD = $(iolib_libadd)
vusb_la_LIBADD += $(INTLLIBS)
vusb_la_SOURCES = vusb/vusb.c
vusb_la_SOURCES = vusb/vusb.c vusb/vcamera.c vusb/vcamera.h

View File

@@ -0,0 +1,66 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* camera.c
*
* Copyright (c) 2015 Marcus Meissner <marcus@jet.franken.de>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
#include "config.h"
#include <gphoto2/gphoto2-port-library.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/time.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#include <string.h>
#include "vcamera.h"
#include <gphoto2/gphoto2-port.h>
#include <gphoto2/gphoto2-port-result.h>
#include <gphoto2/gphoto2-port-log.h>
#ifdef ENABLE_NLS
# include <libintl.h>
# undef _
# define _(String) dgettext (GETTEXT_PACKAGE, String)
# ifdef gettext_noop
# define N_(String) gettext_noop (String)
# else
# define N_(String) (String)
# endif
#else
# define textdomain(String) (String)
# define gettext(String) (String)
# define dgettext(Domain,Message) (Message)
# define dcgettext(Domain,Message,Type) (Message)
# define bindtextdomain(Domain,Directory) (Domain)
# define _(String) (String)
# define N_(String) (String)
#endif
#define CHECK(result) {int r=(result); if (r<0) return (r);}
vcamera*
vcamera_new(void) {
return calloc(sizeof(vcamera),1);
}

View File

@@ -0,0 +1,32 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* vcamera.h
*
* Copyright (c) 2015 Marcus Meissner <marcus@jet.franken.de>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
#ifndef __VCAMERA_H__
#define __VCAMERA_H__
typedef struct vcamera {
int (*open)(struct vcamera*);
int (*close)(struct vcamera*);
} vcamera;
vcamera *vcamera_new(void);
#endif

View File

@@ -259,6 +259,9 @@ static int
gp_port_vusb_find_device_by_class_lib(GPPort *port, int class, int subclass, int protocol)
{
gp_log(GP_LOG_DEBUG,__FUNCTION__,"(0x%02x,0x%02x,0x%02x)", class, subclass, protocol);
if ((class == 6) && (subclass == 1) && (protocol == 1))
return GP_OK;
return GP_ERROR_IO_USB_FIND;
}