Changeset 142
- Timestamp:
- 10/26/10 12:50:10 (19 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 60 edited
-
builders/cmake/vg.sh (added)
-
sources/thelib/include/netio/epoll/inboundnamedpipecarrier.h (modified) (2 diffs)
-
sources/thelib/include/netio/epoll/iohandler.h (modified) (3 diffs)
-
sources/thelib/include/netio/epoll/iotimer.h (modified) (1 diff)
-
sources/thelib/include/netio/epoll/stdiocarrier.h (modified) (1 diff)
-
sources/thelib/include/netio/epoll/tcpacceptor.h (modified) (1 diff)
-
sources/thelib/include/netio/epoll/tcpcarrier.h (modified) (2 diffs)
-
sources/thelib/include/netio/epoll/tcpconnector.h (modified) (2 diffs)
-
sources/thelib/include/netio/epoll/udpcarrier.h (modified) (1 diff)
-
sources/thelib/include/netio/kqueue/inboundnamedpipecarrier.h (modified) (2 diffs)
-
sources/thelib/include/netio/kqueue/iohandler.h (modified) (2 diffs)
-
sources/thelib/include/netio/kqueue/iotimer.h (modified) (1 diff)
-
sources/thelib/include/netio/kqueue/stdiocarrier.h (modified) (2 diffs)
-
sources/thelib/include/netio/kqueue/tcpacceptor.h (modified) (1 diff)
-
sources/thelib/include/netio/kqueue/tcpcarrier.h (modified) (2 diffs)
-
sources/thelib/include/netio/kqueue/tcpconnector.h (modified) (1 diff)
-
sources/thelib/include/netio/kqueue/udpcarrier.h (modified) (3 diffs)
-
sources/thelib/include/netio/netio.h (modified) (1 diff)
-
sources/thelib/include/netio/select/inboundnamedpipecarrier.h (modified) (2 diffs)
-
sources/thelib/include/netio/select/iohandler.h (modified) (3 diffs)
-
sources/thelib/include/netio/select/iotimer.h (modified) (2 diffs)
-
sources/thelib/include/netio/select/stdiocarrier.h (modified) (1 diff)
-
sources/thelib/include/netio/select/tcpcarrier.h (modified) (3 diffs)
-
sources/thelib/include/netio/select/tcpconnector.h (modified) (1 diff)
-
sources/thelib/include/netio/select/udpcarrier.h (modified) (2 diffs)
-
sources/thelib/include/protocols/baseprotocol.h (modified) (3 diffs)
-
sources/thelib/include/protocols/rtmp/basertmpprotocol.h (modified) (1 diff)
-
sources/thelib/include/protocols/ts/inboundtsprotocol.h (modified) (1 diff)
-
sources/thelib/src/application/baseclientapplication.cpp (modified) (1 diff)
-
sources/thelib/src/netio/epoll/inboundnamedpipecarrier.cpp (modified) (2 diffs)
-
sources/thelib/src/netio/epoll/iohandler.cpp (modified) (3 diffs)
-
sources/thelib/src/netio/epoll/iotimer.cpp (modified) (2 diffs)
-
sources/thelib/src/netio/epoll/stdiocarrier.cpp (modified) (3 diffs)
-
sources/thelib/src/netio/epoll/tcpacceptor.cpp (modified) (1 diff)
-
sources/thelib/src/netio/epoll/tcpcarrier.cpp (modified) (2 diffs)
-
sources/thelib/src/netio/epoll/udpcarrier.cpp (modified) (3 diffs)
-
sources/thelib/src/netio/kqueue/inboundnamedpipecarrier.cpp (modified) (3 diffs)
-
sources/thelib/src/netio/kqueue/iohandler.cpp (modified) (1 diff)
-
sources/thelib/src/netio/kqueue/iotimer.cpp (modified) (2 diffs)
-
sources/thelib/src/netio/kqueue/stdiocarrier.cpp (modified) (3 diffs)
-
sources/thelib/src/netio/kqueue/tcpacceptor.cpp (modified) (1 diff)
-
sources/thelib/src/netio/kqueue/tcpcarrier.cpp (modified) (2 diffs)
-
sources/thelib/src/netio/kqueue/udpcarrier.cpp (modified) (3 diffs)
-
sources/thelib/src/netio/select/inboundnamedpipecarrier.cpp (modified) (2 diffs)
-
sources/thelib/src/netio/select/iohandler.cpp (modified) (3 diffs)
-
sources/thelib/src/netio/select/iohandlermanager.cpp (modified) (1 diff)
-
sources/thelib/src/netio/select/iotimer.cpp (modified) (2 diffs)
-
sources/thelib/src/netio/select/stdiocarrier.cpp (modified) (3 diffs)
-
sources/thelib/src/netio/select/tcpacceptor.cpp (modified) (1 diff)
-
sources/thelib/src/netio/select/tcpcarrier.cpp (modified) (2 diffs)
-
sources/thelib/src/netio/select/udpcarrier.cpp (modified) (3 diffs)
-
sources/thelib/src/protocols/baseprotocol.cpp (modified) (3 diffs)
-
sources/thelib/src/protocols/protocolmanager.cpp (modified) (2 diffs)
-
sources/thelib/src/protocols/rtmp/basertmpappprotocolhandler.cpp (modified) (1 diff)
-
sources/thelib/src/protocols/rtmp/basertmpprotocol.cpp (modified) (4 diffs)
-
sources/thelib/src/protocols/rtp/rtspprotocol.cpp (modified) (1 diff)
-
sources/thelib/src/protocols/tcpprotocol.cpp (modified) (2 diffs)
-
sources/thelib/src/protocols/timer/basetimerprotocol.cpp (modified) (2 diffs)
-
sources/thelib/src/protocols/ts/inboundtsprotocol.cpp (modified) (1 diff)
-
sources/thelib/src/protocols/udpprotocol.cpp (modified) (1 diff)
-
sources/thelib/src/protocols/variant/basevariantprotocol.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/thelib/include/netio/epoll/inboundnamedpipecarrier.h
r56 r142 24 24 #include "netio/epoll/iohandler.h" 25 25 26 class BaseProtocol;27 28 26 class InboundNamedPipeCarrier 29 27 : public IOHandler { 30 28 private: 31 BaseProtocol *_pProtocol;32 29 string _path; 33 30 public: … … 36 33 37 34 static InboundNamedPipeCarrier *Create(string path, uint16_t mode); 38 39 void SetProtocol(BaseProtocol *pPotocol);40 35 41 36 virtual bool SignalOutputData(); -
trunk/sources/thelib/include/netio/epoll/iohandler.h
r58 r142 35 35 } IOHandlerType; 36 36 37 class BaseProtocol; 38 37 39 class IOHandler { 38 40 protected: … … 41 43 int32_t _inboundFd; 42 44 int32_t _outboundFd; 45 BaseProtocol *_pProtocol; 43 46 private: 44 47 IOHandlerType _type; … … 53 56 int32_t GetOutboundFd(); 54 57 IOHandlerType GetType(); 58 void SetProtocol(BaseProtocol *pPotocol); 55 59 virtual bool SignalOutputData() = 0; 56 60 virtual bool OnEvent(struct epoll_event &event) = 0; -
trunk/sources/thelib/include/netio/epoll/iotimer.h
r56 r142 24 24 #include "netio/epoll/iohandler.h" 25 25 26 class BaseProtocol;27 28 26 class IOTimer 29 27 : public IOHandler { 30 28 private: 31 29 static int32_t _idGenerator; 32 BaseProtocol *_pProtocol;33 30 public: 34 IOTimer( BaseProtocol *pProtocol);31 IOTimer(); 35 32 virtual ~IOTimer(); 36 33 37 void ResetProtocol();38 34 virtual bool SignalOutputData(); 39 35 virtual bool OnEvent(struct epoll_event &eventWrapper); -
trunk/sources/thelib/include/netio/epoll/stdiocarrier.h
r56 r142 25 25 #include "netio/epoll/iohandler.h" 26 26 27 class BaseProtocol;28 29 27 class StdioCarrier 30 28 : public IOHandler { 31 29 private: 32 30 static StdioCarrier *_pInstance; 33 BaseProtocol *_pProtocol;34 31 bool _writeDataEnabled; 35 32 private: 36 StdioCarrier( BaseProtocol *pProtocol);33 StdioCarrier(); 37 34 public: 38 35 static StdioCarrier *GetInstance(BaseProtocol *pProtocol); 39 36 virtual ~StdioCarrier(); 40 void ResetProtocol();41 37 virtual bool OnEvent(struct epoll_event &event); 42 38 virtual bool SignalOutputData(); -
trunk/sources/thelib/include/netio/epoll/tcpacceptor.h
r56 r142 21 21 #ifndef _TCPACCEPTOR_H 22 22 #define _TCPACCEPTOR_H 23 23 24 24 25 25 #include "netio/epoll/iohandler.h" -
trunk/sources/thelib/include/netio/epoll/tcpcarrier.h
r56 r142 22 22 #define _TCPCARRIER_H 23 23 24 25 24 #include "netio/epoll/iohandler.h" 26 27 class BaseProtocol;28 25 29 26 class TCPCarrier 30 27 : public IOHandler { 31 28 private: 32 BaseProtocol *_pProtocol;33 29 bool _writeDataEnabled; 34 30 sockaddr_in _farAddress; … … 41 37 int32_t _recvBufferSize; 42 38 public: 43 TCPCarrier(int32_t fd , BaseProtocol *pProtocol);39 TCPCarrier(int32_t fd); 44 40 virtual ~TCPCarrier(); 45 void ResetProtocol();46 41 virtual bool OnEvent(struct epoll_event &event); 47 42 virtual bool SignalOutputData(); -
trunk/sources/thelib/include/netio/epoll/tcpconnector.h
r131 r142 67 67 if ((event.events & EPOLLERR) != 0) { 68 68 DEBUG("***CONNECT ERROR: Unable to connect to: %s:%d", 69 STR(_ip),70 _port);69 STR(_ip), 70 _port); 71 71 _closeSocket = true; 72 72 return false; … … 82 82 } 83 83 84 TCPCarrier *pTCPCarrier = new TCPCarrier(_inboundFd, pProtocol->GetFarEndpoint()); 84 TCPCarrier *pTCPCarrier = new TCPCarrier(_inboundFd); 85 pTCPCarrier->SetProtocol(pProtocol->GetFarEndpoint()); 85 86 pProtocol->GetFarEndpoint()->SetIOHandler(pTCPCarrier); 86 87 -
trunk/sources/thelib/include/netio/epoll/udpcarrier.h
r56 r142 36 36 uint16_t _nearPort; 37 37 public: 38 UDPCarrier(int32_t fd , BaseProtocol *pProtocol);38 UDPCarrier(int32_t fd); 39 39 virtual ~UDPCarrier(); 40 40 41 void ResetProtocol();42 void SetProtocol(BaseProtocol *pProtocol);43 41 virtual bool OnEvent(struct epoll_event &event); 44 42 virtual bool SignalOutputData(); -
trunk/sources/thelib/include/netio/kqueue/inboundnamedpipecarrier.h
r2 r142 24 24 #include "netio/kqueue/iohandler.h" 25 25 26 class BaseProtocol;27 28 26 class InboundNamedPipeCarrier 29 27 : public IOHandler { 30 28 private: 31 BaseProtocol *_pProtocol;32 29 string _path; 33 30 public: … … 36 33 37 34 static InboundNamedPipeCarrier *Create(string path, uint16_t mode); 38 39 void SetProtocol(BaseProtocol *pPotocol);40 35 41 36 virtual bool SignalOutputData(); -
trunk/sources/thelib/include/netio/kqueue/iohandler.h
r58 r142 1 1 /* 2 * Copyright (c) 2010,3 * Gavriloaie Eugen-Andrei (shiretu@gmail.com)4 * 5 * This file is part of crtmpserver.6 * crtmpserver is free software: you can redistribute it and/or modify7 * it under the terms of the GNU General Public License as published by8 * the Free Software Foundation, either version 3 of the License, or9 * (at your option) any later version.10 * 11 * crtmpserver is distributed in the hope that it will be useful,12 * but WITHOUT ANY WARRANTY; without even the implied warranty of13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14 * GNU General Public License for more details.15 * 16 * You should have received a copy of the GNU General Public License17 * along with crtmpserver. If not, see <http://www.gnu.org/licenses/>.18 */2 * Copyright (c) 2010, 3 * Gavriloaie Eugen-Andrei (shiretu@gmail.com) 4 * 5 * This file is part of crtmpserver. 6 * crtmpserver is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * crtmpserver is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with crtmpserver. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 19 20 20 #ifdef NET_KQUEUE … … 26 26 27 27 typedef enum _IOHandlerType { 28 IOHT_ACCEPTOR,29 IOHT_TCP_CONNECTOR,30 IOHT_TCP_CARRIER,31 IOHT_UDP_CARRIER,32 IOHT_INBOUNDNAMEDPIPE_CARRIER,33 IOHT_TIMER,34 IOHT_STDIO28 IOHT_ACCEPTOR, 29 IOHT_TCP_CONNECTOR, 30 IOHT_TCP_CARRIER, 31 IOHT_UDP_CARRIER, 32 IOHT_INBOUNDNAMEDPIPE_CARRIER, 33 IOHT_TIMER, 34 IOHT_STDIO 35 35 } IOHandlerType; 36 37 class BaseProtocol; 36 38 37 39 class IOHandler { 38 40 protected: 39 static uint32_t _idGenerator;40 uint32_t _id;41 protected: 42 int32_t _inboundFd;43 int32_t _outboundFd;41 static uint32_t _idGenerator; 42 uint32_t _id; 43 int32_t _inboundFd; 44 int32_t _outboundFd; 45 BaseProtocol *_pProtocol; 44 46 private: 45 IOHandlerType _type;46 IOHandlerManagerToken *_pToken;47 IOHandlerType _type; 48 IOHandlerManagerToken *_pToken; 47 49 public: 48 IOHandler(int32_t inboundFd, int32_t outboundFd, IOHandlerType type); 49 virtual ~IOHandler(); 50 void SetIOHandlerManagerToken(IOHandlerManagerToken *pToken); 51 IOHandlerManagerToken * GetIOHandlerManagerToken(); 52 uint32_t GetId(); 53 int32_t GetInboundFd(); 54 int32_t GetOutboundFd(); 55 IOHandlerType GetType(); 56 virtual bool SignalOutputData() = 0; 57 virtual bool OnEvent(struct kevent &event) = 0; 58 static string IOHTToString(IOHandlerType type); 59 virtual operator string() = 0; 50 IOHandler(int32_t inboundFd, int32_t outboundFd, IOHandlerType type); 51 virtual ~IOHandler(); 52 void SetIOHandlerManagerToken(IOHandlerManagerToken *pToken); 53 IOHandlerManagerToken * GetIOHandlerManagerToken(); 54 uint32_t GetId(); 55 int32_t GetInboundFd(); 56 int32_t GetOutboundFd(); 57 IOHandlerType GetType(); 58 void SetProtocol(BaseProtocol *pPotocol); 59 virtual bool SignalOutputData() = 0; 60 virtual bool OnEvent(struct kevent &event) = 0; 61 static string IOHTToString(IOHandlerType type); 62 virtual operator string() = 0; 60 63 }; 61 64 -
trunk/sources/thelib/include/netio/kqueue/iotimer.h
r2 r142 24 24 #include "netio/kqueue/iohandler.h" 25 25 26 class BaseProtocol;27 28 26 class IOTimer 29 27 : public IOHandler { 30 28 private: 31 29 static int32_t _idGenerator; 32 BaseProtocol *_pProtocol;33 30 public: 34 IOTimer( BaseProtocol *pProtocol);31 IOTimer(); 35 32 virtual ~IOTimer(); 36 33 37 void ResetProtocol();38 34 virtual bool SignalOutputData(); 39 35 virtual bool OnEvent(struct kevent &event); -
trunk/sources/thelib/include/netio/kqueue/stdiocarrier.h
r2 r142 1 1 /* 2 * Copyright (c) 2010,3 * Gavriloaie Eugen-Andrei (shiretu@gmail.com)4 * 5 * This file is part of crtmpserver.6 * crtmpserver is free software: you can redistribute it and/or modify7 * it under the terms of the GNU General Public License as published by8 * the Free Software Foundation, either version 3 of the License, or9 * (at your option) any later version.10 * 11 * crtmpserver is distributed in the hope that it will be useful,12 * but WITHOUT ANY WARRANTY; without even the implied warranty of13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14 * GNU General Public License for more details.15 * 16 * You should have received a copy of the GNU General Public License17 * along with crtmpserver. If not, see <http://www.gnu.org/licenses/>.18 */2 * Copyright (c) 2010, 3 * Gavriloaie Eugen-Andrei (shiretu@gmail.com) 4 * 5 * This file is part of crtmpserver. 6 * crtmpserver is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * crtmpserver is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with crtmpserver. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 19 20 20 … … 25 25 #include "netio/kqueue/iohandler.h" 26 26 27 class BaseProtocol;28 29 27 class StdioCarrier 30 28 : public IOHandler { 31 29 private: 32 static StdioCarrier *_pInstance; 33 BaseProtocol *_pProtocol; 34 bool _writeDataEnabled; 30 static StdioCarrier *_pInstance; 31 bool _writeDataEnabled; 35 32 private: 36 StdioCarrier(BaseProtocol *pProtocol);33 StdioCarrier(); 37 34 public: 38 static StdioCarrier *GetInstance(BaseProtocol *pProtocol); 39 virtual ~StdioCarrier(); 40 void ResetProtocol(); 41 virtual bool OnEvent(struct kevent &event); 42 virtual bool SignalOutputData(); 43 virtual operator string(); 35 static StdioCarrier *GetInstance(BaseProtocol *pProtocol); 36 virtual ~StdioCarrier(); 37 virtual bool OnEvent(struct kevent &event); 38 virtual bool SignalOutputData(); 39 virtual operator string(); 44 40 }; 45 41 -
trunk/sources/thelib/include/netio/kqueue/tcpacceptor.h
r2 r142 24 24 25 25 #include "netio/kqueue/iohandler.h" 26 #include "protocols/baseprotocol.h"27 26 28 27 class BaseClientApplication; -
trunk/sources/thelib/include/netio/kqueue/tcpcarrier.h
r2 r142 1 1 /* 2 * Copyright (c) 2010,3 * Gavriloaie Eugen-Andrei (shiretu@gmail.com)4 * 5 * This file is part of crtmpserver.6 * crtmpserver is free software: you can redistribute it and/or modify7 * it under the terms of the GNU General Public License as published by8 * the Free Software Foundation, either version 3 of the License, or9 * (at your option) any later version.10 * 11 * crtmpserver is distributed in the hope that it will be useful,12 * but WITHOUT ANY WARRANTY; without even the implied warranty of13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14 * GNU General Public License for more details.15 * 16 * You should have received a copy of the GNU General Public License17 * along with crtmpserver. If not, see <http://www.gnu.org/licenses/>.18 */2 * Copyright (c) 2010, 3 * Gavriloaie Eugen-Andrei (shiretu@gmail.com) 4 * 5 * This file is part of crtmpserver. 6 * crtmpserver is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * crtmpserver is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with crtmpserver. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 19 20 20 #ifdef NET_KQUEUE … … 22 22 #define _TCPCARRIER_H 23 23 24 25 24 #include "netio/kqueue/iohandler.h" 26 27 class BaseProtocol;28 25 29 26 class TCPCarrier 30 27 : public IOHandler { 31 28 private: 32 BaseProtocol *_pProtocol; 33 bool _writeDataEnabled; 34 sockaddr_in _farAddress; 35 string _farIp; 36 uint16_t _farPort; 37 sockaddr_in _nearAddress; 38 string _nearIp; 39 uint16_t _nearPort; 29 bool _writeDataEnabled; 30 sockaddr_in _farAddress; 31 string _farIp; 32 uint16_t _farPort; 33 sockaddr_in _nearAddress; 34 string _nearIp; 35 uint16_t _nearPort; 40 36 public: 41 TCPCarrier(int32_t fd, BaseProtocol *pProtocol); 42 virtual ~TCPCarrier(); 43 void ResetProtocol(); 44 virtual bool OnEvent(struct kevent &event); 45 virtual bool SignalOutputData(); 46 virtual operator string(); 37 TCPCarrier(int32_t fd); 38 virtual ~TCPCarrier(); 39 virtual bool OnEvent(struct kevent &event); 40 virtual bool SignalOutputData(); 41 virtual operator string(); 47 42 48 sockaddr_in &GetFarEndpointAddress();49 string GetFarEndpointAddressIp();50 uint16_t GetFarEndpointPort();51 sockaddr_in &GetNearEndpointAddress();52 string GetNearEndpointAddressIp();53 uint16_t GetNearEndpointPort();43 sockaddr_in &GetFarEndpointAddress(); 44 string GetFarEndpointAddressIp(); 45 uint16_t GetFarEndpointPort(); 46 sockaddr_in &GetNearEndpointAddress(); 47 string GetNearEndpointAddressIp(); 48 uint16_t GetNearEndpointPort(); 54 49 private: 55 bool GetEndpointsInfo();50 bool GetEndpointsInfo(); 56 51 }; 57 52 -
trunk/sources/thelib/include/netio/kqueue/tcpconnector.h
r131 r142 84 84 } 85 85 86 TCPCarrier *pTCPCarrier = new TCPCarrier(_inboundFd, pProtocol->GetFarEndpoint()); 86 TCPCarrier *pTCPCarrier = new TCPCarrier(_inboundFd); 87 pTCPCarrier->SetProtocol(pProtocol->GetFarEndpoint()); 87 88 pProtocol->GetFarEndpoint()->SetIOHandler(pTCPCarrier); 88 89 -
trunk/sources/thelib/include/netio/kqueue/udpcarrier.h
r2 r142 1 1 /* 2 * Copyright (c) 2010,3 * Gavriloaie Eugen-Andrei (shiretu@gmail.com)4 * 5 * This file is part of crtmpserver.6 * crtmpserver is free software: you can redistribute it and/or modify7 * it under the terms of the GNU General Public License as published by8 * the Free Software Foundation, either version 3 of the License, or9 * (at your option) any later version.10 * 11 * crtmpserver is distributed in the hope that it will be useful,12 * but WITHOUT ANY WARRANTY; without even the implied warranty of13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14 * GNU General Public License for more details.15 * 16 * You should have received a copy of the GNU General Public License17 * along with crtmpserver. If not, see <http://www.gnu.org/licenses/>.18 */2 * Copyright (c) 2010, 3 * Gavriloaie Eugen-Andrei (shiretu@gmail.com) 4 * 5 * This file is part of crtmpserver. 6 * crtmpserver is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * crtmpserver is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with crtmpserver. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 19 20 20 … … 25 25 #include "netio/kqueue/iohandler.h" 26 26 27 class BaseProtocol;28 29 27 class UDPCarrier 30 28 : public IOHandler { 31 29 private: 32 BaseProtocol *_pProtocol;33 30 sockaddr_in _peerAddress; 34 31 sockaddr_in _nearAddress; … … 36 33 uint16_t _nearPort; 37 34 public: 38 UDPCarrier(int32_t fd , BaseProtocol *pProtocol);35 UDPCarrier(int32_t fd); 39 36 virtual ~UDPCarrier(); 40 37 41 void ResetProtocol();42 void SetProtocol(BaseProtocol *pProtocol);43 38 virtual bool OnEvent(struct kevent &event); 44 39 virtual bool SignalOutputData(); -
trunk/sources/thelib/include/netio/netio.h
r56 r142 65 65 #include "netio/select/stdiocarrier.h" 66 66 #define NETWORK_REACTOR "select" 67 #error "Select system is not working now" 67 68 #endif 68 69 -
trunk/sources/thelib/include/netio/select/inboundnamedpipecarrier.h
r56 r142 24 24 #include "netio/select/iohandler.h" 25 25 26 class BaseProtocol;27 28 26 class InboundNamedPipeCarrier 29 27 : public IOHandler { 30 28 private: 31 BaseProtocol *_pProtocol;32 29 string _path; 33 30 public: … … 36 33 37 34 static InboundNamedPipeCarrier *Create(string path, uint16_t mode); 38 39 void SetProtocol(BaseProtocol *pPotocol);40 35 41 36 virtual bool SignalOutputData(); -
trunk/sources/thelib/include/netio/select/iohandler.h
r58 r142 24 24 #include "common.h" 25 25 26 26 27 typedef enum _IOHandlerType { 27 28 IOHT_ACCEPTOR, … … 34 35 } IOHandlerType; 35 36 37 class BaseProtocol; 38 36 39 class DLLEXP IOHandler { 37 40 protected: 38 41 static uint32_t _idGenerator; 39 42 uint32_t _id; 40 protected:41 43 int32_t _inboundFd; 42 44 int32_t _outboundFd; 45 BaseProtocol *_pProtocol; 43 46 private: 44 47 IOHandlerType _type; … … 50 53 int32_t GetOutboundFd(); 51 54 IOHandlerType GetType(); 55 void SetProtocol(BaseProtocol *pPotocol); 52 56 virtual bool SignalOutputData() = 0; 53 57 virtual bool OnEvent(select_event &event) = 0; -
trunk/sources/thelib/include/netio/select/iotimer.h
r56 r142 24 24 #include "netio/select/iohandler.h" 25 25 26 class BaseProtocol;27 28 26 class DLLEXP IOTimer 29 27 : public IOHandler { … … 32 30 BaseProtocol *_pProtocol; 33 31 public: 34 IOTimer( BaseProtocol *pProtocol);32 IOTimer(); 35 33 virtual ~IOTimer(); 36 34 37 void ResetProtocol();38 35 virtual bool SignalOutputData(); 39 36 virtual bool OnEvent(select_event &event); -
trunk/sources/thelib/include/netio/select/stdiocarrier.h
r56 r142 25 25 #include "netio/select/iohandler.h" 26 26 27 class BaseProtocol;28 29 27 class DLLEXP StdioCarrier 30 28 : public IOHandler { 31 29 private: 32 30 static StdioCarrier *_pInstance; 33 BaseProtocol *_pProtocol;34 31 bool _writeDataEnabled; 35 32 private: 36 StdioCarrier( BaseProtocol *pProtocol);33 StdioCarrier(); 37 34 public: 38 35 static StdioCarrier *GetInstance(BaseProtocol *pProtocol); 39 36 virtual ~StdioCarrier(); 40 void ResetProtocol();41 37 virtual bool OnEvent(select_event &event); 42 38 virtual bool SignalOutputData(); -
trunk/sources/thelib/include/netio/select/tcpcarrier.h
r56 r142 22 22 #define _TCPCARRIER_H 23 23 24 25 24 #include "netio/select/iohandler.h" 26 25 … … 30 29 : public IOHandler { 31 30 private: 32 BaseProtocol *_pProtocol;33 31 bool _writeDataEnabled; 34 32 sockaddr_in _farAddress; … … 41 39 int32_t _recvBufferSize; 42 40 public: 43 TCPCarrier(int32_t fd , BaseProtocol *pProtocol);41 TCPCarrier(int32_t fd); 44 42 virtual ~TCPCarrier(); 45 void ResetProtocol();46 43 virtual bool OnEvent(select_event &event); 47 44 virtual bool SignalOutputData(); -
trunk/sources/thelib/include/netio/select/tcpconnector.h
r49 r142 82 82 } 83 83 84 TCPCarrier *pTCPCarrier = new TCPCarrier(_inboundFd, pProtocol->GetFarEndpoint()); 84 TCPCarrier *pTCPCarrier = new TCPCarrier(_inboundFd); 85 pTCPCarrier->SetProtocol(pProtocol->GetFarEndpoint()); 85 86 pProtocol->GetFarEndpoint()->SetIOHandler(pTCPCarrier); 86 87 -
trunk/sources/thelib/include/netio/select/udpcarrier.h
r56 r142 25 25 #include "netio/select/iohandler.h" 26 26 27 class BaseProtocol;28 29 27 class DLLEXP UDPCarrier 30 28 : public IOHandler { … … 36 34 uint16_t _nearPort; 37 35 public: 38 UDPCarrier(int32_t fd , BaseProtocol *pProtocol);36 UDPCarrier(int32_t fd); 39 37 virtual ~UDPCarrier(); 40 38 41 void ResetProtocol();42 void SetProtocol(BaseProtocol *pProtocol);43 39 virtual bool OnEvent(select_event &event); 44 40 virtual bool SignalOutputData(); -
trunk/sources/thelib/include/protocols/baseprotocol.h
r58 r142 35 35 static uint32_t _idGenerator; 36 36 uint32_t _id; 37 BaseClientApplication *_pApplication; 37 38 protected: 38 39 uint64_t _type; … … 43 44 bool _enqueueForDelete; 44 45 bool _gracefullyEnqueueForDelete; 45 BaseClientApplication *_pApplication;46 46 Variant _customParameters; 47 47 public: … … 160 160 virtual void SetApplication(BaseClientApplication *pApplication); 161 161 162 //Resets the protocol's application163 virtual void ResetApplication();164 165 162 //This is called by the framework when data is available for processing, 166 163 //when making use of connection-less protocols -
trunk/sources/thelib/include/protocols/rtmp/basertmpprotocol.h
r131 r142 89 89 virtual void ReadyForSend(); 90 90 virtual void SetApplication(BaseClientApplication *pApplication); 91 virtual void ResetApplication();92 91 93 92 bool SendMessage(Variant &message); -
trunk/sources/thelib/include/protocols/ts/inboundtsprotocol.h
r56 r142 70 70 71 71 virtual void SetApplication(BaseClientApplication *pApplication); 72 virtual void ResetApplication();73 72 BaseTSAppProtocolHandler *GetProtocolHandler(); 74 73 uint32_t GetChunkSize(); -
trunk/sources/thelib/src/application/baseclientapplication.cpp
r131 r142 29 29 BaseClientApplication::BaseClientApplication(Variant &configuration) 30 30 : _streamsManager(this) { 31 _id = _idGenerator++;31 _id = ++_idGenerator; 32 32 _configuration = configuration; 33 33 _name = (string) configuration[CONF_APPLICATION_NAME]; -
trunk/sources/thelib/src/netio/epoll/inboundnamedpipecarrier.cpp
r56 r142 26 26 InboundNamedPipeCarrier::InboundNamedPipeCarrier(int32_t fd, string path) 27 27 : IOHandler(fd, fd, IOHT_INBOUNDNAMEDPIPE_CARRIER) { 28 _pProtocol = NULL;29 28 _path = path; 30 29 } … … 61 60 62 61 return pResult; 63 }64 65 void InboundNamedPipeCarrier::SetProtocol(BaseProtocol *pPotocol) {66 if (_pProtocol != NULL) {67 ASSERT("protocol already set up");68 }69 _pProtocol = pPotocol;70 62 } 71 63 -
trunk/sources/thelib/src/netio/epoll/iohandler.cpp
r56 r142 21 21 #include "netio/epoll/iohandler.h" 22 22 #include "netio/epoll/iohandlermanager.h" 23 #include "protocols/baseprotocol.h" 23 24 24 25 uint32_t IOHandler::_idGenerator = 0; 25 26 26 27 IOHandler::IOHandler(int32_t inboundFd, int32_t outboundFd, IOHandlerType type) { 28 _pProtocol = NULL; 27 29 _type = type; 28 _id = _idGenerator++;30 _id = ++_idGenerator; 29 31 _inboundFd = inboundFd; 30 32 _outboundFd = outboundFd; … … 34 36 35 37 IOHandler::~IOHandler() { 38 if (_pProtocol != NULL) { 39 _pProtocol->SetIOHandler(NULL); 40 _pProtocol->EnqueueForDelete(); 41 _pProtocol = NULL; 42 } 36 43 IOHandlerManager::UnRegisterIOHandler(this); 37 44 } … … 61 68 } 62 69 70 void IOHandler::SetProtocol(BaseProtocol *pPotocol) { 71 _pProtocol = pPotocol; 72 } 73 63 74 string IOHandler::IOHTToString(IOHandlerType type) { 64 75 switch (type) { -
trunk/sources/thelib/src/netio/epoll/iotimer.cpp
r56 r142 25 25 int32_t IOTimer::_idGenerator; 26 26 27 IOTimer::IOTimer( BaseProtocol *pProtocol)27 IOTimer::IOTimer() 28 28 : IOHandler(0, 0, IOHT_TIMER) { 29 _pProtocol = pProtocol;30 29 _inboundFd = _outboundFd = ++_idGenerator; 31 30 } … … 34 33 //FINEST("Disable timer"); 35 34 IOHandlerManager::DisableTimer(this, true); 36 if (_pProtocol != NULL) {37 _pProtocol->SetIOHandler(NULL);38 delete _pProtocol;39 }40 }41 42 void IOTimer::ResetProtocol() {43 _pProtocol = NULL;44 35 } 45 36 -
trunk/sources/thelib/src/netio/epoll/stdiocarrier.cpp
r56 r142 40 40 StdioCarrier *StdioCarrier::_pInstance = NULL; 41 41 42 StdioCarrier::StdioCarrier( BaseProtocol *pProtocol)42 StdioCarrier::StdioCarrier() 43 43 : IOHandler(fileno(stdin), fileno(stdout), IOHT_TCP_CARRIER) { 44 _pProtocol = pProtocol;45 44 IOHandlerManager::EnableReadData(this); 46 45 _writeDataEnabled = false; … … 49 48 StdioCarrier *StdioCarrier::GetInstance(BaseProtocol *pProtocol) { 50 49 if (_pInstance == NULL) { 51 _pInstance = new StdioCarrier(pProtocol); 50 _pInstance = new StdioCarrier(); 51 _pInstance->SetProtocol(pProtocol); 52 pProtocol->GetFarEndpoint()->SetIOHandler(_pInstance); 52 53 return _pInstance; 53 54 } … … 62 63 63 64 StdioCarrier::~StdioCarrier() { 64 if (_pProtocol != NULL) {65 _pProtocol->SetIOHandler(NULL);66 delete _pProtocol;67 }68 65 _pInstance = NULL; 69 }70 71 void StdioCarrier::ResetProtocol() {72 _pProtocol = NULL;73 66 } 74 67 -
trunk/sources/thelib/src/netio/epoll/tcpacceptor.cpp
r20 r142 160 160 161 161 //5. Create the carrier and bind it 162 TCPCarrier *pTCPCarrier = new TCPCarrier(fd, pProtocol->GetFarEndpoint()); 162 TCPCarrier *pTCPCarrier = new TCPCarrier(fd); 163 pTCPCarrier->SetProtocol(pProtocol->GetFarEndpoint()); 163 164 pProtocol->GetFarEndpoint()->SetIOHandler(pTCPCarrier); 164 165 -
trunk/sources/thelib/src/netio/epoll/tcpcarrier.cpp
r56 r142 38 38 } 39 39 40 TCPCarrier::TCPCarrier(int32_t fd , BaseProtocol *pProtocol)40 TCPCarrier::TCPCarrier(int32_t fd) 41 41 : IOHandler(fd, fd, IOHT_TCP_CARRIER) { 42 _pProtocol = pProtocol;43 42 IOHandlerManager::EnableReadData(this); 44 43 _writeDataEnabled = false; … … 63 62 TCPCarrier::~TCPCarrier() { 64 63 close(_inboundFd); 65 if (_pProtocol != NULL) {66 _pProtocol->SetIOHandler(NULL);67 delete _pProtocol;68 }69 }70 71 void TCPCarrier::ResetProtocol() {72 _pProtocol = NULL;73 64 } 74 65 -
trunk/sources/thelib/src/netio/epoll/udpcarrier.cpp
r56 r142 27 27 #define SOCKET_WRITE_CHUNK SOCKET_READ_CHUNK 28 28 29 UDPCarrier::UDPCarrier(int32_t fd , BaseProtocol *pProtocol)29 UDPCarrier::UDPCarrier(int32_t fd) 30 30 : IOHandler(fd, fd, IOHT_UDP_CARRIER) { 31 _pProtocol = pProtocol;32 31 IOHandlerManager::EnableReadData(this); 33 32 memset(&_peerAddress, 0, sizeof (sockaddr_in)); … … 39 38 UDPCarrier::~UDPCarrier() { 40 39 close(_inboundFd); 41 if (_pProtocol != NULL) {42 _pProtocol->SetIOHandler(NULL);43 delete _pProtocol;44 }45 }46 47 void UDPCarrier::ResetProtocol() {48 _pProtocol = NULL;49 }50 51 void UDPCarrier::SetProtocol(BaseProtocol *pProtocol) {52 if (_pProtocol != NULL) {53 ASSERT("This carrier is already bound");54 }55 _pProtocol = pProtocol;56 40 } 57 41 … … 159 143 160 144 //4. Create the carrier 161 UDPCarrier *pResult = new UDPCarrier(sock , NULL);145 UDPCarrier *pResult = new UDPCarrier(sock); 162 146 pResult->_nearAddress = bindAddress; 163 147 -
trunk/sources/thelib/src/netio/kqueue/inboundnamedpipecarrier.cpp
r56 r142 20 20 21 21 #ifdef NET_KQUEUE 22 23 22 #include "netio/kqueue/iohandlermanager.h" 24 23 #include "netio/kqueue/inboundnamedpipecarrier.h" … … 27 26 InboundNamedPipeCarrier::InboundNamedPipeCarrier(int32_t fd, string path) 28 27 : IOHandler(fd, fd, IOHT_INBOUNDNAMEDPIPE_CARRIER) { 29 _pProtocol = NULL;30 28 _path = path; 31 29 } … … 62 60 63 61 return pResult; 64 }65 66 void InboundNamedPipeCarrier::SetProtocol(BaseProtocol *pPotocol) {67 if (_pProtocol != NULL) {68 ASSERT("protocol already set up");69 }70 _pProtocol = pPotocol;71 62 } 72 63 -
trunk/sources/thelib/src/netio/kqueue/iohandler.cpp
r2 r142 1 1 /* 2 * Copyright (c) 2010,3 * Gavriloaie Eugen-Andrei (shiretu@gmail.com)4 * 5 * This file is part of crtmpserver.6 * crtmpserver is free software: you can redistribute it and/or modify7 * it under the terms of the GNU General Public License as published by8 * the Free Software Foundation, either version 3 of the License, or9 * (at your option) any later version.10 * 11 * crtmpserver is distributed in the hope that it will be useful,12 * but WITHOUT ANY WARRANTY; without even the implied warranty of13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14 * GNU General Public License for more details.15 * 16 * You should have received a copy of the GNU General Public License17 * along with crtmpserver. If not, see <http://www.gnu.org/licenses/>.18 */2 * Copyright (c) 2010, 3 * Gavriloaie Eugen-Andrei (shiretu@gmail.com) 4 * 5 * This file is part of crtmpserver. 6 * crtmpserver is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * crtmpserver is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with crtmpserver. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 19 20 20 #ifdef NET_KQUEUE 21 21 #include "netio/kqueue/iohandler.h" 22 22 #include "netio/kqueue/iohandlermanager.h" 23 24 25 23 #include "protocols/baseprotocol.h" 26 24 27 25 uint32_t IOHandler::_idGenerator = 0; 28 26 29 27 IOHandler::IOHandler(int32_t inboundFd, int32_t outboundFd, IOHandlerType type) { 30 _type = type; 31 _id = _idGenerator++; 32 _inboundFd = inboundFd; 33 _outboundFd = outboundFd; 34 _pToken = NULL; 35 IOHandlerManager::RegisterIOHandler(this); 28 _pProtocol = NULL; 29 _type = type; 30 _id = ++_idGenerator; 31 _inboundFd = inboundFd; 32 _outboundFd = outboundFd; 33 _pToken = NULL; 34 IOHandlerManager::RegisterIOHandler(this); 36 35 } 37 36 38 37 IOHandler::~IOHandler() { 39 //FINEST("IOHandler %p is in destructor", this); 40 IOHandlerManager::UnRegisterIOHandler(this); 38 //FINEST("IOHandler %p is in destructor", this); 39 if (_pProtocol != NULL) { 40 _pProtocol->SetIOHandler(NULL); 41 _pProtocol->EnqueueForDelete(); 42 _pProtocol = NULL; 43 } 44 IOHandlerManager::UnRegisterIOHandler(this); 41 45 } 42 46 43 47 void IOHandler::SetIOHandlerManagerToken(IOHandlerManagerToken *pToken) { 44 _pToken = pToken;48 _pToken = pToken; 45 49 } 46 50 47 51 IOHandlerManagerToken * IOHandler::GetIOHandlerManagerToken() { 48 return _pToken;52 return _pToken; 49 53 } 50 54 51 55 uint32_t IOHandler::GetId() { 52 return _id;56 return _id; 53 57 } 54 58 55 59 int32_t IOHandler::GetInboundFd() { 56 return _inboundFd;60 return _inboundFd; 57 61 } 58 62 59 63 int32_t IOHandler::GetOutboundFd() { 60 return _outboundFd;64 return _outboundFd; 61 65 } 62 66 63 67 IOHandlerType IOHandler::GetType() { 64 return _type; 68 return _type; 69 } 70 71 void IOHandler::SetProtocol(BaseProtocol *pPotocol) { 72 _pProtocol = pPotocol; 65 73 } 66 74 67 75 string IOHandler::IOHTToString(IOHandlerType type) { 68 switch (type) {69 case IOHT_ACCEPTOR:70 return "IOHT_ACCEPTOR";71 case IOHT_TCP_CARRIER:72 return "IOHT_TCP_CARRIER";73 case IOHT_UDP_CARRIER:74 return "IOHT_UDP_CARRIER";75 case IOHT_TCP_CONNECTOR:76 return "IOHT_TCP_CONNECTOR";77 case IOHT_TIMER:78 return "IOHT_TIMER";79 case IOHT_INBOUNDNAMEDPIPE_CARRIER:80 return "IOHT_INBOUNDNAMEDPIPE_CARRIER";81 case IOHT_STDIO:82 return "IOHT_STDIO";83 default:84 return format("#unknown: %d#", type);85 }76 switch (type) { 77 case IOHT_ACCEPTOR: 78 return "IOHT_ACCEPTOR"; 79 case IOHT_TCP_CARRIER: 80 return "IOHT_TCP_CARRIER"; 81 case IOHT_UDP_CARRIER: 82 return "IOHT_UDP_CARRIER"; 83 case IOHT_TCP_CONNECTOR: 84 return "IOHT_TCP_CONNECTOR"; 85 case IOHT_TIMER: 86 return "IOHT_TIMER"; 87 case IOHT_INBOUNDNAMEDPIPE_CARRIER: 88 return "IOHT_INBOUNDNAMEDPIPE_CARRIER"; 89 case IOHT_STDIO: 90 return "IOHT_STDIO"; 91 default: 92 return format("#unknown: %d#", type); 93 } 86 94 } 87 95 #endif /* NET_KQUEUE */ -
trunk/sources/thelib/src/netio/kqueue/iotimer.cpp
r2 r142 25 25 int32_t IOTimer::_idGenerator; 26 26 27 IOTimer::IOTimer( BaseProtocol *pProtocol)27 IOTimer::IOTimer() 28 28 : IOHandler(0, 0, IOHT_TIMER) { 29 _pProtocol = pProtocol;30 29 _outboundFd = _inboundFd = ++_idGenerator; 31 30 } … … 34 33 //FINEST("Disable timer"); 35 34 IOHandlerManager::DisableTimer(this, true); 36 if (_pProtocol != NULL) {37 _pProtocol->SetIOHandler(NULL);38 delete _pProtocol;39 }40 }41 42 void IOTimer::ResetProtocol() {43 _pProtocol = NULL;44 35 } 45 36 -
trunk/sources/thelib/src/netio/kqueue/stdiocarrier.cpp
r58 r142 46 46 StdioCarrier *StdioCarrier::_pInstance = NULL; 47 47 48 StdioCarrier::StdioCarrier( BaseProtocol *pProtocol)48 StdioCarrier::StdioCarrier() 49 49 : IOHandler(fileno(stdin), fileno(stdout), IOHT_STDIO) { 50 _pProtocol = pProtocol;51 50 IOHandlerManager::EnableReadData(this); 52 51 _writeDataEnabled = false; … … 55 54 StdioCarrier *StdioCarrier::GetInstance(BaseProtocol *pProtocol) { 56 55 if (_pInstance == NULL) { 57 _pInstance = new StdioCarrier(pProtocol); 56 _pInstance = new StdioCarrier(); 57 _pInstance->SetProtocol(pProtocol); 58 pProtocol->GetFarEndpoint()->SetIOHandler(_pInstance); 58 59 return _pInstance; 59 60 } … … 68 69 69 70 StdioCarrier::~StdioCarrier() { 70 if (_pProtocol != NULL) {71 _pProtocol->SetIOHandler(NULL);72 delete _pProtocol;73 }74 71 _pInstance = NULL; 75 }76 77 void StdioCarrier::ResetProtocol() {78 _pProtocol = NULL;79 72 } 80 73 -
trunk/sources/thelib/src/netio/kqueue/tcpacceptor.cpp
r56 r142 158 158 159 159 //5. Create the carrier and bind it 160 TCPCarrier *pTCPCarrier = new TCPCarrier(fd, pProtocol->GetFarEndpoint()); 160 TCPCarrier *pTCPCarrier = new TCPCarrier(fd); 161 pTCPCarrier->SetProtocol(pProtocol->GetFarEndpoint()); 161 162 pProtocol->GetFarEndpoint()->SetIOHandler(pTCPCarrier); 162 163 -
trunk/sources/thelib/src/netio/kqueue/tcpcarrier.cpp
r56 r142 43 43 }*/ 44 44 45 TCPCarrier::TCPCarrier(int32_t fd , BaseProtocol *pProtocol)45 TCPCarrier::TCPCarrier(int32_t fd) 46 46 : IOHandler(fd, fd, IOHT_TCP_CARRIER) { 47 _pProtocol = pProtocol;48 47 IOHandlerManager::EnableReadData(this); 49 48 _writeDataEnabled = false; … … 60 59 //FINEST("Delete tcp carrier %p", this); 61 60 close(_inboundFd); 62 if (_pProtocol != NULL) {63 _pProtocol->SetIOHandler(NULL);64 delete _pProtocol;65 }66 61 //FINEST("Done delete tcp carrier %p", this); 67 }68 69 void TCPCarrier::ResetProtocol() {70 _pProtocol = NULL;71 62 } 72 63 -
trunk/sources/thelib/src/netio/kqueue/udpcarrier.cpp
r56 r142 25 25 #include "protocols/baseprotocol.h" 26 26 27 UDPCarrier::UDPCarrier(int32_t fd , BaseProtocol *pProtocol)27 UDPCarrier::UDPCarrier(int32_t fd) 28 28 : IOHandler(fd, fd, IOHT_UDP_CARRIER) { 29 _pProtocol = pProtocol;30 29 IOHandlerManager::EnableReadData(this); 31 30 memset(&_peerAddress, 0, sizeof (sockaddr_in)); … … 37 36 UDPCarrier::~UDPCarrier() { 38 37 close(_inboundFd); 39 if (_pProtocol != NULL) {40 _pProtocol->SetIOHandler(NULL);41 delete _pProtocol;42 }43 }44 45 void UDPCarrier::ResetProtocol() {46 _pProtocol = NULL;47 }48 49 void UDPCarrier::SetProtocol(BaseProtocol *pProtocol) {50 if (_pProtocol != NULL) {51 ASSERT("This carrier is already bound");52 }53 _pProtocol = pProtocol;54 38 } 55 39 … … 153 137 154 138 //4. Create the carrier 155 UDPCarrier *pResult = new UDPCarrier(sock , NULL);139 UDPCarrier *pResult = new UDPCarrier(sock); 156 140 pResult->_nearAddress = bindAddress; 157 141 -
trunk/sources/thelib/src/netio/select/inboundnamedpipecarrier.cpp
r56 r142 27 27 InboundNamedPipeCarrier::InboundNamedPipeCarrier(int32_t fd, string path) 28 28 : IOHandler(fd, fd, IOHT_INBOUNDNAMEDPIPE_CARRIER) { 29 _pProtocol = NULL;30 29 _path = path; 31 30 } … … 62 61 63 62 return pResult; 64 }65 66 void InboundNamedPipeCarrier::SetProtocol(BaseProtocol *pPotocol) {67 if (_pProtocol != NULL) {68 ASSERT("protocol already set up");69 }70 _pProtocol = pPotocol;71 63 } 72 64 -
trunk/sources/thelib/src/netio/select/iohandler.cpp
r56 r142 21 21 #include "netio/select/iohandler.h" 22 22 #include "netio/select/iohandlermanager.h" 23 #include "protocols/baseprotocol.h" 23 24 24 25 uint32_t IOHandler::_idGenerator = 0; 25 26 26 27 IOHandler::IOHandler(int32_t inboundFd, int32_t outboundFd, IOHandlerType type) { 28 _pProtocol = NULL; 27 29 _type = type; 28 _id = _idGenerator++;30 _id = ++_idGenerator; 29 31 _inboundFd = inboundFd; 30 32 _outboundFd = outboundFd; … … 34 36 IOHandler::~IOHandler() { 35 37 //FINEST("IOHandler %p is in destructor", this); 38 if (_pProtocol != NULL) { 39 _pProtocol->SetIOHandler(NULL); 40 _pProtocol->EnqueueForDelete(); 41 _pProtocol = NULL; 42 } 36 43 IOHandlerManager::UnRegisterIOHandler(this); 37 44 } … … 51 58 IOHandlerType IOHandler::GetType() { 52 59 return _type; 60 } 61 62 void IOHandler::SetProtocol(BaseProtocol *pPotocol) { 63 _pProtocol = pPotocol; 53 64 } 54 65 -
trunk/sources/thelib/src/netio/select/iohandlermanager.cpp
r56 r142 206 206 207 207 bool IOHandlerManager::UpdateFdSets(int32_t fd) { 208 uint8_t state ;208 uint8_t state = 0; 209 209 210 210 // string str = ""; -
trunk/sources/thelib/src/netio/select/iotimer.cpp
r56 r142 25 25 int32_t IOTimer::_idGenerator; 26 26 27 IOTimer::IOTimer( BaseProtocol *pProtocol)27 IOTimer::IOTimer() 28 28 : IOHandler(0, 0, IOHT_TIMER) { 29 _pProtocol = pProtocol;30 29 _outboundFd = _inboundFd = ++_idGenerator; 31 30 } … … 34 33 //FINEST("Disable timer"); 35 34 IOHandlerManager::DisableTimer(this); 36 if (_pProtocol != NULL) {37 _pProtocol->SetIOHandler(NULL);38 delete _pProtocol;39 }40 }41 42 void IOTimer::ResetProtocol() {43 _pProtocol = NULL;44 35 } 45 36 -
trunk/sources/thelib/src/netio/select/stdiocarrier.cpp
r56 r142 45 45 StdioCarrier *StdioCarrier::_pInstance = NULL; 46 46 47 StdioCarrier::StdioCarrier( BaseProtocol *pProtocol)47 StdioCarrier::StdioCarrier() 48 48 : IOHandler(fileno(stdin), fileno(stdout), IOHT_STDIO) { 49 _pProtocol = pProtocol;50 49 IOHandlerManager::EnableReadData(this); 51 50 _writeDataEnabled = false; … … 54 53 StdioCarrier *StdioCarrier::GetInstance(BaseProtocol *pProtocol) { 55 54 if (_pInstance == NULL) { 56 _pInstance = new StdioCarrier(pProtocol); 55 _pInstance = new StdioCarrier(); 56 _pInstance->SetProtocol(pProtocol); 57 pProtocol->GetFarEndpoint()->SetIOHandler(_pInstance); 57 58 return _pInstance; 58 59 } … … 67 68 68 69 StdioCarrier::~StdioCarrier() { 69 if (_pProtocol != NULL) {70 _pProtocol->SetIOHandler(NULL);71 delete _pProtocol;72 }73 70 _pInstance = NULL; 74 }75 76 void StdioCarrier::ResetProtocol() {77 _pProtocol = NULL;78 71 } 79 72 -
trunk/sources/thelib/src/netio/select/tcpacceptor.cpp
r56 r142 154 154 155 155 //5. Create the carrier and bind it 156 TCPCarrier *pTCPCarrier = new TCPCarrier(fd, pProtocol->GetFarEndpoint()); 156 TCPCarrier *pTCPCarrier = new TCPCarrier(fd); 157 pTCPCarrier->SetProtocol(pProtocol->GetFarEndpoint()); 157 158 pProtocol->GetFarEndpoint()->SetIOHandler(pTCPCarrier); 158 159 -
trunk/sources/thelib/src/netio/select/tcpcarrier.cpp
r56 r142 43 43 }*/ 44 44 45 TCPCarrier::TCPCarrier(int32_t fd , BaseProtocol *pProtocol)45 TCPCarrier::TCPCarrier(int32_t fd) 46 46 : IOHandler(fd, fd, IOHT_TCP_CARRIER) { 47 _pProtocol = pProtocol;48 47 IOHandlerManager::EnableReadData(this); 49 48 _writeDataEnabled = false; … … 69 68 //FINEST("Delete tcp carrier %p", this); 70 69 CLOSE_SOCKET(_inboundFd); 71 if (_pProtocol != NULL) {72 _pProtocol->SetIOHandler(NULL);73 delete _pProtocol;74 }75 70 //FINEST("Done delete tcp carrier %p", this); 76 }77 78 void TCPCarrier::ResetProtocol() {79 _pProtocol = NULL;80 71 } 81 72 -
trunk/sources/thelib/src/netio/select/udpcarrier.cpp
r56 r142 25 25 #include "protocols/baseprotocol.h" 26 26 27 UDPCarrier::UDPCarrier(int32_t fd , BaseProtocol *pProtocol)27 UDPCarrier::UDPCarrier(int32_t fd) 28 28 : IOHandler(fd, fd, IOHT_UDP_CARRIER) { 29 _pProtocol = pProtocol;30 29 IOHandlerManager::EnableReadData(this); 31 30 memset(&_peerAddress, 0, sizeof (sockaddr_in)); … … 37 36 UDPCarrier::~UDPCarrier() { 38 37 CLOSE_SOCKET(_inboundFd); 39 if (_pProtocol != NULL) {40 _pProtocol->SetIOHandler(NULL);41 delete _pProtocol;42 }43 }44 45 void UDPCarrier::ResetProtocol() {46 _pProtocol = NULL;47 }48 49 void UDPCarrier::SetProtocol(BaseProtocol *pProtocol) {50 if (_pProtocol != NULL) {51 ASSERT("This carrier is already bound");52 }53 _pProtocol = pProtocol;54 38 } 55 39 … … 154 138 155 139 //4. Create the carrier 156 UDPCarrier *pResult = new UDPCarrier(sock , NULL);140 UDPCarrier *pResult = new UDPCarrier(sock); 157 141 pResult->_nearAddress = bindAddress; 158 142 -
trunk/sources/thelib/src/protocols/baseprotocol.cpp
r56 r142 52 52 _pFarProtocol, _pNearProtocol, _deleteFar, _deleteNear); 53 53 #endif 54 if (_pFarProtocol != NULL) { 55 _pFarProtocol->_pNearProtocol = NULL; 56 if (_deleteFar) { 57 delete _pFarProtocol; 58 } 59 } 60 if (_pNearProtocol != NULL) { 61 _pNearProtocol->_pFarProtocol = NULL; 62 if (_deleteNear) { 63 delete _pNearProtocol; 64 65 } 66 } 54 BaseProtocol *pFar = _pFarProtocol; 55 BaseProtocol *pNear = _pNearProtocol; 56 67 57 _pFarProtocol = NULL; 68 58 _pNearProtocol = NULL; 59 if (pFar != NULL) { 60 pFar->_pNearProtocol = NULL; 61 if (_deleteFar) { 62 pFar->EnqueueForDelete(); 63 } 64 } 65 if (pNear != NULL) { 66 pNear->_pFarProtocol = NULL; 67 if (_deleteNear) { 68 pNear->EnqueueForDelete(); 69 } 70 } 69 71 #ifdef LOG_CONSTRUCTOR_DESTRUCTOR 70 72 FINEST("Protocol with id %d of type %s deleted; F: %p,N: %p, DF: %d, DN: %d", … … 72 74 _pFarProtocol, _pNearProtocol, _deleteFar, _deleteNear); 73 75 #endif 74 if (_pApplication != NULL) {75 _pApplication->UnRegisterProtocol(this);76 _pApplication = NULL;77 }78 76 ProtocolManager::UnRegisterProtocol(this); 79 77 } … … 330 328 331 329 void BaseProtocol::SetApplication(BaseClientApplication *pApplication) { 330 //1. Get the old and the new application name and id 331 string oldAppName = "(none)"; 332 uint32_t oldAppId = 0; 333 string newAppName = "(none)"; 334 uint32_t newAppId = 0; 335 if (_pApplication != NULL) { 336 oldAppName = _pApplication->GetName(); 337 oldAppId = _pApplication->GetId(); 338 } 339 if (pApplication != NULL) { 340 newAppName = pApplication->GetName(); 341 newAppId = pApplication->GetId(); 342 } 343 344 //2. Are we landing on the same application? 345 if (oldAppId == newAppId) { 346 return; 347 } 348 349 //3. If the application is the same, return. Otherwise, unregister 332 350 if (_pApplication != NULL) { 333 351 _pApplication->UnRegisterProtocol(this); 334 352 _pApplication = NULL; 335 353 } 354 355 //4. Setup the new application 336 356 _pApplication = pApplication; 337 _pApplication->RegisterProtocol(this); 338 } 339 340 void BaseProtocol::ResetApplication() { 341 _pApplication = NULL; 357 358 //5. Register to it 359 if (_pApplication != NULL) { 360 _pApplication->RegisterProtocol(this); 361 } 362 363 //6. Trigger log to production 364 // FINEST("********** %s -> %s ********** %s", STR(oldAppName), STR(newAppName), 365 // STR(*this)); 342 366 } 343 367 -
trunk/sources/thelib/src/protocols/protocolmanager.cpp
r2 r142 1 1 /* 2 * Copyright (c) 2010,3 * Gavriloaie Eugen-Andrei (shiretu@gmail.com)4 * 5 * This file is part of crtmpserver.6 * crtmpserver is free software: you can redistribute it and/or modify7 * it under the terms of the GNU General Public License as published by8 * the Free Software Foundation, either version 3 of the License, or9 * (at your option) any later version.10 * 11 * crtmpserver is distributed in the hope that it will be useful,12 * but WITHOUT ANY WARRANTY; without even the implied warranty of13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14 * GNU General Public License for more details.15 * 16 * You should have received a copy of the GNU General Public License17 * along with crtmpserver. If not, see <http://www.gnu.org/licenses/>.18 */2 * Copyright (c) 2010, 3 * Gavriloaie Eugen-Andrei (shiretu@gmail.com) 4 * 5 * This file is part of crtmpserver. 6 * crtmpserver is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * crtmpserver is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with crtmpserver. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 19 20 20 … … 26 26 27 27 void ProtocolManager::RegisterProtocol(BaseProtocol *pProtocol) { 28 if (MAP_HAS1(_activeProtocols, pProtocol->GetId()))29 return;30 if (MAP_HAS1(_deadProtocols, pProtocol->GetId()))31 return;32 _activeProtocols[pProtocol->GetId()] = pProtocol;28 if (MAP_HAS1(_activeProtocols, pProtocol->GetId())) 29 return; 30 if (MAP_HAS1(_deadProtocols, pProtocol->GetId())) 31 return; 32 _activeProtocols[pProtocol->GetId()] = pProtocol; 33 33 } 34 34 35 35 void ProtocolManager::UnRegisterProtocol(BaseProtocol *pProtocol) { 36 if (MAP_HAS1(_activeProtocols, pProtocol->GetId()))37 _activeProtocols.erase(pProtocol->GetId());38 if (MAP_HAS1(_deadProtocols, pProtocol->GetId()))39 _deadProtocols.erase(pProtocol->GetId());36 if (MAP_HAS1(_activeProtocols, pProtocol->GetId())) 37 _activeProtocols.erase(pProtocol->GetId()); 38 if (MAP_HAS1(_deadProtocols, pProtocol->GetId())) 39 _deadProtocols.erase(pProtocol->GetId()); 40 40 } 41 41 42 42 void ProtocolManager::EnqueueForDelete(BaseProtocol *pProtocol) { 43 FINEST("Enqueue for delete for protool %s", STR(*pProtocol)); 44 if (MAP_HAS1(_activeProtocols, pProtocol->GetId())) 45 _activeProtocols.erase(pProtocol->GetId()); 46 if (!MAP_HAS1(_deadProtocols, pProtocol->GetId())) 47 _deadProtocols[pProtocol->GetId()] = pProtocol; 43 FINEST("Enqueue for delete for protool %s", STR(*pProtocol)); 44 pProtocol->SetApplication(NULL); 45 if (MAP_HAS1(_activeProtocols, pProtocol->GetId())) 46 _activeProtocols.erase(pProtocol->GetId()); 47 if (!MAP_HAS1(_deadProtocols, pProtocol->GetId())) 48 _deadProtocols[pProtocol->GetId()] = pProtocol; 48 49 } 49 50 50 51 void ProtocolManager::CleanupDeadProtocols() { 51 while (_deadProtocols.size() > 0) {52 BaseProtocol *pBaseProtocol = MAP_VAL(_deadProtocols.begin());53 delete pBaseProtocol;54 }52 while (_deadProtocols.size() > 0) { 53 BaseProtocol *pBaseProtocol = MAP_VAL(_deadProtocols.begin()); 54 delete pBaseProtocol; 55 } 55 56 } 56 57 57 58 void ProtocolManager::Shutdown() { 58 while (_activeProtocols.size() > 0) {59 EnqueueForDelete(MAP_VAL(_activeProtocols.begin()));60 }59 while (_activeProtocols.size() > 0) { 60 EnqueueForDelete(MAP_VAL(_activeProtocols.begin())); 61 } 61 62 } 62 63 63 64 BaseProtocol * ProtocolManager::GetProtocol(uint32_t id, 64 bool includeDeadProtocols) {65 if (!includeDeadProtocols && MAP_HAS1(_deadProtocols, id))66 return NULL;67 if (MAP_HAS1(_activeProtocols, id))68 return _activeProtocols[id];69 if (MAP_HAS1(_deadProtocols, id))70 return _deadProtocols[id];71 return NULL;65 bool includeDeadProtocols) { 66 if (!includeDeadProtocols && MAP_HAS1(_deadProtocols, id)) 67 return NULL; 68 if (MAP_HAS1(_activeProtocols, id)) 69 return _activeProtocols[id]; 70 if (MAP_HAS1(_deadProtocols, id)) 71 return _deadProtocols[id]; 72 return NULL; 72 73 } 73 74 -
trunk/sources/thelib/src/protocols/rtmp/basertmpappprotocolhandler.cpp
r140 r142 54 54 55 55 FOR_MAP(_connections, uint32_t, BaseRTMPProtocol *, i) { 56 MAP_VAL(i)-> ResetApplication();56 MAP_VAL(i)->SetApplication(NULL); 57 57 MAP_VAL(i)->EnqueueForDelete(); 58 58 } -
trunk/sources/thelib/src/protocols/rtmp/basertmpprotocol.cpp
r131 r142 74 74 _inboundChunkSize = 128; 75 75 _outboundChunkSize = 128; 76 _pApplication = ClientApplicationManager::GetDefaultApplication();77 76 78 77 for (uint32_t i = 0; i < MAX_STREAMS_COUNT; i++) { … … 88 87 89 88 BaseRTMPProtocol::~BaseRTMPProtocol() { 90 if (_pApplication != NULL) {91 _pApplication->UnRegisterProtocol(this);92 _pProtocolHandler = NULL;93 _pApplication = NULL;94 }95 89 for (uint32_t i = 0; i < MAX_STREAMS_COUNT; i++) { 96 90 if (_streams[i] != NULL) { … … 190 184 191 185 void BaseRTMPProtocol::SetApplication(BaseClientApplication *pApplication) { 192 assert(pApplication != NULL);193 186 BaseProtocol::SetApplication(pApplication); 194 _pProtocolHandler = (BaseRTMPAppProtocolHandler *) 195 _pApplication->GetProtocolHandler(this); 196 } 197 198 void BaseRTMPProtocol::ResetApplication() { 199 BaseProtocol::ResetApplication(); 200 _pProtocolHandler = NULL; 187 if (pApplication != NULL) { 188 _pProtocolHandler = (BaseRTMPAppProtocolHandler *) 189 pApplication->GetProtocolHandler(this); 190 } else { 191 _pProtocolHandler = NULL; 192 } 201 193 } 202 194 … … 780 772 if (H_ML(header) == channel.lastInProcBytes) { 781 773 channel.lastInProcBytes = 0; 782 if (_p Application == NULL || _pProtocolHandler == NULL) {774 if (_pProtocolHandler == NULL) { 783 775 FATAL("RTMP connection no longer associated with an application"); 784 776 return false; -
trunk/sources/thelib/src/protocols/rtp/rtspprotocol.cpp
r131 r142 71 71 void RTSPProtocol::SetApplication(BaseClientApplication *pApplication) { 72 72 BaseProtocol::SetApplication(pApplication); 73 _pProtocolHandler = (BaseRTSPAppProtocolHandler *) 74 _pApplication->GetProtocolHandler(GetType()); 75 if (_pProtocolHandler == NULL) { 76 FATAL("Protocol handler not found"); 77 EnqueueForDelete(); 73 if (pApplication != NULL) { 74 _pProtocolHandler = (BaseRTSPAppProtocolHandler *) 75 pApplication->GetProtocolHandler(GetType()); 76 if (_pProtocolHandler == NULL) { 77 FATAL("Protocol handler not found"); 78 EnqueueForDelete(); 79 } 80 } else { 81 _pProtocolHandler = NULL; 78 82 } 79 83 } -
trunk/sources/thelib/src/protocols/tcpprotocol.cpp
r2 r142 1 1 /* 2 * Copyright (c) 2010,3 * Gavriloaie Eugen-Andrei (shiretu@gmail.com)4 * 5 * This file is part of crtmpserver.6 * crtmpserver is free software: you can redistribute it and/or modify7 * it under the terms of the GNU General Public License as published by8 * the Free Software Foundation, either version 3 of the License, or9 * (at your option) any later version.10 * 11 * crtmpserver is distributed in the hope that it will be useful,12 * but WITHOUT ANY WARRANTY; without even the implied warranty of13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14 * GNU General Public License for more details.15 * 16 * You should have received a copy of the GNU General Public License17 * along with crtmpserver. If not, see <http://www.gnu.org/licenses/>.18 */2 * Copyright (c) 2010, 3 * Gavriloaie Eugen-Andrei (shiretu@gmail.com) 4 * 5 * This file is part of crtmpserver. 6 * crtmpserver is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * crtmpserver is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with crtmpserver. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 19 20 20 … … 24 24 TCPProtocol::TCPProtocol() 25 25 : BaseProtocol(PT_TCP) { 26 _decodedBytesCount = 0;27 _pCarrier = NULL;26 _decodedBytesCount = 0; 27 _pCarrier = NULL; 28 28 } 29 29 30 30 TCPProtocol::~TCPProtocol() { 31 if (_pCarrier != NULL) { 32 IOHandler *pCarrier = _pCarrier; 33 _pCarrier = NULL; 34 if (pCarrier->GetType() == IOHT_TCP_CARRIER) 35 ((TCPCarrier *) pCarrier)->ResetProtocol(); 36 if (pCarrier->GetType() == IOHT_STDIO) 37 ((StdioCarrier *) pCarrier)->ResetProtocol(); 38 delete pCarrier; 39 } 31 if (_pCarrier != NULL) { 32 IOHandler *pCarrier = _pCarrier; 33 _pCarrier = NULL; 34 pCarrier->SetProtocol(NULL); 35 delete pCarrier; 36 } 40 37 } 41 38 42 39 bool TCPProtocol::Initialize(Variant ¶meters) { 43 return true;40 return true; 44 41 } 45 42 46 43 IOHandler *TCPProtocol::GetIOHandler() { 47 return _pCarrier;44 return _pCarrier; 48 45 } 49 46 50 47 void TCPProtocol::SetIOHandler(IOHandler *pIOHandler) { 51 if (pIOHandler != NULL) {52 if ((pIOHandler->GetType() != IOHT_TCP_CARRIER)53 && (pIOHandler->GetType() != IOHT_STDIO)) {54 ASSERT("This protocol accepts only TCP carriers");55 }56 }57 _pCarrier = pIOHandler;48 if (pIOHandler != NULL) { 49 if ((pIOHandler->GetType() != IOHT_TCP_CARRIER) 50 && (pIOHandler->GetType() != IOHT_STDIO)) { 51 ASSERT("This protocol accepts only TCP carriers"); 52 } 53 } 54 _pCarrier = pIOHandler; 58 55 } 59 56 60 57 bool TCPProtocol::AllowFarProtocol(uint64_t type) { 61 WARN("This protocol doesn't accept any far protocol");62 return false;58 WARN("This protocol doesn't accept any far protocol"); 59 return false; 63 60 } 64 61 65 62 bool TCPProtocol::AllowNearProtocol(uint64_t type) { 66 // if (67 // type == PT_INBOUNDRTMP ||68 // type == PT_OUTBOUNDRTMP ||69 // type == PT_RTMPE ||70 // type == PT_SSL ||71 // type == PT_INBOUNDDNS ||72 // type == PT_OUTBOUNDDNS ||73 // type == PT_INBOUNDTS ||74 // type == PT_INBOUNDHTTP ||75 // type == PT_OUTBOUNDHTTP ||76 // false77 // )78 // return true;79 // WARN("Near protocol %s not accepted by %s",80 // STR(tagToString(type)),81 // STR(tagToString(_type)));82 // return false;83 return true;63 // if ( 64 // type == PT_INBOUNDRTMP || 65 // type == PT_OUTBOUNDRTMP || 66 // type == PT_RTMPE || 67 // type == PT_SSL || 68 // type == PT_INBOUNDDNS || 69 // type == PT_OUTBOUNDDNS || 70 // type == PT_INBOUNDTS || 71 // type == PT_INBOUNDHTTP || 72 // type == PT_OUTBOUNDHTTP || 73 // false 74 // ) 75 // return true; 76 // WARN("Near protocol %s not accepted by %s", 77 // STR(tagToString(type)), 78 // STR(tagToString(_type))); 79 // return false; 80 return true; 84 81 } 85 82 86 83 IOBuffer * TCPProtocol::GetInputBuffer() { 87 return &_inputBuffer;84 return &_inputBuffer; 88 85 } 89 86 90 87 bool TCPProtocol::SignalInputData(int32_t recvAmount) { 91 _decodedBytesCount += recvAmount;92 //FINEST("_decodedBytesCount: %d", _decodedBytesCount);93 return _pNearProtocol->SignalInputData(_inputBuffer);88 _decodedBytesCount += recvAmount; 89 //FINEST("_decodedBytesCount: %d", _decodedBytesCount); 90 return _pNearProtocol->SignalInputData(_inputBuffer); 94 91 } 95 92 96 93 bool TCPProtocol::SignalInputData(IOBuffer & /* ignored */) { 97 ASSERT("OPERATION NOT SUPPORTED");94 ASSERT("OPERATION NOT SUPPORTED"); 98 95 return false; 99 96 } 100 97 101 98 bool TCPProtocol::EnqueueForOutbound() { 102 if (_pCarrier == NULL) {103 ASSERT("TCPProtocol has no carrier");104 return false;105 }106 return _pCarrier->SignalOutputData();99 if (_pCarrier == NULL) { 100 ASSERT("TCPProtocol has no carrier"); 101 return false; 102 } 103 return _pCarrier->SignalOutputData(); 107 104 } 108 105 109 106 uint32_t TCPProtocol::GetDecodedBytesCount() { 110 return _decodedBytesCount;107 return _decodedBytesCount; 111 108 } 112 109 -
trunk/sources/thelib/src/protocols/timer/basetimerprotocol.cpp
r56 r142 24 24 BaseTimerProtocol::BaseTimerProtocol() 25 25 : BaseProtocol(PT_TIMER) { 26 _pTimer = new IOTimer(this); 26 _pTimer = new IOTimer(); 27 _pTimer->SetProtocol(this); 27 28 } 28 29 … … 31 32 IOTimer *pTimer = _pTimer; 32 33 _pTimer = NULL; 33 pTimer-> ResetProtocol();34 pTimer->SetProtocol(NULL); 34 35 delete pTimer; 35 36 } -
trunk/sources/thelib/src/protocols/ts/inboundtsprotocol.cpp
r56 r142 143 143 144 144 void InboundTSProtocol::SetApplication(BaseClientApplication *pApplication) { 145 assert(pApplication != NULL);146 145 BaseProtocol::SetApplication(pApplication); 147 _pProtocolHandler = (BaseTSAppProtocolHandler *) 148 _pApplication->GetProtocolHandler(this); 149 } 150 151 void InboundTSProtocol::ResetApplication() { 152 BaseProtocol::ResetApplication(); 153 _pProtocolHandler = NULL; 146 if (pApplication != NULL) { 147 _pProtocolHandler = (BaseTSAppProtocolHandler *) 148 pApplication->GetProtocolHandler(this); 149 } else { 150 _pProtocolHandler = NULL; 151 } 154 152 } 155 153 -
trunk/sources/thelib/src/protocols/udpprotocol.cpp
r2 r142 32 32 IOHandler *pCarrier = _pCarrier; 33 33 _pCarrier = NULL; 34 ((UDPCarrier *) pCarrier)->ResetProtocol();34 pCarrier->SetProtocol(NULL); 35 35 delete pCarrier; 36 36 } -
trunk/sources/thelib/src/protocols/variant/basevariantprotocol.cpp
r17 r142 39 39 40 40 void BaseVariantProtocol::SetApplication(BaseClientApplication *pApplication) { 41 if (pApplication == NULL)42 return;43 41 BaseProtocol::SetApplication(pApplication); 44 _pProtocolHandler = (BaseVariantAppProtocolHandler *) 45 _pApplication->GetProtocolHandler(this); 42 if (pApplication != NULL) { 43 _pProtocolHandler = (BaseVariantAppProtocolHandler *) 44 pApplication->GetProtocolHandler(this); 45 } else { 46 _pProtocolHandler = NULL; 47 } 46 48 } 47 49
Note: See TracChangeset
for help on using the changeset viewer.
