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
2014-12-07 13:26:45 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5a2b8afeadcd1bf7c63b7228b416d4c4ba87614e
5a2b8afe
1 parent
8f72f795
for bug #251, add queue fast vector. 2.0.66
显示空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
131 行增加
和
3 行删除
trunk/src/app/srs_app_source.cpp
trunk/src/app/srs_app_source.hpp
trunk/src/core/srs_core.hpp
trunk/src/core/srs_core_performance.hpp
trunk/src/app/srs_app_source.cpp
查看文件 @
5a2b8af
...
...
@@ -156,6 +156,93 @@ int SrsRtmpJitter::get_time()
return
(
int
)
last_pkt_correct_time
;
}
#ifdef SRS_PERF_QUEUE_FAST_VECTOR
SrsFastVector
::
SrsFastVector
()
{
count
=
0
;
nb_msgs
=
SRS_PERF_MW_MSGS
*
2
;
msgs
=
new
SrsSharedPtrMessage
*
[
nb_msgs
];
}
SrsFastVector
::~
SrsFastVector
()
{
free
();
}
int
SrsFastVector
::
size
()
{
return
count
;
}
int
SrsFastVector
::
begin
()
{
return
0
;
}
int
SrsFastVector
::
end
()
{
return
count
;
}
SrsSharedPtrMessage
**
SrsFastVector
::
data
()
{
return
msgs
;
}
SrsSharedPtrMessage
*
SrsFastVector
::
at
(
int
index
)
{
srs_assert
(
index
<
count
);
return
msgs
[
index
];
}
void
SrsFastVector
::
clear
()
{
count
=
0
;
}
void
SrsFastVector
::
erase
(
int
_begin
,
int
_end
)
{
srs_assert
(
_begin
<
_end
);
// move all erased to previous.
for
(
int
i
=
0
;
i
<
count
-
_end
;
i
++
)
{
msgs
[
_begin
+
i
]
=
msgs
[
_end
+
i
];
}
// update the count.
count
-=
_end
-
_begin
;
}
void
SrsFastVector
::
push_back
(
SrsSharedPtrMessage
*
msg
)
{
// increase vector.
if
(
count
>=
nb_msgs
)
{
int
size
=
nb_msgs
*
2
;
SrsSharedPtrMessage
**
buf
=
new
SrsSharedPtrMessage
*
[
size
];
for
(
int
i
=
0
;
i
<
nb_msgs
;
i
++
)
{
buf
[
i
]
=
msgs
[
i
];
}
srs_warn
(
"fast vector incrase %d=>%d"
,
nb_msgs
,
size
);
// use new array.
srs_freep
(
msgs
);
msgs
=
buf
;
nb_msgs
=
size
;
}
msgs
[
count
++
]
=
msg
;
}
void
SrsFastVector
::
free
()
{
for
(
int
i
=
0
;
i
<
count
;
i
++
)
{
SrsSharedPtrMessage
*
msg
=
msgs
[
i
];
srs_freep
(
msg
);
}
count
=
0
;
}
#endif
SrsMessageQueue
::
SrsMessageQueue
()
{
queue_size_ms
=
0
;
...
...
@@ -251,7 +338,7 @@ void SrsMessageQueue::shrink()
// 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
++
)
{
SrsSharedPtrMessage
*
msg
=
msgs
[
i
]
;
SrsSharedPtrMessage
*
msg
=
msgs
.
at
(
i
)
;
if
(
msg
->
is_video
())
{
if
(
SrsFlvCodec
::
video_is_keyframe
(
msg
->
payload
,
msg
->
size
))
{
...
...
@@ -281,7 +368,7 @@ void SrsMessageQueue::shrink()
// remove the first gop from the front
for
(
int
i
=
0
;
i
<
iframe_index
;
i
++
)
{
SrsSharedPtrMessage
*
msg
=
msgs
[
i
]
;
SrsSharedPtrMessage
*
msg
=
msgs
.
at
(
i
)
;
srs_freep
(
msg
);
}
msgs
.
erase
(
msgs
.
begin
(),
msgs
.
begin
()
+
iframe_index
);
...
...
@@ -289,12 +376,16 @@ void SrsMessageQueue::shrink()
void
SrsMessageQueue
::
clear
()
{
#ifndef SRS_PERF_QUEUE_FAST_VECTOR
std
::
vector
<
SrsSharedPtrMessage
*>::
iterator
it
;
for
(
it
=
msgs
.
begin
();
it
!=
msgs
.
end
();
++
it
)
{
SrsSharedPtrMessage
*
msg
=
*
it
;
srs_freep
(
msg
);
}
#else
msgs
.
free
();
#endif
msgs
.
clear
();
...
...
trunk/src/app/srs_app_source.hpp
查看文件 @
5a2b8af
...
...
@@ -102,6 +102,34 @@ public:
virtual
int
get_time
();
};
#ifdef SRS_PERF_QUEUE_FAST_VECTOR
/**
* to alloc and increase fixed space,
* fast remove and insert for msgs sender.
* @see https://github.com/winlinvip/simple-rtmp-server/issues/251
*/
class
SrsFastVector
{
private
:
SrsSharedPtrMessage
**
msgs
;
int
nb_msgs
;
int
count
;
public
:
SrsFastVector
();
virtual
~
SrsFastVector
();
public
:
virtual
int
size
();
virtual
int
begin
();
virtual
int
end
();
virtual
SrsSharedPtrMessage
**
data
();
virtual
SrsSharedPtrMessage
*
at
(
int
index
);
virtual
void
clear
();
virtual
void
erase
(
int
_begin
,
int
_end
);
virtual
void
push_back
(
SrsSharedPtrMessage
*
msg
);
virtual
void
free
();
};
#endif
/**
* the message queue for the consumer(client), forwarder.
* we limit the size in seconds, drop old messages(the whole gop) if full.
...
...
@@ -112,7 +140,11 @@ private:
int64_t
av_start_time
;
int64_t
av_end_time
;
int
queue_size_ms
;
#ifdef SRS_PERF_QUEUE_FAST_VECTOR
SrsFastVector
msgs
;
#else
std
::
vector
<
SrsSharedPtrMessage
*>
msgs
;
#endif
public
:
SrsMessageQueue
();
virtual
~
SrsMessageQueue
();
...
...
trunk/src/core/srs_core.hpp
查看文件 @
5a2b8af
...
...
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version
#define VERSION_MAJOR 2
#define VERSION_MINOR 0
#define VERSION_REVISION 6
5
#define VERSION_REVISION 6
6
// server info.
#define RTMP_SIG_SRS_KEY "SRS"
#define RTMP_SIG_SRS_ROLE "origin/edge server"
...
...
trunk/src/core/srs_core_performance.hpp
查看文件 @
5a2b8af
...
...
@@ -135,6 +135,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#undef SRS_PERF_QUEUE_FAST_CACHE
/**
* whether enable the fast vector for qeueue.
* @see https://github.com/winlinvip/simple-rtmp-server/issues/251
*/
#undef SRS_PERF_QUEUE_FAST_VECTOR
/**
* whether use cond wait to send messages.
* @remark this improve performance for large connectios.
* @see https://github.com/winlinvip/simple-rtmp-server/issues/251
...
...
请
注册
或
登录
后发表评论