winlin

remove the complex handshake of librtmp. refine makefile of librtmp tools

1 GCC = gcc 1 GCC = gcc
2 2
  3 +ifeq ($(HANDSHAKE),)
  4 + ST_ALL = help
  5 +else
  6 + ST_ALL = srs_flv_parser srs_publish srs_play srs_ingest_flv srs_ingest_rtmp
  7 +endif
  8 +
3 .PHONY: default clean help ssl nossl 9 .PHONY: default clean help ssl nossl
4 10
5 -default: help 11 +default: $(ST_ALL)
6 12
7 help: 13 help:
8 - @echo "Usage: make <help>|<clean>|<srs_flv_parser>|<srs_publish_nossl>|<srs_play_nossl>|<srs_ingest_flv_nossl>|<srs_ingest_rtmp_nossl>|<srs_publish_ssl>|<srs_play_ssl>|<srs_ingest_flv_ssl>|<srs_ingest_rtmp_ssl>" 14 + @echo "Usage: make <help>|<clean>|<srs_flv_parser>|<srs_publish>|<srs_play>|<srs_ingest_flv>|<srs_ingest_rtmp>"
9 @echo " help display this help" 15 @echo " help display this help"
10 @echo " clean cleanup build" 16 @echo " clean cleanup build"
11 - @echo " ssl srs_flv_parser, srs_publish_ssl, srs_play_ssl, srs_ingest_flv, srs_ingest_rtmp"  
12 - @echo " nossl srs_flv_parser, srs_publish_nossl, srs_play_nossl, srs_ingest_flv, srs_ingest_rtmp" 17 + @echo " ssl all tools link ssl"
  18 + @echo " nossl all tools never link ssl"
13 @echo " srs_flv_parser parse flv file, print detail info." 19 @echo " srs_flv_parser parse flv file, print detail info."
14 - @echo " srs_publish_nossl publish program using srs-librtmp, without ssl(simple handshake)"  
15 - @echo " srs_play_nossl play program using srs-librtmp, without ssl(simple handshake)"  
16 - @echo " srs_publish_ssl publish program using srs-librtmp, with ssl(complex handshake)"  
17 - @echo " srs_play_ssl play program using srs-librtmp, with ssl(complex handshake)"  
18 - @echo " srs_ingest_flv_nossl ingest flv file and publish to RTMP server. (simple handshake)"  
19 - @echo " srs_ingest_rtmp_nossl ingest RTMP and publish to RTMP server. (simple handshake)"  
20 - @echo " srs_ingest_flv_ssl ingest flv file and publish to RTMP server. (complex handshake)"  
21 - @echo " srs_ingest_rtmp_ssl ingest RTMP and publish to RTMP server. (complex handshake)" 20 + @echo " srs_publish publish program using srs-librtmp"
  21 + @echo " srs_play play program using srs-librtmp"
  22 + @echo " srs_ingest_flv ingest flv file and publish to RTMP server."
  23 + @echo " srs_ingest_rtmp ingest RTMP and publish to RTMP server."
22 @echo "Remark: about simple/complex handshake, see: http://blog.csdn.net/win_lin/article/details/13006803" 24 @echo "Remark: about simple/complex handshake, see: http://blog.csdn.net/win_lin/article/details/13006803"
23 @echo "Remark: srs Makefile will auto invoke this by --with/without-ssl, " 25 @echo "Remark: srs Makefile will auto invoke this by --with/without-ssl, "
24 @echo " that is, if user specified ssl(by --with-ssl), srs will make this by 'make ssl'" 26 @echo " that is, if user specified ssl(by --with-ssl), srs will make this by 'make ssl'"
@@ -27,7 +29,7 @@ help: @@ -27,7 +29,7 @@ help:
27 @echo "Remark: before make this sample, user must make the srs, with/without ssl" 29 @echo "Remark: before make this sample, user must make the srs, with/without ssl"
28 30
29 clean: 31 clean:
30 - @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 32 + @rm -f srs_flv_parser srs_publish srs_play srs_ingest_flv srs_ingest_rtmp
31 33
32 # srs library root 34 # srs library root
33 SRS_OBJS = ../../objs 35 SRS_OBJS = ../../objs
@@ -35,7 +37,7 @@ SRS_OBJS = ../../objs @@ -35,7 +37,7 @@ SRS_OBJS = ../../objs
35 SRS_LIBRTMP_I = $(SRS_OBJS)/include/srs_librtmp.h 37 SRS_LIBRTMP_I = $(SRS_OBJS)/include/srs_librtmp.h
36 SRS_LIBRTMP_L = $(SRS_OBJS)/lib/srs_librtmp.a 38 SRS_LIBRTMP_L = $(SRS_OBJS)/lib/srs_librtmp.a
37 # openssl for complex handshake, built by srs. 39 # openssl for complex handshake, built by srs.
38 -SRS_LIBSSL_L = $(SRS_OBJS)/openssl/lib/libssl.a $(SRS_OBJS)/openssl/lib/libcrypto.a 40 +SRS_LIBSSL_L =
39 # the research public headers 41 # the research public headers
40 SRS_RESEARCH_DEPS = Makefile srs_research_public.h 42 SRS_RESEARCH_DEPS = Makefile srs_research_public.h
41 43
@@ -51,37 +53,27 @@ endif @@ -51,37 +53,27 @@ endif
51 ifeq ($(GCC), mipsel-openwrt-linux-gcc) 53 ifeq ($(GCC), mipsel-openwrt-linux-gcc)
52 EXTRA_CXX_FLAG = -g -O0 -ldl -lstdc++ -lgcc_eh 54 EXTRA_CXX_FLAG = -g -O0 -ldl -lstdc++ -lgcc_eh
53 endif 55 endif
  56 +# for ssl or nossl
  57 +ifeq ($(HANDSHAKE), SSL)
  58 + SRS_LIBSSL_L = $(SRS_OBJS)/openssl/lib/libssl.a $(SRS_OBJS)/openssl/lib/libcrypto.a
  59 +endif
