Commit 8521737f authored by Andreas Schmidt's avatar Andreas Schmidt

CodingParams are not as a reference in a Block.

parent 4ac61e73
Pipeline #1083 failed with stages
in 43 seconds
......@@ -68,12 +68,12 @@ bool PrrtBlock_destroy(PrrtBlock *block_ptr)
return false;
}
PrrtBlock * PrrtBlock_create(const PrrtCodingParams *cpar, prrtSequenceNumber_t baseSequenceNumber)
PrrtBlock * PrrtBlock_create(PrrtCodingParams *cpar, prrtSequenceNumber_t baseSequenceNumber)
{
PrrtBlock *block_ptr = calloc(1, sizeof(PrrtBlock));
check_mem(block_ptr);
block_ptr->codingParams = *cpar;
block_ptr->codingParams = cpar;
block_ptr->dataPackets = List_create();
block_ptr->redundancyPackets = List_create();
block_ptr->baseSequenceNumber = baseSequenceNumber;
......@@ -142,7 +142,7 @@ bool PrrtBlock_insert_redundancy_packet(PrrtBlock *block_ptr, const PrrtPacket *
bool PrrtBlock_encode_ready(PrrtBlock *block_ptr)
{
check(pthread_mutex_lock(&block_ptr->lock) == EXIT_SUCCESS, "Lock failed.");
bool res = List_count(block_ptr->dataPackets) == block_ptr->codingParams.k;
bool res = List_count(block_ptr->dataPackets) == block_ptr->codingParams->k;
check(pthread_mutex_unlock(&block_ptr->lock) == EXIT_SUCCESS, "Unlock failed.");
return res;
......@@ -154,7 +154,7 @@ bool PrrtBlock_encode_ready(PrrtBlock *block_ptr)
bool PrrtBlock_decode_ready(PrrtBlock *block_ptr)
{
check(pthread_mutex_lock(&block_ptr->lock) == EXIT_SUCCESS, "Lock failed.");
bool res = (List_count(block_ptr->dataPackets) + List_count(block_ptr->redundancyPackets) == block_ptr->codingParams.k);
bool res = (List_count(block_ptr->dataPackets) + List_count(block_ptr->redundancyPackets) == block_ptr->codingParams->k);
check(pthread_mutex_unlock(&block_ptr->lock) == EXIT_SUCCESS, "Unlock failed.");
return res;
......@@ -179,12 +179,12 @@ void PrrtBlock_encode(PrrtBlock *block_ptr, prrtSequenceNumber_t *seqno)
{
check(pthread_mutex_lock(&block_ptr->lock) == EXIT_SUCCESS, "Lock failed.");
int j = 0;
uint8_t k = block_ptr->codingParams.k;
uint8_t r = block_ptr->codingParams.r;
uint8_t k = block_ptr->codingParams->k;
uint8_t r = block_ptr->codingParams->r;
prrtSequenceNumber_t baseSequenceNumber = block_ptr->baseSequenceNumber;
prrtPacketLength_t length = block_ptr->largestDataLength;
PrrtCoder *coder = block_ptr->codingParams.coder;
PrrtCoder *coder = block_ptr->codingParams->coder;
gf **src = calloc(k, sizeof(gf *));
check_mem(src);
......@@ -233,11 +233,11 @@ bool PrrtBlock_decode(PrrtBlock *block_ptr)
int *idx_p = NULL;
uint8_t k = 0;
check(pthread_mutex_lock(&block_ptr->lock) == EXIT_SUCCESS, "Lock failed.");
k = block_ptr->codingParams.k;
k = block_ptr->codingParams->k;
prrtSequenceNumber_t baseSequenceNumber = block_ptr->baseSequenceNumber;
prrtPacketLength_t length = block_ptr->largestDataLength;
PrrtCoder *coder = block_ptr->codingParams.coder;
PrrtCoder *coder = block_ptr->codingParams->coder;
fec = calloc(k, sizeof(gf *));
check_mem(fec);
......
......@@ -7,7 +7,7 @@
#include "../util/list.h"
typedef struct prrtBlock {
PrrtCodingParams codingParams;
PrrtCodingParams* codingParams;
prrtPacketLength_t largestDataLength;
prrtSequenceNumber_t baseSequenceNumber;
List*dataPackets;
......@@ -21,7 +21,7 @@ typedef struct prrtBlock {
/**
* Allocate space for a block.
*/
PrrtBlock * PrrtBlock_create(const PrrtCodingParams *cpar, prrtSequenceNumber_t baseSequenceNumber);
PrrtBlock * PrrtBlock_create(PrrtCodingParams *cpar, prrtSequenceNumber_t baseSequenceNumber);
/**
* Frees the PrrtBlock data structure.
......
......@@ -453,7 +453,7 @@ PrrtPacket *PrrtPacket_create_data_packet(uint8_t priority, const void *payloadP
PrrtPacket *PrrtPacket_create_redundancy_packet(uint8_t priority, void *payloadPointer,
prrtPacketLength_t payloadLength,
prrtSequenceNumber_t sequenceNumber, uint8_t index,
prrtSequenceNumber_t baseSequenceNumber, PrrtCodingParams codingParams)
prrtSequenceNumber_t baseSequenceNumber, PrrtCodingParams* codingParams)
{
PrrtPacket *packet = create_header(priority, sequenceNumber,
(prrtPacketLength_t) (payloadLength + PRRT_PACKET_REDUNDANCY_HEADER_SIZE),
......@@ -464,8 +464,8 @@ PrrtPacket *PrrtPacket_create_redundancy_packet(uint8_t priority, void *payloadP
packet->payload = redundancyPayload;
redundancyPayload->baseSequenceNumber = baseSequenceNumber;
redundancyPayload->k = codingParams.k;
redundancyPayload->n = codingParams.n;
redundancyPayload->k = codingParams->k;
redundancyPayload->n = codingParams->n;
PrrtPacket_copy_buffer_to_payload(packet, payloadPointer, PRRT_PACKET_REDUNDANCY_HEADER_SIZE);
return packet;
......
......@@ -93,7 +93,7 @@ PrrtPacket *PrrtPacket_create_feedback_packet(uint8_t priority, uint8_t index, p
PrrtPacket *PrrtPacket_create_redundancy_packet(uint8_t priority, void *payloadPointer,
prrtPacketLength_t payloadLength,
prrtSequenceNumber_t sequenceNumber, uint8_t index,
prrtSequenceNumber_t baseSequenceNumber, PrrtCodingParams codingParams);
prrtSequenceNumber_t baseSequenceNumber, PrrtCodingParams* codingParams);
bool PrrtPacket_decode(void *srcBuffer, uint16_t srcBufferSize, PrrtPacket *targetPacket);
......
......@@ -170,7 +170,7 @@ static void handle_redundancy_packet(PrrtSocket *socket, PrrtPacket *packet)
PrrtRepairBlockStore_insert(socket->repairBlockStore, block);
}
retrieve_data_blocks(socket, redundancyPayload->baseSequenceNumber, block->codingParams.k, block);
retrieve_data_blocks(socket, redundancyPayload->baseSequenceNumber, block->codingParams->k, block);
if(PrrtBlock_insert_redundancy_packet(block, packet)) {
decode_block(socket, block);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment