【流媒體】jrtplib—VS2010下RTP开源协议库JRTPLIB3.9.1编译
一、JRTPLIB简介
老外用C++编写的开源RTP协议库,用来进行实时数据传输,可以运行在 Windows、Linux、 FreeBSD、Solaris、Unix和VxWorks 等多种操作系统上,主页为:http://research.edm.uhasselt.be/~jori/page/index.php?n=Main.HomePage
二、相关下载
jrtplib: http://research.edm.uhasselt.be/~jori/page/index.php?n=CS.Jrtplib
jthread: http://research.edm.uhasselt.be/~jori/page/index.php?n=CS.Jthread
cmake: http://www.cmake.org/cmake/resources/software.html
三、 编译步骤
1 下载jrtplib和jthread并解压缩。阅读README。
2 编译jthread生成jthread.lib和jthread_d.lib。
① 打开cmake,添加好输入(where..)和输出路径(where to…),完成configure配置(选visual studio 10),配置结果如下图:
② 点击generate,生成VS2010工程文件
③ 打开工程文件并编译,在debug和release下分别生成jthread.lib和jthread_d.lib
编译的具体方法为:选择Solution Explorer里的 Solution jthread,点右键,运行"Rebuild Solution";如编译无错误,再选择INSTALL项目,运行"Build"。
④ 如果编译成功(如下图),会在C:\Program Files\jthread的include\jthread下生成头文件;在lib下生成lib和cmake文件
温馨提示:在win7下,你必须拥有管理者权限,否则编译不会通过,因为无法在C:\Program Files创建jthread文件,当然你可以手动创建。
3 编译jrtplib生成jrtplib.lib和jrtplib_d.lib。
① 同2-①,其中configure会稍微麻烦一些,详细配置结果如下:
② 点击generate,生成VS2010工程文件
③ 打开工程文件并编译,在debug和release下分别生成jrtplib_d.lib和jrtplib.lib
④ 编译成功(如下图),在C:\Program Files\jrtplib下include\jrtplib3下会生成一堆头文件;在lib下会生成jrtplib_d.lib和jrtplib.lib以及cmake文件
说明:网上提到的一些用VS2008和VC6.0方法中提到了两个细节: 一是要把"jmutex.h"和"jthread.h"两个头文件放入jrtplib/src目录下,二是要把src文件夹下所有头文件中的<jmutex.h>和<jthread.h>语句修改为"jmutex.h"和"jthread.h"。我在编译时没有处理这两个细节成功了,后续调试出现相应问题相应修改一下即可。
四、 使用实例
1 添加库
①步骤一:
方法1. 将编译生成的jrtplib.lib和jthread.lib库拷贝到“*:\Program Files\Microsoft Visual Studio 10.0\VC\lib”下面
方法2. 将编译生成的四个lib库库拷贝到当前工程的cpp文件下
②步骤二:
方法1. [菜单]“项目->属性->配置属性->连接器->输入->附加依赖项”里填写“jrtplib.lib;jthread.lib;WS2_32.lib”
方法2. pragma 方式,在stdafx.h文件中 添加
复制代码
ifdef DEBUG
#pragma comment(lib, "jrtplib_d.lib")
#pragma comment(lib,"jthread_d.lib")
#pragma comment(lib,"WS2_32.lib")
else
#pragma comment(lib, "jrtplib.lib")
#pragma comment(lib,"jthread.lib")
#pragma comment(lib,"WS2_32.lib")
endif
复制代码
2 添加头文件
①步骤一:将所有的.h文件放到一起,如myJRTPLIBHeader里面,再添加include
②步骤二:
方法1.“项目->属性->配置属性->C/C++->常规->附加包含目录”
方法2.“工具->选项->项目和解决方案->C++ 目录”,选择对应平台,然后添加所需“包括文件”目录(此法VS2010不通)
3 测试代码(sample1)
cpp文件:
复制代码
// jrtplibTest.cpp : 定义控制台应用程序的入口点。
//
include “stdafx.h”
// 头文件
include “rtpsession.h”
include “rtpudpv4transmitter.h”
include “rtpipv4address.h”
include “rtpsessionparams.h”
include “rtperrors.h”
ifndef WIN32
include
include
else
include
endif // WIN32
include
include
include
include
using namespace jrtplib;
//
// 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;// First, we'll ask for the necessary informationstd::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;// 获得接收端的IP地址和端口号
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);
// 创建RTP会话
status = sess.Create(sessparams,&transparams);
checkerror(status);RTPIPv4Address addr(destip,destport);
// 指定RTP数据接收端
status = sess.AddDestination(addr);
checkerror(status);for (i = 1 ; i <= num ; i++)
{printf("\nSending packet %d/%d\n",i,num);// send the packetstatus = sess.SendPacket((void *)"1234567890",10,0,false,10);checkerror(status);sess.BeginDataAccess();// check incoming packetsif (sess.GotoFirstSourceWithData()){do{RTPPacket *pack;while ((pack = sess.GetNextPacket()) != NULL){// You can examine the data hereprintf("Got packet !\n");// we don't longer need the packet, so// we'll delete itsess.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;
}
复制代码
4 下载
在VS2010+Win7下编译好的JRTPLIB库及相关头文件下载:(刚传CSDN,现在打不开,等等,明天补上…)
补充:下载(猛击)
Ref/Related
1 http://research.edm.uhasselt.be/~jori/page/index.php?n=CS.Jrtplib
2 http://research.edm.uhasselt.be/jori/jrtplib/documentation/index.html
3 http://blog.csdn.net/nickche300/article/details/6408099
4 http://blog.csdn.net/sunloverain2/article/details/5398694
5 http://blog.csdn.net/aaronalan/article/details/5153604
转载自这里
【流媒體】jrtplib—VS2010下RTP开源协议库JRTPLIB3.9.1编译相关推荐
- 【流媒體】jrtplib—VS2010 下RTP开源协议库JRTPLIB3.9.1编译
[流媒體]jrtplib-VS2010下RTP开源协议库JRTPLIB3.9.1编译 SkySeraph Apr 7th 2012 Email:skyseraph00@163.com 一.JRTPLI ...
- 【流媒體】live555—VS2010/VS2013 下live555编译、使用及测试
[流媒體]live555-VS2010 /VS2013 下live555编译.使用及测试 SkySeraph Apr 11st 2012 Email:skyseraph00@163.com 更多精彩请 ...
- RTP/RTCP流媒體服務器技術研究
來源:http://www.sharp-i.net/big5/articles/article/26.htm 隨著互聯網的飛速發展,流媒體技術的應用越來越廣泛,從網上廣播.電影播放到遠程教學以及在線的 ...
- 【流媒體】Android 实时视频采集—Camera预览采集
[流媒體]Android 实时视频采集-Cameara预览采集 SkySeraph Mar 26th 2012 SZ Email:skyseraph00@163.com 更多精彩请直接访问SkySe ...
- 【流媒體】H264—MP4格式及在MP4文件中提取H264的SPS、PPS及码流
原文地址为: [流媒體]H264-MP4格式及在MP4文件中提取H264的SPS.PPS及码流 [流媒體]H264-MP4格式及在MP4文件中提取H264的SPS.PPS及码流 SkySeraph A ...
- [转]【流媒體】H264—MP4格式及在MP4文件中提取H264的SPS、PPS及码流
[流媒體]H264-MP4格式及在MP4文件中提取H264的SPS.PPS及码流 SkySeraph Apr 1st 2012 Email:skyseraph00@163 .com 一.MP4格式基 ...
- 流媒體】H264—MP4格式及在MP4文件中提取H264的SPS、PPS及码流
源地址:http://www.cnblogs.com/skyseraph/archive/2012/04/01/2429384.html [流媒體]H264-MP4格式及在MP4文件中提取H264的S ...
- 【流媒體】live555—VS2010 下live555编译、使用及测试
Ⅰ live555简介 Live555 是一个为流媒体提供解决方案的跨平台的C++开源项目,它实现了对标准流媒体传输协议如RTP/RTCP.RTSP.SIP等的支持.Live555实现了对多种音视频编 ...
- 龙芯处理器下面的golang第三方库或框架实地编译与运行测试
编译运行机器环境: CPU 龙芯3A3000 操作系统 中标麒麟v7.0 gcc版本 4.9 先说不能用的吧: godror:用于访问oracle的,编译项目没有问题,但是运行时依赖的oracle I ...
最新文章
- ubuntu安装Android SDK,adb,fastboot
- PANS最新脑神经科学研究:激活一种新语言并不费力气
- vector和deque的区别?
- isless()函数与C ++中的示例
- 如何写出好的Java代码?
- 基于JAVA+SSH+MYSQL的工资管理系统
- werkzeug routing.MapAdapter
- Windows没有关机按钮 如何使用命令行关机 重启
- RTKLIB专题学习(十二)—支持的信号ID/观测类型及读取优先级
- 无线网卡SP-WL450U的驱动问题
- MNE学习笔记(六):Epoched data的可视化
- 头指针为head的带头结点的单链表判空条件head->next==null?
- 数字图像处理实验八图像的傅里叶变换
- 如何将PDF文件或图片或网页中的公式变为可编辑的--mathpix快速输入公式
- PetaLinux使用Gstreamer传输USB摄像头到DP显示屏
- log4j2输出中文乱码
- 通过ReleaseId创建现有项目的KieContainer的时候,提示Cannot find KieModule
- 小米汽车设计图纸泄露,官方称非最终文件;微软裁员遣散费高达8亿美元,人均获赔54万元;苹果暂停自研Wi-Fi芯片|极客头条...
- 【强化学习】模仿学习:行为克隆
- 这10个白嫖网站,或许你一个都不知道!