1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-15 04:42:04 +00:00

support config and reload the pithy print.

This commit is contained in:
winlin 2013-11-10 11:52:19 +08:00
parent 6c3b5943e9
commit 3669419e4c
20 changed files with 235 additions and 97 deletions

View file

@ -48,6 +48,7 @@ url: rtmp://127.0.0.1:1935/live/livestream
* nginx v1.5.0: 139524 lines <br/> * nginx v1.5.0: 139524 lines <br/>
### History ### History
* v0.4, 2013-11-10, support config and reload the pithy print.
* v0.4, 2013-11-09, support reload config(vhost and its detail). * v0.4, 2013-11-09, support reload config(vhost and its detail).
* v0.4, 2013-11-09, support reload config(listen and chunk_size) by SIGHUP(1). * v0.4, 2013-11-09, support reload config(listen and chunk_size) by SIGHUP(1).
* v0.4, 2013-11-09, support longtime(>4.6hours) publish/play. * v0.4, 2013-11-09, support longtime(>4.6hours) publish/play.

BIN
trunk/3rdparty/http-parser-2.1.zip vendored Normal file

Binary file not shown.

0
trunk/auto/modules.sh Normal file → Executable file
View file

View file

@ -47,4 +47,15 @@ vhost refer.anti_suck.com {
# default: not specified. # default: not specified.
refer_play github.com github.io; refer_play github.com github.io;
} }
# config for the pithy print,
# which always print constant message specified by interval,
# whatever the clients in concurrency.
pithy_print {
# shared print interval for all publish clients, in milliseconds.
# if not specified, set to 1100.
publish 2000;
# shared print interval for all play clients, in milliseconds.
# if not specified, set to 1300.
play 3000;
}

49
trunk/configure vendored
View file

