找回密码
 用户注册

QQ登录

只需一步,快速开始

查看: 4694|回复: 1

jrtp移植的问题

[复制链接]
发表于 2008-9-21 15:22:08 | 显示全部楼层 |阅读模式
我把jrtp库移植到MONTAVISTA LINUX 系统中了,
如果在jrtp的那个文件夹中的examples文件夹中编写一个使用JRTP库的函数,并使用它的MAKEFILE
可以正确编译并运行。
但是如果我在另外的地方写个函数,调用JRTP库,则链接时出现问题:
In function `checkerror(int)':
/opt/dvevm_1_00_00_32/demos/encodedecode/rtp.cpp:46: `RTPSessionParams::RTPSessionParams()'
debug/rtp.po(.text+0x308):/opt/dvevm_1_00_00_32/demos/encodedecode/rtp.cpp:117: undefined reference to `RTPSession::Create(RTPSessionParams const&, RTPTransmissionParams const*)'
debug/rtp.po(.text+0x344):/opt/dvevm_1_00_00_32/demos/encodedecode/rtp.cpp:122: undefined reference to `RTPSession::AddDestination(RTPAddress const&)'
debug/rtp.po(.text+0x460): In function `uninit_rtp()':
/opt/dvevm_1_00_00_32/demos/encodedecode/rtp.cpp:129: undefined reference

我的RTP.CPP程序为:
/*
   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 "rtppacket.h"
#include "rtpudpv4transmitter.h"
#include "rtpipv4address.h"
#include "rtpsessionparams.h"
#include "rtperrors.h"
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
  
#include <assert.h>
#include <sys/types.h>
#include <string.h>
#include <errno.h>
#include <sys/time.h>
#include <fcntl.h>
#include <unistd.h>

#include "rtp.h"
extern void ****(void);
int rtp_init(void);
void uninit_rtp(void);
int send_rtppack(void *bufferhead , int length );

void checkerror(int rtperr)
{
if (rtperr < 0)
{
  std::cout << "ERROR: " << RTPGetErrorString(rtperr) << std::endl;
  exit(-1);
}
}

RTPSession sess;
int status ;
int rtp_init(void)
{
printf("*******************rtp_init*********\n");
uint16_t portbase,destport;
uint32_t destip;
std::string ipstr;
// int i,num;

// FILE * filep ;
// size_t rdsize = 0 ;
// static int n = 0 ;

       // First, we'll ask for the necessary information
  
//std::cout << "Enter local portbase:" << std::endl;
//std::cin >> portbase;
portbase = 5154 ;
///////////////////////
//std::cout << std::endl;
ipstr = "211.69.205.252";
//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 0;
}

// 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;
destport = 8000 ;

//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);
return 1 ;
}
void uninit_rtp(void)
{
  sess.BYEDestroy(RTPTime(10,0),0,0);
}
int send_rtppack(void *bufferhead , int length )
{
char * ptr = (char * ) bufferhead ;
printf("\nSending packet \n");
while (length > 1024 ){
  status = sess.SendPacket((void *)ptr,1024,0,false,10);
  checkerror(status);
  ptr += 1024 ;
  length -= 1024 ;  
}
status = sess.SendPacket((void *)bufferhead,length,0,false,10);
checkerror(status);

#ifndef RTP_SUPPORT_THREAD
  status = sess.Poll();
  checkerror(status);
#endif // RTP_SUPPORT_THREAD
return 1 ;
}
求高手指教啊!!!
 楼主| 发表于 2008-9-21 15:22:16 | 显示全部楼层
设置好链接的库,需要先编译一下jrtp
您需要登录后才可以回帖 登录 | 用户注册

本版积分规则

Archiver|手机版|小黑屋|ACE Developer ( 京ICP备06055248号 )

GMT+8, 2024-11-22 07:30 , Processed in 0.011731 second(s), 6 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表