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
2016-12-15 14:48:38 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
759c84a3950d1e062bcd9bba3bfa3fb7dd25c9dc
759c84a3
1 parent
34e5cdcd
for #513, remove hls ram from srs2 to srs3+. 2.0.224
隐藏空白字符变更
内嵌
并排对比
正在显示
17 个修改的文件
包含
26 行增加
和
556 行删除
README.md
trunk/conf/full.conf
trunk/conf/ram.hls.conf
trunk/src/app/srs_app_config.cpp
trunk/src/app/srs_app_config.hpp
trunk/src/app/srs_app_hls.cpp
trunk/src/app/srs_app_hls.hpp
trunk/src/app/srs_app_http_conn.cpp
trunk/src/app/srs_app_http_conn.hpp
trunk/src/app/srs_app_http_stream.cpp
trunk/src/app/srs_app_http_stream.hpp
trunk/src/app/srs_app_rtmp_conn.cpp
trunk/src/app/srs_app_server.cpp
trunk/src/app/srs_app_server.hpp
trunk/src/app/srs_app_source.cpp
trunk/src/app/srs_app_source.hpp
trunk/src/core/srs_core.hpp
README.md
查看文件 @
759c84a
...
...
@@ -345,6 +345,7 @@ Remark:
## History
*
v2.0, 2016-12-15, for #513, remove hls ram from srs2 to srs3+. 2.0.224
*
<strong>
v2.0, 2016-12-13,
[
2.0 beta3(2.0.223)
][
r2.0b3
]
released. 86685 lines.
</strong>
*
v2.0, 2016-12-13, fix #713, disable the source cleanup. 2.0.223
*
v2.0, 2016-12-13, fix #713, refine source to avoid critical fetch and create. 2.0.222
...
...
trunk/conf/full.conf
查看文件 @
759c84a
...
...
@@ -558,12 +558,6 @@ vhost with-hls.srs.com {
# @see https://github.com/ossrs/srs/issues/264
# default: continue
hls_on_error
continue
;
# the hls storage: disk, ram or both.
# disk, to write hls m3u8/ts to disk.
# ram, serve m3u8/ts in memory, which use embeded http server to delivery.
# both, disk and ram.
# default: disk
hls_storage
disk
;
# the hls output path.
# the m3u8 file is configed by hls_path/hls_m3u8_file, the default is:
# ./objs/nginx/html/[app]/[stream].m3u8
...
...
@@ -610,13 +604,6 @@ vhost with-hls.srs.com {
# ...
# optional, default to empty string.
hls_entry_prefix
http
://
your
-
server
;
# the hls mount for hls_storage ram,
# which use srs embeded http server to delivery HLS,
# where the mount specifies the HTTP url to mount.
# @see the mount of http_remux.
# @remark the hls_mount must endswith .m3u8.
# default: [vhost]/[app]/[stream].m3u8
hls_mount
[
vhost
]/[
app
]/[
stream
].
m3u8
;
# the default audio codec of hls.
# when codec changed, write the PAT/PMT table, but maybe ok util next ts.
# so user can set the default codec for mp3.
...
...
trunk/conf/ram.hls.conf
已删除
100644 → 0
查看文件 @
34e5cdc
# the config for srs to delivery hls
# @see https://github.com/ossrs/srs/wiki/v1_CN_SampleHLS
# @see full.conf for detail config.
listen
1935
;
max_connections
1000
;
http_server
{
enabled
on
;
listen
8080
;
dir
./
objs
/
nginx
/
html
;
}
vhost
__
defaultVhost__
{
hls
{
enabled
on
;
hls_fragment
10
;
hls_window
60
;
hls_storage
ram
;
hls_mount
/[
app
]/[
stream
].
m3u8
;
}
}
trunk/src/app/srs_app_config.cpp
查看文件 @
759c84a
...
...
@@ -82,8 +82,6 @@ const char* _srs_version = "XCORE-"RTMP_SIG_SRS_SERVER;
#define SRS_CONF_DEFAULT_HLS_ON_ERROR_DISCONNECT "disconnect"
#define SRS_CONF_DEFAULT_HLS_ON_ERROR_CONTINUE "continue"
#define SRS_CONF_DEFAULT_HLS_ON_ERROR SRS_CONF_DEFAULT_HLS_ON_ERROR_IGNORE
#define SRS_CONF_DEFAULT_HLS_STORAGE "disk"
#define SRS_CONF_DEFAULT_HLS_MOUNT "[vhost]/[app]/[stream].m3u8"
#define SRS_CONF_DEFAULT_HLS_ACODEC "aac"
#define SRS_CONF_DEFAULT_HLS_VCODEC "h264"
#define SRS_CONF_DEFAULT_HLS_CLEANUP true
...
...
@@ -1906,6 +1904,11 @@ int SrsConfig::check_config()
srs_error
(
"unsupported vhost hls directive %s, ret=%d"
,
m
.
c_str
(),
ret
);
return
ret
;
}
// TODO: FIXME: remove it in future.
if
(
m
==
"hls_storage"
||
m
==
"hls_mount"
)
{
srs_warn
(
"HLS RAM is removed from SRS2 to SRS3+, please read https://github.com/ossrs/srs/issues/513."
);
}
}
}
else
if
(
n
==
"http_hooks"
)
{
for
(
int
j
=
0
;
j
<
(
int
)
conf
->
directives
.
size
();
j
++
)
{
...
...
@@ -3793,40 +3796,6 @@ string SrsConfig::get_hls_on_error(string vhost)
return
conf
->
arg0
();
}
string
SrsConfig
::
get_hls_storage
(
string
vhost
)
{
SrsConfDirective
*
hls
=
get_hls
(
vhost
);
if
(
!
hls
)
{
return
SRS_CONF_DEFAULT_HLS_STORAGE
;
}
SrsConfDirective
*
conf
=
hls
->
get
(
"hls_storage"
);
if
(
!
conf
)
{
return
SRS_CONF_DEFAULT_HLS_STORAGE
;
}
return
conf
->
arg0
();
}
string
SrsConfig
::
get_hls_mount
(
string
vhost
)
{
SrsConfDirective
*
hls
=
get_hls
(
vhost
);
if
(
!
hls
)
{
return
SRS_CONF_DEFAULT_HLS_MOUNT
;
}
SrsConfDirective
*
conf
=
hls
->
get
(
"hls_mount"
);
if
(
!
conf
)
{
return
SRS_CONF_DEFAULT_HLS_MOUNT
;
}
return
conf
->
arg0
();
}
string
SrsConfig
::
get_hls_acodec
(
string
vhost
)
{
SrsConfDirective
*
hls
=
get_hls
(
vhost
);
...
...
trunk/src/app/srs_app_config.hpp
查看文件 @
759c84a
...
...
@@ -915,14 +915,6 @@ public:
*/
virtual
std
::
string
get_hls_on_error
(
std
::
string
vhost
);
/**
* get the HLS storage type.
*/
virtual
std
::
string
get_hls_storage
(
std
::
string
vhost
);
/**
* get the HLS mount url for HTTP server.
*/
virtual
std
::
string
get_hls_mount
(
std
::
string
vhost
);
/**
* get the HLS default audio codec.
*/
virtual
std
::
string
get_hls_acodec
(
std
::
string
vhost
);
...
...
trunk/src/app/srs_app_hls.cpp
查看文件 @
759c84a
...
...
@@ -61,14 +61,6 @@ using namespace std;
// reset the piece id when deviation overflow this.
#define SRS_JUMP_WHEN_PIECE_DEVIATION 20
ISrsHlsHandler
::
ISrsHlsHandler
()
{
}
ISrsHlsHandler
::~
ISrsHlsHandler
()
{
}
/**
* * the HLS section, only available when HLS enabled.
* */
...
...
@@ -294,7 +286,6 @@ string SrsDvrAsyncCallOnHlsNotify::to_string()
SrsHlsMuxer
::
SrsHlsMuxer
()
{
req
=
NULL
;
handler
=
NULL
;
hls_fragment
=
hls_window
=
0
;
hls_aof_ratio
=
1.0
;
deviation_ts
=
0
;
...
...
@@ -384,12 +375,10 @@ int SrsHlsMuxer::deviation()
return
deviation_ts
;
}
int
SrsHlsMuxer
::
initialize
(
ISrsHlsHandler
*
h
)
int
SrsHlsMuxer
::
initialize
()
{
int
ret
=
ERROR_SUCCESS
;
handler
=
h
;
if
((
ret
=
async
->
start
())
!=
ERROR_SUCCESS
)
{
return
ret
;
}
...
...
@@ -425,19 +414,10 @@ int SrsHlsMuxer::update_config(SrsRequest* r, string entry_prefix,
// when update config, reset the history target duration.
max_td
=
(
int
)(
fragment
*
_srs_config
->
get_hls_td_ratio
(
r
->
vhost
));
std
::
string
storage
=
_srs_config
->
get_hls_storage
(
r
->
vhost
);
if
(
storage
==
"ram"
)
{
should_write_cache
=
true
;
should_write_file
=
false
;
}
else
if
(
storage
==
"disk"
)
{
should_write_cache
=
false
;
should_write_file
=
true
;
}
else
{
srs_assert
(
storage
==
"both"
);
should_write_cache
=
true
;
should_write_file
=
true
;
}
// TODO: FIXME: refine better for SRS2 only support disk.
should_write_cache
=
false
;
should_write_file
=
true
;
// create m3u8 dir once.
m3u8_dir
=
srs_path_dirname
(
m3u8
);
...
...
@@ -755,13 +735,6 @@ int SrsHlsMuxer::segment_close(string log_desc)
srs_info
(
"%s reap ts segment, sequence_no=%d, uri=%s, duration=%.2f, start=%"
PRId64
,
log_desc
.
c_str
(),
current
->
sequence_no
,
current
->
uri
.
c_str
(),
current
->
duration
,
current
->
segment_start_dts
);
// notify handler for update ts.
srs_assert
(
current
->
writer
);
if
(
handler
&&
(
ret
=
handler
->
on_update_ts
(
req
,
current
->
uri
,
current
->
writer
->
cache
()))
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify handler for update ts failed. ret=%d"
,
ret
);
return
ret
;
}
// close the muxer of finished segment.
srs_freep
(
current
->
muxer
);
...
...
@@ -829,13 +802,6 @@ int SrsHlsMuxer::segment_close(string log_desc)
}
}
if
(
should_write_cache
)
{
if
((
ret
=
handler
->
on_remove_ts
(
req
,
segment
->
uri
))
!=
ERROR_SUCCESS
)
{
srs_warn
(
"remove the ts from ram hls failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_freep
(
segment
);
}
segment_to_remove
.
clear
();
...
...
@@ -957,12 +923,6 @@ int SrsHlsMuxer::_refresh_m3u8(string m3u8_file)
return
ret
;
}
srs_info
(
"write m3u8 %s success."
,
m3u8_file
.
c_str
());
// notify handler for update m3u8.
if
(
handler
&&
(
ret
=
handler
->
on_update_m3u8
(
req
,
writer
.
cache
()))
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify handler for update m3u8 failed. ret=%d"
,
ret
);
return
ret
;
}
return
ret
;
}
...
...
@@ -1171,7 +1131,6 @@ SrsHls::SrsHls()
{
_req
=
NULL
;
source
=
NULL
;
handler
=
NULL
;
hls_enabled
=
false
;
hls_can_dispose
=
false
;
...
...
@@ -1244,14 +1203,13 @@ int SrsHls::cycle()
return
ret
;
}
int
SrsHls
::
initialize
(
SrsSource
*
s
,
ISrsHlsHandler
*
h
)
int
SrsHls
::
initialize
(
SrsSource
*
s
)
{
int
ret
=
ERROR_SUCCESS
;
source
=
s
;
handler
=
h
;
if
((
ret
=
muxer
->
initialize
(
h
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
muxer
->
initialize
())
!=
ERROR_SUCCESS
)
{
return
ret
;
}
...
...
trunk/src/app/srs_app_hls.hpp
查看文件 @
759c84a
...
...
@@ -54,39 +54,6 @@ class SrsTsCache;
class
SrsTsContext
;
/**
* the handler for hls event.
* for example, we use memory only hls for
*/
class
ISrsHlsHandler
{
public
:
ISrsHlsHandler
();
virtual
~
ISrsHlsHandler
();
public
:
/**
* when publish stream
*/
virtual
int
on_hls_publish
(
SrsRequest
*
req
)
=
0
;
/**
* when update the m3u8 file.
*/
virtual
int
on_update_m3u8
(
SrsRequest
*
r
,
std
::
string
m3u8
)
=
0
;
/**
* when reap new ts file.
*/
virtual
int
on_update_ts
(
SrsRequest
*
r
,
std
::
string
uri
,
std
::
string
ts
)
=
0
;
/**
* when remove the specified ts file,
* for the hls to remove the expired ts not in hls window.
*/
virtual
int
on_remove_ts
(
SrsRequest
*
r
,
std
::
string
uri
)
=
0
;
/**
* when unpublish stream
*/
virtual
int
on_hls_unpublish
(
SrsRequest
*
req
)
=
0
;
};
/**
* * the HLS section, only available when HLS enabled.
* */
#ifdef SRS_AUTO_HLS
...
...
@@ -239,8 +206,7 @@ private:
std
::
string
m3u8
;
std
::
string
m3u8_url
;
private
:
ISrsHlsHandler
*
handler
;
// TODO: FIXME: supports reload.
// TODO: FIXME: remove it.
bool
should_write_cache
;
bool
should_write_file
;
private
:
...
...
@@ -277,7 +243,7 @@ public:
/**
* initialize the hls muxer.
*/
virtual
int
initialize
(
ISrsHlsHandler
*
h
);
virtual
int
initialize
();
/**
* when publish, update the config for muxer.
*/
...
...
@@ -390,7 +356,6 @@ class SrsHls
private
:
SrsHlsMuxer
*
muxer
;
SrsHlsCache
*
hls_cache
;
ISrsHlsHandler
*
handler
;
private
:
SrsRequest
*
_req
;
bool
hls_enabled
;
...
...
@@ -426,7 +391,7 @@ public:
/**
* initialize the hls by handler and source.
*/
virtual
int
initialize
(
SrsSource
*
s
,
ISrsHlsHandler
*
h
);
virtual
int
initialize
(
SrsSource
*
s
);
/**
* publish stream event, continue to write the m3u8,
* for the muxer object not destroyed.
...
...
trunk/src/app/srs_app_http_conn.cpp
查看文件 @
759c84a
...
...
@@ -1382,30 +1382,5 @@ void SrsHttpServer::http_unmount(SrsSource* s, SrsRequest* r)
http_stream
->
http_unmount
(
s
,
r
);
}
int
SrsHttpServer
::
mount_hls
(
SrsRequest
*
r
)
{
return
http_stream
->
mount_hls
(
r
);
}
int
SrsHttpServer
::
hls_update_m3u8
(
SrsRequest
*
r
,
std
::
string
m3u8
)
{
return
http_stream
->
hls_update_m3u8
(
r
,
m3u8
);
}
int
SrsHttpServer
::
hls_update_ts
(
SrsRequest
*
r
,
std
::
string
uri
,
std
::
string
ts
)
{
return
http_stream
->
hls_update_ts
(
r
,
uri
,
ts
);
}
int
SrsHttpServer
::
hls_remove_ts
(
SrsRequest
*
r
,
std
::
string
uri
)
{
return
http_stream
->
hls_remove_ts
(
r
,
uri
);
}
void
SrsHttpServer
::
unmount_hls
(
SrsRequest
*
r
)
{
http_stream
->
unmount_hls
(
r
);
}
#endif
...
...
trunk/src/app/srs_app_http_conn.hpp
查看文件 @
759c84a
...
...
@@ -446,13 +446,6 @@ public:
public:
virtual
int
http_mount
(
SrsSource
*
s
,
SrsRequest
*
r
);
virtual
void
http_unmount
(
SrsSource
*
s
,
SrsRequest
*
r
);
// hls stream
public:
virtual
int
mount_hls
(
SrsRequest
*
r
);
virtual
int
hls_update_m3u8
(
SrsRequest
*
r
,
std
::
string
m3u8
);
virtual
int
hls_update_ts
(
SrsRequest
*
r
,
std
::
string
uri
,
std
::
string
ts
);
virtual
int
hls_remove_ts
(
SrsRequest
*
r
,
std
::
string
uri
);
virtual
void
unmount_hls
(
SrsRequest
*
r
);
};
#endif
...
...
trunk/src/app/srs_app_http_stream.cpp
查看文件 @
759c84a
...
...
@@ -760,22 +760,6 @@ SrsHttpStreamServer::~SrsHttpStreamServer()
}
sflvs
.
clear
();
}
if
(
true
)
{
std
::
map
<
std
::
string
,
SrsHlsEntry
*>::
iterator
it
;
for
(
it
=
thls
.
begin
();
it
!=
thls
.
end
();
++
it
)
{
SrsHlsEntry
*
entry
=
it
->
second
;
srs_freep
(
entry
);
}
thls
.
clear
();
}
if
(
true
)
{
std
::
map
<
std
::
string
,
SrsHlsEntry
*>::
iterator
it
;
for
(
it
=
shls
.
begin
();
it
!=
shls
.
end
();
++
it
)
{
SrsHlsEntry
*
entry
=
it
->
second
;
srs_freep
(
entry
);
}
shls
.
clear
();
}
}
int
SrsHttpStreamServer
::
initialize
()
...
...
@@ -787,11 +771,6 @@ int SrsHttpStreamServer::initialize()
return
ret
;
}
// remux rtmp to hls live streaming
if
((
ret
=
initialize_hls_streaming
())
!=
ERROR_SUCCESS
)
{
return
ret
;
}
return
ret
;
}
...
...
@@ -957,190 +936,6 @@ int SrsHttpStreamServer::on_reload_vhost_http_remux_updated(string vhost)
return
ret
;
}
int
SrsHttpStreamServer
::
mount_hls
(
SrsRequest
*
r
)
{
int
ret
=
ERROR_SUCCESS
;
std
::
string
sid
=
r
->
get_stream_url
();
if
(
shls
.
find
(
sid
)
==
shls
.
end
())
{
srs_info
(
"ignore mount hls stream for disabled"
);
return
ret
;
}
SrsHlsEntry
*
entry
=
shls
[
sid
];
// TODO: FIXME: supports reload.
std
::
map
<
std
::
string
,
ISrsHttpHandler
*>::
iterator
it
;
for
(
it
=
entry
->
streams
.
begin
();
it
!=
entry
->
streams
.
end
();
++
it
)
{
ISrsHttpHandler
*
stream
=
it
->
second
;
stream
->
entry
->
enabled
=
true
;
}
return
ret
;
}
int
SrsHttpStreamServer
::
hls_update_m3u8
(
SrsRequest
*
r
,
string
m3u8
)
{
int
ret
=
ERROR_SUCCESS
;
std
::
string
mount
;
std
::
string
sid
=
r
->
get_stream_url
();
SrsHlsEntry
*
entry
=
NULL
;
// create stream from template when not found.
if
(
shls
.
find
(
sid
)
==
shls
.
end
())
{
if
(
thls
.
find
(
r
->
vhost
)
==
thls
.
end
())
{
srs_info
(
"ignore mount hls stream for disabled"
);
return
ret
;
}
SrsHlsEntry
*
tmpl
=
thls
[
r
->
vhost
];
srs_assert
(
tmpl
);
entry
=
new
SrsHlsEntry
();
mount
=
tmpl
->
mount
;
// replace the vhost variable
mount
=
srs_string_replace
(
mount
,
"[vhost]"
,
r
->
vhost
);
mount
=
srs_string_replace
(
mount
,
"[app]"
,
r
->
app
);
mount
=
srs_string_replace
(
mount
,
"[stream]"
,
r
->
stream
);
// remove the default vhost mount
mount
=
srs_string_replace
(
mount
,
SRS_CONSTS_RTMP_DEFAULT_VHOST
"/"
,
"/"
);
entry
->
tmpl
=
tmpl
;
entry
->
mount
=
mount
;
shls
[
sid
]
=
entry
;
if
(
entry
->
streams
.
find
(
mount
)
==
entry
->
streams
.
end
())
{
ISrsHttpHandler
*
he
=
new
SrsHlsM3u8Stream
();
entry
->
streams
[
mount
]
=
he
;
if
((
ret
=
mux
.
handle
(
mount
,
he
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"handle mount=%s failed. ret=%d"
,
mount
.
c_str
(),
ret
);
return
ret
;
}
}
}
else
{
entry
=
shls
[
sid
];
}
mount
=
entry
->
mount
;
// update the m3u8 stream.
SrsHlsM3u8Stream
*
hms
=
dynamic_cast
<
SrsHlsM3u8Stream
*>
(
entry
->
streams
[
mount
]);
if
(
hms
)
{
hms
->
set_m3u8
(
m3u8
);
}
srs_trace
(
"hls update m3u8 ok, mount=%s"
,
mount
.
c_str
());
return
ret
;
}
int
SrsHttpStreamServer
::
hls_update_ts
(
SrsRequest
*
r
,
string
uri
,
string
ts
)
{
int
ret
=
ERROR_SUCCESS
;
std
::
string
sid
=
r
->
get_stream_url
();
// when no hls mounted, init with empty m3u8.
if
(
shls
.
find
(
sid
)
==
shls
.
end
())
{
if
((
ret
=
hls_update_m3u8
(
r
,
""
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
}
// find again, ignore if not exits.
if
(
shls
.
find
(
sid
)
==
shls
.
end
())
{
return
ret
;
}
SrsHlsEntry
*
entry
=
shls
[
sid
];
srs_assert
(
entry
);
srs_assert
(
entry
->
tmpl
);
std
::
string
mount
=
hls_mount_generate
(
r
,
uri
,
entry
->
tmpl
->
mount
);
if
(
entry
->
streams
.
find
(
mount
)
==
entry
->
streams
.
end
())
{
ISrsHttpHandler
*
he
=
new
SrsHlsTsStream
();
entry
->
streams
[
mount
]
=
he
;
if
((
ret
=
mux
.
handle
(
mount
,
he
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"handle mount=%s failed. ret=%d"
,
mount
.
c_str
(),
ret
);
return
ret
;
}
}
// update the ts stream.
SrsHlsTsStream
*
hts
=
dynamic_cast
<
SrsHlsTsStream
*>
(
entry
->
streams
[
mount
]);
if
(
hts
)
{
hts
->
set_ts
(
ts
);
}
srs_trace
(
"hls update ts ok, mount=%s"
,
mount
.
c_str
());
return
ret
;
}
int
SrsHttpStreamServer
::
hls_remove_ts
(
SrsRequest
*
r
,
string
uri
)
{
int
ret
=
ERROR_SUCCESS
;
std
::
string
sid
=
r
->
get_stream_url
();
// when no hls mounted, ignore.
if
(
shls
.
find
(
sid
)
==
shls
.
end
())
{
return
ret
;
}
SrsHlsEntry
*
entry
=
shls
[
sid
];
srs_assert
(
entry
);
srs_assert
(
entry
->
tmpl
);
std
::
string
mount
=
hls_mount_generate
(
r
,
uri
,
entry
->
tmpl
->
mount
);
// ignore when no ts mounted.
if
(
entry
->
streams
.
find
(
mount
)
==
entry
->
streams
.
end
())
{
return
ret
;
}
// update the ts stream.
SrsHlsTsStream
*
hts
=
dynamic_cast
<
SrsHlsTsStream
*>
(
entry
->
streams
[
mount
]);
if
(
hts
)
{
hts
->
set_ts
(
""
);
// TODO: FIXME: unmount and remove the http handler.
}
srs_trace
(
"hls remove ts ok, mount=%s"
,
mount
.
c_str
());
return
ret
;
}
void
SrsHttpStreamServer
::
unmount_hls
(
SrsRequest
*
r
)
{
std
::
string
sid
=
r
->
get_stream_url
();
if
(
shls
.
find
(
sid
)
==
shls
.
end
())
{
srs_info
(
"ignore unmount hls stream for disabled"
);
return
;
}
SrsHlsEntry
*
entry
=
shls
[
sid
];
std
::
map
<
std
::
string
,
ISrsHttpHandler
*>::
iterator
it
;
for
(
it
=
entry
->
streams
.
begin
();
it
!=
entry
->
streams
.
end
();
++
it
)
{
ISrsHttpHandler
*
stream
=
it
->
second
;
stream
->
entry
->
enabled
=
false
;
}
}
int
SrsHttpStreamServer
::
on_reload_vhost_hls
(
string
vhost
)
{
int
ret
=
ERROR_SUCCESS
;
// TODO: FIXME: implements it.
return
ret
;
}
int
SrsHttpStreamServer
::
hijack
(
ISrsHttpMessage
*
request
,
ISrsHttpHandler
**
ph
)
{
int
ret
=
ERROR_SUCCESS
;
...
...
@@ -1229,7 +1024,7 @@ int SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandler** ph)
}
SrsSource
*
s
=
NULL
;
if
((
ret
=
SrsSource
::
fetch_or_create
(
r
,
server
,
server
,
&
s
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
SrsSource
::
fetch_or_create
(
r
,
server
,
&
s
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
srs_assert
(
s
!=
NULL
);
...
...
@@ -1295,62 +1090,5 @@ int SrsHttpStreamServer::initialize_flv_entry(std::string vhost)
return
ret
;
}
int
SrsHttpStreamServer
::
initialize_hls_streaming
()
{
int
ret
=
ERROR_SUCCESS
;
// http hls live stream mount for each vhost.
SrsConfDirective
*
root
=
_srs_config
->
get_root
();
for
(
int
i
=
0
;
i
<
(
int
)
root
->
directives
.
size
();
i
++
)
{
SrsConfDirective
*
conf
=
root
->
at
(
i
);
if
(
!
conf
->
is_vhost
())
{
continue
;
}
std
::
string
vhost
=
conf
->
arg0
();
if
(
!
_srs_config
->
get_hls_enabled
(
vhost
))
{
continue
;
}
std
::
string
storage
=
_srs_config
->
get_hls_storage
(
vhost
);
if
(
storage
!=
"ram"
&&
storage
!=
"both"
)
{
continue
;
}
SrsHlsEntry
*
entry
=
new
SrsHlsEntry
();
entry
->
mount
=
_srs_config
->
get_hls_mount
(
vhost
);
thls
[
vhost
]
=
entry
;
srs_trace
(
"http hls live stream, vhost=%s, mount=%s"
,
vhost
.
c_str
(),
entry
->
mount
.
c_str
());
}
return
ret
;
}
string
SrsHttpStreamServer
::
hls_mount_generate
(
SrsRequest
*
r
,
string
uri
,
string
tmpl
)
{
std
::
string
mount
=
tmpl
;
// the ts is relative from the m3u8, the same start dir.
size_t
pos
=
string
::
npos
;
if
((
pos
=
mount
.
rfind
(
"/"
))
!=
string
::
npos
)
{
mount
=
mount
.
substr
(
0
,
pos
);
}
// replace the vhost variable
mount
=
srs_string_replace
(
mount
,
"[vhost]"
,
r
->
vhost
);
mount
=
srs_string_replace
(
mount
,
"[app]"
,
r
->
app
);
// remove the default vhost mount
mount
=
srs_string_replace
(
mount
,
SRS_CONSTS_RTMP_DEFAULT_VHOST
"/"
,
"/"
);
// mount with ts.
mount
+=
"/"
;
mount
+=
uri
;
return
mount
;
}
#endif
...
...
trunk/src/app/srs_app_http_stream.hpp
查看文件 @
759c84a
...
...
@@ -334,10 +334,6 @@ public:
std
::
map
<
std
::
string
,
SrsLiveEntry
*>
tflvs
;
// the http live streaming streams, crote by template.
std
::
map
<
std
::
string
,
SrsLiveEntry
*>
sflvs
;
// the hls live streaming template, to create streams.
std
::
map
<
std
::
string
,
SrsHlsEntry
*>
thls
;
// the hls live streaming streams, crote by template.
std
::
map
<
std
::
string
,
SrsHlsEntry
*>
shls
;
public
:
SrsHttpStreamServer
(
SrsServer
*
svr
);
virtual
~
SrsHttpStreamServer
();
...
...
@@ -347,26 +343,16 @@ public:
public:
virtual
int
http_mount
(
SrsSource
*
s
,
SrsRequest
*
r
);
virtual
void
http_unmount
(
SrsSource
*
s
,
SrsRequest
*
r
);
// hls stream
public:
virtual
int
mount_hls
(
SrsRequest
*
r
);
virtual
int
hls_update_m3u8
(
SrsRequest
*
r
,
std
::
string
m3u8
);
virtual
int
hls_update_ts
(
SrsRequest
*
r
,
std
::
string
uri
,
std
::
string
ts
);
virtual
int
hls_remove_ts
(
SrsRequest
*
r
,
std
::
string
uri
);
virtual
void
unmount_hls
(
SrsRequest
*
r
);
// interface ISrsReloadHandler.
public:
virtual
int
on_reload_vhost_added
(
std
::
string
vhost
);
virtual
int
on_reload_vhost_http_remux_updated
(
std
::
string
vhost
);
virtual
int
on_reload_vhost_hls
(
std
::
string
vhost
);
// interface ISrsHttpMatchHijacker
public:
virtual
int
hijack
(
ISrsHttpMessage
*
request
,
ISrsHttpHandler
**
ph
);
private
:
virtual
int
initialize_flv_streaming
();
virtual
int
initialize_flv_entry
(
std
::
string
vhost
);
virtual
int
initialize_hls_streaming
();
virtual
std
::
string
hls_mount_generate
(
SrsRequest
*
r
,
std
::
string
uri
,
std
::
string
tmpl
);
};
#endif
...
...
trunk/src/app/srs_app_rtmp_conn.cpp
查看文件 @
759c84a
...
...
@@ -487,7 +487,7 @@ int SrsRtmpConn::stream_service_cycle()
// find a source to serve.
SrsSource
*
source
=
NULL
;
if
((
ret
=
SrsSource
::
fetch_or_create
(
req
,
server
,
server
,
&
source
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
SrsSource
::
fetch_or_create
(
req
,
server
,
&
source
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
srs_assert
(
source
!=
NULL
);
...
...
trunk/src/app/srs_app_server.cpp
查看文件 @
759c84a
...
...
@@ -1441,67 +1441,3 @@ void SrsServer::on_unpublish(SrsSource* s, SrsRequest* r)
#endif
}
int
SrsServer
::
on_hls_publish
(
SrsRequest
*
r
)
{
int
ret
=
ERROR_SUCCESS
;
#ifdef SRS_AUTO_HTTP_SERVER
if
((
ret
=
http_server
->
mount_hls
(
r
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
#endif
return
ret
;
}
int
SrsServer
::
on_update_m3u8
(
SrsRequest
*
r
,
string
m3u8
)
{
int
ret
=
ERROR_SUCCESS
;
#ifdef SRS_AUTO_HTTP_SERVER
if
((
ret
=
http_server
->
hls_update_m3u8
(
r
,
m3u8
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
#endif
return
ret
;
}
int
SrsServer
::
on_update_ts
(
SrsRequest
*
r
,
string
uri
,
string
ts
)
{
int
ret
=
ERROR_SUCCESS
;
#ifdef SRS_AUTO_HTTP_SERVER
if
((
ret
=
http_server
->
hls_update_ts
(
r
,
uri
,
ts
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
#endif
return
ret
;
}
int
SrsServer
::
on_remove_ts
(
SrsRequest
*
r
,
string
uri
)
{
int
ret
=
ERROR_SUCCESS
;
#ifdef SRS_AUTO_HTTP_SERVER
if
((
ret
=
http_server
->
hls_remove_ts
(
r
,
uri
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
#endif
return
ret
;
}
int
SrsServer
::
on_hls_unpublish
(
SrsRequest
*
r
)
{
int
ret
=
ERROR_SUCCESS
;
#ifdef SRS_AUTO_HTTP_SERVER
http_server
->
unmount_hls
(
r
);
#endif
return
ret
;
}
...
...
trunk/src/app/srs_app_server.hpp
查看文件 @
759c84a
...
...
@@ -230,7 +230,7 @@ public:
* start connection service thread, destroy client.
*/
class
SrsServer
:
virtual
public
ISrsReloadHandler
,
virtual
public
ISrsSourceHandler
,
virtual
public
ISrsHlsHandler
,
virtual
public
ISrsSourceHandler
,
virtual
public
IConnectionManager
{
private
:
...
...
@@ -377,13 +377,6 @@ public:
public:
virtual
int
on_publish
(
SrsSource
*
s
,
SrsRequest
*
r
);
virtual
void
on_unpublish
(
SrsSource
*
s
,
SrsRequest
*
r
);
// interface ISrsHlsHandler
public:
virtual
int
on_hls_publish
(
SrsRequest
*
r
);
virtual
int
on_update_m3u8
(
SrsRequest
*
r
,
std
::
string
m3u8
);
virtual
int
on_update_ts
(
SrsRequest
*
r
,
std
::
string
uri
,
std
::
string
ts
);
virtual
int
on_remove_ts
(
SrsRequest
*
r
,
std
::
string
uri
);
virtual
int
on_hls_unpublish
(
SrsRequest
*
r
);
};
#endif
...
...
trunk/src/app/srs_app_source.cpp
查看文件 @
759c84a
...
...
@@ -731,7 +731,7 @@ ISrsSourceHandler::~ISrsSourceHandler()
std
::
map
<
std
::
string
,
SrsSource
*>
SrsSource
::
pool
;
int
SrsSource
::
fetch_or_create
(
SrsRequest
*
r
,
ISrsSourceHandler
*
h
,
ISrsHlsHandler
*
hh
,
SrsSource
**
pps
)
int
SrsSource
::
fetch_or_create
(
SrsRequest
*
r
,
ISrsSourceHandler
*
h
,
SrsSource
**
pps
)
{
int
ret
=
ERROR_SUCCESS
;
...
...
@@ -748,7 +748,7 @@ int SrsSource::fetch_or_create(SrsRequest* r, ISrsSourceHandler* h, ISrsHlsHandl
srs_assert
(
pool
.
find
(
stream_url
)
==
pool
.
end
());
source
=
new
SrsSource
();
if
((
ret
=
source
->
initialize
(
r
,
h
,
hh
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
source
->
initialize
(
r
,
h
))
!=
ERROR_SUCCESS
)
{
srs_freep
(
source
);
return
ret
;
}
...
...
@@ -1053,12 +1053,11 @@ bool SrsSource::expired()
return
false
;
}
int
SrsSource
::
initialize
(
SrsRequest
*
r
,
ISrsSourceHandler
*
h
,
ISrsHlsHandler
*
hh
)
int
SrsSource
::
initialize
(
SrsRequest
*
r
,
ISrsSourceHandler
*
h
)
{
int
ret
=
ERROR_SUCCESS
;
srs_assert
(
h
);
srs_assert
(
hh
);
srs_assert
(
!
_req
);
handler
=
h
;
...
...
@@ -1066,7 +1065,7 @@ int SrsSource::initialize(SrsRequest* r, ISrsSourceHandler* h, ISrsHlsHandler* h
atc
=
_srs_config
->
get_atc
(
_req
->
vhost
);
#ifdef SRS_AUTO_HLS
if
((
ret
=
hls
->
initialize
(
this
,
hh
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
hls
->
initialize
(
this
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
#endif
...
...
trunk/src/app/srs_app_source.hpp
查看文件 @
759c84a
...
...
@@ -62,7 +62,6 @@ class SrsDvr;
class
SrsEncoder
;
#endif
class
SrsStream
;
class
ISrsHlsHandler
;
#ifdef SRS_AUTO_HDS
class
SrsHds
;
#endif
...
...
@@ -421,10 +420,9 @@ public:
* create source when fetch from cache failed.
* @param r the client request.
* @param h the event handler for source.
* @param hh the event handler for hls.
* @param pps the matched source, if success never be NULL.
*/
static
int
fetch_or_create
(
SrsRequest
*
r
,
ISrsSourceHandler
*
h
,
ISrsHlsHandler
*
hh
,
SrsSource
**
pps
);
static
int
fetch_or_create
(
SrsRequest
*
r
,
ISrsSourceHandler
*
h
,
SrsSource
**
pps
);
private
:
/**
* get the exists source, NULL when not exists.
...
...
@@ -526,7 +524,7 @@ public:
/**
* initialize the hls with handlers.
*/
virtual
int
initialize
(
SrsRequest
*
r
,
ISrsSourceHandler
*
h
,
ISrsHlsHandler
*
hh
);
virtual
int
initialize
(
SrsRequest
*
r
,
ISrsSourceHandler
*
h
);
// interface ISrsReloadHandler
public:
virtual
int
on_reload_vhost_atc
(
std
::
string
vhost
);
...
...
trunk/src/core/srs_core.hpp
查看文件 @
759c84a
...
...
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version
#define VERSION_MAJOR 2
#define VERSION_MINOR 0
#define VERSION_REVISION 22
3
#define VERSION_REVISION 22
4
// generated by configure, only macros.
#include <srs_auto_headers.hpp>
...
...
请
注册
或
登录
后发表评论