Add support for dual-'?' params in RIST push outputs, fix a small memory leak in RIST output

This commit is contained in:
Thulinma 2022-09-22 16:12:24 +02:00
parent 2d4a2f5835
commit 696e04d6a0
3 changed files with 19 additions and 9 deletions

View file

@ -206,8 +206,9 @@ std::string HTTP::URL::getUrl() const{
ret += host; ret += host;
} }
if (port.size() && getPort() != getDefaultPort()){ret += ":" + port;} if (port.size() && getPort() != getDefaultPort()){ret += ":" + port;}
ret += "/"; if (protocol != "rist"){
ret += getEncodedPath(); ret += "/" + getEncodedPath();
}
if (args.size()){ret += "?" + args;} if (args.size()){ret += "?" + args;}
if (frag.size()){ret += "#" + Encodings::URL::encode(frag, "/:=@[]#?&");} if (frag.size()){ret += "#" + Encodings::URL::encode(frag, "/:=@[]#?&");}
return ret; return ret;

View file

@ -48,6 +48,7 @@ int cb_stats(void *arg, const struct rist_stats *stats_container){
pktReceived += sObj["received"].asInt(); pktReceived += sObj["received"].asInt();
pktLost += sObj["lost"].asInt(); pktLost += sObj["lost"].asInt();
pktRetransmitted += sObj["retries"].asInt(); pktRetransmitted += sObj["retries"].asInt();
rist_stats_free(stats_container);
return 0; return 0;
} }

View file

@ -39,6 +39,7 @@ namespace Mist{
JSON::Value & sObj = stats["sender-stats"]["peer"]["stats"]; JSON::Value & sObj = stats["sender-stats"]["peer"]["stats"];
pktSent += sObj["sent"].asInt(); pktSent += sObj["sent"].asInt();
pktRetransmitted += sObj["retransmitted"].asInt(); pktRetransmitted += sObj["retransmitted"].asInt();
rist_stats_free(stats_container);
return 0; return 0;
} }
@ -79,7 +80,18 @@ namespace Mist{
pushOut = false; pushOut = false;
// Push output configuration // Push output configuration
if (config->getString("target").size()){ if (config->getString("target").size()){
target = HTTP::URL(config->getString("target")); std::string ristURL = config->getString("target").c_str();
//If there are two ?, grab everything after the last first
if (ristURL.rfind('?') != std::string::npos && ristURL.find('?') != ristURL.rfind('?')){
std::string extraParams = ristURL.substr(ristURL.rfind('?')+1);
std::map<std::string, std::string> arguments;
HTTP::parseVars(extraParams, arguments);
for (std::map<std::string, std::string>::iterator it = arguments.begin(); it != arguments.end(); ++it){
targetParams[it->first] = it->second;
}
ristURL.erase(ristURL.rfind('?'));
}
target = HTTP::URL(ristURL);
if (target.protocol != "rist"){ if (target.protocol != "rist"){
FAIL_MSG("Target %s must begin with rist://, aborting", target.getUrl().c_str()); FAIL_MSG("Target %s must begin with rist://, aborting", target.getUrl().c_str());
onFail("Invalid RIST target: doesn't start with rist://", true); onFail("Invalid RIST target: doesn't start with rist://", true);
@ -96,11 +108,6 @@ namespace Mist{
return; return;
} }
pushOut = true; pushOut = true;
std::map<std::string, std::string> arguments;
HTTP::parseVars(target.args, arguments);
for (std::map<std::string, std::string>::iterator it = arguments.begin(); it != arguments.end(); ++it){
targetParams[it->first] = it->second;
}
rist_profile profile = RIST_PROFILE_MAIN; rist_profile profile = RIST_PROFILE_MAIN;
if (targetParams.count("profile")){ if (targetParams.count("profile")){
@ -111,8 +118,9 @@ namespace Mist{
onFail("Failed to create sender context"); onFail("Failed to create sender context");
return; return;
} }
INFO_MSG("Letting libRIST parse URL: %s", ristURL.c_str());
struct rist_peer_config *peer_config_link = 0; struct rist_peer_config *peer_config_link = 0;
if (rist_parse_address2(config->getString("target").c_str(), &peer_config_link)){ if (rist_parse_address2(ristURL.c_str(), &peer_config_link)){
onFail("Failed to parse target URL: %s", config->getString("target").c_str()); onFail("Failed to parse target URL: %s", config->getString("target").c_str());
return; return;
} }