source: svn/newcon3bcm2_21bu/BSEAV/lib/utils/biovec.h @ 46

Last change on this file since 46 was 46, checked in by megakiss, 11 years ago

459Mhz로 OTC 주파수 변경

  • Property svn:executable set to *
File size: 6.6 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2006-2007, Broadcom Corporation
3 *     All Rights Reserved
4 *     Confidential Property of Broadcom Corporation
5 *
6 *  THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7 *  AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8 *  EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9 *
10 * $brcm_Workfile: biovec.h $
11 * $brcm_Revision: 9 $
12 * $brcm_Date: 2/5/07 5:32p $
13 *
14 * Module Description:
15 *
16 * ASF parser library
17 *
18 * Revision History:
19 *
20 * $brcm_Log: /BSEAV/lib/utils/biovec.h $
21 *
22 * 9   2/5/07 5:32p vsilyaev
23 * PR 25701: Fixed typo
24 *
25 * 8   10/6/06 1:57p vsilyaev
26 * PR24127: Don't use  memcpy (include <string.h> conflicts with a 2.6
27 * kernel build)
28 *
29 * 7   4/14/06 10:07a vsilyaev
30 * PR 20308: Added way to pause a ASF parser from a object handler
31 *
32 * 6   4/13/06 3:14p vsilyaev
33 * PR 20308: Improved API description
34 *
35 * 5   4/7/06 12:29p vsilyaev
36 * PR 20683: added basf_player
37 *
38 * 4   4/5/06 4:18p vsilyaev
39 * PR 20308: Rerranged data flow to accumulate entire media object, before
40 * converting to PES
41 *
42 * 3   4/3/06 5:59p vsilyaev
43 * PR 20577: optimized bio_cursor_copy function
44 *
45 * 2   3/30/06 4:04p vsilyaev
46 * PR 20308: Support for looped streams
47 *
48 * 1   3/28/06 11:02a vsilyaev
49 * PR 20308: ASF parser library
50 *
51 *******************************************************************************/
52
53#ifndef _BIOVEC_H__
54#define _BIOVEC_H__
55
56#define B_IOVEC_FAST    1
57#ifndef B_IOVEC_memcpy
58/* use memcpy in body of the bio_cursor_copy */
59/* #define B_IOVEC_memcpy 1 */
60#endif
61
62#ifdef __cplusplus
63extern "C"
64{
65#endif
66
67/* this type is used to define I/O vector */
68typedef struct bio_vec {
69        void *base;   /* Starting address */
70        size_t len;   /* Number of bytes */
71} bio_vec;
72
73#define B_IO_ARRAY_INLINE       2
74/* this type is used to describe Array of I/O vectors */
75typedef struct bio_array {
76        unsigned count; /* number of entrries in the array */
77        bio_vec *vec; /* variable length array */
78        bio_vec vec_[B_IO_ARRAY_INLINE]; /* inline array */
79        unsigned size; /* number of allocated entries */
80        size_t length; /* total length of data accumulated in the array */
81        bio_vec const *owner_[B_IO_ARRAY_INLINE];
82        bio_vec const * * owner; 
83}bio_array;
84
85/* this type is used to define read-only cursor for the array of I/O vectors */
86typedef struct bio_cursor {
87        const uint8_t *cursor;
88        int     left;
89        unsigned pos;
90        const bio_array *array;
91} bio_cursor;
92#define BIO_CURSOR_DUMP(DBG, header, cursor) DBG((header "%#lx cursor:%#lx left:%d pos:%u array:%#x", (unsigned long)(cursor),  (cursor)->cursor, (cursor)->left, (cursor)->pos, (unsigned long)(cursor)->array))
93
94/* this type is used to save read position in the cursor */
95typedef struct bio_checkpoint {
96        int     left;
97        unsigned pos;
98} bio_checkpoint;
99
100/* this function initializes array */
101void bio_array_init(bio_array *array);
102/* this function created array from list of the I/O vectors */
103void bio_array_from_iov(bio_array *array, const bio_vec *vec, unsigned count);
104
105/* this function sets array length to zero */
106void bio_array_reset(bio_array *array);
107
108/* this function releases all resources allocated for the array */
109void bio_array_shutdown(bio_array *array);
110
111/* this function appends vector  to the array */
112size_t bio_array_add_vec(bio_array *array, const bio_vec *vec);
113
114/* this function appends block of memory to the array */
115size_t bio_array_add(bio_array *array, const void *base, size_t len);
116
117/* this function is used to trim array at current cursor position, the iov_free function would be called for each I/O vector removed from the array */
118size_t bio_array_trim(bio_array *array, bio_cursor *cursor, void (*iov_free)(void *cnxt, const bio_vec *v), void *cnxt);
119
120size_t bio_array_len(const bio_array *array);
121
122
123/* this function is used to initialize cursor from array, after initialization cursor will point to first byte in the array */
124void bio_cursor_init(bio_cursor *cursor, const bio_array *array);
125/* this function is used to initialize cursor from list of I/O vectors, after initialization cursor will point to first byte in the first I/O vector*/
126void bio_cursor_from_iov(bio_cursor *cursor, bio_array *array, const bio_vec *vec, unsigned count);
127/* this function is used to initialize cursor from the memory range, after initialization cursor will point to first byte */
128void bio_cursor_from_range(bio_cursor *cursor, bio_array *array, const void *base, size_t len);
129/* this function is used to create empty cursor */
130void bio_cursor_empty(bio_cursor *cursor);
131
132/* this function saves current cursor position to the checkpoint */
133void bio_cursor_save(const bio_cursor *cursor, bio_checkpoint *checkpoint);
134/* this function restores cursor's position from the checkpoint */
135void bio_cursor_rollback(bio_cursor *cursor, const bio_checkpoint *checkpoint);
136/* this function extracts one I/O vector from the cursor, and then advanced to number of extracted bytes, if EOF reached function will return 0 */
137size_t bio_cursor_get(bio_cursor *cursor, size_t size, bio_vec *vec, bio_vec const **owner);
138
139#define BIO_EOF (-1)
140
141/* this function reads next byte from the cursor, if EOF reached it will return BIO_EOF */
142int bio_cursor_next(bio_cursor *cursor);
143/* this function advances current cursor position to 'count' bytes */
144void bio_cursor_skip(bio_cursor *cursor, size_t count);
145
146/* this function reserves 'count' bytes in the cursor, it returns number of bytes that were actually reserved */
147size_t bio_cursor_reserve(bio_cursor *cursor, size_t count);
148
149/* this function copies 'count' bytes from the cursor, it returns number of bytes actually copied */
150size_t bio_cursor_copy(bio_cursor *cursor, void *dest, size_t count);
151
152/* this function returns true if there is nothing to read from the cursor */
153bool bio_cursor_eof(const bio_cursor *cursor);
154/* this function returns current position in the cursor */
155size_t bio_cursor_pos(const bio_cursor *cursor);
156
157/* this function returns new cursor, intenticaled to the old one */
158void bio_cursor_clone(bio_cursor *dst, const bio_cursor *src);
159
160#if B_IOVEC_FAST
161#define BIO_NEXT(d,c) do {if((c)->left>0) {(c)->left--;d=*(c)->cursor++;} else {d=bio_cursor_next(c);}}while(0)
162#define BIO_IS_EOF(c) ((c)->left<0)
163#define BIO_SAVE(cur,check) do {(check)->left=(cur)->left;(check)->pos=(cur)->pos;}while(0)
164#define BIO_ALEN(a) ((a)->length)
165#define BIO_CLONE(dst,src) *(dst)=*(src)
166#else
167#define BIO_NEXT(d,c) (d)=bio_cursor_next(c)
168#define BIO_IS_EOF(c) bio_cursor_eof(c)
169#define BIO_SAVE(cur,check) bio_cursor_save((cur),(check))
170#define BIO_ALEN(a) bio_array_len(a)
171#define BIO_CLONE(dst,src) bio_cursor_clone((dst),(src))
172#endif
173
174#ifdef __cplusplus
175}
176#endif
177
178#endif /* _BIOVEC_H__ */
179
180
Note: See TracBrowser for help on using the repository browser.