void V4RCamNode::processQueue() { if(!queueLoadConfiguration_.empty()) { load_controls(queueLoadConfiguration_); if(hasInfoMsg()) ROS_INFO_STREAM(pullInfoMsg()); if(hasErrorMsg()) ROS_ERROR_STREAM(pullErrorMsg()); writeV4lParams(); queueLoadConfiguration_ = std::string(); } else if(!queueSaveConfiguration_.empty()) { save_controls(queueSaveConfiguration_); if(hasInfoMsg()) ROS_INFO_STREAM(pullInfoMsg()); if(hasErrorMsg()) ROS_ERROR_STREAM(pullErrorMsg()); queueLoadConfiguration_ = std::string(); } }
int main (int argc, char **argv) { CHandle handle = 0; CResult res = C_SUCCESS; // Parse the command line if(cmdline_parser(argc, argv, &args_info) != 0) exit(1); // Display help if no arguments were specified if(argc == 1) { cmdline_parser_print_help(); exit(0); } res = c_init(); if(res) goto done; // Open the device if (!args_info.list_given && (!args_info.import_given || args_info.device_given)) { handle = c_open_device(args_info.device_arg); if(!handle) { print_error("Unable to open device", -1); res = C_INVALID_DEVICE; goto done; } } // List devices if(args_info.list_given) { res = list_devices(); goto done; } // Import dynamic controls from XML file else if(args_info.import_given) { res = add_control_mappings(handle, args_info.import_arg); goto done; } // Import dynamic controls from XML files at default location if(args_info.addctrl_given) { // list all xml files at default data/vid dir int nf=0; char vid[5]; char pid[5]; short pid_set = 0; if(fnmatch("[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]]", args_info.addctrl_arg, 0)) { if(fnmatch("[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]]", args_info.addctrl_arg, 0)) { printf("%s invalid: set at least a valid vid value, :pid is optional\n", args_info.addctrl_arg); goto done; } else { /*extract vid and reset pid*/ int c = 0; for (c = 0; c < 4; c++) { vid[c] = args_info.addctrl_arg[c]; pid[c] = 0; } vid[4] = '\0'; pid[4] = '\0'; } } else { /*extract vid and pid*/ int c = 0; for (c = 0; c < 4; c++) { vid[c] = args_info.addctrl_arg[c]; pid[c] = args_info.addctrl_arg[c+5]; } vid[4] = '\0'; pid[4] = '\0'; pid_set = 1; /*flag pid.xml check*/ //printf("vid:%s pid:%s\n", vid, pid); } /* get xml file list from DATA_DIR/vid/ */ char **xml_files = get_filename (DATA_DIR, vid); /*check for pid.xml*/ char fname[9]; strcpy(fname, pid); strcat(fname,".xml"); if(pid_set) { pid_set = 0; /*reset*/ nf=0; while (xml_files[nf] != NULL) { if ( strcasecmp(fname, xml_files[nf]) == 0) pid_set = 1; /*file exists so flag it*/ nf++; } } /*parse xml files*/ nf = 0; while (xml_files[nf] != NULL) { /* if pid was set and pid.xml exists parse it*/ if(pid_set) { if ((strcasecmp(fname, xml_files[nf]) == 0)) { printf ( "Parsing: %s \n", xml_files[nf]); res = add_control_mappings(handle, xml_files[nf]); } } else /* parse all xml files inside vid dir */ { printf ( "Parsing: %s \n", xml_files[nf]); res = add_control_mappings(handle, xml_files[nf]); } free(xml_files[nf]); xml_files[nf]=NULL; nf++; } free(xml_files); goto done; } // List frame formats if(args_info.formats_given) { printf("Listing available frame formats for device %s:\n", args_info.device_arg); res = list_frame_formats(handle); } // List controls else if(args_info.clist_given) { printf("Listing available controls for device %s:\n", args_info.device_arg); res = list_controls(handle); } // Retrieve control value else if(args_info.get_given) { CControlValue value; // Resolve the control Id CControlId controlId = get_control_id(handle, args_info.get_arg); if(!controlId) { res = 1; print_handle_error(handle, "Unknown control specified", -1); goto done; } // Retrieve the control value res = c_get_control(handle, controlId, &value); if(res) { print_handle_error(handle, "Unable to retrieve control value", res); goto done; } printf("%d\n", value.value); } // Retrieve raw control value else if(args_info.get_raw_given) { //scan input uint16_t unit_id; unsigned char selector; sscanf(args_info.get_raw_arg, "%hu:%hhu", &unit_id, &selector); CControlValue value; value.type = CC_TYPE_RAW; // the entity is only used for the generating a control name //TODO: pass the guid through cmdline (optional) unsigned char entity[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; res = c_read_xu_control(handle, entity, unit_id, selector, &value); if(res) { print_handle_error(handle, "Unable to retrieve control value", res); goto done; } //print the raw value uint8_t * val = value.raw.data; int i=0; printf("query current value of: (LE)0x"); for(i=0; i<value.raw.size; i++) { printf("%.2x", val[i]); } printf(" (BE)0x"); for(i=value.raw.size-1; i >=0; i--) { printf("%.2x", val[i]); } printf("\n"); //free the raw value alocation if(value.raw.data) free(value.raw.data); } else if(args_info.set_given) { CControlValue value; // Parse the control value if(args_info.inputs_num < 1) { res = 3; print_error("No control value specified", -1); goto done; } if(parse_control_value(args_info.inputs[0], &value)) { res = 2; print_error("Invalid control value specified", -1); goto done; } // Resolve the control Id CControlId controlId = get_control_id(handle, args_info.set_arg); if(!controlId) { res = 1; print_handle_error(handle, "Unknown control specified", -1); goto done; } // Set the new control value res = c_set_control(handle, controlId, &value); if(res) { print_handle_error(handle, "Unable to set new control value", res); goto done; } } // Set the raw control value else if(args_info.set_raw_given) { CControlValue value; // Parse the control value if(args_info.inputs_num < 1) { res = 3; print_error("No raw control value specified", -1); goto done; } uint16_t unit_id; unsigned char selector; sscanf(args_info.set_raw_arg, "%hu:%hhu", &unit_id, &selector); parse_raw_control_value (args_info.inputs[0], &value); // the entity is only used for the generating a control name //TODO: pass the guid through cmdline (optional) unsigned char entity[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; res = c_write_xu_control(handle, entity, unit_id, selector, &value); if(res) { print_handle_error(handle, "Unable to set the control value", res); goto done; } //print the raw value le and be format uint8_t * val = value.raw.data; int i=0; printf("set value of : (LE)0x"); for(i=0; i<value.raw.size; i++) { printf("%.2x", val[i]); } printf(" (BE)0x"); for(i=value.raw.size-1; i >=0; i--) { printf("%.2x", val[i]); } printf("\n"); //free the raw value alocation if(value.raw.data) free(value.raw.data); } else if(args_info.save_ctrl_given) { res = save_controls( handle, args_info.save_ctrl_arg); } else if(args_info.load_ctrl_given) { res = load_controls( handle, args_info.load_ctrl_arg); } // Clean up done: if(handle) c_close_device(handle); c_cleanup(); cmdline_parser_free(&args_info); return res; }
static int eventThread(void *data) { struct pt_data *gdata = (struct pt_data *) data; struct v4l2_control control; SDL_Surface *pscreen = *gdata->ptscreen; struct vdIn *videoIn = gdata->ptvideoIn; SDL_Event *sdlevent = gdata->ptsdlevent; SDL_Rect *drect = gdata->drect; SDL_mutex *affmutex = gdata->affmutex; unsigned char frmrate; int x, y; int mouseon = 0; int value = 0; int len = 0; short incpantilt = INCPANTILT; int boucle = 0; action_gui curr_action = A_VIDEO; while (videoIn->signalquit) { SDL_LockMutex(affmutex); frmrate = gdata->frmrate; while (SDL_PollEvent(sdlevent)) { //scan the event queue switch (sdlevent->type) { case SDL_KEYUP: case SDL_MOUSEBUTTONUP: mouseon = 0; incpantilt = INCPANTILT; boucle = 0; break; case SDL_MOUSEBUTTONDOWN: mouseon = 1; case SDL_MOUSEMOTION: SDL_GetMouseState(&x, &y); curr_action = GUI_whichbutton(x, y, pscreen, videoIn); break; case SDL_VIDEORESIZE: pscreen = SDL_SetVideoMode(sdlevent->resize.w, sdlevent->resize.h, 0, SDL_VIDEO_Flags); drect->w = sdlevent->resize.w; drect->h = sdlevent->resize.h; break; case SDL_KEYDOWN: curr_action = GUI_keytoaction(sdlevent->key.keysym.sym); if (curr_action != A_VIDEO) mouseon = 1; break; case SDL_QUIT: printf("\nStop asked\n"); videoIn->signalquit = 0; break; } } //end if poll SDL_UnlockMutex(affmutex); /* traiter les actions */ value = 0; if (mouseon){ boucle++; switch (curr_action) { case A_BRIGHTNESS_UP: if ((value = v4l2UpControl(videoIn, V4L2_CID_BRIGHTNESS)) < 0) printf("Set Brightness up error\n"); break; case A_CONTRAST_UP: if ((value = v4l2UpControl(videoIn, V4L2_CID_CONTRAST)) < 0) printf("Set Contrast up error \n"); break; case A_SATURATION_UP: if ((value = v4l2UpControl(videoIn, V4L2_CID_SATURATION)) < 0) printf("Set Saturation up error\n"); break; case A_GAIN_UP: if ((value = v4l2UpControl(videoIn, V4L2_CID_GAIN)) < 0) printf("Set Gain up error\n"); break; case A_SHARPNESS_UP: if ((value = v4l2UpControl(videoIn, V4L2_CID_SHARPNESS)) < 0) printf("Set Sharpness up error\n"); break; case A_GAMMA_UP: if ((value = v4l2UpControl(videoIn, V4L2_CID_GAMMA)) < 0) printf("Set Gamma up error\n"); break; case A_PAN_UP: if ((value =v4L2UpDownPan(videoIn, -incpantilt)) < 0) printf("Set Pan up error\n"); break; case A_TILT_UP: if ((value =v4L2UpDownTilt(videoIn, -incpantilt)) < 0) printf("Set Tilt up error\n"); break; case A_PAN_RESET: if (v4l2ResetPanTilt(videoIn,1) < 0) printf("reset pantilt error\n"); break; case A_SCREENSHOT: SDL_Delay(200); videoIn->getPict = 1; value = 1; break; case A_RESET: if (v4l2ResetControl(videoIn, V4L2_CID_BRIGHTNESS) < 0) printf("reset Brightness error\n"); if (v4l2ResetControl(videoIn, V4L2_CID_SATURATION) < 0) printf("reset Saturation error\n"); if (v4l2ResetControl(videoIn, V4L2_CID_CONTRAST) < 0) printf("reset Contrast error\n"); if (v4l2ResetControl(videoIn, V4L2_CID_HUE) < 0) printf("reset Hue error\n"); if (v4l2ResetControl(videoIn, V4L2_CID_SHARPNESS) < 0) printf("reset Sharpness error\n"); if (v4l2ResetControl(videoIn, V4L2_CID_GAMMA) < 0) printf("reset Gamma error\n"); if (v4l2ResetControl(videoIn, V4L2_CID_GAIN) < 0) printf("reset Gain error\n"); if (v4l2ResetPanTilt(videoIn,3) < 0) printf("reset pantilt error\n"); break; case A_BRIGHTNESS_DOWN: if ((value = v4l2DownControl(videoIn, V4L2_CID_BRIGHTNESS)) < 0) printf("Set Brightness down error\n"); break; case A_CONTRAST_DOWN: if ((value = v4l2DownControl(videoIn, V4L2_CID_CONTRAST)) < 0) printf("Set Contrast down error\n"); break; case A_SATURATION_DOWN: if ((value = v4l2DownControl(videoIn, V4L2_CID_SATURATION)) < 0) printf("Set Saturation down error\n"); break; case A_GAIN_DOWN: if ((value = v4l2DownControl(videoIn, V4L2_CID_GAIN)) < 0) printf("Set Gain down error\n"); break; case A_SHARPNESS_DOWN: if ((value = v4l2DownControl(videoIn, V4L2_CID_SHARPNESS)) < 0) printf("Set Sharpness down error\n"); break; case A_GAMMA_DOWN: if ((value = v4l2DownControl(videoIn, V4L2_CID_GAMMA)) < 0) printf("Set Gamma down error\n"); break; case A_PAN_DOWN: if ((value =v4L2UpDownPan(videoIn, incpantilt)) < 0) printf("Set Pan down error\n"); break; case A_TILT_DOWN: if ((value =v4L2UpDownTilt(videoIn,incpantilt)) < 0) printf("Set Tilt down error\n"); break; case A_TILT_RESET: if (v4l2ResetPanTilt(videoIn,2) < 0) printf("reset pantilt error\n"); break; case A_RECORD_TOGGLE: SDL_Delay(200); videoIn->toggleAvi = !videoIn->toggleAvi; value = videoIn->toggleAvi; if ( value == 1 ) { printf("avi recording started\n"); videoIn->recordstart=SDL_GetTicks(); } else { int dur=SDL_GetTicks()-videoIn->recordstart; printf("\navi recording stopped (%ds)\n",dur/1000); videoIn->recordtime+=dur; } break; case A_SWITCH_LIGHTFREQFILT: if ((value =v4l2GetControl(videoIn,V4L2_CID_POWER_LINE_FREQUENCY)) < 0) printf("Get value of light frequency filter error\n"); if(value < 2) // round switch 50->60->NoFliker->. value++; // \_______________; else value=0; if(value == 0) printf("Current light frequency filter: 50Hz\n"); else if(value == 1) printf("Current light frequency filter: 60Hz\n"); else if(value == 2) printf("Current light frequency filter: NoFliker\n"); if ((value =v4l2SetLightFrequencyFilter(videoIn,value)) < 0) printf("Switch light frequency filter error\n"); break; case A_QUIT: videoIn->signalquit = 0; break; case A_VIDEO: break; case A_CAPTURE_FRAME: value = 1; videoIn->rawFrameCapture = 1; break; case A_CAPTURE_FRAMESTREAM: value = 1; if (!videoIn->rawFrameCapture) { videoIn->rawFrameCapture = 2; videoIn->rfsBytesWritten = 0; videoIn->rfsFramesWritten = 0; printf("Starting raw frame stream capturing ...\n"); } else if(videoIn->framesWritten >= 5) { videoIn->rawFrameCapture = 0; printf("Stopped raw frame stream capturing. %u bytes written for %u frames.\n", videoIn->rfsBytesWritten, videoIn->rfsFramesWritten); } break; case A_CAPTURE_STREAM: value = 1; if (videoIn->captureFile == NULL) { videoIn->captureFile = fopen("stream.raw", "wb"); if(videoIn->captureFile == NULL) { perror("Unable to open file for raw stream capturing"); } else { printf("Starting raw stream capturing to stream.raw ...\n"); } videoIn->bytesWritten = 0; videoIn->framesWritten = 0; } else if(videoIn->framesWritten >= 5) { fclose(videoIn->captureFile); printf("Stopped raw stream capturing to stream.raw. %u bytes written for %u frames.\n", videoIn->bytesWritten, videoIn->framesWritten); videoIn->captureFile = NULL; } break; case A_EXPOSURE_UP: if ((value = v4l2UpControl(videoIn, V4L2_CID_EXPOSURE_ABSOLUTE)) < 0) printf("Set Absolute Exposure up error\n"); break; case A_EXPOSURE_DOWN: if ((value = v4l2DownControl(videoIn, V4L2_CID_EXPOSURE_ABSOLUTE)) < 0) printf("Set Absolute Exposure down error\n"); break; case A_EXPOSURE_ON: control.id =V4L2_CID_EXPOSURE_AUTO; control.value =1; if ((value = ioctl(videoIn->fd, VIDIOC_S_CTRL, &control)) < 0) printf("Set Auto Exposure on error\n"); else printf("Auto Exposure set to %d \n", control.value); break; case A_EXPOSURE_OFF: control.id =V4L2_CID_EXPOSURE_AUTO; control.value =8; if ((value = ioctl(videoIn->fd, VIDIOC_S_CTRL, &control)) < 0) printf("Set Auto Exposure off error\n"); else printf("Auto Exposure set to %d \n", control.value); break; case A_BALANCE_UP: if ((value = v4l2UpControl(videoIn, V4L2_CID_WHITE_BALANCE_TEMPERATURE)) < 0) printf("Set Balance Temperature up error\n"); break; case A_BALANCE_DOWN: if ((value = v4l2DownControl(videoIn, V4L2_CID_WHITE_BALANCE_TEMPERATURE)) < 0) printf("Set Balance Temperature down error\n"); break; case A_BALANCE_ON: control.id =V4L2_CID_WHITE_BALANCE_TEMPERATURE_AUTO; control.value =1; if ((value = ioctl(videoIn->fd, VIDIOC_S_CTRL, &control)) < 0) printf("Set Auto Balance on error\n"); else printf("Auto Balance set to %d \n", control.value); break; case A_BALANCE_OFF: control.id =V4L2_CID_WHITE_BALANCE_TEMPERATURE_AUTO; control.value =0; if ((value = ioctl(videoIn->fd, VIDIOC_S_CTRL, &control)) < 0) printf("Set Auto Balance off error\n"); else printf("Auto Balance set to %d \n", control.value); break; case A_SAVE: printf("Save controls \n"); save_controls(videoIn->fd); break; case A_LOAD: printf("load controls \n"); load_controls(videoIn->fd); break; default: break; } if(!(boucle%10)) // smooth pan tilt method if(incpantilt < (10*INCPANTILT)) incpantilt += (INCPANTILT/4); if(value){ len = strlen(title_act[curr_action].title)+8; snprintf(videoIn->status, len,"%s %06d",title_act[curr_action].title,value); } } else { // mouseon len = strlen(title_act[curr_action].title)+9; snprintf(videoIn->status, len,"%s, %02d Fps",title_act[curr_action].title, frmrate); } SDL_Delay(50); //printf("fp/s %d \n",frmrate); } //end main loop /* Close the stream capture file */ if (videoIn->captureFile) { fclose(videoIn->captureFile); printf("Stopped raw stream capturing to stream.raw. %u bytes written for %u frames.\n", videoIn->bytesWritten, videoIn->framesWritten); } /* Display stats for raw frame stream capturing */ if (videoIn->rawFrameCapture == 2) { printf("Stopped raw frame stream capturing. %u bytes written for %u frames.\n", videoIn->rfsBytesWritten, videoIn->rfsFramesWritten); } }
int main(int argc, char *argv[]) { #ifndef EMBEDED_X210 //PC platform const SDL_VideoInfo *info; char driver[128]; SDL_Surface *pscreen; SDL_Overlay *overlay; SDL_Rect drect; SDL_Event sdlevent; SDL_Thread *mythread; SDL_mutex *affmutex; Uint32 currtime; Uint32 lasttime; #endif int status; unsigned char *p = NULL; int hwaccel = 0; const char *videodevice = NULL; const char *mode = NULL; int format = V4L2_PIX_FMT_MJPEG; int i; int grabmethod = 1; int width = 320; int height = 240; int fps = 15; unsigned char frmrate = 0; char *avifilename = NULL; int queryformats = 0; int querycontrols = 0; int readconfigfile = 0; char *separateur; char *sizestring = NULL; char *fpsstring = NULL; int enableRawStreamCapture = 0; int enableRawFrameCapture = 0; char * pRGBData=NULL; printf("luvcview version %s \n", version); for (i = 1; i < argc; i++) { /* skip bad arguments */ if (argv[i] == NULL || *argv[i] == 0 || *argv[i] != '-') { continue; } if (strcmp(argv[i], "-d") == 0) { if (i + 1 >= argc) { printf("No parameter specified with -d, aborting.\n"); exit(1); } videodevice = strdup(argv[i + 1]); } if (strcmp(argv[i], "-g") == 0) { /* Ask for read instead default mmap */ grabmethod = 0; } if (strcmp(argv[i], "-w") == 0) { /* disable hw acceleration */ hwaccel = 1; } if (strcmp(argv[i], "-f") == 0) { if (i + 1 >= argc) { printf("No parameter specified with -f, aborting.\n"); exit(1); } mode = strdup(argv[i + 1]); if (strncmp(mode, "yuv", 3) == 0) { format = V4L2_PIX_FMT_YUYV; } else if (strncmp(mode, "jpg", 3) == 0) { format = V4L2_PIX_FMT_MJPEG; } else { format = V4L2_PIX_FMT_MJPEG; } } if (strcmp(argv[i], "-s") == 0) { if (i + 1 >= argc) { printf("No parameter specified with -s, aborting.\n"); exit(1); } sizestring = strdup(argv[i + 1]); width = strtoul(sizestring, &separateur, 10); if (*separateur != 'x') { printf("Error in size use -s widthxheight \n"); exit(1); } else { ++separateur; height = strtoul(separateur, &separateur, 10); if (*separateur != 0) printf("hmm.. dont like that!! trying this height \n"); printf(" size width: %d height: %d \n", width, height); } } if (strcmp(argv[i], "-i") == 0){ if (i + 1 >= argc) { printf("No parameter specified with -i, aborting. \n"); exit(1); } fpsstring = strdup(argv[i + 1]); fps = strtoul(fpsstring, &separateur, 10); printf(" interval: %d fps \n", fps); } if (strcmp(argv[i], "-S") == 0) { /* Enable raw stream capture from the start */ enableRawStreamCapture = 1; } if (strcmp(argv[i], "-c") == 0) { /* Enable raw frame capture for the first frame */ enableRawFrameCapture = 1; } if (strcmp(argv[i], "-C") == 0) { /* Enable raw frame stream capture from the start*/ enableRawFrameCapture = 2; } if (strcmp(argv[i], "-o") == 0) { /* set the avi filename */ if (i + 1 >= argc) { printf("No parameter specified with -o, aborting.\n"); exit(1); } avifilename = strdup(argv[i + 1]); } if (strcmp(argv[i], "-L") == 0) { /* query list of valid video formats */ queryformats = 1; } if (strcmp(argv[i], "-l") == 0) { /* query list of valid video formats */ querycontrols = 1; } if (strcmp(argv[i], "-r") == 0) { /* query list of valid video formats */ readconfigfile = 1; } if (strcmp(argv[i], "-h") == 0) { printf("usage: uvcview [-h -d -g -f -s -i -c -o -C -S -L -l -r] \n"); printf("-h print this message \n"); printf("-d /dev/videoX use videoX device\n"); printf("-g use read method for grab instead mmap \n"); printf("-w disable SDL hardware accel. \n"); printf("-f video format default jpg others options are yuv jpg \n"); printf("-i fps use specified frame interval \n"); printf("-s widthxheight use specified input size \n"); printf("-c enable raw frame capturing for the first frame\n"); printf("-C enable raw frame stream capturing from the start\n"); printf("-S enable raw stream capturing from the start\n"); printf("-o avifile create avifile, default video.avi\n"); printf("-L query valid video formats\n"); printf("-l query valid controls and settings\n"); printf("-r read and set control settings from luvcview.cfg\n"); exit(0); } } #ifndef EMBEDED_X210 //PC platform /************* Test SDL capabilities ************/ if (SDL_Init(SDL_INIT_VIDEO) < 0) { fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); exit(1); } /* For this version, we'll be save and disable hardware acceleration */ if(hwaccel) { if ( ! getenv("SDL_VIDEO_YUV_HWACCEL") ) { putenv("SDL_VIDEO_YUV_HWACCEL=0"); } } if (SDL_VideoDriverName(driver, sizeof(driver))) { printf("Video driver: %s\n", driver); } info = SDL_GetVideoInfo(); if (info->wm_available) { printf("A window manager is available\n"); } if (info->hw_available) { printf("Hardware surfaces are available (%dK video memory)\n", info->video_mem); SDL_VIDEO_Flags |= SDL_HWSURFACE; } if (info->blit_hw) { printf("Copy blits between hardware surfaces are accelerated\n"); SDL_VIDEO_Flags |= SDL_ASYNCBLIT; } if (info->blit_hw_CC) { printf ("Colorkey blits between hardware surfaces are accelerated\n"); } if (info->blit_hw_A) { printf("Alpha blits between hardware surfaces are accelerated\n"); } if (info->blit_sw) { printf ("Copy blits from software surfaces to hardware surfaces are accelerated\n"); } if (info->blit_sw_CC) { printf ("Colorkey blits from software surfaces to hardware surfaces are accelerated\n"); } if (info->blit_sw_A) { printf ("Alpha blits from software surfaces to hardware surfaces are accelerated\n"); } if (info->blit_fill) { printf("Color fills on hardware surfaces are accelerated\n"); } if (!(SDL_VIDEO_Flags & SDL_HWSURFACE)) SDL_VIDEO_Flags |= SDL_SWSURFACE; #endif if (videodevice == NULL || *videodevice == 0) { videodevice = "/dev/video0"; } if (avifilename == NULL || *avifilename == 0) { avifilename = "video.avi"; } videoIn = (struct vdIn *) calloc(1, sizeof(struct vdIn)); if ( queryformats ) { /* if we're supposed to list the video formats, do that now and go out */ check_videoIn(videoIn,(char *) videodevice); free(videoIn); #ifndef EMBEDED_X210 SDL_Quit(); #endif exit(1); } if (init_videoIn(videoIn, (char *) videodevice, width, height, fps, format, grabmethod, avifilename) < 0) exit(1); /* if we're supposed to list the controls, do that now */ if ( querycontrols ) enum_controls(videoIn->fd); /* if we're supposed to read the control settings from a configfile, do that now */ if ( readconfigfile ) load_controls(videoIn->fd); #ifdef EMBEDED_X210 #ifdef SOFT_COLOR_CONVERT init_framebuffer(); #else x6410_init_Draw(videoIn->width,videoIn->height); #endif #else pscreen = SDL_SetVideoMode(videoIn->width, videoIn->height+30 , 0,SDL_VIDEO_Flags); overlay =SDL_CreateYUVOverlay(videoIn->width, videoIn->height+30 , SDL_YUY2_OVERLAY, pscreen); p = (unsigned char *) overlay->pixels[0]; drect.x = 0; drect.y = 0; drect.w =pscreen->w; drect.h = pscreen->h; #endif if (enableRawStreamCapture) { videoIn->captureFile = fopen("stream.raw", "wb"); if(videoIn->captureFile == NULL) { perror("Unable to open file for raw stream capturing"); } else { printf("Starting raw stream capturing to stream.raw ...\n"); } } if (enableRawFrameCapture) videoIn->rawFrameCapture = enableRawFrameCapture; initLut(); #ifndef EMBEDED_X210 SDL_WM_SetCaption(title_act[A_VIDEO].title, NULL); lasttime = SDL_GetTicks(); creatButt(videoIn->width, 32); SDL_LockYUVOverlay(overlay); memcpy(p + (videoIn->width * (videoIn->height) * 2), YUYVbutt, videoIn->width * 64); SDL_UnlockYUVOverlay(overlay); /* initialize thread data */ ptdata.ptscreen = &pscreen; ptdata.ptvideoIn = videoIn; ptdata.ptsdlevent = &sdlevent; ptdata.drect = &drect; affmutex = SDL_CreateMutex(); ptdata.affmutex = affmutex; mythread = SDL_CreateThread(eventThread, (void *) &ptdata); #endif pRGBData = (unsigned char *)malloc(videoIn->width*videoIn->width*4*sizeof(char)); if(pRGBData==NULL) { return ; } /* main big loop */ while (videoIn->signalquit) { #ifndef EMBEDED_X210 currtime = SDL_GetTicks(); if (currtime - lasttime > 0) { frmrate = 1000/(currtime - lasttime); } lasttime = currtime; #endif if (uvcGrab(videoIn) < 0) { printf("Error grabbing \n"); break; } /* if we're grabbing video, show the frame rate */ if (videoIn->toggleAvi) printf("\rframe rate: %d ",frmrate); #ifndef EMBEDED_X210 SDL_LockYUVOverlay(overlay); memcpy(p, videoIn->framebuffer, videoIn->width * (videoIn->height) * 2); SDL_UnlockYUVOverlay(overlay); SDL_DisplayYUVOverlay(overlay, &drect); #endif #ifdef EMBEDED_X210 #ifdef SOFT_COLOR_CONVERT // yuv to rgb565 ,and to frambuffer process_image(videoIn->framebuffer,fbp,videoIn->width,videoIn->height,vinfo,finfo); // convertYUYVtoRGB565(videoIn->framebuffer,pRGBData,videoIn->width,videoIn->height); // Pyuv422torgb24(videoIn->framebuffer, pRGBData, videoIn->width, videoIn->height); // memcpy(fbp,pRGBData,videoIn->width*videoIn->height*2); #else //X6410 post processor convert yuv to rgb,X210 not suport now. /* memcpy(pInbuffer, videoIn->framebuffer, videoIn->width * (videoIn->height) * 2); ioctl(dev_fb0, GET_FB_INFO, &fb_info); pp_param.SrcFrmSt = ioctl(dev_pp, S3C_PP_GET_RESERVED_MEM_ADDR_PHY); //must be physical adress pp_param.DstFrmSt = fb_info.map_dma_f1; //must be physical adress ioctl(dev_pp, S3C_PP_SET_PARAMS, &pp_param); ioctl(dev_pp, S3C_PP_SET_DST_BUF_ADDR_PHY, &pp_param); ioctl(dev_pp, S3C_PP_SET_SRC_BUF_ADDR_PHY, &pp_param); ioctl(dev_pp, S3C_PP_START); */ #endif #endif if (videoIn->getPict) { switch(videoIn->formatIn){ case V4L2_PIX_FMT_MJPEG: get_picture(videoIn->tmpbuffer,videoIn->buf.bytesused); break; case V4L2_PIX_FMT_YUYV: get_pictureYV2(videoIn->framebuffer,videoIn->width,videoIn->height); break; default: break; } videoIn->getPict = 0; printf("get picture !\n"); } #ifndef EMBEDED_X210 SDL_LockMutex(affmutex); ptdata.frmrate = frmrate; SDL_WM_SetCaption(videoIn->status, NULL); SDL_UnlockMutex(affmutex); #endif #ifdef EMBEDED_X210 usleep(10); #else SDL_Delay(10); #endif } #ifndef EMBEDED_X210 SDL_WaitThread(mythread, &status); SDL_DestroyMutex(affmutex); #endif /* if avifile is defined, we made a video: compute the exact fps and set it in the video */ if (videoIn->avifile != NULL) { float fps=(videoIn->framecount/(videoIn->recordtime/1000)); fprintf(stderr,"setting fps to %f\n",fps); AVI_set_video(videoIn->avifile, videoIn->width, videoIn->height, fps, "MJPG"); AVI_close(videoIn->avifile); } close_v4l2(videoIn); #ifdef EMBEDED_X210 #ifdef SOFT_COLOR_CONVERT close_frambuffer(); #else x6410_DeInit_Draw(); #endif #endif free(pRGBData); free(videoIn); destroyButt(); freeLut(); printf(" Clean Up done Quit \n"); #ifndef EMBEDED_X210 SDL_Quit(); #endif }
int main(int argc, char *argv[]) { char driver[128]; int status; //Uint32 currtime; //Uint32 lasttime; unsigned char *p = NULL; int hwaccel = 0; const char *videodevice = NULL; const char *mode = NULL; int format = V4L2_PIX_FMT_MJPEG; int i; int grabmethod = 1; int width = 320; int height = 240; int fps = 15; unsigned char frmrate = 0; char *avifilename = NULL; int queryformats = 0; int querycontrols = 0; int readconfigfile = 0; char *separateur; char *sizestring = NULL; char *fpsstring = NULL; int enableRawStreamCapture = 0; int enableRawFrameCapture = 0; printf("luvcview version %s \n", version); for (i = 1; i < argc; i++) { /* skip bad arguments */ if (argv[i] == NULL || *argv[i] == 0 || *argv[i] != '-') { continue; } if (strcmp(argv[i], "-d") == 0) { if (i + 1 >= argc) { printf("No parameter specified with -d, aborting.\n"); exit(1); } videodevice = strdup(argv[i + 1]); } if (strcmp(argv[i], "-g") == 0) { /* Ask for read instead default mmap */ grabmethod = 0; } if (strcmp(argv[i], "-w") == 0) { /* disable hw acceleration */ hwaccel = 1; } if (strcmp(argv[i], "-f") == 0) { if (i + 1 >= argc) { printf("No parameter specified with -f, aborting.\n"); exit(1); } mode = strdup(argv[i + 1]); if (strncmp(mode, "yuv", 3) == 0) { format = V4L2_PIX_FMT_YUYV; } else if (strncmp(mode, "jpg", 3) == 0) { format = V4L2_PIX_FMT_MJPEG; } else { format = V4L2_PIX_FMT_JPEG; } } if (strcmp(argv[i], "-s") == 0) { if (i + 1 >= argc) { printf("No parameter specified with -s, aborting.\n"); exit(1); } sizestring = strdup(argv[i + 1]); width = strtoul(sizestring, &separateur, 10); if (*separateur != 'x') { printf("Error in size use -s widthxheight \n"); exit(1); } else { ++separateur; height = strtoul(separateur, &separateur, 10); if (*separateur != 0) printf("hmm.. dont like that!! trying this height \n"); printf(" size width: %d height: %d \n", width, height); } } if (strcmp(argv[i], "-i") == 0) { if (i + 1 >= argc) { printf("No parameter specified with -i, aborting. \n"); exit(1); } fpsstring = strdup(argv[i + 1]); fps = strtoul(fpsstring, &separateur, 10); printf(" interval: %d fps \n", fps); } if (strcmp(argv[i], "-S") == 0) { /* Enable raw stream capture from the start */ enableRawStreamCapture = 1; } if (strcmp(argv[i], "-c") == 0) { /* Enable raw frame capture for the first frame */ enableRawFrameCapture = 1; } if (strcmp(argv[i], "-C") == 0) { /* Enable raw frame stream capture from the start*/ enableRawFrameCapture = 2; } if (strcmp(argv[i], "-o") == 0) { /* set the avi filename */ if (i + 1 >= argc) { printf("No parameter specified with -o, aborting.\n"); exit(1); } avifilename = strdup(argv[i + 1]); } if (strcmp(argv[i], "-L") == 0) { /* query list of valid video formats */ queryformats = 1; } if (strcmp(argv[i], "-l") == 0) { /* query list of valid video formats */ querycontrols = 1; } if (strcmp(argv[i], "-r") == 0) { /* query list of valid video formats */ readconfigfile = 1; } if (strcmp(argv[i], "-O") == 0) { /* get picture */ getpictureflag = 1; } if (strcmp(argv[i], "-h") == 0) { printf( "usage: uvcview [-h -d -g -f -s -i -c -o -C -S -L -l -r] \n"); printf("-h print this message \n"); printf("-d /dev/videoX use videoX device\n"); printf("-g use read method for grab instead mmap \n"); printf("-w disable SDL hardware accel. \n"); printf( "-f video format default jpg others options are yuv jpg \n"); printf("-i fps use specified frame interval \n"); printf("-s widthxheight use specified input size \n"); printf("-c enable raw frame capturing for the first frame\n"); printf("-C enable raw frame stream capturing from the start\n"); printf("-S enable raw stream capturing from the start\n"); printf("-o avifile create avifile, default video.avi\n"); printf("-L query valid video formats\n"); printf("-l query valid controls and settings\n"); printf("-r read and set control settings from luvcview.cfg\n"); printf("-O get picture.\n"); exit(0); } } if (videodevice == NULL || *videodevice == 0) { videodevice = "/dev/video0"; } if (avifilename == NULL || *avifilename == 0) { avifilename = "video.avi"; } videoIn = (struct vdIn *) calloc(1, sizeof(struct vdIn)); if (queryformats) { /* if we're supposed to list the video formats, do that now and go out */ check_videoIn(videoIn, (char *) videodevice); free(videoIn); exit(1); } if (init_videoIn(videoIn, (char *) videodevice, width, height, fps, format, grabmethod, avifilename) < 0) exit(1); /* if we're supposed to list the controls, do that now */ if (querycontrols) enum_controls(videoIn->fd); /* if we're supposed to read the control settings from a configfile, do that now */ if (readconfigfile) load_controls(videoIn->fd); printf("Enable Raw Stream Capture\n"); if (enableRawStreamCapture) { videoIn->captureFile = fopen("stream.raw", "wb"); if (videoIn->captureFile == NULL) { perror("Unable to open file for raw stream capturing"); } else { printf("Starting raw stream capturing to stream.raw ...\n"); } } if (enableRawFrameCapture) videoIn->rawFrameCapture = enableRawFrameCapture; initLut(); printf("Begin main big loop\n"); int loopNum = 0; /* main big loop */ while (videoIn->signalquit) { // if (uvcGrab(videoIn) < 0) { printf("Error grabbing \n"); break; } // /* if we're grabbing video, show the frame rate */ if (videoIn->toggleAvi) printf("\rframe rate: %d ", frmrate); // if (getpictureflag) { //if (videoIn->getPict) { switch (videoIn->formatIn) { case V4L2_PIX_FMT_MJPEG: get_picture(videoIn->tmpbuffer, videoIn->buf.bytesused); break; case V4L2_PIX_FMT_YUYV: printf("get picture yuv...\n"); get_pictureYV2(videoIn->framebuffer, videoIn->width, videoIn->height); break; default: break; } videoIn->getPict = 0; printf("get picture !\n"); } printf("loop number %d\n",loopNum); loopNum ++; } /* if avifile is defined, we made a video: compute the exact fps and set it in the video */ if (videoIn->avifile != NULL) { float fps = (videoIn->framecount / (videoIn->recordtime / 1000)); fprintf(stderr, "setting fps to %f\n", fps); AVI_set_video(videoIn->avifile, videoIn->width, videoIn->height, fps, "MJPG"); AVI_close(videoIn->avifile); } close_v4l2(videoIn); free(videoIn); freeLut(); printf(" Clean Up done Quit \n"); }
int main(int argc, char **argv) { if (!XInitThreads()) { printf("Xlib not thread safe\n"); exit(1); } //const SDL_VideoInfo *info; char driver[128]; SDL_Surface *pscreen; //SDL_Overlay *overlay; //SDL_Rect drect, dclip; SDL_Event sdlevent; SDL_Thread *mythread; SDL_mutex *affmutex; int status; Uint32 currtime; Uint32 lasttime; unsigned char *p = NULL; int hwaccel = 0; const char *videodevice = NULL; const char *mode = NULL; int format = V4L2_PIX_FMT_MJPEG; //int sdl_format = SDL_YUY2_OVERLAY; int i; int grabmethod = 1; int width = 640; int height = 480; float fps = 30.0; // Requested frame rate float frmrate = 0.0; // Measured frame rate char *avifilename = NULL; int queryformats = 0; int querycontrols = 0; int readconfigfile = 0; char *separateur; char *sizestring = NULL; char *fpsstring = NULL; int enableRawStreamCapture = 0; int enableRawFrameCapture = 0; printf("luvcview %s\n\n", version); for (i = 1; i < argc; i++) { /* skip bad arguments */ if (argv[i] == NULL || *argv[i] == 0 || *argv[i] != '-') { continue; } if (strcmp(argv[i], "-d") == 0) { if (i + 1 >= argc) { printf("No parameter specified with -d, aborting.\n"); exit(1); } videodevice = strdup(argv[i + 1]); } if (strcmp(argv[i], "-g") == 0) { /* Ask for read instead default mmap */ grabmethod = 0; } if (strcmp(argv[i], "-w") == 0) { /* disable hw acceleration */ hwaccel = 1; } if (strcmp(argv[i], "-f") == 0) { if (i + 1 >= argc) { printf("No parameter specified with -f, aborting.\n"); exit(1); } mode = argv[i + 1]; if (strcasecmp(mode, "yuv") == 0 || strcasecmp(mode, "YUYV") == 0) { format = V4L2_PIX_FMT_YUYV; } else if (strcasecmp(mode, "uyvy") == 0 || strcasecmp(mode, "UYVY") == 0) { format = V4L2_PIX_FMT_UYVY; //sdl_format = SDL_UYVY_OVERLAY; } else if (strcasecmp(mode, "jpg") == 0 || strcasecmp(mode, "MJPG") == 0) { format = V4L2_PIX_FMT_MJPEG; } else { printf("Unknown format specified. Aborting.\n"); exit(1); } } if (strcmp(argv[i], "-s") == 0) { if (i + 1 >= argc) { printf("No parameter specified with -s, aborting.\n"); exit(1); } sizestring = strdup(argv[i + 1]); width = strtoul(sizestring, &separateur, 10); if (*separateur != 'x') { printf("Error in size use -s widthxheight\n"); exit(1); } else { ++separateur; height = strtoul(separateur, &separateur, 10); if (*separateur != 0) printf("hmm.. dont like that!! trying this height\n"); } } if (strcmp(argv[i], "-i") == 0) { if (i + 1 >= argc) { printf("No parameter specified with -i, aborting.\n"); exit(1); } fpsstring = argv[i + 1]; fps = strtof(fpsstring, &separateur); if(*separateur != '\0') { printf("Invalid frame rate '%s' specified with -i. " "Only numbers are supported. Aborting.\n", fpsstring); exit(1); } } if (strcmp(argv[i], "-S") == 0) { /* Enable raw stream capture from the start */ enableRawStreamCapture = 1; } if (strcmp(argv[i], "-c") == 0) { /* Enable raw frame capture for the first frame */ enableRawFrameCapture = 1; } if (strcmp(argv[i], "-C") == 0) { /* Enable raw frame stream capture from the start*/ enableRawFrameCapture = 2; } if (strcmp(argv[i], "-o") == 0) { /* set the avi filename */ if (i + 1 >= argc) { printf("No parameter specified with -o, aborting.\n"); exit(1); } avifilename = strdup(argv[i + 1]); } if (strcmp(argv[i], "-L") == 0) { /* query list of valid video formats */ queryformats = 1; } if (strcmp(argv[i], "-l") == 0) { /* query list of valid video formats */ querycontrols = 1; } if (strcmp(argv[i], "-r") == 0) { /* query list of valid video formats */ readconfigfile = 1; } if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { printf("usage: uvcview [-h -d -g -f -s -i -c -o -C -S -L -l -r]\n"); printf("-h print this message\n"); printf("-d /dev/videoX use videoX device\n"); printf("-g use read method for grab instead mmap\n"); printf("-w disable SDL hardware accel.\n"); printf("-f choose video format (YUYV/yuv, UYVY/uyvy and MJPG/jpg are valid, MJPG is default)\n"); printf("-i fps use specified frame rate\n"); printf("-s widthxheight use specified input size\n"); printf("-c enable raw frame capturing for the first frame\n"); printf("-C enable raw frame stream capturing from the start\n"); printf("-S enable raw stream capturing from the start\n"); printf("-o avifile create avifile, default video.avi\n"); printf("-L query valid video formats\n"); printf("-l query valid controls and settings\n"); printf("-r read and set control settings from luvcview.cfg (save/restore with F1/F2)\n"); exit(0); } } /************* Test SDL capabilities ************/ if (SDL_Init(SDL_INIT_VIDEO) < 0) { fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); exit(1); } /* For this version, we'll be save and disable hardware acceleration */ if(hwaccel) if ( ! getenv("SDL_VIDEO_YUV_HWACCEL") ) { putenv("SDL_VIDEO_YUV_HWACCEL=0"); } /* printf("SDL information:\n"); if (SDL_VideoDriverName(driver, sizeof(driver))) { printf(" Video driver: %s\n", driver); } /* info = SDL_GetVideoInfo(); if (info->wm_available) { printf(" A window manager is available\n"); } if (info->hw_available) { printf(" Hardware surfaces are available (%dk video memory)\n", info->video_mem); SDL_VIDEO_Flags |= SDL_HWSURFACE; } if (info->blit_hw) { printf(" Copy blits between hardware surfaces are accelerated\n"); SDL_VIDEO_Flags |= SDL_ASYNCBLIT; } if (info->blit_hw_CC) { printf (" Colorkey blits between hardware surfaces are accelerated\n"); } if (info->blit_hw_A) { printf(" Alpha blits between hardware surfaces are accelerated\n"); } if (info->blit_sw) { printf (" Copy blits from software surfaces to hardware surfaces are accelerated\n"); } if (info->blit_sw_CC) { printf (" Colorkey blits from software surfaces to hardware surfaces are accelerated\n"); } if (info->blit_sw_A) { printf (" Alpha blits from software surfaces to hardware surfaces are accelerated\n"); } if (info->blit_fill) { printf(" Color fills on hardware surfaces are accelerated\n"); } if (!(SDL_VIDEO_Flags & SDL_HWSURFACE)) SDL_VIDEO_Flags |= SDL_SWSURFACE; */ if (videodevice == NULL || *videodevice == 0) { videodevice = "/dev/video0"; } if (avifilename == NULL || *avifilename == 0) { avifilename = "video.avi"; } char* adev[2] = { "/dev/video0", "/dev/video1" }; //tCam* gM.apCam[2]; gM.aCam[0].Image_W = width; gM.aCam[0].Image_H = height; gM.Cam_N = 2; for (int i = 0; i < gM.Cam_N; ++i) { //gM.apCam[i] = malloc(sizeof *gM.apCam[i]); memset(&gM.aCam[i], 0, sizeof gM.aCam[i]); tCam* pcam = &gM.aCam[i]; pcam->Idx = i; pcam->Image_W = width; pcam->Image_H = height; pcam->UVC = (struct vdIn *) calloc(1, sizeof(struct vdIn)); if ( queryformats ) { /* if we're supposed to list the video formats, do that now and go out */ check_videoIn(pcam->UVC, adev[i]); free(pcam->UVC); SDL_Quit(); exit(1); } if (init_videoIn (pcam->UVC, adev[i], width, height, fps, format, grabmethod, avifilename) < 0) exit(1); /* if we're supposed to list the controls, do that now */ if ( querycontrols ) enum_controls(pcam->UVC->fd); /* if we're supposed to read the control settings from a configfile, do that now */ if ( readconfigfile ) load_controls(pcam->UVC->fd); pcam->SDL_Win = SDL_CreateWindow(title_act[A_VIDEO].title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, pcam->UVC->width/2, pcam->UVC->height/2, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL ); if (!pcam->SDL_Win) abort(); pcam->SDL_Surf = SDL_GetWindowSurface(pcam->SDL_Win); if (!pcam->SDL_Surf) abort(); } pcam = &gM.aCam[0]; //gM.pScreen = pscreen = gM.aCam[0]->SDL_Surf; //gM.pOverlay = overlay = SDL_CreateYUVOverlay(videoIn->width, videoIn->height, sdl_format, pscreen); //p = (unsigned char *) overlay->pixels[0]; /* if (enableRawStreamCapture) { videoIn->captureFile = fopen("stream.raw", "wb"); if(videoIn->captureFile == NULL) { perror("Unable to open file for raw stream capturing"); } else { printf("Starting raw stream capturing to stream.raw ...\n"); } } if (enableRawFrameCapture) videoIn->rawFrameCapture = enableRawFrameCapture;*/ initLut(); //SDL_WM_SetCaption(title_act[A_VIDEO].title, NULL); lasttime = SDL_GetTicks(); // creatButt(videoIn->width, 32); // SDL_LockYUVOverlay(overlay); // memcpy(p + (videoIn->width * (videoIn->height) * 2), YUYVbutt, videoIn->width * 64); // SDL_UnlockYUVOverlay(overlay); /* initialize thread data */ //ptdata.ptscreen = &pscreen; //ptdata.ptvideoIn = videoIn; ptdata.ptsdlevent = &sdlevent; //ptdata.drect = &drect; affmutex = SDL_CreateMutex(); ptdata.affmutex = affmutex; // mythread = SDL_CreateThread(eventThread, (void *) &ptdata); muhaha_Init (); gM.pDst = p; muhaha_Loop (); muhaha_DeInit (); SDL_WaitThread(mythread, &status); SDL_DestroyMutex(affmutex); /* if avifile is defined, we made a video: compute the exact fps and set it in the video */ //close_v4l2(videoIn); //free(videoIn); destroyButt(); freeLut(); printf("Cleanup done. Exiting ...\n"); SDL_Quit(); }
void interface_start (UserInterface * ui, gchar * uri) { ClutterColor stage_color = { 0x00, 0x00, 0x00, 0x00 }; g_print ("Loading ui!\n"); // Init UserInterface structure variables ui->fileuri = uri; ui->filename = g_path_get_basename (ui->fileuri); ui->media_width = ui->engine->media_width; ui->media_height = ui->engine->media_height; ui->stage_width = ui->engine->media_width; ui->stage_height = ui->engine->media_height; ui->stage = clutter_stage_get_default (); ui->controls_showing = FALSE; ui->keep_showing_controls = FALSE; ui->penalty_box_active = FALSE; ui->controls_timeout = -1; ui->seek_width = ui->stage_width / SEEK_WIDTH_RATIO; ui->seek_height = ui->stage_height / SEEK_HEIGHT_RATIO; ui->progress_id = -1; ui->title_length = TITLE_LENGTH; ui->duration_str = position_ns_to_str (ui->engine->media_duration); ui->rotated = FALSE; clutter_stage_set_color (CLUTTER_STAGE (ui->stage), &stage_color); clutter_stage_set_minimum_size (CLUTTER_STAGE (ui->stage), ui->stage_width, ui->stage_height); clutter_stage_set_title (CLUTTER_STAGE (ui->stage), ui->filename); clutter_actor_set_size (CLUTTER_ACTOR (ui->stage), ui->stage_width, ui->stage_height); if (ui->fullscreen) { clutter_stage_set_fullscreen (CLUTTER_STAGE (ui->stage), TRUE); } // Controls load_controls (ui); // Add video texture and control UI to stage clutter_container_add (CLUTTER_CONTAINER (ui->stage), ui->texture, ui->control_box, NULL); clutter_stage_hide_cursor (CLUTTER_STAGE (ui->stage)); clutter_actor_animate (ui->control_box, CLUTTER_EASE_OUT_QUINT, SECOND, "opacity", 0, NULL); g_signal_connect (CLUTTER_STAGE (ui->stage), "fullscreen", G_CALLBACK (size_change), ui); g_signal_connect (CLUTTER_STAGE (ui->stage), "unfullscreen", G_CALLBACK (size_change), ui); g_signal_connect (ui->stage, "event", G_CALLBACK (event_cb), ui); clutter_actor_set_anchor_point_from_gravity (CLUTTER_ACTOR (ui->texture), CLUTTER_GRAVITY_CENTER); clutter_actor_set_position (CLUTTER_ACTOR (ui->texture), ui->stage_width / 2, ui->stage_height / 2); center_controls (ui); progress_timing (ui); ui->screensaver = screensaver_new (CLUTTER_STAGE (ui->stage)); screensaver_enable (ui->screensaver, FALSE); g_timeout_add (SECOND, progress_update_text, ui); clutter_actor_show (ui->stage); }