Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2013-10-23 21:31:22 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e31e3d601dab222a1df2caccf935b11f07be501f
e31e3d60
1 parent
2a346c23
time jitter detect and correct, very simple algorithm
隐藏空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
34 行增加
和
0 行删除
trunk/src/core/srs_core.hpp
trunk/src/core/srs_core_source.cpp
trunk/src/core/srs_core_source.hpp
trunk/src/core/srs_core.hpp
查看文件 @
e31e3d6
...
...
@@ -72,5 +72,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// compare
#define srs_min(a, b) ((a < b)? a : b)
#define srs_max(a, b) ((a < b)? b : a)
#endif
\ No newline at end of file
...
...
trunk/src/core/srs_core_source.cpp
查看文件 @
e31e3d6
...
...
@@ -30,6 +30,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_core_auto_free.hpp>
#include <srs_core_amf0.hpp>
#define CONST_MAX_JITTER_MS 500
#define DEFAULT_FRAME_TIME_MS 10
std
::
map
<
std
::
string
,
SrsSource
*>
SrsSource
::
pool
;
SrsSource
*
SrsSource
::
find
(
std
::
string
stream_url
)
...
...
@@ -45,6 +48,7 @@ SrsSource* SrsSource::find(std::string stream_url)
SrsConsumer
::
SrsConsumer
(
SrsSource
*
_source
)
{
source
=
_source
;
last_pkt_correct_time
=
last_pkt_time
=
0
;
}
SrsConsumer
::~
SrsConsumer
()
...
...
@@ -62,7 +66,34 @@ SrsConsumer::~SrsConsumer()
int
SrsConsumer
::
enqueue
(
SrsSharedPtrMessage
*
msg
)
{
int
ret
=
ERROR_SUCCESS
;
/**
* we use a very simple time jitter detect/correct algorithm,
* if the delta of time is nagative or greater than CONST_MAX_JITTER_MS,
* we enforce the delta to DEFAULT_FRAME_TIME_MS,
* and update the last_pkt_time which used to detect next jitter.
* the last_pkt_correct_time is enforce the time monotonically.
*/
int32_t
time
=
msg
->
header
.
timestamp
;
int32_t
delta
=
time
-
last_pkt_time
;
// if jitter detected, reset the delta.
if
(
delta
<
0
||
delta
>
CONST_MAX_JITTER_MS
)
{
delta
=
DEFAULT_FRAME_TIME_MS
;
srs_info
(
"jitter detected, delta=%d, last_pkt=%d, time=%d, correct_to=%d"
,
delta
,
last_pkt_time
,
time
,
last_pkt_correct_time
+
delta
);
}
else
{
srs_verbose
(
"timestamp no jitter. time=%d, last_pkt=%d, correct_to=%d"
,
time
,
last_pkt_time
,
last_pkt_correct_time
+
delta
);
}
last_pkt_correct_time
=
srs_max
(
0
,
last_pkt_correct_time
+
delta
);
msg
->
header
.
timestamp
=
last_pkt_correct_time
;
last_pkt_time
=
time
;
msgs
.
push_back
(
msg
);
return
ret
;
}
...
...
trunk/src/core/srs_core_source.hpp
查看文件 @
e31e3d6
...
...
@@ -45,6 +45,8 @@ class SrsSharedPtrMessage;
class
SrsConsumer
{
private
:
int32_t
last_pkt_time
;
int32_t
last_pkt_correct_time
;
SrsSource
*
source
;
std
::
vector
<
SrsSharedPtrMessage
*>
msgs
;
public
:
...
...
请
注册
或
登录
后发表评论