Merge branch 'srs.master'

pull/133/head
winlin 10 years ago
commit 14e6caeeb8

@ -62,6 +62,10 @@ int main(int argc, char** argv)
srs_primary_authors[0] = 0; srs_primary_authors[0] = 0;
srs_version[0] = 0; srs_version[0] = 0;
printf("RTMP bandwidth check/test with server.\n");
printf("srs(simple-rtmp-server) client librtmp library.\n");
printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision());
if (argc <= 1) { if (argc <= 1) {
printf("RTMP bandwidth check/test with server.\n" printf("RTMP bandwidth check/test with server.\n"
"Usage: %s <rtmp_url>\n" "Usage: %s <rtmp_url>\n"
@ -71,45 +75,40 @@ int main(int argc, char** argv)
" %s rtmp://127.0.0.1:1935/app?key=35c9b402c12a7246868752e2878f7e0e,vhost=bandcheck.srs.com>/dev/null\n" " %s rtmp://127.0.0.1:1935/app?key=35c9b402c12a7246868752e2878f7e0e,vhost=bandcheck.srs.com>/dev/null\n"
"@remark, output text to stdout, while json to stderr.\n", "@remark, output text to stdout, while json to stderr.\n",
argv[0], argv[0], argv[0]); argv[0], argv[0], argv[0]);
ret = 1; exit(-1);
exit(ret);
return ret;
} }
rtmp = srs_rtmp_create2(argv[1]); rtmp = srs_rtmp_create2(argv[1]);
printf("RTMP bandwidth check/test with server.\n"); srs_trace("bandwidth check/test url: %s", argv[1]);
printf("srs(simple-rtmp-server) client librtmp library.\n");
printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision());
printf("bandwidth check/test url: %s\n", argv[1]);
if ((ret = srs_simple_handshake(rtmp)) != 0) { if ((ret = srs_simple_handshake(rtmp)) != 0) {
printf("simple handshake failed.\n"); srs_trace("simple handshake failed.");
goto rtmp_destroy; goto rtmp_destroy;
} }
printf("simple handshake success\n"); srs_trace("simple handshake success");
if ((ret = srs_connect_app2(rtmp, if ((ret = srs_connect_app2(rtmp,
srs_server_ip, srs_server, srs_primary_authors, srs_version, &srs_id, &srs_pid)) != 0) { srs_server_ip, srs_server, srs_primary_authors, srs_version, &srs_id, &srs_pid)) != 0) {
printf("connect vhost/app failed.\n"); srs_trace("connect vhost/app failed.");
goto rtmp_destroy; goto rtmp_destroy;
} }
printf("connect vhost/app success\n"); srs_trace("connect vhost/app success");
if ((ret = srs_bandwidth_check(rtmp, if ((ret = srs_bandwidth_check(rtmp,
&start_time, &end_time, &play_kbps, &publish_kbps, &start_time, &end_time, &play_kbps, &publish_kbps,
&play_bytes, &publish_bytes, &play_duration, &publish_duration)) != 0 &play_bytes, &publish_bytes, &play_duration, &publish_duration)) != 0
) { ) {
printf("bandwidth check/test failed.\n"); srs_trace("bandwidth check/test failed.");
goto rtmp_destroy; goto rtmp_destroy;
} }
printf("bandwidth check/test success\n"); srs_trace("bandwidth check/test success");
printf("\n%s, %s\n" srs_trace("\n%s, %s\n"
"%s, %s, srs_pid=%d, srs_id=%d\n" "%s, %s, srs_pid=%d, srs_id=%d\n"
"duration: %dms(%d+%d)\n" "duration: %dms(%d+%d)\n"
"play: %dkbps\n" "play: %dkbps\n"
"publish: %dkbps\n\n", "publish: %dkbps",
(char*)srs_server, (char*)srs_primary_authors, (char*)srs_server, (char*)srs_primary_authors,
(char*)srs_server_ip, (char*)srs_version, srs_pid, srs_id, (char*)srs_server_ip, (char*)srs_version, srs_pid, srs_id,
(int)(end_time - start_time), play_duration, publish_duration, (int)(end_time - start_time), play_duration, publish_duration,
@ -119,8 +118,6 @@ int main(int argc, char** argv)
rtmp_destroy: rtmp_destroy:
srs_rtmp_destroy(rtmp); srs_rtmp_destroy(rtmp);
printf("terminate with ret=%d\n\n", ret);
fprintf(stderr, "{\"code\":%d," fprintf(stderr, "{\"code\":%d,"
"\"srs_server\":\"%s\", " "\"srs_server\":\"%s\", "
"\"srs_primary_authors\":\"%s\", " "\"srs_primary_authors\":\"%s\", "
@ -138,5 +135,9 @@ rtmp_destroy:
(char*)srs_server_ip, (char*)srs_version, srs_pid, srs_id, (char*)srs_server_ip, (char*)srs_version, srs_pid, srs_id,
(int)(end_time - start_time), play_duration, publish_duration, (int)(end_time - start_time), play_duration, publish_duration,
play_kbps, publish_kbps); play_kbps, publish_kbps);
srs_trace("");
srs_trace("completed");
return ret; return ret;
} }

@ -84,7 +84,7 @@ int main(int argc, char** argv)
if (duration <= 0 || timeout <= 0) { if (duration <= 0 || timeout <= 0) {
srs_trace("duration and timeout must be positive."); srs_trace("duration and timeout must be positive.");
exit(-1); exit(-2);
} }
rtmp = srs_rtmp_create(rtmp_url); rtmp = srs_rtmp_create(rtmp_url);

Loading…
Cancel
Save