正在显示
4 个修改的文件
包含
102 行增加
和
3 行删除
trunk/research/librtmp/Makefile
100755 → 100644
| @@ -3,7 +3,7 @@ GCC = gcc | @@ -3,7 +3,7 @@ GCC = gcc | ||
| 3 | ifeq ($(HANDSHAKE),) | 3 | ifeq ($(HANDSHAKE),) |
| 4 | ST_ALL = help | 4 | ST_ALL = help |
| 5 | else | 5 | else |
| 6 | - ST_ALL = srs_flv_parser srs_flv_injecter srs_publish srs_play srs_ingest_flv srs_ingest_rtmp | 6 | + ST_ALL = srs_flv_parser srs_flv_injecter srs_publish srs_play srs_ingest_flv srs_ingest_rtmp srs_detect_rtmp |
| 7 | endif | 7 | endif |
| 8 | 8 | ||
| 9 | .PHONY: default clean help ssl nossl | 9 | .PHONY: default clean help ssl nossl |
| @@ -11,17 +11,19 @@ endif | @@ -11,17 +11,19 @@ endif | ||
| 11 | default: $(ST_ALL) | 11 | default: $(ST_ALL) |
| 12 | 12 | ||
| 13 | help: | 13 | help: |
| 14 | - @echo "Usage: make <help>|<clean>|<srs_flv_parser>|<srs_flv_injecter>|<srs_publish>|<srs_play>|<srs_ingest_flv>|<srs_ingest_rtmp>" | 14 | + @echo "Usage: make <help>|<clean>|<ssl>|<nossl>" |
| 15 | @echo " help display this help" | 15 | @echo " help display this help" |
| 16 | @echo " clean cleanup build" | 16 | @echo " clean cleanup build" |
| 17 | @echo " ssl all tools link ssl" | 17 | @echo " ssl all tools link ssl" |
| 18 | @echo " nossl all tools never link ssl" | 18 | @echo " nossl all tools never link ssl" |
| 19 | + @echo "ssl/nossl will build the following tools:" | ||
| 19 | @echo " srs_flv_parser parse flv file, print detail info." | 20 | @echo " srs_flv_parser parse flv file, print detail info." |
| 20 | @echo " srs_flv_injecter inject keyframes information to metadata." | 21 | @echo " srs_flv_injecter inject keyframes information to metadata." |
| 21 | @echo " srs_publish publish program using srs-librtmp" | 22 | @echo " srs_publish publish program using srs-librtmp" |
| 22 | @echo " srs_play play program using srs-librtmp" | 23 | @echo " srs_play play program using srs-librtmp" |
| 23 | @echo " srs_ingest_flv ingest flv file and publish to RTMP server." | 24 | @echo " srs_ingest_flv ingest flv file and publish to RTMP server." |
| 24 | @echo " srs_ingest_rtmp ingest RTMP and publish to RTMP server." | 25 | @echo " srs_ingest_rtmp ingest RTMP and publish to RTMP server." |
| 26 | + @echo " srs_detect_rtmp detect RTMP stream info." | ||
| 25 | @echo "Remark: about simple/complex handshake, see: http://blog.csdn.net/win_lin/article/details/13006803" | 27 | @echo "Remark: about simple/complex handshake, see: http://blog.csdn.net/win_lin/article/details/13006803" |
| 26 | @echo "Remark: srs Makefile will auto invoke this by --with/without-ssl, " | 28 | @echo "Remark: srs Makefile will auto invoke this by --with/without-ssl, " |
| 27 | @echo " that is, if user specified ssl(by --with-ssl), srs will make this by 'make ssl'" | 29 | @echo " that is, if user specified ssl(by --with-ssl), srs will make this by 'make ssl'" |
| @@ -30,7 +32,7 @@ help: | @@ -30,7 +32,7 @@ help: | ||
| 30 | @echo "Remark: before make this sample, user must make the srs, with/without ssl" | 32 | @echo "Remark: before make this sample, user must make the srs, with/without ssl" |
| 31 | 33 | ||
| 32 | clean: | 34 | clean: |
| 33 | - @rm -f srs_flv_parser srs_flv_injecter srs_publish srs_play srs_ingest_flv srs_ingest_rtmp | 35 | + @rm -f srs_flv_parser srs_flv_injecter srs_publish srs_play srs_ingest_flv srs_ingest_rtmp srs_detect_rtmp |
| 34 | 36 | ||
| 35 | # srs library root | 37 | # srs library root |
| 36 | SRS_OBJS = ../../objs | 38 | SRS_OBJS = ../../objs |
| @@ -81,3 +83,6 @@ srs_ingest_flv: srs_ingest_flv.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIB | @@ -81,3 +83,6 @@ srs_ingest_flv: srs_ingest_flv.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIB | ||
| 81 | 83 | ||
| 82 | srs_ingest_rtmp: srs_ingest_rtmp.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) | 84 | srs_ingest_rtmp: 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 | 85 | $(GCC) srs_ingest_rtmp.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_ingest_rtmp |
| 86 | + | ||
| 87 | +srs_detect_rtmp: srs_detect_rtmp.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) | ||
| 88 | + $(GCC) srs_detect_rtmp.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o srs_detect_rtmp |
trunk/research/librtmp/srs_detect_rtmp.c
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 | +gcc srs_detect_rtmp.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_detect_rtmp | ||
| 25 | +*/ | ||
| 26 | + | ||
| 27 | +#include <stdio.h> | ||
| 28 | +#include <stdlib.h> | ||
| 29 | + | ||
| 30 | +#include "../../objs/include/srs_librtmp.h" | ||
| 31 | + | ||
| 32 | +int main(int argc, char** argv) | ||
| 33 | +{ | ||
| 34 | + srs_rtmp_t rtmp; | ||
| 35 | + | ||
| 36 | + // packet data | ||
| 37 | + int type, size; | ||
| 38 | + u_int32_t timestamp = 0; | ||
| 39 | + char* data; | ||
| 40 | + | ||
| 41 | + if (argc <= 1) { | ||
| 42 | + printf("detect stream on RTMP server\n" | ||
| 43 | + "Usage: %s <rtmp_url>\n" | ||
| 44 | + " rtmp_url RTMP stream url to play\n" | ||
| 45 | + "For example:\n" | ||
| 46 | + " %s rtmp://127.0.0.1:1935/live/livestream\n", | ||
| 47 | + argv[0]); | ||
| 48 | + int ret = 1; | ||
| 49 | + exit(ret); | ||
| 50 | + return ret; | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + rtmp = srs_rtmp_create(argv[1]); | ||
| 54 | + | ||
| 55 | + printf("detect rtmp stream\n"); | ||
| 56 | + printf("srs(simple-rtmp-server) client librtmp library.\n"); | ||
| 57 | + printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision()); | ||
| 58 | + printf("rtmp url: %s\n", rtmp); | ||
| 59 | + | ||
| 60 | + if (srs_simple_handshake(rtmp) != 0) { | ||
| 61 | + printf("simple handshake failed.\n"); | ||
| 62 | + goto rtmp_destroy; | ||
| 63 | + } | ||
| 64 | + printf("simple handshake success\n"); | ||
| 65 | + | ||
| 66 | + if (srs_connect_app(rtmp) != 0) { | ||
| 67 | + printf("connect vhost/app failed.\n"); | ||
| 68 | + goto rtmp_destroy; | ||
| 69 | + } | ||
| 70 | + printf("connect vhost/app success\n"); | ||
| 71 | + | ||
| 72 | + if (srs_play_stream(rtmp) != 0) { | ||
| 73 | + printf("play stream failed.\n"); | ||
| 74 | + goto rtmp_destroy; | ||
| 75 | + } | ||
| 76 | + printf("play stream success\n"); | ||
| 77 | + | ||
| 78 | + for (;;) { | ||
| 79 | + if (srs_read_packet(rtmp, &type, ×tamp, &data, &size) != 0) { | ||
| 80 | + goto rtmp_destroy; | ||
| 81 | + } | ||
| 82 | + printf("got packet: type=%s, time=%d, size=%d\n", srs_type2string(type), timestamp, size); | ||
| 83 | + | ||
| 84 | + free(data); | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | +rtmp_destroy: | ||
| 88 | + srs_rtmp_destroy(rtmp); | ||
| 89 | + | ||
| 90 | + return 0; | ||
| 91 | +} |
| @@ -32,6 +32,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -32,6 +32,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 32 | 32 | ||
| 33 | #include <srs_kernel_codec.hpp> | 33 | #include <srs_kernel_codec.hpp> |
| 34 | 34 | ||
| 35 | +class SrsStream; | ||
| 36 | + | ||
| 35 | #define SRS_MAX_CODEC_SAMPLE 128 | 37 | #define SRS_MAX_CODEC_SAMPLE 128 |
| 36 | 38 | ||
| 37 | // Sampling rate. The following values are defined: | 39 | // Sampling rate. The following values are defined: |
| @@ -115,6 +115,7 @@ file | @@ -115,6 +115,7 @@ file | ||
| 115 | ..\utest\srs_utest_handshake.hpp, | 115 | ..\utest\srs_utest_handshake.hpp, |
| 116 | ..\utest\srs_utest_handshake.cpp, | 116 | ..\utest\srs_utest_handshake.cpp, |
| 117 | research readonly separator, | 117 | research readonly separator, |
| 118 | + ..\..\research\librtmp\srs_detect_rtmp.c, | ||
| 118 | ..\..\research\librtmp\srs_flv_injecter.c, | 119 | ..\..\research\librtmp\srs_flv_injecter.c, |
| 119 | ..\..\research\librtmp\srs_flv_parser.c, | 120 | ..\..\research\librtmp\srs_flv_parser.c, |
| 120 | ..\..\research\librtmp\srs_ingest_flv.c, | 121 | ..\..\research\librtmp\srs_ingest_flv.c, |
-
请 注册 或 登录 后发表评论