| 526 | } |
| 527 | |
| 528 | int CRcvBuffer::readBufferTo(int len, copy_to_dst_f funcCopyToDst, void* arg) |
| 529 | { |
| 530 | int p = m_iStartPos; |
| 531 | const int end_pos = m_iFirstNonreadPos; |
| 532 | |
| 533 | const bool bTsbPdEnabled = m_tsbpd.isEnabled(); |
| 534 | const steady_clock::time_point now = (bTsbPdEnabled ? steady_clock::now() : steady_clock::time_point()); |
| 535 | |
| 536 | int rs = len; |
| 537 | while ((p != end_pos) && (rs > 0)) |
| 538 | { |
| 539 | if (!m_entries[p].pUnit) |
| 540 | { |
| 541 | p = incPos(p); |
| 542 | LOGC(rbuflog.Error, log << "readBufferTo: IPE: NULL unit found in file transmission"); |
| 543 | return -1; |
| 544 | } |
| 545 | |
| 546 | const srt::CPacket& pkt = packetAt(p); |
| 547 | |
| 548 | if (bTsbPdEnabled) |
| 549 | { |
| 550 | const steady_clock::time_point tsPlay = getPktTsbPdTime(pkt.getMsgTimeStamp()); |
| 551 | HLOGC(rbuflog.Debug, |
| 552 | log << "readBuffer: check if time to play:" |
| 553 | << " NOW=" << FormatTime(now) |
| 554 | << " PKT TS=" << FormatTime(tsPlay)); |
| 555 | |
| 556 | if ((tsPlay > now)) |
| 557 | break; /* too early for this unit, return whatever was copied */ |
| 558 | } |
| 559 | |
| 560 | const int pktlen = (int)pkt.getLength(); |
| 561 | const int remain_pktlen = pktlen - m_iNotch; |
| 562 | const int unitsize = std::min(remain_pktlen, rs); |
| 563 | |
| 564 | if (!funcCopyToDst(pkt.m_pcData + m_iNotch, unitsize, len - rs, arg)) |
| 565 | break; |
| 566 | |
| 567 | if (rs >= remain_pktlen) |
| 568 | { |
| 569 | releaseUnitInPos(p); |
| 570 | p = incPos(p); |
| 571 | m_iNotch = 0; |
| 572 | |
| 573 | m_iStartPos = p; |
| 574 | --m_iMaxPosOff; |
| 575 | SRT_ASSERT(m_iMaxPosOff >= 0); |
| 576 | m_iStartSeqNo = CSeqNo::incseq(m_iStartSeqNo); |
| 577 | } |
| 578 | else |
| 579 | m_iNotch += rs; |
| 580 | |
| 581 | rs -= unitsize; |
| 582 | } |
| 583 | |
| 584 | const int iBytesRead = len - rs; |
| 585 | /* we removed acked bytes form receive buffer */ |
nothing calls this directly
no test coverage detected