merge from bravo system, add the rtmfp to bms(commercial srs). 2.0.163.
正在显示
17 个修改的文件
包含
297 行增加
和
250 行删除
| @@ -562,6 +562,7 @@ Supported operating systems and hardware: | @@ -562,6 +562,7 @@ Supported operating systems and hardware: | ||
| 562 | 562 | ||
| 563 | ### SRS 2.0 history | 563 | ### SRS 2.0 history |
| 564 | 564 | ||
| 565 | +* v2.0, 2015-05-19, merge from bravo system, add the rtmfp to bms(commercial srs). 2.0.163. | ||
| 565 | * v2.0, 2015-05-10, support push flv stream over HTTP POST to SRS. | 566 | * v2.0, 2015-05-10, support push flv stream over HTTP POST to SRS. |
| 566 | * v2.0, 2015-04-20, support ingest hls live stream to RTMP. | 567 | * v2.0, 2015-04-20, support ingest hls live stream to RTMP. |
| 567 | * v2.0, 2015-04-15, for [#383](https://github.com/simple-rtmp-server/srs/issues/383), support mix_correct algorithm. 2.0.161. | 568 | * v2.0, 2015-04-15, for [#383](https://github.com/simple-rtmp-server/srs/issues/383), support mix_correct algorithm. 2.0.161. |
| @@ -514,12 +514,12 @@ | @@ -514,12 +514,12 @@ | ||
| 514 | 3C12324B1AAE81CE00CE8F6C /* app */ = { | 514 | 3C12324B1AAE81CE00CE8F6C /* app */ = { |
| 515 | isa = PBXGroup; | 515 | isa = PBXGroup; |
| 516 | children = ( | 516 | children = ( |
| 517 | - 3C28EDDD1AF5C43F00A3AEAC /* srs_app_caster_flv.cpp */, | ||
| 518 | - 3C28EDDE1AF5C43F00A3AEAC /* srs_app_caster_flv.hpp */, | ||
| 519 | 3CD88B3D1ACA9C58000359E0 /* srs_app_async_call.cpp */, | 517 | 3CD88B3D1ACA9C58000359E0 /* srs_app_async_call.cpp */, |
| 520 | 3CD88B3E1ACA9C58000359E0 /* srs_app_async_call.hpp */, | 518 | 3CD88B3E1ACA9C58000359E0 /* srs_app_async_call.hpp */, |
| 521 | 3C12324C1AAE81D900CE8F6C /* srs_app_bandwidth.cpp */, | 519 | 3C12324C1AAE81D900CE8F6C /* srs_app_bandwidth.cpp */, |
| 522 | 3C12324D1AAE81D900CE8F6C /* srs_app_bandwidth.hpp */, | 520 | 3C12324D1AAE81D900CE8F6C /* srs_app_bandwidth.hpp */, |
| 521 | + 3C28EDDD1AF5C43F00A3AEAC /* srs_app_caster_flv.cpp */, | ||
| 522 | + 3C28EDDE1AF5C43F00A3AEAC /* srs_app_caster_flv.hpp */, | ||
| 523 | 3C12324E1AAE81D900CE8F6C /* srs_app_config.cpp */, | 523 | 3C12324E1AAE81D900CE8F6C /* srs_app_config.cpp */, |
| 524 | 3C12324F1AAE81D900CE8F6C /* srs_app_config.hpp */, | 524 | 3C12324F1AAE81D900CE8F6C /* srs_app_config.hpp */, |
| 525 | 3C1232501AAE81D900CE8F6C /* srs_app_conn.cpp */, | 525 | 3C1232501AAE81D900CE8F6C /* srs_app_conn.cpp */, |
| @@ -536,10 +536,10 @@ | @@ -536,10 +536,10 @@ | ||
| 536 | 3C12325B1AAE81D900CE8F6C /* srs_app_ffmpeg.hpp */, | 536 | 3C12325B1AAE81D900CE8F6C /* srs_app_ffmpeg.hpp */, |
| 537 | 3C12325C1AAE81D900CE8F6C /* srs_app_forward.cpp */, | 537 | 3C12325C1AAE81D900CE8F6C /* srs_app_forward.cpp */, |
| 538 | 3C12325D1AAE81D900CE8F6C /* srs_app_forward.hpp */, | 538 | 3C12325D1AAE81D900CE8F6C /* srs_app_forward.hpp */, |
| 539 | - 3C12325E1AAE81D900CE8F6C /* srs_app_heartbeat.cpp */, | ||
| 540 | - 3C12325F1AAE81D900CE8F6C /* srs_app_heartbeat.hpp */, | ||
| 541 | 3C1EE6AC1AB1055800576EE9 /* srs_app_hds.cpp */, | 539 | 3C1EE6AC1AB1055800576EE9 /* srs_app_hds.cpp */, |
| 542 | 3C1EE6AD1AB1055800576EE9 /* srs_app_hds.hpp */, | 540 | 3C1EE6AD1AB1055800576EE9 /* srs_app_hds.hpp */, |
| 541 | + 3C12325E1AAE81D900CE8F6C /* srs_app_heartbeat.cpp */, | ||
| 542 | + 3C12325F1AAE81D900CE8F6C /* srs_app_heartbeat.hpp */, | ||
| 543 | 3C1232601AAE81D900CE8F6C /* srs_app_hls.cpp */, | 543 | 3C1232601AAE81D900CE8F6C /* srs_app_hls.cpp */, |
| 544 | 3C1232611AAE81D900CE8F6C /* srs_app_hls.hpp */, | 544 | 3C1232611AAE81D900CE8F6C /* srs_app_hls.hpp */, |
| 545 | 3C1232621AAE81D900CE8F6C /* srs_app_http_api.cpp */, | 545 | 3C1232621AAE81D900CE8F6C /* srs_app_http_api.cpp */, |
| @@ -441,11 +441,23 @@ int SrsConfig::reload_conf(SrsConfig* conf) | @@ -441,11 +441,23 @@ int SrsConfig::reload_conf(SrsConfig* conf) | ||
| 441 | // daemon | 441 | // daemon |
| 442 | // | 442 | // |
| 443 | // always support reload without additional code: | 443 | // always support reload without additional code: |
| 444 | - // chunk_size, ff_log_dir, max_connections, | 444 | + // chunk_size, ff_log_dir, |
| 445 | // bandcheck, http_hooks, heartbeat, | 445 | // bandcheck, http_hooks, heartbeat, |
| 446 | // token_traverse, debug_srs_upnode, | 446 | // token_traverse, debug_srs_upnode, |
| 447 | // security | 447 | // security |
| 448 | 448 | ||
| 449 | + // merge config: max_connections | ||
| 450 | + if (!srs_directive_equals(root->get("max_connections"), old_root->get("max_connections"))) { | ||
| 451 | + for (it = subscribes.begin(); it != subscribes.end(); ++it) { | ||
| 452 | + ISrsReloadHandler* subscribe = *it; | ||
| 453 | + if ((ret = subscribe->on_reload_max_conns()) != ERROR_SUCCESS) { | ||
| 454 | + srs_error("notify subscribes reload max_connections failed. ret=%d", ret); | ||
| 455 | + return ret; | ||
| 456 | + } | ||
| 457 | + } | ||
| 458 | + srs_trace("reload max_connections success."); | ||
| 459 | + } | ||
| 460 | + | ||
| 449 | // merge config: listen | 461 | // merge config: listen |
| 450 | if (!srs_directive_equals(root->get("listen"), old_root->get("listen"))) { | 462 | if (!srs_directive_equals(root->get("listen"), old_root->get("listen"))) { |
| 451 | for (it = subscribes.begin(); it != subscribes.end(); ++it) { | 463 | for (it = subscribes.begin(); it != subscribes.end(); ++it) { |
| @@ -40,6 +40,11 @@ int ISrsReloadHandler::on_reload_listen() | @@ -40,6 +40,11 @@ int ISrsReloadHandler::on_reload_listen() | ||
| 40 | return ERROR_SUCCESS; | 40 | return ERROR_SUCCESS; |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | +int ISrsReloadHandler::on_reload_max_conns() | ||
| 44 | +{ | ||
| 45 | + return ERROR_SUCCESS; | ||
| 46 | +} | ||
| 47 | + | ||
| 43 | int ISrsReloadHandler::on_reload_pid() | 48 | int ISrsReloadHandler::on_reload_pid() |
| 44 | { | 49 | { |
| 45 | return ERROR_SUCCESS; | 50 | return ERROR_SUCCESS; |
| @@ -44,6 +44,7 @@ public: | @@ -44,6 +44,7 @@ public: | ||
| 44 | ISrsReloadHandler(); | 44 | ISrsReloadHandler(); |
| 45 | virtual ~ISrsReloadHandler(); | 45 | virtual ~ISrsReloadHandler(); |
| 46 | public: | 46 | public: |
| 47 | + virtual int on_reload_max_conns(); | ||
| 47 | virtual int on_reload_listen(); | 48 | virtual int on_reload_listen(); |
| 48 | virtual int on_reload_pid(); | 49 | virtual int on_reload_pid(); |
| 49 | virtual int on_reload_log_tank(); | 50 | virtual int on_reload_log_tank(); |
| @@ -55,6 +56,7 @@ public: | @@ -55,6 +56,7 @@ public: | ||
| 55 | virtual int on_reload_http_stream_enabled(); | 56 | virtual int on_reload_http_stream_enabled(); |
| 56 | virtual int on_reload_http_stream_disabled(); | 57 | virtual int on_reload_http_stream_disabled(); |
| 57 | virtual int on_reload_http_stream_updated(); | 58 | virtual int on_reload_http_stream_updated(); |
| 59 | +public: | ||
| 58 | virtual int on_reload_vhost_http_updated(); | 60 | virtual int on_reload_vhost_http_updated(); |
| 59 | virtual int on_reload_vhost_http_remux_updated(); | 61 | virtual int on_reload_vhost_http_remux_updated(); |
| 60 | virtual int on_reload_vhost_added(std::string vhost); | 62 | virtual int on_reload_vhost_added(std::string vhost); |
| @@ -1068,13 +1068,9 @@ int SrsRtmpConn::process_play_control_msg(SrsConsumer* consumer, SrsCommonMessag | @@ -1068,13 +1068,9 @@ int SrsRtmpConn::process_play_control_msg(SrsConsumer* consumer, SrsCommonMessag | ||
| 1068 | return ret; | 1068 | return ret; |
| 1069 | } | 1069 | } |
| 1070 | 1070 | ||
| 1071 | - // pause or other msg. | 1071 | + // pause |
| 1072 | SrsPausePacket* pause = dynamic_cast<SrsPausePacket*>(pkt); | 1072 | SrsPausePacket* pause = dynamic_cast<SrsPausePacket*>(pkt); |
| 1073 | - if (!pause) { | ||
| 1074 | - srs_info("ignore all amf0/amf3 command except pause."); | ||
| 1075 | - return ret; | ||
| 1076 | - } | ||
| 1077 | - | 1073 | + if (pause) { |
| 1078 | if ((ret = rtmp->on_play_client_pause(res->stream_id, pause->is_pause)) != ERROR_SUCCESS) { | 1074 | if ((ret = rtmp->on_play_client_pause(res->stream_id, pause->is_pause)) != ERROR_SUCCESS) { |
| 1079 | srs_error("rtmp process play client pause failed. ret=%d", ret); | 1075 | srs_error("rtmp process play client pause failed. ret=%d", ret); |
| 1080 | return ret; | 1076 | return ret; |
| @@ -1085,7 +1081,11 @@ int SrsRtmpConn::process_play_control_msg(SrsConsumer* consumer, SrsCommonMessag | @@ -1085,7 +1081,11 @@ int SrsRtmpConn::process_play_control_msg(SrsConsumer* consumer, SrsCommonMessag | ||
| 1085 | return ret; | 1081 | return ret; |
| 1086 | } | 1082 | } |
| 1087 | srs_info("process pause success, is_pause=%d, time=%d.", pause->is_pause, pause->time_ms); | 1083 | srs_info("process pause success, is_pause=%d, time=%d.", pause->is_pause, pause->time_ms); |
| 1084 | + return ret; | ||
| 1085 | + } | ||
| 1088 | 1086 | ||
| 1087 | + // other msg. | ||
| 1088 | + srs_info("ignore all amf0/amf3 command except pause and video control."); | ||
| 1089 | return ret; | 1089 | return ret; |
| 1090 | } | 1090 | } |
| 1091 | 1091 |
| @@ -113,23 +113,23 @@ std::string srs_listener_type2string(SrsListenerType type) | @@ -113,23 +113,23 @@ std::string srs_listener_type2string(SrsListenerType type) | ||
| 113 | } | 113 | } |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | -SrsListener::SrsListener(SrsServer* server, SrsListenerType type) | 116 | +SrsListener::SrsListener(SrsServer* svr, SrsListenerType t) |
| 117 | { | 117 | { |
| 118 | - _port = 0; | ||
| 119 | - _server = server; | ||
| 120 | - _type = type; | 118 | + port = 0; |
| 119 | + server = svr; | ||
| 120 | + type = t; | ||
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | SrsListener::~SrsListener() | 123 | SrsListener::~SrsListener() |
| 124 | { | 124 | { |
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | -SrsListenerType SrsListener::type() | 127 | +SrsListenerType SrsListener::listen_type() |
| 128 | { | 128 | { |
| 129 | - return _type; | 129 | + return type; |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | -SrsStreamListener::SrsStreamListener(SrsServer* server, SrsListenerType type) : SrsListener(server, type) | 132 | +SrsStreamListener::SrsStreamListener(SrsServer* svr, SrsListenerType t) : SrsListener(svr, t) |
| 133 | { | 133 | { |
| 134 | listener = NULL; | 134 | listener = NULL; |
| 135 | } | 135 | } |
| @@ -139,12 +139,12 @@ SrsStreamListener::~SrsStreamListener() | @@ -139,12 +139,12 @@ SrsStreamListener::~SrsStreamListener() | ||
| 139 | srs_freep(listener); | 139 | srs_freep(listener); |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | -int SrsStreamListener::listen(string ip, int port) | 142 | +int SrsStreamListener::listen(string i, int p) |
| 143 | { | 143 | { |
| 144 | int ret = ERROR_SUCCESS; | 144 | int ret = ERROR_SUCCESS; |
| 145 | 145 | ||
| 146 | - _ip = ip; | ||
| 147 | - _port = port; | 146 | + ip = i; |
| 147 | + port = p; | ||
| 148 | 148 | ||
| 149 | srs_freep(listener); | 149 | srs_freep(listener); |
| 150 | listener = new SrsTcpListener(this, ip, port); | 150 | listener = new SrsTcpListener(this, ip, port); |
| @@ -158,7 +158,7 @@ int SrsStreamListener::listen(string ip, int port) | @@ -158,7 +158,7 @@ int SrsStreamListener::listen(string ip, int port) | ||
| 158 | "listen at port=%d, type=%d, fd=%d started success, ep=%s:%d", | 158 | "listen at port=%d, type=%d, fd=%d started success, ep=%s:%d", |
| 159 | pthread->cid(), _srs_context->get_id(), _port, _type, fd, ip.c_str(), port); | 159 | pthread->cid(), _srs_context->get_id(), _port, _type, fd, ip.c_str(), port); |
| 160 | 160 | ||
| 161 | - srs_trace("%s listen at tcp://%s:%d, fd=%d", srs_listener_type2string(_type).c_str(), ip.c_str(), _port, listener->fd()); | 161 | + srs_trace("%s listen at tcp://%s:%d, fd=%d", srs_listener_type2string(type).c_str(), ip.c_str(), port, listener->fd()); |
| 162 | 162 | ||
| 163 | return ret; | 163 | return ret; |
| 164 | } | 164 | } |
| @@ -167,7 +167,7 @@ int SrsStreamListener::on_tcp_client(st_netfd_t stfd) | @@ -167,7 +167,7 @@ int SrsStreamListener::on_tcp_client(st_netfd_t stfd) | ||
| 167 | { | 167 | { |
| 168 | int ret = ERROR_SUCCESS; | 168 | int ret = ERROR_SUCCESS; |
| 169 | 169 | ||
| 170 | - if ((ret = _server->accept_client(_type, stfd)) != ERROR_SUCCESS) { | 170 | + if ((ret = server->accept_client(type, stfd)) != ERROR_SUCCESS) { |
| 171 | srs_warn("accept client error. ret=%d", ret); | 171 | srs_warn("accept client error. ret=%d", ret); |
| 172 | return ret; | 172 | return ret; |
| 173 | } | 173 | } |
| @@ -176,14 +176,14 @@ int SrsStreamListener::on_tcp_client(st_netfd_t stfd) | @@ -176,14 +176,14 @@ int SrsStreamListener::on_tcp_client(st_netfd_t stfd) | ||
| 176 | } | 176 | } |
| 177 | 177 | ||
| 178 | #ifdef SRS_AUTO_STREAM_CASTER | 178 | #ifdef SRS_AUTO_STREAM_CASTER |
| 179 | -SrsRtspListener::SrsRtspListener(SrsServer* server, SrsListenerType type, SrsConfDirective* c) : SrsListener(server, type) | 179 | +SrsRtspListener::SrsRtspListener(SrsServer* svr, SrsListenerType t, SrsConfDirective* c) : SrsListener(svr, t) |
| 180 | { | 180 | { |
| 181 | listener = NULL; | 181 | listener = NULL; |
| 182 | 182 | ||
| 183 | // the caller already ensure the type is ok, | 183 | // the caller already ensure the type is ok, |
| 184 | // we just assert here for unknown stream caster. | 184 | // we just assert here for unknown stream caster. |
| 185 | - srs_assert(_type == SrsListenerRtsp); | ||
| 186 | - if (_type == SrsListenerRtsp) { | 185 | + srs_assert(type == SrsListenerRtsp); |
| 186 | + if (type == SrsListenerRtsp) { | ||
| 187 | caster = new SrsRtspCaster(c); | 187 | caster = new SrsRtspCaster(c); |
| 188 | } | 188 | } |
| 189 | } | 189 | } |
| @@ -194,16 +194,16 @@ SrsRtspListener::~SrsRtspListener() | @@ -194,16 +194,16 @@ SrsRtspListener::~SrsRtspListener() | ||
| 194 | srs_freep(listener); | 194 | srs_freep(listener); |
| 195 | } | 195 | } |
| 196 | 196 | ||
| 197 | -int SrsRtspListener::listen(string ip, int port) | 197 | +int SrsRtspListener::listen(string i, int p) |
| 198 | { | 198 | { |
| 199 | int ret = ERROR_SUCCESS; | 199 | int ret = ERROR_SUCCESS; |
| 200 | 200 | ||
| 201 | // the caller already ensure the type is ok, | 201 | // the caller already ensure the type is ok, |
| 202 | // we just assert here for unknown stream caster. | 202 | // we just assert here for unknown stream caster. |
| 203 | - srs_assert(_type == SrsListenerRtsp); | 203 | + srs_assert(type == SrsListenerRtsp); |
| 204 | 204 | ||
| 205 | - _ip = ip; | ||
| 206 | - _port = port; | 205 | + ip = i; |
| 206 | + port = p; | ||
| 207 | 207 | ||
| 208 | srs_freep(listener); | 208 | srs_freep(listener); |
| 209 | listener = new SrsTcpListener(this, ip, port); | 209 | listener = new SrsTcpListener(this, ip, port); |
| @@ -215,9 +215,9 @@ int SrsRtspListener::listen(string ip, int port) | @@ -215,9 +215,9 @@ int SrsRtspListener::listen(string ip, int port) | ||
| 215 | 215 | ||
| 216 | srs_info("listen thread cid=%d, current_cid=%d, " | 216 | srs_info("listen thread cid=%d, current_cid=%d, " |
| 217 | "listen at port=%d, type=%d, fd=%d started success, ep=%s:%d", | 217 | "listen at port=%d, type=%d, fd=%d started success, ep=%s:%d", |
| 218 | - pthread->cid(), _srs_context->get_id(), _port, _type, fd, ip.c_str(), port); | 218 | + pthread->cid(), _srs_context->get_id(), port, type, fd, ip.c_str(), port); |
| 219 | 219 | ||
| 220 | - srs_trace("%s listen at tcp://%s:%d, fd=%d", srs_listener_type2string(_type).c_str(), ip.c_str(), _port, listener->fd()); | 220 | + srs_trace("%s listen at tcp://%s:%d, fd=%d", srs_listener_type2string(type).c_str(), ip.c_str(), port, listener->fd()); |
| 221 | 221 | ||
| 222 | return ret; | 222 | return ret; |
| 223 | } | 223 | } |
| @@ -234,14 +234,14 @@ int SrsRtspListener::on_tcp_client(st_netfd_t stfd) | @@ -234,14 +234,14 @@ int SrsRtspListener::on_tcp_client(st_netfd_t stfd) | ||
| 234 | return ret; | 234 | return ret; |
| 235 | } | 235 | } |
| 236 | 236 | ||
| 237 | -SrsHttpFlvListener::SrsHttpFlvListener(SrsServer* server, SrsListenerType type, SrsConfDirective* c) : SrsListener(server, type) | 237 | +SrsHttpFlvListener::SrsHttpFlvListener(SrsServer* svr, SrsListenerType t, SrsConfDirective* c) : SrsListener(svr, t) |
| 238 | { | 238 | { |
| 239 | listener = NULL; | 239 | listener = NULL; |
| 240 | 240 | ||
| 241 | // the caller already ensure the type is ok, | 241 | // the caller already ensure the type is ok, |
| 242 | // we just assert here for unknown stream caster. | 242 | // we just assert here for unknown stream caster. |
| 243 | - srs_assert(_type == SrsListenerFlv); | ||
| 244 | - if (_type == SrsListenerFlv) { | 243 | + srs_assert(type == SrsListenerFlv); |
| 244 | + if (type == SrsListenerFlv) { | ||
| 245 | caster = new SrsAppCasterFlv(c); | 245 | caster = new SrsAppCasterFlv(c); |
| 246 | } | 246 | } |
| 247 | } | 247 | } |
| @@ -252,16 +252,16 @@ SrsHttpFlvListener::~SrsHttpFlvListener() | @@ -252,16 +252,16 @@ SrsHttpFlvListener::~SrsHttpFlvListener() | ||
| 252 | srs_freep(listener); | 252 | srs_freep(listener); |
| 253 | } | 253 | } |
| 254 | 254 | ||
| 255 | -int SrsHttpFlvListener::listen(string ip, int port) | 255 | +int SrsHttpFlvListener::listen(string i, int p) |
| 256 | { | 256 | { |
| 257 | int ret = ERROR_SUCCESS; | 257 | int ret = ERROR_SUCCESS; |
| 258 | 258 | ||
| 259 | // the caller already ensure the type is ok, | 259 | // the caller already ensure the type is ok, |
| 260 | // we just assert here for unknown stream caster. | 260 | // we just assert here for unknown stream caster. |
| 261 | - srs_assert(_type == SrsListenerFlv); | 261 | + srs_assert(type == SrsListenerFlv); |
| 262 | 262 | ||
| 263 | - _ip = ip; | ||
| 264 | - _port = port; | 263 | + ip = i; |
| 264 | + port = p; | ||
| 265 | 265 | ||
| 266 | if ((ret = caster->initialize()) != ERROR_SUCCESS) { | 266 | if ((ret = caster->initialize()) != ERROR_SUCCESS) { |
| 267 | return ret; | 267 | return ret; |
| @@ -277,9 +277,9 @@ int SrsHttpFlvListener::listen(string ip, int port) | @@ -277,9 +277,9 @@ int SrsHttpFlvListener::listen(string ip, int port) | ||
| 277 | 277 | ||
| 278 | srs_info("listen thread cid=%d, current_cid=%d, " | 278 | srs_info("listen thread cid=%d, current_cid=%d, " |
| 279 | "listen at port=%d, type=%d, fd=%d started success, ep=%s:%d", | 279 | "listen at port=%d, type=%d, fd=%d started success, ep=%s:%d", |
| 280 | - pthread->cid(), _srs_context->get_id(), _port, _type, fd, ip.c_str(), port); | 280 | + pthread->cid(), _srs_context->get_id(), port, type, fd, ip.c_str(), port); |
| 281 | 281 | ||
| 282 | - srs_trace("%s listen at tcp://%s:%d, fd=%d", srs_listener_type2string(_type).c_str(), ip.c_str(), _port, listener->fd()); | 282 | + srs_trace("%s listen at tcp://%s:%d, fd=%d", srs_listener_type2string(type).c_str(), ip.c_str(), port, listener->fd()); |
| 283 | 283 | ||
| 284 | return ret; | 284 | return ret; |
| 285 | } | 285 | } |
| @@ -295,36 +295,29 @@ int SrsHttpFlvListener::on_tcp_client(st_netfd_t stfd) | @@ -295,36 +295,29 @@ int SrsHttpFlvListener::on_tcp_client(st_netfd_t stfd) | ||
| 295 | 295 | ||
| 296 | return ret; | 296 | return ret; |
| 297 | } | 297 | } |
| 298 | +#endif | ||
| 298 | 299 | ||
| 299 | -SrsUdpCasterListener::SrsUdpCasterListener(SrsServer* server, SrsListenerType type, SrsConfDirective* c) : SrsListener(server, type) | 300 | +SrsUdpStreamListener::SrsUdpStreamListener(SrsServer* svr, SrsListenerType t, ISrsUdpHandler* c) : SrsListener(svr, t) |
| 300 | { | 301 | { |
| 301 | - _type = type; | ||
| 302 | listener = NULL; | 302 | listener = NULL; |
| 303 | - | ||
| 304 | - // the caller already ensure the type is ok, | ||
| 305 | - // we just assert here for unknown stream caster. | ||
| 306 | - srs_assert(_type == SrsListenerMpegTsOverUdp); | ||
| 307 | - if (_type == SrsListenerMpegTsOverUdp) { | ||
| 308 | - caster = new SrsMpegtsOverUdp(c); | ||
| 309 | - } | 303 | + caster = c; |
| 310 | } | 304 | } |
| 311 | 305 | ||
| 312 | -SrsUdpCasterListener::~SrsUdpCasterListener() | 306 | +SrsUdpStreamListener::~SrsUdpStreamListener() |
| 313 | { | 307 | { |
| 314 | - srs_freep(caster); | ||
| 315 | srs_freep(listener); | 308 | srs_freep(listener); |
| 316 | } | 309 | } |
| 317 | 310 | ||
| 318 | -int SrsUdpCasterListener::listen(string ip, int port) | 311 | +int SrsUdpStreamListener::listen(string i, int p) |
| 319 | { | 312 | { |
| 320 | int ret = ERROR_SUCCESS; | 313 | int ret = ERROR_SUCCESS; |
| 321 | 314 | ||
| 322 | // the caller already ensure the type is ok, | 315 | // the caller already ensure the type is ok, |
| 323 | // we just assert here for unknown stream caster. | 316 | // we just assert here for unknown stream caster. |
| 324 | - srs_assert(_type == SrsListenerMpegTsOverUdp); | 317 | + srs_assert(type == SrsListenerMpegTsOverUdp); |
| 325 | 318 | ||
| 326 | - _ip = ip; | ||
| 327 | - _port = port; | 319 | + ip = i; |
| 320 | + port = p; | ||
| 328 | 321 | ||
| 329 | srs_freep(listener); | 322 | srs_freep(listener); |
| 330 | listener = new SrsUdpListener(caster, ip, port); | 323 | listener = new SrsUdpListener(caster, ip, port); |
| @@ -336,12 +329,28 @@ int SrsUdpCasterListener::listen(string ip, int port) | @@ -336,12 +329,28 @@ int SrsUdpCasterListener::listen(string ip, int port) | ||
| 336 | 329 | ||
| 337 | srs_info("listen thread cid=%d, current_cid=%d, " | 330 | srs_info("listen thread cid=%d, current_cid=%d, " |
| 338 | "listen at port=%d, type=%d, fd=%d started success, ep=%s:%d", | 331 | "listen at port=%d, type=%d, fd=%d started success, ep=%s:%d", |
| 339 | - pthread->cid(), _srs_context->get_id(), _port, _type, fd, ip.c_str(), port); | 332 | + pthread->cid(), _srs_context->get_id(), port, type, fd, ip.c_str(), port); |
| 340 | 333 | ||
| 341 | - srs_trace("%s listen at udp://%s:%d, fd=%d", srs_listener_type2string(_type).c_str(), ip.c_str(), _port, listener->fd()); | 334 | + srs_trace("%s listen at udp://%s:%d, fd=%d", srs_listener_type2string(type).c_str(), ip.c_str(), port, listener->fd()); |
| 342 | 335 | ||
| 343 | return ret; | 336 | return ret; |
| 344 | } | 337 | } |
| 338 | + | ||
| 339 | +#ifdef SRS_AUTO_STREAM_CASTER | ||
| 340 | +SrsUdpCasterListener::SrsUdpCasterListener(SrsServer* svr, SrsListenerType t, SrsConfDirective* c) : SrsUdpStreamListener(svr, t, NULL) | ||
| 341 | +{ | ||
| 342 | + // the caller already ensure the type is ok, | ||
| 343 | + // we just assert here for unknown stream caster. | ||
| 344 | + srs_assert(type == SrsListenerMpegTsOverUdp); | ||
| 345 | + if (type == SrsListenerMpegTsOverUdp) { | ||
| 346 | + caster = new SrsMpegtsOverUdp(c); | ||
| 347 | + } | ||
| 348 | +} | ||
| 349 | + | ||
| 350 | +SrsUdpCasterListener::~SrsUdpCasterListener() | ||
| 351 | +{ | ||
| 352 | + srs_freep(caster); | ||
| 353 | +} | ||
| 345 | #endif | 354 | #endif |
| 346 | 355 | ||
| 347 | SrsSignalManager* SrsSignalManager::instance = NULL; | 356 | SrsSignalManager* SrsSignalManager::instance = NULL; |
| @@ -588,6 +597,34 @@ int SrsServer::initialize(ISrsServerCycle* cycle_handler) | @@ -588,6 +597,34 @@ int SrsServer::initialize(ISrsServerCycle* cycle_handler) | ||
| 588 | return ret; | 597 | return ret; |
| 589 | } | 598 | } |
| 590 | 599 | ||
| 600 | +int SrsServer::initialize_st() | ||
| 601 | +{ | ||
| 602 | + int ret = ERROR_SUCCESS; | ||
| 603 | + | ||
| 604 | + // init st | ||
| 605 | + if ((ret = srs_init_st()) != ERROR_SUCCESS) { | ||
| 606 | + srs_error("init st failed. ret=%d", ret); | ||
| 607 | + return ret; | ||
| 608 | + } | ||
| 609 | + | ||
| 610 | + // @remark, st alloc segment use mmap, which only support 32757 threads, | ||
| 611 | + // if need to support more, for instance, 100k threads, define the macro MALLOC_STACK. | ||
| 612 | + // TODO: FIXME: maybe can use "sysctl vm.max_map_count" to refine. | ||
| 613 | + if (_srs_config->get_max_connections() > 32756) { | ||
| 614 | + ret = ERROR_ST_EXCEED_THREADS; | ||
| 615 | + srs_error("st mmap for stack allocation must <= %d threads, " | ||
| 616 | + "@see Makefile of st for MALLOC_STACK, please build st manually by " | ||
| 617 | + "\"make EXTRA_CFLAGS=-DMALLOC_STACK linux-debug\", ret=%d", ret); | ||
| 618 | + return ret; | ||
| 619 | + } | ||
| 620 | + | ||
| 621 | + // set current log id. | ||
| 622 | + _srs_context->generate_id(); | ||
| 623 | + srs_trace("server main cid=%d", _srs_context->get_id()); | ||
| 624 | + | ||
| 625 | + return ret; | ||
| 626 | +} | ||
| 627 | + | ||
| 591 | int SrsServer::initialize_signal() | 628 | int SrsServer::initialize_signal() |
| 592 | { | 629 | { |
| 593 | return signal_manager->initialize(); | 630 | return signal_manager->initialize(); |
| @@ -669,34 +706,6 @@ int SrsServer::acquire_pid_file() | @@ -669,34 +706,6 @@ int SrsServer::acquire_pid_file() | ||
| 669 | return ret; | 706 | return ret; |
| 670 | } | 707 | } |
| 671 | 708 | ||
| 672 | -int SrsServer::initialize_st() | ||
| 673 | -{ | ||
| 674 | - int ret = ERROR_SUCCESS; | ||
| 675 | - | ||
| 676 | - // init st | ||
| 677 | - if ((ret = srs_init_st()) != ERROR_SUCCESS) { | ||
| 678 | - srs_error("init st failed. ret=%d", ret); | ||
| 679 | - return ret; | ||
| 680 | - } | ||
| 681 | - | ||
| 682 | - // @remark, st alloc segment use mmap, which only support 32757 threads, | ||
| 683 | - // if need to support more, for instance, 100k threads, define the macro MALLOC_STACK. | ||
| 684 | - // TODO: FIXME: maybe can use "sysctl vm.max_map_count" to refine. | ||
| 685 | - if (_srs_config->get_max_connections() > 32756) { | ||
| 686 | - ret = ERROR_ST_EXCEED_THREADS; | ||
| 687 | - srs_error("st mmap for stack allocation must <= %d threads, " | ||
| 688 | - "@see Makefile of st for MALLOC_STACK, please build st manually by " | ||
| 689 | - "\"make EXTRA_CFLAGS=-DMALLOC_STACK linux-debug\", ret=%d", ret); | ||
| 690 | - return ret; | ||
| 691 | - } | ||
| 692 | - | ||
| 693 | - // set current log id. | ||
| 694 | - _srs_context->generate_id(); | ||
| 695 | - srs_trace("server main cid=%d", _srs_context->get_id()); | ||
| 696 | - | ||
| 697 | - return ret; | ||
| 698 | -} | ||
| 699 | - | ||
| 700 | int SrsServer::listen() | 709 | int SrsServer::listen() |
| 701 | { | 710 | { |
| 702 | int ret = ERROR_SUCCESS; | 711 | int ret = ERROR_SUCCESS; |
| @@ -959,6 +968,7 @@ int SrsServer::do_cycle() | @@ -959,6 +968,7 @@ int SrsServer::do_cycle() | ||
| 959 | } | 968 | } |
| 960 | #endif | 969 | #endif |
| 961 | #endif | 970 | #endif |
| 971 | + | ||
| 962 | srs_info("server main thread loop"); | 972 | srs_info("server main thread loop"); |
| 963 | } | 973 | } |
| 964 | } | 974 | } |
| @@ -1103,7 +1113,7 @@ void SrsServer::close_listeners(SrsListenerType type) | @@ -1103,7 +1113,7 @@ void SrsServer::close_listeners(SrsListenerType type) | ||
| 1103 | for (it = listeners.begin(); it != listeners.end();) { | 1113 | for (it = listeners.begin(); it != listeners.end();) { |
| 1104 | SrsListener* listener = *it; | 1114 | SrsListener* listener = *it; |
| 1105 | 1115 | ||
| 1106 | - if (listener->type() != type) { | 1116 | + if (listener->listen_type() != type) { |
| 1107 | ++it; | 1117 | ++it; |
| 1108 | continue; | 1118 | continue; |
| 1109 | } | 1119 | } |
| @@ -80,17 +80,17 @@ enum SrsListenerType | @@ -80,17 +80,17 @@ enum SrsListenerType | ||
| 80 | class SrsListener | 80 | class SrsListener |
| 81 | { | 81 | { |
| 82 | protected: | 82 | protected: |
| 83 | - SrsListenerType _type; | 83 | + SrsListenerType type; |
| 84 | protected: | 84 | protected: |
| 85 | - std::string _ip; | ||
| 86 | - int _port; | ||
| 87 | - SrsServer* _server; | 85 | + std::string ip; |
| 86 | + int port; | ||
| 87 | + SrsServer* server; | ||
| 88 | public: | 88 | public: |
| 89 | - SrsListener(SrsServer* server, SrsListenerType type); | 89 | + SrsListener(SrsServer* svr, SrsListenerType t); |
| 90 | virtual ~SrsListener(); | 90 | virtual ~SrsListener(); |
| 91 | public: | 91 | public: |
| 92 | - virtual SrsListenerType type(); | ||
| 93 | - virtual int listen(std::string ip, int port) = 0; | 92 | + virtual SrsListenerType listen_type(); |
| 93 | + virtual int listen(std::string i, int p) = 0; | ||
| 94 | }; | 94 | }; |
| 95 | 95 | ||
| 96 | /** | 96 | /** |
| @@ -120,10 +120,10 @@ private: | @@ -120,10 +120,10 @@ private: | ||
| 120 | SrsTcpListener* listener; | 120 | SrsTcpListener* listener; |
| 121 | ISrsTcpHandler* caster; | 121 | ISrsTcpHandler* caster; |
| 122 | public: | 122 | public: |
| 123 | - SrsRtspListener(SrsServer* server, SrsListenerType type, SrsConfDirective* c); | 123 | + SrsRtspListener(SrsServer* svr, SrsListenerType t, SrsConfDirective* c); |
| 124 | virtual ~SrsRtspListener(); | 124 | virtual ~SrsRtspListener(); |
| 125 | public: | 125 | public: |
| 126 | - virtual int listen(std::string ip, int port); | 126 | + virtual int listen(std::string i, int p); |
| 127 | // ISrsTcpHandler | 127 | // ISrsTcpHandler |
| 128 | public: | 128 | public: |
| 129 | virtual int on_tcp_client(st_netfd_t stfd); | 129 | virtual int on_tcp_client(st_netfd_t stfd); |
| @@ -138,28 +138,40 @@ private: | @@ -138,28 +138,40 @@ private: | ||
| 138 | SrsTcpListener* listener; | 138 | SrsTcpListener* listener; |
| 139 | SrsAppCasterFlv* caster; | 139 | SrsAppCasterFlv* caster; |
| 140 | public: | 140 | public: |
| 141 | - SrsHttpFlvListener(SrsServer* server, SrsListenerType type, SrsConfDirective* c); | 141 | + SrsHttpFlvListener(SrsServer* svr, SrsListenerType t, SrsConfDirective* c); |
| 142 | virtual ~SrsHttpFlvListener(); | 142 | virtual ~SrsHttpFlvListener(); |
| 143 | public: | 143 | public: |
| 144 | - virtual int listen(std::string ip, int port); | 144 | + virtual int listen(std::string i, int p); |
| 145 | // ISrsTcpHandler | 145 | // ISrsTcpHandler |
| 146 | public: | 146 | public: |
| 147 | virtual int on_tcp_client(st_netfd_t stfd); | 147 | virtual int on_tcp_client(st_netfd_t stfd); |
| 148 | }; | 148 | }; |
| 149 | +#endif | ||
| 149 | 150 | ||
| 150 | /** | 151 | /** |
| 151 | -* the udp listener, for udp server. | ||
| 152 | -*/ | ||
| 153 | -class SrsUdpCasterListener : public SrsListener | 152 | + * the udp listener, for udp server. |
| 153 | + */ | ||
| 154 | +class SrsUdpStreamListener : public SrsListener | ||
| 154 | { | 155 | { |
| 155 | -private: | 156 | +protected: |
| 156 | SrsUdpListener* listener; | 157 | SrsUdpListener* listener; |
| 157 | ISrsUdpHandler* caster; | 158 | ISrsUdpHandler* caster; |
| 158 | public: | 159 | public: |
| 159 | - SrsUdpCasterListener(SrsServer* server, SrsListenerType type, SrsConfDirective* c); | ||
| 160 | - virtual ~SrsUdpCasterListener(); | 160 | + SrsUdpStreamListener(SrsServer* svr, SrsListenerType t, ISrsUdpHandler* c); |
| 161 | + virtual ~SrsUdpStreamListener(); | ||
| 161 | public: | 162 | public: |
| 162 | - virtual int listen(std::string ip, int port); | 163 | + virtual int listen(std::string i, int p); |
| 164 | +}; | ||
| 165 | + | ||
| 166 | +/** | ||
| 167 | + * the udp listener, for udp stream caster server. | ||
| 168 | + */ | ||
| 169 | +#ifdef SRS_AUTO_STREAM_CASTER | ||
| 170 | +class SrsUdpCasterListener : public SrsUdpStreamListener | ||
| 171 | +{ | ||
| 172 | +public: | ||
| 173 | + SrsUdpCasterListener(SrsServer* svr, SrsListenerType t, SrsConfDirective* c); | ||
| 174 | + virtual ~SrsUdpCasterListener(); | ||
| 163 | }; | 175 | }; |
| 164 | #endif | 176 | #endif |
| 165 | 177 | ||
| @@ -337,7 +349,7 @@ public: | @@ -337,7 +349,7 @@ public: | ||
| 337 | * @param client_stfd, the client fd in st boxed, the underlayer fd. | 349 | * @param client_stfd, the client fd in st boxed, the underlayer fd. |
| 338 | */ | 350 | */ |
| 339 | virtual int accept_client(SrsListenerType type, st_netfd_t client_stfd); | 351 | virtual int accept_client(SrsListenerType type, st_netfd_t client_stfd); |
| 340 | -// interface ISrsThreadHandler. | 352 | +// interface ISrsReloadHandler. |
| 341 | public: | 353 | public: |
| 342 | virtual int on_reload_listen(); | 354 | virtual int on_reload_listen(); |
| 343 | virtual int on_reload_pid(); | 355 | virtual int on_reload_pid(); |
| @@ -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 162 | 34 | +#define VERSION_REVISION 163 |
| 35 | 35 | ||
| 36 | // server info. | 36 | // server info. |
| 37 | #define RTMP_SIG_SRS_KEY "SRS" | 37 | #define RTMP_SIG_SRS_KEY "SRS" |
| @@ -723,8 +723,8 @@ int SrsIngestSrsOutput::on_ts_message(SrsTsMessage* msg) | @@ -723,8 +723,8 @@ int SrsIngestSrsOutput::on_ts_message(SrsTsMessage* msg) | ||
| 723 | // because when audio stream_number is 0, the elementary is ADTS(aac-mp4a-format-ISO_IEC_14496-3+2001.pdf, page 75, 1.A.2.2 ADTS). | 723 | // because when audio stream_number is 0, the elementary is ADTS(aac-mp4a-format-ISO_IEC_14496-3+2001.pdf, page 75, 1.A.2.2 ADTS). |
| 724 | 724 | ||
| 725 | // about the bytes of PES_packet_data_byte, defined in hls-mpeg-ts-iso13818-1.pdf, page 58 | 725 | // about the bytes of PES_packet_data_byte, defined in hls-mpeg-ts-iso13818-1.pdf, page 58 |
| 726 | - // PES_packet_data_byte "C PES_packet_data_bytes shall be contiguous bytes of data from the elementary stream | ||
| 727 | - // indicated by the packets stream_id or PID. When the elementary stream data conforms to ITU-T | 726 | + // PES_packet_data_byte ¨C PES_packet_data_bytes shall be contiguous bytes of data from the elementary stream |
| 727 | + // indicated by the packet¡¯s stream_id or PID. When the elementary stream data conforms to ITU-T | ||
| 728 | // Rec. H.262 | ISO/IEC 13818-2 or ISO/IEC 13818-3, the PES_packet_data_bytes shall be byte aligned to the bytes of this | 728 | // Rec. H.262 | ISO/IEC 13818-2 or ISO/IEC 13818-3, the PES_packet_data_bytes shall be byte aligned to the bytes of this |
| 729 | // Recommendation | International Standard. The byte-order of the elementary stream shall be preserved. The number of | 729 | // Recommendation | International Standard. The byte-order of the elementary stream shall be preserved. The number of |
| 730 | // PES_packet_data_bytes, N, is specified by the PES_packet_length field. N shall be equal to the value indicated in the | 730 | // PES_packet_data_bytes, N, is specified by the PES_packet_length field. N shall be equal to the value indicated in the |
| @@ -735,12 +735,12 @@ int SrsIngestSrsOutput::on_ts_message(SrsTsMessage* msg) | @@ -735,12 +735,12 @@ int SrsIngestSrsOutput::on_ts_message(SrsTsMessage* msg) | ||
| 735 | // PES_packet_data_byte field are user definable and will not be specified by ITU-T | ISO/IEC in the future. | 735 | // PES_packet_data_byte field are user definable and will not be specified by ITU-T | ISO/IEC in the future. |
| 736 | 736 | ||
| 737 | // about the bytes of stream_id, define in hls-mpeg-ts-iso13818-1.pdf, page 49 | 737 | // about the bytes of stream_id, define in hls-mpeg-ts-iso13818-1.pdf, page 49 |
| 738 | - // stream_id "C In Program Streams, the stream_id specifies the type and number of the elementary stream as defined by the | 738 | + // stream_id ¨C In Program Streams, the stream_id specifies the type and number of the elementary stream as defined by the |
| 739 | // stream_id Table 2-18. In Transport Streams, the stream_id may be set to any valid value which correctly describes the | 739 | // stream_id Table 2-18. In Transport Streams, the stream_id may be set to any valid value which correctly describes the |
| 740 | // elementary stream type as defined in Table 2-18. In Transport Streams, the elementary stream type is specified in the | 740 | // elementary stream type as defined in Table 2-18. In Transport Streams, the elementary stream type is specified in the |
| 741 | // Program Specific Information as specified in 2.4.4. | 741 | // Program Specific Information as specified in 2.4.4. |
| 742 | 742 | ||
| 743 | - // about the stream_id table, define in Table 2-18 "C Stream_id assignments, hls-mpeg-ts-iso13818-1.pdf, page 52. | 743 | + // about the stream_id table, define in Table 2-18 ¨C Stream_id assignments, hls-mpeg-ts-iso13818-1.pdf, page 52. |
| 744 | // | 744 | // |
| 745 | // 110x xxxx | 745 | // 110x xxxx |
| 746 | // ISO/IEC 13818-3 or ISO/IEC 11172-3 or ISO/IEC 13818-7 or ISO/IEC | 746 | // ISO/IEC 13818-3 or ISO/IEC 11172-3 or ISO/IEC 13818-7 or ISO/IEC |
| @@ -344,15 +344,15 @@ int run_master() | @@ -344,15 +344,15 @@ int run_master() | ||
| 344 | { | 344 | { |
| 345 | int ret = ERROR_SUCCESS; | 345 | int ret = ERROR_SUCCESS; |
| 346 | 346 | ||
| 347 | - if ((ret = _srs_server->initialize_signal()) != ERROR_SUCCESS) { | 347 | + if ((ret = _srs_server->initialize_st()) != ERROR_SUCCESS) { |
| 348 | return ret; | 348 | return ret; |
| 349 | } | 349 | } |
| 350 | 350 | ||
| 351 | - if ((ret = _srs_server->acquire_pid_file()) != ERROR_SUCCESS) { | 351 | + if ((ret = _srs_server->initialize_signal()) != ERROR_SUCCESS) { |
| 352 | return ret; | 352 | return ret; |
| 353 | } | 353 | } |
| 354 | 354 | ||
| 355 | - if ((ret = _srs_server->initialize_st()) != ERROR_SUCCESS) { | 355 | + if ((ret = _srs_server->acquire_pid_file()) != ERROR_SUCCESS) { |
| 356 | return ret; | 356 | return ret; |
| 357 | } | 357 | } |
| 358 | 358 |
| @@ -38,36 +38,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -38,36 +38,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 38 | 38 | ||
| 39 | using namespace std; | 39 | using namespace std; |
| 40 | 40 | ||
| 41 | -/** | ||
| 42 | -* the signature for packets to client. | ||
| 43 | -*/ | ||
| 44 | -#define RTMP_SIG_FMS_VER "3,5,3,888" | ||
| 45 | -#define RTMP_SIG_AMF0_VER 0 | ||
| 46 | -#define RTMP_SIG_CLIENT_ID "ASAICiss" | ||
| 47 | - | ||
| 48 | -/** | ||
| 49 | -* onStatus consts. | ||
| 50 | -*/ | ||
| 51 | -#define StatusLevel "level" | ||
| 52 | -#define StatusCode "code" | ||
| 53 | -#define StatusDescription "description" | ||
| 54 | -#define StatusDetails "details" | ||
| 55 | -#define StatusClientId "clientid" | ||
| 56 | -// status value | ||
| 57 | -#define StatusLevelStatus "status" | ||
| 58 | -// status error | ||
| 59 | -#define StatusLevelError "error" | ||
| 60 | -// code value | ||
| 61 | -#define StatusCodeConnectSuccess "NetConnection.Connect.Success" | ||
| 62 | -#define StatusCodeConnectRejected "NetConnection.Connect.Rejected" | ||
| 63 | -#define StatusCodeStreamReset "NetStream.Play.Reset" | ||
| 64 | -#define StatusCodeStreamStart "NetStream.Play.Start" | ||
| 65 | -#define StatusCodeStreamPause "NetStream.Pause.Notify" | ||
| 66 | -#define StatusCodeStreamUnpause "NetStream.Unpause.Notify" | ||
| 67 | -#define StatusCodePublishStart "NetStream.Publish.Start" | ||
| 68 | -#define StatusCodeDataStart "NetStream.Data.Start" | ||
| 69 | -#define StatusCodeUnpublishSuccess "NetStream.Unpublish.Success" | ||
| 70 | - | ||
| 71 | // FMLE | 41 | // FMLE |
| 72 | #define RTMP_AMF0_COMMAND_ON_FC_PUBLISH "onFCPublish" | 42 | #define RTMP_AMF0_COMMAND_ON_FC_PUBLISH "onFCPublish" |
| 73 | #define RTMP_AMF0_COMMAND_ON_FC_UNPUBLISH "onFCUnpublish" | 43 | #define RTMP_AMF0_COMMAND_ON_FC_UNPUBLISH "onFCUnpublish" |
| @@ -49,6 +49,36 @@ class SrsAmf0Object; | @@ -49,6 +49,36 @@ class SrsAmf0Object; | ||
| 49 | class IMergeReadHandler; | 49 | class IMergeReadHandler; |
| 50 | 50 | ||
| 51 | /** | 51 | /** |
| 52 | + * the signature for packets to client. | ||
| 53 | + */ | ||
| 54 | +#define RTMP_SIG_FMS_VER "3,5,3,888" | ||
| 55 | +#define RTMP_SIG_AMF0_VER 0 | ||
| 56 | +#define RTMP_SIG_CLIENT_ID "ASAICiss" | ||
| 57 | + | ||
| 58 | +/** | ||
| 59 | + * onStatus consts. | ||
| 60 | + */ | ||
| 61 | +#define StatusLevel "level" | ||
| 62 | +#define StatusCode "code" | ||
| 63 | +#define StatusDescription "description" | ||
| 64 | +#define StatusDetails "details" | ||
| 65 | +#define StatusClientId "clientid" | ||
| 66 | +// status value | ||
| 67 | +#define StatusLevelStatus "status" | ||
| 68 | +// status error | ||
| 69 | +#define StatusLevelError "error" | ||
| 70 | +// code value | ||
| 71 | +#define StatusCodeConnectSuccess "NetConnection.Connect.Success" | ||
| 72 | +#define StatusCodeConnectRejected "NetConnection.Connect.Rejected" | ||
| 73 | +#define StatusCodeStreamReset "NetStream.Play.Reset" | ||
| 74 | +#define StatusCodeStreamStart "NetStream.Play.Start" | ||
| 75 | +#define StatusCodeStreamPause "NetStream.Pause.Notify" | ||
| 76 | +#define StatusCodeStreamUnpause "NetStream.Unpause.Notify" | ||
| 77 | +#define StatusCodePublishStart "NetStream.Publish.Start" | ||
| 78 | +#define StatusCodeDataStart "NetStream.Data.Start" | ||
| 79 | +#define StatusCodeUnpublishSuccess "NetStream.Unpublish.Success" | ||
| 80 | + | ||
| 81 | +/** | ||
| 52 | * the original request from client. | 82 | * the original request from client. |
| 53 | */ | 83 | */ |
| 54 | class SrsRequest | 84 | class SrsRequest |
| @@ -47,89 +47,6 @@ using namespace std; | @@ -47,89 +47,6 @@ using namespace std; | ||
| 47 | ***************************************************************************** | 47 | ***************************************************************************** |
| 48 | ****************************************************************************/ | 48 | ****************************************************************************/ |
| 49 | /** | 49 | /** |
| 50 | -5. Protocol Control Messages | ||
| 51 | -RTMP reserves message type IDs 1-7 for protocol control messages. | ||
| 52 | -These messages contain information needed by the RTM Chunk Stream | ||
| 53 | -protocol or RTMP itself. Protocol messages with IDs 1 & 2 are | ||
| 54 | -reserved for usage with RTM Chunk Stream protocol. Protocol messages | ||
| 55 | -with IDs 3-6 are reserved for usage of RTMP. Protocol message with ID | ||
| 56 | -7 is used between edge server and origin server. | ||
| 57 | -*/ | ||
| 58 | -#define RTMP_MSG_SetChunkSize 0x01 | ||
| 59 | -#define RTMP_MSG_AbortMessage 0x02 | ||
| 60 | -#define RTMP_MSG_Acknowledgement 0x03 | ||
| 61 | -#define RTMP_MSG_UserControlMessage 0x04 | ||
| 62 | -#define RTMP_MSG_WindowAcknowledgementSize 0x05 | ||
| 63 | -#define RTMP_MSG_SetPeerBandwidth 0x06 | ||
| 64 | -#define RTMP_MSG_EdgeAndOriginServerCommand 0x07 | ||
| 65 | -/** | ||
| 66 | -3. Types of messages | ||
| 67 | -The server and the client send messages over the network to | ||
| 68 | -communicate with each other. The messages can be of any type which | ||
| 69 | -includes audio messages, video messages, command messages, shared | ||
| 70 | -object messages, data messages, and user control messages. | ||
| 71 | -3.1. Command message | ||
| 72 | -Command messages carry the AMF-encoded commands between the client | ||
| 73 | -and the server. These messages have been assigned message type value | ||
| 74 | -of 20 for AMF0 encoding and message type value of 17 for AMF3 | ||
| 75 | -encoding. These messages are sent to perform some operations like | ||
| 76 | -connect, createStream, publish, play, pause on the peer. Command | ||
| 77 | -messages like onstatus, result etc. are used to inform the sender | ||
| 78 | -about the status of the requested commands. A command message | ||
| 79 | -consists of command name, transaction ID, and command object that | ||
| 80 | -contains related parameters. A client or a server can request Remote | ||
| 81 | -Procedure Calls (RPC) over streams that are communicated using the | ||
| 82 | -command messages to the peer. | ||
| 83 | -*/ | ||
| 84 | -#define RTMP_MSG_AMF3CommandMessage 17 // 0x11 | ||
| 85 | -#define RTMP_MSG_AMF0CommandMessage 20 // 0x14 | ||
| 86 | -/** | ||
| 87 | -3.2. Data message | ||
| 88 | -The client or the server sends this message to send Metadata or any | ||
| 89 | -user data to the peer. Metadata includes details about the | ||
| 90 | -data(audio, video etc.) like creation time, duration, theme and so | ||
| 91 | -on. These messages have been assigned message type value of 18 for | ||
| 92 | -AMF0 and message type value of 15 for AMF3. | ||
| 93 | -*/ | ||
| 94 | -#define RTMP_MSG_AMF0DataMessage 18 // 0x12 | ||
| 95 | -#define RTMP_MSG_AMF3DataMessage 15 // 0x0F | ||
| 96 | -/** | ||
| 97 | -3.3. Shared object message | ||
| 98 | -A shared object is a Flash object (a collection of name value pairs) | ||
| 99 | -that are in synchronization across multiple clients, instances, and | ||
| 100 | -so on. The message types kMsgContainer=19 for AMF0 and | ||
| 101 | -kMsgContainerEx=16 for AMF3 are reserved for shared object events. | ||
| 102 | -Each message can contain multiple events. | ||
| 103 | -*/ | ||
| 104 | -#define RTMP_MSG_AMF3SharedObject 16 // 0x10 | ||
| 105 | -#define RTMP_MSG_AMF0SharedObject 19 // 0x13 | ||
| 106 | -/** | ||
| 107 | -3.4. Audio message | ||
| 108 | -The client or the server sends this message to send audio data to the | ||
| 109 | -peer. The message type value of 8 is reserved for audio messages. | ||
| 110 | -*/ | ||
| 111 | -#define RTMP_MSG_AudioMessage 8 // 0x08 | ||
| 112 | -/* * | ||
| 113 | -3.5. Video message | ||
| 114 | -The client or the server sends this message to send video data to the | ||
| 115 | -peer. The message type value of 9 is reserved for video messages. | ||
| 116 | -These messages are large and can delay the sending of other type of | ||
| 117 | -messages. To avoid such a situation, the video message is assigned | ||
| 118 | -the lowest priority. | ||
| 119 | -*/ | ||
| 120 | -#define RTMP_MSG_VideoMessage 9 // 0x09 | ||
| 121 | -/** | ||
| 122 | -3.6. Aggregate message | ||
| 123 | -An aggregate message is a single message that contains a list of submessages. | ||
| 124 | -The message type value of 22 is reserved for aggregate | ||
| 125 | -messages. | ||
| 126 | -*/ | ||
| 127 | -#define RTMP_MSG_AggregateMessage 22 // 0x16 | ||
| 128 | - | ||
| 129 | -/**************************************************************************** | ||
| 130 | -***************************************************************************** | ||
| 131 | -****************************************************************************/ | ||
| 132 | -/** | ||
| 133 | * 6.1.2. Chunk Message Header | 50 | * 6.1.2. Chunk Message Header |
| 134 | * There are four different formats for the chunk message header, | 51 | * There are four different formats for the chunk message header, |
| 135 | * selected by the "fmt" field in the chunk basic header. | 52 | * selected by the "fmt" field in the chunk basic header. |
| @@ -173,24 +90,6 @@ messages. | @@ -173,24 +90,6 @@ messages. | ||
| 173 | ***************************************************************************** | 90 | ***************************************************************************** |
| 174 | ****************************************************************************/ | 91 | ****************************************************************************/ |
| 175 | /** | 92 | /** |
| 176 | -* amf0 command message, command name macros | ||
| 177 | -*/ | ||
| 178 | -#define RTMP_AMF0_COMMAND_CONNECT "connect" | ||
| 179 | -#define RTMP_AMF0_COMMAND_CREATE_STREAM "createStream" | ||
| 180 | -#define RTMP_AMF0_COMMAND_CLOSE_STREAM "closeStream" | ||
| 181 | -#define RTMP_AMF0_COMMAND_PLAY "play" | ||
| 182 | -#define RTMP_AMF0_COMMAND_PAUSE "pause" | ||
| 183 | -#define RTMP_AMF0_COMMAND_ON_BW_DONE "onBWDone" | ||
| 184 | -#define RTMP_AMF0_COMMAND_ON_STATUS "onStatus" | ||
| 185 | -#define RTMP_AMF0_COMMAND_RESULT "_result" | ||
| 186 | -#define RTMP_AMF0_COMMAND_ERROR "_error" | ||
| 187 | -#define RTMP_AMF0_COMMAND_RELEASE_STREAM "releaseStream" | ||
| 188 | -#define RTMP_AMF0_COMMAND_FC_PUBLISH "FCPublish" | ||
| 189 | -#define RTMP_AMF0_COMMAND_UNPUBLISH "FCUnpublish" | ||
| 190 | -#define RTMP_AMF0_COMMAND_PUBLISH "publish" | ||
| 191 | -#define RTMP_AMF0_DATA_SAMPLE_ACCESS "|RtmpSampleAccess" | ||
| 192 | - | ||
| 193 | -/** | ||
| 194 | * band width check method name, which will be invoked by client. | 93 | * band width check method name, which will be invoked by client. |
| 195 | * band width check mothods use SrsBandwidthPacket as its internal packet type, | 94 | * band width check mothods use SrsBandwidthPacket as its internal packet type, |
| 196 | * so ensure you set command name when you use it. | 95 | * so ensure you set command name when you use it. |
| @@ -57,6 +57,110 @@ class SrsSharedPtrMessage; | @@ -57,6 +57,110 @@ class SrsSharedPtrMessage; | ||
| 57 | class IMergeReadHandler; | 57 | class IMergeReadHandler; |
| 58 | 58 | ||
| 59 | /**************************************************************************** | 59 | /**************************************************************************** |
| 60 | + ***************************************************************************** | ||
| 61 | + ****************************************************************************/ | ||
| 62 | +/** | ||
| 63 | + 5. Protocol Control Messages | ||
| 64 | + RTMP reserves message type IDs 1-7 for protocol control messages. | ||
| 65 | + These messages contain information needed by the RTM Chunk Stream | ||
| 66 | + protocol or RTMP itself. Protocol messages with IDs 1 & 2 are | ||
| 67 | + reserved for usage with RTM Chunk Stream protocol. Protocol messages | ||
| 68 | + with IDs 3-6 are reserved for usage of RTMP. Protocol message with ID | ||
| 69 | + 7 is used between edge server and origin server. | ||
| 70 | + */ | ||
| 71 | +#define RTMP_MSG_SetChunkSize 0x01 | ||
| 72 | +#define RTMP_MSG_AbortMessage 0x02 | ||
| 73 | +#define RTMP_MSG_Acknowledgement 0x03 | ||
| 74 | +#define RTMP_MSG_UserControlMessage 0x04 | ||
| 75 | +#define RTMP_MSG_WindowAcknowledgementSize 0x05 | ||
| 76 | +#define RTMP_MSG_SetPeerBandwidth 0x06 | ||
| 77 | +#define RTMP_MSG_EdgeAndOriginServerCommand 0x07 | ||
| 78 | +/** | ||
| 79 | + 3. Types of messages | ||
| 80 | + The server and the client send messages over the network to | ||
| 81 | + communicate with each other. The messages can be of any type which | ||
| 82 | + includes audio messages, video messages, command messages, shared | ||
| 83 | + object messages, data messages, and user control messages. | ||
| 84 | + 3.1. Command message | ||
| 85 | + Command messages carry the AMF-encoded commands between the client | ||
| 86 | + and the server. These messages have been assigned message type value | ||
| 87 | + of 20 for AMF0 encoding and message type value of 17 for AMF3 | ||
| 88 | + encoding. These messages are sent to perform some operations like | ||
| 89 | + connect, createStream, publish, play, pause on the peer. Command | ||
| 90 | + messages like onstatus, result etc. are used to inform the sender | ||
| 91 | + about the status of the requested commands. A command message | ||
| 92 | + consists of command name, transaction ID, and command object that | ||
| 93 | + contains related parameters. A client or a server can request Remote | ||
| 94 | + Procedure Calls (RPC) over streams that are communicated using the | ||
| 95 | + command messages to the peer. | ||
| 96 | + */ | ||
| 97 | +#define RTMP_MSG_AMF3CommandMessage 17 // 0x11 | ||
| 98 | +#define RTMP_MSG_AMF0CommandMessage 20 // 0x14 | ||
| 99 | +/** | ||
| 100 | + 3.2. Data message | ||
| 101 | + The client or the server sends this message to send Metadata or any | ||
| 102 | + user data to the peer. Metadata includes details about the | ||
| 103 | + data(audio, video etc.) like creation time, duration, theme and so | ||
| 104 | + on. These messages have been assigned message type value of 18 for | ||
| 105 | + AMF0 and message type value of 15 for AMF3. | ||
| 106 | + */ | ||
| 107 | +#define RTMP_MSG_AMF0DataMessage 18 // 0x12 | ||
| 108 | +#define RTMP_MSG_AMF3DataMessage 15 // 0x0F | ||
| 109 | +/** | ||
| 110 | + 3.3. Shared object message | ||
| 111 | + A shared object is a Flash object (a collection of name value pairs) | ||
| 112 | + that are in synchronization across multiple clients, instances, and | ||
| 113 | + so on. The message types kMsgContainer=19 for AMF0 and | ||
| 114 | + kMsgContainerEx=16 for AMF3 are reserved for shared object events. | ||
| 115 | + Each message can contain multiple events. | ||
| 116 | + */ | ||
| 117 | +#define RTMP_MSG_AMF3SharedObject 16 // 0x10 | ||
| 118 | +#define RTMP_MSG_AMF0SharedObject 19 // 0x13 | ||
| 119 | +/** | ||
| 120 | + 3.4. Audio message | ||
| 121 | + The client or the server sends this message to send audio data to the | ||
| 122 | + peer. The message type value of 8 is reserved for audio messages. | ||
| 123 | + */ | ||
| 124 | +#define RTMP_MSG_AudioMessage 8 // 0x08 | ||
| 125 | +/* * | ||
| 126 | + 3.5. Video message | ||
| 127 | + The client or the server sends this message to send video data to the | ||
| 128 | + peer. The message type value of 9 is reserved for video messages. | ||
| 129 | + These messages are large and can delay the sending of other type of | ||
| 130 | + messages. To avoid such a situation, the video message is assigned | ||
| 131 | + the lowest priority. | ||
| 132 | + */ | ||
| 133 | +#define RTMP_MSG_VideoMessage 9 // 0x09 | ||
| 134 | +/** | ||
| 135 | + 3.6. Aggregate message | ||
| 136 | + An aggregate message is a single message that contains a list of submessages. | ||
| 137 | + The message type value of 22 is reserved for aggregate | ||
| 138 | + messages. | ||
| 139 | + */ | ||
| 140 | +#define RTMP_MSG_AggregateMessage 22 // 0x16 | ||
| 141 | + | ||
| 142 | +/**************************************************************************** | ||
| 143 | + ***************************************************************************** | ||
| 144 | + ****************************************************************************/ | ||
| 145 | +/** | ||
| 146 | + * amf0 command message, command name macros | ||
| 147 | + */ | ||
| 148 | +#define RTMP_AMF0_COMMAND_CONNECT "connect" | ||
| 149 | +#define RTMP_AMF0_COMMAND_CREATE_STREAM "createStream" | ||
| 150 | +#define RTMP_AMF0_COMMAND_CLOSE_STREAM "closeStream" | ||
| 151 | +#define RTMP_AMF0_COMMAND_PLAY "play" | ||
| 152 | +#define RTMP_AMF0_COMMAND_PAUSE "pause" | ||
| 153 | +#define RTMP_AMF0_COMMAND_ON_BW_DONE "onBWDone" | ||
| 154 | +#define RTMP_AMF0_COMMAND_ON_STATUS "onStatus" | ||
| 155 | +#define RTMP_AMF0_COMMAND_RESULT "_result" | ||
| 156 | +#define RTMP_AMF0_COMMAND_ERROR "_error" | ||
| 157 | +#define RTMP_AMF0_COMMAND_RELEASE_STREAM "releaseStream" | ||
| 158 | +#define RTMP_AMF0_COMMAND_FC_PUBLISH "FCPublish" | ||
| 159 | +#define RTMP_AMF0_COMMAND_UNPUBLISH "FCUnpublish" | ||
| 160 | +#define RTMP_AMF0_COMMAND_PUBLISH "publish" | ||
| 161 | +#define RTMP_AMF0_DATA_SAMPLE_ACCESS "|RtmpSampleAccess" | ||
| 162 | + | ||
| 163 | +/**************************************************************************** | ||
| 60 | ***************************************************************************** | 164 | ***************************************************************************** |
| 61 | ****************************************************************************/ | 165 | ****************************************************************************/ |
| 62 | /** | 166 | /** |
| @@ -78,10 +78,7 @@ void srs_vhost_resolve(string& vhost, string& app, string& param) | @@ -78,10 +78,7 @@ void srs_vhost_resolve(string& vhost, string& app, string& param) | ||
| 78 | app = srs_string_replace(app, "&&", "?"); | 78 | app = srs_string_replace(app, "&&", "?"); |
| 79 | app = srs_string_replace(app, "=", "?"); | 79 | app = srs_string_replace(app, "=", "?"); |
| 80 | 80 | ||
| 81 | - if ((pos = app.find("?")) == std::string::npos) { | ||
| 82 | - return; | ||
| 83 | - } | ||
| 84 | - | 81 | + if ((pos = app.find("?")) != std::string::npos) { |
| 85 | std::string query = app.substr(pos + 1); | 82 | std::string query = app.substr(pos + 1); |
| 86 | app = app.substr(0, pos); | 83 | app = app.substr(0, pos); |
| 87 | 84 | ||
| @@ -94,6 +91,9 @@ void srs_vhost_resolve(string& vhost, string& app, string& param) | @@ -94,6 +91,9 @@ void srs_vhost_resolve(string& vhost, string& app, string& param) | ||
| 94 | vhost = vhost.substr(0, pos); | 91 | vhost = vhost.substr(0, pos); |
| 95 | } | 92 | } |
| 96 | } | 93 | } |
| 94 | + } | ||
| 95 | + | ||
| 96 | + /* others */ | ||
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | void srs_random_generate(char* bytes, int size) | 99 | void srs_random_generate(char* bytes, int size) |
| @@ -63,7 +63,9 @@ extern void srs_discovery_tc_url( | @@ -63,7 +63,9 @@ extern void srs_discovery_tc_url( | ||
| 63 | * app...vhost...request_vhost | 63 | * app...vhost...request_vhost |
| 64 | * @param param, the query, for example, ?vhost=xxx | 64 | * @param param, the query, for example, ?vhost=xxx |
| 65 | */ | 65 | */ |
| 66 | -extern void srs_vhost_resolve(std::string& vhost, std::string& app, std::string& param); | 66 | +extern void srs_vhost_resolve( |
| 67 | + std::string& vhost, std::string& app, std::string& param | ||
| 68 | +); | ||
| 67 | 69 | ||
| 68 | /** | 70 | /** |
| 69 | * generate ramdom data for handshake. | 71 | * generate ramdom data for handshake. |
-
请 注册 或 登录 后发表评论