資源簡介
linux 2.6.28---UBUNTU9.04
V4L2及uvcvideo驅動采集
采用libjrtp-2.9 實現RTP傳輸

代碼片段和文件信息
#include?
#include?
#include?“rtpsession.h“
#include?“rtppacket.h“
//?錯誤處理函數
void?checkerror(int?err)
{
??if?(err?0)?{
????char*?errstr?=?RTPGetErrorString(err);
????printf(“Error:%s\\n“?errstr);
????exit(-1);
??}
}
int?main(int?argc?char**?argv)
{
??RTPSession?sess;
??int?localport;
??int?status;
??int?timestamplengh?=?1025length?=?0;
??char?buffer[32768];
??unsigned?char?*RawData;
??
??if?(argc?!=?2)?{
????printf(“Usage:?./recieve?localport\\n“);
????return?-1;
??}
???//?獲得用戶指定的端口號
??localport?=?atoi(argv[1]);
??//?創建RTP會話
??status?=?sess.Create(localport);
??checkerror(status);
??FILE?*file?=?0;?
??int?i?=?0;
??int?j?=?1;
????????
??do?{
????//?接受RTP數據
????status?=?sess.PollData();
? //?檢索RTP數據源
????if?(sess.GotoFirstSourceWithData())
????{
??????do?{
????????RTPPacket*?packet;
????????//?獲取RTP數據報
????????
????????while?((packet?=?sess.GetNextPacket())?!=?NULL)?{
????????
??????????? printf(“Got?packet?%d!?of?pic?%d!\n“ij);
??? ??? timestamp?=?packet->GetTimeStamp();
??????????? lengh=packet->GetPayloadLength();
??????????? length?+=?lengh;
??????????? RawData=packet->GetPayload();???//得到實際有效數據
??????????? printf(“?timestamp:%d;lengh=%d\n“timestamplengh);
??????????? memcpy(&buffer[1024*i]RawDatalengh);?
??????????? i?++;??? ?
????????????delete?packet;
?????????? //?刪除RTP數據報
????????}
??????}?while?(sess.GotoNextSourceWithData());
????}????
????if(lengh?1024)
????{
????????if((file?=?fopen(“rtp_rev.jpg“?“wb“))?0)
???? {
??????????? printf(“Unable?to?create?y?frame?recording?file\n“);
????????????return?-1;
???? }
???? else
???? {
???? fwrite(buffer?length?1?file);
???? printf(“buffer?write?%d?bytes?into?file.\n“length);
???? fclose(file);
???? i?=?0;//write?over?so?reset?i
???? j?++?;//write?pic?and?j++
???? lengh?=?1025;
???? }
????}??
??}?while(1);
??return?0;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????55477??2010-05-31?14:28??v4l2_jpeg_rtp\jpegrtp_recieve
?????文件???????7553??2010-05-31?14:50??v4l2_jpeg_rtp\jpegvideo
?????文件??????60218??2010-05-31?14:44??v4l2_jpeg_rtp\v4l2_sendrtp
?????文件??????36864??2010-05-31?14:50??v4l2_jpeg_rtp\rtp_rev.jpg
?????文件??????????0??2010-05-31?14:50??v4l2_jpeg_rtp\1.jpg
?????文件??????12300??2010-05-31?13:44??v4l2_jpeg_rtp\jpegsdl
?????文件???????3456??2010-05-31?14:36??v4l2_jpeg_rtp\jpegvideo.c
?????文件??????60213??2010-05-31?14:14??v4l2_jpeg_rtp\v4l2sdl
?????文件??????11309??2010-05-31?14:46??v4l2_jpeg_rtp\v4l2_sendrtp.c
?????文件????????294??2010-05-31?13:48??v4l2_jpeg_rtp\Makefile
?????文件???????1951??2010-05-31?14:28??v4l2_jpeg_rtp\jpegrtp_recieve.c
?????目錄??????????0??2010-05-31?14:50??v4l2_jpeg_rtp
-----------?---------??----------?-----??----
???????????????249635????????????????????12
評論
共有 條評論