MCPcopy Create free account
hub / github.com/Haivision/srt / PackControl

Method PackControl

srtcore/fec.cpp:724–773  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

722}
723
724void FECFilterBuiltin::PackControl(const Group& g, signed char index, SrtPacket& pkt, int32_t seq)
725{
726 // Allocate as much space as needed, regardless of the PAYLOADSIZE value.
727
728 static const size_t INDEX_SIZE = 1;
729
730 size_t total_size =
731 INDEX_SIZE
732 + sizeof(g.flag_clip)
733 + sizeof(g.length_clip)
734 + g.payload_clip.size();
735
736 // Sanity
737#if ENABLE_DEBUG
738 if (g.output_buffer.size() < total_size)
739 {
740 LOGC(pflog.Fatal, log << "OUTPUT BUFFER TOO SMALL!");
741 abort();
742 }
743#endif
744
745 char* out = pkt.buffer;
746 size_t off = 0;
747 // Spread the index. This is the index of the payload in the vertical group.
748 // For horizontal group this value is always -1.
749 out[off++] = index;
750 // Flags, currently only the encryption flags
751 out[off++] = g.flag_clip;
752
753 // Ok, now the length clip
754 memcpy((out + off), &g.length_clip, sizeof g.length_clip);
755 off += sizeof g.length_clip;
756
757 // And finally the payload clip
758 memcpy((out + off), &g.payload_clip[0], g.payload_clip.size());
759
760 // Ready. Now fill the header and finalize other data.
761 pkt.length = total_size;
762
763 pkt.hdr[SRT_PH_TIMESTAMP] = g.timestamp_clip;
764 pkt.hdr[SRT_PH_SEQNO] = seq;
765
766 HLOGC(pflog.Debug, log << "FEC: PackControl: hdr("
767 << (total_size - g.payload_clip.size()) << "): INDEX="
768 << int(index) << " LENGTH[ne]=" << hex << g.length_clip
769 << " FLAGS=" << int(g.flag_clip) << " TS=" << g.timestamp_clip
770 << " PL(" << dec << g.payload_clip.size() << ")[0-4]=" << hex
771 << (*(uint32_t*)&g.payload_clip[0]));
772
773}
774
775bool FECFilterBuiltin::receive(const CPacket& rpkt, loss_seqs_t& loss_seqs)
776{

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected