Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
e3f6bf6e
提交
e3f6bf6e
authored
10月 16, 2017
作者:
José Luis Millán
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
lipsync: Fix RTP SR generation
上级
5af523b2
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
48 行增加
和
11 行删除
+48
-11
Utils.hpp
worker/include/Utils.hpp
+8
-2
RtpStream.cpp
worker/src/RTC/RtpStream.cpp
+11
-2
RtpStreamSend.cpp
worker/src/RTC/RtpStreamSend.cpp
+29
-7
没有找到文件。
worker/include/Utils.hpp
浏览文件 @
e3f6bf6e
...
@@ -272,6 +272,7 @@ namespace Utils
...
@@ -272,6 +272,7 @@ namespace Utils
};
};
static
void
CurrentTimeNtp
(
Ntp
&
ntp
);
static
void
CurrentTimeNtp
(
Ntp
&
ntp
);
static
void
UnixTime2Ntp
(
struct
timeval
*
unixTime
,
Ntp
&
ntp
);
static
bool
IsNewerTimestamp
(
uint32_t
timestamp
,
uint32_t
prevTimestamp
);
static
bool
IsNewerTimestamp
(
uint32_t
timestamp
,
uint32_t
prevTimestamp
);
static
uint32_t
LatestTimestamp
(
uint32_t
timestamp1
,
uint32_t
timestamp2
);
static
uint32_t
LatestTimestamp
(
uint32_t
timestamp1
,
uint32_t
timestamp2
);
};
};
...
@@ -282,9 +283,14 @@ namespace Utils
...
@@ -282,9 +283,14 @@ namespace Utils
gettimeofday
(
&
tv
,
nullptr
);
gettimeofday
(
&
tv
,
nullptr
);
ntp
.
seconds
=
tv
.
tv_sec
+
UnixNtpOffset
;
UnixTime2Ntp
(
&
tv
,
ntp
);
}
inline
void
Time
::
UnixTime2Ntp
(
struct
timeval
*
unixTime
,
Ntp
&
ntp
)
{
ntp
.
seconds
=
unixTime
->
tv_sec
+
UnixNtpOffset
;
ntp
.
fractions
=
ntp
.
fractions
=
static_cast
<
uint32_t
>
(
static_cast
<
double
>
(
tv
.
tv_usec
)
*
NtpFractionalUnit
*
1.0e-6
);
static_cast
<
uint32_t
>
(
static_cast
<
double
>
(
unixTime
->
tv_usec
)
*
NtpFractionalUnit
*
1.0e-6
);
}
}
inline
bool
Time
::
IsNewerTimestamp
(
uint32_t
timestamp
,
uint32_t
prevTimestamp
)
inline
bool
Time
::
IsNewerTimestamp
(
uint32_t
timestamp
,
uint32_t
prevTimestamp
)
...
...
worker/src/RTC/RtpStream.cpp
浏览文件 @
e3f6bf6e
...
@@ -110,6 +110,9 @@ namespace RTC
...
@@ -110,6 +110,9 @@ namespace RTC
this
->
started
=
true
;
this
->
started
=
true
;
this
->
maxSeq
=
seq
-
1
;
this
->
maxSeq
=
seq
-
1
;
this
->
maxPacketTs
=
packet
->
GetTimestamp
();
this
->
maxPacketMs
=
DepLibUV
::
GetTime
();
}
}
// If not a valid packet ignore it.
// If not a valid packet ignore it.
...
@@ -130,8 +133,12 @@ namespace RTC
...
@@ -130,8 +133,12 @@ namespace RTC
// Update highest seen RTP timestamp.
// Update highest seen RTP timestamp.
if
(
SeqManager
<
uint32_t
>::
IsSeqHigherThan
(
packet
->
GetTimestamp
(),
this
->
maxPacketTs
))
if
(
SeqManager
<
uint32_t
>::
IsSeqHigherThan
(
packet
->
GetTimestamp
(),
this
->
maxPacketTs
))
{
{
// Calculate time diff between this and previous highest RTP timestamp.
uint32_t
diffTs
=
packet
->
GetTimestamp
()
-
this
->
maxPacketTs
;
uint32_t
diffMs
=
diffTs
*
1000
/
this
->
params
.
clockRate
;
this
->
maxPacketTs
=
packet
->
GetTimestamp
();
this
->
maxPacketTs
=
packet
->
GetTimestamp
();
this
->
maxPacketMs
=
DepLibUV
::
GetTime
()
;
this
->
maxPacketMs
+=
diffMs
;
}
}
return
true
;
return
true
;
...
@@ -157,7 +164,6 @@ namespace RTC
...
@@ -157,7 +164,6 @@ namespace RTC
this
->
baseSeq
=
seq
;
this
->
baseSeq
=
seq
;
this
->
maxSeq
=
seq
;
this
->
maxSeq
=
seq
;
this
->
badSeq
=
RtpSeqMod
+
1
;
// So seq == badSeq is false.
this
->
badSeq
=
RtpSeqMod
+
1
;
// So seq == badSeq is false.
this
->
maxPacketTs
=
0
;
// Also reset the highest seen RTP timestamp.
}
}
bool
RtpStream
::
UpdateSeq
(
RTC
::
RtpPacket
*
packet
)
bool
RtpStream
::
UpdateSeq
(
RTC
::
RtpPacket
*
packet
)
...
@@ -199,6 +205,9 @@ namespace RTC
...
@@ -199,6 +205,9 @@ namespace RTC
packet
->
GetSequenceNumber
());
packet
->
GetSequenceNumber
());
InitSeq
(
seq
);
InitSeq
(
seq
);
this
->
maxPacketTs
=
packet
->
GetTimestamp
();
this
->
maxPacketMs
=
DepLibUV
::
GetTime
();
}
}
else
else
{
{
...
...
worker/src/RTC/RtpStreamSend.cpp
浏览文件 @
e3f6bf6e
...
@@ -277,21 +277,43 @@ namespace RTC
...
@@ -277,21 +277,43 @@ namespace RTC
return
nullptr
;
return
nullptr
;
auto
report
=
new
RTC
::
RTCP
::
SenderReport
();
auto
report
=
new
RTC
::
RTCP
::
SenderReport
();
report
->
SetPacketCount
(
this
->
transmissionCounter
.
GetPacketCount
());
report
->
SetPacketCount
(
this
->
transmissionCounter
.
GetPacketCount
());
report
->
SetOctetCount
(
this
->
transmissionCounter
.
GetBytes
());
report
->
SetOctetCount
(
this
->
transmissionCounter
.
GetBytes
());
Utils
::
Time
::
Ntp
ntp
{};
Utils
::
Time
::
CurrentTimeNtp
(
ntp
);
report
->
SetNtpSec
(
ntp
.
seconds
);
report
->
SetNtpFrac
(
ntp
.
fractions
);
// Calculate RTP timestamp diff between now and last received RTP packet.
// Calculate RTP timestamp diff between now and last received RTP packet.
auto
diffMs
=
static_cast
<
uint32_t
>
(
now
-
this
->
maxPacketMs
);
uint32_t
diffMs
=
static_cast
<
uint32_t
>
(
now
-
this
->
maxPacketMs
);
uint32_t
diffTs
=
diffMs
*
this
->
params
.
clockRate
/
1000
;
uint32_t
diffTs
=
diffMs
*
this
->
params
.
clockRate
/
1000
;
Utils
::
Time
::
Ntp
ntp
{};
struct
timeval
unixTime
;
uint64_t
unixTimeMs
;
gettimeofday
(
&
unixTime
,
nullptr
);
// Convert unix time to millisecods.
unixTimeMs
=
unixTime
.
tv_sec
*
1000
+
unixTime
.
tv_usec
/
1000
;
if
(
now
>=
this
->
maxPacketMs
)
{
unixTimeMs
+=
diffMs
;
report
->
SetRtpTs
(
this
->
maxPacketTs
+
diffTs
);
report
->
SetRtpTs
(
this
->
maxPacketTs
+
diffTs
);
}
else
{
unixTimeMs
-=
diffMs
;
report
->
SetRtpTs
(
this
->
maxPacketTs
-
diffTs
);
}
// Convert milliseconds to unix time.
unixTime
.
tv_sec
=
unixTimeMs
/
1000
;
unixTime
.
tv_usec
=
(
unixTimeMs
%
1000
)
*
1000
;
// Convert unix time to NTP.
Utils
::
Time
::
UnixTime2Ntp
(
&
unixTime
,
ntp
);
report
->
SetNtpSec
(
ntp
.
seconds
);
report
->
SetNtpFrac
(
ntp
.
fractions
);
return
report
;
return
report
;
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论