mirror of
https://github.com/ossrs/srs.git
synced 2025-02-12 19:31:53 +00:00
rename srs-client to srs-rtmp-conn
This commit is contained in:
parent
aa89f9f51e
commit
ab3c6c92a0
6 changed files with 62 additions and 57 deletions
|
@ -43,7 +43,7 @@ using namespace std;
|
|||
#include <srs_app_bandwidth.hpp>
|
||||
#include <srs_app_socket.hpp>
|
||||
|
||||
SrsClient::SrsClient(SrsServer* srs_server, st_netfd_t client_stfd)
|
||||
SrsRtmpConn::SrsRtmpConn(SrsServer* srs_server, st_netfd_t client_stfd)
|
||||
: SrsConnection(srs_server, client_stfd)
|
||||
{
|
||||
ip = NULL;
|
||||
|
@ -60,7 +60,7 @@ SrsClient::SrsClient(SrsServer* srs_server, st_netfd_t client_stfd)
|
|||
_srs_config->subscribe(this);
|
||||
}
|
||||
|
||||
SrsClient::~SrsClient()
|
||||
SrsRtmpConn::~SrsRtmpConn()
|
||||
{
|
||||
_srs_config->unsubscribe(this);
|
||||
|
||||
|
@ -77,7 +77,7 @@ SrsClient::~SrsClient()
|
|||
}
|
||||
|
||||
// TODO: return detail message when error for client.
|
||||
int SrsClient::do_cycle()
|
||||
int SrsRtmpConn::do_cycle()
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
|
@ -139,7 +139,7 @@ int SrsClient::do_cycle()
|
|||
return ret;
|
||||
}
|
||||
|
||||
int SrsClient::on_reload_vhost_removed(string vhost)
|
||||
int SrsRtmpConn::on_reload_vhost_removed(string vhost)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
|
@ -156,7 +156,7 @@ int SrsClient::on_reload_vhost_removed(string vhost)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int SrsClient::service_cycle()
|
||||
int SrsRtmpConn::service_cycle()
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
|
@ -232,11 +232,11 @@ int SrsClient::service_cycle()
|
|||
return ret;
|
||||
}
|
||||
|
||||
int SrsClient::stream_service_cycle()
|
||||
int SrsRtmpConn::stream_service_cycle()
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
SrsClientType type;
|
||||
SrsRtmpConnType type;
|
||||
if ((ret = rtmp->identify_client(res->stream_id, type, req->stream)) != ERROR_SUCCESS) {
|
||||
srs_error("identify client failed. ret=%d", ret);
|
||||
return ret;
|
||||
|
@ -262,7 +262,7 @@ int SrsClient::stream_service_cycle()
|
|||
srs_assert(source != NULL);
|
||||
|
||||
// check publish available.
|
||||
if (type != SrsClientPlay && !source->can_publish()) {
|
||||
if (type != SrsRtmpConnPlay && !source->can_publish()) {
|
||||
ret = ERROR_SYSTEM_STREAM_BUSY;
|
||||
srs_warn("stream %s is already publishing. ret=%d",
|
||||
req->get_stream_url().c_str(), ret);
|
||||
|
@ -276,7 +276,7 @@ int SrsClient::stream_service_cycle()
|
|||
source->set_cache(enabled_cache);
|
||||
|
||||
switch (type) {
|
||||
case SrsClientPlay: {
|
||||
case SrsRtmpConnPlay: {
|
||||
srs_verbose("start to play stream %s.", req->stream.c_str());
|
||||
|
||||
if ((ret = rtmp->start_play(res->stream_id)) != ERROR_SUCCESS) {
|
||||
|
@ -292,7 +292,7 @@ int SrsClient::stream_service_cycle()
|
|||
on_stop();
|
||||
return ret;
|
||||
}
|
||||
case SrsClientFMLEPublish: {
|
||||
case SrsRtmpConnFMLEPublish: {
|
||||
srs_verbose("FMLE start to publish stream %s.", req->stream.c_str());
|
||||
|
||||
if ((ret = rtmp->start_fmle_publish(res->stream_id)) != ERROR_SUCCESS) {
|
||||
|
@ -309,7 +309,7 @@ int SrsClient::stream_service_cycle()
|
|||
on_unpublish();
|
||||
return ret;
|
||||
}
|
||||
case SrsClientFlashPublish: {
|
||||
case SrsRtmpConnFlashPublish: {
|
||||
srs_verbose("flash start to publish stream %s.", req->stream.c_str());
|
||||
|
||||
if ((ret = rtmp->start_flash_publish(res->stream_id)) != ERROR_SUCCESS) {
|
||||
|
@ -336,7 +336,7 @@ int SrsClient::stream_service_cycle()
|
|||
return ret;
|
||||
}
|
||||
|
||||
int SrsClient::check_vhost()
|
||||
int SrsRtmpConn::check_vhost()
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
|
@ -373,7 +373,7 @@ int SrsClient::check_vhost()
|
|||
return ret;
|
||||
}
|
||||
|
||||
int SrsClient::playing(SrsSource* source)
|
||||
int SrsRtmpConn::playing(SrsSource* source)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
|
@ -462,7 +462,7 @@ int SrsClient::playing(SrsSource* source)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int SrsClient::fmle_publish(SrsSource* source)
|
||||
int SrsRtmpConn::fmle_publish(SrsSource* source)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
|
@ -531,7 +531,7 @@ int SrsClient::fmle_publish(SrsSource* source)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int SrsClient::flash_publish(SrsSource* source)
|
||||
int SrsRtmpConn::flash_publish(SrsSource* source)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
|
@ -595,7 +595,7 @@ int SrsClient::flash_publish(SrsSource* source)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int SrsClient::process_publish_message(SrsSource* source, SrsCommonMessage* msg)
|
||||
int SrsRtmpConn::process_publish_message(SrsSource* source, SrsCommonMessage* msg)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
|
@ -639,7 +639,7 @@ int SrsClient::process_publish_message(SrsSource* source, SrsCommonMessage* msg)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int SrsClient::get_peer_ip()
|
||||
int SrsRtmpConn::get_peer_ip()
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
|
@ -674,7 +674,7 @@ int SrsClient::get_peer_ip()
|
|||
return ret;
|
||||
}
|
||||
|
||||
int SrsClient::process_play_control_msg(SrsConsumer* consumer, SrsCommonMessage* msg)
|
||||
int SrsRtmpConn::process_play_control_msg(SrsConsumer* consumer, SrsCommonMessage* msg)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
|
@ -722,7 +722,7 @@ int SrsClient::process_play_control_msg(SrsConsumer* consumer, SrsCommonMessage*
|
|||
return ret;
|
||||
}
|
||||
|
||||
int SrsClient::on_connect()
|
||||
int SrsRtmpConn::on_connect()
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
|
@ -746,7 +746,7 @@ int SrsClient::on_connect()
|
|||
return ret;
|
||||
}
|
||||
|
||||
void SrsClient::on_close()
|
||||
void SrsRtmpConn::on_close()
|
||||
{
|
||||
#ifdef SRS_HTTP_CALLBACK
|
||||
// whatever the ret code, notify the api hooks.
|
||||
|
@ -764,7 +764,7 @@ void SrsClient::on_close()
|
|||
#endif
|
||||
}
|
||||
|
||||
int SrsClient::on_publish()
|
||||
int SrsRtmpConn::on_publish()
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
|
@ -788,7 +788,7 @@ int SrsClient::on_publish()
|
|||
return ret;
|
||||
}
|
||||
|
||||
void SrsClient::on_unpublish()
|
||||
void SrsRtmpConn::on_unpublish()
|
||||
{
|
||||
#ifdef SRS_HTTP_CALLBACK
|
||||
// whatever the ret code, notify the api hooks.
|
||||
|
@ -806,7 +806,7 @@ void SrsClient::on_unpublish()
|
|||
#endif
|
||||
}
|
||||
|
||||
int SrsClient::on_play()
|
||||
int SrsRtmpConn::on_play()
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
|
@ -830,7 +830,7 @@ int SrsClient::on_play()
|
|||
return ret;
|
||||
}
|
||||
|
||||
void SrsClient::on_stop()
|
||||
void SrsRtmpConn::on_stop()
|
||||
{
|
||||
#ifdef SRS_HTTP_CALLBACK
|
||||
// whatever the ret code, notify the api hooks.
|
||||
|
|
|
@ -50,7 +50,7 @@ class SrsBandwidth;
|
|||
/**
|
||||
* the client provides the main logic control for RTMP clients.
|
||||
*/
|
||||
class SrsClient : public SrsConnection, public ISrsReloadHandler
|
||||
class SrsRtmpConn : public SrsConnection, public ISrsReloadHandler
|
||||
{
|
||||
private:
|
||||
char* ip;
|
||||
|
@ -64,8 +64,8 @@ private:
|
|||
#endif
|
||||
SrsBandwidth* bandwidth;
|
||||
public:
|
||||
SrsClient(SrsServer* srs_server, st_netfd_t client_stfd);
|
||||
virtual ~SrsClient();
|
||||
SrsRtmpConn(SrsServer* srs_server, st_netfd_t client_stfd);
|
||||
virtual ~SrsRtmpConn();
|
||||
protected:
|
||||
virtual int do_cycle();
|
||||
// interface ISrsReloadHandler
|
||||
|
|
|
@ -296,7 +296,7 @@ int SrsServer::listen()
|
|||
close_listeners();
|
||||
|
||||
for (int i = 0; i < (int)conf->args.size(); i++) {
|
||||
SrsListener* listener = new SrsListener(this, SrsListenerStream);
|
||||
SrsListener* listener = new SrsListener(this, SrsListenerRtmpStream);
|
||||
listeners.push_back(listener);
|
||||
|
||||
int port = ::atoi(conf->args.at(i).c_str());
|
||||
|
@ -433,8 +433,8 @@ int SrsServer::accept_client(SrsListenerType type, st_netfd_t client_stfd)
|
|||
}
|
||||
|
||||
SrsConnection* conn = NULL;
|
||||
if (type == SrsListenerStream) {
|
||||
conn = new SrsClient(this, client_stfd);
|
||||
if (type == SrsListenerRtmpStream) {
|
||||
conn = new SrsRtmpConn(this, client_stfd);
|
||||
} else if (type == SrsListenerHttpApi) {
|
||||
} else if (type == SrsListenerHttpStream) {
|
||||
} else {
|
||||
|
|
|
@ -39,11 +39,16 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
class SrsServer;
|
||||
class SrsConnection;
|
||||
|
||||
// listener type for server to identify the connection,
|
||||
// that is, use different type to process the connection.
|
||||
enum SrsListenerType
|
||||
{
|
||||
SrsListenerStream = 0,
|
||||
SrsListenerHttpApi,
|
||||
SrsListenerHttpStream
|
||||
// RTMP client,
|
||||
SrsListenerRtmpStream = 0,
|
||||
// HTTP api,
|
||||
SrsListenerHttpApi = 1,
|
||||
// HTTP stream, HDS/HLS/DASH
|
||||
SrsListenerHttpStream = 2
|
||||
};
|
||||
|
||||
class SrsListener : public ISrsThreadHandler
|
||||
|
|
|
@ -178,12 +178,12 @@ SrsResponse::~SrsResponse()
|
|||
{
|
||||
}
|
||||
|
||||
string srs_client_type_string(SrsClientType type)
|
||||
string srs_client_type_string(SrsRtmpConnType type)
|
||||
{
|
||||
switch (type) {
|
||||
case SrsClientPlay: return "Play";
|
||||
case SrsClientFlashPublish: return "FlashPublish";
|
||||
case SrsClientFMLEPublish: return "FMLEPublish";
|
||||
case SrsRtmpConnPlay: return "Play";
|
||||
case SrsRtmpConnFlashPublish: return "FlashPublish";
|
||||
case SrsRtmpConnFMLEPublish: return "FMLEPublish";
|
||||
default: return "Unknown";
|
||||
}
|
||||
return "Unknown";
|
||||
|
@ -947,9 +947,9 @@ int SrsRtmpServer::on_bw_done()
|
|||
return ret;
|
||||
}
|
||||
|
||||
int SrsRtmpServer::identify_client(int stream_id, SrsClientType& type, string& stream_name)
|
||||
int SrsRtmpServer::identify_client(int stream_id, SrsRtmpConnType& type, string& stream_name)
|
||||
{
|
||||
type = SrsClientUnknown;
|
||||
type = SrsRtmpConnUnknown;
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
while (true) {
|
||||
|
@ -1380,7 +1380,7 @@ int SrsRtmpServer::start_flash_publish(int stream_id)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int SrsRtmpServer::identify_create_stream_client(SrsCreateStreamPacket* req, int stream_id, SrsClientType& type, string& stream_name)
|
||||
int SrsRtmpServer::identify_create_stream_client(SrsCreateStreamPacket* req, int stream_id, SrsRtmpConnType& type, string& stream_name)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
|
@ -1433,11 +1433,11 @@ int SrsRtmpServer::identify_create_stream_client(SrsCreateStreamPacket* req, int
|
|||
return ret;
|
||||
}
|
||||
|
||||
int SrsRtmpServer::identify_fmle_publish_client(SrsFMLEStartPacket* req, SrsClientType& type, string& stream_name)
|
||||
int SrsRtmpServer::identify_fmle_publish_client(SrsFMLEStartPacket* req, SrsRtmpConnType& type, string& stream_name)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
type = SrsClientFMLEPublish;
|
||||
type = SrsRtmpConnFMLEPublish;
|
||||
stream_name = req->stream_name;
|
||||
|
||||
// releaseStream response
|
||||
|
@ -1457,21 +1457,21 @@ int SrsRtmpServer::identify_fmle_publish_client(SrsFMLEStartPacket* req, SrsClie
|
|||
return ret;
|
||||
}
|
||||
|
||||
int SrsRtmpServer::identify_flash_publish_client(SrsPublishPacket* req, SrsClientType& type, string& stream_name)
|
||||
int SrsRtmpServer::identify_flash_publish_client(SrsPublishPacket* req, SrsRtmpConnType& type, string& stream_name)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
type = SrsClientFlashPublish;
|
||||
type = SrsRtmpConnFlashPublish;
|
||||
stream_name = req->stream_name;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int SrsRtmpServer::identify_play_client(SrsPlayPacket* req, SrsClientType& type, string& stream_name)
|
||||
int SrsRtmpServer::identify_play_client(SrsPlayPacket* req, SrsRtmpConnType& type, string& stream_name)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
type = SrsClientPlay;
|
||||
type = SrsRtmpConnPlay;
|
||||
stream_name = req->stream_name;
|
||||
|
||||
srs_trace("identity client type=play, stream_name=%s", stream_name.c_str());
|
||||
|
|
|
@ -101,14 +101,14 @@ struct SrsResponse
|
|||
/**
|
||||
* the rtmp client type.
|
||||
*/
|
||||
enum SrsClientType
|
||||
enum SrsRtmpConnType
|
||||
{
|
||||
SrsClientUnknown,
|
||||
SrsClientPlay,
|
||||
SrsClientFMLEPublish,
|
||||
SrsClientFlashPublish,
|
||||
SrsRtmpConnUnknown,
|
||||
SrsRtmpConnPlay,
|
||||
SrsRtmpConnFMLEPublish,
|
||||
SrsRtmpConnFlashPublish,
|
||||
};
|
||||
std::string srs_client_type_string(SrsClientType type);
|
||||
std::string srs_client_type_string(SrsRtmpConnType type);
|
||||
|
||||
/**
|
||||
* store the handshake bytes,
|
||||
|
@ -223,7 +223,7 @@ public:
|
|||
* the stream_id used to response the createStream request.
|
||||
* @type, output the client type.
|
||||
*/
|
||||
virtual int identify_client(int stream_id, SrsClientType& type, std::string& stream_name);
|
||||
virtual int identify_client(int stream_id, SrsRtmpConnType& type, std::string& stream_name);
|
||||
/**
|
||||
* set the chunk size when client type identified.
|
||||
*/
|
||||
|
@ -267,11 +267,11 @@ public:
|
|||
*/
|
||||
virtual int start_flash_publish(int stream_id);
|
||||
private:
|
||||
virtual int identify_create_stream_client(SrsCreateStreamPacket* req, int stream_id, SrsClientType& type, std::string& stream_name);
|
||||
virtual int identify_fmle_publish_client(SrsFMLEStartPacket* req, SrsClientType& type, std::string& stream_name);
|
||||
virtual int identify_flash_publish_client(SrsPublishPacket* req, SrsClientType& type, std::string& stream_name);
|
||||
virtual int identify_create_stream_client(SrsCreateStreamPacket* req, int stream_id, SrsRtmpConnType& type, std::string& stream_name);
|
||||
virtual int identify_fmle_publish_client(SrsFMLEStartPacket* req, SrsRtmpConnType& type, std::string& stream_name);
|
||||
virtual int identify_flash_publish_client(SrsPublishPacket* req, SrsRtmpConnType& type, std::string& stream_name);
|
||||
private:
|
||||
virtual int identify_play_client(SrsPlayPacket* req, SrsClientType& type, std::string& stream_name);
|
||||
virtual int identify_play_client(SrsPlayPacket* req, SrsRtmpConnType& type, std::string& stream_name);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue