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-24 17:15:37 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
4af3982721049c4478abf4dd04785a56825f09af
4af39827
1 parent
3623af8a
add ts muxer to write hls/ts file
显示空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
94 行增加
和
6 行删除
trunk/src/core/srs_core_client.cpp
trunk/src/core/srs_core_config.cpp
trunk/src/core/srs_core_config.hpp
trunk/src/core/srs_core_error.hpp
trunk/src/core/srs_core_hls.cpp
trunk/src/core/srs_core_hls.hpp
trunk/src/core/srs_core_client.cpp
查看文件 @
4af3982
...
...
@@ -223,7 +223,7 @@ int SrsClient::check_vhost()
}
SrsConfDirective
*
conf
=
NULL
;
if
((
conf
=
vhost
->
get
(
RTMP_VHOST_ENABLED
))
!=
NULL
&&
conf
->
arg0
()
!=
"on"
)
{
if
((
conf
=
config
->
get_vhost_enabled
(
req
->
vhost
))
!=
NULL
&&
conf
->
arg0
()
!=
"on"
)
{
ret
=
ERROR_RTMP_VHOST_NOT_FOUND
;
srs_error
(
"vhost %s disabled. ret=%d"
,
req
->
vhost
.
c_str
(),
ret
);
return
ret
;
...
...
@@ -336,7 +336,7 @@ int SrsClient::publish(SrsSource* source, bool is_fmle)
SrsHLS
*
hls
=
source
->
get_hls
();
// notify the hls to prepare when publish start.
if
((
ret
=
hls
->
on_publish
())
!=
ERROR_SUCCESS
)
{
if
((
ret
=
hls
->
on_publish
(
req
->
vhost
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"hls on_publish failed. ret=%d"
,
ret
);
return
ret
;
}
...
...
trunk/src/core/srs_core_config.cpp
查看文件 @
4af3982
...
...
@@ -551,6 +551,17 @@ SrsConfDirective* SrsConfig::get_vhost(std::string vhost)
return
NULL
;
}
SrsConfDirective
*
SrsConfig
::
get_vhost_enabled
(
std
::
string
vhost
)
{
SrsConfDirective
*
conf
=
get_vhost
(
vhost
);
if
(
!
conf
)
{
return
NULL
;
}
return
conf
->
get
(
"enabled"
);
}
SrsConfDirective
*
SrsConfig
::
get_gop_cache
(
std
::
string
vhost
)
{
SrsConfDirective
*
conf
=
get_vhost
(
vhost
);
...
...
@@ -668,6 +679,8 @@ int SrsConfig::parse_file(const char* filename)
"directive
\"
listen
\"
is empty, ret=%d"
,
(
conf
?
conf
->
conf_line
:
0
),
ret
);
return
ret
;
}
// TODO: check the hls.
// TODO: check other config.
return
ret
;
}
...
...
trunk/src/core/srs_core_config.hpp
查看文件 @
4af3982
...
...
@@ -37,8 +37,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// default vhost for rtmp
#define RTMP_VHOST_DEFAULT "__defaultVhost__"
// conf node: enabled.
#define RTMP_VHOST_ENABLED "enabled"
#define SRS_CONF_DEFAULT_HLS_PATH "./hls"
class
SrsFileBuffer
{
...
...
@@ -108,6 +107,7 @@ public:
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_gop_cache
(
std
::
string
vhost
);
virtual
SrsConfDirective
*
get_hls
(
std
::
string
vhost
);
virtual
SrsConfDirective
*
get_hls_path
(
std
::
string
vhost
);
...
...
trunk/src/core/srs_core_error.hpp
查看文件 @
4af3982
...
...
@@ -109,5 +109,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define ERROR_HLS_METADATA 600
#define ERROR_HLS_DECODE_ERROR 601
#define ERROR_HLS_BUSY 602
#endif
\ No newline at end of file
...
...
trunk/src/core/srs_core_hls.cpp
查看文件 @
4af3982
...
...
@@ -27,27 +27,62 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_core_codec.hpp>
#include <srs_core_amf0.hpp>
#include <srs_core_protocol.hpp>
#include <srs_core_config.hpp>
SrsHLS
::
SrsHLS
()
{
hls_enabled
=
false
;
codec
=
new
SrsCodec
();
sample
=
new
SrsCodecSample
();
muxer
=
NULL
;
}
SrsHLS
::~
SrsHLS
()
{
srs_freep
(
codec
);
srs_freep
(
sample
);
srs_freep
(
muxer
);
}
int
SrsHLS
::
on_publish
()
int
SrsHLS
::
on_publish
(
std
::
string
_vhost
)
{
int
ret
=
ERROR_SUCCESS
;
if
(
muxer
)
{
ret
=
ERROR_HLS_BUSY
;
srs_error
(
"hls is busy, something error, "
"vhost=%s, ret=%d"
,
_vhost
.
c_str
(),
ret
);
return
ret
;
}
vhost
=
_vhost
;
muxer
=
new
SrsTSMuxer
();
// try to open the HLS muxer
SrsConfDirective
*
conf
=
config
->
get_hls
(
vhost
);
if
(
!
conf
&&
conf
->
arg0
()
==
"off"
)
{
return
ret
;
}
hls_enabled
=
true
;
std
::
string
path
=
SRS_CONF_DEFAULT_HLS_PATH
;
if
((
conf
=
config
->
get_hls_path
(
vhost
))
!=
NULL
)
{
path
=
conf
->
arg0
();
}
if
((
ret
=
muxer
->
open
(
path
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"open hls muxer failed. ret=%d"
,
ret
);
return
ret
;
}
return
ret
;
}
void
SrsHLS
::
on_unpublish
()
{
hls_enabled
=
false
;
srs_freep
(
muxer
);
}
int
SrsHLS
::
on_meta_data
(
SrsOnMetaDataPacket
*
metadata
)
...
...
@@ -145,6 +180,11 @@ int SrsHLS::on_audio(SrsCommonMessage* audio)
return
ret
;
}
// TODO: maybe donot need to demux the aac?
if
(
!
hls_enabled
)
{
return
ret
;
}
return
ret
;
}
...
...
@@ -161,6 +201,25 @@ int SrsHLS::on_video(SrsCommonMessage* video)
return
ret
;
}
// TODO: maybe donot need to demux the avc?
if
(
!
hls_enabled
)
{
return
ret
;
}
return
ret
;
}
SrsTSMuxer
::
SrsTSMuxer
()
{
}
SrsTSMuxer
::~
SrsTSMuxer
()
{
}
int
SrsTSMuxer
::
open
(
std
::
string
path
)
{
int
ret
=
ERROR_SUCCESS
;
return
ret
;
}
...
...
trunk/src/core/srs_core_hls.hpp
查看文件 @
4af3982
...
...
@@ -29,25 +29,40 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_core.hpp>
#include <string>
class
SrsOnMetaDataPacket
;
class
SrsCommonMessage
;
class
SrsCodecSample
;
class
SrsTSMuxer
;
class
SrsCodec
;
class
SrsHLS
{
private
:
std
::
string
vhost
;
bool
hls_enabled
;
SrsCodec
*
codec
;
SrsCodecSample
*
sample
;
SrsTSMuxer
*
muxer
;
public
:
SrsHLS
();
virtual
~
SrsHLS
();
public
:
virtual
int
on_publish
();
virtual
int
on_publish
(
std
::
string
_vhost
);
virtual
void
on_unpublish
();
virtual
int
on_meta_data
(
SrsOnMetaDataPacket
*
metadata
);
virtual
int
on_audio
(
SrsCommonMessage
*
audio
);
virtual
int
on_video
(
SrsCommonMessage
*
video
);
};
class
SrsTSMuxer
{
public
:
SrsTSMuxer
();
virtual
~
SrsTSMuxer
();
public
:
virtual
int
open
(
std
::
string
path
);
};
#endif
\ No newline at end of file
...
...
请
注册
或
登录
后发表评论