正在显示
5 个修改的文件
包含
83 行增加
和
25 行删除
| @@ -26,7 +26,7 @@ help: | @@ -26,7 +26,7 @@ help: | ||
| 26 | @echo "Remark: before make this sample, user must make the srs, with/without ssl" | 26 | @echo "Remark: before make this sample, user must make the srs, with/without ssl" |
| 27 | 27 | ||
| 28 | clean: | 28 | clean: |
| 29 | - @rm -f srs_publish_nossl srs_play_nossl srs_publish_ssl srs_play_ssl srs_ingest_flv srs_ingest_rtmp | 29 | + @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 |
| 30 | 30 | ||
| 31 | # srs library root | 31 | # srs library root |
| 32 | SRS_OBJS = ../../objs | 32 | SRS_OBJS = ../../objs |
| @@ -35,6 +35,8 @@ SRS_LIBRTMP_I = $(SRS_OBJS)/include/srs_librtmp.h | @@ -35,6 +35,8 @@ SRS_LIBRTMP_I = $(SRS_OBJS)/include/srs_librtmp.h | ||
| 35 | SRS_LIBRTMP_L = $(SRS_OBJS)/lib/srs_librtmp.a | 35 | SRS_LIBRTMP_L = $(SRS_OBJS)/lib/srs_librtmp.a |
| 36 | # openssl for complex handshake, built by srs. | 36 | # openssl for complex handshake, built by srs. |
| 37 | SRS_LIBSSL_L = $(SRS_OBJS)/openssl/lib/libssl.a $(SRS_OBJS)/openssl/lib/libcrypto.a | 37 | SRS_LIBSSL_L = $(SRS_OBJS)/openssl/lib/libssl.a $(SRS_OBJS)/openssl/lib/libcrypto.a |
| 38 | +# the research public headers | ||
| 39 | +SRS_RESEARCH_DEPS = Makefile srs_research_public.h | ||
| 38 | 40 | ||
| 39 | # for x86/x64 platform | 41 | # for x86/x64 platform |
| 40 | ifeq ($(GCC), gcc) | 42 | ifeq ($(GCC), gcc) |
| @@ -44,28 +46,28 @@ else | @@ -44,28 +46,28 @@ else | ||
| 44 | EXTRA_CXX_FLAG = -g -O0 -static -lstdc++ | 46 | EXTRA_CXX_FLAG = -g -O0 -static -lstdc++ |
| 45 | endif | 47 | endif |
| 46 | 48 | ||
| 47 | -srs_publish_nossl: srs_publish.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) | 49 | +srs_publish_nossl: srs_publish.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) |
| 48 | $(GCC) srs_publish.c $(SRS_LIBRTMP_L) $(EXTRA_CXX_FLAG) -o srs_publish_nossl | 50 | $(GCC) srs_publish.c $(SRS_LIBRTMP_L) $(EXTRA_CXX_FLAG) -o srs_publish_nossl |
| 49 | 51 | ||
| 50 | -srs_play_nossl: srs_play.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) | 52 | +srs_play_nossl: srs_play.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) |
| 51 | $(GCC) srs_play.c $(SRS_LIBRTMP_L) $(EXTRA_CXX_FLAG) -o srs_play_nossl | 53 | $(GCC) srs_play.c $(SRS_LIBRTMP_L) $(EXTRA_CXX_FLAG) -o srs_play_nossl |
| 52 | 54 | ||
| 53 | -srs_ingest_flv_nossl: srs_ingest_flv.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) | 55 | +srs_ingest_flv_nossl: srs_ingest_flv.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) |
| 54 | $(GCC) srs_ingest_flv.c $(SRS_LIBRTMP_L) $(EXTRA_CXX_FLAG) -o srs_ingest_flv_nossl | 56 | $(GCC) srs_ingest_flv.c $(SRS_LIBRTMP_L) $(EXTRA_CXX_FLAG) -o srs_ingest_flv_nossl |
| 55 | 57 | ||
| 56 | -srs_ingest_rtmp_nossl: srs_ingest_rtmp.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) | 58 | +srs_ingest_rtmp_nossl: srs_ingest_rtmp.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) |
| 57 | $(GCC) srs_ingest_rtmp.c $(SRS_LIBRTMP_L) $(EXTRA_CXX_FLAG) -o srs_ingest_rtmp_nossl | 59 | $(GCC) srs_ingest_rtmp.c $(SRS_LIBRTMP_L) $(EXTRA_CXX_FLAG) -o srs_ingest_rtmp_nossl |
| 58 | 60 | ||
| 59 | -srs_publish_ssl: srs_publish.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) | 61 | +srs_publish_ssl: srs_publish.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) |
| 60 | $(GCC) srs_publish.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_publish_ssl | 62 | $(GCC) srs_publish.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_publish_ssl |
| 61 | 63 | ||
| 62 | -srs_play_ssl: srs_play.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) | 64 | +srs_play_ssl: srs_play.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) |
| 63 | $(GCC) srs_play.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_play_ssl | 65 | $(GCC) srs_play.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_play_ssl |
| 64 | 66 | ||
| 65 | -srs_ingest_flv_ssl: srs_ingest_flv.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) | 67 | +srs_ingest_flv_ssl: srs_ingest_flv.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) |
| 66 | $(GCC) srs_ingest_flv.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_ingest_flv_ssl | 68 | $(GCC) srs_ingest_flv.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_ingest_flv_ssl |
| 67 | 69 | ||
| 68 | -srs_ingest_rtmp_ssl: srs_ingest_rtmp.c Makefile $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) | 70 | +srs_ingest_rtmp_ssl: srs_ingest_rtmp.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) |
| 69 | $(GCC) srs_ingest_rtmp.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_ingest_rtmp_ssl | 71 | $(GCC) srs_ingest_rtmp.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_ingest_rtmp_ssl |
| 70 | 72 | ||
| 71 | # alias for publish/play with/without ssl | 73 | # alias for publish/play with/without ssl |
| @@ -33,13 +33,7 @@ gcc srs_ingest_flv.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_ingest_ | @@ -33,13 +33,7 @@ gcc srs_ingest_flv.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_ingest_ | ||
| 33 | #include <fcntl.h> | 33 | #include <fcntl.h> |
| 34 | 34 | ||
| 35 | #include "../../objs/include/srs_librtmp.h" | 35 | #include "../../objs/include/srs_librtmp.h" |
| 36 | - | ||
| 37 | -#define trace(msg, ...) printf(msg, ##__VA_ARGS__);printf("\n") | ||
| 38 | -#define verbose(msg, ...) printf(msg, ##__VA_ARGS__);printf("\n") | ||
| 39 | -#if 1 | ||
| 40 | -#undef verbose | ||
| 41 | -#define verbose(msg, ...) (void)0 | ||
| 42 | -#endif | 36 | +#include "srs_research_public.h" |
| 43 | 37 | ||
| 44 | int proxy(int flv_fd, srs_rtmp_t ortmp); | 38 | int proxy(int flv_fd, srs_rtmp_t ortmp); |
| 45 | int connect_oc(srs_rtmp_t ortmp); | 39 | 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 | @@ -235,8 +229,8 @@ int flv_read_packet(int flv_fd, int* type, u_int32_t* timestamp, char** data, in | ||
| 235 | char th[11]; // tag header | 229 | char th[11]; // tag header |
| 236 | char ts[4]; // tag size | 230 | char ts[4]; // tag size |
| 237 | 231 | ||
| 238 | - u_int32_t data_size; | ||
| 239 | - u_int32_t time; | 232 | + u_int32_t data_size = 0; |
| 233 | + u_int32_t time = 0; | ||
| 240 | 234 | ||
| 241 | char* pp; | 235 | char* pp; |
| 242 | 236 |
| @@ -29,13 +29,7 @@ gcc srs_ingest_rtmp.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_ingest | @@ -29,13 +29,7 @@ gcc srs_ingest_rtmp.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_ingest | ||
| 29 | #include <unistd.h> | 29 | #include <unistd.h> |
| 30 | 30 | ||
| 31 | #include "../../objs/include/srs_librtmp.h" | 31 | #include "../../objs/include/srs_librtmp.h" |
| 32 | - | ||
| 33 | -#define trace(msg, ...) printf(msg, ##__VA_ARGS__);printf("\n") | ||
| 34 | -#define verbose(msg, ...) printf(msg, ##__VA_ARGS__);printf("\n") | ||
| 35 | -#if 1 | ||
| 36 | -#undef verbose | ||
| 37 | -#define verbose(msg, ...) (void)0 | ||
| 38 | -#endif | 32 | +#include "srs_research_public.h" |
| 39 | 33 | ||
| 40 | int connect_ic(srs_rtmp_t irtmp); | 34 | int connect_ic(srs_rtmp_t irtmp); |
| 41 | int connect_oc(srs_rtmp_t ortmp); | 35 | int connect_oc(srs_rtmp_t ortmp); |
trunk/research/librtmp/srs_research_public.h
0 → 100644
| 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 | +#ifndef SRS_RESEARH_PUBLIC_HPP | ||
| 25 | +#define SRS_RESEARH_PUBLIC_HPP | ||
| 26 | + | ||
| 27 | +/* | ||
| 28 | +#include "srs_research_public.h" | ||
| 29 | +*/ | ||
| 30 | + | ||
| 31 | +#include <string.h> | ||
| 32 | +#include <time.h> | ||
| 33 | + | ||
| 34 | +char* format_time() | ||
| 35 | +{ | ||
| 36 | + struct timeval tv; | ||
| 37 | + static char buf[23]; | ||
| 38 | + | ||
| 39 | + memset(buf, 0, sizeof(buf)); | ||
| 40 | + | ||
| 41 | + // clock time | ||
| 42 | + if (gettimeofday(&tv, NULL) == -1) { | ||
| 43 | + return buf; | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + // to calendar time | ||
| 47 | + struct tm* tm; | ||
| 48 | + if ((tm = localtime(&tv.tv_sec)) == NULL) { | ||
| 49 | + return buf; | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + snprintf(buf, sizeof(buf), | ||
| 53 | + "%d-%02d-%02d %02d:%02d:%02d.%03d", | ||
| 54 | + 1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, | ||
| 55 | + tm->tm_hour, tm->tm_min, tm->tm_sec, | ||
| 56 | + (int)(tv.tv_usec / 1000)); | ||
| 57 | + | ||
| 58 | + return buf; | ||
| 59 | +} | ||
| 60 | +#define trace(msg, ...) printf("[%s]", format_time());printf(msg, ##__VA_ARGS__);printf("\n") | ||
| 61 | +#define verbose(msg, ...) printf("[%s]", format_time());printf(msg, ##__VA_ARGS__);printf("\n") | ||
| 62 | +#if 1 | ||
| 63 | +#undef verbose | ||
| 64 | +#define verbose(msg, ...) (void)0 | ||
| 65 | +#endif | ||
| 66 | + | ||
| 67 | +#endif |
| @@ -103,6 +103,7 @@ file | @@ -103,6 +103,7 @@ file | ||
| 103 | ..\..\research\librtmp\srs_ingest_rtmp.c, | 103 | ..\..\research\librtmp\srs_ingest_rtmp.c, |
| 104 | ..\..\research\librtmp\srs_play.c, | 104 | ..\..\research\librtmp\srs_play.c, |
| 105 | ..\..\research\librtmp\srs_publish.c, | 105 | ..\..\research\librtmp\srs_publish.c, |
| 106 | + ..\..\research\librtmp\srs_research_public.h, | ||
| 106 | ..\..\research\hls\ts_info.cc; | 107 | ..\..\research\hls\ts_info.cc; |
| 107 | 108 | ||
| 108 | mainconfig | 109 | mainconfig |
-
请 注册 或 登录 后发表评论