1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

for #742, always enable http utilities.

This commit is contained in:
winlin 2017-01-23 17:43:59 +08:00
parent 79def81792
commit a1fcf66f32
25 changed files with 42 additions and 362 deletions

View file

@ -3783,17 +3783,6 @@ int SrsConfig::check_config()
////////////////////////////////////////////////////////////////////////
// check features
////////////////////////////////////////////////////////////////////////
#ifndef SRS_AUTO_HTTP_SERVER
if (get_http_stream_enabled()) {
srs_warn("http_stream is disabled by configure");
}
#endif
#ifndef SRS_AUTO_HTTP_API
if (get_http_api_enabled()) {
srs_warn("http_api is disabled by configure");
}
#endif
vector<SrsConfDirective*> stream_casters = get_stream_casters();
for (int n = 0; n < (int)stream_casters.size(); n++) {
SrsConfDirective* stream_caster = stream_casters[n];
@ -4066,11 +4055,6 @@ int SrsConfig::check_config()
srs_warn("hls of vhost %s is disabled by configure", vhost->arg0().c_str());
}
#endif
#ifndef SRS_AUTO_HTTP_CALLBACK
if (get_vhost_http_hooks_enabled(vhost->arg0())) {
srs_warn("http_hooks of vhost %s is disabled by configure", vhost->arg0().c_str());
}
#endif
#ifndef SRS_AUTO_TRANSCODE
if (get_transcode_enabled(get_transcode(vhost->arg0(), ""))) {
srs_warn("transcode of vhost %s is disabled by configure", vhost->arg0().c_str());

View file

@ -302,7 +302,6 @@ int SrsFlvSegment::write_video(SrsSharedPtrMessage* shared_video)
int size = video->size;
bool is_sequence_header = SrsFlvCodec::video_is_sequence_header(payload, size);
#ifdef SRS_AUTO_HTTP_CALLBACK
bool is_key_frame = SrsFlvCodec::video_is_h264(payload, size)
&& SrsFlvCodec::video_is_keyframe(payload, size) && !is_sequence_header;
if (is_key_frame) {
@ -312,7 +311,6 @@ int SrsFlvSegment::write_video(SrsSharedPtrMessage* shared_video)
}
}
srs_verbose("dvr video is key: %d", is_key_frame);
#endif
// accept the sequence header here.
// when got no keyframe, ignore when should wait keyframe.
@ -512,7 +510,6 @@ int SrsDvrAsyncCallOnDvr::call()
{
int ret = ERROR_SUCCESS;
#ifdef SRS_AUTO_HTTP_CALLBACK
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
return ret;
}
@ -540,7 +537,6 @@ int SrsDvrAsyncCallOnDvr::call()
return ret;
}
}
#endif
return ret;
}

View file

@ -23,8 +23,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_app_heartbeat.hpp>
#ifdef SRS_AUTO_HTTP_CORE
#include <sstream>
using namespace std;
@ -104,5 +102,3 @@ void SrsHttpHeartbeat::heartbeat()
return;
}
#endif

View file

