blob: b51ec0c6e68bdd75f2604504fa0c6dcc13cebee2
1 | /* ***** BEGIN LICENSE BLOCK ***** |
2 | * Source last modified: $Id: ra_decode.h,v 1.2.2.1 2005/05/04 18:20:57 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 | #ifndef RA_DECODE_H |
39 | #define RA_DECODE_H |
40 | |
41 | /* Simple unified decoder frontend for RealAudio */ |
42 | |
43 | #include "helix_types.h" |
44 | #include "helix_result.h" |
45 | #include "rm_memory.h" |
46 | #include "rm_error.h" |
47 | #include "ra_format_info.h" |
48 | #include "ra_backend.h" |
49 | |
50 | #ifdef __cplusplus |
51 | extern "C" { |
52 | #endif /* #ifdef __cplusplus */ |
53 | |
54 | /* The ra_decode struct contains the RealAudio decoder frontend |
55 | * function pointers and pointers to the backend. */ |
56 | |
57 | typedef struct ra_decode_struct { |
58 | void* pUserError; |
59 | rm_error_func_ptr fpError; |
60 | void* pUserMem; |
61 | rm_malloc_func_ptr fpMalloc; |
62 | rm_free_func_ptr fpFree; |
63 | |
64 | ra_decode_init_func_ptr fpInit; |
65 | ra_decode_reset_func_ptr fpReset; |
66 | ra_decode_conceal_func_ptr fpConceal; |
67 | ra_decode_decode_func_ptr fpDecode; |
68 | ra_decode_getmaxsize_func_ptr fpGetMaxSize; |
69 | ra_decode_getchannels_func_ptr fpGetChannels; |
70 | ra_decode_getchannelmask_func_ptr fpGetChannelMask; |
71 | ra_decode_getrate_func_ptr fpGetSampleRate; |
72 | ra_decode_getdelay_func_ptr fpMaxSamp; |
73 | ra_decode_close_func_ptr fpClose; |
74 | |
75 | void* pDecode; |
76 | } ra_decode; |
77 | |
78 | /* ra_decode_create() |
79 | * Creates RA decoder frontend struct, copies memory utilities. |
80 | * Returns struct pointer on success, NULL on failure. */ |
81 | ra_decode* ra_decode_create(void* pUserError, |
82 | rm_error_func_ptr fpError); |
83 | |
84 | ra_decode* ra_decode_create2(void* pUserError, |
85 | rm_error_func_ptr fpError, |
86 | void* pUserMem, |
87 | rm_malloc_func_ptr fpMalloc, |
88 | rm_free_func_ptr fpFree); |
89 | |
90 | /* ra_decode_destroy() |
91 | * Deletes the decoder backend and frontend instances. */ |
92 | void ra_decode_destroy(ra_decode* pFrontEnd); |
93 | |
94 | /* ra_decode_init() |
95 | * Selects decoder backend with fourCC code. |
96 | * Calls decoder backend init function with init params. |
97 | * Returns zero on success, negative result indicates failure. */ |
98 | HX_RESULT ra_decode_init(ra_decode* pFrontEnd, |
99 | UINT32 ulFourCC, |
100 | void* pInitParams, |
101 | UINT32 ulInitParamsSize, |
102 | ra_format_info* pStreamInfo); |
103 | |
104 | /* ra_decode_reset() |
105 | * Calls decoder backend reset function. |
106 | * Depending on which codec is in use, *pNumSamplesOut samples may |
107 | * be flushed. After reset, the decoder returns to its initial state. |
108 | * Returns zero on success, negative result indicates failure. */ |
109 | HX_RESULT ra_decode_reset(ra_decode* pFrontEnd, |
110 | UINT16* pSamplesOut, |
111 | UINT32 ulNumSamplesAvail, |
112 | UINT32* pNumSamplesOut); |
113 | |
114 | /* ra_decode_conceal() |
115 | * Calls decoder backend conceal function. |
116 | * On successive calls to ra_decode_decode(), the decoder will attempt |
117 | * to conceal ulNumSamples. No input data should be sent while concealed |
118 | * frames are being produced. Once the decoder has exhausted the concealed |
119 | * samples, it can proceed normally with decoding valid input data. |
120 | * Returns zero on success, negative result indicates failure. */ |
121 | HX_RESULT ra_decode_conceal(ra_decode* pFrontEnd, |
122 | UINT32 ulNumSamples); |
123 | |
124 | /* ra_decode_decode() |
125 | * Calls decoder backend decode function. |
126 | * pData : input data (compressed frame). |
127 | * ulNumBytes : input data size in bytes. |
128 | * pNumBytesConsumed : amount of input data consumed by decoder. |
129 | * pSamplesOut : output data (uncompressed frame). |
130 | * ulNumSamplesAvail : size of output buffer. |
131 | * pNumSamplesOut : amount of ouput data produced by decoder. |
132 | * ulFlags : control flags for decoder. |
133 | * Returns zero on success, negative result indicates failure. */ |
134 | HX_RESULT ra_decode_decode(ra_decode* pFrontEnd, |
135 | UINT8* pData, |
136 | UINT32 ulNumBytes, |
137 | UINT32* pNumBytesConsumed, |
138 | UINT16* pSamplesOut, |
139 | UINT32 ulNumSamplesAvail, |
140 | UINT32* pNumSamplesOut, |
141 | UINT32 ulFlags, |
142 | UINT32 ulTimeStamp); |
143 | |
144 | |
145 | /**************** Accessor Functions *******************/ |
146 | /* ra_decode_getmaxsize() |
147 | * pNumSamples receives the maximum number of samples produced |
148 | * by the decoder in response to a call to ra_decode_decode(). |
149 | * Returns zero on success, negative result indicates failure. */ |
150 | HX_RESULT ra_decode_getmaxsize(ra_decode* pFrontEnd, |
151 | UINT32* pNumSamples); |
152 | |
153 | /* ra_decode_getchannels() |
154 | * pNumChannels receives the number of audio channels in the bitstream. |
155 | * Returns zero on success, negative result indicates failure. */ |
156 | HX_RESULT ra_decode_getchannels(ra_decode* pFrontEnd, |
157 | UINT32* pNumChannels); |
158 | |
159 | /* ra_decode_getchannelmask() |
160 | * pChannelMask receives the 32-bit mapping of the audio output channels. |
161 | * Returns zero on success, negative result indicates failure. */ |
162 | HX_RESULT ra_decode_getchannelmask(ra_decode* pFrontEnd, |
163 | UINT32* pChannelMask); |
164 | |
165 | /* ra_decode_getrate() |
166 | * pSampleRate receives the sampling rate of the output samples. |
167 | * Returns zero on success, negative result indicates failure. */ |
168 | HX_RESULT ra_decode_getrate(ra_decode* pFrontEnd, |
169 | UINT32* pSampleRate); |
170 | |
171 | /* ra_decode_getdelay() |
172 | * pNumSamples receives the number of invalid output samples |
173 | * produced by the decoder at startup. |
174 | * If non-zero, it is up to the user to discard these samples. |
175 | * Returns zero on success, negative result indicates failure. */ |
176 | HX_RESULT ra_decode_getdelay(ra_decode* pFrontEnd, |
177 | UINT32* pNumSamples); |
178 | |
179 | #ifdef __cplusplus |
180 | } |
181 | #endif /* #ifdef __cplusplus */ |
182 | |
183 | #endif /* #ifndef RA_DECODE_H */ |
184 |