File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -180,7 +180,28 @@ extension RTMPSession {
180180 return true
181181
182182 case . only:
183- streamInBuffer. didRead ( 1 )
183+ guard let previousChunk = previousChunkMap [ chunk_stream_id] else {
184+ Logger . error ( " could not find previous chunk with stream id \( chunk_stream_id) " )
185+ return false
186+ }
187+ // the message length is the same as previous message.
188+ Logger . debug ( " Previous chunk length: \( previousChunk. msg_length) , " +
189+ " msgid: \( previousChunk. msg_type_id) , streamid: \( String ( describing: previousChunk. msg_stream_id) ) " )
190+ guard streamInBuffer. availableBytes >= 1 else {
191+ Logger . debug ( " Not enough a header " )
192+ // DEBUG only
193+ Logger . dumpBuffer ( " RTMPChunk3 ERROR " ,
194+ buf: streamInBuffer. readBuffer, size: streamInBuffer. availableBytes)
195+ return false
196+ }
197+ var msg : [ UInt8 ] = . init( repeating: 0 , count: Int ( previousChunk. msg_length) )
198+ let full_msgsize = tryReadOneMessage ( & msg, from_offset: 1 )
199+ guard full_msgsize > 0 else {
200+ Logger . debug ( " Not enough one message in buffer " )
201+ return false
202+ }
203+ streamInBuffer. didRead ( 1 + full_msgsize)
204+ handleMessage ( msg, msgTypeId: previousChunk. msg_type_id)
184205 return true
185206 }
186207 }
You can’t perform that action at this time.
0 commit comments