winlin

extract the rtmp connection

@@ -82,7 +82,7 @@ LibSTfile="${LibSTRoot}/libst.a" @@ -82,7 +82,7 @@ LibSTfile="${LibSTRoot}/libst.a"
82 MODULE_ID="CORE" 82 MODULE_ID="CORE"
83 MODULE_DEPENDS=() 83 MODULE_DEPENDS=()
84 ModuleLibIncs=(${LibSTRoot}) 84 ModuleLibIncs=(${LibSTRoot})
85 -MODULE_FILES=("srs_core" "srs_core_log" "srs_core_server" "srs_core_error" "srs_core_conn") 85 +MODULE_FILES=("srs_core" "srs_core_log" "srs_core_server" "srs_core_error" "srs_core_conn" "srs_core_conn_rtmp")
86 MODULE_DIR="src/core" . auto/modules.sh 86 MODULE_DIR="src/core" . auto/modules.sh
87 CORE_OBJS="${MODULE_OBJS[@]}" 87 CORE_OBJS="${MODULE_OBJS[@]}"
88 88
@@ -51,12 +51,6 @@ int SrsConnection::start() @@ -51,12 +51,6 @@ int SrsConnection::start()
51 return ret; 51 return ret;
52 } 52 }
53 53
54 -int SrsConnection::do_cycle()  
55 -{  
56 - int ret = ERROR_SUCCESS;  
57 - return ret;  
58 -}  
59 -  
60 void SrsConnection::cycle() 54 void SrsConnection::cycle()
61 { 55 {
62 int ret = ERROR_SUCCESS; 56 int ret = ERROR_SUCCESS;
@@ -43,8 +43,9 @@ public: @@ -43,8 +43,9 @@ public:
43 virtual ~SrsConnection(); 43 virtual ~SrsConnection();
44 public: 44 public:
45 virtual int start(); 45 virtual int start();
  46 +protected:
  47 + virtual int do_cycle() = 0;
46 private: 48 private:
47 - virtual int do_cycle();  
48 virtual void cycle(); 49 virtual void cycle();
49 static void* cycle_thread(void* arg); 50 static void* cycle_thread(void* arg);
50 }; 51 };
  1 +/*
  2 +The MIT License (MIT)
  3 +
  4 +Copyright (c) 2013 winlin
  5 +
  6 +Permission is hereby granted, free of charge, to any person obtaining a copy of
  7 +this software and associated documentation files (the "Software"), to deal in
  8 +the Software without restriction, including without limitation the rights to
  9 +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  10 +the Software, and to permit persons to whom the Software is furnished to do so,
  11 +subject to the following conditions:
  12 +
  13 +The above copyright notice and this permission notice shall be included in all
  14 +copies or substantial portions of the Software.
  15 +
  16 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  18 +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  19 +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  20 +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21 +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22 +*/
  23 +
  24 +#include <srs_core_conn_rtmp.hpp>
  25 +
  26 +#include <srs_core_error.hpp>
  27 +
  28 +SrsRtmpConnection::SrsRtmpConnection(SrsServer* srs_server, st_netfd_t client_stfd)
  29 + : SrsConnection(srs_server, client_stfd)
  30 +{
  31 +}
  32 +
  33 +SrsRtmpConnection::~SrsRtmpConnection()
  34 +{
  35 +}
  36 +
  37 +int SrsRtmpConnection::do_cycle()
  38 +{
  39 + int ret = ERROR_SUCCESS;
  40 + return ret;
  41 +}
  42 +
  1 +/*
  2 +The MIT License (MIT)
  3 +
  4 +Copyright (c) 2013 winlin
  5 +
  6 +Permission is hereby granted, free of charge, to any person obtaining a copy of
  7 +this software and associated documentation files (the "Software"), to deal in
  8 +the Software without restriction, including without limitation the rights to
  9 +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  10 +the Software, and to permit persons to whom the Software is furnished to do so,
  11 +subject to the following conditions:
  12 +
  13 +The above copyright notice and this permission notice shall be included in all
  14 +copies or substantial portions of the Software.
  15 +
  16 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  18 +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  19 +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  20 +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21 +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22 +*/
  23 +
  24 +#ifndef SRS_CORE_CONN_RTMP_HPP
  25 +#define SRS_CORE_CONN_RTMP_HPP
  26 +
  27 +/*
  28 +#include <srs_core_conn_rtmp.hpp>
  29 +*/
  30 +
  31 +#include <srs_core_conn.hpp>
  32 +
  33 +class SrsRtmpConnection : public SrsConnection
  34 +{
  35 +public:
  36 + SrsRtmpConnection(SrsServer* srs_server, st_netfd_t client_stfd);
  37 + virtual ~SrsRtmpConnection();
  38 +protected:
  39 + virtual int do_cycle();
  40 +};
  41 +
  42 +#endif
