srs/trunk/src/app/srs_app_rtc_api.hpp
Winlin 32dfed43ef
AI: Merge SRT and RTC servers into unified SrsServer. v7.0.68 (#4459)
This PR consolidates the SRT and RTC server functionality into the main
SrsServer class, eliminating the separate `SrsSrtServer` and
`SrsRtcServer` classes and their corresponding adapter classes. This
architectural change simplifies the codebase by removing the hybrid
server pattern and integrating all protocol handling directly into
`SrsServer`.

As unified connection manager (`_srs_conn_manager`) for all protocol
connections, all incoming connections are checked against the same
connection limit in `on_before_connection()`. This enables consistent
connection limits: `max_connections` now protects against resource
exhaustion from any protocol, not just RTMP.

Remove modules because it's not used now, so only keep the server
application module and main entry point. Remove the wait group to run
server, instead, directly run server and invoke the cycle method.

After this PR, the startup workflow and servers architecture should be
much easier to maintain.

---------

Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-08-31 08:58:37 -04:00

107 lines
2.5 KiB
C++

//
// Copyright (c) 2013-2025 The SRS Authors
//
// SPDX-License-Identifier: MIT
//
#ifndef SRS_APP_RTC_API_HPP
#define SRS_APP_RTC_API_HPP
#include <srs_app_security.hpp>
#include <srs_core.hpp>
#include <srs_protocol_http_stack.hpp>
class SrsServer;
class ISrsRequest;
class SrsSdp;
class SrsRtcUserConfig;
class SrsGoApiRtcPlay : public ISrsHttpHandler
{
private:
SrsServer *server_;
SrsSecurity *security_;
public:
SrsGoApiRtcPlay(SrsServer *server);
virtual ~SrsGoApiRtcPlay();
public:
virtual srs_error_t serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r);
private:
virtual srs_error_t do_serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, SrsJsonObject *res);
public:
virtual srs_error_t serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, SrsRtcUserConfig *ruc);
private:
srs_error_t check_remote_sdp(const SrsSdp &remote_sdp);
private:
virtual srs_error_t http_hooks_on_play(ISrsRequest *req);
};
class SrsGoApiRtcPublish : public ISrsHttpHandler
{
private:
SrsServer *server_;
SrsSecurity *security_;
public:
SrsGoApiRtcPublish(SrsServer *server);
virtual ~SrsGoApiRtcPublish();
public:
virtual srs_error_t serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r);
private:
virtual srs_error_t do_serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, SrsJsonObject *res);
public:
virtual srs_error_t serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, SrsRtcUserConfig *ruc);
private:
srs_error_t check_remote_sdp(const SrsSdp &remote_sdp);
private:
virtual srs_error_t http_hooks_on_publish(ISrsRequest *req);
};
// See https://datatracker.ietf.org/doc/draft-ietf-wish-whip/
class SrsGoApiRtcWhip : public ISrsHttpHandler
{
private:
SrsServer *server_;
SrsGoApiRtcPublish *publish_;
SrsGoApiRtcPlay *play_;
public:
SrsGoApiRtcWhip(SrsServer *server);
virtual ~SrsGoApiRtcWhip();
public:
virtual srs_error_t serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r);
private:
virtual srs_error_t do_serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, SrsRtcUserConfig *ruc);
};
class SrsGoApiRtcNACK : public ISrsHttpHandler
{
private:
SrsServer *server_;
public:
SrsGoApiRtcNACK(SrsServer *server);
virtual ~SrsGoApiRtcNACK();
public:
virtual srs_error_t serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r);
private:
virtual srs_error_t do_serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, SrsJsonObject *res);
};
#endif