mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
fix bug of buffer assert, erase can accept any value
This commit is contained in:
parent
d48d739fa7
commit
a639eb0596
4 changed files with 29 additions and 12 deletions
|
@ -79,8 +79,8 @@ int main(int argc, char** argv)
|
|||
printf("duration: %ds, timeout:%ds\n", duration, timeout);
|
||||
|
||||
if (duration <= 0 || timeout <= 0) {
|
||||
printf("duration and timeout must be positive.\n");
|
||||
ret = 1;
|
||||
fprintf(stderr, "duration and timeout must be positive. ret=%d\n", ret);
|
||||
exit(ret);
|
||||
return ret;
|
||||
}
|
||||
|
@ -88,33 +88,33 @@ int main(int argc, char** argv)
|
|||
rtmp = srs_rtmp_create(rtmp_url);
|
||||
|
||||
if ((ret = __srs_dns_resolve(rtmp)) != 0) {
|
||||
printf("dns resolve failed.\n");
|
||||
fprintf(stderr, "dns resolve failed. ret=%d\n", ret);
|
||||
goto rtmp_destroy;
|
||||
}
|
||||
printf("dns resolve success\n");
|
||||
time_dns_resolve = srs_get_time_ms();
|
||||
|
||||
if ((ret = __srs_connect_server(rtmp)) != 0) {
|
||||
printf("socket connect failed.\n");
|
||||
fprintf(stderr, "socket connect failed. ret=%d\n", ret);
|
||||
goto rtmp_destroy;
|
||||
}
|
||||
printf("socket connect success\n");
|
||||
time_socket_connect = srs_get_time_ms();
|
||||
|
||||
if ((ret = __srs_do_simple_handshake(rtmp)) != 0) {
|
||||
printf("do simple handshake failed.\n");
|
||||
fprintf(stderr, "do simple handshake failed. ret=%d\n", ret);
|
||||
goto rtmp_destroy;
|
||||
}
|
||||
printf("do simple handshake success\n");
|
||||
|
||||
if ((ret = srs_connect_app(rtmp)) != 0) {
|
||||
printf("connect vhost/app failed.\n");
|
||||
fprintf(stderr, "connect vhost/app failed. ret=%d\n", ret);
|
||||
goto rtmp_destroy;
|
||||
}
|
||||
printf("connect vhost/app success\n");
|
||||
|
||||
if ((ret = srs_play_stream(rtmp)) != 0) {
|
||||
printf("play stream failed.\n");
|
||||
fprintf(stderr, "play stream failed. ret=%d\n", ret);
|
||||
goto rtmp_destroy;
|
||||
}
|
||||
printf("play stream success\n");
|
||||
|
@ -122,6 +122,7 @@ int main(int argc, char** argv)
|
|||
|
||||
for (;;) {
|
||||
if ((ret = srs_read_packet(rtmp, &type, ×tamp, &data, &size)) != 0) {
|
||||
fprintf(stderr, "read packet failed. ret=%d\n", ret);
|
||||
goto rtmp_destroy;
|
||||
}
|
||||
printf("got packet: type=%s, time=%d, size=%d\n", srs_type2string(type), timestamp, size);
|
||||
|
@ -158,7 +159,7 @@ rtmp_destroy:
|
|||
"\"%s\":%d, " // #6
|
||||
"\"%s\":%d, " // #7
|
||||
"\"%s\":%d, " // #8
|
||||
"%s%s%s%s}",
|
||||
"%s,%s,%s,%s}",
|
||||
"code", ret, //#0
|
||||
// total = dns + tcp_connect + start_play + first_packet + last_packet
|
||||
"total", (int)(time_cleanup - time_startup), //#1
|
||||
|
@ -173,12 +174,12 @@ rtmp_destroy:
|
|||
// delay = actual - expect
|
||||
"delay", (int)(timestamp - (time_cleanup - time_first_packet)), //#8
|
||||
// unit in ms.
|
||||
"\"unit\": \"ms\",",
|
||||
"\"remark0\": \"total = dns + tcp_connect + start_play + first_packet + last_packet\",",
|
||||
"\"unit\": \"ms\"",
|
||||
"\"remark0\": \"total = dns + tcp_connect + start_play + first_packet + last_packet\"",
|
||||
"\"remark1\": \"delay = stream - (time_cleanup - time_first_packet)\"",
|
||||
"\"remark2\": \"if code is not 0, user must ignore all data\""
|
||||
);
|
||||
printf("\n");
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue