jrtplib-2.6.lib 如何使用?

stevphen 2002-09-23 05:52:35
请问如何使用该库,我想做Mpeg-1网络传输程序
...全文
120 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
capboy 2002-12-17
  • 打赏
  • 举报
回复
to: sonnian(sonnian)
当然了...需要注意的是rtcp默认是5秒发送一次数据.但是你每次调用
if((rsda = sess.GetCurrentSourceInfo()) != NULL)都不是null的,除了开始没有数据.呵呵
rtp,rtcp都是使用udp实现的...看rtp的协议好像可以tcp的协议完成rtcp.
比较复杂一些...没有看到相应的实现.
sunshine_djh 2002-12-12
  • 打赏
  • 举报
回复
VisualStudio(嗷~~~) ,能否提供一个发送,一个等待接收的例子?
不胜感激!
sonnian 2002-11-20
  • 打赏
  • 举报
回复
我看见的例子都是发送后就接受了,也就只定义了一个session,那么可否在两个文件里各自定义一个session接受和发送,是否可以?
gxqcdit 2002-11-18
  • 打赏
  • 举报
回复
能否告知小弟该RTP库在哪里可以下载?
E_mail: G_Gump@caep.ac.cn
sonnian 2002-11-18
  • 打赏
  • 举报
回复
如何来跑这些例子呢?
我已经按照上述的例子和要求建立,可是就是看不到相应的窗口,请问为什么?
谢谢
sum_7124 2002-10-08
  • 打赏
  • 举报
回复
capboy:
是需要设置带宽的默认已经设置了,如果有必要可以再设置一遍。
rtcp发送的都是一些什么数据:包的丢失率发送,包抖动,等。
调用POLLDATA();会发送和接收RTCP包。
关于RTCP包,我懂的也不多。
我们可以互相学习,
我的EMAIL: sum_7124@sohu.com
zzugao 2002-10-01
  • 打赏
  • 举报
回复
太长了
我看不懂!!
capboy 2002-09-29
  • 打赏
  • 举报
回复
好像是需要设置的吧.是通过带宽设置来计算的.
- void SetSessionBandwidth(double bw)
Sets the bandwidth the session is supposed to use. The parameter
is treated in units of bits per second (bps). This value is used to
calculate the interval at which RTCP packets should be sent. The
default value is 64000 bps.
你知道他的rtcp发送的都是一些什么数据阿?提高了丢包的情况么?协议好像有.可是看他的sdk需要一些函数...他会自己发送么?
我比较关系rtcp发送的数据,你能够详细说明一下么?
sum_7124 2002-09-24
  • 打赏
  • 举报
回复
VisualStudio(嗷~~~) :
我也不太会,
但我不太明白:一个就可以发送和接收RTP和RTCP包,你为什么要用两个RTPSession呢?
另外请教一个问题:
为什么JRTPLIB的例子中RR包接收的不对?RR包接收的过多,太多了。
下面有两个例子: 例子1为发送RTP包,接收RR包。
例子2为接收RTP包,接收SR包。
谢谢!!

例子1:
#include
#include
#include "rtpsession.h"
#include "rtppacket.h"
#include "rtpsourcedata.h"

/*
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)
{
char *errstr;

// This function gets the error string for a certain error code
errstr = RTPGetErrorString(rtperr);

printf("Error:\n");
printf("%s\n",errstr);
exit(-1);
}
}

/*
The main routine
*/

int main(void)
{
RTPSession sess;
int portbase;
unsigned long destip;
int destport;
char ipstr[256];
int status,i;
char dummybuffer[1024];
int sock1,sock2;
struct timeval rttprev = {0,0},rtt,tv; //时间结构体
fd_set fdset;

/*
First, we‘ll ask for the necessary information
*/

printf("Enter the local portbase\n");
scanf("%d",&portbase);
printf("\n");

printf("Enter the destination IP address\n");
scanf("%s",ipstr);
destip = inet_addr(ipstr);
if (destip == INADDR_NONE)
{
printf("Bad IP address specified\n");
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);

printf("Enter the destination port\n");
scanf("%d",&destport);

/*
Now, we‘ll create a RTP session, set the destination, send some
packets and poll for incoming data.
*/
WORD wVersionRequested;
WSADATA wsaData;
int err;

wVersionRequested = MAKEWORD( 1, 1);

err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 ) {
/* Tell the user that we could not find a usable */
/* WinSock DLL. */
printf("winsock dll init error !\n");
return 0;
}
status = sess.Create(portbase);
checkerror(status);
status = sess.AddDestination(destip,destport);
checkerror(status);


unsigned long lssrc = 0;
sess.GetLocalSSRC(&lssrc);

unsigned long ul;




int j=0;
//bool bo =false;
for (i = 1 ; i <= 1000; i++)

sess.SendPacket("1232547680",10,0,0,(unsigned long)1);
// send the packet
// Sleep(1);



// poll for incoming data
status = sess.PollData();
checkerror(status);

