From 93c9c55fb9d3f8cb02ce5a714401c14bc7088901 Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 26 May 2014 15:54:39 +0800 Subject: [PATCH] remove the complex handshake of librtmp. refine makefile of librtmp tools --- trunk/research/librtmp/Makefile | 76 +++++++++++++--------------- trunk/research/librtmp/srs_play.c | 16 ++---- trunk/research/librtmp/srs_publish.c | 3 +- trunk/src/libs/srs_librtmp.cpp | 27 ---------- trunk/src/libs/srs_librtmp.hpp | 8 --- 5 files changed, 39 insertions(+), 91 deletions(-) mode change 100755 => 100644 trunk/research/librtmp/Makefile diff --git a/trunk/research/librtmp/Makefile b/trunk/research/librtmp/Makefile old mode 100755 new mode 100644 index ec2e30ca1..9caab7f05 --- a/trunk/research/librtmp/Makefile +++ b/trunk/research/librtmp/Makefile @@ -1,24 +1,26 @@ GCC = gcc +ifeq ($(HANDSHAKE),) + ST_ALL = help +else + ST_ALL = srs_flv_parser srs_publish srs_play srs_ingest_flv srs_ingest_rtmp +endif + .PHONY: default clean help ssl nossl -default: help +default: $(ST_ALL) help: - @echo "Usage: make ||||||||||" + @echo "Usage: make ||||||" @echo " help display this help" @echo " clean cleanup build" - @echo " ssl srs_flv_parser, srs_publish_ssl, srs_play_ssl, srs_ingest_flv, srs_ingest_rtmp" - @echo " nossl srs_flv_parser, srs_publish_nossl, srs_play_nossl, srs_ingest_flv, srs_ingest_rtmp" + @echo " ssl all tools link ssl" + @echo " nossl all tools never link ssl" @echo " srs_flv_parser parse flv file, print detail info." - @echo " srs_publish_nossl publish program using srs-librtmp, without ssl(simple handshake)" - @echo " srs_play_nossl play program using srs-librtmp, without ssl(simple handshake)" - @echo " srs_publish_ssl publish program using srs-librtmp, with ssl(complex handshake)" - @echo " srs_play_ssl play program using srs-librtmp, with ssl(complex handshake)" - @echo " srs_ingest_flv_nossl ingest flv file and publish to RTMP server. (simple handshake)" - @echo " srs_ingest_rtmp_nossl ingest RTMP and publish to RTMP server. (simple handshake)" - @echo " srs_ingest_flv_ssl ingest flv file and publish to RTMP server. (complex handshake)" - @echo " srs_ingest_rtmp_ssl ingest RTMP and publish to RTMP server. (complex handshake)" + @echo " srs_publish publish program using srs-librtmp" + @echo " srs_play play program using srs-librtmp" + @echo " srs_ingest_flv ingest flv file and publish to RTMP server." + @echo " srs_ingest_rtmp ingest RTMP and publish to RTMP server." @echo "Remark: about simple/complex handshake, see: http://blog.csdn.net/win_lin/article/details/13006803" @echo "Remark: srs Makefile will auto invoke this by --with/without-ssl, " @echo " that is, if user specified ssl(by --with-ssl), srs will make this by 'make ssl'" @@ -27,7 +29,7 @@ help: @echo "Remark: before make this sample, user must make the srs, with/without ssl" clean: - @rm -f srs_flv_parser srs_publish_nossl srs_play_nossl srs_publish_ssl srs_play_ssl srs_ingest_flv_ssl srs_ingest_rtmp_ssl srs_ingest_flv_nossl srs_ingest_rtmp_nossl + @rm -f srs_flv_parser srs_publish srs_play srs_ingest_flv srs_ingest_rtmp # srs library root SRS_OBJS = ../../objs @@ -35,7 +37,7 @@ SRS_OBJS = ../../objs SRS_LIBRTMP_I = $(SRS_OBJS)/include/srs_librtmp.h SRS_LIBRTMP_L = $(SRS_OBJS)/lib/srs_librtmp.a # openssl for complex handshake, built by srs. -SRS_LIBSSL_L = $(SRS_OBJS)/openssl/lib/libssl.a $(SRS_OBJS)/openssl/lib/libcrypto.a +SRS_LIBSSL_L = # the research public headers SRS_RESEARCH_DEPS = Makefile srs_research_public.h @@ -51,37 +53,27 @@ endif ifeq ($(GCC), mipsel-openwrt-linux-gcc) EXTRA_CXX_FLAG = -g -O0 -ldl -lstdc++ -lgcc_eh endif +# for ssl or nossl +ifeq ($(HANDSHAKE), SSL) + SRS_LIBSSL_L = $(SRS_OBJS)/openssl/lib/libssl.a $(SRS_OBJS)/openssl/lib/libcrypto.a +endif -srs_flv_parser_nossl: srs_flv_parser.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) - $(GCC) srs_flv_parser.c $(SRS_LIBRTMP_L) $(EXTRA_CXX_FLAG) -o srs_flv_parser_nossl +ssl: + $(MAKE) HANDSHAKE="SSL" +nossl: + $(MAKE) HANDSHAKE="NOSSL" -srs_publish_nossl: srs_publish.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) - $(GCC) srs_publish.c $(SRS_LIBRTMP_L) $(EXTRA_CXX_FLAG) -o srs_publish_nossl +srs_flv_parser: srs_flv_parser.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) + $(GCC) srs_flv_parser.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_flv_parser -srs_play_nossl: srs_play.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) - $(GCC) srs_play.c $(SRS_LIBRTMP_L) $(EXTRA_CXX_FLAG) -o srs_play_nossl +srs_publish: srs_publish.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) + $(GCC) srs_publish.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_publish -srs_ingest_flv_nossl: srs_ingest_flv.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) - $(GCC) srs_ingest_flv.c $(SRS_LIBRTMP_L) $(EXTRA_CXX_FLAG) -o srs_ingest_flv_nossl +srs_play: srs_play.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) + $(GCC) srs_play.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_play -srs_ingest_rtmp_nossl: srs_ingest_rtmp.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) - $(GCC) srs_ingest_rtmp.c $(SRS_LIBRTMP_L) $(EXTRA_CXX_FLAG) -o srs_ingest_rtmp_nossl +srs_ingest_flv: srs_ingest_flv.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) + $(GCC) srs_ingest_flv.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_ingest_flv -srs_flv_parser_ssl: srs_flv_parser.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) - $(GCC) srs_flv_parser.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_flv_parser_ssl - -srs_publish_ssl: srs_publish.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) - $(GCC) srs_publish.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_publish_ssl - -srs_play_ssl: srs_play.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) - $(GCC) srs_play.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_play_ssl - -srs_ingest_flv_ssl: srs_ingest_flv.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) - $(GCC) srs_ingest_flv.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_ingest_flv_ssl - -srs_ingest_rtmp_ssl: srs_ingest_rtmp.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) - $(GCC) srs_ingest_rtmp.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_ingest_rtmp_ssl - -# alias for publish/play with/without ssl -ssl: srs_flv_parser_ssl srs_publish_ssl srs_play_ssl srs_ingest_flv_ssl srs_ingest_rtmp_ssl -nossl: srs_flv_parser_nossl srs_publish_nossl srs_play_nossl srs_ingest_flv_nossl srs_ingest_rtmp_nossl +srs_ingest_rtmp: srs_ingest_rtmp.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) + $(GCC) srs_ingest_rtmp.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_ingest_rtmp diff --git a/trunk/research/librtmp/srs_play.c b/trunk/research/librtmp/srs_play.c index 9dcda9b8d..7bb0ef796 100644 --- a/trunk/research/librtmp/srs_play.c +++ b/trunk/research/librtmp/srs_play.c @@ -48,19 +48,11 @@ int main(int argc, char** argv) rtmp = srs_rtmp_create("rtmp://127.0.0.1:1935/live/livestream"); } - if (1) { - if (srs_complex_handshake(rtmp) != 0) { - printf("complex handshake failed.\n"); - goto rtmp_destroy; - } - printf("complex handshake success\n"); - } else { - if (srs_simple_handshake(rtmp) != 0) { - printf("simple handshake failed.\n"); - goto rtmp_destroy; - } - printf("simple handshake success\n"); + if (srs_simple_handshake(rtmp) != 0) { + printf("simple handshake failed.\n"); + goto rtmp_destroy; } + printf("simple handshake success\n"); if (srs_connect_app(rtmp) != 0) { printf("connect vhost/app failed.\n"); diff --git a/trunk/research/librtmp/srs_publish.c b/trunk/research/librtmp/srs_publish.c index 865cc2854..e0e9424ec 100644 --- a/trunk/research/librtmp/srs_publish.c +++ b/trunk/research/librtmp/srs_publish.c @@ -45,8 +45,7 @@ int main(int argc, char** argv) rtmp = srs_rtmp_create("rtmp://127.0.0.1:1935/live/livestream"); - //if (srs_simple_handshake(rtmp) != 0) { - if (srs_complex_handshake(rtmp) != 0) { + if (srs_simple_handshake(rtmp) != 0) { printf("simple handshake failed.\n"); goto rtmp_destroy; } diff --git a/trunk/src/libs/srs_librtmp.cpp b/trunk/src/libs/srs_librtmp.cpp index 044166455..adcefa580 100644 --- a/trunk/src/libs/srs_librtmp.cpp +++ b/trunk/src/libs/srs_librtmp.cpp @@ -183,33 +183,6 @@ int srs_simple_handshake(srs_rtmp_t rtmp) return ret; } -int srs_complex_handshake(srs_rtmp_t rtmp) -{ -#ifndef SRS_AUTO_SSL - return ERROR_RTMP_HS_SSL_REQUIRE; -#endif - - int ret = ERROR_SUCCESS; - - srs_assert(rtmp != NULL); - Context* context = (Context*)rtmp; - - // parse uri, resolve host, connect to server:port - if ((ret = srs_librtmp_context_connect(context)) != ERROR_SUCCESS) { - return ret; - } - - // complex handshake - srs_freep(context->rtmp); - context->rtmp = new SrsRtmpClient(context->skt); - - if ((ret = context->rtmp->complex_handshake()) != ERROR_SUCCESS) { - return ret; - } - - return ret; -} - int srs_connect_app(srs_rtmp_t rtmp) { int ret = ERROR_SUCCESS; diff --git a/trunk/src/libs/srs_librtmp.hpp b/trunk/src/libs/srs_librtmp.hpp index e5eb37d6d..41f5a4d25 100644 --- a/trunk/src/libs/srs_librtmp.hpp +++ b/trunk/src/libs/srs_librtmp.hpp @@ -66,14 +66,6 @@ void srs_rtmp_destroy(srs_rtmp_t rtmp); * not depends on ssl. */ int srs_simple_handshake(srs_rtmp_t rtmp); -/** -* complex handshake is specified by adobe Flash player, -* depends on ssl, user must compile srs with ssl, then -* link user program libssl.a and libcrypt.a -* @remark user can use srs_ssl_enabled() to detect -* whether ssl is ok. -*/ -int srs_complex_handshake(srs_rtmp_t rtmp); /** * connect to rtmp vhost/app