1 /* Copyright (C) 2010-2020 The RetroArch team
3 * ---------------------------------------------------------------------------------------
4 * The following license statement only applies to this file (trans_stream.h).
5 * ---------------------------------------------------------------------------------------
7 * Permission is hereby granted, free of charge,
8 * to any person obtaining a copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 #ifndef LIBRETRO_SDK_TRANS_STREAM_H__
24 #define LIBRETRO_SDK_TRANS_STREAM_H__
36 #include <retro_miscellaneous.h>
38 #include <retro_common_api.h>
42 enum trans_stream_error
44 TRANS_STREAM_ERROR_NONE = 0,
45 TRANS_STREAM_ERROR_AGAIN, /* more work to do */
46 TRANS_STREAM_ERROR_ALLOCATION_FAILURE, /* malloc failure */
47 TRANS_STREAM_ERROR_INVALID, /* invalid state */
48 TRANS_STREAM_ERROR_BUFFER_FULL, /* output buffer full */
49 TRANS_STREAM_ERROR_OTHER
52 struct trans_stream_backend
55 const struct trans_stream_backend *reverse;
57 /* Create a stream data structure */
58 void *(*stream_new)(void);
61 void (*stream_free)(void *);
63 /* (Optional) Set extra properties, defined per transcoder */
64 bool (*define)(void *, const char *, uint32_t);
66 /* Set our input source */
67 void (*set_in)(void *, const uint8_t *, uint32_t);
69 /* Set our output target */
70 void (*set_out)(void *, uint8_t *, uint32_t);
72 /* Perform a transcoding, flushing/finalizing if asked to. Writes out how
73 * many bytes were read and written. Error target optional. */
74 bool (*trans)(void *, bool, uint32_t *, uint32_t *, enum trans_stream_error *);
78 * trans_stream_trans_full:
79 * @backend : transcoding backend
80 * @data : (optional) existing stream data, or a target
81 * for the new stream data to be saved
83 * @in_size : input size
85 * @out_size : output size
86 * @error : (optional) output for error code
88 * Perform a full transcoding from a source to a destination.
90 bool trans_stream_trans_full(
91 struct trans_stream_backend *backend, void **data,
92 const uint8_t *in, uint32_t in_size,
93 uint8_t *out, uint32_t out_size,
94 enum trans_stream_error *error);
96 const struct trans_stream_backend* trans_stream_get_zlib_deflate_backend(void);
97 const struct trans_stream_backend* trans_stream_get_zlib_inflate_backend(void);
98 const struct trans_stream_backend* trans_stream_get_pipe_backend(void);
100 extern const struct trans_stream_backend zlib_deflate_backend;
101 extern const struct trans_stream_backend zlib_inflate_backend;
102 extern const struct trans_stream_backend pipe_backend;