Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
f9252843
提交
f9252843
authored
4月 19, 2013
作者:
Anthony Minessale
提交者:
Brian West
4月 19, 2013
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-5302 --resolve
上级
e1da1e7b
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
90 行增加
和
52 行删除
+90
-52
mod_oreka.c
src/mod/applications/mod_oreka/mod_oreka.c
+87
-52
switch_rtp.c
src/switch_rtp.c
+3
-0
没有找到文件。
src/mod/applications/mod_oreka/mod_oreka.c
浏览文件 @
f9252843
...
@@ -52,10 +52,12 @@ typedef struct oreka_session_s {
...
@@ -52,10 +52,12 @@ typedef struct oreka_session_s {
uint32_t
read_cnt
;
uint32_t
read_cnt
;
uint32_t
write_cnt
;
uint32_t
write_cnt
;
switch_media_bug_t
*
read_bug
;
switch_media_bug_t
*
read_bug
;
switch_media_bug_t
*
write_bug
;
//
switch_media_bug_t *write_bug;
switch_event_t
*
invite_extra_headers
;
switch_event_t
*
invite_extra_headers
;
switch_event_t
*
bye_extra_headers
;
switch_event_t
*
bye_extra_headers
;
int
usecnt
;
int
usecnt
;
switch_audio_resampler_t
*
read_resampler
;
switch_audio_resampler_t
*
write_resampler
;
}
oreka_session_t
;
}
oreka_session_t
;
struct
{
struct
{
...
@@ -117,6 +119,7 @@ static int oreka_setup_rtp(oreka_session_t *oreka, oreka_stream_type_t type)
...
@@ -117,6 +119,7 @@ static int oreka_setup_rtp(oreka_session_t *oreka, oreka_stream_type_t type)
const
char
*
err
=
"unknown error"
;
const
char
*
err
=
"unknown error"
;
const
char
*
type_str
=
type
==
FS_OREKA_READ
?
"read"
:
"write"
;
const
char
*
type_str
=
type
==
FS_OREKA_READ
?
"read"
:
"write"
;
if
(
type
==
FS_OREKA_READ
)
{
if
(
type
==
FS_OREKA_READ
)
{
status
=
switch_core_session_get_read_impl
(
oreka
->
session
,
&
oreka
->
read_impl
);
status
=
switch_core_session_get_read_impl
(
oreka
->
session
,
&
oreka
->
read_impl
);
codec_impl
=
&
oreka
->
read_impl
;
codec_impl
=
&
oreka
->
read_impl
;
...
@@ -150,6 +153,10 @@ static int oreka_setup_rtp(oreka_session_t *oreka, oreka_stream_type_t type)
...
@@ -150,6 +153,10 @@ static int oreka_setup_rtp(oreka_session_t *oreka, oreka_stream_type_t type)
res
=
-
1
;
res
=
-
1
;
goto
done
;
goto
done
;
}
}
switch_rtp_intentional_bugs
(
rtp_stream
,
RTP_BUG_SEND_LINEAR_TIMESTAMPS
);
done:
done:
if
(
res
==
-
1
)
{
if
(
res
==
-
1
)
{
if
(
rtp_port
)
{
if
(
rtp_port
)
{
...
@@ -379,57 +386,105 @@ done:
...
@@ -379,57 +386,105 @@ done:
return
rc
;
return
rc
;
}
}
static
switch_bool_t
oreka_
core_callback
(
switch_media_bug_t
*
bug
,
void
*
user_data
,
switch_abc_type_t
type
,
oreka_stream_type_t
stype
,
const
char
*
stype_str
)
static
switch_bool_t
oreka_
audio_callback
(
switch_media_bug_t
*
bug
,
void
*
user_data
,
switch_abc_type_t
type
)
{
{
oreka_session_t
*
oreka
=
user_data
;
oreka_session_t
*
oreka
=
user_data
;
switch_core_session_t
*
session
=
oreka
->
session
;
switch_core_session_t
*
session
=
oreka
->
session
;
switch_frame_t
pcmu_frame
;
switch_frame_t
pcmu_frame
=
{
0
};
switch_frame_t
linear_frame
=
{
0
};
switch_frame_t
*
linear_frame
;
switch_status_t
status
=
SWITCH_STATUS_SUCCESS
;
uint8_t
pcmu_data
[
SWITCH_RECOMMENDED_BUFFER_SIZE
];
uint8_t
pcmu_data
[
SWITCH_RECOMMENDED_BUFFER_SIZE
];
uint8_t
linear_data
[
SWITCH_RECOMMENDED_BUFFER_SIZE
];
uint8_t
resample_data
[
SWITCH_RECOMMENDED_BUFFER_SIZE
];
uint32_t
linear_len
=
0
;
uint32_t
i
=
0
;
uint32_t
i
=
0
;
int16_t
*
linear_samples
=
NULL
;
int16_t
*
linear_samples
=
NULL
;
if
(
type
==
SWITCH_ABC_TYPE_READ
||
type
==
SWITCH_ABC_TYPE_WRITE
)
{
memset
(
&
linear_frame
,
0
,
sizeof
(
linear_frame
));
linear_frame
.
data
=
linear_data
;
if
(
type
==
SWITCH_ABC_TYPE_READ_REPLACE
||
type
==
SWITCH_ABC_TYPE_WRITE_REPLACE
)
{
linear_frame
.
buflen
=
sizeof
(
linear_data
);
int16_t
*
data
;
status
=
switch_core_media_bug_read
(
bug
,
&
linear_frame
,
SWITCH_TRUE
);
if
(
status
!=
SWITCH_STATUS_SUCCESS
&&
status
!=
SWITCH_STATUS_BREAK
)
{
if
(
type
==
SWITCH_ABC_TYPE_READ_REPLACE
)
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_ERROR
,
"Error reading media bug: %d
\n
"
,
status
);
linear_frame
=
switch_core_media_bug_get_read_replace_frame
(
bug
);
goto
done
;
}
if
(
oreka
->
read_resampler
)
{
if
(
!
linear_frame
.
datalen
)
{
data
=
(
int16_t
*
)
linear_frame
->
data
;
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_ERROR
,
"Linear frame with no length!
\n
"
);
switch_resample_process
(
oreka
->
read_resampler
,
data
,
(
int
)
linear_frame
->
datalen
/
2
);
goto
done
;
linear_len
=
oreka
->
read_resampler
->
to_len
*
2
;
}
memcpy
(
resample_data
,
oreka
->
read_resampler
->
to
,
linear_len
);
linear_samples
=
(
int16_t
*
)
resample_data
;
}
else
{
linear_samples
=
linear_frame
->
data
;
linear_len
=
linear_frame
->
datalen
;
}
}
if
(
type
==
SWITCH_ABC_TYPE_WRITE_REPLACE
)
{
linear_frame
=
switch_core_media_bug_get_write_replace_frame
(
bug
);
if
(
oreka
->
write_resampler
)
{
data
=
(
int16_t
*
)
linear_frame
->
data
;
switch_resample_process
(
oreka
->
write_resampler
,
data
,
(
int
)
linear_frame
->
datalen
/
2
);
linear_len
=
oreka
->
write_resampler
->
to_len
*
2
;
memcpy
(
resample_data
,
oreka
->
write_resampler
->
to
,
linear_len
);
linear_samples
=
(
int16_t
*
)
resample_data
;
}
else
{
linear_samples
=
linear_frame
->
data
;
linear_len
=
linear_frame
->
datalen
;
}
}
/* convert the L16 frame into PCMU */
/* convert the L16 frame into PCMU */
linear_samples
=
linear_frame
.
data
;
memset
(
&
pcmu_frame
,
0
,
sizeof
(
pcmu_frame
));
memset
(
&
pcmu_frame
,
0
,
sizeof
(
pcmu_frame
));
for
(
i
=
0
;
i
<
linear_
frame
.
datalen
/
sizeof
(
int16_t
);
i
++
)
{
for
(
i
=
0
;
i
<
linear_
len
/
sizeof
(
int16_t
);
i
++
)
{
pcmu_data
[
i
]
=
linear_to_ulaw
(
linear_samples
[
i
]);
pcmu_data
[
i
]
=
linear_to_ulaw
(
linear_samples
[
i
]);
}
}
pcmu_frame
.
source
=
__FUNCTION__
;
pcmu_frame
.
source
=
__FUNCTION__
;
pcmu_frame
.
data
=
pcmu_data
;
pcmu_frame
.
data
=
pcmu_data
;
pcmu_frame
.
datalen
=
i
;
pcmu_frame
.
datalen
=
i
;
pcmu_frame
.
payload
=
0
;
pcmu_frame
.
payload
=
0
;
}
}
switch
(
type
)
{
switch
(
type
)
{
case
SWITCH_ABC_TYPE_INIT
:
case
SWITCH_ABC_TYPE_INIT
:
{
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_INFO
,
"Starting Oreka recording for %s stream
\n
"
,
stype_str
);
switch_codec_implementation_t
read_impl
;
oreka_send_sip_message
(
oreka
,
FS_OREKA_START
,
stype
);
switch_core_session_get_read_impl
(
session
,
&
read_impl
);
if
(
read_impl
.
actual_samples_per_second
!=
8000
)
{
switch_resample_create
(
&
oreka
->
read_resampler
,
read_impl
.
actual_samples_per_second
,
8000
,
320
,
SWITCH_RESAMPLE_QUALITY
,
1
);
switch_resample_create
(
&
oreka
->
write_resampler
,
read_impl
.
actual_samples_per_second
,
8000
,
320
,
SWITCH_RESAMPLE_QUALITY
,
1
);
}
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_INFO
,
"Starting Oreka recording for audio stream
\n
"
);
oreka_send_sip_message
(
oreka
,
FS_OREKA_START
,
FS_OREKA_READ
);
oreka_send_sip_message
(
oreka
,
FS_OREKA_START
,
FS_OREKA_WRITE
);
}
}
break
;
break
;
case
SWITCH_ABC_TYPE_CLOSE
:
case
SWITCH_ABC_TYPE_CLOSE
:
{
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_INFO
,
"Stopping Oreka recording for %s stream
\n
"
,
stype_str
);
if
(
oreka
->
read_resampler
)
{
oreka_send_sip_message
(
oreka
,
FS_OREKA_STOP
,
stype
);
switch_resample_destroy
(
&
oreka
->
read_resampler
);
}
if
(
oreka
->
write_resampler
)
{
switch_resample_destroy
(
&
oreka
->
write_resampler
);
}
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_INFO
,
"Stopping Oreka recording for audio stream
\n
"
);
oreka_send_sip_message
(
oreka
,
FS_OREKA_STOP
,
FS_OREKA_READ
);
oreka_send_sip_message
(
oreka
,
FS_OREKA_STOP
,
FS_OREKA_WRITE
);
}
}
break
;
break
;
case
SWITCH_ABC_TYPE_READ
:
case
SWITCH_ABC_TYPE_READ
_REPLACE
:
{
{
if
(
pcmu_frame
.
datalen
)
{
if
(
pcmu_frame
.
datalen
)
{
if
(
switch_rtp_write_frame
(
oreka
->
read_rtp_stream
,
&
pcmu_frame
)
>
0
)
{
if
(
switch_rtp_write_frame
(
oreka
->
read_rtp_stream
,
&
pcmu_frame
)
>
0
)
{
...
@@ -443,7 +498,7 @@ static switch_bool_t oreka_core_callback(switch_media_bug_t *bug, void *user_dat
...
@@ -443,7 +498,7 @@ static switch_bool_t oreka_core_callback(switch_media_bug_t *bug, void *user_dat
}
}
}
}
break
;
break
;
case
SWITCH_ABC_TYPE_WRITE
:
case
SWITCH_ABC_TYPE_WRITE
_REPLACE
:
{
{
if
(
pcmu_frame
.
datalen
)
{
if
(
pcmu_frame
.
datalen
)
{
if
(
switch_rtp_write_frame
(
oreka
->
write_rtp_stream
,
&
pcmu_frame
)
>
0
)
{
if
(
switch_rtp_write_frame
(
oreka
->
write_rtp_stream
,
&
pcmu_frame
)
>
0
)
{
...
@@ -460,19 +515,10 @@ static switch_bool_t oreka_core_callback(switch_media_bug_t *bug, void *user_dat
...
@@ -460,19 +515,10 @@ static switch_bool_t oreka_core_callback(switch_media_bug_t *bug, void *user_dat
default:
default:
break
;
break
;
}
}
done:
return
SWITCH_TRUE
;
}
static
switch_bool_t
oreka_read_callback
(
switch_media_bug_t
*
bug
,
void
*
user_data
,
switch_abc_type_t
type
)
return
SWITCH_TRUE
;
{
return
oreka_core_callback
(
bug
,
user_data
,
type
,
FS_OREKA_READ
,
"read"
);
}
}
static
switch_bool_t
oreka_write_callback
(
switch_media_bug_t
*
bug
,
void
*
user_data
,
switch_abc_type_t
type
)
{
return
oreka_core_callback
(
bug
,
user_data
,
type
,
FS_OREKA_WRITE
,
"write"
);
}
SWITCH_STANDARD_APP
(
oreka_start_function
)
SWITCH_STANDARD_APP
(
oreka_start_function
)
{
{
...
@@ -491,10 +537,6 @@ SWITCH_STANDARD_APP(oreka_start_function)
...
@@ -491,10 +537,6 @@ SWITCH_STANDARD_APP(oreka_start_function)
switch_core_media_bug_remove
(
session
,
&
oreka
->
read_bug
);
switch_core_media_bug_remove
(
session
,
&
oreka
->
read_bug
);
oreka
->
read_bug
=
NULL
;
oreka
->
read_bug
=
NULL
;
}
}
if
(
oreka
->
write_bug
)
{
switch_core_media_bug_remove
(
session
,
&
oreka
->
write_bug
);
oreka
->
write_bug
=
NULL
;
}
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
"Stopped oreka recorder
\n
"
);
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
"Stopped oreka recorder
\n
"
);
}
else
{
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_WARNING
,
"Cannot run oreka recording 2 times on the same session!
\n
"
);
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_WARNING
,
"Cannot run oreka recording 2 times on the same session!
\n
"
);
...
@@ -516,22 +558,15 @@ SWITCH_STANDARD_APP(oreka_start_function)
...
@@ -516,22 +558,15 @@ SWITCH_STANDARD_APP(oreka_start_function)
}
}
oreka
->
session
=
session
;
oreka
->
session
=
session
;
status
=
switch_core_media_bug_add
(
session
,
OREKA_BUG_NAME_READ
,
NULL
,
oreka_
read
_callback
,
oreka
,
0
,
status
=
switch_core_media_bug_add
(
session
,
OREKA_BUG_NAME_READ
,
NULL
,
oreka_
audio
_callback
,
oreka
,
0
,
(
SMBF_READ_
STREAM
|
SMBF_ANSWER_REQ
),
&
bug
);
(
SMBF_READ_
REPLACE
|
SMBF_WRITE_REPLACE
|
SMBF_ANSWER_REQ
),
&
bug
);
if
(
status
!=
SWITCH_STATUS_SUCCESS
)
{
if
(
status
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_ERROR
,
"Failed to attach oreka to
read
media stream!
\n
"
);
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_ERROR
,
"Failed to attach oreka to media stream!
\n
"
);
return
;
return
;
}
}
oreka
->
read_bug
=
bug
;
oreka
->
read_bug
=
bug
;
oreka
->
usecnt
++
;
oreka
->
usecnt
++
;
bug
=
NULL
;
bug
=
NULL
;
status
=
switch_core_media_bug_add
(
session
,
OREKA_BUG_NAME_WRITE
,
NULL
,
oreka_write_callback
,
oreka
,
0
,
(
SMBF_WRITE_STREAM
|
SMBF_ANSWER_REQ
),
&
bug
);
if
(
status
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_ERROR
,
"Failed to attach oreka to write media stream!
\n
"
);
return
;
}
oreka
->
write_bug
=
bug
;
oreka
->
usecnt
++
;
oreka
->
usecnt
++
;
switch_channel_set_private
(
channel
,
OREKA_PRIVATE
,
oreka
);
switch_channel_set_private
(
channel
,
OREKA_PRIVATE
,
oreka
);
...
...
src/switch_rtp.c
浏览文件 @
f9252843
...
@@ -1303,6 +1303,9 @@ static uint8_t get_next_write_ts(switch_rtp_t *rtp_session, uint32_t timestamp)
...
@@ -1303,6 +1303,9 @@ static uint8_t get_next_write_ts(switch_rtp_t *rtp_session, uint32_t timestamp)
}
}
}
else
{
}
else
{
rtp_session
->
ts
+=
rtp_session
->
samples_per_interval
;
rtp_session
->
ts
+=
rtp_session
->
samples_per_interval
;
if
(
rtp_session
->
ts
<=
rtp_session
->
last_write_ts
&&
rtp_session
->
ts
>
0
)
{
rtp_session
->
ts
=
rtp_session
->
last_write_ts
+
rtp_session
->
samples_per_interval
;
}
}
}
return
m
;
return
m
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论