winlin

Merge branch 'srs.master'

@@ -59,8 +59,12 @@ int main(int argc, char** argv) @@ -59,8 +59,12 @@ int main(int argc, char** argv)
59 int duration = 0; 59 int duration = 0;
60 int timeout = 0; 60 int timeout = 0;
61 61
  62 + printf("detect rtmp stream\n");
  63 + printf("srs(simple-rtmp-server) client librtmp library.\n");
  64 + printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision());
  65 +
62 if (argc <= 3) { 66 if (argc <= 3) {
63 - printf("detect stream on RTMP server\n" 67 + printf("detect stream on RTMP server, print result to stderr.\n"
64 "Usage: %s <rtmp_url> <duration> <timeout>\n" 68 "Usage: %s <rtmp_url> <duration> <timeout>\n"
65 " rtmp_url RTMP stream url to play\n" 69 " rtmp_url RTMP stream url to play\n"
66 " duration how long to play, in seconds, stream time.\n" 70 " duration how long to play, in seconds, stream time.\n"
@@ -68,69 +72,63 @@ int main(int argc, char** argv) @@ -68,69 +72,63 @@ int main(int argc, char** argv)
68 "For example:\n" 72 "For example:\n"
69 " %s rtmp://127.0.0.1:1935/live/livestream 3 10\n", 73 " %s rtmp://127.0.0.1:1935/live/livestream 3 10\n",
70 argv[0], argv[0]); 74 argv[0], argv[0]);
71 - ret = 1;  
72 - exit(ret);  
73 - return ret; 75 + exit(-1);
74 } 76 }
75 77
76 rtmp_url = argv[1]; 78 rtmp_url = argv[1];
77 duration = atoi(argv[2]); 79 duration = atoi(argv[2]);
78 timeout = atoi(argv[3]); 80 timeout = atoi(argv[3]);
79 81
80 - printf("detect rtmp stream\n");  
81 - printf("srs(simple-rtmp-server) client librtmp library.\n");  
82 - printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision());  
83 - printf("rtmp url: %s\n", rtmp_url);  
84 - printf("duration: %ds, timeout:%ds\n", duration, timeout); 82 + srs_trace("rtmp url: %s", rtmp_url);
  83 + srs_trace("duration: %ds, timeout:%ds", duration, timeout);
