正在显示
5 个修改的文件
包含
77 行增加
和
3 行删除
| @@ -208,6 +208,7 @@ Supported operating systems and hardware: | @@ -208,6 +208,7 @@ Supported operating systems and hardware: | ||
| 208 | * 2013-10-17, Created.<br/> | 208 | * 2013-10-17, Created.<br/> |
| 209 | 209 | ||
| 210 | ## History | 210 | ## History |
| 211 | +* v1.0, 2014-08-06, fix [#147](https://github.com/winlinvip/simple-rtmp-server/issues/147), support identify the srs edge. 0.9.190. | ||
| 211 | * <strong>v1.0, 2014-08-03, [1.0 mainline7(0.9.189)](https://github.com/winlinvip/simple-rtmp-server/releases/tag/1.0.mainline7) released. 57432 lines.</strong> | 212 | * <strong>v1.0, 2014-08-03, [1.0 mainline7(0.9.189)](https://github.com/winlinvip/simple-rtmp-server/releases/tag/1.0.mainline7) released. 57432 lines.</strong> |
| 212 | * v1.0, 2014-08-03, fix [#79](https://github.com/winlinvip/simple-rtmp-server/issues/79), fix the reload remove edge assert bug. 0.9.189. | 213 | * v1.0, 2014-08-03, fix [#79](https://github.com/winlinvip/simple-rtmp-server/issues/79), fix the reload remove edge assert bug. 0.9.189. |
| 213 | * v1.0, 2014-08-03, fix [#57](https://github.com/winlinvip/simple-rtmp-server/issues/57), use lock(acquire/release publish) to avoid duplicated publishing. 0.9.188. | 214 | * v1.0, 2014-08-03, fix [#57](https://github.com/winlinvip/simple-rtmp-server/issues/57), use lock(acquire/release publish) to avoid duplicated publishing. 0.9.188. |
| @@ -46,6 +46,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -46,6 +46,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 46 | #include <srs_kernel_utility.hpp> | 46 | #include <srs_kernel_utility.hpp> |
| 47 | #include <srs_protocol_msg_array.hpp> | 47 | #include <srs_protocol_msg_array.hpp> |
| 48 | #include <srs_app_utility.hpp> | 48 | #include <srs_app_utility.hpp> |
| 49 | +#include <srs_protocol_amf0.hpp> | ||
| 49 | 50 | ||
| 50 | // when error, edge ingester sleep for a while and retry. | 51 | // when error, edge ingester sleep for a while and retry. |
| 51 | #define SRS_EDGE_INGESTER_SLEEP_US (int64_t)(1*1000*1000LL) | 52 | #define SRS_EDGE_INGESTER_SLEEP_US (int64_t)(1*1000*1000LL) |
| @@ -131,8 +132,7 @@ int SrsEdgeIngester::cycle() | @@ -131,8 +132,7 @@ int SrsEdgeIngester::cycle() | ||
| 131 | srs_error("handshake with server failed. ret=%d", ret); | 132 | srs_error("handshake with server failed. ret=%d", ret); |
| 132 | return ret; | 133 | return ret; |
| 133 | } | 134 | } |
| 134 | - if ((ret = client->connect_app(req->app, req->tcUrl, req)) != ERROR_SUCCESS) { | ||
| 135 | - srs_error("connect with server failed, tcUrl=%s. ret=%d", req->tcUrl.c_str(), ret); | 135 | + if ((ret = connect_app()) != ERROR_SUCCESS) { |
| 136 | return ret; | 136 | return ret; |
| 137 | } | 137 | } |
| 138 | if ((ret = client->create_stream(stream_id)) != ERROR_SUCCESS) { | 138 | if ((ret = client->create_stream(stream_id)) != ERROR_SUCCESS) { |
| @@ -209,6 +209,49 @@ int SrsEdgeIngester::ingest() | @@ -209,6 +209,49 @@ int SrsEdgeIngester::ingest() | ||
| 209 | return ret; | 209 | return ret; |
| 210 | } | 210 | } |
| 211 | 211 | ||
| 212 | +int SrsEdgeIngester::connect_app() | ||
| 213 | +{ | ||
| 214 | + int ret = ERROR_SUCCESS; | ||
| 215 | + | ||
| 216 | + SrsRequest* req = _req; | ||
| 217 | + | ||
| 218 | + // args of request takes the srs info. | ||
| 219 | + if (req->args == NULL) { | ||
| 220 | + req->args = SrsAmf0Any::object(); | ||
| 221 | + } | ||
| 222 | + | ||
| 223 | + // notify server the edge identity, | ||
| 224 | + // @see https://github.com/winlinvip/simple-rtmp-server/issues/147 | ||
| 225 | + SrsAmf0Object* data = req->args; | ||
| 226 | + data->set("srs_sig", SrsAmf0Any::str(RTMP_SIG_SRS_KEY)); | ||
| 227 | + data->set("srs_server", SrsAmf0Any::str(RTMP_SIG_SRS_KEY" "RTMP_SIG_SRS_VERSION" ("RTMP_SIG_SRS_URL_SHORT")")); | ||
| 228 | + data->set("srs_license", SrsAmf0Any::str(RTMP_SIG_SRS_LICENSE)); | ||
| 229 | + data->set("srs_role", SrsAmf0Any::str(RTMP_SIG_SRS_ROLE)); | ||
| 230 | + data->set("srs_url", SrsAmf0Any::str(RTMP_SIG_SRS_URL)); | ||
| 231 | + data->set("srs_version", SrsAmf0Any::str(RTMP_SIG_SRS_VERSION)); | ||
| 232 | + data->set("srs_site", SrsAmf0Any::str(RTMP_SIG_SRS_WEB)); | ||
| 233 | + data->set("srs_email", SrsAmf0Any::str(RTMP_SIG_SRS_EMAIL)); | ||
| 234 | + data->set("srs_copyright", SrsAmf0Any::str(RTMP_SIG_SRS_COPYRIGHT)); | ||
| 235 | + data->set("srs_primary_authors", SrsAmf0Any::str(RTMP_SIG_SRS_PRIMARY_AUTHROS)); | ||
| 236 | + // for edge to directly get the id of client. | ||
| 237 | + data->set("srs_pid", SrsAmf0Any::number(getpid())); | ||
| 238 | + data->set("srs_id", SrsAmf0Any::number(_srs_context->get_id())); | ||
| 239 | + | ||
| 240 | + // local ip of edge | ||
| 241 | + std::vector<std::string> ips = srs_get_local_ipv4_ips(); | ||
| 242 | + assert(_srs_config->get_stats_network() < (int)ips.size()); | ||
| 243 | + std::string local_ip = ips[_srs_config->get_stats_network()]; | ||
| 244 | + data->set("srs_server_ip", SrsAmf0Any::str(local_ip.c_str())); | ||
| 245 | + | ||
| 246 | + // upnode server identity will show in the connect_app of client. | ||
| 247 | + if ((ret = client->connect_app(req->app, req->tcUrl, req)) != ERROR_SUCCESS) { | ||
| 248 | + srs_error("connect with server failed, tcUrl=%s. ret=%d", req->tcUrl.c_str(), ret); | ||
| 249 | + return ret; | ||
| 250 | + } | ||
| 251 | + | ||
| 252 | + return ret; | ||
| 253 | +} | ||
| 254 | + | ||
| 212 | int SrsEdgeIngester::process_publish_message(SrsMessage* msg) | 255 | int SrsEdgeIngester::process_publish_message(SrsMessage* msg) |
| 213 | { | 256 | { |
| 214 | int ret = ERROR_SUCCESS; | 257 | int ret = ERROR_SUCCESS; |
| @@ -101,6 +101,7 @@ private: | @@ -101,6 +101,7 @@ private: | ||
| 101 | virtual int ingest(); | 101 | virtual int ingest(); |
| 102 | virtual void close_underlayer_socket(); | 102 | virtual void close_underlayer_socket(); |
| 103 | virtual int connect_server(); | 103 | virtual int connect_server(); |
| 104 | + virtual int connect_app(); | ||
| 104 | virtual int process_publish_message(SrsMessage* msg); | 105 | virtual int process_publish_message(SrsMessage* msg); |
| 105 | }; | 106 | }; |
| 106 | 107 |
| @@ -163,6 +163,35 @@ int SrsRtmpConn::do_cycle() | @@ -163,6 +163,35 @@ int SrsRtmpConn::do_cycle() | ||
| 163 | req->schema.c_str(), req->vhost.c_str(), req->port.c_str(), | 163 | req->schema.c_str(), req->vhost.c_str(), req->port.c_str(), |
| 164 | req->app.c_str(), (req->args? "(obj)":"null")); | 164 | req->app.c_str(), (req->args? "(obj)":"null")); |
| 165 | 165 | ||
| 166 | + // show client identity | ||
| 167 | + if(req->args) { | ||
| 168 | + std::string srs_version; | ||
| 169 | + std::string srs_server_ip; | ||
| 170 | + int srs_pid = 0; | ||
| 171 | + int srs_id = 0; | ||
| 172 | + | ||
| 173 | + SrsAmf0Any* prop = NULL; | ||
| 174 | + if ((prop = req->args->ensure_property_string("srs_version")) != NULL) { | ||
| 175 | + srs_version = prop->to_str(); | ||
| 176 | + } | ||
| 177 | + if ((prop = req->args->ensure_property_string("srs_server_ip")) != NULL) { | ||
| 178 | + srs_server_ip = prop->to_str(); | ||
| 179 | + } | ||
| 180 | + if ((prop = req->args->ensure_property_number("srs_pid")) != NULL) { | ||
| 181 | + srs_pid = (int)prop->to_number(); | ||
| 182 | + } | ||
| 183 | + if ((prop = req->args->ensure_property_number("srs_id")) != NULL) { | ||
| 184 | + srs_id = (int)prop->to_number(); | ||
| 185 | + } | ||
| 186 | + | ||
| 187 | + srs_info("edge-srs ip=%s, version=%s, pid=%d, id=%d", | ||
| 188 | + srs_server_ip.c_str(), srs_version.c_str(), srs_pid, srs_id); | ||
| 189 | + if (srs_pid > 0) { | ||
| 190 | + srs_trace("edge-srs ip=%s, version=%s, pid=%d, id=%d", | ||
| 191 | + srs_server_ip.c_str(), srs_version.c_str(), srs_pid, srs_id); | ||
| 192 | + } | ||
| 193 | + } | ||
| 194 | + | ||
| 166 | ret = service_cycle(); | 195 | ret = service_cycle(); |
| 167 | http_hooks_on_close(); | 196 | http_hooks_on_close(); |
| 168 | 197 |
| @@ -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 "0" | 32 | #define VERSION_MAJOR "0" |
| 33 | #define VERSION_MINOR "9" | 33 | #define VERSION_MINOR "9" |
| 34 | -#define VERSION_REVISION "189" | 34 | +#define VERSION_REVISION "190" |
| 35 | #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION | 35 | #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION |
| 36 | // server info. | 36 | // server info. |
| 37 | #define RTMP_SIG_SRS_KEY "SRS" | 37 | #define RTMP_SIG_SRS_KEY "SRS" |
-
请 注册 或 登录 后发表评论