From ead8d6c6164945482a4e688c347a2d446b17e5eb Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Mon, 7 Dec 2015 15:59:09 +0100 Subject: [PATCH] add virtual camera report us being a ptp class camera --- libgphoto2_port/vusb/Makefile-files | 2 +- libgphoto2_port/vusb/vcamera.c | 66 +++++++++++++++++++++++++++++ libgphoto2_port/vusb/vcamera.h | 32 ++++++++++++++ libgphoto2_port/vusb/vusb.c | 3 ++ 4 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 libgphoto2_port/vusb/vcamera.c create mode 100644 libgphoto2_port/vusb/vcamera.h diff --git a/libgphoto2_port/vusb/Makefile-files b/libgphoto2_port/vusb/Makefile-files index a7f785266..cca0a125b 100644 --- a/libgphoto2_port/vusb/Makefile-files +++ b/libgphoto2_port/vusb/Makefile-files @@ -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 diff --git a/libgphoto2_port/vusb/vcamera.c b/libgphoto2_port/vusb/vcamera.c new file mode 100644 index 000000000..550c7b7b2 --- /dev/null +++ b/libgphoto2_port/vusb/vcamera.c @@ -0,0 +1,66 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* camera.c + * + * Copyright (c) 2015 Marcus Meissner + * + * 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 + +#include +#include +#include +#include +#include +#include +#ifdef HAVE_SYS_PARAM_H +#include +#endif +#include + +#include "vcamera.h" + +#include +#include +#include + +#ifdef ENABLE_NLS +# include +# 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); +} diff --git a/libgphoto2_port/vusb/vcamera.h b/libgphoto2_port/vusb/vcamera.h new file mode 100644 index 000000000..175b3dace --- /dev/null +++ b/libgphoto2_port/vusb/vcamera.h @@ -0,0 +1,32 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* vcamera.h + * + * Copyright (c) 2015 Marcus Meissner + * + * 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 diff --git a/libgphoto2_port/vusb/vusb.c b/libgphoto2_port/vusb/vusb.c index b417724f8..f26023e49 100644 --- a/libgphoto2_port/vusb/vusb.c +++ b/libgphoto2_port/vusb/vusb.c @@ -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; }