Skip to content

Commit

Permalink
improve video fec
Browse files Browse the repository at this point in the history
  • Loading branch information
Consti10 committed Jan 7, 2024
1 parent f66357f commit 449855a
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/WBStreamRx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,7 @@ void WBStreamRx::reset_stream_stats() {
m_n_input_bytes=0;
m_n_input_packets=0;
}

void WBStreamRx::set_on_fec_block_done_cb(WBStreamRx::ON_BLOCK_DONE_CB cb) {
m_fec_decoder->m_block_done_cb=cb;
}
4 changes: 4 additions & 0 deletions src/WBStreamRx.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ class WBStreamRx {
};
FECRxStats2 get_latest_fec_stats();
void reset_stream_stats();
// DIRTY AF !
typedef std::function<void(uint64_t block_idx,int n_fragments_total,int n_fragments_forwarded)>
ON_BLOCK_DONE_CB;
void set_on_fec_block_done_cb(ON_BLOCK_DONE_CB cb);
private:
const Options m_options;
std::shared_ptr<WBTxRx> m_txrx;
Expand Down
6 changes: 6 additions & 0 deletions src/fec/FECDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ void FECDecoder::rxQueuePopFront() {
block.get_missing_primary_packets_readable());
}
}
if(m_block_done_cb){
auto& block = *rx_queue.front();
const int n_p_fragments=block.get_n_primary_fragments();
const int n_p_fragments_forwarded=block.get_n_forwarded_primary_fragments();
m_block_done_cb(block.getBlockIdx(),n_p_fragments,n_p_fragments_forwarded);
}
rx_queue.pop_front();
}

Expand Down
4 changes: 4 additions & 0 deletions src/fec/FECDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ class FECDecoder {
SEND_DECODED_PACKET;
// WARNING: Don't forget to register this callback !
SEND_DECODED_PACKET mSendDecodedPayloadCallback;
// Experimental
typedef std::function<void(uint64_t block_idx,int n_fragments_total,int n_fragments_forwarded)>
ON_BLOCK_DONE_CB;
ON_BLOCK_DONE_CB m_block_done_cb= nullptr;
// A value too high doesn't really give much benefit and increases memory
// usage
const unsigned int RX_QUEUE_MAX_SIZE;
Expand Down
5 changes: 4 additions & 1 deletion src/fec/RxBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,7 @@ std::string RxBlock::get_missing_primary_packets_readable() const {

int RxBlock::get_n_primary_fragments() const {
return m_n_primary_fragments_in_block;
}
}
int RxBlock::get_n_forwarded_primary_fragments() const {
return nAlreadyForwardedPrimaryFragments;
}
1 change: 1 addition & 0 deletions src/fec/RxBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class RxBlock {
std::optional<int> get_missing_primary_packets() const;
std::string get_missing_primary_packets_readable() const;
int get_n_primary_fragments() const;
int get_n_forwarded_primary_fragments()const;

private:
// the block idx marks which block this element refers to
Expand Down

0 comments on commit 449855a

Please sign in to comment.