From: Andreas Ă–man Date: Tue, 26 Oct 2010 19:08:38 +0000 (+0000) Subject: Add some helpers X-Git-Tag: 2.12~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b7cc8e29610b4bab2b8ecb7959d318886b40f4f3;p=thirdparty%2Ftvheadend.git Add some helpers --- diff --git a/src/packet.c b/src/packet.c index 972c4526c..c3efdb0f2 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 0ed40ad59..836c2d551 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);