Added AAC output support
This commit is contained in:
		
							parent
							
								
									04d28181e0
								
							
						
					
					
						commit
						0870a91e12
					
				
					 4 changed files with 102 additions and 0 deletions
				
			
		
							
								
								
									
										81
									
								
								src/output/output_aac.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										81
									
								
								src/output/output_aac.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,81 @@ | |||
| #include "output_aac.h" | ||||
| #include <mist/ts_packet.h> | ||||
| 
 | ||||
| namespace Mist{ | ||||
|   OutAAC::OutAAC(Socket::Connection &conn) : HTTPOutput(conn){} | ||||
| 
 | ||||
|   void OutAAC::init(Util::Config *cfg){ | ||||
|     HTTPOutput::init(cfg); | ||||
|     capa["name"] = "AAC"; | ||||
|     capa["friendly"] = "AAC over HTTP"; | ||||
|     capa["desc"] = "Pseudostreaming in AAC format over HTTP"; | ||||
|     capa["url_rel"] = "/$.aac"; | ||||
|     capa["url_match"] = "/$.aac"; | ||||
|     capa["codecs"][0u][0u].append("AAC"); | ||||
|     capa["methods"][0u]["handler"] = "http"; | ||||
|     capa["methods"][0u]["type"] = "html5/audio/aac"; | ||||
|     capa["methods"][0u]["priority"] = 8; | ||||
| 
 | ||||
|     JSON::Value opt; | ||||
|     opt["arg"] = "string"; | ||||
|     opt["default"] = ""; | ||||
|     opt["arg_num"] = 1; | ||||
|     opt["help"] = "Target filename to store AAC file as, or - for stdout."; | ||||
|     cfg->addOption("target", opt); | ||||
|   } | ||||
| 
 | ||||
|   bool OutAAC::isRecording(){return config->getString("target").size();} | ||||
| 
 | ||||
|   void OutAAC::initialSeek(){ | ||||
|     if (!meta){return;} | ||||
|     maxSkipAhead = 30000; | ||||
|     if (targetParams.count("buffer")){ | ||||
|       maxSkipAhead = atof(targetParams["buffer"].c_str())*1000; | ||||
|     } | ||||
|     Output::initialSeek(); | ||||
|     uint64_t cTime = currentTime(); | ||||
|     if (M.getLive() && cTime > maxSkipAhead){ | ||||
|       seek(cTime-maxSkipAhead); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   void OutAAC::sendNext(){ | ||||
|     char *dataPointer = 0; | ||||
|     size_t len = 0; | ||||
| 
 | ||||
|     thisPacket.getString("data", dataPointer, len); | ||||
|     std::string head = TS::getAudioHeader(len, M.getInit(thisIdx)); | ||||
|     myConn.SendNow(head); | ||||
|     myConn.SendNow(dataPointer, len); | ||||
|   } | ||||
| 
 | ||||
|   void OutAAC::sendHeader(){ | ||||
|     if (!isRecording()){ | ||||
|       H.Clean(); | ||||
|       H.SetHeader("Content-Type", "audio/aac"); | ||||
|       H.SetHeader("Accept-Ranges", "none"); | ||||
|       H.protocol = "HTTP/1.0"; | ||||
|       H.setCORSHeaders(); | ||||
|       H.SendResponse("200", "OK", myConn); | ||||
|     } | ||||
|     sentHeader = true; | ||||
|   } | ||||
| 
 | ||||
|   void OutAAC::onHTTP(){ | ||||
|     std::string method = H.method; | ||||
|     if (method == "OPTIONS" || method == "HEAD"){ | ||||
|       H.Clean(); | ||||
|       H.SetHeader("Content-Type", "audio/aac"); | ||||
|       H.SetHeader("Accept-Ranges", "none"); | ||||
|       H.protocol = "HTTP/1.0"; | ||||
|       H.setCORSHeaders(); | ||||
|       H.SendResponse("200", "OK", myConn); | ||||
|       H.Clean(); | ||||
|       return; | ||||
|     } | ||||
| 
 | ||||
|     parseData = true; | ||||
|     wantRequest = false; | ||||
|   } | ||||
| 
 | ||||
| }// namespace Mist
 | ||||
							
								
								
									
										19
									
								
								src/output/output_aac.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								src/output/output_aac.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,19 @@ | |||
| #include "output_http.h" | ||||
| 
 | ||||
| namespace Mist{ | ||||
|   class OutAAC : public HTTPOutput{ | ||||
|   public: | ||||
|     OutAAC(Socket::Connection &conn); | ||||
|     static void init(Util::Config *cfg); | ||||
|     void onHTTP(); | ||||
|     void sendNext(); | ||||
|     void sendHeader(); | ||||
|     void initialSeek(); | ||||
| 
 | ||||
|   private: | ||||
|     bool isRecording(); | ||||
|     bool isFileTarget(){return isRecording();} | ||||
|   }; | ||||
| }// namespace Mist
 | ||||
| 
 | ||||
| typedef Mist::OutAAC mistOut; | ||||
|  | @ -253,6 +253,7 @@ namespace Mist{ | |||
|       if (H.GetVar("stop") != ""){targetParams["stop"] = H.GetVar("stop");} | ||||
|       if (H.GetVar("startunix") != ""){targetParams["startunix"] = H.GetVar("startunix");} | ||||
|       if (H.GetVar("stopunix") != ""){targetParams["stopunix"] = H.GetVar("stopunix");} | ||||
|       if (H.GetVar("buffer") != ""){targetParams["buffer"] = H.GetVar("buffer");} | ||||
|       // allow setting of play back rate through buffer variable.
 | ||||
|       // play back rate is set in MS per second, but the variable is a simple multiplier.
 | ||||
|       if (H.GetVar("rate") != ""){ | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Thulinma
						Thulinma