/*
The oRTP library is an RTP (Realtime Transport Protocol - rfc3550) stack.
Copyright (C) 2001 Simon MORLAT simon.morlat@linphone.org
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "ortp/ortp.h"
#include "ortp/telephonyevents.h"
#include "rtpmod.h"
#include "jitterctl.h"
#include "scheduler.h"
#include "utils.h"
#include "ortp-config.h"
#include <WinDef.h>
#ifdef _WIN32
extern inet_aton (const char * cp, struct in_addr * addr);
#endif
#if defined(HAVE_POLL_H)
#include <poll.h>
#elif defined(HAVE_SYS_POLL_H)
#include <sys/poll.h>
#endif
#ifdef HAVE_SYS_UIO_H
#include <sys/uio.h>
#define USE_SENDMSG 1
#endif
#define ORTP_VERSION 0.9.1
/* this function initialize all session parameter's that depend on the payload type */
static void payload_type_changed(RtpSession *session, PayloadType *pt){
jitter_control_set_payload(&session->rtp.jittctl,pt);
session->rtp.rtcp_report_snt_interval=RTCP_DEFAULT_REPORT_INTERVAL*pt->clock_rate;
rtp_session_set_time_jump_limit(session,session->rtp.time_jump);
}
void wait_point_init(WaitPoint *wp){
ortp_mutex_init(&wp->lock,NULL);
ortp_cond_init(&wp->cond,NULL);
wp->time=0;
wp->wakeup=FALSE;
}
void wait_point_uninit(WaitPoint *wp){
ortp_cond_destroy(&wp->cond);
ortp_mutex_destroy(&wp->lock);
}
#define wait_point_lock(wp) ortp_mutex_lock(&(wp)->lock)
#define wait_point_unlock(wp) ortp_mutex_unlock(&(wp)->lock)
void wait_point_wakeup_at(WaitPoint *wp, uint32_t t, bool_t dosleep){
wp->time=t;
wp->wakeup=TRUE;
if (dosleep) ortp_cond_wait(&wp->cond,&wp->lock);
}
bool_t wait_point_check(WaitPoint *wp, uint32_t t){
bool_t ok=FALSE;
if (wp->wakeup){
if (TIME_IS_NEWER_THAN(t,wp->time)){
wp->wakeup=FALSE;
ok=TRUE;
}
}
return ok;
}
#define wait_point_wakeup(wp) ortp_cond_signal(&(wp)->cond);
extern void rtp_parse(RtpSession *session, mblk_t *mp, uint32_t local_str_ts);
static uint32_t uint32_t_random(){
return random();
}
void
rtp_session_init (RtpSession * session, int mode)
{
memset (session, 0, sizeof (RtpSession));
ortp_mutex_init(&session->lock,NULL);
session->rtp.max_rq_size = 100;/* maximum number of packet allowed to be queued */
session->mode = (RtpSessionMode) mode;
if ((mode == RTP_SESSION_RECVONLY) || (mode == RTP_SESSION_SENDRECV))
{
rtp_session_set_flag (session, RTP_SESSION_RECV_SYNC);
rtp_session_set_flag (session, RTP_SESSION_RECV_NOT_STARTED);
}
if ((mode == RTP_SESSION_SENDONLY) || (mode == RTP_SESSION_SENDRECV))
{
rtp_session_set_flag (session, RTP_SESSION_SEND_NOT_STARTED);
rtp_session_set_flag (session, RTP_SESSION_SEND_SYNC);
session->send_ssrc=uint32_t_random();
/* set default source description */
rtp_session_set_source_description(session,"unknown@unknown",NULL,NULL,
NULL,NULL,"oRTP-0.9.1","This is free sofware (LGPL) !");
}
session->telephone_events_pt=-1; /* not defined a priori */
rtp_session_set_profile (session, &av_profile); /*the default profile to work with */
session->rtp.socket=-1;
session->rtcp.socket=-1;
qinit(&session->rtp.rq);
qinit(&session->rtp.tev_rq);
qinit(&session->contributing_sources);
/* init signal tables */
rtp_signal_table_init (&session->on_ssrc_changed, session,"ssrc_changed");
rtp_signal_table_init (&session->on_payload_type_changed, session,"payload_type_changed");
rtp_signal_table_init (&session->on_telephone_event, session,"telephone-event");
rtp_signal_table_init (&session->on_telephone_event_packet, session,"telephone-event_packet");
rtp_signal_table_init (&session->on_timestamp_jump,session,"timestamp_jump");
rtp_signal_table_init (&session->on_network_error,session,"network_error");
rtp_signal_table_init (&session->on_rtcp_bye,session,"rtcp_bye");
wait_point_init(&session->send_wp);
wait_point_init(&session->recv_wp);
/*defaults send payload type to 0 (pcmu)*/
rtp_session_set_send_payload_type(session,0);
/*sets supposed recv payload type to undefined */
rtp_session_set_recv_payload_type(session,-1);
rtp_session_set_jitter_compensation(session,RTP_DEFAULT_JITTER_TIME);
rtp_session_enable_adaptive_jitter_compensation(session,FALSE);
rtp_session_set_time_jump_limit(session,5000);
session->recv_buf_size = UDP_MAX_SIZE;
}
/**
*rtp_session_new:
*@mode: One of the #RtpSessionMode flags.
*
* Creates a new rtp session.
* If the session is able to send data (RTP_SESSION_SENDONLY or RTP_SESSION_SENDRECV), then a
* random SSRC number is choosed for the outgoing stream.
*
*Returns: the newly created rtp session.
**/
RtpSession *
rtp_session_new (int mode)
{
RtpSession *session;
session = (RtpSession *) ortp_malloc (sizeof (RtpSession));
rtp_session_init (session, mode);
return session;
}
/**
*rtp_session_set_scheduling_mode:
*@session: a rtp session.
*@yesno: a boolean to indicate the scheduling mode.
*
* Sets the scheduling mode of the rtp session. If @yesno is TRUE, the rtp session is in
* the scheduled mode, that means that you can use session_set_select() to block until it's time
* to receive or send on this session according to the timestamp passed to the respective functions.
* You can also use blocking mode (see rtp_session_set_blocking_mode() ), to simply block within
* the receive and send functions.
* If @yesno is FALSE, the ortp scheduler will not manage those sessions, meaning that blocking mode
* and the use of session_set_select() for this session are disabled.
*
**/
void
rtp_session_set_scheduling_mode (RtpSession * session, int yesno)
{
if (yesno)
{
RtpScheduler *sched;
sched = ortp_get_scheduler ();
if (sched != NULL)
{
rtp_session_set_flag (session, RTP_SESSION_SCHEDULED);
session->sched = sched;
rtp_scheduler_add_session (sched, session);
}
else
ortp_warning
("rtp_session_set_scheduling_mode: Cannot use scheduled mode because the "
"scheduler is not started. Use ortp_scheduler_init() before.");
}
else
rtp_session_unset_flag (session, RTP_SESSION_SCHEDULED);
}
/**
*rtp_session_set_blocking_mode:
*@session: a rtp session
*@yesno: a boolean
*
* Using this function implies that you previously enabled scheduled mode on the session
* (see rtp_session_set_scheduling_mode() ).
* rtp_session_set_blocking_mode() defines the behaviour of the rtp_session_recv_with_ts() and
* rtp_session_send_with_ts() functions. If @yesno is TRUE, rtp_session_recv_with_ts()
* will block until it is time for the packet to be received, according to the timestamp
* passed to the function. After this time, the function returns.
* For rtp_session_send_with_ts(), it will block until it is time for the packet to be sent.
* If @yesno is FALSE, then the two functions will return immediately.
*
**/
void
rtp_session_set_blocking_mode (RtpSession * session, int yesno)
{
if (yesno)
rtp_session_set_flag (session, RTP_SESSION_BLOCKING_MODE);
else
rtp_session_unset_flag (session, RTP_SESSION_BLOCKING_MODE);
}
/**
*rtp_session_set_profile:
*@session: a rtp session
*@profile: a rtp profile
*
* Set the RTP profile to be used for the session. By default, all session are created by
* rtp_session_new() are
没有合适的资源?快使用搜索试试~ 我知道了~
ortplib
共77个文件
c:19个
h:19个
obj:19个
4星 · 超过85%的资源 需积分: 0 81 下载量 163 浏览量
2008-07-19
19:03:17
上传
评论
收藏 4.03MB RAR 举报
温馨提示
<br>我参考了《如何在windows下编译ortp!(原创)》<br> 文章他本人是在ortp-0.9.1,VC6.0,Windows XP条件下进行编译的。<br><br>而我的编译条件是:ortp-0.13.0 ,VS 2005 ,Windows XP<br> 相对他的来说比较实用一些。(我非常感谢和欣赏他)<br>
资源推荐
资源详情
资源评论
收起资源包目录
ortplib.rar (77个子文件)
ortp
ortp
ortp
ortp.vcproj.53F188B5865340C.Administrator.user 1KB
Debug
ortp.dll.embed.manifest 403B
scheduler.obj 32KB
payloadtype.obj 36KB
rtpsession_ext.obj 19KB
vc80.pdb 84KB
telephonyevents.obj 30KB
port.obj 34KB
ortp.obj 38KB
BuildLog.htm 15KB
rtcpparse.obj 24KB
rtptimer.obj 19KB
rtcp.obj 38KB
rtpsignaltable.obj 22KB
mt.dep 67B
posixtimer.obj 23KB
ortp.dll.intermediate.manifest 385B
jitterctl.obj 27KB
str_utils.obj 34KB
utils.obj 19KB
vc80.idb 275KB
ortp.dll.embed.manifest.res 468B
avprofile.obj 23KB
rtpparse.obj 23KB
rtpsession.obj 94KB
rtpmod.obj 19KB
sessionset.obj 22KB
ortp.vcproj 5KB
sessionset.c 5KB
ortp.suo 14KB
rtptimer.h 1KB
rtcp.c 10KB
rtpsession_ext.c 2KB
ortp-config.h 7KB
utils.c 2KB
rtpsession.c 62KB
rtpparse.c 5KB
telephonyevents.c 10KB
rtptimer.c 1KB
utils.h 2KB
rtpsignaltable.c 2KB
ortp.ncb 12.4MB
rtpmod.c 4KB
ortp.sln 877B
rtpmod.h 1KB
glib.h 98KB
ortp.c 7KB
jitterctl.h 2KB
scheduler.h 2KB
posixtimer.c 4KB
port.c 5KB
jitterctl.c 5KB
payloadtype.c 7KB
scheduler.c 7KB
str_utils.c 6KB
ortp-config-win32.h 1KB
avprofile.c 7KB
rtcpparse.c 8KB
debug
ortp.dll 104KB
ortp.ilk 480KB
ortp.lib 599KB
ortp.pdb 627KB
glibconfig.h 4KB
include
ortp
rtpsession.h 12KB
port.h 5KB
ortp.h 3KB
str_utils.h 3KB
rtcp.h 4KB
payloadtype.h 5KB
telephonyevents.h 3KB
Makefile.in 12KB
sessionset.h 3KB
rtp.h 3KB
rtpsignaltable.h 2KB
Makefile.am 226B
Makefile.in 14KB
Makefile.am 13B
共 77 条
- 1
资源评论
- zhouweibin20122012-06-26资源不错,可以使用
- hero952014-05-27已经用在项目上了,源码 架构真是没得说的!
- cosoco2012-04-02VC6上用不到
hulihany
- 粉丝: 1
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功