@ -29,8 +29,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_core.hpp>
#ifdef SRS_AUTO_HTTP_CORE
/**
* the http heartbeat to api-server to notice api
* that the information of SRS.
@ -46,5 +44,3 @@ public:
#endif
#endif

View file

@ -190,7 +190,6 @@ int SrsDvrAsyncCallOnHls::call()
{
int ret = ERROR_SUCCESS;
#ifdef SRS_AUTO_HTTP_CALLBACK
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
return ret;
}
@ -218,7 +217,6 @@ int SrsDvrAsyncCallOnHls::call()
return ret;
}
}
#endif
return ret;
}
@ -244,7 +242,6 @@ int SrsDvrAsyncCallOnHlsNotify::call()
{
int ret = ERROR_SUCCESS;
#ifdef SRS_AUTO_HTTP_CALLBACK
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
return ret;
}
@ -273,7 +270,6 @@ int SrsDvrAsyncCallOnHlsNotify::call()
return ret;
}
}
#endif
return ret;
}

View file

@ -23,8 +23,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_app_http_api.hpp>
#ifdef SRS_AUTO_HTTP_API
#include <sstream>
#include <stdlib.h>
#include <signal.h>
@ -556,21 +554,9 @@ int SrsGoApiFeatures::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
#else
features->set("hds", SrsJsonAny::boolean(false));
#endif
#ifdef SRS_AUTO_HTTP_CALLBACK
features->set("callback", SrsJsonAny::boolean(true));
#else
features->set("callback", SrsJsonAny::boolean(false));
#endif
#ifdef SRS_AUTO_HTTP_API
features->set("api", SrsJsonAny::boolean(true));
#else
features->set("api", SrsJsonAny::boolean(false));
#endif
#ifdef SRS_AUTO_HTTP_SERVER
features->set("httpd", SrsJsonAny::boolean(true));
#else
features->set("httpd", SrsJsonAny::boolean(false));
#endif
#ifdef SRS_AUTO_DVR
features->set("dvr", SrsJsonAny::boolean(true));
#else
@ -1447,5 +1433,3 @@ int SrsHttpApi::on_reload_http_api_crossdomain()
return ERROR_SUCCESS;
}
#endif

View file

@ -30,8 +30,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_core.hpp>
#ifdef SRS_AUTO_HTTP_API
class SrsStSocket;
class ISrsHttpMessage;
class SrsHttpParser;
@ -233,5 +231,3 @@ public:
#endif
#endif

View file

@ -23,8 +23,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_app_http_client.hpp>
#ifdef SRS_AUTO_HTTP_CORE
#include <arpa/inet.h>
using namespace std;
@ -247,5 +245,3 @@ int SrsHttpClient::connect()
return ret;
}
#endif

View file

@ -32,8 +32,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <string>
#include <map>
#ifdef SRS_AUTO_HTTP_CORE
#include <srs_app_st.hpp>
class SrsHttpUri;
@ -112,5 +110,3 @@ private:
#endif
#endif

View file

@ -23,8 +23,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_app_http_conn.hpp>
#if defined(SRS_AUTO_HTTP_CORE)
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@ -60,10 +58,6 @@ using namespace std;
#include <srs_protocol_amf0.hpp>
#include <srs_app_utility.hpp>
#endif
#ifdef SRS_AUTO_HTTP_CORE
SrsHttpResponseWriter::SrsHttpResponseWriter(SrsStSocket* io)
{
skt = io;
@ -1280,12 +1274,10 @@ int SrsHttpServer::initialize()
{
int ret = ERROR_SUCCESS;
#if defined(SRS_AUTO_HTTP_SERVER) && defined(SRS_AUTO_HTTP_API)
// for SRS go-sharp to detect the status of HTTP server of SRS HTTP FLV Cluster.
if ((ret = http_static->mux.handle("/api/v1/versions", new SrsGoApiVersion())) != ERROR_SUCCESS) {
return ret;
}
#endif
if ((ret = http_stream->initialize()) != ERROR_SUCCESS) {
return ret;
@ -1318,5 +1310,3 @@ void SrsHttpServer::http_unmount(SrsSource* s, SrsRequest* r)
http_stream->http_unmount(s, r);
}
#endif

View file

@ -30,8 +30,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_core.hpp>
#ifdef SRS_AUTO_HTTP_CORE
#include <map>
#include <string>
#include <vector>
@ -428,5 +426,3 @@ public:
#endif
#endif

View file

@ -23,8 +23,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_app_http_hooks.hpp>
#ifdef SRS_AUTO_HTTP_CALLBACK
#include <sstream>
using namespace std;
@ -503,5 +501,3 @@ int SrsHttpHooks::do_post(SrsHttpClient* hc, std::string url, std::string req, i
return ret;
}
#endif

View file

@ -31,8 +31,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <string>
#ifdef SRS_AUTO_HTTP_CALLBACK
class SrsHttpUri;
class SrsStSocket;
class SrsRequest;
@ -124,5 +122,3 @@ private:
#endif
#endif

View file

@ -23,8 +23,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_app_http_static.hpp>
#if defined(SRS_AUTO_HTTP_CORE)
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@ -53,10 +51,6 @@ using namespace std;
#include <srs_app_source.hpp>
#include <srs_app_server.hpp>
#endif
#ifdef SRS_AUTO_HTTP_SERVER
SrsVodStream::SrsVodStream(string root_dir)
: SrsHttpFileServer(root_dir)
{
@ -315,5 +309,3 @@ int SrsHttpStaticServer::on_reload_vhost_http_updated()
return ret;
}
#endif

View file

@ -32,8 +32,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_app_http_conn.hpp>
#ifdef SRS_AUTO_HTTP_SERVER
/**
* the flv vod stream supports flv?start=offset-bytes.
* for example, http://server/file.flv?start=10240
@ -75,5 +73,3 @@ public:
#endif
#endif

View file

@ -25,8 +25,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define SRS_STREAM_CACHE_CYCLE_SECONDS 30
#if defined(SRS_AUTO_HTTP_CORE)
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@ -56,10 +54,6 @@ using namespace std;
#include <srs_app_server.hpp>
#include <srs_app_statistic.hpp>
#endif
#ifdef SRS_AUTO_HTTP_SERVER
SrsBufferCache::SrsBufferCache(SrsSource* s, SrsRequest* r)
{
req = r->copy();
@ -1077,5 +1071,3 @@ int SrsHttpStreamServer::initialize_flv_entry(std::string vhost)
return ret;
}
#endif

View file

@ -32,8 +32,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_app_http_conn.hpp>
#ifdef SRS_AUTO_HTTP_SERVER
/**
* for the srs http stream cache,
* for example, the audio stream cache to make android(weixin) happy.
@ -354,5 +352,3 @@ private:
#endif
#endif

View file

@ -1567,7 +1567,6 @@ int SrsRtmpConn::http_hooks_on_connect()
SrsRequest* req = info->req;
#ifdef SRS_AUTO_HTTP_CALLBACK
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
return ret;
}
@ -1595,14 +1594,12 @@ int SrsRtmpConn::http_hooks_on_connect()
return ret;
}
}
#endif
return ret;
}
void SrsRtmpConn::http_hooks_on_close()
{
#ifdef SRS_AUTO_HTTP_CALLBACK
SrsRequest* req = info->req;
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
@ -1629,14 +1626,12 @@ void SrsRtmpConn::http_hooks_on_close()
std::string url = hooks.at(i);
SrsHttpHooks::on_close(url, req, kbps->get_send_bytes(), kbps->get_recv_bytes());
}
#endif
}
int SrsRtmpConn::http_hooks_on_publish()
{
int ret = ERROR_SUCCESS;
#ifdef SRS_AUTO_HTTP_CALLBACK
SrsRequest* req = info->req;
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
@ -1666,14 +1661,12 @@ int SrsRtmpConn::http_hooks_on_publish()
return ret;
}
}
#endif
return ret;
}
void SrsRtmpConn::http_hooks_on_unpublish()
{
#ifdef SRS_AUTO_HTTP_CALLBACK
SrsRequest* req = info->req;
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
@ -1700,14 +1693,12 @@ void SrsRtmpConn::http_hooks_on_unpublish()
std::string url = hooks.at(i);
SrsHttpHooks::on_unpublish(url, req);
}
#endif
}
int SrsRtmpConn::http_hooks_on_play()
{
int ret = ERROR_SUCCESS;
#ifdef SRS_AUTO_HTTP_CALLBACK
SrsRequest* req = info->req;
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
@ -1737,14 +1728,12 @@ int SrsRtmpConn::http_hooks_on_play()
return ret;
}
}
#endif
return ret;
}
void SrsRtmpConn::http_hooks_on_stop()
{
#ifdef SRS_AUTO_HTTP_CALLBACK
SrsRequest* req = info->req;
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
@ -1771,7 +1760,6 @@ void SrsRtmpConn::http_hooks_on_stop()
std::string url = hooks.at(i);
SrsHttpHooks::on_stop(url, req);
}
#endif
return;
}

View file

@ -46,9 +46,7 @@ class SrsRefer;
class SrsConsumer;
class SrsCommonMessage;
class SrsStSocket;
#ifdef SRS_AUTO_HTTP_CALLBACK
class SrsHttpHooks;
#endif
class SrsBandwidth;
class SrsKbps;
class SrsRtmpClient;

View file

@ -493,15 +493,10 @@ SrsServer::SrsServer()
// donot new object in constructor,
// for some global instance is not ready now,
// new these objects in initialize instead.
#ifdef SRS_AUTO_HTTP_API
http_api_mux = new SrsHttpServeMux();
#endif
#ifdef SRS_AUTO_HTTP_SERVER
http_server = new SrsHttpServer(this);
#endif
#ifdef SRS_AUTO_HTTP_CORE
http_heartbeat = NULL;
#endif
#ifdef SRS_AUTO_INGEST
ingester = NULL;
#endif
@ -518,17 +513,9 @@ void SrsServer::destroy()
dispose();
#ifdef SRS_AUTO_HTTP_API
srs_freep(http_api_mux);
#endif
#ifdef SRS_AUTO_HTTP_SERVER
srs_freep(http_server);
#endif
#ifdef SRS_AUTO_HTTP_CORE
srs_freep(http_heartbeat);
#endif
#ifdef SRS_AUTO_INGEST
srs_freep(ingester);
@ -591,23 +578,15 @@ int SrsServer::initialize(ISrsServerCycle* cycle_handler)
return ret;
}
#ifdef SRS_AUTO_HTTP_API
if ((ret = http_api_mux->initialize()) != ERROR_SUCCESS) {
return ret;
}
#endif
#ifdef SRS_AUTO_HTTP_SERVER
srs_assert(http_server);
if ((ret = http_server->initialize()) != ERROR_SUCCESS) {
return ret;
}
#endif
#ifdef SRS_AUTO_HTTP_CORE
srs_assert(!http_heartbeat);
http_heartbeat = new SrsHttpHeartbeat();
#endif
#ifdef SRS_AUTO_INGEST
srs_assert(!ingester);
@ -779,7 +758,6 @@ int SrsServer::http_handle()
{
int ret = ERROR_SUCCESS;
#ifdef SRS_AUTO_HTTP_API
srs_assert(http_api_mux);
if ((ret = http_api_mux->handle("/", new SrsHttpNotFoundHandler())) != ERROR_SUCCESS) {
return ret;
@ -852,7 +830,6 @@ int SrsServer::http_handle()
return ret;
}
srs_trace("http: api mount /console to %s", dir.c_str());
#endif
return ret;
}
@ -1075,14 +1052,12 @@ int SrsServer::do_cycle()
srs_info("update network server kbps info.");
resample_kbps();
}
#ifdef SRS_AUTO_HTTP_CORE
if (_srs_config->get_heartbeat_enabled()) {
if ((i % heartbeat_max_resolution) == 0) {
srs_info("do http heartbeat, for internal server to report.");
http_heartbeat->heartbeat();
}
}
#endif
#endif
srs_info("server main thread loop");
@ -1123,7 +1098,6 @@ int SrsServer::listen_http_api()
{
int ret = ERROR_SUCCESS;
#ifdef SRS_AUTO_HTTP_API
close_listeners(SrsListenerHttpApi);
if (_srs_config->get_http_api_enabled()) {
SrsListener* listener = new SrsBufferListener(this, SrsListenerHttpApi);
@ -1140,7 +1114,6 @@ int SrsServer::listen_http_api()
return ret;
}
}
#endif
return ret;
}
@ -1149,7 +1122,6 @@ int SrsServer::listen_http_stream()
{
int ret = ERROR_SUCCESS;
#ifdef SRS_AUTO_HTTP_SERVER
close_listeners(SrsListenerHttpStream);
if (_srs_config->get_http_stream_enabled()) {
SrsListener* listener = new SrsBufferListener(this, SrsListenerHttpStream);
@ -1166,7 +1138,6 @@ int SrsServer::listen_http_stream()
return ret;
}
}
#endif
return ret;
}
@ -1329,30 +1300,15 @@ SrsConnection* SrsServer::fd2conn(SrsListenerType type, st_netfd_t stfd)
}
SrsConnection* conn = NULL;
bool close_for_not_served = false;
if (type == SrsListenerRtmpStream) {
conn = new SrsRtmpConn(this, stfd, ip);
} else if (type == SrsListenerHttpApi) {
#ifdef SRS_AUTO_HTTP_API
conn = new SrsHttpApi(this, stfd, http_api_mux, ip);
#else
srs_warn("close http client for server not support http-api");
close_for_not_served = true;
#endif
} else if (type == SrsListenerHttpStream) {
#ifdef SRS_AUTO_HTTP_SERVER
conn = new SrsResponseOnlyHttpConn(this, stfd, http_server, ip);
#else
srs_warn("close http client for server not support http-server");
close_for_not_served = true;
#endif
} else {
// TODO: FIXME: handler others
srs_assert(false);
}
if (close_for_not_served) {
srs_warn("close for no service handler. fd=%d, ip=%s", fd, ip.c_str());
srs_close_stfd(stfd);
return NULL;
}
@ -1402,7 +1358,6 @@ int SrsServer::on_reload_vhost_added(std::string vhost)
{
int ret = ERROR_SUCCESS;
#ifdef SRS_AUTO_HTTP_SERVER
if (!_srs_config->get_vhost_http_enabled(vhost)) {
return ret;
}
@ -1411,7 +1366,6 @@ int SrsServer::on_reload_vhost_added(std::string vhost)
if ((ret = on_reload_vhost_http_updated()) != ERROR_SUCCESS) {
return ret;
}
#endif
return ret;
}
@ -1420,58 +1374,34 @@ int SrsServer::on_reload_vhost_removed(std::string /*vhost*/)
{
int ret = ERROR_SUCCESS;
#ifdef SRS_AUTO_HTTP_SERVER
// TODO: FIXME: should handle the event in SrsHttpStaticServer
if ((ret = on_reload_vhost_http_updated()) != ERROR_SUCCESS) {
return ret;
}
#endif
return ret;
}
int SrsServer::on_reload_http_api_enabled()
{
int ret = ERROR_SUCCESS;
#ifdef SRS_AUTO_HTTP_API
ret = listen_http_api();
#endif
return ret;
return listen_http_api();
}
int SrsServer::on_reload_http_api_disabled()
{
int ret = ERROR_SUCCESS;
#ifdef SRS_AUTO_HTTP_API
close_listeners(SrsListenerHttpApi);
#endif
return ret;
return ERROR_SUCCESS;
}
int SrsServer::on_reload_http_stream_enabled()
{
int ret = ERROR_SUCCESS;
#ifdef SRS_AUTO_HTTP_SERVER
ret = listen_http_stream();
#endif
return ret;
return listen_http_stream();
}
int SrsServer::on_reload_http_stream_disabled()
{
int ret = ERROR_SUCCESS;
#ifdef SRS_AUTO_HTTP_SERVER
close_listeners(SrsListenerHttpStream);
#endif
return ret;
return ERROR_SUCCESS;
}
// TODO: FIXME: rename to http_remux
@ -1479,7 +1409,6 @@ int SrsServer::on_reload_http_stream_updated()
{
int ret = ERROR_SUCCESS;
#ifdef SRS_AUTO_HTTP_SERVER
if ((ret = on_reload_http_stream_enabled()) != ERROR_SUCCESS) {
return ret;
}
@ -1488,7 +1417,6 @@ int SrsServer::on_reload_http_stream_updated()
if ((ret = on_reload_vhost_http_updated()) != ERROR_SUCCESS) {
return ret;
}
#endif
return ret;
}
@ -1497,19 +1425,15 @@ int SrsServer::on_publish(SrsSource* s, SrsRequest* r)
{
int ret = ERROR_SUCCESS;
#ifdef SRS_AUTO_HTTP_SERVER
if ((ret = http_server->http_mount(s, r)) != ERROR_SUCCESS) {
return ret;
}
#endif
return ret;
}
void SrsServer::on_unpublish(SrsSource* s, SrsRequest* r)
{
#ifdef SRS_AUTO_HTTP_SERVER
http_server->http_unmount(s, r);
#endif
}

