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

refine code, rename the human functions to prefixed with srs_human_

This commit is contained in:
winlin 2014-11-21 14:03:30 +08:00
parent 30e7c38a48
commit b3bb2cdf2b
12 changed files with 190 additions and 190 deletions

View file

@ -89,19 +89,19 @@ int main(int argc, char** argv)
}
}
srs_lib_trace("input: %s", in_flv_file);
srs_lib_trace("output: %s", out_rtmp_url);
srs_human_trace("input: %s", in_flv_file);
srs_human_trace("output: %s", out_rtmp_url);
if ((flv = srs_flv_open_read(in_flv_file)) == NULL) {
ret = 2;
srs_lib_trace("open flv file failed. ret=%d", ret);
srs_human_trace("open flv file failed. ret=%d", ret);
return ret;
}
ortmp = srs_rtmp_create(out_rtmp_url);
ret = proxy(flv, ortmp);
srs_lib_trace("ingest flv to RTMP completed");
srs_human_trace("ingest flv to RTMP completed");
srs_rtmp_destroy(ortmp);
srs_flv_close(flv);
@ -118,20 +118,20 @@ int do_proxy(srs_flv_t flv, srs_rtmp_t ortmp, int64_t re, int32_t* pstarttime, u
int size;
char* data = NULL;
srs_lib_trace("start ingest flv to RTMP stream");
srs_human_trace("start ingest flv to RTMP stream");
for (;;) {
// tag header
if ((ret = srs_flv_read_tag_header(flv, &type, &size, ptimestamp)) != 0) {
if (srs_flv_is_eof(ret)) {
srs_lib_trace("parse completed.");
srs_human_trace("parse completed.");
return 0;
}
srs_lib_trace("flv get packet failed. ret=%d", ret);
srs_human_trace("flv get packet failed. ret=%d", ret);
return ret;
}
if (size <= 0) {
srs_lib_trace("invalid size=%d", size);
srs_human_trace("invalid size=%d", size);
break;
}
@ -143,13 +143,13 @@ int do_proxy(srs_flv_t flv, srs_rtmp_t ortmp, int64_t re, int32_t* pstarttime, u
u_int32_t timestamp = *ptimestamp;
if ((ret = srs_print_rtmp_packet(type, timestamp, data, size)) != 0) {
srs_lib_trace("print packet failed. ret=%d", ret);
if ((ret = srs_human_print_rtmp_packet(type, timestamp, data, size)) != 0) {
srs_human_trace("print packet failed. ret=%d", ret);
return ret;
}
if ((ret = srs_write_packet(ortmp, type, *ptimestamp, data, size)) != 0) {
srs_lib_trace("irtmp get packet failed. ret=%d", ret);
srs_human_trace("irtmp get packet failed. ret=%d", ret);
return ret;
}
@ -192,22 +192,22 @@ int connect_oc(srs_rtmp_t ortmp)
int ret = 0;
if ((ret = srs_simple_handshake(ortmp)) != 0) {
srs_lib_trace("ortmp simple handshake failed. ret=%d", ret);
srs_human_trace("ortmp simple handshake failed. ret=%d", ret);
return ret;
}
srs_lib_trace("ortmp simple handshake success");
srs_human_trace("ortmp simple handshake success");
if ((ret = srs_connect_app(ortmp)) != 0) {
srs_lib_trace("ortmp connect vhost/app failed. ret=%d", ret);
srs_human_trace("ortmp connect vhost/app failed. ret=%d", ret);
return ret;
}
srs_lib_trace("ortmp connect vhost/app success");
srs_human_trace("ortmp connect vhost/app success");
if ((ret = srs_publish_stream(ortmp)) != 0) {
srs_lib_trace("ortmp publish stream failed. ret=%d", ret);
srs_human_trace("ortmp publish stream failed. ret=%d", ret);
return ret;
}
srs_lib_trace("ortmp publish stream success");
srs_human_trace("ortmp publish stream success");
return ret;
}
@ -219,16 +219,16 @@ int64_t re_create()
// use the starttime to get the deviation
int64_t deviation = re - tools_main_entrance_startup_time;
srs_lib_trace("deviation is %d ms, pulse is %d ms", (int)(deviation), (int)(RE_PULSE_MS));
srs_human_trace("deviation is %d ms, pulse is %d ms", (int)(deviation), (int)(RE_PULSE_MS));
// so, we adjust time to max(0, deviation)
// because the last pulse, we already sleeped
int adjust = (int)(deviation);
if (adjust > 0) {
srs_lib_trace("adjust re time for %d ms", adjust);
srs_human_trace("adjust re time for %d ms", adjust);
re -= adjust;
} else {
srs_lib_trace("no need to adjust re time");
srs_human_trace("no need to adjust re time");
}
return re;
@ -249,7 +249,7 @@ void re_cleanup(int64_t re, int32_t starttime, u_int32_t time)
int64_t now = srs_get_time_ms();
int64_t diff = time - starttime - (now -re);
if (diff > 0) {
srs_lib_trace("re_cleanup, diff=%d, start=%d, last=%d ms",
srs_human_trace("re_cleanup, diff=%d, start=%d, last=%d ms",
(int)diff, starttime, time);
usleep(diff * 1000);
}