最近要做网络监控视频的传输,以前就接触过图像处理的基本东西,对于网络稍微了解一点,对于视频的编解码则是一窍不通。这两周查阅了不少资料,发现一般使

用的网路协议都是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 重新编译的才行了。

附上一个在网上找到的例子:

view plain copy to clipboard print ?
  1. /*
  2. Here's a small IPv4 example: it asks for a portbase and a destination and
  3. starts sending packets to that destination.
  4. */
  5. #include "rtpsession.h"
  6. #include "rtpudpv4transmitter.h"
  7. #include "rtpipv4address.h"
  8. #include "rtpsessionparams.h"
  9. #include "rtperrors.h"
  10. #include "rtppacket.h"
  11. #ifndef WIN32
  12. #include <netinet/in.h>
  13. #include <arpa/inet.h>
  14. #else
  15. #include <winsock2.h>
  16. #endif // WIN32
  17. #include <stdlib.h>
  18. #include <stdio.h>
  19. #include <iostream>
  20. #include <string>
  21. using namespace jrtplib;
  22. #pragma comment(lib,"jrtplib_d.lib")
  23. #pragma comment(lib,"jthread_d.lib")
  24. #pragma comment(lib,"ws2_32.lib")
  25. //
  26. // This function checks if there was a RTP error. If so, it displays an error
  27. // message and exists.
  28. //
  29. void checkerror(int rtperr)
  30. {
  31. if (rtperr < 0)
  32. {
  33. std::cout << "ERROR: " << RTPGetErrorString(rtperr) << std::endl;
  34. exit(-1);
  35. }
  36. }
  37. //
  38. // The main routine
  39. //
  40. int main(void)
  41. {
  42. #ifdef WIN32
  43. WSADATA dat;
  44. WSAStartup(MAKEWORD(2,2),&dat);
  45. #endif // WIN32
  46. RTPSession sess;
  47. uint16_t portbase,destport;
  48. uint32_t destip;
  49. std::string ipstr;
  50. int status,i,num;
  51. BYTE *pBuffer;
  52. BYTE *pfBuffer;
  53. // First, we'll ask for the necessary information
  54. std::cout << "Enter local portbase:" << std::endl;
  55. std::cin >> portbase;
  56. std::cout << std::endl;
  57. std::cout << "Enter the destination IP address" << std::endl;
  58. std::cin >> ipstr;
  59. destip = inet_addr(ipstr.c_str());
  60. if (destip == INADDR_NONE)
  61. {
  62. std::cerr << "Bad IP address specified" << std::endl;
  63. return -1;
  64. }
  65. // The inet_addr function returns a value in network byte order, but
  66. // we need the IP address in host byte order, so we use a call to
  67. // ntohl
  68. destip = ntohl(destip);
  69. std::cout << "Enter the destination port" << std::endl;
  70. std::cin >> destport;
  71. std::cout << std::endl;
  72. std::cout << "Number of packets you wish to be sent:" << std::endl;
  73. std::cin >> num;
  74. // Now, we'll create a RTP session, set the destination, send some
  75. // packets and poll for incoming data.
  76. RTPUDPv4TransmissionParams transparams;
  77. RTPSessionParams sessparams;
  78. // IMPORTANT: The local timestamp unit MUST be set, otherwise
  79. //            RTCP Sender Report info will be calculated wrong
  80. // In this case, we'll be sending 10 samples each second, so we'll
  81. // put the timestamp unit to (1.0/10.0)
  82. sessparams.SetOwnTimestampUnit(1.0/10.0);
  83. sessparams.SetAcceptOwnPackets(true);
  84. transparams.SetPortbase(portbase);
  85. status = sess.Create(sessparams,&transparams);
  86. checkerror(status);
  87. RTPIPv4Address addr(destip,destport);
  88. status = sess.AddDestination(addr);
  89. checkerror(status);
  90. for (i = 1 ; i <= num ; i++)
  91. {
  92. printf("\nSending packet %d/%d\n",i,num);
  93. // send the packet
  94. status = sess.SendPacket((void *)"1234567890",10,0,false,10);
  95. checkerror(status);
  96. sess.BeginDataAccess();
  97. // check incoming packets
  98. if (sess.GotoFirstSourceWithData())
  99. {
  100. do
  101. {
  102. RTPPacket *pack;
  103. while ((pack = sess.GetNextPacket()) != NULL)
  104. {
  105. // You can examine the data here
  106. printf("Got packet !\n");
  107. std::cout << "Got packet with "
  108. << "extended sequence number "
  109. << pack->GetExtendedSequenceNumber()
  110. << " from SSRC " << pack->GetSSRC()
  111. << std::endl;
  112. int dataLength = pack->GetPayloadLength();
  113. pfBuffer =(unsigned char*)pack->GetPayloadData();
  114. pBuffer = new BYTE[dataLength + 1];
  115. memcpy(pBuffer, pfBuffer, dataLength);
  116. pBuffer[dataLength] = 0;
  117. std::cout << pBuffer << std::endl;
  118. delete []pBuffer;
  119. pBuffer = NULL;
  120. // we don't longer need the packet, so
  121. // we'll delete it
  122. sess.DeletePacket(pack);
  123. }
  124. } while (sess.GotoNextSourceWithData());
  125. }
  126. sess.EndDataAccess();
  127. #ifndef RTP_SUPPORT_THREAD
  128. status = sess.Poll();
  129. checkerror(status);
  130. #endif // RTP_SUPPORT_THREAD
  131. RTPTime::Wait(RTPTime(1,0));
  132. }
  133. sess.BYEDestroy(RTPTime(10,0),0,0);
  134. #ifdef WIN32
  135. WSACleanup();
  136. #endif // WIN32
  137. return 0;
  138. }