85 84
86 if (duration <= 0 || timeout <= 0) { 85 if (duration <= 0 || timeout <= 0) {
87 - ret = 1;  
88 - fprintf(stderr, "duration and timeout must be positive. ret=%d\n", ret);  
89 - exit(ret);  
90 - return ret; 86 + srs_trace("duration and timeout must be positive.");
  87 + exit(-1);
91 } 88 }
92 89
93 rtmp = srs_rtmp_create(rtmp_url); 90 rtmp = srs_rtmp_create(rtmp_url);
94 91
95 if ((ret = __srs_dns_resolve(rtmp)) != 0) { 92 if ((ret = __srs_dns_resolve(rtmp)) != 0) {
96 - fprintf(stderr, "dns resolve failed. ret=%d\n", ret); 93 + srs_trace("dns resolve failed. ret=%d", ret);
97 goto rtmp_destroy; 94 goto rtmp_destroy;
98 } 95 }
99 - printf("dns resolve success\n"); 96 + srs_trace("dns resolve success");
100 time_dns_resolve = srs_get_time_ms(); 97 time_dns_resolve = srs_get_time_ms();
101 98
102 if ((ret = __srs_connect_server(rtmp)) != 0) { 99 if ((ret = __srs_connect_server(rtmp)) != 0) {
103 - fprintf(stderr, "socket connect failed. ret=%d\n", ret); 100 + srs_trace("socket connect failed. ret=%d", ret);
104 goto rtmp_destroy; 101 goto rtmp_destroy;
105 } 102 }
106 - printf("socket connect success\n"); 103 + srs_trace("socket connect success");
107 time_socket_connect = srs_get_time_ms(); 104 time_socket_connect = srs_get_time_ms();
108 105
109 if ((ret = __srs_do_simple_handshake(rtmp)) != 0) { 106 if ((ret = __srs_do_simple_handshake(rtmp)) != 0) {
110 - fprintf(stderr, "do simple handshake failed. ret=%d\n", ret); 107 + srs_trace("do simple handshake failed. ret=%d", ret);
111 goto rtmp_destroy; 108 goto rtmp_destroy;
112 } 109 }
113 - printf("do simple handshake success\n"); 110 + srs_trace("do simple handshake success");
114 111
115 if ((ret = srs_connect_app(rtmp)) != 0) { 112 if ((ret = srs_connect_app(rtmp)) != 0) {
116 - fprintf(stderr, "connect vhost/app failed. ret=%d\n", ret); 113 + srs_trace("connect vhost/app failed. ret=%d", ret);
117 goto rtmp_destroy; 114 goto rtmp_destroy;
118 } 115 }
119 - printf("connect vhost/app success\n"); 116 + srs_trace("connect vhost/app success");
120 117
121 if ((ret = srs_play_stream(rtmp)) != 0) { 118 if ((ret = srs_play_stream(rtmp)) != 0) {
122 - fprintf(stderr, "play stream failed. ret=%d\n", ret); 119 + srs_trace("play stream failed. ret=%d", ret);
123 goto rtmp_destroy; 120 goto rtmp_destroy;
124 } 121 }
125 - printf("play stream success\n"); 122 + srs_trace("play stream success");
126 time_play_stream = srs_get_time_ms(); 123 time_play_stream = srs_get_time_ms();
127 124
128 for (;;) { 125 for (;;) {
129 if ((ret = srs_read_packet(rtmp, &type, &timestamp, &data, &size)) != 0) { 126 if ((ret = srs_read_packet(rtmp, &type, &timestamp, &data, &size)) != 0) {
130 - fprintf(stderr, "read packet failed. ret=%d\n", ret); 127 + srs_trace("read packet failed. ret=%d", ret);
131 goto rtmp_destroy; 128 goto rtmp_destroy;
132 } 129 }
133 - printf("got packet: type=%s, time=%d, size=%d\n", srs_type2string(type), timestamp, size); 130 + srs_trace("got packet: type=%s, time=%d, size=%d",
  131 + srs_type2string(type), timestamp, size);
134 132
135 if (SRS_RTMP_TYPE_VIDEO == type || SRS_RTMP_TYPE_AUDIO == type) { 133 if (SRS_RTMP_TYPE_VIDEO == type || SRS_RTMP_TYPE_AUDIO == type) {
136 if (time_first_packet <= 0) { 134 if (time_first_packet <= 0) {
@@ -144,12 +142,12 @@ int main(int argc, char** argv) @@ -144,12 +142,12 @@ int main(int argc, char** argv)
144 free(data); 142 free(data);
145 143
146 if (srs_get_time_ms() - time_startup > timeout * 1000) { 144 if (srs_get_time_ms() - time_startup > timeout * 1000) {
147 - printf("timeout, terminate.\n"); 145 + srs_trace("timeout, terminate.");
148 goto rtmp_destroy; 146 goto rtmp_destroy;
149 } 147 }
150 148
151 if ((timestamp - basetime) > duration * 1000) { 149 if ((timestamp - basetime) > duration * 1000) {
152 - printf("duration exceed, terminate.\n"); 150 + srs_trace("duration exceed, terminate.");
153 goto rtmp_destroy; 151 goto rtmp_destroy;
154 } 152 }
155 } 153 }
@@ -197,7 +195,9 @@ rtmp_destroy: @@ -197,7 +195,9 @@ rtmp_destroy:
197 "\"remark1\": \"delay = stream - (time_cleanup - time_first_packet)\"", 195 "\"remark1\": \"delay = stream - (time_cleanup - time_first_packet)\"",
198 "\"remark2\": \"if code is not 0, user must ignore all data\"" 196 "\"remark2\": \"if code is not 0, user must ignore all data\""
199 ); 197 );
200 - printf("\n"); 198 +
  199 + srs_trace("");
  200 + srs_trace("completed");
201 201
202 return ret; 202 return ret;
203 } 203 }
@@ -53,17 +53,20 @@ int main(int argc, char** argv) @@ -53,17 +53,20 @@ int main(int argc, char** argv)
53 int tmp_file_size = 0; 53 int tmp_file_size = 0;
54 char* tmp_file; 54 char* tmp_file;
55 55
  56 + printf("inject flv file keyframes to metadata.\n");
  57 + printf("srs(simple-rtmp-server) client librtmp library.\n");
  58 + printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision());
  59 +
