正在显示
15 个修改的文件
包含
698 行增加
和
687 行删除
| @@ -482,6 +482,7 @@ Supported operating systems and hardware: | @@ -482,6 +482,7 @@ Supported operating systems and hardware: | ||
| 482 | * 2013-10-17, Created.<br/> | 482 | * 2013-10-17, Created.<br/> |
| 483 | 483 | ||
| 484 | ## History | 484 | ## History |
| 485 | +* v2.0, 2014-11-21, srs-librtmp add rtmp prefix for rtmp/utils/human apis. 2.0.29. | ||
| 485 | * v2.0, 2014-11-21, refine examples of srs-librtmp, add srs_print_rtmp_packet. 2.0.28. | 486 | * v2.0, 2014-11-21, refine examples of srs-librtmp, add srs_print_rtmp_packet. 2.0.28. |
| 486 | * v2.0, 2014-11-20, fix [#212](https://github.com/winlinvip/simple-rtmp-server/issues/212), support publish audio raw frames. 2.0.27 | 487 | * v2.0, 2014-11-20, fix [#212](https://github.com/winlinvip/simple-rtmp-server/issues/212), support publish audio raw frames. 2.0.27 |
| 487 | * v2.0, 2014-11-19, fix [#213](https://github.com/winlinvip/simple-rtmp-server/issues/213), support compile [srs-librtmp on windows](https://github.com/winlinvip/srs.librtmp), [bug #213](https://github.com/winlinvip/simple-rtmp-server/issues/213). 2.0.26 | 488 | * v2.0, 2014-11-19, fix [#213](https://github.com/winlinvip/simple-rtmp-server/issues/213), support compile [srs-librtmp on windows](https://github.com/winlinvip/srs.librtmp), [bug #213](https://github.com/winlinvip/simple-rtmp-server/issues/213). 2.0.26 |
| @@ -46,7 +46,7 @@ int read_audio_frame(char* audio_raw, int file_size, char** pp, char** pdata, in | @@ -46,7 +46,7 @@ int read_audio_frame(char* audio_raw, int file_size, char** pp, char** pdata, in | ||
| 46 | char* p = *pp; | 46 | char* p = *pp; |
| 47 | 47 | ||
| 48 | if (file_size - (p - audio_raw) < 168) { | 48 | if (file_size - (p - audio_raw) < 168) { |
| 49 | - srs_lib_trace("audio must be 160+8 bytes. left %d bytes.", | 49 | + srs_human_trace("audio must be 160+8 bytes. left %d bytes.", |
| 50 | file_size - (p - audio_raw)); | 50 | file_size - (p - audio_raw)); |
| 51 | return - 1; | 51 | return - 1; |
| 52 | } | 52 | } |
| @@ -83,32 +83,32 @@ int main(int argc, char** argv) | @@ -83,32 +83,32 @@ int main(int argc, char** argv) | ||
| 83 | 83 | ||
| 84 | const char* raw_file = argv[1]; | 84 | const char* raw_file = argv[1]; |
| 85 | const char* rtmp_url = argv[2]; | 85 | const char* rtmp_url = argv[2]; |
| 86 | - srs_lib_trace("raw_file=%s, rtmp_url=%s", raw_file, rtmp_url); | 86 | + srs_human_trace("raw_file=%s, rtmp_url=%s", raw_file, rtmp_url); |
| 87 | 87 | ||
| 88 | // open file | 88 | // open file |
| 89 | int raw_fd = open(raw_file, O_RDONLY); | 89 | int raw_fd = open(raw_file, O_RDONLY); |
| 90 | if (raw_fd < 0) { | 90 | if (raw_fd < 0) { |
| 91 | - srs_lib_trace("open audio raw file %s failed.", raw_fd); | 91 | + srs_human_trace("open audio raw file %s failed.", raw_fd); |
| 92 | goto rtmp_destroy; | 92 | goto rtmp_destroy; |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | off_t file_size = lseek(raw_fd, 0, SEEK_END); | 95 | off_t file_size = lseek(raw_fd, 0, SEEK_END); |
| 96 | if (file_size <= 0) { | 96 | if (file_size <= 0) { |
| 97 | - srs_lib_trace("audio raw file %s empty.", raw_file); | 97 | + srs_human_trace("audio raw file %s empty.", raw_file); |
| 98 | goto rtmp_destroy; | 98 | goto rtmp_destroy; |
| 99 | } | 99 | } |
| 100 | - srs_lib_trace("read entirely audio raw file, size=%dKB", (int)(file_size / 1024)); | 100 | + srs_human_trace("read entirely audio raw file, size=%dKB", (int)(file_size / 1024)); |
| 101 | 101 | ||
| 102 | char* audio_raw = (char*)malloc(file_size); | 102 | char* audio_raw = (char*)malloc(file_size); |
| 103 | if (!audio_raw) { | 103 | if (!audio_raw) { |
| 104 | - srs_lib_trace("alloc raw buffer failed for file %s.", raw_file); | 104 | + srs_human_trace("alloc raw buffer failed for file %s.", raw_file); |
| 105 | goto rtmp_destroy; | 105 | goto rtmp_destroy; |
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | lseek(raw_fd, 0, SEEK_SET); | 108 | lseek(raw_fd, 0, SEEK_SET); |
| 109 | ssize_t nb_read = 0; | 109 | ssize_t nb_read = 0; |
| 110 | if ((nb_read = read(raw_fd, audio_raw, file_size)) != file_size) { | 110 | if ((nb_read = read(raw_fd, audio_raw, file_size)) != file_size) { |
| 111 | - srs_lib_trace("buffer %s failed, expect=%dKB, actual=%dKB.", | 111 | + srs_human_trace("buffer %s failed, expect=%dKB, actual=%dKB.", |
| 112 | raw_file, (int)(file_size / 1024), (int)(nb_read / 1024)); | 112 | raw_file, (int)(file_size / 1024), (int)(nb_read / 1024)); |
| 113 | goto rtmp_destroy; | 113 | goto rtmp_destroy; |
| 114 | } | 114 | } |
| @@ -116,23 +116,23 @@ int main(int argc, char** argv) | @@ -116,23 +116,23 @@ int main(int argc, char** argv) | ||
| 116 | // connect rtmp context | 116 | // connect rtmp context |
| 117 | srs_rtmp_t rtmp = srs_rtmp_create(rtmp_url); | 117 | srs_rtmp_t rtmp = srs_rtmp_create(rtmp_url); |
| 118 | 118 | ||
| 119 | - if (srs_simple_handshake(rtmp) != 0) { | ||
| 120 | - srs_lib_trace("simple handshake failed."); | 119 | + if (srs_rtmp_handshake(rtmp) != 0) { |
| 120 | + srs_human_trace("simple handshake failed."); | ||
| 121 | goto rtmp_destroy; | 121 | goto rtmp_destroy; |
| 122 | } | 122 | } |
| 123 | - srs_lib_trace("simple handshake success"); | 123 | + srs_human_trace("simple handshake success"); |
| 124 | 124 | ||
| 125 | - if (srs_connect_app(rtmp) != 0) { | ||
| 126 | - srs_lib_trace("connect vhost/app failed."); | 125 | + if (srs_rtmp_connect_app(rtmp) != 0) { |
| 126 | + srs_human_trace("connect vhost/app failed."); | ||
| 127 | goto rtmp_destroy; | 127 | goto rtmp_destroy; |
| 128 | } | 128 | } |
| 129 | - srs_lib_trace("connect vhost/app success"); | 129 | + srs_human_trace("connect vhost/app success"); |
| 130 | 130 | ||
| 131 | - if (srs_publish_stream(rtmp) != 0) { | ||
| 132 | - srs_lib_trace("publish stream failed."); | 131 | + if (srs_rtmp_publish_stream(rtmp) != 0) { |
| 132 | + srs_human_trace("publish stream failed."); | ||
| 133 | goto rtmp_destroy; | 133 | goto rtmp_destroy; |
| 134 | } | 134 | } |
| 135 | - srs_lib_trace("publish stream success"); | 135 | + srs_human_trace("publish stream success"); |
| 136 | 136 | ||
| 137 | u_int32_t timestamp = 0; | 137 | u_int32_t timestamp = 0; |
| 138 | u_int32_t time_delta = 17; | 138 | u_int32_t time_delta = 17; |
| @@ -143,7 +143,7 @@ int main(int argc, char** argv) | @@ -143,7 +143,7 @@ int main(int argc, char** argv) | ||
| 143 | char* data = NULL; | 143 | char* data = NULL; |
| 144 | int size = 0; | 144 | int size = 0; |
| 145 | if (read_audio_frame(audio_raw, file_size, &p, &data, &size) < 0) { | 145 | if (read_audio_frame(audio_raw, file_size, &p, &data, &size) < 0) { |
| 146 | - srs_lib_trace("read a frame from file buffer failed."); | 146 | + srs_human_trace("read a frame from file buffer failed."); |
| 147 | goto rtmp_destroy; | 147 | goto rtmp_destroy; |
| 148 | } | 148 | } |
| 149 | 149 | ||
| @@ -168,12 +168,12 @@ int main(int argc, char** argv) | @@ -168,12 +168,12 @@ int main(int argc, char** argv) | ||
| 168 | sound_format, sound_rate, sound_size, sound_type, | 168 | sound_format, sound_rate, sound_size, sound_type, |
| 169 | 0, data, size, timestamp) != 0 | 169 | 0, data, size, timestamp) != 0 |
| 170 | ) { | 170 | ) { |
| 171 | - srs_lib_trace("send audio raw data failed."); | 171 | + srs_human_trace("send audio raw data failed."); |
| 172 | goto rtmp_destroy; | 172 | goto rtmp_destroy; |
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | - srs_lib_trace("sent packet: type=%s, time=%d, size=%d, codec=%d, rate=%d, sample=%d, channel=%d", | ||
| 176 | - srs_type2string(SRS_RTMP_TYPE_AUDIO), timestamp, size, sound_format, sound_rate, sound_size, | 175 | + srs_human_trace("sent packet: type=%s, time=%d, size=%d, codec=%d, rate=%d, sample=%d, channel=%d", |
| 176 | + srs_human_flv_tag_type2string(SRS_RTMP_TYPE_AUDIO), timestamp, size, sound_format, sound_rate, sound_size, | ||
| 177 | sound_type); | 177 | sound_type); |
| 178 | 178 | ||
| 179 | // @remark, when use encode device, it not need to sleep. | 179 | // @remark, when use encode device, it not need to sleep. |
| @@ -21,7 +21,7 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | @@ -21,7 +21,7 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| 21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 22 | */ | 22 | */ |
| 23 | /** | 23 | /** |
| 24 | -gcc srs_bandwidth_check.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_bandwidth_check | 24 | +gcc srs_rtmp_bandwidth_check.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_rtmp_bandwidth_check |
| 25 | */ | 25 | */ |
| 26 | 26 | ||
| 27 | #include <stdio.h> | 27 | #include <stdio.h> |
| @@ -81,31 +81,31 @@ int main(int argc, char** argv) | @@ -81,31 +81,31 @@ int main(int argc, char** argv) | ||
| 81 | 81 | ||
| 82 | rtmp = srs_rtmp_create2(argv[1]); | 82 | rtmp = srs_rtmp_create2(argv[1]); |
| 83 | 83 | ||
| 84 | - srs_lib_trace("bandwidth check/test url: %s", argv[1]); | 84 | + srs_human_trace("bandwidth check/test url: %s", argv[1]); |
| 85 | 85 | ||
| 86 | - if ((ret = srs_simple_handshake(rtmp)) != 0) { | ||
| 87 | - srs_lib_trace("simple handshake failed."); | 86 | + if ((ret = srs_rtmp_handshake(rtmp)) != 0) { |
| 87 | + srs_human_trace("simple handshake failed."); | ||
| 88 | goto rtmp_destroy; | 88 | goto rtmp_destroy; |
| 89 | } | 89 | } |
| 90 | - srs_lib_trace("simple handshake success"); | 90 | + srs_human_trace("simple handshake success"); |
| 91 | 91 | ||
| 92 | - if ((ret = srs_connect_app2(rtmp, | 92 | + if ((ret = srs_rtmp_connect_app2(rtmp, |
| 93 | srs_server_ip, srs_server, srs_primary_authors, srs_version, &srs_id, &srs_pid)) != 0) { | 93 | srs_server_ip, srs_server, srs_primary_authors, srs_version, &srs_id, &srs_pid)) != 0) { |
| 94 | - srs_lib_trace("connect vhost/app failed."); | 94 | + srs_human_trace("connect vhost/app failed."); |
| 95 | goto rtmp_destroy; | 95 | goto rtmp_destroy; |
| 96 | } | 96 | } |
| 97 | - srs_lib_trace("connect vhost/app success"); | 97 | + srs_human_trace("connect vhost/app success"); |
| 98 | 98 | ||
| 99 | - if ((ret = srs_bandwidth_check(rtmp, | 99 | + if ((ret = srs_rtmp_bandwidth_check(rtmp, |
| 100 | &start_time, &end_time, &play_kbps, &publish_kbps, | 100 | &start_time, &end_time, &play_kbps, &publish_kbps, |
| 101 | &play_bytes, &publish_bytes, &play_duration, &publish_duration)) != 0 | 101 | &play_bytes, &publish_bytes, &play_duration, &publish_duration)) != 0 |
| 102 | ) { | 102 | ) { |
| 103 | - srs_lib_trace("bandwidth check/test failed."); | 103 | + srs_human_trace("bandwidth check/test failed."); |
| 104 | goto rtmp_destroy; | 104 | goto rtmp_destroy; |
| 105 | } | 105 | } |
| 106 | - srs_lib_trace("bandwidth check/test success"); | 106 | + srs_human_trace("bandwidth check/test success"); |
| 107 | 107 | ||
| 108 | - srs_lib_trace("\n%s, %s\n" | 108 | + srs_human_trace("\n%s, %s\n" |
| 109 | "%s, %s, srs_pid=%d, srs_id=%d\n" | 109 | "%s, %s, srs_pid=%d, srs_id=%d\n" |
| 110 | "duration: %dms(%d+%d)\n" | 110 | "duration: %dms(%d+%d)\n" |
| 111 | "play: %dkbps\n" | 111 | "play: %dkbps\n" |
| @@ -137,8 +137,8 @@ rtmp_destroy: | @@ -137,8 +137,8 @@ rtmp_destroy: | ||
| 137 | (int)(end_time - start_time), play_duration, publish_duration, | 137 | (int)(end_time - start_time), play_duration, publish_duration, |
| 138 | play_kbps, publish_kbps); | 138 | play_kbps, publish_kbps); |
| 139 | 139 | ||
| 140 | - srs_lib_trace(""); | ||
| 141 | - srs_lib_trace("completed"); | 140 | + srs_human_trace(""); |
| 141 | + srs_human_trace("completed"); | ||
| 142 | 142 | ||
| 143 | return ret; | 143 | return ret; |
| 144 | } | 144 | } |
| @@ -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; |
| @@ -80,60 +80,60 @@ int main(int argc, char** argv) | @@ -80,60 +80,60 @@ int main(int argc, char** argv) | ||
| 80 | duration = atoi(argv[2]); | 80 | duration = atoi(argv[2]); |
| 81 | timeout = atoi(argv[3]); | 81 | timeout = atoi(argv[3]); |
| 82 | 82 | ||
| 83 | - srs_lib_trace("rtmp url: %s", rtmp_url); | ||
| 84 | - srs_lib_trace("duration: %ds, timeout:%ds", duration, timeout); | 83 | + srs_human_trace("rtmp url: %s", rtmp_url); |
| 84 | + srs_human_trace("duration: %ds, timeout:%ds", duration, timeout); | ||
| 85 | 85 | ||
| 86 | if (duration <= 0 || timeout <= 0) { | 86 | if (duration <= 0 || timeout <= 0) { |
| 87 | - srs_lib_trace("duration and timeout must be positive."); | 87 | + srs_human_trace("duration and timeout must be positive."); |
| 88 | exit(-2); | 88 | exit(-2); |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | rtmp = srs_rtmp_create(rtmp_url); | 91 | rtmp = srs_rtmp_create(rtmp_url); |
| 92 | 92 | ||
| 93 | - if ((ret = __srs_dns_resolve(rtmp)) != 0) { | ||
| 94 | - srs_lib_trace("dns resolve failed. ret=%d", ret); | 93 | + if ((ret = __srs_rtmp_dns_resolve(rtmp)) != 0) { |
| 94 | + srs_human_trace("dns resolve failed. ret=%d", ret); | ||
| 95 | goto rtmp_destroy; | 95 | goto rtmp_destroy; |
| 96 | } | 96 | } |
| 97 | - srs_lib_trace("dns resolve success"); | ||
| 98 | - time_dns_resolve = srs_get_time_ms(); | 97 | + srs_human_trace("dns resolve success"); |
| 98 | + time_dns_resolve = srs_utils_get_time_ms(); | ||
| 99 | 99 | ||
| 100 | - if ((ret = __srs_connect_server(rtmp)) != 0) { | ||
| 101 | - srs_lib_trace("socket connect failed. ret=%d", ret); | 100 | + if ((ret = __srs_rtmp_connect_server(rtmp)) != 0) { |
| 101 | + srs_human_trace("socket connect failed. ret=%d", ret); | ||
| 102 | goto rtmp_destroy; | 102 | goto rtmp_destroy; |
| 103 | } | 103 | } |
| 104 | - srs_lib_trace("socket connect success"); | ||
| 105 | - time_socket_connect = srs_get_time_ms(); | 104 | + srs_human_trace("socket connect success"); |
| 105 | + time_socket_connect = srs_utils_get_time_ms(); | ||
| 106 | 106 | ||
| 107 | - if ((ret = __srs_do_simple_handshake(rtmp)) != 0) { | ||
| 108 | - srs_lib_trace("do simple handshake failed. ret=%d", ret); | 107 | + if ((ret = __srs_rtmp_do_simple_handshake(rtmp)) != 0) { |
| 108 | + srs_human_trace("do simple handshake failed. ret=%d", ret); | ||
| 109 | goto rtmp_destroy; | 109 | goto rtmp_destroy; |
| 110 | } | 110 | } |
| 111 | - srs_lib_trace("do simple handshake success"); | 111 | + srs_human_trace("do simple handshake success"); |
| 112 | 112 | ||
| 113 | - if ((ret = srs_connect_app(rtmp)) != 0) { | ||
| 114 | - srs_lib_trace("connect vhost/app failed. ret=%d", ret); | 113 | + if ((ret = srs_rtmp_connect_app(rtmp)) != 0) { |
| 114 | + srs_human_trace("connect vhost/app failed. ret=%d", ret); | ||
| 115 | goto rtmp_destroy; | 115 | goto rtmp_destroy; |
| 116 | } | 116 | } |
| 117 | - srs_lib_trace("connect vhost/app success"); | 117 | + srs_human_trace("connect vhost/app success"); |
| 118 | 118 | ||
| 119 | - if ((ret = srs_play_stream(rtmp)) != 0) { | ||
| 120 | - srs_lib_trace("play stream failed. ret=%d", ret); | 119 | + if ((ret = srs_rtmp_play_stream(rtmp)) != 0) { |
| 120 | + srs_human_trace("play stream failed. ret=%d", ret); | ||
| 121 | goto rtmp_destroy; | 121 | goto rtmp_destroy; |
| 122 | } | 122 | } |
| 123 | - srs_lib_trace("play stream success"); | ||
| 124 | - time_play_stream = srs_get_time_ms(); | 123 | + srs_human_trace("play stream success"); |
| 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) { | ||
| 128 | - srs_lib_trace("read packet failed. ret=%d", ret); | 127 | + if ((ret = srs_rtmp_read_packet(rtmp, &type, ×tamp, &data, &size)) != 0) { |
| 128 | + srs_human_trace("read packet failed. ret=%d", ret); | ||
| 129 | goto rtmp_destroy; | 129 | goto rtmp_destroy; |
| 130 | } | 130 | } |
| 131 | - srs_lib_trace("got packet: type=%s, time=%d, size=%d", | ||
| 132 | - srs_type2string(type), timestamp, size); | 131 | + srs_human_trace("got packet: type=%s, time=%d, size=%d", |
| 132 | + srs_human_flv_tag_type2string(type), timestamp, size); | ||
| 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,23 +142,23 @@ int main(int argc, char** argv) | @@ -142,23 +142,23 @@ 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) { | ||
| 146 | - srs_lib_trace("timeout, terminate."); | 145 | + if (srs_utils_get_time_ms() - time_startup > timeout * 1000) { |
| 146 | + srs_human_trace("timeout, terminate."); | ||
| 147 | goto rtmp_destroy; | 147 | goto rtmp_destroy; |
| 148 | } | 148 | } |
| 149 | 149 | ||
| 150 | if ((timestamp - basetime) > duration * 1000) { | 150 | if ((timestamp - basetime) > duration * 1000) { |
| 151 | - srs_lib_trace("duration exceed, terminate."); | 151 | + srs_human_trace("duration exceed, terminate."); |
| 152 | goto rtmp_destroy; | 152 | goto rtmp_destroy; |
| 153 | } | 153 | } |
| 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. |
| @@ -197,8 +197,8 @@ rtmp_destroy: | @@ -197,8 +197,8 @@ rtmp_destroy: | ||
| 197 | "\"remark2\": \"if code is not 0, user must ignore all data\"" | 197 | "\"remark2\": \"if code is not 0, user must ignore all data\"" |
| 198 | ); | 198 | ); |
| 199 | 199 | ||
| 200 | - srs_lib_trace(""); | ||
| 201 | - srs_lib_trace("completed"); | 200 | + srs_human_trace(""); |
| 201 | + srs_human_trace("completed"); | ||
| 202 | 202 | ||
| 203 | return ret; | 203 | return ret; |
| 204 | } | 204 | } |
| @@ -76,9 +76,9 @@ int main(int argc, char** argv) | @@ -76,9 +76,9 @@ int main(int argc, char** argv) | ||
| 76 | tmp_file = (char*)malloc(tmp_file_size); | 76 | tmp_file = (char*)malloc(tmp_file_size); |
| 77 | snprintf(tmp_file, tmp_file_size, "%s.tmp", out_flv_file); | 77 | snprintf(tmp_file, tmp_file_size, "%s.tmp", out_flv_file); |
| 78 | 78 | ||
| 79 | - srs_lib_trace("input: %s", in_flv_file); | ||
| 80 | - srs_lib_trace("output: %s", out_flv_file); | ||
| 81 | - srs_lib_trace("tmp_file: %s", tmp_file); | 79 | + srs_human_trace("input: %s", in_flv_file); |
| 80 | + srs_human_trace("output: %s", out_flv_file); | ||
| 81 | + srs_human_trace("tmp_file: %s", tmp_file); | ||
| 82 | 82 | ||
| 83 | ret = process(in_flv_file, tmp_file, &ic, &oc); | 83 | ret = process(in_flv_file, tmp_file, &ic, &oc); |
| 84 | 84 | ||
| @@ -89,13 +89,13 @@ int main(int argc, char** argv) | @@ -89,13 +89,13 @@ int main(int argc, char** argv) | ||
| 89 | unlink(tmp_file); | 89 | unlink(tmp_file); |
| 90 | if (ret == ERROR_INJECTED) { | 90 | if (ret == ERROR_INJECTED) { |
| 91 | ret = 0; | 91 | ret = 0; |
| 92 | - srs_lib_trace("file already injected."); | 92 | + srs_human_trace("file already injected."); |
| 93 | } else { | 93 | } else { |
| 94 | - srs_lib_trace("error, remove tmp file."); | 94 | + srs_human_trace("error, remove tmp file."); |
| 95 | } | 95 | } |
| 96 | } else { | 96 | } else { |
| 97 | rename(tmp_file, out_flv_file); | 97 | rename(tmp_file, out_flv_file); |
| 98 | - srs_lib_trace("completed, rename to %s", out_flv_file); | 98 | + srs_human_trace("completed, rename to %s", out_flv_file); |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | free(tmp_file); | 101 | free(tmp_file); |
| @@ -123,14 +123,14 @@ int process(const char* in_flv_file, const char* out_flv_file, srs_flv_t* pic, s | @@ -123,14 +123,14 @@ int process(const char* in_flv_file, const char* out_flv_file, srs_flv_t* pic, s | ||
| 123 | 123 | ||
| 124 | if ((ic = srs_flv_open_read(in_flv_file)) == NULL) { | 124 | if ((ic = srs_flv_open_read(in_flv_file)) == NULL) { |
| 125 | ret = 2; | 125 | ret = 2; |
| 126 | - srs_lib_trace("open input flv file failed. ret=%d", ret); | 126 | + srs_human_trace("open input flv file failed. ret=%d", ret); |
| 127 | return ret; | 127 | return ret; |
| 128 | } | 128 | } |
| 129 | *pic = ic; | 129 | *pic = ic; |
| 130 | 130 | ||
| 131 | if ((oc = srs_flv_open_write(out_flv_file)) == NULL) { | 131 | if ((oc = srs_flv_open_write(out_flv_file)) == NULL) { |
| 132 | ret = 2; | 132 | ret = 2; |
| 133 | - srs_lib_trace("open output flv file failed. ret=%d", ret); | 133 | + srs_human_trace("open output flv file failed. ret=%d", ret); |
| 134 | return ret; | 134 | return ret; |
| 135 | } | 135 | } |
| 136 | *poc = oc; | 136 | *poc = oc; |
| @@ -164,13 +164,13 @@ int parse_metadata(char* data, int size, srs_amf0_t* pname, srs_amf0_t* pdata) | @@ -164,13 +164,13 @@ int parse_metadata(char* data, int size, srs_amf0_t* pname, srs_amf0_t* pdata) | ||
| 164 | *pname = srs_amf0_parse(data, size, &nparsed); | 164 | *pname = srs_amf0_parse(data, size, &nparsed); |
| 165 | 165 | ||
| 166 | if (*pname == NULL || nparsed >= size) { | 166 | if (*pname == NULL || nparsed >= size) { |
| 167 | - srs_lib_trace("invalid amf0 name data."); | 167 | + srs_human_trace("invalid amf0 name data."); |
| 168 | return -1; | 168 | return -1; |
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | *pdata = srs_amf0_parse(data + nparsed, size - nparsed, &nparsed); | 171 | *pdata = srs_amf0_parse(data + nparsed, size - nparsed, &nparsed); |
| 172 | if (*pdata == NULL || nparsed > size) { | 172 | if (*pdata == NULL || nparsed > size) { |
| 173 | - srs_lib_trace("invalid amf0 value data"); | 173 | + srs_human_trace("invalid amf0 value data"); |
| 174 | return -1; | 174 | return -1; |
| 175 | } | 175 | } |
| 176 | 176 | ||
| @@ -206,22 +206,22 @@ int build_keyframes(srs_flv_t ic, srs_amf0_t *pname, srs_amf0_t* pdata, srs_amf0 | @@ -206,22 +206,22 @@ int build_keyframes(srs_flv_t ic, srs_amf0_t *pname, srs_amf0_t* pdata, srs_amf0 | ||
| 206 | return ret; | 206 | return ret; |
| 207 | } | 207 | } |
| 208 | 208 | ||
| 209 | - srs_lib_trace("build keyframe infos from flv"); | 209 | + srs_human_trace("build keyframe infos from flv"); |
| 210 | for (;;) { | 210 | for (;;) { |
| 211 | offset = srs_flv_tellg(ic); | 211 | offset = srs_flv_tellg(ic); |
| 212 | 212 | ||
| 213 | // tag header | 213 | // tag header |
| 214 | if ((ret = srs_flv_read_tag_header(ic, &type, &size, ×tamp)) != 0) { | 214 | if ((ret = srs_flv_read_tag_header(ic, &type, &size, ×tamp)) != 0) { |
| 215 | if (srs_flv_is_eof(ret)) { | 215 | if (srs_flv_is_eof(ret)) { |
| 216 | - srs_lib_trace("parse completed."); | 216 | + srs_human_trace("parse completed."); |
| 217 | return 0; | 217 | return 0; |
| 218 | } | 218 | } |
| 219 | - srs_lib_trace("flv get packet failed. ret=%d", ret); | 219 | + srs_human_trace("flv get packet failed. ret=%d", ret); |
| 220 | return ret; | 220 | return ret; |
| 221 | } | 221 | } |
| 222 | 222 | ||
| 223 | if (size <= 0) { | 223 | if (size <= 0) { |
| 224 | - srs_lib_trace("invalid size=%d", size); | 224 | + srs_human_trace("invalid size=%d", size); |
| 225 | return ret; | 225 | return ret; |
| 226 | } | 226 | } |
| 227 | 227 | ||
| @@ -343,20 +343,20 @@ int do_inject_flv(srs_flv_t ic, srs_flv_t oc, srs_amf0_t amf0_name, srs_amf0_t a | @@ -343,20 +343,20 @@ int do_inject_flv(srs_flv_t ic, srs_flv_t oc, srs_amf0_t amf0_name, srs_amf0_t a | ||
| 343 | free(data); | 343 | free(data); |
| 344 | } | 344 | } |
| 345 | 345 | ||
| 346 | - srs_lib_trace("build keyframe infos from flv"); | 346 | + srs_human_trace("build keyframe infos from flv"); |
| 347 | for (;;) { | 347 | for (;;) { |
| 348 | // tag header | 348 | // tag header |
| 349 | if ((ret = srs_flv_read_tag_header(ic, &type, &size, ×tamp)) != 0) { | 349 | if ((ret = srs_flv_read_tag_header(ic, &type, &size, ×tamp)) != 0) { |
| 350 | if (srs_flv_is_eof(ret)) { | 350 | if (srs_flv_is_eof(ret)) { |
| 351 | - srs_lib_trace("parse completed."); | 351 | + srs_human_trace("parse completed."); |
| 352 | return 0; | 352 | return 0; |
| 353 | } | 353 | } |
| 354 | - srs_lib_trace("flv get packet failed. ret=%d", ret); | 354 | + srs_human_trace("flv get packet failed. ret=%d", ret); |
| 355 | return ret; | 355 | return ret; |
| 356 | } | 356 | } |
| 357 | 357 | ||
| 358 | if (size <= 0) { | 358 | if (size <= 0) { |
| 359 | - srs_lib_trace("invalid size=%d", size); | 359 | + srs_human_trace("invalid size=%d", size); |
| 360 | break; | 360 | break; |
| 361 | } | 361 | } |
| 362 | 362 |
| @@ -61,11 +61,11 @@ int main(int argc, char** argv) | @@ -61,11 +61,11 @@ int main(int argc, char** argv) | ||
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | in_flv_file = argv[1]; | 63 | in_flv_file = argv[1]; |
| 64 | - srs_lib_trace("input: %s", in_flv_file); | 64 | + srs_human_trace("input: %s", in_flv_file); |
| 65 | 65 | ||
| 66 | if ((flv = srs_flv_open_read(in_flv_file)) == NULL) { | 66 | if ((flv = srs_flv_open_read(in_flv_file)) == NULL) { |
| 67 | ret = 2; | 67 | ret = 2; |
| 68 | - srs_lib_trace("open flv file failed. ret=%d", ret); | 68 | + srs_human_trace("open flv file failed. ret=%d", ret); |
| 69 | return ret; | 69 | return ret; |
| 70 | } | 70 | } |
| 71 | 71 | ||
| @@ -141,44 +141,44 @@ int parse_flv(srs_flv_t flv) | @@ -141,44 +141,44 @@ int parse_flv(srs_flv_t flv) | ||
| 141 | return ret; | 141 | return ret; |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | - srs_lib_trace("start parse flv"); | 144 | + srs_human_trace("start parse flv"); |
| 145 | for (;;) { | 145 | for (;;) { |
| 146 | offset = srs_flv_tellg(flv); | 146 | offset = srs_flv_tellg(flv); |
| 147 | 147 | ||
| 148 | // tag header | 148 | // tag header |
| 149 | if ((ret = srs_flv_read_tag_header(flv, &type, &size, ×tamp)) != 0) { | 149 | if ((ret = srs_flv_read_tag_header(flv, &type, &size, ×tamp)) != 0) { |
| 150 | if (srs_flv_is_eof(ret)) { | 150 | if (srs_flv_is_eof(ret)) { |
| 151 | - srs_lib_trace("parse completed."); | 151 | + srs_human_trace("parse completed."); |
| 152 | return 0; | 152 | return 0; |
| 153 | } | 153 | } |
| 154 | - srs_lib_trace("flv get packet failed. ret=%d", ret); | 154 | + srs_human_trace("flv get packet failed. ret=%d", ret); |
| 155 | return ret; | 155 | return ret; |
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | if (size <= 0) { | 158 | if (size <= 0) { |
| 159 | - srs_lib_trace("invalid size=%d", size); | 159 | + srs_human_trace("invalid size=%d", size); |
| 160 | break; | 160 | break; |
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | data = (char*)malloc(size); | 163 | data = (char*)malloc(size); |
| 164 | 164 | ||
| 165 | if ((ret = srs_flv_read_tag_data(flv, data, size)) == 0) { | 165 | if ((ret = srs_flv_read_tag_data(flv, data, size)) == 0) { |
| 166 | - if ((ret = srs_print_rtmp_packet(type, timestamp, data, size)) == 0) { | 166 | + if ((ret = srs_human_print_rtmp_packet(type, timestamp, data, size)) == 0) { |
| 167 | char hbuf[48]; char tbuf[48]; | 167 | char hbuf[48]; char tbuf[48]; |
| 168 | parse_bytes(data, size, hbuf, sizeof(hbuf), tbuf, sizeof(tbuf), 16); | 168 | parse_bytes(data, size, hbuf, sizeof(hbuf), tbuf, sizeof(tbuf), 16); |
| 169 | - srs_raw_trace("offset=%d, first and last 16 bytes:\n" | 169 | + srs_human_raw("offset=%d, first and last 16 bytes:\n" |
| 170 | "[+00, +15] %s\n[-15, EOF] %s\n", (int)offset, hbuf, tbuf); | 170 | "[+00, +15] %s\n[-15, EOF] %s\n", (int)offset, hbuf, tbuf); |
| 171 | } else { | 171 | } else { |
| 172 | - srs_lib_trace("print packet failed. ret=%d", ret); | 172 | + srs_human_trace("print packet failed. ret=%d", ret); |
| 173 | } | 173 | } |
| 174 | } else { | 174 | } else { |
| 175 | - srs_lib_trace("read flv failed. ret=%d", ret); | 175 | + srs_human_trace("read flv failed. ret=%d", ret); |
| 176 | } | 176 | } |
| 177 | 177 | ||
| 178 | free(data); | 178 | free(data); |
| 179 | 179 | ||
| 180 | if (ret != 0) { | 180 | if (ret != 0) { |
| 181 | - srs_lib_trace("parse failed, ret=%d", ret); | 181 | + srs_human_trace("parse failed, ret=%d", ret); |
| 182 | return ret; | 182 | return ret; |
| 183 | } | 183 | } |
| 184 | } | 184 | } |
| @@ -44,7 +44,7 @@ int read_h264_frame(char* data, int size, char** pp, int* pnb_start_code, int fp | @@ -44,7 +44,7 @@ int read_h264_frame(char* data, int size, char** pp, int* pnb_start_code, int fp | ||
| 44 | // we search the h264 frame from the buffer which cached the h264 data. | 44 | // we search the h264 frame from the buffer which cached the h264 data. |
| 45 | // please get h264 raw data from device, it always a encoded frame. | 45 | // please get h264 raw data from device, it always a encoded frame. |
| 46 | if (!srs_h264_startswith_annexb(p, size - (p - data), pnb_start_code)) { | 46 | if (!srs_h264_startswith_annexb(p, size - (p - data), pnb_start_code)) { |
| 47 | - srs_lib_trace("h264 raw data invalid."); | 47 | + srs_human_trace("h264 raw data invalid."); |
| 48 | return -1; | 48 | return -1; |
| 49 | } | 49 | } |
| 50 | 50 | ||
| @@ -63,7 +63,7 @@ int read_h264_frame(char* data, int size, char** pp, int* pnb_start_code, int fp | @@ -63,7 +63,7 @@ int read_h264_frame(char* data, int size, char** pp, int* pnb_start_code, int fp | ||
| 63 | *pp = p; | 63 | *pp = p; |
| 64 | *frame_size = p - *frame; | 64 | *frame_size = p - *frame; |
| 65 | if (*frame_size <= 0) { | 65 | if (*frame_size <= 0) { |
| 66 | - srs_lib_trace("h264 raw data invalid."); | 66 | + srs_human_trace("h264 raw data invalid."); |
| 67 | return -1; | 67 | return -1; |
| 68 | } | 68 | } |
| 69 | 69 | ||
| @@ -95,32 +95,32 @@ int main(int argc, char** argv) | @@ -95,32 +95,32 @@ int main(int argc, char** argv) | ||
| 95 | 95 | ||
| 96 | const char* raw_file = argv[1]; | 96 | const char* raw_file = argv[1]; |
| 97 | const char* rtmp_url = argv[2]; | 97 | const char* rtmp_url = argv[2]; |
| 98 | - srs_lib_trace("raw_file=%s, rtmp_url=%s", raw_file, rtmp_url); | 98 | + srs_human_trace("raw_file=%s, rtmp_url=%s", raw_file, rtmp_url); |
| 99 | 99 | ||
| 100 | // open file | 100 | // open file |
| 101 | int raw_fd = open(raw_file, O_RDONLY); | 101 | int raw_fd = open(raw_file, O_RDONLY); |
| 102 | if (raw_fd < 0) { | 102 | if (raw_fd < 0) { |
| 103 | - srs_lib_trace("open h264 raw file %s failed.", raw_fd); | 103 | + srs_human_trace("open h264 raw file %s failed.", raw_fd); |
| 104 | goto rtmp_destroy; | 104 | goto rtmp_destroy; |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | off_t file_size = lseek(raw_fd, 0, SEEK_END); | 107 | off_t file_size = lseek(raw_fd, 0, SEEK_END); |
| 108 | if (file_size <= 0) { | 108 | if (file_size <= 0) { |
| 109 | - srs_lib_trace("h264 raw file %s empty.", raw_file); | 109 | + srs_human_trace("h264 raw file %s empty.", raw_file); |
| 110 | goto rtmp_destroy; | 110 | goto rtmp_destroy; |
| 111 | } | 111 | } |
| 112 | - srs_lib_trace("read entirely h264 raw file, size=%dKB", (int)(file_size / 1024)); | 112 | + srs_human_trace("read entirely h264 raw file, size=%dKB", (int)(file_size / 1024)); |
| 113 | 113 | ||
| 114 | char* h264_raw = (char*)malloc(file_size); | 114 | char* h264_raw = (char*)malloc(file_size); |
| 115 | if (!h264_raw) { | 115 | if (!h264_raw) { |
| 116 | - srs_lib_trace("alloc raw buffer failed for file %s.", raw_file); | 116 | + srs_human_trace("alloc raw buffer failed for file %s.", raw_file); |
| 117 | goto rtmp_destroy; | 117 | goto rtmp_destroy; |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | lseek(raw_fd, 0, SEEK_SET); | 120 | lseek(raw_fd, 0, SEEK_SET); |
| 121 | ssize_t nb_read = 0; | 121 | ssize_t nb_read = 0; |
| 122 | if ((nb_read = read(raw_fd, h264_raw, file_size)) != file_size) { | 122 | if ((nb_read = read(raw_fd, h264_raw, file_size)) != file_size) { |
| 123 | - srs_lib_trace("buffer %s failed, expect=%dKB, actual=%dKB.", | 123 | + srs_human_trace("buffer %s failed, expect=%dKB, actual=%dKB.", |
| 124 | raw_file, (int)(file_size / 1024), (int)(nb_read / 1024)); | 124 | raw_file, (int)(file_size / 1024), (int)(nb_read / 1024)); |
| 125 | goto rtmp_destroy; | 125 | goto rtmp_destroy; |
| 126 | } | 126 | } |
| @@ -128,23 +128,23 @@ int main(int argc, char** argv) | @@ -128,23 +128,23 @@ int main(int argc, char** argv) | ||
| 128 | // connect rtmp context | 128 | // connect rtmp context |
| 129 | srs_rtmp_t rtmp = srs_rtmp_create(rtmp_url); | 129 | srs_rtmp_t rtmp = srs_rtmp_create(rtmp_url); |
| 130 | 130 | ||
| 131 | - if (srs_simple_handshake(rtmp) != 0) { | ||
| 132 | - srs_lib_trace("simple handshake failed."); | 131 | + if (srs_rtmp_handshake(rtmp) != 0) { |
| 132 | + srs_human_trace("simple handshake failed."); | ||
| 133 | goto rtmp_destroy; | 133 | goto rtmp_destroy; |
| 134 | } | 134 | } |
| 135 | - srs_lib_trace("simple handshake success"); | 135 | + srs_human_trace("simple handshake success"); |
| 136 | 136 | ||
| 137 | - if (srs_connect_app(rtmp) != 0) { | ||
| 138 | - srs_lib_trace("connect vhost/app failed."); | 137 | + if (srs_rtmp_connect_app(rtmp) != 0) { |
| 138 | + srs_human_trace("connect vhost/app failed."); | ||
| 139 | goto rtmp_destroy; | 139 | goto rtmp_destroy; |
| 140 | } | 140 | } |
| 141 | - srs_lib_trace("connect vhost/app success"); | 141 | + srs_human_trace("connect vhost/app success"); |
| 142 | 142 | ||
| 143 | - if (srs_publish_stream(rtmp) != 0) { | ||
| 144 | - srs_lib_trace("publish stream failed."); | 143 | + if (srs_rtmp_publish_stream(rtmp) != 0) { |
| 144 | + srs_human_trace("publish stream failed."); | ||
| 145 | goto rtmp_destroy; | 145 | goto rtmp_destroy; |
| 146 | } | 146 | } |
| 147 | - srs_lib_trace("publish stream success"); | 147 | + srs_human_trace("publish stream success"); |
| 148 | 148 | ||
| 149 | u_int32_t dts = 0; | 149 | u_int32_t dts = 0; |
| 150 | u_int32_t pts = 0; | 150 | u_int32_t pts = 0; |
| @@ -161,7 +161,7 @@ int main(int argc, char** argv) | @@ -161,7 +161,7 @@ int main(int argc, char** argv) | ||
| 161 | if (read_h264_frame(h264_raw, file_size, &p, &nb_start_code, fps, | 161 | if (read_h264_frame(h264_raw, file_size, &p, &nb_start_code, fps, |
| 162 | &data, &size, &dts, &pts) < 0 | 162 | &data, &size, &dts, &pts) < 0 |
| 163 | ) { | 163 | ) { |
| 164 | - srs_lib_trace("read a frame from file buffer failed."); | 164 | + srs_human_trace("read a frame from file buffer failed."); |
| 165 | goto rtmp_destroy; | 165 | goto rtmp_destroy; |
| 166 | } | 166 | } |
| 167 | 167 | ||
| @@ -169,13 +169,13 @@ int main(int argc, char** argv) | @@ -169,13 +169,13 @@ int main(int argc, char** argv) | ||
| 169 | int error = srs_h264_write_raw_frames(rtmp, data, size, dts, pts); | 169 | int error = srs_h264_write_raw_frames(rtmp, data, size, dts, pts); |
| 170 | if (error != 0) { | 170 | if (error != 0) { |
| 171 | if (srs_h264_is_dvbsp_error(error)) { | 171 | if (srs_h264_is_dvbsp_error(error)) { |
| 172 | - srs_lib_trace("ignore drop video error, code=%d", error); | 172 | + srs_human_trace("ignore drop video error, code=%d", error); |
| 173 | } else if (srs_h264_is_duplicated_sps_error(error)) { | 173 | } else if (srs_h264_is_duplicated_sps_error(error)) { |
| 174 | - srs_lib_trace("ignore duplicated sps, code=%d", error); | 174 | + srs_human_trace("ignore duplicated sps, code=%d", error); |
| 175 | } else if (srs_h264_is_duplicated_pps_error(error)) { | 175 | } else if (srs_h264_is_duplicated_pps_error(error)) { |
| 176 | - srs_lib_trace("ignore duplicated pps, code=%d", error); | 176 | + srs_human_trace("ignore duplicated pps, code=%d", error); |
| 177 | } else { | 177 | } else { |
| 178 | - srs_lib_trace("send h264 raw data failed."); | 178 | + srs_human_trace("send h264 raw data failed."); |
| 179 | goto rtmp_destroy; | 179 | goto rtmp_destroy; |
| 180 | } | 180 | } |
| 181 | } | 181 | } |
| @@ -183,14 +183,14 @@ int main(int argc, char** argv) | @@ -183,14 +183,14 @@ int main(int argc, char** argv) | ||
| 183 | // 5bits, 7.3.1 NAL unit syntax, | 183 | // 5bits, 7.3.1 NAL unit syntax, |
| 184 | // H.264-AVC-ISO_IEC_14496-10.pdf, page 44. | 184 | // H.264-AVC-ISO_IEC_14496-10.pdf, page 44. |
| 185 | u_int8_t nut = (char)data[nb_start_code] & 0x1f; | 185 | u_int8_t nut = (char)data[nb_start_code] & 0x1f; |
| 186 | - srs_lib_trace("sent packet: type=%s, time=%d, size=%d, fps=%d, b[%d]=%#x(%s)", | ||
| 187 | - srs_type2string(SRS_RTMP_TYPE_VIDEO), dts, size, fps, nb_start_code, (char)data[nb_start_code], | 186 | + srs_human_trace("sent packet: type=%s, time=%d, size=%d, fps=%d, b[%d]=%#x(%s)", |
| 187 | + srs_human_flv_tag_type2string(SRS_RTMP_TYPE_VIDEO), dts, size, fps, nb_start_code, (char)data[nb_start_code], | ||
| 188 | (nut == 7? "SPS":(nut == 8? "PPS":(nut == 5? "I":(nut == 1? "P":"Unknown"))))); | 188 | (nut == 7? "SPS":(nut == 8? "PPS":(nut == 5? "I":(nut == 1? "P":"Unknown"))))); |
| 189 | 189 | ||
| 190 | // @remark, when use encode device, it not need to sleep. | 190 | // @remark, when use encode device, it not need to sleep. |
| 191 | usleep(1000 / fps * 1000); | 191 | usleep(1000 / fps * 1000); |
| 192 | } | 192 | } |
| 193 | - srs_lib_trace("h264 raw data completed"); | 193 | + srs_human_trace("h264 raw data completed"); |
| 194 | 194 | ||
| 195 | rtmp_destroy: | 195 | rtmp_destroy: |
| 196 | srs_rtmp_destroy(rtmp); | 196 | srs_rtmp_destroy(rtmp); |
| @@ -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; |
| @@ -89,19 +89,19 @@ int main(int argc, char** argv) | @@ -89,19 +89,19 @@ int main(int argc, char** argv) | ||
| 89 | } | 89 | } |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | - srs_lib_trace("input: %s", in_flv_file); | ||
| 93 | - srs_lib_trace("output: %s", out_rtmp_url); | 92 | + srs_human_trace("input: %s", in_flv_file); |
| 93 | + srs_human_trace("output: %s", out_rtmp_url); | ||
| 94 | 94 | ||
| 95 | if ((flv = srs_flv_open_read(in_flv_file)) == NULL) { | 95 | if ((flv = srs_flv_open_read(in_flv_file)) == NULL) { |
| 96 | ret = 2; | 96 | ret = 2; |
| 97 | - srs_lib_trace("open flv file failed. ret=%d", ret); | 97 | + srs_human_trace("open flv file failed. ret=%d", ret); |
| 98 | return ret; | 98 | return ret; |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | ortmp = srs_rtmp_create(out_rtmp_url); | 101 | ortmp = srs_rtmp_create(out_rtmp_url); |
| 102 | 102 | ||
| 103 | ret = proxy(flv, ortmp); | 103 | ret = proxy(flv, ortmp); |
| 104 | - srs_lib_trace("ingest flv to RTMP completed"); | 104 | + srs_human_trace("ingest flv to RTMP completed"); |
| 105 | 105 | ||
| 106 | srs_rtmp_destroy(ortmp); | 106 | srs_rtmp_destroy(ortmp); |
| 107 | srs_flv_close(flv); | 107 | 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 | @@ -118,20 +118,20 @@ int do_proxy(srs_flv_t flv, srs_rtmp_t ortmp, int64_t re, int32_t* pstarttime, u | ||
| 118 | int size; | 118 | int size; |
| 119 | char* data = NULL; | 119 | char* data = NULL; |
| 120 | 120 | ||
| 121 | - srs_lib_trace("start ingest flv to RTMP stream"); | 121 | + srs_human_trace("start ingest flv to RTMP stream"); |
| 122 | for (;;) { | 122 | for (;;) { |
| 123 | // tag header | 123 | // tag header |
| 124 | if ((ret = srs_flv_read_tag_header(flv, &type, &size, ptimestamp)) != 0) { | 124 | if ((ret = srs_flv_read_tag_header(flv, &type, &size, ptimestamp)) != 0) { |
| 125 | if (srs_flv_is_eof(ret)) { | 125 | if (srs_flv_is_eof(ret)) { |
| 126 | - srs_lib_trace("parse completed."); | 126 | + srs_human_trace("parse completed."); |
| 127 | return 0; | 127 | return 0; |
| 128 | } | 128 | } |
| 129 | - srs_lib_trace("flv get packet failed. ret=%d", ret); | 129 | + srs_human_trace("flv get packet failed. ret=%d", ret); |
| 130 | return ret; | 130 | return ret; |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | if (size <= 0) { | 133 | if (size <= 0) { |
| 134 | - srs_lib_trace("invalid size=%d", size); | 134 | + srs_human_trace("invalid size=%d", size); |
| 135 | break; | 135 | break; |
| 136 | } | 136 | } |
| 137 | 137 | ||
| @@ -143,13 +143,13 @@ int do_proxy(srs_flv_t flv, srs_rtmp_t ortmp, int64_t re, int32_t* pstarttime, u | @@ -143,13 +143,13 @@ int do_proxy(srs_flv_t flv, srs_rtmp_t ortmp, int64_t re, int32_t* pstarttime, u | ||
| 143 | 143 | ||
| 144 | u_int32_t timestamp = *ptimestamp; | 144 | u_int32_t timestamp = *ptimestamp; |
| 145 | 145 | ||
| 146 | - if ((ret = srs_print_rtmp_packet(type, timestamp, data, size)) != 0) { | ||
| 147 | - srs_lib_trace("print packet failed. ret=%d", ret); | 146 | + if ((ret = srs_human_print_rtmp_packet(type, timestamp, data, size)) != 0) { |
| 147 | + srs_human_trace("print packet failed. ret=%d", ret); | ||
| 148 | return ret; | 148 | return ret; |
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | - if ((ret = srs_write_packet(ortmp, type, *ptimestamp, data, size)) != 0) { | ||
| 152 | - srs_lib_trace("irtmp get packet failed. ret=%d", ret); | 151 | + if ((ret = srs_rtmp_write_packet(ortmp, type, *ptimestamp, data, size)) != 0) { |
| 152 | + srs_human_trace("irtmp get packet failed. ret=%d", ret); | ||
| 153 | return ret; | 153 | return ret; |
| 154 | } | 154 | } |
| 155 | 155 | ||
| @@ -191,23 +191,23 @@ int connect_oc(srs_rtmp_t ortmp) | @@ -191,23 +191,23 @@ int connect_oc(srs_rtmp_t ortmp) | ||
| 191 | { | 191 | { |
| 192 | int ret = 0; | 192 | int ret = 0; |
| 193 | 193 | ||
| 194 | - if ((ret = srs_simple_handshake(ortmp)) != 0) { | ||
| 195 | - srs_lib_trace("ortmp simple handshake failed. ret=%d", ret); | 194 | + if ((ret = srs_rtmp_handshake(ortmp)) != 0) { |
| 195 | + srs_human_trace("ortmp simple handshake failed. ret=%d", ret); | ||
| 196 | return ret; | 196 | return ret; |
| 197 | } | 197 | } |
| 198 | - srs_lib_trace("ortmp simple handshake success"); | 198 | + srs_human_trace("ortmp simple handshake success"); |
| 199 | 199 | ||
| 200 | - if ((ret = srs_connect_app(ortmp)) != 0) { | ||
| 201 | - srs_lib_trace("ortmp connect vhost/app failed. ret=%d", ret); | 200 | + if ((ret = srs_rtmp_connect_app(ortmp)) != 0) { |
| 201 | + srs_human_trace("ortmp connect vhost/app failed. ret=%d", ret); | ||
| 202 | return ret; | 202 | return ret; |
| 203 | } | 203 | } |
| 204 | - srs_lib_trace("ortmp connect vhost/app success"); | 204 | + srs_human_trace("ortmp connect vhost/app success"); |
| 205 | 205 | ||
| 206 | - if ((ret = srs_publish_stream(ortmp)) != 0) { | ||
| 207 | - srs_lib_trace("ortmp publish stream failed. ret=%d", ret); | 206 | + if ((ret = srs_rtmp_publish_stream(ortmp)) != 0) { |
| 207 | + srs_human_trace("ortmp publish stream failed. ret=%d", ret); | ||
| 208 | return ret; | 208 | return ret; |
| 209 | } | 209 | } |
| 210 | - srs_lib_trace("ortmp publish stream success"); | 210 | + srs_human_trace("ortmp publish stream success"); |
| 211 | 211 | ||
| 212 | return ret; | 212 | return ret; |
| 213 | } | 213 | } |
| @@ -215,20 +215,20 @@ int connect_oc(srs_rtmp_t ortmp) | @@ -215,20 +215,20 @@ 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; |
| 222 | - srs_lib_trace("deviation is %d ms, pulse is %d ms", (int)(deviation), (int)(RE_PULSE_MS)); | 222 | + srs_human_trace("deviation is %d ms, pulse is %d ms", (int)(deviation), (int)(RE_PULSE_MS)); |
| 223 | 223 | ||
| 224 | // so, we adjust time to max(0, deviation) | 224 | // so, we adjust time to max(0, deviation) |
| 225 | // because the last pulse, we already sleeped | 225 | // because the last pulse, we already sleeped |
| 226 | int adjust = (int)(deviation); | 226 | int adjust = (int)(deviation); |
| 227 | if (adjust > 0) { | 227 | if (adjust > 0) { |
| 228 | - srs_lib_trace("adjust re time for %d ms", adjust); | 228 | + srs_human_trace("adjust re time for %d ms", adjust); |
| 229 | re -= adjust; | 229 | re -= adjust; |
| 230 | } else { | 230 | } else { |
| 231 | - srs_lib_trace("no need to adjust re time"); | 231 | + srs_human_trace("no need to adjust re time"); |
| 232 | } | 232 | } |
| 233 | 233 | ||
| 234 | return re; | 234 | return re; |
| @@ -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,10 +246,10 @@ void re_cleanup(int64_t re, int32_t starttime, u_int32_t time) | @@ -246,10 +246,10 @@ 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_lib_trace("re_cleanup, diff=%d, start=%d, last=%d ms", | 252 | + srs_human_trace("re_cleanup, diff=%d, start=%d, last=%d ms", |
| 253 | (int)diff, starttime, time); | 253 | (int)diff, starttime, time); |
| 254 | usleep(diff * 1000); | 254 | usleep(diff * 1000); |
| 255 | } | 255 | } |
| @@ -74,14 +74,14 @@ int main(int argc, char** argv) | @@ -74,14 +74,14 @@ int main(int argc, char** argv) | ||
| 74 | } | 74 | } |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | - srs_lib_trace("input: %s", in_rtmp_url); | ||
| 78 | - srs_lib_trace("output: %s", out_rtmp_url); | 77 | + srs_human_trace("input: %s", in_rtmp_url); |
| 78 | + srs_human_trace("output: %s", out_rtmp_url); | ||
| 79 | 79 | ||
| 80 | irtmp = srs_rtmp_create(in_rtmp_url); | 80 | irtmp = srs_rtmp_create(in_rtmp_url); |
| 81 | ortmp = srs_rtmp_create(out_rtmp_url); | 81 | ortmp = srs_rtmp_create(out_rtmp_url); |
| 82 | 82 | ||
| 83 | ret = proxy(irtmp, ortmp); | 83 | ret = proxy(irtmp, ortmp); |
| 84 | - srs_lib_trace("proxy completed"); | 84 | + srs_human_trace("proxy completed"); |
| 85 | 85 | ||
| 86 | srs_rtmp_destroy(irtmp); | 86 | srs_rtmp_destroy(irtmp); |
| 87 | srs_rtmp_destroy(ortmp); | 87 | srs_rtmp_destroy(ortmp); |
| @@ -106,24 +106,24 @@ int proxy(srs_rtmp_t irtmp, srs_rtmp_t ortmp) | @@ -106,24 +106,24 @@ int proxy(srs_rtmp_t irtmp, srs_rtmp_t ortmp) | ||
| 106 | return ret; | 106 | return ret; |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | - srs_lib_trace("start proxy RTMP stream"); | 109 | + srs_human_trace("start proxy RTMP stream"); |
| 110 | for (;;) { | 110 | for (;;) { |
| 111 | - if ((ret = srs_read_packet(irtmp, &type, ×tamp, &data, &size)) != 0) { | ||
| 112 | - srs_lib_trace("irtmp get packet failed. ret=%d", ret); | 111 | + if ((ret = srs_rtmp_read_packet(irtmp, &type, ×tamp, &data, &size)) != 0) { |
| 112 | + srs_human_trace("irtmp get packet failed. ret=%d", ret); | ||
| 113 | return ret; | 113 | return ret; |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | - if ((ret = srs_print_rtmp_packet(type, timestamp, data, size)) != 0) { | ||
| 117 | - srs_lib_trace("print packet failed. ret=%d", ret); | 116 | + if ((ret = srs_human_print_rtmp_packet(type, timestamp, data, size)) != 0) { |
| 117 | + srs_human_trace("print packet failed. ret=%d", ret); | ||
| 118 | return ret; | 118 | return ret; |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | - if ((ret = srs_write_packet(ortmp, type, timestamp, data, size)) != 0) { | ||
| 122 | - srs_lib_trace("irtmp get packet failed. ret=%d", ret); | 121 | + if ((ret = srs_rtmp_write_packet(ortmp, type, timestamp, data, size)) != 0) { |
| 122 | + srs_human_trace("irtmp get packet failed. ret=%d", ret); | ||
| 123 | return ret; | 123 | return ret; |
| 124 | } | 124 | } |
| 125 | - srs_lib_verbose("ortmp sent packet: type=%s, time=%d, size=%d", | ||
| 126 | - srs_type2string(type), timestamp, size); | 125 | + srs_human_verbose("ortmp sent packet: type=%s, time=%d, size=%d", |
| 126 | + srs_human_flv_tag_type2string(type), timestamp, size); | ||
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | return ret; | 129 | return ret; |
| @@ -133,23 +133,23 @@ int connect_ic(srs_rtmp_t irtmp) | @@ -133,23 +133,23 @@ int connect_ic(srs_rtmp_t irtmp) | ||
| 133 | { | 133 | { |
| 134 | int ret = 0; | 134 | int ret = 0; |
| 135 | 135 | ||
| 136 | - if ((ret = srs_simple_handshake(irtmp)) != 0) { | ||
| 137 | - srs_lib_trace("irtmp simple handshake failed. ret=%d", ret); | 136 | + if ((ret = srs_rtmp_handshake(irtmp)) != 0) { |
| 137 | + srs_human_trace("irtmp simple handshake failed. ret=%d", ret); | ||
| 138 | return ret; | 138 | return ret; |
| 139 | } | 139 | } |
| 140 | - srs_lib_trace("irtmp simple handshake success"); | 140 | + srs_human_trace("irtmp simple handshake success"); |
| 141 | 141 | ||
| 142 | - if ((ret = srs_connect_app(irtmp)) != 0) { | ||
| 143 | - srs_lib_trace("irtmp connect vhost/app failed. ret=%d", ret); | 142 | + if ((ret = srs_rtmp_connect_app(irtmp)) != 0) { |
| 143 | + srs_human_trace("irtmp connect vhost/app failed. ret=%d", ret); | ||
| 144 | return ret; | 144 | return ret; |
| 145 | } | 145 | } |
| 146 | - srs_lib_trace("irtmp connect vhost/app success"); | 146 | + srs_human_trace("irtmp connect vhost/app success"); |
| 147 | 147 | ||
| 148 | - if ((ret = srs_play_stream(irtmp)) != 0) { | ||
| 149 | - srs_lib_trace("irtmp play stream failed. ret=%d", ret); | 148 | + if ((ret = srs_rtmp_play_stream(irtmp)) != 0) { |
| 149 | + srs_human_trace("irtmp play stream failed. ret=%d", ret); | ||
| 150 | return ret; | 150 | return ret; |
| 151 | } | 151 | } |
| 152 | - srs_lib_trace("irtmp play stream success"); | 152 | + srs_human_trace("irtmp play stream success"); |
| 153 | 153 | ||
| 154 | return ret; | 154 | return ret; |
| 155 | } | 155 | } |
| @@ -158,23 +158,23 @@ int connect_oc(srs_rtmp_t ortmp) | @@ -158,23 +158,23 @@ int connect_oc(srs_rtmp_t ortmp) | ||
| 158 | { | 158 | { |
| 159 | int ret = 0; | 159 | int ret = 0; |
| 160 | 160 | ||
| 161 | - if ((ret = srs_simple_handshake(ortmp)) != 0) { | ||
| 162 | - srs_lib_trace("ortmp simple handshake failed. ret=%d", ret); | 161 | + if ((ret = srs_rtmp_handshake(ortmp)) != 0) { |
| 162 | + srs_human_trace("ortmp simple handshake failed. ret=%d", ret); | ||
| 163 | return ret; | 163 | return ret; |
| 164 | } | 164 | } |
| 165 | - srs_lib_trace("ortmp simple handshake success"); | 165 | + srs_human_trace("ortmp simple handshake success"); |
| 166 | 166 | ||
| 167 | - if ((ret = srs_connect_app(ortmp)) != 0) { | ||
| 168 | - srs_lib_trace("ortmp connect vhost/app failed. ret=%d", ret); | 167 | + if ((ret = srs_rtmp_connect_app(ortmp)) != 0) { |
| 168 | + srs_human_trace("ortmp connect vhost/app failed. ret=%d", ret); | ||
| 169 | return ret; | 169 | return ret; |
| 170 | } | 170 | } |
| 171 | - srs_lib_trace("ortmp connect vhost/app success"); | 171 | + srs_human_trace("ortmp connect vhost/app success"); |
| 172 | 172 | ||
| 173 | - if ((ret = srs_publish_stream(ortmp)) != 0) { | ||
| 174 | - srs_lib_trace("ortmp publish stream failed. ret=%d", ret); | 173 | + if ((ret = srs_rtmp_publish_stream(ortmp)) != 0) { |
| 174 | + srs_human_trace("ortmp publish stream failed. ret=%d", ret); | ||
| 175 | return ret; | 175 | return ret; |
| 176 | } | 176 | } |
| 177 | - srs_lib_trace("ortmp publish stream success"); | 177 | + srs_human_trace("ortmp publish stream success"); |
| 178 | 178 | ||
| 179 | return ret; | 179 | return ret; |
| 180 | } | 180 | } |
| @@ -44,26 +44,26 @@ int main(int argc, char** argv) | @@ -44,26 +44,26 @@ int main(int argc, char** argv) | ||
| 44 | exit(-1); | 44 | exit(-1); |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | - srs_lib_trace("rtmp url: %s", argv[1]); | 47 | + srs_human_trace("rtmp url: %s", argv[1]); |
| 48 | srs_rtmp_t rtmp = srs_rtmp_create(argv[1]); | 48 | srs_rtmp_t rtmp = srs_rtmp_create(argv[1]); |
| 49 | 49 | ||
| 50 | - if (srs_simple_handshake(rtmp) != 0) { | ||
| 51 | - srs_lib_trace("simple handshake failed."); | 50 | + if (srs_rtmp_handshake(rtmp) != 0) { |
| 51 | + srs_human_trace("simple handshake failed."); | ||
| 52 | goto rtmp_destroy; | 52 | goto rtmp_destroy; |
| 53 | } | 53 | } |
| 54 | - srs_lib_trace("simple handshake success"); | 54 | + srs_human_trace("simple handshake success"); |
| 55 | 55 | ||
| 56 | - if (srs_connect_app(rtmp) != 0) { | ||
| 57 | - srs_lib_trace("connect vhost/app failed."); | 56 | + if (srs_rtmp_connect_app(rtmp) != 0) { |
| 57 | + srs_human_trace("connect vhost/app failed."); | ||
| 58 | goto rtmp_destroy; | 58 | goto rtmp_destroy; |
| 59 | } | 59 | } |
| 60 | - srs_lib_trace("connect vhost/app success"); | 60 | + srs_human_trace("connect vhost/app success"); |
| 61 | 61 | ||
| 62 | - if (srs_play_stream(rtmp) != 0) { | ||
| 63 | - srs_lib_trace("play stream failed."); | 62 | + if (srs_rtmp_play_stream(rtmp) != 0) { |
| 63 | + srs_human_trace("play stream failed."); | ||
| 64 | goto rtmp_destroy; | 64 | goto rtmp_destroy; |
| 65 | } | 65 | } |
| 66 | - srs_lib_trace("play stream success"); | 66 | + srs_human_trace("play stream success"); |
| 67 | 67 | ||
| 68 | for (;;) { | 68 | for (;;) { |
| 69 | int size; | 69 | int size; |
| @@ -71,11 +71,11 @@ int main(int argc, char** argv) | @@ -71,11 +71,11 @@ int main(int argc, char** argv) | ||
| 71 | char* data; | 71 | char* data; |
| 72 | u_int32_t timestamp; | 72 | u_int32_t timestamp; |
| 73 | 73 | ||
| 74 | - if (srs_read_packet(rtmp, &type, ×tamp, &data, &size) != 0) { | 74 | + if (srs_rtmp_read_packet(rtmp, &type, ×tamp, &data, &size) != 0) { |
| 75 | goto rtmp_destroy; | 75 | goto rtmp_destroy; |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | - if (srs_print_rtmp_packet(type, timestamp, data, size) != 0) { | 78 | + if (srs_human_print_rtmp_packet(type, timestamp, data, size) != 0) { |
| 79 | goto rtmp_destroy; | 79 | goto rtmp_destroy; |
| 80 | } | 80 | } |
| 81 | 81 |
| @@ -47,31 +47,31 @@ int main(int argc, char** argv) | @@ -47,31 +47,31 @@ int main(int argc, char** argv) | ||
| 47 | 47 | ||
| 48 | // warn it . | 48 | // warn it . |
| 49 | // @see: https://github.com/winlinvip/simple-rtmp-server/issues/126 | 49 | // @see: https://github.com/winlinvip/simple-rtmp-server/issues/126 |
| 50 | - srs_lib_trace("\033[33m%s\033[0m", | 50 | + srs_human_trace("\033[33m%s\033[0m", |
| 51 | "[warning] it's only a sample to use librtmp. " | 51 | "[warning] it's only a sample to use librtmp. " |
| 52 | "please never use it to publish and test forward/transcode/edge/HLS whatever. " | 52 | "please never use it to publish and test forward/transcode/edge/HLS whatever. " |
| 53 | "you should refer to this tool to use the srs-librtmp to publish the real media stream." | 53 | "you should refer to this tool to use the srs-librtmp to publish the real media stream." |
| 54 | "read about: https://github.com/winlinvip/simple-rtmp-server/issues/126"); | 54 | "read about: https://github.com/winlinvip/simple-rtmp-server/issues/126"); |
| 55 | - srs_lib_trace("rtmp url: %s", argv[1]); | 55 | + srs_human_trace("rtmp url: %s", argv[1]); |
| 56 | srs_rtmp_t rtmp = srs_rtmp_create(argv[1]); | 56 | srs_rtmp_t rtmp = srs_rtmp_create(argv[1]); |
| 57 | 57 | ||
| 58 | - if (srs_simple_handshake(rtmp) != 0) { | ||
| 59 | - srs_lib_trace("simple handshake failed."); | 58 | + if (srs_rtmp_handshake(rtmp) != 0) { |
| 59 | + srs_human_trace("simple handshake failed."); | ||
| 60 | goto rtmp_destroy; | 60 | goto rtmp_destroy; |
| 61 | } | 61 | } |
| 62 | - srs_lib_trace("simple handshake success"); | 62 | + srs_human_trace("simple handshake success"); |
| 63 | 63 | ||
| 64 | - if (srs_connect_app(rtmp) != 0) { | ||
| 65 | - srs_lib_trace("connect vhost/app failed."); | 64 | + if (srs_rtmp_connect_app(rtmp) != 0) { |
| 65 | + srs_human_trace("connect vhost/app failed."); | ||
| 66 | goto rtmp_destroy; | 66 | goto rtmp_destroy; |
| 67 | } | 67 | } |
| 68 | - srs_lib_trace("connect vhost/app success"); | 68 | + srs_human_trace("connect vhost/app success"); |
| 69 | 69 | ||
| 70 | - if (srs_publish_stream(rtmp) != 0) { | ||
| 71 | - srs_lib_trace("publish stream failed."); | 70 | + if (srs_rtmp_publish_stream(rtmp) != 0) { |
| 71 | + srs_human_trace("publish stream failed."); | ||
| 72 | goto rtmp_destroy; | 72 | goto rtmp_destroy; |
| 73 | } | 73 | } |
| 74 | - srs_lib_trace("publish stream success"); | 74 | + srs_human_trace("publish stream success"); |
| 75 | 75 | ||
| 76 | u_int32_t timestamp = 0; | 76 | u_int32_t timestamp = 0; |
| 77 | for (;;) { | 77 | for (;;) { |
| @@ -81,11 +81,11 @@ int main(int argc, char** argv) | @@ -81,11 +81,11 @@ int main(int argc, char** argv) | ||
| 81 | 81 | ||
| 82 | timestamp += 40; | 82 | timestamp += 40; |
| 83 | 83 | ||
| 84 | - if (srs_write_packet(rtmp, type, timestamp, data, size) != 0) { | 84 | + if (srs_rtmp_write_packet(rtmp, type, timestamp, data, size) != 0) { |
| 85 | goto rtmp_destroy; | 85 | goto rtmp_destroy; |
| 86 | } | 86 | } |
| 87 | - srs_lib_trace("sent packet: type=%s, time=%d, size=%d", | ||
| 88 | - srs_type2string(type), timestamp, size); | 87 | + srs_human_trace("sent packet: type=%s, time=%d, size=%d", |
| 88 | + srs_human_flv_tag_type2string(type), timestamp, size); | ||
| 89 | 89 | ||
| 90 | usleep(40 * 1000); | 90 | usleep(40 * 1000); |
| 91 | } | 91 | } |
| @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 31 | // current release version | 31 | // current release version |
| 32 | #define VERSION_MAJOR 2 | 32 | #define VERSION_MAJOR 2 |
| 33 | #define VERSION_MINOR 0 | 33 | #define VERSION_MINOR 0 |
| 34 | -#define VERSION_REVISION 28 | 34 | +#define VERSION_REVISION 29 |
| 35 | // server info. | 35 | // server info. |
| 36 | #define RTMP_SIG_SRS_KEY "SRS" | 36 | #define RTMP_SIG_SRS_KEY "SRS" |
| 37 | #define RTMP_SIG_SRS_ROLE "origin/edge server" | 37 | #define RTMP_SIG_SRS_ROLE "origin/edge server" |
| @@ -514,6 +514,21 @@ int srs_librtmp_context_connect(Context* context) | @@ -514,6 +514,21 @@ int srs_librtmp_context_connect(Context* context) | ||
| 514 | extern "C"{ | 514 | extern "C"{ |
| 515 | #endif | 515 | #endif |
| 516 | 516 | ||
| 517 | +int srs_version_major() | ||
| 518 | +{ | ||
| 519 | + return VERSION_MAJOR; | ||
| 520 | +} | ||
| 521 | + | ||
| 522 | +int srs_version_minor() | ||
| 523 | +{ | ||
| 524 | + return VERSION_MINOR; | ||
| 525 | +} | ||
| 526 | + | ||
| 527 | +int srs_version_revision() | ||
| 528 | +{ | ||
| 529 | + return VERSION_REVISION; | ||
| 530 | +} | ||
| 531 | + | ||
| 517 | srs_rtmp_t srs_rtmp_create(const char* url) | 532 | srs_rtmp_t srs_rtmp_create(const char* url) |
| 518 | { | 533 | { |
| 519 | Context* context = new Context(); | 534 | Context* context = new Context(); |
| @@ -541,26 +556,26 @@ void srs_rtmp_destroy(srs_rtmp_t rtmp) | @@ -541,26 +556,26 @@ void srs_rtmp_destroy(srs_rtmp_t rtmp) | ||
| 541 | srs_freep(context); | 556 | srs_freep(context); |
| 542 | } | 557 | } |
| 543 | 558 | ||
| 544 | -int srs_simple_handshake(srs_rtmp_t rtmp) | 559 | +int srs_rtmp_handshake(srs_rtmp_t rtmp) |
| 545 | { | 560 | { |
| 546 | int ret = ERROR_SUCCESS; | 561 | int ret = ERROR_SUCCESS; |
| 547 | 562 | ||
| 548 | - if ((ret = __srs_dns_resolve(rtmp)) != ERROR_SUCCESS) { | 563 | + if ((ret = __srs_rtmp_dns_resolve(rtmp)) != ERROR_SUCCESS) { |
| 549 | return ret; | 564 | return ret; |
| 550 | } | 565 | } |
| 551 | 566 | ||
| 552 | - if ((ret = __srs_connect_server(rtmp)) != ERROR_SUCCESS) { | 567 | + if ((ret = __srs_rtmp_connect_server(rtmp)) != ERROR_SUCCESS) { |
| 553 | return ret; | 568 | return ret; |
| 554 | } | 569 | } |
| 555 | 570 | ||
| 556 | - if ((ret = __srs_do_simple_handshake(rtmp)) != ERROR_SUCCESS) { | 571 | + if ((ret = __srs_rtmp_do_simple_handshake(rtmp)) != ERROR_SUCCESS) { |
| 557 | return ret; | 572 | return ret; |
| 558 | } | 573 | } |
| 559 | 574 | ||
| 560 | return ret; | 575 | return ret; |
| 561 | } | 576 | } |
| 562 | 577 | ||
| 563 | -int __srs_dns_resolve(srs_rtmp_t rtmp) | 578 | +int __srs_rtmp_dns_resolve(srs_rtmp_t rtmp) |
| 564 | { | 579 | { |
| 565 | int ret = ERROR_SUCCESS; | 580 | int ret = ERROR_SUCCESS; |
| 566 | 581 | ||
| @@ -579,7 +594,7 @@ int __srs_dns_resolve(srs_rtmp_t rtmp) | @@ -579,7 +594,7 @@ int __srs_dns_resolve(srs_rtmp_t rtmp) | ||
| 579 | return ret; | 594 | return ret; |
| 580 | } | 595 | } |
| 581 | 596 | ||
| 582 | -int __srs_connect_server(srs_rtmp_t rtmp) | 597 | +int __srs_rtmp_connect_server(srs_rtmp_t rtmp) |
| 583 | { | 598 | { |
| 584 | int ret = ERROR_SUCCESS; | 599 | int ret = ERROR_SUCCESS; |
| 585 | 600 | ||
| @@ -593,7 +608,7 @@ int __srs_connect_server(srs_rtmp_t rtmp) | @@ -593,7 +608,7 @@ int __srs_connect_server(srs_rtmp_t rtmp) | ||
| 593 | return ret; | 608 | return ret; |
| 594 | } | 609 | } |
| 595 | 610 | ||
| 596 | -int __srs_do_simple_handshake(srs_rtmp_t rtmp) | 611 | +int __srs_rtmp_do_simple_handshake(srs_rtmp_t rtmp) |
| 597 | { | 612 | { |
| 598 | int ret = ERROR_SUCCESS; | 613 | int ret = ERROR_SUCCESS; |
| 599 | 614 | ||
| @@ -613,7 +628,7 @@ int __srs_do_simple_handshake(srs_rtmp_t rtmp) | @@ -613,7 +628,7 @@ int __srs_do_simple_handshake(srs_rtmp_t rtmp) | ||
| 613 | return ret; | 628 | return ret; |
| 614 | } | 629 | } |
| 615 | 630 | ||
| 616 | -int srs_connect_app(srs_rtmp_t rtmp) | 631 | +int srs_rtmp_connect_app(srs_rtmp_t rtmp) |
| 617 | { | 632 | { |
| 618 | int ret = ERROR_SUCCESS; | 633 | int ret = ERROR_SUCCESS; |
| 619 | 634 | ||
| @@ -634,7 +649,7 @@ int srs_connect_app(srs_rtmp_t rtmp) | @@ -634,7 +649,7 @@ int srs_connect_app(srs_rtmp_t rtmp) | ||
| 634 | return ret; | 649 | return ret; |
| 635 | } | 650 | } |
| 636 | 651 | ||
| 637 | -int srs_connect_app2(srs_rtmp_t rtmp, | 652 | +int srs_rtmp_connect_app2(srs_rtmp_t rtmp, |
| 638 | char srs_server_ip[128],char srs_server[128], char srs_primary_authors[128], | 653 | char srs_server_ip[128],char srs_server[128], char srs_primary_authors[128], |
| 639 | char srs_version[32], int* srs_id, int* srs_pid | 654 | char srs_version[32], int* srs_id, int* srs_pid |
| 640 | ) { | 655 | ) { |
| @@ -670,7 +685,7 @@ int srs_connect_app2(srs_rtmp_t rtmp, | @@ -670,7 +685,7 @@ int srs_connect_app2(srs_rtmp_t rtmp, | ||
| 670 | return ret; | 685 | return ret; |
| 671 | } | 686 | } |
| 672 | 687 | ||
| 673 | -int srs_play_stream(srs_rtmp_t rtmp) | 688 | +int srs_rtmp_play_stream(srs_rtmp_t rtmp) |
| 674 | { | 689 | { |
| 675 | int ret = ERROR_SUCCESS; | 690 | int ret = ERROR_SUCCESS; |
| 676 | 691 | ||
| @@ -687,7 +702,7 @@ int srs_play_stream(srs_rtmp_t rtmp) | @@ -687,7 +702,7 @@ int srs_play_stream(srs_rtmp_t rtmp) | ||
| 687 | return ret; | 702 | return ret; |
| 688 | } | 703 | } |
| 689 | 704 | ||
| 690 | -int srs_publish_stream(srs_rtmp_t rtmp) | 705 | +int srs_rtmp_publish_stream(srs_rtmp_t rtmp) |
| 691 | { | 706 | { |
| 692 | int ret = ERROR_SUCCESS; | 707 | int ret = ERROR_SUCCESS; |
| 693 | 708 | ||
| @@ -701,24 +716,7 @@ int srs_publish_stream(srs_rtmp_t rtmp) | @@ -701,24 +716,7 @@ int srs_publish_stream(srs_rtmp_t rtmp) | ||
| 701 | return ret; | 716 | return ret; |
| 702 | } | 717 | } |
| 703 | 718 | ||
| 704 | -const char* srs_type2string(char type) | ||
| 705 | -{ | ||
| 706 | - static const char* audio = "Audio"; | ||
| 707 | - static const char* video = "Video"; | ||
| 708 | - static const char* data = "Data"; | ||
| 709 | - static const char* unknown = "Unknown"; | ||
| 710 | - | ||
| 711 | - switch (type) { | ||
| 712 | - case SRS_RTMP_TYPE_AUDIO: return audio; | ||
| 713 | - case SRS_RTMP_TYPE_VIDEO: return video; | ||
| 714 | - case SRS_RTMP_TYPE_SCRIPT: return data; | ||
| 715 | - default: return unknown; | ||
| 716 | - } | ||
| 717 | - | ||
| 718 | - return unknown; | ||
| 719 | -} | ||
| 720 | - | ||
| 721 | -int srs_bandwidth_check(srs_rtmp_t rtmp, | 719 | +int srs_rtmp_bandwidth_check(srs_rtmp_t rtmp, |
| 722 | int64_t* start_time, int64_t* end_time, | 720 | int64_t* start_time, int64_t* end_time, |
| 723 | int* play_kbps, int* publish_kbps, | 721 | int* play_kbps, int* publish_kbps, |
| 724 | int* play_bytes, int* publish_bytes, | 722 | int* play_bytes, int* publish_bytes, |
| @@ -754,7 +752,7 @@ int srs_bandwidth_check(srs_rtmp_t rtmp, | @@ -754,7 +752,7 @@ int srs_bandwidth_check(srs_rtmp_t rtmp, | ||
| 754 | return ret; | 752 | return ret; |
| 755 | } | 753 | } |
| 756 | 754 | ||
| 757 | -int srs_read_packet(srs_rtmp_t rtmp, char* type, u_int32_t* timestamp, char** data, int* size) | 755 | +int srs_rtmp_read_packet(srs_rtmp_t rtmp, char* type, u_int32_t* timestamp, char** data, int* size) |
| 758 | { | 756 | { |
| 759 | *type = 0; | 757 | *type = 0; |
| 760 | *timestamp = 0; | 758 | *timestamp = 0; |
| @@ -809,7 +807,7 @@ int srs_read_packet(srs_rtmp_t rtmp, char* type, u_int32_t* timestamp, char** da | @@ -809,7 +807,7 @@ int srs_read_packet(srs_rtmp_t rtmp, char* type, u_int32_t* timestamp, char** da | ||
| 809 | return ret; | 807 | return ret; |
| 810 | } | 808 | } |
| 811 | 809 | ||
| 812 | -int srs_write_packet(srs_rtmp_t rtmp, char type, u_int32_t timestamp, char* data, int size) | 810 | +int srs_rtmp_write_packet(srs_rtmp_t rtmp, char type, u_int32_t timestamp, char* data, int size) |
| 813 | { | 811 | { |
| 814 | int ret = ERROR_SUCCESS; | 812 | int ret = ERROR_SUCCESS; |
| 815 | 813 | ||
| @@ -860,267 +858,6 @@ int srs_write_packet(srs_rtmp_t rtmp, char type, u_int32_t timestamp, char* data | @@ -860,267 +858,6 @@ int srs_write_packet(srs_rtmp_t rtmp, char type, u_int32_t timestamp, char* data | ||
| 860 | return ret; | 858 | return ret; |
| 861 | } | 859 | } |
| 862 | 860 | ||
| 863 | -int srs_version_major() | ||
| 864 | -{ | ||
| 865 | - return VERSION_MAJOR; | ||
| 866 | -} | ||
| 867 | - | ||
| 868 | -int srs_version_minor() | ||
| 869 | -{ | ||
| 870 | - return VERSION_MINOR; | ||
| 871 | -} | ||
| 872 | - | ||
| 873 | -int srs_version_revision() | ||
| 874 | -{ | ||
| 875 | - return VERSION_REVISION; | ||
| 876 | -} | ||
| 877 | - | ||
| 878 | -int64_t srs_get_time_ms() | ||
| 879 | -{ | ||
| 880 | - srs_update_system_time_ms(); | ||
| 881 | - return srs_get_system_time_ms(); | ||
| 882 | -} | ||
| 883 | - | ||
| 884 | -int64_t srs_get_nsend_bytes(srs_rtmp_t rtmp) | ||
| 885 | -{ | ||
| 886 | - srs_assert(rtmp != NULL); | ||
| 887 | - Context* context = (Context*)rtmp; | ||
| 888 | - return context->rtmp->get_send_bytes(); | ||
| 889 | -} | ||
| 890 | - | ||
| 891 | -int64_t srs_get_nrecv_bytes(srs_rtmp_t rtmp) | ||
| 892 | -{ | ||
| 893 | - srs_assert(rtmp != NULL); | ||
| 894 | - Context* context = (Context*)rtmp; | ||
| 895 | - return context->rtmp->get_recv_bytes(); | ||
| 896 | -} | ||
| 897 | - | ||
| 898 | -int srs_parse_timestamp( | ||
| 899 | - u_int32_t time, char type, char* data, int size, | ||
| 900 | - u_int32_t* ppts | ||
| 901 | -) { | ||
| 902 | - int ret = ERROR_SUCCESS; | ||
| 903 | - | ||
| 904 | - if (type != SRS_RTMP_TYPE_VIDEO) { | ||
| 905 | - *ppts = time; | ||
| 906 | - return ret; | ||
| 907 | - } | ||
| 908 | - | ||
| 909 | - if (!SrsFlvCodec::video_is_h264(data, size)) { | ||
| 910 | - return ERROR_FLV_INVALID_VIDEO_TAG; | ||
| 911 | - } | ||
| 912 | - | ||
| 913 | - if (SrsFlvCodec::video_is_sequence_header(data, size)) { | ||
| 914 | - *ppts = time; | ||
| 915 | - return ret; | ||
| 916 | - } | ||
| 917 | - | ||
| 918 | - // 1bytes, frame type and codec id. | ||
| 919 | - // 1bytes, avc packet type. | ||
| 920 | - // 3bytes, cts, composition time, | ||
| 921 | - // pts = dts + cts, or | ||
| 922 | - // cts = pts - dts. | ||
| 923 | - if (size < 5) { | ||
| 924 | - return ERROR_FLV_INVALID_VIDEO_TAG; | ||
| 925 | - } | ||
| 926 | - | ||
| 927 | - u_int32_t cts = 0; | ||
| 928 | - char* p = data + 2; | ||
| 929 | - char* pp = (char*)&cts; | ||
| 930 | - pp[2] = *p++; | ||
| 931 | - pp[1] = *p++; | ||
| 932 | - pp[0] = *p++; | ||
| 933 | - | ||
| 934 | - *ppts = time + cts; | ||
| 935 | - | ||
| 936 | - return ret; | ||
| 937 | -} | ||
| 938 | - | ||
| 939 | -char srs_get_codec_id(char* data, int size) | ||
| 940 | -{ | ||
| 941 | - if (size < 1) { | ||
| 942 | - return 0; | ||
| 943 | - } | ||
| 944 | - | ||
| 945 | - char codec_id = data[0]; | ||
| 946 | - codec_id = codec_id & 0x0F; | ||
| 947 | - | ||
| 948 | - return codec_id; | ||
| 949 | -} | ||
| 950 | - | ||
| 951 | -const char* srs_code_id2string(char codec_id) | ||
| 952 | -{ | ||
| 953 | - static const char* h263 = "H.263"; | ||
| 954 | - static const char* screen = "Screen"; | ||
| 955 | - static const char* vp6 = "VP6"; | ||
| 956 | - static const char* vp6_alpha = "VP6Alpha"; | ||
| 957 | - static const char* screen2 = "Screen2"; | ||
| 958 | - static const char* h264 = "H.264"; | ||
| 959 | - static const char* unknown = "Unknown"; | ||
| 960 | - | ||
| 961 | - switch (codec_id) { | ||
| 962 | - case 2: return h263; | ||
| 963 | - case 3: return screen; | ||
| 964 | - case 4: return vp6; | ||
| 965 | - case 5: return vp6_alpha; | ||
| 966 | - case 6: return screen2; | ||
| 967 | - case 7: return h264; | ||
| 968 | - default: return unknown; | ||
| 969 | - } | ||
| 970 | - | ||
| 971 | - return unknown; | ||
| 972 | -} | ||
| 973 | - | ||
| 974 | -char srs_get_avc_packet_type(char* data, int size) | ||
| 975 | -{ | ||
| 976 | - if (size < 2) { | ||
| 977 | - return -1; | ||
| 978 | - } | ||
| 979 | - | ||
| 980 | - if (!SrsFlvCodec::video_is_h264(data, size)) { | ||
| 981 | - return -1; | ||
| 982 | - } | ||
| 983 | - | ||
| 984 | - u_int8_t avc_packet_type = data[1]; | ||
| 985 | - | ||
| 986 | - if (avc_packet_type > 2) { | ||
| 987 | - return -1; | ||
| 988 | - } | ||
| 989 | - | ||
| 990 | - return avc_packet_type; | ||
| 991 | -} | ||
| 992 | - | ||
| 993 | -const char* srs_avc_packet2string(char avc_packet_type) | ||
| 994 | -{ | ||
| 995 | - static const char* sps_pps = "SpsPps"; | ||
| 996 | - static const char* nalu = "Nalu"; | ||
| 997 | - static const char* sps_pps_end = "SpsPpsEnd"; | ||
| 998 | - static const char* unknown = "Unknown"; | ||
| 999 | - | ||
| 1000 | - switch (avc_packet_type) { | ||
| 1001 | - case 0: return sps_pps; | ||
| 1002 | - case 1: return nalu; | ||
| 1003 | - case 2: return sps_pps_end; | ||
| 1004 | - default: return unknown; | ||
| 1005 | - } | ||
| 1006 | - | ||
| 1007 | - return unknown; | ||
| 1008 | -} | ||
| 1009 | - | ||
| 1010 | -char srs_get_frame_type(char* data, int size) | ||
| 1011 | -{ | ||
| 1012 | - if (size < 1) { | ||
| 1013 | - return -1; | ||
| 1014 | - } | ||
| 1015 | - | ||
| 1016 | - if (!SrsFlvCodec::video_is_h264(data, size)) { | ||
| 1017 | - return -1; | ||
| 1018 | - } | ||
| 1019 | - | ||
| 1020 | - u_int8_t frame_type = data[0]; | ||
| 1021 | - frame_type = (frame_type >> 4) & 0x0f; | ||
| 1022 | - if (frame_type < 1 || frame_type > 5) { | ||
| 1023 | - return -1; | ||
| 1024 | - } | ||
| 1025 | - | ||
| 1026 | - return frame_type; | ||
| 1027 | -} | ||
| 1028 | - | ||
| 1029 | -const char* srs_frame_type2string(char frame_type) | ||
| 1030 | -{ | ||
| 1031 | - static const char* keyframe = "I"; | ||
| 1032 | - static const char* interframe = "P/B"; | ||
| 1033 | - static const char* disposable_interframe = "DI"; | ||
| 1034 | - static const char* generated_keyframe = "GI"; | ||
| 1035 | - static const char* video_infoframe = "VI"; | ||
| 1036 | - static const char* unknown = "Unknown"; | ||
| 1037 | - | ||
| 1038 | - switch (frame_type) { | ||
| 1039 | - case 1: return keyframe; | ||
| 1040 | - case 2: return interframe; | ||
| 1041 | - case 3: return disposable_interframe; | ||
| 1042 | - case 4: return generated_keyframe; | ||
| 1043 | - case 5: return video_infoframe; | ||
| 1044 | - default: return unknown; | ||
| 1045 | - } | ||
| 1046 | - | ||
| 1047 | - return unknown; | ||
| 1048 | -} | ||
| 1049 | - | ||
| 1050 | -int srs_print_rtmp_packet(char type, u_int32_t timestamp, char* data, int size) | ||
| 1051 | -{ | ||
| 1052 | - int ret = ERROR_SUCCESS; | ||
| 1053 | - | ||
| 1054 | - u_int32_t pts; | ||
| 1055 | - if (srs_parse_timestamp(timestamp, type, data, size, &pts) != 0) { | ||
| 1056 | - return ret; | ||
| 1057 | - } | ||
| 1058 | - | ||
| 1059 | - if (type == SRS_RTMP_TYPE_VIDEO) { | ||
| 1060 | - srs_lib_trace("Video packet type=%s, dts=%d, pts=%d, size=%d, %s(%s,%s)", | ||
| 1061 | - srs_type2string(type), timestamp, pts, size, | ||
| 1062 | - srs_code_id2string(srs_get_codec_id(data, size)), | ||
| 1063 | - srs_avc_packet2string(srs_get_avc_packet_type(data, size)), | ||
| 1064 | - srs_frame_type2string(srs_get_frame_type(data, size)) | ||
| 1065 | - ); | ||
| 1066 | - } else if (type == SRS_RTMP_TYPE_AUDIO) { | ||
| 1067 | - srs_lib_trace("Audio packet type=%s, dts=%d, pts=%d, size=%d", | ||
| 1068 | - srs_type2string(type), timestamp, pts, size); | ||
| 1069 | - } else if (type == SRS_RTMP_TYPE_SCRIPT) { | ||
| 1070 | - srs_lib_verbose("Data packet type=%s, time=%d, size=%d", | ||
| 1071 | - srs_type2string(type), timestamp, size); | ||
| 1072 | - int nparsed = 0; | ||
| 1073 | - while (nparsed < size) { | ||
| 1074 | - int nb_parsed_this = 0; | ||
| 1075 | - srs_amf0_t amf0 = srs_amf0_parse(data + nparsed, size - nparsed, &nb_parsed_this); | ||
| 1076 | - if (amf0 == NULL) { | ||
| 1077 | - break; | ||
| 1078 | - } | ||
| 1079 | - | ||
| 1080 | - nparsed += nb_parsed_this; | ||
| 1081 | - | ||
| 1082 | - char* amf0_str = NULL; | ||
| 1083 | - srs_raw_trace("%s", srs_amf0_human_print(amf0, &amf0_str, NULL)); | ||
| 1084 | - srs_amf0_free_bytes(amf0_str); | ||
| 1085 | - } | ||
| 1086 | - } else { | ||
| 1087 | - srs_lib_trace("Unknown packet type=%s, dts=%d, pts=%d, size=%d", | ||
| 1088 | - srs_type2string(type), timestamp, pts, size); | ||
| 1089 | - } | ||
| 1090 | - | ||
| 1091 | - return ret; | ||
| 1092 | -} | ||
| 1093 | - | ||
| 1094 | -const char* srs_format_time() | ||
| 1095 | -{ | ||
| 1096 | - struct timeval tv; | ||
| 1097 | - static char buf[23]; | ||
| 1098 | - | ||
| 1099 | - memset(buf, 0, sizeof(buf)); | ||
| 1100 | - | ||
| 1101 | - // clock time | ||
| 1102 | - if (gettimeofday(&tv, NULL) == -1) { | ||
| 1103 | - return buf; | ||
| 1104 | - } | ||
| 1105 | - | ||
| 1106 | - // to calendar time | ||
| 1107 | - struct tm* tm; | ||
| 1108 | - if ((tm = localtime((const time_t*)&tv.tv_sec)) == NULL) { | ||
| 1109 | - return buf; | ||
| 1110 | - } | ||
| 1111 | - | ||
| 1112 | - snprintf(buf, sizeof(buf), | ||
| 1113 | - "%d-%02d-%02d %02d:%02d:%02d.%03d", | ||
| 1114 | - 1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, | ||
| 1115 | - tm->tm_hour, tm->tm_min, tm->tm_sec, | ||
| 1116 | - (int)(tv.tv_usec / 1000)); | ||
| 1117 | - | ||
| 1118 | - // for srs-librtmp, @see https://github.com/winlinvip/simple-rtmp-server/issues/213 | ||
| 1119 | - buf[sizeof(buf) - 1] = 0; | ||
| 1120 | - | ||
| 1121 | - return buf; | ||
| 1122 | -} | ||
| 1123 | - | ||
| 1124 | struct FlvContext | 861 | struct FlvContext |
| 1125 | { | 862 | { |
| 1126 | SrsFileReader reader; | 863 | SrsFileReader reader; |
| @@ -1574,25 +1311,14 @@ srs_amf0_t srs_amf0_strict_array_property_at(srs_amf0_t amf0, int index) | @@ -1574,25 +1311,14 @@ srs_amf0_t srs_amf0_strict_array_property_at(srs_amf0_t amf0, int index) | ||
| 1574 | return (srs_amf0_t)obj->at(index); | 1311 | return (srs_amf0_t)obj->at(index); |
| 1575 | } | 1312 | } |
| 1576 | 1313 | ||
| 1577 | -void srs_amf0_strict_array_append(srs_amf0_t amf0, srs_amf0_t value) | ||
| 1578 | -{ | ||
| 1579 | - SrsAmf0Any* any = (SrsAmf0Any*)amf0; | ||
| 1580 | - srs_assert(any->is_strict_array()); | ||
| 1581 | - | ||
| 1582 | - SrsAmf0StrictArray* obj = (SrsAmf0StrictArray*)amf0; | ||
| 1583 | - any = (SrsAmf0Any*)value; | ||
| 1584 | - obj->append(any); | ||
| 1585 | -} | ||
| 1586 | - | ||
| 1587 | -char* srs_amf0_human_print(srs_amf0_t amf0, char** pdata, int* psize) | ||
| 1588 | -{ | ||
| 1589 | - if (!amf0) { | ||
| 1590 | - return NULL; | ||
| 1591 | - } | ||
| 1592 | - | 1314 | +void srs_amf0_strict_array_append(srs_amf0_t amf0, srs_amf0_t value) |
| 1315 | +{ | ||
| 1593 | SrsAmf0Any* any = (SrsAmf0Any*)amf0; | 1316 | SrsAmf0Any* any = (SrsAmf0Any*)amf0; |
| 1594 | - | ||
| 1595 | - return any->human_print(pdata, psize); | 1317 | + srs_assert(any->is_strict_array()); |
| 1318 | + | ||
| 1319 | + SrsAmf0StrictArray* obj = (SrsAmf0StrictArray*)amf0; | ||
| 1320 | + any = (SrsAmf0Any*)value; | ||
| 1321 | + obj->append(any); | ||
| 1596 | } | 1322 | } |
| 1597 | 1323 | ||
| 1598 | /** | 1324 | /** |
| @@ -1630,7 +1356,7 @@ int srs_audio_write_raw_frame(srs_rtmp_t rtmp, | @@ -1630,7 +1356,7 @@ int srs_audio_write_raw_frame(srs_rtmp_t rtmp, | ||
| 1630 | 1356 | ||
| 1631 | memcpy(p, frame, frame_size); | 1357 | memcpy(p, frame, frame_size); |
| 1632 | 1358 | ||
| 1633 | - return srs_write_packet(context, SRS_RTMP_TYPE_AUDIO, timestamp, data, size); | 1359 | + return srs_rtmp_write_packet(context, SRS_RTMP_TYPE_AUDIO, timestamp, data, size); |
| 1634 | } | 1360 | } |
| 1635 | 1361 | ||
| 1636 | /** | 1362 | /** |
| @@ -1677,7 +1403,7 @@ int __srs_write_h264_packet(Context* context, | @@ -1677,7 +1403,7 @@ int __srs_write_h264_packet(Context* context, | ||
| 1677 | // h.264 raw data. | 1403 | // h.264 raw data. |
| 1678 | memcpy(p, h264_raw_data, h264_raw_size); | 1404 | memcpy(p, h264_raw_data, h264_raw_size); |
| 1679 | 1405 | ||
| 1680 | - return srs_write_packet(context, SRS_RTMP_TYPE_VIDEO, timestamp, data, size); | 1406 | + return srs_rtmp_write_packet(context, SRS_RTMP_TYPE_VIDEO, timestamp, data, size); |
| 1681 | } | 1407 | } |
| 1682 | 1408 | ||
| 1683 | /** | 1409 | /** |
| @@ -1986,6 +1712,280 @@ int srs_h264_startswith_annexb(char* h264_raw_data, int h264_raw_size, int* pnb_ | @@ -1986,6 +1712,280 @@ int srs_h264_startswith_annexb(char* h264_raw_data, int h264_raw_size, int* pnb_ | ||
| 1986 | return srs_avc_startswith_annexb(&stream, pnb_start_code); | 1712 | return srs_avc_startswith_annexb(&stream, pnb_start_code); |
| 1987 | } | 1713 | } |
| 1988 | 1714 | ||
| 1715 | +int64_t srs_utils_get_time_ms() | ||
| 1716 | +{ | ||
| 1717 | + srs_update_system_time_ms(); | ||
| 1718 | + return srs_get_system_time_ms(); | ||
| 1719 | +} | ||
| 1720 | + | ||
| 1721 | +int64_t srs_utils_get_send_bytes(srs_rtmp_t rtmp) | ||
| 1722 | +{ | ||
| 1723 | + srs_assert(rtmp != NULL); | ||
| 1724 | + Context* context = (Context*)rtmp; | ||
| 1725 | + return context->rtmp->get_send_bytes(); | ||
| 1726 | +} | ||
| 1727 | + | ||
| 1728 | +int64_t srs_utils_get_recv_bytes(srs_rtmp_t rtmp) | ||
| 1729 | +{ | ||
| 1730 | + srs_assert(rtmp != NULL); | ||
| 1731 | + Context* context = (Context*)rtmp; | ||
| 1732 | + return context->rtmp->get_recv_bytes(); | ||
| 1733 | +} | ||
| 1734 | + | ||
| 1735 | +int srs_utils_parse_timestamp( | ||
| 1736 | + u_int32_t time, char type, char* data, int size, | ||
| 1737 | + u_int32_t* ppts | ||
| 1738 | +) { | ||
| 1739 | + int ret = ERROR_SUCCESS; | ||
| 1740 | + | ||
| 1741 | + if (type != SRS_RTMP_TYPE_VIDEO) { | ||
| 1742 | + *ppts = time; | ||
| 1743 | + return ret; | ||
| 1744 | + } | ||
| 1745 | + | ||
| 1746 | + if (!SrsFlvCodec::video_is_h264(data, size)) { | ||
| 1747 | + return ERROR_FLV_INVALID_VIDEO_TAG; | ||
| 1748 | + } | ||
| 1749 | + | ||
| 1750 | + if (SrsFlvCodec::video_is_sequence_header(data, size)) { | ||
| 1751 | + *ppts = time; | ||
| 1752 | + return ret; | ||
| 1753 | + } | ||
| 1754 | + | ||
| 1755 | + // 1bytes, frame type and codec id. | ||
| 1756 | + // 1bytes, avc packet type. | ||
| 1757 | + // 3bytes, cts, composition time, | ||
| 1758 | + // pts = dts + cts, or | ||
| 1759 | + // cts = pts - dts. | ||
| 1760 | + if (size < 5) { | ||
| 1761 | + return ERROR_FLV_INVALID_VIDEO_TAG; | ||
| 1762 | + } | ||
| 1763 | + | ||
| 1764 | + u_int32_t cts = 0; | ||
| 1765 | + char* p = data + 2; | ||
| 1766 | + char* pp = (char*)&cts; | ||
| 1767 | + pp[2] = *p++; | ||
| 1768 | + pp[1] = *p++; | ||
| 1769 | + pp[0] = *p++; | ||
| 1770 | + | ||
| 1771 | + *ppts = time + cts; | ||
| 1772 | + | ||
| 1773 | + return ret; | ||
| 1774 | +} | ||
| 1775 | + | ||
| 1776 | +char srs_utils_get_flv_video_codec_id(char* data, int size) | ||
| 1777 | +{ | ||
| 1778 | + if (size < 1) { | ||
| 1779 | + return 0; | ||
| 1780 | + } | ||
| 1781 | + | ||
| 1782 | + char codec_id = data[0]; | ||
| 1783 | + codec_id = codec_id & 0x0F; | ||
| 1784 | + | ||
| 1785 | + return codec_id; | ||
| 1786 | +} | ||
| 1787 | + | ||
| 1788 | +char srs_utils_get_flv_video_avc_packet_type(char* data, int size) | ||
| 1789 | +{ | ||
| 1790 | + if (size < 2) { | ||
| 1791 | + return -1; | ||
| 1792 | + } | ||
| 1793 | + | ||
| 1794 | + if (!SrsFlvCodec::video_is_h264(data, size)) { | ||
| 1795 | + return -1; | ||
| 1796 | + } | ||
| 1797 | + | ||
| 1798 | + u_int8_t avc_packet_type = data[1]; | ||
| 1799 | + | ||
| 1800 | + if (avc_packet_type > 2) { | ||
| 1801 | + return -1; | ||
| 1802 | + } | ||
| 1803 | + | ||
| 1804 | + return avc_packet_type; | ||
| 1805 | +} | ||
| 1806 | + | ||
| 1807 | +char srs_utils_get_flv_video_frame_type(char* data, int size) | ||
| 1808 | +{ | ||
| 1809 | + if (size < 1) { | ||
| 1810 | + return -1; | ||
| 1811 | + } | ||
| 1812 | + | ||
| 1813 | + if (!SrsFlvCodec::video_is_h264(data, size)) { | ||
| 1814 | + return -1; | ||
| 1815 | + } | ||
| 1816 | + | ||
| 1817 | + u_int8_t frame_type = data[0]; | ||
| 1818 | + frame_type = (frame_type >> 4) & 0x0f; | ||
| 1819 | + if (frame_type < 1 || frame_type > 5) { | ||
| 1820 | + return -1; | ||
| 1821 | + } | ||
| 1822 | + | ||
| 1823 | + return frame_type; | ||
| 1824 | +} | ||
| 1825 | + | ||
| 1826 | +char* srs_human_amf0_print(srs_amf0_t amf0, char** pdata, int* psize) | ||
| 1827 | +{ | ||
| 1828 | + if (!amf0) { | ||
| 1829 | + return NULL; | ||
| 1830 | + } | ||
| 1831 | + | ||
| 1832 | + SrsAmf0Any* any = (SrsAmf0Any*)amf0; | ||
| 1833 | + | ||
| 1834 | + return any->human_print(pdata, psize); | ||
| 1835 | +} | ||
| 1836 | + | ||
| 1837 | +const char* srs_human_flv_tag_type2string(char type) | ||
| 1838 | +{ | ||
| 1839 | + static const char* audio = "Audio"; | ||
| 1840 | + static const char* video = "Video"; | ||
| 1841 | + static const char* data = "Data"; | ||
| 1842 | + static const char* unknown = "Unknown"; | ||
| 1843 | + | ||
| 1844 | + switch (type) { | ||
| 1845 | + case SRS_RTMP_TYPE_AUDIO: return audio; | ||
| 1846 | + case SRS_RTMP_TYPE_VIDEO: return video; | ||
| 1847 | + case SRS_RTMP_TYPE_SCRIPT: return data; | ||
| 1848 | + default: return unknown; | ||
| 1849 | + } | ||
| 1850 | + | ||
| 1851 | + return unknown; | ||
| 1852 | +} | ||
| 1853 | + | ||
| 1854 | +const char* srs_human_flv_video_codec_id2string(char codec_id) | ||
| 1855 | +{ | ||
| 1856 | + static const char* h263 = "H.263"; | ||
| 1857 | + static const char* screen = "Screen"; | ||
| 1858 | + static const char* vp6 = "VP6"; | ||
| 1859 | + static const char* vp6_alpha = "VP6Alpha"; | ||
| 1860 | + static const char* screen2 = "Screen2"; | ||
| 1861 | + static const char* h264 = "H.264"; | ||
| 1862 | + static const char* unknown = "Unknown"; | ||
| 1863 | + | ||
| 1864 | + switch (codec_id) { | ||
| 1865 | + case 2: return h263; | ||
| 1866 | + case 3: return screen; | ||
| 1867 | + case 4: return vp6; | ||
| 1868 | + case 5: return vp6_alpha; | ||
| 1869 | + case 6: return screen2; | ||
| 1870 | + case 7: return h264; | ||
| 1871 | + default: return unknown; | ||
| 1872 | + } | ||
| 1873 | + | ||
| 1874 | + return unknown; | ||
| 1875 | +} | ||
| 1876 | + | ||
| 1877 | +const char* srs_human_flv_video_avc_packet_type2string(char avc_packet_type) | ||
| 1878 | +{ | ||
| 1879 | + static const char* sps_pps = "SpsPps"; | ||
| 1880 | + static const char* nalu = "Nalu"; | ||
| 1881 | + static const char* sps_pps_end = "SpsPpsEnd"; | ||
| 1882 | + static const char* unknown = "Unknown"; | ||
| 1883 | + | ||
| 1884 | + switch (avc_packet_type) { | ||
| 1885 | + case 0: return sps_pps; | ||
| 1886 | + case 1: return nalu; | ||
| 1887 | + case 2: return sps_pps_end; | ||
| 1888 | + default: return unknown; | ||
| 1889 | + } | ||
| 1890 | + | ||
| 1891 | + return unknown; | ||
| 1892 | +} | ||
| 1893 | + | ||
| 1894 | +const char* srs_human_flv_video_frame_type2string(char frame_type) | ||
| 1895 | +{ | ||
| 1896 | + static const char* keyframe = "I"; | ||
| 1897 | + static const char* interframe = "P/B"; | ||
| 1898 | + static const char* disposable_interframe = "DI"; | ||
| 1899 | + static const char* generated_keyframe = "GI"; | ||
| 1900 | + static const char* video_infoframe = "VI"; | ||
| 1901 | + static const char* unknown = "Unknown"; | ||
| 1902 | + | ||
| 1903 | + switch (frame_type) { | ||
| 1904 | + case 1: return keyframe; | ||
| 1905 | + case 2: return interframe; | ||
| 1906 | + case 3: return disposable_interframe; | ||
| 1907 | + case 4: return generated_keyframe; | ||
| 1908 | + case 5: return video_infoframe; | ||
| 1909 | + default: return unknown; | ||
| 1910 | + } | ||
| 1911 | + | ||
| 1912 | + return unknown; | ||
| 1913 | +} | ||
| 1914 | + | ||
| 1915 | +int srs_human_print_rtmp_packet(char type, u_int32_t timestamp, char* data, int size) | ||
| 1916 | +{ | ||
| 1917 | + int ret = ERROR_SUCCESS; | ||
| 1918 | + | ||
| 1919 | + u_int32_t pts; | ||
| 1920 | + if (srs_utils_parse_timestamp(timestamp, type, data, size, &pts) != 0) { | ||
| 1921 | + return ret; | ||
| 1922 | + } | ||
| 1923 | + | ||
| 1924 | + if (type == SRS_RTMP_TYPE_VIDEO) { | ||
| 1925 | + srs_human_trace("Video packet type=%s, dts=%d, pts=%d, size=%d, %s(%s,%s)", | ||
| 1926 | + srs_human_flv_tag_type2string(type), timestamp, pts, size, | ||
| 1927 | + srs_human_flv_video_codec_id2string(srs_utils_get_flv_video_codec_id(data, size)), | ||
| 1928 | + srs_human_flv_video_avc_packet_type2string(srs_utils_get_flv_video_avc_packet_type(data, size)), | ||
| 1929 | + srs_human_flv_video_frame_type2string(srs_utils_get_flv_video_frame_type(data, size)) | ||
| 1930 | + ); | ||
| 1931 | + } else if (type == SRS_RTMP_TYPE_AUDIO) { | ||
| 1932 | + srs_human_trace("Audio packet type=%s, dts=%d, pts=%d, size=%d", | ||
| 1933 | + srs_human_flv_tag_type2string(type), timestamp, pts, size); | ||
| 1934 | + } else if (type == SRS_RTMP_TYPE_SCRIPT) { | ||
| 1935 | + srs_human_verbose("Data packet type=%s, time=%d, size=%d", | ||
| 1936 | + srs_human_flv_tag_type2string(type), timestamp, size); | ||
| 1937 | + int nparsed = 0; | ||
| 1938 | + while (nparsed < size) { | ||
| 1939 | + int nb_parsed_this = 0; | ||
| 1940 | + srs_amf0_t amf0 = srs_amf0_parse(data + nparsed, size - nparsed, &nb_parsed_this); | ||
| 1941 | + if (amf0 == NULL) { | ||
| 1942 | + break; | ||
| 1943 | + } | ||
| 1944 | + | ||
| 1945 | + nparsed += nb_parsed_this; | ||
| 1946 | + | ||
| 1947 | + char* amf0_str = NULL; | ||
| 1948 | + srs_human_raw("%s", srs_human_amf0_print(amf0, &amf0_str, NULL)); | ||
| 1949 | + srs_amf0_free_bytes(amf0_str); | ||
| 1950 | + } | ||
| 1951 | + } else { | ||
| 1952 | + srs_human_trace("Unknown packet type=%s, dts=%d, pts=%d, size=%d", | ||
| 1953 | + srs_human_flv_tag_type2string(type), timestamp, pts, size); | ||
| 1954 | + } | ||
| 1955 | + | ||
| 1956 | + return ret; | ||
| 1957 | +} | ||
| 1958 | + | ||
| 1959 | +const char* srs_human_format_time() | ||
| 1960 | +{ | ||
| 1961 | + struct timeval tv; | ||
| 1962 | + static char buf[23]; | ||
| 1963 | + | ||
| 1964 | + memset(buf, 0, sizeof(buf)); | ||
| 1965 | + | ||
| 1966 | + // clock time | ||
| 1967 | + if (gettimeofday(&tv, NULL) == -1) { | ||
| 1968 | + return buf; | ||
| 1969 | + } | ||
| 1970 | + | ||
| 1971 | + // to calendar time | ||
| 1972 | + struct tm* tm; | ||
| 1973 | + if ((tm = localtime((const time_t*)&tv.tv_sec)) == NULL) { | ||
| 1974 | + return buf; | ||
| 1975 | + } | ||
| 1976 | + | ||
| 1977 | + snprintf(buf, sizeof(buf), | ||
| 1978 | + "%d-%02d-%02d %02d:%02d:%02d.%03d", | ||
| 1979 | + 1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, | ||
| 1980 | + tm->tm_hour, tm->tm_min, tm->tm_sec, | ||
| 1981 | + (int)(tv.tv_usec / 1000)); | ||
| 1982 | + | ||
| 1983 | + // for srs-librtmp, @see https://github.com/winlinvip/simple-rtmp-server/issues/213 | ||
| 1984 | + buf[sizeof(buf) - 1] = 0; | ||
| 1985 | + | ||
| 1986 | + return buf; | ||
| 1987 | +} | ||
| 1988 | + | ||
| 1989 | #ifdef __cplusplus | 1989 | #ifdef __cplusplus |
| 1990 | } | 1990 | } |
| 1991 | #endif | 1991 | #endif |
| @@ -86,6 +86,15 @@ extern "C"{ | @@ -86,6 +86,15 @@ extern "C"{ | ||
| 86 | 86 | ||
| 87 | /************************************************************* | 87 | /************************************************************* |
| 88 | ************************************************************** | 88 | ************************************************************** |
| 89 | +* srs-librtmp version | ||
| 90 | +************************************************************** | ||
| 91 | +*************************************************************/ | ||
| 92 | +extern int srs_version_major(); | ||
| 93 | +extern int srs_version_minor(); | ||
| 94 | +extern int srs_version_revision(); | ||
| 95 | + | ||
| 96 | +/************************************************************* | ||
| 97 | +************************************************************** | ||
| 89 | * RTMP protocol context | 98 | * RTMP protocol context |
| 90 | ************************************************************** | 99 | ************************************************************** |
| 91 | *************************************************************/ | 100 | *************************************************************/ |
| @@ -134,19 +143,19 @@ extern void srs_rtmp_destroy(srs_rtmp_t rtmp); | @@ -134,19 +143,19 @@ extern void srs_rtmp_destroy(srs_rtmp_t rtmp); | ||
| 134 | * not depends on ssl. | 143 | * not depends on ssl. |
| 135 | */ | 144 | */ |
| 136 | /** | 145 | /** |
| 137 | -* srs_simple_handshake equals to invoke: | ||
| 138 | -* __srs_dns_resolve() | ||
| 139 | -* __srs_connect_server() | ||
| 140 | -* __srs_do_simple_handshake() | 146 | +* srs_rtmp_handshake equals to invoke: |
| 147 | +* __srs_rtmp_dns_resolve() | ||
| 148 | +* __srs_rtmp_connect_server() | ||
| 149 | +* __srs_rtmp_do_simple_handshake() | ||
| 141 | * user can use these functions if needed. | 150 | * user can use these functions if needed. |
| 142 | */ | 151 | */ |
| 143 | -extern int srs_simple_handshake(srs_rtmp_t rtmp); | 152 | +extern int srs_rtmp_handshake(srs_rtmp_t rtmp); |
| 144 | // parse uri, create socket, resolve host | 153 | // parse uri, create socket, resolve host |
| 145 | -extern int __srs_dns_resolve(srs_rtmp_t rtmp); | 154 | +extern int __srs_rtmp_dns_resolve(srs_rtmp_t rtmp); |
| 146 | // connect socket to server | 155 | // connect socket to server |
| 147 | -extern int __srs_connect_server(srs_rtmp_t rtmp); | 156 | +extern int __srs_rtmp_connect_server(srs_rtmp_t rtmp); |
| 148 | // do simple handshake over socket. | 157 | // do simple handshake over socket. |
| 149 | -extern int __srs_do_simple_handshake(srs_rtmp_t rtmp); | 158 | +extern int __srs_rtmp_do_simple_handshake(srs_rtmp_t rtmp); |
| 150 | 159 | ||
| 151 | /** | 160 | /** |
| 152 | * connect to rtmp vhost/app | 161 | * connect to rtmp vhost/app |
| @@ -156,7 +165,7 @@ extern int __srs_do_simple_handshake(srs_rtmp_t rtmp); | @@ -156,7 +165,7 @@ extern int __srs_do_simple_handshake(srs_rtmp_t rtmp); | ||
| 156 | * | 165 | * |
| 157 | * @return 0, success; otherswise, failed. | 166 | * @return 0, success; otherswise, failed. |
| 158 | */ | 167 | */ |
| 159 | -extern int srs_connect_app(srs_rtmp_t rtmp); | 168 | +extern int srs_rtmp_connect_app(srs_rtmp_t rtmp); |
| 160 | 169 | ||
| 161 | /** | 170 | /** |
| 162 | * connect to server, get the debug srs info. | 171 | * connect to server, get the debug srs info. |
| @@ -171,7 +180,7 @@ extern int srs_connect_app(srs_rtmp_t rtmp); | @@ -171,7 +180,7 @@ extern int srs_connect_app(srs_rtmp_t rtmp); | ||
| 171 | * | 180 | * |
| 172 | * @return 0, success; otherswise, failed. | 181 | * @return 0, success; otherswise, failed. |
| 173 | */ | 182 | */ |
| 174 | -extern int srs_connect_app2(srs_rtmp_t rtmp, | 183 | +extern int srs_rtmp_connect_app2(srs_rtmp_t rtmp, |
| 175 | char srs_server_ip[128], char srs_server[128], char srs_primary_authors[128], | 184 | char srs_server_ip[128], char srs_server[128], char srs_primary_authors[128], |
| 176 | char srs_version[32], int* srs_id, int* srs_pid | 185 | char srs_version[32], int* srs_id, int* srs_pid |
| 177 | ); | 186 | ); |
| @@ -183,7 +192,7 @@ extern int srs_connect_app2(srs_rtmp_t rtmp, | @@ -183,7 +192,7 @@ extern int srs_connect_app2(srs_rtmp_t rtmp, | ||
| 183 | * next: destroy | 192 | * next: destroy |
| 184 | * @return 0, success; otherwise, failed. | 193 | * @return 0, success; otherwise, failed. |
| 185 | */ | 194 | */ |
| 186 | -extern int srs_play_stream(srs_rtmp_t rtmp); | 195 | +extern int srs_rtmp_play_stream(srs_rtmp_t rtmp); |
| 187 | 196 | ||
| 188 | /** | 197 | /** |
| 189 | * publish a live stream. | 198 | * publish a live stream. |
| @@ -192,7 +201,7 @@ extern int srs_play_stream(srs_rtmp_t rtmp); | @@ -192,7 +201,7 @@ extern int srs_play_stream(srs_rtmp_t rtmp); | ||
| 192 | * next: destroy | 201 | * next: destroy |
| 193 | * @return 0, success; otherwise, failed. | 202 | * @return 0, success; otherwise, failed. |
| 194 | */ | 203 | */ |
| 195 | -extern int srs_publish_stream(srs_rtmp_t rtmp); | 204 | +extern int srs_rtmp_publish_stream(srs_rtmp_t rtmp); |
| 196 | 205 | ||
| 197 | /** | 206 | /** |
| 198 | * do bandwidth check with srs server. | 207 | * do bandwidth check with srs server. |
| @@ -209,7 +218,7 @@ extern int srs_publish_stream(srs_rtmp_t rtmp); | @@ -209,7 +218,7 @@ extern int srs_publish_stream(srs_rtmp_t rtmp); | ||
| 209 | * | 218 | * |
| 210 | * @return 0, success; otherswise, failed. | 219 | * @return 0, success; otherswise, failed. |
| 211 | */ | 220 | */ |
| 212 | -extern int srs_bandwidth_check(srs_rtmp_t rtmp, | 221 | +extern int srs_rtmp_bandwidth_check(srs_rtmp_t rtmp, |
| 213 | int64_t* start_time, int64_t* end_time, | 222 | int64_t* start_time, int64_t* end_time, |
| 214 | int* play_kbps, int* publish_kbps, | 223 | int* play_kbps, int* publish_kbps, |
| 215 | int* play_bytes, int* publish_bytes, | 224 | int* play_bytes, int* publish_bytes, |
| @@ -226,16 +235,6 @@ extern int srs_bandwidth_check(srs_rtmp_t rtmp, | @@ -226,16 +235,6 @@ extern int srs_bandwidth_check(srs_rtmp_t rtmp, | ||
| 226 | // 18 = script data | 235 | // 18 = script data |
| 227 | #define SRS_RTMP_TYPE_SCRIPT 18 | 236 | #define SRS_RTMP_TYPE_SCRIPT 18 |
| 228 | /** | 237 | /** |
| 229 | -* convert the flv tag type to string. | ||
| 230 | -* SRS_RTMP_TYPE_AUDIO to "Audio" | ||
| 231 | -* SRS_RTMP_TYPE_VIDEO to "Video" | ||
| 232 | -* SRS_RTMP_TYPE_SCRIPT to "Data" | ||
| 233 | -* otherwise, "Unknown" | ||
| 234 | -* @remark user never free the return char*, | ||
| 235 | -* it's static shared const string. | ||
| 236 | -*/ | ||
| 237 | -extern const char* srs_type2string(char type); | ||
| 238 | -/** | ||
| 239 | * read a audio/video/script-data packet from rtmp stream. | 238 | * read a audio/video/script-data packet from rtmp stream. |
| 240 | * @param type, output the packet type, macros: | 239 | * @param type, output the packet type, macros: |
| 241 | * SRS_RTMP_TYPE_AUDIO, FlvTagAudio | 240 | * SRS_RTMP_TYPE_AUDIO, FlvTagAudio |
| @@ -256,146 +255,13 @@ extern const char* srs_type2string(char type); | @@ -256,146 +255,13 @@ extern const char* srs_type2string(char type); | ||
| 256 | * | 255 | * |
| 257 | * @return 0, success; otherswise, failed. | 256 | * @return 0, success; otherswise, failed. |
| 258 | */ | 257 | */ |
| 259 | -extern int srs_read_packet(srs_rtmp_t rtmp, | 258 | +extern int srs_rtmp_read_packet(srs_rtmp_t rtmp, |
| 260 | char* type, u_int32_t* timestamp, char** data, int* size | 259 | char* type, u_int32_t* timestamp, char** data, int* size |
| 261 | ); | 260 | ); |
| 262 | -extern int srs_write_packet(srs_rtmp_t rtmp, | 261 | +extern int srs_rtmp_write_packet(srs_rtmp_t rtmp, |
| 263 | char type, u_int32_t timestamp, char* data, int size | 262 | char type, u_int32_t timestamp, char* data, int size |
| 264 | ); | 263 | ); |
| 265 | 264 | ||
| 266 | -// get protocol stack version | ||
| 267 | -extern int srs_version_major(); | ||
| 268 | -extern int srs_version_minor(); | ||
| 269 | -extern int srs_version_revision(); | ||
| 270 | - | ||
| 271 | -/************************************************************* | ||
| 272 | -************************************************************** | ||
| 273 | -* utilities | ||
| 274 | -************************************************************** | ||
| 275 | -*************************************************************/ | ||
| 276 | -/** | ||
| 277 | -* get the current system time in ms. | ||
| 278 | -* use gettimeofday() to get system time. | ||
| 279 | -*/ | ||
| 280 | -extern int64_t srs_get_time_ms(); | ||
| 281 | - | ||
| 282 | -/** | ||
| 283 | -* get the send bytes. | ||
| 284 | -*/ | ||
| 285 | -extern int64_t srs_get_nsend_bytes(srs_rtmp_t rtmp); | ||
| 286 | - | ||
| 287 | -/** | ||
| 288 | -* get the recv bytes. | ||
| 289 | -*/ | ||
| 290 | -extern int64_t srs_get_nrecv_bytes(srs_rtmp_t rtmp); | ||
| 291 | - | ||
| 292 | -/** | ||
| 293 | -* parse the dts and pts by time in header and data in tag, | ||
| 294 | -* or to parse the RTMP packet by srs_read_packet(). | ||
| 295 | -* | ||
| 296 | -* @param time, the timestamp of tag, read by srs_flv_read_tag_header(). | ||
| 297 | -* @param type, the type of tag, read by srs_flv_read_tag_header(). | ||
| 298 | -* @param data, the data of tag, read by srs_flv_read_tag_data(). | ||
| 299 | -* @param size, the size of tag, read by srs_flv_read_tag_header(). | ||
| 300 | -* @param ppts, output the pts in ms, | ||
| 301 | -* | ||
| 302 | -* @return 0, success; otherswise, failed. | ||
| 303 | -* @remark, the dts always equals to @param time. | ||
| 304 | -* @remark, the pts=dts for audio or data. | ||
| 305 | -* @remark, video only support h.264. | ||
| 306 | -*/ | ||
| 307 | -extern int srs_parse_timestamp( | ||
| 308 | - u_int32_t time, char type, char* data, int size, | ||
| 309 | - u_int32_t* ppts | ||
| 310 | -); | ||
| 311 | - | ||
| 312 | -/** | ||
| 313 | -* get the CodecID of video tag. | ||
| 314 | -* Codec Identifier. The following values are defined: | ||
| 315 | -* 2 = Sorenson H.263 | ||
| 316 | -* 3 = Screen video | ||
| 317 | -* 4 = On2 VP6 | ||
| 318 | -* 5 = On2 VP6 with alpha channel | ||
| 319 | -* 6 = Screen video version 2 | ||
| 320 | -* 7 = AVC | ||
| 321 | -* @return the code id. 0 for error. | ||
| 322 | -*/ | ||
| 323 | -extern char srs_get_codec_id(char* data, int size); | ||
| 324 | - | ||
| 325 | -/** | ||
| 326 | -* get the codec id string. | ||
| 327 | -* H.263 = Sorenson H.263 | ||
| 328 | -* Screen = Screen video | ||
| 329 | -* VP6 = On2 VP6 | ||
| 330 | -* VP6Alpha = On2 VP6 with alpha channel | ||
| 331 | -* Screen2 = Screen video version 2 | ||
| 332 | -* H.264 = AVC | ||
| 333 | -* otherwise, "Unknown" | ||
| 334 | -* @remark user never free the return char*, | ||
| 335 | -* it's static shared const string. | ||
| 336 | -*/ | ||
| 337 | -extern const char* srs_code_id2string(char codec_id); | ||
| 338 | - | ||
| 339 | -/** | ||
| 340 | -* get the AVCPacketType of video tag. | ||
| 341 | -* The following values are defined: | ||
| 342 | -* 0 = AVC sequence header | ||
| 343 | -* 1 = AVC NALU | ||
| 344 | -* 2 = AVC end of sequence (lower level NALU sequence ender is | ||
| 345 | -* not required or supported) | ||
| 346 | -* @return the avc packet type. -1(0xff) for error. | ||
| 347 | -*/ | ||
| 348 | -extern char srs_get_avc_packet_type(char* data, int size); | ||
| 349 | - | ||
| 350 | -/** | ||
| 351 | -* get the avc packet type string. | ||
| 352 | -* SpsPps = AVC sequence header | ||
| 353 | -* Nalu = AVC NALU | ||
| 354 | -* SpsPpsEnd = AVC end of sequence | ||
| 355 | -* otherwise, "Unknown" | ||
| 356 | -* @remark user never free the return char*, | ||
| 357 | -* it's static shared const string. | ||
| 358 | -*/ | ||
| 359 | -extern const char* srs_avc_packet2string(char avc_packet_type); | ||
| 360 | - | ||
| 361 | -/** | ||
| 362 | -* get the FrameType of video tag. | ||
| 363 | -* Type of video frame. The following values are defined: | ||
| 364 | -* 1 = key frame (for AVC, a seekable frame) | ||
| 365 | -* 2 = inter frame (for AVC, a non-seekable frame) | ||
| 366 | -* 3 = disposable inter frame (H.263 only) | ||
| 367 | -* 4 = generated key frame (reserved for server use only) | ||
| 368 | -* 5 = video info/command frame | ||
| 369 | -* @return the frame type. 0 for error. | ||
| 370 | -*/ | ||
| 371 | -extern char srs_get_frame_type(char* data, int size); | ||
| 372 | - | ||
| 373 | -/** | ||
| 374 | -* get the frame type string. | ||
| 375 | -* I = key frame (for AVC, a seekable frame) | ||
| 376 | -* P/B = inter frame (for AVC, a non-seekable frame) | ||
| 377 | -* DI = disposable inter frame (H.263 only) | ||
| 378 | -* GI = generated key frame (reserved for server use only) | ||
| 379 | -* VI = video info/command frame | ||
| 380 | -* otherwise, "Unknown" | ||
| 381 | -* @remark user never free the return char*, | ||
| 382 | -* it's static shared const string. | ||
| 383 | -*/ | ||
| 384 | -extern const char* srs_frame_type2string(char frame_type); | ||
| 385 | - | ||
| 386 | -/** | ||
| 387 | -* print the rtmp packet, use srs_lib_trace/srs_lib_verbose for packet, | ||
| 388 | -* and use srs_raw_trace for script data body. | ||
| 389 | -* @return an error code for parse the timetstamp to dts and pts. | ||
| 390 | -*/ | ||
| 391 | -extern int srs_print_rtmp_packet(char type, u_int32_t timestamp, char* data, int size); | ||
| 392 | - | ||
| 393 | -// log to console, for use srs-librtmp application. | ||
| 394 | -extern const char* srs_format_time(); | ||
| 395 | -#define srs_lib_trace(msg, ...) printf("[%s] ", srs_format_time());printf(msg, ##__VA_ARGS__);printf("\n") | ||
| 396 | -#define srs_lib_verbose(msg, ...) printf("[%s] ", srs_format_time());printf(msg, ##__VA_ARGS__);printf("\n") | ||
| 397 | -#define srs_raw_trace(msg, ...) printf(msg, ##__VA_ARGS__) | ||
| 398 | - | ||
| 399 | /************************************************************* | 265 | /************************************************************* |
| 400 | ************************************************************** | 266 | ************************************************************** |
| 401 | * flv codec | 267 | * flv codec |
| @@ -553,13 +419,6 @@ extern void srs_amf0_ecma_array_property_set(srs_amf0_t amf0, const char* name, | @@ -553,13 +419,6 @@ extern void srs_amf0_ecma_array_property_set(srs_amf0_t amf0, const char* name, | ||
| 553 | extern int srs_amf0_strict_array_property_count(srs_amf0_t amf0); | 419 | extern int srs_amf0_strict_array_property_count(srs_amf0_t amf0); |
| 554 | extern srs_amf0_t srs_amf0_strict_array_property_at(srs_amf0_t amf0, int index); | 420 | extern srs_amf0_t srs_amf0_strict_array_property_at(srs_amf0_t amf0, int index); |
| 555 | extern void srs_amf0_strict_array_append(srs_amf0_t amf0, srs_amf0_t value); | 421 | extern void srs_amf0_strict_array_append(srs_amf0_t amf0, srs_amf0_t value); |
| 556 | -/** | ||
| 557 | -* human readable print | ||
| 558 | -* @param pdata, output the heap data, NULL to ignore. | ||
| 559 | -* user must use srs_amf0_free_bytes to free it. | ||
| 560 | -* @return return the *pdata for print. NULL to ignore. | ||
| 561 | -*/ | ||
| 562 | -extern char* srs_amf0_human_print(srs_amf0_t amf0, char** pdata, int* psize); | ||
| 563 | 422 | ||
| 564 | /************************************************************* | 423 | /************************************************************* |
| 565 | ************************************************************** | 424 | ************************************************************** |
| @@ -724,6 +583,157 @@ extern int srs_h264_startswith_annexb( | @@ -724,6 +583,157 @@ extern int srs_h264_startswith_annexb( | ||
| 724 | int* pnb_start_code | 583 | int* pnb_start_code |
| 725 | ); | 584 | ); |
| 726 | 585 | ||
| 586 | +/************************************************************* | ||
| 587 | +************************************************************** | ||
| 588 | +* utilities | ||
| 589 | +************************************************************** | ||
| 590 | +*************************************************************/ | ||
| 591 | +/** | ||
| 592 | +* get the current system time in ms. | ||
| 593 | +* use gettimeofday() to get system time. | ||
| 594 | +*/ | ||
| 595 | +extern int64_t srs_utils_get_time_ms(); | ||
| 596 | + | ||
| 597 | +/** | ||
| 598 | +* get the send bytes. | ||
| 599 | +*/ | ||
| 600 | +extern int64_t srs_utils_get_send_bytes(srs_rtmp_t rtmp); | ||
| 601 | + | ||
| 602 | +/** | ||
| 603 | +* get the recv bytes. | ||
| 604 | +*/ | ||
| 605 | +extern int64_t srs_utils_get_recv_bytes(srs_rtmp_t rtmp); | ||
| 606 | + | ||
| 607 | +/** | ||
| 608 | +* parse the dts and pts by time in header and data in tag, | ||
| 609 | +* or to parse the RTMP packet by srs_rtmp_read_packet(). | ||
| 610 | +* | ||
| 611 | +* @param time, the timestamp of tag, read by srs_flv_read_tag_header(). | ||
| 612 | +* @param type, the type of tag, read by srs_flv_read_tag_header(). | ||
| 613 | +* @param data, the data of tag, read by srs_flv_read_tag_data(). | ||
| 614 | +* @param size, the size of tag, read by srs_flv_read_tag_header(). | ||
| 615 | +* @param ppts, output the pts in ms, | ||
| 616 | +* | ||
| 617 | +* @return 0, success; otherswise, failed. | ||
| 618 | +* @remark, the dts always equals to @param time. | ||
| 619 | +* @remark, the pts=dts for audio or data. | ||
| 620 | +* @remark, video only support h.264. | ||
| 621 | +*/ | ||
| 622 | +extern int srs_utils_parse_timestamp( | ||
| 623 | + u_int32_t time, char type, char* data, int size, | ||
| 624 | + u_int32_t* ppts | ||
| 625 | +); | ||
| 626 | + | ||
| 627 | +/** | ||
| 628 | +* get the CodecID of video tag. | ||
| 629 | +* Codec Identifier. The following values are defined: | ||
| 630 | +* 2 = Sorenson H.263 | ||
| 631 | +* 3 = Screen video | ||
| 632 | +* 4 = On2 VP6 | ||
| 633 | +* 5 = On2 VP6 with alpha channel | ||
| 634 | +* 6 = Screen video version 2 | ||
| 635 | +* 7 = AVC | ||
| 636 | +* @return the code id. 0 for error. | ||
| 637 | +*/ | ||
| 638 | +extern char srs_utils_get_flv_video_codec_id(char* data, int size); | ||
| 639 | + | ||
| 640 | +/** | ||
| 641 | +* get the AVCPacketType of video tag. | ||
| 642 | +* The following values are defined: | ||
| 643 | +* 0 = AVC sequence header | ||
| 644 | +* 1 = AVC NALU | ||
| 645 | +* 2 = AVC end of sequence (lower level NALU sequence ender is | ||
| 646 | +* not required or supported) | ||
| 647 | +* @return the avc packet type. -1(0xff) for error. | ||
| 648 | +*/ | ||
| 649 | +extern char srs_utils_get_flv_video_avc_packet_type(char* data, int size); | ||
| 650 | + | ||
| 651 | +/** | ||
| 652 | +* get the FrameType of video tag. | ||
| 653 | +* Type of video frame. The following values are defined: | ||
| 654 | +* 1 = key frame (for AVC, a seekable frame) | ||
| 655 | +* 2 = inter frame (for AVC, a non-seekable frame) | ||
| 656 | +* 3 = disposable inter frame (H.263 only) | ||
| 657 | +* 4 = generated key frame (reserved for server use only) | ||
| 658 | +* 5 = video info/command frame | ||
| 659 | +* @return the frame type. 0 for error. | ||
| 660 | +*/ | ||
| 661 | +extern char srs_utils_get_flv_video_frame_type(char* data, int size); | ||
| 662 | + | ||
| 663 | +/************************************************************* | ||
| 664 | +************************************************************** | ||
| 665 | +* human readable print. | ||
| 666 | +************************************************************** | ||
| 667 | +*************************************************************/ | ||
| 668 | +/** | ||
| 669 | +* human readable print | ||
| 670 | +* @param pdata, output the heap data, NULL to ignore. | ||
| 671 | +* user must use srs_amf0_free_bytes to free it. | ||
| 672 | +* @return return the *pdata for print. NULL to ignore. | ||
| 673 | +*/ | ||
| 674 | +extern char* srs_human_amf0_print(srs_amf0_t amf0, char** pdata, int* psize); | ||
| 675 | +/** | ||
| 676 | +* convert the flv tag type to string. | ||
| 677 | +* SRS_RTMP_TYPE_AUDIO to "Audio" | ||
| 678 | +* SRS_RTMP_TYPE_VIDEO to "Video" | ||
| 679 | +* SRS_RTMP_TYPE_SCRIPT to "Data" | ||
| 680 | +* otherwise, "Unknown" | ||
| 681 | +* @remark user never free the return char*, | ||
| 682 | +* it's static shared const string. | ||
| 683 | +*/ | ||
| 684 | +extern const char* srs_human_flv_tag_type2string(char type); | ||
| 685 | + | ||
| 686 | +/** | ||
| 687 | +* get the codec id string. | ||
| 688 | +* H.263 = Sorenson H.263 | ||
| 689 | +* Screen = Screen video | ||
| 690 | +* VP6 = On2 VP6 | ||
| 691 | +* VP6Alpha = On2 VP6 with alpha channel | ||
| 692 | +* Screen2 = Screen video version 2 | ||
| 693 | +* H.264 = AVC | ||
| 694 | +* otherwise, "Unknown" | ||
| 695 | +* @remark user never free the return char*, | ||
| 696 | +* it's static shared const string. | ||
| 697 | +*/ | ||
| 698 | +extern const char* srs_human_flv_video_codec_id2string(char codec_id); | ||
| 699 | + | ||
| 700 | +/** | ||
| 701 | +* get the avc packet type string. | ||
| 702 | +* SpsPps = AVC sequence header | ||
| 703 | +* Nalu = AVC NALU | ||
| 704 | +* SpsPpsEnd = AVC end of sequence | ||
| 705 | +* otherwise, "Unknown" | ||
| 706 | +* @remark user never free the return char*, | ||
| 707 | +* it's static shared const string. | ||
| 708 | +*/ | ||
| 709 | +extern const char* srs_human_flv_video_avc_packet_type2string(char avc_packet_type); | ||
| 710 | + | ||
| 711 | +/** | ||
| 712 | +* get the frame type string. | ||
| 713 | +* I = key frame (for AVC, a seekable frame) | ||
| 714 | +* P/B = inter frame (for AVC, a non-seekable frame) | ||
| 715 | +* DI = disposable inter frame (H.263 only) | ||
| 716 | +* GI = generated key frame (reserved for server use only) | ||
| 717 | +* VI = video info/command frame | ||
| 718 | +* otherwise, "Unknown" | ||
| 719 | +* @remark user never free the return char*, | ||
| 720 | +* it's static shared const string. | ||
| 721 | +*/ | ||
| 722 | +extern const char* srs_human_flv_video_frame_type2string(char frame_type); | ||
| 723 | + | ||
| 724 | +/** | ||
| 725 | +* print the rtmp packet, use srs_human_trace/srs_human_verbose for packet, | ||
| 726 | +* and use srs_human_raw for script data body. | ||
| 727 | +* @return an error code for parse the timetstamp to dts and pts. | ||
| 728 | +*/ | ||
| 729 | +extern int srs_human_print_rtmp_packet(char type, u_int32_t timestamp, char* data, int size); | ||
| 730 | + | ||
| 731 | +// log to console, for use srs-librtmp application. | ||
| 732 | +extern const char* srs_human_format_time(); | ||
| 733 | +#define srs_human_trace(msg, ...) printf("[%s] ", srs_human_format_time());printf(msg, ##__VA_ARGS__);printf("\n") | ||
| 734 | +#define srs_human_verbose(msg, ...) printf("[%s] ", srs_human_format_time());printf(msg, ##__VA_ARGS__);printf("\n") | ||
| 735 | +#define srs_human_raw(msg, ...) printf(msg, ##__VA_ARGS__) | ||
| 736 | + | ||
| 727 | #ifdef __cplusplus | 737 | #ifdef __cplusplus |
| 728 | } | 738 | } |
| 729 | #endif | 739 | #endif |
| @@ -129,7 +129,7 @@ file | @@ -129,7 +129,7 @@ file | ||
| 129 | ..\utest\srs_utest_reload.cpp, | 129 | ..\utest\srs_utest_reload.cpp, |
| 130 | research readonly separator, | 130 | research readonly separator, |
| 131 | ..\..\research\librtmp\srs_audio_raw_publish.c, | 131 | ..\..\research\librtmp\srs_audio_raw_publish.c, |
| 132 | - ..\..\research\librtmp\srs_bandwidth_check.c, | 132 | + ..\..\research\librtmp\srs_rtmp_bandwidth_check.c, |
| 133 | ..\..\research\librtmp\srs_detect_rtmp.c, | 133 | ..\..\research\librtmp\srs_detect_rtmp.c, |
| 134 | ..\..\research\librtmp\srs_flv_injecter.c, | 134 | ..\..\research\librtmp\srs_flv_injecter.c, |
| 135 | ..\..\research\librtmp\srs_flv_parser.c, | 135 | ..\..\research\librtmp\srs_flv_parser.c, |
-
请 注册 或 登录 后发表评论