int v4l_open(char *dev , v4l_device *vd) { if(!dev){ //dev = “/dev/video0”; return -2; } if((vd->fd=open(dev,O_RDWR))<0) { //(“v4l_open:”); return -1; } if(v4l_get_capability(vd))return -1; if(v4l_get_picture(vd))return -1;//这两个函数就是即将要完成的获取设备信息的函数 return 0; }
int v4l_open(char* dev, v4l_device* vd) { if(!dev) dev = DEFAULT_DEVICE; if((vd->fd = open(dev, O_RDWR)) < 0) { perror("v4l_open: "); return -1; } if(v4l_get_capability(vd)) return -1; if(v4l_get_picture(vd)) return -1; return 0; }
/* norm: VIDEO_MODE_PAL | VIDEO_MODE_NTSC | VIDEO_MODE_SECAM | VIDEO_MODE_AUTO (see videodev.h) */ int v4l_set_norm(v4l_device *vd, int norm) { int i; for (i = 0; i < vd->capability.channels; i++) { vd->channel[i].norm = norm; //vd->channel[i].type = VIDEO_TYPE_TV; //default (VIDEO_TYPE_TV | VIDEO_TYPE_CAMERA) } if (v4l_get_capability(vd)) { perror("v4l_set_norm"); return -1; } if (v4l_get_picture(vd)) { perror("v4l_set_norm"); } return 0; }