56 if (argc <= 2) { 60 if (argc <= 2) {
57 printf("inject flv file keyframes to metadata\n" 61 printf("inject flv file keyframes to metadata\n"
58 "Usage: %s in_flv_file out_flv_file\n" 62 "Usage: %s in_flv_file out_flv_file\n"
59 " in_flv_file input flv file to inject.\n" 63 " in_flv_file input flv file to inject.\n"
60 " out_flv_file the inject output file, can be in_flv_file.\n" 64 " out_flv_file the inject output file, can be in_flv_file.\n"
61 "For example:\n" 65 "For example:\n"
  66 + " %s doc/source.200kbps.768x320.flv injected.flv\n"
62 " %s ../../doc/source.200kbps.768x320.flv injected.flv\n", 67 " %s ../../doc/source.200kbps.768x320.flv injected.flv\n",
63 - argv[0], argv[0]);  
64 - ret = 1;  
65 - exit(ret);  
66 - return ret; 68 + argv[0], argv[0], argv[0]);
  69 + exit(-1);
67 } 70 }
68 71
69 in_flv_file = argv[1]; 72 in_flv_file = argv[1];
@@ -73,9 +76,6 @@ int main(int argc, char** argv) @@ -73,9 +76,6 @@ int main(int argc, char** argv)
73 tmp_file = (char*)malloc(tmp_file_size); 76 tmp_file = (char*)malloc(tmp_file_size);
74 snprintf(tmp_file, tmp_file_size, "%s.tmp", out_flv_file); 77 snprintf(tmp_file, tmp_file_size, "%s.tmp", out_flv_file);
75 78
76 - srs_trace("inject flv file keyframes to metadata.");  
77 - srs_trace("srs(simple-rtmp-server) client librtmp library.");  
78 - srs_trace("version: %d.%d.%d", srs_version_major(), srs_version_minor(), srs_version_revision());  
79 srs_trace("input: %s", in_flv_file); 79 srs_trace("input: %s", in_flv_file);
80 srs_trace("output: %s", out_flv_file); 80 srs_trace("output: %s", out_flv_file);
81 srs_trace("tmp_file: %s", tmp_file); 81 srs_trace("tmp_file: %s", tmp_file);
@@ -45,23 +45,22 @@ int main(int argc, char** argv) @@ -45,23 +45,22 @@ int main(int argc, char** argv)
45 // flv handler 45 // flv handler
46 srs_flv_t flv; 46 srs_flv_t flv;
47 47
  48 + printf("parse and show flv file detail.\n");
  49 + printf("srs(simple-rtmp-server) client librtmp library.\n");
  50 + printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision());
  51 +
