start of ivac (webcam tests)
[my-code/ivac.git] / ivac.c
1 /* internet audio/video conferencing
2  *
3  * author: hackbard
4  *
5  */
6
7 #include <stdio.h>
8 #include <string.h>
9 #include <unistd.h>
10 #include "ivac.h"
11 #include "dfbapi.h"
12
13 // in development
14
15 int usage(void) {
16         puts("usage: ivac <options>");
17         puts("options:");
18         puts("-h \t this help");
19         puts("-V \t <video device>"); 
20         puts("-A \t <audio device>");
21         puts("-v \t verbose debug output");
22         return 1;
23 }
24
25 int video_callback(void *ctx) {
26         struct ivac *ivac;
27         IDirectFBSurface *surf;
28         DFBSurfaceDescription desc;
29         
30         ivac=ctx;
31         puts("debug: callback!");
32         ivac->dfb_stuff.v_provider->GetSurfaceDescription(ivac->dfb_stuff.v_provider,&desc);
33         printf("debug: w: %d -- h: %d\n",desc.width,desc.height);
34         ivac->dfb_stuff.dfb->CreateSurface(ivac->dfb_stuff.dfb,&desc,&surf);
35         ivac->dfb_stuff.p_surface->Blit(ivac->dfb_stuff.p_surface,surf,NULL,0,0);
36         ivac->dfb_stuff.p_surface->Flip(ivac->dfb_stuff.p_surface,NULL,DSFLIP_WAITFORSYNC);
37         ivac->dfb_stuff.count+=1;
38         if(ivac->dfb_stuff.count==5000)
39                 ivac->dfb_stuff.v_provider->Stop(ivac->dfb_stuff.v_provider);
40         return DFENUM_OK;
41 }
42
43 int main(int argc, char **argv) {
44         int i;
45         struct ivac ivac;
46
47         /* default */
48         strcpy(ivac.video_dev,VIDEO_DEV);
49         strcpy(ivac.audio_dev,AUDIO_DEV);
50         
51         for(i=1;i<argc;i++) {
52                 if(argv[i][0]=='-') {
53                         switch(argv[i][1]) {
54                                 case 'h':
55                                         usage();
56                                         break;
57                                 case 'V':
58                                         strcpy(ivac.video_dev,argv[++i]);
59                                         break;
60                                 case 'A':
61                                         strcpy(ivac.audio_dev,argv[++i]);
62                                         break;
63                                 case 'v':
64                                         ivac.flags|=VERBOSE_FLAG;
65                                         break;
66                                 default:
67                                         usage();
68                                         break;
69                         }
70                 } else usage();
71         }
72         
73         if(dfb_init(argc,argv,&ivac)<0) {
74                 puts("dfb init failed");
75                 return -1;
76         }
77
78         puts("debug: dfb init done!!");
79
80         ivac.dfb_stuff.count=0;
81         ivac.dfb_stuff.rect.x=5;
82         ivac.dfb_stuff.rect.y=5;
83         ivac.dfb_stuff.rect.w=500;
84         ivac.dfb_stuff.rect.h=400;
85         ivac.dfb_stuff.v_provider->PlayTo(ivac.dfb_stuff.v_provider,ivac.dfb_stuff.p_surface,&(ivac.dfb_stuff.rect),video_callback,(void *)&ivac);
86
87         sleep(2);
88
89         dfb_tini(&ivac);
90         puts("debug: dfb tini done!!");
91
92         return 1;
93 }