blob: 47c1ff0bba3e30dcba33b6f5b8e3acb8bfc1265f
1 | /* ***** BEGIN LICENSE BLOCK ***** |
2 | * Source last modified: $Id: rm_stream.c,v 1.1.1.1.2.1 2005/05/04 18:21:24 hubbe Exp $ |
3 | * |
4 | * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM |
5 | * Portions Copyright (c) 1995-2005 RealNetworks, Inc. |
6 | * All Rights Reserved. |
7 | * |
8 | * The contents of this file, and the files included with this file, |
9 | * are subject to the current version of the Real Format Source Code |
10 | * Porting and Optimization License, available at |
11 | * https://helixcommunity.org/2005/license/realformatsource (unless |
12 | * RealNetworks otherwise expressly agrees in writing that you are |
13 | * subject to a different license). You may also obtain the license |
14 | * terms directly from RealNetworks. You may not use this file except |
15 | * in compliance with the Real Format Source Code Porting and |
16 | * Optimization License. There are no redistribution rights for the |
17 | * source code of this file. Please see the Real Format Source Code |
18 | * Porting and Optimization License for the rights, obligations and |
19 | * limitations governing use of the contents of the file. |
20 | * |
21 | * RealNetworks is the developer of the Original Code and owns the |
22 | * copyrights in the portions it created. |
23 | * |
24 | * This file, and the files included with this file, is distributed and |
25 | * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, |
26 | * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL |
27 | * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF |
28 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT |
29 | * OR NON-INFRINGEMENT. |
30 | * |
31 | * Technology Compatibility Kit Test Suite(s) Location: |
32 | * https://rarvcode-tck.helixcommunity.org |
33 | * |
34 | * Contributor(s): |
35 | * |
36 | * ***** END LICENSE BLOCK ***** */ |
37 | |
38 | #include <string.h> |
39 | #include "../include/helix_types.h" |
40 | #include "../include/helix_mime_types.h" |
41 | #include "../include/rm_property.h" |
42 | #include "../include/rm_stream.h" |
43 | |
44 | UINT32 rm_stream_get_number(rm_stream_header* hdr) |
45 | { |
46 | UINT32 ulRet = 0; |
47 | |
48 | if (hdr) { |
49 | ulRet = hdr->ulStreamNumber; |
50 | } |
51 | |
52 | return ulRet; |
53 | } |
54 | |
55 | UINT32 rm_stream_get_max_bit_rate(rm_stream_header* hdr) |
56 | { |
57 | UINT32 ulRet = 0; |
58 | |
59 | if (hdr) { |
60 | ulRet = hdr->ulMaxBitRate; |
61 | } |
62 | |
63 | return ulRet; |
64 | } |
65 | |
66 | UINT32 rm_stream_get_avg_bit_rate(rm_stream_header* hdr) |
67 | { |
68 | UINT32 ulRet = 0; |
69 | |
70 | if (hdr) { |
71 | ulRet = hdr->ulAvgBitRate; |
72 | } |
73 | |
74 | return ulRet; |
75 | } |
76 | |
77 | UINT32 rm_stream_get_max_packet_size(rm_stream_header* hdr) |
78 | { |
79 | UINT32 ulRet = 0; |
80 | |
81 | if (hdr) { |
82 | ulRet = hdr->ulMaxPacketSize; |
83 | } |
84 | |
85 | return ulRet; |
86 | } |
87 | |
88 | UINT32 rm_stream_get_avg_packet_size(rm_stream_header* hdr) |
89 | { |
90 | UINT32 ulRet = 0; |
91 | |
92 | if (hdr) { |
93 | ulRet = hdr->ulAvgPacketSize; |
94 | } |
95 | |
96 | return ulRet; |
97 | } |
98 | |
99 | UINT32 rm_stream_get_start_time(rm_stream_header* hdr) |
100 | { |
101 | UINT32 ulRet = 0; |
102 | |
103 | if (hdr) { |
104 | ulRet = hdr->ulStartTime; |
105 | } |
106 | |
107 | return ulRet; |
108 | } |
109 | |
110 | UINT32 rm_stream_get_preroll(rm_stream_header* hdr) |
111 | { |
112 | UINT32 ulRet = 0; |
113 | |
114 | if (hdr) { |
115 | ulRet = hdr->ulPreroll; |
116 | } |
117 | |
118 | return ulRet; |
119 | } |
120 | |
121 | UINT32 rm_stream_get_duration(rm_stream_header* hdr) |
122 | { |
123 | UINT32 ulRet = 0; |
124 | |
125 | if (hdr) { |
126 | ulRet = hdr->ulDuration; |
127 | } |
128 | |
129 | return ulRet; |
130 | } |
131 | |
132 | UINT32 rm_stream_get_data_offset(rm_stream_header* hdr) |
133 | { |
134 | UINT32 ulRet = 0; |
135 | |
136 | if (hdr) { |
137 | ulRet = hdr->ulStartOffset; |
138 | } |
139 | |
140 | return ulRet; |
141 | } |
142 | |
143 | UINT32 rm_stream_get_data_size(rm_stream_header* hdr) |
144 | { |
145 | UINT32 ulRet = 0; |
146 | |
147 | if (hdr) { |
148 | ulRet = hdr->ulStreamSize; |
149 | } |
150 | |
151 | return ulRet; |
152 | } |
153 | |
154 | const char* rm_stream_get_name(rm_stream_header* hdr) |
155 | { |
156 | const char* pRet = HXNULL; |
157 | |
158 | if (hdr) { |
159 | pRet = (const char*) hdr->pStreamName; |
160 | } |
161 | |
162 | return pRet; |
163 | } |
164 | |
165 | const char* rm_stream_get_mime_type(rm_stream_header* hdr) |
166 | { |
167 | const char* pRet = HXNULL; |
168 | |
169 | if (hdr) { |
170 | pRet = (const char*) hdr->pMimeType; |
171 | } |
172 | |
173 | return pRet; |
174 | } |
175 | |
176 | UINT32 rm_stream_get_properties(rm_stream_header* hdr, rm_property** ppProp) |
177 | { |
178 | UINT32 ulRet = 0; |
179 | |
180 | if (hdr && ppProp) { |
181 | *ppProp = hdr->pProperty; |
182 | ulRet = hdr->ulNumProperties; |
183 | } |
184 | |
185 | return ulRet; |
186 | } |
187 | |
188 | HXBOOL rm_stream_is_realaudio(rm_stream_header* hdr) |
189 | { |
190 | HXBOOL bRet = FALSE; |
191 | |
192 | if (hdr) { |
193 | bRet = rm_stream_is_realaudio_mimetype((const char*) hdr->pMimeType); |
194 | } |
195 | |
196 | return bRet; |
197 | } |
198 | |
199 | HXBOOL rm_stream_is_realvideo(rm_stream_header* hdr) |
200 | { |
201 | HXBOOL bRet = FALSE; |
202 | |
203 | if (hdr) { |
204 | bRet = rm_stream_is_realvideo_mimetype((const char*) hdr->pMimeType); |
205 | } |
206 | |
207 | return bRet; |
208 | } |
209 | |
210 | HXBOOL rm_stream_is_realevent(rm_stream_header* hdr) |
211 | { |
212 | HXBOOL bRet = FALSE; |
213 | |
214 | if (hdr) { |
215 | bRet = rm_stream_is_realevent_mimetype((const char*) hdr->pMimeType); |
216 | } |
217 | |
218 | return bRet; |
219 | } |
220 | |
221 | HXBOOL rm_stream_is_realaudio_mimetype(const char* pszStr) |
222 | { |
223 | HXBOOL bRet = FALSE; |
224 | |
225 | if (pszStr) { |
226 | if (!strcmp(pszStr, REALAUDIO_MIME_TYPE) || |
227 | !strcmp(pszStr, REALAUDIO_MULTIRATE_MIME_TYPE) || |
228 | !strcmp(pszStr, REALAUDIO_ENCRYPTED_MIME_TYPE)) { |
229 | bRet = TRUE; |
230 | } |
231 | } |
232 | |
233 | return bRet; |
234 | } |
235 | |
236 | HXBOOL rm_stream_is_realvideo_mimetype(const char* pszStr) |
237 | { |
238 | HXBOOL bRet = FALSE; |
239 | |
240 | if (pszStr) { |
241 | if (!strcmp(pszStr, REALVIDEO_MIME_TYPE) || |
242 | !strcmp(pszStr, REALVIDEO_MULTIRATE_MIME_TYPE) || |
243 | !strcmp(pszStr, REALVIDEO_ENCRYPTED_MIME_TYPE)) { |
244 | bRet = TRUE; |
245 | } |
246 | } |
247 | |
248 | return bRet; |
249 | } |
250 | |
251 | HXBOOL rm_stream_is_realevent_mimetype(const char* pszStr) |
252 | { |
253 | HXBOOL bRet = FALSE; |
254 | |
255 | if (pszStr) { |
256 | if (!strcmp(pszStr, REALEVENT_MIME_TYPE) || |
257 | !strcmp(pszStr, REALEVENT_ENCRYPTED_MIME_TYPE) || |
258 | !strcmp(pszStr, REALIMAGEMAP_MIME_TYPE) || |
259 | !strcmp(pszStr, REALIMAGEMAP_ENCRYPTED_MIME_TYPE) || |
260 | !strcmp(pszStr, IMAGEMAP_MIME_TYPE) || |
261 | !strcmp(pszStr, IMAGEMAP_ENCRYPTED_MIME_TYPE) || |
262 | !strcmp(pszStr, SYNCMM_MIME_TYPE) || |
263 | !strcmp(pszStr, SYNCMM_ENCRYPTED_MIME_TYPE)) { |
264 | bRet = TRUE; |
265 | } |
266 | } |
267 | |
268 | return bRet; |
269 | } |
270 | |
271 | HXBOOL rm_stream_is_real_mimetype(const char* pszStr) |
272 | { |
273 | return rm_stream_is_realaudio_mimetype(pszStr) || |
274 | rm_stream_is_realvideo_mimetype(pszStr) || |
275 | rm_stream_is_realevent_mimetype(pszStr); |
276 | } |
277 | |
278 | HX_RESULT rm_stream_get_property_int(rm_stream_header* hdr, |
279 | const char* pszStr, |
280 | UINT32* pulVal) |
281 | { |
282 | HX_RESULT retVal = HXR_FAIL; |
283 | |
284 | if (hdr && pszStr && pulVal && |
285 | hdr->pProperty && hdr->ulNumProperties) { |
286 | UINT32 i = 0; |
287 | for (i = 0; i < hdr->ulNumProperties; i++) { |
288 | rm_property* pProp = &hdr->pProperty[i]; |
289 | if (pProp->ulType == RM_PROPERTY_TYPE_UINT32 && |
290 | pProp->pName && |
291 | !strcmp(pszStr, (const char*) pProp->pName)) { |
292 | /* Assign the out parameter */ |
293 | *pulVal = (UINT32) pProp->pValue; |
294 | /* Clear the return value */ |
295 | retVal = HXR_OK; |
296 | break; |
297 | } |
298 | } |
299 | } |
300 | |
301 | return retVal; |
302 | } |
303 | |
304 | HX_RESULT rm_stream_get_property_buf(rm_stream_header* hdr, |
305 | const char* pszStr, |
306 | BYTE** ppBuf, |
307 | UINT32* pulLen) |
308 | { |
309 | HX_RESULT retVal = HXR_FAIL; |
310 | |
311 | if (hdr && pszStr && ppBuf && pulLen && |
312 | hdr->pProperty && hdr->ulNumProperties) { |
313 | UINT32 i = 0; |
314 | for (i = 0; i < hdr->ulNumProperties; i++) { |
315 | rm_property* pProp = &hdr->pProperty[i]; |
316 | if (pProp->ulType == RM_PROPERTY_TYPE_BUFFER && |
317 | pProp->pName && |
318 | !strcmp(pszStr, (const char*) pProp->pName)) { |
319 | /* Assign the out parameters */ |
320 | *ppBuf = pProp->pValue; |
321 | *pulLen = pProp->ulValueLen; |
322 | /* Clear the return value */ |
323 | retVal = HXR_OK; |
324 | break; |
325 | } |
326 | } |
327 | } |
328 | |
329 | return retVal; |
330 | } |
331 | |
332 | HX_RESULT rm_stream_get_property_str(rm_stream_header* hdr, |
333 | const char* pszStr, |
334 | char** ppszStr) |
335 | { |
336 | HX_RESULT retVal = HXR_FAIL; |
337 | |
338 | if (hdr && pszStr && ppszStr && |
339 | hdr->pProperty && hdr->ulNumProperties) { |
340 | UINT32 i = 0; |
341 | for (i = 0; i < hdr->ulNumProperties; i++) { |
342 | rm_property* pProp = &hdr->pProperty[i]; |
343 | if (pProp->ulType == RM_PROPERTY_TYPE_CSTRING && |
344 | pProp->pName && |
345 | !strcmp(pszStr, (const char*) pProp->pName)) { |
346 | /* Assign the out parameter */ |
347 | *ppszStr = (char*) pProp->pValue; |
348 | /* Clear the return value */ |
349 | retVal = HXR_OK; |
350 | break; |
351 | } |
352 | } |
353 | } |
354 | |
355 | return retVal; |
356 | } |
357 |