48 if (argc <= 1) { 52 if (argc <= 1) {
49 printf("parse and show flv file detail\n" 53 printf("parse and show flv file detail\n"
50 "Usage: %s in_flv_file\n" 54 "Usage: %s in_flv_file\n"
51 " in_flv_file flv file to parse and show.\n" 55 " in_flv_file flv file to parse and show.\n"
52 "For example:\n" 56 "For example:\n"
  57 + " %s doc/source.200kbps.768x320.flv\n"
53 " %s ../../doc/source.200kbps.768x320.flv\n", 58 " %s ../../doc/source.200kbps.768x320.flv\n",
54 - argv[0], argv[0]);  
55 - ret = 1;  
56 - exit(ret);  
57 - return ret; 59 + argv[0], argv[0], argv[0]);
  60 + exit(-1);
58 } 61 }
59 62
60 in_flv_file = argv[1]; 63 in_flv_file = argv[1];
61 -  
62 - srs_trace("parse and show flv file detail.");  
63 - srs_trace("srs(simple-rtmp-server) client librtmp library.");  
64 - srs_trace("version: %d.%d.%d", srs_version_major(), srs_version_minor(), srs_version_revision());  
65 srs_trace("input: %s", in_flv_file); 64 srs_trace("input: %s", in_flv_file);
66 65
67 if ((flv = srs_flv_open_read(in_flv_file)) == NULL) { 66 if ((flv = srs_flv_open_read(in_flv_file)) == NULL) {
@@ -59,17 +59,20 @@ int main(int argc, char** argv) @@ -59,17 +59,20 @@ int main(int argc, char** argv)
59 // flv handler 59 // flv handler
60 srs_flv_t flv; 60 srs_flv_t flv;
61 61
  62 + printf("ingest flv file and publish to RTMP server like FFMPEG.\n");
  63 + printf("srs(simple-rtmp-server) client librtmp library.\n");
  64 + printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision());
  65 +
62 if (argc <= 2) { 66 if (argc <= 2) {
63 printf("ingest flv file and publish to RTMP server\n" 67 printf("ingest flv file and publish to RTMP server\n"
64 "Usage: %s <-i in_flv_file> <-y out_rtmp_url>\n" 68 "Usage: %s <-i in_flv_file> <-y out_rtmp_url>\n"
65 " in_flv_file input flv file, ingest from this file.\n" 69 " in_flv_file input flv file, ingest from this file.\n"
66 " out_rtmp_url output rtmp url, publish to this url.\n" 70 " out_rtmp_url output rtmp url, publish to this url.\n"
67 "For example:\n" 71 "For example:\n"
68 - " %s -i ../../doc/source.200kbps.768x320.flv -y rtmp://127.0.0.1/live/demo\n",  
69 - argv[0], argv[0]);  
70 - ret = 1;  
71 - exit(ret);  
72 - return ret; 72 + " %s -i doc/source.200kbps.768x320.flv -y rtmp://127.0.0.1/live/livestream\n"
  73 + " %s -i ../../doc/source.200kbps.768x320.flv -y rtmp://127.0.0.1/live/livestream\n",
  74 + argv[0], argv[0], argv[0]);
  75 + exit(-1);
73 } 76 }
74 77
75 // parse options in FFMPEG format. 78 // parse options in FFMPEG format.
@@ -86,9 +89,6 @@ int main(int argc, char** argv) @@ -86,9 +89,6 @@ int main(int argc, char** argv)
86 } 89 }
87 } 90 }
88 91
89 - srs_trace("ingest flv file and publish to RTMP server like FFMPEG.");  
90 - srs_trace("srs(simple-rtmp-server) client librtmp library.");  
91 - srs_trace("version: %d.%d.%d", srs_version_major(), srs_version_minor(), srs_version_revision());  
92 srs_trace("input: %s", in_flv_file); 92 srs_trace("input: %s", in_flv_file);
93 srs_trace("output: %s", out_rtmp_url); 93 srs_trace("output: %s", out_rtmp_url);
94 94
@@ -45,6 +45,10 @@ int main(int argc, char** argv) @@ -45,6 +45,10 @@ int main(int argc, char** argv)
45 // rtmp handler 45 // rtmp handler
46 srs_rtmp_t irtmp, ortmp; 46 srs_rtmp_t irtmp, ortmp;
47 47
  48 + printf("ingest RTMP and publish to RTMP server like edge.\n");
  49 + printf("srs(simple-rtmp-server) client librtmp library.\n");
  50 + printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision());
  51 +
