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
2015-05-27 23:44:07 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
60775485c4db96c16153b1895948b90576e4bf99
60775485
2 parents
385ee893
4864e796
Merge branch '2.0release' of github.com:simple-rtmp-server/srs into 2.0release
显示空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
29 行增加
和
32 行删除
trunk/src/app/srs_app_source.cpp
trunk/src/app/srs_app_source.cpp
100644 → 100755
查看文件 @
6077548
...
...
@@ -357,52 +357,49 @@ int SrsMessageQueue::dump_packets(SrsConsumer* consumer, bool atc, int tba, int
void
SrsMessageQueue
::
shrink
()
{
int
iframe_index
=
-
1
;
SrsSharedPtrMessage
*
video_sh
=
NULL
;
SrsSharedPtrMessage
*
audio_sh
=
NULL
;
int
msgs_size
=
(
int
)
msgs
.
size
();
// issue the first iframe.
// skip the first frame, whatever the type of it,
// for when we shrinked, the first is the iframe,
// we will directly remove the gop next time.
for
(
int
i
=
1
;
i
<
(
int
)
msgs
.
size
();
i
++
)
{
// remove all msg
// igone the sequence header
for
(
int
i
=
0
;
i
<
(
int
)
msgs
.
size
();
i
++
)
{
SrsSharedPtrMessage
*
msg
=
msgs
.
at
(
i
);
if
(
msg
->
is_video
())
{
if
(
SrsFlvCodec
::
video_is_keyframe
(
msg
->
payload
,
msg
->
size
))
{
// the max frame index to remove.
iframe_index
=
i
;
// set the start time, we will remove until this frame.
av_start_time
=
msg
->
timestamp
;
break
;
if
(
msg
->
is_video
()
&&
SrsFlvCodec
::
video_is_sequence_header
(
msg
->
payload
,
msg
->
size
))
{
srs_freep
(
video_sh
);
video_sh
=
msg
;
continue
;
}
else
if
(
msg
->
is_audio
()
&&
SrsFlvCodec
::
audio_is_sequence_header
(
msg
->
payload
,
msg
->
size
))
{
srs_freep
(
audio_sh
);
audio_sh
=
msg
;
continue
;
}
srs_freep
(
msg
);
}
msgs
.
clear
();
// no iframe, for audio, clear the queue.
// it is ok to clear for audio, for the shrink tell us the queue is full.
// for video, we clear util the I-Frame, for the decoding must start from I-frame,
// for audio, it's ok to clear any data, also we can clear the whole queue.
// @see: https://github.com/simple-rtmp-server/srs/issues/134
if
(
iframe_index
<
0
)
{
clear
();
return
;
// update av_start_time
av_start_time
=
av_end_time
;
//push_back secquence header and update timestamp
if
(
video_sh
)
{
video_sh
->
timestamp
=
av_end_time
;
msgs
.
push_back
(
video_sh
);
}
if
(
audio_sh
)
{
audio_sh
->
timestamp
=
av_end_time
;
msgs
.
push_back
(
audio_sh
);
}
if
(
_ignore_shrink
)
{
srs_info
(
"shrink the cache queue, size=%d, removed=%d, max=%.2f"
,
(
int
)
msgs
.
size
(),
iframe_index
,
queue_size_ms
/
1000.0
);
(
int
)
msgs
.
size
(),
msgs_size
-
(
int
)
msgs
.
size
()
,
queue_size_ms
/
1000.0
);
}
else
{
srs_trace
(
"shrink the cache queue, size=%d, removed=%d, max=%.2f"
,
(
int
)
msgs
.
size
(),
iframe_index
,
queue_size_ms
/
1000.0
);
}
// remove the first gop from the front
for
(
int
i
=
0
;
i
<
iframe_index
;
i
++
)
{
SrsSharedPtrMessage
*
msg
=
msgs
.
at
(
i
);
srs_freep
(
msg
);
(
int
)
msgs
.
size
(),
msgs_size
-
(
int
)
msgs
.
size
(),
queue_size_ms
/
1000.0
);
}
msgs
.
erase
(
msgs
.
begin
(),
msgs
.
begin
()
+
iframe_index
);
}
void
SrsMessageQueue
::
clear
()
...
...
请
注册
或
登录
后发表评论