编译jrtplib和jthread
最近要做网络监控视频的传输,以前就接触过图像处理的基本东西,对于网络稍微了解一点,对于视频的编解码则是一窍不通。这两周查阅了不少资料,发现一般使
用的网路协议都是RTP/RTCP,网络上找了不少资料,本来想整个现成的例子看看,下了不少发现都不满意,只好自己找到那个很牛的老外Jori写的开源的RTP库jrtplib研究一下自己编译一下,学学了。
首先从他的个人网站上http://research.edm.uhasselt.be/~jori/page/index.php?n=CS.Jrtplib下载最新的jrtplib-3.9.0,以及最新的jthread-1.3.0(他的页面上也有下载),解压完之后,看了看ReadMe发现需要Cmake编译,oh!mygod!慢慢来吧。
使用Cmake_gui 2.8版本,首先编译生成jthread.lib。
添加完路径之后,很顺利的就可以得到vs2005下的工程文件,编译之后可以在C:/Program Files/jthread/include(默认的路径)下看到jthread的头文件以及在C:/Program Files/jthread/lib下的lib文件(一般吧debug和release都编译一下)。
然后就是jrtplib的编译了。
jrtplib的cmake编译需要jthread.lib(jthread_d.lib)编译,cmake不会用,开始时出现错误,后来自己摸索着试了试,成功了,就是在编译几个example时发现有warning,也没什么关系。设置如图所示
这样再generate就可以了(不知道以后有没有问题,反正现在没问题)。
然后就是vs2005中的生成lib库了。
首先需要将所有jrtplib中src下的头文件中包含jmutex.h和jthread.h的include全部修改为include "jmutex."和include"jthread.h",然后进行下一步
打开工程文件编译之后安装,可以在C:\Program Files\jrtplib下面看到两个文件夹include和lib分别放着头文件和库文件。
打开example1,进行相应的设置之后run,发现可以运行了!
这样应该就可以在工程中使用jrtplib库了---------还没有试,期待ing。。。。。
另:在Jori的主页上有关于这两个库jrtplib和jthread的使用手册的pdf下载可以参考。
NOTE:开始时没有将jthread和jmutex的include修改,虽然编译成功了,运行example也可以但是自己编的程序就出问题,后来参考了一下http://blog.csdn.net/aaronalan/article/details/5153604 重新编译的才行了。
附上一个在网上找到的例子:
- /*
- Here's a small IPv4 example: it asks for a portbase and a destination and
- starts sending packets to that destination.
- */
- #include "rtpsession.h"
- #include "rtpudpv4transmitter.h"
- #include "rtpipv4address.h"
- #include "rtpsessionparams.h"
- #include "rtperrors.h"
- #include "rtppacket.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;
- #pragma comment(lib,"jrtplib_d.lib")
- #pragma comment(lib,"jthread_d.lib")
- #pragma comment(lib,"ws2_32.lib")
- //
- // This function checks if there was a RTP error. If so, it displays an error
- // message and exists.
- //
- void checkerror(int rtperr)
- {
- if (rtperr < 0)
- {
- std::cout << "ERROR: " << RTPGetErrorString(rtperr) << std::endl;
- exit(-1);
- }
- }
- //
- // The main routine
- //
- int main(void)
- {
- #ifdef WIN32
- WSADATA dat;
- WSAStartup(MAKEWORD(2,2),&dat);
- #endif // WIN32
- RTPSession sess;
- uint16_t portbase,destport;
- uint32_t destip;
- std::string ipstr;
- int status,i,num;
- BYTE *pBuffer;
- BYTE *pfBuffer;
- // First, we'll ask for the necessary information
- std::cout << "Enter local portbase:" << std::endl;
- std::cin >> portbase;
- std::cout << std::endl;
- std::cout << "Enter the destination IP address" << std::endl;
- std::cin >> ipstr;
- destip = inet_addr(ipstr.c_str());
- if (destip == INADDR_NONE)
- {
- std::cerr << "Bad IP address specified" << std::endl;
- return -1;
- }
- // The inet_addr function returns a value in network byte order, but
- // we need the IP address in host byte order, so we use a call to
- // ntohl
- destip = ntohl(destip);
- std::cout << "Enter the destination port" << std::endl;
- std::cin >> destport;
- std::cout << std::endl;
- std::cout << "Number of packets you wish to be sent:" << std::endl;
- std::cin >> num;
- // Now, we'll create a RTP session, set the destination, send some
- // packets and poll for incoming data.
- RTPUDPv4TransmissionParams transparams;
- RTPSessionParams sessparams;
- // IMPORTANT: The local timestamp unit MUST be set, otherwise
- // RTCP Sender Report info will be calculated wrong
- // In this case, we'll be sending 10 samples each second, so we'll
- // put the timestamp unit to (1.0/10.0)
- sessparams.SetOwnTimestampUnit(1.0/10.0);
- sessparams.SetAcceptOwnPackets(true);
- transparams.SetPortbase(portbase);
- status = sess.Create(sessparams,&transparams);
- checkerror(status);
- RTPIPv4Address addr(destip,destport);
- status = sess.AddDestination(addr);
- checkerror(status);
- for (i = 1 ; i <= num ; i++)
- {
- printf("\nSending packet %d/%d\n",i,num);
- // send the packet
- status = sess.SendPacket((void *)"1234567890",10,0,false,10);
- checkerror(status);
- sess.BeginDataAccess();
- // check incoming packets
- if (sess.GotoFirstSourceWithData())
- {
- do
- {
- RTPPacket *pack;
- while ((pack = sess.GetNextPacket()) != NULL)
- {
- // You can examine the data here
- printf("Got packet !\n");
- std::cout << "Got packet with "
- << "extended sequence number "
- << pack->GetExtendedSequenceNumber()
- << " from SSRC " << pack->GetSSRC()
- << std::endl;
- int dataLength = pack->GetPayloadLength();
- pfBuffer =(unsigned char*)pack->GetPayloadData();
- pBuffer = new BYTE[dataLength + 1];
- memcpy(pBuffer, pfBuffer, dataLength);
- pBuffer[dataLength] = 0;
- std::cout << pBuffer << std::endl;
- delete []pBuffer;
- pBuffer = NULL;
- // we don't longer need the packet, so
- // we'll delete it
- sess.DeletePacket(pack);
- }
- } while (sess.GotoNextSourceWithData());
- }
- sess.EndDataAccess();
- #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;
- }
/* Here's a small IPv4 example: it asks for a portbase and a destination and starts sending packets to that destination. */ #include "rtpsession.h" #include "rtpudpv4transmitter.h" #include "rtpipv4address.h" #include "rtpsessionparams.h" #include "rtperrors.h" #include "rtppacket.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; #pragma comment(lib,"jrtplib_d.lib") #pragma comment(lib,"jthread_d.lib") #pragma comment(lib,"ws2_32.lib") // // This function checks if there was a RTP error. If so, it displays an error // message and exists. // void checkerror(int rtperr) { if (rtperr < 0) { std::cout << "ERROR: " << RTPGetErrorString(rtperr) << std::endl; exit(-1); } } // // The main routine // int main(void) { #ifdef WIN32 WSADATA dat; WSAStartup(MAKEWORD(2,2),&dat); #endif // WIN32 RTPSession sess; uint16_t portbase,destport; uint32_t destip; std::string ipstr; int status,i,num; BYTE *pBuffer; BYTE *pfBuffer; // First, we'll ask for the necessary information std::cout << "Enter local portbase:" << std::endl; std::cin >> portbase; std::cout << std::endl; std::cout << "Enter the destination IP address" << std::endl; std::cin >> ipstr; destip = inet_addr(ipstr.c_str()); if (destip == INADDR_NONE) { std::cerr << "Bad IP address specified" << std::endl; return -1; } // The inet_addr function returns a value in network byte order, but // we need the IP address in host byte order, so we use a call to // ntohl destip = ntohl(destip); std::cout << "Enter the destination port" << std::endl; std::cin >> destport; std::cout << std::endl; std::cout << "Number of packets you wish to be sent:" << std::endl; std::cin >> num; // Now, we'll create a RTP session, set the destination, send some // packets and poll for incoming data. RTPUDPv4TransmissionParams transparams; RTPSessionParams sessparams; // IMPORTANT: The local timestamp unit MUST be set, otherwise // RTCP Sender Report info will be calculated wrong // In this case, we'll be sending 10 samples each second, so we'll // put the timestamp unit to (1.0/10.0) sessparams.SetOwnTimestampUnit(1.0/10.0); sessparams.SetAcceptOwnPackets(true); transparams.SetPortbase(portbase); status = sess.Create(sessparams,&transparams); checkerror(status); RTPIPv4Address addr(destip,destport); status = sess.AddDestination(addr); checkerror(status); for (i = 1 ; i <= num ; i++) { printf("\nSending packet %d/%d\n",i,num); // send the packet status = sess.SendPacket((void *)"1234567890",10,0,false,10); checkerror(status); sess.BeginDataAccess(); // check incoming packets if (sess.GotoFirstSourceWithData()) { do { RTPPacket *pack; while ((pack = sess.GetNextPacket()) != NULL) { // You can examine the data here printf("Got packet !\n"); std::cout << "Got packet with " << "extended sequence number " << pack->GetExtendedSequenceNumber() << " from SSRC " << pack->GetSSRC() << std::endl; int dataLength = pack->GetPayloadLength(); pfBuffer =(unsigned char*)pack->GetPayloadData(); pBuffer = new BYTE[dataLength + 1]; memcpy(pBuffer, pfBuffer, dataLength); pBuffer[dataLength] = 0; std::cout << pBuffer << std::endl; delete []pBuffer; pBuffer = NULL; // we don't longer need the packet, so // we'll delete it sess.DeletePacket(pack); } } while (sess.GotoNextSourceWithData()); } sess.EndDataAccess(); #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; }
编译jrtplib和jthread相关推荐
- Windows 7(Win7)下Visual Studio 2012(VS2012)编译jrtplib与MinGW编译jrtplib
一.下载jrtplib.jthread.CMake.Visual Studio 2012和Qt5.5.1 jrtplib:http://research.edm.uhasselt.be/jori/jr ...
- 【流媒體】jrtplib—VS2010下RTP开源协议库JRTPLIB3.9.1编译
一.JRTPLIB简介 老外用C++编写的开源RTP协议库,用来进行实时数据传输,可以运行在 Windows.Linux. FreeBSD.Solaris.Unix和VxWorks 等多种操作系统上, ...
- 【流媒體】jrtplib—VS2010 下RTP开源协议库JRTPLIB3.9.1编译
[流媒體]jrtplib-VS2010下RTP开源协议库JRTPLIB3.9.1编译 SkySeraph Apr 7th 2012 Email:skyseraph00@163.com 一.JRTPLI ...
- JRtplib开发笔记(二):JRtplib库编译、示例演示
原博主博客地址:https://blog.csdn.net/qq21497936 本文章博客地址:https://blog.csdn.net/qq21497936/article/details/84 ...
- 国标28181:jrtplib从编译到使用
jrtplib 作用 jrtplib是一个基于C++编写的面向对象的库,旨在帮助开发人员使用RFC3550中描述的实时传输协议(RTP),目前已经可以运行在Windows.Linux.FreeBSD. ...
- jrtplib+jthread 交叉编译
一.移植JRTPLib到嵌入式(arm)平台 JRTPLIB库是一个RTP协议的开源库,使用这套库文件,我们可以创建端到端的RTP连接,实现数据的实时传输. JRTPLIB是使用标准c++编写的. ...
- 移植JRTPLib到Montavista
http://www.cnblogs.com/rockstone/archive/2010/01/15/1648809.html 1. 将jrtplib-3.7.1和jthread-1.2.1解压到/ ...
- linux下编译jrtplib-3.9.1
网站:http://blog.csdn.net/caoshangpa/article/details/51416822 一.下载jrtplib.jthread.CMake jrtplib:http:/ ...
- 基于JRTPLIB库的RTP数据传输设计文档
http://xiyong8260.blog.163.com/blog/static/665146212008824112748499/ 版权所有,若转载,请注明出处,谢谢合作. 关键词:JRTP ...
最新文章
- 人工智能的发展历史是怎样的?
- 从将机器学习模型转化成真正产品和服务中学到的经验教训
- jQuery里面的datepicker日期控件默认是显示英文的,如何显示中文或其他语言呢?...
- docker 容器 导入 导出
- JQuery Event属性说明
- 原来R语言还有这些不为人知的用处!
- Mac SecureCRT解决中文乱码
- 【转】细说.NET中的多线程 (五 使用信号量进行同步)
- spring的动态代理,碰到了一个类型转换的问题:java.lang.ClassCastException: com.sun.proxy.$Proxy16 cannot be cast to com.
- Js Vue 对象数组的创建方式
- go设置后端启动_Vue 之前后端分离的跨域
- 视频压缩神器--小丸工具箱--小丸工具箱入门操作教程
- 什么是LoRa协议?
- catia怎么将特征参数化_catia 怎么做参数化设计
- 惠普MFP774dn扫描功能
- 纹理压缩格式DXT/PVR/ETC编码
- 摩托罗拉Android 7寸,3.7寸屏600MHz处理器 摩托罗拉MT710评测
- CO-PA: 获利能力分析数据的传送(日常业务)
- ym——物联网入口之一Android蓝牙4.0
- 什么是即时消息(IM)?