- 1、本文档共11页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 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
您可能关注的文档
- 仁爱版中考英语模拟4.docx
- Introduction of China’s Cosmopolitan Empire.doc
- 运动会管理系统实习报告.doc
- 无线电台语音互联关键技术研究.doc
- 原发性痛风 诊治指南(中华医学会).docx
- Synplify Pro软件的使用.docx
- 八大法语日常经典交流用语.doc
- 2012深圳中考英语试题及答案.doc
- 政府在中国跨国公司成长中的作用.doc
- 英美文化知识竞赛试题.doc
- 四川省德阳市罗江中学2025届高三考前热身化学试卷含解析.doc
- 山东省枣庄现代实验学校2025届高三下学期第五次调研考试化学试题含解析.doc
- 吉林省长春市十一高中等九校教育联盟2025届高三一诊考试生物试卷含解析.doc
- 2025届江苏省盐城市伍佑中学高考仿真模拟化学试卷含解析.doc
- 2025届广西贺州中学高考冲刺押题(最后一卷)生物试卷含解析.doc
- 安徽省池州市贵池区2025届高三第一次模拟考试生物试卷含解析.doc
- 宁夏银川一中2025届高三(最后冲刺)化学试卷含解析.doc
- 广东省广州市增城区四校联考2025届高考压轴卷化学试卷含解析.doc
- 2025届邯郸市第一中学高考生物必刷试卷含解析.doc
- 2025届安徽省安庆市石化第一中学高考仿真卷化学试卷含解析.doc
文档评论(0)