1 | //transcode.h: |
---|
2 | |
---|
3 | /* |
---|
4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2012 |
---|
5 | * |
---|
6 | * This file is part of libroar a part of RoarAudio, |
---|
7 | * a cross-platform sound system for both, home and professional use. |
---|
8 | * See README for details. |
---|
9 | * |
---|
10 | * This file is free software; you can redistribute it and/or modify |
---|
11 | * it under the terms of the GNU General Public License version 3 |
---|
12 | * as published by the Free Software Foundation. |
---|
13 | * |
---|
14 | * libroar is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this software; see the file COPYING. If not, write to |
---|
21 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
---|
22 | * Boston, MA 02110-1301, USA. |
---|
23 | * |
---|
24 | * NOTE for everyone want's to change something and send patches: |
---|
25 | * read README and HACKING! There a addition information on |
---|
26 | * the license of this document you need to read before you send |
---|
27 | * any patches. |
---|
28 | * |
---|
29 | * NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc |
---|
30 | * or libpulse*: |
---|
31 | * The libs libroaresd, libroararts and libroarpulse link this lib |
---|
32 | * and are therefore GPL. Because of this it may be illigal to use |
---|
33 | * them with any software that uses libesd, libartsc or libpulse*. |
---|
34 | */ |
---|
35 | |
---|
36 | #ifndef _LIBROARDSP_TRANSCODE_H_ |
---|
37 | #define _LIBROARDSP_TRANSCODE_H_ |
---|
38 | |
---|
39 | #include "libroardsp.h" |
---|
40 | |
---|
41 | #define ROAR_XCODER_STAGE_NONE 0 |
---|
42 | #define ROAR_XCODER_STAGE_INITED 0 |
---|
43 | #define ROAR_XCODER_STAGE_WAIT 1 |
---|
44 | #define ROAR_XCODER_STAGE_MAGIC 2 |
---|
45 | #define ROAR_XCODER_STAGE_OPENING 3 |
---|
46 | #define ROAR_XCODER_STAGE_OPENED 4 |
---|
47 | #define ROAR_XCODER_STAGE_CLOSING 5 |
---|
48 | #define ROAR_XCODER_STAGE_CLOSED 6 |
---|
49 | |
---|
50 | #define ROAR_BIXCODER_FLAGS_NONE 0x0000 |
---|
51 | #define ROAR_BIXCODER_FLAGS_ENCODE 0x0001 |
---|
52 | #define ROAR_BIXCODER_FLAGS_DECODE 0x0002 |
---|
53 | |
---|
54 | struct roar_xcoder; |
---|
55 | |
---|
56 | struct roar_xcoder_entry { |
---|
57 | int codec; |
---|
58 | int (*init)(struct roar_xcoder * state); |
---|
59 | int (*uninit)(struct roar_xcoder * state); |
---|
60 | int (*packet_size)(struct roar_xcoder * state, int samples); |
---|
61 | int (*encode)(struct roar_xcoder * state, void * buf, size_t len); |
---|
62 | int (*decode)(struct roar_xcoder * state, void * buf, size_t len); |
---|
63 | int (*proc_header)(struct roar_xcoder * state); |
---|
64 | }; |
---|
65 | |
---|
66 | struct roar_xcoder { |
---|
67 | void * inst; |
---|
68 | struct roar_xcoder_entry * entry; |
---|
69 | struct roar_vio_calls * backend; |
---|
70 | int encode; |
---|
71 | int flags; |
---|
72 | int stage; |
---|
73 | ssize_t packet_len; |
---|
74 | struct roar_buffer * iobuffer; |
---|
75 | struct { |
---|
76 | struct roar_audio_info coded; |
---|
77 | struct roar_audio_info pcm; |
---|
78 | } info; |
---|
79 | }; |
---|
80 | |
---|
81 | struct roar_bixcoder { |
---|
82 | struct roar_xcoder encoder, decoder; |
---|
83 | int flags; |
---|
84 | }; |
---|
85 | |
---|
86 | struct roar_transcoder { |
---|
87 | struct roar_xcoder encoder, decoder; |
---|
88 | }; |
---|
89 | |
---|
90 | int roar_xcoder_init(struct roar_xcoder * state, int encoder, struct roar_audio_info * info, struct roar_vio_calls * vio); |
---|
91 | int roar_xcoder_set_backend(struct roar_xcoder * state, struct roar_vio_calls * vio); |
---|
92 | int roar_xcoder_packet_size(struct roar_xcoder * state, int samples); |
---|
93 | int roar_xcoder_close (struct roar_xcoder * state); |
---|
94 | int roar_xcoder_proc_header(struct roar_xcoder * state); |
---|
95 | int roar_xcoder_proc_packet(struct roar_xcoder * state, void * buf, size_t len); |
---|
96 | int roar_xcoder_proc (struct roar_xcoder * state, void * buf, size_t len); |
---|
97 | |
---|
98 | int roar_bixcoder_init(struct roar_bixcoder * state, struct roar_audio_info * info, struct roar_vio_calls * vio); |
---|
99 | int roar_bixcoder_packet_size (struct roar_bixcoder * state, int samples); |
---|
100 | int roar_bixcoder_close (struct roar_bixcoder * state); |
---|
101 | int roar_bixcoder_read_header (struct roar_bixcoder * state); |
---|
102 | int roar_bixcoder_read_packet (struct roar_bixcoder * state, void * buf, size_t len); |
---|
103 | int roar_bixcoder_read (struct roar_bixcoder * state, void * buf, size_t len); |
---|
104 | int roar_bixcoder_write_header(struct roar_bixcoder * state); |
---|
105 | int roar_bixcoder_write_packet(struct roar_bixcoder * state, void * buf, size_t len); |
---|
106 | int roar_bixcoder_write (struct roar_bixcoder * state, void * buf, size_t len); |
---|
107 | |
---|
108 | // dummy functions used by some de/encoders: |
---|
109 | int roar_xcoder_dummy_inituninit(struct roar_xcoder * state); |
---|
110 | int roar_xcoder_dummy_packet_size_any(struct roar_xcoder * state, int samples); |
---|
111 | int roar_xcoder_dummy_proc_header(struct roar_xcoder * state); |
---|
112 | |
---|
113 | // prototypes for some simple xcoders: |
---|
114 | int roar_xcoder_alaw_encode(struct roar_xcoder * state, void * buf, size_t len); |
---|
115 | int roar_xcoder_alaw_decode(struct roar_xcoder * state, void * buf, size_t len); |
---|
116 | |
---|
117 | int roar_xcoder_mulaw_encode(struct roar_xcoder * state, void * buf, size_t len); |
---|
118 | int roar_xcoder_mulaw_decode(struct roar_xcoder * state, void * buf, size_t len); |
---|
119 | |
---|
120 | #endif |
---|
121 | |
---|
122 | //ll |
---|