[asterisk-commits] file: branch file/rtp_engine r129143 - in /team/file/rtp_engine: channels/ in...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jul 8 15:26:43 CDT 2008
Author: file
Date: Tue Jul 8 15:26:42 2008
New Revision: 129143
URL: http://svn.digium.com/view/asterisk?view=rev&rev=129143
Log:
Some work stuff, close to having chan_sip basically converted minus stats.
Modified:
team/file/rtp_engine/channels/chan_sip.c
team/file/rtp_engine/include/asterisk/rtp_engine.h
team/file/rtp_engine/main/rtp_engine.c
Modified: team/file/rtp_engine/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/file/rtp_engine/channels/chan_sip.c?view=diff&rev=129143&r1=129142&r2=129143
==============================================================================
--- team/file/rtp_engine/channels/chan_sip.c (original)
+++ team/file/rtp_engine/channels/chan_sip.c Tue Jul 8 15:26:42 2008
@@ -5117,7 +5117,7 @@
ast_set_flag(&p->flags[0], SIP_PROGRESS_SENT);
}
p->lastrtptx = time(NULL);
-// res = ast_rtp_write(p->trtp, frame);
+ res = ast_rtp_instance_write(p->trtp, frame);
}
}
sip_pvt_unlock(p);
@@ -5480,15 +5480,15 @@
/* Set file descriptors for audio, video, realtime text and UDPTL as needed */
if (i->rtp) {
- ast_channel_set_fd(tmp, 0, ast_rtp_fd(i->rtp));
- ast_channel_set_fd(tmp, 1, ast_rtcp_fd(i->rtp));
+ ast_channel_set_fd(tmp, 0, ast_rtp_instance_fd(i->rtp, 0));
+ ast_channel_set_fd(tmp, 1, ast_rtp_instance_fd(i->rtp, 1));
}
if (needvideo && i->vrtp) {
- ast_channel_set_fd(tmp, 2, ast_rtp_fd(i->vrtp));
- ast_channel_set_fd(tmp, 3, ast_rtcp_fd(i->vrtp));
+ ast_channel_set_fd(tmp, 2, ast_rtp_instance_fd(i->vrtp, 0));
+ ast_channel_set_fd(tmp, 3, ast_rtp_instance_fd(i->vrtp, 1));
}
if (needtext && i->trtp)
- ast_channel_set_fd(tmp, 4, ast_rtp_fd(i->trtp));
+ ast_channel_set_fd(tmp, 4, ast_rtp_instance_fd(i->trtp, 0));
if (i->udptl)
ast_channel_set_fd(tmp, 5, ast_udptl_fd(i->udptl));
@@ -5713,19 +5713,19 @@
switch(ast->fdno) {
case 0:
- f = ast_rtp_read(p->rtp); /* RTP Audio */
+ f = ast_rtp_instance_read(p->rtp, 0); /* RTP Audio */
break;
case 1:
- f = ast_rtcp_read(p->rtp); /* RTCP Control Channel */
+ f = ast_rtp_instance_read(p->rtp, 1); /* RTCP Control Channel */
break;
case 2:
- f = ast_rtp_read(p->vrtp); /* RTP Video */
+ f = ast_rtp_instance_read(p->vrtp, 0); /* RTP Video */
break;
case 3:
- f = ast_rtcp_read(p->vrtp); /* RTCP Control Channel for video */
+ f = ast_rtp_instance_read(p->vrtp, 1); /* RTCP Control Channel for video */
break;
case 4:
- f = ast_rtp_read(p->trtp); /* RTP Text */
+ f = ast_rtp_instance_read(p->trtp, 0); /* RTP Text */
if (sipdebug_text) {
int i;
unsigned char* arr = f->data.ptr;
@@ -6744,10 +6744,8 @@
if (udptlportno > 0) {
sin.sin_port = htons(udptlportno);
if (ast_test_flag(&p->flags[0], SIP_NAT) && ast_test_flag(&p->flags[1], SIP_PAGE2_UDPTL_DESTINATION)) {
- struct sockaddr_in peer;
- ast_rtp_get_peer(p->rtp, &peer);
- if (peer.sin_addr.s_addr) {
- memcpy(&sin.sin_addr, &peer.sin_addr, sizeof(&sin.sin_addr));
+ if (p->rtp->remote_address.sin_addr.s_addr) {
+ memcpy(&sin.sin_addr, &p->rtp->remote_address.sin_addr, sizeof(&sin.sin_addr));
if (debug) {
ast_log(LOG_DEBUG, "Peer T.38 UDPTL is set behind NAT and with destination, destination address now %s\n", ast_inet_ntoa(sin.sin_addr));
}
@@ -6767,7 +6765,7 @@
if (p->rtp) {
if (portno > 0) {
sin.sin_port = htons(portno);
- ast_rtp_set_peer(p->rtp, &sin);
+ ast_rtp_instance_set_remote_address(p->rtp, &sin);
if (debug)
ast_verbose("Peer audio RTP is at port %s:%d\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
} else {
@@ -6775,7 +6773,7 @@
if (debug)
ast_verbose("Got T.38 Re-invite without audio. Keeping RTP active during T.38 session. Callid %s\n", p->callid);
} else {
- ast_rtp_stop(p->rtp);
+ ast_rtp_instance_stop(p->rtp);
if (debug)
ast_verbose("Peer doesn't provide audio. Callid %s\n", p->callid);
}
@@ -7047,9 +7045,9 @@
}
/* Now gather all of the codecs that we are asked for: */
- ast_rtp_get_current_formats(newaudiortp, &peercapability, &peernoncodeccapability);
- ast_rtp_get_current_formats(newvideortp, &vpeercapability, &vpeernoncodeccapability);
- ast_rtp_get_current_formats(newtextrtp, &tpeercapability, &tpeernoncodeccapability);
+ ast_rtp_codecs_payload_formats(&newaudiortp, &peercapability, &peernoncodeccapability);
+ ast_rtp_codecs_payload_formats(&newvideortp, &vpeercapability, &vpeernoncodeccapability);
+ ast_rtp_codecs_payload_formats(&newtextrtp, &tpeercapability, &tpeernoncodeccapability);
newjointcapability = p->capability & (peercapability | vpeercapability | tpeercapability);
newpeercapability = (peercapability | vpeercapability | tpeercapability);
@@ -7115,21 +7113,21 @@
/* Setup audio port number */
if (p->rtp && sin.sin_port) {
- ast_rtp_set_peer(p->rtp, &sin);
+ ast_rtp_instance_set_remote_address(p->rtp, &sin);
if (debug)
ast_verbose("Peer audio RTP is at port %s:%d\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
}
/* Setup video port number */
if (p->vrtp && vsin.sin_port) {
- ast_rtp_set_peer(p->vrtp, &vsin);
+ ast_rtp_instance_set_remote_address(p->vrtp, &vsin);
if (debug)
ast_verbose("Peer video RTP is at port %s:%d\n", ast_inet_ntoa(vsin.sin_addr), ntohs(vsin.sin_port));
}
/* Setup text port number */
if (p->trtp && tsin.sin_port) {
- ast_rtp_set_peer(p->trtp, &tsin);
+ ast_rtp_instance_set_remote_address(p->trtp, &tsin);
if (debug)
ast_verbose("Peer text RTP is at port %s:%d\n", ast_inet_ntoa(tsin.sin_addr), ntohs(tsin.sin_port));
}
@@ -7176,7 +7174,7 @@
S_OR(p->mohsuggest, NULL),
!ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
if (sendonly)
- ast_rtp_stop(p->rtp);
+ ast_rtp_instance_stop(p->rtp);
/* RTCP needs to go ahead, even if we're on hold!!! */
/* Activate a re-invite */
ast_queue_frame(p->owner, &ast_null_frame);
@@ -15126,9 +15124,12 @@
if (bridgepvt->udptl) {
if (p->t38.state == T38_ENABLED && bridgepvt->t38.state == T38_PEER_REINVITE) {
sip_handle_t38_reinvite(bridgepeer, p, 0);
- ast_rtp_set_rtptimers_onhold(p->rtp);
- if (p->vrtp)
- ast_rtp_set_rtptimers_onhold(p->vrtp); /* Turn off RTP timers while we send fax */
+ p->rtp->timeout = 0;
+ p->rtp->holdtimeout = 0;
+ if (p->vrtp) {
+ p->vrtp->timeout = 0;
+ p->vrtp->holdtimeout = 0;
+ }
} else if (p->t38.state == T38_DISABLED && bridgepvt->t38.state == T38_ENABLED) {
ast_log(LOG_WARNING, "RTP re-invite after T38 session not handled yet !\n");
/* Insted of this we should somehow re-invite the other side of the bridge to RTP */
@@ -15639,11 +15640,11 @@
{
/* Immediately stop RTP, VRTP and UDPTL as applicable */
if (p->rtp)
- ast_rtp_stop(p->rtp);
+ ast_rtp_instance_stop(p->rtp);
if (p->vrtp)
- ast_rtp_stop(p->vrtp);
+ ast_rtp_instance_stop(p->vrtp);
if (p->trtp)
- ast_rtp_stop(p->trtp);
+ ast_rtp_instance_stop(p->trtp);
if (p->udptl)
ast_udptl_stop(p->udptl);
}
@@ -17844,11 +17845,11 @@
args.type = "audio";
if (!strcasecmp(args.type, "audio"))
- ast_rtp_get_peer(p->rtp, &sin);
+ memcpy(&sin, &p->rtp->remote_address, sizeof(sin));
else if (!strcasecmp(args.type, "video"))
- ast_rtp_get_peer(p->vrtp, &sin);
+ memcpy(&sin, &p->vrtp->remote_address, sizeof(sin));
else if (!strcasecmp(args.type, "text"))
- ast_rtp_get_peer(p->trtp, &sin);
+ memcpy(&sin, &p->trtp->remote_address, sizeof(sin));
else
return -1;
@@ -19045,11 +19046,7 @@
/* Check AUDIO RTP timers */
if (dialog->lastrtprx && (dialog->rtp->timeout || dialog->rtp->holdtimeout) && (t > dialog->lastrtprx + dialog->rtp->timeout)) {
-
- /* Might be a timeout now -- see if we're on hold */
- struct sockaddr_in sin;
- ast_rtp_get_peer(dialog->rtp, &sin);
- if (sin.sin_addr.s_addr || (dialog->rtp->holdtimeout && (t > dialog->lastrtprx + dialog->rtp->holdtimeout))) {
+ if (dialog->rtp->remote_address.sin_addr.s_addr || (dialog->rtp->holdtimeout && (t > dialog->lastrtprx + dialog->rtp->holdtimeout))) {
/* Needs a hangup */
if (dialog->rtp->timeout) {
while (dialog->owner && ast_channel_trylock(dialog->owner)) {
Modified: team/file/rtp_engine/include/asterisk/rtp_engine.h
URL: http://svn.digium.com/view/asterisk/team/file/rtp_engine/include/asterisk/rtp_engine.h?view=diff&rev=129143&r1=129142&r2=129143
==============================================================================
--- team/file/rtp_engine/include/asterisk/rtp_engine.h (original)
+++ team/file/rtp_engine/include/asterisk/rtp_engine.h Tue Jul 8 15:26:42 2008
@@ -86,7 +86,8 @@
void (*packetization_set)(struct ast_rtp_instance *instance, struct ast_codec_pref *pref); /*!< Callback for setting codec packetization preferences */
int (*get_stats)(struct ast_rtp_instance *instance, struct ast_rtp_instance_stats *stats); /*!< Callback for retrieving statistics about the session */
int (*qos)(struct ast_rtp_instance *instance, int tos, int cos, const char *desc); /*!< Callback for setting QoS parameters on the RTP session */
- struct ast_frame *(*read)(struct ast_rtp_instance *instance); /*!< Callback for reading a frame in */
+ int (*fd)(struct ast_rtp_instance *instance, int rtcp); /*!< Callback for retrieving a file descriptor for RTP or RTCP */
+ struct ast_frame *(*read)(struct ast_rtp_instance *instance, int rtcp); /*!< Callback for reading a frame in */
enum ast_bridge_result (*bridge)(struct ast_rtp_instance *instance0, struct ast_rtp_instance *instance1); /*!< Callback for bridging two RTP instances together */
AST_RWLIST_ENTRY(ast_rtp_engine) entry; /*!< Linked list information */
};
@@ -166,11 +167,12 @@
/*! \brief Receive a frame over RTP
*
* \param instance The RTP instance to receive frame on
+ * \param rtcp Whether to read in RTCP or not
*
* \retval non-NULL success
* \retval NULL failure
*/
-struct ast_frame *ast_rtp_instance_read(struct ast_rtp_instance *instance);
+struct ast_frame *ast_rtp_instance_read(struct ast_rtp_instance *instance, int rtcp);
/*! \brief Set the address of the remote endpoint that we are sending RTP to
*
@@ -254,6 +256,9 @@
/*! \brief Stop an RTP instance */
void ast_rtp_instance_stop(struct ast_rtp_instance *instance);
+/*! \brief Get the file descriptor for an RTP session (or RTCP) */
+int ast_rtp_instance_fd(struct ast_rtp_instance *instance, int rtcp);
+
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
Modified: team/file/rtp_engine/main/rtp_engine.c
URL: http://svn.digium.com/view/asterisk/team/file/rtp_engine/main/rtp_engine.c?view=diff&rev=129143&r1=129142&r2=129143
==============================================================================
--- team/file/rtp_engine/main/rtp_engine.c (original)
+++ team/file/rtp_engine/main/rtp_engine.c Tue Jul 8 15:26:42 2008
@@ -248,9 +248,9 @@
return instance->engine->write(instance, frame);
}
-struct ast_frame *ast_rtp_instance_read(struct ast_rtp_instance *instance)
-{
- return instance->engine->read(instance);
+struct ast_frame *ast_rtp_instance_read(struct ast_rtp_instance *instance, int rtcp)
+{
+ return instance->engine->read(instance, rtcp);
}
int ast_rtp_instance_set_remote_address(struct ast_rtp_instance *instance, struct sockaddr_in *address)
@@ -521,3 +521,8 @@
return;
}
+
+int ast_rtp_instance_fd(struct ast_rtp_instance *instance, int rtcp)
+{
+ return instance->engine->fd ? instance->engine->fd(instance, rtcp) : -1;
+}
More information about the asterisk-commits
mailing list