1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-12 19:31:53 +00:00

change to 0.9.37, for http api/stream

This commit is contained in:
winlin 2014-03-27 12:14:04 +08:00
parent 041a07dfda
commit aa89f9f51e
14 changed files with 1205 additions and 950 deletions

View file

@ -67,10 +67,11 @@ http_api {
http_stream {
# whether http streaming service is enabled.
# default: off
enabled on;
enabled on;
# the http streaming port
# default: 80
listen 80;
# @remark, if use lower port, for instance 80, user must start srs by root.
# default: 8080
listen 8080;
}
#############################################################################################

5
trunk/configure vendored
View file

@ -416,10 +416,11 @@ RTMP_OBJS="${MODULE_OBJS[@]}"
MODULE_ID="APP"
MODULE_DEPENDS=("CORE" "KERNEL" "RTMP")
ModuleLibIncs=(${LibSTRoot} ${LibHttpParserRoot} ${SRS_OBJS})
MODULE_FILES=("srs_app_server" "srs_app_conn" "srs_app_client" "srs_app_socket" "srs_app_source"
MODULE_FILES=("srs_app_server" "srs_app_conn" "srs_app_rtmp_conn" "srs_app_socket" "srs_app_source"
"srs_app_codec" "srs_app_refer" "srs_app_hls" "srs_app_forward" "srs_app_encoder"
"srs_app_http" "srs_app_thread" "srs_app_bandwidth" "srs_app_st" "srs_app_log"
"srs_app_config" "srs_app_pithy_print" "srs_app_reload")
"srs_app_config" "srs_app_pithy_print" "srs_app_reload" "srs_app_http_api"
"srs_app_http_conn")
APP_INCS="src/app"; MODULE_DIR=${APP_INCS} . auto/modules.sh
APP_OBJS="${MODULE_OBJS[@]}"
#

View file

@ -1466,6 +1466,79 @@ double SrsConfig::get_hls_window(string vhost)
return ::atof(conf->arg0().c_str());
}
SrsConfDirective* SrsConfig::get_http_api()
{
return root->get("http_api");
}
bool SrsConfig::get_http_api_enabled()
{
SrsConfDirective* conf = get_http_api();
if (!conf) {
return false;
}
conf = conf->get("enabled");
if (conf && conf->arg0() == "on") {
return true;
}
return false;
}
int SrsConfig::get_http_api_listen()
{
SrsConfDirective* conf = get_http_api();
if (conf) {
conf = conf->get("listen");
if (conf && !conf->arg0().empty()) {
return ::atoi(conf->arg0().c_str());
}
}
return 1985;
}
SrsConfDirective* SrsConfig::get_http_stream()
{
return root->get("http_stream");
}
bool SrsConfig::get_http_stream_enabled()
{
SrsConfDirective* conf = get_http_stream();
if (!conf) {
return false;
}
conf = conf->get("enabled");
if (conf && conf->arg0() == "on") {
return true;
}
return false;
}
int SrsConfig::get_http_stream_listen()
{
SrsConfDirective* conf = get_http_stream();
if (conf) {
conf = conf->get("listen");
if (conf && !conf->arg0().empty()) {
return ::atoi(conf->arg0().c_str());
}
}
return 8080;
}
SrsConfDirective* SrsConfig::get_refer(string vhost)
{
SrsConfDirective* conf = get_vhost(vhost);

View file

@ -156,6 +156,7 @@ public:
virtual bool get_atc(std::string vhost);
virtual double get_queue_length(std::string vhost);
virtual SrsConfDirective* get_forward(std::string vhost);
// hls section
private:
virtual SrsConfDirective* get_hls(std::string vhost);
public:
@ -163,6 +164,20 @@ public:
virtual std::string get_hls_path(std::string vhost);
virtual double get_hls_fragment(std::string vhost);
virtual double get_hls_window(std::string vhost);
// http api section
private:
virtual SrsConfDirective* get_http_api();
public:
virtual bool get_http_api_enabled();
virtual int get_http_api_listen();
// http stream section
private:
virtual SrsConfDirective* get_http_stream();
public:
virtual bool get_http_stream_enabled();
virtual int get_http_stream_listen();
// others
public:
virtual SrsConfDirective* get_refer(std::string vhost);
virtual SrsConfDirective* get_refer_play(std::string vhost);
virtual SrsConfDirective* get_refer_publish(std::string vhost);

View file

@ -0,0 +1,30 @@
/*
The MIT License (MIT)
Copyright (c) 2013-2014 winlin
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_app_http_api.hpp>
SrsHttpApi::SrsHttpApi() {
}
SrsHttpApi::~SrsHttpApi() {
}

View file

@ -0,0 +1,40 @@
/*
The MIT License (MIT)
Copyright (c) 2013-2014 winlin
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef SRS_APP_HTTP_API_HPP
#define SRS_APP_HTTP_API_HPP
/*
#include <srs_app_http_api.hpp>
*/
#include <srs_core.hpp>
class SrsHttpApi
{
public:
SrsHttpApi();
virtual ~SrsHttpApi();
};
#endif

View file

@ -0,0 +1,24 @@
/*
The MIT License (MIT)
Copyright (c) 2013-2014 winlin
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_app_http_conn.hpp>

View file

@ -0,0 +1,40 @@
/*
The MIT License (MIT)
Copyright (c) 2013-2014 winlin
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef SRS_APP_HTTP_CONN_HPP
#define SRS_APP_HTTP_CONN_HPP
/*
#include <srs_app_http_conn.hpp>
*/
#include <srs_core.hpp>
class SrsHttpConn
{
public:
SrsHttpConn();
virtual ~SrsHttpConn();
};
#endif

File diff suppressed because it is too large Load diff

View file

@ -21,11 +21,11 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef SRS_APP_CLIENT_HPP
#define SRS_APP_CLIENT_HPP
#ifndef SRS_APP_RTMP_CONN_HPP
#define SRS_APP_RTMP_CONN_HPP
/*
#include <srs_app_client.hpp>
#include <srs_app_rtmp_conn.hpp>
*/
#include <srs_core.hpp>

View file

@ -35,7 +35,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_kernel_log.hpp>
#include <srs_kernel_error.hpp>
#include <srs_app_client.hpp>
#include <srs_app_rtmp_conn.hpp>
#include <srs_app_config.hpp>
#include <srs_kernel_utility.hpp>
@ -118,7 +118,7 @@ int SrsListener::listen(int _port)
}
srs_verbose("create st listen thread success.");
srs_trace("server started, listen at port=%d, fd=%d", port, fd);
srs_trace("server started, listen at port=%d, type=%d, fd=%d", port, type, fd);
return ret;
}
@ -301,7 +301,29 @@ int SrsServer::listen()
int port = ::atoi(conf->args.at(i).c_str());
if ((ret = listener->listen(port)) != ERROR_SUCCESS) {
srs_error("listen at port %d failed. ret=%d", port, ret);
srs_error("RTMP stream listen at port %d failed. ret=%d", port, ret);
return ret;
}
}
if (_srs_config->get_http_api_enabled()) {
SrsListener* listener = new SrsListener(this, SrsListenerHttpApi);
listeners.push_back(listener);
int port = _srs_config->get_http_api_listen();
if ((ret = listener->listen(port)) != ERROR_SUCCESS) {
srs_error("HTTP api listen at port %d failed. ret=%d", port, ret);
return ret;
}
}
if (_srs_config->get_http_stream_enabled()) {
SrsListener* listener = new SrsListener(this, SrsListenerHttpStream);
listeners.push_back(listener);
int port = _srs_config->get_http_stream_listen();
if ((ret = listener->listen(port)) != ERROR_SUCCESS) {
srs_error("HTTP stream listen at port %d failed. ret=%d", port, ret);
return ret;
}
}
@ -413,6 +435,8 @@ int SrsServer::accept_client(SrsListenerType type, st_netfd_t client_stfd)
SrsConnection* conn = NULL;
if (type == SrsListenerStream) {
conn = new SrsClient(this, client_stfd);
} else if (type == SrsListenerHttpApi) {
} else if (type == SrsListenerHttpStream) {
} else {
// TODO: FIXME: handler others
}

