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-12-02 23:51:51 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
113731dd6b6331244a71606dfec0bc370324200b
113731dd
1 parent
b5bba297
reap the transcode process
隐藏空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
63 行增加
和
12 行删除
trunk/conf/srs.conf
trunk/src/core/srs_core_encoder.cpp
trunk/src/core/srs_core_encoder.hpp
trunk/src/core/srs_core_error.hpp
trunk/src/core/srs_core_hls.cpp
trunk/src/core/srs_core_hls.hpp
trunk/conf/srs.conf
查看文件 @
113731d
...
...
@@ -72,18 +72,19 @@ vhost __defaultVhost__ {
vhost
dev
{
enabled
on
;
gop_cache
on
;
hls
o
n
;
hls
o
ff
;
hls_path
./
objs
/
nginx
/
html
;
hls_fragment
5
;
hls_window
30
;
#forward 127.0.0.1:19350;
forward
127
.
0
.
0
.
1
:
1936
;
#
forward 127.0.0.1:1936;
transcode
{
enabled
o
ff
;
enabled
o
n
;
ffmpeg
./
objs
/
ffmpeg
/
bin
/
ffmpeg
;
engine
dev
{
enabled
on
;
vfilter
{
t
10
;
}
vcodec
libx264
;
vbitrate
300
;
...
...
trunk/src/core/srs_core_encoder.cpp
查看文件 @
113731d
...
...
@@ -25,6 +25,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#include <algorithm>
...
...
@@ -356,6 +357,34 @@ int SrsFFMPEG::start()
return
ret
;
}
int
SrsFFMPEG
::
cycle
()
{
int
ret
=
ERROR_SUCCESS
;
if
(
!
started
)
{
return
ret
;
}
int
status
=
0
;
pid_t
p
=
waitpid
(
pid
,
&
status
,
WNOHANG
);
if
(
p
<
0
)
{
ret
=
ERROR_SYSTEM_WAITPID
;
srs_error
(
"transcode waitpid failed, pid=%d, ret=%d"
,
pid
,
ret
);
return
ret
;
}
if
(
p
==
0
)
{
srs_info
(
"transcode process pid=%d is running."
,
pid
);
return
ret
;
}
srs_trace
(
"transcode process pid=%d terminate, restart it."
,
pid
);
started
=
false
;
return
ret
;
}
void
SrsFFMPEG
::
stop
()
{
if
(
!
started
)
{
...
...
@@ -538,18 +567,23 @@ int SrsEncoder::cycle()
{
int
ret
=
ERROR_SUCCESS
;
// start all ffmpegs.
std
::
vector
<
SrsFFMPEG
*>::
iterator
it
;
for
(
it
=
ffmpegs
.
begin
();
it
!=
ffmpegs
.
end
();
++
it
)
{
SrsFFMPEG
*
ffmpeg
=
*
it
;
// start all ffmpegs.
if
((
ret
=
ffmpeg
->
start
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"ffmpeg start failed. ret=%d"
,
ret
);
return
ret
;
}
// check ffmpeg status.
if
((
ret
=
ffmpeg
->
cycle
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"ffmpeg cycle failed. ret=%d"
,
ret
);
return
ret
;
}
}
// TODO: cycle all processes.
return
ret
;
}
...
...
trunk/src/core/srs_core_encoder.hpp
查看文件 @
113731d
...
...
@@ -73,6 +73,7 @@ public:
public
:
virtual
int
initialize
(
SrsRequest
*
req
,
SrsConfDirective
*
engine
);
virtual
int
start
();
virtual
int
cycle
();
virtual
void
stop
();
};
...
...
trunk/src/core/srs_core_error.hpp
查看文件 @
113731d
...
...
@@ -86,6 +86,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define ERROR_SYSTEM_IP_INVALID 411
#define ERROR_SYSTEM_CONFIG_TOO_LARGE 412
#define ERROR_SYSTEM_FORWARD_LOOP 413
#define ERROR_SYSTEM_WAITPID 414
// see librtmp.
// failed when open ssl create the dh
...
...
trunk/src/core/srs_core_hls.cpp
查看文件 @
113731d
...
...
@@ -502,6 +502,7 @@ SrsM3u8Muxer::SrsM3u8Muxer()
video_stream_dts
=
0
;
file_index
=
0
;
current
=
NULL
;
_is_open
=
false
;
}
SrsM3u8Muxer
::~
SrsM3u8Muxer
()
...
...
@@ -516,6 +517,11 @@ SrsM3u8Muxer::~SrsM3u8Muxer()
srs_freep
(
current
);
}
bool
SrsM3u8Muxer
::
is_open
()
{
return
_is_open
;
}
int
SrsM3u8Muxer
::
update_config
(
std
::
string
_app
,
std
::
string
_stream
,
std
::
string
path
,
int
fragment
,
int
window
...
...
@@ -571,6 +577,8 @@ int SrsM3u8Muxer::segment_open()
srs_info
(
"open HLS muxer success. vhost=%s, path=%s"
,
vhost
.
c_str
(),
current
->
full_path
.
c_str
());
_is_open
=
true
;
return
ret
;
}
...
...
@@ -709,6 +717,8 @@ int SrsM3u8Muxer::segment_close()
return
ret
;
}
_is_open
=
false
;
return
ret
;
}
...
...
@@ -1171,12 +1181,14 @@ void SrsHls::on_unpublish()
{
int
ret
=
ERROR_SUCCESS
;
// close muxer when unpublish.
ret
=
ts_cache
->
flush_audio
(
muxer
);
ret
+=
muxer
->
segment_close
();
if
(
ret
!=
ERROR_SUCCESS
)
{
srs_error
(
"ignore m3u8 muxer flush/close audio failed. ret=%d"
,
ret
);
return
;
if
(
muxer
->
is_open
())
{
// close muxer when unpublish.
ret
=
ts_cache
->
flush_audio
(
muxer
);
ret
+=
muxer
->
segment_close
();
if
(
ret
!=
ERROR_SUCCESS
)
{
srs_error
(
"ignore m3u8 muxer flush/close audio failed. ret=%d"
,
ret
);
}
}
hls_enabled
=
false
;
...
...
trunk/src/core/srs_core_hls.hpp
查看文件 @
113731d
...
...
@@ -131,6 +131,7 @@ private:
int
hls_fragment
;
int
hls_window
;
private
:
bool
_is_open
;
int
file_index
;
std
::
string
m3u8
;
private
:
...
...
@@ -148,6 +149,7 @@ public:
SrsM3u8Muxer
();
virtual
~
SrsM3u8Muxer
();
public
:
virtual
bool
is_open
();
virtual
int
update_config
(
std
::
string
_app
,
std
::
string
_stream
,
std
::
string
path
,
int
fragment
,
int
window
);
virtual
int
segment_open
();
virtual
int
flush_audio
(
SrsMpegtsFrame
*
af
,
SrsCodecBuffer
*
ab
);
...
...
请
注册
或
登录
后发表评论