@ -16,13 +16,36 @@ if [[ -f ${GLOBAL_DIR_OBJS}/st-1.9/obj/libst.a && -f ${GLOBAL_DIR_OBJS}/st-1.9/o
echo "st-1.9t is ok."; echo "st-1.9t is ok.";
else else
echo "build st-1.9t"; echo "build st-1.9t";
(rm -rf ${GLOBAL_DIR_OBJS}/st-1.9 && cd ${GLOBAL_DIR_OBJS} && unzip ../3rdparty/st-1.9.zip && cd st-1.9 && make linux-debug) (
rm -rf ${GLOBAL_DIR_OBJS}/st-1.9 && cd ${GLOBAL_DIR_OBJS} &&
unzip -q ../3rdparty/st-1.9.zip && cd st-1.9 && make linux-debug &&
cd .. && rm -f st && ln -sf st-1.9/obj st
)
fi fi
# check status # check status
ret=$?; if [[ $ret -ne 0 ]]; then echo "build st-1.9 failed, ret=$ret"; exit $ret; fi ret=$?; if [[ $ret -ne 0 ]]; then echo "build st-1.9 failed, ret=$ret"; exit $ret; fi
if [ ! -f ${GLOBAL_DIR_OBJS}/st-1.9/obj/libst.a ]; then echo "build st-1.9 failed."; exit -1; fi if [ ! -f ${GLOBAL_DIR_OBJS}/st-1.9/obj/libst.a ]; then echo "build st-1.9 failed."; exit -1; fi
if [ ! -f ${GLOBAL_DIR_OBJS}/st-1.9/obj/libst.so ]; then echo "build st-1.9 failed."; exit -1; fi if [ ! -f ${GLOBAL_DIR_OBJS}/st-1.9/obj/libst.so ]; then echo "build st-1.9 failed."; exit -1; fi
# http-parser-2.1
if [[ -f ${GLOBAL_DIR_OBJS}/http-parser-2.1/http_parser.h && -f ${GLOBAL_DIR_OBJS}/http-parser-2.1/libhttp_parser.a ]]; then
echo "http-parser-2.1 is ok.";
else
echo "build http-parser-2.1";
(
rm -rf ${GLOBAL_DIR_OBJS}/http-parser-2.1 && cd ${GLOBAL_DIR_OBJS} && unzip -q ../3rdparty/http-parser-2.1.zip &&
cd http-parser-2.1 &&
sed -i "s/CPPFLAGS_FAST +=.*$/CPPFLAGS_FAST = \$\(CPPFLAGS_DEBUG\)/g" Makefile &&
sed -i "s/CFLAGS_FAST =.*$/CFLAGS_FAST = \$\(CFLAGS_DEBUG\)/g" Makefile &&
make package &&
cd .. && rm -f hp && ln -sf http-parser-2.1 hp
)
fi
# check status
ret=$?; if [[ $ret -ne 0 ]]; then echo "build http-parser-2.1 failed, ret=$ret"; exit $ret; fi
if [[ ! -f ${GLOBAL_DIR_OBJS}/http-parser-2.1/http_parser.h ]]; then echo "build http-parser-2.1 failed"; exit -1; fi
if [[ ! -f ${GLOBAL_DIR_OBJS}/http-parser-2.1/libhttp_parser.a ]]; then echo "build http-parser-2.1 failed"; exit -1; fi
##################################################################################### #####################################################################################
# generate Makefile. # generate Makefile.
##################################################################################### #####################################################################################
@ -53,18 +76,16 @@ END
echo 'generate Makefile ok!' echo 'generate Makefile ok!'
# the performance analysis, uncomments the following when use gperf to analysis the performance. see third-party/readme.txt # the performance analysis, uncomments the following when use gperf to analysis the performance. see third-party/readme.txt
#Performance="-pg" Performance="-pg"
#PerformanceLink="-pg"
# enable gdb debug # enable gdb debug
GDBDebug="-g -O0" GDBDebug="-g -O0"
# the warning level. # the warning level.
WarnLevel="-Wall -Wextra" WarnLevel="-Wall"
# the compile standard. # the compile standard.
CppStd="-std=c++98" CppStd="-ansi"
# other macros defined
UserMacros=""
# the cxx flag generated. # the cxx flag generated.
CXXFLAGS="${CppStd} ${WarnLevel} ${GDBDebug} ${Performance} ${UserMacros}" CXXFLAGS="${CppStd} ${WarnLevel} ${GDBDebug}"
#CXXFLAGS="${CppStd} ${WarnLevel} ${GDBDebug} ${Performance}"
cat << END > ${GLOBAL_DIR_OBJS}/${GLOBAL_FILE_MAKEFILE} cat << END > ${GLOBAL_DIR_OBJS}/${GLOBAL_FILE_MAKEFILE}
CXXFLAGS = ${CXXFLAGS} CXXFLAGS = ${CXXFLAGS}
GCC = g++ GCC = g++
@ -78,19 +99,21 @@ default:
END END
# Libraries # Libraries
LibSTRoot="${GLOBAL_DIR_OBJS}/st-1.9/obj" LibSTRoot="${GLOBAL_DIR_OBJS}/st"
LibSTfile="${LibSTRoot}/libst.a" LibSTfile="${LibSTRoot}/libst.a"
LibHttpParserRoot="${GLOBAL_DIR_OBJS}/hp"
LibHttpParserfile="${LibHttpParserRoot}/libhttp_parser.a"
#Core Module #Core Module
MODULE_ID="CORE" MODULE_ID="CORE"
MODULE_DEPENDS=() MODULE_DEPENDS=()
ModuleLibIncs=(${LibSTRoot}) ModuleLibIncs=(${LibSTRoot} ${LibHttpParserRoot})
MODULE_FILES=("srs_core" "srs_core_log" "srs_core_server" MODULE_FILES=("srs_core" "srs_core_log" "srs_core_server"
"srs_core_error" "srs_core_conn" "srs_core_client" "srs_core_error" "srs_core_conn" "srs_core_client"
"srs_core_rtmp" "srs_core_socket" "srs_core_buffer" "srs_core_rtmp" "srs_core_socket" "srs_core_buffer"
"srs_core_auto_free" "srs_core_protocol" "srs_core_amf0" "srs_core_autofree" "srs_core_protocol" "srs_core_amf0"
"srs_core_stream" "srs_core_source" "srs_core_codec" "srs_core_stream" "srs_core_source" "srs_core_codec"
"srs_core_complex_handshake" "srs_core_pithy_print" "srs_core_handshake" "srs_core_pithy_print"
"srs_core_config" "srs_core_refer" "srs_core_reload") "srs_core_config" "srs_core_refer" "srs_core_reload")
MODULE_DIR="src/core" . auto/modules.sh MODULE_DIR="src/core" . auto/modules.sh
CORE_OBJS="${MODULE_OBJS[@]}" CORE_OBJS="${MODULE_OBJS[@]}"
@ -107,7 +130,7 @@ MAIN_OBJS="${MODULE_OBJS[@].o}"
MAIN_ENTRANCES=("srs_main_server") MAIN_ENTRANCES=("srs_main_server")
# srs(simple rtmp server) over st(state-threads) # srs(simple rtmp server) over st(state-threads)
ModuleLibFiles=(${LibSTfile}) ModuleLibFiles=(${LibSTfile} ${LibHttpParserfile})
MODULE_OBJS="${CORE_OBJS[@]} ${CONFIG_OBJS[@]} ${PROTOCOL_OBJS[@]} ${MAIN_OBJS[@]}" MODULE_OBJS="${CORE_OBJS[@]} ${CONFIG_OBJS[@]} ${PROTOCOL_OBJS[@]} ${MAIN_OBJS[@]}"
BUILD_KEY="simple_rtmp_server" APP_MAIN="srs_main_server" APP_NAME="simple_rtmp_server" LINK_OPTIONS="-ldl -lssl" SO_PATH="" . auto/apps.sh BUILD_KEY="simple_rtmp_server" APP_MAIN="srs_main_server" APP_NAME="simple_rtmp_server" LINK_OPTIONS="-ldl -lssl" SO_PATH="" . auto/apps.sh

View file

@ -21,4 +21,4 @@ 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. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <srs_core_auto_free.hpp> #include <srs_core_autofree.hpp>

View file

@ -25,7 +25,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define SRS_CORE_AUTO_FREE_HPP #define SRS_CORE_AUTO_FREE_HPP
/* /*
#include <srs_core_auto_free.hpp> #include <srs_core_autofree.hpp>
*/ */
#include <srs_core.hpp> #include <srs_core.hpp>

View file

@ -30,7 +30,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_core_log.hpp> #include <srs_core_log.hpp>
#include <srs_core_rtmp.hpp> #include <srs_core_rtmp.hpp>
#include <srs_core_protocol.hpp> #include <srs_core_protocol.hpp>
#include <srs_core_auto_free.hpp> #include <srs_core_autofree.hpp>
#include <srs_core_source.hpp> #include <srs_core_source.hpp>
#include <srs_core_server.hpp> #include <srs_core_server.hpp>
#include <srs_core_pithy_print.hpp> #include <srs_core_pithy_print.hpp>

View file

@ -38,7 +38,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_core_error.hpp> #include <srs_core_error.hpp>
#include <srs_core_log.hpp> #include <srs_core_log.hpp>
#include <srs_core_auto_free.hpp> #include <srs_core_autofree.hpp>
#define FILE_OFFSET(fd) lseek(fd, 0, SEEK_CUR) #define FILE_OFFSET(fd) lseek(fd, 0, SEEK_CUR)
@ -455,6 +455,18 @@ int SrsConfig::reload()
return ret; return ret;
} }
} }
srs_trace("reload listen success.");
}
// merge config: pithy_print
if (!srs_directive_equals(root->get("pithy_print"), old_root->get("pithy_print"))) {
for (it = subscribes.begin(); it != subscribes.end(); ++it) {
SrsReloadHandler* subscribe = *it;
if ((ret = subscribe->on_reload_pithy_print()) != ERROR_SUCCESS) {
srs_error("notify subscribes pithy_print listen failed. ret=%d", ret);
return ret;
}
}
srs_trace("reload pithy_print success.");
} }
return ret; return ret;
@ -593,6 +605,26 @@ SrsConfDirective* SrsConfig::get_chunk_size()
return root->get("chunk_size"); return root->get("chunk_size");
} }
SrsConfDirective* SrsConfig::get_pithy_print_publish()
{
SrsConfDirective* pithy = root->get("pithy_print");
if (!pithy) {
return NULL;
}
return pithy->get("publish");
}
SrsConfDirective* SrsConfig::get_pithy_print_play()
{
SrsConfDirective* pithy = root->get("pithy_print");
if (!pithy) {
return NULL;
}
return pithy->get("play");
}
int SrsConfig::parse_file(const char* filename) int SrsConfig::parse_file(const char* filename)
{ {
int ret = ERROR_SUCCESS; int ret = ERROR_SUCCESS;

View file

@ -114,6 +114,8 @@ public:
virtual SrsConfDirective* get_refer_publish(std::string vhost); virtual SrsConfDirective* get_refer_publish(std::string vhost);
virtual SrsConfDirective* get_listen(); virtual SrsConfDirective* get_listen();
virtual SrsConfDirective* get_chunk_size(); virtual SrsConfDirective* get_chunk_size();
virtual SrsConfDirective* get_pithy_print_publish();
virtual SrsConfDirective* get_pithy_print_play();
private: private:
virtual int parse_file(const char* filename); virtual int parse_file(const char* filename);
virtual int parse_argv(int& i, char** argv); virtual int parse_argv(int& i, char** argv);

View file

@ -21,14 +21,14 @@ 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. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <srs_core_complex_handshake.hpp> #include <srs_core_handshake.hpp>
#include <time.h> #include <time.h>
#include <stdlib.h> #include <stdlib.h>
#include <srs_core_error.hpp> #include <srs_core_error.hpp>
#include <srs_core_log.hpp> #include <srs_core_log.hpp>
#include <srs_core_auto_free.hpp> #include <srs_core_autofree.hpp>
#include <srs_core_socket.hpp> #include <srs_core_socket.hpp>
// 68bytes FMS key which is used to sign the sever packet. // 68bytes FMS key which is used to sign the sever packet.
@ -1058,6 +1058,72 @@ void c1s1::destroy_blocks()
} }
} }
SrsSimpleHandshake::SrsSimpleHandshake()
{
}
SrsSimpleHandshake::~SrsSimpleHandshake()
{
}
int SrsSimpleHandshake::handshake(SrsSocket& skt)
{
int ret = ERROR_SUCCESS;
ssize_t nsize;
char* c0c1 = new char[1537];
SrsAutoFree(char, c0c1, true);
if ((ret = skt.read_fully(c0c1, 1537, &nsize)) != ERROR_SUCCESS) {
srs_warn("read c0c1 failed. ret=%d", ret);
return ret;
}
srs_verbose("read c0c1 success.");
// plain text required.
if (c0c1[0] != 0x03) {
ret = ERROR_RTMP_PLAIN_REQUIRED;
srs_warn("only support rtmp plain text. ret=%d", ret);
return ret;
}
srs_verbose("check c0 success, required plain text.");
// try complex handshake
SrsComplexHandshake complex_handshake;
ret = complex_handshake.handshake(skt, c0c1 + 1);
if (ret == ERROR_SUCCESS) {
srs_trace("complex handshake success.");
return ret;
}
if (ret != ERROR_RTMP_TRY_SIMPLE_HS) {
srs_error("complex handshake failed. ret=%d", ret);
return ret;
}
srs_info("complex handhskae failed, try simple. ret=%d", ret);
char* s0s1s2 = new char[3073];
SrsAutoFree(char, s0s1s2, true);
// plain text required.
s0s1s2[0] = 0x03;
if ((ret = skt.write(s0s1s2, 3073, &nsize)) != ERROR_SUCCESS) {
srs_warn("simple handshake send s0s1s2 failed. ret=%d", ret);
return ret;
}
srs_verbose("simple handshake send s0s1s2 success.");
char* c2 = new char[1536];
SrsAutoFree(char, c2, true);
if ((ret = skt.read_fully(c2, 1536, &nsize)) != ERROR_SUCCESS) {
srs_warn("simple handshake read c2 failed. ret=%d", ret);
return ret;
}
srs_verbose("simple handshake read c2 success.");
srs_trace("simple handshake success.");
return ret;
}
SrsComplexHandshake::SrsComplexHandshake() SrsComplexHandshake::SrsComplexHandshake()
{ {
} }

