正在显示
2 个修改的文件
包含
19 行增加
和
18 行删除
@@ -62,6 +62,10 @@ int main(int argc, char** argv) | @@ -62,6 +62,10 @@ int main(int argc, char** argv) | ||
62 | srs_primary_authors[0] = 0; | 62 | srs_primary_authors[0] = 0; |
63 | srs_version[0] = 0; | 63 | srs_version[0] = 0; |
64 | 64 | ||
65 | + printf("RTMP bandwidth check/test with server.\n"); | ||
66 | + printf("srs(simple-rtmp-server) client librtmp library.\n"); | ||
67 | + printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision()); | ||
68 | + | ||
65 | if (argc <= 1) { | 69 | if (argc <= 1) { |
66 | printf("RTMP bandwidth check/test with server.\n" | 70 | printf("RTMP bandwidth check/test with server.\n" |
67 | "Usage: %s <rtmp_url>\n" | 71 | "Usage: %s <rtmp_url>\n" |
@@ -71,45 +75,40 @@ int main(int argc, char** argv) | @@ -71,45 +75,40 @@ int main(int argc, char** argv) | ||
71 | " %s rtmp://127.0.0.1:1935/app?key=35c9b402c12a7246868752e2878f7e0e,vhost=bandcheck.srs.com>/dev/null\n" | 75 | " %s rtmp://127.0.0.1:1935/app?key=35c9b402c12a7246868752e2878f7e0e,vhost=bandcheck.srs.com>/dev/null\n" |
72 | "@remark, output text to stdout, while json to stderr.\n", | 76 | "@remark, output text to stdout, while json to stderr.\n", |
73 | argv[0], argv[0], argv[0]); | 77 | argv[0], argv[0], argv[0]); |
74 | - ret = 1; | ||
75 | - exit(ret); | ||
76 | - return ret; | 78 | + exit(-1); |
77 | } | 79 | } |
78 | 80 | ||
79 | rtmp = srs_rtmp_create2(argv[1]); | 81 | rtmp = srs_rtmp_create2(argv[1]); |
80 | 82 | ||
81 | - printf("RTMP bandwidth check/test with server.\n"); | ||
82 | - printf("srs(simple-rtmp-server) client librtmp library.\n"); | ||
83 | - printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision()); | ||
84 | - printf("bandwidth check/test url: %s\n", argv[1]); | 83 | + srs_trace("bandwidth check/test url: %s", argv[1]); |
85 | 84 | ||
86 | if ((ret = srs_simple_handshake(rtmp)) != 0) { | 85 | if ((ret = srs_simple_handshake(rtmp)) != 0) { |
87 | - printf("simple handshake failed.\n"); | 86 | + srs_trace("simple handshake failed."); |
88 | goto rtmp_destroy; | 87 | goto rtmp_destroy; |
89 | } | 88 | } |
90 | - printf("simple handshake success\n"); | 89 | + srs_trace("simple handshake success"); |
91 | 90 | ||
92 | if ((ret = srs_connect_app2(rtmp, | 91 | if ((ret = srs_connect_app2(rtmp, |
93 | srs_server_ip, srs_server, srs_primary_authors, srs_version, &srs_id, &srs_pid)) != 0) { | 92 | srs_server_ip, srs_server, srs_primary_authors, srs_version, &srs_id, &srs_pid)) != 0) { |
94 | - printf("connect vhost/app failed.\n"); | 93 | + srs_trace("connect vhost/app failed."); |
95 | goto rtmp_destroy; | 94 | goto rtmp_destroy; |
96 | } | 95 | } |
97 | - printf("connect vhost/app success\n"); | 96 | + srs_trace("connect vhost/app success"); |
98 | 97 | ||
99 | if ((ret = srs_bandwidth_check(rtmp, | 98 | if ((ret = srs_bandwidth_check(rtmp, |
100 | &start_time, &end_time, &play_kbps, &publish_kbps, | 99 | &start_time, &end_time, &play_kbps, &publish_kbps, |
101 | &play_bytes, &publish_bytes, &play_duration, &publish_duration)) != 0 | 100 | &play_bytes, &publish_bytes, &play_duration, &publish_duration)) != 0 |
102 | ) { | 101 | ) { |
103 | - printf("bandwidth check/test failed.\n"); | 102 | + srs_trace("bandwidth check/test failed."); |
104 | goto rtmp_destroy; | 103 | goto rtmp_destroy; |
105 | } | 104 | } |
106 | - printf("bandwidth check/test success\n"); | 105 | + srs_trace("bandwidth check/test success"); |
107 | 106 | ||
108 | - printf("\n%s, %s\n" | 107 | + srs_trace("\n%s, %s\n" |
109 | "%s, %s, srs_pid=%d, srs_id=%d\n" | 108 | "%s, %s, srs_pid=%d, srs_id=%d\n" |
110 | "duration: %dms(%d+%d)\n" | 109 | "duration: %dms(%d+%d)\n" |
111 | "play: %dkbps\n" | 110 | "play: %dkbps\n" |
112 | - "publish: %dkbps\n\n", | 111 | + "publish: %dkbps", |
113 | (char*)srs_server, (char*)srs_primary_authors, | 112 | (char*)srs_server, (char*)srs_primary_authors, |
114 | (char*)srs_server_ip, (char*)srs_version, srs_pid, srs_id, | 113 | (char*)srs_server_ip, (char*)srs_version, srs_pid, srs_id, |
115 | (int)(end_time - start_time), play_duration, publish_duration, | 114 | (int)(end_time - start_time), play_duration, publish_duration, |
@@ -119,8 +118,6 @@ int main(int argc, char** argv) | @@ -119,8 +118,6 @@ int main(int argc, char** argv) | ||
119 | rtmp_destroy: | 118 | rtmp_destroy: |
120 | srs_rtmp_destroy(rtmp); | 119 | srs_rtmp_destroy(rtmp); |
121 | 120 | ||
122 | - printf("terminate with ret=%d\n\n", ret); | ||
123 | - | ||
124 | fprintf(stderr, "{\"code\":%d," | 121 | fprintf(stderr, "{\"code\":%d," |
125 | "\"srs_server\":\"%s\", " | 122 | "\"srs_server\":\"%s\", " |
126 | "\"srs_primary_authors\":\"%s\", " | 123 | "\"srs_primary_authors\":\"%s\", " |
@@ -138,5 +135,9 @@ rtmp_destroy: | @@ -138,5 +135,9 @@ rtmp_destroy: | ||
138 | (char*)srs_server_ip, (char*)srs_version, srs_pid, srs_id, | 135 | (char*)srs_server_ip, (char*)srs_version, srs_pid, srs_id, |
139 | (int)(end_time - start_time), play_duration, publish_duration, | 136 | (int)(end_time - start_time), play_duration, publish_duration, |
140 | play_kbps, publish_kbps); | 137 | play_kbps, publish_kbps); |
138 | + | ||
139 | + srs_trace(""); | ||
140 | + srs_trace("completed"); | ||
141 | + | ||
141 | return ret; | 142 | return ret; |
142 | } | 143 | } |
@@ -84,7 +84,7 @@ int main(int argc, char** argv) | @@ -84,7 +84,7 @@ int main(int argc, char** argv) | ||
84 | 84 | ||
85 | if (duration <= 0 || timeout <= 0) { | 85 | if (duration <= 0 || timeout <= 0) { |
86 | srs_trace("duration and timeout must be positive."); | 86 | srs_trace("duration and timeout must be positive."); |
87 | - exit(-1); | 87 | + exit(-2); |
88 | } | 88 | } |
89 | 89 | ||
90 | rtmp = srs_rtmp_create(rtmp_url); | 90 | rtmp = srs_rtmp_create(rtmp_url); |
-
请 注册 或 登录 后发表评论