1. ioctl(fd,VIDIOCGCAP,&cap); 该命令主要是为了获取电视卡的功能信息。例如电视卡的名称,类型,channel等。参数cap是一个结构,当ioctl命令返回时,结构的各成员就被赋值了,结构体的定义为: struct video_capability { char name[32]; int type; int channels; /* Num channels */ int audios; /* Num audio devices */ int maxwidth; /* Supported width */ int maxheight; /* And height */ int minwidth; /* Supported width */ int minheight; /* And height */ }; channel 指的是有几个信号输入源,例如television,composite,s-video等。
2.ioctl(fd,VIDIOCGCHAN,&vc) 3.ioctl(fd,VIDIOCSCHAN.&vc) 这两个命令用来取得和设置电视卡的channel信息,例如使用那个输入源,制式等。 vc 是一个video_channel结构,其定义为: struct video_capability { char name[32]; int type; int channels; /* Num channels */ int audios; /* Num audio devices */ int maxwidth; /* Supported width */ int maxheight; /* And height */ int minwidth; /* Supported width */ int minheight; /* And height */ }; struct video_channel { int channel; char name[32]; int tuners; //number of tuners for this input __u32 flags; __u16 type; __u16 norm; }; 成员channel代表输入源,通常,
0: television 1:composite1 2:s-video name 表示该输入源的名称。 norm 表示制式,通常,
0:pal 1:ntsc 2:secam 3:auto
4. ioctl(fd,VIDIOCGMBUF,*mbuf) 获得电视卡缓存的信息,参数mbuf是video_mbuf结构。其定义如下: struct video_mbuf { int size; /* Total memory to map */ int frames; /* Frames */ int offsets[VIDEO_MAX_FRAME]; }; size是缓存的大小,frames表明该电视卡的缓存可以容纳的帧数,数组offsets则表明 对应一帧的起始位置,0帧对应offsets[0],1帧对应offsets[1].... 执行完该命令后,就可以用mmap函数将缓存映射到内存中了。大致用法可以参考以下的代 码 struct video_mbuf mbuf; unsigned char *buf1,*buf2;