Fixed RTMP offsets and VoD seeking
This commit is contained in:
		
							parent
							
								
									781d32e9a2
								
							
						
					
					
						commit
						8710a8b988
					
				
					 2 changed files with 23 additions and 10 deletions
				
			
		|  | @ -260,6 +260,9 @@ namespace Mist { | ||||||
|     static bool multiWrong = false; |     static bool multiWrong = false; | ||||||
|     //Save the trackid of the track for easier access
 |     //Save the trackid of the track for easier access
 | ||||||
|     unsigned long tid = pack.getTrackId(); |     unsigned long tid = pack.getTrackId(); | ||||||
|  |     if (myMeta.live && pack.getTime() > 0xFFFF0000 && !myMeta.tracks[tid].lastms){ | ||||||
|  |       return;//ignore bullshit timestamps
 | ||||||
|  |     } | ||||||
|     if (myMeta.live && pack.getTime() < myMeta.tracks[tid].lastms){ |     if (myMeta.live && pack.getTime() < myMeta.tracks[tid].lastms){ | ||||||
|       DEBUG_MSG(multiWrong?DLVL_HIGH:DLVL_WARN, "Wrong order on track %lu ignored: %lu < %lu", tid, pack.getTime(), myMeta.tracks[tid].lastms); |       DEBUG_MSG(multiWrong?DLVL_HIGH:DLVL_WARN, "Wrong order on track %lu ignored: %lu < %lu", tid, pack.getTime(), myMeta.tracks[tid].lastms); | ||||||
|       multiWrong = true; |       multiWrong = true; | ||||||
|  |  | ||||||
|  | @ -170,13 +170,21 @@ namespace Mist { | ||||||
| 
 | 
 | ||||||
|     //If there are now more selectable tracks, select the new track and do a seek to the current timestamp
 |     //If there are now more selectable tracks, select the new track and do a seek to the current timestamp
 | ||||||
|     //Set sentHeader to false to force it to send init data
 |     //Set sentHeader to false to force it to send init data
 | ||||||
|     if (selectedTracks.size() < 2 && myMeta.tracks.size() > 1){ |     if (myMeta.live && selectedTracks.size() < 2){ | ||||||
|       size_t prevTrackCount = selectedTracks.size(); |       static unsigned long long lastMeta = 0; | ||||||
|       selectDefaultTracks(); |       if (Util::epoch() > lastMeta + 5){ | ||||||
|       if (selectedTracks.size() > prevTrackCount){ |         lastMeta = Util::epoch(); | ||||||
|         INFO_MSG("Picked up new track - selecting it and resetting state."); |         updateMeta(); | ||||||
|         sentHeader = false; |         if (myMeta.tracks.size() > 1){ | ||||||
|         seek(thisPacket.getTime()); |           size_t prevTrackCount = selectedTracks.size(); | ||||||
|  |           selectDefaultTracks(); | ||||||
|  |           if (selectedTracks.size() > prevTrackCount){ | ||||||
|  |             INFO_MSG("Picked up new track - selecting it and resetting state."); | ||||||
|  |             sentHeader = false; | ||||||
|  |             initialSeek(); | ||||||
|  |             return; | ||||||
|  |           } | ||||||
|  |         } | ||||||
|       } |       } | ||||||
|       return; |       return; | ||||||
|     } |     } | ||||||
|  | @ -278,6 +286,7 @@ namespace Mist { | ||||||
|     data_len += dheader_len; |     data_len += dheader_len; | ||||||
|      |      | ||||||
|     unsigned int timestamp = thisPacket.getTime() - rtmpOffset; |     unsigned int timestamp = thisPacket.getTime() - rtmpOffset; | ||||||
|  |     if (rtmpOffset > thisPacket.getTime()){timestamp = 0;}//make sure we don't go negative
 | ||||||
|      |      | ||||||
|     bool allow_short = RTMPStream::lastsend.count(4); |     bool allow_short = RTMPStream::lastsend.count(4); | ||||||
|     RTMPStream::Chunk & prev = RTMPStream::lastsend[4]; |     RTMPStream::Chunk & prev = RTMPStream::lastsend[4]; | ||||||
|  | @ -740,9 +749,10 @@ namespace Mist { | ||||||
|       amfreply.getContentP(3)->addContent(AMF::Object("description", "Playing!")); |       amfreply.getContentP(3)->addContent(AMF::Object("description", "Playing!")); | ||||||
|       amfreply.getContentP(3)->addContent(AMF::Object("details", "DDV")); |       amfreply.getContentP(3)->addContent(AMF::Object("details", "DDV")); | ||||||
|       amfreply.getContentP(3)->addContent(AMF::Object("clientid", (double)1337)); |       amfreply.getContentP(3)->addContent(AMF::Object("clientid", (double)1337)); | ||||||
|       initialSeek(); |       if (myMeta.live){ | ||||||
|       rtmpOffset = currentTime(); |         rtmpOffset = currentTime(); | ||||||
|       amfreply.getContentP(3)->addContent(AMF::Object("timecodeOffset", (double)rtmpOffset)); |         amfreply.getContentP(3)->addContent(AMF::Object("timecodeOffset", (double)rtmpOffset)); | ||||||
|  |       } | ||||||
|       sendCommand(amfreply, playMessageType, playStreamId); |       sendCommand(amfreply, playMessageType, playStreamId); | ||||||
|       RTMPStream::chunk_snd_max = 10240000; //10000KiB
 |       RTMPStream::chunk_snd_max = 10240000; //10000KiB
 | ||||||
|       myConn.SendNow(RTMPStream::SendCTL(1, RTMPStream::chunk_snd_max)); //send chunk size max (msg 1)
 |       myConn.SendNow(RTMPStream::SendCTL(1, RTMPStream::chunk_snd_max)); //send chunk size max (msg 1)
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Thulinma
						Thulinma