From a323483bea377ac233774ac25d9ad48b29bd9bf6 Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 19 Oct 2013 08:42:21 +0800 Subject: [PATCH] add protocol stack --- trunk/configure | 2 +- trunk/src/core/srs_core_client.cpp | 7 +++++ trunk/src/core/srs_core_protocol.cpp | 39 ++++++++++++++++++++++++ trunk/src/core/srs_core_protocol.hpp | 45 ++++++++++++++++++++++++++++ trunk/src/core/srs_core_rtmp.cpp | 13 +++++++- trunk/src/core/srs_core_rtmp.hpp | 11 +++++++ trunk/src/srs/srs.upp | 2 ++ 7 files changed, 117 insertions(+), 2 deletions(-) create mode 100755 trunk/src/core/srs_core_protocol.cpp create mode 100755 trunk/src/core/srs_core_protocol.hpp diff --git a/trunk/configure b/trunk/configure index ec2872b0b..504b62f81 100755 --- a/trunk/configure +++ b/trunk/configure @@ -85,7 +85,7 @@ ModuleLibIncs=(${LibSTRoot}) MODULE_FILES=("srs_core" "srs_core_log" "srs_core_server" "srs_core_error" "srs_core_conn" "srs_core_client" "srs_core_rtmp" "srs_core_socket" "srs_core_buffer" - "srs_core_auto_free") + "srs_core_auto_free" "srs_core_protocol") MODULE_DIR="src/core" . auto/modules.sh CORE_OBJS="${MODULE_OBJS[@]}" diff --git a/trunk/src/core/srs_core_client.cpp b/trunk/src/core/srs_core_client.cpp index 4efa04848..bc9baca39 100755 --- a/trunk/src/core/srs_core_client.cpp +++ b/trunk/src/core/srs_core_client.cpp @@ -65,6 +65,13 @@ int SrsClient::do_cycle() } srs_verbose("rtmp handshake success"); + SrsApp* app = NULL; + if ((ret = rtmp->connect_app(&app)) != ERROR_SUCCESS) { + srs_warn("rtmp connect vhost/app failed. ret=%d", ret); + return ret; + } + srs_verbose("rtmp connect vhost/app success"); + return ret; } diff --git a/trunk/src/core/srs_core_protocol.cpp b/trunk/src/core/srs_core_protocol.cpp new file mode 100755 index 000000000..9eb2ce52b --- /dev/null +++ b/trunk/src/core/srs_core_protocol.cpp @@ -0,0 +1,39 @@ +/* +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 + +#include +#include +#include +#include + +SrsProtocol::SrsProtocol(st_netfd_t client_stfd) +{ + stfd = client_stfd; +} + +SrsProtocol::~SrsProtocol() +{ +} + diff --git a/trunk/src/core/srs_core_protocol.hpp b/trunk/src/core/srs_core_protocol.hpp new file mode 100755 index 000000000..7f8cf1460 --- /dev/null +++ b/trunk/src/core/srs_core_protocol.hpp @@ -0,0 +1,45 @@ +/* +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_PROTOCOL_HPP +#define SRS_CORE_PROTOCOL_HPP + +/* +#include +*/ + +#include + +#include + +class SrsProtocol +{ +private: + st_netfd_t stfd; +public: + SrsProtocol(st_netfd_t client_stfd); + virtual ~SrsProtocol(); +public: +}; + +#endif \ No newline at end of file diff --git a/trunk/src/core/srs_core_rtmp.cpp b/trunk/src/core/srs_core_rtmp.cpp index 60b1387d7..5c4560f71 100755 --- a/trunk/src/core/srs_core_rtmp.cpp +++ b/trunk/src/core/srs_core_rtmp.cpp @@ -25,17 +25,22 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include -#include #include +#include #include SrsRtmp::SrsRtmp(st_netfd_t client_stfd) { + protocol = new SrsProtocol(client_stfd); stfd = client_stfd; } SrsRtmp::~SrsRtmp() { + if (protocol) { + delete protocol; + protocol = NULL; + } } int SrsRtmp::handshake() @@ -83,3 +88,9 @@ int SrsRtmp::handshake() return ret; } +int SrsRtmp::connect_app(SrsApp** papp) +{ + int ret = ERROR_SUCCESS; + return ret; +} + diff --git a/trunk/src/core/srs_core_rtmp.hpp b/trunk/src/core/srs_core_rtmp.hpp index d7b087138..c4a19a1e4 100755 --- a/trunk/src/core/srs_core_rtmp.hpp +++ b/trunk/src/core/srs_core_rtmp.hpp @@ -30,17 +30,28 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include +#include + #include +struct SrsApp +{ + std::string vhost; + std::string app; +}; + +class SrsProtocol; class SrsRtmp { private: + SrsProtocol* protocol; st_netfd_t stfd; public: SrsRtmp(st_netfd_t client_stfd); virtual ~SrsRtmp(); public: virtual int handshake(); + virtual int connect_app(SrsApp** papp); }; #endif \ No newline at end of file diff --git a/trunk/src/srs/srs.upp b/trunk/src/srs/srs.upp index 8ee01992e..ba3ed0bec 100755 --- a/trunk/src/srs/srs.upp +++ b/trunk/src/srs/srs.upp @@ -16,6 +16,8 @@ file ..\core\srs_core_client.cpp, ..\core\srs_core_rtmp.hpp, ..\core\srs_core_rtmp.cpp, + ..\core\srs_core_protocol.hpp, + ..\core\srs_core_protocol.cpp, ..\core\srs_core_socket.hpp, ..\core\srs_core_socket.cpp, ..\core\srs_core_buffer.hpp,