start of ivac (webcam tests)
[my-code/ivac.git] / ivac.c
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;
+}