提交 4dda1b7b authored 作者: Anthony Minessale's avatar Anthony Minessale

update

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1108 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 e28a9ee8
......@@ -202,22 +202,23 @@ SWITCH_DECLARE(void) switch_rtp_set_invald_handler(switch_rtp *rtp_session, swit
\brief Read data from a given RTP session
\param rtp_session the RTP session to read from
\param data the data to read
\param datalen the length of the data
\param datalen a pointer to the datalen
\param payload_type the IANA payload of the packet
\param flags flags
\return the number of bytes read
*/
SWITCH_DECLARE(int) switch_rtp_read(switch_rtp *rtp_session, void *data, uint32_t datalen, int *payload_type, switch_frame_flag *flags);
SWITCH_DECLARE(switch_status) switch_rtp_read(switch_rtp *rtp_session, void *data, uint32_t *datalen, int *payload_type, switch_frame_flag *flags);
/*!
\brief Read data from a given RTP session without copying
\param rtp_session the RTP session to read from
\param data a pointer to point directly to the RTP read buffer
\param datalen a pointer to the datalen
\param payload_type the IANA payload of the packet
\param flags flags
\return the number of bytes read
*/
SWITCH_DECLARE(int) switch_rtp_zerocopy_read(switch_rtp *rtp_session, void **data, int *payload_type, switch_frame_flag *flags);
SWITCH_DECLARE(switch_status) switch_rtp_zerocopy_read(switch_rtp *rtp_session, void **data, uint32_t *datalen, int *payload_type, switch_frame_flag *flags);
/*!
\brief Write data to a given RTP session
......
......@@ -573,8 +573,15 @@ static switch_status channel_read_frame(switch_core_session *session, switch_fra
while (!switch_test_flag(tech_pvt, TFLAG_BYE) && switch_test_flag(tech_pvt, TFLAG_IO) && tech_pvt->read_frame.datalen == 0) {
payload = -1;
tech_pvt->read_frame.flags = 0;
tech_pvt->read_frame.datalen = switch_rtp_zerocopy_read(tech_pvt->rtp_session, &tech_pvt->read_frame.data, &payload, &tech_pvt->read_frame.flags);
if (switch_rtp_zerocopy_read(tech_pvt->rtp_session,
&tech_pvt->read_frame.data,
&tech_pvt->read_frame.datalen,
&payload,
&tech_pvt->read_frame.flags) != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_FALSE;
}
/* RFC2833 ... TBD try harder to honor the duration etc.*/
if (payload == 101) {
......
......@@ -584,9 +584,12 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram
&& tech_pvt->read_frame.datalen == 0) {
now = switch_time_now();
tech_pvt->read_frame.flags = 0;
tech_pvt->read_frame.datalen = switch_rtp_zerocopy_read(tech_pvt->rtp_session, &tech_pvt->read_frame.data, &payload, &tech_pvt->read_frame.flags);
if (tech_pvt->read_frame.datalen < 0) {
if (switch_rtp_zerocopy_read(tech_pvt->rtp_session,
&tech_pvt->read_frame.data,
&tech_pvt->read_frame.datalen,
&payload,
&tech_pvt->read_frame.flags) != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_FALSE;
}
......
......@@ -534,29 +534,36 @@ static int rtp_common_read(switch_rtp *rtp_session, void *data, int *payload_typ
return (int)(bytes - rtp_header_len);
}
SWITCH_DECLARE(int) switch_rtp_read(switch_rtp *rtp_session, void *data, uint32_t datalen, int *payload_type, switch_frame_flag *flags)
SWITCH_DECLARE(switch_status) switch_rtp_read(switch_rtp *rtp_session, void *data, uint32_t *datalen, int *payload_type, switch_frame_flag *flags)
{
int bytes = rtp_common_read(rtp_session, data, payload_type, flags);
if (bytes <= 0) {
return bytes;
*datalen = 0;
return SWITCH_STATUS_GENERR;
}
*datalen = bytes;
memcpy(data, rtp_session->recv_msg.body, bytes);
return bytes;
return SWITCH_STATUS_SUCCESS;
}
SWITCH_DECLARE(int) switch_rtp_zerocopy_read(switch_rtp *rtp_session, void **data, int *payload_type, switch_frame_flag *flags)
SWITCH_DECLARE(switch_status) switch_rtp_zerocopy_read(switch_rtp *rtp_session, void **data, uint32_t *datalen, int *payload_type, switch_frame_flag *flags)
{
int bytes = rtp_common_read(rtp_session, data, payload_type, flags);
*data = rtp_session->recv_msg.body;
if (bytes <= 0) {
return bytes;
*datalen = 0;
return SWITCH_STATUS_GENERR;
}
return bytes;
*datalen = bytes;
return SWITCH_STATUS_SUCCESS;
}
static int rtp_common_write(switch_rtp *rtp_session, void *data, uint32_t datalen, uint8_t payload)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论