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
2015-03-06 13:37:57 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f26e719800bc7dde51c3bef6d9d924cac8cbe49f
f26e7198
1 parent
1277968d
fix #322, fix http-flv stream bug, support multiple streams. 2.0.133.
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
123 行增加
和
75 行删除
README.md
trunk/src/app/srs_app_http_conn.cpp
trunk/src/app/srs_app_http_conn.hpp
trunk/src/core/srs_core.hpp
README.md
查看文件 @
f26e719
...
...
@@ -551,6 +551,7 @@ Supported operating systems and hardware:
### SRS 2.0 history
*
v2.0, 2015-03-06, for
[
#322
](
https://github.com/winlinvip/simple-rtmp-server/issues/322
)
, fix http-flv stream bug, support multiple streams. 2.0.133.
*
v2.0, 2015-03-06, refine http request parse. 2.0.132.
*
v2.0, 2015-03-01, for
[
#179
](
https://github.com/winlinvip/simple-rtmp-server/issues/179
)
, revert dvr http api. 2.0.128.
*
v2.0, 2015-02-24, for
[
#304
](
https://github.com/winlinvip/simple-rtmp-server/issues/304
)
, fix hls bug, write pts/dts error. 2.0.124
...
...
trunk/src/app/srs_app_http_conn.cpp
查看文件 @
f26e719
...
...
@@ -771,19 +771,35 @@ SrsHttpServer::~SrsHttpServer()
{
if
(
true
)
{
std
::
map
<
std
::
string
,
SrsLiveEntry
*>::
iterator
it
;
for
(
it
=
flvs
.
begin
();
it
!=
flvs
.
end
();
++
it
)
{
for
(
it
=
tflvs
.
begin
();
it
!=
t
flvs
.
end
();
++
it
)
{
SrsLiveEntry
*
entry
=
it
->
second
;
srs_freep
(
entry
);
}
flvs
.
clear
();
tflvs
.
clear
();
}
if
(
true
)
{
std
::
map
<
std
::
string
,
SrsLiveEntry
*>::
iterator
it
;
for
(
it
=
sflvs
.
begin
();
it
!=
sflvs
.
end
();
++
it
)
{
SrsLiveEntry
*
entry
=
it
->
second
;
srs_freep
(
entry
);
}
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
=
hls
.
begin
();
it
!=
hls
.
end
();
++
it
)
{
for
(
it
=
shls
.
begin
();
it
!=
s
hls
.
end
();
++
it
)
{
SrsHlsEntry
*
entry
=
it
->
second
;
srs_freep
(
entry
);
}
hls
.
clear
();
s
hls
.
clear
();
}
}
...
...
@@ -814,56 +830,72 @@ int SrsHttpServer::mount(SrsSource* s, SrsRequest* r)
{
int
ret
=
ERROR_SUCCESS
;
if
(
flvs
.
find
(
r
->
vhost
)
==
flvs
.
end
())
{
srs_info
(
"ignore mount flv stream for disabled"
);
return
ret
;
}
// the id to identify stream.
std
::
string
sid
=
r
->
get_stream_url
();
SrsLiveEntry
*
entry
=
NULL
;
SrsLiveEntry
*
entry
=
flvs
[
r
->
vhost
];
// create stream from template when not found.
if
(
sflvs
.
find
(
sid
)
==
sflvs
.
end
())
{
if
(
tflvs
.
find
(
r
->
vhost
)
==
tflvs
.
end
())
{
srs_info
(
"ignore mount flv stream for disabled"
);
return
ret
;
}
// TODO: FIXME: supports reload.
if
(
entry
->
stream
)
{
entry
->
stream
->
entry
->
enabled
=
true
;
return
ret
;
}
std
::
string
mount
=
entry
->
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
);
SrsLiveEntry
*
tmpl
=
tflvs
[
r
->
vhost
];
// remove the default vhost mount
mount
=
srs_string_replace
(
mount
,
SRS_CONSTS_RTMP_DEFAULT_VHOST
"/"
,
"/"
);
std
::
string
mount
=
tmpl
->
mount
;
entry
->
cache
=
new
SrsStreamCache
(
s
,
r
);
entry
->
stream
=
new
SrsLiveStream
(
s
,
r
,
entry
->
cache
);
// 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
);
// start http stream cache thread
if
((
ret
=
entry
->
cache
->
start
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"http: start stream cache failed. ret=%d"
,
ret
);
return
ret
;
// remove the default vhost mount
mount
=
srs_string_replace
(
mount
,
SRS_CONSTS_RTMP_DEFAULT_VHOST
"/"
,
"/"
);
entry
=
new
SrsLiveEntry
();
entry
->
mount
=
mount
;
entry
->
cache
=
new
SrsStreamCache
(
s
,
r
);
entry
->
stream
=
new
SrsLiveStream
(
s
,
r
,
entry
->
cache
);
sflvs
[
sid
]
=
entry
;
// start http stream cache thread
if
((
ret
=
entry
->
cache
->
start
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"http: start stream cache failed. ret=%d"
,
ret
);
return
ret
;
}
// mount the http flv stream.
if
((
ret
=
mux
.
handle
(
mount
,
entry
->
stream
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"http: mount flv stream for vhost=%s failed. ret=%d"
,
sid
.
c_str
(),
ret
);
return
ret
;
}
srs_trace
(
"http: mount flv stream for vhost=%s, mount=%s"
,
sid
.
c_str
(),
mount
.
c_str
());
}
else
{
entry
=
sflvs
[
sid
];
}
// mount the http flv stream.
if
((
ret
=
mux
.
handle
(
mount
,
entry
->
stream
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"http: mount flv stream for vhost=%s failed. ret=%d"
,
r
->
vhost
.
c_str
(),
ret
);
// TODO: FIXME: supports reload.
if
(
entry
->
stream
)
{
entry
->
stream
->
entry
->
enabled
=
true
;
return
ret
;
}
srs_trace
(
"http: mount flv stream for vhost=%s, mount=%s"
,
r
->
vhost
.
c_str
(),
mount
.
c_str
());
return
ret
;
}
void
SrsHttpServer
::
unmount
(
SrsSource
*
s
,
SrsRequest
*
r
)
{
if
(
flvs
.
find
(
r
->
vhost
)
==
flvs
.
end
())
{
std
::
string
sid
=
r
->
get_stream_url
();
if
(
sflvs
.
find
(
sid
)
==
sflvs
.
end
())
{
srs_info
(
"ignore unmount flv stream for disabled"
);
return
;
}
SrsLiveEntry
*
entry
=
flvs
[
r
->
vhost
];
SrsLiveEntry
*
entry
=
sflvs
[
sid
];
entry
->
stream
->
entry
->
enabled
=
false
;
}
...
...
@@ -871,12 +903,14 @@ int SrsHttpServer::mount_hls(SrsRequest* r)
{
int
ret
=
ERROR_SUCCESS
;
if
(
hls
.
find
(
r
->
vhost
)
==
hls
.
end
())
{
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
=
hls
[
r
->
vhost
];
SrsHlsEntry
*
entry
=
shls
[
sid
];
// TODO: FIXME: supports reload.
std
::
map
<
std
::
string
,
ISrsHttpHandler
*>::
iterator
it
;
...
...
@@ -891,33 +925,37 @@ int SrsHttpServer::mount_hls(SrsRequest* r)
int
SrsHttpServer
::
hls_update_m3u8
(
SrsRequest
*
r
,
string
m3u8
)
{
int
ret
=
ERROR_SUCCESS
;
std
::
string
mount
=
m3u8
;
// when no hls mounted, ignore.
if
(
hls
.
find
(
r
->
vhost
)
==
hls
.
end
())
{
return
ret
;
}
std
::
string
sid
=
r
->
get_stream_url
();
SrsHlsEntry
*
entry
=
NULL
;
SrsHlsEntry
*
entry
=
hls
[
r
->
vhost
];
srs_assert
(
entry
);
std
::
string
mount
=
entry
->
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
"/"
,
"/"
);
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
);
// 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
];
entry
=
new
SrsHlsEntry
();
entry
->
mount
=
tmpl
->
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
];
}
// update the m3u8 stream.
...
...
@@ -934,12 +972,14 @@ int SrsHttpServer::hls_update_ts(SrsRequest* r, string uri, string ts)
{
int
ret
=
ERROR_SUCCESS
;
std
::
string
sid
=
r
->
get_stream_url
();
// when no hls mounted, ignore.
if
(
hls
.
find
(
r
->
vhost
)
==
hls
.
end
())
{
if
(
shls
.
find
(
sid
)
==
s
hls
.
end
())
{
return
ret
;
}
SrsHlsEntry
*
entry
=
hls
[
r
->
vhost
];
SrsHlsEntry
*
entry
=
shls
[
sid
];
srs_assert
(
entry
);
std
::
string
mount
=
entry
->
mount
;
...
...
@@ -983,12 +1023,14 @@ int SrsHttpServer::hls_update_ts(SrsRequest* r, string uri, string ts)
void
SrsHttpServer
::
unmount_hls
(
SrsRequest
*
r
)
{
if
(
hls
.
find
(
r
->
vhost
)
==
hls
.
end
())
{
std
::
string
sid
=
r
->
get_stream_url
();
if
(
shls
.
find
(
sid
)
==
shls
.
end
())
{
srs_info
(
"ignore unmount hls stream for disabled"
);
return
;
}
SrsHlsEntry
*
entry
=
hls
[
r
->
vhost
];
SrsHlsEntry
*
entry
=
shls
[
sid
];
std
::
map
<
std
::
string
,
ISrsHttpHandler
*>::
iterator
it
;
for
(
it
=
entry
->
streams
.
begin
();
it
!=
entry
->
streams
.
end
();
++
it
)
{
...
...
@@ -1097,9 +1139,8 @@ int SrsHttpServer::initialize_flv_streaming()
}
SrsLiveEntry
*
entry
=
new
SrsLiveEntry
();
entry
->
vhost
=
vhost
;
entry
->
mount
=
_srs_config
->
get_vhost_http_remux_mount
(
vhost
);
flvs
[
vhost
]
=
entry
;
t
flvs
[
vhost
]
=
entry
;
srs_trace
(
"http flv live stream, vhost=%s, mount=%s"
,
vhost
.
c_str
(),
entry
->
mount
.
c_str
());
}
...
...
@@ -1131,9 +1172,8 @@ int SrsHttpServer::initialize_hls_streaming()
}
SrsHlsEntry
*
entry
=
new
SrsHlsEntry
();
entry
->
vhost
=
vhost
;
entry
->
mount
=
_srs_config
->
get_hls_mount
(
vhost
);
hls
[
vhost
]
=
entry
;
t
hls
[
vhost
]
=
entry
;
srs_trace
(
"http hls live stream, vhost=%s, mount=%s"
,
vhost
.
c_str
(),
entry
->
mount
.
c_str
());
}
...
...
trunk/src/app/srs_app_http_conn.hpp
查看文件 @
f26e719
...
...
@@ -252,8 +252,10 @@ private:
*/
struct
SrsLiveEntry
{
std
::
string
vhost
;
// for template, the mount contains variables.
// for concrete stream, the mount is url to access.
std
::
string
mount
;
SrsLiveStream
*
stream
;
SrsStreamCache
*
cache
;
...
...
@@ -297,7 +299,8 @@ public:
*/
struct
SrsHlsEntry
{
std
::
string
vhost
;
// for template, the mount contains variables.
// for concrete stream, the mount is url to access.
std
::
string
mount
;
// key: the m3u8/ts file path.
...
...
@@ -315,10 +318,14 @@ class SrsHttpServer : public ISrsReloadHandler
{
public
:
SrsHttpServeMux
mux
;
// the flv live streaming template.
std
::
map
<
std
::
string
,
SrsLiveEntry
*>
flvs
;
// the hls live streaming template.
std
::
map
<
std
::
string
,
SrsHlsEntry
*>
hls
;
// the flv live streaming template, to create streams.
std
::
map
<
std
::
string
,
SrsLiveEntry
*>
tflvs
;
// the flv 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
:
SrsHttpServer
();
virtual
~
SrsHttpServer
();
...
...
trunk/src/core/srs_core.hpp
查看文件 @
f26e719
...
...
@@ -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 13
2
#define VERSION_REVISION 13
3
// server info.
#define RTMP_SIG_SRS_KEY "SRS"
...
...
请
注册
或
登录
后发表评论