winlin

srs-librtmp add rtmp prefix for rtmp apis. 2.0.29

@@ -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
@@ -116,19 +116,19 @@ int main(int argc, char** argv) @@ -116,19 +116,19 @@ 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) { 119 + if (srs_rtmp_handshake(rtmp) != 0) {
120 srs_human_trace("simple handshake failed."); 120 srs_human_trace("simple handshake failed.");
121 goto rtmp_destroy; 121 goto rtmp_destroy;
122 } 122 }
123 srs_human_trace("simple handshake success"); 123 srs_human_trace("simple handshake success");
124 124
125 - if (srs_connect_app(rtmp) != 0) { 125 + if (srs_rtmp_connect_app(rtmp) != 0) {
126 srs_human_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_human_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_rtmp_publish_stream(rtmp) != 0) {
132 srs_human_trace("publish stream failed."); 132 srs_human_trace("publish stream failed.");
133 goto rtmp_destroy; 133 goto rtmp_destroy;
134 } 134 }
@@ -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>
@@ -83,20 +83,20 @@ int main(int argc, char** argv) @@ -83,20 +83,20 @@ int main(int argc, char** argv)
83 83
84 srs_human_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_rtmp_handshake(rtmp)) != 0) {
87 srs_human_trace("simple handshake failed."); 87 srs_human_trace("simple handshake failed.");
88 goto rtmp_destroy; 88 goto rtmp_destroy;
89 } 89 }
90 srs_human_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_human_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_human_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 ) {
@@ -90,33 +90,33 @@ int main(int argc, char** argv) @@ -90,33 +90,33 @@ int main(int argc, char** argv)
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_rtmp_dns_resolve(rtmp)) != 0) {
94 srs_human_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_human_trace("dns resolve success"); 97 srs_human_trace("dns resolve success");
98 time_dns_resolve = srs_utils_get_time_ms(); 98 time_dns_resolve = srs_utils_get_time_ms();
99 99
100 - if ((ret = __srs_connect_server(rtmp)) != 0) { 100 + if ((ret = __srs_rtmp_connect_server(rtmp)) != 0) {
101 srs_human_trace("socket connect failed. ret=%d", ret); 101 srs_human_trace("socket connect failed. ret=%d", ret);
102 goto rtmp_destroy; 102 goto rtmp_destroy;
103 } 103 }
104 srs_human_trace("socket connect success"); 104 srs_human_trace("socket connect success");
105 time_socket_connect = srs_utils_get_time_ms(); 105 time_socket_connect = srs_utils_get_time_ms();
106 106
107 - if ((ret = __srs_do_simple_handshake(rtmp)) != 0) { 107 + if ((ret = __srs_rtmp_do_simple_handshake(rtmp)) != 0) {
108 srs_human_trace("do simple handshake failed. ret=%d", ret); 108 srs_human_trace("do simple handshake failed. ret=%d", ret);
109 goto rtmp_destroy; 109 goto rtmp_destroy;
110 } 110 }
111 srs_human_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_rtmp_connect_app(rtmp)) != 0) {
114 srs_human_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_human_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_rtmp_play_stream(rtmp)) != 0) {
120 srs_human_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 }
@@ -124,7 +124,7 @@ int main(int argc, char** argv) @@ -124,7 +124,7 @@ int main(int argc, char** argv)
124 time_play_stream = srs_utils_get_time_ms(); 124 time_play_stream = srs_utils_get_time_ms();
125 125
126 for (;;) { 126 for (;;) {
127 - if ((ret = srs_read_packet(rtmp, &type, &timestamp, &data, &size)) != 0) { 127 + if ((ret = srs_rtmp_read_packet(rtmp, &type, &timestamp, &data, &size)) != 0) {
128 srs_human_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 }
@@ -128,19 +128,19 @@ int main(int argc, char** argv) @@ -128,19 +128,19 @@ 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) { 131 + if (srs_rtmp_handshake(rtmp) != 0) {
132 srs_human_trace("simple handshake failed."); 132 srs_human_trace("simple handshake failed.");
133 goto rtmp_destroy; 133 goto rtmp_destroy;
134 } 134 }
135 srs_human_trace("simple handshake success"); 135 srs_human_trace("simple handshake success");
136 136
137 - if (srs_connect_app(rtmp) != 0) { 137 + if (srs_rtmp_connect_app(rtmp) != 0) {
138 srs_human_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_human_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_rtmp_publish_stream(rtmp) != 0) {
144 srs_human_trace("publish stream failed."); 144 srs_human_trace("publish stream failed.");
145 goto rtmp_destroy; 145 goto rtmp_destroy;
146 } 146 }
@@ -148,7 +148,7 @@ int do_proxy(srs_flv_t flv, srs_rtmp_t ortmp, int64_t re, int32_t* pstarttime, u @@ -148,7 +148,7 @@ int do_proxy(srs_flv_t flv, srs_rtmp_t ortmp, int64_t re, int32_t* pstarttime, u
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_rtmp_write_packet(ortmp, type, *ptimestamp, data, size)) != 0) {
152 srs_human_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 }
@@ -191,19 +191,19 @@ int connect_oc(srs_rtmp_t ortmp) @@ -191,19 +191,19 @@ 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) { 194 + if ((ret = srs_rtmp_handshake(ortmp)) != 0) {
195 srs_human_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_human_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_rtmp_connect_app(ortmp)) != 0) {
201 srs_human_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_human_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_rtmp_publish_stream(ortmp)) != 0) {
207 srs_human_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 }
@@ -108,7 +108,7 @@ int proxy(srs_rtmp_t irtmp, srs_rtmp_t ortmp) @@ -108,7 +108,7 @@ int proxy(srs_rtmp_t irtmp, srs_rtmp_t ortmp)
108 108
109 srs_human_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, &timestamp, &data, &size)) != 0) { 111 + if ((ret = srs_rtmp_read_packet(irtmp, &type, &timestamp, &data, &size)) != 0) {
112 srs_human_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 }
@@ -118,7 +118,7 @@ int proxy(srs_rtmp_t irtmp, srs_rtmp_t ortmp) @@ -118,7 +118,7 @@ int proxy(srs_rtmp_t irtmp, srs_rtmp_t ortmp)
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_rtmp_write_packet(ortmp, type, timestamp, data, size)) != 0) {
122 srs_human_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 }
@@ -133,19 +133,19 @@ int connect_ic(srs_rtmp_t irtmp) @@ -133,19 +133,19 @@ 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) { 136 + if ((ret = srs_rtmp_handshake(irtmp)) != 0) {
137 srs_human_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_human_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_rtmp_connect_app(irtmp)) != 0) {
143 srs_human_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_human_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_rtmp_play_stream(irtmp)) != 0) {
149 srs_human_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 }
@@ -158,19 +158,19 @@ int connect_oc(srs_rtmp_t ortmp) @@ -158,19 +158,19 @@ 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) { 161 + if ((ret = srs_rtmp_handshake(ortmp)) != 0) {
162 srs_human_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_human_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_rtmp_connect_app(ortmp)) != 0) {
168 srs_human_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_human_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_rtmp_publish_stream(ortmp)) != 0) {
174 srs_human_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 }
@@ -47,19 +47,19 @@ int main(int argc, char** argv) @@ -47,19 +47,19 @@ int main(int argc, char** argv)
47 srs_human_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_rtmp_handshake(rtmp) != 0) {
51 srs_human_trace("simple handshake failed."); 51 srs_human_trace("simple handshake failed.");
52 goto rtmp_destroy; 52 goto rtmp_destroy;
53 } 53 }
54 srs_human_trace("simple handshake success"); 54 srs_human_trace("simple handshake success");
55 55
56 - if (srs_connect_app(rtmp) != 0) { 56 + if (srs_rtmp_connect_app(rtmp) != 0) {
57 srs_human_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_human_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_rtmp_play_stream(rtmp) != 0) {
63 srs_human_trace("play stream failed."); 63 srs_human_trace("play stream failed.");
64 goto rtmp_destroy; 64 goto rtmp_destroy;
65 } 65 }
@@ -71,7 +71,7 @@ int main(int argc, char** argv) @@ -71,7 +71,7 @@ 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, &timestamp, &data, &size) != 0) { 74 + if (srs_rtmp_read_packet(rtmp, &type, &timestamp, &data, &size) != 0) {
75 goto rtmp_destroy; 75 goto rtmp_destroy;
76 } 76 }
77 77
@@ -55,19 +55,19 @@ int main(int argc, char** argv) @@ -55,19 +55,19 @@ int main(int argc, char** argv)
55 srs_human_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_rtmp_handshake(rtmp) != 0) {
59 srs_human_trace("simple handshake failed."); 59 srs_human_trace("simple handshake failed.");
60 goto rtmp_destroy; 60 goto rtmp_destroy;
61 } 61 }
62 srs_human_trace("simple handshake success"); 62 srs_human_trace("simple handshake success");
63 63
64 - if (srs_connect_app(rtmp) != 0) { 64 + if (srs_rtmp_connect_app(rtmp) != 0) {
65 srs_human_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_human_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_rtmp_publish_stream(rtmp) != 0) {
71 srs_human_trace("publish stream failed."); 71 srs_human_trace("publish stream failed.");
72 goto rtmp_destroy; 72 goto rtmp_destroy;
73 } 73 }
@@ -81,7 +81,7 @@ int main(int argc, char** argv) @@ -81,7 +81,7 @@ 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_human_trace("sent packet: type=%s, time=%d, size=%d", 87 srs_human_trace("sent packet: type=%s, time=%d, size=%d",
@@ -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,7 +716,7 @@ int srs_publish_stream(srs_rtmp_t rtmp) @@ -701,7 +716,7 @@ int srs_publish_stream(srs_rtmp_t rtmp)
701 return ret; 716 return ret;
702 } 717 }
703 718
704 -int srs_bandwidth_check(srs_rtmp_t rtmp, 719 +int srs_rtmp_bandwidth_check(srs_rtmp_t rtmp,
705 int64_t* start_time, int64_t* end_time, 720 int64_t* start_time, int64_t* end_time,
706 int* play_kbps, int* publish_kbps, 721 int* play_kbps, int* publish_kbps,
707 int* play_bytes, int* publish_bytes, 722 int* play_bytes, int* publish_bytes,
@@ -737,7 +752,7 @@ int srs_bandwidth_check(srs_rtmp_t rtmp, @@ -737,7 +752,7 @@ int srs_bandwidth_check(srs_rtmp_t rtmp,
737 return ret; 752 return ret;
738 } 753 }
739 754
740 -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)
741 { 756 {
742 *type = 0; 757 *type = 0;
743 *timestamp = 0; 758 *timestamp = 0;
@@ -792,7 +807,7 @@ int srs_read_packet(srs_rtmp_t rtmp, char* type, u_int32_t* timestamp, char** da @@ -792,7 +807,7 @@ int srs_read_packet(srs_rtmp_t rtmp, char* type, u_int32_t* timestamp, char** da
792 return ret; 807 return ret;
793 } 808 }
794 809
795 -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)
796 { 811 {
797 int ret = ERROR_SUCCESS; 812 int ret = ERROR_SUCCESS;
798 813
@@ -843,21 +858,6 @@ int srs_write_packet(srs_rtmp_t rtmp, char type, u_int32_t timestamp, char* data @@ -843,21 +858,6 @@ int srs_write_packet(srs_rtmp_t rtmp, char type, u_int32_t timestamp, char* data
843 return ret; 858 return ret;
844 } 859 }
845 860
846 -int srs_version_major()  
847 -{  
848 - return VERSION_MAJOR;  
849 -}  
850 -  
851 -int srs_version_minor()  
852 -{  
853 - return VERSION_MINOR;  
854 -}  
855 -  
856 -int srs_version_revision()  
857 -{  
858 - return VERSION_REVISION;  
859 -}  
860 -  
861 struct FlvContext 861 struct FlvContext
862 { 862 {
863 SrsFileReader reader; 863 SrsFileReader reader;
@@ -1356,7 +1356,7 @@ int srs_audio_write_raw_frame(srs_rtmp_t rtmp, @@ -1356,7 +1356,7 @@ int srs_audio_write_raw_frame(srs_rtmp_t rtmp,
1356 1356
1357 memcpy(p, frame, frame_size); 1357 memcpy(p, frame, frame_size);
1358 1358
1359 - 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);
1360 } 1360 }
1361 1361
1362 /** 1362 /**
@@ -1403,7 +1403,7 @@ int __srs_write_h264_packet(Context* context, @@ -1403,7 +1403,7 @@ int __srs_write_h264_packet(Context* context,
1403 // h.264 raw data. 1403 // h.264 raw data.
1404 memcpy(p, h264_raw_data, h264_raw_size); 1404 memcpy(p, h264_raw_data, h264_raw_size);
1405 1405
1406 - 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);
1407 } 1407 }
1408 1408
1409 /** 1409 /**
@@ -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,
@@ -246,25 +255,15 @@ extern int srs_bandwidth_check(srs_rtmp_t rtmp, @@ -246,25 +255,15 @@ extern int srs_bandwidth_check(srs_rtmp_t rtmp,
246 * 255 *
247 * @return 0, success; otherswise, failed. 256 * @return 0, success; otherswise, failed.
248 */ 257 */
249 -extern int srs_read_packet(srs_rtmp_t rtmp, 258 +extern int srs_rtmp_read_packet(srs_rtmp_t rtmp,
250 char* type, u_int32_t* timestamp, char** data, int* size 259 char* type, u_int32_t* timestamp, char** data, int* size
251 ); 260 );
252 -extern int srs_write_packet(srs_rtmp_t rtmp, 261 +extern int srs_rtmp_write_packet(srs_rtmp_t rtmp,
253 char type, u_int32_t timestamp, char* data, int size 262 char type, u_int32_t timestamp, char* data, int size
254 ); 263 );
255 264
256 /************************************************************* 265 /*************************************************************
257 ************************************************************** 266 **************************************************************
258 -* version apis  
259 -**************************************************************  
260 -*************************************************************/  
261 -// get protocol stack version  
262 -extern int srs_version_major();  
263 -extern int srs_version_minor();  
264 -extern int srs_version_revision();  
265 -  
266 -/*************************************************************  
267 -**************************************************************  
268 * flv codec 267 * flv codec
269 * @example /trunk/research/librtmp/srs_flv_injecter.c 268 * @example /trunk/research/librtmp/srs_flv_injecter.c
270 * @example /trunk/research/librtmp/srs_flv_parser.c 269 * @example /trunk/research/librtmp/srs_flv_parser.c
@@ -607,7 +606,7 @@ extern int64_t srs_utils_get_recv_bytes(srs_rtmp_t rtmp); @@ -607,7 +606,7 @@ extern int64_t srs_utils_get_recv_bytes(srs_rtmp_t rtmp);
607 606
608 /** 607 /**
609 * parse the dts and pts by time in header and data in tag, 608 * parse the dts and pts by time in header and data in tag,
610 -* or to parse the RTMP packet by srs_read_packet(). 609 +* or to parse the RTMP packet by srs_rtmp_read_packet().
611 * 610 *
612 * @param time, the timestamp of tag, read by srs_flv_read_tag_header(). 611 * @param time, the timestamp of tag, read by srs_flv_read_tag_header().
613 * @param type, the type of tag, read by srs_flv_read_tag_header(). 612 * @param type, the type of tag, read by srs_flv_read_tag_header().
@@ -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,