Restore RTMP parameters in request URLs, handle variable parsing in trigger responses

This commit is contained in:
Thulinma 2020-09-10 12:21:22 +02:00
parent 4af7f3e9ed
commit c4e6f0ad31

View file

@ -833,17 +833,19 @@ namespace Mist{
} }
if (amfData.getContentP(3)){ if (amfData.getContentP(3)){
streamName = Encodings::URL::decode(amfData.getContentP(3)->StrValue()); streamName = Encodings::URL::decode(amfData.getContentP(3)->StrValue());
reqUrl += "/" + streamName; // LTS
// handle variables // handle variables
if (streamName.find('?') != std::string::npos){ if (streamName.find('?') != std::string::npos){
std::string tmpVars = streamName.substr(streamName.find('?') + 1); std::string tmpVars = streamName.substr(streamName.find('?') + 1);
streamName = streamName.substr(0, streamName.find('?')); streamName = streamName.substr(0, streamName.find('?'));
Util::setStreamName(streamName);
HTTP::parseVars(tmpVars, targetParams); HTTP::parseVars(tmpVars, targetParams);
} }
//Remove anything before the last slash
if (streamName.find('/')){
streamName = streamName.substr(0, streamName.find('/'));
}
Util::setStreamName(streamName); Util::setStreamName(streamName);
reqUrl += "/" + streamName; // LTS
/*LTS-START*/ /*LTS-START*/
if (Triggers::shouldTrigger("RTMP_PUSH_REWRITE")){ if (Triggers::shouldTrigger("RTMP_PUSH_REWRITE")){
@ -860,18 +862,18 @@ namespace Mist{
size_t lSlash = newUrl.rfind('/'); size_t lSlash = newUrl.rfind('/');
if (lSlash != std::string::npos){ if (lSlash != std::string::npos){
streamName = newUrl.substr(lSlash + 1); streamName = newUrl.substr(lSlash + 1);
Util::setStreamName(streamName);
}else{ }else{
streamName = newUrl; streamName = newUrl;
Util::setStreamName(streamName);
} }
} // handle variables
/*LTS-END*/ if (streamName.find('?') != std::string::npos){
std::string tmpVars = streamName.substr(streamName.find('?') + 1);
if (streamName.find('/')){ streamName = streamName.substr(0, streamName.find('?'));
streamName = streamName.substr(0, streamName.find('/')); HTTP::parseVars(tmpVars, targetParams);
}
Util::setStreamName(streamName); Util::setStreamName(streamName);
} }
/*LTS-END*/
size_t colonPos = streamName.find(':'); size_t colonPos = streamName.find(':');
if (colonPos != std::string::npos && colonPos < 6){ if (colonPos != std::string::npos && colonPos < 6){
@ -900,6 +902,12 @@ namespace Mist{
return; return;
}else{ }else{
streamName = newStream; streamName = newStream;
// handle variables
if (streamName.find('?') != std::string::npos){
std::string tmpVars = streamName.substr(streamName.find('?') + 1);
streamName = streamName.substr(0, streamName.find('?'));
HTTP::parseVars(tmpVars, targetParams);
}
Util::sanitizeName(streamName); Util::sanitizeName(streamName);
Util::setStreamName(streamName); Util::setStreamName(streamName);
} }
@ -951,14 +959,12 @@ namespace Mist{
int8_t playMessageType = messageType; int8_t playMessageType = messageType;
int32_t playStreamId = streamId; int32_t playStreamId = streamId;
streamName = Encodings::URL::decode(amfData.getContentP(3)->StrValue()); streamName = Encodings::URL::decode(amfData.getContentP(3)->StrValue());
Util::setStreamName(streamName);
reqUrl += "/" + streamName; // LTS reqUrl += "/" + streamName; // LTS
// handle variables // handle variables
if (streamName.find('?') != std::string::npos){ if (streamName.find('?') != std::string::npos){
std::string tmpVars = streamName.substr(streamName.find('?') + 1); std::string tmpVars = streamName.substr(streamName.find('?') + 1);
streamName = streamName.substr(0, streamName.find('?')); streamName = streamName.substr(0, streamName.find('?'));
Util::setStreamName(streamName);
HTTP::parseVars(tmpVars, targetParams); HTTP::parseVars(tmpVars, targetParams);
} }
@ -970,9 +976,9 @@ namespace Mist{
}else{ }else{
streamName = oldName.substr(colonPos + 1) + std::string(".") + oldName.substr(0, colonPos); streamName = oldName.substr(colonPos + 1) + std::string(".") + oldName.substr(0, colonPos);
} }
Util::setStreamName(streamName);
} }
Util::sanitizeName(streamName); Util::sanitizeName(streamName);
Util::setStreamName(streamName);
if (config->getInteger("acceptable") == 2){// Only allow incoming ( = 2)? Abort! if (config->getInteger("acceptable") == 2){// Only allow incoming ( = 2)? Abort!
AMF::Object amfReply("container", AMF::AMF0_DDV_CONTAINER); AMF::Object amfReply("container", AMF::AMF0_DDV_CONTAINER);