+ // This fragment is lost, It was around the buffer and it was never completed the packet.
+ LOG(3, this_fragmentation->fragment[frag_index_prev].sid, this_fragmentation->fragment[frag_index_prev].tid,
+ "MPPP: (PREV) seq_num:%d frag_index:%d flags:%d jitteravg:%d is LOST\n",
+ this_fragmentation->fragment[frag_index_prev].seq, frag_index_prev,
+ this_fragmentation->fragment[frag_index_prev].flags, this_fragmentation->fragment[frag_index_prev].jitteravg);
+
+ this_fragmentation->fragment[frag_index_prev].length = 0;
+ this_fragmentation->fragment[frag_index_prev].flags = 0;
+
+ if (end_frame && (!begin_frame)) return; // assembling frame failed
+ }
+ }
+
+find_frame:
+ begin_index = this_fragmentation->start_index;
+ uint32_t b_seq = this_fragmentation->start_seq;
+ // Try to find a Begin sequence from the start_seq sequence to M sequence
+ while (b_seq < Mmin)
+ {
+ if (this_fragmentation->fragment[begin_index].length)
+ {
+ if (b_seq == this_fragmentation->fragment[begin_index].seq)
+ {
+ if (this_fragmentation->fragment[begin_index].flags & MP_BEGIN)
+ {
+ int isfoundE = 0;
+ // Adjust the new start sequence and start index
+ this_fragmentation->start_index = begin_index;
+ this_fragmentation->start_seq = b_seq;
+ // Begin Sequence found, now try to found the End Sequence to complete the frame
+ end_index = begin_index;
+ while (b_seq < Mmin)
+ {
+ if (this_fragmentation->fragment[end_index].length)
+ {
+ if (b_seq == this_fragmentation->fragment[end_index].seq)
+ {
+ if (this_fragmentation->fragment[end_index].flags & MP_END)
+ {
+ // The End sequence was found and the frame is complete
+ isfoundE = 1;
+ break;
+ }
+ }
+ else
+ {
+ // This fragment is lost, it was never completed the packet.
+ LOG(3, this_fragmentation->fragment[end_index].sid, this_fragmentation->fragment[end_index].tid,
+ "MPPP: (FIND END) seq_num:%d frag_index:%d flags:%d jitteravg:%d is LOST\n",
+ this_fragmentation->fragment[end_index].seq, begin_index,
+ this_fragmentation->fragment[end_index].flags, this_fragmentation->fragment[end_index].jitteravg);
+ // this frag is lost
+ this_fragmentation->fragment[end_index].length = 0;
+ this_fragmentation->fragment[end_index].flags = 0;
+ // This frame is not complete find the next Begin
+ break;
+ }
+ }
+ else
+ {
+ // This frame is not complete find the next Begin if exist
+ break;
+ }
+ end_index = (end_index +1) & MAXFRAGNUM_MASK;
+ b_seq++;
+ }
+
+ if (isfoundE)
+ // The End sequence was found and the frame is complete
+ break;
+ else
+ // find the next Begin
+ begin_index = end_index;
+ }
+ }
+ else
+ {
+ // This fragment is lost, it was never completed the packet.
+ LOG(3, this_fragmentation->fragment[begin_index].sid, this_fragmentation->fragment[begin_index].tid,
+ "MPPP: (FIND BEGIN) seq_num:%d frag_index:%d flags:%d jitteravg:%d is LOST\n",
+ this_fragmentation->fragment[begin_index].seq, begin_index,
+ this_fragmentation->fragment[begin_index].flags, this_fragmentation->fragment[begin_index].jitteravg);
+ // this frag is lost
+ this_fragmentation->fragment[begin_index].length = 0;
+ this_fragmentation->fragment[begin_index].flags = 0;
+ }