/* 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相关推荐

  1. 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 ...

  2. 【流媒體】jrtplib—VS2010下RTP开源协议库JRTPLIB3.9.1编译

    一.JRTPLIB简介 老外用C++编写的开源RTP协议库,用来进行实时数据传输,可以运行在 Windows.Linux. FreeBSD.Solaris.Unix和VxWorks 等多种操作系统上, ...

  3. 【流媒體】jrtplib—VS2010 下RTP开源协议库JRTPLIB3.9.1编译

    [流媒體]jrtplib-VS2010下RTP开源协议库JRTPLIB3.9.1编译 SkySeraph Apr 7th 2012 Email:skyseraph00@163.com 一.JRTPLI ...

  4. JRtplib开发笔记(二):JRtplib库编译、示例演示

    原博主博客地址:https://blog.csdn.net/qq21497936 本文章博客地址:https://blog.csdn.net/qq21497936/article/details/84 ...

  5. 国标28181:jrtplib从编译到使用

    jrtplib 作用 jrtplib是一个基于C++编写的面向对象的库,旨在帮助开发人员使用RFC3550中描述的实时传输协议(RTP),目前已经可以运行在Windows.Linux.FreeBSD. ...

  6. jrtplib+jthread 交叉编译

      一.移植JRTPLib到嵌入式(arm)平台 JRTPLIB库是一个RTP协议的开源库,使用这套库文件,我们可以创建端到端的RTP连接,实现数据的实时传输. JRTPLIB是使用标准c++编写的. ...

  7. 移植JRTPLib到Montavista

    http://www.cnblogs.com/rockstone/archive/2010/01/15/1648809.html 1. 将jrtplib-3.7.1和jthread-1.2.1解压到/ ...

  8. linux下编译jrtplib-3.9.1

    网站:http://blog.csdn.net/caoshangpa/article/details/51416822 一.下载jrtplib.jthread.CMake jrtplib:http:/ ...

  9. 基于JRTPLIB库的RTP数据传输设计文档

    http://xiyong8260.blog.163.com/blog/static/665146212008824112748499/  版权所有,若转载,请注明出处,谢谢合作.  关键词:JRTP ...

最新文章

  1. 人工智能的发展历史是怎样的?
  2. 从将机器学习模型转化成真正产品和服务中学到的经验教训
  3. jQuery里面的datepicker日期控件默认是显示英文的,如何显示中文或其他语言呢?...
  4. docker 容器 导入 导出
  5. JQuery Event属性说明
  6. 原来R语言还有这些不为人知的用处!
  7. Mac SecureCRT解决中文乱码
  8. 【转】细说.NET中的多线程 (五 使用信号量进行同步)
  9. spring的动态代理,碰到了一个类型转换的问题:java.lang.ClassCastException: com.sun.proxy.$Proxy16 cannot be cast to com.
  10. Js Vue 对象数组的创建方式
  11. go设置后端启动_Vue 之前后端分离的跨域
  12. 视频压缩神器--小丸工具箱--小丸工具箱入门操作教程
  13. 什么是LoRa协议?
  14. catia怎么将特征参数化_catia 怎么做参数化设计
  15. 惠普MFP774dn扫描功能
  16. 纹理压缩格式DXT/PVR/ETC编码
  17. 摩托罗拉Android 7寸,3.7寸屏600MHz处理器 摩托罗拉MT710评测
  18. CO-PA: 获利能力分析数据的传送(日常业务)
  19. ym——物联网入口之一Android蓝牙4.0
  20. 什么是即时消息(IM)?

热门文章

  1. C# 篇基础知识6——文件和流
  2. 01背包问题(动态规划)
  3. x264源代码简单分析 编码器主干部分-1
  4. CMMI2.0是什么?
  5. 基于java+SpringBoot+HTML+Mysql旅游网站设计与实现
  6. linux设置共享文件夹和删除共享文件夹(vmware:linux-windows共享文件夹)
  7. C#,图像二值化(13)——全局阈值的双峰平均值算法(Bimodal Thresholding)与源程序
  8. linux 下安装apache 快速教程
  9. 微泡基础知识及其在半导体清洗中的应用
  10. fstream用法总结