Added TS output passthrough support
This commit is contained in:
		
							parent
							
								
									8fbdafb288
								
							
						
					
					
						commit
						adb76e2cf8
					
				
					 6 changed files with 38 additions and 24 deletions
				
			
		|  | @ -4,12 +4,24 @@ | |||
| #include <mist/stream.h> | ||||
| #include <unistd.h> | ||||
| 
 | ||||
| namespace Mist { | ||||
| namespace Mist{ | ||||
|   OutHTTPTS::OutHTTPTS(Socket::Connection & conn) : TSOutput(conn){ | ||||
|     sendRepeatingHeaders = 500;//PAT/PMT every 500ms (DVB spec)
 | ||||
|   } | ||||
|    | ||||
|   OutHTTPTS::~OutHTTPTS() {} | ||||
|   OutHTTPTS::~OutHTTPTS(){} | ||||
| 
 | ||||
|   void OutHTTPTS::initialSeek(){ | ||||
|     //Adds passthrough support to the regular initialSeek function
 | ||||
|     if (targetParams.count("passthrough")){ | ||||
|       selectedTracks.clear(); | ||||
|       for (std::map<unsigned int, DTSC::Track>::iterator it = myMeta.tracks.begin(); | ||||
|            it != myMeta.tracks.end(); it++){ | ||||
|         selectedTracks.insert(it->first); | ||||
|       } | ||||
|     } | ||||
|     Output::initialSeek(); | ||||
|   } | ||||
| 
 | ||||
|   void OutHTTPTS::init(Util::Config * cfg){ | ||||
|     HTTPOutput::init(cfg); | ||||
|  |  | |||
|  | @ -9,6 +9,7 @@ namespace Mist { | |||
|       static void init(Util::Config * cfg); | ||||
|       void onHTTP(); | ||||
|       void sendTS(const char * tsData, unsigned int len=188); | ||||
|       void initialSeek(); | ||||
|     private: | ||||
|       bool isRecording(); | ||||
|       bool isFileTarget(){return isRecording();} | ||||
|  |  | |||
|  | @ -29,12 +29,8 @@ namespace Mist { | |||
|       } | ||||
|       pushOut = true; | ||||
|       udpSize = 5; | ||||
|       if (target.find('?') != std::string::npos){ | ||||
|         std::map<std::string, std::string> vars; | ||||
|         HTTP::parseVars(target.substr(target.find('?')+1), vars); | ||||
|         if (vars.count("tracks")){tracks = vars["tracks"];} | ||||
|         if (vars.count("pkts")){udpSize = atoi(vars["pkts"].c_str());} | ||||
|       } | ||||
|       if (targetParams.count("tracks")){tracks = targetParams["tracks"];} | ||||
|       if (targetParams.count("pkts")){udpSize = atoi(targetParams["pkts"].c_str());} | ||||
|       packetBuffer.reserve(188*udpSize); | ||||
|       int port = atoi(target.substr(target.find(":") + 1).c_str()); | ||||
|       target.erase(target.find(":"));//strip all after the colon
 | ||||
|  | @ -97,6 +93,18 @@ namespace Mist { | |||
|     cfg->addOption("target", opt); | ||||
|   } | ||||
| 
 | ||||
|   void OutTS::initialSeek(){ | ||||
|     //Adds passthrough support to the regular initialSeek function
 | ||||
|     if (targetParams.count("passthrough")){ | ||||
|       selectedTracks.clear(); | ||||
|       for (std::map<unsigned int, DTSC::Track>::iterator it = myMeta.tracks.begin(); | ||||
|            it != myMeta.tracks.end(); it++){ | ||||
|         selectedTracks.insert(it->first); | ||||
|       } | ||||
|     } | ||||
|     Output::initialSeek(); | ||||
|   } | ||||
| 
 | ||||
|   void OutTS::sendTS(const char * tsData, unsigned int len){ | ||||
|     if (pushOut){ | ||||
|       static int curFilled = 0; | ||||
|  |  | |||
|  | @ -8,6 +8,7 @@ namespace Mist { | |||
|       static void init(Util::Config * cfg); | ||||
|       void sendTS(const char * tsData, unsigned int len=188); | ||||
|       static bool listenMode(); | ||||
|       void initialSeek(); | ||||
|     private: | ||||
|       unsigned int udpSize; | ||||
|       bool pushOut; | ||||
|  |  | |||
|  | @ -3,8 +3,6 @@ | |||
| namespace Mist { | ||||
|   TSOutput::TSOutput(Socket::Connection & conn) : TS_BASECLASS(conn){ | ||||
|     packCounter=0; | ||||
|     haveAvcc = false; | ||||
|     haveHvcc = false; | ||||
|     ts_from = 0; | ||||
|     setBlocking(true); | ||||
|     sendRepeatingHeaders = 0; | ||||
|  | @ -89,19 +87,15 @@ namespace Mist { | |||
|         } | ||||
|         if (keyframe){ | ||||
|           if (Trk.codec == "H264"){ | ||||
|             if (!haveAvcc){ | ||||
|             MP4::AVCC avccbox; | ||||
|             avccbox.setPayload(Trk.init); | ||||
|               haveAvcc = true; | ||||
|             } | ||||
|             bs = avccbox.asAnnexB(); | ||||
|             extraSize += bs.size(); | ||||
|           } | ||||
|           /*LTS-START*/ | ||||
|           if (Trk.codec == "HEVC"){ | ||||
|             if (!haveHvcc){ | ||||
|             MP4::HVCC hvccbox; | ||||
|             hvccbox.setPayload(Trk.init); | ||||
|               haveHvcc = true; | ||||
|             } | ||||
|             bs = hvccbox.asAnnexB(); | ||||
|             extraSize += bs.size(); | ||||
|           } | ||||
|  | @ -128,12 +122,16 @@ namespace Mist { | |||
|             } | ||||
|             if (keyframe){ | ||||
|               if (Trk.codec == "H264"){ | ||||
|                 MP4::AVCC avccbox; | ||||
|                 avccbox.setPayload(Trk.init); | ||||
|                 bs = avccbox.asAnnexB(); | ||||
|                 fillPacket(bs.data(), bs.size(), firstPack, video, keyframe, pkgPid, contPkg); | ||||
|                 alreadySent += bs.size(); | ||||
|               } | ||||
|               /*LTS-START*/ | ||||
|               if (Trk.codec == "HEVC"){ | ||||
|                 MP4::HVCC hvccbox; | ||||
|                 hvccbox.setPayload(Trk.init); | ||||
|                 bs = hvccbox.asAnnexB(); | ||||
|                 fillPacket(bs.data(), bs.size(), firstPack, video, keyframe, pkgPid, contPkg); | ||||
|                 alreadySent += bs.size(); | ||||
|  |  | |||
|  | @ -25,13 +25,7 @@ namespace Mist { | |||
|       int contSDT; | ||||
|       unsigned int packCounter; ///\todo update constructors?
 | ||||
|       TS::Packet packData; | ||||
|       bool haveAvcc; | ||||
|       MP4::AVCC avccbox; | ||||
|       bool appleCompat; | ||||
|       /*LTS-START*/ | ||||
|       bool haveHvcc; | ||||
|       MP4::HVCC hvccbox; | ||||
|       /*LTS-END*/ | ||||
|       uint64_t sendRepeatingHeaders; ///< Amount of ms between PAT/PMT. Zero means do not repeat.
 | ||||
|       uint64_t lastHeaderTime; ///< Timestamp last PAT/PMT were sent.
 | ||||
|       uint64_t ts_from; ///< Starting time to subtract from timestamps
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Thulinma
						Thulinma