Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1347813
  • 博文数量: 244
  • 博客积分: 10311
  • 博客等级: 上将
  • 技术积分: 3341
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-14 21:50
文章分类

全部博文(244)

文章存档

2013年(6)

2012年(5)

2011年(16)

2010年(11)

2009年(172)

2008年(34)

分类: LINUX

2009-05-11 19:28:34

最近做的东西,需要使用RTP,但是下载了 JRTPLIB,按照example用了用上了,

可是,结果确是很差,还不如直接使用TCP来做。

但是,我确信,RTP可以做得更好,于是,仔细研究,并做笔记,记录之。

相关介绍太少了,所以,我决定从代码入手,虽然这是比较不好的一个方法,

但是,至少是一种方法。

那就一个一个类的来看吧,怎么看呢?

我是从例子了入手,example1中,首先定义了RTPUDPv4TransmissionParams,RTPSessionParams和RTPSession,因为RTPSession是一个高级类,综合了大部的功能,比较复杂,而且RTPSessionParams和RTPUDPv4TransmissionParams也是RTPSession::Create时需要的两个变量,所以,我觉得先看RTPSessionParams。

/** Describes the parameters for to be used by an RTPSession instance.
 *  Describes the parameters for to be used by an RTPSession instance. Note that the own timestamp
 *  unit must be set to a valid number, otherwise the session can't be created.
 */
/************************************************************************/
/* 描述了RTPSession实例中使用的参数          */
/* 注意timestamp 单位必须设为有效数据,否则将不能创建成功    */
/************************************************************************/
class RTPSessionParams
{
public:
 RTPSessionParams();
 
 /** If \c usethread is \c true, the session will use a poll thread to automatically process incoming
  *  data and to send RTCP packets when necessary.
  */
 /************************************************************************/
 /* 如果 \c usethread为 \c true,这个会话将使用poll线程,poll线程会自动  */
 /* 处理接收到的数据,并且在必要的时候发送RTCP packets     */
 /************************************************************************/
 int SetUsePollThread(bool usethread);

 /** Returns whether the session should use a poll thread or not (default is \c true). */
 /************************************************************************/
 /* 返回session是否利用poll线程,默认为 \c true                          */
 /************************************************************************/
 bool IsUsingPollThread() const      { return usepollthread; }

 /** Sets the maximum allowed packet size for the session. */
 /************************************************************************/
 /* 设置允许的最大的packet size                                          */
 /************************************************************************/
 void SetMaximumPacketSize(size_t max)     { maxpacksize = max; }

 /** Returns the maximum allowed packet size (default is 1400 bytes). */
 /************************************************************************/
 /* 返回允许的最大的packet size, 默认为1400字节                         */
 /************************************************************************/
 size_t GetMaximumPacketSize() const     { return maxpacksize; }

 /** If the argument is \c true, the session should accept its own packets and store
  *  them accordingly in the source table.
  */
 /************************************************************************/
 /* 如果变量值为 \c true,session将接受自己的packets并相应地将它们存储在 */
 /* 源表中                */
 /************************************************************************/
 void SetAcceptOwnPackets(bool accept)     { acceptown = accept; }
 
 /** Returns \c true if the session should accept its own packets (default is \c false). */
 /************************************************************************/
 /* 如果session要接受自己的packets,则返回 \c true(缺省为 \c false)    */
 /************************************************************************/
 bool AcceptOwnPackets() const      { return acceptown; }

 /** Sets the receive mode to be used by the session. */
 /************************************************************************/
 /* 设置session将使用的接收模式                                          */
 /************************************************************************/
 void SetReceiveMode(RTPTransmitter::ReceiveMode recvmode)  { receivemode = recvmode; }

 /** Gets the receive mode to be used by the session (default is: accept all packets). */
 /************************************************************************/
 /* 获取session将使用的接收模式(缺省为: accept all packets).           */
 /************************************************************************/
 RTPTransmitter::ReceiveMode GetReceiveMode() const   { return receivemode; }

 /** Sets the timestamp unit for our own data.
  *  Sets the timestamp unit for our own data. The timestamp unit is defined as a time interval in
  *  seconds divided by the corresponding timestamp interval. For example, for 8000 Hz audio, the
  *  timestamp unit would typically be 1/8000. Since this value is initially set to an illegal value,
  *  the user must set this to an allowed value to be able to create a session.
  */
 /************************************************************************/
 /* 设置我们数据的时间戳单位。时间戳单位被定义为以秒为单位的时间间隔。例 */
 /* 如,8000Hz的音频,时间戳单位为1/8000。由于该值初始为无效值,用户必须 */
 /* 将其设置为有效值,以便能够创建一个session                            */ 
 /************************************************************************/
 void SetOwnTimestampUnit(double tsunit)     { owntsunit = tsunit; }

 /** Returns the currently set timestamp unit. */
 /************************************************************************/
 /* 返回时间戳单位                                                                     */
 /************************************************************************/
 double GetOwnTimestampUnit() const     { return owntsunit; }

