start of ivac (webcam tests)
authorhackbard <hackbard>
Tue, 26 Aug 2003 02:47:34 +0000 (02:47 +0000)
committerhackbard <hackbard>
Tue, 26 Aug 2003 02:47:34 +0000 (02:47 +0000)
Makefile_new [new file with mode: 0644]
dfbapi.c [new file with mode: 0644]
dfbapi.h [new file with mode: 0644]
dfbapi.o [new file with mode: 0644]
ivac.c
ivac.h [new file with mode: 0644]

diff --git a/Makefile_new b/Makefile_new
new file mode 100644 (file)
index 0000000..fb312e7
--- /dev/null
@@ -0,0 +1,17 @@
+INCLUDEDIR = /usr/include
+CFLAGS = -O3 -Wall -I/usr/include/directfb
+LIBS = -L/usr/lib -ldirectfb
+
+OBJS = dfbapi.o
+OBJS2 = new_ivac
+
+new_ivac: $(OBJS)
+       $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) ivac.c
+
+all: new_ivac
+
+clean:
+       rm $(OBJS) $(OBJS2)
+
+remake: clean all
+
diff --git a/dfbapi.c b/dfbapi.c
new file mode 100644 (file)
index 0000000..45960be
--- /dev/null
+++ b/dfbapi.c
@@ -0,0 +1,38 @@
+/* dfb functions
+ *
+ * author: hackbard@hackdaworld.dyndns.org
+ *
+ */
+
+#include <stdio.h>
+#include <directfb.h>
+#include "ivac.h"
+
+int dfb_init(int arg_c,char **arg_v,struct ivac *ivac) {
+       DFBSurfaceDescription surface_dsc;
+       DFBFontDescription font_dsc;
+       
+       DirectFBInit(&arg_c,&arg_v);
+       DirectFBCreate(&(ivac->dfb_stuff.dfb));
+       ivac->dfb_stuff.dfb->SetCooperativeLevel(ivac->dfb_stuff.dfb,DFSCL_FULLSCREEN);
+
+       surface_dsc.flags=DSDESC_CAPS;
+       surface_dsc.caps=DSCAPS_PRIMARY|DSCAPS_FLIPPING;
+       ivac->dfb_stuff.dfb->CreateSurface(ivac->dfb_stuff.dfb,&surface_dsc,&(ivac->dfb_stuff.p_surface));
+       ivac->dfb_stuff.p_surface->GetSize(ivac->dfb_stuff.p_surface,&(ivac->dfb_stuff.s_width),&(ivac->dfb_stuff.s_height));
+
+       font_dsc.flags=DFDESC_HEIGHT;
+       font_dsc.height=ivac->dfb_stuff.s_height/20;
+       ivac->dfb_stuff.dfb->CreateVideoProvider(ivac->dfb_stuff.dfb,ivac->video_dev,&(ivac->dfb_stuff.v_provider));
+
+       return 1;
+}
+
+int dfb_tini(struct ivac *ivac) {
+       ivac->dfb_stuff.v_provider->Release(ivac->dfb_stuff.v_provider);
+       ivac->dfb_stuff.p_surface->Release(ivac->dfb_stuff.p_surface);
+       ivac->dfb_stuff.dfb->Release(ivac->dfb_stuff.dfb);
+       
+       return 1;
+}
+
diff --git a/dfbapi.h b/dfbapi.h
new file mode 100644 (file)
index 0000000..e1f4a20
--- /dev/null
+++ b/dfbapi.h
@@ -0,0 +1,10 @@
+/* dfbapi.h
+ *
+ * author: hackbard@hackdaworld.dyndns.org
+ *
+ */
+
+/* function prototypes */
+int dfb_init(int arg_c,char **arg_v,struct ivac *ivac);
+int dfb_tini(struct ivac *ivac);
+
diff --git a/dfbapi.o b/dfbapi.o
new file mode 100644 (file)
index 0000000..c1ce110
Binary files /dev/null and b/dfbapi.o differ
diff --git a/ivac.c b/ivac.c
index 25822a8..d4e1581 100644 (file)
--- a/ivac.c
+++ b/ivac.c
@@ -5,6 +5,89 @@
  */
 
 #include <stdio.h>
-
+#include <string.h>
+#include <unistd.h>
+#include "ivac.h"
+#include "dfbapi.h"
 
 // in development