// check incoming packets
if(sess.GotoFirstSource())
{
do
{
RTPSourceData *rtpsource;
if ((rtpsource = sess.GetCurrentSourceInfo()) != NULL)
{


if(rtpsource->RR_HasInfo())
{
// ul = rtpsource->GetSSRC();
// rtpsource = sess.GetSourceInfo(ul);
printf("GetLocalSSRC : %u\n",lssrc);
printf("rr number :%d\n",j++);
printf("getssrc : %u\n",rtpsource->GetSSRC());
printf("RR_GetDelaySinceLastSR : %u\n",rtpsource->RR_GetDelaySinceLastSR());
printf("RR_GetExtendedHighestSequenceNumber: %u\n",rtpsource->RR_GetExtendedHighestSequenceNumber());
printf("RR_GetFractionLost : %f\n",rtpsource->RR_GetFractionLost());
printf("RR_GetJitter : %u\n",rtpsource->RR_GetJitter());
printf("RR_GetLastSRTimestamp : %u\n",rtpsource->RR_GetLastSRTimestamp());
printf("RR_GetPacketsLost : %u\n",rtpsource->RR_GetPacketsLost());


}
rtpsource->FlushPackets();


}
} while (sess.GotoNextSource());




}
}
return 0;
}

例子2:
#include
#include
#include "rtpsession.h"
#include "rtppacket.h"


void checkerror(int rtperr)
{
if (rtperr < 0)
{
char *errstr;

str = RTPGetErrorString(rtperr);

printf("Error:\n");
printf("%s\n",errstr);
exit(-1);
}
}

/*
The main routine
*/

int main(void)
{
RTPSession sess;
int portbase;
unsigned long destip;
int destport;
char ipstr[256];
int status,i;
char dummybuffer[1024];
int sock1,sock2;
struct timeval rttprev = {0,0},rtt,tv; //时间结构体
fd_set fdset;
/*
First, we‘ll ask for the necessary information
*/

printf("Enter the local portbase\n");
scanf("%d",&portbase);
printf("\n");

printf("Enter the destination IP address\n");
scanf("%s",ipstr);
destip = inet_addr(ipstr);
if (destip == INADDR_NONE)
{
printf("Bad IP address specified\n");
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);

printf("Enter the destination port\n");

scanf("%d",&destport);

/*
Now, we‘ll create a RTP session, set the destination, send some
packets and poll for incoming data.
*/
WORD wVersionRequested;
WSADATA wsaData;
int err;

wVersionRequested = MAKEWORD( 1, 1);

err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 )
{
/* Tell the user that we could not find a usable */
/* WinSock DLL. */
printf("winsock dll init error !\n");
return 0;
}
status = sess.Create(portbase);
checkerror(status);
//得到会话的RTP的SOCKET (SOCK1)
sess.GetRTPSocket((unsigned int *)&sock1);
//得到会话的RTCP的SOCKET (SOCK2)
sess.GetRTCPSocket((unsigned int *)&sock2);
unsigned long assrc = 0;
sess.GetLocalSSRC(&assrc);
status = sess.AddDestination(destip,destport);
checkerror(status);

bool bRecv = true;
int j=0;
while(bRecv)

//等待1秒

// poll for incoming data
status = sess.PollData();


// check incoming packets
if (sess.GotoFirstSource())
{
do
{

RTPSourceData * rsda;
if((rsda = sess.GetCurrentSourceInfo()) != NULL)
{
if(rsda->SR_HasInfo())
{
printf("GetSSRC :%u\n",rsda->GetSSRC());
printf("number :%d\n",j++);
printf("SR_GetByteCount :%u\n",rsda->SR_GetByteCount());
printf("SR_GetPacketCount :%u\n",rsda->SR_GetPacketCount());

rsda->FlushPackets();

}

}

}while(sess.GotoNextSource());

}

}
return 0;
}


stevphen 2002-09-23
  • 打赏
  • 举报
回复
谢谢。
VisualStudio 2002-09-23
  • 打赏
  • 举报
回复
//举个例子给你吧
#include <rtpsession.h>
#include <rtppacket.h>

RTPSession* m_sess0, m_sess;
SOCKET RecSock;
int CreatServerAndClient()
{
SOCKERR serr = 0;
WSADATA wsadata;
WORD wVersionRequested = MAKEWORD( 2, 2 );
serr = ::WSAStartup(wVersionRequested, &wsadata);
if(serr != 0)
{
return serr;
}
m_sess0=new RTPSession;
m_sess0->Create(rec_Port);
m_sess0->SetMaxPacketSize(RTP_PACK_MAX_SIZE);
//自定义宏RTP_PACK_MAX_SIZE, BANDWIDTH
m_sess0->SetSessionBandwidth(BANDWIDTH);
m_sess0->SetDefaultPayloadType(1);
m_sess0->SetDefaultMark(true);
m_sess0->SetDefaultTimeStampIncrement(10);
m_sess0->GetRTPSocket(&RecSock);

m_sess=new RTPSession;
m_sess->Create(send_Port);

m_sess->SetMaxPacketSize(RTP_PACK_SIZE);
m_sess->SetSessionBandwidth(BANDWIDTH);


serr=::WSAAsyncSelect(RecSock,
this->m_hWnd,
USER_SOCKET_REC,
FD_READ) ;

if (serr != 0) {
return serr;
}

return serr;
}
stevphen 2002-09-23
  • 打赏
  • 举报
回复
我指的是api调用的顺序,就象socket一样,该如何使用呢?
VisualStudio 2002-09-23
  • 打赏
  • 举报
回复
jrtplib-2.6.lib
RTP 的函数都在这个lib中
把它加入到你的Project中
再包含你需要的头文件, 就可以了, 和使用一个dll相似

4,356

社区成员

发帖
与我相关
我的任务
社区描述
通信技术相关讨论
社区管理员
  • 网络通信
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