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