/*---------------------------------------------------------------------------*/
/* main.cpp
/*---------------------------------------------------------------------------*/
#include <crtdbg.h> //for _ASSERT
//JRTP includes
#include "RTPSession.h"
#include "RTPIPv4Address.h"
#include "RTPSessionParams.h"
#include "RTPUDPv4Transmitter.h"
#pragma comment(lib,"jthread.lib")
#pragma comment(lib,"jrtplib.lib")
#pragma comment(lib,"Ws2_32.lib")
#define MCAST_IP "192.168.0.9"
#define MCAST_PORT 10025
#define SERVER_PORT 8000
#define MAX_PACKET_SIZE ((1024 * 64) - 1)
/*-------------------------------------------------------*/
/* ReportError
/* Checking & display of RTP status codes
/* Returns true if there was an error, false otherwise
/*-------------------------------------------------------*/
int ReportError(int errCode)
{
int isErr = (errCode < 0);
if (isErr) {
std::string stdErrStr = RTPGetErrorString(errCode);
printf("Error %d: %s\n", errCode, stdErrStr.c_str());
printf("======================================\nPress Enter to exit\n");
getchar();
}
return isErr;
}
/*-------------------------------------------------------*/
/* RunRtpServer
/*-------------------------------------------------------*/
void RunRtpServer()
{
//设置端口
RTPSession rtpSession;
//setup session parameters
RTPSessionParams sessParams;
sessParams.SetOwnTimestampUnit(1.0 / 30.0); //30 video frames per second
sessParams.SetUsePollThread(1); //background thread to call virtual callbacks - set by default, but just to be sure
sessParams.SetMaximumPacketSize(MAX_PACKET_SIZE);
//setup transmission parameters
RTPUDPv4TransmissionParams transParams;
transParams.SetPortbase(SERVER_PORT);//设置端口
//CREATE THE SESSION
int status = rtpSession.Create(sessParams, &transParams);
if (ReportError(status))
return; //unable to create the session
printf("RTP session created with portbase %d\n", SERVER_PORT);//设置8000
//SET TRANSMISSION DEFAULTS if we want to use them
//rtpSession.SetDefaultPayloadType(96);
//rtpSession.SetDefaultMark(false);
//rtpSession.SetDefaultTimestampIncrement(160);
//ADD THE MULTICAST to our destination,多点传送
unsigned long intIP = inet_addr(MCAST_IP);//定义的IP
_ASSERT(intIP != INADDR_NONE);//判断一个等式是否为false
intIP = ntohl(intIP); //put in host byte order,返回主机的IP地址
RTPIPv4Address rtpAddr(intIP, MCAST_PORT);
status = rtpSession.AddDestination(rtpAddr);
if (!ReportError(status)) {
printf("Transmitting to multicast group %s port %d\n\n", MCAST_IP, MCAST_PORT);
char testBuf[MAX_PACKET_SIZE];
while (1) {
printf("\n__________________________________________________________\nPress Enter key to send data - 'x' to exit\n");
int ch = getchar();
if (tolower(ch) == 'x')
break;
//SEND a packet
int byteCnt = rand() % sizeof(testBuf);//随即产生的数
rtpSession.SendPacket(testBuf, byteCnt, 0, false, 10UL);
printf("%d bytes sent\n", byteCnt);
}
//LEAVE THE MULTICAST
rtpSession.DeleteDestination(rtpAddr);
}
rtpSession.Destroy();//释放
}
/*-------------------------------------------------------*/
/* main
/* entry point for the application
/*-------------------------------------------------------*/
int main()
{
//MUST call WSAStartup() to use WS2_32.DLL
WSADATA wsaData;
WORD wVersionRequested = MAKEWORD( 2, 2 );
WSAStartup(wVersionRequested, &wsaData); //WSACleanup called in OnDestroy
RunRtpServer();
WSACleanup();
return 0;
}
没有合适的资源?快使用搜索试试~ 我知道了~
RTP通信的客户端和服务器程序,使用jrtplib来实现RTP的通信
共120个文件
h:97个
cpp:3个
pdb:2个
4星 · 超过85%的资源 需积分: 12 180 下载量 6 浏览量
2008-12-31
09:34:03
上传
评论
收藏 3.4MB RAR 举报
温馨提示
rtp&rtcp在实时流媒体传送过程中相当重要!因为UDP无法保障传送信息的准确性。rtp是基于udp上层的一个协议
资源推荐
资源详情
资源评论
收起资源包目录
RTP通信的客户端和服务器程序,使用jrtplib来实现RTP的通信 (120个子文件)
ConsoleServer.bsc 2.52MB
ConsoleServer.cpp 4KB
ConsoleClient.cpp 3KB
RTPAppSession.cpp 509B
ConsoleServer.dsp 8KB
ConsoleClient.dsp 8KB
ConsoleClient.dsw 765B
ConsoleServer.dsw 551B
ConsoleServer.exe 368KB
rtpsession.h 24KB
rtpsession.h 24KB
rtpsourcedata.h 20KB
rtpsourcedata.h 20KB
rtpsources.h 17KB
rtpsources.h 17KB
rtcppacketbuilder.h 11KB
rtcppacketbuilder.h 11KB
rtcpcompoundpacketbuilder.h 11KB
rtcpcompoundpacketbuilder.h 11KB
rtpudpv6transmitter.h 11KB
rtpudpv6transmitter.h 11KB
rtptransmitter.h 11KB
rtptransmitter.h 11KB
rtcpsdespacket.h 11KB
rtcpsdespacket.h 11KB
rtpudpv4transmitter.h 11KB
rtpudpv4transmitter.h 11KB
rtppacketbuilder.h 10KB
rtppacketbuilder.h 10KB
rtpsessionparams.h 10KB
rtpsessionparams.h 10KB
rtperrors.h 10KB
rtperrors.h 10KB
rtpkeyhashtable.h 9KB
rtpkeyhashtable.h 9KB
rtphashtable.h 8KB
rtphashtable.h 8KB
rtptimeutilities.h 8KB
rtptimeutilities.h 8KB
rtcpsdesinfo.h 8KB
rtcpsdesinfo.h 8KB
rtcpsrpacket.h 8KB
rtcpsrpacket.h 8KB
rtppacket.h 7KB
rtppacket.h 7KB
rtpmemorymanager.h 7KB
rtpmemorymanager.h 7KB
rtcpscheduler.h 7KB
rtcpscheduler.h 7KB
rtcprrpacket.h 6KB
rtcprrpacket.h 6KB
rtpinternalsourcedata.h 5KB
rtpinternalsourcedata.h 5KB
rtprawpacket.h 4KB
rtprawpacket.h 4KB
rtpipv6address.h 4KB
rtpipv6address.h 4KB
rtcpcompoundpacket.h 4KB
rtcpcompoundpacket.h 4KB
rtpipv4address.h 4KB
rtpipv4address.h 4KB
rtcpbyepacket.h 4KB
rtcpbyepacket.h 4KB
rtcpapppacket.h 4KB
rtcpapppacket.h 4KB
rtpipv4destination.h 3KB
rtpipv4destination.h 3KB
rtpipv6destination.h 3KB
rtpipv6destination.h 3KB
rtpaddress.h 3KB
rtpaddress.h 3KB
rtpsessionsources.h 3KB
rtpsessionsources.h 3KB
rtpcollisionlist.h 3KB
rtpcollisionlist.h 3KB
rtpdefines.h 3KB
rtpdefines.h 3KB
rtcppacket.h 3KB
rtcppacket.h 3KB
rtpstructs.h 3KB
rtpstructs.h 3KB
rtcpunknownpacket.h 3KB
rtcpunknownpacket.h 3KB
rtplibraryversion.h 2KB
rtplibraryversion.h 2KB
rtpmemoryobject.h 2KB
rtpmemoryobject.h 2KB
jthread.h 2KB
jthread.h 2KB
rtprandom.h 2KB
rtprandom.h 2KB
jmutex.h 2KB
jmutex.h 2KB
rtppollthread.h 2KB
rtppollthread.h 2KB
rtptypes_win.h 2KB
rtptypes_win.h 2KB
rtpdebug.h 2KB
rtpdebug.h 2KB
rtpconfig_win.h 2KB
共 120 条
- 1
- 2
anxiangcanliu2003168
- 粉丝: 22
- 资源: 23
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Screenshot_20240427_031602.jpg
- 网页PDF_2024年04月26日 23-46-14_QQ浏览器网页保存_QQ浏览器转格式(6).docx
- 直接插入排序,冒泡排序,直接选择排序.zip
- 在排序2的基础上,再次对快排进行优化,其次增加快排非递归,归并排序,归并排序非递归版.zip
- 实现了7种排序算法.三种复杂度排序.三种nlogn复杂度排序(堆排序,归并排序,快速排序)一种线性复杂度的排序.zip
- 冒泡排序 直接选择排序 直接插入排序 随机快速排序 归并排序 堆排序.zip
- 课设-内部排序算法比较 包括冒泡排序、直接插入排序、简单选择排序、快速排序、希尔排序、归并排序和堆排序.zip
- Python排序算法.zip
- C语言实现直接插入排序、希尔排序、选择排序、冒泡排序、堆排序、快速排序、归并排序、计数排序,并带图详解.zip
- 常用工具集参考用于图像等数据处理
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
前往页