diff --git a/trunk/research/librtmp/Makefile b/trunk/research/librtmp/Makefile index e097c191d..66ebb56a3 100644 --- a/trunk/research/librtmp/Makefile +++ b/trunk/research/librtmp/Makefile @@ -26,7 +26,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 srs_ingest_flv srs_ingest_rtmp + @rm -f 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 # srs library root SRS_OBJS = ../../objs @@ -35,6 +35,8 @@ 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 +# the research public headers +SRS_RESEARCH_DEPS = Makefile srs_research_public.h # for x86/x64 platform ifeq ($(GCC), gcc) @@ -44,28 +46,28 @@ else EXTRA_CXX_FLAG = -g -O0 -static -lstdc++ endif -srs_publish_nossl: srs_publish.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) +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_play_nossl: srs_play.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) +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_ingest_flv_nossl: srs_ingest_flv.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) +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_ingest_rtmp_nossl: srs_ingest_rtmp.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) +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_publish_ssl: srs_publish.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) +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 Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) +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 Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) +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 Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) +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 diff --git a/trunk/research/librtmp/srs_ingest_flv.c b/trunk/research/librtmp/srs_ingest_flv.c index e624a972d..07bf1af7f 100644 --- a/trunk/research/librtmp/srs_ingest_flv.c +++ b/trunk/research/librtmp/srs_ingest_flv.c @@ -33,13 +33,7 @@ gcc srs_ingest_flv.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_ingest_ #include #include "../../objs/include/srs_librtmp.h" - -#define trace(msg, ...) printf(msg, ##__VA_ARGS__);printf("\n") -#define verbose(msg, ...) printf(msg, ##__VA_ARGS__);printf("\n") -#if 1 -#undef verbose -#define verbose(msg, ...) (void)0 -#endif +#include "srs_research_public.h" int proxy(int flv_fd, srs_rtmp_t ortmp); int connect_oc(srs_rtmp_t ortmp); @@ -235,8 +229,8 @@ int flv_read_packet(int flv_fd, int* type, u_int32_t* timestamp, char** data, in char th[11]; // tag header char ts[4]; // tag size - u_int32_t data_size; - u_int32_t time; + u_int32_t data_size = 0; + u_int32_t time = 0; char* pp; diff --git a/trunk/research/librtmp/srs_ingest_rtmp.c b/trunk/research/librtmp/srs_ingest_rtmp.c index 45811dec3..1adeb889f 100644 --- a/trunk/research/librtmp/srs_ingest_rtmp.c +++ b/trunk/research/librtmp/srs_ingest_rtmp.c @@ -29,13 +29,7 @@ gcc srs_ingest_rtmp.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_ingest #include #include "../../objs/include/srs_librtmp.h" - -#define trace(msg, ...) printf(msg, ##__VA_ARGS__);printf("\n") -#define verbose(msg, ...) printf(msg, ##__VA_ARGS__);printf("\n") -#if 1 -#undef verbose -#define verbose(msg, ...) (void)0 -#endif +#include "srs_research_public.h" int connect_ic(srs_rtmp_t irtmp); int connect_oc(srs_rtmp_t ortmp); diff --git a/trunk/research/librtmp/srs_research_public.h b/trunk/research/librtmp/srs_research_public.h new file mode 100644 index 000000000..63d13190b --- /dev/null +++ b/trunk/research/librtmp/srs_research_public.h @@ -0,0 +1,67 @@ +/* +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. +*/ + +#ifndef SRS_RESEARH_PUBLIC_HPP +#define SRS_RESEARH_PUBLIC_HPP + +/* +#include "srs_research_public.h" +*/ + +#include +#include + +char* format_time() +{ + struct timeval tv; + static char buf[23]; + + memset(buf, 0, sizeof(buf)); + + // clock time + if (gettimeofday(&tv, NULL) == -1) { + return buf; + } + + // to calendar time + struct tm* tm; + if ((tm = localtime(&tv.tv_sec)) == NULL) { + return buf; + } + + snprintf(buf, sizeof(buf), + "%d-%02d-%02d %02d:%02d:%02d.%03d", + 1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, + tm->tm_hour, tm->tm_min, tm->tm_sec, + (int)(tv.tv_usec / 1000)); + + return buf; +} +#define trace(msg, ...) printf("[%s]", format_time());printf(msg, ##__VA_ARGS__);printf("\n") +#define verbose(msg, ...) printf("[%s]", format_time());printf(msg, ##__VA_ARGS__);printf("\n") +#if 1 +#undef verbose +#define verbose(msg, ...) (void)0 +#endif + +#endif diff --git a/trunk/src/srs/srs.upp b/trunk/src/srs/srs.upp index 51dafb6be..f9e3cacac 100755 --- a/trunk/src/srs/srs.upp +++ b/trunk/src/srs/srs.upp @@ -103,6 +103,7 @@ file ..\..\research\librtmp\srs_ingest_rtmp.c, ..\..\research\librtmp\srs_play.c, ..\..\research\librtmp\srs_publish.c, + ..\..\research\librtmp\srs_research_public.h, ..\..\research\hls\ts_info.cc; mainconfig