The realization of streaming media learning four--------ORTP queue

Source: Internet
Author: User

A common queue is implemented in ORTP, each of which consists of three entities, namely queues, message blocks, and data blocks, which correspond to queue_t, MSGB, and datab structures, respectively.

The definition of queue_t is as follows:

typedef struct _QUEUE {mblk_t _q_stopper;           /* Message Queue header */int Q_mcount; /*number of packet in the Q */} queue_t;
_q_stopper: A message block, embedded in queue_t, whose primary function is to act as a table header for the list; _q_stopper points to a mblk_t with no actual data, just as the header of the header of the message to the column. PUTQ or GETQ are all starting from the first mblk_t after _q_stopper. Q_mcount: Used to record the number of queue elements. To construct an empty message queue:
Note: void Qinit (queue_t *q) {
Mblk_init (&q->_q_stopper);
q->_q_stopper.b_next=&q->_q_stopper;
q->_q_stopper.b_prev=&q->_q_stopper;
q->q_mcount=0;
}
From the above initialization of a queue_t function can be learned that _q_stopper initialization, _q_stopper.b_next, _q_stopper.b_prev are pointing to _q_stopper their own.

The definition of mblk_t is as follows:

typedef struct MSGB {struct MSGB *b_prev;    /* Point to Previous message Block */struct MSGB *b_next;    /* point to the next message Block */struct MSGB *b_cont;  /* Compound message fast mblk_t */struct datab *b_datap;  /* Data block pointer */unsigned Char *b_rptr;  /* Data pointer read */unsigned char *b_wptr; /* Data pointer written */uint32_t reserved1;uint32_t RESERVED2;} mblk_t;
B_prev and B_next: The list pointer of the message block, in which all the message blocks are strung into chains through the two pointers. B_cout: This pointer can form a composite message block, the composite message block consists of multiple message blocks, but in the queue as an element B_DATAP: The data pointer of the message block, pointing to a data block B_RPTR: The data that points to the data block has been read part B_ WPTR: Part of the data that points to the data block has been written to reserved1 and reserved2: Reserved use

The definition of Datab is as follows:

typedef struct DATAB {unsigned char *db_base;/* Data base of data block */unsigned Char *db_lim; /* End address of the data portion of the data Block */void (*DB_FREEFN) (void *);             /* The release function of data block data */int db_ref; /* Data Block reference count */} dblk_t;
Db_base: Data base db_lim: End of data address db_freefn: function to release data for block Db_ref: reference count of data blocks

The realization of streaming media learning four--------ORTP queue

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.