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

rename srs-client to srs-rtmp-conn

This commit is contained in:
winlin 2014-03-27 12:27:47 +08:00
parent aa89f9f51e
commit ab3c6c92a0
6 changed files with 62 additions and 57 deletions

View file

@ -43,7 +43,7 @@ using namespace std;
#include <srs_app_bandwidth.hpp> #include <srs_app_bandwidth.hpp>
#include <srs_app_socket.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) : SrsConnection(srs_server, client_stfd)
{ {
ip = NULL; ip = NULL;
@ -60,7 +60,7 @@ SrsClient::SrsClient(SrsServer* srs_server, st_netfd_t client_stfd)
_srs_config->subscribe(this); _srs_config->subscribe(this);
} }
SrsClient::~SrsClient() SrsRtmpConn::~SrsRtmpConn()
{ {
_srs_config->unsubscribe(this); _srs_config->unsubscribe(this);
@ -77,7 +77,7 @@ SrsClient::~SrsClient()
} }
// TODO: return detail message when error for client. // TODO: return detail message when error for client.
int SrsClient::do_cycle() int SrsRtmpConn::do_cycle()
{ {
int ret = ERROR_SUCCESS; int ret = ERROR_SUCCESS;
@ -139,7 +139,7 @@ int SrsClient::do_cycle()
return ret; return ret;
} }
int SrsClient::on_reload_vhost_removed(string vhost) int SrsRtmpConn::on_reload_vhost_removed(string vhost)
{ {
int ret = ERROR_SUCCESS; int ret = ERROR_SUCCESS;
@ -156,7 +156,7 @@ int SrsClient::on_reload_vhost_removed(string vhost)
return ret; return ret;
} }
int SrsClient::service_cycle() int SrsRtmpConn::service_cycle()
{ {
int ret = ERROR_SUCCESS; int ret = ERROR_SUCCESS;
@ -232,11 +232,11 @@ int SrsClient::service_cycle()
return ret; return ret;
} }
int SrsClient::stream_service_cycle() int SrsRtmpConn::stream_service_cycle()
{ {
int ret = ERROR_SUCCESS; int ret = ERROR_SUCCESS;
SrsClientType type; SrsRtmpConnType type;
if ((ret = rtmp->identify_client(res->stream_id, type, req->stream)) != ERROR_SUCCESS) { if ((ret = rtmp->identify_client(res->stream_id, type, req->stream)) != ERROR_SUCCESS) {
srs_error("identify client failed. ret=%d", ret); srs_error("identify client failed. ret=%d", ret);
return ret; return ret;
@ -262,7 +262,7 @@ int SrsClient::stream_service_cycle()
srs_assert(source != NULL); srs_assert(source != NULL);
// check publish available. // check publish available.
if (type != SrsClientPlay && !source->can_publish()) { if (type != SrsRtmpConnPlay && !source->can_publish()) {
ret = ERROR_SYSTEM_STREAM_BUSY; ret = ERROR_SYSTEM_STREAM_BUSY;
srs_warn("stream %s is already publishing. ret=%d", srs_warn("stream %s is already publishing. ret=%d",
req->get_stream_url().c_str(), ret); req->get_stream_url().c_str(), ret);
@ -276,7 +276,7 @@ int SrsClient::stream_service_cycle()
source->set_cache(enabled_cache); source->set_cache(enabled_cache);
switch (type) { switch (type) {
case SrsClientPlay: { case SrsRtmpConnPlay: {
srs_verbose("start to play stream %s.", req->stream.c_str()); srs_verbose("start to play stream %s.", req->stream.c_str());
if ((ret = rtmp->start_play(res->stream_id)) != ERROR_SUCCESS) { if ((ret = rtmp->start_play(res->stream_id)) != ERROR_SUCCESS) {
@ -292,7 +292,7 @@ int SrsClient::stream_service_cycle()
on_stop(); on_stop();
return ret; return ret;
} }
case SrsClientFMLEPublish: { case SrsRtmpConnFMLEPublish: {
srs_verbose("FMLE start to publish stream %s.", req->stream.c_str()); srs_verbose("FMLE start to publish stream %s.", req->stream.c_str());
if ((ret = rtmp->start_fmle_publish(res->stream_id)) != ERROR_SUCCESS) { if ((ret = rtmp->start_fmle_publish(res->stream_id)) != ERROR_SUCCESS) {
@ -309,7 +309,7 @@ int SrsClient::stream_service_cycle()
on_unpublish(); on_unpublish();
return ret; return ret;
} }
case SrsClientFlashPublish: { case SrsRtmpConnFlashPublish: {
srs_verbose("flash start to publish stream %s.", req->stream.c_str()); srs_verbose("flash start to publish stream %s.", req->stream.c_str());
if ((ret = rtmp->start_flash_publish(res->stream_id)) != ERROR_SUCCESS) { if ((ret = rtmp->start_flash_publish(res->stream_id)) != ERROR_SUCCESS) {
@ -336,7 +336,7 @@ int SrsClient::stream_service_cycle()
return ret; return ret;
} }
int SrsClient::check_vhost() int SrsRtmpConn::check_vhost()
{ {
int ret = ERROR_SUCCESS; int ret = ERROR_SUCCESS;
@ -373,7 +373,7 @@ int SrsClient::check_vhost()
return ret; return ret;
} }
int SrsClient::playing(SrsSource* source) int SrsRtmpConn::playing(SrsSource* source)
{ {
int ret = ERROR_SUCCESS; int ret = ERROR_SUCCESS;
@ -462,7 +462,7 @@ int SrsClient::playing(SrsSource* source)
return ret; return ret;
} }
int SrsClient::fmle_publish(SrsSource* source) int SrsRtmpConn::fmle_publish(SrsSource* source)
{ {
int ret = ERROR_SUCCESS; int ret = ERROR_SUCCESS;
@ -531,7 +531,7 @@ int SrsClient::fmle_publish(SrsSource* source)
return ret; return ret;
} }
int SrsClient::flash_publish(SrsSource* source) int SrsRtmpConn::flash_publish(SrsSource* source)
{ {
int ret = ERROR_SUCCESS; int ret = ERROR_SUCCESS;
@ -595,7 +595,7 @@ int SrsClient::flash_publish(SrsSource* source)
return ret; return ret;
} }
int SrsClient::process_publish_message(SrsSource* source, SrsCommonMessage* msg) int SrsRtmpConn::process_publish_message(SrsSource* source, SrsCommonMessage* msg)
{ {
int ret = ERROR_SUCCESS; int ret = ERROR_SUCCESS;
@ -639,7 +639,7 @@ int SrsClient::process_publish_message(SrsSource* source, SrsCommonMessage* msg)
return ret; return ret;
} }
int SrsClient::get_peer_ip() int SrsRtmpConn::get_peer_ip()
{ {
int ret = ERROR_SUCCESS; int ret = ERROR_SUCCESS;
@ -674,7 +674,7 @@ int SrsClient::get_peer_ip()
return ret; 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; int ret = ERROR_SUCCESS;
@ -722,7 +722,7 @@ int SrsClient::process_play_control_msg(SrsConsumer* consumer, SrsCommonMessage*
return ret; return ret;
} }
int SrsClient::on_connect() int SrsRtmpConn::on_connect()
{ {
int ret = ERROR_SUCCESS; int ret = ERROR_SUCCESS;
@ -746,7 +746,7 @@ int SrsClient::on_connect()
return ret; return ret;
} }
void SrsClient::on_close() void SrsRtmpConn::on_close()
{ {
#ifdef SRS_HTTP_CALLBACK #ifdef SRS_HTTP_CALLBACK
// whatever the ret code, notify the api hooks. // whatever the ret code, notify the api hooks.
@ -764,7 +764,7 @@ void SrsClient::on_close()
#endif #endif
} }
int SrsClient::on_publish() int SrsRtmpConn::on_publish()
{ {
int ret = ERROR_SUCCESS; int ret = ERROR_SUCCESS;
@ -788,7 +788,7 @@ int SrsClient::on_publish()
return ret; return ret;
} }
void SrsClient::on_unpublish() void SrsRtmpConn::on_unpublish()
{ {
#ifdef SRS_HTTP_CALLBACK #ifdef SRS_HTTP_CALLBACK
// whatever the ret code, notify the api hooks. // whatever the ret code, notify the api hooks.
@ -806,7 +806,7 @@ void SrsClient::on_unpublish()
#endif #endif
} }
int SrsClient::on_play() int SrsRtmpConn::on_play()
{ {
int ret = ERROR_SUCCESS; int ret = ERROR_SUCCESS;
@ -830,7 +830,7 @@ int SrsClient::on_play()
return ret; return ret;
} }
void SrsClient::on_stop() void SrsRtmpConn::on_stop()
{ {
#ifdef SRS_HTTP_CALLBACK #ifdef SRS_HTTP_CALLBACK
// whatever the ret code, notify the api hooks. // whatever the ret code, notify the api hooks.

View file

@ -50,7 +50,7 @@ class SrsBandwidth;
/** /**
* the client provides the main logic control for RTMP clients. * the client provides the main logic control for RTMP clients.
*/ */
class SrsClient : public SrsConnection, public ISrsReloadHandler class SrsRtmpConn : public SrsConnection, public ISrsReloadHandler
{ {
private: private:
char* ip; char* ip;
@ -64,8 +64,8 @@ private:
#endif #endif
SrsBandwidth* bandwidth; SrsBandwidth* bandwidth;
public: public:
SrsClient(SrsServer* srs_server, st_netfd_t client_stfd); SrsRtmpConn(SrsServer* srs_server, st_netfd_t client_stfd);
virtual ~SrsClient(); virtual ~SrsRtmpConn();
protected: protected:
virtual int do_cycle(); virtual int do_cycle();
// interface ISrsReloadHandler // interface ISrsReloadHandler

View file

@ -296,7 +296,7 @@ int SrsServer::listen()
close_listeners(); close_listeners();
for (int i = 0; i < (int)conf->args.size(); i++) { 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); listeners.push_back(listener);
int port = ::atoi(conf->args.at(i).c_str()); 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; SrsConnection* conn = NULL;
if (type == SrsListenerStream) { if (type == SrsListenerRtmpStream) {
conn = new SrsClient(this, client_stfd); conn = new SrsRtmpConn(this, client_stfd);
} else if (type == SrsListenerHttpApi) { } else if (type == SrsListenerHttpApi) {
} else if (type == SrsListenerHttpStream) { } else if (type == SrsListenerHttpStream) {
} else { } else {

View file

@ -39,11 +39,16 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
class SrsServer; class SrsServer;
class SrsConnection; class SrsConnection;
// listener type for server to identify the connection,
// that is, use different type to process the connection.
enum SrsListenerType enum SrsListenerType
{ {
SrsListenerStream = 0, // RTMP client,
SrsListenerHttpApi, SrsListenerRtmpStream = 0,
SrsListenerHttpStream // HTTP api,
SrsListenerHttpApi = 1,
// HTTP stream, HDS/HLS/DASH
SrsListenerHttpStream = 2
}; };
class SrsListener : public ISrsThreadHandler class SrsListener : public ISrsThreadHandler

View file

@ -178,12 +178,12 @@ SrsResponse::~SrsResponse()
{ {
} }
string srs_client_type_string(SrsClientType type) string srs_client_type_string(SrsRtmpConnType type)
{ {
switch (type) { switch (type) {
case SrsClientPlay: return "Play"; case SrsRtmpConnPlay: return "Play";
case SrsClientFlashPublish: return "FlashPublish"; case SrsRtmpConnFlashPublish: return "FlashPublish";
case SrsClientFMLEPublish: return "FMLEPublish"; case SrsRtmpConnFMLEPublish: return "FMLEPublish";
default: return "Unknown"; default: return "Unknown";
} }
return "Unknown"; return "Unknown";
@ -947,9 +947,9 @@ int SrsRtmpServer::on_bw_done()
return ret; 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; int ret = ERROR_SUCCESS;
while (true) { while (true) {
@ -1380,7 +1380,7 @@ int SrsRtmpServer::start_flash_publish(int stream_id)
return ret; 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; int ret = ERROR_SUCCESS;
@ -1433,11 +1433,11 @@ int SrsRtmpServer::identify_create_stream_client(SrsCreateStreamPacket* req, int
return ret; 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; int ret = ERROR_SUCCESS;
type = SrsClientFMLEPublish; type = SrsRtmpConnFMLEPublish;
stream_name = req->stream_name; stream_name = req->stream_name;
// releaseStream response // releaseStream response
@ -1457,21 +1457,21 @@ int SrsRtmpServer::identify_fmle_publish_client(SrsFMLEStartPacket* req, SrsClie
return ret; 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; int ret = ERROR_SUCCESS;
type = SrsClientFlashPublish; type = SrsRtmpConnFlashPublish;
stream_name = req->stream_name; stream_name = req->stream_name;
return ret; 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; int ret = ERROR_SUCCESS;
type = SrsClientPlay; type = SrsRtmpConnPlay;
stream_name = req->stream_name; stream_name = req->stream_name;
srs_trace("identity client type=play, stream_name=%s", stream_name.c_str()); srs_trace("identity client type=play, stream_name=%s", stream_name.c_str());

View file

@ -101,14 +101,14 @@ struct SrsResponse
/** /**
* the rtmp client type. * the rtmp client type.
*/ */
enum SrsClientType enum SrsRtmpConnType
{ {
SrsClientUnknown, SrsRtmpConnUnknown,
SrsClientPlay, SrsRtmpConnPlay,
SrsClientFMLEPublish, SrsRtmpConnFMLEPublish,
SrsClientFlashPublish, SrsRtmpConnFlashPublish,
}; };
std::string srs_client_type_string(SrsClientType type); std::string srs_client_type_string(SrsRtmpConnType type);
/** /**
* store the handshake bytes, * store the handshake bytes,
@ -223,7 +223,7 @@ public:
* the stream_id used to response the createStream request. * the stream_id used to response the createStream request.
* @type, output the client type. * @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. * set the chunk size when client type identified.
*/ */
@ -267,11 +267,11 @@ public:
*/ */
virtual int start_flash_publish(int stream_id); virtual int start_flash_publish(int stream_id);
private: private:
virtual int identify_create_stream_client(SrsCreateStreamPacket* req, int stream_id, 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, SrsClientType& 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, SrsClientType& type, std::string& stream_name); virtual int identify_flash_publish_client(SrsPublishPacket* req, SrsRtmpConnType& type, std::string& stream_name);
private: 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 #endif