Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
c0891ce9
提交
c0891ce9
authored
4月 18, 2006
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
git-svn-id:
http://svn.freeswitch.org/svn/freeswitch/trunk@1186
d0543943-73ff-0310-b7d9-9358b9ac24b2
上级
1f3dedbf
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
83 行增加
和
25 行删除
+83
-25
Makefile.am
Makefile.am
+1
-1
Makefile.in
Makefile.in
+1
-1
switch_rtp.h
src/include/switch_rtp.h
+9
-0
mod_exosip.c
src/mod/endpoints/mod_exosip/mod_exosip.c
+14
-9
mod_iax.c
src/mod/endpoints/mod_iax/mod_iax.c
+20
-8
switch_ivr.c
src/switch_ivr.c
+4
-4
switch_rtp.c
src/switch_rtp.c
+34
-2
没有找到文件。
Makefile.am
浏览文件 @
c0891ce9
...
@@ -118,7 +118,7 @@ CLEANFILES = src/include/switch_version.h
...
@@ -118,7 +118,7 @@ CLEANFILES = src/include/switch_version.h
lib_LTLIBRARIES
=
libfreeswitch.la
lib_LTLIBRARIES
=
libfreeswitch.la
libfreeswitch_la_CFLAGS
=
$(AM_CFLAGS)
-Wall
-Werror
-Wstrict-prototypes
-Wmissing-prototypes
-g
libfreeswitch_la_CFLAGS
=
$(AM_CFLAGS)
-Wall
-Werror
-Wstrict-prototypes
-Wmissing-prototypes
-g
libfreeswitch_la_LDFLAGS
=
-version-info
1:0:0
libfreeswitch_la_LDFLAGS
=
-version-info
1:0:0
libfreeswitch_la_LIBADD
=
-lteletone
-lresample
-lsrtp
-lsqlite3
-ljitterbuffer
libfreeswitch_la_LIBADD
=
-lteletone
-lresample
-lsrtp
-lsqlite3
nodist_libfreeswitch_la_SOURCES
=
src/include/switch_version.h
nodist_libfreeswitch_la_SOURCES
=
src/include/switch_version.h
bin_PROGRAMS
=
freeswitch
bin_PROGRAMS
=
freeswitch
...
...
Makefile.in
浏览文件 @
c0891ce9
...
@@ -333,7 +333,7 @@ CLEANFILES = src/include/switch_version.h
...
@@ -333,7 +333,7 @@ CLEANFILES = src/include/switch_version.h
lib_LTLIBRARIES
=
libfreeswitch.la
lib_LTLIBRARIES
=
libfreeswitch.la
libfreeswitch_la_CFLAGS
=
$(AM_CFLAGS)
-Wall
-Werror
-Wstrict-prototypes
-Wmissing-prototypes
-g
libfreeswitch_la_CFLAGS
=
$(AM_CFLAGS)
-Wall
-Werror
-Wstrict-prototypes
-Wmissing-prototypes
-g
libfreeswitch_la_LDFLAGS
=
-version-info
1:0:0
libfreeswitch_la_LDFLAGS
=
-version-info
1:0:0
libfreeswitch_la_LIBADD
=
-lteletone
-lresample
-lsrtp
-lsqlite3
-ljitterbuffer
libfreeswitch_la_LIBADD
=
-lteletone
-lresample
-lsrtp
-lsqlite3
nodist_libfreeswitch_la_SOURCES
=
src/include/switch_version.h
nodist_libfreeswitch_la_SOURCES
=
src/include/switch_version.h
freeswitch_SOURCES
=
src/switch.c
\
freeswitch_SOURCES
=
src/switch.c
\
src/include/switch_version.h
src/include/switch_version.h
...
...
src/include/switch_rtp.h
浏览文件 @
c0891ce9
...
@@ -263,6 +263,15 @@ SWITCH_DECLARE(switch_status) switch_rtp_zerocopy_read_frame(switch_rtp *rtp_ses
...
@@ -263,6 +263,15 @@ SWITCH_DECLARE(switch_status) switch_rtp_zerocopy_read_frame(switch_rtp *rtp_ses
*/
*/
SWITCH_DECLARE
(
int
)
switch_rtp_write
(
switch_rtp
*
rtp_session
,
void
*
data
,
uint32_t
datalen
,
uint32_t
ts
,
switch_frame_flag
*
flags
);
SWITCH_DECLARE
(
int
)
switch_rtp_write
(
switch_rtp
*
rtp_session
,
void
*
data
,
uint32_t
datalen
,
uint32_t
ts
,
switch_frame_flag
*
flags
);
/*!
\brief Write data to a given RTP session
\param rtp_session the RTP session to write to
\param frame the frame to write
\param ts then number of bytes to increment the timestamp by
\return the number of bytes written
*/
SWITCH_DECLARE
(
int
)
switch_rtp_write_frame
(
switch_rtp
*
rtp_session
,
switch_frame
*
frame
,
uint32_t
ts
);
/*!
/*!
\brief Write data with a specified payload and sequence number to a given RTP session
\brief Write data with a specified payload and sequence number to a given RTP session
\param rtp_session the RTP session to write to
\param rtp_session the RTP session to write to
...
...
src/mod/endpoints/mod_exosip/mod_exosip.c
浏览文件 @
c0891ce9
...
@@ -503,7 +503,7 @@ static switch_status activate_rtp(struct private_object *tech_pvt)
...
@@ -503,7 +503,7 @@ static switch_status activate_rtp(struct private_object *tech_pvt)
tech_pvt
->
read_codec
.
codec_interface
->
ianacode
,
tech_pvt
->
read_codec
.
codec_interface
->
ianacode
,
tech_pvt
->
read_codec
.
implementation
->
encoded_bytes_per_frame
,
tech_pvt
->
read_codec
.
implementation
->
encoded_bytes_per_frame
,
ms
,
ms
,
0
,
SWITCH_RTP_FLAG_NOBLOCK
|
SWITCH_RTP_FLAG_RAW_WRITE
,
key
,
key
,
&
err
,
switch_core_session_get_pool
(
tech_pvt
->
session
));
&
err
,
switch_core_session_get_pool
(
tech_pvt
->
session
));
...
@@ -589,8 +589,9 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram
...
@@ -589,8 +589,9 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram
return
SWITCH_STATUS_TIMEOUT
;
return
SWITCH_STATUS_TIMEOUT
;
}
}
}
}
if
(
switch_test_flag
(
tech_pvt
,
TFLAG_IO
))
{
if
(
switch_test_flag
(
tech_pvt
,
TFLAG_IO
))
{
switch_status
status
;
if
(
!
switch_test_flag
(
tech_pvt
,
TFLAG_RTP
))
{
if
(
!
switch_test_flag
(
tech_pvt
,
TFLAG_RTP
))
{
return
SWITCH_STATUS_GENERR
;
return
SWITCH_STATUS_GENERR
;
...
@@ -600,16 +601,18 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram
...
@@ -600,16 +601,18 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram
tech_pvt
->
read_frame
.
datalen
=
0
;
tech_pvt
->
read_frame
.
datalen
=
0
;
while
(
!
switch_test_flag
(
tech_pvt
,
TFLAG_BYE
)
&&
switch_test_flag
(
tech_pvt
,
TFLAG_IO
)
while
(
!
switch_test_flag
(
tech_pvt
,
TFLAG_BYE
)
&&
switch_test_flag
(
tech_pvt
,
TFLAG_IO
)
&&
tech_pvt
->
read_frame
.
datalen
==
0
)
{
&&
tech_pvt
->
read_frame
.
datalen
==
0
)
{
now
=
switch_time_now
();
now
=
switch_time_now
();
tech_pvt
->
read_frame
.
flags
=
0
;
tech_pvt
->
read_frame
.
flags
=
0
;
if
(
switch_rtp_zerocopy_read_frame
(
tech_pvt
->
rtp_session
,
&
tech_pvt
->
read_frame
)
!=
SWITCH_STATUS_SUCCESS
)
{
status
=
switch_rtp_zerocopy_read_frame
(
tech_pvt
->
rtp_session
,
&
tech_pvt
->
read_frame
);
if
(
status
!=
SWITCH_STATUS_SUCCESS
&&
status
!=
SWITCH_STATUS_BREAK
)
{
return
SWITCH_STATUS_FALSE
;
return
SWITCH_STATUS_FALSE
;
}
}
payload
=
tech_pvt
->
read_frame
.
payload
;
payload
=
tech_pvt
->
read_frame
.
payload
;
if
(
timeout
>
-
1
)
{
if
(
timeout
>
-
1
)
{
elapsed
=
(
unsigned
int
)((
switch_time_now
()
-
started
)
/
1000
);
elapsed
=
(
unsigned
int
)((
switch_time_now
()
-
started
)
/
1000
);
if
(
elapsed
>=
(
unsigned
int
)
timeout
)
{
if
(
elapsed
>=
(
unsigned
int
)
timeout
)
{
...
@@ -732,6 +735,7 @@ static switch_status exosip_write_frame(switch_core_session *session, switch_fra
...
@@ -732,6 +735,7 @@ static switch_status exosip_write_frame(switch_core_session *session, switch_fra
for
(
x
=
0
;
x
<
loops
;
x
++
)
{
for
(
x
=
0
;
x
<
loops
;
x
++
)
{
frame
->
flags
=
0
;
switch_rtp_write_payload
(
tech_pvt
->
rtp_session
,
tech_pvt
->
out_digit_packet
,
4
,
101
,
ts
,
tech_pvt
->
out_digit_seq
,
&
frame
->
flags
);
switch_rtp_write_payload
(
tech_pvt
->
rtp_session
,
tech_pvt
->
out_digit_packet
,
4
,
101
,
ts
,
tech_pvt
->
out_digit_seq
,
&
frame
->
flags
);
printf
(
"Send %s packet for [%c] ts=%d sofar=%u dur=%d
\n
"
,
printf
(
"Send %s packet for [%c] ts=%d sofar=%u dur=%d
\n
"
,
loops
==
1
?
"middle"
:
"end"
,
loops
==
1
?
"middle"
:
"end"
,
...
@@ -759,6 +763,7 @@ static switch_status exosip_write_frame(switch_core_session *session, switch_fra
...
@@ -759,6 +763,7 @@ static switch_status exosip_write_frame(switch_core_session *session, switch_fra
ts
=
tech_pvt
->
timestamp_dtmf
+=
samples
;
ts
=
tech_pvt
->
timestamp_dtmf
+=
samples
;
tech_pvt
->
out_digit_seq
++
;
tech_pvt
->
out_digit_seq
++
;
for
(
x
=
0
;
x
<
3
;
x
++
)
{
for
(
x
=
0
;
x
<
3
;
x
++
)
{
frame
->
flags
=
0
;
switch_rtp_write_payload
(
tech_pvt
->
rtp_session
,
tech_pvt
->
out_digit_packet
,
4
,
101
,
ts
,
tech_pvt
->
out_digit_seq
,
&
frame
->
flags
);
switch_rtp_write_payload
(
tech_pvt
->
rtp_session
,
tech_pvt
->
out_digit_packet
,
4
,
101
,
ts
,
tech_pvt
->
out_digit_seq
,
&
frame
->
flags
);
printf
(
"Send start packet for [%c] ts=%d sofar=%u dur=%d
\n
"
,
tech_pvt
->
out_digit
,
ts
,
printf
(
"Send start packet for [%c] ts=%d sofar=%u dur=%d
\n
"
,
tech_pvt
->
out_digit
,
ts
,
tech_pvt
->
out_digit_sofar
,
0
);
tech_pvt
->
out_digit_sofar
,
0
);
...
@@ -770,10 +775,10 @@ static switch_status exosip_write_frame(switch_core_session *session, switch_fra
...
@@ -770,10 +775,10 @@ static switch_status exosip_write_frame(switch_core_session *session, switch_fra
//printf("%s %s->%s send %d bytes %d samples in %d frames t
aking up %d ms ts=%d\n", switch_channel_get_name(channel), tech_pvt->local_sdp_audio_ip, tech_pvt->remote_sdp_audio_ip, frame->datalen, samples, frames, m
s, tech_pvt->timestamp_send);
//printf("%s %s->%s send %d bytes %d samples in %d frames t
s=%d\n", switch_channel_get_name(channel), tech_pvt->local_sdp_audio_ip, tech_pvt->remote_sdp_audio_ip, frame->datalen, samples, frame
s, tech_pvt->timestamp_send);
switch_rtp_write_frame
(
tech_pvt
->
rtp_session
,
frame
,
samples
);
switch_rtp_write
(
tech_pvt
->
rtp_session
,
frame
->
data
,
(
int
)
frame
->
datalen
,
samples
,
&
frame
->
flags
);
tech_pvt
->
timestamp_send
+=
(
int
)
samples
;
tech_pvt
->
timestamp_send
+=
(
int
)
samples
;
switch_clear_flag
(
tech_pvt
,
TFLAG_WRITING
);
switch_clear_flag
(
tech_pvt
,
TFLAG_WRITING
);
...
...
src/mod/endpoints/mod_iax/mod_iax.c
浏览文件 @
c0891ce9
...
@@ -55,7 +55,8 @@ typedef enum {
...
@@ -55,7 +55,8 @@ typedef enum {
TFLAG_DTMF
=
(
1
<<
3
),
TFLAG_DTMF
=
(
1
<<
3
),
TFLAG_VOICE
=
(
1
<<
4
),
TFLAG_VOICE
=
(
1
<<
4
),
TFLAG_HANGUP
=
(
1
<<
5
),
TFLAG_HANGUP
=
(
1
<<
5
),
TFLAG_LINEAR
=
(
1
<<
6
)
TFLAG_LINEAR
=
(
1
<<
6
),
TFLAG_CODEC
=
(
1
<<
7
)
}
TFLAGS
;
}
TFLAGS
;
typedef
enum
{
typedef
enum
{
...
@@ -375,6 +376,7 @@ static switch_status iax_set_codec(struct private_object *tech_pvt, struct iax_s
...
@@ -375,6 +376,7 @@ static switch_status iax_set_codec(struct private_object *tech_pvt, struct iax_s
tech_pvt
->
read_frame
.
codec
=
&
tech_pvt
->
read_codec
;
tech_pvt
->
read_frame
.
codec
=
&
tech_pvt
->
read_codec
;
switch_core_session_set_read_codec
(
tech_pvt
->
session
,
&
tech_pvt
->
read_codec
);
switch_core_session_set_read_codec
(
tech_pvt
->
session
,
&
tech_pvt
->
read_codec
);
switch_core_session_set_write_codec
(
tech_pvt
->
session
,
&
tech_pvt
->
write_codec
);
switch_core_session_set_write_codec
(
tech_pvt
->
session
,
&
tech_pvt
->
write_codec
);
switch_set_flag
(
tech_pvt
,
TFLAG_CODEC
);
}
}
tech_pvt
->
codec
=
chosen
;
tech_pvt
->
codec
=
chosen
;
tech_pvt
->
codecs
=
local_cap
;
tech_pvt
->
codecs
=
local_cap
;
...
@@ -409,7 +411,7 @@ static void iax_err_cb(const char *s)
...
@@ -409,7 +411,7 @@ static void iax_err_cb(const char *s)
static
void
iax_out_cb
(
const
char
*
s
)
static
void
iax_out_cb
(
const
char
*
s
)
{
{
if
(
globals
.
debug
)
{
if
(
globals
.
debug
>
1
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG_CLEAN
,
SWITCH_LOG_DEBUG
,
"IAX INFO: %s"
,
s
);
switch_log_printf
(
SWITCH_CHANNEL_LOG_CLEAN
,
SWITCH_LOG_DEBUG
,
"IAX INFO: %s"
,
s
);
}
}
}
}
...
@@ -874,7 +876,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
...
@@ -874,7 +876,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
return
SWITCH_STATUS_TERM
;
return
SWITCH_STATUS_TERM
;
}
}
if
(
globals
.
debug
)
{
if
(
globals
.
debug
>
1
)
{
iax_enable_debug
();
iax_enable_debug
();
}
}
if
(
iax_init
(
globals
.
ip
,
globals
.
port
)
<
0
)
{
if
(
iax_init
(
globals
.
ip
,
globals
.
port
)
<
0
)
{
...
@@ -909,8 +911,9 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
...
@@ -909,8 +911,9 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
if
(
globals
.
debug
&&
iaxevent
->
etype
!=
IAX_EVENT_VOICE
)
{
if
(
globals
.
debug
&&
iaxevent
->
etype
!=
IAX_EVENT_VOICE
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Event %d [%s]!
\n
"
,
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Event %d [%s]!
\n
"
,
iaxevent
->
etype
,
IAXNAMES
[
iaxevent
->
etype
]);
iaxevent
->
etype
,
IAXNAMES
[
iaxevent
->
etype
]);
}
}
switch
(
iaxevent
->
etype
)
{
switch
(
iaxevent
->
etype
)
{
case
IAX_EVENT_REGACK
:
case
IAX_EVENT_REGACK
:
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_NOTICE
,
"Registration completed successfully.
\n
"
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_NOTICE
,
"Registration completed successfully.
\n
"
);
...
@@ -926,7 +929,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
...
@@ -926,7 +929,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
if
(
tech_pvt
)
{
if
(
tech_pvt
)
{
unsigned
int
cap
=
iax_session_get_capability
(
iaxevent
->
session
);
unsigned
int
cap
=
iax_session_get_capability
(
iaxevent
->
session
);
unsigned
int
format
=
iaxevent
->
ies
.
format
;
unsigned
int
format
=
iaxevent
->
ies
.
format
;
if
(
iax_set_codec
(
tech_pvt
,
iaxevent
->
session
,
&
format
,
&
cap
,
&
iaxevent
->
ies
.
samprate
,
IAX_SET
)
!=
if
(
iax_set_codec
(
tech_pvt
,
iaxevent
->
session
,
&
format
,
&
cap
,
&
iaxevent
->
ies
.
samprate
,
IAX_SET
)
!=
SWITCH_STATUS_SUCCESS
)
{
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"WTF? %u %u
\n
"
,
iaxevent
->
ies
.
format
,
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"WTF? %u %u
\n
"
,
iaxevent
->
ies
.
format
,
...
@@ -950,7 +953,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
...
@@ -950,7 +953,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
if
((
channel
=
switch_core_session_get_channel
(
tech_pvt
->
session
))
!=
0
)
{
if
((
channel
=
switch_core_session_get_channel
(
tech_pvt
->
session
))
!=
0
)
{
if
(
switch_channel_test_flag
(
channel
,
CF_ANSWERED
))
{
if
(
switch_channel_test_flag
(
channel
,
CF_ANSWERED
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"WTF Mutiple Answer %s?
\n
"
,
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"WTF Mutiple Answer %s?
\n
"
,
switch_channel_get_name
(
channel
));
switch_channel_get_name
(
channel
));
}
else
{
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_NOTICE
,
"Answer %s
\n
"
,
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_NOTICE
,
"Answer %s
\n
"
,
switch_channel_get_name
(
channel
));
switch_channel_get_name
(
channel
));
...
@@ -1054,8 +1057,17 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
...
@@ -1054,8 +1057,17 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
switch_channel
*
channel
;
switch_channel
*
channel
;
if
(((
channel
=
switch_core_session_get_channel
(
tech_pvt
->
session
))
!=
0
)
if
(((
channel
=
switch_core_session_get_channel
(
tech_pvt
->
session
))
!=
0
)
&&
switch_channel_get_state
(
channel
)
<=
CS_HANGUP
)
{
&&
switch_channel_get_state
(
channel
)
<=
CS_HANGUP
)
{
int
bytes
=
tech_pvt
->
read_codec
.
implementation
->
encoded_bytes_per_frame
;
int
bytes
,
frames
;
int
frames
=
(
int
)
(
tech_pvt
->
read_frame
.
datalen
/
bytes
);
if
(
!
switch_test_flag
(
tech_pvt
,
TFLAG_CODEC
))
{
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "audio with no codec yet!\n");
break
;
}
bytes
=
tech_pvt
->
read_codec
.
implementation
->
encoded_bytes_per_frame
;
frames
=
(
int
)
(
tech_pvt
->
read_frame
.
datalen
/
bytes
);
tech_pvt
->
read_frame
.
samples
=
frames
*
tech_pvt
->
read_codec
.
implementation
->
samples_per_frame
;
tech_pvt
->
read_frame
.
samples
=
frames
*
tech_pvt
->
read_codec
.
implementation
->
samples_per_frame
;
memcpy
(
tech_pvt
->
read_frame
.
data
,
iaxevent
->
data
,
iaxevent
->
datalen
);
memcpy
(
tech_pvt
->
read_frame
.
data
,
iaxevent
->
data
,
iaxevent
->
datalen
);
/* wake up the i/o thread */
/* wake up the i/o thread */
...
...
src/switch_ivr.c
浏览文件 @
c0891ce9
...
@@ -759,8 +759,6 @@ static void *audio_bridge_thread(switch_thread *thread, void *obj)
...
@@ -759,8 +759,6 @@ static void *audio_bridge_thread(switch_thread *thread, void *obj)
/* read audio from 1 channel and write it to the other */
/* read audio from 1 channel and write it to the other */
if
(
switch_core_session_read_frame
(
session_a
,
&
read_frame
,
-
1
,
stream_id
)
==
SWITCH_STATUS_SUCCESS
&&
read_frame
->
datalen
)
{
if
(
switch_core_session_read_frame
(
session_a
,
&
read_frame
,
-
1
,
stream_id
)
==
SWITCH_STATUS_SUCCESS
&&
read_frame
->
datalen
)
{
if
(
switch_core_session_write_frame
(
session_b
,
read_frame
,
-
1
,
stream_id
)
!=
SWITCH_STATUS_SUCCESS
)
{
if
(
switch_core_session_write_frame
(
session_b
,
read_frame
,
-
1
,
stream_id
)
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"write: %s Bad Frame....[%u] Bubye!
\n
"
,
switch_channel_get_name
(
chan_b
),
read_frame
->
datalen
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"write: %s Bad Frame....[%u] Bubye!
\n
"
,
switch_channel_get_name
(
chan_b
),
read_frame
->
datalen
);
data
->
running
=
-
1
;
data
->
running
=
-
1
;
...
@@ -903,14 +901,14 @@ SWITCH_DECLARE(switch_status) switch_ivr_multi_threaded_bridge(switch_core_sessi
...
@@ -903,14 +901,14 @@ SWITCH_DECLARE(switch_status) switch_ivr_multi_threaded_bridge(switch_core_sessi
!
switch_channel_test_flag
(
peer_channel
,
CF_ANSWERED
)
&&
!
switch_channel_test_flag
(
peer_channel
,
CF_ANSWERED
)
&&
!
switch_channel_test_flag
(
peer_channel
,
CF_EARLY_MEDIA
)
&&
!
switch_channel_test_flag
(
peer_channel
,
CF_EARLY_MEDIA
)
&&
((
time
(
NULL
)
-
start
)
<
timelimit
))
{
((
time
(
NULL
)
-
start
)
<
timelimit
))
{
/* read from the channel while we wait if the audio is up on it */
/* read from the channel while we wait if the audio is up on it */
if
(
switch_channel_test_flag
(
caller_channel
,
CF_ANSWERED
)
||
switch_channel_test_flag
(
caller_channel
,
CF_EARLY_MEDIA
))
{
if
(
switch_channel_test_flag
(
caller_channel
,
CF_ANSWERED
)
||
switch_channel_test_flag
(
caller_channel
,
CF_EARLY_MEDIA
))
{
if
(
switch_core_session_read_frame
(
session
,
&
read_frame
,
1000
,
0
)
!=
SWITCH_STATUS_SUCCESS
)
{
if
(
switch_core_session_read_frame
(
session
,
&
read_frame
,
1000
,
0
)
!=
SWITCH_STATUS_SUCCESS
)
{
break
;
break
;
}
}
if
(
read_frame
)
{
if
(
read_frame
)
{
memset
(
read_frame
->
data
,
0
,
read_frame
->
datalen
);
//
memset(read_frame->data, 0, read_frame->datalen);
if
(
switch_core_session_write_frame
(
session
,
read_frame
,
1000
,
0
)
!=
SWITCH_STATUS_SUCCESS
)
{
if
(
switch_core_session_write_frame
(
session
,
read_frame
,
1000
,
0
)
!=
SWITCH_STATUS_SUCCESS
)
{
break
;
break
;
}
}
...
@@ -919,6 +917,7 @@ SWITCH_DECLARE(switch_status) switch_ivr_multi_threaded_bridge(switch_core_sessi
...
@@ -919,6 +917,7 @@ SWITCH_DECLARE(switch_status) switch_ivr_multi_threaded_bridge(switch_core_sessi
}
else
{
}
else
{
switch_yield
(
1000
);
switch_yield
(
1000
);
}
}
}
}
if
(
switch_channel_test_flag
(
peer_channel
,
CF_ANSWERED
))
{
if
(
switch_channel_test_flag
(
peer_channel
,
CF_ANSWERED
))
{
...
@@ -941,6 +940,7 @@ SWITCH_DECLARE(switch_status) switch_ivr_multi_threaded_bridge(switch_core_sessi
...
@@ -941,6 +940,7 @@ SWITCH_DECLARE(switch_status) switch_ivr_multi_threaded_bridge(switch_core_sessi
msg
.
pointer_arg
=
peer_session
;
msg
.
pointer_arg
=
peer_session
;
switch_core_session_receive_message
(
session
,
&
msg
);
switch_core_session_receive_message
(
session
,
&
msg
);
switch_core_session_launch_thread
(
peer_session
,
audio_bridge_thread
,
(
void
*
)
&
other_audio_thread
);
switch_core_session_launch_thread
(
peer_session
,
audio_bridge_thread
,
(
void
*
)
&
other_audio_thread
);
audio_bridge_thread
(
NULL
,
(
void
*
)
&
this_audio_thread
);
audio_bridge_thread
(
NULL
,
(
void
*
)
&
this_audio_thread
);
...
...
src/switch_rtp.c
浏览文件 @
c0891ce9
...
@@ -495,7 +495,7 @@ static int rtp_common_read(switch_rtp *rtp_session, int *payload_type, switch_fr
...
@@ -495,7 +495,7 @@ static int rtp_common_read(switch_rtp *rtp_session, int *payload_type, switch_fr
for
(;;)
{
for
(;;)
{
bytes
=
sizeof
(
rtp_msg_t
);
bytes
=
sizeof
(
rtp_msg_t
);
status
=
switch_socket_recvfrom
(
rtp_session
->
from_addr
,
rtp_session
->
sock
,
0
,
(
void
*
)
&
rtp_session
->
recv_msg
,
&
bytes
);
status
=
switch_socket_recvfrom
(
rtp_session
->
from_addr
,
rtp_session
->
sock
,
0
,
(
void
*
)
&
rtp_session
->
recv_msg
,
&
bytes
);
if
(
switch_test_flag
(
rtp_session
,
SWITCH_RTP_FLAG_AUTOADJ
)
&&
rtp_session
->
from_addr
->
port
!=
rtp_session
->
remote_port
)
{
if
(
switch_test_flag
(
rtp_session
,
SWITCH_RTP_FLAG_AUTOADJ
)
&&
rtp_session
->
from_addr
->
port
!=
rtp_session
->
remote_port
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"Auto Changing port to %u
\n
"
,
rtp_session
->
from_addr
->
port
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"Auto Changing port to %u
\n
"
,
rtp_session
->
from_addr
->
port
);
rtp_session
->
remote_addr
->
port
=
rtp_session
->
from_addr
->
port
;
rtp_session
->
remote_addr
->
port
=
rtp_session
->
from_addr
->
port
;
...
@@ -601,6 +601,9 @@ SWITCH_DECLARE(switch_status) switch_rtp_zerocopy_read_frame(switch_rtp *rtp_ses
...
@@ -601,6 +601,9 @@ SWITCH_DECLARE(switch_status) switch_rtp_zerocopy_read_frame(switch_rtp *rtp_ses
if
(
bytes
<
0
)
{
if
(
bytes
<
0
)
{
frame
->
datalen
=
0
;
frame
->
datalen
=
0
;
return
SWITCH_STATUS_GENERR
;
return
SWITCH_STATUS_GENERR
;
}
else
if
(
bytes
==
0
)
{
frame
->
datalen
=
0
;
return
SWITCH_STATUS_BREAK
;
}
else
{
}
else
{
bytes
-=
rtp_header_len
;
bytes
-=
rtp_header_len
;
}
}
...
@@ -630,6 +633,7 @@ SWITCH_DECLARE(switch_status) switch_rtp_zerocopy_read(switch_rtp *rtp_session,
...
@@ -630,6 +633,7 @@ SWITCH_DECLARE(switch_status) switch_rtp_zerocopy_read(switch_rtp *rtp_session,
static
int
rtp_common_write
(
switch_rtp
*
rtp_session
,
void
*
data
,
uint32_t
datalen
,
uint8_t
payload
,
switch_frame_flag
*
flags
)
static
int
rtp_common_write
(
switch_rtp
*
rtp_session
,
void
*
data
,
uint32_t
datalen
,
uint8_t
payload
,
switch_frame_flag
*
flags
)
{
{
switch_size_t
bytes
;
switch_size_t
bytes
;
uint8_t
packetize
=
(
rtp_session
->
packet_size
>
datalen
&&
(
payload
==
rtp_session
->
payload
))
?
1
:
0
;
uint8_t
fwd
=
(
switch_test_flag
(
rtp_session
,
SWITCH_RTP_FLAG_RAW_WRITE
)
&&
(
*
flags
&
SFF_RAW_RTP
))
?
1
:
0
;
uint8_t
fwd
=
(
switch_test_flag
(
rtp_session
,
SWITCH_RTP_FLAG_RAW_WRITE
)
&&
(
*
flags
&
SFF_RAW_RTP
))
?
1
:
0
;
rtp_msg_t
*
send_msg
;
rtp_msg_t
*
send_msg
;
...
@@ -639,7 +643,7 @@ static int rtp_common_write(switch_rtp *rtp_session, void *data, uint32_t datale
...
@@ -639,7 +643,7 @@ static int rtp_common_write(switch_rtp *rtp_session, void *data, uint32_t datale
}
else
{
}
else
{
send_msg
=
&
rtp_session
->
send_msg
;
send_msg
=
&
rtp_session
->
send_msg
;
send_msg
->
header
.
pt
=
rtp_session
->
payload
;
send_msg
->
header
.
pt
=
rtp_session
->
payload
;
if
(
rtp_session
->
packet_size
>
datalen
&&
(
payload
==
rtp_session
->
payload
)
)
{
if
(
packetize
)
{
if
(
!
rtp_session
->
packet_buffer
)
{
if
(
!
rtp_session
->
packet_buffer
)
{
if
(
switch_buffer_create
(
rtp_session
->
pool
,
&
rtp_session
->
packet_buffer
,
rtp_session
->
packet_size
*
2
)
!=
SWITCH_STATUS_SUCCESS
)
{
if
(
switch_buffer_create
(
rtp_session
->
pool
,
&
rtp_session
->
packet_buffer
,
rtp_session
->
packet_size
*
2
)
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_CRIT
,
"Buffer memory error
\n
"
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_CRIT
,
"Buffer memory error
\n
"
);
...
@@ -700,6 +704,34 @@ SWITCH_DECLARE(int) switch_rtp_write(switch_rtp *rtp_session, void *data, uint32
...
@@ -700,6 +704,34 @@ SWITCH_DECLARE(int) switch_rtp_write(switch_rtp *rtp_session, void *data, uint32
}
}
SWITCH_DECLARE
(
int
)
switch_rtp_write_frame
(
switch_rtp
*
rtp_session
,
switch_frame
*
frame
,
uint32_t
ts
)
{
uint8_t
fwd
=
(
switch_test_flag
(
rtp_session
,
SWITCH_RTP_FLAG_RAW_WRITE
)
&&
switch_test_flag
(
frame
,
SFF_RAW_RTP
))
?
1
:
0
;
uint8_t
packetize
=
(
rtp_session
->
packet_size
>
frame
->
datalen
&&
(
frame
->
payload
==
rtp_session
->
payload
))
?
1
:
0
;
void
*
data
;
uint32_t
len
;
if
(
!
switch_test_flag
(
rtp_session
,
SWITCH_RTP_FLAG_IO
)
||
!
rtp_session
->
remote_addr
)
{
return
-
1
;
}
if
(
fwd
&&
!
packetize
)
{
data
=
frame
->
packet
;
len
=
frame
->
packetlen
;
}
else
{
data
=
frame
->
data
;
len
=
frame
->
datalen
;
rtp_session
->
ts
+=
ts
;
rtp_session
->
seq
=
ntohs
(
rtp_session
->
seq
)
+
1
;
rtp_session
->
seq
=
htons
(
rtp_session
->
seq
);
rtp_session
->
send_msg
.
header
.
seq
=
rtp_session
->
seq
;
rtp_session
->
send_msg
.
header
.
ts
=
htonl
(
rtp_session
->
ts
);
}
return
rtp_common_write
(
rtp_session
,
data
,
len
,
rtp_session
->
payload
,
&
frame
->
flags
);
}
SWITCH_DECLARE
(
int
)
switch_rtp_write_payload
(
switch_rtp
*
rtp_session
,
void
*
data
,
uint16_t
datalen
,
uint8_t
payload
,
uint32_t
ts
,
uint16_t
mseq
,
switch_frame_flag
*
flags
)
SWITCH_DECLARE
(
int
)
switch_rtp_write_payload
(
switch_rtp
*
rtp_session
,
void
*
data
,
uint16_t
datalen
,
uint8_t
payload
,
uint32_t
ts
,
uint16_t
mseq
,
switch_frame_flag
*
flags
)
{
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论