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-11-28 14:53:46 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
af5e7f002fc2d3aa98db470c60318874d25d9d17
af5e7f00
1 parent
005f8214
fix the memory leak error
隐藏空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
36 行增加
和
24 行删除
trunk/conf/srs.conf
trunk/src/core/srs_core_client.cpp
trunk/src/core/srs_core_codec.cpp
trunk/src/core/srs_core_protocol.cpp
trunk/src/core/srs_core_protocol.hpp
trunk/src/core/srs_core_source.cpp
trunk/conf/srs.conf
查看文件 @
af5e7f0
# the listen ports, split by space.
listen
193
5
;
listen
193
6
;
# the default chunk size is 128, max is 65536,
# some client does not support chunk size change,
# however, most clients supports it and it can improve
...
...
@@ -10,7 +10,7 @@ chunk_size 65000;
# for which cannot identify the required vhost.
vhost
__
defaultVhost__
{
enabled
on
;
gop_cache
o
n
;
gop_cache
o
ff
;
hls
on
;
hls_path
./
objs
/
nginx
/
html
;
hls_fragment
5
;
...
...
trunk/src/core/srs_core_client.cpp
查看文件 @
af5e7f0
...
...
@@ -384,7 +384,7 @@ int SrsClient::process_publish_message(SrsSource* source, SrsCommonMessage* msg,
int
ret
=
ERROR_SUCCESS
;
// process audio packet
if
(
msg
->
header
.
is_audio
())
{
if
(
false
&&
msg
->
header
.
is_audio
())
{
if
((
ret
=
source
->
on_audio
(
msg
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"source process audio message failed. ret=%d"
,
ret
);
return
ret
;
...
...
trunk/src/core/srs_core_codec.cpp
查看文件 @
af5e7f0
...
...
@@ -41,7 +41,7 @@ void SrsCodecBuffer::append(void* data, int len)
{
srs_assert
(
data
);
srs_assert
(
len
>
0
);
bytes
=
(
char
*
)
realloc
(
bytes
,
size
+
len
);
memcpy
(
bytes
+
size
,
data
,
len
);
size
+=
len
;
...
...
trunk/src/core/srs_core_protocol.cpp
查看文件 @
af5e7f0
...
...
@@ -1356,11 +1356,26 @@ bool SrsSharedPtrMessage::can_decode()
return
false
;
}
int
SrsSharedPtrMessage
::
initialize
(
ISrsMessage
*
msg
,
char
*
payload
,
int
siz
e
)
int
SrsSharedPtrMessage
::
initialize
(
SrsCommonMessage
*
sourc
e
)
{
int
ret
=
ERROR_SUCCESS
;
srs_assert
(
msg
!=
NULL
);
if
((
ret
=
initialize
(
source
,
(
char
*
)
source
->
payload
,
source
->
size
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
// detach the payload from source
source
->
payload
=
NULL
;
source
->
size
=
0
;
return
ret
;
}
int
SrsSharedPtrMessage
::
initialize
(
SrsCommonMessage
*
source
,
char
*
payload
,
int
size
)
{
int
ret
=
ERROR_SUCCESS
;
srs_assert
(
source
!=
NULL
);
if
(
ptr
)
{
ret
=
ERROR_SYSTEM_ASSERT_FAILED
;
srs_error
(
"should not set the payload twice. ret=%d"
,
ret
);
...
...
@@ -1369,20 +1384,18 @@ int SrsSharedPtrMessage::initialize(ISrsMessage* msg, char* payload, int size)
return
ret
;
}
header
=
msg
->
header
;
header
=
source
->
header
;
header
.
payload_length
=
size
;
ptr
=
new
SrsSharedPtr
();
// should copy the payload once
// TODO: maybe can directly attach the common message.
ptr
->
payload
=
new
char
[
size
];
memcpy
(
ptr
->
payload
,
payload
,
size
);
// direct attach the data of common message.
ptr
->
payload
=
payload
;
ptr
->
size
=
size
;
if
(
msg
->
header
.
is_video
())
{
if
(
source
->
header
.
is_video
())
{
ptr
->
perfer_cid
=
RTMP_CID_Video
;
}
else
if
(
msg
->
header
.
is_audio
())
{
}
else
if
(
source
->
header
.
is_audio
())
{
ptr
->
perfer_cid
=
RTMP_CID_Audio
;
}
else
{
ptr
->
perfer_cid
=
RTMP_CID_OverConnection2
;
...
...
trunk/src/core/srs_core_protocol.hpp
查看文件 @
af5e7f0
...
...
@@ -375,8 +375,15 @@ public:
public
:
/**
* set the shared payload.
* we will detach the payload of source,
* so ensure donot use it before.
*/
virtual
int
initialize
(
ISrsMessage
*
msg
,
char
*
payload
,
int
size
);
virtual
int
initialize
(
SrsCommonMessage
*
source
);
/**
* set the shared payload.
* we will use the payload, donot use the payload of source.
*/
virtual
int
initialize
(
SrsCommonMessage
*
source
,
char
*
payload
,
int
size
);
virtual
SrsSharedPtrMessage
*
copy
();
public
:
/**
...
...
trunk/src/core/srs_core_source.cpp
查看文件 @
af5e7f0
...
...
@@ -370,7 +370,7 @@ int SrsSource::on_audio(SrsCommonMessage* audio)
SrsSharedPtrMessage
*
msg
=
new
SrsSharedPtrMessage
();
SrsAutoFree
(
SrsSharedPtrMessage
,
msg
,
false
);
if
((
ret
=
msg
->
initialize
(
audio
,
(
char
*
)
audio
->
payload
,
audio
->
size
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
msg
->
initialize
(
audio
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"initialize the audio failed. ret=%d"
,
ret
);
return
ret
;
}
...
...
@@ -383,10 +383,6 @@ int SrsSource::on_audio(SrsCommonMessage* audio)
}
#endif
// detach the original audio
audio
->
payload
=
NULL
;
audio
->
size
=
0
;
// copy to all consumer
std
::
vector
<
SrsConsumer
*>::
iterator
it
;
for
(
it
=
consumers
.
begin
();
it
!=
consumers
.
end
();
++
it
)
{
...
...
@@ -422,7 +418,7 @@ int SrsSource::on_video(SrsCommonMessage* video)
SrsSharedPtrMessage
*
msg
=
new
SrsSharedPtrMessage
();
SrsAutoFree
(
SrsSharedPtrMessage
,
msg
,
false
);
if
((
ret
=
msg
->
initialize
(
video
,
(
char
*
)
video
->
payload
,
video
->
size
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
msg
->
initialize
(
video
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"initialize the video failed. ret=%d"
,
ret
);
return
ret
;
}
...
...
@@ -435,10 +431,6 @@ int SrsSource::on_video(SrsCommonMessage* video)
}
#endif
// detach the original audio
video
->
payload
=
NULL
;
video
->
size
=
0
;
// copy to all consumer
std
::
vector
<
SrsConsumer
*>::
iterator
it
;
for
(
it
=
consumers
.
begin
();
it
!=
consumers
.
end
();
++
it
)
{
...
...
请
注册
或
登录
后发表评论