1 | /* |
2 | Copyright (c) 2012, Broadcom Europe Ltd |
3 | All rights reserved. |
4 | |
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the following conditions are met: |
7 | * Redistributions of source code must retain the above copyright |
8 | notice, this list of conditions and the following disclaimer. |
9 | * Redistributions in binary form must reproduce the above copyright |
10 | notice, this list of conditions and the following disclaimer in the |
11 | documentation and/or other materials provided with the distribution. |
12 | * Neither the name of the copyright holder nor the |
13 | names of its contributors may be used to endorse or promote products |
14 | derived from this software without specific prior written permission. |
15 | |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY |
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ |
27 | #ifndef VC_CONTAINERS_PRIVATE_H |
28 | #define VC_CONTAINERS_PRIVATE_H |
29 | |
30 | /** \file containers_private.h |
31 | * Private interface for container readers and writers |
32 | */ |
33 | |
34 | #include <stdarg.h> |
35 | #include "containers/containers.h" |
36 | #include "containers/core/containers_common.h" |
37 | #include "containers/core/containers_io.h" |
38 | #include "containers/core/containers_filters.h" |
39 | #include "containers/packetizers.h" |
40 | #include "containers/core/containers_uri.h" |
41 | |
42 | #define URI_MAX_LEN 256 |
43 | |
44 | /** \defgroup VcContainerModuleApi Container Module API |
45 | * Private interface for modules implementing container readers and writers */ |
46 | /* @{ */ |
47 | |
48 | /** Track context private to the container reader / writer instance. This private context is used to |
49 | * store data which shouldn't be exported by the public API. */ |
50 | typedef struct VC_CONTAINER_TRACK_PRIVATE_T |
51 | { |
52 | /** Pointer to the private data of the container module in use */ |
53 | struct VC_CONTAINER_TRACK_MODULE_T *module; |
54 | |
55 | /** Pointer to the allocated buffer for the track extradata */ |
56 | uint8_t *; |
57 | /** Size of the allocated buffer for the track extradata */ |
58 | uint32_t ; |
59 | |
60 | /** Pointer to the allocated buffer for the track DRM data*/ |
61 | uint8_t *drmdata; |
62 | /** Size of the allocated buffer for the track DRM data */ |
63 | uint32_t drmdata_size; |
64 | |
65 | /** Packetizer used by this track */ |
66 | VC_PACKETIZER_T *packetizer; |
67 | |
68 | } VC_CONTAINER_TRACK_PRIVATE_T; |
69 | |
70 | /** Context private to the container reader / writer instance. This private context is used to |
71 | * store data which shouldn't be exported by the public API. */ |
72 | typedef struct VC_CONTAINER_PRIVATE_T |
73 | { |
74 | /** Pointer to the container i/o instance used to read / write to the container */ |
75 | struct VC_CONTAINER_IO_T *io; |
76 | /** Pointer to the private data of the container module in use */ |
77 | struct VC_CONTAINER_MODULE_T *module; |
78 | |
79 | /** Reads a data packet from a container reader. |
80 | * By default, the reader will read whatever packet comes next in the container and update the |
81 | * given \ref VC_CONTAINER_PACKET_T structure with this packet's information. |
82 | * This behaviour can be changed using the \ref VC_CONTAINER_READ_FLAGS_T.\n |
83 | * \ref VC_CONTAINER_READ_FLAG_INFO will instruct the reader to only return information on the |
84 | * following packet but not its actual data. The data can be retreived later by issuing another |
85 | * read request. |
86 | * \ref VC_CONTAINER_READ_FLAG_FORCE_TRACK will force the reader to read the next packet for the |
87 | * selected track (as present in the \ref VC_CONTAINER_PACKET_T structure) instead of defaulting |
88 | * to reading the packet which comes next in the container. |
89 | * \ref VC_CONTAINER_READ_FLAG_SKIP will instruct the reader to skip the next packet. In this case |
90 | * it isn't necessary for the caller to pass a pointer to a \ref VC_CONTAINER_PACKET_T structure |
91 | * unless the \ref VC_CONTAINER_READ_FLAG_INFO is also given. |
92 | * A combination of all these flags can be used. |
93 | * |
94 | * \param context Pointer to the context of the reader to use |
95 | * \param packet Pointer to the VC_CONTAINER_PACKET_T structure describing the data packet |
96 | * This needs to be partially filled before the call (buffer, buffer_size) |
97 | * \param flags Flags controlling the read operation |
98 | * \return the status of the operation |
99 | */ |
100 | VC_CONTAINER_STATUS_T (*pf_read)( VC_CONTAINER_T *context, |
101 | VC_CONTAINER_PACKET_T *packet, VC_CONTAINER_READ_FLAGS_T flags ); |
102 | |
103 | /** Writes a data packet to a container writer. |
104 | * |
105 | * \param context Pointer to the context of the writer to use |
106 | * \param packet Pointer to the VC_CONTAINER_PACKET_T structure describing the data packet |
107 | * \return the status of the operation |
108 | */ |
109 | VC_CONTAINER_STATUS_T (*pf_write)( struct VC_CONTAINER_T *context, |
110 | VC_CONTAINER_PACKET_T *packet ); |
111 | |
112 | /** Seek into a container reader. |
113 | * |
114 | * \param context Pointer to the context of the reader to use |
115 | * \param offset Offset to seek to. Used as an input as well as output value. |
116 | * \param mode Seeking mode requested. |
117 | * \param flags Flags affecting the seeking operation. |
118 | * \return the status of the operation |
119 | */ |
120 | VC_CONTAINER_STATUS_T (*pf_seek)( VC_CONTAINER_T *context, int64_t *offset, |
121 | VC_CONTAINER_SEEK_MODE_T mode, VC_CONTAINER_SEEK_FLAGS_T flags); |
122 | |
123 | /** Extensible control function for container readers and writers. |
124 | * This function takes a variable number of arguments which will depend on the specific operation. |
125 | * |
126 | * \param context Pointer to the VC_CONTAINER_T context to use |
127 | * \param operation The requested operation |
128 | * \return the status of the operation |
129 | */ |
130 | VC_CONTAINER_STATUS_T (*pf_control)( VC_CONTAINER_T *context, VC_CONTAINER_CONTROL_T operation, va_list args ); |
131 | |
132 | /** Closes a container reader / writer module. |
133 | * |
134 | * \param context Pointer to the context of the instance to close |
135 | * \return the status of the operation |
136 | */ |
137 | VC_CONTAINER_STATUS_T (*pf_close)( struct VC_CONTAINER_T *context ); |
138 | |
139 | /** Pointer to container filter instance used for DRM */ |
140 | struct VC_CONTAINER_FILTER_T *drm_filter; |
141 | |
142 | /** Pointer to the container module code and symbols*/ |
143 | void *module_handle; |
144 | |
145 | /** Maximum size of a stream that is being written. |
146 | * This is set by the client using the control mechanism */ |
147 | int64_t max_size; |
148 | |
149 | /** Pointer to the temp i/o instance used to write temporary data */ |
150 | struct VC_CONTAINER_IO_T *tmp_io; |
151 | |
152 | /** Current status of the container (only used for writers to prevent trying to write |
153 | * more data if one of the writes failed) */ |
154 | VC_CONTAINER_STATUS_T status; |
155 | |
156 | /** Logging verbosity */ |
157 | uint32_t verbosity; |
158 | |
159 | /** Uniform Resource Identifier */ |
160 | struct VC_URI_PARTS_T *uri; |
161 | |
162 | /** Flag specifying whether one of the tracks is being packetized */ |
163 | bool packetizing; |
164 | |
165 | /** Temporary packet structure used to feed data to the packetizer */ |
166 | VC_CONTAINER_PACKET_T packetizer_packet; |
167 | |
168 | /** Temporary buffer used by the packetizer */ |
169 | uint8_t *packetizer_buffer; |
170 | |
171 | } VC_CONTAINER_PRIVATE_T; |
172 | |
173 | /* Internal functions */ |
174 | VC_CONTAINER_TRACK_T *vc_container_allocate_track( VC_CONTAINER_T *context, unsigned int ); |
175 | void vc_container_free_track( VC_CONTAINER_T *context, VC_CONTAINER_TRACK_T *track ); |
176 | VC_CONTAINER_STATUS_T ( VC_CONTAINER_T *context, |
177 | VC_CONTAINER_TRACK_T *p_track, unsigned int ); |
178 | VC_CONTAINER_STATUS_T vc_container_track_allocate_drmdata( VC_CONTAINER_T *context, |
179 | VC_CONTAINER_TRACK_T *p_track, unsigned int size ); |
180 | |
181 | /* @} */ |
182 | |
183 | #endif /* VC_CONTAINERS_PRIVATE_H */ |
184 | |