54 60
55 -srs_flv_parser_nossl: srs_flv_parser.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L)  
56 - $(GCC) srs_flv_parser.c $(SRS_LIBRTMP_L) $(EXTRA_CXX_FLAG) -o srs_flv_parser_nossl  
57 -  
58 -srs_publish_nossl: srs_publish.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L)  
59 - $(GCC) srs_publish.c $(SRS_LIBRTMP_L) $(EXTRA_CXX_FLAG) -o srs_publish_nossl  
60 -  
61 -srs_play_nossl: srs_play.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L)  
62 - $(GCC) srs_play.c $(SRS_LIBRTMP_L) $(EXTRA_CXX_FLAG) -o srs_play_nossl  
63 -  
64 -srs_ingest_flv_nossl: srs_ingest_flv.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L)  
65 - $(GCC) srs_ingest_flv.c $(SRS_LIBRTMP_L) $(EXTRA_CXX_FLAG) -o srs_ingest_flv_nossl  
66 -  
67 -srs_ingest_rtmp_nossl: srs_ingest_rtmp.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L)  
68 - $(GCC) srs_ingest_rtmp.c $(SRS_LIBRTMP_L) $(EXTRA_CXX_FLAG) -o srs_ingest_rtmp_nossl  
69 -  
70 -srs_flv_parser_ssl: srs_flv_parser.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L)  
71 - $(GCC) srs_flv_parser.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_flv_parser_ssl 61 +ssl:
  62 + $(MAKE) HANDSHAKE="SSL"
  63 +nossl:
  64 + $(MAKE) HANDSHAKE="NOSSL"
72 65
73 -srs_publish_ssl: srs_publish.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L)  
74 - $(GCC) srs_publish.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_publish_ssl 66 +srs_flv_parser: srs_flv_parser.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L)
  67 + $(GCC) srs_flv_parser.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_flv_parser
75 68
76 -srs_play_ssl: srs_play.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L)  
77 - $(GCC) srs_play.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_play_ssl 69 +srs_publish: srs_publish.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L)
  70 + $(GCC) srs_publish.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_publish
78 71
79 -srs_ingest_flv_ssl: srs_ingest_flv.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L)  
80 - $(GCC) srs_ingest_flv.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_ingest_flv_ssl 72 +srs_play: srs_play.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L)
  73 + $(GCC) srs_play.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_play
81 74
82 -srs_ingest_rtmp_ssl: srs_ingest_rtmp.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L)  
83 - $(GCC) srs_ingest_rtmp.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_ingest_rtmp_ssl 75 +srs_ingest_flv: srs_ingest_flv.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L)
  76 + $(GCC) srs_ingest_flv.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_ingest_flv
84 77
85 -# alias for publish/play with/without ssl  
86 -ssl: srs_flv_parser_ssl srs_publish_ssl srs_play_ssl srs_ingest_flv_ssl srs_ingest_rtmp_ssl  
87 -nossl: srs_flv_parser_nossl srs_publish_nossl srs_play_nossl srs_ingest_flv_nossl srs_ingest_rtmp_nossl 78 +srs_ingest_rtmp: srs_ingest_rtmp.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L)
  79 + $(GCC) srs_ingest_rtmp.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_ingest_rtmp
