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 16:22:04 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b231550c3295a4f07c01f6a9aba51f778e3e1932
b231550c
1 parent
f6661989
fix #717, #691, http api/static/stream support cors. 3.0.9
显示空白字符变更
内嵌
并排对比
正在显示
12 个修改的文件
包含
79 行增加
和
7 行删除
README.md
trunk/.gitignore
trunk/conf/full.conf
trunk/src/app/srs_app_config.cpp
trunk/src/app/srs_app_config.hpp
trunk/src/app/srs_app_conn.hpp
trunk/src/app/srs_app_http_api.cpp
trunk/src/app/srs_app_http_conn.cpp
trunk/src/app/srs_app_http_conn.hpp
trunk/src/app/srs_app_reload.cpp
trunk/src/app/srs_app_reload.hpp
trunk/src/core/srs_core.hpp
README.md
查看文件 @
b231550
...
...
@@ -379,6 +379,7 @@ Remark:
### History
*
v3.0, 2016-12-15, fix #717, #691, http api/static/stream support cors. 3.0.9
*
v3.0, 2016-12-08, support log rotate signal SIGUSR1. 3.0.8
*
v3.0, 2016-12-07, fix typo and refine grammar. 3.0.7
*
v3.0, 2015-10-23, fix
[
#467
][
bug #467
]
, support write log to kafka. 3.0.6
...
...
trunk/.gitignore
查看文件 @
b231550
console.conf
console
*
.conf
doc/frozen.2Mbps.1644x1028.flv
doc/frozen.500Kbps.766x480.flv
doc/kungfupanda3-tlr1_h1080p.200kbps.flv
...
...
trunk/conf/full.conf
查看文件 @
b231550
...
...
@@ -178,6 +178,10 @@ http_server {
# the default dir for http root.
# default: ./objs/nginx/html
dir
./
objs
/
nginx
/
html
;
# whether enable crossdomain request.
# for both http static and stream server and apply on all vhosts.
# default: on
crossdomain
on
;
}
#############################################################################################
...
...
trunk/src/app/srs_app_config.cpp
查看文件 @
b231550
...
...
@@ -1704,6 +1704,17 @@ int SrsConfig::reload_http_stream(SrsConfDirective* old_root)
}
srs_trace
(
"reload enabled modified http_stream success."
);
if
(
!
srs_directive_equals
(
old_http_stream
->
get
(
"crossdomain"
),
new_http_stream
->
get
(
"crossdomain"
)))
{
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_http_stream_crossdomain
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes http_stream crossdomain modified failed. ret=%d"
,
ret
);
return
ret
;
}
}
}
srs_trace
(
"reload crossdomain modified http_stream success."
);
return
ret
;
}
...
...
@@ -3570,7 +3581,7 @@ int SrsConfig::check_config()
SrsConfDirective
*
conf
=
root
->
get
(
"http_server"
);
for
(
int
i
=
0
;
conf
&&
i
<
(
int
)
conf
->
directives
.
size
();
i
++
)
{
string
n
=
conf
->
at
(
i
)
->
name
;
if
(
n
!=
"enabled"
&&
n
!=
"listen"
&&
n
!=
"dir"
)
{
if
(
n
!=
"enabled"
&&
n
!=
"listen"
&&
n
!=
"dir"
&&
n
!=
"crossdomain"
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"unsupported http_stream directive %s, ret=%d"
,
n
.
c_str
(),
ret
);
return
ret
;
...
...
@@ -6591,6 +6602,23 @@ string SrsConfig::get_http_stream_dir()
return
conf
->
arg0
();
}
bool
SrsConfig
::
get_http_stream_crossdomain
()
{
static
bool
DEFAULT
=
true
;
SrsConfDirective
*
conf
=
root
->
get
(
"http_server"
);
if
(
!
conf
)
{
return
DEFAULT
;
}
conf
=
conf
->
get
(
"crossdomain"
);
if
(
!
conf
||
conf
->
arg0
().
empty
())
{
return
DEFAULT
;
}
return
SRS_CONF_PERFER_TRUE
(
conf
->
arg0
());
}
bool
SrsConfig
::
get_vhost_http_enabled
(
string
vhost
)
{
static
bool
DEFAULT
=
false
;
...
...
trunk/src/app/srs_app_config.hpp
查看文件 @
b231550
...
...
@@ -1324,6 +1324,10 @@ public:
* get the http stream root dir.
*/
virtual
std
::
string
get_http_stream_dir
();
/**
* whether enable crossdomain for http static and stream server.
*/
virtual
bool
get_http_stream_crossdomain
();
public
:
/**
* get whether vhost enabled http stream
...
...
trunk/src/app/srs_app_conn.hpp
查看文件 @
b231550
...
...
@@ -35,6 +35,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_app_st.hpp>
#include <srs_app_thread.hpp>
#include <srs_protocol_kbps.hpp>
#include <srs_app_reload.hpp>
class
SrsConnection
;
...
...
@@ -58,7 +59,7 @@ public:
* all connections accept from listener must extends from this base class,
* server will add the connection to manager, and delete it when remove.
*/
class
SrsConnection
:
public
virtual
ISrsOneCycleThreadHandler
,
public
virtual
IKbpsDelta
class
SrsConnection
:
virtual
public
ISrsOneCycleThreadHandler
,
virtual
public
IKbpsDelta
,
virtual
public
ISrsReloadHandler
{
private
:
/**
...
...
trunk/src/app/srs_app_http_api.cpp
查看文件 @
b231550
...
...
@@ -1424,7 +1424,7 @@ int SrsHttpApi::process_request(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
r
->
method_str
().
c_str
(),
r
->
url
().
c_str
(),
r
->
content_length
(),
hm
->
is_chunked
(),
hm
->
is_infinite_chunked
());
// use
default server mux to serve http request
.
// use
cors server mux to serve http request, which will proxy to mux
.
if
((
ret
=
cors
->
serve_http
(
w
,
r
))
!=
ERROR_SUCCESS
)
{
if
(
!
srs_is_client_gracefully_close
(
ret
))
{
srs_error
(
"serve http msg failed. ret=%d"
,
ret
);
...
...
trunk/src/app/srs_app_http_conn.cpp
查看文件 @
b231550
...
...
@@ -1091,12 +1091,14 @@ SrsHttpConn::SrsHttpConn(IConnectionManager* cm, st_netfd_t fd, ISrsHttpServeMux
:
SrsConnection
(
cm
,
fd
,
cip
)
{
parser
=
new
SrsHttpParser
();
cors
=
new
SrsHttpCorsMux
();
http_mux
=
m
;
}
SrsHttpConn
::~
SrsHttpConn
()
{
srs_freep
(
parser
);
srs_freep
(
cors
);
}
void
SrsHttpConn
::
resample
()
...
...
@@ -1140,6 +1142,12 @@ int SrsHttpConn::do_cycle()
SrsRequest
*
last_req
=
NULL
;
SrsAutoFree
(
SrsRequest
,
last_req
);
// initialize the cors, which will proxy to mux.
bool
crossdomain_enabled
=
_srs_config
->
get_http_stream_crossdomain
();
if
((
ret
=
cors
->
initialize
(
http_mux
,
crossdomain_enabled
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
// process http messages.
while
(
!
disposed
)
{
ISrsHttpMessage
*
req
=
NULL
;
...
...
@@ -1193,8 +1201,8 @@ int SrsHttpConn::process_request(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
srs_trace
(
"HTTP %s %s, content-length=%"
PRId64
""
,
r
->
method_str
().
c_str
(),
r
->
url
().
c_str
(),
r
->
content_length
());
// use default server mux to serve http request.
if
((
ret
=
http_mux
->
serve_http
(
w
,
r
))
!=
ERROR_SUCCESS
)
{
// use cors server mux to serve http request, which will proxy to http_remux.
if
((
ret
=
cors
->
serve_http
(
w
,
r
))
!=
ERROR_SUCCESS
)
{
if
(
!
srs_is_client_gracefully_close
(
ret
))
{
srs_error
(
"serve http msg failed. ret=%d"
,
ret
);
}
...
...
@@ -1211,6 +1219,19 @@ int SrsHttpConn::on_disconnect(SrsRequest* req)
return
ret
;
}
int
SrsHttpConn
::
on_reload_http_stream_crossdomain
()
{
int
ret
=
ERROR_SUCCESS
;
// initialize the cors, which will proxy to mux.
bool
crossdomain_enabled
=
_srs_config
->
get_http_stream_crossdomain
();
if
((
ret
=
cors
->
initialize
(
http_mux
,
crossdomain_enabled
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
return
ret
;
}
SrsResponseOnlyHttpConn
::
SrsResponseOnlyHttpConn
(
IConnectionManager
*
cm
,
st_netfd_t
fd
,
ISrsHttpServeMux
*
m
,
string
cip
)
:
SrsHttpConn
(
cm
,
fd
,
m
,
cip
)
{
...
...
trunk/src/app/srs_app_http_conn.hpp
查看文件 @
b231550
...
...
@@ -353,11 +353,15 @@ private:
static
int
on_body
(
http_parser
*
parser
,
const
char
*
at
,
size_t
length
);
};
/**
* The http connection which request the static or stream content.
*/
class
SrsHttpConn
:
public
SrsConnection
{
private
:
SrsHttpParser
*
parser
;
ISrsHttpServeMux
*
http_mux
;
SrsHttpCorsMux
*
cors
;
public
:
SrsHttpConn
(
IConnectionManager
*
cm
,
st_netfd_t
fd
,
ISrsHttpServeMux
*
m
,
std
::
string
cip
);
virtual
~
SrsHttpConn
();
...
...
@@ -382,6 +386,9 @@ private:
* @param request: request which is converted by the last http message.
*/
virtual
int
on_disconnect
(
SrsRequest
*
req
);
// interface ISrsReloadHandler
public:
virtual
int
on_reload_http_stream_crossdomain
();
};
/**
...
...
trunk/src/app/srs_app_reload.cpp
查看文件 @
b231550
...
...
@@ -110,6 +110,11 @@ int ISrsReloadHandler::on_reload_http_stream_updated()
return
ERROR_SUCCESS
;
}
int
ISrsReloadHandler
::
on_reload_http_stream_crossdomain
()
{
return
ERROR_SUCCESS
;
}
int
ISrsReloadHandler
::
on_reload_vhost_http_updated
()
{
return
ERROR_SUCCESS
;
...
...
trunk/src/app/srs_app_reload.hpp
查看文件 @
b231550
...
...
@@ -59,6 +59,7 @@ public:
virtual
int
on_reload_http_stream_enabled
();
virtual
int
on_reload_http_stream_disabled
();
virtual
int
on_reload_http_stream_updated
();
virtual
int
on_reload_http_stream_crossdomain
();
public
:
// TODO: FIXME: should rename to http_static
virtual
int
on_reload_vhost_http_updated
();
...
...
trunk/src/core/srs_core.hpp
查看文件 @
b231550
...
...
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version
#define VERSION_MAJOR 3
#define VERSION_MINOR 0
#define VERSION_REVISION
8
#define VERSION_REVISION
9
// generated by configure, only macros.
#include <srs_auto_headers.hpp>
...
...
请
注册
或
登录
后发表评论