Added basic stream fallback feature, allowing to redirect to a different stream name on stream source load errors
This commit is contained in:
		
							parent
							
								
									6e125707f1
								
							
						
					
					
						commit
						7beea43d31
					
				
					 4 changed files with 22 additions and 1 deletions
				
			
		|  | @ -372,6 +372,19 @@ namespace Mist{ | |||
|       } | ||||
|     }else{ | ||||
|       if (!Util::startInput(streamName, "", true, isPushing())){ | ||||
|         //If stream is configured, use fallback stream setting, if set.
 | ||||
|         JSON::Value strCnf = Util::getStreamConfig(streamName); | ||||
|         if (strCnf && strCnf["fallback_stream"].asStringRef().size()){ | ||||
|           streamName = strCnf["fallback_stream"].asStringRef(); | ||||
|           Util::Config::streamName = streamName; | ||||
|           INFO_MSG("Switching to configured fallback stream '%s'", streamName.c_str()); | ||||
|           reconnect(); | ||||
|           return; | ||||
|         } | ||||
| 
 | ||||
|         //Not configured or no fallback stream? Use the default stream handler instead
 | ||||
|         //Note: Since fallback stream is handled recursively, the defaultStream handler
 | ||||
|         //may still be triggered for the fallback stream! This is intentional.
 | ||||
|         JSON::Value defStrmJson = Util::getGlobalConfig("defaultStream"); | ||||
|         std::string defStrm = defStrmJson.asString(); | ||||
|         if(Triggers::shouldTrigger("DEFAULT_STREAM", streamName)){ | ||||
|  |  | |||
|  | @ -433,7 +433,8 @@ namespace Mist { | |||
|       H.Clean(); //clean for any possible next requests
 | ||||
|       return; | ||||
|     }else if (HTTP::URL(H.url).getExt().substr(0, 3) != "m3u") { | ||||
|       std::string tmpStr = H.getUrl().substr(5 + streamName.size()); | ||||
|       size_t slashPos = H.getUrl().find('/', 5); | ||||
|       std::string tmpStr = H.getUrl().substr(slashPos); | ||||
|       long long unsigned int from; | ||||
|       if (sscanf(tmpStr.c_str(), "/%u_%u/%llu_%llu.ts", &vidTrack, &audTrack, &from, &until) != 4) { | ||||
|         if (sscanf(tmpStr.c_str(), "/%u/%llu_%llu.ts", &vidTrack, &from, &until) != 3) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Thulinma
						Thulinma