diff --git a/src/packet.c b/src/packet.c index 972c4526..c3efdb0f 100644 --- a/src/packet.c +++ b/src/packet.c @@ -101,6 +101,30 @@ pktref_clear_queue(struct th_pktref_queue *q) } +/** + * Reference count is transfered to queue + */ +void +pktref_enqueue(struct th_pktref_queue *q, th_pkt_t *pkt) +{ + th_pktref_t *pr = malloc(sizeof(th_pktref_t)); + pr->pr_pkt = pkt; + TAILQ_INSERT_TAIL(q, pr, pr_link); +} + + +/** + * + */ +void +pktref_remove(struct th_pktref_queue *q, th_pktref_t *pr) +{ + TAILQ_REMOVE(q, pr, pr_link); + pkt_ref_dec(pr->pr_pkt); + free(pr); +} + + /** * */ diff --git a/src/packet.h b/src/packet.h index 0ed40ad5..836c2d55 100644 --- a/src/packet.h +++ b/src/packet.h @@ -79,6 +79,12 @@ void pkt_ref_inc_poly(th_pkt_t *pkt, int n); void pktref_clear_queue(struct th_pktref_queue *q); +// Reference count is transfered to queue +void pktref_enqueue(struct th_pktref_queue *q, th_pkt_t *pkt); + +void pktref_remove(struct th_pktref_queue *q, th_pktref_t *pr); + + th_pkt_t *pkt_alloc(const void *data, size_t datalen, int64_t pts, int64_t dts); th_pkt_t *pkt_merge_header(th_pkt_t *pkt);