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 18:31:07 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8d91561ca021dd5b2f647fa08ef344d620fe28b9
8d91561c
1 parent
b1466c88
add ffmpeg transcoding framework
隐藏空白字符变更
内嵌
并排对比
正在显示
9 个修改的文件
包含
161 行增加
和
1 行删除
trunk/conf/srs.conf
trunk/configure
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_source.cpp
trunk/src/core/srs_core_source.hpp
trunk/src/srs/srs.upp
trunk/conf/srs.conf
查看文件 @
8d91561
...
...
@@ -20,6 +20,7 @@ vhost __defaultVhost__ {
enabled
on
;
ffmpeg
./
objs
/
ffmpeg
/
bin
/
ffmpeg
;
engine
fd
{
enabled
on
;
vcodec
libx264
;
vbitrate
300
;
vfps
20
;
...
...
@@ -47,9 +48,12 @@ vhost all.transcode.vhost.com {
enabled
on
;
# the ffmpeg
ffmpeg
./
objs
/
ffmpeg
/
bin
/
ffmpeg
;
# the transcode engine for matched stream.
# all matched stream will transcoded to the following stream.
# the transcode set name(ie. hd) is optional and not used.
engine
super
{
# whether the engine is enabled
enabled
on
;
# video encoder name
vcodec
libx264
;
# video bitrate, in kbps
...
...
@@ -92,6 +96,7 @@ vhost all.transcode.vhost.com {
output
rtmp
://[
vhost
]:[
port
]/[
app
]/[
stream
]
_
super
;
}
engine
hd
{
enabled
on
;
vcodec
libx264
;
vbitrate
1200
;
vfps
25
;
...
...
@@ -111,6 +116,7 @@ vhost all.transcode.vhost.com {
output
rtmp
://[
vhost
]:[
port
]/[
app
]/[
stream
]
_
hd
;
}
engine
sd
{
enabled
on
;
vcodec
libx264
;
vbitrate
800
;
vfps
25
;
...
...
@@ -130,6 +136,7 @@ vhost all.transcode.vhost.com {
output
rtmp
://[
vhost
]:[
port
]/[
app
]/[
stream
]
_
sd
;
}
engine
fast
{
enabled
on
;
vcodec
libx264
;
vbitrate
300
;
vfps
20
;
...
...
@@ -150,6 +157,30 @@ vhost all.transcode.vhost.com {
}
}
}
# transcode all app and stream of app
vhost
app
.
transcode
.
vhost
.
com
{
# the streaming transcode configs.
# if app specified, transcode all streams of app.
transcode
live
{
enabled
on
;
ffmpeg
./
objs
/
ffmpeg
/
bin
/
ffmpeg
;
engine
fd
{
enabled
off
;
}
}
}
# transcode specified stream.
vhost
stream
.
transcode
.
vhost
.
com
{
# the streaming transcode configs.
# if stream specified, transcode the matched stream.
transcode
live
/
livestream
{
enabled
on
;
ffmpeg
./
objs
/
ffmpeg
/
bin
/
ffmpeg
;
engine
fd
{
enabled
off
;
}
}
}
# the vhost which forward publish streams.
vhost
forward
.
vhost
.
com
{
# forward all publish stream to the specified server.
...
...
trunk/configure
查看文件 @
8d91561
...
...
@@ -98,7 +98,7 @@ MODULE_FILES=("srs_core" "srs_core_log" "srs_core_server"
"srs_core_stream"
"srs_core_source"
"srs_core_codec"
"srs_core_handshake"
"srs_core_pithy_print"
"srs_core_config"
"srs_core_refer"
"srs_core_reload"
"srs_core_hls"
"srs_core_forward"
)
"srs_core_hls"
"srs_core_forward"
"srs_core_encoder"
)
MODULE_DIR
=
"src/core"
. auto/modules.sh
CORE_OBJS
=
"
${
MODULE_OBJS
[@]
}
"
...
...
trunk/src/core/srs_core_config.cpp
查看文件 @
8d91561
...
...
@@ -568,6 +568,17 @@ SrsConfDirective* SrsConfig::get_vhost_enabled(std::string vhost)
return
conf
->
get
(
"enabled"
);
}
SrsConfDirective
*
SrsConfig
::
get_transcode
(
std
::
string
vhost
)
{
SrsConfDirective
*
conf
=
get_vhost
(
vhost
);
if
(
!
conf
)
{
return
NULL
;
}
return
conf
->
get
(
"transcode"
);
}
SrsConfDirective
*
SrsConfig
::
get_gop_cache
(
std
::
string
vhost
)
{
SrsConfDirective
*
conf
=
get_vhost
(
vhost
);
...
...
@@ -732,6 +743,7 @@ int SrsConfig::parse_file(const char* filename)
// TODO: check other config.
// TODO: check hls.
// TODO: check ssl.
// TODO: check ffmpeg.
return
ret
;
}
...
...
trunk/src/core/srs_core_config.hpp
查看文件 @
8d91561
...
...
@@ -114,6 +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_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
0 → 100644
查看文件 @
8d91561
/*
The MIT License (MIT)
Copyright (c) 2013 winlin
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_core_encoder.hpp>
#include <srs_core_error.hpp>
#include <srs_core_log.hpp>
SrsEncoder
::
SrsEncoder
()
{
}
SrsEncoder
::~
SrsEncoder
()
{
}
int
SrsEncoder
::
on_publish
(
std
::
string
vhost
,
std
::
string
app
,
std
::
string
stream
)
{
int
ret
=
ERROR_SUCCESS
;
return
ret
;
}
void
SrsEncoder
::
on_unpublish
()
{
}
...
...
trunk/src/core/srs_core_encoder.hpp
0 → 100644
查看文件 @
8d91561
/*
The MIT License (MIT)
Copyright (c) 2013 winlin
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef SRS_CORE_ENCODER_HPP
#define SRS_CORE_ENCODER_HPP
/*
#include <srs_core_encoder.hpp>
*/
#include <srs_core.hpp>
#include <string>
class
SrsEncoder
{
public
:
SrsEncoder
();
virtual
~
SrsEncoder
();
public
:
virtual
int
on_publish
(
std
::
string
vhost
,
std
::
string
app
,
std
::
string
stream
);
virtual
void
on_unpublish
();
};
#endif
...
...
trunk/src/core/srs_core_source.cpp
查看文件 @
8d91561
...
...
@@ -33,6 +33,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_core_hls.hpp>
#include <srs_core_forward.hpp>
#include <srs_core_config.hpp>
#include <srs_core_encoder.hpp>
#define CONST_MAX_JITTER_MS 500
#define DEFAULT_FRAME_TIME_MS 10
...
...
@@ -354,6 +355,9 @@ SrsSource::SrsSource(std::string _stream_url)
#ifdef SRS_HLS
hls
=
new
SrsHls
();
#endif
#ifdef SRS_FFMPEG
encoder
=
new
SrsEncoder
();
#endif
cache_metadata
=
cache_sh_video
=
cache_sh_audio
=
NULL
;
...
...
@@ -392,6 +396,9 @@ SrsSource::~SrsSource()
#ifdef SRS_HLS
srs_freep
(
hls
);
#endif
#ifdef SRS_FFMPEG
srs_freep
(
encoder
);
#endif
}
bool
SrsSource
::
can_publish
()
...
...
@@ -617,6 +624,12 @@ int SrsSource::on_publish(std::string vhost, std::string app, std::string stream
}
#endif
#ifdef SRS_FFMPEG
if
((
ret
=
encoder
->
on_publish
(
vhost
,
app
,
stream
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
#endif
// TODO: support reload.
// create forwarders
...
...
@@ -645,6 +658,10 @@ void SrsSource::on_unpublish()
hls
->
on_unpublish
();
#endif
#ifdef SRS_FFMPEG
encoder
->
on_unpublish
();
#endif
// close all forwarders
std
::
vector
<
SrsForwarder
*>::
iterator
it
;
for
(
it
=
forwarders
.
begin
();
it
!=
forwarders
.
end
();
++
it
)
{
...
...
trunk/src/core/srs_core_source.hpp
查看文件 @
8d91561
...
...
@@ -42,6 +42,9 @@ class SrsForwarder;
#ifdef SRS_HLS
class
SrsHls
;
#endif
#ifdef SRS_FFMPEG
class
SrsEncoder
;
#endif
/**
* time jitter detect and correct,
...
...
@@ -172,6 +175,10 @@ private:
#ifdef SRS_HLS
SrsHls
*
hls
;
#endif
// transcoding handler.
#ifdef SRS_FFMPEG
SrsEncoder
*
encoder
;
#endif
// gop cache for client fast startup.
SrsGopCache
*
gop_cache
;
// to forward stream to other servers
...
...
trunk/src/srs/srs.upp
查看文件 @
8d91561
...
...
@@ -26,6 +26,8 @@ file
..\core\srs_core_source.cpp,
..\core\srs_core_forward.hpp,
..\core\srs_core_forward.cpp,
..\core\srs_core_encoder.hpp,
..\core\srs_core_encoder.cpp,
..\core\srs_core_hls.hpp,
..\core\srs_core_hls.cpp,
..\core\srs_core_codec.hpp,
...
...
请
注册
或
登录
后发表评论