mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
change to 0.9.37, for http api/stream
This commit is contained in:
parent
041a07dfda
commit
aa89f9f51e
14 changed files with 1205 additions and 950 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
30
trunk/src/app/srs_app_http_api.cpp
Normal file
30
trunk/src/app/srs_app_http_api.cpp
Normal 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() {
|
||||
}
|
40
trunk/src/app/srs_app_http_api.hpp
Normal file
40
trunk/src/app/srs_app_http_api.hpp
Normal 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
|
24
trunk/src/app/srs_app_http_conn.cpp
Normal file
24
trunk/src/app/srs_app_http_conn.cpp
Normal 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>
|
40
trunk/src/app/srs_app_http_conn.hpp
Normal file
40
trunk/src/app/srs_app_http_conn.hpp
Normal 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
|
1700
trunk/src/app/srs_app_client.cpp → trunk/src/app/srs_app_rtmp_conn.cpp
Executable file → Normal file
1700
trunk/src/app/srs_app_client.cpp → trunk/src/app/srs_app_rtmp_conn.cpp
Executable file → Normal file
File diff suppressed because it is too large
Load diff
|
@ -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>
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -42,7 +42,8 @@ class SrsConnection;
|
|||
enum SrsListenerType
|
||||
{
|
||||
SrsListenerStream = 0,
|
||||
SrsListenerApi
|
||||
SrsListenerHttpApi,
|
||||
SrsListenerHttpStream
|
||||
};
|
||||
|
||||
class SrsListener : public ISrsThreadHandler
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue