Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 60350 Details for
Bug 76127
Gyach enhanced is a Yahoo Messenger linux client
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
gyach-enhanced-1.0.7-webcam_support.patch
gyach-enhanced-1.0.7-webcam_support.patch (text/plain), 10.86 KB, created by
Natanael Copa
on 2005-06-01 03:52:54 UTC
(
hide
)
Description:
gyach-enhanced-1.0.7-webcam_support.patch
Filename:
MIME Type:
Creator:
Natanael Copa
Created:
2005-06-01 03:52:54 UTC
Size:
10.86 KB
patch
obsolete
>--- 1.0.7.orig/gyach/src/webcam/gyacheupload-v4l.c 2005-04-08 15:51:37.714929848 +0200 >+++ 1.0.7/gyach/src/webcam/gyacheupload-v4l.c 2005-06-01 11:22:20.646843816 +0200 >@@ -47,7 +47,11 @@ > and Copyright (C) 1999-2002, Torrey Searle <tsearle@uci.edu> > */ > >-# include "gyacheupload.h" >+#ifdef HAVE_CONFIG_H >+# include "config.h" >+#endif >+ >+#include "gyacheupload.h" > > /* ******************************* */ > /* PATCHES BELOW for webcams with OV519 sensors and >@@ -71,7 +75,7 @@ > /* Uncomment the line below to enable contributed but UNTESTED patch to support > cameras with OV519 chips - includes double-buffering support */ > >- /* #define USE_VIDEO_OV519 1 */ >+#define USE_MULTICAM_SUPPORT 1 > > > /* Uncomment the following definition to enable the use of the >@@ -81,10 +85,13 @@ > * modify the definitions of INCLUDE and gyach_LDADD in the Makefile > * to refer to the ccvt source and built libraries. > */ >-/* #define USE_CCVT 1 */ > >-#ifdef USE_CCVT >-#include "ccvt.h" >+/* NC: should be detected automatically from ./configure */ >+ >+/* #define HAVE_LIBCCVT 1 */ >+ >+#ifdef HAVE_LIBCCVT >+# include "ccvt.h" > #endif > > int exit_on_error=0; >@@ -95,7 +102,7 @@ > struct video_capability grab_cap; > struct video_mmap grab_buf; > >-#ifdef USE_VIDEO_OV519 >+#ifdef USE_MULTICAM_SUPPORT > static struct video_mbuf mbuf; > #endif > >@@ -105,19 +112,19 @@ > int pnm_size; > unsigned char *rgb_buf; > >+static char webcamrc_path[256]; > extern int app_debugger; > >-/* Hard-coding my own favorite cam settings into here... >- everybody else can update theirs from the config window */ >- > int fix_color=0; >+int skip_rgb24 = 0; > >- >-#ifdef USE_VIDEO_OV519 >+/* #ifdef USE_MULTICAM_SUPPORT > int hue=32767, contrast=32767, brightness=32767, colour=32767; >-#else >+#else */ > int hue=47104, contrast=65280, brightness=65280, colour=17152; >-#endif >+/* #endif */ >+ >+#define dir_exists(x) (access((x), R_OK) == 0) > > unsigned char* grab_one(int *, int *); > int grab_init(); >@@ -183,13 +190,7 @@ > return; > } > >- >-#ifdef USE_VIDEO_OV519 > current_pixbuf=gdk_pixbuf_new_from_data(grabit,GDK_COLORSPACE_RGB,FALSE,8,x,y,x*grab_pic.depth/8,NULL,NULL); >-#else >- current_pixbuf=gdk_pixbuf_new_from_data(grabit,GDK_COLORSPACE_RGB,FALSE,8,320,240,320*grab_pic.depth/8,NULL,NULL); >-#endif >- > > gtk_image_set_from_pixbuf(GTK_IMAGE(current_image), current_pixbuf); > gdk_pixbuf_unref(current_pixbuf); >@@ -242,22 +243,107 @@ > if (brightness > -1) grab_pic.brightness=brightness; > if (colour > -1) grab_pic.colour=colour; > >-#ifdef USE_VIDEO_OV519 >- /* hardcoded... */ >+ /* first we try RGB24 */ > grab_pic.depth = 24; > grab_pic.palette = VIDEO_PALETTE_RGB24; >-#endif >+ if (ioctl(grab_fd, VIDIOCSPICT, &grab_pic) < 0 || skip_rgb24) { >+ /* RGB24 not supported we try YUV420P */ >+ grab_pic.palette = VIDEO_PALETTE_YUV420P; >+ if (ioctl(grab_fd, VIDIOCSPICT, &grab_pic) < 0) { >+ /* try other palettes here... */ >+ } else return; >+ } else return; > >- if (ioctl(grab_fd, VIDIOCSPICT, &grab_pic) == -1) { > show_error_dialog("An error occurred at 'ioctl VIDIOCSPICT'.\nCould not set camera properties."); >- return; >- } > } > > void set_video_device(char *myvdev) { > v_device=strdup(myvdev); > } > >+/* read webcamrc configuration file */ >+void read_webcamrc () { >+ FILE *f; >+ char line[256]; >+ >+ snprintf(webcamrc_path, sizeof(webcamrc_path), >+ "%s/.yahoorc/gyach/webcamrc", getenv("HOME")); >+ >+ if ((f = fopen(webcamrc_path, "r")) == NULL) { >+ /* noconfig available */ >+ return; >+ } >+ while (fgets(line, sizeof(line), f)) { >+ char *p, *key, *value; >+ /* strip comments */ >+ if ((p = strchr(line, '#'))) *p = '\0'; >+ if ( (key = strtok(line, "=")) && (value = strtok(NULL, "\n"))) { >+ if (strcmp(key,"width")==0) >+ x = atoi(value); >+ >+ else if (strcmp(key,"height") == 0) >+ y = atoi(value); >+ >+ else if (strcmp(key, "fix_color") == 0) >+ fix_color = atoi(value); >+ >+ else if (strcmp(key, "hue") == 0) >+ hue = atoi(value); >+ >+ else if (strcmp(key, "contrast") == 0) >+ contrast = atoi(value); >+ >+ else if (strcmp(key, "brightness") == 0) >+ brightness = atoi(value); >+ >+ else if (strcmp(key, "colour") == 0) >+ colour = atoi(value); >+ >+ else if (strcmp(key, "skip_rgb24") == 0) >+ skip_rgb24 = atoi(value); >+ >+ } else { >+ fprintf(stderr, "Problems in %s\n", webcamrc_path); >+ } >+ } >+ fclose(f); >+} >+ >+void write_webcamrc() { >+ FILE *f; >+ >+ /* create ~/.yahoorc/gyach dir if it does not exist (it should) */ >+ snprintf(webcamrc_path, sizeof(webcamrc_path), "%s/.yahoorc", >+ getenv("HOME")); >+ if (!dir_exists(webcamrc_path)) >+ mkdir(webcamrc_path, 0700); >+ >+ snprintf(webcamrc_path, sizeof(webcamrc_path), "%s/.yahoorc/gyach", >+ getenv("HOME")); >+ if (!dir_exists(webcamrc_path)) >+ mkdir(webcamrc_path, 0700); >+ >+ snprintf(webcamrc_path, sizeof(webcamrc_path), >+ "%s/.yahoorc/gyach/webcamrc", getenv("HOME")); >+ >+ if ((f = fopen(webcamrc_path, "w")) == NULL) { >+ fprintf(stderr, "Problems when writing configuration to %s\n", >+ webcamrc_path); >+ return; >+ } >+ fprintf(f, "width=%i\n" >+ "height=%i\n" >+ "fix_color=%i\n" >+ "hue=%i\n" >+ "contrast=%i\n" >+ "brightness=%i\n" >+ "colour=%i\n" >+ "skip_rgb24=%i\n", >+ x, y, fix_color, hue, contrast, brightness, colour, skip_rgb24); >+ fclose(f); >+} >+ >+ > void init_cam () { > signal (SIGINT, _sighandler); > if (!v_device) { >@@ -268,12 +354,13 @@ > show_error_dialog("No Video4Linux device was specified."); > return; > } >+ read_webcamrc(); > grab_init(); > set_picture(); > } > > >-#ifdef USE_VIDEO_OV519 >+#ifdef USE_MULTICAM_SUPPORT > int grab_init() { > if ((grab_fd = open(v_device,O_RDWR)) == -1 ) { > show_error_dialog("Could not open Video4Linux device.\nThe device may already be in use."); >@@ -283,38 +370,25 @@ > show_error_dialog("An error occurred at 'ioctl VIDIOCGCAP'.\nWrong device."); > return 0; > } >+ if (!(grab_cap.type & VID_TYPE_CAPTURE)) { >+ show_error_dialog("Fatal: grab device does not handle capture\n"); >+ return 0; >+ } >+ > memset (&grab_pic, 0, sizeof(struct video_picture)); >- snprintf(webcam_description, 3, "%s", ""); >- strncpy(webcam_description, grab_cap.name ,28); >- strcat(webcam_description, " V4L1"); >+ memset(webcam_description, '\0', sizeof(webcam_description)); >+ snprintf(webcam_description, sizeof(webcam_description), "%s %s", >+ grab_cap.name, " V4L1"); >+ > if (ioctl (grab_fd, VIDIOCGPICT, &grab_pic) == -1) { > show_error_dialog("An error occurred at 'ioctl VIDIOCGPICT'."); > return 0; > } > >- >- /* The line below cannot work: we must force use of RGB24 for >- PNM image creation */ >- /* grab_buf.format=grab_pic.palette; */ >- >- /* A V4L device supporting the VIDEO_PALETTE_RGB24 >- ( 24bit RGB) color palette is REQUIRED, Gdk-Pixbuf >- can only handle RGB Color spaces, so no support for >- greyscale palettes or cams using non-standard, weirdo palettes >- at this time */ >- >- grab_buf.format = VIDEO_PALETTE_RGB24; >- grab_buf.frame = 0; >- grab_buf.width = x; >- grab_buf.height = y; >- grab_size = x * y * w; >- set_picture(); >- > if (ioctl (grab_fd, VIDIOCGMBUF, &mbuf) < 0) { > show_error_dialog("An error occurred at 'ioctl VIDIOCGMBUF'."); > return 0; > } >- printf("frames per capture: %i\n", mbuf.frames); > if ((grab_data = mmap(0, mbuf.size, PROT_READ|PROT_WRITE, MAP_SHARED, > grab_fd,0)) == MAP_FAILED) { > perror("mmap"); >@@ -322,13 +396,34 @@ > return 0; > } > >+ grab_buf.frame = 0; >+ grab_buf.width = x; >+ grab_buf.height = y; >+ grab_size = x * y * w; >+ set_picture(); >+ > /* grab first frame */ >+ grab_buf.format = VIDEO_PALETTE_RGB24; >+ if (ioctl(grab_fd,VIDIOCMCAPTURE,&grab_buf) <0 || skip_rgb24) { >+ /* some cam's don't support grabbing RBG24. try YUV420P */ >+ grab_buf.format = VIDEO_PALETTE_YUV420P; >+ if (-1 == ioctl(grab_fd,VIDIOCMCAPTURE,&grab_buf)) { >+#ifdef HAVE_LIBCCVT >+ /* try YUV422 before we give up if we have CCVT */ >+ /* grab_buf.format = VIDEO_PALETTE_YUV422; > if (-1 == ioctl(grab_fd,VIDIOCMCAPTURE,&grab_buf)) { > show_error_dialog("An error occurred at 'ioctl VIDIOCMCAPTURE'."); > return 0; > } >+ */ >+#else >+ show_error_dialog("An error occurred at 'ioctl VIDIOCMCAPTURE'."); >+ return 0; >+#endif >+ } >+ } > if (mbuf.frames > 1) grab_buf.frame = 1 - grab_buf.frame; >- >+ init_pnm_buf(); > return(1); > } > >@@ -384,9 +479,10 @@ > brightness=tbrightness; > fix_color=tfc; > set_picture(); >+ write_webcamrc(); > } > >-#ifndef USE_CCVT >+#ifndef HAVE_LIBCCVT > > /* The following conversion routines were taken from drivers/usb/ov511.c > * in the Mandrake Linux 2.4.21 kernel. >@@ -495,13 +591,14 @@ > } > } > >-#endif /* !USE_CCVT */ >+#endif /* !HAVE_LIBCCVT */ > > > >-#ifdef USE_VIDEO_OV519 >+#ifdef USE_MULTICAM_SUPPORT > > unsigned char* grab_one(int *width, int *height) { >+ char *frame_buf; > set_picture(); > > if (-1 == ioctl(grab_fd,VIDIOCMCAPTURE,&grab_buf)) { >@@ -509,15 +606,72 @@ > return NULL; > } > >+ /* switch frame if cam support double buf */ > if (mbuf.frames > 1) grab_buf.frame = 1 - grab_buf.frame; >+ // if (mbuf.frames > 1) grab_buf.frame = 1 - grab_buf.frame; > if (-1 == ioctl(grab_fd,VIDIOCSYNC,&grab_buf)) { > show_error_dialog("An error occurred at 'ioctl VIDIOCSYNC'."); > return NULL; > } >- if (fix_color) {fix_colour(grab_data + mbuf.offsets[grab_buf.frame], x, y); } >+ >+ frame_buf = grab_data + mbuf.offsets[grab_buf.frame]; > *width = grab_buf.width; > *height = grab_buf.height; >- return grab_data + mbuf.offsets[grab_buf.frame]; >+ >+#ifdef HAVE_LIBCCVT >+ switch (grab_buf.format) { >+ /* if we have ccvt we must check the yuyv converting also */ >+ >+ /* >+ case VIDEO_PALETTE_YUV422: { >+ if (fix_color) >+ ccvt_yuyv_bgr24(*width, *height, frame_buf, rgb_buf); >+ else >+ ccvt_yuyv_rgb24(*width, *height, frame_buf, rgb_buf); >+ break; >+ } >+ */ >+ case VIDEO_PALETTE_YUV420P: { >+ /* let ccvt do the bgr->rgb convertion */ >+ if (fix_color) >+ ccvt_420p_bgr24(*width, *height, frame_buf, rgb_buf); >+ else >+ ccvt_420p_rgb24(*width, *height, frame_buf, rgb_buf); >+ return rgb_buf; >+ } >+ >+ case VIDEO_PALETTE_RGB24: { >+ if (fix_color) fix_colour(frame_buf, x, y); >+ return frame_buf; >+ } >+ default: { >+ printf("oups...\n"); >+ return NULL; >+ } >+ } /* switch */ >+ >+#else /* HAVE_LIBCCVT */ >+ >+ switch (grab_buf.format) { >+ case VIDEO_PALETTE_YUV420P: { >+ yuv420p_to_rgb(frame_buf, rgb_buf, 24); >+ if (fix_color) fix_colour(rgb_buf, x, y); >+ break; >+ } >+ case VIDEO_PALETTE_RGB24: { >+ if (fix_color) fix_colour(frame_buf, x, y); >+ return frame_buf; >+ } >+ default: { >+ printf("oups...\n"); >+ return NULL; >+ } >+ >+ } /* switch */ >+ >+#endif /* HAVE_LIBCCVT */ >+ >+ return rgb_buf; > } > > #else >@@ -529,6 +683,7 @@ > set_picture(); > > for (;;) { >+ grab_buf.format = VIDEO_PALETTE_RGB24; > ret = ioctl(grab_fd,VIDIOCMCAPTURE,&grab_buf); > if (ret == -1) { > /* Some drivers (such as pwc) don't support capturing >@@ -553,7 +708,7 @@ > *height = grab_buf.height; > if (grab_buf.format == VIDEO_PALETTE_YUV420P) { > /* Convert from YUV420P to RGB24. */ >-#ifdef USE_CCVT >+#ifdef HAVE_LIBCCVT > ccvt_420p_rgb24(grab_buf.width, > grab_buf.height, > grab_data,
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 76127
:
51178
|
53246
|
53247
|
53248
|
53659
|
53660
|
54911
|
54914
|
55611
|
55612
|
55613
|
55628
|
55629
|
55630
|
55631
|
55698
|
55699
|
55700
|
55830
|
57052
|
57054
|
57684
|
60349
| 60350 |
60351
|
60353
|
62038