View file

@ -42,7 +42,8 @@ class SrsConnection;
enum SrsListenerType
{
SrsListenerStream = 0,
SrsListenerApi
SrsListenerHttpApi,
SrsListenerHttpStream
};
class SrsListener : public ISrsThreadHandler

View file

@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version
#define VERSION_MAJOR "0"
#define VERSION_MINOR "9"
#define VERSION_REVISION "36"
#define VERSION_REVISION "37"
#define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
// server info.
#define RTMP_SIG_SRS_KEY "srs"

View file

@ -1,92 +1,96 @@
file
main readonly separator,
..\main\srs_main_server.cpp,
..\main\srs_main_bandcheck.cpp,
auto readonly separator,
..\..\objs\srs_auto_headers.hpp,
libs readonly separator,
..\libs\srs_librtmp.hpp,
..\libs\srs_librtmp.cpp,
..\libs\srs_lib_simple_socket.hpp,
..\libs\srs_lib_simple_socket.cpp,
core readonly separator,
..\core\srs_core.hpp,
..\core\srs_core.cpp,
..\core\srs_core_autofree.hpp,
..\core\srs_core_autofree.cpp,
kernel readonly separator,
..\kernel\srs_kernel_buffer.hpp,
..\kernel\srs_kernel_buffer.cpp,
..\kernel\srs_kernel_error.hpp,
..\kernel\srs_kernel_error.cpp,
..\kernel\srs_kernel_log.hpp,
..\kernel\srs_kernel_log.cpp,
..\kernel\srs_kernel_stream.hpp,
..\kernel\srs_kernel_stream.cpp,
..\kernel\srs_kernel_utility.hpp,
..\kernel\srs_kernel_utility.cpp,
rtmp-protocol readonly separator,
..\rtmp\srs_protocol_amf0.hpp,
..\rtmp\srs_protocol_amf0.cpp,
..\rtmp\srs_protocol_handshake.hpp,
..\rtmp\srs_protocol_handshake.cpp,
..\rtmp\srs_protocol_io.hpp,
..\rtmp\srs_protocol_io.cpp,
..\rtmp\srs_protocol_rtmp.hpp,
..\rtmp\srs_protocol_rtmp.cpp,
..\rtmp\srs_protocol_rtmp_stack.hpp,
..\rtmp\srs_protocol_rtmp_stack.cpp,
..\rtmp\srs_protocol_utility.hpp,
..\rtmp\srs_protocol_utility.cpp,
app readonly separator,
..\app\srs_app_bandwidth.hpp,
..\app\srs_app_bandwidth.cpp,
..\app\srs_app_client.hpp,
..\app\srs_app_client.cpp,
..\app\srs_app_codec.hpp,
..\app\srs_app_codec.cpp,
..\app\srs_app_conn.hpp,
..\app\srs_app_conn.cpp,
..\app\srs_app_config.hpp,
..\app\srs_app_config.cpp,
..\app\srs_app_encoder.hpp,
..\app\srs_app_encoder.cpp,
..\app\srs_app_forward.hpp,
..\app\srs_app_forward.cpp,
..\app\srs_app_hls.hpp,
..\app\srs_app_hls.cpp,
..\app\srs_app_http.hpp,
..\app\srs_app_http.cpp,
..\app\srs_app_log.hpp,
..\app\srs_app_log.cpp,
..\app\srs_app_refer.hpp,
..\app\srs_app_refer.cpp,
..\app\srs_app_reload.hpp,
..\app\srs_app_reload.cpp,
..\app\srs_app_pithy_print.hpp,
..\app\srs_app_pithy_print.cpp,
..\app\srs_app_thread.hpp,
..\app\srs_app_thread.cpp,
..\app\srs_app_server.hpp,
..\app\srs_app_server.cpp,
..\app\srs_app_st.hpp,
..\app\srs_app_st.cpp,
..\app\srs_app_socket.hpp,
..\app\srs_app_socket.cpp,
..\app\srs_app_source.hpp,
..\app\srs_app_source.cpp,
utest readonly separator,
..\utest\srs_utest.hpp,
..\utest\srs_utest.cpp,
..\utest\srs_utest_amf0.hpp,
..\utest\srs_utest_amf0.cpp,
..\utest\srs_utest_handshake.hpp,
..\utest\srs_utest_handshake.cpp,
research readonly separator,
..\..\research\librtmp\srs_play.c,
..\..\research\librtmp\srs_publish.c,
..\..\research\hls\ts_info.cc;
main readonly separator,
..\main\srs_main_server.cpp,
..\main\srs_main_bandcheck.cpp,
auto readonly separator,
..\..\objs\srs_auto_headers.hpp,
libs readonly separator,
..\libs\srs_librtmp.hpp,
..\libs\srs_librtmp.cpp,
..\libs\srs_lib_simple_socket.hpp,
..\libs\srs_lib_simple_socket.cpp,
core readonly separator,
..\core\srs_core.hpp,
..\core\srs_core.cpp,
..\core\srs_core_autofree.hpp,
..\core\srs_core_autofree.cpp,
kernel readonly separator,
..\kernel\srs_kernel_buffer.hpp,
..\kernel\srs_kernel_buffer.cpp,
..\kernel\srs_kernel_error.hpp,
..\kernel\srs_kernel_error.cpp,
..\kernel\srs_kernel_log.hpp,
..\kernel\srs_kernel_log.cpp,
..\kernel\srs_kernel_stream.hpp,
..\kernel\srs_kernel_stream.cpp,
..\kernel\srs_kernel_utility.hpp,
..\kernel\srs_kernel_utility.cpp,
rtmp-protocol readonly separator,
..\rtmp\srs_protocol_amf0.hpp,
..\rtmp\srs_protocol_amf0.cpp,
..\rtmp\srs_protocol_handshake.hpp,
..\rtmp\srs_protocol_handshake.cpp,
..\rtmp\srs_protocol_io.hpp,
..\rtmp\srs_protocol_io.cpp,
..\rtmp\srs_protocol_rtmp.hpp,
..\rtmp\srs_protocol_rtmp.cpp,
..\rtmp\srs_protocol_rtmp_stack.hpp,
..\rtmp\srs_protocol_rtmp_stack.cpp,
..\rtmp\srs_protocol_utility.hpp,
..\rtmp\srs_protocol_utility.cpp,
app readonly separator,
..\app\srs_app_bandwidth.hpp,
..\app\srs_app_bandwidth.cpp,
..\app\srs_app_codec.hpp,
..\app\srs_app_codec.cpp,
..\app\srs_app_conn.hpp,
..\app\srs_app_conn.cpp,
..\app\srs_app_config.hpp,
..\app\srs_app_config.cpp,
..\app\srs_app_encoder.hpp,
..\app\srs_app_encoder.cpp,
..\app\srs_app_forward.hpp,
..\app\srs_app_forward.cpp,
..\app\srs_app_hls.hpp,
..\app\srs_app_hls.cpp,
..\app\srs_app_http.hpp,
..\app\srs_app_http.cpp,
..\app\srs_app_http_api.hpp,
..\app\srs_app_http_api.cpp,
..\app\srs_app_http_conn.hpp,
..\app\srs_app_http_conn.cpp,
..\app\srs_app_log.hpp,
..\app\srs_app_log.cpp,
..\app\srs_app_refer.hpp,
..\app\srs_app_refer.cpp,
..\app\srs_app_reload.hpp,
..\app\srs_app_reload.cpp,
..\app\srs_app_rtmp_conn.hpp,
..\app\srs_app_rtmp_conn.cpp,
..\app\srs_app_pithy_print.hpp,
..\app\srs_app_pithy_print.cpp,
..\app\srs_app_thread.hpp,
..\app\srs_app_thread.cpp,
..\app\srs_app_server.hpp,
..\app\srs_app_server.cpp,
..\app\srs_app_st.hpp,
..\app\srs_app_st.cpp,
..\app\srs_app_socket.hpp,
..\app\srs_app_socket.cpp,
..\app\srs_app_source.hpp,
..\app\srs_app_source.cpp,
utest readonly separator,
..\utest\srs_utest.hpp,
..\utest\srs_utest.cpp,
..\utest\srs_utest_amf0.hpp,
..\utest\srs_utest_amf0.cpp,
..\utest\srs_utest_handshake.hpp,
..\utest\srs_utest_handshake.cpp,
research readonly separator,
..\..\research\librtmp\srs_play.c,
..\..\research\librtmp\srs_publish.c,
..\..\research\hls\ts_info.cc;
mainconfig
"" = "MAIN";
"" = "MAIN";