正在显示
5 个修改的文件
包含
131 行增加
和
2 行删除
@@ -485,6 +485,7 @@ Supported operating systems and hardware: | @@ -485,6 +485,7 @@ Supported operating systems and hardware: | ||
485 | * 2013-10-17, Created.<br/> | 485 | * 2013-10-17, Created.<br/> |
486 | 486 | ||
487 | ## History | 487 | ## History |
488 | +* v2.0, 2014-11-28, fix [#215](https://github.com/winlinvip/simple-rtmp-server/issues/215), for bug #215, add srs_rtmp_dump tool. 2.0.37. | ||
488 | * v2.0, 2014-11-25, update PRIMARY, AUTHORS, CONTRIBUTORS rule. 2.0.32. | 489 | * v2.0, 2014-11-25, update PRIMARY, AUTHORS, CONTRIBUTORS rule. 2.0.32. |
489 | * v2.0, 2014-11-24, fix [#212](https://github.com/winlinvip/simple-rtmp-server/issues/212), support publish aac adts raw stream. 2.0.31. | 490 | * v2.0, 2014-11-24, fix [#212](https://github.com/winlinvip/simple-rtmp-server/issues/212), support publish aac adts raw stream. 2.0.31. |
490 | * v2.0, 2014-11-22, fix [#217](https://github.com/winlinvip/simple-rtmp-server/issues/217), remove timeout recv, support 7.5k+ 250kbps clients. 2.0.30. | 491 | * v2.0, 2014-11-22, fix [#217](https://github.com/winlinvip/simple-rtmp-server/issues/217), remove timeout recv, support 7.5k+ 250kbps clients. 2.0.30. |
@@ -7,7 +7,8 @@ else | @@ -7,7 +7,8 @@ else | ||
7 | objs/srs_flv_injecter objs/srs_publish objs/srs_play \ | 7 | objs/srs_flv_injecter objs/srs_publish objs/srs_play \ |
8 | objs/srs_ingest_flv objs/srs_ingest_rtmp objs/srs_detect_rtmp \ | 8 | objs/srs_ingest_flv objs/srs_ingest_rtmp objs/srs_detect_rtmp \ |
9 | objs/srs_bandwidth_check objs/srs_h264_raw_publish \ | 9 | objs/srs_bandwidth_check objs/srs_h264_raw_publish \ |
10 | - objs/srs_audio_raw_publish objs/srs_aac_raw_publish | 10 | + objs/srs_audio_raw_publish objs/srs_aac_raw_publish \ |
11 | + objs/srs_rtmp_dump | ||
11 | endif | 12 | endif |
12 | 13 | ||
13 | .PHONY: default clean help ssl nossl | 14 | .PHONY: default clean help ssl nossl |
@@ -32,6 +33,7 @@ help: | @@ -32,6 +33,7 @@ help: | ||
32 | @echo " srs_ingest_rtmp ingest RTMP and publish to RTMP server." | 33 | @echo " srs_ingest_rtmp ingest RTMP and publish to RTMP server." |
33 | @echo " srs_detect_rtmp detect RTMP stream info." | 34 | @echo " srs_detect_rtmp detect RTMP stream info." |
34 | @echo " srs_bandwidth_check bandwidth check/test tool." | 35 | @echo " srs_bandwidth_check bandwidth check/test tool." |
36 | + @echo " srs_rtmp_dump dump rtmp stream to flv file." | ||
35 | @echo "Remark: about simple/complex handshake, see: http://blog.csdn.net/win_lin/article/details/13006803" | 37 | @echo "Remark: about simple/complex handshake, see: http://blog.csdn.net/win_lin/article/details/13006803" |
36 | @echo "Remark: srs Makefile will auto invoke this by --with/without-ssl, " | 38 | @echo "Remark: srs Makefile will auto invoke this by --with/without-ssl, " |
37 | @echo " that is, if user specified ssl(by --with-ssl), srs will make this by 'make ssl'" | 39 | @echo " that is, if user specified ssl(by --with-ssl), srs will make this by 'make ssl'" |
@@ -108,3 +110,6 @@ objs/srs_detect_rtmp: srs_detect_rtmp.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $( | @@ -108,3 +110,6 @@ objs/srs_detect_rtmp: srs_detect_rtmp.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $( | ||
108 | 110 | ||
109 | objs/srs_bandwidth_check: srs_bandwidth_check.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) | 111 | objs/srs_bandwidth_check: srs_bandwidth_check.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) |
110 | $(GCC) srs_bandwidth_check.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o objs/srs_bandwidth_check | 112 | $(GCC) srs_bandwidth_check.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o objs/srs_bandwidth_check |
113 | + | ||
114 | +objs/srs_rtmp_dump: srs_rtmp_dump.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) | ||
115 | + $(GCC) srs_rtmp_dump.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o objs/srs_rtmp_dump |
trunk/research/librtmp/srs_rtmp_dump.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_rtmp_dump.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_rtmp_dump | ||
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 | + printf("dump rtmp stream to flv file\n"); | ||
35 | + printf("srs(simple-rtmp-server) client librtmp library.\n"); | ||
36 | + printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision()); | ||
37 | + | ||
38 | + if (argc <= 2) { | ||
39 | + printf("Usage: %s <rtmp_url> <flv_path>\n" | ||
40 | + " rtmp_url RTMP stream url to play\n" | ||
41 | + " flv_path The flv file path to save\n" | ||
42 | + "For example:\n" | ||
43 | + " %s rtmp://127.0.0.1:1935/live/livestream output.flv\n", | ||
44 | + argv[0], argv[0]); | ||
45 | + exit(-1); | ||
46 | + } | ||
47 | + | ||
48 | + srs_human_trace("rtmp url: %s", argv[1]); | ||
49 | + srs_human_trace("flv path: %s", argv[2]); | ||
50 | + srs_rtmp_t rtmp = srs_rtmp_create(argv[1]); | ||
51 | + | ||
52 | + if (srs_rtmp_handshake(rtmp) != 0) { | ||
53 | + srs_human_trace("simple handshake failed."); | ||
54 | + goto rtmp_destroy; | ||
55 | + } | ||
56 | + srs_human_trace("simple handshake success"); | ||
57 | + | ||
58 | + if (srs_rtmp_connect_app(rtmp) != 0) { | ||
59 | + srs_human_trace("connect vhost/app failed."); | ||
60 | + goto rtmp_destroy; | ||
61 | + } | ||
62 | + srs_human_trace("connect vhost/app success"); | ||
63 | + | ||
64 | + if (srs_rtmp_play_stream(rtmp) != 0) { | ||
65 | + srs_human_trace("play stream failed."); | ||
66 | + goto rtmp_destroy; | ||
67 | + } | ||
68 | + srs_human_trace("play stream success"); | ||
69 | + | ||
70 | + srs_flv_t flv = srs_flv_open_write(argv[2]); | ||
71 | + | ||
72 | + // flv header | ||
73 | + char header[9]; | ||
74 | + // 3bytes, signature, "FLV", | ||
75 | + header[0] = 'F'; | ||
76 | + header[1] = 'L'; | ||
77 | + header[2] = 'V'; | ||
78 | + // 1bytes, version, 0x01, | ||
79 | + header[3] = 0x01; | ||
80 | + // 1bytes, flags, UB[5] 0, UB[1] audio present, UB[1] 0, UB[1] video present. | ||
81 | + header[4] = 0x03; // audio + video. | ||
82 | + // 4bytes, dataoffset | ||
83 | + header[5] = 0x00; | ||
84 | + header[6] = 0x00; | ||
85 | + header[7] = 0x00; | ||
86 | + header[8] = 0x09; | ||
87 | + if (srs_flv_write_header(flv, header) != 0) { | ||
88 | + srs_human_trace("write flv header failed."); | ||
89 | + goto rtmp_destroy; | ||
90 | + } | ||
91 | + | ||
92 | + for (;;) { | ||
93 | + int size; | ||
94 | + char type; | ||
95 | + char* data; | ||
96 | + u_int32_t timestamp; | ||
97 | + | ||
98 | + if (srs_rtmp_read_packet(rtmp, &type, ×tamp, &data, &size) != 0) { | ||
99 | + srs_human_trace("read rtmp packet failed."); | ||
100 | + goto rtmp_destroy; | ||
101 | + } | ||
102 | + | ||
103 | + if (srs_human_print_rtmp_packet(type, timestamp, data, size) != 0) { | ||
104 | + srs_human_trace("print rtmp packet failed."); | ||
105 | + goto rtmp_destroy; | ||
106 | + } | ||
107 | + | ||
108 | + if (srs_flv_write_tag(flv, type, timestamp, data, size) != 0) { | ||
109 | + srs_human_trace("dump rtmp packet failed."); | ||
110 | + goto rtmp_destroy; | ||
111 | + } | ||
112 | + | ||
113 | + free(data); | ||
114 | + } | ||
115 | + | ||
116 | +rtmp_destroy: | ||
117 | + srs_rtmp_destroy(rtmp); | ||
118 | + srs_flv_close(flv); | ||
119 | + srs_human_trace("completed"); | ||
120 | + | ||
121 | + return 0; | ||
122 | +} |
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
31 | // current release version | 31 | // current release version |
32 | #define VERSION_MAJOR 2 | 32 | #define VERSION_MAJOR 2 |
33 | #define VERSION_MINOR 0 | 33 | #define VERSION_MINOR 0 |
34 | -#define VERSION_REVISION 36 | 34 | +#define VERSION_REVISION 37 |
35 | // server info. | 35 | // server info. |
36 | #define RTMP_SIG_SRS_KEY "SRS" | 36 | #define RTMP_SIG_SRS_KEY "SRS" |
37 | #define RTMP_SIG_SRS_ROLE "origin/edge server" | 37 | #define RTMP_SIG_SRS_ROLE "origin/edge server" |
@@ -141,6 +141,7 @@ file | @@ -141,6 +141,7 @@ file | ||
141 | ..\..\research\librtmp\srs_ingest_rtmp.c, | 141 | ..\..\research\librtmp\srs_ingest_rtmp.c, |
142 | ..\..\research\librtmp\srs_play.c, | 142 | ..\..\research\librtmp\srs_play.c, |
143 | ..\..\research\librtmp\srs_publish.c, | 143 | ..\..\research\librtmp\srs_publish.c, |
144 | + ..\..\research\librtmp\srs_rtmp_dump.c, | ||
144 | ..\..\research\hls\ts_info.cc; | 145 | ..\..\research\hls\ts_info.cc; |
145 | 146 | ||
146 | mainconfig | 147 | mainconfig |
-
请 注册 或 登录 后发表评论