 /** Sets a flag indicating if a DNS lookup should be done to determine our hostname (to construct a CNAME item).
  *  If \c v is set to \c true, the session will ask the transmitter to find a host name based upon the IP
  *  addresses in its list of local IP addresses. If set to \c false, a call to \c gethostname or something
  *  similar will be used to find the local hostname. Note that the first method might take some time.
  */
 /************************************************************************/
 /* 指明是否需要DNS lookup来确定主机名(构造一个CNAME)                  */
 /* 如果 \c v设为 \c true,session会要求transmitter查找本地IP地址列表中IP*/
 /* 相应的主机名               */
 /************************************************************************/
 void SetResolveLocalHostname(bool v)     { resolvehostname = v; }

 /** Returns whether the local hostname should be determined from the transmitter's list of local IP addresses
  *  or not (default is \c false).
  */
 /************************************************************************/
 /* 返回本地主机名是否需要由transmitter的IP地址列表中来确定,(缺省为 \c false */
 /************************************************************************/
 bool GetResolveLocalHostname() const     { return resolvehostname; }
#ifdef RTP_SUPPORT_PROBATION
 /** If probation support is enabled, this function sets the probation type to be used. */
 /************************************************************************/
 /* 如果probation suport是激活的,这个函数将设置使用的probation type     */
 /************************************************************************/
 void SetProbationType(RTPSources::ProbationType probtype)  { probationtype = probtype; }

 /** Returns the probation type which will be used (default is RTPSources::ProbationStore). */
 /************************************************************************/
 /* 返回使用的probatin类型,(缺省为RTPSource::ProbationStore)          */
 /************************************************************************/
 RTPSources::ProbationType GetProbationType() const   { return probationtype; }
#endif // RTP_SUPPORT_PROBATION

 /** Sets the session bandwidth in bytes per second. */
 /************************************************************************/
 /* 设置session的带宽,单位是字节每秒                                    */
 /************************************************************************/
 void SetSessionBandwidth(double sessbw)     { sessionbandwidth = sessbw; }

 /** Returns the session bandwidth in bytes per second (default is 10000 bytes per second). */
 /************************************************************************/
 /* 返回session的带宽,单位是字节每秒(缺省为10000字节每秒)             */
 /************************************************************************/
 double GetSessionBandwidth() const     { return sessionbandwidth; }

 /** Sets the fraction of the session bandwidth to be used for control traffic. */
 /************************************************************************/
 /* 设置用来控制通信的fraction的session的带宽                            */
 /************************************************************************/
 void SetControlTrafficFraction(double frac)    { controlfrac = frac; }

 /** Returns the fraction of the session bandwidth that will be used for control traffic (default is 5%). */
 /************************************************************************/
 /* 返回用来控制通信的fraction的session的带宽(缺省为5%)                */
 /************************************************************************/
 double GetControlTrafficFraction() const    { return controlfrac; }

 /** Sets the minimum fraction of the control traffic that will be used by senders. */
 /************************************************************************/
 /* 设置最小用于通信的fraction,这将用于发送者                           */
 /************************************************************************/
 void SetSenderControlBandwidthFraction(double frac)   { senderfrac = frac; }

 /** Returns the minimum fraction of the control traffic that will be used by senders (default is 25%). */
 /************************************************************************/
 /* 返回用于发送的最小的控制通信的fraction,(缺省为25%)                */
 /************************************************************************/
 double GetSenderControlBandwidthFraction() const   { return senderfrac; }

 /** Set the minimal time interval between sending RTCP packets. */
 /************************************************************************/
 /* 设置发送rtcp packets的最小时间间隔                                   */
 /************************************************************************/
 void SetMinimumRTCPTransmissionInterval(const RTPTime &t)  { mininterval = t; }

 /** Returns the minimal time interval between sending RTCP packets (default is 5 seconds). */
 /************************************************************************/
 /* 返回发送rtcp packets的最小时间间隔,(缺省为5秒)                    */
 /************************************************************************/
 RTPTime GetMinimumRTCPTransmissionInterval() const   { return mininterval; }

 /** If \c usehalf is set to \c true, the session will only wait half of the calculated RTCP
  *  interval before sending its first RTCP packet.
  */
 /************************************************************************/
 /* 如果 \c usehalf设为 \c true,session将在发送第一个RTCP packet之前,只*/
 /* 等待一半计算出的RTCP时间间隔                                         */
 /************************************************************************/
 void SetUseHalfRTCPIntervalAtStartup(bool usehalf)   { usehalfatstartup = usehalf; }

 /** Returns whether the session will only wait half of the calculated RTCP interval before sending its
  *  first RTCP packet or not (default is \c true).
  */
 /************************************************************************/
 /* 返回session在发送第一个RTCP packet之前,是否只等待一半计算出的RTCP时间间隔*/
 /************************************************************************/
 bool GetUseHalfRTCPIntervalAtStartup() const    { return usehalfatstartup; }