View file

@ -21,8 +21,8 @@ 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. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#ifndef SRS_CORE_COMPLEX_HANDSHKAE_HPP #ifndef SRS_CORE_HANDSHKAE_HPP
#define SRS_CORE_COMPLEX_HANDSHKAE_HPP #define SRS_CORE_HANDSHKAE_HPP
/* /*
#include <srs_core_complex_handshake.hpp> #include <srs_core_complex_handshake.hpp>
@ -32,6 +32,21 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
class SrsSocket; class SrsSocket;
/**
* try complex handshake, if failed, fallback to simple handshake.
*/
class SrsSimpleHandshake
{
public:
SrsSimpleHandshake();
virtual ~SrsSimpleHandshake();
public:
/**
* simple handshake.
*/
virtual int handshake(SrsSocket& skt);
};
/** /**
* rtmp complex handshake, * rtmp complex handshake,
* @see also crtmp(crtmpserver) or librtmp, * @see also crtmp(crtmpserver) or librtmp,

View file

@ -23,15 +23,19 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_core_pithy_print.hpp> #include <srs_core_pithy_print.hpp>
#include <stdlib.h>
#include <map> #include <map>
#include <srs_core_log.hpp> #include <srs_core_log.hpp>
#include <srs_core_config.hpp>
#include <srs_core_reload.hpp>
#include <srs_core_error.hpp>
#define SRS_STAGE_DEFAULT_INTERVAL_MS 1200 #define SRS_STAGE_DEFAULT_INTERVAL_MS 1200
#define SRS_STAGE_PLAY_USER_INTERVAL_MS 1300 #define SRS_STAGE_PLAY_USER_INTERVAL_MS 1300
#define SRS_STAGE_PUBLISH_USER_INTERVAL_MS 1100 #define SRS_STAGE_PUBLISH_USER_INTERVAL_MS 1100
struct SrsStageInfo struct SrsStageInfo : public SrsReloadHandler
{ {
int stage_id; int stage_id;
int pithy_print_time_ms; int pithy_print_time_ms;
@ -40,19 +44,46 @@ struct SrsStageInfo
SrsStageInfo(int _stage_id) SrsStageInfo(int _stage_id)
{ {
stage_id = _stage_id; stage_id = _stage_id;
nb_clients = 0;
switch (_stage_id) { update_print_time();
case SRS_STAGE_PLAY_USER:
config->subscribe(this);
}
virtual ~SrsStageInfo()
{
config->unsubscribe(this);
}
void update_print_time()
{
switch (stage_id) {
case SRS_STAGE_PLAY_USER: {
pithy_print_time_ms = SRS_STAGE_PLAY_USER_INTERVAL_MS; pithy_print_time_ms = SRS_STAGE_PLAY_USER_INTERVAL_MS;
case SRS_STAGE_PUBLISH_USER: SrsConfDirective* conf = config->get_pithy_print_play();
pithy_print_time_ms = SRS_STAGE_PUBLISH_USER_INTERVAL_MS; if (conf && !conf->arg0().empty()) {
pithy_print_time_ms = ::atoi(conf->arg0().c_str());
}
break; break;
default: }
case SRS_STAGE_PUBLISH_USER: {
pithy_print_time_ms = SRS_STAGE_PUBLISH_USER_INTERVAL_MS;
SrsConfDirective* conf = config->get_pithy_print_publish();
if (conf && !conf->arg0().empty()) {
pithy_print_time_ms = ::atoi(conf->arg0().c_str());
}
break;
}
default: {
pithy_print_time_ms = SRS_STAGE_DEFAULT_INTERVAL_MS; pithy_print_time_ms = SRS_STAGE_DEFAULT_INTERVAL_MS;
break; break;
} }
}
nb_clients = 0; }
public:
virtual int on_reload_pithy_print()
{
update_print_time();
return ERROR_SUCCESS;
} }
}; };
static std::map<int, SrsStageInfo*> _srs_stages; static std::map<int, SrsStageInfo*> _srs_stages;

View file

@ -29,7 +29,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_core_socket.hpp> #include <srs_core_socket.hpp>
#include <srs_core_buffer.hpp> #include <srs_core_buffer.hpp>
#include <srs_core_stream.hpp> #include <srs_core_stream.hpp>
#include <srs_core_auto_free.hpp> #include <srs_core_autofree.hpp>
/**************************************************************************** /****************************************************************************
***************************************************************************** *****************************************************************************

View file

@ -35,7 +35,11 @@ SrsReloadHandler::~SrsReloadHandler()
int SrsReloadHandler::on_reload_listen() int SrsReloadHandler::on_reload_listen()
{ {
int ret = ERROR_SUCCESS; return ERROR_SUCCESS;
return ret; }
int SrsReloadHandler::on_reload_pithy_print()
{
return ERROR_SUCCESS;
} }

View file

@ -39,6 +39,7 @@ public:
virtual ~SrsReloadHandler(); virtual ~SrsReloadHandler();
public: public:
virtual int on_reload_listen(); virtual int on_reload_listen();
virtual int on_reload_pithy_print();
}; };
#endif #endif

View file

@ -27,9 +27,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_core_error.hpp> #include <srs_core_error.hpp>
#include <srs_core_socket.hpp> #include <srs_core_socket.hpp>
#include <srs_core_protocol.hpp> #include <srs_core_protocol.hpp>
#include <srs_core_auto_free.hpp> #include <srs_core_autofree.hpp>
#include <srs_core_amf0.hpp> #include <srs_core_amf0.hpp>
#include <srs_core_complex_handshake.hpp> #include <srs_core_handshake.hpp>
/** /**
* the signature for packets to client. * the signature for packets to client.
@ -167,13 +167,11 @@ SrsRtmp::SrsRtmp(st_netfd_t client_stfd)
{ {
protocol = new SrsProtocol(client_stfd); protocol = new SrsProtocol(client_stfd);
stfd = client_stfd; stfd = client_stfd;
complex_handshake = new SrsComplexHandshake();
} }
SrsRtmp::~SrsRtmp() SrsRtmp::~SrsRtmp()
{ {
srs_freep(protocol); srs_freep(protocol);
srs_freep(complex_handshake);
} }
void SrsRtmp::set_recv_timeout(int64_t timeout_us) void SrsRtmp::set_recv_timeout(int64_t timeout_us)
@ -225,56 +223,12 @@ int SrsRtmp::handshake()
{ {
int ret = ERROR_SUCCESS; int ret = ERROR_SUCCESS;
ssize_t nsize;
SrsSocket skt(stfd); SrsSocket skt(stfd);
char* c0c1 = new char[1537]; SrsSimpleHandshake hs;
SrsAutoFree(char, c0c1, true); if ((ret = hs.handshake(skt)) != ERROR_SUCCESS) {
if ((ret = skt.read_fully(c0c1, 1537, &nsize)) != ERROR_SUCCESS) {
srs_warn("read c0c1 failed. ret=%d", ret);
return ret; return ret;
} }
srs_verbose("read c0c1 success.");
// plain text required.
if (c0c1[0] != 0x03) {
ret = ERROR_RTMP_PLAIN_REQUIRED;
srs_warn("only support rtmp plain text. ret=%d", ret);
return ret;
}
srs_verbose("check c0 success, required plain text.");
// try complex handshake
ret = complex_handshake->handshake(skt, c0c1 + 1);
if (ret == ERROR_SUCCESS) {
srs_trace("complex handshake success.");
return ret;
}
if (ret != ERROR_RTMP_TRY_SIMPLE_HS) {
srs_error("complex handshake failed. ret=%d", ret);
return ret;
}
srs_info("complex handhskae failed, try simple. ret=%d", ret);
char* s0s1s2 = new char[3073];
SrsAutoFree(char, s0s1s2, true);
// plain text required.
s0s1s2[0] = 0x03;
if ((ret = skt.write(s0s1s2, 3073, &nsize)) != ERROR_SUCCESS) {
srs_warn("simple handshake send s0s1s2 failed. ret=%d", ret);
return ret;
}
srs_verbose("simple handshake send s0s1s2 success.");
char* c2 = new char[1536];
SrsAutoFree(char, c2, true);
if ((ret = skt.read_fully(c2, 1536, &nsize)) != ERROR_SUCCESS) {
srs_warn("simple handshake read c2 failed. ret=%d", ret);
return ret;
}
srs_verbose("simple handshake read c2 success.");
srs_trace("simple handshake success.");
return ret; return ret;
} }

View file

@ -39,7 +39,6 @@ class ISrsMessage;
class SrsCommonMessage; class SrsCommonMessage;
class SrsCreateStreamPacket; class SrsCreateStreamPacket;
class SrsFMLEStartPacket; class SrsFMLEStartPacket;
class SrsComplexHandshake;
class SrsPublishPacket; class SrsPublishPacket;
/** /**
@ -101,7 +100,6 @@ enum SrsClientType
class SrsRtmp class SrsRtmp
{ {
private: private:
SrsComplexHandshake* complex_handshake;
SrsProtocol* protocol; SrsProtocol* protocol;
st_netfd_t stfd; st_netfd_t stfd;
public: public:

View file

@ -27,7 +27,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_core_log.hpp> #include <srs_core_log.hpp>
#include <srs_core_protocol.hpp> #include <srs_core_protocol.hpp>
#include <srs_core_auto_free.hpp> #include <srs_core_autofree.hpp>
#include <srs_core_amf0.hpp> #include <srs_core_amf0.hpp>
#include <srs_core_codec.hpp> #include <srs_core_codec.hpp>

View file

@ -6,8 +6,8 @@ file
..\core\srs_core.cpp, ..\core\srs_core.cpp,
..\core\srs_core_error.hpp, ..\core\srs_core_error.hpp,
..\core\srs_core_error.cpp, ..\core\srs_core_error.cpp,
..\core\srs_core_auto_free.hpp, ..\core\srs_core_autofree.hpp,
..\core\srs_core_auto_free.cpp, ..\core\srs_core_autofree.cpp,
..\core\srs_core_server.hpp, ..\core\srs_core_server.hpp,
..\core\srs_core_server.cpp, ..\core\srs_core_server.cpp,
..\core\srs_core_reload.hpp, ..\core\srs_core_reload.hpp,
@ -26,8 +26,8 @@ file
..\core\srs_core_codec.cpp, ..\core\srs_core_codec.cpp,
..\core\srs_core_rtmp.hpp, ..\core\srs_core_rtmp.hpp,
..\core\srs_core_rtmp.cpp, ..\core\srs_core_rtmp.cpp,
..\core\srs_core_complex_handshake.hpp, ..\core\srs_core_handshake.hpp,
..\core\srs_core_complex_handshake.cpp, ..\core\srs_core_handshake.cpp,
..\core\srs_core_protocol.hpp, ..\core\srs_core_protocol.hpp,
..\core\srs_core_protocol.cpp, ..\core\srs_core_protocol.cpp,
..\core\srs_core_amf0.hpp, ..\core\srs_core_amf0.hpp,