Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
ded7fa6c
提交
ded7fa6c
authored
8月 29, 2006
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
g726 work
git-svn-id:
http://svn.freeswitch.org/svn/freeswitch/trunk@2432
d0543943-73ff-0310-b7d9-9358b9ac24b2
上级
b4f50d09
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
52 行增加
和
28 行删除
+52
-28
mod_g726.c
src/mod/codecs/mod_g726/mod_g726.c
+20
-12
mod_sofia.c
src/mod/endpoints/mod_sofia/mod_sofia.c
+32
-16
没有找到文件。
src/mod/codecs/mod_g726/mod_g726.c
浏览文件 @
ded7fa6c
...
@@ -34,20 +34,27 @@
...
@@ -34,20 +34,27 @@
static
const
char
modname
[]
=
"mod_g726"
;
static
const
char
modname
[]
=
"mod_g726"
;
typedef
struct
{
g726_state
context
;
uint8_t
flag
;
uint8_t
bytes
;
}
g726_handle_t
;
static
switch_status_t
switch_g726_init
(
switch_codec_t
*
codec
,
switch_codec_flag_t
flags
,
static
switch_status_t
switch_g726_init
(
switch_codec_t
*
codec
,
switch_codec_flag_t
flags
,
const
switch_codec_settings_t
*
codec_settings
)
const
switch_codec_settings_t
*
codec_settings
)
{
{
int
encoding
,
decoding
;
int
encoding
,
decoding
;
g726_
state
*
context
=
NULL
;
g726_
handle_t
*
handle
;
encoding
=
(
flags
&
SWITCH_CODEC_FLAG_ENCODE
);
encoding
=
(
flags
&
SWITCH_CODEC_FLAG_ENCODE
);
decoding
=
(
flags
&
SWITCH_CODEC_FLAG_DECODE
);
decoding
=
(
flags
&
SWITCH_CODEC_FLAG_DECODE
);
if
(
!
(
encoding
||
decoding
)
||
(
!
(
context
=
switch_core_alloc
(
codec
->
memory_pool
,
sizeof
(
g726_stat
e
)))))
{
if
(
!
(
encoding
||
decoding
)
||
(
!
(
handle
=
switch_core_alloc
(
codec
->
memory_pool
,
sizeof
(
*
handl
e
)))))
{
return
SWITCH_STATUS_FALSE
;
return
SWITCH_STATUS_FALSE
;
}
else
{
}
else
{
g726_init_state
(
context
);
g726_init_state
(
&
handle
->
context
);
codec
->
private_info
=
context
;
codec
->
private_info
=
handle
;
handle
->
bytes
=
codec
->
implementation
->
encoded_bytes_per_frame
/
(
codec
->
implementation
->
microseconds_per_frame
/
1000
);
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
}
}
...
@@ -75,7 +82,8 @@ static switch_status_t switch_g726_encode(switch_codec_t *codec,
...
@@ -75,7 +82,8 @@ static switch_status_t switch_g726_encode(switch_codec_t *codec,
unsigned
int
*
flag
)
unsigned
int
*
flag
)
{
{
g726_state
*
context
=
codec
->
private_info
;
g726_handle_t
*
handle
=
codec
->
private_info
;
g726_state
*
context
=
&
handle
->
context
;
uint32_t
len
=
codec
->
implementation
->
bytes_per_frame
;
uint32_t
len
=
codec
->
implementation
->
bytes_per_frame
;
uint32_t
elen
=
codec
->
implementation
->
encoded_bytes_per_frame
;
uint32_t
elen
=
codec
->
implementation
->
encoded_bytes_per_frame
;
encoder_t
encoder
;
encoder_t
encoder
;
...
@@ -112,17 +120,17 @@ static switch_status_t switch_g726_encode(switch_codec_t *codec,
...
@@ -112,17 +120,17 @@ static switch_status_t switch_g726_encode(switch_codec_t *codec,
uint32_t
loops
=
decoded_data_len
/
(
sizeof
(
*
ddp
));
uint32_t
loops
=
decoded_data_len
/
(
sizeof
(
*
ddp
));
for
(
x
=
0
;
x
<
loops
&&
new_len
<
*
encoded_data_len
;
x
++
)
{
for
(
x
=
0
;
x
<
loops
&&
new_len
<
*
encoded_data_len
;
x
++
)
{
int
sample
=
encoder
(
*
ddp
,
AUDIO_ENCODING_LINEAR
,
context
);
if
(
handle
->
flag
&
0x80
)
{
*
edp
=
sample
;
edp
[
new_len
++
]
=
((
handle
->
flag
&
0xf
)
<<
handle
->
bytes
)
|
encoder
(
*
ddp
,
AUDIO_ENCODING_LINEAR
,
context
);
edp
++
;
handle
->
flag
=
0
;
}
else
{
handle
->
flag
=
0x80
|
encoder
(
*
ddp
,
AUDIO_ENCODING_LINEAR
,
context
);
}
ddp
++
;
ddp
++
;
new_len
++
;
}
}
if
(
new_len
<=
*
encoded_data_len
)
{
if
(
new_len
<=
*
encoded_data_len
)
{
printf
(
"encode %d->%d %d
\n
"
,
decoded_data_len
,
elen
,
new_len
/
2
);
*
encoded_data_len
=
new_len
;
*
encoded_data_len
=
new_len
/
2
;
}
else
{
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"buffer overflow!!! %u >= %u
\n
"
,
new_len
,
*
encoded_data_len
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"buffer overflow!!! %u >= %u
\n
"
,
new_len
,
*
encoded_data_len
);
return
SWITCH_STATUS_FALSE
;
return
SWITCH_STATUS_FALSE
;
...
...
src/mod/endpoints/mod_sofia/mod_sofia.c
浏览文件 @
ded7fa6c
...
@@ -590,27 +590,17 @@ static void deactivate_rtp(private_object_t *tech_pvt)
...
@@ -590,27 +590,17 @@ static void deactivate_rtp(private_object_t *tech_pvt)
}
}
}
}
static
switch_status_t
tech_set_codec
(
private_object_t
*
tech_pvt
)
static
switch_status_t
activate_rtp
(
private_object_t
*
tech_pvt
)
{
{
int
bw
,
ms
;
switch_channel_t
*
channel
;
switch_channel_t
*
channel
;
const
char
*
err
=
NULL
;
switch_rtp_flag_t
flags
;
assert
(
tech_pvt
!=
NULL
);
channel
=
switch_core_session_get_channel
(
tech_pvt
->
session
);
assert
(
channel
!=
NULL
);
assert
(
tech_pvt
->
codecs
[
tech_pvt
->
codec_index
]
!=
NULL
);
assert
(
tech_pvt
->
codecs
[
tech_pvt
->
codec_index
]
!=
NULL
);
if
(
switch_rtp_ready
(
tech_pvt
->
rtp_session
)
)
{
if
(
tech_pvt
->
read_codec
.
implementation
)
{
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
channel
=
switch_core_session_get_channel
(
tech_pvt
->
session
);
assert
(
channel
!=
NULL
);
if
(
switch_core_codec_init
(
&
tech_pvt
->
read_codec
,
if
(
switch_core_codec_init
(
&
tech_pvt
->
read_codec
,
tech_pvt
->
rm_encoding
,
tech_pvt
->
rm_encoding
,
...
@@ -648,7 +638,31 @@ static switch_status_t activate_rtp(private_object_t *tech_pvt)
...
@@ -648,7 +638,31 @@ static switch_status_t activate_rtp(private_object_t *tech_pvt)
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
);
}
}
}
}
return
SWITCH_STATUS_SUCCESS
;
}
static
switch_status_t
activate_rtp
(
private_object_t
*
tech_pvt
)
{
int
bw
,
ms
;
switch_channel_t
*
channel
;
const
char
*
err
=
NULL
;
switch_rtp_flag_t
flags
;
switch_status_t
status
;
assert
(
tech_pvt
!=
NULL
);
channel
=
switch_core_session_get_channel
(
tech_pvt
->
session
);
assert
(
channel
!=
NULL
);
if
(
switch_rtp_ready
(
tech_pvt
->
rtp_session
))
{
return
SWITCH_STATUS_SUCCESS
;
}
if
((
status
=
tech_set_codec
(
tech_pvt
))
!=
SWITCH_STATUS_SUCCESS
)
{
return
status
;
}
bw
=
tech_pvt
->
read_codec
.
implementation
->
bits_per_second
;
bw
=
tech_pvt
->
read_codec
.
implementation
->
bits_per_second
;
ms
=
tech_pvt
->
read_codec
.
implementation
->
microseconds_per_frame
;
ms
=
tech_pvt
->
read_codec
.
implementation
->
microseconds_per_frame
;
...
@@ -993,7 +1007,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
...
@@ -993,7 +1007,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
tech_pvt
=
switch_core_session_get_private
(
session
);
tech_pvt
=
switch_core_session_get_private
(
session
);
assert
(
tech_pvt
!=
NULL
);
assert
(
tech_pvt
!=
NULL
);
if
(
!
switch_test_flag
(
tech_pvt
,
TFLAG_EARLY_MEDIA
))
{
if
(
!
switch_test_flag
(
tech_pvt
,
TFLAG_EARLY_MEDIA
))
{
switch_set_flag_locked
(
tech_pvt
,
TFLAG_EARLY_MEDIA
);
switch_set_flag_locked
(
tech_pvt
,
TFLAG_EARLY_MEDIA
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"Asked to send early media by %s
\n
"
,
msg
->
from
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"Asked to send early media by %s
\n
"
,
msg
->
from
);
...
@@ -1006,7 +1020,6 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
...
@@ -1006,7 +1020,6 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
nua_respond
(
tech_pvt
->
nh
,
SIP_183_SESSION_PROGRESS
,
nua_respond
(
tech_pvt
->
nh
,
SIP_183_SESSION_PROGRESS
,
//SIPTAG_CONTACT(tech_pvt->contact),
//SIPTAG_CONTACT(tech_pvt->contact),
SOATAG_USER_SDP_STR
(
tech_pvt
->
local_sdp_str
),
TAG_END
());
SOATAG_USER_SDP_STR
(
tech_pvt
->
local_sdp_str
),
TAG_END
());
//nua_respond(tech_pvt->nh, SIP_200_OK, SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), TAG_END());
}
}
}
}
break
;
break
;
...
@@ -1157,6 +1170,9 @@ static uint8_t negotiate_sdp(switch_core_session_t *session, sdp_session_t *sdp)
...
@@ -1157,6 +1170,9 @@ static uint8_t negotiate_sdp(switch_core_session_t *session, sdp_session_t *sdp)
}
}
if
(
match
)
{
if
(
match
)
{
if
(
tech_set_codec
(
tech_pvt
)
!=
SWITCH_STATUS_SUCCESS
)
{
match
=
0
;
}
break
;
break
;
}
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论