 /** If \c v is \c true, the session will send a BYE packet immediately if this is allowed. */
 /************************************************************************/
 /* 如果 \c v为 \c trur,session会立即发送一个BYE packet(如果允许)     */
 /************************************************************************/
 void SetRequestImmediateBYE(bool v)      { immediatebye = v; }

 /** Returns whether the session should send a BYE packet immediately (if allowed) or not (default is \c true). */
 /************************************************************************/
 /* 返回session是否需要立即发送一个BYE packet(如果允许)(缺省为 \c true)*/
 /************************************************************************/
 bool GetRequestImmediateBYE() const     { return immediatebye; }

 /** When sending a BYE packet, this indicates whether it will be part of an RTCP compound packet
  *  that begins with a sender report (if allowed) or a receiver report.
  */
 /************************************************************************/
 /* 当发送BYE packet的时候,此处表明这将成为RTCP compound packet的一部分 */
 /* 这里提到的RTCP compound packet以一个发送报告(如果允许)或接收报告开始*/
 /************************************************************************/
 void SetSenderReportForBYE(bool v)     { SR_BYE = v; }

 /** Returns \c true if a BYE packet will be sent in an RTCP compound packet which starts with a
  *  sender report; if a receiver report will be used, the function returns \c false (default is \c true).
  */
 /************************************************************************/
 /* 返回 \c true,如果一个BYE packet在一个RTCP compound packet中发送,此 */
 /* RTCP compound packet以一个发送报告开始。如果用接收报告,此函数返回 \c false */
 /* (缺省)为 \c true             */
 /************************************************************************/
 bool GetSenderReportForBYE() const     { return SR_BYE; }
 
 /** Sets the multiplier to be used when timing out senders. */
 /************************************************************************/
 /* 设置中止发送者时使用的multiplier                                   */
 /************************************************************************/
 void SetSenderTimeoutMultiplier(double m)    { sendermultiplier = m; }

 /** Returns the multiplier to be used when timing out senders (default is 2). */
 /************************************************************************/
 /* 返回中止发送者时使用的multiplier(缺省为2)                          */
 /************************************************************************/
 double GetSenderTimeoutMultiplier() const    { return sendermultiplier; }

 /** Sets the multiplier to be used when timing out members. */
 /************************************************************************/
 /* 设置中止成员时使用的multiplier                                    */
 /************************************************************************/
 void SetSourceTimeoutMultiplier(double m)    { generaltimeoutmultiplier = m; }

 /** Returns the multiplier to be used when timing out members (default is 5). */
 /************************************************************************/
 /* 返回中止成员时使用的multiplier(缺省为5)                           */
 /************************************************************************/
 double GetSourceTimeoutMultiplier() const    { return generaltimeoutmultiplier; }

 /** Sets the multiplier to be used when timing out a member after it has sent a BYE packet. */
 /************************************************************************/
 /* 设置在发送BYE packet后,中止成员时使用的multiplier                   */
 /************************************************************************/
 void SetBYETimeoutMultiplier(double m)     { byetimeoutmultiplier = m; }

 /** Returns the multiplier to be used when timing out a member after it has sent a BYE packet (default is 1). */
 /************************************************************************/
 /* 返回在发送BYE packet后,中止成员时使用的multiplier(缺省为1)        */
 /************************************************************************/
 double GetBYETimeoutMultiplier() const     { return byetimeoutmultiplier; }

 /** Sets the multiplier to be used when timing out entries in the collision table. */
 /************************************************************************/
 /* 设置中止collision表中入口时使用的multiplier                          */
 /************************************************************************/
 void SetCollisionTimeoutMultiplier(double m)    { collisionmultiplier = m; }

 /** Returns the multiplier to be used when timing out entries in the collision table (default is 10). */
 /************************************************************************/
 /* 返回中止collision表中入口时使用的multiplier,(缺省为10)            */
 /************************************************************************/
 double GetCollisionTimeoutMultiplier() const    { return collisionmultiplier; }

 /** Sets the multiplier to be used when timing out SDES NOTE information. */
 /************************************************************************/
 /* 设置中止SDES NOTE信息时使用的multiplier                              */
 /************************************************************************/
 void SetNoteTimeoutMultiplier(double m)     { notemultiplier = m; }

 /** Returns the multiplier to be used when timing out SDES NOTE information (default is 25). */
 /************************************************************************/
 /* 返回中止SDES NOTE信息时使用的multiplier,(缺省为25)                */
 /************************************************************************/
 double GetNoteTimeoutMultiplier() const     { return notemultiplier; }

to be continued...

阅读(3273) | 评论(1) | 转发(0) |
0

上一篇:TOP

下一篇:JRTPLIB学习笔记(二)

给主人留下些什么吧!~~

chinaunix网友2009-07-16 22:10:02

陈金双?