mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Remove using of connect_app2.
This commit is contained in:
parent
26c20db2b3
commit
68a5407b3a
3 changed files with 263 additions and 236 deletions
|
@ -26,36 +26,67 @@
|
|||
|
||||
#include "../../objs/include/srs_librtmp.h"
|
||||
|
||||
// srs debug info.
|
||||
char* ip = NULL;
|
||||
char* sig = NULL;
|
||||
int pid = 0, cid = 0;
|
||||
int major = 0, minor = 0, revision= 0, build = 0;
|
||||
// bandwidth test data.
|
||||
int64_t start_time = 0;
|
||||
int64_t end_time = 0;
|
||||
int play_kbps = 0;
|
||||
int publish_kbps = 0;
|
||||
int play_bytes = 0;
|
||||
int publish_bytes = 0;
|
||||
int play_duration = 0;
|
||||
int publish_duration = 0;
|
||||
|
||||
int do_check(srs_rtmp_t rtmp)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if ((ret = srs_rtmp_handshake(rtmp)) != 0) {
|
||||
srs_human_trace("simple handshake failed.");
|
||||
return ret;
|
||||
}
|
||||
srs_human_trace("simple handshake success");
|
||||
|
||||
if ((ret = srs_rtmp_connect_app(rtmp)) != 0) {
|
||||
srs_human_trace("connect vhost/app failed.");
|
||||
return ret;
|
||||
}
|
||||
srs_human_trace("connect vhost/app success");
|
||||
|
||||
if ((ret = srs_rtmp_get_server_sig(rtmp, &sig)) != 0) {
|
||||
srs_human_trace("Retrieve server ID failed, ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
if ((ret = srs_rtmp_get_server_id(rtmp, &ip, &pid, &cid)) != 0) {
|
||||
srs_human_trace("Retrieve server ID failed, ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
if ((ret = srs_rtmp_get_server_version(rtmp, &major, &minor, &revision, &build)) != 0) {
|
||||
srs_human_trace("Retrieve server version failed, ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = srs_rtmp_bandwidth_check(rtmp,
|
||||
&start_time, &end_time, &play_kbps, &publish_kbps,
|
||||
&play_bytes, &publish_bytes, &play_duration, &publish_duration)) != 0
|
||||
) {
|
||||
srs_human_trace("bandwidth check/test failed.");
|
||||
return ret;
|
||||
}
|
||||
srs_human_trace("bandwidth check/test success");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int ret = 0;
|
||||
srs_rtmp_t rtmp;
|
||||
|
||||
// srs debug info.
|
||||
char srs_server_ip[128];
|
||||
char srs_server[128];
|
||||
char srs_primary[128];
|
||||
char srs_authors[128];
|
||||
char srs_version[32];
|
||||
int srs_id = 0;
|
||||
int srs_pid = 0;
|
||||
// bandwidth test data.
|
||||
int64_t start_time = 0;
|
||||
int64_t end_time = 0;
|
||||
int play_kbps = 0;
|
||||
int publish_kbps = 0;
|
||||
int play_bytes = 0;
|
||||
int publish_bytes = 0;
|
||||
int play_duration = 0;
|
||||
int publish_duration = 0;
|
||||
|
||||
// set to zero.
|
||||
srs_server_ip[0] = 0;
|
||||
srs_server[0] = 0;
|
||||
srs_primary[0] = 0;
|
||||
srs_authors[0] = 0;
|
||||
srs_version[0] = 0;
|
||||
|
||||
printf("RTMP bandwidth check/test with server.\n");
|
||||
printf("srs(ossrs) client librtmp library.\n");
|
||||
printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision());
|
||||
|
@ -75,52 +106,30 @@ int main(int argc, char** argv)
|
|||
char url[512];
|
||||
snprintf(url, sizeof(url), "%s/%s", argv[1], "livestream");
|
||||
rtmp = srs_rtmp_create((const char*)url);
|
||||
|
||||
srs_human_trace("bandwidth check/test url: %s", argv[1]);
|
||||
|
||||
if ((ret = srs_rtmp_handshake(rtmp)) != 0) {
|
||||
srs_human_trace("simple handshake failed.");
|
||||
if ((ret = do_check(rtmp)) != 0) {
|
||||
goto rtmp_destroy;
|
||||
}
|
||||
srs_human_trace("simple handshake success");
|
||||
|
||||
if ((ret = srs_rtmp_connect_app2(rtmp,
|
||||
srs_server_ip, srs_server, srs_primary, srs_authors, srs_version,
|
||||
&srs_id, &srs_pid)) != 0) {
|
||||
srs_human_trace("connect vhost/app failed.");
|
||||
goto rtmp_destroy;
|
||||
}
|
||||
srs_human_trace("connect vhost/app success");
|
||||
|
||||
if ((ret = srs_rtmp_bandwidth_check(rtmp,
|
||||
&start_time, &end_time, &play_kbps, &publish_kbps,
|
||||
&play_bytes, &publish_bytes, &play_duration, &publish_duration)) != 0
|
||||
) {
|
||||
srs_human_trace("bandwidth check/test failed.");
|
||||
goto rtmp_destroy;
|
||||
}
|
||||
srs_human_trace("bandwidth check/test success");
|
||||
|
||||
srs_human_trace("\n%s, %s, %s\n"
|
||||
"%s, %s, srs_pid=%d, srs_id=%d\n"
|
||||
"%s, %d.%d.%d.%d, srs_pid=%d, srs_id=%d\n"
|
||||
"duration: %dms(%d+%d)\n"
|
||||
"play: %dkbps\n"
|
||||
"publish: %dkbps",
|
||||
(char*)srs_server, (char*)srs_primary, (char*)srs_authors,
|
||||
(char*)srs_server_ip, (char*)srs_version, srs_pid, srs_id,
|
||||
"publish: %dkbps",
|
||||
(char*)sig, NULL, NULL,
|
||||
(char*)ip, major, minor, revision, build, pid, cid,
|
||||
(int)(end_time - start_time), play_duration, publish_duration,
|
||||
play_kbps,
|
||||
publish_kbps);
|
||||
|
||||
rtmp_destroy:
|
||||
srs_rtmp_destroy(rtmp);
|
||||
|
||||
fprintf(stderr, "{\"code\":%d,"
|
||||
"\"srs_server\":\"%s\", "
|
||||
"\"srs_primary\":\"%s\", "
|
||||
"\"srs_authors\":\"%s\", "
|
||||
"\"srs_server_ip\":\"%s\", "
|
||||
"\"srs_version\":\"%s\", "
|
||||
"\"srs_version\":\"%d.%d.%d.%d\", "
|
||||
"\"srs_pid\":%d, "
|
||||
"\"srs_id\":%d, "
|
||||
"\"duration\":%d, "
|
||||
|
@ -130,10 +139,11 @@ rtmp_destroy:
|
|||
"\"publish_kbps\":%d"
|
||||
"}",
|
||||
ret,
|
||||
(char*)srs_server, (char*)srs_primary, (char*)srs_authors,
|
||||
(char*)srs_server_ip, (char*)srs_version, srs_pid, srs_id,
|
||||
(char*)sig, NULL, NULL,
|
||||
(char*)ip, major, minor, revision, build, pid, cid,
|
||||
(int)(end_time - start_time), play_duration, publish_duration,
|
||||
play_kbps, publish_kbps);
|
||||
srs_rtmp_destroy(rtmp);
|
||||
|
||||
srs_human_trace(" ");
|
||||
srs_human_trace("completed");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue