Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
74d6db88
提交
74d6db88
authored
7月 26, 2014
作者:
Seven Du
提交者:
Michael Jerris
5月 28, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-7514: refactor timestamp code
上级
c9a13474
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
29 行增加
和
48 行删除
+29
-48
mod_fsv.c
src/mod/applications/mod_fsv/mod_fsv.c
+7
-13
mod_vlc.c
src/mod/formats/mod_vlc/mod_vlc.c
+22
-35
没有找到文件。
src/mod/applications/mod_fsv/mod_fsv.c
浏览文件 @
74d6db88
...
@@ -575,7 +575,7 @@ SWITCH_STANDARD_APP(play_yuv_function)
...
@@ -575,7 +575,7 @@ SWITCH_STANDARD_APP(play_yuv_function)
switch_frame_t
*
read_frame
;
switch_frame_t
*
read_frame
;
uint32_t
width
=
0
,
height
=
0
,
size
;
uint32_t
width
=
0
,
height
=
0
,
size
;
switch_byte_t
*
yuv
;
switch_byte_t
*
yuv
;
uint32_t
last_video_ts
;
switch_time_t
last_video_ts
=
0
;
int
argc
;
int
argc
;
char
*
argv
[
3
]
=
{
0
};
char
*
argv
[
3
]
=
{
0
};
char
*
mydata
=
switch_core_session_strdup
(
session
,
data
);
char
*
mydata
=
switch_core_session_strdup
(
session
,
data
);
...
@@ -670,24 +670,18 @@ SWITCH_STANDARD_APP(play_yuv_function)
...
@@ -670,24 +670,18 @@ SWITCH_STANDARD_APP(play_yuv_function)
uint32_t
encoded_data_len
=
1500
;
uint32_t
encoded_data_len
=
1500
;
uint32_t
encoded_rate
=
0
;
uint32_t
encoded_rate
=
0
;
switch_frame_t
*
frame
=
&
vid_frame
;
switch_frame_t
*
frame
=
&
vid_frame
;
uint32_t
now
;
switch_time_t
now
=
switch_micro_time_now
()
/
1000
;
char
ts_str
[
33
];
char
ts_str
[
33
];
int
delta
;
codec
->
enc_picture
.
width
=
width
;
codec
->
enc_picture
.
width
=
width
;
codec
->
enc_picture
.
height
=
height
;
codec
->
enc_picture
.
height
=
height
;
decoded_data_len
=
width
*
height
*
3
/
2
;
decoded_data_len
=
width
*
height
*
3
/
2
;
delta
=
now
-
last_video_ts
;
now
=
switch_micro_time_now
()
/
1000
;
if
(
delta
>
0
)
{
frame
->
timestamp
+=
delta
*
90
;
if
(
!
last_video_ts
)
{
last_video_ts
=
now
;
last_video_ts
=
now
;
frame
->
timestamp
=
last_video_ts
;
}
else
{
int
delta
=
now
-
last_video_ts
;
if
(
delta
>
0
)
{
frame
->
timestamp
+=
delta
*
90
;
last_video_ts
=
now
;
}
}
}
sprintf
(
ts_str
,
"%u"
,
(
uint32_t
)
frame
->
timestamp
);
sprintf
(
ts_str
,
"%u"
,
(
uint32_t
)
frame
->
timestamp
);
...
@@ -695,7 +689,7 @@ SWITCH_STANDARD_APP(play_yuv_function)
...
@@ -695,7 +689,7 @@ SWITCH_STANDARD_APP(play_yuv_function)
switch_core_codec_encode
(
codec
,
NULL
,
yuv
,
decoded_data_len
,
0
,
vid_frame
.
data
,
&
encoded_data_len
,
&
encoded_rate
,
&
flag
);
switch_core_codec_encode
(
codec
,
NULL
,
yuv
,
decoded_data_len
,
0
,
vid_frame
.
data
,
&
encoded_data_len
,
&
encoded_rate
,
&
flag
);
while
(
encoded_data_len
)
{
while
(
encoded_data_len
)
{
// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "encoded: %s [%d] flag=%d ts=%u\n", codec->implementation->iananame, encoded_data_len, flag,
context->
last_video_ts);
// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "encoded: %s [%d] flag=%d ts=%u\n", codec->implementation->iananame, encoded_data_len, flag, last_video_ts);
frame
->
datalen
=
encoded_data_len
;
frame
->
datalen
=
encoded_data_len
;
frame
->
packetlen
=
frame
->
datalen
+
12
;
frame
->
packetlen
=
frame
->
datalen
+
12
;
...
...
src/mod/formats/mod_vlc/mod_vlc.c
浏览文件 @
74d6db88
...
@@ -107,14 +107,13 @@ struct vlc_video_context {
...
@@ -107,14 +107,13 @@ struct vlc_video_context {
uint8_t
video_packet
[
1500
+
12
];
uint8_t
video_packet
[
1500
+
12
];
void
*
raw_yuyv_data
;
void
*
raw_yuyv_data
;
void
*
raw_i420_data
;
void
*
raw_i420_data
;
uint32
_t
last_video_ts
;
switch_time
_t
last_video_ts
;
switch_payload_t
pt
;
switch_payload_t
pt
;
uint32_t
seq
;
uint32_t
seq
;
int
width
;
int
width
;
int
height
;
int
height
;
int
force_width
;
int
force_width
;
int
force_height
;
int
force_height
;
int
new_frame
;
// next frame is a new frame(new timestamp)
};
};
typedef
struct
vlc_video_context
vlc_video_context_t
;
typedef
struct
vlc_video_context
vlc_video_context_t
;
...
@@ -271,16 +270,27 @@ static void vlc_video_unlock_callback(void *data, void *id, void *const *p_pixel
...
@@ -271,16 +270,27 @@ static void vlc_video_unlock_callback(void *data, void *id, void *const *p_pixel
uint32_t
flag
=
0
;
uint32_t
flag
=
0
;
uint32_t
encoded_data_len
=
1500
;
uint32_t
encoded_data_len
=
1500
;
uint32_t
encoded_rate
=
0
;
uint32_t
encoded_rate
=
0
;
switch_time_t
now
=
(
switch_time_t
)(
switch_micro_time_now
()
/
1000
);
switch_codec_t
*
codec
=
switch_core_session_get_video_write_codec
(
context
->
session
);
switch_codec_t
*
codec
=
switch_core_session_get_video_write_codec
(
context
->
session
);
int
delta
;
switch_assert
(
id
==
NULL
);
/* picture identifier, not needed here */
switch_assert
(
id
==
NULL
);
/* picture identifier, not needed here */
switch_assert
(
codec
);
switch_assert
(
codec
);
if
(
now
-
context
->
last_video_ts
<
60
)
goto
end
;
yuyv_to_i420
(
*
p_pixels
,
context
->
raw_i420_data
,
context
->
width
,
context
->
height
);
yuyv_to_i420
(
*
p_pixels
,
context
->
raw_i420_data
,
context
->
width
,
context
->
height
);
codec
->
enc_picture
.
width
=
context
->
width
;
codec
->
enc_picture
.
width
=
context
->
width
;
codec
->
enc_picture
.
height
=
context
->
height
;
codec
->
enc_picture
.
height
=
context
->
height
;
decoded_data_len
=
context
->
width
*
context
->
height
*
3
/
2
;
decoded_data_len
=
context
->
width
*
context
->
height
*
3
/
2
;
delta
=
now
-
context
->
last_video_ts
;
if
(
delta
>
0
)
{
frame
->
timestamp
+=
delta
*
90
;
context
->
last_video_ts
=
now
;
}
switch_core_codec_encode
(
codec
,
NULL
,
context
->
raw_i420_data
,
decoded_data_len
,
0
,
frame
->
data
,
&
encoded_data_len
,
&
encoded_rate
,
&
flag
);
switch_core_codec_encode
(
codec
,
NULL
,
context
->
raw_i420_data
,
decoded_data_len
,
0
,
frame
->
data
,
&
encoded_data_len
,
&
encoded_rate
,
&
flag
);
while
(
encoded_data_len
)
{
while
(
encoded_data_len
)
{
...
@@ -289,23 +299,6 @@ static void vlc_video_unlock_callback(void *data, void *id, void *const *p_pixel
...
@@ -289,23 +299,6 @@ static void vlc_video_unlock_callback(void *data, void *id, void *const *p_pixel
frame
->
datalen
=
encoded_data_len
;
frame
->
datalen
=
encoded_data_len
;
frame
->
packetlen
=
frame
->
datalen
+
12
;
frame
->
packetlen
=
frame
->
datalen
+
12
;
frame
->
m
=
flag
&
SFF_MARKER
?
1
:
0
;
frame
->
m
=
flag
&
SFF_MARKER
?
1
:
0
;
// frame->timestamp = context->ts;
// if (frame->m) context->ts += 90000 / FPS;
if
(
!
context
->
last_video_ts
)
{
context
->
last_video_ts
=
switch_micro_time_now
()
/
1000
;
frame
->
timestamp
=
context
->
last_video_ts
;
}
if
(
context
->
new_frame
)
{
int
delta
=
switch_micro_time_now
()
/
1000
-
context
->
last_video_ts
;
frame
->
timestamp
+=
delta
*
90
;
context
->
last_video_ts
=
switch_micro_time_now
()
/
1000
;
context
->
new_frame
=
0
;
}
if
(
frame
->
m
)
{
// next frame is a new frame
context
->
new_frame
=
1
;
}
if
(
1
)
{
if
(
1
)
{
/* set correct mark and ts */
/* set correct mark and ts */
...
@@ -329,6 +322,7 @@ static void vlc_video_unlock_callback(void *data, void *id, void *const *p_pixel
...
@@ -329,6 +322,7 @@ static void vlc_video_unlock_callback(void *data, void *id, void *const *p_pixel
switch_core_codec_encode
(
codec
,
NULL
,
NULL
,
0
,
0
,
frame
->
data
,
&
encoded_data_len
,
&
encoded_rate
,
&
flag
);
switch_core_codec_encode
(
codec
,
NULL
,
NULL
,
0
,
0
,
frame
->
data
,
&
encoded_data_len
,
&
encoded_rate
,
&
flag
);
}
}
end:
switch_mutex_unlock
(
context
->
video_mutex
);
switch_mutex_unlock
(
context
->
video_mutex
);
}
}
...
@@ -358,6 +352,8 @@ static void vlc_video_channel_unlock_callback(void *data, void *id, void *const
...
@@ -358,6 +352,8 @@ static void vlc_video_channel_unlock_callback(void *data, void *id, void *const
uint32_t
encoded_rate
=
0
;
uint32_t
encoded_rate
=
0
;
switch_codec_t
*
codec
=
switch_core_session_get_video_write_codec
(
context
->
session
);
switch_codec_t
*
codec
=
switch_core_session_get_video_write_codec
(
context
->
session
);
switch_frame_t
*
frame
=
context
->
vid_frame
;
switch_frame_t
*
frame
=
context
->
vid_frame
;
switch_time_t
now
=
(
switch_time_t
)(
switch_micro_time_now
()
/
1000
);
int
delta
;
switch_assert
(
id
==
NULL
);
/* picture identifier, not needed here */
switch_assert
(
id
==
NULL
);
/* picture identifier, not needed here */
switch_assert
(
codec
);
switch_assert
(
codec
);
...
@@ -371,6 +367,12 @@ static void vlc_video_channel_unlock_callback(void *data, void *id, void *const
...
@@ -371,6 +367,12 @@ static void vlc_video_channel_unlock_callback(void *data, void *id, void *const
frame
->
packet
=
context
->
video_packet
;
frame
->
packet
=
context
->
video_packet
;
frame
->
data
=
context
->
video_packet
+
12
;
frame
->
data
=
context
->
video_packet
+
12
;
delta
=
now
-
context
->
last_video_ts
;
if
(
delta
>
0
)
{
frame
->
timestamp
+=
delta
*
90
;
context
->
last_video_ts
=
now
;
}
switch_core_codec_encode
(
codec
,
NULL
,
context
->
raw_i420_data
,
decoded_data_len
,
0
,
frame
->
data
,
&
encoded_data_len
,
&
encoded_rate
,
&
flag
);
switch_core_codec_encode
(
codec
,
NULL
,
context
->
raw_i420_data
,
decoded_data_len
,
0
,
frame
->
data
,
&
encoded_data_len
,
&
encoded_rate
,
&
flag
);
...
@@ -380,21 +382,6 @@ static void vlc_video_channel_unlock_callback(void *data, void *id, void *const
...
@@ -380,21 +382,6 @@ static void vlc_video_channel_unlock_callback(void *data, void *id, void *const
frame
->
datalen
=
encoded_data_len
;
frame
->
datalen
=
encoded_data_len
;
frame
->
packetlen
=
frame
->
datalen
+
12
;
frame
->
packetlen
=
frame
->
datalen
+
12
;
frame
->
m
=
flag
&
SFF_MARKER
?
1
:
0
;
frame
->
m
=
flag
&
SFF_MARKER
?
1
:
0
;
if
(
!
context
->
last_video_ts
)
{
context
->
last_video_ts
=
switch_micro_time_now
()
/
1000
;
frame
->
timestamp
=
context
->
last_video_ts
;
}
if
(
context
->
new_frame
)
{
int
delta
=
switch_micro_time_now
()
/
1000
-
context
->
last_video_ts
;
frame
->
timestamp
+=
delta
*
90
;
context
->
last_video_ts
=
switch_micro_time_now
()
/
1000
;
context
->
new_frame
=
0
;
}
if
(
frame
->
m
)
{
// next frame is a new frame
context
->
new_frame
=
1
;
}
if
(
1
)
{
if
(
1
)
{
/* set correct mark and ts */
/* set correct mark and ts */
...
@@ -1163,7 +1150,7 @@ static switch_status_t setup_tech_pvt(switch_core_session_t *session, const char
...
@@ -1163,7 +1150,7 @@ static switch_status_t setup_tech_pvt(switch_core_session_t *session, const char
fail:
fail:
return
SWITCH_STATUS_FALSE
;
return
status
;
}
}
static
switch_status_t
channel_on_init
(
switch_core_session_t
*
session
)
static
switch_status_t
channel_on_init
(
switch_core_session_t
*
session
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论