From 608b28f22351664039ce58bb6d221cb05ea61157 Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 19 Apr 2014 09:47:47 +0800 Subject: [PATCH] add srs ingest flv/rtmp base on srs-librtmp --- trunk/research/librtmp/Makefile | 40 +++++++++---------- trunk/research/librtmp/srs_ingest_flv.c | 36 +++++++++++++++++ trunk/research/librtmp/srs_ingest_rtmp.c | 49 ++++++++++++++++++++++++ trunk/src/srs/srs.upp | 2 + 4 files changed, 107 insertions(+), 20 deletions(-) mode change 100755 => 100644 trunk/research/librtmp/Makefile create mode 100644 trunk/research/librtmp/srs_ingest_flv.c create mode 100644 trunk/research/librtmp/srs_ingest_rtmp.c diff --git a/trunk/research/librtmp/Makefile b/trunk/research/librtmp/Makefile old mode 100755 new mode 100644 index dc236541e..7def39571 --- a/trunk/research/librtmp/Makefile +++ b/trunk/research/librtmp/Makefile @@ -5,15 +5,17 @@ GCC = gcc default: help help: - @echo "Usage: make |||||" + @echo "Usage: make |||||||" @echo " help display this help" @echo " clean cleanup build" @echo " ssl srs_publish_ssl, srs_play_ssl" - @echo " nossl srs_publish_nossl, srs_play_nossl" + @echo " nossl srs_publish_nossl, srs_play_nossl, srs_ingest_flv, srs_ingest_rtmp" @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 ingest flv file and publish to RTMP server. (simple handshake)" + @echo " srs_ingest_rtmp ingest RTMP and publish to RTMP server. (simple handshake)" @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'" @@ -22,7 +24,7 @@ help: @echo "Remark: before make this sample, user must make the srs, with/without ssl" clean: - @rm -f srs_publish_nossl srs_play_nossl srs_publish_ssl srs_play_ssl + @rm -f srs_publish_nossl srs_play_nossl srs_publish_ssl srs_play_ssl srs_ingest_flv srs_ingest_rtmp # srs library root SRS_OBJS = ../../objs @@ -34,32 +36,30 @@ SRS_LIBSSL_L = $(SRS_OBJS)/openssl/lib/libssl.a $(SRS_OBJS)/openssl/lib/libcrypt # for x86/x64 platform ifeq ($(GCC), gcc) -srs_publish_nossl: srs_publish.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) - $(GCC) srs_publish.c $(SRS_LIBRTMP_L) -g -O0 -lstdc++ -o srs_publish_nossl - -srs_play_nossl: srs_play.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) - $(GCC) srs_play.c $(SRS_LIBRTMP_L) -g -O0 -lstdc++ -o srs_play_nossl - -srs_publish_ssl: srs_publish.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) - $(GCC) srs_publish.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) -g -O0 -ldl -lstdc++ -o srs_publish_ssl - -srs_play_ssl: srs_play.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) - $(GCC) srs_play.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) -g -O0 -ldl -lstdc++ -o srs_play_ssl + EXTRA_CXX_FLAG = -g -O0 -ldl -lstdc++ # for arm. else + EXTRA_CXX_FLAG = -g -O0 -static -lstdc++ +endif + srs_publish_nossl: srs_publish.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) - $(GCC) srs_publish.c $(SRS_LIBRTMP_L) -g -O0 -static -lstdc++ -o srs_publish_nossl + $(GCC) srs_publish.c $(SRS_LIBRTMP_L) $(EXTRA_CXX_FLAG) -o srs_publish_nossl srs_play_nossl: srs_play.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) - $(GCC) srs_play.c $(SRS_LIBRTMP_L) -g -O0 -static -lstdc++ -o srs_play_nossl + $(GCC) srs_play.c $(SRS_LIBRTMP_L) $(EXTRA_CXX_FLAG) -o srs_play_nossl + +srs_ingest_flv: srs_ingest_flv.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) + $(GCC) srs_ingest_flv.c $(SRS_LIBRTMP_L) $(EXTRA_CXX_FLAG) -o srs_ingest_flv + +srs_ingest_rtmp: srs_ingest_rtmp.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) + $(GCC) srs_ingest_rtmp.c $(SRS_LIBRTMP_L) $(EXTRA_CXX_FLAG) -o srs_ingest_rtmp srs_publish_ssl: srs_publish.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) - $(GCC) srs_publish.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) -g -O0 -static -ldl -lstdc++ -o srs_publish_ssl + $(GCC) srs_publish.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_publish_ssl srs_play_ssl: srs_play.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) - $(GCC) srs_play.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) -g -O0 -static -ldl -lstdc++ -o srs_play_ssl -endif + $(GCC) srs_play.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_play_ssl # alias for publish/play with/without ssl ssl: srs_publish_ssl srs_play_ssl -nossl: srs_publish_nossl srs_play_nossl +nossl: srs_publish_nossl srs_play_nossl srs_ingest_flv srs_ingest_rtmp diff --git a/trunk/research/librtmp/srs_ingest_flv.c b/trunk/research/librtmp/srs_ingest_flv.c new file mode 100644 index 000000000..b7e5c3693 --- /dev/null +++ b/trunk/research/librtmp/srs_ingest_flv.c @@ -0,0 +1,36 @@ +/* +The MIT License (MIT) + +Copyright (c) 2013-2014 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. +*/ +/** +gcc srs_ingest_flv.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_ingest_flv +*/ + +#include +#include +#include + +#include "../../objs/include/srs_librtmp.h" + +int main(int argc, char** argv) +{ + return 0; +} diff --git a/trunk/research/librtmp/srs_ingest_rtmp.c b/trunk/research/librtmp/srs_ingest_rtmp.c new file mode 100644 index 000000000..adf47f9d1 --- /dev/null +++ b/trunk/research/librtmp/srs_ingest_rtmp.c @@ -0,0 +1,49 @@ +/* +The MIT License (MIT) + +Copyright (c) 2013-2014 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. +*/ +/** +gcc srs_ingest_rtmp.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_ingest_rtmp +*/ + +#include +#include +#include + +#include "../../objs/include/srs_librtmp.h" + +int main(int argc, char** argv) +{ + if (argc <= 2) { + printf("ingest RTMP and publish to RTMP server\n" + "Usage: %s \n" + " in_rtmp_url input rtmp url, ingest from this url.\n" + " out_rtmp_url output rtmp url, publish to this url.\n", + argv[0]); + exit(1); + } + + printf("ingest RTMP and publish to RTMP server like edge.\n"); + printf("srs(simple-rtmp-server) client librtmp library.\n"); + printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision()); + + return 0; +} diff --git a/trunk/src/srs/srs.upp b/trunk/src/srs/srs.upp index 0af75902f..51dafb6be 100755 --- a/trunk/src/srs/srs.upp +++ b/trunk/src/srs/srs.upp @@ -99,6 +99,8 @@ file ..\utest\srs_utest_handshake.hpp, ..\utest\srs_utest_handshake.cpp, research readonly separator, + ..\..\research\librtmp\srs_ingest_flv.c, + ..\..\research\librtmp\srs_ingest_rtmp.c, ..\..\research\librtmp\srs_play.c, ..\..\research\librtmp\srs_publish.c, ..\..\research\hls\ts_info.cc;