@@ -48,19 +48,11 @@ int main(int argc, char** argv) @@ -48,19 +48,11 @@ int main(int argc, char** argv)
48 rtmp = srs_rtmp_create("rtmp://127.0.0.1:1935/live/livestream"); 48 rtmp = srs_rtmp_create("rtmp://127.0.0.1:1935/live/livestream");
49 } 49 }
50 50
51 - if (1) {  
52 - if (srs_complex_handshake(rtmp) != 0) {  
53 - printf("complex handshake failed.\n");  
54 - goto rtmp_destroy;  
55 - }  
56 - printf("complex handshake success\n");  
57 - } else {  
58 - if (srs_simple_handshake(rtmp) != 0) {  
59 - printf("simple handshake failed.\n");  
60 - goto rtmp_destroy;  
61 - }  
62 - printf("simple handshake success\n"); 51 + if (srs_simple_handshake(rtmp) != 0) {
  52 + printf("simple handshake failed.\n");
  53 + goto rtmp_destroy;
63 } 54 }
  55 + printf("simple handshake success\n");
64 56
65 if (srs_connect_app(rtmp) != 0) { 57 if (srs_connect_app(rtmp) != 0) {
66 printf("connect vhost/app failed.\n"); 58 printf("connect vhost/app failed.\n");
@@ -45,8 +45,7 @@ int main(int argc, char** argv) @@ -45,8 +45,7 @@ int main(int argc, char** argv)
45 45
46 rtmp = srs_rtmp_create("rtmp://127.0.0.1:1935/live/livestream"); 46 rtmp = srs_rtmp_create("rtmp://127.0.0.1:1935/live/livestream");
47 47
48 - //if (srs_simple_handshake(rtmp) != 0) {  
49 - if (srs_complex_handshake(rtmp) != 0) { 48 + if (srs_simple_handshake(rtmp) != 0) {
50 printf("simple handshake failed.\n"); 49 printf("simple handshake failed.\n");
51 goto rtmp_destroy; 50 goto rtmp_destroy;
52 } 51 }
@@ -183,33 +183,6 @@ int srs_simple_handshake(srs_rtmp_t rtmp) @@ -183,33 +183,6 @@ int srs_simple_handshake(srs_rtmp_t rtmp)
183 return ret; 183 return ret;
184 } 184 }
185 185
186 -int srs_complex_handshake(srs_rtmp_t rtmp)  
187 -{  
188 -#ifndef SRS_AUTO_SSL  
189 - return ERROR_RTMP_HS_SSL_REQUIRE;  
190 -#endif  
191 -  
192 - int ret = ERROR_SUCCESS;  
193 -  
194 - srs_assert(rtmp != NULL);  
195 - Context* context = (Context*)rtmp;  
196 -  
197 - // parse uri, resolve host, connect to server:port  
198 - if ((ret = srs_librtmp_context_connect(context)) != ERROR_SUCCESS) {  
199 - return ret;  
200 - }  
201 -  
202 - // complex handshake  
203 - srs_freep(context->rtmp);  
204 - context->rtmp = new SrsRtmpClient(context->skt);  
205 -  
206 - if ((ret = context->rtmp->complex_handshake()) != ERROR_SUCCESS) {  
207 - return ret;  
208 - }  
209 -  
210 - return ret;  
211 -}  
212 -  
213 int srs_connect_app(srs_rtmp_t rtmp) 186 int srs_connect_app(srs_rtmp_t rtmp)
214 { 187 {
215 int ret = ERROR_SUCCESS; 188 int ret = ERROR_SUCCESS;
@@ -66,14 +66,6 @@ void srs_rtmp_destroy(srs_rtmp_t rtmp); @@ -66,14 +66,6 @@ void srs_rtmp_destroy(srs_rtmp_t rtmp);
66 * not depends on ssl. 66 * not depends on ssl.
67 */ 67 */
68 int srs_simple_handshake(srs_rtmp_t rtmp); 68 int srs_simple_handshake(srs_rtmp_t rtmp);
69 -/**  
70 -* complex handshake is specified by adobe Flash player,  
71 -* depends on ssl, user must compile srs with ssl, then  
72 -* link user program libssl.a and libcrypt.a  
73 -* @remark user can use srs_ssl_enabled() to detect  
74 -* whether ssl is ok.  
75 -*/  
76 -int srs_complex_handshake(srs_rtmp_t rtmp);  
77 69
78 /** 70 /**
79 * connect to rtmp vhost/app 71 * connect to rtmp vhost/app