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-30 19:14:19 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ce15f4bce342a7d572501f169d8c410a3e2e2aa3
ce15f4bc
1 parent
8d91561c
update encoder framework
显示空白字符变更
内嵌
并排对比
正在显示
7 个修改的文件
包含
100 行增加
和
10 行删除
README.md
trunk/src/core/srs_core_config.cpp
trunk/src/core/srs_core_config.hpp
trunk/src/core/srs_core_encoder.cpp
trunk/src/core/srs_core_encoder.hpp
trunk/src/core/srs_core_forward.cpp
trunk/src/core/srs_core_forward.hpp
README.md
查看文件 @
ce15f4b
...
...
@@ -117,7 +117,7 @@ usr sys idl wai hiq siq| read writ| recv send| in out | int csw
*
nginx v1.5.0: 139524 lines
<br/>
### History
*
v0.7, 2013-11-30,
add transcoding params to confi
g.
*
v0.7, 2013-11-30,
support live stream transcoding by ffmpe
g.
*
v0.7, 2013-11-30, support --with/without -ffmpeg, build ffmpeg-2.1.
*
v0.7, 2013-11-30, add ffmpeg-2.1, x264-core138, lame-3.99.5, libaacplus-2.0.2.
*
v0.6, 2013-11-29, v0.6 released. 16094 lines.
...
...
trunk/src/core/srs_core_config.cpp
查看文件 @
ce15f4b
...
...
@@ -568,7 +568,7 @@ SrsConfDirective* SrsConfig::get_vhost_enabled(std::string vhost)
return
conf
->
get
(
"enabled"
);
}
SrsConfDirective
*
SrsConfig
::
get_transcode
(
std
::
string
vhost
)
SrsConfDirective
*
SrsConfig
::
get_transcode
(
std
::
string
vhost
,
std
::
string
scope
)
{
SrsConfDirective
*
conf
=
get_vhost
(
vhost
);
...
...
@@ -576,7 +576,16 @@ SrsConfDirective* SrsConfig::get_transcode(std::string vhost)
return
NULL
;
}
return
conf
->
get
(
"transcode"
);
SrsConfDirective
*
transcode
=
conf
->
get
(
"transcode"
);
if
(
!
transcode
)
{
return
NULL
;
}
if
(
transcode
->
arg0
()
==
scope
)
{
return
transcode
;
}
return
NULL
;
}
SrsConfDirective
*
SrsConfig
::
get_gop_cache
(
std
::
string
vhost
)
...
...
trunk/src/core/srs_core_config.hpp
查看文件 @
ce15f4b
...
...
@@ -114,7 +114,7 @@ public:
virtual
int
parse_options
(
int
argc
,
char
**
argv
);
virtual
SrsConfDirective
*
get_vhost
(
std
::
string
vhost
);
virtual
SrsConfDirective
*
get_vhost_enabled
(
std
::
string
vhost
);
virtual
SrsConfDirective
*
get_transcode
(
std
::
string
vhost
);
virtual
SrsConfDirective
*
get_transcode
(
std
::
string
vhost
,
std
::
string
scope
);
virtual
SrsConfDirective
*
get_gop_cache
(
std
::
string
vhost
);
virtual
SrsConfDirective
*
get_forward
(
std
::
string
vhost
);
virtual
SrsConfDirective
*
get_hls
(
std
::
string
vhost
);
...
...
trunk/src/core/srs_core_encoder.cpp
查看文件 @
ce15f4b
...
...
@@ -25,22 +25,89 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_core_error.hpp>
#include <srs_core_log.hpp>
#include <srs_core_config.hpp>
#define SRS_ENCODER_SLEEP_MS 2000
SrsEncoder
::
SrsEncoder
()
{
tid
=
NULL
;
loop
=
false
;
}
SrsEncoder
::~
SrsEncoder
()
{
on_unpublish
();
}
int
SrsEncoder
::
on_publish
(
std
::
string
vhost
,
std
::
string
app
,
std
::
string
stream
)
int
SrsEncoder
::
on_publish
(
std
::
string
_vhost
,
std
::
string
_app
,
std
::
string
_
stream
)
{
int
ret
=
ERROR_SUCCESS
;
vhost
=
_vhost
;
app
=
_app
;
stream
=
_stream
;
srs_assert
(
!
tid
);
if
((
tid
=
st_thread_create
(
encoder_thread
,
this
,
1
,
0
))
==
NULL
){
ret
=
ERROR_ST_CREATE_FORWARD_THREAD
;
srs_error
(
"st_thread_create failed. ret=%d"
,
ret
);
return
ret
;
}
return
ret
;
}
void
SrsEncoder
::
on_unpublish
()
{
if
(
tid
)
{
loop
=
false
;
st_thread_interrupt
(
tid
);
st_thread_join
(
tid
,
NULL
);
tid
=
NULL
;
}
}
int
SrsEncoder
::
cycle
()
{
int
ret
=
ERROR_SUCCESS
;
return
ret
;
}
void
SrsEncoder
::
encoder_cycle
()
{
int
ret
=
ERROR_SUCCESS
;
log_context
->
generate_id
();
srs_trace
(
"encoder cycle start"
);
while
(
loop
)
{
if
((
ret
=
cycle
())
!=
ERROR_SUCCESS
)
{
srs_warn
(
"encoder cycle failed, ignored and retry, ret=%d"
,
ret
);
}
else
{
srs_info
(
"encoder cycle success, retry"
);
}
if
(
!
loop
)
{
break
;
}
st_usleep
(
SRS_ENCODER_SLEEP_MS
*
1000
);
}
// TODO: kill ffmpeg when finished and it alive
srs_trace
(
"encoder cycle finished"
);
}
void
*
SrsEncoder
::
encoder_thread
(
void
*
arg
)
{
SrsEncoder
*
obj
=
(
SrsEncoder
*
)
arg
;
srs_assert
(
obj
!=
NULL
);
obj
->
loop
=
true
;
obj
->
encoder_cycle
();
return
NULL
;
}
...
...
trunk/src/core/srs_core_encoder.hpp
查看文件 @
ce15f4b
...
...
@@ -31,14 +31,27 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <string>
#include <st.h>
class
SrsEncoder
{
private
:
std
::
string
vhost
;
std
::
string
app
;
std
::
string
stream
;
private
:
st_thread_t
tid
;
bool
loop
;
public
:
SrsEncoder
();
virtual
~
SrsEncoder
();
public
:
virtual
int
on_publish
(
std
::
string
vhost
,
std
::
string
app
,
std
::
string
stream
);
virtual
void
on_unpublish
();
private
:
virtual
int
cycle
();
virtual
void
encoder_cycle
();
static
void
*
encoder_thread
(
void
*
arg
);
};
#endif
...
...
trunk/src/core/srs_core_forward.cpp
查看文件 @
ce15f4b
...
...
@@ -43,10 +43,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
SrsForwarder
::
SrsForwarder
()
{
client
=
NULL
;
tid
=
NULL
;
stfd
=
NULL
;
loop
=
false
;
stream_id
=
0
;
tid
=
NULL
;
loop
=
false
;
}
SrsForwarder
::~
SrsForwarder
()
...
...
@@ -221,7 +222,7 @@ std::string SrsForwarder::parse_server(std::string host)
return
ipv4
;
}
int
SrsForwarder
::
forward_cycle_imp
()
int
SrsForwarder
::
cycle
()
{
int
ret
=
ERROR_SUCCESS
;
...
...
@@ -316,7 +317,7 @@ void SrsForwarder::forward_cycle()
srs_trace
(
"forward cycle start"
);
while
(
loop
)
{
if
((
ret
=
forward_cycle_imp
())
!=
ERROR_SUCCESS
)
{
if
((
ret
=
cycle
())
!=
ERROR_SUCCESS
)
{
srs_warn
(
"forward cycle failed, ignored and retry, ret=%d"
,
ret
);
}
else
{
srs_info
(
"forward cycle success, retry"
);
...
...
trunk/src/core/srs_core_forward.hpp
查看文件 @
ce15f4b
...
...
@@ -71,7 +71,7 @@ private:
virtual
int
connect_server
();
std
::
string
parse_server
(
std
::
string
host
);
private
:
virtual
int
forward_cycle_imp
();
virtual
int
cycle
();
virtual
int
forward
();
virtual
void
forward_cycle
();
static
void
*
forward_thread
(
void
*
arg
);
...
...
请
注册
或
登录
后发表评论