SDL學習教程:http://lazyfoo.net/SDL_tutorials/index.php
代碼下載:http://download.csdn.net/download/jinchaoqi/6953321
代碼:
main.c
#include <stdio.h><stdlib.h><.h><sys/types.h><sys/stat.h><sys/ioctl.h><sys/time.h><unistd.h><fcntl.h><errno.h><sys/mman.h><linux/videodev2.h><linux/fb.h><pthread.h><libavcodec/avcodec.h><libavformat/avformat.h><libswscale/swscale.h><SDL/SDL.h><SDL/SDL_thread.h> PRINT printf("LINE: %d\n",__LINE__) main( argc, ** n = *p =* status =*bmp =*screen = SwsContext *sws_ctx =(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO |= SDL_SetVideoMode(WIDTH, HEIGHT, , = SDL_SetVideoMode(WIDTH, HEIGHT, , (!== (unsigned *) bmp->pixels[= = ==((i = ; i < ; i++ * HEIGHT* &(video_enqueue(i) < -&(
gather_picture.h:
GATHER_PICTURE_H VIDEO_DEV "/dev/video0" WIDTH 640 HEIGHT 480 frame_buf{ length[ * start[ video_getframe( video_enqueue(
gather_picture.c:
#include <stdio.h><stdlib.h><.h><sys/types.h><sys/stat.h><sys/ioctl.h><fcntl.h><errno.h><sys/mman.h><linux/videodev2.h> g_videofd = -; v4l2_buffer buf; video_enqueue(=(ioctl(g_videofd, VIDIOC_QBUF, &buf) < - v4l2_capability cap ; v4l2_fmtdesc stfmt; v4l2_format fmt; g_videofd =(g_videofd == - - (ioctl(g_videofd, VIDIOC_QUERYCAP, &cap) < - ((cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) == ((cap.capabilities & V4L2_CAP_STREAMING) == memset(&stfmt, , = =(ioctl(g_videofd, VIDIOC_ENUM_FMT, &stfmt) != -, stfmt.index++ memset(&fmt, ,=====&(fmt.fmt.pix.height != - v4l2_requestbuffers reqbuf; i = reqbuf.count = ; reqbuf.type ==(ioctl(g_videofd, VIDIOC_REQBUFS, &reqbuf)==- - (i = ; i < reqbuf.count; i++=== (ioctl (g_videofd, VIDIOC_QUERYBUF, &buf) == - -== mmap(NULL, buf.length, PROT_READ |(frame_buf.start[i] ==- v4l2_buf_type type =(ioctl(g_videofd, VIDIOC_STREAMON, &type) < - v4l2_buf_type type =(ioctl(g_videofd, VIDIOC_STREAMOFF, &type) < - video_getframe(=(ioctl(g_videofd, VIDIOC_DQBUF, &buf) < -