1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

refine librtmp api, add prefix utils for utilities.

This commit is contained in:
winlin 2014-11-21 14:09:17 +08:00
parent b3bb2cdf2b
commit 10bc5399ec
4 changed files with 36 additions and 31 deletions

View file

@ -35,7 +35,7 @@ int main(int argc, char** argv)
srs_rtmp_t rtmp;
// time
int64_t time_startup = srs_get_time_ms();
int64_t time_startup = srs_utils_get_time_ms();
int64_t time_dns_resolve = 0;
int64_t time_socket_connect = 0;
int64_t time_play_stream = 0;
@ -95,14 +95,14 @@ int main(int argc, char** argv)
goto rtmp_destroy;
}
srs_human_trace("dns resolve success");
time_dns_resolve = srs_get_time_ms();
time_dns_resolve = srs_utils_get_time_ms();
if ((ret = __srs_connect_server(rtmp)) != 0) {
srs_human_trace("socket connect failed. ret=%d", ret);
goto rtmp_destroy;
}
srs_human_trace("socket connect success");
time_socket_connect = srs_get_time_ms();
time_socket_connect = srs_utils_get_time_ms();
if ((ret = __srs_do_simple_handshake(rtmp)) != 0) {
srs_human_trace("do simple handshake failed. ret=%d", ret);
@ -121,7 +121,7 @@ int main(int argc, char** argv)
goto rtmp_destroy;
}
srs_human_trace("play stream success");
time_play_stream = srs_get_time_ms();
time_play_stream = srs_utils_get_time_ms();
for (;;) {
if ((ret = srs_read_packet(rtmp, &type, &timestamp, &data, &size)) != 0) {
@ -133,7 +133,7 @@ int main(int argc, char** argv)
if (SRS_RTMP_TYPE_VIDEO == type || SRS_RTMP_TYPE_AUDIO == type) {
if (time_first_packet <= 0) {
time_first_packet = srs_get_time_ms();
time_first_packet = srs_utils_get_time_ms();
}
if (basetime <= 0) {
basetime = timestamp;
@ -142,7 +142,7 @@ int main(int argc, char** argv)
free(data);
if (srs_get_time_ms() - time_startup > timeout * 1000) {
if (srs_utils_get_time_ms() - time_startup > timeout * 1000) {
srs_human_trace("timeout, terminate.");
goto rtmp_destroy;
}
@ -154,11 +154,11 @@ int main(int argc, char** argv)
}
rtmp_destroy:
bytes_nsend = srs_get_nsend_bytes(rtmp);
bytes_nrecv = srs_get_nrecv_bytes(rtmp);
bytes_nsend = srs_utils_get_send_bytes(rtmp);
bytes_nrecv = srs_utils_get_recv_bytes(rtmp);
srs_rtmp_destroy(rtmp);
time_cleanup = srs_get_time_ms();
time_cleanup = srs_utils_get_time_ms();
time_duration = (int)(time_cleanup - time_startup);
// print result to stderr.

View file

@ -48,7 +48,7 @@ int main(int argc, char** argv)
int ret = 0;
// main function
tools_main_entrance_startup_time = srs_get_time_ms();
tools_main_entrance_startup_time = srs_utils_get_time_ms();
// user option parse index.
int opt = 0;
@ -215,7 +215,7 @@ int connect_oc(srs_rtmp_t ortmp)
int64_t re_create()
{
// if not very precise, we can directly use this as re.
int64_t re = srs_get_time_ms();
int64_t re = srs_utils_get_time_ms();
// use the starttime to get the deviation
int64_t deviation = re - tools_main_entrance_startup_time;
@ -236,7 +236,7 @@ int64_t re_create()
void re_update(int64_t re, int32_t starttime, u_int32_t time)
{
// send by pulse algorithm.
int64_t now = srs_get_time_ms();
int64_t now = srs_utils_get_time_ms();
int64_t diff = time - starttime - (now -re);
if (diff > RE_PULSE_MS) {
usleep(diff * 1000);
@ -246,7 +246,7 @@ void re_cleanup(int64_t re, int32_t starttime, u_int32_t time)
{
// for the last pulse, always sleep.
// for the virtual live encoder long time publishing.
int64_t now = srs_get_time_ms();
int64_t now = srs_utils_get_time_ms();
int64_t diff = time - starttime - (now -re);
if (diff > 0) {
srs_human_trace("re_cleanup, diff=%d, start=%d, last=%d ms",