1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-12 11:21:52 +00:00

extract the rtmp connection

This commit is contained in:
winlin 2013-10-18 16:57:21 +08:00
parent d8a64603c0
commit 973bea1e14
8 changed files with 94 additions and 12 deletions

2
trunk/configure vendored
View file

@ -82,7 +82,7 @@ LibSTfile="${LibSTRoot}/libst.a"
MODULE_ID="CORE"
MODULE_DEPENDS=()
ModuleLibIncs=(${LibSTRoot})
MODULE_FILES=("srs_core" "srs_core_log" "srs_core_server" "srs_core_error" "srs_core_conn")
MODULE_FILES=("srs_core" "srs_core_log" "srs_core_server" "srs_core_error" "srs_core_conn" "srs_core_conn_rtmp")
MODULE_DIR="src/core" . auto/modules.sh
CORE_OBJS="${MODULE_OBJS[@]}"

View file

@ -51,12 +51,6 @@ int SrsConnection::start()
return ret;
}
int SrsConnection::do_cycle()
{
int ret = ERROR_SUCCESS;
return ret;
}
void SrsConnection::cycle()
{
int ret = ERROR_SUCCESS;

View file

@ -43,8 +43,9 @@ public:
virtual ~SrsConnection();
public:
virtual int start();
protected:
virtual int do_cycle() = 0;
private:
virtual int do_cycle();
virtual void cycle();
static void* cycle_thread(void* arg);
};

View file

@ -0,0 +1,42 @@
/*
The MIT License (MIT)
Copyright (c) 2013 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_core_conn_rtmp.hpp>
#include <srs_core_error.hpp>
SrsRtmpConnection::SrsRtmpConnection(SrsServer* srs_server, st_netfd_t client_stfd)
: SrsConnection(srs_server, client_stfd)
{
}
SrsRtmpConnection::~SrsRtmpConnection()
{
}
int SrsRtmpConnection::do_cycle()
{
int ret = ERROR_SUCCESS;
return ret;
}

View file

@ -0,0 +1,42 @@
/*
The MIT License (MIT)
Copyright (c) 2013 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_CORE_CONN_RTMP_HPP
#define SRS_CORE_CONN_RTMP_HPP
/*
#include <srs_core_conn_rtmp.hpp>
*/
#include <srs_core_conn.hpp>
class SrsRtmpConnection : public SrsConnection
{
public:
SrsRtmpConnection(SrsServer* srs_server, st_netfd_t client_stfd);
virtual ~SrsRtmpConnection();
protected:
virtual int do_cycle();
};
#endif

View file

@ -33,7 +33,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_core_log.hpp>
#include <srs_core_error.hpp>
#include <srs_core_conn.hpp>
#include <srs_core_conn_rtmp.hpp>
#define SERVER_LISTEN_BACKLOG 10
@ -135,6 +135,7 @@ int SrsServer::start(int port)
int SrsServer::cycle()
{
int ret = ERROR_SUCCESS;
// TODO: canbe a api thread.
st_thread_exit(NULL);
return ret;
}
@ -156,7 +157,7 @@ int SrsServer::accept_client(st_netfd_t client_stfd)
{
int ret = ERROR_SUCCESS;
SrsConnection* conn = new SrsConnection(this, client_stfd);
SrsConnection* conn = new SrsRtmpConnection(this, client_stfd);
// directly enqueue, the cycle thread will remove the client.
conns.push_back(conn);

View file

@ -21,12 +21,12 @@ 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 <unistd.h>
#include <srs_core_log.hpp>
#include <srs_core_error.hpp>
#include <srs_core_server.hpp>
#include <unistd.h>
int main(int /*argc*/, char** /*argv*/){
int ret = ERROR_SUCCESS;

View file

@ -10,6 +10,8 @@ file
..\core\srs_core_server.cpp,
..\core\srs_core_conn.hpp,
..\core\srs_core_conn.cpp,
..\core\srs_core_conn_rtmp.hpp,
..\core\srs_core_conn_rtmp.cpp,
..\core\srs_core_log.hpp,
..\core\srs_core_log.cpp;
mainconfig