+
+int usage(void) {
+       puts("usage: ivac <options>");
+       puts("options:");
+       puts("-h \t this help");
+       puts("-V \t <video device>"); 
+       puts("-A \t <audio device>");
+       puts("-v \t verbose debug output");
+       return 1;
+}
+
+int video_callback(void *ctx) {
+       struct ivac *ivac;
+       IDirectFBSurface *surf;
+       DFBSurfaceDescription desc;
+       
+       ivac=ctx;
+       puts("debug: callback!");
+       ivac->dfb_stuff.v_provider->GetSurfaceDescription(ivac->dfb_stuff.v_provider,&desc);
+       printf("debug: w: %d -- h: %d\n",desc.width,desc.height);
+       ivac->dfb_stuff.dfb->CreateSurface(ivac->dfb_stuff.dfb,&desc,&surf);
+       ivac->dfb_stuff.p_surface->Blit(ivac->dfb_stuff.p_surface,surf,NULL,0,0);
+       ivac->dfb_stuff.p_surface->Flip(ivac->dfb_stuff.p_surface,NULL,DSFLIP_WAITFORSYNC);
+       ivac->dfb_stuff.count+=1;
+       if(ivac->dfb_stuff.count==5000)
+               ivac->dfb_stuff.v_provider->Stop(ivac->dfb_stuff.v_provider);
+       return DFENUM_OK;
+}
+
+int main(int argc, char **argv) {
+       int i;
+       struct ivac ivac;
+
+       /* default */
+       strcpy(ivac.video_dev,VIDEO_DEV);
+       strcpy(ivac.audio_dev,AUDIO_DEV);
+       
+       for(i=1;i<argc;i++) {
+               if(argv[i][0]=='-') {
+                       switch(argv[i][1]) {
+                               case 'h':
+                                       usage();
+                                       break;
+                               case 'V':
+                                       strcpy(ivac.video_dev,argv[++i]);
+                                       break;
+                               case 'A':
+                                       strcpy(ivac.audio_dev,argv[++i]);
+                                       break;
+                               case 'v':
+                                       ivac.flags|=VERBOSE_FLAG;
+                                       break;
+                               default:
+                                       usage();
+                                       break;
+                       }
+               } else usage();
+       }
+       
+       if(dfb_init(argc,argv,&ivac)<0) {
+               puts("dfb init failed");
+               return -1;
+       }
+
+       puts("debug: dfb init done!!");
+
+       ivac.dfb_stuff.count=0;
+       ivac.dfb_stuff.rect.x=5;
+       ivac.dfb_stuff.rect.y=5;
+       ivac.dfb_stuff.rect.w=500;
+       ivac.dfb_stuff.rect.h=400;
+       ivac.dfb_stuff.v_provider->PlayTo(ivac.dfb_stuff.v_provider,ivac.dfb_stuff.p_surface,&(ivac.dfb_stuff.rect),video_callback,(void *)&ivac);
+
+       sleep(2);
+
+       dfb_tini(&ivac);
+       puts("debug: dfb tini done!!");
+
+       return 1;
+}
diff --git a/ivac.h b/ivac.h
new file mode 100644 (file)
index 0000000..beb9b82
--- /dev/null
+++ b/ivac.h
@@ -0,0 +1,41 @@
+/* internet video/audio conferencing
+ *
+ * author: hackbard@hackdaworld.dyndns.org
+ *
+ */
+
+#ifndef IVAC_H
+#define IVAC_H
+
+#define MAX_CHAR_VIDEO_DEV 64
+#define MAX_CHAR_AUDIO_DEV 64
+
+#define VIDEO_DEV "/dev/v4l/video0"
+#define AUDIO_DEV "/dev/sound/dsp"
+
+#define VERBOSE_FLAG 1
+
+#include <directfb.h>
+
+struct dfb_stuff {
+       IDirectFB *dfb;
+       IDirectFBSurface *p_surface;
+       IDirectFBFont *font;
+       IDirectFBInputDevice *keyboard;
+       IDirectFBEventBuffer *k_buffer;
+       IDirectFBVideoProvider *v_provider;
+       IDirectFBImageProvider *i_provider;
+       int s_width,s_height;
+       DFBRectangle rect;
+       int count;
+};
+
+struct ivac {
+       struct dfb_stuff dfb_stuff;
+       char video_dev[MAX_CHAR_VIDEO_DEV];
+       char audio_dev[MAX_CHAR_AUDIO_DEV];
+       unsigned char flags;
+};
+
+
+#endif /* IVAC_H */