int SrsSource::create_forwarders() { int ret = ERROR_SUCCESS; SrsConfDirective* conf = config->get_forward(req->vhost); for (int i = 0; conf && i < (int)conf->args.size(); i++) { std::string forward_server = conf->args.at(i); SrsForwarder* forwarder = new SrsForwarder(this); forwarders.push_back(forwarder); double queue_size = config->get_queue_length(req->vhost); forwarder->set_queue_size(queue_size); if ((ret = forwarder->on_publish(req, forward_server)) != ERROR_SUCCESS) { srs_error("start forwarder failed. " "vhost=%s, app=%s, stream=%s, forward-to=%s", req->vhost.c_str(), req->app.c_str(), req->stream.c_str(), forward_server.c_str()); return ret; } } return ret; }
int SrsSource::on_publish(std::string vhost, std::string port, std::string app, std::string stream) { int ret = ERROR_SUCCESS; _can_publish = false; #ifdef SRS_HLS if ((ret = hls->on_publish(vhost, app, stream)) != ERROR_SUCCESS) { return ret; } #endif #ifdef SRS_FFMPEG if ((ret = encoder->on_publish(vhost, port, app, stream)) != ERROR_SUCCESS) { return ret; } #endif // TODO: support reload. // create forwarders SrsConfDirective* conf = config->get_forward(vhost); for (int i = 0; conf && i < (int)conf->args.size(); i++) { std::string forward_server = conf->args.at(i); SrsForwarder* forwarder = new SrsForwarder(); forwarders.push_back(forwarder); if ((ret = forwarder->on_publish(vhost, app, stream, forward_server)) != ERROR_SUCCESS) { srs_error("start forwarder failed. " "vhost=%s, app=%s, stream=%s, forward-to=%s", vhost.c_str(), app.c_str(), stream.c_str(), forward_server.c_str()); return ret; } } return ret; }