View file

@ -241,16 +241,10 @@ class SrsServer : virtual public ISrsReloadHandler
, virtual public IConnectionManager
{
private:
#ifdef SRS_AUTO_HTTP_API
// TODO: FIXME: rename to http_api
SrsHttpServeMux* http_api_mux;
#endif
#ifdef SRS_AUTO_HTTP_SERVER
SrsHttpServer* http_server;
#endif
#ifdef SRS_AUTO_HTTP_CORE
SrsHttpHeartbeat* http_heartbeat;
#endif
#ifdef SRS_AUTO_INGEST
SrsIngester* ingester;
#endif

View file

@ -59,8 +59,6 @@ ISrsThreadContext* _srs_context = new ISrsThreadContext();
// @global config object for app module.
SrsConfig* _srs_config = NULL;
#if defined(SRS_AUTO_HTTP_CORE)
/**
* main entrance.
*/
@ -70,11 +68,6 @@ int main(int argc, char** argv)
srs_assert(srs_is_little_endian());
// directly failed when compile limited.
#if !defined(SRS_AUTO_HTTP_CORE)
srs_error("depends on http-parser.");
exit(-1);
#endif
#if defined(SRS_AUTO_GPERF_MP) || defined(SRS_AUTO_GPERF_MP) \
|| defined(SRS_AUTO_GPERF_MC) || defined(SRS_AUTO_GPERF_MP)
srs_error("donot support gmc/gmp/gcp/gprof");
@ -1326,15 +1319,3 @@ int proxy_hls2rtmp(string hls, string rtmp)
return ret;
}
#else
int main(int argc, char** argv)
{
#ifndef SRS_AUTO_HTTP_CORE
srs_error("ingest requires http-api or http-server");
#endif
return -1;
}
#endif