正在显示
1 个修改的文件
包含
21 行增加
和
12 行删除
@@ -34,18 +34,26 @@ gcc srs_h264_raw_publish.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_h | @@ -34,18 +34,26 @@ gcc srs_h264_raw_publish.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_h | ||
34 | 34 | ||
35 | int main(int argc, char** argv) | 35 | int main(int argc, char** argv) |
36 | { | 36 | { |
37 | - srs_rtmp_t rtmp; | ||
38 | - | ||
39 | - // packet data | ||
40 | - int type, size; | ||
41 | - u_int32_t timestamp = 0; | ||
42 | - char* data; | ||
43 | - | ||
44 | srs_trace("publish raw h.264 as rtmp stream to server like FMLE/FFMPEG/Encoder"); | 37 | srs_trace("publish raw h.264 as rtmp stream to server like FMLE/FFMPEG/Encoder"); |
45 | srs_trace("srs(simple-rtmp-server) client librtmp library."); | 38 | srs_trace("srs(simple-rtmp-server) client librtmp library."); |
46 | - srs_trace("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision()); | 39 | + srs_trace("version: %d.%d.%d", srs_version_major(), srs_version_minor(), srs_version_revision()); |
47 | 40 | ||
48 | - rtmp = srs_rtmp_create("rtmp://127.0.0.1:1935/live/livestream"); | 41 | + if (argc <= 2) { |
42 | + srs_trace("Usage: %s <h264_raw_file> <rtmp_publish_url>", argv[0]); | ||
43 | + srs_trace(" h264_raw_file: the raw h264 steam file."); | ||
44 | + srs_trace(" rtmp_publish_url: the rtmp publish url."); | ||
45 | + srs_trace("For example:"); | ||
46 | + srs_trace(" %s ./720p.h264.raw rtmp://127.0.0.1:1935/live/livestream", argv[0]); | ||
47 | + srs_trace("Where the file: http://winlinvip.github.io/srs.release/3rdparty/720p.h264.raw"); | ||
48 | + srs_trace("See: https://github.com/winlinvip/simple-rtmp-server/issues/66"); | ||
49 | + exit(-1); | ||
50 | + } | ||
51 | + | ||
52 | + const char* raw_file = argv[1]; | ||
53 | + const char* rtmp_url = argv[2]; | ||
54 | + srs_trace("raw_file=%s, rtmp_url=%s", raw_file, rtmp_url); | ||
55 | + | ||
56 | + srs_rtmp_t rtmp = srs_rtmp_create(rtmp_url); | ||
49 | 57 | ||
50 | if (srs_simple_handshake(rtmp) != 0) { | 58 | if (srs_simple_handshake(rtmp) != 0) { |
51 | srs_trace("simple handshake failed."); | 59 | srs_trace("simple handshake failed."); |
@@ -65,11 +73,12 @@ int main(int argc, char** argv) | @@ -65,11 +73,12 @@ int main(int argc, char** argv) | ||
65 | } | 73 | } |
66 | srs_trace("publish stream success"); | 74 | srs_trace("publish stream success"); |
67 | 75 | ||
76 | + u_int32_t timestamp = 0; | ||
68 | for (;;) { | 77 | for (;;) { |
69 | - type = SRS_RTMP_TYPE_VIDEO; | 78 | + int type = SRS_RTMP_TYPE_VIDEO; |
70 | timestamp += 40; | 79 | timestamp += 40; |
71 | - size = 4096; | ||
72 | - data = (char*)malloc(4096); | 80 | + int size = 4096; |
81 | + char* data = (char*)malloc(4096); | ||
73 | 82 | ||
74 | if (srs_write_packet(rtmp, type, timestamp, data, size) != 0) { | 83 | if (srs_write_packet(rtmp, type, timestamp, data, size) != 0) { |
75 | goto rtmp_destroy; | 84 | goto rtmp_destroy; |
-
请 注册 或 登录 后发表评论