#include <directfb.h>
#include "ivac.h"
+// do
+// int flip_blit_callback()
+// int dfb_play_video()
+// int dfb_stop_video()
+
int dfb_init(int arg_c,char **arg_v,struct ivac *ivac) {
- DFBSurfaceDescription surface_dsc;
- DFBFontDescription font_dsc;
-
+ DFBSurfaceDescription sdsc;
+ // DFBFontDescription fdsc;
+ DFBWindowDescription wdsc;
+
+ /* init */
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));
+ /* input devices and event stuff */
+ ivac->dfb_stuff.dfb->GetInputDevice(ivac->dfb_stuff.dfb,DIDID_MOUSE,&(ivac->dfb_stuff.mouse));
+ ivac->dfb_stuff.dfb->GetInputDevice(ivac->dfb_stuff.dfb,DIDID_KEYBOARD,&(ivac->dfb_stuff.keyboard));
+ ivac->dfb_stuff.mouse->CreateEventBuffer(ivac->dfb_stuff.mouse,&(ivac->dfb_stuff.buffer));
- font_dsc.flags=DFDESC_HEIGHT;
- font_dsc.height=ivac->dfb_stuff.s_height/20;
+ /* first window -- video window */
+ ivac->dfb_stuff.dfb->GetDisplayLayer(ivac->dfb_stuff.dfb,DLID_PRIMARY,&(ivac->dfb_stuff.layer));
ivac->dfb_stuff.dfb->CreateVideoProvider(ivac->dfb_stuff.dfb,ivac->video_dev,&(ivac->dfb_stuff.v_provider));
+ ivac->dfb_stuff.v_provider->GetSurfaceDescription(ivac->dfb_stuff.v_provider,&sdsc);
+
+ wdsc.flags=DWDESC_POSX|DWDESC_POSY|DWDESC_WIDTH|DWDESC_HEIGHT;
+ wdsc.posx=0;
+ wdsc.posy=0;
+ wdsc.width=sdsc.width;
+ wdsc.height=sdsc.height;
+
+ ivac->dfb_stuff.layer->CreateWindow(ivac->dfb_stuff.layer,&wdsc,&(ivac->dfb_stuff.v_window));
+ ivac->dfb_stuff.v_window->GetSurface(ivac->dfb_stuff.v_window,&(ivac->dfb_stuff.v_surface));
+ ivac->dfb_stuff.v_window->SetOpacity(ivac->dfb_stuff.v_window,0xff);
+ ivac->dfb_stuff.v_provider->PlayTo(ivac->dfb_stuff.v_provider,ivac->dfb_stuff.v_surface,NULL,NULL,NULL);
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.v_window->Release(ivac->dfb_stuff.v_window);
+ ivac->dfb_stuff.layer->Release(ivac->dfb_stuff.layer);
ivac->dfb_stuff.dfb->Release(ivac->dfb_stuff.dfb);
return 1;
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;
+ DFBInputDeviceKeyState quit;
+
+ quit=DIKS_UP;
/* default */
strcpy(ivac.video_dev,VIDEO_DEV);
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);
+ getchar();
dfb_tini(&ivac);
- puts("debug: dfb tini done!!");
return 1;
}
struct dfb_stuff {
IDirectFB *dfb;
- IDirectFBSurface *p_surface;
- IDirectFBFont *font;
- IDirectFBInputDevice *keyboard;
- IDirectFBEventBuffer *k_buffer;
- IDirectFBVideoProvider *v_provider;
+ IDirectFBDisplayLayer *layer;
IDirectFBImageProvider *i_provider;
- int s_width,s_height;
- DFBRectangle rect;
- int count;
+ IDirectFBVideoProvider *v_provider;
+ IDirectFBWindow *window,*v_window;;
+ IDirectFBSurface *v_surface,*i_surface,*surface;
+ IDirectFBFont *font;
+ IDirectFBInputDevice *keyboard,*mouse;
+ IDirectFBEventBuffer *buffer;
};
struct ivac {
char video_dev[MAX_CHAR_VIDEO_DEV];
char audio_dev[MAX_CHAR_AUDIO_DEV];
unsigned char flags;
+ int count;
};