正在显示
4 个修改的文件
包含
36 行增加
和
31 行删除
@@ -35,7 +35,7 @@ int main(int argc, char** argv) | @@ -35,7 +35,7 @@ int main(int argc, char** argv) | ||
35 | srs_rtmp_t rtmp; | 35 | srs_rtmp_t rtmp; |
36 | 36 | ||
37 | // time | 37 | // time |
38 | - int64_t time_startup = srs_get_time_ms(); | 38 | + int64_t time_startup = srs_utils_get_time_ms(); |
39 | int64_t time_dns_resolve = 0; | 39 | int64_t time_dns_resolve = 0; |
40 | int64_t time_socket_connect = 0; | 40 | int64_t time_socket_connect = 0; |
41 | int64_t time_play_stream = 0; | 41 | int64_t time_play_stream = 0; |
@@ -95,14 +95,14 @@ int main(int argc, char** argv) | @@ -95,14 +95,14 @@ int main(int argc, char** argv) | ||
95 | goto rtmp_destroy; | 95 | goto rtmp_destroy; |
96 | } | 96 | } |
97 | srs_human_trace("dns resolve success"); | 97 | srs_human_trace("dns resolve success"); |
98 | - time_dns_resolve = srs_get_time_ms(); | 98 | + time_dns_resolve = srs_utils_get_time_ms(); |
99 | 99 | ||
100 | if ((ret = __srs_connect_server(rtmp)) != 0) { | 100 | if ((ret = __srs_connect_server(rtmp)) != 0) { |
101 | srs_human_trace("socket connect failed. ret=%d", ret); | 101 | srs_human_trace("socket connect failed. ret=%d", ret); |
102 | goto rtmp_destroy; | 102 | goto rtmp_destroy; |
103 | } | 103 | } |
104 | srs_human_trace("socket connect success"); | 104 | srs_human_trace("socket connect success"); |
105 | - time_socket_connect = srs_get_time_ms(); | 105 | + time_socket_connect = srs_utils_get_time_ms(); |
106 | 106 | ||
107 | if ((ret = __srs_do_simple_handshake(rtmp)) != 0) { | 107 | if ((ret = __srs_do_simple_handshake(rtmp)) != 0) { |
108 | srs_human_trace("do simple handshake failed. ret=%d", ret); | 108 | srs_human_trace("do simple handshake failed. ret=%d", ret); |
@@ -121,7 +121,7 @@ int main(int argc, char** argv) | @@ -121,7 +121,7 @@ int main(int argc, char** argv) | ||
121 | goto rtmp_destroy; | 121 | goto rtmp_destroy; |
122 | } | 122 | } |
123 | srs_human_trace("play stream success"); | 123 | srs_human_trace("play stream success"); |
124 | - time_play_stream = srs_get_time_ms(); | 124 | + time_play_stream = srs_utils_get_time_ms(); |
125 | 125 | ||
126 | for (;;) { | 126 | for (;;) { |
127 | if ((ret = srs_read_packet(rtmp, &type, ×tamp, &data, &size)) != 0) { | 127 | if ((ret = srs_read_packet(rtmp, &type, ×tamp, &data, &size)) != 0) { |
@@ -133,7 +133,7 @@ int main(int argc, char** argv) | @@ -133,7 +133,7 @@ int main(int argc, char** argv) | ||
133 | 133 | ||
134 | if (SRS_RTMP_TYPE_VIDEO == type || SRS_RTMP_TYPE_AUDIO == type) { | 134 | if (SRS_RTMP_TYPE_VIDEO == type || SRS_RTMP_TYPE_AUDIO == type) { |
135 | if (time_first_packet <= 0) { | 135 | if (time_first_packet <= 0) { |
136 | - time_first_packet = srs_get_time_ms(); | 136 | + time_first_packet = srs_utils_get_time_ms(); |
137 | } | 137 | } |
138 | if (basetime <= 0) { | 138 | if (basetime <= 0) { |
139 | basetime = timestamp; | 139 | basetime = timestamp; |
@@ -142,7 +142,7 @@ int main(int argc, char** argv) | @@ -142,7 +142,7 @@ int main(int argc, char** argv) | ||
142 | 142 | ||
143 | free(data); | 143 | free(data); |
144 | 144 | ||
145 | - if (srs_get_time_ms() - time_startup > timeout * 1000) { | 145 | + if (srs_utils_get_time_ms() - time_startup > timeout * 1000) { |
146 | srs_human_trace("timeout, terminate."); | 146 | srs_human_trace("timeout, terminate."); |
147 | goto rtmp_destroy; | 147 | goto rtmp_destroy; |
148 | } | 148 | } |
@@ -154,11 +154,11 @@ int main(int argc, char** argv) | @@ -154,11 +154,11 @@ int main(int argc, char** argv) | ||
154 | } | 154 | } |
155 | 155 | ||
156 | rtmp_destroy: | 156 | rtmp_destroy: |
157 | - bytes_nsend = srs_get_nsend_bytes(rtmp); | ||
158 | - bytes_nrecv = srs_get_nrecv_bytes(rtmp); | 157 | + bytes_nsend = srs_utils_get_send_bytes(rtmp); |
158 | + bytes_nrecv = srs_utils_get_recv_bytes(rtmp); | ||
159 | 159 | ||
160 | srs_rtmp_destroy(rtmp); | 160 | srs_rtmp_destroy(rtmp); |
161 | - time_cleanup = srs_get_time_ms(); | 161 | + time_cleanup = srs_utils_get_time_ms(); |
162 | time_duration = (int)(time_cleanup - time_startup); | 162 | time_duration = (int)(time_cleanup - time_startup); |
163 | 163 | ||
164 | // print result to stderr. | 164 | // print result to stderr. |
@@ -48,7 +48,7 @@ int main(int argc, char** argv) | @@ -48,7 +48,7 @@ int main(int argc, char** argv) | ||
48 | int ret = 0; | 48 | int ret = 0; |
49 | 49 | ||
50 | // main function | 50 | // main function |
51 | - tools_main_entrance_startup_time = srs_get_time_ms(); | 51 | + tools_main_entrance_startup_time = srs_utils_get_time_ms(); |
52 | 52 | ||
53 | // user option parse index. | 53 | // user option parse index. |
54 | int opt = 0; | 54 | int opt = 0; |
@@ -215,7 +215,7 @@ int connect_oc(srs_rtmp_t ortmp) | @@ -215,7 +215,7 @@ int connect_oc(srs_rtmp_t ortmp) | ||
215 | int64_t re_create() | 215 | int64_t re_create() |
216 | { | 216 | { |
217 | // if not very precise, we can directly use this as re. | 217 | // if not very precise, we can directly use this as re. |
218 | - int64_t re = srs_get_time_ms(); | 218 | + int64_t re = srs_utils_get_time_ms(); |
219 | 219 | ||
220 | // use the starttime to get the deviation | 220 | // use the starttime to get the deviation |
221 | int64_t deviation = re - tools_main_entrance_startup_time; | 221 | int64_t deviation = re - tools_main_entrance_startup_time; |
@@ -236,7 +236,7 @@ int64_t re_create() | @@ -236,7 +236,7 @@ int64_t re_create() | ||
236 | void re_update(int64_t re, int32_t starttime, u_int32_t time) | 236 | void re_update(int64_t re, int32_t starttime, u_int32_t time) |
237 | { | 237 | { |
238 | // send by pulse algorithm. | 238 | // send by pulse algorithm. |
239 | - int64_t now = srs_get_time_ms(); | 239 | + int64_t now = srs_utils_get_time_ms(); |
240 | int64_t diff = time - starttime - (now -re); | 240 | int64_t diff = time - starttime - (now -re); |
241 | if (diff > RE_PULSE_MS) { | 241 | if (diff > RE_PULSE_MS) { |
242 | usleep(diff * 1000); | 242 | usleep(diff * 1000); |
@@ -246,7 +246,7 @@ void re_cleanup(int64_t re, int32_t starttime, u_int32_t time) | @@ -246,7 +246,7 @@ void re_cleanup(int64_t re, int32_t starttime, u_int32_t time) | ||
246 | { | 246 | { |
247 | // for the last pulse, always sleep. | 247 | // for the last pulse, always sleep. |
248 | // for the virtual live encoder long time publishing. | 248 | // for the virtual live encoder long time publishing. |
249 | - int64_t now = srs_get_time_ms(); | 249 | + int64_t now = srs_utils_get_time_ms(); |
250 | int64_t diff = time - starttime - (now -re); | 250 | int64_t diff = time - starttime - (now -re); |
251 | if (diff > 0) { | 251 | if (diff > 0) { |
252 | srs_human_trace("re_cleanup, diff=%d, start=%d, last=%d ms", | 252 | srs_human_trace("re_cleanup, diff=%d, start=%d, last=%d ms", |
@@ -858,27 +858,27 @@ int srs_version_revision() | @@ -858,27 +858,27 @@ int srs_version_revision() | ||
858 | return VERSION_REVISION; | 858 | return VERSION_REVISION; |
859 | } | 859 | } |
860 | 860 | ||
861 | -int64_t srs_get_time_ms() | 861 | +int64_t srs_utils_get_time_ms() |
862 | { | 862 | { |
863 | srs_update_system_time_ms(); | 863 | srs_update_system_time_ms(); |
864 | return srs_get_system_time_ms(); | 864 | return srs_get_system_time_ms(); |
865 | } | 865 | } |
866 | 866 | ||
867 | -int64_t srs_get_nsend_bytes(srs_rtmp_t rtmp) | 867 | +int64_t srs_utils_get_send_bytes(srs_rtmp_t rtmp) |
868 | { | 868 | { |
869 | srs_assert(rtmp != NULL); | 869 | srs_assert(rtmp != NULL); |
870 | Context* context = (Context*)rtmp; | 870 | Context* context = (Context*)rtmp; |
871 | return context->rtmp->get_send_bytes(); | 871 | return context->rtmp->get_send_bytes(); |
872 | } | 872 | } |
873 | 873 | ||
874 | -int64_t srs_get_nrecv_bytes(srs_rtmp_t rtmp) | 874 | +int64_t srs_utils_get_recv_bytes(srs_rtmp_t rtmp) |
875 | { | 875 | { |
876 | srs_assert(rtmp != NULL); | 876 | srs_assert(rtmp != NULL); |
877 | Context* context = (Context*)rtmp; | 877 | Context* context = (Context*)rtmp; |
878 | return context->rtmp->get_recv_bytes(); | 878 | return context->rtmp->get_recv_bytes(); |
879 | } | 879 | } |
880 | 880 | ||
881 | -int srs_parse_timestamp( | 881 | +int srs_utils_parse_timestamp( |
882 | u_int32_t time, char type, char* data, int size, | 882 | u_int32_t time, char type, char* data, int size, |
883 | u_int32_t* ppts | 883 | u_int32_t* ppts |
884 | ) { | 884 | ) { |
@@ -919,7 +919,7 @@ int srs_parse_timestamp( | @@ -919,7 +919,7 @@ int srs_parse_timestamp( | ||
919 | return ret; | 919 | return ret; |
920 | } | 920 | } |
921 | 921 | ||
922 | -char srs_get_codec_id(char* data, int size) | 922 | +char srs_utils_get_flv_video_codec_id(char* data, int size) |
923 | { | 923 | { |
924 | if (size < 1) { | 924 | if (size < 1) { |
925 | return 0; | 925 | return 0; |
@@ -931,7 +931,7 @@ char srs_get_codec_id(char* data, int size) | @@ -931,7 +931,7 @@ char srs_get_codec_id(char* data, int size) | ||
931 | return codec_id; | 931 | return codec_id; |
932 | } | 932 | } |
933 | 933 | ||
934 | -char srs_get_avc_packet_type(char* data, int size) | 934 | +char srs_utils_get_flv_video_avc_packet_type(char* data, int size) |
935 | { | 935 | { |
936 | if (size < 2) { | 936 | if (size < 2) { |
937 | return -1; | 937 | return -1; |
@@ -950,7 +950,7 @@ char srs_get_avc_packet_type(char* data, int size) | @@ -950,7 +950,7 @@ char srs_get_avc_packet_type(char* data, int size) | ||
950 | return avc_packet_type; | 950 | return avc_packet_type; |
951 | } | 951 | } |
952 | 952 | ||
953 | -char srs_get_frame_type(char* data, int size) | 953 | +char srs_utils_get_flv_video_frame_type(char* data, int size) |
954 | { | 954 | { |
955 | if (size < 1) { | 955 | if (size < 1) { |
956 | return -1; | 956 | return -1; |
@@ -1526,16 +1526,16 @@ int srs_human_print_rtmp_packet(char type, u_int32_t timestamp, char* data, int | @@ -1526,16 +1526,16 @@ int srs_human_print_rtmp_packet(char type, u_int32_t timestamp, char* data, int | ||
1526 | int ret = ERROR_SUCCESS; | 1526 | int ret = ERROR_SUCCESS; |
1527 | 1527 | ||
1528 | u_int32_t pts; | 1528 | u_int32_t pts; |
1529 | - if (srs_parse_timestamp(timestamp, type, data, size, &pts) != 0) { | 1529 | + if (srs_utils_parse_timestamp(timestamp, type, data, size, &pts) != 0) { |
1530 | return ret; | 1530 | return ret; |
1531 | } | 1531 | } |
1532 | 1532 | ||
1533 | if (type == SRS_RTMP_TYPE_VIDEO) { | 1533 | if (type == SRS_RTMP_TYPE_VIDEO) { |
1534 | srs_human_trace("Video packet type=%s, dts=%d, pts=%d, size=%d, %s(%s,%s)", | 1534 | srs_human_trace("Video packet type=%s, dts=%d, pts=%d, size=%d, %s(%s,%s)", |
1535 | srs_human_flv_tag_type2string(type), timestamp, pts, size, | 1535 | srs_human_flv_tag_type2string(type), timestamp, pts, size, |
1536 | - srs_human_flv_video_codec_id2string(srs_get_codec_id(data, size)), | ||
1537 | - srs_human_flv_video_avc_packet_type2string(srs_get_avc_packet_type(data, size)), | ||
1538 | - srs_human_flv_video_frame_type2string(srs_get_frame_type(data, size)) | 1536 | + srs_human_flv_video_codec_id2string(srs_utils_get_flv_video_codec_id(data, size)), |
1537 | + srs_human_flv_video_avc_packet_type2string(srs_utils_get_flv_video_avc_packet_type(data, size)), | ||
1538 | + srs_human_flv_video_frame_type2string(srs_utils_get_flv_video_frame_type(data, size)) | ||
1539 | ); | 1539 | ); |
1540 | } else if (type == SRS_RTMP_TYPE_AUDIO) { | 1540 | } else if (type == SRS_RTMP_TYPE_AUDIO) { |
1541 | srs_human_trace("Audio packet type=%s, dts=%d, pts=%d, size=%d", | 1541 | srs_human_trace("Audio packet type=%s, dts=%d, pts=%d, size=%d", |
@@ -253,6 +253,11 @@ extern int srs_write_packet(srs_rtmp_t rtmp, | @@ -253,6 +253,11 @@ extern int srs_write_packet(srs_rtmp_t rtmp, | ||
253 | char type, u_int32_t timestamp, char* data, int size | 253 | char type, u_int32_t timestamp, char* data, int size |
254 | ); | 254 | ); |
255 | 255 | ||
256 | +/************************************************************* | ||
257 | +************************************************************** | ||
258 | +* version apis | ||
259 | +************************************************************** | ||
260 | +*************************************************************/ | ||
256 | // get protocol stack version | 261 | // get protocol stack version |
257 | extern int srs_version_major(); | 262 | extern int srs_version_major(); |
258 | extern int srs_version_minor(); | 263 | extern int srs_version_minor(); |
@@ -267,17 +272,17 @@ extern int srs_version_revision(); | @@ -267,17 +272,17 @@ extern int srs_version_revision(); | ||
267 | * get the current system time in ms. | 272 | * get the current system time in ms. |
268 | * use gettimeofday() to get system time. | 273 | * use gettimeofday() to get system time. |
269 | */ | 274 | */ |
270 | -extern int64_t srs_get_time_ms(); | 275 | +extern int64_t srs_utils_get_time_ms(); |
271 | 276 | ||
272 | /** | 277 | /** |
273 | * get the send bytes. | 278 | * get the send bytes. |
274 | */ | 279 | */ |
275 | -extern int64_t srs_get_nsend_bytes(srs_rtmp_t rtmp); | 280 | +extern int64_t srs_utils_get_send_bytes(srs_rtmp_t rtmp); |
276 | 281 | ||
277 | /** | 282 | /** |
278 | * get the recv bytes. | 283 | * get the recv bytes. |
279 | */ | 284 | */ |
280 | -extern int64_t srs_get_nrecv_bytes(srs_rtmp_t rtmp); | 285 | +extern int64_t srs_utils_get_recv_bytes(srs_rtmp_t rtmp); |
281 | 286 | ||
282 | /** | 287 | /** |
283 | * parse the dts and pts by time in header and data in tag, | 288 | * parse the dts and pts by time in header and data in tag, |
@@ -294,7 +299,7 @@ extern int64_t srs_get_nrecv_bytes(srs_rtmp_t rtmp); | @@ -294,7 +299,7 @@ extern int64_t srs_get_nrecv_bytes(srs_rtmp_t rtmp); | ||
294 | * @remark, the pts=dts for audio or data. | 299 | * @remark, the pts=dts for audio or data. |
295 | * @remark, video only support h.264. | 300 | * @remark, video only support h.264. |
296 | */ | 301 | */ |
297 | -extern int srs_parse_timestamp( | 302 | +extern int srs_utils_parse_timestamp( |
298 | u_int32_t time, char type, char* data, int size, | 303 | u_int32_t time, char type, char* data, int size, |
299 | u_int32_t* ppts | 304 | u_int32_t* ppts |
300 | ); | 305 | ); |
@@ -310,7 +315,7 @@ extern int srs_parse_timestamp( | @@ -310,7 +315,7 @@ extern int srs_parse_timestamp( | ||
310 | * 7 = AVC | 315 | * 7 = AVC |
311 | * @return the code id. 0 for error. | 316 | * @return the code id. 0 for error. |
312 | */ | 317 | */ |
313 | -extern char srs_get_codec_id(char* data, int size); | 318 | +extern char srs_utils_get_flv_video_codec_id(char* data, int size); |
314 | 319 | ||
315 | /** | 320 | /** |
316 | * get the AVCPacketType of video tag. | 321 | * get the AVCPacketType of video tag. |
@@ -321,7 +326,7 @@ extern char srs_get_codec_id(char* data, int size); | @@ -321,7 +326,7 @@ extern char srs_get_codec_id(char* data, int size); | ||
321 | * not required or supported) | 326 | * not required or supported) |
322 | * @return the avc packet type. -1(0xff) for error. | 327 | * @return the avc packet type. -1(0xff) for error. |
323 | */ | 328 | */ |
324 | -extern char srs_get_avc_packet_type(char* data, int size); | 329 | +extern char srs_utils_get_flv_video_avc_packet_type(char* data, int size); |
325 | 330 | ||
326 | /** | 331 | /** |
327 | * get the FrameType of video tag. | 332 | * get the FrameType of video tag. |
@@ -333,7 +338,7 @@ extern char srs_get_avc_packet_type(char* data, int size); | @@ -333,7 +338,7 @@ extern char srs_get_avc_packet_type(char* data, int size); | ||
333 | * 5 = video info/command frame | 338 | * 5 = video info/command frame |
334 | * @return the frame type. 0 for error. | 339 | * @return the frame type. 0 for error. |
335 | */ | 340 | */ |
336 | -extern char srs_get_frame_type(char* data, int size); | 341 | +extern char srs_utils_get_flv_video_frame_type(char* data, int size); |
337 | 342 | ||
338 | /************************************************************* | 343 | /************************************************************* |
339 | ************************************************************** | 344 | ************************************************************** |
-
请 注册 或 登录 后发表评论