@@ -33,7 +33,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -33,7 +33,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 33
34 #include <srs_core_log.hpp> 34 #include <srs_core_log.hpp>
35 #include <srs_core_error.hpp> 35 #include <srs_core_error.hpp>
36 -#include <srs_core_conn.hpp> 36 +#include <srs_core_conn_rtmp.hpp>
37 37
38 #define SERVER_LISTEN_BACKLOG 10 38 #define SERVER_LISTEN_BACKLOG 10
39 39
@@ -135,6 +135,7 @@ int SrsServer::start(int port) @@ -135,6 +135,7 @@ int SrsServer::start(int port)
135 int SrsServer::cycle() 135 int SrsServer::cycle()
136 { 136 {
137 int ret = ERROR_SUCCESS; 137 int ret = ERROR_SUCCESS;
  138 + // TODO: canbe a api thread.
138 st_thread_exit(NULL); 139 st_thread_exit(NULL);
139 return ret; 140 return ret;
140 } 141 }
@@ -156,7 +157,7 @@ int SrsServer::accept_client(st_netfd_t client_stfd) @@ -156,7 +157,7 @@ int SrsServer::accept_client(st_netfd_t client_stfd)
156 { 157 {
157 int ret = ERROR_SUCCESS; 158 int ret = ERROR_SUCCESS;
158 159
159 - SrsConnection* conn = new SrsConnection(this, client_stfd); 160 + SrsConnection* conn = new SrsRtmpConnection(this, client_stfd);
160 161
161 // directly enqueue, the cycle thread will remove the client. 162 // directly enqueue, the cycle thread will remove the client.
162 conns.push_back(conn); 163 conns.push_back(conn);
@@ -21,12 +21,12 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN @@ -21,12 +21,12 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */ 22 */
23 23
24 -#include <unistd.h>  
25 -  
26 #include <srs_core_log.hpp> 24 #include <srs_core_log.hpp>
27 #include <srs_core_error.hpp> 25 #include <srs_core_error.hpp>
28 #include <srs_core_server.hpp> 26 #include <srs_core_server.hpp>
29 27
  28 +#include <unistd.h>
  29 +
30 int main(int /*argc*/, char** /*argv*/){ 30 int main(int /*argc*/, char** /*argv*/){
31 int ret = ERROR_SUCCESS; 31 int ret = ERROR_SUCCESS;
32 32
@@ -10,6 +10,8 @@ file @@ -10,6 +10,8 @@ file
10 ..\core\srs_core_server.cpp, 10 ..\core\srs_core_server.cpp,
11 ..\core\srs_core_conn.hpp, 11 ..\core\srs_core_conn.hpp,
12 ..\core\srs_core_conn.cpp, 12 ..\core\srs_core_conn.cpp,
  13 + ..\core\srs_core_conn_rtmp.hpp,
  14 + ..\core\srs_core_conn_rtmp.cpp,
13 ..\core\srs_core_log.hpp, 15 ..\core\srs_core_log.hpp,
14 ..\core\srs_core_log.cpp; 16 ..\core\srs_core_log.cpp;
15 mainconfig 17 mainconfig