refine code, rename the human functions to prefixed with srs_human_
正在显示
12 个修改的文件
包含
190 行增加
和
190 行删除
@@ -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 | } |
@@ -117,22 +117,22 @@ int main(int argc, char** argv) | @@ -117,22 +117,22 @@ int main(int argc, char** argv) | ||
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) { | 119 | if (srs_simple_handshake(rtmp) != 0) { |
120 | - srs_lib_trace("simple handshake failed."); | 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) { | 125 | if (srs_connect_app(rtmp) != 0) { |
126 | - srs_lib_trace("connect vhost/app failed."); | 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) { | 131 | if (srs_publish_stream(rtmp) != 0) { |
132 | - srs_lib_trace("publish stream failed."); | 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. |
@@ -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) { | 86 | if ((ret = srs_simple_handshake(rtmp)) != 0) { |
87 | - srs_lib_trace("simple handshake failed."); | 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_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_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 | } |
@@ -80,56 +80,56 @@ int main(int argc, char** argv) | @@ -80,56 +80,56 @@ 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) { | 93 | if ((ret = __srs_dns_resolve(rtmp)) != 0) { |
94 | - srs_lib_trace("dns resolve failed. ret=%d", ret); | 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"); | 97 | + srs_human_trace("dns resolve success"); |
98 | time_dns_resolve = srs_get_time_ms(); | 98 | time_dns_resolve = srs_get_time_ms(); |
99 | 99 | ||
100 | if ((ret = __srs_connect_server(rtmp)) != 0) { | 100 | if ((ret = __srs_connect_server(rtmp)) != 0) { |
101 | - srs_lib_trace("socket connect failed. ret=%d", ret); | 101 | + srs_human_trace("socket connect failed. ret=%d", ret); |
102 | goto rtmp_destroy; | 102 | goto rtmp_destroy; |
103 | } | 103 | } |
104 | - srs_lib_trace("socket connect success"); | 104 | + srs_human_trace("socket connect success"); |
105 | time_socket_connect = srs_get_time_ms(); | 105 | time_socket_connect = srs_get_time_ms(); |
106 | 106 | ||
107 | if ((ret = __srs_do_simple_handshake(rtmp)) != 0) { | 107 | if ((ret = __srs_do_simple_handshake(rtmp)) != 0) { |
108 | - srs_lib_trace("do simple handshake failed. ret=%d", ret); | 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) { | 113 | if ((ret = srs_connect_app(rtmp)) != 0) { |
114 | - srs_lib_trace("connect vhost/app failed. ret=%d", ret); | 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) { | 119 | if ((ret = srs_play_stream(rtmp)) != 0) { |
120 | - srs_lib_trace("play stream failed. ret=%d", ret); | 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"); | 123 | + srs_human_trace("play stream success"); |
124 | time_play_stream = srs_get_time_ms(); | 124 | time_play_stream = srs_get_time_ms(); |
125 | 125 | ||
126 | for (;;) { | 126 | for (;;) { |
127 | if ((ret = srs_read_packet(rtmp, &type, ×tamp, &data, &size)) != 0) { | 127 | if ((ret = srs_read_packet(rtmp, &type, ×tamp, &data, &size)) != 0) { |
128 | - srs_lib_trace("read packet failed. ret=%d", ret); | 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) { |
@@ -143,12 +143,12 @@ int main(int argc, char** argv) | @@ -143,12 +143,12 @@ int main(int argc, char** argv) | ||
143 | free(data); | 143 | free(data); |
144 | 144 | ||
145 | if (srs_get_time_ms() - time_startup > timeout * 1000) { | 145 | if (srs_get_time_ms() - time_startup > timeout * 1000) { |
146 | - srs_lib_trace("timeout, terminate."); | 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 | } |
@@ -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 | } |
@@ -129,22 +129,22 @@ int main(int argc, char** argv) | @@ -129,22 +129,22 @@ int main(int argc, char** argv) | ||
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) { | 131 | if (srs_simple_handshake(rtmp) != 0) { |
132 | - srs_lib_trace("simple handshake failed."); | 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) { | 137 | if (srs_connect_app(rtmp) != 0) { |
138 | - srs_lib_trace("connect vhost/app failed."); | 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) { | 143 | if (srs_publish_stream(rtmp) != 0) { |
144 | - srs_lib_trace("publish stream failed."); | 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); |
@@ -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) { | 151 | if ((ret = srs_write_packet(ortmp, type, *ptimestamp, data, size)) != 0) { |
152 | - srs_lib_trace("irtmp get packet failed. ret=%d", ret); | 152 | + srs_human_trace("irtmp get packet failed. ret=%d", ret); |
153 | return ret; | 153 | return ret; |
154 | } | 154 | } |
155 | 155 | ||
@@ -192,22 +192,22 @@ int connect_oc(srs_rtmp_t ortmp) | @@ -192,22 +192,22 @@ int connect_oc(srs_rtmp_t ortmp) | ||
192 | int ret = 0; | 192 | int ret = 0; |
193 | 193 | ||
194 | if ((ret = srs_simple_handshake(ortmp)) != 0) { | 194 | if ((ret = srs_simple_handshake(ortmp)) != 0) { |
195 | - srs_lib_trace("ortmp simple handshake failed. ret=%d", ret); | 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) { | 200 | if ((ret = srs_connect_app(ortmp)) != 0) { |
201 | - srs_lib_trace("ortmp connect vhost/app failed. ret=%d", ret); | 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) { | 206 | if ((ret = srs_publish_stream(ortmp)) != 0) { |
207 | - srs_lib_trace("ortmp publish stream failed. ret=%d", ret); | 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 | } |
@@ -219,16 +219,16 @@ int64_t re_create() | @@ -219,16 +219,16 @@ int64_t re_create() | ||
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; |
@@ -249,7 +249,7 @@ void re_cleanup(int64_t re, int32_t starttime, u_int32_t time) | @@ -249,7 +249,7 @@ void re_cleanup(int64_t re, int32_t starttime, u_int32_t time) | ||
249 | int64_t now = srs_get_time_ms(); | 249 | int64_t now = srs_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) { | 111 | if ((ret = srs_read_packet(irtmp, &type, ×tamp, &data, &size)) != 0) { |
112 | - srs_lib_trace("irtmp get packet failed. ret=%d", ret); | 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) { | 121 | if ((ret = srs_write_packet(ortmp, type, timestamp, data, size)) != 0) { |
122 | - srs_lib_trace("irtmp get packet failed. ret=%d", ret); | 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; |
@@ -134,22 +134,22 @@ int connect_ic(srs_rtmp_t irtmp) | @@ -134,22 +134,22 @@ int connect_ic(srs_rtmp_t irtmp) | ||
134 | int ret = 0; | 134 | int ret = 0; |
135 | 135 | ||
136 | if ((ret = srs_simple_handshake(irtmp)) != 0) { | 136 | if ((ret = srs_simple_handshake(irtmp)) != 0) { |
137 | - srs_lib_trace("irtmp simple handshake failed. ret=%d", ret); | 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) { | 142 | if ((ret = srs_connect_app(irtmp)) != 0) { |
143 | - srs_lib_trace("irtmp connect vhost/app failed. ret=%d", ret); | 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) { | 148 | if ((ret = srs_play_stream(irtmp)) != 0) { |
149 | - srs_lib_trace("irtmp play stream failed. ret=%d", ret); | 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 | } |
@@ -159,22 +159,22 @@ int connect_oc(srs_rtmp_t ortmp) | @@ -159,22 +159,22 @@ int connect_oc(srs_rtmp_t ortmp) | ||
159 | int ret = 0; | 159 | int ret = 0; |
160 | 160 | ||
161 | if ((ret = srs_simple_handshake(ortmp)) != 0) { | 161 | if ((ret = srs_simple_handshake(ortmp)) != 0) { |
162 | - srs_lib_trace("ortmp simple handshake failed. ret=%d", ret); | 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) { | 167 | if ((ret = srs_connect_app(ortmp)) != 0) { |
168 | - srs_lib_trace("ortmp connect vhost/app failed. ret=%d", ret); | 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) { | 173 | if ((ret = srs_publish_stream(ortmp)) != 0) { |
174 | - srs_lib_trace("ortmp publish stream failed. ret=%d", ret); | 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) { | 50 | if (srs_simple_handshake(rtmp) != 0) { |
51 | - srs_lib_trace("simple handshake failed."); | 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) { | 56 | if (srs_connect_app(rtmp) != 0) { |
57 | - srs_lib_trace("connect vhost/app failed."); | 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) { | 62 | if (srs_play_stream(rtmp) != 0) { |
63 | - srs_lib_trace("play stream failed."); | 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; |
@@ -75,7 +75,7 @@ int main(int argc, char** argv) | @@ -75,7 +75,7 @@ int main(int argc, char** argv) | ||
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) { | 58 | if (srs_simple_handshake(rtmp) != 0) { |
59 | - srs_lib_trace("simple handshake failed."); | 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) { | 64 | if (srs_connect_app(rtmp) != 0) { |
65 | - srs_lib_trace("connect vhost/app failed."); | 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) { | 70 | if (srs_publish_stream(rtmp) != 0) { |
71 | - srs_lib_trace("publish stream failed."); | 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 (;;) { |
@@ -84,8 +84,8 @@ int main(int argc, char** argv) | @@ -84,8 +84,8 @@ int main(int argc, char** argv) | ||
84 | if (srs_write_packet(rtmp, type, timestamp, data, size) != 0) { | 84 | if (srs_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 | } |
@@ -1432,7 +1432,7 @@ void srs_amf0_strict_array_append(srs_amf0_t amf0, srs_amf0_t value) | @@ -1432,7 +1432,7 @@ void srs_amf0_strict_array_append(srs_amf0_t amf0, srs_amf0_t value) | ||
1432 | obj->append(any); | 1432 | obj->append(any); |
1433 | } | 1433 | } |
1434 | 1434 | ||
1435 | -char* srs_amf0_human_print(srs_amf0_t amf0, char** pdata, int* psize) | 1435 | +char* srs_human_amf0_print(srs_amf0_t amf0, char** pdata, int* psize) |
1436 | { | 1436 | { |
1437 | if (!amf0) { | 1437 | if (!amf0) { |
1438 | return NULL; | 1438 | return NULL; |
@@ -1443,7 +1443,7 @@ char* srs_amf0_human_print(srs_amf0_t amf0, char** pdata, int* psize) | @@ -1443,7 +1443,7 @@ char* srs_amf0_human_print(srs_amf0_t amf0, char** pdata, int* psize) | ||
1443 | return any->human_print(pdata, psize); | 1443 | return any->human_print(pdata, psize); |
1444 | } | 1444 | } |
1445 | 1445 | ||
1446 | -const char* srs_type2string(char type) | 1446 | +const char* srs_human_flv_tag_type2string(char type) |
1447 | { | 1447 | { |
1448 | static const char* audio = "Audio"; | 1448 | static const char* audio = "Audio"; |
1449 | static const char* video = "Video"; | 1449 | static const char* video = "Video"; |
@@ -1460,7 +1460,7 @@ const char* srs_type2string(char type) | @@ -1460,7 +1460,7 @@ const char* srs_type2string(char type) | ||
1460 | return unknown; | 1460 | return unknown; |
1461 | } | 1461 | } |
1462 | 1462 | ||
1463 | -const char* srs_code_id2string(char codec_id) | 1463 | +const char* srs_human_flv_video_codec_id2string(char codec_id) |
1464 | { | 1464 | { |
1465 | static const char* h263 = "H.263"; | 1465 | static const char* h263 = "H.263"; |
1466 | static const char* screen = "Screen"; | 1466 | static const char* screen = "Screen"; |
@@ -1483,7 +1483,7 @@ const char* srs_code_id2string(char codec_id) | @@ -1483,7 +1483,7 @@ const char* srs_code_id2string(char codec_id) | ||
1483 | return unknown; | 1483 | return unknown; |
1484 | } | 1484 | } |
1485 | 1485 | ||
1486 | -const char* srs_avc_packet2string(char avc_packet_type) | 1486 | +const char* srs_human_flv_video_avc_packet_type2string(char avc_packet_type) |
1487 | { | 1487 | { |
1488 | static const char* sps_pps = "SpsPps"; | 1488 | static const char* sps_pps = "SpsPps"; |
1489 | static const char* nalu = "Nalu"; | 1489 | static const char* nalu = "Nalu"; |
@@ -1500,7 +1500,7 @@ const char* srs_avc_packet2string(char avc_packet_type) | @@ -1500,7 +1500,7 @@ const char* srs_avc_packet2string(char avc_packet_type) | ||
1500 | return unknown; | 1500 | return unknown; |
1501 | } | 1501 | } |
1502 | 1502 | ||
1503 | -const char* srs_frame_type2string(char frame_type) | 1503 | +const char* srs_human_flv_video_frame_type2string(char frame_type) |
1504 | { | 1504 | { |
1505 | static const char* keyframe = "I"; | 1505 | static const char* keyframe = "I"; |
1506 | static const char* interframe = "P/B"; | 1506 | static const char* interframe = "P/B"; |
@@ -1521,7 +1521,7 @@ const char* srs_frame_type2string(char frame_type) | @@ -1521,7 +1521,7 @@ const char* srs_frame_type2string(char frame_type) | ||
1521 | return unknown; | 1521 | return unknown; |
1522 | } | 1522 | } |
1523 | 1523 | ||
1524 | -int srs_print_rtmp_packet(char type, u_int32_t timestamp, char* data, int size) | 1524 | +int srs_human_print_rtmp_packet(char type, u_int32_t timestamp, char* data, int size) |
1525 | { | 1525 | { |
1526 | int ret = ERROR_SUCCESS; | 1526 | int ret = ERROR_SUCCESS; |
1527 | 1527 | ||
@@ -1531,18 +1531,18 @@ int srs_print_rtmp_packet(char type, u_int32_t timestamp, char* data, int size) | @@ -1531,18 +1531,18 @@ int srs_print_rtmp_packet(char type, u_int32_t timestamp, char* data, int size) | ||
1531 | } | 1531 | } |
1532 | 1532 | ||
1533 | if (type == SRS_RTMP_TYPE_VIDEO) { | 1533 | if (type == SRS_RTMP_TYPE_VIDEO) { |
1534 | - srs_lib_trace("Video packet type=%s, dts=%d, pts=%d, size=%d, %s(%s,%s)", | ||
1535 | - srs_type2string(type), timestamp, pts, size, | ||
1536 | - srs_code_id2string(srs_get_codec_id(data, size)), | ||
1537 | - srs_avc_packet2string(srs_get_avc_packet_type(data, size)), | ||
1538 | - srs_frame_type2string(srs_get_frame_type(data, size)) | 1534 | + srs_human_trace("Video packet type=%s, dts=%d, pts=%d, size=%d, %s(%s,%s)", |
1535 | + srs_human_flv_tag_type2string(type), timestamp, pts, size, | ||
1536 | + srs_human_flv_video_codec_id2string(srs_get_codec_id(data, size)), | ||
1537 | + srs_human_flv_video_avc_packet_type2string(srs_get_avc_packet_type(data, size)), | ||
1538 | + srs_human_flv_video_frame_type2string(srs_get_frame_type(data, size)) | ||
1539 | ); | 1539 | ); |
1540 | } else if (type == SRS_RTMP_TYPE_AUDIO) { | 1540 | } else if (type == SRS_RTMP_TYPE_AUDIO) { |
1541 | - srs_lib_trace("Audio packet type=%s, dts=%d, pts=%d, size=%d", | ||
1542 | - srs_type2string(type), timestamp, pts, size); | 1541 | + srs_human_trace("Audio packet type=%s, dts=%d, pts=%d, size=%d", |
1542 | + srs_human_flv_tag_type2string(type), timestamp, pts, size); | ||
1543 | } else if (type == SRS_RTMP_TYPE_SCRIPT) { | 1543 | } else if (type == SRS_RTMP_TYPE_SCRIPT) { |
1544 | - srs_lib_verbose("Data packet type=%s, time=%d, size=%d", | ||
1545 | - srs_type2string(type), timestamp, size); | 1544 | + srs_human_verbose("Data packet type=%s, time=%d, size=%d", |
1545 | + srs_human_flv_tag_type2string(type), timestamp, size); | ||
1546 | int nparsed = 0; | 1546 | int nparsed = 0; |
1547 | while (nparsed < size) { | 1547 | while (nparsed < size) { |
1548 | int nb_parsed_this = 0; | 1548 | int nb_parsed_this = 0; |
@@ -1554,18 +1554,18 @@ int srs_print_rtmp_packet(char type, u_int32_t timestamp, char* data, int size) | @@ -1554,18 +1554,18 @@ int srs_print_rtmp_packet(char type, u_int32_t timestamp, char* data, int size) | ||
1554 | nparsed += nb_parsed_this; | 1554 | nparsed += nb_parsed_this; |
1555 | 1555 | ||
1556 | char* amf0_str = NULL; | 1556 | char* amf0_str = NULL; |
1557 | - srs_raw_trace("%s", srs_amf0_human_print(amf0, &amf0_str, NULL)); | 1557 | + srs_human_raw("%s", srs_human_amf0_print(amf0, &amf0_str, NULL)); |
1558 | srs_amf0_free_bytes(amf0_str); | 1558 | srs_amf0_free_bytes(amf0_str); |
1559 | } | 1559 | } |
1560 | } else { | 1560 | } else { |
1561 | - srs_lib_trace("Unknown packet type=%s, dts=%d, pts=%d, size=%d", | ||
1562 | - srs_type2string(type), timestamp, pts, size); | 1561 | + srs_human_trace("Unknown packet type=%s, dts=%d, pts=%d, size=%d", |
1562 | + srs_human_flv_tag_type2string(type), timestamp, pts, size); | ||
1563 | } | 1563 | } |
1564 | 1564 | ||
1565 | return ret; | 1565 | return ret; |
1566 | } | 1566 | } |
1567 | 1567 | ||
1568 | -const char* srs_format_time() | 1568 | +const char* srs_human_format_time() |
1569 | { | 1569 | { |
1570 | struct timeval tv; | 1570 | struct timeval tv; |
1571 | static char buf[23]; | 1571 | static char buf[23]; |
@@ -504,7 +504,7 @@ extern void srs_amf0_strict_array_append(srs_amf0_t amf0, srs_amf0_t value); | @@ -504,7 +504,7 @@ extern void srs_amf0_strict_array_append(srs_amf0_t amf0, srs_amf0_t value); | ||
504 | * user must use srs_amf0_free_bytes to free it. | 504 | * user must use srs_amf0_free_bytes to free it. |
505 | * @return return the *pdata for print. NULL to ignore. | 505 | * @return return the *pdata for print. NULL to ignore. |
506 | */ | 506 | */ |
507 | -extern char* srs_amf0_human_print(srs_amf0_t amf0, char** pdata, int* psize); | 507 | +extern char* srs_human_amf0_print(srs_amf0_t amf0, char** pdata, int* psize); |
508 | /** | 508 | /** |
509 | * convert the flv tag type to string. | 509 | * convert the flv tag type to string. |
510 | * SRS_RTMP_TYPE_AUDIO to "Audio" | 510 | * SRS_RTMP_TYPE_AUDIO to "Audio" |
@@ -514,7 +514,7 @@ extern char* srs_amf0_human_print(srs_amf0_t amf0, char** pdata, int* psize); | @@ -514,7 +514,7 @@ extern char* srs_amf0_human_print(srs_amf0_t amf0, char** pdata, int* psize); | ||
514 | * @remark user never free the return char*, | 514 | * @remark user never free the return char*, |
515 | * it's static shared const string. | 515 | * it's static shared const string. |
516 | */ | 516 | */ |
517 | -extern const char* srs_type2string(char type); | 517 | +extern const char* srs_human_flv_tag_type2string(char type); |
518 | 518 | ||
519 | /** | 519 | /** |
520 | * get the codec id string. | 520 | * get the codec id string. |
@@ -528,7 +528,7 @@ extern const char* srs_type2string(char type); | @@ -528,7 +528,7 @@ extern const char* srs_type2string(char type); | ||
528 | * @remark user never free the return char*, | 528 | * @remark user never free the return char*, |
529 | * it's static shared const string. | 529 | * it's static shared const string. |
530 | */ | 530 | */ |
531 | -extern const char* srs_code_id2string(char codec_id); | 531 | +extern const char* srs_human_flv_video_codec_id2string(char codec_id); |
532 | 532 | ||
533 | /** | 533 | /** |
534 | * get the avc packet type string. | 534 | * get the avc packet type string. |
@@ -539,7 +539,7 @@ extern const char* srs_code_id2string(char codec_id); | @@ -539,7 +539,7 @@ extern const char* srs_code_id2string(char codec_id); | ||
539 | * @remark user never free the return char*, | 539 | * @remark user never free the return char*, |
540 | * it's static shared const string. | 540 | * it's static shared const string. |
541 | */ | 541 | */ |
542 | -extern const char* srs_avc_packet2string(char avc_packet_type); | 542 | +extern const char* srs_human_flv_video_avc_packet_type2string(char avc_packet_type); |
543 | 543 | ||
544 | /** | 544 | /** |
545 | * get the frame type string. | 545 | * get the frame type string. |
@@ -552,20 +552,20 @@ extern const char* srs_avc_packet2string(char avc_packet_type); | @@ -552,20 +552,20 @@ extern const char* srs_avc_packet2string(char avc_packet_type); | ||
552 | * @remark user never free the return char*, | 552 | * @remark user never free the return char*, |
553 | * it's static shared const string. | 553 | * it's static shared const string. |
554 | */ | 554 | */ |
555 | -extern const char* srs_frame_type2string(char frame_type); | 555 | +extern const char* srs_human_flv_video_frame_type2string(char frame_type); |
556 | 556 | ||
557 | /** | 557 | /** |
558 | -* print the rtmp packet, use srs_lib_trace/srs_lib_verbose for packet, | ||
559 | -* and use srs_raw_trace for script data body. | 558 | +* print the rtmp packet, use srs_human_trace/srs_human_verbose for packet, |
559 | +* and use srs_human_raw for script data body. | ||
560 | * @return an error code for parse the timetstamp to dts and pts. | 560 | * @return an error code for parse the timetstamp to dts and pts. |
561 | */ | 561 | */ |
562 | -extern int srs_print_rtmp_packet(char type, u_int32_t timestamp, char* data, int size); | 562 | +extern int srs_human_print_rtmp_packet(char type, u_int32_t timestamp, char* data, int size); |
563 | 563 | ||
564 | // log to console, for use srs-librtmp application. | 564 | // log to console, for use srs-librtmp application. |
565 | -extern const char* srs_format_time(); | ||
566 | -#define srs_lib_trace(msg, ...) printf("[%s] ", srs_format_time());printf(msg, ##__VA_ARGS__);printf("\n") | ||
567 | -#define srs_lib_verbose(msg, ...) printf("[%s] ", srs_format_time());printf(msg, ##__VA_ARGS__);printf("\n") | ||
568 | -#define srs_raw_trace(msg, ...) printf(msg, ##__VA_ARGS__) | 565 | +extern const char* srs_human_format_time(); |
566 | +#define srs_human_trace(msg, ...) printf("[%s] ", srs_human_format_time());printf(msg, ##__VA_ARGS__);printf("\n") | ||
567 | +#define srs_human_verbose(msg, ...) printf("[%s] ", srs_human_format_time());printf(msg, ##__VA_ARGS__);printf("\n") | ||
568 | +#define srs_human_raw(msg, ...) printf(msg, ##__VA_ARGS__) | ||
569 | 569 | ||
570 | /************************************************************* | 570 | /************************************************************* |
571 | ************************************************************** | 571 | ************************************************************** |
-
请 注册 或 登录 后发表评论