linux下视频采集服务器(UDP传输、多线程模式).doc

linux下视频采集服务器(UDP传输、多线程模式).doc

  1. 1、本文档共11页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
linux下视频采集服务器(UDP传输、多线程模式)

linux下多线程网络编程,实现arm9视频采集和网络发送jpeg数据,使用udp协议,自己写的,搞了好几天!linux下的多线程比较复杂易出错。 linux network under the multi-threaded programming, video capture and realize ARM9 send jpeg data network, using udp protocol, wrote it myself, engaged in for several days! linux under the more complicated multi-threaded, error-prone. //多线程成功实例 ? #include?strings.h ? #include?stdio.h ? #include?unistd.h ? #include?stdlib.h ? #include?errno.h ? #include?stdarg.h ? #include?linux/types.h? ? #include?linux/videodev.h ? #include?pthread.h ? #include?semaphore.h ? #include?sys/types.h ? #include?sys/mman.h ? #include?sys/ioctl.h ? #include?sys/stat.h ? #include?sys/time.h ? #include?sys/file.h ? #include?sys/stat.h ? #include?fcntl.h ? #include?time.h ? #include?string.h? ? #include?netdb.h ? #include?arpa/inet.h ? #include?sys/times.h ? #include?netinet/in.h ? #include?sys/socket.h ? #include?sys/param.h ? #include?ctype.h ? #include?sys/utsname.h ? ? #define?BUFSIZE??6 ? #define?DATA?????32*1024 ? #define?PORT?????5000? ? #define?RTP_HDR_SZ?12? ? #define?VIDEO_PALETTE_JPEG?21? ? ?? ? unsigned?char?buf[BUFSIZE+2][DATA];? ? int?head,tail;? ? ? ? sem_t?writen;? ? sem_t?readn; ? ? struct?ARG{int?sockfd; ? ?int?sin_size; ? ?struct?sockaddr_in?client;? ? }; ? ? ? struct?FDG{? ? int?video_fd;? ? }; ? ? ? typedef?unsigned?char??u_int8;? ? typedef?unsigned?short?u_int16;? ? ? int?get_jpegsize?(unsigned?char?*buf,?int?insize); ? double?tdbl(struct?timeval?*a);? ? pthread_mutex_t??buffer_mutex=PTHREAD_MUTEX_INITIALIZER;? ? ? ? static?void?*producer(void?*fdg)? ? { ? ??struct?FDG?*vd;? ? ?int?video_fd; ? ? ? ??if(sizeof(fdg)!=sizeof(struct?FDG)) ? ??{ ? ????perror(producer?arg?error); ? ????exit(1); ? ???} ? ??else? ? ??{? ? ??vd=(struct?FDG?*)fdg;? ? ??video_fd=vd-video_fd;? ? ??free(fdg); ? ??fdg=NULL; ? ??} ? ? ??? ? ??for(?;?;?) ? ??{? ? ?????????sem_wait(writen);//减少可读的资源数? ? ?????????pthread_mutex_lock(buffer_mutex);//进入互斥区 ? ???????//?memset(buf[head],?s,?20);? ? ?????????read(video_fd,?buf[head],?DAT

文档评论(0)

xcs88858 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8130065136000003

1亿VIP精品文档

相关文档