winlin

add srs ingest flv/rtmp base on srs-librtmp

@@ -5,15 +5,17 @@ GCC = gcc @@ -5,15 +5,17 @@ GCC = gcc
5 default: help 5 default: help
6 6
7 help: 7 help:
8 - @echo "Usage: make <help>|<clean>|<srs_publish_nossl>|<srs_play_nossl>|<srs_publish_ssl>|<srs_play_ssl>" 8 + @echo "Usage: make <help>|<clean>|<srs_publish_nossl>|<srs_play_nossl>|<srs_publish_ssl>|<srs_play_ssl>|<srs_ingest_flv>|<srs_ingest_rtmp>"
9 @echo " help display this help" 9 @echo " help display this help"
10 @echo " clean cleanup build" 10 @echo " clean cleanup build"
11 @echo " ssl srs_publish_ssl, srs_play_ssl" 11 @echo " ssl srs_publish_ssl, srs_play_ssl"
12 - @echo " nossl srs_publish_nossl, srs_play_nossl" 12 + @echo " nossl srs_publish_nossl, srs_play_nossl, srs_ingest_flv, srs_ingest_rtmp"
13 @echo " srs_publish_nossl publish program using srs-librtmp, without ssl(simple handshake)" 13 @echo " srs_publish_nossl publish program using srs-librtmp, without ssl(simple handshake)"
14 @echo " srs_play_nossl play program using srs-librtmp, without ssl(simple handshake)" 14 @echo " srs_play_nossl play program using srs-librtmp, without ssl(simple handshake)"
15 @echo " srs_publish_ssl publish program using srs-librtmp, with ssl(complex handshake)" 15 @echo " srs_publish_ssl publish program using srs-librtmp, with ssl(complex handshake)"
16 @echo " srs_play_ssl play program using srs-librtmp, with ssl(complex handshake)" 16 @echo " srs_play_ssl play program using srs-librtmp, with ssl(complex handshake)"
  17 + @echo " srs_ingest_flv ingest flv file and publish to RTMP server. (simple handshake)"
  18 + @echo " srs_ingest_rtmp ingest RTMP and publish to RTMP server. (simple handshake)"
17 @echo "Remark: about simple/complex handshake, see: http://blog.csdn.net/win_lin/article/details/13006803" 19 @echo "Remark: about simple/complex handshake, see: http://blog.csdn.net/win_lin/article/details/13006803"
18 @echo "Remark: srs Makefile will auto invoke this by --with/without-ssl, " 20 @echo "Remark: srs Makefile will auto invoke this by --with/without-ssl, "
19 @echo " that is, if user specified ssl(by --with-ssl), srs will make this by 'make ssl'" 21 @echo " that is, if user specified ssl(by --with-ssl), srs will make this by 'make ssl'"
@@ -22,7 +24,7 @@ help: @@ -22,7 +24,7 @@ help:
22 @echo "Remark: before make this sample, user must make the srs, with/without ssl" 24 @echo "Remark: before make this sample, user must make the srs, with/without ssl"
23 25
24 clean: 26 clean:
25 - @rm -f srs_publish_nossl srs_play_nossl srs_publish_ssl srs_play_ssl 27 + @rm -f srs_publish_nossl srs_play_nossl srs_publish_ssl srs_play_ssl srs_ingest_flv srs_ingest_rtmp
26 28
27 # srs library root 29 # srs library root
28 SRS_OBJS = ../../objs 30 SRS_OBJS = ../../objs
@@ -34,32 +36,30 @@ SRS_LIBSSL_L = $(SRS_OBJS)/openssl/lib/libssl.a $(SRS_OBJS)/openssl/lib/libcrypt @@ -34,32 +36,30 @@ SRS_LIBSSL_L = $(SRS_OBJS)/openssl/lib/libssl.a $(SRS_OBJS)/openssl/lib/libcrypt
34 36
35 # for x86/x64 platform 37 # for x86/x64 platform
36 ifeq ($(GCC), gcc) 38 ifeq ($(GCC), gcc)
37 -srs_publish_nossl: srs_publish.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L)  
38 - $(GCC) srs_publish.c $(SRS_LIBRTMP_L) -g -O0 -lstdc++ -o srs_publish_nossl  
39 -  
40 -srs_play_nossl: srs_play.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L)  
41 - $(GCC) srs_play.c $(SRS_LIBRTMP_L) -g -O0 -lstdc++ -o srs_play_nossl  
42 -  
43 -srs_publish_ssl: srs_publish.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L)  
44 - $(GCC) srs_publish.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) -g -O0 -ldl -lstdc++ -o srs_publish_ssl  
45 -  
46 -srs_play_ssl: srs_play.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L)  
47 - $(GCC) srs_play.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) -g -O0 -ldl -lstdc++ -o srs_play_ssl 39 + EXTRA_CXX_FLAG = -g -O0 -ldl -lstdc++
48 # for arm. 40 # for arm.
49 else 41 else
  42 + EXTRA_CXX_FLAG = -g -O0 -static -lstdc++
  43 +endif
  44 +
