block.h 1.24 KB
Newer Older
1 2 3
#ifndef PRRT_BLOCK_H
#define PRRT_BLOCK_H

Andreas Schmidt's avatar
Andreas Schmidt committed
4
#include <stdbool.h>
Andreas Schmidt's avatar
Andreas Schmidt committed
5
#include "codingParams.h"
6
#include "types/packet.h"
7
#include "../util/list.h"
Andreas Schmidt's avatar
Andreas Schmidt committed
8
#include "vdmcode/block_code.h"
Andreas Schmidt's avatar
Andreas Schmidt committed
9

10
typedef struct prrtBlock {
11
    PrrtCodingConfiguration* codingParams;
rna's avatar
rna committed
12
    prrtPacketLength_t largestPayloadLength;
13
    prrtSequenceNumber_t baseSequenceNumber;
14 15
    List*dataPackets;
    List*redundancyPackets;
16
    bool isCoded;
Andreas Schmidt's avatar
Andreas Schmidt committed
17
    pthread_mutex_t lock;
18
    PrrtCoder *coder;
Andreas Schmidt's avatar
Andreas Schmidt committed
19 20 21 22 23 24
} PrrtBlock;


/**
 * Allocate space for a block.
 */
25
PrrtBlock * PrrtBlock_create(PrrtCodingConfiguration *cpar, PrrtCoder* coder, prrtSequenceNumber_t baseSequenceNumber);
Andreas Schmidt's avatar
Andreas Schmidt committed
26 27 28 29

/**
 * Frees the PrrtBlock data structure.
 */
Andreas Schmidt's avatar
Andreas Schmidt committed
30
bool PrrtBlock_destroy(PrrtBlock *block_ptr);
Andreas Schmidt's avatar
Andreas Schmidt committed
31

Andreas Schmidt's avatar
Andreas Schmidt committed
32
bool PrrtBlock_insert_data_packet(PrrtBlock *block_ptr, const PrrtPacket *prrtPacket);
33
bool PrrtBlock_insert_redundancy_packet(PrrtBlock *prrtBlock, const PrrtPacket *prrtPacket);
34

Andreas Schmidt's avatar
Andreas Schmidt committed
35 36
bool PrrtBlock_encode_ready(PrrtBlock *block_ptr);
bool PrrtBlock_decode_ready(PrrtBlock *block_ptr);
37 38 39

PrrtPacket *PrrtBlock_get_first_data(PrrtBlock *block_ptr);

40
void PrrtBlock_encode(PrrtBlock *block_ptr, prrtSequenceNumber_t *seqno);
41
bool PrrtBlock_decode(PrrtBlock *block_ptr);
42

43
PrrtPacket *PrrtBlock_get_first_red_data(PrrtBlock *block_ptr);
44 45

#endif //PRRT_BLOCK_H