1b3a6c5adSopenharmony_ci/*
2b3a6c5adSopenharmony_ci * Copyright (c) 2016 The Khronos Group Inc.
3b3a6c5adSopenharmony_ci *
4b3a6c5adSopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining
5b3a6c5adSopenharmony_ci * a copy of this software and associated documentation files (the
6b3a6c5adSopenharmony_ci * "Software"), to deal in the Software without restriction, including
7b3a6c5adSopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish,
8b3a6c5adSopenharmony_ci * distribute, sublicense, and/or sell copies of the Software, and to
9b3a6c5adSopenharmony_ci * permit persons to whom the Software is furnished to do so, subject
10b3a6c5adSopenharmony_ci * to the following conditions:
11b3a6c5adSopenharmony_ci * The above copyright notice and this permission notice shall be included
12b3a6c5adSopenharmony_ci * in all copies or substantial portions of the Software.
13b3a6c5adSopenharmony_ci *
14b3a6c5adSopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15b3a6c5adSopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16b3a6c5adSopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17b3a6c5adSopenharmony_ci * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18b3a6c5adSopenharmony_ci * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19b3a6c5adSopenharmony_ci * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20b3a6c5adSopenharmony_ci * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21b3a6c5adSopenharmony_ci *
22b3a6c5adSopenharmony_ci */
23b3a6c5adSopenharmony_ci
24b3a6c5adSopenharmony_ci/** OMX_ContentPipe.h - OpenMax IL version 1.1.2
25b3a6c5adSopenharmony_ci *  The OMX_ContentPipe header file contains the definitions used to define
26b3a6c5adSopenharmony_ci *  the public interface for content piples.  This header file is intended to
27b3a6c5adSopenharmony_ci *  be used by the component.
28b3a6c5adSopenharmony_ci */
29b3a6c5adSopenharmony_ci
30b3a6c5adSopenharmony_ci#ifndef OMX_CONTENTPIPE_H
31b3a6c5adSopenharmony_ci#define OMX_CONTENTPIPE_H
32b3a6c5adSopenharmony_ci
33b3a6c5adSopenharmony_ci#ifndef KD_EACCES
34b3a6c5adSopenharmony_ci/* OpenKODE error codes. CPResult values may be zero (indicating success
35b3a6c5adSopenharmony_ci   or one of the following values) */
36b3a6c5adSopenharmony_ci#define KD_EACCES (1)
37b3a6c5adSopenharmony_ci#define KD_EADDRINUSE (2)
38b3a6c5adSopenharmony_ci#define KD_EAGAIN (5)
39b3a6c5adSopenharmony_ci#define KD_EBADF (7)
40b3a6c5adSopenharmony_ci#define KD_EBUSY (8)
41b3a6c5adSopenharmony_ci#define KD_ECONNREFUSED (9)
42b3a6c5adSopenharmony_ci#define KD_ECONNRESET (10)
43b3a6c5adSopenharmony_ci#define KD_EDEADLK (11)
44b3a6c5adSopenharmony_ci#define KD_EDESTADDRREQ (12)
45b3a6c5adSopenharmony_ci#define KD_ERANGE (35)
46b3a6c5adSopenharmony_ci#define KD_EEXIST (13)
47b3a6c5adSopenharmony_ci#define KD_EFBIG (14)
48b3a6c5adSopenharmony_ci#define KD_EHOSTUNREACH (15)
49b3a6c5adSopenharmony_ci#define KD_EINVAL (17)
50b3a6c5adSopenharmony_ci#define KD_EIO (18)
51b3a6c5adSopenharmony_ci#define KD_EISCONN (20)
52b3a6c5adSopenharmony_ci#define KD_EISDIR (21)
53b3a6c5adSopenharmony_ci#define KD_EMFILE (22)
54b3a6c5adSopenharmony_ci#define KD_ENAMETOOLONG (23)
55b3a6c5adSopenharmony_ci#define KD_ENOENT (24)
56b3a6c5adSopenharmony_ci#define KD_ENOMEM (25)
57b3a6c5adSopenharmony_ci#define KD_ENOSPC (26)
58b3a6c5adSopenharmony_ci#define KD_ENOSYS (27)
59b3a6c5adSopenharmony_ci#define KD_ENOTCONN (28)
60b3a6c5adSopenharmony_ci#define KD_EPERM (33)
61b3a6c5adSopenharmony_ci#define KD_ETIMEDOUT (36)
62b3a6c5adSopenharmony_ci#define KD_EILSEQ (19)
63b3a6c5adSopenharmony_ci#endif
64b3a6c5adSopenharmony_ci
65b3a6c5adSopenharmony_ci/** Map types from OMX standard types only here so interface is as generic as possible. */
66b3a6c5adSopenharmony_citypedef OMX_U32    CPresult;
67b3a6c5adSopenharmony_citypedef char *     CPstring;
68b3a6c5adSopenharmony_citypedef void *     CPhandle;
69b3a6c5adSopenharmony_citypedef OMX_U32    CPuint;
70b3a6c5adSopenharmony_citypedef OMX_S32    CPint;
71b3a6c5adSopenharmony_citypedef char       CPbyte;
72b3a6c5adSopenharmony_citypedef OMX_BOOL   CPbool;
73b3a6c5adSopenharmony_ci
74b3a6c5adSopenharmony_ci/** enumeration of origin types used in the CP_PIPETYPE's Seek function
75b3a6c5adSopenharmony_ci * @ingroup cp
76b3a6c5adSopenharmony_ci */
77b3a6c5adSopenharmony_citypedef enum CP_ORIGINTYPE {
78b3a6c5adSopenharmony_ci    CP_OriginBegin,
79b3a6c5adSopenharmony_ci    CP_OriginCur,
80b3a6c5adSopenharmony_ci    CP_OriginEnd,
81b3a6c5adSopenharmony_ci    CP_OriginKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
82b3a6c5adSopenharmony_ci    CP_OriginVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
83b3a6c5adSopenharmony_ci    CP_OriginMax = 0X7FFFFFFF
84b3a6c5adSopenharmony_ci} CP_ORIGINTYPE;
85b3a6c5adSopenharmony_ci
86b3a6c5adSopenharmony_ci/** enumeration of contact access types used in the CP_PIPETYPE's Open function
87b3a6c5adSopenharmony_ci * @ingroup cp
88b3a6c5adSopenharmony_ci */
89b3a6c5adSopenharmony_citypedef enum CP_ACCESSTYPE {
90b3a6c5adSopenharmony_ci    CP_AccessRead,
91b3a6c5adSopenharmony_ci    CP_AccessWrite,
92b3a6c5adSopenharmony_ci    CP_AccessReadWrite ,
93b3a6c5adSopenharmony_ci    CP_AccessKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
94b3a6c5adSopenharmony_ci    CP_AccessVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
95b3a6c5adSopenharmony_ci    CP_AccessMax = 0X7FFFFFFF
96b3a6c5adSopenharmony_ci} CP_ACCESSTYPE;
97b3a6c5adSopenharmony_ci
98b3a6c5adSopenharmony_ci/** enumeration of results returned by the CP_PIPETYPE's CheckAvailableBytes function
99b3a6c5adSopenharmony_ci * @ingroup cp
100b3a6c5adSopenharmony_ci */
101b3a6c5adSopenharmony_citypedef enum CP_CHECKBYTESRESULTTYPE
102b3a6c5adSopenharmony_ci{
103b3a6c5adSopenharmony_ci    CP_CheckBytesOk,                    /**< There are at least the request number
104b3a6c5adSopenharmony_ci                                              of bytes available */
105b3a6c5adSopenharmony_ci    CP_CheckBytesNotReady,              /**< The pipe is still retrieving bytes
106b3a6c5adSopenharmony_ci                                              and presently lacks sufficient bytes.
107b3a6c5adSopenharmony_ci                                              Client will be called when they are
108b3a6c5adSopenharmony_ci                                              sufficient bytes are available. */
109b3a6c5adSopenharmony_ci    CP_CheckBytesInsufficientBytes  ,     /**< The pipe has retrieved all bytes
110b3a6c5adSopenharmony_ci                                              but those available are less than those
111b3a6c5adSopenharmony_ci                                              requested */
112b3a6c5adSopenharmony_ci    CP_CheckBytesAtEndOfStream,         /**< The pipe has reached the end of stream
113b3a6c5adSopenharmony_ci                                              and no more bytes are available. */
114b3a6c5adSopenharmony_ci    CP_CheckBytesOutOfBuffers,          /**< All read/write buffers are currently in use. */
115b3a6c5adSopenharmony_ci    CP_CheckBytesKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
116b3a6c5adSopenharmony_ci    CP_CheckBytesVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
117b3a6c5adSopenharmony_ci    CP_CheckBytesMax = 0X7FFFFFFF
118b3a6c5adSopenharmony_ci} CP_CHECKBYTESRESULTTYPE;
119b3a6c5adSopenharmony_ci
120b3a6c5adSopenharmony_ci/** enumeration of content pipe events sent to the client callback.
121b3a6c5adSopenharmony_ci * @ingroup cp
122b3a6c5adSopenharmony_ci */
123b3a6c5adSopenharmony_citypedef enum CP_EVENTTYPE{
124b3a6c5adSopenharmony_ci    CP_BytesAvailable,      	    /** bytes requested in a CheckAvailableBytes call are now available*/
125b3a6c5adSopenharmony_ci    CP_Overflow,  		           /** enumeration of content pipe events sent to the client callback*/
126b3a6c5adSopenharmony_ci    CP_PipeDisconnected  ,  		    /** enumeration of content pipe events sent to the client callback*/
127b3a6c5adSopenharmony_ci    CP_EventKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
128b3a6c5adSopenharmony_ci    CP_EventVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
129b3a6c5adSopenharmony_ci    CP_EventMax = 0X7FFFFFFF
130b3a6c5adSopenharmony_ci} CP_EVENTTYPE;
131b3a6c5adSopenharmony_ci
132b3a6c5adSopenharmony_ci/** content pipe definition
133b3a6c5adSopenharmony_ci * @ingroup cp
134b3a6c5adSopenharmony_ci */
135b3a6c5adSopenharmony_citypedef struct CP_PIPETYPE
136b3a6c5adSopenharmony_ci{
137b3a6c5adSopenharmony_ci    /** Open a content stream for reading or writing. */
138b3a6c5adSopenharmony_ci    CPresult (*Open)( CPhandle* hContent, CPstring szURI, CP_ACCESSTYPE eAccess );
139b3a6c5adSopenharmony_ci
140b3a6c5adSopenharmony_ci    /** Close a content stream. */
141b3a6c5adSopenharmony_ci    CPresult (*Close)( CPhandle hContent );
142b3a6c5adSopenharmony_ci
143b3a6c5adSopenharmony_ci    /** Create a content source and open it for writing. */
144b3a6c5adSopenharmony_ci    CPresult (*Create)( CPhandle *hContent, CPstring szURI );
145b3a6c5adSopenharmony_ci
146b3a6c5adSopenharmony_ci    /** Check the that specified number of bytes are available for reading or writing (depending on access type).*/
147b3a6c5adSopenharmony_ci    CPresult (*CheckAvailableBytes)( CPhandle hContent, CPuint nBytesRequested, CP_CHECKBYTESRESULTTYPE *eResult );
148b3a6c5adSopenharmony_ci
149b3a6c5adSopenharmony_ci    /** Seek to certain position in the content relative to the specified origin. */
150b3a6c5adSopenharmony_ci    CPresult (*SetPosition)( CPhandle  hContent, CPint nOffset, CP_ORIGINTYPE eOrigin);
151b3a6c5adSopenharmony_ci
152b3a6c5adSopenharmony_ci    /** Retrieve the current position relative to the start of the content. */
153b3a6c5adSopenharmony_ci    CPresult (*GetPosition)( CPhandle hContent, CPuint *pPosition);
154b3a6c5adSopenharmony_ci
155b3a6c5adSopenharmony_ci    /** Retrieve data of the specified size from the content stream (advance content pointer by size of data).
156b3a6c5adSopenharmony_ci       Note: pipe client provides pointer. This function is appropriate for small high frequency reads. */
157b3a6c5adSopenharmony_ci    CPresult (*Read)( CPhandle hContent, CPbyte *pData, CPuint nSize);
158b3a6c5adSopenharmony_ci
159b3a6c5adSopenharmony_ci    /** Retrieve a buffer allocated by the pipe that contains the requested number of bytes.
160b3a6c5adSopenharmony_ci       Buffer contains the next block of bytes, as specified by nSize, of the content. nSize also
161b3a6c5adSopenharmony_ci       returns the size of the block actually read. Content pointer advances the by the returned size.
162b3a6c5adSopenharmony_ci       Note: pipe provides pointer. This function is appropriate for large reads. The client must call
163b3a6c5adSopenharmony_ci       ReleaseReadBuffer when done with buffer.
164b3a6c5adSopenharmony_ci
165b3a6c5adSopenharmony_ci       In some cases the requested block may not reside in contiguous memory within the
166b3a6c5adSopenharmony_ci       pipe implementation. For instance if the pipe leverages a circular buffer then the requested
167b3a6c5adSopenharmony_ci       block may straddle the boundary of the circular buffer. By default a pipe implementation
168b3a6c5adSopenharmony_ci       performs a copy in this case to provide the block to the pipe client in one contiguous buffer.
169b3a6c5adSopenharmony_ci       If, however, the client sets bForbidCopy, then the pipe returns only those bytes preceding the memory
170b3a6c5adSopenharmony_ci       boundary. Here the client may retrieve the data in segments over successive calls. */
171b3a6c5adSopenharmony_ci    CPresult (*ReadBuffer)( CPhandle hContent, CPbyte **ppBuffer, CPuint *nSize, CPbool bForbidCopy);
172b3a6c5adSopenharmony_ci
173b3a6c5adSopenharmony_ci    /** Release a buffer obtained by ReadBuffer back to the pipe. */
174b3a6c5adSopenharmony_ci    CPresult (*ReleaseReadBuffer)(CPhandle hContent, CPbyte *pBuffer);
175b3a6c5adSopenharmony_ci
176b3a6c5adSopenharmony_ci    /** Write data of the specified size to the content (advance content pointer by size of data).
177b3a6c5adSopenharmony_ci       Note: pipe client provides pointer. This function is appropriate for small high frequency writes. */
178b3a6c5adSopenharmony_ci    CPresult (*Write)( CPhandle hContent, CPbyte *data, CPuint nSize);
179b3a6c5adSopenharmony_ci
180b3a6c5adSopenharmony_ci    /** Retrieve a buffer allocated by the pipe used to write data to the content.
181b3a6c5adSopenharmony_ci       Client will fill buffer with output data. Note: pipe provides pointer. This function is appropriate
182b3a6c5adSopenharmony_ci       for large writes. The client must call WriteBuffer when done it has filled the buffer with data.*/
183b3a6c5adSopenharmony_ci    CPresult (*GetWriteBuffer)( CPhandle hContent, CPbyte **ppBuffer, CPuint nSize);
184b3a6c5adSopenharmony_ci
185b3a6c5adSopenharmony_ci    /** Deliver a buffer obtained via GetWriteBuffer to the pipe. Pipe will write the
186b3a6c5adSopenharmony_ci       the contents of the buffer to content and advance content pointer by the size of the buffer */
187b3a6c5adSopenharmony_ci    CPresult (*WriteBuffer)( CPhandle hContent, CPbyte *pBuffer, CPuint nFilledSize);
188b3a6c5adSopenharmony_ci
189b3a6c5adSopenharmony_ci    /** Register a per-handle client callback with the content pipe. */
190b3a6c5adSopenharmony_ci    CPresult (*RegisterCallback)( CPhandle hContent, CPresult (*ClientCallback)(CP_EVENTTYPE eEvent, CPuint iParam));
191b3a6c5adSopenharmony_ci
192b3a6c5adSopenharmony_ci} CP_PIPETYPE;
193b3a6c5adSopenharmony_ci
194b3a6c5adSopenharmony_ci#endif
195b3a6c5adSopenharmony_ci
196