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-08-11 15:49:48 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
f28c9b7eb55b6ec7e87f683d1de3bc7e688c4c69
f28c9b7e
2 parents
e8c0ca7a
3a6854fc
merge from 2.0release
隐藏空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
72 行增加
和
11 行删除
trunk/src/app/srs_app_http_api.cpp
trunk/src/app/srs_app_http_api.hpp
trunk/src/app/srs_app_http_conn.cpp
trunk/src/app/srs_app_server.cpp
trunk/src/app/srs_app_source.cpp
trunk/src/app/srs_app_http_api.cpp
查看文件 @
f28c9b7
...
...
@@ -111,7 +111,13 @@ int SrsGoApiV1::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
<<
SRS_JFIELD_STR
(
"authors"
,
"the primary authors and contributors"
)
<<
SRS_JFIELD_CONT
<<
SRS_JFIELD_STR
(
"requests"
,
"the request itself, for http debug"
)
<<
SRS_JFIELD_CONT
<<
SRS_JFIELD_STR
(
"vhosts"
,
"dumps vhost to json"
)
<<
SRS_JFIELD_CONT
<<
SRS_JFIELD_STR
(
"streams"
,
"dumps streams to json"
)
<<
SRS_JFIELD_STR
(
"streams"
,
"dumps streams to json"
)
<<
SRS_JFIELD_CONT
<<
SRS_JFIELD_ORG
(
"test"
,
SRS_JOBJECT_START
)
<<
SRS_JFIELD_STR
(
"requests"
,
"show the request info"
)
<<
SRS_JFIELD_CONT
<<
SRS_JFIELD_STR
(
"errors"
,
"always return an error 100"
)
<<
SRS_JFIELD_CONT
<<
SRS_JFIELD_STR
(
"redirects"
,
"always redirect to /api/v1/test/errors"
)
<<
SRS_JFIELD_CONT
<<
SRS_JFIELD_STR
(
".vhost."
,
"http vhost for error.srs.com/api/v1/test/errors"
)
<<
SRS_JOBJECT_END
<<
SRS_JOBJECT_END
<<
SRS_JOBJECT_END
;
...
...
@@ -443,9 +449,9 @@ int SrsGoApiVhosts::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
std
::
stringstream
ss
;
ss
<<
SRS_JOBJECT_START
<<
SRS_JFIELD_ERROR
(
ret
)
<<
SRS_JFIELD_CONT
<<
SRS_JFIELD_ORG
(
"server"
,
stat
->
server_id
())
<<
SRS_JFIELD_CONT
<<
SRS_JFIELD_ORG
(
"vhosts"
,
data
.
str
())
<<
SRS_JFIELD_ERROR
(
ret
)
<<
SRS_JFIELD_CONT
<<
SRS_JFIELD_ORG
(
"server"
,
stat
->
server_id
())
<<
SRS_JFIELD_CONT
<<
SRS_JFIELD_ORG
(
"vhosts"
,
data
.
str
())
<<
SRS_JOBJECT_END
;
return
srs_http_response_json
(
w
,
ss
.
str
());
...
...
@@ -521,6 +527,27 @@ int SrsGoApiStreams::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
}
}
SrsGoApiError
::
SrsGoApiError
()
{
}
SrsGoApiError
::~
SrsGoApiError
()
{
}
int
SrsGoApiError
::
serve_http
(
ISrsHttpResponseWriter
*
w
,
ISrsHttpMessage
*
r
)
{
std
::
stringstream
ss
;
ss
<<
SRS_JOBJECT_START
<<
SRS_JFIELD_ERROR
(
100
)
<<
SRS_JFIELD_CONT
<<
SRS_JFIELD_STR
(
"msg"
,
"SRS demo error."
)
<<
SRS_JFIELD_CONT
<<
SRS_JFIELD_STR
(
"path"
,
r
->
path
())
<<
SRS_JOBJECT_END
;
return
srs_http_response_json
(
w
,
ss
.
str
());
}
SrsHttpApi
::
SrsHttpApi
(
IConnectionManager
*
cm
,
st_netfd_t
fd
,
SrsHttpServeMux
*
m
)
:
SrsConnection
(
cm
,
fd
)
...
...
trunk/src/app/srs_app_http_api.hpp
查看文件 @
f28c9b7
...
...
@@ -159,6 +159,15 @@ public:
virtual
int
serve_http
(
ISrsHttpResponseWriter
*
w
,
ISrsHttpMessage
*
r
);
};
class
SrsGoApiError
:
public
ISrsHttpHandler
{
public
:
SrsGoApiError
();
virtual
~
SrsGoApiError
();
public
:
virtual
int
serve_http
(
ISrsHttpResponseWriter
*
w
,
ISrsHttpMessage
*
r
);
};
class
SrsHttpApi
:
public
SrsConnection
{
private
:
...
...
trunk/src/app/srs_app_http_conn.cpp
查看文件 @
f28c9b7
...
...
@@ -102,10 +102,12 @@ int SrsHttpResponseWriter::write(char* data, int size)
{
int
ret
=
ERROR_SUCCESS
;
// write the header data in memory.
if
(
!
header_wrote
)
{
write_header
(
SRS_CONSTS_HTTP_OK
);
}
// whatever header is wrote, we should try to send header.
if
((
ret
=
send_header
(
data
,
size
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"http: send header failed. ret=%d"
,
ret
);
return
ret
;
...
...
@@ -261,7 +263,7 @@ int SrsHttpResponseWriter::send_header(char* data, int size)
// status_line
ss
<<
"HTTP/1.1 "
<<
status
<<
" "
<<
srs_generate_http_status_text
(
status
)
<<
SRS_HTTP_CRLF
;
<<
srs_generate_http_status_text
(
status
)
<<
SRS_HTTP_CRLF
;
// detect content type
if
(
srs_go_http_body_allowd
(
status
))
{
...
...
trunk/src/app/srs_app_server.cpp
查看文件 @
f28c9b7
...
...
@@ -770,7 +770,7 @@ int SrsServer::http_handle()
#ifdef SRS_AUTO_HTTP_API
srs_assert
(
http_api_mux
);
if
((
ret
=
http_api_mux
->
handle
(
"/"
,
new
Srs
GoApiRoot
()))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
http_api_mux
->
handle
(
"/"
,
new
Srs
HttpNotFoundHandler
()))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
if
((
ret
=
http_api_mux
->
handle
(
"/api"
,
new
SrsGoApiApi
()))
!=
ERROR_SUCCESS
)
{
...
...
@@ -800,15 +800,38 @@ int SrsServer::http_handle()
if
((
ret
=
http_api_mux
->
handle
(
"/api/v1/authors"
,
new
SrsGoApiAuthors
()))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
if
((
ret
=
http_api_mux
->
handle
(
"/api/v1/requests"
,
new
SrsGoApiRequests
()))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
if
((
ret
=
http_api_mux
->
handle
(
"/api/v1/vhosts"
,
new
SrsGoApiVhosts
()))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
if
((
ret
=
http_api_mux
->
handle
(
"/api/v1/streams/"
,
new
SrsGoApiStreams
()))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
// test the request info.
if
((
ret
=
http_api_mux
->
handle
(
"/api/v1/test/requests"
,
new
SrsGoApiRequests
()))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
// test the error code response.
if
((
ret
=
http_api_mux
->
handle
(
"/api/v1/test/errors"
,
new
SrsGoApiError
()))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
// test the redirect mechenism.
if
((
ret
=
http_api_mux
->
handle
(
"/api/v1/test/redirects"
,
new
SrsHttpRedirectHandler
(
"/api/v1/test/errors"
,
SRS_CONSTS_HTTP_MovedPermanently
)))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
// test the http vhost.
if
((
ret
=
http_api_mux
->
handle
(
"error.srs.com/api/v1/test/errors"
,
new
SrsGoApiError
()))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
// TODO: FIXME: for console.
// TODO: FIXME: support reload.
std
::
string
dir
=
_srs_config
->
get_http_stream_dir
()
+
"/srs-console"
;
if
((
ret
=
http_api_mux
->
handle
(
"/console/"
,
new
SrsHttpFileServer
(
dir
)))
!=
ERROR_SUCCESS
)
{
srs_error
(
"http: mount console dir=%s failed. ret=%d"
,
dir
.
c_str
(),
ret
);
return
ret
;
}
srs_trace
(
"http: console mount to %s"
,
dir
.
c_str
());
#endif
return
ret
;
...
...
trunk/src/app/srs_app_source.cpp
查看文件 @
f28c9b7
...
...
@@ -1490,7 +1490,7 @@ int SrsSource::on_audio(SrsCommonMessage* shared_audio)
if
(
!
mix_correct
&&
is_monotonically_increase
)
{
if
(
last_packet_time
>
0
&&
shared_audio
->
header
.
timestamp
<
last_packet_time
)
{
is_monotonically_increase
=
false
;
srs_warn
(
"AU
T
IO: stream not monotonically increase, please open mix_correct."
);
srs_warn
(
"AU
D
IO: stream not monotonically increase, please open mix_correct."
);
}
}
last_packet_time
=
shared_audio
->
header
.
timestamp
;
...
...
请
注册
或
登录
后发表评论