一、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。

 编译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 <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; //
// 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 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; // 获得接收端的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 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"); // 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;
}

4  下载

  在VS2010+Win7下编译好的JRTPLIB库及相关头文件下载:(刚传CSDN,现在打不开,等等,明天补上...)

补充:下载(猛击


Ref/Related

http://research.edm.uhasselt.be/~jori/page/index.php?n=CS.Jrtplib

http://research.edm.uhasselt.be/jori/jrtplib/documentation/index.html

http://blog.csdn.net/nickche300/article/details/6408099

http://blog.csdn.net/sunloverain2/article/details/5398694

http://blog.csdn.net/aaronalan/article/details/5153604

流媒體】jrtplib—VS2010下RTP开源协议库JRTPLIB3.9.1编译的更多相关文章

  1. 【流媒體】live555—VS2008 下live555编译、使用及测试

    [流媒體]live555—VS22008 下live555编译.使用及测试 Ⅰ live555简介 Live555 是一个为流媒体提供解决方案的跨平台的C++开源项目,它实现了对标准流媒体传输协议如R ...

  2. [转]【流媒體】H264—MP4格式及在MP4文件中提取H264的SPS、PPS及码流

    [流媒體]H264—MP4格式及在MP4文件中提取H264的SPS.PPS及码流 SkySeraph Apr 1st 2012  Email:skyseraph00@163.com 一.MP4格式基本 ...

  3. 【流媒體】live555—VS2010 下live555编译、使用及测试

    Ⅰ live555简介 Live555 是一个为流媒体提供解决方案的跨平台的C++开源项目,它实现了对标准流媒体传输协议如RTP/RTCP.RTSP.SIP等的支持.Live555实现了对多种音视频编 ...

  4. linux下RTP编程(使用JRTPLIB)(转)

    流媒体指的是在网络中使用流技术传输的连续时基媒体,其特点是在播放前不需要下载整个文件,而是采用边下载边播放的方式,它是视频会议.IP电话等应用场合的技术基础.RTP是进行实时流媒体传输的标准协议和关键 ...

  5. VS2010下MFC的串口编程

    串口通信简介 一般来说,计算机都有一个或多个串行端口,这些串口提供了外部设备与PC进行数据传输和通信的通道,在CPU和外设之间充当解释器的角色.当字符数据从CPU发送给外设时,这些字符数据将被转换成串 ...

  6. 【转】VS2010下MFC的串口编程

    串口通信简介 一般来说,计算机都有一个或多个串行端口,这些串口提供了外部设备与PC进行数据传输和通信的通道,在CPU和外设之间充当解释器的角色.当字符数据从CPU发送给外设时,这些字符数据将被转换成串 ...

  7. Linux下经常使用的C/C++开源Socket库

    1.      Linux Socket Programming In C++ : http://tldp.org/LDP/LG/issue74/tougher.html 2.      ACE: h ...

  8. Linux下经常使用的C/C++开源Socket库【转】

    转自:https://www.cnblogs.com/gccbuaa/p/7015599.html 1.      Linux Socket Programming In C++ : http://t ...

  9. CxImage在VS2010下的配置

    http://blog.csdn.net/youzhuo/article/details/24601621 一.编译Cximage 1.在SourceForge上下载cximage702_full.7 ...

随机推荐

  1. 以“图片渐入渐出”为例讲述jQuery插件的具体实现

    首先声明,此代码以网友“斯迈欧”原创作为此例的讲解: 在这之前我们先看看我们要做的效果是什么样的: 解析下面的样式:我们要图片在过“一定时间”后自动切换,在右下角处有小方块似数字1,2,3,4,这些数 ...

  2. 解Linux进程间通信(IPC)方式

    http://blog.csdn.net/liuhongxiangm/article/details/7928790 linux下的进程通信手段基本上是从Unix平台上的进程通信手段继承而来的.而对U ...

  3. Linux 操作Mysql详解

    一.引言 想使用Linux已经很长时间了,由于没有硬性任务一直也没有系统学习,近日由于工作需要必须使用Linux下的MySQL.本以为有 Windows下使用SQL Server的经验,觉得在Linu ...

  4. ural 1869

    简单题 ~~ #include <cstdio> #include <cstring> #include <iostream> using namespace st ...

  5. A const field of a reference type other than string can only be initialized with null Error [duplicate]

    I'm trying to create a 2D array to store some values that don't change like this. const int[,] hiveI ...

  6. [转载]Spring Java Based Configuration

    @Configuration & @Bean Annotations Annotating a class with the @Configuration indicates that the ...

  7. POJ 1930

    Dead Fraction Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 1762   Accepted: 568 Desc ...

  8. POJ 2499 Binary Tree(二叉树,找规律)

    题意:给一个这样的二叉树,每个节点用一对数(a,b)表示,根节点为(1,1).设父亲为(a,b),左儿子(a+b,b),右儿子(a,a+b). 给几组数据,(i,j),求从根节点到(i,j)节点需要向 ...

  9. 欧拉工程第58题:Spiral primes

    题目链接 Java程序 package projecteuler51to60; import java.math.BigInteger; import java.util.Iterator; impo ...

  10. 2014-9-17二班----9 web project

    http://localhost:8080/rwkj1/indexServlet             跳转                    http://localhost:8080/rwk ...