dows 下資料
http://www.cnblogs.com/skyseraph/archive/2012/04/07/2435540.html
一,安裝Cmake
二,在 jrtplib-3.9.1_1 中運行 cmake . 生成Makefile
三,而後 make
接着 make install
頭文件被安裝在 /usr/local/include/jrtplib3/ 因此編譯程序時候須要添加 -I /usr/local/include/jrtplib3/
庫文件被安裝在 /usr/local/lib/libjrtp.a 因此編譯程序時候須要添加 -ljrtp
四,編譯 example1
g++ -o test example1.cpp -ljrtp -I /usr/local/include/jrtplib3/
報錯:./test: error while loading shared libraries: libjrtp.so.3.9.1: cannot open shared object file: No such file or directory
分析:已經將 jrtp 安裝完畢,爲何找不到動態庫呢?
解決:將 usr/local/lib/libjrtp.so.3.9.1 拷貝到 usr/lib 下面就能夠執行了
五,調試
報錯:The specified port base is not an even numberhtml
分析:jrtp 不支持奇數端口ios
附:session
發送端代碼:send.cpp函數
- /*
- Here's a small IPv4 example: it asks for a portbase and a destination and
- starts sending packets to that destination.
- */
-
- #include "jrtplib3/rtpsession.h"
- #include "jrtplib3/rtpudpv4transmitter.h"
- #include "jrtplib3/rtpipv4address.h"
- #include "jrtplib3/rtpsessionparams.h"
- #include "jrtplib3/rtperrors.h"
- #ifndef WIN32
- #include <netinet/in.h>
- #include <arpa/inet.h>
- #else
- #include <winsock2.h>
- #endif // WIN32
- #include <stdlib.h>
- #include <stdio.h>
- #include <iostream>
- #include <string>
-
- using namespace jrtplib;
-
- void checkerror(int rtperr)
- {
- if (rtperr < 0) //若是爲負數 則返回失敗信息
- {
- std::cout << "ERROR: " << RTPGetErrorString(rtperr) << std::endl;
- exit(-1);
- }
- }
-
- int main(void)
- {
- #ifdef WIN32
- WSADATA dat;
- WSAStartup(MAKEWORD(2,2),&dat);
- #endif // WIN32
-
- RTPSession sess;
-
- uint16_t portbase=8000,destport=7800;
- uint32_t destip;
- std::string ipstr="127.0.0.1";
- int status,i,num=10;
-
- destip = inet_addr(ipstr.c_str());//IP地址的創建
- if (destip == INADDR_NONE)
- {
- std::cerr << "Bad IP address specified" << std::endl;
- return -1;
- }
-
- destip = ntohl(destip);
-
-
- RTPUDPv4TransmissionParams transparams;
- RTPSessionParams sessparams;
-
- sessparams.SetOwnTimestampUnit(1.0/10.0);
-
- sessparams.SetAcceptOwnPackets(true);
- transparams.SetPortbase(portbase);
-
- status = sess.Create(sessparams,&transparams);
- checkerror(status);//檢查RTP會話建立過程是否失敗
-
- RTPIPv4Address addr(destip,destport);//套接字
-
- status = sess.AddDestination(addr);//設置數據發送的目標地址(容許有多個目的地址)
- checkerror(status);
-
- for (i = 1 ; i <= num ; i++)
- {
- printf("\nSending packet %d/%d\n",i,num);
-
- status = sess.SendPacket((void *)"1234567890",10,0,false,10);
- checkerror(status);
-
-
- // #ifndef RTP_SUPPORT_THREAD
- // status = sess.Poll();
- // checkerror(status);
- // #endif // RTP_SUPPORT_THREAD
-
- RTPTime::Wait(RTPTime(1,0));
- }
-
- sess.BYEDestroy(RTPTime(10,0),0,0);
-
- #ifdef WIN32
- WSACleanup();
- #endif // WIN32
- return 0;
- }
編譯:g++ -o send send.cpp -ljrtp -I /usr/local/include/jrtplib3/
ui
接受端代碼:spa
編譯:g++ -o receive receive.cpp -ljrtp -I /usr/local/include/jrtplib3/.net