48 if (argc <= 2) { 52 if (argc <= 2) {
49 printf("ingest RTMP and publish to RTMP server\n" 53 printf("ingest RTMP and publish to RTMP server\n"
50 "Usage: %s <-i in_rtmp_url> <-y out_rtmp_url>\n" 54 "Usage: %s <-i in_rtmp_url> <-y out_rtmp_url>\n"
@@ -53,9 +57,7 @@ int main(int argc, char** argv) @@ -53,9 +57,7 @@ int main(int argc, char** argv)
53 "For example:\n" 57 "For example:\n"
54 " %s -i rtmp://127.0.0.1/live/livestream -y rtmp://127.0.0.1/live/demo\n", 58 " %s -i rtmp://127.0.0.1/live/livestream -y rtmp://127.0.0.1/live/demo\n",
55 argv[0], argv[0]); 59 argv[0], argv[0]);
56 - ret = 1;  
57 - exit(ret);  
58 - return ret; 60 + exit(-1);
59 } 61 }
60 62
61 // parse options in FFMPEG format. 63 // parse options in FFMPEG format.
@@ -72,9 +74,6 @@ int main(int argc, char** argv) @@ -72,9 +74,6 @@ int main(int argc, char** argv)
72 } 74 }
73 } 75 }
74 76
75 - srs_trace("ingest RTMP and publish to RTMP server like edge.");  
76 - srs_trace("srs(simple-rtmp-server) client librtmp library.");  
77 - srs_trace("version: %d.%d.%d", srs_version_major(), srs_version_minor(), srs_version_revision());  
78 srs_trace("input: %s", in_rtmp_url); 77 srs_trace("input: %s", in_rtmp_url);
79 srs_trace("output: %s", out_rtmp_url); 78 srs_trace("output: %s", out_rtmp_url);
80 79
@@ -31,31 +31,21 @@ gcc srs_play.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_play @@ -31,31 +31,21 @@ gcc srs_play.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_play
31 31
32 int main(int argc, char** argv) 32 int main(int argc, char** argv)
33 { 33 {
34 - srs_rtmp_t rtmp;  
35 -  
36 - // packet data  
37 - int type, size;  
38 - u_int32_t timestamp = 0;  
39 - char* data; 34 + printf("suck rtmp stream like rtmpdump\n");
  35 + printf("srs(simple-rtmp-server) client librtmp library.\n");
  36 + printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision());
40 37
41 if (argc <= 1) { 38 if (argc <= 1) {
42 - printf("play stream on RTMP server\n"  
43 - "Usage: %s <rtmp_url>\n" 39 + printf("Usage: %s <rtmp_url>\n"
44 " rtmp_url RTMP stream url to play\n" 40 " rtmp_url RTMP stream url to play\n"
45 "For example:\n" 41 "For example:\n"
46 " %s rtmp://127.0.0.1:1935/live/livestream\n", 42 " %s rtmp://127.0.0.1:1935/live/livestream\n",
47 argv[0], argv[0]); 43 argv[0], argv[0]);
48 - int ret = 1;  
49 - exit(ret);  
50 - return ret; 44 + exit(-1);
51 } 45 }
52 46
53 - rtmp = srs_rtmp_create(argv[1]);  
54 -  
55 - srs_trace("suck rtmp stream like rtmpdump");  
56 - srs_trace("srs(simple-rtmp-server) client librtmp library.");  
57 - srs_trace("version: %d.%d.%d", srs_version_major(), srs_version_minor(), srs_version_revision());  
58 srs_trace("rtmp url: %s", argv[1]); 47 srs_trace("rtmp url: %s", argv[1]);
  48 + srs_rtmp_t rtmp = srs_rtmp_create(argv[1]);
59 49
60 if (srs_simple_handshake(rtmp) != 0) { 50 if (srs_simple_handshake(rtmp) != 0) {
61 srs_trace("simple handshake failed."); 51 srs_trace("simple handshake failed.");
@@ -76,6 +66,10 @@ int main(int argc, char** argv) @@ -76,6 +66,10 @@ int main(int argc, char** argv)
76 srs_trace("play stream success"); 66 srs_trace("play stream success");
77 67
78 for (;;) { 68 for (;;) {
  69 + int type, size;
  70 + u_int32_t timestamp = 0;
  71 + char* data;
  72 +
79 if (srs_read_packet(rtmp, &type, &timestamp, &data, &size) != 0) { 73 if (srs_read_packet(rtmp, &type, &timestamp, &data, &size) != 0) {
80 goto rtmp_destroy; 74 goto rtmp_destroy;
81 } 75 }
@@ -32,54 +32,60 @@ gcc srs_publish.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_publish @@ -32,54 +32,60 @@ gcc srs_publish.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_publish
32 32
33 int main(int argc, char** argv) 33 int main(int argc, char** argv)
34 { 34 {
35 - srs_rtmp_t rtmp;  
36 -  
37 - // packet data  
38 - int type, size;  
39 - u_int32_t timestamp = 0;  
40 - char* data;  
41 -  
42 printf("publish rtmp stream to server like FMLE/FFMPEG/Encoder\n"); 35 printf("publish rtmp stream to server like FMLE/FFMPEG/Encoder\n");
43 printf("srs(simple-rtmp-server) client librtmp library.\n"); 36 printf("srs(simple-rtmp-server) client librtmp library.\n");
44 printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision()); 37 printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision());
  38 +
  39 + if (argc <= 1) {
  40 + printf("Usage: %s <rtmp_url>\n"
  41 + " rtmp_url RTMP stream url to publish\n"
  42 + "For example:\n"
  43 + " %s rtmp://127.0.0.1:1935/live/livestream\n",
  44 + argv[0], argv[0]);
  45 + exit(-1);
  46 + }
  47 +
45 // warn it . 48 // warn it .
46 // @see: https://github.com/winlinvip/simple-rtmp-server/issues/126 49 // @see: https://github.com/winlinvip/simple-rtmp-server/issues/126
47 - printf("\033[33m%s\033[0m", 50 + srs_trace("\033[33m%s\033[0m",
48 "[warning] it's only a sample to use librtmp. " 51 "[warning] it's only a sample to use librtmp. "
49 "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. "
50 - "you should refer to this tool to use the srs-librtmp to publish the real media stream.");  
51 - printf("\n");  
52 -  
53 - rtmp = srs_rtmp_create("rtmp://127.0.0.1:1935/live/livestream"); 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");
  55 + srs_trace("rtmp url: %s", argv[1]);
  56 + srs_rtmp_t rtmp = srs_rtmp_create(argv[1]);
54 57
55 if (srs_simple_handshake(rtmp) != 0) { 58 if (srs_simple_handshake(rtmp) != 0) {
56 - printf("simple handshake failed.\n"); 59 + srs_trace("simple handshake failed.");
57 goto rtmp_destroy; 60 goto rtmp_destroy;
58 } 61 }
59 - printf("simple handshake success\n"); 62 + srs_trace("simple handshake success");
60 63
61 if (srs_connect_app(rtmp) != 0) { 64 if (srs_connect_app(rtmp) != 0) {
62 - printf("connect vhost/app failed.\n"); 65 + srs_trace("connect vhost/app failed.");
63 goto rtmp_destroy; 66 goto rtmp_destroy;
64 } 67 }
65 - printf("connect vhost/app success\n"); 68 + srs_trace("connect vhost/app success");
66 69
67 if (srs_publish_stream(rtmp) != 0) { 70 if (srs_publish_stream(rtmp) != 0) {
68 - printf("publish stream failed.\n"); 71 + srs_trace("publish stream failed.");
69 goto rtmp_destroy; 72 goto rtmp_destroy;
70 } 73 }
71 - printf("publish stream success\n"); 74 + srs_trace("publish stream success");
72 75
  76 + u_int32_t timestamp = 0;
73 for (;;) { 77 for (;;) {
74 - type = SRS_RTMP_TYPE_VIDEO; 78 + int type = SRS_RTMP_TYPE_VIDEO;
  79 + int size = 4096;
  80 + char* data = (char*)malloc(4096);
  81 +
75 timestamp += 40; 82 timestamp += 40;
76 - size = 4096;  
77 - data = (char*)malloc(4096);  
78 83
79 if (srs_write_packet(rtmp, type, timestamp, data, size) != 0) { 84 if (srs_write_packet(rtmp, type, timestamp, data, size) != 0) {
80 goto rtmp_destroy; 85 goto rtmp_destroy;
81 } 86 }
82 - printf("sent packet: type=%s, time=%d, size=%d\n", srs_type2string(type), timestamp, size); 87 + srs_trace("sent packet: type=%s, time=%d, size=%d",
  88 + srs_type2string(type), timestamp, size);
83 89
84 usleep(40 * 1000); 90 usleep(40 * 1000);
85 } 91 }
@@ -237,8 +237,8 @@ extern int64_t srs_get_nrecv_bytes(srs_rtmp_t rtmp); @@ -237,8 +237,8 @@ extern int64_t srs_get_nrecv_bytes(srs_rtmp_t rtmp);
237 237
238 // log to console, for use srs-librtmp application. 238 // log to console, for use srs-librtmp application.
239 extern const char* srs_format_time(); 239 extern const char* srs_format_time();
240 -#define srs_trace(msg, ...) printf("[%s]", srs_format_time());printf(msg, ##__VA_ARGS__);printf("\n")  
241 -#define srs_verbose(msg, ...) printf("[%s]", srs_format_time());printf(msg, ##__VA_ARGS__);printf("\n") 240 +#define srs_trace(msg, ...) printf("[%s] ", srs_format_time());printf(msg, ##__VA_ARGS__);printf("\n")
  241 +#define srs_verbose(msg, ...) printf("[%s] ", srs_format_time());printf(msg, ##__VA_ARGS__);printf("\n")
242 242
243 /************************************************************* 243 /*************************************************************
244 ************************************************************** 244 **************************************************************