50 srs_publish_nossl: srs_publish.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) 45 srs_publish_nossl: srs_publish.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L)
51 - $(GCC) srs_publish.c $(SRS_LIBRTMP_L) -g -O0 -static -lstdc++ -o srs_publish_nossl 46 + $(GCC) srs_publish.c $(SRS_LIBRTMP_L) $(EXTRA_CXX_FLAG) -o srs_publish_nossl
52 47
53 srs_play_nossl: srs_play.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) 48 srs_play_nossl: srs_play.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L)
54 - $(GCC) srs_play.c $(SRS_LIBRTMP_L) -g -O0 -static -lstdc++ -o srs_play_nossl 49 + $(GCC) srs_play.c $(SRS_LIBRTMP_L) $(EXTRA_CXX_FLAG) -o srs_play_nossl
  50 +
  51 +srs_ingest_flv: srs_ingest_flv.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L)
  52 + $(GCC) srs_ingest_flv.c $(SRS_LIBRTMP_L) $(EXTRA_CXX_FLAG) -o srs_ingest_flv
  53 +
  54 +srs_ingest_rtmp: srs_ingest_rtmp.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L)
  55 + $(GCC) srs_ingest_rtmp.c $(SRS_LIBRTMP_L) $(EXTRA_CXX_FLAG) -o srs_ingest_rtmp
55 56
56 srs_publish_ssl: srs_publish.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) 57 srs_publish_ssl: srs_publish.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L)
57 - $(GCC) srs_publish.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) -g -O0 -static -ldl -lstdc++ -o srs_publish_ssl 58 + $(GCC) srs_publish.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_publish_ssl
58 59
59 srs_play_ssl: srs_play.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) 60 srs_play_ssl: srs_play.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L)
60 - $(GCC) srs_play.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) -g -O0 -static -ldl -lstdc++ -o srs_play_ssl  
61 -endif 61 + $(GCC) srs_play.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_play_ssl
62 62
63 # alias for publish/play with/without ssl 63 # alias for publish/play with/without ssl
64 ssl: srs_publish_ssl srs_play_ssl 64 ssl: srs_publish_ssl srs_play_ssl
65 -nossl: srs_publish_nossl srs_play_nossl 65 +nossl: srs_publish_nossl srs_play_nossl srs_ingest_flv srs_ingest_rtmp
  1 +/*
  2 +The MIT License (MIT)
  3 +
  4 +Copyright (c) 2013-2014 winlin
  5 +
  6 +Permission is hereby granted, free of charge, to any person obtaining a copy of
  7 +this software and associated documentation files (the "Software"), to deal in
  8 +the Software without restriction, including without limitation the rights to
  9 +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  10 +the Software, and to permit persons to whom the Software is furnished to do so,
  11 +subject to the following conditions:
  12 +
  13 +The above copyright notice and this permission notice shall be included in all
  14 +copies or substantial portions of the Software.
  15 +
  16 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  18 +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  19 +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  20 +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21 +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22 +*/
  23 +/**
  24 +gcc srs_ingest_flv.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_ingest_flv
  25 +*/
  26 +
  27 +#include <stdio.h>
  28 +#include <stdlib.h>
  29 +#include <unistd.h>
  30 +
  31 +#include "../../objs/include/srs_librtmp.h"
  32 +
  33 +int main(int argc, char** argv)
  34 +{
  35 + return 0;
  36 +}
  1 +/*
  2 +The MIT License (MIT)
  3 +
  4 +Copyright (c) 2013-2014 winlin
  5 +
  6 +Permission is hereby granted, free of charge, to any person obtaining a copy of
  7 +this software and associated documentation files (the "Software"), to deal in
  8 +the Software without restriction, including without limitation the rights to
  9 +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  10 +the Software, and to permit persons to whom the Software is furnished to do so,
  11 +subject to the following conditions:
  12 +
  13 +The above copyright notice and this permission notice shall be included in all
  14 +copies or substantial portions of the Software.
  15 +
  16 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  18 +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  19 +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  20 +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21 +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22 +*/
  23 +/**
  24 +gcc srs_ingest_rtmp.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_ingest_rtmp
  25 +*/
  26 +
  27 +#include <stdio.h>
  28 +#include <stdlib.h>
  29 +#include <unistd.h>
  30 +
  31 +#include "../../objs/include/srs_librtmp.h"
  32 +
  33 +int main(int argc, char** argv)
  34 +{
  35 + if (argc <= 2) {
  36 + printf("ingest RTMP and publish to RTMP server\n"
  37 + "Usage: %s <in_rtmp_url> <out_rtmp_url>\n"
  38 + " in_rtmp_url input rtmp url, ingest from this url.\n"
  39 + " out_rtmp_url output rtmp url, publish to this url.\n",
  40 + argv[0]);
  41 + exit(1);
  42 + }
  43 +
  44 + printf("ingest RTMP and publish to RTMP server like edge.\n");
  45 + printf("srs(simple-rtmp-server) client librtmp library.\n");
  46 + printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision());
  47 +
  48 + return 0;
  49 +}
@@ -99,6 +99,8 @@ file @@ -99,6 +99,8 @@ file
99 ..\utest\srs_utest_handshake.hpp, 99 ..\utest\srs_utest_handshake.hpp,
100 ..\utest\srs_utest_handshake.cpp, 100 ..\utest\srs_utest_handshake.cpp,
101 research readonly separator, 101 research readonly separator,
  102 + ..\..\research\librtmp\srs_ingest_flv.c,
  103 + ..\..\research\librtmp\srs_ingest_rtmp.c,
102 ..\..\research\librtmp\srs_play.c, 104 ..\..\research\librtmp\srs_play.c,
103 ..\..\research\librtmp\srs_publish.c, 105 ..\..\research\librtmp\srs_publish.c,
104 ..\..\research\hls\ts_info.cc; 106 ..\..\research\hls\ts_info.cc;