exit(1);
}
sleep(1);
printf("Initializing SDL.\n");
/* Initialize defaults, Video and Audio */
if((SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO| SDL_INIT_TIMER)==-1)) {
printf("Could not initialize SDL: %s.\n", SDL_GetError());
exit(-1);
}
atexit (SDL_Quit);
printf("SDL initialized.\n");
screen = SDL_SetVideoMode (WIDTH, HEIGHT, 0, SDL_HWSURFACE
| SDL_DOUBLEBUF
| SDL_ANYFORMAT
| SDL_RESIZABLE);
if (screen == NULL)
{
fprintf(stderr, "SDL_SetVideoMode ==>> %s\n", SDL_GetError());
goto fatal;
}
if (0 == (screen->flags & SDL_HWSURFACE))
{
fprintf(stderr,"Can't get hardware surface\n");
}
SDL_WM_SetCaption ("USB Camera By Breeze", NULL);
overlay = SDL_CreateYUVOverlay(XDIM, YDIM, SDL_YV12_OVERLAY, screen);
if (!overlay)
{
fprintf(stderr, "Couldn't create overlay: %s\n", SDL_GetError());
exit(4);
}
printf("SDL_CreateYUVOverlay info: %dx%dx%d %s %s overlay\n",overlay->w,overlay->h,overlay->planes,
overlay->hw_overlay?"hardware":"software",
overlay->format==SDL_YV12_OVERLAY?"YV12":
overlay->format==SDL_IYUV_OVERLAY?"IYUV":
overlay->format==SDL_YUY2_OVERLAY?"YUY2":
overlay->format==SDL_UYVY_OVERLAY?"UYVY":
overlay->format==SDL_YVYU_OVERLAY?"YVYU":
"Unknown");
rect.x=0;
rect.y=0;
rect.w=SHXDIM;
rect.h=SHYDIM;
do{
while (SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_VIDEORESIZE:
{
screen=SDL_SetVideoMode(event.resize.w, event.resize.h, 0, SDL_RESIZABLE | SDL_SWSURFACE);
rect.w=event.resize.w;
rect.h=event.resize.h;
if (paused)
{
resized=1;
}
}break;
case SDL_QUIT:
{
aEncoder.finish_coder();
fclose(ftrRawDta);
goto release_all;
}break;
}//! end switch
}//! end while (SDL_PollEvent(&event))
show_rtp_pict();
SDL_Delay(10);//! delay 1 ms
//!printf("Wvent Poll.\n");
}while(1);
//cin >>cmd;
printf("Quiting SDL.\n");
release_all:
printf("Quiting....\n");
exit(0);
fatal:
printf("fatal!!,exit\n");
return -1;;
}