winlin

refine librtmp, remove the _get_ for some attribute get.

... ... @@ -35,7 +35,7 @@ int main(int argc, char** argv)
srs_rtmp_t rtmp;
// time
int64_t time_startup = srs_utils_get_time_ms();
int64_t time_startup = srs_utils_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_utils_get_time_ms();
time_dns_resolve = srs_utils_time_ms();
if ((ret = __srs_rtmp_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_utils_get_time_ms();
time_socket_connect = srs_utils_time_ms();
if ((ret = __srs_rtmp_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_utils_get_time_ms();
time_play_stream = srs_utils_time_ms();
for (;;) {
if ((ret = srs_rtmp_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_utils_get_time_ms();
time_first_packet = srs_utils_time_ms();
}
if (basetime <= 0) {
basetime = timestamp;
... ... @@ -142,7 +142,7 @@ int main(int argc, char** argv)
free(data);
if (srs_utils_get_time_ms() - time_startup > timeout * 1000) {
if (srs_utils_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_utils_get_send_bytes(rtmp);
bytes_nrecv = srs_utils_get_recv_bytes(rtmp);
bytes_nsend = srs_utils_send_bytes(rtmp);
bytes_nrecv = srs_utils_recv_bytes(rtmp);
srs_rtmp_destroy(rtmp);
time_cleanup = srs_utils_get_time_ms();
time_cleanup = srs_utils_time_ms();
time_duration = (int)(time_cleanup - time_startup);
// print result to stderr.
... ...
... ... @@ -48,7 +48,7 @@ int main(int argc, char** argv)
int ret = 0;
// main function
tools_main_entrance_startup_time = srs_utils_get_time_ms();
tools_main_entrance_startup_time = srs_utils_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_utils_get_time_ms();
int64_t re = srs_utils_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_utils_get_time_ms();
int64_t now = srs_utils_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_utils_get_time_ms();
int64_t now = srs_utils_time_ms();
int64_t diff = time - starttime - (now -re);
if (diff > 0) {
srs_human_trace("re_cleanup, diff=%d, start=%d, last=%d ms",
... ...
... ... @@ -1712,20 +1712,20 @@ void srs_amf0_strict_array_append(srs_amf0_t amf0, srs_amf0_t value)
obj->append(any);
}
int64_t srs_utils_get_time_ms()
int64_t srs_utils_time_ms()
{
srs_update_system_time_ms();
return srs_get_system_time_ms();
}
int64_t srs_utils_get_send_bytes(srs_rtmp_t rtmp)
int64_t srs_utils_send_bytes(srs_rtmp_t rtmp)
{
srs_assert(rtmp != NULL);
Context* context = (Context*)rtmp;
return context->rtmp->get_send_bytes();
}
int64_t srs_utils_get_recv_bytes(srs_rtmp_t rtmp)
int64_t srs_utils_recv_bytes(srs_rtmp_t rtmp)
{
srs_assert(rtmp != NULL);
Context* context = (Context*)rtmp;
... ... @@ -1773,7 +1773,7 @@ int srs_utils_parse_timestamp(
return ret;
}
char srs_utils_get_flv_video_codec_id(char* data, int size)
char srs_utils_flv_video_codec_id(char* data, int size)
{
if (size < 1) {
return 0;
... ... @@ -1785,7 +1785,7 @@ char srs_utils_get_flv_video_codec_id(char* data, int size)
return codec_id;
}
char srs_utils_get_flv_video_avc_packet_type(char* data, int size)
char srs_utils_flv_video_avc_packet_type(char* data, int size)
{
if (size < 2) {
return -1;
... ... @@ -1804,7 +1804,7 @@ char srs_utils_get_flv_video_avc_packet_type(char* data, int size)
return avc_packet_type;
}
char srs_utils_get_flv_video_frame_type(char* data, int size)
char srs_utils_flv_video_frame_type(char* data, int size)
{
if (size < 1) {
return -1;
... ... @@ -1924,9 +1924,9 @@ int srs_human_print_rtmp_packet(char type, u_int32_t timestamp, char* data, int
if (type == SRS_RTMP_TYPE_VIDEO) {
srs_human_trace("Video packet type=%s, dts=%d, pts=%d, size=%d, %s(%s,%s)",
srs_human_flv_tag_type2string(type), timestamp, pts, size,
srs_human_flv_video_codec_id2string(srs_utils_get_flv_video_codec_id(data, size)),
srs_human_flv_video_avc_packet_type2string(srs_utils_get_flv_video_avc_packet_type(data, size)),
srs_human_flv_video_frame_type2string(srs_utils_get_flv_video_frame_type(data, size))
srs_human_flv_video_codec_id2string(srs_utils_flv_video_codec_id(data, size)),
srs_human_flv_video_avc_packet_type2string(srs_utils_flv_video_avc_packet_type(data, size)),
srs_human_flv_video_frame_type2string(srs_utils_flv_video_frame_type(data, size))
);
} else if (type == SRS_RTMP_TYPE_AUDIO) {
srs_human_trace("Audio packet type=%s, dts=%d, pts=%d, size=%d",
... ...
... ... @@ -592,17 +592,17 @@ extern void srs_amf0_strict_array_append(srs_amf0_t amf0, srs_amf0_t value);
* get the current system time in ms.
* use gettimeofday() to get system time.
*/
extern int64_t srs_utils_get_time_ms();
extern int64_t srs_utils_time_ms();
/**
* get the send bytes.
*/
extern int64_t srs_utils_get_send_bytes(srs_rtmp_t rtmp);
extern int64_t srs_utils_send_bytes(srs_rtmp_t rtmp);
/**
* get the recv bytes.
*/
extern int64_t srs_utils_get_recv_bytes(srs_rtmp_t rtmp);
extern int64_t srs_utils_recv_bytes(srs_rtmp_t rtmp);
/**
* parse the dts and pts by time in header and data in tag,
... ... @@ -635,7 +635,7 @@ extern int srs_utils_parse_timestamp(
* 7 = AVC
* @return the code id. 0 for error.
*/
extern char srs_utils_get_flv_video_codec_id(char* data, int size);
extern char srs_utils_flv_video_codec_id(char* data, int size);
/**
* get the AVCPacketType of video tag.
... ... @@ -646,7 +646,7 @@ extern char srs_utils_get_flv_video_codec_id(char* data, int size);
* not required or supported)
* @return the avc packet type. -1(0xff) for error.
*/
extern char srs_utils_get_flv_video_avc_packet_type(char* data, int size);
extern char srs_utils_flv_video_avc_packet_type(char* data, int size);
/**
* get the FrameType of video tag.
... ... @@ -658,7 +658,7 @@ extern char srs_utils_get_flv_video_avc_packet_type(char* data, int size);
* 5 = video info/command frame
* @return the frame type. 0 for error.
*/
extern char srs_utils_get_flv_video_frame_type(char* data, int size);
extern char srs_utils_flv_video_frame_type(char* data, int size);
/*************************************************************
**************************************************************
... ...