Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
8adca826
提交
8adca826
authored
5月 29, 2015
作者:
Seven Du
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-7585 detect packet loss where possible
上级
721c9c99
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
33 行增加
和
19 行删除
+33
-19
rtmp_video.c
src/mod/endpoints/mod_rtmp/rtmp_video.c
+33
-19
没有找到文件。
src/mod/endpoints/mod_rtmp/rtmp_video.c
浏览文件 @
8adca826
...
@@ -124,6 +124,7 @@ switch_status_t on_rtmp_destroy(rtmp_private_t *tech_pvt)
...
@@ -124,6 +124,7 @@ switch_status_t on_rtmp_destroy(rtmp_private_t *tech_pvt)
switch_status_t
rtmp_rtmp2rtpH264
(
rtmp2rtp_helper_t
*
read_helper
,
uint8_t
*
data
,
uint32_t
len
)
switch_status_t
rtmp_rtmp2rtpH264
(
rtmp2rtp_helper_t
*
read_helper
,
uint8_t
*
data
,
uint32_t
len
)
{
{
switch_status_t
status
=
SWITCH_STATUS_SUCCESS
;
switch_status_t
status
=
SWITCH_STATUS_SUCCESS
;
uint8_t
*
end
=
data
+
len
;
if
(
data
[
0
]
==
0x17
&&
data
[
1
]
==
0
)
{
if
(
data
[
0
]
==
0x17
&&
data
[
1
]
==
0
)
{
switch_byte_t
*
pdata
=
data
+
2
;
switch_byte_t
*
pdata
=
data
+
2
;
...
@@ -139,8 +140,14 @@ switch_status_t rtmp_rtmp2rtpH264(rtmp2rtp_helper_t *read_helper, uint8_t* data
...
@@ -139,8 +140,14 @@ switch_status_t rtmp_rtmp2rtpH264(rtmp2rtp_helper_t *read_helper, uint8_t* data
numSPS
=
pdata
[
8
]
&
0x1f
;
numSPS
=
pdata
[
8
]
&
0x1f
;
pdata
+=
9
;
pdata
+=
9
;
for
(
i
=
0
;
i
<
numSPS
;
i
++
)
{
for
(
i
=
0
;
i
<
numSPS
;
i
++
)
{
lenSPS
=
((
pdata
[
0
]
&
0xff
)
<<
8
)
|
(
pdata
[
1
]
&
0xff
);
lenSPS
=
ntohs
(
*
(
uint16_t
*
)
pdata
);
pdata
+=
2
;
pdata
+=
2
;
if
(
lenSPS
>
end
-
pdata
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"corrupted data
\n
"
);
return
SWITCH_STATUS_FALSE
;
}
if
(
read_helper
->
sps
==
NULL
)
{
if
(
read_helper
->
sps
==
NULL
)
{
read_helper
->
sps
=
amf0_string_new
(
pdata
,
lenSPS
);
read_helper
->
sps
=
amf0_string_new
(
pdata
,
lenSPS
);
}
}
...
@@ -150,8 +157,13 @@ switch_status_t rtmp_rtmp2rtpH264(rtmp2rtp_helper_t *read_helper, uint8_t* data
...
@@ -150,8 +157,13 @@ switch_status_t rtmp_rtmp2rtpH264(rtmp2rtp_helper_t *read_helper, uint8_t* data
numPPS
=
pdata
[
0
];
numPPS
=
pdata
[
0
];
pdata
+=
1
;
pdata
+=
1
;
for
(
i
=
0
;
i
<
numPPS
;
i
++
)
{
for
(
i
=
0
;
i
<
numPPS
;
i
++
)
{
lenPPS
=
((
pdata
[
0
]
&
0xff
)
<<
8
)
|
(
pdata
[
1
]
&
0xff
);
lenPPS
=
ntohs
(
*
(
uint16_t
*
)
pdata
);
pdata
+=
2
;
pdata
+=
2
;
if
(
lenPPS
>
end
-
pdata
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"corrupted data
\n
"
);
return
SWITCH_STATUS_FALSE
;
}
if
(
read_helper
->
pps
==
NULL
)
{
if
(
read_helper
->
pps
==
NULL
)
{
read_helper
->
pps
=
amf0_string_new
(
pdata
,
lenPPS
);
read_helper
->
pps
=
amf0_string_new
(
pdata
,
lenPPS
);
}
}
...
@@ -282,14 +294,14 @@ switch_bool_t sps_changed(amf0_data *data, uint8_t *new, int datalen)
...
@@ -282,14 +294,14 @@ switch_bool_t sps_changed(amf0_data *data, uint8_t *new, int datalen)
switch_status_t
rtmp_rtp2rtmpH264
(
rtp2rtmp_helper_t
*
helper
,
switch_frame_t
*
frame
)
switch_status_t
rtmp_rtp2rtmpH264
(
rtp2rtmp_helper_t
*
helper
,
switch_frame_t
*
frame
)
{
{
uint8_t
*
packet
=
frame
->
packet
;
uint8_t
*
packet
=
frame
->
packet
;
uint32_t
len
=
frame
->
packetlen
;
//
uint32_t len = frame->packetlen;
switch_rtp_hdr_t
*
raw_rtp
=
(
switch_rtp_hdr_t
*
)
packet
;
switch_rtp_hdr_t
*
raw_rtp
=
(
switch_rtp_hdr_t
*
)
packet
;
switch_byte_t
*
payload
=
packet
+
12
;
switch_byte_t
*
payload
=
frame
->
data
;
int
datalen
=
len
-
12
;
int
datalen
=
frame
->
datalen
;
int
nalType
=
payload
[
0
]
&
0x1f
;
int
nalType
=
payload
[
0
]
&
0x1f
;
uint32_t
size
=
0
;
uint32_t
size
=
0
;
uint16_t
rtp_seq
=
ntohs
(
raw_rtp
->
seq
)
;
uint16_t
rtp_seq
=
0
;
// uint32_t rtp_ts = ntohl(raw_rtp->ts)
;
uint32_t
rtp_ts
=
0
;
static
const
uint8_t
rtmp_header17
[]
=
{
0x17
,
1
,
0
,
0
,
0
};
static
const
uint8_t
rtmp_header17
[]
=
{
0x17
,
1
,
0
,
0
,
0
};
static
const
uint8_t
rtmp_header27
[]
=
{
0x27
,
1
,
0
,
0
,
0
};
static
const
uint8_t
rtmp_header27
[]
=
{
0x27
,
1
,
0
,
0
,
0
};
...
@@ -297,13 +309,16 @@ switch_status_t rtmp_rtp2rtmpH264(rtp2rtmp_helper_t *helper, switch_frame_t *fra
...
@@ -297,13 +309,16 @@ switch_status_t rtmp_rtp2rtmpH264(rtp2rtmp_helper_t *helper, switch_frame_t *fra
// "read: %-4u: %02x %02x ts:%u seq:%u %s\n",
// "read: %-4u: %02x %02x ts:%u seq:%u %s\n",
// len, payload[0], payload[1], rtp_ts, rtp_seq, raw_rtp->m ? " mark" : "");
// len, payload[0], payload[1], rtp_ts, rtp_seq, raw_rtp->m ? " mark" : "");
#if 0
if
(
switch_test_flag
(
frame
,
SFF_RAW_RTP
)
&&
!
switch_test_flag
(
frame
,
SFF_RAW_RTP_PARSE_FRAME
))
{
if (helper->last_seq && helper->last_seq + 1 != rtp_seq) {
rtp_seq
=
ntohs
(
raw_rtp
->
seq
);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "possible video rtp packet loss? seq: %u - %u - 1 = %d ts: %u - %u = %d\n",
rtp_ts
=
ntohl
(
raw_rtp
->
ts
);
ntohs(raw_rtp->seq), helper->last_seq, (int)(rtp_seq - helper->last_seq - 1),
ntohl(raw_rtp->ts), helper->last_recv_ts, (int)(rtp_ts - helper->last_recv_ts));
if
(
helper
->
last_seq
&&
helper
->
last_seq
+
1
!=
rtp_seq
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"possible video rtp packet loss? seq: %u - %u - 1 = %d ts: %u - %u = %d
\n
"
,
ntohs
(
raw_rtp
->
seq
),
helper
->
last_seq
,
(
int
)(
rtp_seq
-
helper
->
last_seq
-
1
),
ntohl
(
raw_rtp
->
ts
),
helper
->
last_recv_ts
,
(
int
)(
rtp_ts
-
helper
->
last_recv_ts
));
/*
if
(
nalType
!=
7
)
{
if
(
nalType
!=
7
)
{
if
(
helper
->
sps
)
{
if
(
helper
->
sps
)
{
amf0_data_free
(
helper
->
sps
);
amf0_data_free
(
helper
->
sps
);
...
@@ -314,17 +329,16 @@ switch_status_t rtmp_rtp2rtmpH264(rtp2rtmp_helper_t *helper, switch_frame_t *fra
...
@@ -314,17 +329,16 @@ switch_status_t rtmp_rtp2rtmpH264(rtp2rtmp_helper_t *helper, switch_frame_t *fra
helper
->
last_seq
=
rtp_seq
;
helper
->
last_seq
=
rtp_seq
;
goto
wait_sps
;
goto
wait_sps
;
}
}
*/
}
}
}
#endif
if
(
helper
->
last_recv_ts
!=
frame
->
timestamp
)
{
if
(
helper
->
last_recv_ts
!=
frame
->
timestamp
)
{
switch_buffer_zero
(
helper
->
rtmp_buf
);
switch_buffer_zero
(
helper
->
rtmp_buf
);
switch_buffer_zero
(
helper
->
fua_buf
);
switch_buffer_zero
(
helper
->
fua_buf
);
}
}
helper
->
last_recv_ts
=
frame
->
timestamp
;
helper
->
last_recv_ts
=
frame
->
timestamp
;
helper
->
last_mark
=
frame
->
m
;
//raw_rtp->m;
helper
->
last_mark
=
frame
->
m
;
helper
->
last_seq
=
rtp_seq
;
helper
->
last_seq
=
rtp_seq
;
switch
(
nalType
)
{
switch
(
nalType
)
{
...
@@ -499,7 +513,7 @@ switch_status_t rtmp_rtp2rtmpH264(rtp2rtmp_helper_t *helper, switch_frame_t *fra
...
@@ -499,7 +513,7 @@ switch_status_t rtmp_rtp2rtmpH264(rtp2rtmp_helper_t *helper, switch_frame_t *fra
helper
->
send
=
SWITCH_TRUE
;
helper
->
send
=
SWITCH_TRUE
;
}
else
{
}
else
{
//
wait_sps:
wait_sps:
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"waiting for sps and pps
\n
"
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"waiting for sps and pps
\n
"
);
switch_buffer_zero
(
helper
->
rtmp_buf
);
switch_buffer_zero
(
helper
->
rtmp_buf
);
switch_buffer_zero
(
helper
->
fua_buf
);
switch_buffer_zero
(
helper
->
fua_buf
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论